summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-03-21 09:15:45 -0400
committerDan Sinclair <dsinclair@chromium.org>2016-03-21 09:15:45 -0400
commit584b1e679f41a580e2b38d5534f126355c78043b (patch)
treeca3f78bc30673b9c4650433168efe574920c60f1 /core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
parentedbb319d3143692befdbb0603089b7e265cf89aa (diff)
downloadpdfium-584b1e679f41a580e2b38d5534f126355c78043b.tar.xz
Move core/include/fpdfapi/fpdf_pageobj.h into core/fpdfapi.
This CL splits the file into individual classes and moves them into core/fpdfapi/fpdf_page as needed. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1811053002 .
Diffstat (limited to 'core/fpdfapi/fpdf_page/cpdf_colorstate.cpp')
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorstate.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp b/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
new file mode 100644
index 0000000000..02999c9d13
--- /dev/null
+++ b/core/fpdfapi/fpdf_page/cpdf_colorstate.cpp
@@ -0,0 +1,70 @@
+// 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"
+
+void CPDF_ColorState::SetFillColor(CPDF_ColorSpace* pCS,
+ FX_FLOAT* pValue,
+ int nValues) {
+ CPDF_ColorStateData* pData = GetModify();
+ SetColor(pData->m_FillColor, pData->m_FillRGB, pCS, pValue, nValues);
+}
+
+void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS,
+ FX_FLOAT* pValue,
+ int nValues) {
+ CPDF_ColorStateData* pData = GetModify();
+ SetColor(pData->m_StrokeColor, pData->m_StrokeRGB, pCS, pValue, nValues);
+}
+
+void CPDF_ColorState::SetColor(CPDF_Color& color,
+ FX_DWORD& rgb,
+ CPDF_ColorSpace* pCS,
+ FX_FLOAT* pValue,
+ int nValues) {
+ if (pCS) {
+ color.SetColorSpace(pCS);
+ } else if (color.IsNull()) {
+ color.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY));
+ }
+ if (color.m_pCS->CountComponents() > nValues) {
+ return;
+ }
+ color.SetValue(pValue);
+ int R, G, B;
+ rgb = color.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (FX_DWORD)-1;
+}
+
+void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern,
+ FX_FLOAT* pValue,
+ int nValues) {
+ CPDF_ColorStateData* pData = GetModify();
+ pData->m_FillColor.SetValue(pPattern, pValue, nValues);
+ int R, G, B;
+ FX_BOOL ret = pData->m_FillColor.GetRGB(R, G, B);
+ if (pPattern->m_PatternType == 1 &&
+ ((CPDF_TilingPattern*)pPattern)->m_bColored && !ret) {
+ pData->m_FillRGB = 0x00BFBFBF;
+ return;
+ }
+ pData->m_FillRGB = ret ? FXSYS_RGB(R, G, B) : (FX_DWORD)-1;
+}
+
+void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern,
+ FX_FLOAT* pValue,
+ int nValues) {
+ CPDF_ColorStateData* pData = GetModify();
+ pData->m_StrokeColor.SetValue(pPattern, pValue, nValues);
+ int R, G, B;
+ FX_BOOL ret = pData->m_StrokeColor.GetRGB(R, G, B);
+ if (pPattern->m_PatternType == 1 &&
+ ((CPDF_TilingPattern*)pPattern)->m_bColored && !ret) {
+ pData->m_StrokeRGB = 0x00BFBFBF;
+ return;
+ }
+ pData->m_StrokeRGB =
+ pData->m_StrokeColor.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (FX_DWORD)-1;
+}