1// Copyright 2016 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "xfa/fxgraphics/cxfa_gecolor.h"
8
9CXFA_GEColor::CXFA_GEColor() : m_type(Invalid) {}
10
11CXFA_GEColor::CXFA_GEColor(const FX_ARGB argb) : m_type(Solid), m_argb(argb) {
12  m_pointer.pattern = nullptr;
13}
14
15CXFA_GEColor::CXFA_GEColor(CXFA_GEPattern* pattern, const FX_ARGB argb)
16    : m_type(Pattern), m_argb(argb) {
17  m_pointer.pattern = pattern;
18}
19
20CXFA_GEColor::CXFA_GEColor(CXFA_GEShading* shading)
21    : m_type(Shading), m_argb(0) {
22  m_pointer.shading = shading;
23}
24
25CXFA_GEColor::~CXFA_GEColor() {}
26
27CXFA_GEColor& CXFA_GEColor::operator=(const CXFA_GEColor& that) {
28  if (this != &that) {
29    m_type = that.m_type;
30    switch (m_type) {
31      case Solid:
32        m_argb = that.m_argb;
33        m_pointer.pattern = nullptr;
34        break;
35      case Pattern:
36        m_argb = that.m_argb;
37        m_pointer.pattern = that.m_pointer.pattern;
38        break;
39      case Shading:
40        m_argb = 0;
41        m_pointer.shading = that.m_pointer.shading;
42      default:
43        break;
44    }
45  }
46  return *this;
47}
48