diff options
author | Lei Zhang <thestig@chromium.org> | 2018-01-19 18:52:49 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-19 18:52:49 +0000 |
commit | f668ed47ae5472e903ba79499cbff39927155ae2 (patch) | |
tree | 68075403f91645fe01cc8cc341cac97efb2e8d73 /core/fxge/dib | |
parent | 27d718ebb2989631d6b4d3425e1fceb4b3bc795b (diff) | |
download | pdfium-f668ed47ae5472e903ba79499cbff39927155ae2.tar.xz |
Remove NeedAlpha() in CFX_ImageTransformer.
WriteColorResult(), which calls NeedAlpha(), runs on a per-pixel basis
in CFX_ImageTransformer. NeedAlpha() repeats some conditional
calculations. Remove that for a slight speed-up.
Change-Id: I0bb3f92001b9ccdb65c4d59c9f832fe9edfa71f4
Reviewed-on: https://pdfium-review.googlesource.com/23175
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxge/dib')
-rw-r--r-- | core/fxge/dib/cfx_imagetransformer.cpp | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp index 8e01127b00..37e2be0431 100644 --- a/core/fxge/dib/cfx_imagetransformer.cpp +++ b/core/fxge/dib/cfx_imagetransformer.cpp @@ -110,10 +110,6 @@ FXDIB_Format GetTransformedFormat(const RetainPtr<CFX_DIBSource>& pDrc) { return FXDIB_Rgba; } -bool NeedAlpha(bool bHasAlpha, FXDIB_Format format) { - return bHasAlpha || format == FXDIB_Cmyka; -} - void WriteMonoResult(uint32_t r_bgra_cmyk, FXDIB_Format format, uint8_t* dest) { if (format == FXDIB_Rgba) { dest[0] = static_cast<uint8_t>(r_bgra_cmyk >> 24); @@ -131,26 +127,24 @@ void WriteColorResult(std::function<uint8_t(int offset)> func, uint8_t blue_c = func(0); uint8_t green_m = func(1); uint8_t red_y = func(2); - uint8_t alpha_k = NeedAlpha(bHasAlpha, format) ? func(3) : kOpaqueAlpha; uint32_t* dest32 = reinterpret_cast<uint32_t*>(dest); if (bHasAlpha) { if (format == FXDIB_Argb) { - *dest32 = FXARGB_TODIB(FXARGB_MAKE(alpha_k, red_y, green_m, blue_c)); + *dest32 = FXARGB_TODIB(FXARGB_MAKE(func(3), red_y, green_m, blue_c)); } else if (format == FXDIB_Rgba) { dest[0] = blue_c; dest[1] = green_m; dest[2] = red_y; } else { - *dest32 = FXCMYK_TODIB(CmykEncode(blue_c, green_m, red_y, alpha_k)); + *dest32 = FXCMYK_TODIB(CmykEncode(blue_c, green_m, red_y, func(3))); } return; } if (format == FXDIB_Cmyka) { - *dest32 = FXCMYK_TODIB(CmykEncode(blue_c, green_m, red_y, alpha_k)); + *dest32 = FXCMYK_TODIB(CmykEncode(blue_c, green_m, red_y, func(3))); } else { - ASSERT(alpha_k == kOpaqueAlpha); *dest32 = FXARGB_TODIB(FXARGB_MAKE(kOpaqueAlpha, red_y, green_m, blue_c)); } } |