summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_page
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/fpdf_page')
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorstate.cpp31
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorstate.h21
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp20
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorstatedata.h26
4 files changed, 40 insertions, 58 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp b/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
index e4e266785a..c6a5254c0f 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
@@ -22,7 +22,7 @@ void CPDF_ColorState::Emplace() {
}
void CPDF_ColorState::SetDefault() {
- m_Ref.GetPrivateCopy()->Default();
+ m_Ref.GetPrivateCopy()->SetDefault();
}
uint32_t CPDF_ColorState::GetFillRGB() const {
@@ -42,7 +42,7 @@ void CPDF_ColorState::SetStrokeRGB(uint32_t rgb) {
}
const CPDF_Color* CPDF_ColorState::GetFillColor() const {
- const CPDF_ColorStateData* pData = m_Ref.GetObject();
+ const ColorData* pData = m_Ref.GetObject();
return pData ? &pData->m_FillColor : nullptr;
}
@@ -56,7 +56,7 @@ bool CPDF_ColorState::HasFillColor() const {
}
const CPDF_Color* CPDF_ColorState::GetStrokeColor() const {
- const CPDF_ColorStateData* pData = m_Ref.GetObject();
+ const ColorData* pData = m_Ref.GetObject();
return pData ? &pData->m_StrokeColor : nullptr;
}
@@ -72,21 +72,21 @@ bool CPDF_ColorState::HasStrokeColor() const {
void CPDF_ColorState::SetFillColor(CPDF_ColorSpace* pCS,
FX_FLOAT* pValue,
uint32_t nValues) {
- CPDF_ColorStateData* pData = m_Ref.GetPrivateCopy();
+ ColorData* pData = m_Ref.GetPrivateCopy();
SetColor(pData->m_FillColor, pData->m_FillRGB, pCS, pValue, nValues);
}
void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS,
FX_FLOAT* pValue,
uint32_t nValues) {
- CPDF_ColorStateData* pData = m_Ref.GetPrivateCopy();
+ ColorData* pData = m_Ref.GetPrivateCopy();
SetColor(pData->m_StrokeColor, pData->m_StrokeRGB, pCS, pValue, nValues);
}
void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
FX_FLOAT* pValue,
uint32_t nValues) {
- CPDF_ColorStateData* pData = m_Ref.GetPrivateCopy();
+ ColorData* pData = m_Ref.GetPrivateCopy();
pData->m_FillColor.SetValue(pPattern, pValue, nValues);
int R, G, B;
FX_BOOL ret = pData->m_FillColor.GetRGB(R, G, B);
@@ -102,7 +102,7 @@ void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
FX_FLOAT* pValue,
uint32_t nValues) {
- CPDF_ColorStateData* pData = m_Ref.GetPrivateCopy();
+ ColorData* pData = m_Ref.GetPrivateCopy();
pData->m_StrokeColor.SetValue(pPattern, pValue, nValues);
int R, G, B;
FX_BOOL ret = pData->m_StrokeColor.GetRGB(R, G, B);
@@ -135,3 +135,20 @@ void CPDF_ColorState::SetColor(CPDF_Color& color,
int B;
rgb = color.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (uint32_t)-1;
}
+
+CPDF_ColorState::ColorData::ColorData() : m_FillRGB(0), m_StrokeRGB(0) {}
+
+CPDF_ColorState::ColorData::ColorData(const ColorData& src)
+ : m_FillRGB(src.m_FillRGB), m_StrokeRGB(src.m_StrokeRGB) {
+ m_FillColor.Copy(&src.m_FillColor);
+ m_StrokeColor.Copy(&src.m_StrokeColor);
+}
+
+CPDF_ColorState::ColorData::~ColorData() {}
+
+void CPDF_ColorState::ColorData::SetDefault() {
+ m_FillRGB = 0;
+ m_StrokeRGB = 0;
+ m_FillColor.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY));
+ m_StrokeColor.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY));
+}
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstate.h b/core/fpdfapi/fpdf_page/cpdf_colorstate.h
index a4077d965f..f6f72a2b46 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorstate.h
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstate.h
@@ -7,7 +7,7 @@
#ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATE_H_
#define CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATE_H_
-#include "core/fpdfapi/fpdf_page/cpdf_colorstatedata.h"
+#include "core/fpdfapi/fpdf_page/include/cpdf_color.h"
#include "core/fxcrt/include/cfx_count_ref.h"
#include "core/fxcrt/include/fx_basic.h"
#include "core/fxcrt/include/fx_system.h"
@@ -48,19 +48,30 @@ class CPDF_ColorState {
FX_FLOAT* pValue,
uint32_t nValues);
- // TODO(tsepez): Stop leaking ColorStateData outside this class.
- const CPDF_ColorStateData* GetObject() const { return m_Ref.GetObject(); }
-
explicit operator bool() const { return !!m_Ref; }
private:
+ class ColorData {
+ public:
+ ColorData();
+ ColorData(const ColorData& src);
+ ~ColorData();
+
+ void SetDefault();
+
+ uint32_t m_FillRGB;
+ uint32_t m_StrokeRGB;
+ CPDF_Color m_FillColor;
+ CPDF_Color m_StrokeColor;
+ };
+
void SetColor(CPDF_Color& color,
uint32_t& rgb,
CPDF_ColorSpace* pCS,
FX_FLOAT* pValue,
uint32_t nValues);
- CFX_CountRef<CPDF_ColorStateData> m_Ref;
+ CFX_CountRef<ColorData> m_Ref;
};
#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
deleted file mode 100644
index 9dbcdec267..0000000000
--- a/core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp
+++ /dev/null
@@ -1,20 +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_colorstatedata.h"
-
-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::Default() {
- m_FillRGB = m_StrokeRGB = 0;
- m_FillColor.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY));
- m_StrokeColor.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY));
-}
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstatedata.h b/core/fpdfapi/fpdf_page/cpdf_colorstatedata.h
deleted file mode 100644
index 6a992ad0b1..0000000000
--- a/core/fpdfapi/fpdf_page/cpdf_colorstatedata.h
+++ /dev/null
@@ -1,26 +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
-
-#ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATEDATA_H_
-#define CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATEDATA_H_
-
-#include "core/fpdfapi/fpdf_page/include/cpdf_color.h"
-#include "core/fxcrt/include/fx_system.h"
-
-class CPDF_ColorStateData {
- public:
- CPDF_ColorStateData() : m_FillRGB(0), m_StrokeRGB(0) {}
- CPDF_ColorStateData(const CPDF_ColorStateData& src);
-
- void Default();
-
- CPDF_Color m_FillColor;
- uint32_t m_FillRGB;
- CPDF_Color m_StrokeColor;
- uint32_t m_StrokeRGB;
-};
-
-#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATEDATA_H_