diff options
Diffstat (limited to 'core/fxge')
-rw-r--r-- | core/fxge/agg/fx_agg_driver.cpp | 18 | ||||
-rw-r--r-- | core/fxge/agg/fx_agg_driver.h | 10 | ||||
-rw-r--r-- | core/fxge/cfx_defaultrenderdevice.h | 2 | ||||
-rw-r--r-- | core/fxge/cfx_renderdevice.cpp | 32 | ||||
-rw-r--r-- | core/fxge/cfx_renderdevice.h | 28 | ||||
-rw-r--r-- | core/fxge/dib/cfx_bitmapcomposer.cpp | 9 | ||||
-rw-r--r-- | core/fxge/dib/cfx_bitmapcomposer.h | 7 | ||||
-rw-r--r-- | core/fxge/dib/cfx_dibitmap.cpp | 4 | ||||
-rw-r--r-- | core/fxge/dib/cfx_dibitmap.h | 5 | ||||
-rw-r--r-- | core/fxge/dib/cfx_imagerenderer.cpp | 8 | ||||
-rw-r--r-- | core/fxge/dib/cfx_scanlinecompositor.cpp | 183 | ||||
-rw-r--r-- | core/fxge/dib/cfx_scanlinecompositor.h | 8 | ||||
-rw-r--r-- | core/fxge/fx_dib.h | 36 | ||||
-rw-r--r-- | core/fxge/renderdevicedriver_iface.cpp | 6 | ||||
-rw-r--r-- | core/fxge/renderdevicedriver_iface.h | 15 | ||||
-rw-r--r-- | core/fxge/skia/fx_skia_device.cpp | 62 | ||||
-rw-r--r-- | core/fxge/skia/fx_skia_device.h | 16 | ||||
-rw-r--r-- | core/fxge/skia/fx_skia_device_embeddertest.cpp | 4 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 40 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_print.cpp | 34 | ||||
-rw-r--r-- | core/fxge/win32/win32_int.h | 34 |
21 files changed, 284 insertions, 277 deletions
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index 39b31b58f1..6e680b9796 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -1311,8 +1311,8 @@ bool CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData, uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type) { - if (blend_type != FXDIB_BLEND_NORMAL) + BlendMode blend_type) { + if (blend_type != BlendMode::kNormal) return false; if (!GetBuffer()) @@ -1410,8 +1410,8 @@ bool CFX_AggDeviceDriver::SetPixel(int x, int y, uint32_t color) { bool CFX_AggDeviceDriver::FillRectWithBlend(const FX_RECT& rect, uint32_t fill_color, - int blend_type) { - if (blend_type != FXDIB_BLEND_NORMAL) + BlendMode blend_type) { + if (blend_type != BlendMode::kNormal) return false; if (!m_pBitmap->GetBuffer()) @@ -1438,7 +1438,7 @@ bool CFX_AggDeviceDriver::FillRectWithBlend(const FX_RECT& rect, m_pBitmap->CompositeMask(draw_rect.left, draw_rect.top, draw_rect.Width(), draw_rect.Height(), m_pClipRgn->GetMask(), fill_color, draw_rect.left - clip_rect.left, - draw_rect.top - clip_rect.top, FXDIB_BLEND_NORMAL, + draw_rect.top - clip_rect.top, BlendMode::kNormal, nullptr, m_bRgbByteOrder, 0); return true; } @@ -1469,7 +1469,7 @@ bool CFX_AggDeviceDriver::GetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap, return true; pBack->CompositeBitmap(0, 0, pBack->GetWidth(), pBack->GetHeight(), - m_pBitmap, 0, 0, FXDIB_BLEND_NORMAL, nullptr, false); + m_pBitmap, 0, 0, BlendMode::kNormal, nullptr, false); } else { pBack = m_pBitmap->Clone(&rect); if (!pBack) @@ -1496,7 +1496,7 @@ bool CFX_AggDeviceDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, const FX_RECT* pSrcRect, int left, int top, - int blend_type) { + BlendMode blend_type) { if (!m_pBitmap->GetBuffer()) return true; @@ -1519,7 +1519,7 @@ bool CFX_AggDeviceDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource, int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int blend_type) { + BlendMode blend_type) { if (!m_pBitmap->GetBuffer()) return true; @@ -1551,7 +1551,7 @@ bool CFX_AggDeviceDriver::StartDIBits( const CFX_Matrix* pMatrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type) { + BlendMode blend_type) { if (!m_pBitmap->GetBuffer()) return true; diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h index 6d6b988c3a..9a8458e374 100644 --- a/core/fxge/agg/fx_agg_driver.h +++ b/core/fxge/agg/fx_agg_driver.h @@ -57,11 +57,11 @@ class CFX_AggDeviceDriver final : public RenderDeviceDriverIface { uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type) override; + BlendMode blend_type) override; bool SetPixel(int x, int y, uint32_t color) override; bool FillRectWithBlend(const FX_RECT& rect, uint32_t fill_color, - int blend_type) override; + BlendMode blend_type) override; bool GetClipBox(FX_RECT* pRect) override; bool GetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap, int left, @@ -72,7 +72,7 @@ class CFX_AggDeviceDriver final : public RenderDeviceDriverIface { const FX_RECT* pSrcRect, int left, int top, - int blend_type) override; + BlendMode blend_type) override; bool StretchDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, uint32_t color, int dest_left, @@ -81,14 +81,14 @@ class CFX_AggDeviceDriver final : public RenderDeviceDriverIface { int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int blend_type) override; + BlendMode blend_type) override; bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, uint32_t flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type) override; + BlendMode blend_type) override; bool ContinueDIBits(CFX_ImageRenderer* handle, PauseIndicatorIface* pPause) override; bool DrawDeviceText(int nChars, diff --git a/core/fxge/cfx_defaultrenderdevice.h b/core/fxge/cfx_defaultrenderdevice.h index 937088f2b2..d001775b17 100644 --- a/core/fxge/cfx_defaultrenderdevice.h +++ b/core/fxge/cfx_defaultrenderdevice.h @@ -36,7 +36,7 @@ class CFX_DefaultRenderDevice final : public CFX_RenderDevice { int left, int top, int bitmap_alpha, - int blend_type) override; + BlendMode blend_type) override; #endif }; diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp index f00d7f9d01..8afff1e84a 100644 --- a/core/fxge/cfx_renderdevice.cpp +++ b/core/fxge/cfx_renderdevice.cpp @@ -510,7 +510,7 @@ bool CFX_RenderDevice::DrawPathWithBlend(const CFX_PathData* pPathData, uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type) { + BlendMode blend_type) { uint8_t stroke_alpha = pGraphState ? FXARGB_A(stroke_color) : 0; uint8_t fill_alpha = (fill_mode & 3) ? FXARGB_A(fill_color) : 0; const std::vector<FX_PATHPOINT>& pPoints = pPathData->GetPoints(); @@ -618,7 +618,7 @@ bool CFX_RenderDevice::DrawFillStrokePath(const CFX_PathData* pPathData, uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type) { + BlendMode blend_type) { if (!(m_RenderCaps & FXRC_GET_BITS)) return false; CFX_FloatRect bbox; @@ -665,12 +665,12 @@ bool CFX_RenderDevice::DrawFillStrokePath(const CFX_PathData* pPathData, #endif FX_RECT src_rect(0, 0, rect.Width(), rect.Height()); return m_pDeviceDriver->SetDIBits(bitmap, 0, &src_rect, rect.left, rect.top, - FXDIB_BLEND_NORMAL); + BlendMode::kNormal); } bool CFX_RenderDevice::FillRectWithBlend(const FX_RECT& rect, uint32_t fill_color, - int blend_type) { + BlendMode blend_type) { if (m_pDeviceDriver->FillRectWithBlend(rect, fill_color, blend_type)) return true; @@ -690,7 +690,7 @@ bool CFX_RenderDevice::FillRectWithBlend(const FX_RECT& rect, } FX_RECT src_rect(0, 0, rect.Width(), rect.Height()); m_pDeviceDriver->SetDIBits(bitmap, 0, &src_rect, rect.left, rect.top, - FXDIB_BLEND_NORMAL); + BlendMode::kNormal); return true; } @@ -698,7 +698,7 @@ bool CFX_RenderDevice::DrawCosmeticLine(const CFX_PointF& ptMoveTo, const CFX_PointF& ptLineTo, uint32_t color, int fill_mode, - int blend_type) { + BlendMode blend_type) { if ((color >= 0xff000000) && m_pDeviceDriver->DrawCosmeticLine( ptMoveTo, ptLineTo, color, blend_type)) { return true; @@ -725,7 +725,7 @@ RetainPtr<CFX_DIBitmap> CFX_RenderDevice::GetBackDrop() { bool CFX_RenderDevice::SetDIBitsWithBlend(const RetainPtr<CFX_DIBBase>& pBitmap, int left, int top, - int blend_mode) { + BlendMode blend_mode) { ASSERT(!pBitmap->IsAlphaMask()); FX_RECT dest_rect(left, top, left + pBitmap->GetWidth(), top + pBitmap->GetHeight()); @@ -736,7 +736,7 @@ bool CFX_RenderDevice::SetDIBitsWithBlend(const RetainPtr<CFX_DIBBase>& pBitmap, FX_RECT src_rect(dest_rect.left - left, dest_rect.top - top, dest_rect.left - left + dest_rect.Width(), dest_rect.top - top + dest_rect.Height()); - if ((blend_mode == FXDIB_BLEND_NORMAL || (m_RenderCaps & FXRC_BLEND_MODE)) && + if ((blend_mode == BlendMode::kNormal || (m_RenderCaps & FXRC_BLEND_MODE)) && (!pBitmap->HasAlpha() || (m_RenderCaps & FXRC_ALPHA_IMAGE))) { return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left, dest_rect.top, blend_mode); @@ -762,7 +762,7 @@ bool CFX_RenderDevice::SetDIBitsWithBlend(const RetainPtr<CFX_DIBBase>& pBitmap, } FX_RECT rect(0, 0, bg_pixel_width, bg_pixel_height); return m_pDeviceDriver->SetDIBits(background, 0, &rect, dest_rect.left, - dest_rect.top, FXDIB_BLEND_NORMAL); + dest_rect.top, BlendMode::kNormal); } bool CFX_RenderDevice::StretchDIBitsWithFlagsAndBlend( @@ -772,7 +772,7 @@ bool CFX_RenderDevice::StretchDIBitsWithFlagsAndBlend( int dest_width, int dest_height, uint32_t flags, - int blend_mode) { + BlendMode blend_mode) { FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); FX_RECT clip_box = m_ClipBox; clip_box.Intersect(dest_rect); @@ -787,7 +787,7 @@ bool CFX_RenderDevice::SetBitMask(const RetainPtr<CFX_DIBBase>& pBitmap, uint32_t argb) { FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top, - FXDIB_BLEND_NORMAL); + BlendMode::kNormal); } bool CFX_RenderDevice::StretchBitMask(const RetainPtr<CFX_DIBBase>& pBitmap, @@ -813,7 +813,7 @@ bool CFX_RenderDevice::StretchBitMaskWithFlags( clip_box.Intersect(dest_rect); return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width, dest_height, &clip_box, flags, - FXDIB_BLEND_NORMAL); + BlendMode::kNormal); } bool CFX_RenderDevice::StartDIBitsWithBlend( @@ -823,7 +823,7 @@ bool CFX_RenderDevice::StartDIBitsWithBlend( const CFX_Matrix* pMatrix, uint32_t flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_mode) { + BlendMode blend_mode) { return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix, flags, handle, blend_mode); } @@ -843,7 +843,7 @@ bool CFX_RenderDevice::SetBitsWithMask(const RetainPtr<CFX_DIBBase>& pBitmap, int left, int top, int bitmap_alpha, - int blend_type) { + BlendMode blend_type) { return m_pDeviceDriver->SetBitsWithMask(pBitmap, pMask, left, top, bitmap_alpha, blend_type); } @@ -1021,7 +1021,7 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, if (anti_alias == FXFT_RENDER_MODE_NORMAL) { if (!bitmap->CompositeMask(left.ValueOrDie(), top.ValueOrDie(), ncols, nrows, pGlyph, fill_color, 0, 0, - FXDIB_BLEND_NORMAL, nullptr, false, 0)) { + BlendMode::kNormal, nullptr, false, 0)) { return false; } continue; @@ -1089,7 +1089,7 @@ bool CFX_RenderDevice::DrawTextPath(int nChars, fill_mode |= FX_FILL_TEXT_MODE; if (!DrawPathWithBlend(&TransformedPath, pUser2Device, pGraphState, fill_color, stroke_color, fill_mode, - FXDIB_BLEND_NORMAL)) { + BlendMode::kNormal)) { return false; } } diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h index f0d78989be..d18161627f 100644 --- a/core/fxge/cfx_renderdevice.h +++ b/core/fxge/cfx_renderdevice.h @@ -138,7 +138,7 @@ class CFX_RenderDevice { uint32_t stroke_color, int fill_mode) { return DrawPathWithBlend(pPathData, pObject2Device, pGraphState, fill_color, - stroke_color, fill_mode, FXDIB_BLEND_NORMAL); + stroke_color, fill_mode, BlendMode::kNormal); } bool DrawPathWithBlend(const CFX_PathData* pPathData, const CFX_Matrix* pObject2Device, @@ -146,27 +146,27 @@ class CFX_RenderDevice { uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type); + BlendMode blend_type); bool FillRect(const FX_RECT& rect, uint32_t color) { - return FillRectWithBlend(rect, color, FXDIB_BLEND_NORMAL); + return FillRectWithBlend(rect, color, BlendMode::kNormal); } RetainPtr<CFX_DIBitmap> GetBackDrop(); bool GetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap, int left, int top); bool SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int left, int top) { - return SetDIBitsWithBlend(pBitmap, left, top, FXDIB_BLEND_NORMAL); + return SetDIBitsWithBlend(pBitmap, left, top, BlendMode::kNormal); } bool SetDIBitsWithBlend(const RetainPtr<CFX_DIBBase>& pBitmap, int left, int top, - int blend_type); + BlendMode blend_type); bool StretchDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int left, int top, int dest_width, int dest_height) { return StretchDIBitsWithFlagsAndBlend(pBitmap, left, top, dest_width, - dest_height, 0, FXDIB_BLEND_NORMAL); + dest_height, 0, BlendMode::kNormal); } bool StretchDIBitsWithFlagsAndBlend(const RetainPtr<CFX_DIBBase>& pBitmap, int left, @@ -174,7 +174,7 @@ class CFX_RenderDevice { int dest_width, int dest_height, uint32_t flags, - int blend_type); + BlendMode blend_type); bool SetBitMask(const RetainPtr<CFX_DIBBase>& pBitmap, int left, int top, @@ -199,7 +199,7 @@ class CFX_RenderDevice { uint32_t flags, std::unique_ptr<CFX_ImageRenderer>* handle) { return StartDIBitsWithBlend(pBitmap, bitmap_alpha, color, pMatrix, flags, - handle, FXDIB_BLEND_NORMAL); + handle, BlendMode::kNormal); } bool StartDIBitsWithBlend(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, @@ -207,7 +207,7 @@ class CFX_RenderDevice { const CFX_Matrix* pMatrix, uint32_t flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type); + BlendMode blend_type); bool ContinueDIBits(CFX_ImageRenderer* handle, PauseIndicatorIface* pPause); bool DrawNormalText(int nChars, @@ -271,7 +271,7 @@ class CFX_RenderDevice { int left, int top, int bitmap_alpha, - int blend_type); + BlendMode blend_type); #endif #if defined _SKIA_SUPPORT_ || defined _SKIA_SUPPORT_PATHS_ void Flush(bool release); @@ -286,13 +286,15 @@ class CFX_RenderDevice { uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type); + BlendMode blend_type); bool DrawCosmeticLine(const CFX_PointF& ptMoveTo, const CFX_PointF& ptLineTo, uint32_t color, int fill_mode, - int blend_type); - bool FillRectWithBlend(const FX_RECT& rect, uint32_t color, int blend_type); + BlendMode blend_type); + bool FillRectWithBlend(const FX_RECT& rect, + uint32_t color, + BlendMode blend_type); RetainPtr<CFX_DIBitmap> m_pBitmap; int m_Width; diff --git a/core/fxge/dib/cfx_bitmapcomposer.cpp b/core/fxge/dib/cfx_bitmapcomposer.cpp index 22e1bc9b65..000ad91099 100644 --- a/core/fxge/dib/cfx_bitmapcomposer.cpp +++ b/core/fxge/dib/cfx_bitmapcomposer.cpp @@ -9,10 +9,9 @@ #include "core/fxge/cfx_cliprgn.h" #include "core/fxge/dib/cfx_dibitmap.h" -CFX_BitmapComposer::CFX_BitmapComposer() - : m_bRgbByteOrder(false), m_BlendType(FXDIB_BLEND_NORMAL) {} +CFX_BitmapComposer::CFX_BitmapComposer() = default; -CFX_BitmapComposer::~CFX_BitmapComposer() {} +CFX_BitmapComposer::~CFX_BitmapComposer() = default; void CFX_BitmapComposer::Compose(const RetainPtr<CFX_DIBitmap>& pDest, const CFX_ClipRgn* pClipRgn, @@ -24,7 +23,7 @@ void CFX_BitmapComposer::Compose(const RetainPtr<CFX_DIBitmap>& pDest, bool bFlipY, bool bRgbByteOrder, int alpha_flag, - int blend_type) { + BlendMode blend_type) { m_pBitmap = pDest; m_pClipRgn = pClipRgn; m_DestLeft = dest_rect.left; @@ -50,7 +49,7 @@ bool CFX_BitmapComposer::SetInfo(int width, uint32_t* pSrcPalette) { m_SrcFormat = src_format; if (!m_Compositor.Init(m_pBitmap->GetFormat(), src_format, width, pSrcPalette, - m_MaskColor, FXDIB_BLEND_NORMAL, + m_MaskColor, BlendMode::kNormal, m_pClipMask != nullptr || (m_BitmapAlpha < 255), m_bRgbByteOrder, m_AlphaFlag)) { return false; diff --git a/core/fxge/dib/cfx_bitmapcomposer.h b/core/fxge/dib/cfx_bitmapcomposer.h index 50a53dbc2b..ef7083db3e 100644 --- a/core/fxge/dib/cfx_bitmapcomposer.h +++ b/core/fxge/dib/cfx_bitmapcomposer.h @@ -14,6 +14,7 @@ #include "core/fxcrt/unowned_ptr.h" #include "core/fxge/dib/cfx_scanlinecompositor.h" #include "core/fxge/dib/scanlinecomposer_iface.h" +#include "core/fxge/fx_dib.h" class CFX_ClipRgn; class CFX_DIBitmap; @@ -33,7 +34,7 @@ class CFX_BitmapComposer final : public ScanlineComposerIface { bool bFlipY, bool bRgbByteOrder, int alpha_flag, - int blend_type); + BlendMode blend_type); // ScanlineComposerIface bool SetInfo(int width, @@ -71,8 +72,8 @@ class CFX_BitmapComposer final : public ScanlineComposerIface { bool m_bFlipX; bool m_bFlipY; int m_AlphaFlag; - bool m_bRgbByteOrder; - int m_BlendType; + bool m_bRgbByteOrder = false; + BlendMode m_BlendType = BlendMode::kNormal; std::vector<uint8_t> m_pScanlineV; std::vector<uint8_t> m_pClipScanV; std::vector<uint8_t> m_pAddClipScan; diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp index 1ab615a172..dcf5fdc7ab 100644 --- a/core/fxge/dib/cfx_dibitmap.cpp +++ b/core/fxge/dib/cfx_dibitmap.cpp @@ -862,7 +862,7 @@ bool CFX_DIBitmap::CompositeBitmap(int dest_left, const RetainPtr<CFX_DIBBase>& pSrcBitmap, int src_left, int src_top, - int blend_type, + BlendMode blend_type, const CFX_ClipRgn* pClipRgn, bool bRgbByteOrder) { if (!m_pBuffer) @@ -934,7 +934,7 @@ bool CFX_DIBitmap::CompositeMask(int dest_left, uint32_t color, int src_left, int src_top, - int blend_type, + BlendMode blend_type, const CFX_ClipRgn* pClipRgn, bool bRgbByteOrder, int alpha_flag) { diff --git a/core/fxge/dib/cfx_dibitmap.h b/core/fxge/dib/cfx_dibitmap.h index 8ab83c3eda..58f69ed4f0 100644 --- a/core/fxge/dib/cfx_dibitmap.h +++ b/core/fxge/dib/cfx_dibitmap.h @@ -11,6 +11,7 @@ #include "core/fxcrt/maybe_owned.h" #include "core/fxcrt/retain_ptr.h" #include "core/fxge/dib/cfx_dibbase.h" +#include "core/fxge/fx_dib.h" class CFX_DIBitmap : public CFX_DIBBase { public: @@ -67,7 +68,7 @@ class CFX_DIBitmap : public CFX_DIBBase { const RetainPtr<CFX_DIBBase>& pSrcBitmap, int src_left, int src_top, - int blend_type, + BlendMode blend_type, const CFX_ClipRgn* pClipRgn, bool bRgbByteOrder); @@ -79,7 +80,7 @@ class CFX_DIBitmap : public CFX_DIBBase { uint32_t color, int src_left, int src_top, - int blend_type, + BlendMode blend_type, const CFX_ClipRgn* pClipRgn, bool bRgbByteOrder, int alpha_flag); diff --git a/core/fxge/dib/cfx_imagerenderer.cpp b/core/fxge/dib/cfx_imagerenderer.cpp index b4d95b8c6f..9641bc0ad0 100644 --- a/core/fxge/dib/cfx_imagerenderer.cpp +++ b/core/fxge/dib/cfx_imagerenderer.cpp @@ -47,7 +47,7 @@ CFX_ImageRenderer::CFX_ImageRenderer(const RetainPtr<CFX_DIBitmap>& pDevice, m_Matrix.c > 0, m_Matrix.b < 0); m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, true, m_Matrix.c > 0, m_Matrix.b < 0, m_bRgbByteOrder, - 0, FXDIB_BLEND_NORMAL); + 0, BlendMode::kNormal); m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>( &m_Composer, pSource, dest_height, dest_width, bitmap_clip, dib_flags); @@ -76,7 +76,7 @@ CFX_ImageRenderer::CFX_ImageRenderer(const RetainPtr<CFX_DIBitmap>& pDevice, bitmap_clip.Offset(-image_rect.left, -image_rect.top); m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, false, false, false, m_bRgbByteOrder, 0, - FXDIB_BLEND_NORMAL); + BlendMode::kNormal); m_Status = 1; m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>( &m_Composer, pSource, dest_width, dest_height, bitmap_clip, dib_flags); @@ -109,14 +109,14 @@ bool CFX_ImageRenderer::Continue(PauseIndicatorIface* pPause) { m_pDevice->CompositeMask( m_pTransformer->result().left, m_pTransformer->result().top, pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap, m_MaskColor, 0, 0, - FXDIB_BLEND_NORMAL, m_pClipRgn.Get(), m_bRgbByteOrder, m_AlphaFlag); + BlendMode::kNormal, m_pClipRgn.Get(), m_bRgbByteOrder, m_AlphaFlag); } else { if (m_BitmapAlpha != 255) pBitmap->MultiplyAlpha(m_BitmapAlpha); m_pDevice->CompositeBitmap( m_pTransformer->result().left, m_pTransformer->result().top, pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap, 0, 0, - FXDIB_BLEND_NORMAL, m_pClipRgn.Get(), m_bRgbByteOrder); + BlendMode::kNormal, m_pClipRgn.Get(), m_bRgbByteOrder); } return false; } diff --git a/core/fxge/dib/cfx_scanlinecompositor.cpp b/core/fxge/dib/cfx_scanlinecompositor.cpp index bfa20e8209..4c6d741c37 100644 --- a/core/fxge/dib/cfx_scanlinecompositor.cpp +++ b/core/fxge/dib/cfx_scanlinecompositor.cpp @@ -45,38 +45,38 @@ const uint8_t color_sqrt[256] = { 0xF7, 0xF8, 0xF8, 0xF9, 0xF9, 0xFA, 0xFA, 0xFB, 0xFB, 0xFC, 0xFC, 0xFD, 0xFD, 0xFE, 0xFE, 0xFF}; -int Blend(int blend_mode, int back_color, int src_color) { +int Blend(BlendMode blend_mode, int back_color, int src_color) { switch (blend_mode) { - case FXDIB_BLEND_NORMAL: + case BlendMode::kNormal: return src_color; - case FXDIB_BLEND_MULTIPLY: + case BlendMode::kMultiply: return src_color * back_color / 255; - case FXDIB_BLEND_SCREEN: + case BlendMode::kScreen: return src_color + back_color - src_color * back_color / 255; - case FXDIB_BLEND_OVERLAY: - return Blend(FXDIB_BLEND_HARDLIGHT, src_color, back_color); - case FXDIB_BLEND_DARKEN: + case BlendMode::kOverlay: + return Blend(BlendMode::kHardLight, src_color, back_color); + case BlendMode::kDarken: return src_color < back_color ? src_color : back_color; - case FXDIB_BLEND_LIGHTEN: + case BlendMode::kLighten: return src_color > back_color ? src_color : back_color; - case FXDIB_BLEND_COLORDODGE: { + case BlendMode::kColorDodge: { if (src_color == 255) return src_color; return std::min(back_color * 255 / (255 - src_color), 255); } - case FXDIB_BLEND_COLORBURN: { + case BlendMode::kColorBurn: { if (src_color == 0) return src_color; return 255 - std::min((255 - back_color) * 255 / src_color, 255); } - case FXDIB_BLEND_HARDLIGHT: + case BlendMode::kHardLight: if (src_color < 128) return (src_color * back_color * 2) / 255; - return Blend(FXDIB_BLEND_SCREEN, back_color, 2 * src_color - 255); - case FXDIB_BLEND_SOFTLIGHT: { + return Blend(BlendMode::kScreen, back_color, 2 * src_color - 255); + case BlendMode::kSoftLight: { if (src_color < 128) { return back_color - (255 - 2 * src_color) * back_color * (255 - back_color) / 255 / @@ -86,10 +86,10 @@ int Blend(int blend_mode, int back_color, int src_color) { (2 * src_color - 255) * (color_sqrt[back_color] - back_color) / 255; } - case FXDIB_BLEND_DIFFERENCE: + case BlendMode::kDifference: return back_color < src_color ? src_color - back_color : back_color - src_color; - case FXDIB_BLEND_EXCLUSION: + case BlendMode::kExclusion: return back_color + src_color - 2 * back_color * src_color / 255; } return src_color; @@ -147,7 +147,7 @@ RGB SetSat(RGB color, int s) { return color; } -void RGB_Blend(int blend_mode, +void RGB_Blend(BlendMode blend_mode, const uint8_t* src_scan, const uint8_t* dest_scan, int results[3]) { @@ -161,16 +161,16 @@ void RGB_Blend(int blend_mode, back.green = dest_scan[1]; back.blue = dest_scan[0]; switch (blend_mode) { - case FXDIB_BLEND_HUE: + case BlendMode::kHue: result = SetLum(SetSat(src, Sat(back)), Lum(back)); break; - case FXDIB_BLEND_SATURATION: + case BlendMode::kSaturation: result = SetLum(SetSat(back, Sat(src)), Lum(back)); break; - case FXDIB_BLEND_COLOR: + case BlendMode::kColor: result = SetLum(src, Lum(back)); break; - case FXDIB_BLEND_LUMINOSITY: + case BlendMode::kLuminosity: result = SetLum(back, Lum(src)); break; } @@ -216,12 +216,12 @@ void CompositeRow_Rgb2Mask(uint8_t* dest_scan, } } -bool IsNonSeparableBlendMode(int mode) { +bool IsNonSeparableBlendMode(BlendMode mode) { switch (mode) { - case FXDIB_BLEND_HUE: - case FXDIB_BLEND_SATURATION: - case FXDIB_BLEND_COLOR: - case FXDIB_BLEND_LUMINOSITY: + case BlendMode::kHue: + case BlendMode::kSaturation: + case BlendMode::kColor: + case BlendMode::kLuminosity: return true; default: return false; @@ -234,11 +234,11 @@ uint8_t GetGray(const uint8_t* src_scan) { uint8_t GetGrayWithBlend(const uint8_t* src_scan, const uint8_t* dest_scan, - int blend_type) { + BlendMode blend_type) { uint8_t gray = GetGray(src_scan); if (IsNonSeparableBlendMode(blend_type)) - gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; - else if (blend_type != FXDIB_BLEND_NORMAL) + gray = blend_type == BlendMode::kLuminosity ? gray : *dest_scan; + else if (blend_type != BlendMode::kNormal) gray = Blend(blend_type, *dest_scan, gray); return gray; } @@ -246,7 +246,7 @@ uint8_t GetGrayWithBlend(const uint8_t* src_scan, void CompositeRow_Argb2Graya(uint8_t* dest_scan, const uint8_t* src_scan, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan, const uint8_t* src_alpha_scan, uint8_t* dst_alpha_scan) { @@ -277,9 +277,9 @@ void CompositeRow_Argb2Graya(uint8_t* dest_scan, int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan); uint8_t gray = GetGray(src_scan); // TODO(npm): Does this if really need src_alpha_scan or was that a bug? - if (blend_type != FXDIB_BLEND_NORMAL && src_alpha_scan) { + if (blend_type != BlendMode::kNormal && src_alpha_scan) { if (IsNonSeparableBlendMode(blend_type)) - gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + gray = blend_type == BlendMode::kLuminosity ? gray : *dest_scan; else gray = Blend(blend_type, *dest_scan, gray); } @@ -293,7 +293,7 @@ void CompositeRow_Argb2Graya(uint8_t* dest_scan, void CompositeRow_Argb2Gray(uint8_t* dest_scan, const uint8_t* src_scan, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan, const uint8_t* src_alpha_scan) { uint8_t gray; @@ -315,7 +315,7 @@ void CompositeRow_Rgb2Gray(uint8_t* dest_scan, const uint8_t* src_scan, int src_Bpp, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan) { uint8_t gray; for (int col = 0; col < pixel_count; ++col) { @@ -333,11 +333,11 @@ void CompositeRow_Rgb2Graya(uint8_t* dest_scan, const uint8_t* src_scan, int src_Bpp, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan, uint8_t* dest_alpha_scan) { for (int col = 0; col < pixel_count; ++col) { - if (blend_type != FXDIB_BLEND_NORMAL && *dest_alpha_scan == 0) { + if (blend_type != BlendMode::kNormal && *dest_alpha_scan == 0) { *dest_scan = GetGray(src_scan); ++dest_scan; ++dest_alpha_scan; @@ -374,7 +374,7 @@ void CompositeRow_Rgb2Graya(uint8_t* dest_scan, void CompositeRow_Argb2Argb(uint8_t* dest_scan, const uint8_t* src_scan, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan, uint8_t* dest_alpha_scan, const uint8_t* src_alpha_scan) { @@ -433,7 +433,7 @@ void CompositeRow_Argb2Argb(uint8_t* dest_scan, if (bNonseparableBlend) RGB_Blend(blend_type, src_scan, dest_scan, blended_colors); for (int color = 0; color < 3; ++color) { - if (blend_type != FXDIB_BLEND_NORMAL) { + if (blend_type != BlendMode::kNormal) { int blended = bNonseparableBlend ? blended_colors[color] : Blend(blend_type, *dest_scan, *src_scan); @@ -455,7 +455,7 @@ void CompositeRow_Argb2Argb(uint8_t* dest_scan, void CompositeRow_Rgb2Argb_Blend_NoClip(uint8_t* dest_scan, const uint8_t* src_scan, int width, - int blend_type, + BlendMode blend_type, int src_Bpp, uint8_t* dest_alpha_scan) { int blended_colors[3]; @@ -507,7 +507,7 @@ void CompositeRow_Rgb2Argb_Blend_NoClip(uint8_t* dest_scan, void CompositeRow_Rgb2Argb_Blend_Clip(uint8_t* dest_scan, const uint8_t* src_scan, int width, - int blend_type, + BlendMode blend_type, int src_Bpp, const uint8_t* clip_scan, uint8_t* dest_alpha_scan) { @@ -660,7 +660,7 @@ void CompositeRow_Rgb2Argb_NoBlend_NoClip(uint8_t* dest_scan, void CompositeRow_Argb2Rgb_Blend(uint8_t* dest_scan, const uint8_t* src_scan, int width, - int blend_type, + BlendMode blend_type, int dest_Bpp, const uint8_t* clip_scan, const uint8_t* src_alpha_scan) { @@ -794,7 +794,7 @@ void CompositeRow_Argb2Rgb_NoBlend(uint8_t* dest_scan, void CompositeRow_Rgb2Rgb_Blend_NoClip(uint8_t* dest_scan, const uint8_t* src_scan, int width, - int blend_type, + BlendMode blend_type, int dest_Bpp, int src_Bpp) { int blended_colors[3]; @@ -823,7 +823,7 @@ void CompositeRow_Rgb2Rgb_Blend_NoClip(uint8_t* dest_scan, void CompositeRow_Rgb2Rgb_Blend_Clip(uint8_t* dest_scan, const uint8_t* src_scan, int width, - int blend_type, + BlendMode blend_type, int dest_Bpp, int src_Bpp, const uint8_t* clip_scan) { @@ -907,17 +907,17 @@ void CompositeRow_8bppPal2Gray(uint8_t* dest_scan, const uint8_t* src_scan, const uint8_t* pPalette, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan, const uint8_t* src_alpha_scan) { if (src_alpha_scan) { - if (blend_type != FXDIB_BLEND_NORMAL) { + if (blend_type != BlendMode::kNormal) { bool bNonseparableBlend = IsNonSeparableBlendMode(blend_type); for (int col = 0; col < pixel_count; col++) { uint8_t gray = pPalette[*src_scan]; int src_alpha = GetAlpha(*src_alpha_scan++, clip_scan, col); if (bNonseparableBlend) - gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + gray = blend_type == BlendMode::kLuminosity ? gray : *dest_scan; else gray = Blend(blend_type, *dest_scan, gray); if (src_alpha) @@ -940,12 +940,12 @@ void CompositeRow_8bppPal2Gray(uint8_t* dest_scan, src_scan++; } } else { - if (blend_type != FXDIB_BLEND_NORMAL) { + if (blend_type != BlendMode::kNormal) { bool bNonseparableBlend = IsNonSeparableBlendMode(blend_type); for (int col = 0; col < pixel_count; col++) { uint8_t gray = pPalette[*src_scan]; if (bNonseparableBlend) - gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + gray = blend_type == BlendMode::kLuminosity ? gray : *dest_scan; else gray = Blend(blend_type, *dest_scan, gray); if (clip_scan && clip_scan[col] < 255) @@ -973,12 +973,12 @@ void CompositeRow_8bppPal2Graya(uint8_t* dest_scan, const uint8_t* src_scan, const uint8_t* pPalette, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan, uint8_t* dest_alpha_scan, const uint8_t* src_alpha_scan) { if (src_alpha_scan) { - if (blend_type != FXDIB_BLEND_NORMAL) { + if (blend_type != BlendMode::kNormal) { bool bNonseparableBlend = IsNonSeparableBlendMode(blend_type); for (int col = 0; col < pixel_count; col++) { uint8_t gray = pPalette[*src_scan]; @@ -1004,7 +1004,7 @@ void CompositeRow_8bppPal2Graya(uint8_t* dest_scan, back_alpha + src_alpha - back_alpha * src_alpha / 255; int alpha_ratio = src_alpha * 255 / (*dest_alpha_scan); if (bNonseparableBlend) - gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + gray = blend_type == BlendMode::kLuminosity ? gray : *dest_scan; else gray = Blend(blend_type, *dest_scan, gray); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); @@ -1040,7 +1040,7 @@ void CompositeRow_8bppPal2Graya(uint8_t* dest_scan, dest_scan++; } } else { - if (blend_type != FXDIB_BLEND_NORMAL) { + if (blend_type != BlendMode::kNormal) { bool bNonseparableBlend = IsNonSeparableBlendMode(blend_type); for (int col = 0; col < pixel_count; col++) { uint8_t gray = pPalette[*src_scan]; @@ -1062,7 +1062,7 @@ void CompositeRow_8bppPal2Graya(uint8_t* dest_scan, *dest_alpha_scan++ = dest_alpha; int alpha_ratio = src_alpha * 255 / dest_alpha; if (bNonseparableBlend) - gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + gray = blend_type == BlendMode::kLuminosity ? gray : *dest_scan; else gray = Blend(blend_type, *dest_scan, gray); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); @@ -1100,11 +1100,11 @@ void CompositeRow_1bppPal2Gray(uint8_t* dest_scan, int src_left, const uint8_t* pPalette, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan) { int reset_gray = pPalette[0]; int set_gray = pPalette[1]; - if (blend_type != FXDIB_BLEND_NORMAL) { + if (blend_type != BlendMode::kNormal) { bool bNonseparableBlend = IsNonSeparableBlendMode(blend_type); for (int col = 0; col < pixel_count; col++) { uint8_t gray = @@ -1112,7 +1112,7 @@ void CompositeRow_1bppPal2Gray(uint8_t* dest_scan, ? set_gray : reset_gray; if (bNonseparableBlend) - gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + gray = blend_type == BlendMode::kLuminosity ? gray : *dest_scan; else gray = Blend(blend_type, *dest_scan, gray); if (clip_scan && clip_scan[col] < 255) { @@ -1143,12 +1143,12 @@ void CompositeRow_1bppPal2Graya(uint8_t* dest_scan, int src_left, const uint8_t* pPalette, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan, uint8_t* dest_alpha_scan) { int reset_gray = pPalette[0]; int set_gray = pPalette[1]; - if (blend_type != FXDIB_BLEND_NORMAL) { + if (blend_type != BlendMode::kNormal) { bool bNonseparableBlend = IsNonSeparableBlendMode(blend_type); for (int col = 0; col < pixel_count; col++) { uint8_t gray = @@ -1172,7 +1172,7 @@ void CompositeRow_1bppPal2Graya(uint8_t* dest_scan, *dest_alpha_scan++ = dest_alpha; int alpha_ratio = src_alpha * 255 / dest_alpha; if (bNonseparableBlend) - gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; + gray = blend_type == BlendMode::kLuminosity ? gray : *dest_scan; else gray = Blend(blend_type, *dest_scan, gray); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); @@ -1512,7 +1512,7 @@ void CompositeRow_ByteMask2Argb(uint8_t* dest_scan, int src_g, int src_b, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan) { for (int col = 0; col < pixel_count; col++) { int src_alpha; @@ -1548,7 +1548,7 @@ void CompositeRow_ByteMask2Argb(uint8_t* dest_scan, dest_scan++; *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], alpha_ratio); - } else if (blend_type != FXDIB_BLEND_NORMAL) { + } else if (blend_type != BlendMode::kNormal) { int blended = Blend(blend_type, *dest_scan, src_b); blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); @@ -1578,7 +1578,7 @@ void CompositeRow_ByteMask2Rgba(uint8_t* dest_scan, int src_g, int src_b, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan, uint8_t* dest_alpha_scan) { for (int col = 0; col < pixel_count; col++) { @@ -1619,7 +1619,7 @@ void CompositeRow_ByteMask2Rgba(uint8_t* dest_scan, *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], alpha_ratio); dest_scan++; - } else if (blend_type != FXDIB_BLEND_NORMAL) { + } else if (blend_type != BlendMode::kNormal) { int blended = Blend(blend_type, *dest_scan, src_b); blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); @@ -1650,7 +1650,7 @@ void CompositeRow_ByteMask2Rgb(uint8_t* dest_scan, int src_g, int src_b, int pixel_count, - int blend_type, + BlendMode blend_type, int Bpp, const uint8_t* clip_scan) { for (int col = 0; col < pixel_count; col++) { @@ -1675,7 +1675,7 @@ void CompositeRow_ByteMask2Rgb(uint8_t* dest_scan, *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], src_alpha); dest_scan++; *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], src_alpha); - } else if (blend_type != FXDIB_BLEND_NORMAL) { + } else if (blend_type != BlendMode::kNormal) { int blended = Blend(blend_type, *dest_scan, src_b); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); dest_scan++; @@ -1778,9 +1778,9 @@ void CompositeRow_BitMask2Argb(uint8_t* dest_scan, int src_b, int src_left, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan) { - if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) { + if (blend_type == BlendMode::kNormal && !clip_scan && mask_alpha == 255) { FX_ARGB argb = ArgbEncode(0xff, src_r, src_g, src_b); for (int col = 0; col < pixel_count; col++) { if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { @@ -1824,7 +1824,7 @@ void CompositeRow_BitMask2Argb(uint8_t* dest_scan, dest_scan++; *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], alpha_ratio); - } else if (blend_type != FXDIB_BLEND_NORMAL) { + } else if (blend_type != BlendMode::kNormal) { int blended = Blend(blend_type, *dest_scan, src_b); blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio); @@ -1855,10 +1855,10 @@ void CompositeRow_BitMask2Rgb(uint8_t* dest_scan, int src_b, int src_left, int pixel_count, - int blend_type, + BlendMode blend_type, int Bpp, const uint8_t* clip_scan) { - if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) { + if (blend_type == BlendMode::kNormal && !clip_scan && mask_alpha == 255) { for (int col = 0; col < pixel_count; col++) { if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { dest_scan[2] = src_r; @@ -1895,7 +1895,7 @@ void CompositeRow_BitMask2Rgb(uint8_t* dest_scan, *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[1], src_alpha); dest_scan++; *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended_colors[2], src_alpha); - } else if (blend_type != FXDIB_BLEND_NORMAL) { + } else if (blend_type != BlendMode::kNormal) { int blended = Blend(blend_type, *dest_scan, src_b); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, src_alpha); dest_scan++; @@ -2009,7 +2009,7 @@ void CompositeRow_BitMask2Graya(uint8_t* dest_scan, void CompositeRow_Argb2Argb_RgbByteOrder(uint8_t* dest_scan, const uint8_t* src_scan, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan) { int blended_colors[3]; bool bNonseparableBlend = IsNonSeparableBlendMode(blend_type); @@ -2052,7 +2052,7 @@ void CompositeRow_Argb2Argb_RgbByteOrder(uint8_t* dest_scan, } for (int color = 0; color < 3; color++) { int index = 2 - color; - if (blend_type != FXDIB_BLEND_NORMAL) { + if (blend_type != BlendMode::kNormal) { int blended = bNonseparableBlend ? blended_colors[color] : Blend(blend_type, dest_scan[index], *src_scan); @@ -2073,7 +2073,7 @@ void CompositeRow_Argb2Argb_RgbByteOrder(uint8_t* dest_scan, void CompositeRow_Rgb2Argb_Blend_NoClip_RgbByteOrder(uint8_t* dest_scan, const uint8_t* src_scan, int width, - int blend_type, + BlendMode blend_type, int src_Bpp) { int blended_colors[3]; bool bNonseparableBlend = IsNonSeparableBlendMode(blend_type); @@ -2116,7 +2116,7 @@ void CompositeRow_Rgb2Argb_Blend_NoClip_RgbByteOrder(uint8_t* dest_scan, void CompositeRow_Argb2Rgb_Blend_RgbByteOrder(uint8_t* dest_scan, const uint8_t* src_scan, int width, - int blend_type, + BlendMode blend_type, int dest_Bpp, const uint8_t* clip_scan) { int blended_colors[3]; @@ -2173,7 +2173,7 @@ void CompositeRow_Rgb2Argb_NoBlend_NoClip_RgbByteOrder(uint8_t* dest_scan, void CompositeRow_Rgb2Rgb_Blend_NoClip_RgbByteOrder(uint8_t* dest_scan, const uint8_t* src_scan, int width, - int blend_type, + BlendMode blend_type, int dest_Bpp, int src_Bpp) { int blended_colors[3]; @@ -2255,7 +2255,7 @@ void CompositeRow_Rgb2Rgb_NoBlend_NoClip_RgbByteOrder(uint8_t* dest_scan, void CompositeRow_Rgb2Argb_Blend_Clip_RgbByteOrder(uint8_t* dest_scan, const uint8_t* src_scan, int width, - int blend_type, + BlendMode blend_type, int src_Bpp, const uint8_t* clip_scan) { int blended_colors[3]; @@ -2306,7 +2306,7 @@ void CompositeRow_Rgb2Argb_Blend_Clip_RgbByteOrder(uint8_t* dest_scan, void CompositeRow_Rgb2Rgb_Blend_Clip_RgbByteOrder(uint8_t* dest_scan, const uint8_t* src_scan, int width, - int blend_type, + BlendMode blend_type, int dest_Bpp, int src_Bpp, const uint8_t* clip_scan) { @@ -2578,7 +2578,7 @@ void CompositeRow_ByteMask2Argb_RgbByteOrder(uint8_t* dest_scan, int src_g, int src_b, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan) { for (int col = 0; col < pixel_count; col++) { int src_alpha; @@ -2614,7 +2614,7 @@ void CompositeRow_ByteMask2Argb_RgbByteOrder(uint8_t* dest_scan, FXDIB_ALPHA_MERGE(dest_scan[1], blended_colors[1], alpha_ratio); dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended_colors[2], alpha_ratio); - } else if (blend_type != FXDIB_BLEND_NORMAL) { + } else if (blend_type != BlendMode::kNormal) { int blended = Blend(blend_type, dest_scan[2], src_b); blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended, alpha_ratio); @@ -2640,7 +2640,7 @@ void CompositeRow_ByteMask2Rgb_RgbByteOrder(uint8_t* dest_scan, int src_g, int src_b, int pixel_count, - int blend_type, + BlendMode blend_type, int Bpp, const uint8_t* clip_scan) { for (int col = 0; col < pixel_count; col++) { @@ -2667,7 +2667,7 @@ void CompositeRow_ByteMask2Rgb_RgbByteOrder(uint8_t* dest_scan, FXDIB_ALPHA_MERGE(dest_scan[1], blended_colors[1], src_alpha); dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended_colors[2], src_alpha); - } else if (blend_type != FXDIB_BLEND_NORMAL) { + } else if (blend_type != BlendMode::kNormal) { int blended = Blend(blend_type, dest_scan[2], src_b); dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended, src_alpha); blended = Blend(blend_type, dest_scan[1], src_g); @@ -2691,9 +2691,9 @@ void CompositeRow_BitMask2Argb_RgbByteOrder(uint8_t* dest_scan, int src_b, int src_left, int pixel_count, - int blend_type, + BlendMode blend_type, const uint8_t* clip_scan) { - if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) { + if (blend_type == BlendMode::kNormal && !clip_scan && mask_alpha == 255) { FX_ARGB argb = ArgbEncode(0xff, src_r, src_g, src_b); for (int col = 0; col < pixel_count; col++) { if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { @@ -2737,7 +2737,7 @@ void CompositeRow_BitMask2Argb_RgbByteOrder(uint8_t* dest_scan, FXDIB_ALPHA_MERGE(dest_scan[1], blended_colors[1], alpha_ratio); dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended_colors[2], alpha_ratio); - } else if (blend_type != FXDIB_BLEND_NORMAL) { + } else if (blend_type != BlendMode::kNormal) { int blended = Blend(blend_type, dest_scan[2], src_b); blended = FXDIB_ALPHA_MERGE(src_b, blended, back_alpha); dest_scan[2] = FXDIB_ALPHA_MERGE(dest_scan[2], blended, alpha_ratio); @@ -2764,10 +2764,10 @@ void CompositeRow_BitMask2Rgb_RgbByteOrder(uint8_t* dest_scan, int src_b, int src_left, int pixel_count, - int blend_type, + BlendMode blend_type, int Bpp, const uint8_t* clip_scan) { - if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) { + if (blend_type == BlendMode::kNormal && !clip_scan && mask_alpha == 255) { for (int col = 0; col < pixel_count; col++) { if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) { dest_scan[2] = src_b; @@ -2806,7 +2806,7 @@ void CompositeRow_BitMask2Rgb_RgbByteOrder(uint8_t* dest_scan, FXDIB_ALPHA_MERGE(dest_scan[1], blended_colors[1], src_alpha); dest_scan[0] = FXDIB_ALPHA_MERGE(dest_scan[0], blended_colors[2], src_alpha); - } else if (blend_type != FXDIB_BLEND_NORMAL) { + } else if (blend_type != BlendMode::kNormal) { int back_color = dest_scan[2]; int blended = Blend(blend_type, back_color, src_b); dest_scan[2] = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha); @@ -2827,17 +2827,16 @@ void CompositeRow_BitMask2Rgb_RgbByteOrder(uint8_t* dest_scan, } // namespace -CFX_ScanlineCompositor::CFX_ScanlineCompositor() - : m_BlendType(FXDIB_BLEND_NORMAL), m_bRgbByteOrder(false) {} +CFX_ScanlineCompositor::CFX_ScanlineCompositor() = default; -CFX_ScanlineCompositor::~CFX_ScanlineCompositor() {} +CFX_ScanlineCompositor::~CFX_ScanlineCompositor() = default; bool CFX_ScanlineCompositor::Init(FXDIB_Format dest_format, FXDIB_Format src_format, int32_t width, uint32_t* pSrcPalette, uint32_t mask_color, - int blend_type, + BlendMode blend_type, bool bClip, bool bRgbByteOrder, int alpha_flag) { @@ -2866,7 +2865,7 @@ bool CFX_ScanlineCompositor::Init(FXDIB_Format dest_format, } m_iTransparency = (src_format & 0x0200 ? 0 : 1) + (dest_format & 0x0200 ? 0 : 2) + - (blend_type == FXDIB_BLEND_NORMAL ? 4 : 0) + (bClip ? 8 : 0) + + (blend_type == BlendMode::kNormal ? 4 : 0) + (bClip ? 8 : 0) + (src_format & 0x0400 ? 16 : 0) + (dest_format & 0x0400 ? 32 : 0); return true; } diff --git a/core/fxge/dib/cfx_scanlinecompositor.h b/core/fxge/dib/cfx_scanlinecompositor.h index 1c373f036b..fc86299032 100644 --- a/core/fxge/dib/cfx_scanlinecompositor.h +++ b/core/fxge/dib/cfx_scanlinecompositor.h @@ -10,11 +10,11 @@ #include <memory> #include "core/fxge/dib/cfx_dibbase.h" +#include "core/fxge/fx_dib.h" class CFX_ScanlineCompositor { public: CFX_ScanlineCompositor(); - ~CFX_ScanlineCompositor(); bool Init(FXDIB_Format dest_format, @@ -22,7 +22,7 @@ class CFX_ScanlineCompositor { int32_t width, uint32_t* pSrcPalette, uint32_t mask_color, - int blend_type, + BlendMode blend_type, bool bClip, bool bRgbByteOrder, int alpha_flag); @@ -70,8 +70,8 @@ class CFX_ScanlineCompositor { int m_MaskRed; int m_MaskGreen; int m_MaskBlue; - int m_BlendType; - bool m_bRgbByteOrder; + BlendMode m_BlendType = BlendMode::kNormal; + bool m_bRgbByteOrder = false; }; #endif // CORE_FXGE_DIB_CFX_SCANLINECOMPOSITOR_H_ diff --git a/core/fxge/fx_dib.h b/core/fxge/fx_dib.h index 4842d11953..96cd82a66b 100644 --- a/core/fxge/fx_dib.h +++ b/core/fxge/fx_dib.h @@ -55,22 +55,26 @@ extern const int16_t SDP_Table[513]; #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_HUE 21 -#define FXDIB_BLEND_SATURATION 22 -#define FXDIB_BLEND_COLOR 23 -#define FXDIB_BLEND_LUMINOSITY 24 +// See PDF 1.7 spec, table 7.2 and 7.3. The enum values need to be in the same +// order as listed in the spec. +enum class BlendMode { + kNormal = 0, + kMultiply, + kScreen, + kOverlay, + kDarken, + kLighten, + kColorDodge, + kColorBurn, + kHardLight, + kSoftLight, + kDifference, + kExclusion, + kHue, + kSaturation, + kColor, + kLuminosity, +}; constexpr uint32_t FXSYS_BGR(uint8_t b, uint8_t g, uint8_t r) { return (b << 16) | (g << 8) | r; diff --git a/core/fxge/renderdevicedriver_iface.cpp b/core/fxge/renderdevicedriver_iface.cpp index 646851ff45..fbd4335604 100644 --- a/core/fxge/renderdevicedriver_iface.cpp +++ b/core/fxge/renderdevicedriver_iface.cpp @@ -31,14 +31,14 @@ bool RenderDeviceDriverIface::SetPixel(int x, int y, uint32_t color) { bool RenderDeviceDriverIface::FillRectWithBlend(const FX_RECT& rect, uint32_t fill_color, - int blend_type) { + BlendMode blend_type) { return false; } bool RenderDeviceDriverIface::DrawCosmeticLine(const CFX_PointF& ptMoveTo, const CFX_PointF& ptLineTo, uint32_t color, - int blend_type) { + BlendMode blend_type) { return false; } @@ -86,7 +86,7 @@ bool RenderDeviceDriverIface::SetBitsWithMask( int left, int top, int bitmap_alpha, - int blend_type) { + BlendMode blend_type) { return false; } diff --git a/core/fxge/renderdevicedriver_iface.h b/core/fxge/renderdevicedriver_iface.h index 62287abe62..051254db2b 100644 --- a/core/fxge/renderdevicedriver_iface.h +++ b/core/fxge/renderdevicedriver_iface.h @@ -12,6 +12,7 @@ #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_system.h" #include "core/fxcrt/retain_ptr.h" +#include "core/fxge/fx_dib.h" class CFX_DIBitmap; class CFX_DIBBase; @@ -48,15 +49,15 @@ class RenderDeviceDriverIface { uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type) = 0; + BlendMode blend_type) = 0; virtual bool SetPixel(int x, int y, uint32_t color); virtual bool FillRectWithBlend(const FX_RECT& rect, uint32_t fill_color, - int blend_type); + BlendMode blend_type); virtual bool DrawCosmeticLine(const CFX_PointF& ptMoveTo, const CFX_PointF& ptLineTo, uint32_t color, - int blend_type); + BlendMode blend_type); virtual bool GetClipBox(FX_RECT* pRect) = 0; virtual bool GetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap, @@ -68,7 +69,7 @@ class RenderDeviceDriverIface { const FX_RECT* pSrcRect, int dest_left, int dest_top, - int blend_type) = 0; + BlendMode blend_type) = 0; virtual bool StretchDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, uint32_t color, int dest_left, @@ -77,14 +78,14 @@ class RenderDeviceDriverIface { int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int blend_type) = 0; + BlendMode blend_type) = 0; virtual bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, uint32_t flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type) = 0; + BlendMode blend_type) = 0; virtual bool ContinueDIBits(CFX_ImageRenderer* handle, PauseIndicatorIface* pPause); virtual bool DrawDeviceText(int nChars, @@ -105,7 +106,7 @@ class RenderDeviceDriverIface { int left, int top, int bitmap_alpha, - int blend_type); + BlendMode blend_type); #if defined _SKIA_SUPPORT_ || defined _SKIA_SUPPORT_PATHS_ virtual void Flush(); #endif diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index ce9bb4240c..63a44cba65 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -318,39 +318,39 @@ SkMatrix ToFlippedSkMatrix(const CFX_Matrix& m, SkScalar flip) { return skMatrix; } -SkBlendMode GetSkiaBlendMode(int blend_type) { +SkBlendMode GetSkiaBlendMode(BlendMode blend_type) { switch (blend_type) { - case FXDIB_BLEND_MULTIPLY: + case BlendMode::kMultiply: return SkBlendMode::kMultiply; - case FXDIB_BLEND_SCREEN: + case BlendMode::kScreen: return SkBlendMode::kScreen; - case FXDIB_BLEND_OVERLAY: + case BlendMode::kOverlay: return SkBlendMode::kOverlay; - case FXDIB_BLEND_DARKEN: + case BlendMode::kDarken: return SkBlendMode::kDarken; - case FXDIB_BLEND_LIGHTEN: + case BlendMode::kLighten: return SkBlendMode::kLighten; - case FXDIB_BLEND_COLORDODGE: + case BlendMode::kColorDodge: return SkBlendMode::kColorDodge; - case FXDIB_BLEND_COLORBURN: + case BlendMode::kColorBurn: return SkBlendMode::kColorBurn; - case FXDIB_BLEND_HARDLIGHT: + case BlendMode::kHardLight: return SkBlendMode::kHardLight; - case FXDIB_BLEND_SOFTLIGHT: + case BlendMode::kSoftLight: return SkBlendMode::kSoftLight; - case FXDIB_BLEND_DIFFERENCE: + case BlendMode::kDifference: return SkBlendMode::kDifference; - case FXDIB_BLEND_EXCLUSION: + case BlendMode::kExclusion: return SkBlendMode::kExclusion; - case FXDIB_BLEND_HUE: + case BlendMode::kHue: return SkBlendMode::kHue; - case FXDIB_BLEND_SATURATION: + case BlendMode::kSaturation: return SkBlendMode::kSaturation; - case FXDIB_BLEND_COLOR: + case BlendMode::kColor: return SkBlendMode::kColor; - case FXDIB_BLEND_LUMINOSITY: + case BlendMode::kLuminosity: return SkBlendMode::kLuminosity; - case FXDIB_BLEND_NORMAL: + case BlendMode::kNormal: default: return SkBlendMode::kSrcOver; } @@ -563,7 +563,7 @@ void SetBitmapMatrix(const CFX_Matrix* pMatrix, void SetBitmapPaint(bool isAlphaMask, uint32_t argb, int bitmap_alpha, - int blend_type, + BlendMode blend_type, SkPaint* paint) { paint->setAntiAlias(true); if (isAlphaMask) { @@ -695,7 +695,7 @@ class SkiaState { uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type) { + BlendMode blend_type) { if (m_debugDisable) return false; Dump(__func__); @@ -1074,7 +1074,7 @@ class SkiaState { uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type, + BlendMode blend_type, bool group_knockout) const { return MatrixChanged(pMatrix, m_drawMatrix) || StateChanged(pState, m_drawState) || fill_color != m_fillColor || @@ -1391,7 +1391,7 @@ class SkiaState { float m_scaleX = 0; uint32_t m_fillColor = 0; uint32_t m_strokeColor = 0; - int m_blendType = FXDIB_BLEND_NORMAL; + BlendMode m_blendType = BlendMode::kNormal; int m_commandIndex = 0; // active position in clip command stack int m_drawIndex = INT_MAX; // position of the pending path or text draw int m_clipIndex = 0; // position reflecting depth of canvas clip stacck @@ -1880,7 +1880,7 @@ bool CFX_SkiaDeviceDriver::DrawPath( uint32_t fill_color, // fill color uint32_t stroke_color, // stroke color int fill_mode, // fill mode, WINDING or ALTERNATE. 0 for not filled - int blend_type) { + BlendMode blend_type) { if (fill_mode & FX_ZEROAREA_FILL) return true; if (m_pCache->DrawPath(pPathData, pObject2Device, pGraphState, fill_color, @@ -1941,13 +1941,13 @@ bool CFX_SkiaDeviceDriver::DrawPath( bool CFX_SkiaDeviceDriver::DrawCosmeticLine(const CFX_PointF& ptMoveTo, const CFX_PointF& ptLineTo, uint32_t color, - int blend_type) { + BlendMode blend_type) { return false; } bool CFX_SkiaDeviceDriver::FillRectWithBlend(const FX_RECT& rect, uint32_t fill_color, - int blend_type) { + BlendMode blend_type) { m_pCache->FlushForDraw(); SkPaint spaint; spaint.setAntiAlias(true); @@ -2212,7 +2212,7 @@ bool CFX_SkiaDeviceDriver::GetDIBits(const RetainPtr<CFX_DIBitmap>& pBitmap, return true; pBack->CompositeBitmap(0, 0, pBack->GetWidth(), pBack->GetHeight(), - m_pBitmap, 0, 0, FXDIB_BLEND_NORMAL, nullptr, false); + m_pBitmap, 0, 0, BlendMode::kNormal, nullptr, false); } else { pBack = m_pBitmap->Clone(&rect); if (!pBack) @@ -2242,7 +2242,7 @@ bool CFX_SkiaDeviceDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, const FX_RECT* pSrcRect, int left, int top, - int blend_type) { + BlendMode blend_type) { if (!m_pBitmap || !m_pBitmap->GetBuffer()) return true; @@ -2275,7 +2275,7 @@ bool CFX_SkiaDeviceDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource, int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int blend_type) { + BlendMode blend_type) { #ifdef _SKIA_SUPPORT_ m_pCache->FlushForDraw(); if (!m_pBitmap->GetBuffer()) @@ -2325,7 +2325,7 @@ bool CFX_SkiaDeviceDriver::StartDIBits( const CFX_Matrix* pMatrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type) { + BlendMode blend_type) { #ifdef _SKIA_SUPPORT_ m_pCache->FlushForDraw(); DebugValidate(m_pBitmap, m_pBackdropBitmap); @@ -2456,7 +2456,7 @@ bool CFX_SkiaDeviceDriver::DrawBitsWithMask( const RetainPtr<CFX_DIBBase>& pMask, int bitmap_alpha, const CFX_Matrix* pMatrix, - int blend_type) { + BlendMode blend_type) { DebugValidate(m_pBitmap, m_pBackdropBitmap); std::unique_ptr<uint8_t, FxFreeDeleter> src8Storage, mask8Storage; std::unique_ptr<uint32_t, FxFreeDeleter> src32Storage, mask32Storage; @@ -2498,7 +2498,7 @@ bool CFX_SkiaDeviceDriver::SetBitsWithMask( int dest_left, int dest_top, int bitmap_alpha, - int blend_type) { + BlendMode blend_type) { if (!m_pBitmap || !m_pBitmap->GetBuffer()) return true; CFX_Matrix m(pBitmap->GetWidth(), 0, 0, -pBitmap->GetHeight(), dest_left, @@ -2599,7 +2599,7 @@ bool CFX_DefaultRenderDevice::SetBitsWithMask( int left, int top, int bitmap_alpha, - int blend_type) { + BlendMode blend_type) { CFX_SkiaDeviceDriver* skDriver = static_cast<CFX_SkiaDeviceDriver*>(GetDeviceDriver()); if (skDriver) diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h index 4baeacbce5..23c85145b1 100644 --- a/core/fxge/skia/fx_skia_device.h +++ b/core/fxge/skia/fx_skia_device.h @@ -62,17 +62,17 @@ class CFX_SkiaDeviceDriver final : public RenderDeviceDriverIface { uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type) override; + BlendMode blend_type) override; bool FillRectWithBlend(const FX_RECT& rect, uint32_t fill_color, - int blend_type) override; + BlendMode blend_type) override; /** Draw a single pixel (device dependant) line */ bool DrawCosmeticLine(const CFX_PointF& ptMoveTo, const CFX_PointF& ptLineTo, uint32_t color, - int blend_type) override; + BlendMode blend_type) override; bool GetClipBox(FX_RECT* pRect) override; @@ -88,14 +88,14 @@ class CFX_SkiaDeviceDriver final : public RenderDeviceDriverIface { const FX_RECT* pSrcRect, int dest_left, int dest_top, - int blend_type) override; + BlendMode blend_type) override; #ifdef _SKIA_SUPPORT_ bool SetBitsWithMask(const RetainPtr<CFX_DIBBase>& pBitmap, const RetainPtr<CFX_DIBBase>& pMask, int dest_left, int dest_top, int bitmap_alpha, - int blend_type) override; + BlendMode blend_type) override; #endif #ifdef _SKIA_SUPPORT_PATHS_ @@ -110,7 +110,7 @@ class CFX_SkiaDeviceDriver final : public RenderDeviceDriverIface { int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int blend_type) override; + BlendMode blend_type) override; bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, @@ -118,7 +118,7 @@ class CFX_SkiaDeviceDriver final : public RenderDeviceDriverIface { const CFX_Matrix* pMatrix, uint32_t flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type) override; + BlendMode blend_type) override; bool ContinueDIBits(CFX_ImageRenderer* handle, PauseIndicatorIface* pPause) override; @@ -127,7 +127,7 @@ class CFX_SkiaDeviceDriver final : public RenderDeviceDriverIface { const RetainPtr<CFX_DIBBase>& pMask, int bitmap_alpha, const CFX_Matrix* pMatrix, - int blend_type); + BlendMode blend_type); bool DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, diff --git a/core/fxge/skia/fx_skia_device_embeddertest.cpp b/core/fxge/skia/fx_skia_device_embeddertest.cpp index 3965a11c56..0a3a8ec1c1 100644 --- a/core/fxge/skia/fx_skia_device_embeddertest.cpp +++ b/core/fxge/skia/fx_skia_device_embeddertest.cpp @@ -61,7 +61,7 @@ void CommonTest(CFX_SkiaDeviceDriver* driver, const State& state) { driver->SetClip_PathFill(&clipPath, &clipMatrix, 0); if (state.m_graphic == State::Graphic::kPath) { driver->DrawPath(&path1, &matrix, &graphState, 0xFF112233, 0, - FXFILL_WINDING, 0); + FXFILL_WINDING, BlendMode::kNormal); } else if (state.m_graphic == State::Graphic::kText) { driver->DrawDeviceText(SK_ARRAY_COUNT(charPos), charPos, &font, &matrix, fontSize, 0xFF445566); @@ -84,7 +84,7 @@ void CommonTest(CFX_SkiaDeviceDriver* driver, const State& state) { driver->SetClip_PathFill(&clipPath, &clipMatrix2, 0); if (state.m_graphic == State::Graphic::kPath) { driver->DrawPath(&path2, &matrix2, &graphState, 0xFF112233, 0, - FXFILL_WINDING, 0); + FXFILL_WINDING, BlendMode::kNormal); } else if (state.m_graphic == State::Graphic::kText) { driver->DrawDeviceText(SK_ARRAY_COUNT(charPos), charPos, &font, &matrix2, fontSize, 0xFF445566); diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index fec656ef93..537e67564c 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -959,8 +959,8 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type) { - if (blend_type != FXDIB_BLEND_NORMAL) + BlendMode blend_type) { + if (blend_type != BlendMode::kNormal) return false; CWin32Platform* pPlatform = @@ -975,12 +975,12 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, if (bbox.Width() <= 0) { return DrawCosmeticLine(CFX_PointF(bbox.left, bbox.top), CFX_PointF(bbox.left, bbox.bottom + 1), - fill_color, FXDIB_BLEND_NORMAL); + fill_color, BlendMode::kNormal); } if (bbox.Height() <= 0) { return DrawCosmeticLine(CFX_PointF(bbox.left, bbox.top), CFX_PointF(bbox.right + 1, bbox.top), fill_color, - FXDIB_BLEND_NORMAL); + BlendMode::kNormal); } } int fill_alpha = FXARGB_A(fill_color); @@ -1061,8 +1061,8 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, bool CGdiDeviceDriver::FillRectWithBlend(const FX_RECT& rect, uint32_t fill_color, - int blend_type) { - if (blend_type != FXDIB_BLEND_NORMAL) + BlendMode blend_type) { + if (blend_type != BlendMode::kNormal) return false; int alpha; @@ -1116,8 +1116,8 @@ bool CGdiDeviceDriver::SetClip_PathStroke( bool CGdiDeviceDriver::DrawCosmeticLine(const CFX_PointF& ptMoveTo, const CFX_PointF& ptLineTo, uint32_t color, - int blend_type) { - if (blend_type != FXDIB_BLEND_NORMAL) + BlendMode blend_type) { + if (blend_type != BlendMode::kNormal) return false; int alpha; @@ -1191,8 +1191,8 @@ bool CGdiDisplayDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pSource, const FX_RECT* pSrcRect, int left, int top, - int blend_type) { - ASSERT(blend_type == FXDIB_BLEND_NORMAL); + BlendMode blend_type) { + ASSERT(blend_type == BlendMode::kNormal); if (pSource->IsAlphaMask()) { int width = pSource->GetWidth(), height = pSource->GetHeight(); int alpha = FXARGB_A(color); @@ -1201,17 +1201,17 @@ bool CGdiDisplayDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pSource, if (!background->Create(width, height, FXDIB_Rgb32) || !GetDIBits(background, left, top) || !background->CompositeMask(0, 0, width, height, pSource, color, 0, 0, - FXDIB_BLEND_NORMAL, nullptr, false, 0)) { + BlendMode::kNormal, nullptr, false, 0)) { return false; } FX_RECT src_rect(0, 0, width, height); - return SetDIBits(background, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL); + return SetDIBits(background, 0, &src_rect, left, top, BlendMode::kNormal); } FX_RECT clip_rect(left, top, left + pSrcRect->Width(), top + pSrcRect->Height()); return StretchDIBits(pSource, color, left - pSrcRect->left, top - pSrcRect->top, width, height, &clip_rect, 0, - FXDIB_BLEND_NORMAL); + BlendMode::kNormal); } int width = pSrcRect->Width(), height = pSrcRect->Height(); if (pSource->HasAlpha()) { @@ -1219,12 +1219,12 @@ bool CGdiDisplayDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pSource, if (!bitmap->Create(width, height, FXDIB_Rgb) || !GetDIBits(bitmap, left, top) || !bitmap->CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, - pSrcRect->top, FXDIB_BLEND_NORMAL, nullptr, + pSrcRect->top, BlendMode::kNormal, nullptr, false)) { return false; } FX_RECT src_rect(0, 0, width, height); - return SetDIBits(bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL); + return SetDIBits(bitmap, 0, &src_rect, left, top, BlendMode::kNormal); } CFX_DIBExtractor temp(pSource); RetainPtr<CFX_DIBitmap> pBitmap = temp.GetBitmap(); @@ -1257,7 +1257,7 @@ bool CGdiDisplayDriver::UseFoxitStretchEngine( FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight()); return SetDIBits(pStretched, color, &src_rect, pClipRect->left, - pClipRect->top, FXDIB_BLEND_NORMAL); + pClipRect->top, BlendMode::kNormal); } bool CGdiDisplayDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource, @@ -1268,7 +1268,7 @@ bool CGdiDisplayDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource, int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int blend_type) { + BlendMode blend_type) { ASSERT(pSource && pClipRect); if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 10000 || dest_height < -10000) { @@ -1295,14 +1295,14 @@ bool CGdiDisplayDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource, !GetDIBits(background, image_rect.left + clip_rect.left, image_rect.top + clip_rect.top) || !background->CompositeMask(0, 0, clip_width, clip_height, pStretched, - color, 0, 0, FXDIB_BLEND_NORMAL, nullptr, + color, 0, 0, BlendMode::kNormal, nullptr, false, 0)) { return false; } FX_RECT src_rect(0, 0, clip_width, clip_height); return SetDIBits(background, 0, &src_rect, image_rect.left + clip_rect.left, - image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL); + image_rect.top + clip_rect.top, BlendMode::kNormal); } if (pSource->HasAlpha()) { CWin32Platform* pPlatform = @@ -1333,7 +1333,7 @@ bool CGdiDisplayDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, const CFX_Matrix* pMatrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type) { + BlendMode blend_type) { return false; } diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index 4d8452db74..1f9b9510f7 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -73,17 +73,17 @@ bool CGdiPrinterDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pSource, const FX_RECT* pSrcRect, int left, int top, - int blend_type) { + BlendMode blend_type) { if (pSource->IsAlphaMask()) { FX_RECT clip_rect(left, top, left + pSrcRect->Width(), top + pSrcRect->Height()); return StretchDIBits(pSource, color, left - pSrcRect->left, top - pSrcRect->top, pSource->GetWidth(), pSource->GetHeight(), &clip_rect, 0, - FXDIB_BLEND_NORMAL); + BlendMode::kNormal); } ASSERT(pSource && !pSource->IsAlphaMask() && pSrcRect); - ASSERT(blend_type == FXDIB_BLEND_NORMAL); + ASSERT(blend_type == BlendMode::kNormal); if (pSource->HasAlpha()) return false; @@ -103,7 +103,7 @@ bool CGdiPrinterDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pSource, int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int blend_type) { + BlendMode blend_type) { if (pSource->IsAlphaMask()) { int alpha = FXARGB_A(color); if (pSource->GetBPP() != 1 || alpha != 255) @@ -164,7 +164,7 @@ bool CGdiPrinterDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pSource, const CFX_Matrix* pMatrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type) { + BlendMode blend_type) { if (bitmap_alpha < 255 || pSource->HasAlpha() || (pSource->IsAlphaMask() && (pSource->GetBPP() != 1))) { return false; @@ -440,8 +440,8 @@ bool CPSPrinterDriver::DrawPath(const CFX_PathData* pPathData, FX_ARGB fill_color, FX_ARGB stroke_color, int fill_mode, - int blend_type) { - if (blend_type != FXDIB_BLEND_NORMAL) { + BlendMode blend_type) { + if (blend_type != BlendMode::kNormal) { return false; } return m_PSRenderer.DrawPath(pPathData, pObject2Device, pGraphState, @@ -458,8 +458,8 @@ bool CPSPrinterDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, const FX_RECT* pSrcRect, int left, int top, - int blend_type) { - if (blend_type != FXDIB_BLEND_NORMAL) + BlendMode blend_type) { + if (blend_type != BlendMode::kNormal) return false; return m_PSRenderer.SetDIBits(pBitmap, color, left, top); } @@ -472,8 +472,8 @@ bool CPSPrinterDriver::StretchDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int blend_type) { - if (blend_type != FXDIB_BLEND_NORMAL) + BlendMode blend_type) { + if (blend_type != BlendMode::kNormal) return false; return m_PSRenderer.StretchDIBits(pBitmap, color, dest_left, dest_top, dest_width, dest_height, flags); @@ -485,8 +485,8 @@ bool CPSPrinterDriver::StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, const CFX_Matrix* pMatrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type) { - if (blend_type != FXDIB_BLEND_NORMAL) + BlendMode blend_type) { + if (blend_type != BlendMode::kNormal) return false; if (bitmap_alpha < 255) @@ -560,7 +560,7 @@ bool CTextOnlyPrinterDriver::DrawPath(const CFX_PathData* pPathData, uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type) { + BlendMode blend_type) { return false; } @@ -569,7 +569,7 @@ bool CTextOnlyPrinterDriver::SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, const FX_RECT* pSrcRect, int left, int top, - int blend_type) { + BlendMode blend_type) { return false; } @@ -590,7 +590,7 @@ bool CTextOnlyPrinterDriver::StretchDIBits( int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int blend_type) { + BlendMode blend_type) { return false; } @@ -601,7 +601,7 @@ bool CTextOnlyPrinterDriver::StartDIBits( const CFX_Matrix* pMatrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type) { + BlendMode blend_type) { return false; } diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h index 7b4f9ab246..2a61a4e651 100644 --- a/core/fxge/win32/win32_int.h +++ b/core/fxge/win32/win32_int.h @@ -149,14 +149,14 @@ class CGdiDeviceDriver : public RenderDeviceDriverIface { uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type) override; + BlendMode blend_type) override; bool FillRectWithBlend(const FX_RECT& rect, uint32_t fill_color, - int blend_type) override; + BlendMode blend_type) override; bool DrawCosmeticLine(const CFX_PointF& ptMoveTo, const CFX_PointF& ptLineTo, uint32_t color, - int blend_type) override; + BlendMode blend_type) override; bool GetClipBox(FX_RECT* pRect) override; void DrawLine(float x1, float y1, float x2, float y2); @@ -202,7 +202,7 @@ class CGdiDisplayDriver final : public CGdiDeviceDriver { const FX_RECT* pSrcRect, int left, int top, - int blend_type) override; + BlendMode blend_type) override; bool StretchDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, uint32_t color, int dest_left, @@ -211,14 +211,14 @@ class CGdiDisplayDriver final : public CGdiDeviceDriver { int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int blend_type) override; + BlendMode blend_type) override; bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type) override; + BlendMode blend_type) override; bool UseFoxitStretchEngine(const RetainPtr<CFX_DIBBase>& pSource, uint32_t color, int dest_left, @@ -241,7 +241,7 @@ class CGdiPrinterDriver final : public CGdiDeviceDriver { const FX_RECT* pSrcRect, int left, int top, - int blend_type) override; + BlendMode blend_type) override; bool StretchDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, uint32_t color, int dest_left, @@ -250,14 +250,14 @@ class CGdiPrinterDriver final : public CGdiDeviceDriver { int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int blend_type) override; + BlendMode blend_type) override; bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type) override; + BlendMode blend_type) override; bool DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, @@ -293,14 +293,14 @@ class CPSPrinterDriver final : public RenderDeviceDriverIface { uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type) override; + BlendMode blend_type) override; bool GetClipBox(FX_RECT* pRect) override; bool SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, uint32_t color, const FX_RECT* pSrcRect, int left, int top, - int blend_type) override; + BlendMode blend_type) override; bool StretchDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, uint32_t color, int dest_left, @@ -309,14 +309,14 @@ class CPSPrinterDriver final : public RenderDeviceDriverIface { int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int blend_type) override; + BlendMode blend_type) override; bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type) override; + BlendMode blend_type) override; bool DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, @@ -356,14 +356,14 @@ class CTextOnlyPrinterDriver final : public RenderDeviceDriverIface { uint32_t fill_color, uint32_t stroke_color, int fill_mode, - int blend_type) override; + BlendMode blend_type) override; bool GetClipBox(FX_RECT* pRect) override; bool SetDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, uint32_t color, const FX_RECT* pSrcRect, int left, int top, - int blend_type) override; + BlendMode blend_type) override; bool StretchDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, uint32_t color, int dest_left, @@ -372,14 +372,14 @@ class CTextOnlyPrinterDriver final : public RenderDeviceDriverIface { int dest_height, const FX_RECT* pClipRect, uint32_t flags, - int blend_type) override; + BlendMode blend_type) override; bool StartDIBits(const RetainPtr<CFX_DIBBase>& pBitmap, int bitmap_alpha, uint32_t color, const CFX_Matrix* pMatrix, uint32_t render_flags, std::unique_ptr<CFX_ImageRenderer>* handle, - int blend_type) override; + BlendMode blend_type) override; bool DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, |