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/fxcrt/unowned_ptr.h"
11 #include "core/fxge/fx_dib.h"
12 
13 class CXFA_GEPattern;
14 class CXFA_GEShading;
15 
16 class CXFA_GEColor {
17  public:
18   enum Type { Invalid, Solid, Pattern, Shading };
19 
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(const CXFA_GEColor& that);
24   ~CXFA_GEColor();
25 
GetType()26   Type GetType() const { return m_type; }
GetArgb()27   FX_ARGB GetArgb() const {
28     ASSERT(m_type == Solid || m_type == Pattern);
29     return m_argb;
30   }
GetPattern()31   CXFA_GEPattern* GetPattern() const {
32     ASSERT(m_type == Pattern);
33     return m_pPattern.Get();
34   }
GetShading()35   CXFA_GEShading* GetShading() const {
36     ASSERT(m_type == Shading);
37     return m_pShading.Get();
38   }
39 
40   CXFA_GEColor& operator=(const CXFA_GEColor& that);
41 
42  private:
43   Type m_type = Invalid;
44   FX_ARGB m_argb = 0;
45   UnownedPtr<CXFA_GEPattern> m_pPattern;
46   UnownedPtr<CXFA_GEShading> m_pShading;
47 };
48 
49 #endif  // XFA_FXGRAPHICS_CXFA_GECOLOR_H_
50