summaryrefslogtreecommitdiff
path: root/core
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
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')
-rw-r--r--core/fpdfapi/page/cpdf_color.cpp25
-rw-r--r--core/fpdfapi/page/cpdf_color.h8
-rw-r--r--core/fpdfapi/page/cpdf_colorstate.cpp12
-rw-r--r--core/fpdfapi/page/cpdf_colorstate.h4
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp8
5 files changed, 32 insertions, 25 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;
};
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 9e8d19abf9..b801c19c53 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1008,14 +1008,14 @@ void CPDF_RenderStatus::Initialize(const CPDF_RenderStatus* pParentState,
if (!m_InitialStates.m_ColorState.HasFillColor()) {
m_InitialStates.m_ColorState.SetFillColorRef(
pParentState->m_InitialStates.m_ColorState.GetFillColorRef());
- m_InitialStates.m_ColorState.GetMutableFillColor()->Copy(
- *pParentState->m_InitialStates.m_ColorState.GetFillColor());
+ *m_InitialStates.m_ColorState.GetMutableFillColor() =
+ *pParentState->m_InitialStates.m_ColorState.GetFillColor();
}
if (!m_InitialStates.m_ColorState.HasStrokeColor()) {
m_InitialStates.m_ColorState.SetStrokeColorRef(
pParentState->m_InitialStates.m_ColorState.GetFillColorRef());
- m_InitialStates.m_ColorState.GetMutableStrokeColor()->Copy(
- *pParentState->m_InitialStates.m_ColorState.GetStrokeColor());
+ *m_InitialStates.m_ColorState.GetMutableStrokeColor() =
+ *pParentState->m_InitialStates.m_ColorState.GetStrokeColor();
}
}
} else {