From dd2a629f9ede484e0e570ce09d1e9d8906aa11be Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 20 Apr 2018 19:14:53 +0000 Subject: Add CPDF_PatternCS::GetPatternRGB(const PatternValue& value). Currently, one gets data from CPDF_PatternCS via its parent class's GetRGB(const float* pBuf) method. To squeeze through this interface, the caller has to pass in a float*, and CPDF_PatternCS::GetRGB() has to cast it to PatternValue*. Instead of doing casting, add a specialized GetPatternRGB() method to CPDF_PatternCS. In its parent class, CPDF_ColorSpace, add AsPatternCS() so callers can get a CPDF_PatternCS* from a CPDF_ColorSpace*. Change existing callers to use these new methods. Change-Id: Id476c9ece7ce8d3499a718acc682bc25036a5407 Reviewed-on: https://pdfium-review.googlesource.com/31030 Reviewed-by: Henrique Nakashima Commit-Queue: Lei Zhang --- core/fpdfapi/page/cpdf_patterncs.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'core/fpdfapi/page/cpdf_patterncs.cpp') diff --git a/core/fpdfapi/page/cpdf_patterncs.cpp b/core/fpdfapi/page/cpdf_patterncs.cpp index 5da176984b..37e91aa4e0 100644 --- a/core/fpdfapi/page/cpdf_patterncs.cpp +++ b/core/fpdfapi/page/cpdf_patterncs.cpp @@ -54,12 +54,25 @@ bool CPDF_PatternCS::GetRGB(const float* pBuf, float* R, float* G, float* B) const { - if (m_pBaseCS) { - ASSERT(m_pBaseCS->GetFamily() != PDFCS_PATTERN); - const auto* pvalue = reinterpret_cast(pBuf); - if (m_pBaseCS->GetRGB(pvalue->m_Comps, R, G, B)) - return true; - } + NOTREACHED(); + return false; +} + +CPDF_PatternCS* CPDF_PatternCS::AsPatternCS() { + return this; +} + +const CPDF_PatternCS* CPDF_PatternCS::AsPatternCS() const { + return this; +} + +bool CPDF_PatternCS::GetPatternRGB(const PatternValue& value, + float* R, + float* G, + float* B) const { + if (m_pBaseCS && m_pBaseCS->GetRGB(value.m_Comps, R, G, B)) + return true; + *R = 0.75f; *G = 0.75f; *B = 0.75f; -- cgit v1.2.3