diff options
Diffstat (limited to 'core/fpdfapi/render')
-rw-r--r-- | core/fpdfapi/render/cpdf_imagerenderer.cpp | 18 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_progressiverenderer.cpp | 8 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_rendercontext.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderoptions.cpp | 4 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderoptions.h | 18 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 70 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_textrenderer.cpp | 13 |
7 files changed, 78 insertions, 57 deletions
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index d71bcf49e5..6efc62c84b 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -76,8 +76,8 @@ bool CPDF_ImageRenderer::StartRenderDIBSource() { CPDF_GeneralState& state = m_pImageObject->m_GeneralState; m_BitmapAlpha = FXSYS_round(255 * state.GetFillAlpha()); m_pDIBSource = m_Loader.m_pBitmap; - if (m_pRenderStatus->GetRenderOptions()->m_ColorMode == - CPDF_RenderOptions::kAlpha && + if (m_pRenderStatus->GetRenderOptions()->ColorModeIs( + CPDF_RenderOptions::kAlpha) && !m_Loader.m_pMask) { return StartBitmapAlpha(); } @@ -104,22 +104,22 @@ bool CPDF_ImageRenderer::StartRenderDIBSource() { m_bPatternColor = true; } m_FillArgb = m_pRenderStatus->GetFillArgb(m_pImageObject.Get()); - } else if (m_pRenderStatus->GetRenderOptions()->m_ColorMode == - CPDF_RenderOptions::kGray) { + } else if (m_pRenderStatus->GetRenderOptions()->ColorModeIs( + CPDF_RenderOptions::kGray)) { m_pClone = m_pDIBSource->Clone(nullptr); m_pClone->ConvertColorScale(0xffffff, 0); m_pDIBSource = m_pClone; } m_Flags = 0; - if (m_pRenderStatus->GetRenderOptions()->m_Flags & RENDER_FORCE_DOWNSAMPLE) + if (m_pRenderStatus->GetRenderOptions()->HasFlag(RENDER_FORCE_DOWNSAMPLE)) m_Flags |= RENDER_FORCE_DOWNSAMPLE; - else if (m_pRenderStatus->GetRenderOptions()->m_Flags & RENDER_FORCE_HALFTONE) + else if (m_pRenderStatus->GetRenderOptions()->HasFlag(RENDER_FORCE_HALFTONE)) m_Flags |= RENDER_FORCE_HALFTONE; if (m_pRenderStatus->GetRenderDevice()->GetDeviceClass() != FXDC_DISPLAY) HandleFilters(); - if (m_pRenderStatus->GetRenderOptions()->m_Flags & RENDER_NOIMAGESMOOTH) + if (m_pRenderStatus->GetRenderOptions()->HasFlag(RENDER_NOIMAGESMOOTH)) m_Flags |= FXDIB_NOSMOOTH; else if (m_pImageObject->GetImage()->IsInterpol()) m_Flags |= FXDIB_INTERPOL; @@ -173,8 +173,8 @@ bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, m_BlendType = blendType; m_pObj2Device = pObj2Device; CPDF_Dictionary* pOC = m_pImageObject->GetImage()->GetOC(); - if (pOC && m_pRenderStatus->GetRenderOptions()->m_pOCContext && - !m_pRenderStatus->GetRenderOptions()->m_pOCContext->CheckOCGVisible( + if (pOC && m_pRenderStatus->GetRenderOptions()->GetOCContext() && + !m_pRenderStatus->GetRenderOptions()->GetOCContext()->CheckOCGVisible( pOC)) { return false; } diff --git a/core/fpdfapi/render/cpdf_progressiverenderer.cpp b/core/fpdfapi/render/cpdf_progressiverenderer.cpp index 275fc6b85e..603c951856 100644 --- a/core/fpdfapi/render/cpdf_progressiverenderer.cpp +++ b/core/fpdfapi/render/cpdf_progressiverenderer.cpp @@ -80,7 +80,7 @@ void CPDF_ProgressiveRenderer::Continue(IFX_PauseIndicator* pPause) { pCurObj->m_Right >= m_ClipRect.left && pCurObj->m_Bottom <= m_ClipRect.top && pCurObj->m_Top >= m_ClipRect.bottom) { - if (m_pOptions->m_Flags & RENDER_BREAKFORMASKS && pCurObj->IsImage() && + if (m_pOptions->HasFlag(RENDER_BREAKFORMASKS) && pCurObj->IsImage() && pCurObj->AsImage()->GetImage()->IsMask()) { if (m_pDevice->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { m_LastObjectRendered = iter; @@ -94,10 +94,10 @@ void CPDF_ProgressiveRenderer::Continue(IFX_PauseIndicator* pPause) { pCurObj, &m_pCurrentLayer->m_Matrix, pPause)) { return; } - if (pCurObj->IsImage() && m_pRenderStatus->GetRenderOptions()->m_Flags & - RENDER_LIMITEDIMAGECACHE) { + if (pCurObj->IsImage() && m_pRenderStatus->GetRenderOptions()->HasFlag( + RENDER_LIMITEDIMAGECACHE)) { m_pContext->GetPageCache()->CacheOptimization( - m_pRenderStatus->GetRenderOptions()->m_dwLimitCacheSize); + m_pRenderStatus->GetRenderOptions()->GetCacheSizeLimit()); } if (pCurObj->IsForm() || pCurObj->IsShading()) nObjsToGo = 0; diff --git a/core/fpdfapi/render/cpdf_rendercontext.cpp b/core/fpdfapi/render/cpdf_rendercontext.cpp index 2fc7da812d..bba24d683c 100644 --- a/core/fpdfapi/render/cpdf_rendercontext.cpp +++ b/core/fpdfapi/render/cpdf_rendercontext.cpp @@ -78,9 +78,9 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, nullptr); status.RenderObjectList(layer.m_pObjectHolder.Get(), &layer.m_Matrix); } - if (status.GetRenderOptions()->m_Flags & RENDER_LIMITEDIMAGECACHE) { + if (status.GetRenderOptions()->HasFlag(RENDER_LIMITEDIMAGECACHE)) { m_pPageCache->CacheOptimization( - status.GetRenderOptions()->m_dwLimitCacheSize); + status.GetRenderOptions()->GetCacheSizeLimit()); } if (status.IsStopped()) break; diff --git a/core/fpdfapi/render/cpdf_renderoptions.cpp b/core/fpdfapi/render/cpdf_renderoptions.cpp index 7916243cba..9af951137e 100644 --- a/core/fpdfapi/render/cpdf_renderoptions.cpp +++ b/core/fpdfapi/render/cpdf_renderoptions.cpp @@ -22,9 +22,9 @@ CPDF_RenderOptions::CPDF_RenderOptions(const CPDF_RenderOptions& rhs) CPDF_RenderOptions::~CPDF_RenderOptions() {} FX_ARGB CPDF_RenderOptions::TranslateColor(FX_ARGB argb) const { - if (m_ColorMode == kNormal) + if (ColorModeIs(kNormal)) return argb; - if (m_ColorMode == kAlpha) + if (ColorModeIs(kAlpha)) return argb; int a; diff --git a/core/fpdfapi/render/cpdf_renderoptions.h b/core/fpdfapi/render/cpdf_renderoptions.h index 1f6afc30e2..9dca633f3f 100644 --- a/core/fpdfapi/render/cpdf_renderoptions.h +++ b/core/fpdfapi/render/cpdf_renderoptions.h @@ -40,6 +40,24 @@ class CPDF_RenderOptions { FX_ARGB TranslateColor(FX_ARGB argb) const; + void SetColorMode(Type mode) { m_ColorMode = mode; } + bool ColorModeIs(Type mode) const { return m_ColorMode == mode; } + + bool HasFlag(uint32_t flag) const { return !!(m_Flags & flag); } + uint32_t GetFlags() const { return m_Flags; } + void SetFlags(uint32_t flags) { m_Flags = flags; } + + uint32_t GetCacheSizeLimit() const { return m_dwLimitCacheSize; } + + void SetDrawAnnots(bool draw) { m_bDrawAnnots = draw; } + bool GetDrawAnnots() const { return m_bDrawAnnots; } + + void SetOCContext(RetainPtr<CPDF_OCContext> context) { + m_pOCContext = context; + } + CPDF_OCContext* GetOCContext() const { return m_pOCContext.Get(); } + + private: Type m_ColorMode; uint32_t m_Flags; uint32_t m_dwLimitCacheSize; diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 906143048d..935fb64ca6 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -937,10 +937,11 @@ RetainPtr<CFX_DIBitmap> DrawPatternBitmap(CPDF_Document* pDoc, mtPattern2Bitmap.Concat(mtAdjust); CPDF_RenderOptions options; if (!pPattern->colored()) - options.m_ColorMode = CPDF_RenderOptions::kAlpha; + options.SetColorMode(CPDF_RenderOptions::kAlpha); flags |= RENDER_FORCE_HALFTONE; - options.m_Flags = flags; + options.SetFlags(flags); + CPDF_RenderContext context(pDoc, pCache); context.AppendLayer(pPattern->form(), &mtPattern2Bitmap); context.Render(&bitmap_device, &options, nullptr); @@ -1084,8 +1085,8 @@ void CPDF_RenderStatus::RenderSingleObject(CPDF_PageObject* pObj, return; } m_pCurObj = pObj; - if (m_Options.m_pOCContext && pObj->m_ContentMark.HasRef()) { - if (!m_Options.m_pOCContext->CheckObjectVisible(pObj)) { + if (m_Options.GetOCContext() && pObj->m_ContentMark.HasRef()) { + if (!m_Options.GetOCContext()->CheckObjectVisible(pObj)) { return; } } @@ -1113,8 +1114,8 @@ bool CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj, } m_pCurObj = pObj; - if (m_Options.m_pOCContext && pObj->m_ContentMark.HasRef() && - !m_Options.m_pOCContext->CheckObjectVisible(pObj)) { + if (m_Options.GetOCContext() && pObj->m_ContentMark.HasRef() && + !m_Options.GetOCContext()->CheckObjectVisible(pObj)) { return false; } @@ -1254,8 +1255,8 @@ bool CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj, DebugVerifyDeviceIsPreMultiplied(); #endif CPDF_Dictionary* pOC = pFormObj->m_pForm->m_pFormDict->GetDictFor("OC"); - if (pOC && m_Options.m_pOCContext && - !m_Options.m_pOCContext->CheckOCGVisible(pOC)) { + if (pOC && m_Options.GetOCContext() && + !m_Options.GetOCContext()->CheckOCGVisible(pOC)) { return true; } CFX_Matrix matrix = pFormObj->m_FormMatrix; @@ -1295,11 +1296,11 @@ bool CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj, if (!IsAvailableMatrix(path_matrix)) return true; - if (FillType && (m_Options.m_Flags & RENDER_RECT_AA)) + if (FillType && (m_Options.HasFlag(RENDER_RECT_AA))) FillType |= FXFILL_RECT_AA; - if (m_Options.m_Flags & RENDER_FILL_FULLCOVER) + if (m_Options.HasFlag(RENDER_FILL_FULLCOVER)) FillType |= FXFILL_FULLCOVER; - if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) + if (m_Options.HasFlag(RENDER_NOPATHSMOOTH)) FillType |= FXFILL_NOPATHSMOOTH; if (bStroke) FillType |= FX_FILL_STROKE; @@ -1312,7 +1313,7 @@ bool CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj, FillType |= FX_FILL_TEXT_MODE; CFX_GraphState graphState = pPathObj->m_GraphState; - if (m_Options.m_Flags & RENDER_THINLINE) + if (m_Options.HasFlag(RENDER_THINLINE)) graphState.SetLineWidth(0); return m_pDevice->DrawPathWithBlend( pPathObj->m_Path.GetObject(), &path_matrix, graphState.GetObject(), @@ -1436,7 +1437,7 @@ void CPDF_RenderStatus::ProcessClipPath(const CPDF_ClipPath& ClipPath, continue; int fill_mode = FXFILL_WINDING; - if (m_Options.m_Flags & RENDER_NOTEXTSMOOTH) + if (m_Options.HasFlag(RENDER_NOTEXTSMOOTH)) fill_mode |= FXFILL_NOPATHSMOOTH; m_pDevice->SetClip_PathFill(pTextClippingPath.get(), nullptr, fill_mode); pTextClippingPath.reset(); @@ -1450,13 +1451,13 @@ bool CPDF_RenderStatus::SelectClipPath(const CPDF_PathObject* pPathObj, path_matrix.Concat(*pObj2Device); if (bStroke) { CFX_GraphState graphState = pPathObj->m_GraphState; - if (m_Options.m_Flags & RENDER_THINLINE) + if (m_Options.HasFlag(RENDER_THINLINE)) graphState.SetLineWidth(0); return m_pDevice->SetClip_PathStroke(pPathObj->m_Path.GetObject(), &path_matrix, graphState.GetObject()); } int fill_mode = pPathObj->m_FillType; - if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { + if (m_Options.HasFlag(RENDER_NOPATHSMOOTH)) { fill_mode |= FXFILL_NOPATHSMOOTH; } return m_pDevice->SetClip_PathFill(pPathObj->m_Path.GetObject(), &path_matrix, @@ -1497,7 +1498,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, (pPageObj->m_ClipPath.HasRef() && pPageObj->m_ClipPath.GetTextCount() && m_pDevice->GetDeviceClass() == FXDC_DISPLAY && !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)); - if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->IsImage() && + if ((m_Options.HasFlag(RENDER_OVERPRINT)) && pPageObj->IsImage() && pPageObj->m_GeneralState.GetFillOP() && pPageObj->m_GeneralState.GetStrokeOP()) { CPDF_Document* pDocument = nullptr; @@ -1802,7 +1803,7 @@ bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, } if (textobj->m_GeneralState.GetStrokeAdjust()) flag |= FX_STROKE_ADJUST; - if (m_Options.m_Flags & RENDER_NOTEXTSMOOTH) + if (m_Options.HasFlag(RENDER_NOTEXTSMOOTH)) flag |= FXFILL_NOPATHSMOOTH; return CPDF_TextRenderer::DrawTextPath( m_pDevice, textobj->GetCharCodes(), textobj->GetCharPositions(), pFont, @@ -1880,9 +1881,12 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, } std::unique_ptr<CPDF_GraphicStates> pStates = CloneObjStates(textobj, false); - CPDF_RenderOptions Options = m_Options; - Options.m_Flags |= RENDER_FORCE_HALFTONE | RENDER_RECT_AA; - Options.m_Flags &= ~RENDER_FORCE_DOWNSAMPLE; + CPDF_RenderOptions options = m_Options; + uint32_t option_flags = options.GetFlags(); + option_flags |= RENDER_FORCE_HALFTONE | RENDER_RECT_AA; + option_flags &= ~RENDER_FORCE_DOWNSAMPLE; + options.SetFlags(option_flags); + CPDF_Dictionary* pFormResource = nullptr; if (pType3Char->m_pForm && pType3Char->m_pForm->m_pFormDict) { pFormResource = @@ -1891,7 +1895,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, if (fill_alpha == 255) { CPDF_RenderStatus status; status.Initialize(m_pContext.Get(), m_pDevice, nullptr, nullptr, this, - pStates.get(), &Options, + pStates.get(), &options, pType3Char->m_pForm->m_Transparency, m_bDropObjects, pFormResource, false, pType3Char, fill_argb); status.m_Type3FontCache = m_Type3FontCache; @@ -1912,7 +1916,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, bitmap_device.GetBitmap()->Clear(0); CPDF_RenderStatus status; status.Initialize(m_pContext.Get(), &bitmap_device, nullptr, nullptr, - this, pStates.get(), &Options, + this, pStates.get(), &options, pType3Char->m_pForm->m_Transparency, m_bDropObjects, pFormResource, false, pType3Char, fill_argb); status.m_Type3FontCache = m_Type3FontCache; @@ -2093,7 +2097,6 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, return; pBitmap->Clear(background); - int fill_mode = m_Options.m_Flags; switch (pPattern->GetShadingType()) { case kInvalidShading: case kMaxShading: @@ -2130,14 +2133,15 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, // the case of dictionary at the moment. if (CPDF_Stream* pStream = ToStream(pPattern->GetShadingObject())) { DrawCoonPatchMeshes(pPattern->GetShadingType(), pBitmap, &FinalMatrix, - pStream, funcs, pColorSpace, fill_mode, alpha); + pStream, funcs, pColorSpace, m_Options.GetFlags(), + alpha); } } break; } if (bAlphaMode) pBitmap->LoadChannel(FXDIB_Red, pBitmap, FXDIB_Alpha); - if (m_Options.m_ColorMode == CPDF_RenderOptions::kGray) + if (m_Options.ColorModeIs(CPDF_RenderOptions::kGray)) pBitmap->ConvertColorScale(0, 0xffffff); buffer.OutputToDevice(); } @@ -2169,7 +2173,7 @@ void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern, FXSYS_round(255 * (bStroke ? pPageObj->m_GeneralState.GetStrokeAlpha() : pPageObj->m_GeneralState.GetFillAlpha())); DrawShading(pattern, &matrix, rect, alpha, - m_Options.m_ColorMode == CPDF_RenderOptions::kAlpha); + m_Options.ColorModeIs(CPDF_RenderOptions::kAlpha)); } void CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj, @@ -2184,7 +2188,7 @@ void CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj, matrix.Concat(*pObj2Device); DrawShading(pShadingObj->m_pShading.Get(), &matrix, rect, FXSYS_round(255 * pShadingObj->m_GeneralState.GetFillAlpha()), - m_Options.m_ColorMode == CPDF_RenderOptions::kAlpha); + m_Options.ColorModeIs(CPDF_RenderOptions::kAlpha)); } void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, @@ -2296,19 +2300,19 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, if (width * height < 16) { RetainPtr<CFX_DIBitmap> pEnlargedBitmap = DrawPatternBitmap(m_pContext->GetDocument(), m_pContext->GetPageCache(), - pPattern, pObj2Device, 8, 8, m_Options.m_Flags); + pPattern, pObj2Device, 8, 8, m_Options.GetFlags()); pPatternBitmap = pEnlargedBitmap->StretchTo(width, height, 0, nullptr); } else { pPatternBitmap = DrawPatternBitmap( m_pContext->GetDocument(), m_pContext->GetPageCache(), pPattern, - pObj2Device, width, height, m_Options.m_Flags); + pObj2Device, width, height, m_Options.GetFlags()); } if (!pPatternBitmap) return; - if (m_Options.m_ColorMode == CPDF_RenderOptions::kGray) { + if (m_Options.ColorModeIs(CPDF_RenderOptions::kGray)) pPatternBitmap->ConvertColorScale(0, 0xffffff); - } + FX_ARGB fill_argb = GetFillArgb(pPageObj); int clip_width = clip_box.right - clip_box.left; int clip_height = clip_box.bottom - clip_box.top; @@ -2611,8 +2615,8 @@ RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask( pFormResource = form.m_pFormDict->GetDictFor("Resources"); } CPDF_RenderOptions options; - options.m_ColorMode = - bLuminosity ? CPDF_RenderOptions::kNormal : CPDF_RenderOptions::kAlpha; + options.SetColorMode(bLuminosity ? CPDF_RenderOptions::kNormal + : CPDF_RenderOptions::kAlpha); CPDF_RenderStatus status; status.Initialize(m_pContext.Get(), &bitmap_device, nullptr, nullptr, nullptr, nullptr, &options, 0, m_bDropObjects, pFormResource, true, diff --git a/core/fpdfapi/render/cpdf_textrenderer.cpp b/core/fpdfapi/render/cpdf_textrenderer.cpp index 283d9946fa..711dbfaf39 100644 --- a/core/fpdfapi/render/cpdf_textrenderer.cpp +++ b/core/fpdfapi/render/cpdf_textrenderer.cpp @@ -125,19 +125,18 @@ bool CPDF_TextRenderer::DrawNormalText(CFX_RenderDevice* pDevice, return true; int FXGE_flags = 0; if (pOptions) { - uint32_t dwFlags = pOptions->m_Flags; - if (dwFlags & RENDER_CLEARTYPE) { + if (pOptions->HasFlag(RENDER_CLEARTYPE)) { FXGE_flags |= FXTEXT_CLEARTYPE; - if (dwFlags & RENDER_BGR_STRIPE) + if (pOptions->HasFlag(RENDER_BGR_STRIPE)) FXGE_flags |= FXTEXT_BGR_STRIPE; } - if (dwFlags & RENDER_NOTEXTSMOOTH) + if (pOptions->HasFlag(RENDER_NOTEXTSMOOTH)) FXGE_flags |= FXTEXT_NOSMOOTH; - if (dwFlags & RENDER_PRINTGRAPHICTEXT) + if (pOptions->HasFlag(RENDER_PRINTGRAPHICTEXT)) FXGE_flags |= FXTEXT_PRINTGRAPHICTEXT; - if (dwFlags & RENDER_NO_NATIVETEXT) + if (pOptions->HasFlag(RENDER_NO_NATIVETEXT)) FXGE_flags |= FXTEXT_NO_NATIVETEXT; - if (dwFlags & RENDER_PRINTIMAGETEXT) + if (pOptions->HasFlag(RENDER_PRINTIMAGETEXT)) FXGE_flags |= FXTEXT_PRINTIMAGETEXT; } else { FXGE_flags = FXTEXT_CLEARTYPE; |