From 584b1e679f41a580e2b38d5534f126355c78043b Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 21 Mar 2016 09:15:45 -0400 Subject: 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 . --- core/fpdfapi/fpdf_page/cpdf_colorstate.cpp | 70 ++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 core/fpdfapi/fpdf_page/cpdf_colorstate.cpp (limited to 'core/fpdfapi/fpdf_page/cpdf_colorstate.cpp') 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; +} -- cgit v1.2.3