diff options
Diffstat (limited to 'core/fpdfapi/page')
-rw-r--r-- | core/fpdfapi/page/cpdf_color.cpp | 25 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_color.h | 8 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_colorstate.cpp | 12 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_colorstate.h | 4 |
4 files changed, 28 insertions, 21 deletions
diff --git a/core/fpdfapi/page/cpdf_color.cpp b/core/fpdfapi/page/cpdf_color.cpp index 44b2e4023d..d772deb530 100644 --- a/core/fpdfapi/page/cpdf_color.cpp +++ b/core/fpdfapi/page/cpdf_color.cpp @@ -12,7 +12,11 @@ #include "core/fpdfapi/parser/cpdf_document.h" #include "core/fxcrt/fx_system.h" -CPDF_Color::CPDF_Color() {} +CPDF_Color::CPDF_Color() = default; + +CPDF_Color::CPDF_Color(const CPDF_Color& that) { + *this = that; +} CPDF_Color::~CPDF_Color() { ReleaseBuffer(); @@ -119,32 +123,37 @@ void CPDF_Color::SetValueForPattern(CPDF_Pattern* pPattern, } } -void CPDF_Color::Copy(const CPDF_Color& src) { +CPDF_Color& CPDF_Color::operator=(const CPDF_Color& that) { + if (this == &that) + return *this; + ReleaseBuffer(); ReleaseColorSpace(); - m_pCS = src.m_pCS; + m_pCS = that.m_pCS; if (!m_pCS) - return; + return *this; CPDF_Document* pDoc = m_pCS->GetDocument(); const CPDF_Array* pArray = m_pCS->GetArray(); if (pDoc && pArray) { m_pCS = pDoc->GetPageData()->GetCopiedColorSpace(pArray); if (!m_pCS) - return; + return *this; } m_pBuffer = m_pCS->CreateBuf(); - memcpy(m_pBuffer, src.m_pBuffer, m_pCS->GetBufSize()); + memcpy(m_pBuffer, that.m_pBuffer, m_pCS->GetBufSize()); if (!IsPatternInternal()) - return; + return *this; PatternValue* pValue = reinterpret_cast<PatternValue*>(m_pBuffer); CPDF_Pattern* pPattern = pValue->m_pPattern; if (!pPattern) - return; + return *this; pValue->m_pPattern = pPattern->document()->GetPageData()->GetPattern( pPattern->pattern_obj(), false, pPattern->parent_matrix()); + + return *this; } uint32_t CPDF_Color::CountComponents() const { diff --git a/core/fpdfapi/page/cpdf_color.h b/core/fpdfapi/page/cpdf_color.h index 3448c152e2..084cc28f95 100644 --- a/core/fpdfapi/page/cpdf_color.h +++ b/core/fpdfapi/page/cpdf_color.h @@ -17,18 +17,18 @@ class CPDF_Pattern; class CPDF_Color { public: CPDF_Color(); + CPDF_Color(const CPDF_Color& that); + ~CPDF_Color(); + CPDF_Color& operator=(const CPDF_Color& that); + bool IsNull() const { return !m_pBuffer; } bool IsPattern() const; - - void Copy(const CPDF_Color& src); - void SetColorSpace(CPDF_ColorSpace* pCS); void SetValueForNonPattern(const std::vector<float>& values); void SetValueForPattern(CPDF_Pattern* pPattern, const std::vector<float>& values); - uint32_t CountComponents() const; bool IsColorSpaceRGB() const; bool GetRGB(int* R, int* G, int* B) const; diff --git a/core/fpdfapi/page/cpdf_colorstate.cpp b/core/fpdfapi/page/cpdf_colorstate.cpp index 05421dc873..c31ea14f0d 100644 --- a/core/fpdfapi/page/cpdf_colorstate.cpp +++ b/core/fpdfapi/page/cpdf_colorstate.cpp @@ -137,17 +137,15 @@ void CPDF_ColorState::SetPattern(CPDF_Pattern* pPattern, *colorref = ret ? FXSYS_BGR(B, G, R) : 0xFFFFFFFF; } -CPDF_ColorState::ColorData::ColorData() - : m_FillColorRef(0), m_StrokeColorRef(0) {} +CPDF_ColorState::ColorData::ColorData() = default; CPDF_ColorState::ColorData::ColorData(const ColorData& src) : m_FillColorRef(src.m_FillColorRef), - m_StrokeColorRef(src.m_StrokeColorRef) { - m_FillColor.Copy(src.m_FillColor); - m_StrokeColor.Copy(src.m_StrokeColor); -} + m_StrokeColorRef(src.m_StrokeColorRef), + m_FillColor(src.m_FillColor), + m_StrokeColor(src.m_StrokeColor) {} -CPDF_ColorState::ColorData::~ColorData() {} +CPDF_ColorState::ColorData::~ColorData() = default; void CPDF_ColorState::ColorData::SetDefault() { m_FillColorRef = 0; diff --git a/core/fpdfapi/page/cpdf_colorstate.h b/core/fpdfapi/page/cpdf_colorstate.h index 7b72a2a9d2..cc8d91d818 100644 --- a/core/fpdfapi/page/cpdf_colorstate.h +++ b/core/fpdfapi/page/cpdf_colorstate.h @@ -58,8 +58,8 @@ class CPDF_ColorState { void SetDefault(); - FX_COLORREF m_FillColorRef; - FX_COLORREF m_StrokeColorRef; + FX_COLORREF m_FillColorRef = 0; + FX_COLORREF m_StrokeColorRef = 0; CPDF_Color m_FillColor; CPDF_Color m_StrokeColor; }; |