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/fpdfapi/render | |
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/fpdfapi/render')
-rw-r--r-- | core/fpdfapi/render/cpdf_devicebuffer.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_imagerenderer.cpp | 12 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_imagerenderer.h | 7 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 33 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.h | 5 |
5 files changed, 31 insertions, 28 deletions
diff --git a/core/fpdfapi/render/cpdf_devicebuffer.cpp b/core/fpdfapi/render/cpdf_devicebuffer.cpp index b29db0054b..4029f2efc2 100644 --- a/core/fpdfapi/render/cpdf_devicebuffer.cpp +++ b/core/fpdfapi/render/cpdf_devicebuffer.cpp @@ -64,7 +64,7 @@ void CPDF_DeviceBuffer::OutputToDevice() { m_pBitmap->GetHeight()); m_pContext->GetBackground(pBuffer, m_pObject.Get(), nullptr, &m_Matrix); pBuffer->CompositeBitmap(0, 0, pBuffer->GetWidth(), pBuffer->GetHeight(), - m_pBitmap, 0, 0, FXDIB_BLEND_NORMAL, nullptr, false); + m_pBitmap, 0, 0, BlendMode::kNormal, nullptr, false); m_pDevice->StretchDIBits(pBuffer, m_Rect.left, m_Rect.top, m_Rect.Width(), m_Rect.Height()); } diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index 362cf558f7..03e00a2554 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -118,7 +118,7 @@ bool CPDF_ImageRenderer::StartRenderDIBBase() { return DrawPatternImage(m_pObj2Device.Get()); if (m_BitmapAlpha != 255 || !state.HasRef() || !state.GetFillOP() || - state.GetOPMode() != 0 || state.GetBlendType() != FXDIB_BLEND_NORMAL || + state.GetOPMode() != 0 || state.GetBlendType() != BlendMode::kNormal || state.GetStrokeAlpha() != 1.0f || state.GetFillAlpha() != 1.0f) { return StartDIBBase(); } @@ -142,7 +142,7 @@ bool CPDF_ImageRenderer::StartRenderDIBBase() { int format = pColorSpace->GetFamily(); if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || format == PDFCS_DEVICEN) { - m_BlendType = FXDIB_BLEND_DARKEN; + m_BlendType = BlendMode::kDarken; } pDocument->GetPageData()->ReleaseColorSpace(pCSObj); return StartDIBBase(); @@ -152,7 +152,7 @@ bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, CPDF_ImageObject* pImageObject, const CFX_Matrix* pObj2Device, bool bStdCS, - int blendType) { + BlendMode blendType) { ASSERT(pImageObject); m_pRenderStatus = pStatus; m_bStdCS = bStdCS; @@ -178,7 +178,7 @@ bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, const CFX_Matrix* pImage2Device, uint32_t flags, bool bStdCS, - int blendType) { + BlendMode blendType) { m_pRenderStatus = pStatus; m_pDIBBase = pDIBBase; m_FillArgb = bitmap_argb; @@ -222,7 +222,7 @@ void CPDF_ImageRenderer::CalculateDrawImage( CPDF_ImageRenderer image_render; if (image_render.Start(&bitmap_render, pDIBBase, 0xffffffff, 255, pNewMatrix, - m_Flags, true, FXDIB_BLEND_NORMAL)) { + m_Flags, true, BlendMode::kNormal)) { image_render.Continue(nullptr); } if (m_Loader.MatteColor() == 0xffffffff) @@ -333,7 +333,7 @@ bool CPDF_ImageRenderer::DrawMaskedImage() { bitmap_render.Initialize(nullptr, nullptr); CPDF_ImageRenderer image_render; if (image_render.Start(&bitmap_render, m_pDIBBase, 0, 255, &new_matrix, - m_Flags, true, FXDIB_BLEND_NORMAL)) { + m_Flags, true, BlendMode::kNormal)) { image_render.Continue(nullptr); } CFX_DefaultRenderDevice bitmap_device2; diff --git a/core/fpdfapi/render/cpdf_imagerenderer.h b/core/fpdfapi/render/cpdf_imagerenderer.h index c538d9f5f2..6df412f2c0 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.h +++ b/core/fpdfapi/render/cpdf_imagerenderer.h @@ -13,6 +13,7 @@ #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/unowned_ptr.h" #include "core/fxge/dib/cfx_imagerenderer.h" +#include "core/fxge/fx_dib.h" class CFX_DIBitmap; class CFX_DIBBase; @@ -33,7 +34,7 @@ class CPDF_ImageRenderer { CPDF_ImageObject* pImageObject, const CFX_Matrix* pObj2Device, bool bStdCS, - int blendType); + BlendMode blendType); bool Start(CPDF_RenderStatus* pStatus, const RetainPtr<CFX_DIBBase>& pDIBBase, @@ -42,7 +43,7 @@ class CPDF_ImageRenderer { const CFX_Matrix* pImage2Device, uint32_t flags, bool bStdCS, - int blendType); + BlendMode blendType); bool Continue(PauseIndicatorIface* pPause); bool GetResult() const { return m_Result; } @@ -76,7 +77,7 @@ class CPDF_ImageRenderer { std::unique_ptr<CFX_ImageRenderer> m_DeviceHandle; int m_Status = 0; int m_BitmapAlpha = 0; - int m_BlendType = FXDIB_BLEND_NORMAL; + BlendMode m_BlendType = BlendMode::kNormal; FX_ARGB m_FillArgb = 0; uint32_t m_Flags = 0; bool m_bPatternColor = false; diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 4e9c69b870..b409203a54 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -1110,7 +1110,7 @@ bool CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj, m_pImageRenderer = pdfium::MakeUnique<CPDF_ImageRenderer>(); if (!m_pImageRenderer->Start(this, pObj->AsImage(), &mtObj2Device, false, - FXDIB_BLEND_NORMAL)) { + BlendMode::kNormal)) { if (!m_pImageRenderer->GetResult()) DrawObjWithBackground(pObj, mtObj2Device); m_pImageRenderer.reset(); @@ -1437,7 +1437,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, #if defined _SKIA_SUPPORT_ DebugVerifyDeviceIsPreMultiplied(); #endif - int blend_type = pPageObj->m_GeneralState.GetBlendType(); + BlendMode blend_type = pPageObj->m_GeneralState.GetBlendType(); CPDF_Dictionary* pSMaskDict = ToDictionary(pPageObj->m_GeneralState.GetSoftMask()); if (pSMaskDict) { @@ -1488,12 +1488,12 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, int format = pColorSpace->GetFamily(); if (format == PDFCS_DEVICECMYK || format == PDFCS_SEPARATION || format == PDFCS_DEVICEN) { - blend_type = FXDIB_BLEND_DARKEN; + blend_type = BlendMode::kDarken; } pDocument->GetPageData()->ReleaseColorSpace(pCSObj); } } - if (!pSMaskDict && group_alpha == 1.0f && blend_type == FXDIB_BLEND_NORMAL && + if (!pSMaskDict && group_alpha == 1.0f && blend_type == BlendMode::kNormal && !bTextClip && !bGroupTransparent) { return false; } @@ -1502,7 +1502,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, int rendCaps = m_pDevice->GetRenderCaps(); if (!(transparency.IsIsolated() || pSMaskDict || bTextClip) && (rendCaps & FXRC_BLEND_MODE)) { - int oldBlend = m_curBlend; + BlendMode oldBlend = m_curBlend; m_curBlend = blend_type; bRet = DrawObjWithBlend(pPageObj, mtObj2Device); m_curBlend = oldBlend; @@ -1910,7 +1910,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, image_matrix.Concat(matrix); CPDF_ImageRenderer renderer; if (renderer.Start(this, pType3Char->GetBitmap(), fill_argb, 255, - &image_matrix, 0, false, FXDIB_BLEND_NORMAL)) { + &image_matrix, 0, false, BlendMode::kNormal)) { renderer.Continue(nullptr); } if (!renderer.GetResult()) @@ -1948,7 +1948,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, glyph.m_pGlyph->m_pBitmap->GetWidth(), glyph.m_pGlyph->m_pBitmap->GetHeight(), glyph.m_pGlyph->m_pBitmap, fill_argb, 0, 0, - FXDIB_BLEND_NORMAL, nullptr, false, 0); + BlendMode::kNormal, nullptr, false, 0); } m_pDevice->SetBitMask(pBitmap, rect.left, rect.top, fill_argb); return true; @@ -2315,18 +2315,18 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, } else { if (pPattern->colored()) { pScreen->CompositeBitmap(start_x, start_y, width, height, - pPatternBitmap, 0, 0, FXDIB_BLEND_NORMAL, + pPatternBitmap, 0, 0, BlendMode::kNormal, nullptr, false); } else { pScreen->CompositeMask(start_x, start_y, width, height, pPatternBitmap, fill_argb, 0, 0, - FXDIB_BLEND_NORMAL, nullptr, false, 0); + BlendMode::kNormal, nullptr, false, 0); } } } } CompositeDIBitmap(pScreen, clip_box.left, clip_box.top, 0, 255, - FXDIB_BLEND_NORMAL, CPDF_Transparency()); + BlendMode::kNormal, CPDF_Transparency()); } void CPDF_RenderStatus::DrawPathWithPattern(CPDF_PathObject* pPathObj, @@ -2380,12 +2380,12 @@ void CPDF_RenderStatus::CompositeDIBitmap( int top, FX_ARGB mask_argb, int bitmap_alpha, - int blend_mode, + BlendMode blend_mode, const CPDF_Transparency& transparency) { if (!pDIBitmap) return; - if (blend_mode == FXDIB_BLEND_NORMAL) { + if (blend_mode == BlendMode::kNormal) { if (!pDIBitmap->IsAlphaMask()) { if (bitmap_alpha < 255) { #ifdef _SKIA_SUPPORT_ @@ -2416,7 +2416,8 @@ void CPDF_RenderStatus::CompositeDIBitmap( } } bool bIsolated = transparency.IsIsolated(); - bool bBackAlphaRequired = blend_mode && bIsolated && !m_bDropObjects; + bool bBackAlphaRequired = + blend_mode != BlendMode::kNormal && bIsolated && !m_bDropObjects; bool bGetBackGround = ((m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT)) || (!(m_pDevice->GetRenderCaps() & FXRC_ALPHA_OUTPUT) && @@ -2440,7 +2441,7 @@ void CPDF_RenderStatus::CompositeDIBitmap( RetainPtr<CFX_DIBitmap> pForeBitmap = m_pDevice->GetBitmap(); pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), pForeBitmap, rect.left, rect.top, - FXDIB_BLEND_NORMAL, nullptr, false); + BlendMode::kNormal, nullptr, false); left = std::min(left, 0); top = std::min(top, 0); if (pDIBitmap->IsAlphaMask()) { @@ -2470,7 +2471,7 @@ void CPDF_RenderStatus::CompositeDIBitmap( FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), top + pDIBitmap->GetHeight()); RetainPtr<CFX_DIBitmap> pBackdrop = GetBackdrop( - m_pCurObj.Get(), rect, blend_mode > FXDIB_BLEND_NORMAL && bIsolated, + m_pCurObj.Get(), rect, blend_mode != BlendMode::kNormal && bIsolated, &back_left, &back_top); if (!pBackdrop) return; @@ -2492,7 +2493,7 @@ void CPDF_RenderStatus::CompositeDIBitmap( pBackdrop1->Clear((uint32_t)-1); pBackdrop1->CompositeBitmap(0, 0, pBackdrop->GetWidth(), pBackdrop->GetHeight(), pBackdrop, 0, 0, - FXDIB_BLEND_NORMAL, nullptr, false); + BlendMode::kNormal, nullptr, false); pBackdrop = std::move(pBackdrop1); m_pDevice->SetDIBits(pBackdrop, back_left, back_top); } diff --git a/core/fpdfapi/render/cpdf_renderstatus.h b/core/fpdfapi/render/cpdf_renderstatus.h index a4f3fd4d75..1911758a2e 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.h +++ b/core/fpdfapi/render/cpdf_renderstatus.h @@ -16,6 +16,7 @@ #include "core/fpdfapi/render/cpdf_renderoptions.h" #include "core/fxcrt/unowned_ptr.h" #include "core/fxge/cfx_renderdevice.h" +#include "core/fxge/fx_dib.h" class CFX_PathData; class CPDF_Color; @@ -111,7 +112,7 @@ class CPDF_RenderStatus { int top, FX_ARGB mask_argb, int bitmap_alpha, - int blend_mode, + BlendMode blend_mode, const CPDF_Transparency& transparency); private: @@ -202,7 +203,7 @@ class CPDF_RenderStatus { uint32_t m_GroupFamily = 0; UnownedPtr<CPDF_Type3Char> m_pType3Char; FX_ARGB m_T3FillColor = 0; - int m_curBlend = FXDIB_BLEND_NORMAL; + BlendMode m_curBlend = BlendMode::kNormal; }; #endif // CORE_FPDFAPI_RENDER_CPDF_RENDERSTATUS_H_ |