diff options
author | Lei Zhang <thestig@chromium.org> | 2018-10-25 19:02:50 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-10-25 19:02:50 +0000 |
commit | 0c327657fb8c23934c5beae520e7a97a48e2eef6 (patch) | |
tree | 75c5749124f32c464d29149e125e47325f0cbd2d /core/fxge/dib/cfx_scanlinecompositor.cpp | |
parent | 94f45b29897f801151ecd085fa083f84558065ee (diff) | |
download | pdfium-0c327657fb8c23934c5beae520e7a97a48e2eef6.tar.xz |
Change FXDIB_BLEND_FOO typedefs to an enum class.
BUG=pdfium:1085
Change-Id: Ieb43d4588e1d689e327e428dcbbf7adba45ce178
Reviewed-on: https://pdfium-review.googlesource.com/c/44545
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxge/dib/cfx_scanlinecompositor.cpp')
-rw-r--r-- | core/fxge/dib/cfx_scanlinecompositor.cpp | 183 |
1 files changed, 91 insertions, 92 deletions
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; } |