summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-08-29 14:07:28 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-29 14:07:28 -0700
commitadbd32950006075fc04ff2cbb01bf3a099f0e010 (patch)
tree62ad8839a0190a8cf5e2b0823276e4ba2dbd99a2
parentdda2c0dc502b50d4de66b80305441bfb612ec6c1 (diff)
downloadpdfium-adbd32950006075fc04ff2cbb01bf3a099f0e010.tar.xz
Revert "Use ->() in CPDF_ColorState"
This reverts commit 91ddd3f7501429222f648b986a99f3959a398889. Reason for revert: may introduce sublte bugs, more thought required. TBR=dsinclair@chromium.org Review-Url: https://codereview.chromium.org/2294553002
-rw-r--r--BUILD.gn1
-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
-rw-r--r--fpdfsdk/fxedit/fxet_edit.cpp9
13 files changed, 193 insertions, 187 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 0d277721b4..8d3e2424f4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -411,6 +411,7 @@ static_library("fpdfapi") {
"core/fpdfapi/fpdf_page/cpdf_clippathdata.h",
"core/fpdfapi/fpdf_page/cpdf_color.cpp",
"core/fpdfapi/fpdf_page/cpdf_colorspace.cpp",
+ "core/fpdfapi/fpdf_page/cpdf_colorstate.cpp",
"core/fpdfapi/fpdf_page/cpdf_colorstate.h",
"core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp",
"core/fpdfapi/fpdf_page/cpdf_colorstatedata.h",
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp b/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
new file mode 100644
index 0000000000..a46dea3bb8
--- /dev/null
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
@@ -0,0 +1,80 @@
+// 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 b412947183..128d67558d 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorstate.h
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstate.h
@@ -9,8 +9,40 @@
#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 3a771ffaf0..9dbcdec267 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp
@@ -6,79 +6,15 @@
#include "core/fpdfapi/fpdf_page/cpdf_colorstatedata.h"
-#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) {
+CPDF_ColorStateData::CPDF_ColorStateData(const CPDF_ColorStateData& src) {
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::SetDefault() {
- m_FillRGB = 0;
- m_StrokeRGB = 0;
+void CPDF_ColorStateData::Default() {
+ m_FillRGB = 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 1b8413f3f1..6a992ad0b1 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorstatedata.h
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstatedata.h
@@ -10,49 +10,17 @@
#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 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);
+ void Default();
- private:
- void SetColor(CPDF_Color& color,
- uint32_t& rgb,
- CPDF_ColorSpace* pCS,
- FX_FLOAT* pValue,
- uint32_t nValues);
-
- uint32_t m_FillRGB;
- uint32_t m_StrokeRGB;
CPDF_Color m_FillColor;
+ uint32_t m_FillRGB;
CPDF_Color m_StrokeColor;
+ uint32_t m_StrokeRGB;
};
#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 d1eabb6908..fc054caf21 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()->SetDefault();
+ m_ColorState.New()->Default();
}
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 5dc8480423..5d5b75b60e 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -6,7 +6,6 @@
#include "core/fpdfapi/fpdf_page/pageint.h"
-#include <algorithm>
#include <memory>
#include <utility>
#include <vector>
@@ -693,7 +692,7 @@ void CPDF_StreamContentParser::Handle_SetColorSpace_Fill() {
return;
m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->GetFillColor()->SetColorSpace(pCS);
+ m_pCurStates->m_ColorState->m_FillColor.SetColorSpace(pCS);
}
void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() {
@@ -702,7 +701,7 @@ void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() {
return;
m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->GetStrokeColor()->SetColorSpace(pCS);
+ m_pCurStates->m_ColorState->m_StrokeColor.SetColorSpace(pCS);
}
void CPDF_StreamContentParser::Handle_SetDash() {
@@ -846,16 +845,14 @@ void CPDF_StreamContentParser::Handle_EOFillPath() {
void CPDF_StreamContentParser::Handle_SetGray_Fill() {
FX_FLOAT value = GetNumber(0);
- m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->SetFillColor(
- CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY), &value, 1);
+ CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY);
+ m_pCurStates->m_ColorState.SetFillColor(pCS, &value, 1);
}
void CPDF_StreamContentParser::Handle_SetGray_Stroke() {
FX_FLOAT value = GetNumber(0);
- m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->SetStrokeColor(
- CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY), &value, 1);
+ CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY);
+ m_pCurStates->m_ColorState.SetStrokeColor(pCS, &value, 1);
}
void CPDF_StreamContentParser::Handle_SetExtendGraphState() {
@@ -903,12 +900,11 @@ 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);
-
- m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->SetFillColor(
- CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK), values, 4);
+ }
+ CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK);
+ m_pCurStates->m_ColorState.SetFillColor(pCS, values, 4);
}
void CPDF_StreamContentParser::Handle_SetCMYKColor_Stroke() {
@@ -916,12 +912,11 @@ 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);
-
- m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->SetStrokeColor(
- CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK), values, 4);
+ }
+ CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICECMYK);
+ m_pCurStates->m_ColorState.SetStrokeColor(pCS, values, 4);
}
void CPDF_StreamContentParser::Handle_LineTo() {
@@ -986,12 +981,11 @@ 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);
-
- m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->SetFillColor(
- CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), values, 3);
+ }
+ CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB);
+ m_pCurStates->m_ColorState.SetFillColor(pCS, values, 3);
}
void CPDF_StreamContentParser::Handle_SetRGBColor_Stroke() {
@@ -999,12 +993,11 @@ 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);
-
- m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->SetStrokeColor(
- CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), values, 3);
+ }
+ CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB);
+ m_pCurStates->m_ColorState.SetStrokeColor(pCS, values, 3);
}
void CPDF_StreamContentParser::Handle_SetRenderIntent() {}
@@ -1020,22 +1013,26 @@ void CPDF_StreamContentParser::Handle_StrokePath() {
void CPDF_StreamContentParser::Handle_SetColor_Fill() {
FX_FLOAT values[4];
- uint32_t nargs = std::min(m_ParamCount, 4u);
- for (uint32_t i = 0; i < nargs; i++)
+ int nargs = m_ParamCount;
+ if (nargs > 4) {
+ nargs = 4;
+ }
+ for (int i = 0; i < nargs; i++) {
values[i] = GetNumber(nargs - i - 1);
-
- m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->SetFillColor(nullptr, values, nargs);
+ }
+ m_pCurStates->m_ColorState.SetFillColor(nullptr, values, nargs);
}
void CPDF_StreamContentParser::Handle_SetColor_Stroke() {
FX_FLOAT values[4];
- uint32_t nargs = std::min(m_ParamCount, 4u);
- for (uint32_t i = 0; i < nargs; i++)
+ int nargs = m_ParamCount;
+ if (nargs > 4) {
+ nargs = 4;
+ }
+ for (int i = 0; i < nargs; i++) {
values[i] = GetNumber(nargs - i - 1);
-
- m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->SetStrokeColor(nullptr, values, nargs);
+ }
+ m_pCurStates->m_ColorState.SetStrokeColor(nullptr, values, nargs);
}
void CPDF_StreamContentParser::Handle_SetColorPS_Fill() {
@@ -1057,12 +1054,10 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Fill() {
if (nvalues != nargs) {
CPDF_Pattern* pPattern = FindPattern(GetString(0), false);
if (pPattern) {
- m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->SetFillPattern(pPattern, values, nvalues);
+ m_pCurStates->m_ColorState.SetFillPattern(pPattern, values, nvalues);
}
} else {
- m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->SetFillColor(nullptr, values, nvalues);
+ m_pCurStates->m_ColorState.SetFillColor(nullptr, values, nvalues);
}
FX_Free(values);
}
@@ -1087,12 +1082,10 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() {
if (nvalues != nargs) {
CPDF_Pattern* pPattern = FindPattern(GetString(0), false);
if (pPattern) {
- m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->SetStrokePattern(pPattern, values, nvalues);
+ m_pCurStates->m_ColorState.SetStrokePattern(pPattern, values, nvalues);
}
} else {
- m_pCurStates->m_ColorState.MakePrivateCopy();
- m_pCurStates->m_ColorState->SetStrokeColor(nullptr, values, nvalues);
+ 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 756ae020aa..e19c9a4a61 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->SetDefault();
+ m_pParser->GetCurStates()->m_ColorState->Default();
}
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 c53cd2acfd..447cc04f06 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->GetFillColor()->IsNull()) {
+ if (!pColorData || pColorData->m_FillColor.IsNull()) {
m_InitialStates.m_ColorState.MakePrivateCopy();
- m_InitialStates.m_ColorState->SetFillRGB(pParentData->GetFillRGB());
- m_InitialStates.m_ColorState->GetFillColor()->Copy(
- pParentData->GetFillColor());
+ m_InitialStates.m_ColorState->m_FillRGB = pParentData->m_FillRGB;
+ m_InitialStates.m_ColorState->m_FillColor.Copy(
+ &pParentData->m_FillColor);
}
- if (!pColorData || pColorData->GetStrokeColor()->IsNull()) {
+ if (!pColorData || pColorData->m_StrokeColor.IsNull()) {
m_InitialStates.m_ColorState.MakePrivateCopy();
- m_InitialStates.m_ColorState->SetStrokeRGB(pParentData->GetFillRGB());
- m_InitialStates.m_ColorState->GetStrokeColor()->Copy(
- pParentData->GetStrokeColor());
+ m_InitialStates.m_ColorState->m_StrokeRGB = pParentData->m_FillRGB;
+ m_InitialStates.m_ColorState->m_StrokeColor.Copy(
+ &pParentData->m_StrokeColor);
}
}
} 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->GetFillColor()->IsNull())))) {
+ (!pColorData || pColorData->m_FillColor.IsNull())))) {
return m_T3FillColor;
}
- if (!pColorData || pColorData->GetFillColor()->IsNull()) {
+ if (!pColorData || pColorData->m_FillColor.IsNull()) {
pColorData = m_InitialStates.m_ColorState.GetObject();
}
- FX_COLORREF rgb = pColorData->GetFillRGB();
+ FX_COLORREF rgb = pColorData->m_FillRGB;
if (rgb == (uint32_t)-1) {
return 0;
}
@@ -544,16 +544,15 @@ 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->GetStrokeColor()->IsNull())))) {
+ if (m_pType3Char && (!m_pType3Char->m_bColored ||
+ (m_pType3Char->m_bColored &&
+ (!pColorData || pColorData->m_StrokeColor.IsNull())))) {
return m_T3FillColor;
}
- if (!pColorData || pColorData->GetStrokeColor()->IsNull()) {
+ if (!pColorData || pColorData->m_StrokeColor.IsNull()) {
pColorData = m_InitialStates.m_ColorState.GetObject();
}
- FX_COLORREF rgb = pColorData->GetStrokeRGB();
+ FX_COLORREF rgb = pColorData->m_StrokeRGB;
if (rgb == (uint32_t)-1) {
return 0;
}
@@ -919,14 +918,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->SetFillRGB(
- bStroke ? pSrcStates->m_ColorState->GetStrokeRGB()
- : pSrcStates->m_ColorState->GetFillRGB());
- pStates->m_ColorState->SetStrokeRGB(pStates->m_ColorState->GetFillRGB());
+ 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;
}
return pStates;
}
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
index b1f09f8c02..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()) {
- 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 b4e5aea8d4..fc06c0be57 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 fb66e27796..387ecff27c 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);
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index 97debe1764..c744958e5e 100644
--- a/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -145,8 +145,7 @@ void AddRectToPageObjects(CPDF_PageObjectHolder* pObjectHolder,
rgb[0] = FXARGB_R(crFill) / 255.0f;
rgb[1] = FXARGB_G(crFill) / 255.0f;
rgb[2] = FXARGB_B(crFill) / 255.0f;
- pPathObj->m_ColorState.MakePrivateCopy();
- pPathObj->m_ColorState->SetFillColor(
+ pPathObj->m_ColorState.SetFillColor(
CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
pPathObj->m_FillType = FXFILL_ALTERNATE;
@@ -178,11 +177,9 @@ CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjectHolder* pObjectHolder,
rgb[0] = FXARGB_R(crText) / 255.0f;
rgb[1] = FXARGB_G(crText) / 255.0f;
rgb[2] = FXARGB_B(crText) / 255.0f;
-
- pTxtObj->m_ColorState.MakePrivateCopy();
- pTxtObj->m_ColorState->SetFillColor(
+ pTxtObj->m_ColorState.SetFillColor(
CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
- pTxtObj->m_ColorState->SetStrokeColor(
+ pTxtObj->m_ColorState.SetStrokeColor(
CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
pTxtObj->SetPosition(point.x, point.y);