OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATE_H_ | 7 #ifndef CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATE_H_ |
8 #define CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATE_H_ | 8 #define CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATE_H_ |
9 | 9 |
10 #include "core/fpdfapi/fpdf_page/cpdf_colorstatedata.h" | 10 #include "core/fpdfapi/fpdf_page/cpdf_colorstatedata.h" |
11 #include "core/fxcrt/include/cfx_count_ref.h" | 11 #include "core/fxcrt/include/cfx_count_ref.h" |
12 #include "core/fxcrt/include/fx_basic.h" | 12 #include "core/fxcrt/include/fx_basic.h" |
13 #include "core/fxcrt/include/fx_system.h" | 13 #include "core/fxcrt/include/fx_system.h" |
14 | 14 |
15 class CPDF_Color; | 15 class CPDF_Color; |
16 class CPDF_ColorSpace; | 16 class CPDF_ColorSpace; |
17 class CPDF_Pattern; | 17 class CPDF_Pattern; |
18 | 18 |
19 class CPDF_ColorState : public CFX_CountRef<CPDF_ColorStateData> { | 19 class CPDF_ColorState { |
20 public: | 20 public: |
21 const CPDF_Color* GetFillColor() const { | 21 CPDF_ColorState(); |
22 const CPDF_ColorStateData* pData = GetObject(); | 22 CPDF_ColorState(const CPDF_ColorState& that); |
23 return pData ? &pData->m_FillColor : nullptr; | 23 ~CPDF_ColorState(); |
24 } | |
25 | 24 |
26 const CPDF_Color* GetStrokeColor() const { | 25 void Emplace(); |
27 const CPDF_ColorStateData* pData = GetObject(); | 26 void SetDefault(); |
28 return pData ? &pData->m_StrokeColor : nullptr; | 27 |
29 } | 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; |
30 | 41 |
31 void SetFillColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues); | 42 void SetFillColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues); |
32 void SetStrokeColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues); | 43 void SetStrokeColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues); |
33 void SetFillPattern(CPDF_Pattern* pattern, | 44 void SetFillPattern(CPDF_Pattern* pattern, |
34 FX_FLOAT* pValue, | 45 FX_FLOAT* pValue, |
35 uint32_t nValues); | 46 uint32_t nValues); |
36 void SetStrokePattern(CPDF_Pattern* pattern, | 47 void SetStrokePattern(CPDF_Pattern* pattern, |
37 FX_FLOAT* pValue, | 48 FX_FLOAT* pValue, |
38 uint32_t nValues); | 49 uint32_t nValues); |
39 | 50 |
| 51 // TODO(tsepez): Stop leaking ColorStateData outside this class. |
| 52 const CPDF_ColorStateData* GetObject() const { return m_Ref.GetObject(); } |
| 53 |
| 54 operator bool() const { return !!m_Ref; } |
| 55 |
40 private: | 56 private: |
41 void SetColor(CPDF_Color& color, | 57 void SetColor(CPDF_Color& color, |
42 uint32_t& rgb, | 58 uint32_t& rgb, |
43 CPDF_ColorSpace* pCS, | 59 CPDF_ColorSpace* pCS, |
44 FX_FLOAT* pValue, | 60 FX_FLOAT* pValue, |
45 uint32_t nValues); | 61 uint32_t nValues); |
| 62 |
| 63 CFX_CountRef<CPDF_ColorStateData> m_Ref; |
46 }; | 64 }; |
47 | 65 |
48 #endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATE_H_ | 66 #endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_COLORSTATE_H_ |
OLD | NEW |