Chromium Code Reviews| Index: core/src/fpdfapi/fpdf_render/fpdf_render.cpp |
| diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp |
| index 8e205df281beff1df2698627e81a48eb5b33a48a..9e100d1deadb7b6fe8a6defdcc1503003e578623 100644 |
| --- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp |
| +++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp |
| @@ -306,8 +306,8 @@ FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj, |
| if (ProcessTransparency(pObj, pObj2Device)) |
| return FALSE; |
| - if (pObj->m_Type == CPDF_PageObject::IMAGE) { |
| - m_pObjectRenderer.reset(IPDF_ObjectRenderer::Create(pObj->m_Type)); |
| + if (pObj->IsImage()) { |
| + m_pObjectRenderer.reset(IPDF_ObjectRenderer::Create(pObj->GetType())); |
| if (!m_pObjectRenderer->Start(this, pObj, pObj2Device, FALSE)) { |
| if (!m_pObjectRenderer->m_Result) |
| DrawObjWithBackground(pObj, pObj2Device); |
| @@ -321,7 +321,7 @@ FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj, |
| return FALSE; |
| } |
| -IPDF_ObjectRenderer* IPDF_ObjectRenderer::Create(int type) { |
| +IPDF_ObjectRenderer* IPDF_ObjectRenderer::Create(CPDF_PageObject::Type type) { |
| if (type != CPDF_PageObject::IMAGE) { |
|
Lei Zhang
2016/02/19 04:22:31
Maybe just remove the type parameter and this chec
Wei Li
2016/02/19 19:32:19
I removed it for now. Looks like IPDF_ObjectRender
|
| return NULL; |
| } |
| @@ -374,7 +374,7 @@ void CPDF_RenderStatus::DitherObjectArea(const CPDF_PageObject* pObj, |
| void CPDF_RenderStatus::ProcessObjectNoClip(const CPDF_PageObject* pObj, |
| const CFX_Matrix* pObj2Device) { |
| FX_BOOL bRet = FALSE; |
| - switch (pObj->m_Type) { |
| + switch (pObj->GetType()) { |
| case CPDF_PageObject::TEXT: |
| bRet = ProcessText((CPDF_TextObject*)pObj, pObj2Device, NULL); |
|
Lei Zhang
2016/02/19 04:22:31
More casts to get rid of.
Wei Li
2016/02/19 19:32:19
Thanks for spotting these. Done.
|
| break; |
| @@ -398,7 +398,7 @@ void CPDF_RenderStatus::ProcessObjectNoClip(const CPDF_PageObject* pObj, |
| FX_BOOL CPDF_RenderStatus::DrawObjWithBlend(const CPDF_PageObject* pObj, |
| const CFX_Matrix* pObj2Device) { |
| FX_BOOL bRet = FALSE; |
| - switch (pObj->m_Type) { |
| + switch (pObj->GetType()) { |
| case CPDF_PageObject::PATH: |
| bRet = ProcessPath((CPDF_PathObject*)pObj, pObj2Device); |
| break; |
| @@ -425,7 +425,7 @@ void CPDF_RenderStatus::DrawObjWithBackground(const CPDF_PageObject* pObj, |
| return; |
| } |
| int res = 300; |
| - if (pObj->m_Type == CPDF_PageObject::IMAGE && |
| + if (pObj->IsImage() && |
| m_pDevice->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { |
| res = 0; |
| } |
| @@ -437,8 +437,8 @@ void CPDF_RenderStatus::DrawObjWithBackground(const CPDF_PageObject* pObj, |
| matrix.Concat(*buffer.GetMatrix()); |
| GetScaledMatrix(matrix); |
| CPDF_Dictionary* pFormResource = NULL; |
| - if (pObj->m_Type == CPDF_PageObject::FORM) { |
| - CPDF_FormObject* pFormObj = (CPDF_FormObject*)pObj; |
| + if (pObj->IsForm()) { |
| + const CPDF_FormObject* pFormObj = pObj->AsForm(); |
| if (pFormObj->m_pForm && pFormObj->m_pForm->m_pFormDict) { |
| pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); |
| } |
| @@ -721,8 +721,8 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, |
| CPDF_Dictionary* pSMaskDict = |
| pGeneralState ? ToDictionary(pGeneralState->m_pSoftMask) : NULL; |
| if (pSMaskDict) { |
| - if (pPageObj->m_Type == CPDF_PageObject::IMAGE && |
| - ((CPDF_ImageObject*)pPageObj)->m_pImage->GetDict()->KeyExist("SMask")) { |
| + if (pPageObj->IsImage() && |
| + pPageObj->AsImage()->m_pImage->GetDict()->KeyExist("SMask")) { |
| pSMaskDict = NULL; |
| } |
| } |
| @@ -730,8 +730,8 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, |
| FX_FLOAT group_alpha = 1.0f; |
| int Transparency = m_Transparency; |
| FX_BOOL bGroupTransparent = FALSE; |
| - if (pPageObj->m_Type == CPDF_PageObject::FORM) { |
| - CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj; |
| + if (pPageObj->IsForm()) { |
| + const CPDF_FormObject* pFormObj = pPageObj->AsForm(); |
| const CPDF_GeneralStateData* pStateData = |
| pFormObj->m_GeneralState.GetObject(); |
| if (pStateData) { |
| @@ -749,22 +749,20 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, |
| !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)) { |
| bTextClip = TRUE; |
| } |
| - if ((m_Options.m_Flags & RENDER_OVERPRINT) && |
| - pPageObj->m_Type == CPDF_PageObject::IMAGE && pGeneralState && |
| - pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) { |
| + if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->IsImage() && |
| + pGeneralState && pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) { |
| CPDF_Document* pDocument = NULL; |
| CPDF_Page* pPage = NULL; |
| if (m_pContext->GetPageCache()) { |
| pPage = m_pContext->GetPageCache()->GetPage(); |
| pDocument = pPage->m_pDocument; |
| } else { |
| - pDocument = ((CPDF_ImageObject*)pPageObj)->m_pImage->GetDocument(); |
| + pDocument = pPageObj->AsImage()->m_pImage->GetDocument(); |
| } |
| CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : NULL; |
| - CPDF_Object* pCSObj = ((CPDF_ImageObject*)pPageObj) |
| - ->m_pImage->GetStream() |
| - ->GetDict() |
| - ->GetElementValue("ColorSpace"); |
| + CPDF_Object* pCSObj = |
| + pPageObj->AsImage()->m_pImage->GetStream()->GetDict()->GetElementValue( |
| + "ColorSpace"); |
| CPDF_ColorSpace* pColorSpace = |
| pDocument->LoadColorSpace(pCSObj, pPageResources); |
| if (pColorSpace) { |
| @@ -870,7 +868,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, |
| bitmap->MultiplyAlpha((int32_t)(group_alpha * 255)); |
| } |
| Transparency = m_Transparency; |
| - if (pPageObj->m_Type == CPDF_PageObject::FORM) { |
| + if (pPageObj->IsForm()) { |
| Transparency |= PDFTRANS_GROUP; |
| } |
| CompositeDIBitmap(bitmap, rect.left, rect.top, 0, 255, blend_type, |
| @@ -1088,13 +1086,12 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) { |
| pCurObj, &m_pCurrentLayer->m_Matrix, pPause)) { |
| return; |
| } |
| - if (pCurObj->m_Type == CPDF_PageObject::IMAGE && |
| + if (pCurObj->IsImage() && |
| m_pRenderStatus->m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
| m_pContext->GetPageCache()->CacheOptimization( |
| m_pRenderStatus->m_Options.m_dwLimitCacheSize); |
| } |
| - if (pCurObj->m_Type == CPDF_PageObject::FORM || |
| - pCurObj->m_Type == CPDF_PageObject::SHADING) { |
| + if (pCurObj->IsForm() || pCurObj->IsShading()) { |
| nObjsToGo = 0; |
| } else { |
| --nObjsToGo; |