• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CORE_FPDFAPI_PAGE_CPDF_COLORSTATE_H_
8 #define CORE_FPDFAPI_PAGE_CPDF_COLORSTATE_H_
9 
10 #include "core/fpdfapi/page/cpdf_color.h"
11 #include "core/fxcrt/cfx_shared_copy_on_write.h"
12 #include "core/fxcrt/fx_basic.h"
13 #include "core/fxcrt/fx_system.h"
14 
15 class CPDF_Color;
16 class CPDF_ColorSpace;
17 class CPDF_Pattern;
18 
19 class CPDF_ColorState {
20  public:
21   CPDF_ColorState();
22   CPDF_ColorState(const CPDF_ColorState& that);
23   ~CPDF_ColorState();
24 
25   void Emplace();
26   void SetDefault();
27 
28   uint32_t GetFillRGB() const;
29   void SetFillRGB(uint32_t rgb);
30 
31   uint32_t GetStrokeRGB() const;
32   void SetStrokeRGB(uint32_t rgb);
33 
34   const CPDF_Color* GetFillColor() const;
35   CPDF_Color* GetMutableFillColor();
36   bool HasFillColor() const;
37 
38   const CPDF_Color* GetStrokeColor() const;
39   CPDF_Color* GetMutableStrokeColor();
40   bool HasStrokeColor() const;
41 
42   void SetFillColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues);
43   void SetStrokeColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues);
44   void SetFillPattern(CPDF_Pattern* pattern,
45                       FX_FLOAT* pValue,
46                       uint32_t nValues);
47   void SetStrokePattern(CPDF_Pattern* pattern,
48                         FX_FLOAT* pValue,
49                         uint32_t nValues);
50 
51   explicit operator bool() const { return !!m_Ref; }
52 
53  private:
54   class ColorData {
55    public:
56     ColorData();
57     ColorData(const ColorData& src);
58     ~ColorData();
59 
60     void SetDefault();
61 
62     uint32_t m_FillRGB;
63     uint32_t m_StrokeRGB;
64     CPDF_Color m_FillColor;
65     CPDF_Color m_StrokeColor;
66   };
67 
68   void SetColor(CPDF_Color& color,
69                 uint32_t& rgb,
70                 CPDF_ColorSpace* pCS,
71                 FX_FLOAT* pValue,
72                 uint32_t nValues);
73 
74   CFX_SharedCopyOnWrite<ColorData> m_Ref;
75 };
76 
77 #endif  // CORE_FPDFAPI_PAGE_CPDF_COLORSTATE_H_
78