diff options
author | tsepez <tsepez@chromium.org> | 2016-08-29 12:52:56 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-29 12:52:56 -0700 |
commit | 91ddd3f7501429222f648b986a99f3959a398889 (patch) | |
tree | b6a712b9caf63f1e344a6475281226394e1e07c2 /core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp | |
parent | c37d7d452d6a37c997c8709576dd71406ecff618 (diff) | |
download | pdfium-91ddd3f7501429222f648b986a99f3959a398889.tar.xz |
Use ->() in CPDF_ColorState
Move methods to CPDF_ColorStateData.
Move MakePrivateCopy() methods to call sites.
Remove now-empty cpdf_colorstate.cpp file.
Review-Url: https://codereview.chromium.org/2291763002
Diffstat (limited to 'core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp')
-rw-r--r-- | core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp | 74 |
1 files changed, 69 insertions, 5 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp b/core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp index 9dbcdec267..3a771ffaf0 100644 --- a/core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp +++ b/core/fpdfapi/fpdf_page/cpdf_colorstatedata.cpp @@ -6,15 +6,79 @@ #include "core/fpdfapi/fpdf_page/cpdf_colorstatedata.h" -CPDF_ColorStateData::CPDF_ColorStateData(const CPDF_ColorStateData& src) { +#include "core/fpdfapi/fpdf_page/cpdf_tilingpattern.h" +#include "core/fxge/include/fx_dib.h" + +CPDF_ColorStateData::CPDF_ColorStateData(const CPDF_ColorStateData& src) + : m_FillRGB(src.m_FillRGB), m_StrokeRGB(src.m_StrokeRGB) { 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; +void CPDF_ColorStateData::SetDefault() { + m_FillRGB = 0; + m_StrokeRGB = 0; m_FillColor.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY)); m_StrokeColor.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY)); } + +void CPDF_ColorStateData::SetFillColor(CPDF_ColorSpace* pCS, + FX_FLOAT* pValue, + uint32_t nValues) { + SetColor(m_FillColor, m_FillRGB, pCS, pValue, nValues); +} + +void CPDF_ColorStateData::SetStrokeColor(CPDF_ColorSpace* pCS, + FX_FLOAT* pValue, + uint32_t nValues) { + SetColor(m_StrokeColor, m_StrokeRGB, pCS, pValue, nValues); +} + +void CPDF_ColorStateData::SetFillPattern(CPDF_Pattern* pPattern, + FX_FLOAT* pValue, + uint32_t nValues) { + m_FillColor.SetValue(pPattern, pValue, nValues); + int R, G, B; + FX_BOOL ret = m_FillColor.GetRGB(R, G, B); + if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) { + if (!ret && pTilingPattern->colored()) { + m_FillRGB = 0x00BFBFBF; + return; + } + } + m_FillRGB = ret ? FXSYS_RGB(R, G, B) : (uint32_t)-1; +} + +void CPDF_ColorStateData::SetStrokePattern(CPDF_Pattern* pPattern, + FX_FLOAT* pValue, + uint32_t nValues) { + m_StrokeColor.SetValue(pPattern, pValue, nValues); + int R, G, B; + FX_BOOL ret = m_StrokeColor.GetRGB(R, G, B); + if (CPDF_TilingPattern* pTilingPattern = pPattern->AsTilingPattern()) { + if (!ret && pTilingPattern->colored()) { + m_StrokeRGB = 0x00BFBFBF; + return; + } + } + m_StrokeRGB = + m_StrokeColor.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (uint32_t)-1; +} + +void CPDF_ColorStateData::SetColor(CPDF_Color& color, + uint32_t& rgb, + CPDF_ColorSpace* pCS, + FX_FLOAT* pValue, + uint32_t nValues) { + if (pCS) { + color.SetColorSpace(pCS); + } else if (color.IsNull()) { + color.SetColorSpace(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY)); + } + if (color.GetColorSpace()->CountComponents() > nValues) + return; + + color.SetValue(pValue); + int R, G, B; + rgb = color.GetRGB(R, G, B) ? FXSYS_RGB(R, G, B) : (uint32_t)-1; +} |