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_INCLUDE_CPDF_COLORSPACE_H_ | 7 #ifndef CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_ |
8 #define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_ | 8 #define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_ |
9 | 9 |
10 #include <memory> | |
11 | |
10 #include "core/fxcrt/include/cfx_weak_ptr.h" | 12 #include "core/fxcrt/include/cfx_weak_ptr.h" |
11 #include "core/fxcrt/include/fx_string.h" | 13 #include "core/fxcrt/include/fx_string.h" |
12 #include "core/fxcrt/include/fx_system.h" | 14 #include "core/fxcrt/include/fx_system.h" |
13 | 15 |
14 #define PDFCS_DEVICEGRAY 1 | 16 #define PDFCS_DEVICEGRAY 1 |
15 #define PDFCS_DEVICERGB 2 | 17 #define PDFCS_DEVICERGB 2 |
16 #define PDFCS_DEVICECMYK 3 | 18 #define PDFCS_DEVICECMYK 3 |
17 #define PDFCS_CALGRAY 4 | 19 #define PDFCS_CALGRAY 4 |
18 #define PDFCS_CALRGB 5 | 20 #define PDFCS_CALRGB 5 |
19 #define PDFCS_LAB 6 | 21 #define PDFCS_LAB 6 |
20 #define PDFCS_ICCBASED 7 | 22 #define PDFCS_ICCBASED 7 |
21 #define PDFCS_SEPARATION 8 | 23 #define PDFCS_SEPARATION 8 |
22 #define PDFCS_DEVICEN 9 | 24 #define PDFCS_DEVICEN 9 |
23 #define PDFCS_INDEXED 10 | 25 #define PDFCS_INDEXED 10 |
24 #define PDFCS_PATTERN 11 | 26 #define PDFCS_PATTERN 11 |
25 | 27 |
26 class CPDF_Array; | 28 class CPDF_Array; |
27 class CPDF_Document; | 29 class CPDF_Document; |
28 class CPDF_Object; | 30 class CPDF_Object; |
29 | 31 |
30 class CPDF_ColorSpace { | 32 class CPDF_ColorSpace { |
31 public: | 33 public: |
32 static CPDF_ColorSpace* GetStockCS(int Family); | 34 static CPDF_ColorSpace* GetStockCS(int Family); |
33 static CPDF_ColorSpace* Load(CPDF_Document* pDoc, CPDF_Object* pCSObj); | |
34 static CPDF_ColorSpace* ColorspaceFromName(const CFX_ByteString& name); | 35 static CPDF_ColorSpace* ColorspaceFromName(const CFX_ByteString& name); |
36 static std::unique_ptr<CPDF_ColorSpace> Load(CPDF_Document* pDoc, | |
37 CPDF_Object* pCSObj); | |
35 | 38 |
36 void ReleaseCS(); | 39 void Release(); |
37 | 40 |
38 int GetBufSize() const; | 41 int GetBufSize() const; |
39 FX_FLOAT* CreateBuf(); | 42 FX_FLOAT* CreateBuf(); |
40 void GetDefaultColor(FX_FLOAT* buf) const; | 43 void GetDefaultColor(FX_FLOAT* buf) const; |
41 uint32_t CountComponents() const; | 44 uint32_t CountComponents() const; |
42 int GetFamily() const { return m_Family; } | 45 int GetFamily() const { return m_Family; } |
43 virtual void GetDefaultValue(int iComponent, | 46 virtual void GetDefaultValue(int iComponent, |
44 FX_FLOAT& value, | 47 FX_FLOAT& value, |
45 FX_FLOAT& min, | 48 FX_FLOAT& min, |
46 FX_FLOAT& max) const; | 49 FX_FLOAT& max) const; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 FX_FLOAT k) const; | 100 FX_FLOAT k) const; |
98 | 101 |
99 int m_Family; | 102 int m_Family; |
100 uint32_t m_nComponents; | 103 uint32_t m_nComponents; |
101 CPDF_Array* m_pArray; | 104 CPDF_Array* m_pArray; |
102 uint32_t m_dwStdConversion; | 105 uint32_t m_dwStdConversion; |
103 }; | 106 }; |
104 | 107 |
105 using CPDF_CountedColorSpace = CFX_WeakPtr<CPDF_ColorSpace>::Handle; | 108 using CPDF_CountedColorSpace = CFX_WeakPtr<CPDF_ColorSpace>::Handle; |
106 | 109 |
110 namespace std { | |
111 | |
112 // Make std::unique_ptr<CPDF_ColorSpace> call Release() rather than | |
113 // simply deleting the object. | |
114 template <> | |
115 struct default_delete<CPDF_ColorSpace> { | |
Lei Zhang
2016/09/23 01:46:21
Neat. Maybe we can do that for CPDF_Object too.
| |
116 void operator()(CPDF_ColorSpace* pColorSpace) const { | |
117 if (pColorSpace) | |
118 pColorSpace->Release(); | |
119 } | |
120 }; | |
121 | |
122 } // namespace std | |
123 | |
107 #endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_ | 124 #endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_ |
OLD | NEW |