summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_render
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-08-26 15:17:12 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-26 15:17:13 -0700
commit987f3ee94c3cb8e4a6113ad05453a2948469386c (patch)
treefbd1fdc800c2510c89ae043331a799a42c3251af /core/fpdfapi/fpdf_render
parent83d2351fd64128156c9abfb70266133d58a5e525 (diff)
downloadpdfium-987f3ee94c3cb8e4a6113ad05453a2948469386c.tar.xz
Make CFX_CountRef<>::m_pObject private, add accessors, fix const-ness.
Hide the CountedObj class from the rest of the code. Rename GetModify() to GetPrivateCopy(), since it turns out there are places where we modify a potentially-shared copy. Add non-const version of GetObject() to permit these. Review-Url: https://codereview.chromium.org/2287633002
Diffstat (limited to 'core/fpdfapi/fpdf_render')
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render.cpp13
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_image.cpp2
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp6
-rw-r--r--core/fpdfapi/fpdf_render/render_int.h2
4 files changed, 13 insertions, 10 deletions
diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp
index f24a66857d..f77e46d923 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -199,12 +199,14 @@ FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext,
const CPDF_ColorStateData* pParentData =
pParentState->m_InitialStates.m_ColorState.GetObject();
if (!pColorData || pColorData->m_FillColor.IsNull()) {
- CPDF_ColorStateData* pData = m_InitialStates.m_ColorState.GetModify();
+ CPDF_ColorStateData* pData =
+ m_InitialStates.m_ColorState.GetPrivateCopy();
pData->m_FillRGB = pParentData->m_FillRGB;
pData->m_FillColor.Copy(&pParentData->m_FillColor);
}
if (!pColorData || pColorData->m_StrokeColor.IsNull()) {
- CPDF_ColorStateData* pData = m_InitialStates.m_ColorState.GetModify();
+ CPDF_ColorStateData* pData =
+ m_InitialStates.m_ColorState.GetPrivateCopy();
pData->m_StrokeRGB = pParentData->m_FillRGB;
pData->m_StrokeColor.Copy(&pParentData->m_StrokeColor);
}
@@ -915,10 +917,11 @@ CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates(
}
CPDF_GraphicStates* pStates = new CPDF_GraphicStates;
pStates->CopyStates(*pSrcStates);
- CPDF_Color* pObjColor = bStroke ? pSrcStates->m_ColorState.GetStrokeColor()
- : pSrcStates->m_ColorState.GetFillColor();
+ const CPDF_Color* pObjColor = bStroke
+ ? pSrcStates->m_ColorState.GetStrokeColor()
+ : pSrcStates->m_ColorState.GetFillColor();
if (!pObjColor->IsNull()) {
- CPDF_ColorStateData* pColorData = pStates->m_ColorState.GetModify();
+ CPDF_ColorStateData* pColorData = pStates->m_ColorState.GetPrivateCopy();
pColorData->m_FillRGB =
bStroke ? pSrcStates->m_ColorState.GetObject()->m_StrokeRGB
: pSrcStates->m_ColorState.GetObject()->m_FillRGB;
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
index 8d638f62f8..295ac4f7d7 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -422,7 +422,7 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() {
m_bPatternColor = FALSE;
m_pPattern = nullptr;
if (m_pDIBSource->IsAlphaMask()) {
- CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor();
+ const CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor();
if (pColor && pColor->IsPattern()) {
m_pPattern = pColor->GetPattern();
if (m_pPattern) {
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
index 21af7686fc..fc06c0be57 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -1169,7 +1169,7 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern,
void CPDF_RenderStatus::DrawPathWithPattern(const CPDF_PathObject* pPathObj,
const CFX_Matrix* pObj2Device,
- CPDF_Color* pColor,
+ const CPDF_Color* pColor,
FX_BOOL bStroke) {
CPDF_Pattern* pattern = pColor->GetPattern();
if (!pattern)
@@ -1186,14 +1186,14 @@ void CPDF_RenderStatus::ProcessPathPattern(const CPDF_PathObject* pPathObj,
int& filltype,
FX_BOOL& bStroke) {
if (filltype) {
- CPDF_Color& FillColor = *pPathObj->m_ColorState.GetFillColor();
+ const CPDF_Color& FillColor = *pPathObj->m_ColorState.GetFillColor();
if (FillColor.IsPattern()) {
DrawPathWithPattern(pPathObj, pObj2Device, &FillColor, FALSE);
filltype = 0;
}
}
if (bStroke) {
- CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor();
+ const CPDF_Color& StrokeColor = *pPathObj->m_ColorState.GetStrokeColor();
if (StrokeColor.IsPattern()) {
DrawPathWithPattern(pPathObj, pObj2Device, &StrokeColor, TRUE);
bStroke = FALSE;
diff --git a/core/fpdfapi/fpdf_render/render_int.h b/core/fpdfapi/fpdf_render/render_int.h
index a10dca5db8..66d0a70d52 100644
--- a/core/fpdfapi/fpdf_render/render_int.h
+++ b/core/fpdfapi/fpdf_render/render_int.h
@@ -186,7 +186,7 @@ class CPDF_RenderStatus {
FX_BOOL& bStroke);
void DrawPathWithPattern(const CPDF_PathObject* pPathObj,
const CFX_Matrix* pObj2Device,
- CPDF_Color* pColor,
+ const CPDF_Color* pColor,
FX_BOOL bStroke);
void DrawTilingPattern(CPDF_TilingPattern* pPattern,
const CPDF_PageObject* pPageObj,