summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_color.cpp8
-rw-r--r--core/fpdfapi/page/cpdf_color.h4
-rw-r--r--core/fpdfapi/page/cpdf_colorstate.cpp2
4 files changed, 12 insertions, 5 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
index 0584e7be48..2a59123344 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
@@ -37,8 +37,7 @@ std::ostream& operator<<(std::ostream& ar, const CFX_Matrix& matrix) {
bool GetColor(const CPDF_Color* pColor, float* rgb) {
int intRGB[3];
- if (!pColor ||
- pColor->GetColorSpace() != CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB) ||
+ if (!pColor || !pColor->IsColorSpaceRGB() ||
!pColor->GetRGB(&intRGB[0], &intRGB[1], &intRGB[2])) {
return false;
}
diff --git a/core/fpdfapi/page/cpdf_color.cpp b/core/fpdfapi/page/cpdf_color.cpp
index 3c87457d1b..dfee9d93ca 100644
--- a/core/fpdfapi/page/cpdf_color.cpp
+++ b/core/fpdfapi/page/cpdf_color.cpp
@@ -146,6 +146,14 @@ void CPDF_Color::Copy(const CPDF_Color& src) {
pPattern->pattern_obj(), false, pPattern->parent_matrix());
}
+uint32_t CPDF_Color::CountComponents() const {
+ return m_pCS->CountComponents();
+}
+
+bool CPDF_Color::IsColorSpaceRGB() const {
+ return m_pCS == CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB);
+}
+
bool CPDF_Color::GetRGB(int* R, int* G, int* B) const {
if (!m_pCS || !m_pBuffer)
return false;
diff --git a/core/fpdfapi/page/cpdf_color.h b/core/fpdfapi/page/cpdf_color.h
index 9b94f0d53b..3448c152e2 100644
--- a/core/fpdfapi/page/cpdf_color.h
+++ b/core/fpdfapi/page/cpdf_color.h
@@ -29,13 +29,13 @@ class CPDF_Color {
void SetValueForPattern(CPDF_Pattern* pPattern,
const std::vector<float>& values);
+ uint32_t CountComponents() const;
+ bool IsColorSpaceRGB() const;
bool GetRGB(int* R, int* G, int* B) const;
// Should only be called if IsPattern() returns true.
CPDF_Pattern* GetPattern() const;
- const CPDF_ColorSpace* GetColorSpace() const { return m_pCS; }
-
protected:
void ReleaseBuffer();
void ReleaseColorSpace();
diff --git a/core/fpdfapi/page/cpdf_colorstate.cpp b/core/fpdfapi/page/cpdf_colorstate.cpp
index 492114ab00..9abd9f78e4 100644
--- a/core/fpdfapi/page/cpdf_colorstate.cpp
+++ b/core/fpdfapi/page/cpdf_colorstate.cpp
@@ -128,7 +128,7 @@ void CPDF_ColorState::SetColor(CPDF_ColorSpace* pCS,
else if (color->IsNull())
color->SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY));
- if (color->GetColorSpace()->CountComponents() > values.size())
+ if (color->CountComponents() > values.size())
return;
if (!color->IsPattern())