summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_color.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-09-21 19:47:47 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-09-21 19:47:47 +0000
commitfbea60879c6a8db4604e6e0f23216c6ee5f238df (patch)
tree6d5d57825914d2fc64367195f60bb042b218f31b /core/fpdfapi/page/cpdf_color.cpp
parentb1d6afbeef3213412e2b45269cab36d016c60bcd (diff)
downloadpdfium-fbea60879c6a8db4604e6e0f23216c6ee5f238df.tar.xz
Replace CPDF_Color::Copy() with honest-to-goodness operator=().
Change-Id: Ifcce7b1e513c8859752d5248ae686bbe5349e342 Reviewed-on: https://pdfium-review.googlesource.com/42614 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/page/cpdf_color.cpp')
-rw-r--r--core/fpdfapi/page/cpdf_color.cpp25
1 files changed, 17 insertions, 8 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 {