xref: /aosp_15_r20/external/pdfium/xfa/fgas/graphics/cfgas_gecolor.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2016 The PDFium Authors
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_FGAS_GRAPHICS_CFGAS_GECOLOR_H_
8 #define XFA_FGAS_GRAPHICS_CFGAS_GECOLOR_H_
9 
10 #include "core/fxcrt/unowned_ptr.h"
11 #include "core/fxge/dib/fx_dib.h"
12 #include "third_party/base/check.h"
13 #include "third_party/base/check_op.h"
14 
15 class CFGAS_GEPattern;
16 class CFGAS_GEShading;
17 
18 class CFGAS_GEColor {
19  public:
20   enum Type { Invalid, Solid, Pattern, Shading };
21 
22   explicit CFGAS_GEColor(const FX_ARGB argb);
23   explicit CFGAS_GEColor(CFGAS_GEShading* shading);
24   CFGAS_GEColor(CFGAS_GEPattern* pattern, const FX_ARGB argb);
25   CFGAS_GEColor(const CFGAS_GEColor& that);
26   ~CFGAS_GEColor();
27 
GetType()28   Type GetType() const { return m_type; }
GetArgb()29   FX_ARGB GetArgb() const {
30     DCHECK(m_type == Solid || m_type == Pattern);
31     return m_argb;
32   }
GetPattern()33   CFGAS_GEPattern* GetPattern() const {
34     DCHECK_EQ(m_type, Pattern);
35     return m_pPattern;
36   }
GetShading()37   CFGAS_GEShading* GetShading() const {
38     DCHECK_EQ(m_type, Shading);
39     return m_pShading;
40   }
41 
42   CFGAS_GEColor& operator=(const CFGAS_GEColor& that);
43 
44  private:
45   Type m_type = Invalid;
46   FX_ARGB m_argb = 0;
47   UnownedPtr<CFGAS_GEPattern> m_pPattern;
48   UnownedPtr<CFGAS_GEShading> m_pShading;
49 };
50 
51 #endif  // XFA_FGAS_GRAPHICS_CFGAS_GECOLOR_H_
52