summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorstate.cpp80
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorstate.h32
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp74
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorstatedata.h38
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_graphicstates.cpp2
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_parser.cpp87
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp2
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render.cpp45
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_image.cpp2
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp4
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_text.cpp4
11 files changed, 181 insertions, 189 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp b/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
deleted file mode 100644
index a46dea3bb8..0000000000
--- a/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "core/fpdfapi/fpdf_page/cpdf_colorstate.h"
-
-#include "core/fpdfapi/fpdf_page/cpdf_pattern.h"
-#include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h"
-#include "core/fxge/include/fx_dib.h"
-
-void CPDF_ColorState::SetFillColor(CPDF_ColorSpace* pCS,
- FX_FLOAT* pValue,
- uint32_t nValues) {
- MakePrivateCopy();
- CPDF_ColorStateData* pData = GetObject();
- SetColor(pData->m_FillColor, pData->m_FillRGB, pCS, pValue, nValues);
-}
-
-void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS,
- FX_FLOAT* pValue,
- uint32_t nValues) {
- MakePrivateCopy();
- CPDF_ColorStateData* pData = GetObject();
- SetColor(pData->m_StrokeColor, pData->m_StrokeRGB, pCS, pValue, nValues);
-}
-
-void CPDF_ColorState::SetColor(CPDF_Color& color,
- uint32_t& rgb,
- CPDF_ColorSpace* pCS,
- FX_FLOAT* pValue,
- uint32_t nValues) {
- if (pCS) {
- color.SetColorSpace(pCS);
- } else if (color.IsNull()) {
- color.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY));
- }
- if (color.GetColorSpace()->CountComponents() > nValues)
- return;
-
- color.SetValue(pValue);
- int R, G, B;
- rgb = color.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (uint32_t)-1;
-}
-
-void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
- FX_FLOAT* pValue,
- uint32_t nValues) {
- MakePrivateCopy();
- CPDF_ColorStateData* pData = GetObject();
- pData->m_FillColor.SetValue(pPattern, pValue, nValues);
- int R, G, B;
- FX_BOOL ret = pData->m_FillColor.GetRGB(R, G, B);
- if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) {
- if (!ret && pTilingPattern->colored()) {
- pData->m_FillRGB = 0x00BFBFBF;
- return;
- }
- }
- pData->m_FillRGB = ret ? FXSYS_RGB(R, G, B) : (uint32_t)-1;
-}
-
-void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
- FX_FLOAT* pValue,
- uint32_t nValues) {
- MakePrivateCopy();
- CPDF_ColorStateData* pData = GetObject();
- pData->m_StrokeColor.SetValue(pPattern, pValue, nValues);
- int R, G, B;
- FX_BOOL ret = pData->m_StrokeColor.GetRGB(R, G, B);
- if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) {
- if (!ret && pTilingPattern->colored()) {
- pData->m_StrokeRGB = 0x00BFBFBF;
- return;
- }
- }
- pData->m_StrokeRGB =
- pData->m_StrokeColor.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (uint32_t)-1;
-}
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstate.h b/core/fpdfapi/fpdf_page/cpdf_colorstate.h
index 128d67558d..b412947183 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorstate.h
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstate.h
@@ -9,40 +9,8 @@
#include "core/fpdfapi/fpdf_page/cpdf_colorstatedata.h"
#include "core/fxcrt/include/cfx_count_ref.h"
-#include "core/fxcrt/include/fx_basic.h"
-#include "core/fxcrt/include/fx_system.h"
-
-class CPDF_Color;
-class CPDF_ColorSpace;
-class CPDF_Pattern;
class CPDF_ColorState : public CFX_CountRef<CPDF_ColorStateData> {
- public:
- const CPDF_Color* GetFillColor() const {
- const CPDF_ColorStateData* pData = GetObject();
- return pData ? &pData->m_FillColor : nullptr;
- }
-
- const CPDF_Color* GetStrokeColor() const {
- const CPDF_ColorStateData* pData = GetObject();
- return pData ? &pData->m_StrokeColor : nullptr;
- }
-
- void SetFillColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues);
- void SetStrokeColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues);
- void SetFillPattern(CPDF_Pattern* pattern,
- FX_FLOAT* pValue,
- uint32_t nValues);
- void SetStrokePattern(CPDF_Pattern* pattern,
- FX_FLOAT* pValue,
- uint32_t nValues);
-
- private:
- void SetColor(CPDF_Color& color,
- uint32_t& rgb,
- CPDF_ColorSpace* pCS,
- FX_FLOAT* pValue,
- uint32_t nValues);
};
#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATE_H_
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp b/core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp
index 9dbcdec267..3a771ffaf0 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp
@@ -6,15 +6,79 @@
#include "core/fpdfapi/fpdf_page/cpdf_colorstatedata.h"
-CPDF_ColorStateData::CPDF_ColorStateData(const CPDF_ColorStateData& src) {
+#include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h"
+#include "core/fxge/include/fx_dib.h"
+
+CPDF_ColorStateData::CPDF_ColorStateData(const CPDF_ColorStateData& src)
+ : m_FillRGB(src.m_FillRGB), m_StrokeRGB(src.m_StrokeRGB) {
m_FillColor.Copy(&src.m_FillColor);
- m_FillRGB = src.m_FillRGB;
m_StrokeColor.Copy(&src.m_StrokeColor);
- m_StrokeRGB = src.m_StrokeRGB;
}
-void CPDF_ColorStateData::Default() {
- m_FillRGB = m_StrokeRGB = 0;
+void CPDF_ColorStateData::SetDefault() {
+ m_FillRGB = 0;
+ m_StrokeRGB = 0;
m_FillColor.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY));
m_StrokeColor.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY));
}
+
+void CPDF_ColorStateData::SetFillColor(CPDF_ColorSpace* pCS,
+ FX_FLOAT* pValue,
+ uint32_t nValues) {
+ SetColor(m_FillColor, m_FillRGB, pCS, pValue, nValues);
+}
+
+void CPDF_ColorStateData::SetStrokeColor(CPDF_ColorSpace* pCS,
+ FX_FLOAT* pValue,
+ uint32_t nValues) {
+ SetColor(m_StrokeColor, m_StrokeRGB, pCS, pValue, nValues);
+}
+
+void CPDF_ColorStateData::SetFillPattern(CPDF_Pattern* pPattern,
+ FX_FLOAT* pValue,
+ uint32_t nValues) {
+ m_FillColor.SetValue(pPattern, pValue, nValues);
+ int R, G, B;
+ FX_BOOL ret = m_FillColor.GetRGB(R, G, B);
+ if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) {
+ if (!ret && pTilingPattern->colored()) {
+ m_FillRGB = 0x00BFBFBF;
+ return;
+ }
+ }
+ m_FillRGB = ret ? FXSYS_RGB(R, G, B) : (uint32_t)-1;
+}
+
+void CPDF_ColorStateData::SetStrokePattern(CPDF_Pattern* pPattern,
+ FX_FLOAT* pValue,
+ uint32_t nValues) {
+ m_StrokeColor.SetValue(pPattern, pValue, nValues);
+ int R, G, B;
+ FX_BOOL ret = m_StrokeColor.GetRGB(R, G, B);
+ if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) {
+ if (!ret && pTilingPattern->colored()) {
+ m_StrokeRGB = 0x00BFBFBF;
+ return;
+ }
+ }
+ m_StrokeRGB =
+ m_StrokeColor.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (uint32_t)-1;
+}
+
+void CPDF_ColorStateData::SetColor(CPDF_Color& color,
+ uint32_t& rgb,
+ CPDF_ColorSpace* pCS,
+ FX_FLOAT* pValue,
+ uint32_t nValues) {
+ if (pCS) {
+ color.SetColorSpace(pCS);
+ } else if (color.IsNull()) {
+ color.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY));
+ }
+ if (color.GetColorSpace()->CountComponents() > nValues)
+ return;
+
+ color.SetValue(pValue);
+ int R, G, B;
+ rgb = color.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (uint32_t)-1;
+}
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstatedata.h b/core/fpdfapi/fpdf_page/cpdf_colorstatedata.h
index 6a992ad0b1..1b8413f3f1 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorstatedata.h
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstatedata.h
@@ -10,17 +10,49 @@
#include "core/fpdfapi/fpdf_page/include/cpdf_color.h"
#include "core/fxcrt/include/fx_system.h"
+class CPDF_Color;
+class CPDF_ColorSpace;
+class CPDF_Pattern;
+
class CPDF_ColorStateData {
public:
CPDF_ColorStateData() : m_FillRGB(0), m_StrokeRGB(0) {}
CPDF_ColorStateData(const CPDF_ColorStateData& src);
- void Default();
+ void SetDefault();
+
+ uint32_t GetFillRGB() const { return m_FillRGB; }
+ void SetFillRGB(uint32_t rgb) { m_FillRGB = rgb; }
+
+ uint32_t GetStrokeRGB() const { return m_StrokeRGB; }
+ void SetStrokeRGB(uint32_t rgb) { m_StrokeRGB = rgb; }
+
+ CPDF_Color* GetFillColor() { return &m_FillColor; }
+ const CPDF_Color* GetFillColor() const { return &m_FillColor; }
+ void SetFillColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues);
+
+ CPDF_Color* GetStrokeColor() { return &m_StrokeColor; }
+ const CPDF_Color* GetStrokeColor() const { return &m_StrokeColor; }
+ void SetStrokeColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues);
+
+ void SetFillPattern(CPDF_Pattern* pattern,
+ FX_FLOAT* pValue,
+ uint32_t nValues);
+ void SetStrokePattern(CPDF_Pattern* pattern,
+ FX_FLOAT* pValue,
+ uint32_t nValues);
+
+ private:
+ void SetColor(CPDF_Color& color,
+ uint32_t& rgb,
+ CPDF_ColorSpace* pCS,
+ FX_FLOAT* pValue,
+ uint32_t nValues);
- CPDF_Color m_FillColor;
uint32_t m_FillRGB;
- CPDF_Color m_StrokeColor;
uint32_t m_StrokeRGB;
+ CPDF_Color m_FillColor;
+ CPDF_Color m_StrokeColor;
};
#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATEDATA_H_
diff --git a/core/fpdfapi/fpdf_page/cpdf_graphicstates.cpp b/core/fpdfapi/fpdf_page/cpdf_graphicstates.cpp
index fc054caf21..d1eabb6908 100644
--- a/core/fpdfapi/fpdf_page/cpdf_graphicstates.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_graphicstates.cpp
@@ -11,7 +11,7 @@ CPDF_GraphicStates::CPDF_GraphicStates() {}
CPDF_GraphicStates::~CPDF_GraphicStates() {}
void CPDF_GraphicStates::DefaultStates() {
- m_ColorState.New()->Default();
+ m_ColorState.New()->SetDefault();
}
void CPDF_GraphicStates::CopyStates(const CPDF_GraphicStates& src) {
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 5d5b75b60e..5dc8480423 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -6,6 +6,7 @@
#include "core/fpdfapi/fpdf_page/pageint.h"
+#include <algorithm>
#include <memory>
#include <utility>
#include <vector>
@@ -692,7 +693,7 @@ void CPDF_StreamContentParser::Handle_SetColorSpace_Fill() {
return;
m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->m_FillColor.SetColorSpace(pCS);
+ m_pCurStates->m_ColorState->GetFillColor()->SetColorSpace(pCS);
}
void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() {
@@ -701,7 +702,7 @@ void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() {
return;
m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->m_StrokeColor.SetColorSpace(pCS);
+ m_pCurStates->m_ColorState->GetStrokeColor()->SetColorSpace(pCS);
}
void CPDF_StreamContentParser::Handle_SetDash() {
@@ -845,14 +846,16 @@ void CPDF_StreamContentParser::Handle_EOFillPath() {
void CPDF_StreamContentParser::Handle_SetGray_Fill() {
FX_FLOAT value = GetNumber(0);
- CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY);
- m_pCurStates->m_ColorState.SetFillColor(pCS, &value, 1);
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->SetFillColor(
+ CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY), &value, 1);
}
void CPDF_StreamContentParser::Handle_SetGray_Stroke() {
FX_FLOAT value = GetNumber(0);
- CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY);
- m_pCurStates->m_ColorState.SetStrokeColor(pCS, &value, 1);
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->SetStrokeColor(
+ CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY), &value, 1);
}
void CPDF_StreamContentParser::Handle_SetExtendGraphState() {
@@ -900,11 +903,12 @@ void CPDF_StreamContentParser::Handle_SetCMYKColor_Fill() {
return;
FX_FLOAT values[4];
- for (int i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++)
values[i] = GetNumber(3 - i);
- }
- CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK);
- m_pCurStates->m_ColorState.SetFillColor(pCS, values, 4);
+
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->SetFillColor(
+ CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK), values, 4);
}
void CPDF_StreamContentParser::Handle_SetCMYKColor_Stroke() {
@@ -912,11 +916,12 @@ void CPDF_StreamContentParser::Handle_SetCMYKColor_Stroke() {
return;
FX_FLOAT values[4];
- for (int i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++)
values[i] = GetNumber(3 - i);
- }
- CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK);
- m_pCurStates->m_ColorState.SetStrokeColor(pCS, values, 4);
+
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->SetStrokeColor(
+ CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK), values, 4);
}
void CPDF_StreamContentParser::Handle_LineTo() {
@@ -981,11 +986,12 @@ void CPDF_StreamContentParser::Handle_SetRGBColor_Fill() {
return;
FX_FLOAT values[3];
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++)
values[i] = GetNumber(2 - i);
- }
- CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB);
- m_pCurStates->m_ColorState.SetFillColor(pCS, values, 3);
+
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->SetFillColor(
+ CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), values, 3);
}
void CPDF_StreamContentParser::Handle_SetRGBColor_Stroke() {
@@ -993,11 +999,12 @@ void CPDF_StreamContentParser::Handle_SetRGBColor_Stroke() {
return;
FX_FLOAT values[3];
- for (int i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++)
values[i] = GetNumber(2 - i);
- }
- CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB);
- m_pCurStates->m_ColorState.SetStrokeColor(pCS, values, 3);
+
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->SetStrokeColor(
+ CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), values, 3);
}
void CPDF_StreamContentParser::Handle_SetRenderIntent() {}
@@ -1013,26 +1020,22 @@ void CPDF_StreamContentParser::Handle_StrokePath() {
void CPDF_StreamContentParser::Handle_SetColor_Fill() {
FX_FLOAT values[4];
- int nargs = m_ParamCount;
- if (nargs > 4) {
- nargs = 4;
- }
- for (int i = 0; i < nargs; i++) {
+ uint32_t nargs = std::min(m_ParamCount, 4u);
+ for (uint32_t i = 0; i < nargs; i++)
values[i] = GetNumber(nargs - i - 1);
- }
- m_pCurStates->m_ColorState.SetFillColor(nullptr, values, nargs);
+
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->SetFillColor(nullptr, values, nargs);
}
void CPDF_StreamContentParser::Handle_SetColor_Stroke() {
FX_FLOAT values[4];
- int nargs = m_ParamCount;
- if (nargs > 4) {
- nargs = 4;
- }
- for (int i = 0; i < nargs; i++) {
+ uint32_t nargs = std::min(m_ParamCount, 4u);
+ for (uint32_t i = 0; i < nargs; i++)
values[i] = GetNumber(nargs - i - 1);
- }
- m_pCurStates->m_ColorState.SetStrokeColor(nullptr, values, nargs);
+
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->SetStrokeColor(nullptr, values, nargs);
}
void CPDF_StreamContentParser::Handle_SetColorPS_Fill() {
@@ -1054,10 +1057,12 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Fill() {
if (nvalues != nargs) {
CPDF_Pattern* pPattern = FindPattern(GetString(0), false);
if (pPattern) {
- m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues);
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->SetFillPattern(pPattern, values, nvalues);
}
} else {
- m_pCurStates->m_ColorState.SetFillColor(nullptr, values, nvalues);
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->SetFillColor(nullptr, values, nvalues);
}
FX_Free(values);
}
@@ -1082,10 +1087,12 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() {
if (nvalues != nargs) {
CPDF_Pattern* pPattern = FindPattern(GetString(0), false);
if (pPattern) {
- m_pCurStates->m_ColorState.SetStrokePattern(pPattern, values, nvalues);
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->SetStrokePattern(pPattern, values, nvalues);
}
} else {
- m_pCurStates->m_ColorState.SetStrokeColor(nullptr, values, nvalues);
+ m_pCurStates->m_ColorState.MakePrivateCopy();
+ m_pCurStates->m_ColorState->SetStrokeColor(nullptr, values, nvalues);
}
FX_Free(values);
}
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index e19c9a4a61..756ae020aa 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -776,7 +776,7 @@ void CPDF_ContentParser::Continue(IFX_Pause* pPause) {
nullptr, nullptr, m_pObjectHolder, m_pObjectHolder->m_pResources,
&m_pObjectHolder->m_BBox, nullptr, 0));
m_pParser->GetCurStates()->m_ColorState.MakePrivateCopy();
- m_pParser->GetCurStates()->m_ColorState->Default();
+ m_pParser->GetCurStates()->m_ColorState->SetDefault();
}
if (m_CurrentOffset >= m_Size) {
m_InternalStage = STAGE_CHECKCLIP;
diff --git a/core/fpdfapi/fpdf_render/fpdf_render.cpp b/core/fpdfapi/fpdf_render/fpdf_render.cpp
index 447cc04f06..c53cd2acfd 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -198,17 +198,17 @@ FX_BOOL CPDF_RenderStatus::Initialize(CPDF_RenderContext* pContext,
m_InitialStates.m_ColorState.GetObject();
const CPDF_ColorStateData* pParentData =
pParentState->m_InitialStates.m_ColorState.GetObject();
- if (!pColorData || pColorData->m_FillColor.IsNull()) {
+ if (!pColorData || pColorData->GetFillColor()->IsNull()) {
m_InitialStates.m_ColorState.MakePrivateCopy();
- m_InitialStates.m_ColorState->m_FillRGB = pParentData->m_FillRGB;
- m_InitialStates.m_ColorState->m_FillColor.Copy(
- &pParentData->m_FillColor);
+ m_InitialStates.m_ColorState->SetFillRGB(pParentData->GetFillRGB());
+ m_InitialStates.m_ColorState->GetFillColor()->Copy(
+ pParentData->GetFillColor());
}
- if (!pColorData || pColorData->m_StrokeColor.IsNull()) {
+ if (!pColorData || pColorData->GetStrokeColor()->IsNull()) {
m_InitialStates.m_ColorState.MakePrivateCopy();
- m_InitialStates.m_ColorState->m_StrokeRGB = pParentData->m_FillRGB;
- m_InitialStates.m_ColorState->m_StrokeColor.Copy(
- &pParentData->m_StrokeColor);
+ m_InitialStates.m_ColorState->SetStrokeRGB(pParentData->GetFillRGB());
+ m_InitialStates.m_ColorState->GetStrokeColor()->Copy(
+ pParentData->GetStrokeColor());
}
}
} else {
@@ -514,13 +514,13 @@ FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj,
if (m_pType3Char && !bType3 &&
(!m_pType3Char->m_bColored ||
(m_pType3Char->m_bColored &&
- (!pColorData || pColorData->m_FillColor.IsNull())))) {
+ (!pColorData || pColorData->GetFillColor()->IsNull())))) {
return m_T3FillColor;
}
- if (!pColorData || pColorData->m_FillColor.IsNull()) {
+ if (!pColorData || pColorData->GetFillColor()->IsNull()) {
pColorData = m_InitialStates.m_ColorState.GetObject();
}
- FX_COLORREF rgb = pColorData->m_FillRGB;
+ FX_COLORREF rgb = pColorData->GetFillRGB();
if (rgb == (uint32_t)-1) {
return 0;
}
@@ -544,15 +544,16 @@ FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj,
}
FX_ARGB CPDF_RenderStatus::GetStrokeArgb(const CPDF_PageObject* pObj) const {
const CPDF_ColorStateData* pColorData = pObj->m_ColorState.GetObject();
- if (m_pType3Char && (!m_pType3Char->m_bColored ||
- (m_pType3Char->m_bColored &&
- (!pColorData || pColorData->m_StrokeColor.IsNull())))) {
+ if (m_pType3Char &&
+ (!m_pType3Char->m_bColored ||
+ (m_pType3Char->m_bColored &&
+ (!pColorData || pColorData->GetStrokeColor()->IsNull())))) {
return m_T3FillColor;
}
- if (!pColorData || pColorData->m_StrokeColor.IsNull()) {
+ if (!pColorData || pColorData->GetStrokeColor()->IsNull()) {
pColorData = m_InitialStates.m_ColorState.GetObject();
}
- FX_COLORREF rgb = pColorData->m_StrokeRGB;
+ FX_COLORREF rgb = pColorData->GetStrokeRGB();
if (rgb == (uint32_t)-1) {
return 0;
}
@@ -918,14 +919,14 @@ CPDF_GraphicStates* CPDF_RenderStatus::CloneObjStates(
CPDF_GraphicStates* pStates = new CPDF_GraphicStates;
pStates->CopyStates(*pSrcStates);
const CPDF_Color* pObjColor = bStroke
- ? pSrcStates->m_ColorState.GetStrokeColor()
- : pSrcStates->m_ColorState.GetFillColor();
+ ? pSrcStates->m_ColorState->GetStrokeColor()
+ : pSrcStates->m_ColorState->GetFillColor();
if (!pObjColor->IsNull()) {
pStates->m_ColorState.MakePrivateCopy();
- pStates->m_ColorState->m_FillRGB =
- bStroke ? pSrcStates->m_ColorState->m_StrokeRGB
- : pSrcStates->m_ColorState->m_FillRGB;
- pStates->m_ColorState->m_StrokeRGB = pStates->m_ColorState->m_FillRGB;
+ pStates->m_ColorState->SetFillRGB(
+ bStroke ? pSrcStates->m_ColorState->GetStrokeRGB()
+ : pSrcStates->m_ColorState->GetFillRGB());
+ pStates->m_ColorState->SetStrokeRGB(pStates->m_ColorState->GetFillRGB());
}
return pStates;
}
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
index 295ac4f7d7..b1f09f8c02 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()) {
- const 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 fc06c0be57..b4e5aea8d4 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -1186,14 +1186,14 @@ void CPDF_RenderStatus::ProcessPathPattern(const CPDF_PathObject* pPathObj,
int& filltype,
FX_BOOL& bStroke) {
if (filltype) {
- const 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) {
- const 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/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
index 387ecff27c..fb66e27796 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -279,14 +279,14 @@ FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj,
FX_ARGB fill_argb = 0;
bool bPattern = false;
if (bStroke) {
- if (textobj->m_ColorState.GetStrokeColor()->IsPattern()) {
+ if (textobj->m_ColorState->GetStrokeColor()->IsPattern()) {
bPattern = true;
} else {
stroke_argb = GetStrokeArgb(textobj);
}
}
if (bFill) {
- if (textobj->m_ColorState.GetFillColor()->IsPattern()) {
+ if (textobj->m_ColorState->GetFillColor()->IsPattern()) {
bPattern = true;
} else {
fill_argb = GetFillArgb(textobj);