summaryrefslogtreecommitdiff
path: root/core/fxge/fx_dib.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxge/fx_dib.h')
-rw-r--r--core/fxge/fx_dib.h314
1 files changed, 2 insertions, 312 deletions
diff --git a/core/fxge/fx_dib.h b/core/fxge/fx_dib.h
index 2208276fa7..85af766992 100644
--- a/core/fxge/fx_dib.h
+++ b/core/fxge/fx_dib.h
@@ -13,66 +13,14 @@
#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_basic.h"
#include "core/fxcrt/fx_coordinates.h"
+#include "core/fxge/dib/cfx_dibitmap.h"
+#include "core/fxge/dib/cfx_dibsource.h"
#include "third_party/base/stl_util.h"
-enum FXDIB_Format {
- FXDIB_Invalid = 0,
- FXDIB_1bppMask = 0x101,
- FXDIB_1bppRgb = 0x001,
- FXDIB_1bppCmyk = 0x401,
- FXDIB_8bppMask = 0x108,
- FXDIB_8bppRgb = 0x008,
- FXDIB_8bppRgba = 0x208,
- FXDIB_8bppCmyk = 0x408,
- FXDIB_8bppCmyka = 0x608,
- FXDIB_Rgb = 0x018,
- FXDIB_Rgba = 0x218,
- FXDIB_Rgb32 = 0x020,
- FXDIB_Argb = 0x220,
- FXDIB_Cmyk = 0x420,
- FXDIB_Cmyka = 0x620,
-};
-
-enum FXDIB_Channel {
- FXDIB_Red = 1,
- FXDIB_Green,
- FXDIB_Blue,
- FXDIB_Cyan,
- FXDIB_Magenta,
- FXDIB_Yellow,
- FXDIB_Black,
- FXDIB_Alpha
-};
-
-#define FXDIB_DOWNSAMPLE 0x04
-#define FXDIB_INTERPOL 0x20
-#define FXDIB_BICUBIC_INTERPOL 0x80
-#define FXDIB_NOSMOOTH 0x100
-#define FXDIB_BLEND_NORMAL 0
-#define FXDIB_BLEND_MULTIPLY 1
-#define FXDIB_BLEND_SCREEN 2
-#define FXDIB_BLEND_OVERLAY 3
-#define FXDIB_BLEND_DARKEN 4
-#define FXDIB_BLEND_LIGHTEN 5
-
-#define FXDIB_BLEND_COLORDODGE 6
-#define FXDIB_BLEND_COLORBURN 7
-#define FXDIB_BLEND_HARDLIGHT 8
-#define FXDIB_BLEND_SOFTLIGHT 9
-#define FXDIB_BLEND_DIFFERENCE 10
-#define FXDIB_BLEND_EXCLUSION 11
-#define FXDIB_BLEND_NONSEPARABLE 21
-#define FXDIB_BLEND_HUE 21
-#define FXDIB_BLEND_SATURATION 22
-#define FXDIB_BLEND_COLOR 23
-#define FXDIB_BLEND_LUMINOSITY 24
-#define FXDIB_BLEND_UNSUPPORTED -1
typedef uint32_t FX_ARGB;
typedef uint32_t FX_COLORREF;
typedef uint32_t FX_CMYK;
class CFX_ClipRgn;
-class CFX_DIBSource;
-class CFX_DIBitmap;
class CStretchEngine;
#define FXSYS_RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16))
@@ -169,229 +117,6 @@ bool ConvertBuffer(FXDIB_Format dest_format,
int src_top,
std::unique_ptr<uint32_t, FxFreeDeleter>* pal);
-class CFX_DIBSource : public CFX_Retainable {
- public:
- ~CFX_DIBSource() override;
-
- virtual uint8_t* GetBuffer() const;
- virtual const uint8_t* GetScanline(int line) const = 0;
- virtual bool SkipToScanline(int line, IFX_Pause* pPause) const;
- virtual void DownSampleScanline(int line,
- uint8_t* dest_scan,
- int dest_bpp,
- int dest_width,
- bool bFlipX,
- int clip_left,
- int clip_width) const = 0;
-
- int GetWidth() const { return m_Width; }
- int GetHeight() const { return m_Height; }
-
- FXDIB_Format GetFormat() const {
- return (FXDIB_Format)(m_AlphaFlag * 0x100 + m_bpp);
- }
- uint32_t GetPitch() const { return m_Pitch; }
- uint32_t* GetPalette() const { return m_pPalette.get(); }
- int GetBPP() const { return m_bpp; }
-
- // TODO(thestig): Investigate this. Given the possible values of FXDIB_Format,
- // it feels as though this should be implemented as !!(m_AlphaFlag & 1) and
- // IsOpaqueImage() below should never be able to return true.
- bool IsAlphaMask() const { return m_AlphaFlag == 1; }
- bool HasAlpha() const { return !!(m_AlphaFlag & 2); }
- bool IsOpaqueImage() const { return !(m_AlphaFlag & 3); }
- bool IsCmykImage() const { return !!(m_AlphaFlag & 4); }
-
- int GetPaletteSize() const {
- return IsAlphaMask() ? 0 : (m_bpp == 1 ? 2 : (m_bpp == 8 ? 256 : 0));
- }
-
- uint32_t GetPaletteEntry(int index) const;
-
- void SetPaletteEntry(int index, uint32_t color);
- uint32_t GetPaletteArgb(int index) const { return GetPaletteEntry(index); }
- void SetPaletteArgb(int index, uint32_t color) {
- SetPaletteEntry(index, color);
- }
-
- // Copies into internally-owned palette.
- void SetPalette(const uint32_t* pSrcPal);
-
- CFX_RetainPtr<CFX_DIBitmap> Clone(const FX_RECT* pClip = nullptr) const;
- CFX_RetainPtr<CFX_DIBitmap> CloneConvert(FXDIB_Format format);
- CFX_RetainPtr<CFX_DIBitmap> StretchTo(int dest_width,
- int dest_height,
- uint32_t flags = 0,
- const FX_RECT* pClip = nullptr);
- CFX_RetainPtr<CFX_DIBitmap> TransformTo(const CFX_Matrix* pMatrix,
- int& left,
- int& top,
- uint32_t flags = 0,
- const FX_RECT* pClip = nullptr);
- CFX_RetainPtr<CFX_DIBitmap> SwapXY(bool bXFlip,
- bool bYFlip,
- const FX_RECT* pClip = nullptr) const;
- CFX_RetainPtr<CFX_DIBitmap> FlipImage(bool bXFlip, bool bYFlip) const;
-
- CFX_RetainPtr<CFX_DIBitmap> CloneAlphaMask(
- const FX_RECT* pClip = nullptr) const;
-
- // Copies into internally-owned mask.
- bool SetAlphaMask(const CFX_RetainPtr<CFX_DIBSource>& pAlphaMask,
- const FX_RECT* pClip = nullptr);
-
- void GetOverlapRect(int& dest_left,
- int& dest_top,
- int& width,
- int& height,
- int src_width,
- int src_height,
- int& src_left,
- int& src_top,
- const CFX_ClipRgn* pClipRgn);
-
-#if defined _SKIA_SUPPORT_ || defined _SKIA_SUPPORT_PATHS_
- void DebugVerifyBitmapIsPreMultiplied(void* buffer = nullptr) const;
-#endif
-
- CFX_RetainPtr<CFX_DIBitmap> m_pAlphaMask;
-
- protected:
- CFX_DIBSource();
-
- void BuildPalette();
- bool BuildAlphaMask();
- int FindPalette(uint32_t color) const;
- void GetPalette(uint32_t* pal, int alpha) const;
-
- int m_Width;
- int m_Height;
- int m_bpp;
- uint32_t m_AlphaFlag;
- uint32_t m_Pitch;
- // TODO(weili): Use std::vector for this.
- std::unique_ptr<uint32_t, FxFreeDeleter> m_pPalette;
-};
-
-class CFX_DIBitmap : public CFX_DIBSource {
- public:
- template <typename T, typename... Args>
- friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
-
- ~CFX_DIBitmap() override;
-
- bool Create(int width,
- int height,
- FXDIB_Format format,
- uint8_t* pBuffer = nullptr,
- int pitch = 0);
-
- bool Copy(const CFX_RetainPtr<CFX_DIBSource>& pSrc);
-
- // CFX_DIBSource
- uint8_t* GetBuffer() const override;
- const uint8_t* GetScanline(int line) const override;
- void DownSampleScanline(int line,
- uint8_t* dest_scan,
- int dest_bpp,
- int dest_width,
- bool bFlipX,
- int clip_left,
- int clip_width) const override;
-
- void TakeOver(CFX_RetainPtr<CFX_DIBitmap>&& pSrcBitmap);
- bool ConvertFormat(FXDIB_Format format);
- void Clear(uint32_t color);
-
- uint32_t GetPixel(int x, int y) const;
- void SetPixel(int x, int y, uint32_t color);
-
- bool LoadChannel(FXDIB_Channel destChannel,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
- FXDIB_Channel srcChannel);
- bool LoadChannel(FXDIB_Channel destChannel, int value);
-
- bool MultiplyAlpha(int alpha);
- bool MultiplyAlpha(const CFX_RetainPtr<CFX_DIBSource>& pAlphaMask);
-
- bool TransferBitmap(int dest_left,
- int dest_top,
- int width,
- int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
- int src_left,
- int src_top);
-
- bool CompositeBitmap(int dest_left,
- int dest_top,
- int width,
- int height,
- const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap,
- int src_left,
- int src_top,
- int blend_type = FXDIB_BLEND_NORMAL,
- const CFX_ClipRgn* pClipRgn = nullptr,
- bool bRgbByteOrder = false,
- void* pIccTransform = nullptr);
-
- bool TransferMask(int dest_left,
- int dest_top,
- int width,
- int height,
- const CFX_RetainPtr<CFX_DIBSource>& pMask,
- uint32_t color,
- int src_left,
- int src_top,
- int alpha_flag = 0,
- void* pIccTransform = nullptr);
-
- bool CompositeMask(int dest_left,
- int dest_top,
- int width,
- int height,
- const CFX_RetainPtr<CFX_DIBSource>& pMask,
- uint32_t color,
- int src_left,
- int src_top,
- int blend_type = FXDIB_BLEND_NORMAL,
- const CFX_ClipRgn* pClipRgn = nullptr,
- bool bRgbByteOrder = false,
- int alpha_flag = 0,
- void* pIccTransform = nullptr);
-
- bool CompositeRect(int dest_left,
- int dest_top,
- int width,
- int height,
- uint32_t color,
- int alpha_flag = 0,
- void* pIccTransform = nullptr);
-
- bool ConvertColorScale(uint32_t forecolor, uint32_t backcolor);
-
-#if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_
- void PreMultiply();
-#endif
-#if defined _SKIA_SUPPORT_PATHS_
- void UnPreMultiply();
-#endif
-
- protected:
- CFX_DIBitmap();
- CFX_DIBitmap(const CFX_DIBitmap& src);
- bool GetGrayData(void* pIccTransform = nullptr);
-
-#if defined _SKIA_SUPPORT_PATHS_
- enum class Format { kCleared, kPreMultiplied, kUnPreMultiplied };
-#endif
-
- uint8_t* m_pBuffer;
-#if defined _SKIA_SUPPORT_PATHS_
- Format m_nFormat;
-#endif
- bool m_bExtBuf;
-};
-
class CFX_DIBExtractor {
public:
explicit CFX_DIBExtractor(const CFX_RetainPtr<CFX_DIBSource>& pSrc);
@@ -403,41 +128,6 @@ class CFX_DIBExtractor {
CFX_RetainPtr<CFX_DIBitmap> m_pBitmap;
};
-class CFX_FilteredDIB : public CFX_DIBSource {
- public:
- template <typename T, typename... Args>
- friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
-
- ~CFX_FilteredDIB() override;
-
- virtual FXDIB_Format GetDestFormat() = 0;
- virtual uint32_t* GetDestPalette() = 0;
- virtual void TranslateScanline(const uint8_t* src_buf,
- std::vector<uint8_t>* dest_buf) const = 0;
- virtual void TranslateDownSamples(uint8_t* dest_buf,
- const uint8_t* src_buf,
- int pixels,
- int Bpp) const = 0;
-
- void LoadSrc(const CFX_RetainPtr<CFX_DIBSource>& pSrc);
-
- protected:
- CFX_FilteredDIB();
-
- // CFX_DIBSource
- const uint8_t* GetScanline(int line) const override;
- void DownSampleScanline(int line,
- uint8_t* dest_scan,
- int dest_bpp,
- int dest_width,
- bool bFlipX,
- int clip_left,
- int clip_width) const override;
-
- CFX_RetainPtr<CFX_DIBSource> m_pSrc;
- mutable std::vector<uint8_t> m_Scanline;
-};
-
class IFX_ScanlineComposer {
public:
virtual ~IFX_ScanlineComposer() {}