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 #ifndef XFA_FXGRAPHICS_CXFA_GECOLOR_H_ 8 #define XFA_FXGRAPHICS_CXFA_GECOLOR_H_ 9 10 #include "core/fxge/fx_dib.h" 11 12 class CXFA_GEPattern; 13 class CXFA_GEShading; 14 15 class CXFA_GEColor { 16 public: 17 enum Type { Invalid, Solid, Pattern, Shading }; 18 19 CXFA_GEColor(); 20 explicit CXFA_GEColor(const FX_ARGB argb); 21 explicit CXFA_GEColor(CXFA_GEShading* shading); 22 CXFA_GEColor(CXFA_GEPattern* pattern, const FX_ARGB argb); 23 ~CXFA_GEColor(); 24 GetType()25 Type GetType() const { return m_type; } GetArgb()26 FX_ARGB GetArgb() const { 27 ASSERT(m_type == Solid || m_type == Pattern); 28 return m_argb; 29 } GetPattern()30 CXFA_GEPattern* GetPattern() const { 31 ASSERT(m_type == Pattern); 32 return m_pointer.pattern; 33 } GetShading()34 CXFA_GEShading* GetShading() const { 35 ASSERT(m_type == Shading); 36 return m_pointer.shading; 37 } 38 39 CXFA_GEColor& operator=(const CXFA_GEColor& that); 40 41 private: 42 Type m_type; 43 FX_ARGB m_argb; 44 union { 45 CXFA_GEPattern* pattern; 46 CXFA_GEShading* shading; 47 } m_pointer; 48 }; 49 50 #endif // XFA_FXGRAPHICS_CXFA_GECOLOR_H_ 51