summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r--core/fpdfapi/page/cpdf_colorstate.cpp48
-rw-r--r--core/fpdfapi/page/cpdf_colorstate.h4
2 files changed, 27 insertions, 25 deletions
diff --git a/core/fpdfapi/page/cpdf_colorstate.cpp b/core/fpdfapi/page/cpdf_colorstate.cpp
index 9abd9f78e4..05421dc873 100644
--- a/core/fpdfapi/page/cpdf_colorstate.cpp
+++ b/core/fpdfapi/page/cpdf_colorstate.cpp
@@ -84,36 +84,13 @@ void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS,
void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
const std::vector<float>& values) {
ColorData* pData = m_Ref.GetPrivateCopy();
- pData->m_FillColor.SetValueForPattern(pPattern, values);
- int R;
- int G;
- int B;
- bool ret = pData->m_FillColor.GetRGB(&R, &G, &B);
- if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) {
- if (!ret && pTilingPattern->colored()) {
- pData->m_FillColorRef = 0x00BFBFBF;
- return;
- }
- }
- pData->m_FillColorRef = ret ? FXSYS_BGR(B, G, R) : 0xFFFFFFFF;
+ SetPattern(pPattern, values, &pData->m_FillColor, &pData->m_FillColorRef);
}
void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
const std::vector<float>& values) {
ColorData* pData = m_Ref.GetPrivateCopy();
- pData->m_StrokeColor.SetValueForPattern(pPattern, values);
- int R;
- int G;
- int B;
- bool ret = pData->m_StrokeColor.GetRGB(&R, &G, &B);
- if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) {
- if (!ret && pTilingPattern->colored()) {
- pData->m_StrokeColorRef = 0x00BFBFBF;
- return;
- }
- }
- pData->m_StrokeColorRef =
- pData->m_StrokeColor.GetRGB(&R, &G, &B) ? FXSYS_BGR(B, G, R) : 0xFFFFFFFF;
+ SetPattern(pPattern, values, &pData->m_StrokeColor, &pData->m_StrokeColorRef);
}
void CPDF_ColorState::SetColor(CPDF_ColorSpace* pCS,
@@ -139,6 +116,27 @@ void CPDF_ColorState::SetColor(CPDF_ColorSpace* pCS,
*colorref = color->GetRGB(&R, &G, &B) ? FXSYS_BGR(B, G, R) : 0xFFFFFFFF;
}
+void CPDF_ColorState::SetPattern(CPDF_Pattern* pPattern,
+ const std::vector<float>& values,
+ CPDF_Color* color,
+ FX_COLORREF* colorref) {
+ ASSERT(color);
+ ASSERT(colorref);
+
+ color->SetValueForPattern(pPattern, values);
+ int R;
+ int G;
+ int B;
+ bool ret = color->GetRGB(&R, &G, &B);
+ if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) {
+ if (!ret && pTilingPattern->colored()) {
+ *colorref = 0x00BFBFBF;
+ return;
+ }
+ }
+ *colorref = ret ? FXSYS_BGR(B, G, R) : 0xFFFFFFFF;
+}
+
CPDF_ColorState::ColorData::ColorData()
: m_FillColorRef(0), m_StrokeColorRef(0) {}
diff --git a/core/fpdfapi/page/cpdf_colorstate.h b/core/fpdfapi/page/cpdf_colorstate.h
index a617409268..49416db1d5 100644
--- a/core/fpdfapi/page/cpdf_colorstate.h
+++ b/core/fpdfapi/page/cpdf_colorstate.h
@@ -68,6 +68,10 @@ class CPDF_ColorState {
const std::vector<float>& values,
CPDF_Color* color,
FX_COLORREF* colorref);
+ void SetPattern(CPDF_Pattern* pPattern,
+ const std::vector<float>& values,
+ CPDF_Color* color,
+ FX_COLORREF* colorref);
SharedCopyOnWrite<ColorData> m_Ref;
};