summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-06-25 19:42:04 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-25 19:42:04 +0000
commit8c955c9d307272d43d532cd206abc4077076d212 (patch)
treee2110aaf636fd5e6835dbe148a059c6502fa6f3f /core/fpdfapi/render
parent8256f1f063793da1e0b4c34884a4e52d5df935c2 (diff)
downloadpdfium-8c955c9d307272d43d532cd206abc4077076d212.tar.xz
Combine common code into CPDF_RenderStatus::ClipPattern().
Change-Id: I53ce4ee699644b0a30132e642b8f466cd9b6e7b1 Reviewed-on: https://pdfium-review.googlesource.com/35972 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/render')
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp29
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.h3
2 files changed, 18 insertions, 14 deletions
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 653d657984..8b58295ab4 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1429,6 +1429,18 @@ void CPDF_RenderStatus::ProcessClipPath(const CPDF_ClipPath& ClipPath,
}
}
+bool CPDF_RenderStatus::ClipPattern(const CPDF_PageObject* pPageObj,
+ const CFX_Matrix* pObj2Device,
+ bool bStroke) {
+ if (pPageObj->IsPath())
+ return SelectClipPath(pPageObj->AsPath(), pObj2Device, bStroke);
+ if (pPageObj->IsImage()) {
+ m_pDevice->SetClip_Rect(pPageObj->GetBBox(pObj2Device));
+ return true;
+ }
+ return false;
+}
+
bool CPDF_RenderStatus::SelectClipPath(const CPDF_PathObject* pPathObj,
const CFX_Matrix* pObj2Device,
bool bStroke) {
@@ -2127,14 +2139,9 @@ void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern,
return;
CFX_RenderDevice::StateRestorer restorer(m_pDevice);
- if (pPageObj->IsPath()) {
- if (!SelectClipPath(pPageObj->AsPath(), pObj2Device, bStroke))
- return;
- } else if (pPageObj->IsImage()) {
- m_pDevice->SetClip_Rect(pPageObj->GetBBox(pObj2Device));
- } else {
+ if (!ClipPattern(pPageObj, pObj2Device, bStroke))
return;
- }
+
FX_RECT rect = GetObjectClippedRect(pPageObj, pObj2Device);
if (rect.IsEmpty())
return;
@@ -2171,14 +2178,8 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
return;
CFX_RenderDevice::StateRestorer restorer(m_pDevice);
- if (pPageObj->IsPath()) {
- if (!SelectClipPath(pPageObj->AsPath(), pObj2Device, bStroke))
- return;
- } else if (pPageObj->IsImage()) {
- m_pDevice->SetClip_Rect(pPageObj->GetBBox(pObj2Device));
- } else {
+ if (!ClipPattern(pPageObj, pObj2Device, bStroke))
return;
- }
FX_RECT clip_box = m_pDevice->GetClipBox();
if (clip_box.IsEmpty())
diff --git a/core/fpdfapi/render/cpdf_renderstatus.h b/core/fpdfapi/render/cpdf_renderstatus.h
index 7dee8142c4..92b96f9bec 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.h
+++ b/core/fpdfapi/render/cpdf_renderstatus.h
@@ -119,6 +119,9 @@ class CPDF_RenderStatus {
const CFX_Matrix* pObj2Device,
const CPDF_Color* pColor,
bool bStroke);
+ bool ClipPattern(const CPDF_PageObject* pPageObj,
+ const CFX_Matrix* pObj2Device,
+ bool bStroke);
bool SelectClipPath(const CPDF_PathObject* pPathObj,
const CFX_Matrix* pObj2Device,
bool bStroke);