diff options
Diffstat (limited to 'core/fxge/dib')
-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 |
7 files changed, 112 insertions, 112 deletions
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_ |