summaryrefslogtreecommitdiff
path: root/xfa/fxgraphics/cxfa_color.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-08-16 15:09:00 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-08-16 22:54:39 +0000
commit574015e0ad53c592fe8a923390b31edeb30c41fe (patch)
treea3774207ebb4c1fc5b5abfb90a32adf974f76a10 /xfa/fxgraphics/cxfa_color.cpp
parenta364729be3725adbc9689c1c8c23902df102243b (diff)
downloadpdfium-574015e0ad53c592fe8a923390b31edeb30c41fe.tar.xz
Tidy CXFA_Color class and argument passing.
Remove friendship. De-virtualize. Nest enum inside class. Make copy-assignable and pass by const ref. Make pack better on 64-bits. Change-Id: I1ae3b6d03756fa5780e9023795db6648e8b8299a Reviewed-on: https://pdfium-review.googlesource.com/11290 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxgraphics/cxfa_color.cpp')
-rw-r--r--xfa/fxgraphics/cxfa_color.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/xfa/fxgraphics/cxfa_color.cpp b/xfa/fxgraphics/cxfa_color.cpp
index 79c0e5f794..731d144c41 100644
--- a/xfa/fxgraphics/cxfa_color.cpp
+++ b/xfa/fxgraphics/cxfa_color.cpp
@@ -6,41 +6,41 @@
#include "xfa/fxgraphics/cxfa_color.h"
-CXFA_Color::CXFA_Color() : m_type(FX_COLOR_None) {}
+CXFA_Color::CXFA_Color() : m_type(Invalid) {}
-CXFA_Color::CXFA_Color(const FX_ARGB argb) {
- Set(argb);
+CXFA_Color::CXFA_Color(const FX_ARGB argb) : m_type(Solid), m_argb(argb) {
+ m_pointer.pattern = nullptr;
}
-CXFA_Color::CXFA_Color(CXFA_Pattern* pattern, const FX_ARGB argb) {
- Set(pattern, argb);
+CXFA_Color::CXFA_Color(CXFA_Pattern* pattern, const FX_ARGB argb)
+ : m_type(Pattern), m_argb(argb) {
+ m_pointer.pattern = pattern;
}
-CXFA_Color::CXFA_Color(CXFA_Shading* shading) {
- Set(shading);
+CXFA_Color::CXFA_Color(CXFA_Shading* shading) : m_type(Shading), m_argb(0) {
+ m_pointer.shading = shading;
}
-CXFA_Color::~CXFA_Color() {
- m_type = FX_COLOR_None;
-}
-
-void CXFA_Color::Set(const FX_ARGB argb) {
- m_type = FX_COLOR_Solid;
- m_info.argb = argb;
- m_info.pattern = nullptr;
-}
-
-void CXFA_Color::Set(CXFA_Pattern* pattern, const FX_ARGB argb) {
- if (!pattern)
- return;
- m_type = FX_COLOR_Pattern;
- m_info.argb = argb;
- m_info.pattern = pattern;
-}
-
-void CXFA_Color::Set(CXFA_Shading* shading) {
- if (!shading)
- return;
- m_type = FX_COLOR_Shading;
- m_shading = shading;
+CXFA_Color::~CXFA_Color() {}
+
+CXFA_Color& CXFA_Color::operator=(const CXFA_Color& that) {
+ if (this != &that) {
+ m_type = that.m_type;
+ switch (m_type) {
+ case Solid:
+ m_argb = that.m_argb;
+ m_pointer.pattern = nullptr;
+ break;
+ case Pattern:
+ m_argb = that.m_argb;
+ m_pointer.pattern = that.m_pointer.pattern;
+ break;
+ case Shading:
+ m_argb = 0;
+ m_pointer.shading = that.m_pointer.shading;
+ default:
+ break;
+ }
+ }
+ return *this;
}