diff options
author | Nicolas Pena <npm@chromium.org> | 2017-04-07 14:12:31 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-07 18:29:13 +0000 |
commit | 6a5c20cd08748da5969cbab756c3e8a6dd27bfbc (patch) | |
tree | 09a5d7e2666b166dc55e94a48270f17741d22b22 /core/fxge | |
parent | 1e8c39f18df6e597e079cce13d18d72631ef0fb9 (diff) | |
download | pdfium-6a5c20cd08748da5969cbab756c3e8a6dd27bfbc.tar.xz |
Remove the ICC transform where it is never initialized.
- All callers of CFX_DIBitmap methods use nullptr as the ICC Transform.
- The CFX_ScanlineCompositor is always initialized with a null ICC transform.
Many of its methods call TranslateScanline from the ICC module. This method
casts just uses ((CLcmsCmm*)pTransform)->m_hTransform, and this should not be
done when pTransform is nullptr.
Change-Id: I1b846d1f20699fa017cb9a276be3214eb8fabd4b
Reviewed-on: https://pdfium-review.googlesource.com/3931
Commit-Queue: Nicolás Peña <npm@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxge')
-rw-r--r-- | core/fxge/agg/fx_agg_driver.cpp | 18 | ||||
-rw-r--r-- | core/fxge/dib/cfx_bitmapcomposer.cpp | 4 | ||||
-rw-r--r-- | core/fxge/dib/cfx_bitmapcomposer.h | 2 | ||||
-rw-r--r-- | core/fxge/dib/cfx_dibitmap.cpp | 271 | ||||
-rw-r--r-- | core/fxge/dib/cfx_dibitmap.h | 21 | ||||
-rw-r--r-- | core/fxge/dib/cfx_imagerenderer.cpp | 20 | ||||
-rw-r--r-- | core/fxge/dib/cfx_imagerenderer.h | 6 | ||||
-rw-r--r-- | core/fxge/dib/cfx_scanlinecompositor.cpp | 460 | ||||
-rw-r--r-- | core/fxge/dib/cfx_scanlinecompositor.h | 4 | ||||
-rw-r--r-- | core/fxge/ge/cfx_renderdevice.cpp | 7 | ||||
-rw-r--r-- | core/fxge/skia/fx_skia_device.cpp | 14 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 7 |
12 files changed, 191 insertions, 643 deletions
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index a04d716b8f..e4fc151fab 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -1530,7 +1530,7 @@ bool CFX_AggDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, fill_color); } else { m_pBitmap->CompositeRect(draw_rect.left, draw_rect.top, draw_rect.Width(), - draw_rect.Height(), fill_color, 0, nullptr); + draw_rect.Height(), fill_color, 0); } return true; } @@ -1538,7 +1538,7 @@ bool CFX_AggDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, draw_rect.Height(), m_pClipRgn->GetMask(), fill_color, draw_rect.left - clip_rect.left, draw_rect.top - clip_rect.top, FXDIB_BLEND_NORMAL, - nullptr, m_bRgbByteOrder, 0, nullptr); + nullptr, m_bRgbByteOrder, 0); return true; } @@ -1600,14 +1600,14 @@ bool CFX_AggDeviceDriver::SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pBitmap, return true; if (pBitmap->IsAlphaMask()) { - return m_pBitmap->CompositeMask( - left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, argb, - pSrcRect->left, pSrcRect->top, blend_type, m_pClipRgn.get(), - m_bRgbByteOrder, 0, nullptr); + return m_pBitmap->CompositeMask(left, top, pSrcRect->Width(), + pSrcRect->Height(), pBitmap, argb, + pSrcRect->left, pSrcRect->top, blend_type, + m_pClipRgn.get(), m_bRgbByteOrder, 0); } return m_pBitmap->CompositeBitmap( left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, pSrcRect->left, - pSrcRect->top, blend_type, m_pClipRgn.get(), m_bRgbByteOrder, nullptr); + pSrcRect->top, blend_type, m_pClipRgn.get(), m_bRgbByteOrder); } bool CFX_AggDeviceDriver::StretchDIBits( @@ -1635,7 +1635,7 @@ bool CFX_AggDeviceDriver::StretchDIBits( dest_clip.Intersect(*pClipRect); CFX_BitmapComposer composer; composer.Compose(m_pBitmap, m_pClipRgn.get(), 255, argb, dest_clip, false, - false, false, m_bRgbByteOrder, 0, nullptr, blend_type); + false, false, m_bRgbByteOrder, 0, blend_type); dest_clip.Offset(-dest_rect.left, -dest_rect.top); CFX_ImageStretcher stretcher(&composer, pSource, dest_width, dest_height, dest_clip, flags); @@ -1657,7 +1657,7 @@ bool CFX_AggDeviceDriver::StartDIBits( *handle = pdfium::MakeUnique<CFX_ImageRenderer>(); (*handle)->Start(m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb, - pMatrix, render_flags, m_bRgbByteOrder, 0, nullptr); + pMatrix, render_flags, m_bRgbByteOrder); return true; } diff --git a/core/fxge/dib/cfx_bitmapcomposer.cpp b/core/fxge/dib/cfx_bitmapcomposer.cpp index bd8dc72094..bd634ad574 100644 --- a/core/fxge/dib/cfx_bitmapcomposer.cpp +++ b/core/fxge/dib/cfx_bitmapcomposer.cpp @@ -26,7 +26,6 @@ void CFX_BitmapComposer::Compose(const CFX_RetainPtr<CFX_DIBitmap>& pDest, bool bFlipY, bool bRgbByteOrder, int alpha_flag, - void* pIccTransform, int blend_type) { m_pBitmap = pDest; m_pClipRgn = pClipRgn; @@ -43,7 +42,6 @@ void CFX_BitmapComposer::Compose(const CFX_RetainPtr<CFX_DIBitmap>& pDest, m_bFlipX = bFlipX; m_bFlipY = bFlipY; m_AlphaFlag = alpha_flag; - m_pIccTransform = pIccTransform; m_bRgbByteOrder = bRgbByteOrder; m_BlendType = blend_type; } @@ -55,7 +53,7 @@ bool CFX_BitmapComposer::SetInfo(int width, if (!m_Compositor.Init(m_pBitmap->GetFormat(), src_format, width, pSrcPalette, m_MaskColor, FXDIB_BLEND_NORMAL, m_pClipMask != nullptr || (m_BitmapAlpha < 255), - m_bRgbByteOrder, m_AlphaFlag, m_pIccTransform)) { + m_bRgbByteOrder, m_AlphaFlag)) { return false; } if (m_bVertical) { diff --git a/core/fxge/dib/cfx_bitmapcomposer.h b/core/fxge/dib/cfx_bitmapcomposer.h index 5ab0647478..6e961cbd45 100644 --- a/core/fxge/dib/cfx_bitmapcomposer.h +++ b/core/fxge/dib/cfx_bitmapcomposer.h @@ -32,7 +32,6 @@ class CFX_BitmapComposer : public IFX_ScanlineComposer { bool bFlipY, bool bRgbByteOrder, int alpha_flag, - void* pIccTransform, int blend_type); // IFX_ScanlineComposer @@ -71,7 +70,6 @@ class CFX_BitmapComposer : public IFX_ScanlineComposer { bool m_bFlipX; bool m_bFlipY; int m_AlphaFlag; - void* m_pIccTransform; bool m_bRgbByteOrder; int m_BlendType; std::vector<uint8_t> m_pScanlineV; diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp index 209fe93f12..61eba3fd74 100644 --- a/core/fxge/dib/cfx_dibitmap.cpp +++ b/core/fxge/dib/cfx_dibitmap.cpp @@ -18,6 +18,12 @@ #define MAX_OOM_LIMIT 12000000 +namespace { + +const int8_t g_ChannelOffset[] = {0, 2, 1, 0, 0, 1, 2, 3, 3}; + +} // namespace + CFX_DIBitmap::CFX_DIBitmap() { m_pPalette = nullptr; #ifdef _SKIA_SUPPORT_PATHS_ @@ -238,118 +244,6 @@ bool CFX_DIBitmap::TransferBitmap( return true; } -bool CFX_DIBitmap::TransferMask(int dest_left, - int dest_top, - int width, - int height, - const CFX_RetainPtr<CFX_DIBSource>& pMask, - uint32_t color, - int src_left, - int src_top, - int alpha_flag, - void* pIccTransform) { - if (!m_pBuffer) - return false; - - ASSERT(HasAlpha() && (m_bpp >= 24)); - ASSERT(pMask->IsAlphaMask()); - if (!HasAlpha() || !pMask->IsAlphaMask() || m_bpp < 24) - return false; - - GetOverlapRect(dest_left, dest_top, width, height, pMask->GetWidth(), - pMask->GetHeight(), src_left, src_top, nullptr); - if (width == 0 || height == 0) - return true; - - int src_bpp = pMask->GetBPP(); - int alpha; - uint32_t dst_color; - if (alpha_flag >> 8) { - alpha = alpha_flag & 0xff; - dst_color = FXCMYK_TODIB(color); - } else { - alpha = FXARGB_A(color); - dst_color = FXARGB_TODIB(color); - } - uint8_t* color_p = (uint8_t*)&dst_color; - if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() && - CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - pIccModule->TranslateScanline(pIccTransform, color_p, color_p, 1); - } else { - if (alpha_flag >> 8 && !IsCmykImage()) { - AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), - FXSYS_GetYValue(color), FXSYS_GetKValue(color), - color_p[2], color_p[1], color_p[0]); - } else if (!(alpha_flag >> 8) && IsCmykImage()) { - return false; - } - } - if (!IsCmykImage()) { - color_p[3] = (uint8_t)alpha; - } - if (GetFormat() == FXDIB_Argb) { - for (int row = 0; row < height; row++) { - uint32_t* dest_pos = reinterpret_cast<uint32_t*>( - m_pBuffer.Get() + (dest_top + row) * m_Pitch + dest_left * 4); - const uint8_t* src_scan = pMask->GetScanline(src_top + row); - if (src_bpp == 1) { - for (int col = 0; col < width; col++) { - int src_bitpos = src_left + col; - if (src_scan[src_bitpos / 8] & (1 << (7 - src_bitpos % 8))) { - *dest_pos = dst_color; - } else { - *dest_pos = 0; - } - dest_pos++; - } - } else { - src_scan += src_left; - dst_color = FXARGB_TODIB(dst_color); - dst_color &= 0xffffff; - for (int col = 0; col < width; col++) { - FXARGB_SETDIB(dest_pos++, - dst_color | ((alpha * (*src_scan++) / 255) << 24)); - } - } - } - } else { - int comps = m_bpp / 8; - for (int row = 0; row < height; row++) { - uint8_t* dest_color_pos = - m_pBuffer.Get() + (dest_top + row) * m_Pitch + dest_left * comps; - uint8_t* dest_alpha_pos = - const_cast<uint8_t*>(m_pAlphaMask->GetScanline(dest_top + row)) + - dest_left; - const uint8_t* src_scan = pMask->GetScanline(src_top + row); - if (src_bpp == 1) { - for (int col = 0; col < width; col++) { - int src_bitpos = src_left + col; - if (src_scan[src_bitpos / 8] & (1 << (7 - src_bitpos % 8))) { - memcpy(dest_color_pos, color_p, comps); - *dest_alpha_pos = 0xff; - } else { - memset(dest_color_pos, 0, comps); - *dest_alpha_pos = 0; - } - dest_color_pos += comps; - dest_alpha_pos++; - } - } else { - src_scan += src_left; - for (int col = 0; col < width; col++) { - memcpy(dest_color_pos, color_p, comps); - dest_color_pos += comps; - *dest_alpha_pos++ = (alpha * (*src_scan++) / 255); - } - } - } - } - return true; -} - -const int g_ChannelOffset[] = {0, 2, 1, 0, 0, 1, 2, 3, 3}; bool CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap, FXDIB_Channel srcChannel) { @@ -573,101 +467,6 @@ bool CFX_DIBitmap::MultiplyAlpha( return true; } -bool CFX_DIBitmap::GetGrayData(void* pIccTransform) { - if (!m_pBuffer) - return false; - - switch (GetFormat()) { - case FXDIB_1bppRgb: { - if (!m_pPalette) - return false; - - uint8_t gray[2]; - for (int i = 0; i < 2; i++) { - int r = static_cast<uint8_t>(m_pPalette.get()[i] >> 16); - int g = static_cast<uint8_t>(m_pPalette.get()[i] >> 8); - int b = static_cast<uint8_t>(m_pPalette.get()[i]); - gray[i] = static_cast<uint8_t>(FXRGB2GRAY(r, g, b)); - } - auto pMask = pdfium::MakeRetain<CFX_DIBitmap>(); - if (!pMask->Create(m_Width, m_Height, FXDIB_8bppMask)) - return false; - - memset(pMask->GetBuffer(), gray[0], pMask->GetPitch() * m_Height); - for (int row = 0; row < m_Height; row++) { - uint8_t* src_pos = m_pBuffer.Get() + row * m_Pitch; - uint8_t* dest_pos = const_cast<uint8_t*>(pMask->GetScanline(row)); - for (int col = 0; col < m_Width; col++) { - if (src_pos[col / 8] & (1 << (7 - col % 8))) - *dest_pos = gray[1]; - dest_pos++; - } - } - TakeOver(std::move(pMask)); - break; - } - case FXDIB_8bppRgb: { - if (!m_pPalette) - return false; - - uint8_t gray[256]; - for (int i = 0; i < 256; i++) { - int r = static_cast<uint8_t>(m_pPalette.get()[i] >> 16); - int g = static_cast<uint8_t>(m_pPalette.get()[i] >> 8); - int b = static_cast<uint8_t>(m_pPalette.get()[i]); - gray[i] = static_cast<uint8_t>(FXRGB2GRAY(r, g, b)); - } - auto pMask = pdfium::MakeRetain<CFX_DIBitmap>(); - if (!pMask->Create(m_Width, m_Height, FXDIB_8bppMask)) - return false; - - for (int row = 0; row < m_Height; row++) { - uint8_t* dest_pos = pMask->GetBuffer() + row * pMask->GetPitch(); - uint8_t* src_pos = m_pBuffer.Get() + row * m_Pitch; - for (int col = 0; col < m_Width; col++) - *dest_pos++ = gray[*src_pos++]; - } - TakeOver(std::move(pMask)); - break; - } - case FXDIB_Rgb: { - auto pMask = pdfium::MakeRetain<CFX_DIBitmap>(); - if (!pMask->Create(m_Width, m_Height, FXDIB_8bppMask)) - return false; - - for (int row = 0; row < m_Height; row++) { - uint8_t* src_pos = m_pBuffer.Get() + row * m_Pitch; - uint8_t* dest_pos = pMask->GetBuffer() + row * pMask->GetPitch(); - for (int col = 0; col < m_Width; col++) { - *dest_pos++ = FXRGB2GRAY(src_pos[2], src_pos[1], *src_pos); - src_pos += 3; - } - } - TakeOver(std::move(pMask)); - break; - } - case FXDIB_Rgb32: { - auto pMask = pdfium::MakeRetain<CFX_DIBitmap>(); - if (!pMask->Create(m_Width, m_Height, FXDIB_8bppMask)) - return false; - - for (int row = 0; row < m_Height; row++) { - uint8_t* src_pos = m_pBuffer.Get() + row * m_Pitch; - uint8_t* dest_pos = pMask->GetBuffer() + row * pMask->GetPitch(); - for (int col = 0; col < m_Width; col++) { - *dest_pos++ = FXRGB2GRAY(src_pos[2], src_pos[1], *src_pos); - src_pos += 4; - } - } - TakeOver(std::move(pMask)); - break; - } - default: - return false; - } - return true; -} - bool CFX_DIBitmap::MultiplyAlpha(int alpha) { if (!m_pBuffer) return false; @@ -1034,8 +833,7 @@ bool CFX_DIBitmap::CompositeBitmap( int src_top, int blend_type, const CFX_ClipRgn* pClipRgn, - bool bRgbByteOrder, - void* pIccTransform) { + bool bRgbByteOrder) { if (!m_pBuffer) return false; @@ -1059,7 +857,7 @@ bool CFX_DIBitmap::CompositeBitmap( CFX_ScanlineCompositor compositor; if (!compositor.Init(GetFormat(), pSrcBitmap->GetFormat(), width, pSrcBitmap->GetPalette(), 0, blend_type, - pClipMask != nullptr, bRgbByteOrder, 0, pIccTransform)) { + pClipMask != nullptr, bRgbByteOrder, 0)) { return false; } int dest_Bpp = m_bpp / 8; @@ -1108,8 +906,7 @@ bool CFX_DIBitmap::CompositeMask(int dest_left, int blend_type, const CFX_ClipRgn* pClipRgn, bool bRgbByteOrder, - int alpha_flag, - void* pIccTransform) { + int alpha_flag) { if (!m_pBuffer) return false; @@ -1140,7 +937,7 @@ bool CFX_DIBitmap::CompositeMask(int dest_left, CFX_ScanlineCompositor compositor; if (!compositor.Init(GetFormat(), pMask->GetFormat(), width, nullptr, color, blend_type, pClipMask != nullptr, bRgbByteOrder, - alpha_flag, pIccTransform)) { + alpha_flag)) { return false; } for (int row = 0; row < height; row++) { @@ -1173,8 +970,7 @@ bool CFX_DIBitmap::CompositeRect(int left, int width, int height, uint32_t color, - int alpha_flag, - void* pIccTransform) { + int alpha_flag) { if (!m_pBuffer) return false; @@ -1197,20 +993,15 @@ bool CFX_DIBitmap::CompositeRect(int left, if (m_bpp == 8) { uint8_t gray = 255; if (!IsAlphaMask()) { - if (pIccTransform && CFX_GEModule::Get()->GetCodecModule() && - CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - pIccModule->TranslateScanline(pIccTransform, &gray, color_p, 1); + if (alpha_flag >> 8) { + uint8_t r; + uint8_t g; + uint8_t b; + AdobeCMYK_to_sRGB1(color_p[0], color_p[1], color_p[2], color_p[3], r, g, + b); + gray = FXRGB2GRAY(r, g, b); } else { - if (alpha_flag >> 8) { - uint8_t r, g, b; - AdobeCMYK_to_sRGB1(color_p[0], color_p[1], color_p[2], color_p[3], r, - g, b); - gray = FXRGB2GRAY(r, g, b); - } else { - gray = (uint8_t)FXRGB2GRAY((int)color_p[2], color_p[1], color_p[0]); - } + gray = (uint8_t)FXRGB2GRAY((int)color_p[2], color_p[1], color_p[0]); } if (IsCmykImage()) { gray = ~gray; @@ -1270,25 +1061,15 @@ bool CFX_DIBitmap::CompositeRect(int left, return true; } ASSERT(m_bpp >= 24); - if (m_bpp < 24) { + if (m_bpp < 24 || (!(alpha_flag >> 8) && IsCmykImage())) return false; + if (alpha_flag >> 8 && !IsCmykImage()) { + AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), + FXSYS_GetYValue(color), FXSYS_GetKValue(color), + color_p[2], color_p[1], color_p[0]); } - if (pIccTransform && CFX_GEModule::Get()->GetCodecModule()) { - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - pIccModule->TranslateScanline(pIccTransform, color_p, color_p, 1); - } else { - if (alpha_flag >> 8 && !IsCmykImage()) { - AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), - FXSYS_GetYValue(color), FXSYS_GetKValue(color), - color_p[2], color_p[1], color_p[0]); - } else if (!(alpha_flag >> 8) && IsCmykImage()) { - return false; - } - } - if (!IsCmykImage()) { - color_p[3] = (uint8_t)src_alpha; - } + if (!IsCmykImage()) + color_p[3] = static_cast<uint8_t>(src_alpha); int Bpp = m_bpp / 8; bool bAlpha = HasAlpha(); bool bArgb = GetFormat() == FXDIB_Argb; diff --git a/core/fxge/dib/cfx_dibitmap.h b/core/fxge/dib/cfx_dibitmap.h index 87688a1ade..6fd4b7c89a 100644 --- a/core/fxge/dib/cfx_dibitmap.h +++ b/core/fxge/dib/cfx_dibitmap.h @@ -72,19 +72,7 @@ class CFX_DIBitmap : public CFX_DIBSource { int src_top, int blend_type = FXDIB_BLEND_NORMAL, const CFX_ClipRgn* pClipRgn = nullptr, - bool bRgbByteOrder = false, - void* pIccTransform = nullptr); - - bool TransferMask(int dest_left, - int dest_top, - int width, - int height, - const CFX_RetainPtr<CFX_DIBSource>& pMask, - uint32_t color, - int src_left, - int src_top, - int alpha_flag = 0, - void* pIccTransform = nullptr); + bool bRgbByteOrder = false); bool CompositeMask(int dest_left, int dest_top, @@ -97,16 +85,14 @@ class CFX_DIBitmap : public CFX_DIBSource { int blend_type = FXDIB_BLEND_NORMAL, const CFX_ClipRgn* pClipRgn = nullptr, bool bRgbByteOrder = false, - int alpha_flag = 0, - void* pIccTransform = nullptr); + int alpha_flag = 0); bool CompositeRect(int dest_left, int dest_top, int width, int height, uint32_t color, - int alpha_flag = 0, - void* pIccTransform = nullptr); + int alpha_flag); bool ConvertColorScale(uint32_t forecolor, uint32_t backcolor); @@ -121,7 +107,6 @@ class CFX_DIBitmap : public CFX_DIBSource { CFX_DIBitmap(); CFX_DIBitmap(const CFX_DIBitmap& src); - bool GetGrayData(void* pIccTransform = nullptr); #if defined _SKIA_SUPPORT_PATHS_ enum class Format { kCleared, kPreMultiplied, kUnPreMultiplied }; #endif diff --git a/core/fxge/dib/cfx_imagerenderer.cpp b/core/fxge/dib/cfx_imagerenderer.cpp index 42c92eda06..aa818555b6 100644 --- a/core/fxge/dib/cfx_imagerenderer.cpp +++ b/core/fxge/dib/cfx_imagerenderer.cpp @@ -15,7 +15,6 @@ CFX_ImageRenderer::CFX_ImageRenderer() : m_Status(0), - m_pIccTransform(nullptr), m_bRgbByteOrder(false), m_BlendType(FXDIB_BLEND_NORMAL) {} @@ -28,10 +27,7 @@ bool CFX_ImageRenderer::Start(const CFX_RetainPtr<CFX_DIBitmap>& pDevice, uint32_t mask_color, const CFX_Matrix* pMatrix, uint32_t dib_flags, - bool bRgbByteOrder, - int alpha_flag, - void* pIccTransform, - int blend_type) { + bool bRgbByteOrder) { m_Matrix = *pMatrix; CFX_FloatRect image_rect_f = m_Matrix.GetUnitRect(); FX_RECT image_rect = image_rect_f.GetOuterRect(); @@ -47,10 +43,9 @@ bool CFX_ImageRenderer::Start(const CFX_RetainPtr<CFX_DIBitmap>& pDevice, m_BitmapAlpha = bitmap_alpha; m_Matrix = *pMatrix; m_Flags = dib_flags; - m_AlphaFlag = alpha_flag; - m_pIccTransform = pIccTransform; + m_AlphaFlag = 0; m_bRgbByteOrder = bRgbByteOrder; - m_BlendType = blend_type; + m_BlendType = FXDIB_BLEND_NORMAL; if ((fabs(m_Matrix.b) >= 0.5f || m_Matrix.a == 0) || (fabs(m_Matrix.c) >= 0.5f || m_Matrix.d == 0)) { @@ -65,7 +60,7 @@ bool CFX_ImageRenderer::Start(const CFX_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, - alpha_flag, pIccTransform, m_BlendType); + 0, m_BlendType); m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>( &m_Composer, pSource, dest_height, dest_width, bitmap_clip, dib_flags); @@ -96,8 +91,7 @@ bool CFX_ImageRenderer::Start(const CFX_RetainPtr<CFX_DIBitmap>& pDevice, FX_RECT bitmap_clip = m_ClipBox; 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, alpha_flag, - pIccTransform, m_BlendType); + false, false, false, m_bRgbByteOrder, 0, m_BlendType); m_Status = 1; m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>( &m_Composer, pSource, dest_width, dest_height, bitmap_clip, dib_flags); @@ -130,14 +124,14 @@ bool CFX_ImageRenderer::Continue(IFX_Pause* pPause) { m_pDevice->CompositeMask( m_pTransformer->result().left, m_pTransformer->result().top, pBitmap->GetWidth(), pBitmap->GetHeight(), pBitmap, m_MaskColor, 0, 0, - m_BlendType, m_pClipRgn, m_bRgbByteOrder, m_AlphaFlag, m_pIccTransform); + m_BlendType, m_pClipRgn, 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, m_BlendType, - m_pClipRgn, m_bRgbByteOrder, m_pIccTransform); + m_pClipRgn, m_bRgbByteOrder); } return false; } diff --git a/core/fxge/dib/cfx_imagerenderer.h b/core/fxge/dib/cfx_imagerenderer.h index db8bd08638..f3d1286dc6 100644 --- a/core/fxge/dib/cfx_imagerenderer.h +++ b/core/fxge/dib/cfx_imagerenderer.h @@ -32,10 +32,7 @@ class CFX_ImageRenderer { uint32_t mask_color, const CFX_Matrix* pMatrix, uint32_t dib_flags, - bool bRgbByteOrder = false, - int alpha_flag = 0, - void* pIccTransform = nullptr, - int blend_type = FXDIB_BLEND_NORMAL); + bool bRgbByteOrder); bool Continue(IFX_Pause* pPause); @@ -52,7 +49,6 @@ class CFX_ImageRenderer { FX_RECT m_ClipBox; uint32_t m_Flags; int m_AlphaFlag; - void* m_pIccTransform; bool m_bRgbByteOrder; int m_BlendType; }; diff --git a/core/fxge/dib/cfx_scanlinecompositor.cpp b/core/fxge/dib/cfx_scanlinecompositor.cpp index f8f0b14090..55546bc425 100644 --- a/core/fxge/dib/cfx_scanlinecompositor.cpp +++ b/core/fxge/dib/cfx_scanlinecompositor.cpp @@ -217,23 +217,14 @@ void CompositeRow_Rgb2Mask(uint8_t* dest_scan, } } -uint8_t GetGray(void* pIccTransform, - CCodec_IccModule* pIccModule, - const uint8_t* src_scan) { - if (!pIccTransform) - return FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); - - uint8_t gray; - pIccModule->TranslateScanline(pIccTransform, &gray, src_scan, 1); - return gray; +uint8_t GetGray(const uint8_t* src_scan) { + return FXRGB2GRAY(src_scan[2], src_scan[1], *src_scan); } -uint8_t GetGrayWithBlend(void* pIccTransform, - CCodec_IccModule* pIccModule, - const uint8_t* src_scan, +uint8_t GetGrayWithBlend(const uint8_t* src_scan, const uint8_t* dest_scan, int blend_type) { - uint8_t gray = GetGray(pIccTransform, pIccModule, src_scan); + uint8_t gray = GetGray(src_scan); if (blend_type >= FXDIB_BLEND_NONSEPARABLE) gray = blend_type == FXDIB_BLEND_LUMINOSITY ? gray : *dest_scan; else if (blend_type) @@ -247,11 +238,7 @@ void CompositeRow_Argb2Graya(uint8_t* dest_scan, int blend_type, const uint8_t* clip_scan, const uint8_t* src_alpha_scan, - uint8_t* dst_alpha_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = nullptr; - if (pIccTransform) - pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); + uint8_t* dst_alpha_scan) { uint8_t offset = src_alpha_scan ? 3 : 4; for (int col = 0; col < pixel_count; ++col) { const uint8_t* alpha_scan = @@ -260,7 +247,7 @@ void CompositeRow_Argb2Graya(uint8_t* dest_scan, if (back_alpha == 0) { int src_alpha = GetAlpha(*alpha_scan, clip_scan, col); if (src_alpha) { - *dest_scan = GetGray(pIccTransform, pIccModule, src_scan); + *dest_scan = GetGray(src_scan); *dst_alpha_scan = src_alpha; } ++dest_scan; @@ -277,7 +264,7 @@ void CompositeRow_Argb2Graya(uint8_t* dest_scan, } *dst_alpha_scan = FXDIB_ALPHA_UNION(back_alpha, src_alpha); int alpha_ratio = src_alpha * 255 / (*dst_alpha_scan); - uint8_t gray = GetGray(pIccTransform, pIccModule, src_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 && src_alpha_scan) { if (blend_type >= FXDIB_BLEND_NONSEPARABLE) @@ -297,21 +284,15 @@ void CompositeRow_Argb2Gray(uint8_t* dest_scan, int pixel_count, int blend_type, const uint8_t* clip_scan, - const uint8_t* src_alpha_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = nullptr; + const uint8_t* src_alpha_scan) { uint8_t gray; - if (pIccTransform) - pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - uint8_t offset = src_alpha_scan ? 3 : 4; for (int col = 0; col < pixel_count; ++col) { const uint8_t* alpha_scan = src_alpha_scan ? src_alpha_scan++ : &src_scan[3]; int src_alpha = GetAlpha(*alpha_scan, clip_scan, col); if (src_alpha) { - gray = GetGrayWithBlend(pIccTransform, pIccModule, src_scan, dest_scan, - blend_type); + gray = GetGrayWithBlend(src_scan, dest_scan, blend_type); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, src_alpha); } ++dest_scan; @@ -324,15 +305,10 @@ void CompositeRow_Rgb2Gray(uint8_t* dest_scan, int src_Bpp, int pixel_count, int blend_type, - const uint8_t* clip_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = nullptr; + const uint8_t* clip_scan) { uint8_t gray; - if (pIccTransform) - pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); for (int col = 0; col < pixel_count; ++col) { - gray = GetGrayWithBlend(pIccTransform, pIccModule, src_scan, dest_scan, - blend_type); + gray = GetGrayWithBlend(src_scan, dest_scan, blend_type); if (clip_scan && clip_scan[col] < 255) *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, clip_scan[col]); else @@ -348,14 +324,10 @@ void CompositeRow_Rgb2Graya(uint8_t* dest_scan, int pixel_count, int blend_type, const uint8_t* clip_scan, - uint8_t* dest_alpha_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = nullptr; - if (pIccTransform) - pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); + uint8_t* dest_alpha_scan) { for (int col = 0; col < pixel_count; ++col) { if (blend_type && *dest_alpha_scan == 0) { - *dest_scan = GetGray(pIccTransform, pIccModule, src_scan); + *dest_scan = GetGray(src_scan); ++dest_scan; ++dest_alpha_scan; src_scan += src_Bpp; @@ -363,8 +335,7 @@ void CompositeRow_Rgb2Graya(uint8_t* dest_scan, } int src_alpha = clip_scan ? clip_scan[col] : 255; if (src_alpha == 255) { - *dest_scan = GetGrayWithBlend(pIccTransform, pIccModule, src_scan, - dest_scan, blend_type); + *dest_scan = GetGrayWithBlend(src_scan, dest_scan, blend_type); ++dest_scan; *dest_alpha_scan = 255; ++dest_alpha_scan; @@ -382,8 +353,7 @@ void CompositeRow_Rgb2Graya(uint8_t* dest_scan, *dest_alpha_scan = dest_alpha; ++dest_alpha_scan; int alpha_ratio = src_alpha * 255 / dest_alpha; - uint8_t gray = GetGrayWithBlend(pIccTransform, pIccModule, src_scan, - dest_scan, blend_type); + uint8_t gray = GetGrayWithBlend(src_scan, dest_scan, blend_type); *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, alpha_ratio); ++dest_scan; src_scan += src_Bpp; @@ -929,30 +899,20 @@ void CompositeRow_Argb2Argb_Transform(uint8_t* dest_scan, const uint8_t* clip_scan, uint8_t* dest_alpha_scan, const uint8_t* src_alpha_scan, - uint8_t* src_cache_scan, - void* pIccTransform) { + uint8_t* src_cache_scan) { uint8_t* dp = src_cache_scan; - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - if (src_alpha_scan) { - if (dest_alpha_scan) { - pIccModule->TranslateScanline(pIccTransform, dp, src_scan, pixel_count); - } else { - for (int col = 0; col < pixel_count; col++) { - pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); - dp[3] = *src_alpha_scan++; - src_scan += 3; - dp += 4; - } - src_alpha_scan = nullptr; + if (src_alpha_scan && !dest_alpha_scan) { + for (int col = 0; col < pixel_count; col++) { + dp[3] = *src_alpha_scan++; + src_scan += 3; + dp += 4; } + src_alpha_scan = nullptr; } else { if (dest_alpha_scan) { int blended_colors[3]; bool bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; for (int col = 0; col < pixel_count; col++) { - pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, - 1); uint8_t back_alpha = *dest_alpha_scan; if (back_alpha == 0) { if (clip_scan) { @@ -1009,7 +969,6 @@ void CompositeRow_Argb2Argb_Transform(uint8_t* dest_scan, return; } for (int col = 0; col < pixel_count; col++) { - pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); dp[3] = src_scan[3]; src_scan += 4; dp += 4; @@ -1025,17 +984,10 @@ void CompositeRow_Rgb2Argb_Blend_NoClip_Transform(uint8_t* dest_scan, int blend_type, int src_Bpp, uint8_t* dest_alpha_scan, - uint8_t* src_cache_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - if (src_Bpp == 3) { - pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, - width); - } else { + uint8_t* src_cache_scan) { + if (src_Bpp != 3) { uint8_t* dp = src_cache_scan; for (int col = 0; col < width; col++) { - pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); src_scan += 4; dp += 3; } @@ -1051,17 +1003,10 @@ void CompositeRow_Rgb2Argb_Blend_Clip_Transform(uint8_t* dest_scan, int src_Bpp, const uint8_t* clip_scan, uint8_t* dest_alpha_scan, - uint8_t* src_cache_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - if (src_Bpp == 3) { - pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, - width); - } else { + uint8_t* src_cache_scan) { + if (src_Bpp != 3) { uint8_t* dp = src_cache_scan; for (int col = 0; col < width; col++) { - pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); src_scan += 4; dp += 3; } @@ -1076,17 +1021,10 @@ void CompositeRow_Rgb2Argb_NoBlend_Clip_Transform(uint8_t* dest_scan, int src_Bpp, const uint8_t* clip_scan, uint8_t* dest_alpha_scan, - uint8_t* src_cache_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - if (src_Bpp == 3) { - pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, - width); - } else { + uint8_t* src_cache_scan) { + if (src_Bpp != 3) { uint8_t* dp = src_cache_scan; for (int col = 0; col < width; col++) { - pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); src_scan += 4; dp += 3; } @@ -1100,17 +1038,10 @@ void CompositeRow_Rgb2Argb_NoBlend_NoClip_Transform(uint8_t* dest_scan, int width, int src_Bpp, uint8_t* dest_alpha_scan, - uint8_t* src_cache_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - if (src_Bpp == 3) { - pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, - width); - } else { + uint8_t* src_cache_scan) { + if (src_Bpp != 3) { uint8_t* dp = src_cache_scan; for (int col = 0; col < width; col++) { - pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); src_scan += 4; dp += 3; } @@ -1126,19 +1057,12 @@ void CompositeRow_Argb2Rgb_Blend_Transform(uint8_t* dest_scan, int dest_Bpp, const uint8_t* clip_scan, const uint8_t* src_alpha_scan, - uint8_t* src_cache_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - if (src_alpha_scan) { - pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, - width); - } else { + uint8_t* src_cache_scan) { + if (!src_alpha_scan) { int blended_colors[3]; bool bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE; int dest_gap = dest_Bpp - 3; for (int col = 0; col < width; col++) { - pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, 1); uint8_t src_alpha; if (clip_scan) { src_alpha = src_scan[3] * (*clip_scan++) / 255; @@ -1177,17 +1101,10 @@ void CompositeRow_Argb2Rgb_NoBlend_Transform(uint8_t* dest_scan, int dest_Bpp, const uint8_t* clip_scan, const uint8_t* src_alpha_scan, - uint8_t* src_cache_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - if (src_alpha_scan) { - pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, - width); - } else { + uint8_t* src_cache_scan) { + if (!src_alpha_scan) { int dest_gap = dest_Bpp - 3; for (int col = 0; col < width; col++) { - pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, 1); uint8_t src_alpha; if (clip_scan) { src_alpha = src_scan[3] * (*clip_scan++) / 255; @@ -1226,17 +1143,10 @@ void CompositeRow_Rgb2Rgb_Blend_NoClip_Transform(uint8_t* dest_scan, int blend_type, int dest_Bpp, int src_Bpp, - uint8_t* src_cache_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - if (src_Bpp == 3) { - pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, - width); - } else { + uint8_t* src_cache_scan) { + if (src_Bpp != 3) { uint8_t* dp = src_cache_scan; for (int col = 0; col < width; col++) { - pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); src_scan += 4; dp += 3; } @@ -1252,17 +1162,10 @@ void CompositeRow_Rgb2Rgb_Blend_Clip_Transform(uint8_t* dest_scan, int dest_Bpp, int src_Bpp, const uint8_t* clip_scan, - uint8_t* src_cache_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - if (src_Bpp == 3) { - pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, - width); - } else { + uint8_t* src_cache_scan) { + if (src_Bpp != 3) { uint8_t* dp = src_cache_scan; for (int col = 0; col < width; col++) { - pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); src_scan += 4; dp += 3; } @@ -1276,17 +1179,10 @@ void CompositeRow_Rgb2Rgb_NoBlend_NoClip_Transform(uint8_t* dest_scan, int width, int dest_Bpp, int src_Bpp, - uint8_t* src_cache_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - if (src_Bpp == 3) { - pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, - width); - } else { + uint8_t* src_cache_scan) { + if (src_Bpp != 3) { uint8_t* dp = src_cache_scan; for (int col = 0; col < width; col++) { - pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); src_scan += 4; dp += 3; } @@ -1301,17 +1197,10 @@ void CompositeRow_Rgb2Rgb_NoBlend_Clip_Transform(uint8_t* dest_scan, int dest_Bpp, int src_Bpp, const uint8_t* clip_scan, - uint8_t* src_cache_scan, - void* pIccTransform) { - CCodec_IccModule* pIccModule = - CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - if (src_Bpp == 3) { - pIccModule->TranslateScanline(pIccTransform, src_cache_scan, src_scan, - width); - } else { + uint8_t* src_cache_scan) { + if (src_Bpp != 3) { uint8_t* dp = src_cache_scan; for (int col = 0; col < width; col++) { - pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1); src_scan += 4; dp += 3; } @@ -3249,9 +3138,7 @@ bool ScanlineCompositor_InitSourceMask(FXDIB_Format dest_format, int& mask_red, int& mask_green, int& mask_blue, - int& mask_black, - CCodec_IccModule* pIccModule, - void* pIccTransform) { + int& mask_black) { if (alpha_flag >> 8) { mask_alpha = alpha_flag & 0xff; mask_red = FXSYS_GetCValue(mask_color); @@ -3268,36 +3155,20 @@ bool ScanlineCompositor_InitSourceMask(FXDIB_Format dest_format, return true; } if ((dest_format & 0xff) == 8) { - if (pIccTransform) { - mask_color = (alpha_flag >> 8) ? FXCMYK_TODIB(mask_color) - : FXARGB_TODIB(mask_color); - uint8_t* gray_p = (uint8_t*)&mask_color; - pIccModule->TranslateScanline(pIccTransform, gray_p, gray_p, 1); - mask_red = dest_format & 0x0400 ? FX_CCOLOR(gray_p[0]) : gray_p[0]; + if (alpha_flag >> 8) { + uint8_t r, g, b; + AdobeCMYK_to_sRGB1(mask_red, mask_green, mask_blue, mask_black, r, g, b); + mask_red = FXRGB2GRAY(r, g, b); } else { - if (alpha_flag >> 8) { - uint8_t r, g, b; - AdobeCMYK_to_sRGB1(mask_red, mask_green, mask_blue, mask_black, r, g, - b); - mask_red = FXRGB2GRAY(r, g, b); - } else { - mask_red = FXRGB2GRAY(mask_red, mask_green, mask_blue); - } - if (dest_format & 0x0400) { - mask_red = FX_CCOLOR(mask_red); - } + mask_red = FXRGB2GRAY(mask_red, mask_green, mask_blue); } + if (dest_format & 0x0400) + mask_red = FX_CCOLOR(mask_red); } else { uint8_t* mask_color_p = (uint8_t*)&mask_color; mask_color = (alpha_flag >> 8) ? FXCMYK_TODIB(mask_color) : FXARGB_TODIB(mask_color); - if (pIccTransform) { - pIccModule->TranslateScanline(pIccTransform, mask_color_p, mask_color_p, - 1); - mask_red = mask_color_p[2]; - mask_green = mask_color_p[1]; - mask_blue = mask_color_p[0]; - } else if (alpha_flag >> 8) { + if (alpha_flag >> 8) { AdobeCMYK_to_sRGB1(mask_color_p[0], mask_color_p[1], mask_color_p[2], mask_color_p[3], mask_color_p[2], mask_color_p[1], mask_color_p[0]); @@ -3312,38 +3183,49 @@ bool ScanlineCompositor_InitSourceMask(FXDIB_Format dest_format, void ScanlineCompositor_InitSourcePalette(FXDIB_Format src_format, FXDIB_Format dest_format, uint32_t*& pDestPalette, - uint32_t* pSrcPalette, - CCodec_IccModule* pIccModule, - void* pIccTransform) { + uint32_t* pSrcPalette) { bool isSrcCmyk = !!(src_format & 0x0400); bool isDstCmyk = !!(dest_format & 0x0400); pDestPalette = nullptr; - if (pIccTransform) { - if (pSrcPalette) { - if ((dest_format & 0xff) == 8) { - int pal_count = 1 << (src_format & 0xff); - uint8_t* gray_pal = FX_Alloc(uint8_t, pal_count); - pDestPalette = (uint32_t*)gray_pal; + if (pSrcPalette) { + if ((dest_format & 0xff) == 8) { + int pal_count = 1 << (src_format & 0xff); + uint8_t* gray_pal = FX_Alloc(uint8_t, pal_count); + pDestPalette = (uint32_t*)gray_pal; + if (isSrcCmyk) { for (int i = 0; i < pal_count; i++) { - uint32_t color = isSrcCmyk ? FXCMYK_TODIB(pSrcPalette[i]) - : FXARGB_TODIB(pSrcPalette[i]); - pIccModule->TranslateScanline(pIccTransform, gray_pal, - (const uint8_t*)&color, 1); - gray_pal++; + FX_CMYK cmyk = pSrcPalette[i]; + uint8_t r, g, b; + AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), + FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g, + b); + *gray_pal++ = FXRGB2GRAY(r, g, b); } } else { - int palsize = 1 << (src_format & 0xff); - pDestPalette = FX_Alloc(uint32_t, palsize); - for (int i = 0; i < palsize; i++) { - uint32_t color = isSrcCmyk ? FXCMYK_TODIB(pSrcPalette[i]) - : FXARGB_TODIB(pSrcPalette[i]); - pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&color, - (const uint8_t*)&color, 1); - pDestPalette[i] = - isDstCmyk ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); + for (int i = 0; i < pal_count; i++) { + FX_ARGB argb = pSrcPalette[i]; + *gray_pal++ = + FXRGB2GRAY(FXARGB_R(argb), FXARGB_G(argb), FXARGB_B(argb)); } } } else { + int palsize = 1 << (src_format & 0xff); + pDestPalette = FX_Alloc(uint32_t, palsize); + if (isDstCmyk == isSrcCmyk) { + memcpy(pDestPalette, pSrcPalette, palsize * sizeof(uint32_t)); + } else { + for (int i = 0; i < palsize; i++) { + FX_CMYK cmyk = pSrcPalette[i]; + uint8_t r, g, b; + AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), + FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g, + b); + pDestPalette[i] = FXARGB_MAKE(0xff, r, g, b); + } + } + } + } else { + if ((dest_format & 0xff) == 8) { int pal_count = 1 << (src_format & 0xff); uint8_t* gray_pal = FX_Alloc(uint8_t, pal_count); if (pal_count == 2) { @@ -3354,92 +3236,26 @@ void ScanlineCompositor_InitSourcePalette(FXDIB_Format src_format, gray_pal[i] = i; } } - if ((dest_format & 0xff) == 8) { - pIccModule->TranslateScanline(pIccTransform, gray_pal, gray_pal, - pal_count); - pDestPalette = (uint32_t*)gray_pal; - } else { - pDestPalette = FX_Alloc(uint32_t, pal_count); - for (int i = 0; i < pal_count; i++) { - pIccModule->TranslateScanline( - pIccTransform, (uint8_t*)&pDestPalette[i], &gray_pal[i], 1); - pDestPalette[i] = isDstCmyk ? FXCMYK_TODIB(pDestPalette[i]) - : FXARGB_TODIB(pDestPalette[i]); - } - FX_Free(gray_pal); - } - } - } else { - if (pSrcPalette) { - if ((dest_format & 0xff) == 8) { - int pal_count = 1 << (src_format & 0xff); - uint8_t* gray_pal = FX_Alloc(uint8_t, pal_count); - pDestPalette = (uint32_t*)gray_pal; - if (isSrcCmyk) { - for (int i = 0; i < pal_count; i++) { - FX_CMYK cmyk = pSrcPalette[i]; - uint8_t r, g, b; - AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), - FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, - g, b); - *gray_pal++ = FXRGB2GRAY(r, g, b); - } - } else { - for (int i = 0; i < pal_count; i++) { - FX_ARGB argb = pSrcPalette[i]; - *gray_pal++ = - FXRGB2GRAY(FXARGB_R(argb), FXARGB_G(argb), FXARGB_B(argb)); - } - } - } else { - int palsize = 1 << (src_format & 0xff); - pDestPalette = FX_Alloc(uint32_t, palsize); - if (isDstCmyk == isSrcCmyk) { - memcpy(pDestPalette, pSrcPalette, palsize * sizeof(uint32_t)); - } else { - for (int i = 0; i < palsize; i++) { - FX_CMYK cmyk = pSrcPalette[i]; - uint8_t r, g, b; - AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), - FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, - g, b); - pDestPalette[i] = FXARGB_MAKE(0xff, r, g, b); - } - } - } + pDestPalette = (uint32_t*)gray_pal; } else { - if ((dest_format & 0xff) == 8) { - int pal_count = 1 << (src_format & 0xff); - uint8_t* gray_pal = FX_Alloc(uint8_t, pal_count); - if (pal_count == 2) { - gray_pal[0] = 0; - gray_pal[1] = 255; - } else { - for (int i = 0; i < pal_count; i++) { - gray_pal[i] = i; - } - } - pDestPalette = (uint32_t*)gray_pal; + int palsize = 1 << (src_format & 0xff); + pDestPalette = FX_Alloc(uint32_t, palsize); + if (palsize == 2) { + pDestPalette[0] = isSrcCmyk ? 255 : 0xff000000; + pDestPalette[1] = isSrcCmyk ? 0 : 0xffffffff; } else { - int palsize = 1 << (src_format & 0xff); - pDestPalette = FX_Alloc(uint32_t, palsize); - if (palsize == 2) { - pDestPalette[0] = isSrcCmyk ? 255 : 0xff000000; - pDestPalette[1] = isSrcCmyk ? 0 : 0xffffffff; - } else { - for (int i = 0; i < palsize; i++) { - pDestPalette[i] = isSrcCmyk ? FX_CCOLOR(i) : (i * 0x10101); - } + for (int i = 0; i < palsize; i++) { + pDestPalette[i] = isSrcCmyk ? FX_CCOLOR(i) : (i * 0x10101); } - if (isSrcCmyk != isDstCmyk) { - for (int i = 0; i < palsize; i++) { - FX_CMYK cmyk = pDestPalette[i]; - uint8_t r, g, b; - AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), - FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, - g, b); - pDestPalette[i] = FXARGB_MAKE(0xff, r, g, b); - } + } + if (isSrcCmyk != isDstCmyk) { + for (int i = 0; i < palsize; i++) { + FX_CMYK cmyk = pDestPalette[i]; + uint8_t r, g, b; + AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), + FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g, + b); + pDestPalette[i] = FXARGB_MAKE(0xff, r, g, b); } } } @@ -3454,7 +3270,6 @@ CFX_ScanlineCompositor::CFX_ScanlineCompositor() { m_CacheSize = 0; m_bRgbByteOrder = false; m_BlendType = FXDIB_BLEND_NORMAL; - m_pIccTransform = nullptr; } CFX_ScanlineCompositor::~CFX_ScanlineCompositor() { @@ -3470,48 +3285,35 @@ bool CFX_ScanlineCompositor::Init(FXDIB_Format dest_format, int blend_type, bool bClip, bool bRgbByteOrder, - int alpha_flag, - void* pIccTransform) { + int alpha_flag) { m_SrcFormat = src_format; m_DestFormat = dest_format; m_BlendType = blend_type; m_bRgbByteOrder = bRgbByteOrder; - CCodec_IccModule* pIccModule = nullptr; - if (CFX_GEModule::Get()->GetCodecModule()) { - pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); - } - if (!pIccModule) { - pIccTransform = nullptr; - } - m_pIccTransform = pIccTransform; - if ((dest_format & 0xff) == 1) { + if ((dest_format & 0xff) == 1) return false; - } if (m_SrcFormat == FXDIB_1bppMask || m_SrcFormat == FXDIB_8bppMask) { return ScanlineCompositor_InitSourceMask( dest_format, alpha_flag, mask_color, m_MaskAlpha, m_MaskRed, - m_MaskGreen, m_MaskBlue, m_MaskBlack, pIccModule, pIccTransform); + m_MaskGreen, m_MaskBlue, m_MaskBlack); } - if (!pIccTransform && (~src_format & 0x0400) && (dest_format & 0x0400)) { + if ((~src_format & 0x0400) && (dest_format & 0x0400)) return false; - } if ((m_SrcFormat & 0xff) <= 8) { - if (dest_format == FXDIB_8bppMask) { + if (dest_format == FXDIB_8bppMask) return true; - } + ScanlineCompositor_InitSourcePalette(src_format, dest_format, m_pSrcPalette, - pSrcPalette, pIccModule, - pIccTransform); + pSrcPalette); m_Transparency = (dest_format == FXDIB_Argb ? 1 : 0) + (dest_format & 0x0200 ? 2 : 0) + (dest_format & 0x0400 ? 4 : 0) + ((src_format & 0xff) == 1 ? 8 : 0); return true; } - m_Transparency = (src_format & 0x0200 ? 0 : 1) + - (dest_format & 0x0200 ? 0 : 2) + - (blend_type == FXDIB_BLEND_NORMAL ? 4 : 0) + - (bClip ? 8 : 0) + (src_format & 0x0400 ? 16 : 0) + - (dest_format & 0x0400 ? 32 : 0) + (pIccTransform ? 64 : 0); + m_Transparency = + (src_format & 0x0200 ? 0 : 1) + (dest_format & 0x0200 ? 0 : 2) + + (blend_type == FXDIB_BLEND_NORMAL ? 4 : 0) + (bClip ? 8 : 0) + + (src_format & 0x0400 ? 16 : 0) + (dest_format & 0x0400 ? 32 : 0); return true; } @@ -3600,19 +3402,18 @@ void CFX_ScanlineCompositor::CompositeRgbBitmapLine( if (m_SrcFormat & 0x0200) { if (m_DestFormat & 0x0200) { CompositeRow_Argb2Graya(dest_scan, src_scan, width, m_BlendType, - clip_scan, src_extra_alpha, dst_extra_alpha, - m_pIccTransform); + clip_scan, src_extra_alpha, dst_extra_alpha); } else { CompositeRow_Argb2Gray(dest_scan, src_scan, width, m_BlendType, - clip_scan, src_extra_alpha, m_pIccTransform); + clip_scan, src_extra_alpha); } } else { if (m_DestFormat & 0x0200) { CompositeRow_Rgb2Graya(dest_scan, src_scan, src_Bpp, width, m_BlendType, - clip_scan, dst_extra_alpha, m_pIccTransform); + clip_scan, dst_extra_alpha); } else { CompositeRow_Rgb2Gray(dest_scan, src_scan, src_Bpp, width, m_BlendType, - clip_scan, m_pIccTransform); + clip_scan); } } if (m_DestFormat & 0x0400) { @@ -3644,7 +3445,7 @@ void CFX_ScanlineCompositor::CompositeRgbBitmapLine( case 4 + 8 + 64: { CompositeRow_Argb2Argb_Transform( dest_scan, src_scan, width, m_BlendType, clip_scan, dst_extra_alpha, - src_extra_alpha, m_pCacheScanline, m_pIccTransform); + src_extra_alpha, m_pCacheScanline); } break; case 1: CompositeRow_Rgb2Argb_Blend_NoClip( @@ -3653,7 +3454,7 @@ void CFX_ScanlineCompositor::CompositeRgbBitmapLine( case 1 + 64: CompositeRow_Rgb2Argb_Blend_NoClip_Transform( dest_scan, src_scan, width, m_BlendType, src_Bpp, dst_extra_alpha, - m_pCacheScanline, m_pIccTransform); + m_pCacheScanline); break; case 1 + 8: CompositeRow_Rgb2Argb_Blend_Clip(dest_scan, src_scan, width, @@ -3663,7 +3464,7 @@ void CFX_ScanlineCompositor::CompositeRgbBitmapLine( case 1 + 8 + 64: CompositeRow_Rgb2Argb_Blend_Clip_Transform( dest_scan, src_scan, width, m_BlendType, src_Bpp, clip_scan, - dst_extra_alpha, m_pCacheScanline, m_pIccTransform); + dst_extra_alpha, m_pCacheScanline); break; case 1 + 4: CompositeRow_Rgb2Argb_NoBlend_NoClip(dest_scan, src_scan, width, @@ -3672,7 +3473,7 @@ void CFX_ScanlineCompositor::CompositeRgbBitmapLine( case 1 + 4 + 64: CompositeRow_Rgb2Argb_NoBlend_NoClip_Transform( dest_scan, src_scan, width, src_Bpp, dst_extra_alpha, - m_pCacheScanline, m_pIccTransform); + m_pCacheScanline); break; case 1 + 4 + 8: CompositeRow_Rgb2Argb_NoBlend_Clip(dest_scan, src_scan, width, src_Bpp, @@ -3681,7 +3482,7 @@ void CFX_ScanlineCompositor::CompositeRgbBitmapLine( case 1 + 4 + 8 + 64: CompositeRow_Rgb2Argb_NoBlend_Clip_Transform( dest_scan, src_scan, width, src_Bpp, clip_scan, dst_extra_alpha, - m_pCacheScanline, m_pIccTransform); + m_pCacheScanline); break; case 2: case 2 + 8: @@ -3692,7 +3493,7 @@ void CFX_ScanlineCompositor::CompositeRgbBitmapLine( case 2 + 8 + 64: CompositeRow_Argb2Rgb_Blend_Transform( dest_scan, src_scan, width, m_BlendType, dest_Bpp, clip_scan, - src_extra_alpha, m_pCacheScanline, m_pIccTransform); + src_extra_alpha, m_pCacheScanline); break; case 2 + 4: case 2 + 4 + 8: @@ -3703,16 +3504,16 @@ void CFX_ScanlineCompositor::CompositeRgbBitmapLine( case 2 + 4 + 8 + 64: CompositeRow_Argb2Rgb_NoBlend_Transform( dest_scan, src_scan, width, dest_Bpp, clip_scan, src_extra_alpha, - m_pCacheScanline, m_pIccTransform); + m_pCacheScanline); break; case 1 + 2: CompositeRow_Rgb2Rgb_Blend_NoClip(dest_scan, src_scan, width, m_BlendType, dest_Bpp, src_Bpp); break; case 1 + 2 + 64: - CompositeRow_Rgb2Rgb_Blend_NoClip_Transform( - dest_scan, src_scan, width, m_BlendType, dest_Bpp, src_Bpp, - m_pCacheScanline, m_pIccTransform); + CompositeRow_Rgb2Rgb_Blend_NoClip_Transform(dest_scan, src_scan, width, + m_BlendType, dest_Bpp, + src_Bpp, m_pCacheScanline); break; case 1 + 2 + 8: CompositeRow_Rgb2Rgb_Blend_Clip(dest_scan, src_scan, width, m_BlendType, @@ -3721,7 +3522,7 @@ void CFX_ScanlineCompositor::CompositeRgbBitmapLine( case 1 + 2 + 8 + 64: CompositeRow_Rgb2Rgb_Blend_Clip_Transform( dest_scan, src_scan, width, m_BlendType, dest_Bpp, src_Bpp, - clip_scan, m_pCacheScanline, m_pIccTransform); + clip_scan, m_pCacheScanline); break; case 1 + 2 + 4: CompositeRow_Rgb2Rgb_NoBlend_NoClip(dest_scan, src_scan, width, @@ -3729,8 +3530,7 @@ void CFX_ScanlineCompositor::CompositeRgbBitmapLine( break; case 1 + 2 + 4 + 64: CompositeRow_Rgb2Rgb_NoBlend_NoClip_Transform( - dest_scan, src_scan, width, dest_Bpp, src_Bpp, m_pCacheScanline, - m_pIccTransform); + dest_scan, src_scan, width, dest_Bpp, src_Bpp, m_pCacheScanline); break; case 1 + 2 + 4 + 8: CompositeRow_Rgb2Rgb_NoBlend_Clip(dest_scan, src_scan, width, dest_Bpp, @@ -3739,7 +3539,7 @@ void CFX_ScanlineCompositor::CompositeRgbBitmapLine( case 1 + 2 + 4 + 8 + 64: CompositeRow_Rgb2Rgb_NoBlend_Clip_Transform( dest_scan, src_scan, width, dest_Bpp, src_Bpp, clip_scan, - m_pCacheScanline, m_pIccTransform); + m_pCacheScanline); break; } } diff --git a/core/fxge/dib/cfx_scanlinecompositor.h b/core/fxge/dib/cfx_scanlinecompositor.h index 2401bc5da8..a933a89b46 100644 --- a/core/fxge/dib/cfx_scanlinecompositor.h +++ b/core/fxge/dib/cfx_scanlinecompositor.h @@ -23,8 +23,7 @@ class CFX_ScanlineCompositor { int blend_type, bool bClip, bool bRgbByteOrder = false, - int alpha_flag = 0, - void* pIccTransform = nullptr); + int alpha_flag = 0); void CompositeRgbBitmapLine(uint8_t* dest_scan, const uint8_t* src_scan, @@ -65,7 +64,6 @@ class CFX_ScanlineCompositor { int m_MaskBlue; int m_MaskBlack; int m_BlendType; - void* m_pIccTransform; uint8_t* m_pCacheScanline; int m_CacheSize; bool m_bRgbByteOrder; diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp index b100f4d2f9..46127ccb07 100644 --- a/core/fxge/ge/cfx_renderdevice.cpp +++ b/core/fxge/ge/cfx_renderdevice.cpp @@ -673,7 +673,7 @@ bool CFX_RenderDevice::FillRectWithBlend(const FX_RECT* pRect, return false; if (!bitmap->CompositeRect(0, 0, pRect->Width(), pRect->Height(), fill_color, - 0, nullptr)) { + 0)) { return false; } FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height()); @@ -755,7 +755,7 @@ bool CFX_RenderDevice::SetDIBitsWithBlend( } if (!background->CompositeBitmap(0, 0, bg_pixel_width, bg_pixel_height, pBitmap, src_rect.left, src_rect.top, - blend_mode, nullptr, false, nullptr)) { + blend_mode, nullptr, false)) { return false; } FX_RECT rect(0, 0, bg_pixel_width, bg_pixel_height); @@ -1042,8 +1042,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, - nullptr)) { + FXDIB_BLEND_NORMAL, nullptr, false, 0)) { return false; } continue; diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index 429510d30e..c9bc6f472f 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -1891,14 +1891,14 @@ bool CFX_SkiaDeviceDriver::SetDIBits( #ifdef _SKIA_SUPPORT_PATHS_ Flush(); if (pBitmap->IsAlphaMask()) { - return m_pBitmap->CompositeMask( - left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, argb, - pSrcRect->left, pSrcRect->top, blend_type, m_pClipRgn.get(), - m_bRgbByteOrder, 0, nullptr); + return m_pBitmap->CompositeMask(left, top, pSrcRect->Width(), + pSrcRect->Height(), pBitmap, argb, + pSrcRect->left, pSrcRect->top, blend_type, + m_pClipRgn.get(), m_bRgbByteOrder, 0); } return m_pBitmap->CompositeBitmap( left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, pSrcRect->left, - pSrcRect->top, blend_type, m_pClipRgn.get(), m_bRgbByteOrder, nullptr); + pSrcRect->top, blend_type, m_pClipRgn.get(), m_bRgbByteOrder); #endif // _SKIA_SUPPORT_PATHS_ } @@ -1944,7 +1944,7 @@ bool CFX_SkiaDeviceDriver::StretchDIBits( dest_clip.Intersect(*pClipRect); CFX_BitmapComposer composer; composer.Compose(m_pBitmap, m_pClipRgn.get(), 255, argb, dest_clip, false, - false, false, m_bRgbByteOrder, 0, nullptr, blend_type); + false, false, m_bRgbByteOrder, 0, blend_type); dest_clip.Offset(-dest_rect.left, -dest_rect.top); CFX_ImageStretcher stretcher(&composer, pSource, dest_width, dest_height, dest_clip, flags); @@ -2011,7 +2011,7 @@ bool CFX_SkiaDeviceDriver::StartDIBits( m_pBitmap->UnPreMultiply(); *handle = pdfium::MakeUnique<CFX_ImageRenderer>(); (*handle)->Start(m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb, - pMatrix, render_flags, m_bRgbByteOrder, 0, nullptr); + pMatrix, render_flags, m_bRgbByteOrder); #endif // _SKIA_SUPPORT_PATHS_ return true; } diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index d4abcbe251..39533e1ef6 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -1224,8 +1224,7 @@ bool CGdiDisplayDriver::SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& 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, - nullptr)) { + FXDIB_BLEND_NORMAL, nullptr, false, 0)) { return false; } FX_RECT src_rect(0, 0, width, height); @@ -1244,7 +1243,7 @@ bool CGdiDisplayDriver::SetDIBits(const CFX_RetainPtr<CFX_DIBSource>& pSource, !GetDIBits(bitmap, left, top) || !bitmap->CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, pSrcRect->top, FXDIB_BLEND_NORMAL, nullptr, - false, nullptr)) { + false)) { return false; } FX_RECT src_rect(0, 0, width, height); @@ -1321,7 +1320,7 @@ bool CGdiDisplayDriver::StretchDIBits( image_rect.top + clip_rect.top) || !background->CompositeMask(0, 0, clip_width, clip_height, pStretched, color, 0, 0, FXDIB_BLEND_NORMAL, nullptr, - false, 0, nullptr)) { + false, 0)) { return false; } |