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_GENERALSTATE_H_ | 7 #ifndef CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_GENERALSTATE_H_ |
8 #define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_GENERALSTATE_H_ | 8 #define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_GENERALSTATE_H_ |
9 | 9 |
10 #include "core/fpdfapi/fpdf_page/include/cpdf_generalstatedata.h" | 10 #include "core/fxcrt/include/cfx_count_ref.h" |
11 #include "core/fxcrt/include/fx_basic.h" | 11 #include "core/fxcrt/include/fx_basic.h" |
| 12 #include "core/fxcrt/include/fx_coordinates.h" |
| 13 |
| 14 class CPDF_TransferFunc; |
| 15 class CPDF_Object; |
12 | 16 |
13 class CPDF_GeneralState { | 17 class CPDF_GeneralState { |
14 public: | 18 public: |
15 CPDF_GeneralState(); | 19 CPDF_GeneralState(); |
16 CPDF_GeneralState(const CPDF_GeneralState& that); | 20 CPDF_GeneralState(const CPDF_GeneralState& that); |
17 ~CPDF_GeneralState(); | 21 ~CPDF_GeneralState(); |
18 | 22 |
19 void Emplace() { m_Ref.Emplace(); } | 23 void Emplace() { m_Ref.Emplace(); } |
20 | 24 |
21 void SetRenderIntent(const CFX_ByteString& ri); | 25 int GetBlendType() const; |
22 | 26 void SetBlendType(int type); |
23 int GetBlendType() const { | |
24 const CPDF_GeneralStateData* pData = m_Ref.GetObject(); | |
25 return pData ? pData->m_BlendType : FXDIB_BLEND_NORMAL; | |
26 } | |
27 | |
28 void SetBlendType(int type) { m_Ref.GetPrivateCopy()->m_BlendType = type; } | |
29 | 27 |
30 int GetAlpha(FX_BOOL bStroke) const { | 28 int GetAlpha(FX_BOOL bStroke) const { |
31 return bStroke ? GetStrokeAlpha() : GetFillAlpha(); | 29 return bStroke ? GetStrokeAlpha() : GetFillAlpha(); |
32 } | 30 } |
33 | 31 |
34 int GetFillAlpha() const { | 32 int GetFillAlpha() const; |
35 const CPDF_GeneralStateData* pData = m_Ref.GetObject(); | 33 void SetFillAlpha(FX_FLOAT alpha); |
36 return pData ? FXSYS_round(255 * pData->m_FillAlpha) : 255; | |
37 } | |
38 | 34 |
39 int GetStrokeAlpha() const { | 35 int GetStrokeAlpha() const; |
40 const CPDF_GeneralStateData* pData = m_Ref.GetObject(); | 36 void SetStrokeAlpha(FX_FLOAT alpha); |
41 return pData ? FXSYS_round(255 * pData->m_StrokeAlpha) : 255; | |
42 } | |
43 | 37 |
44 void SetSoftMask(CPDF_Object* pObject) { | 38 CPDF_Object* GetSoftMask() const; |
45 m_Ref.GetPrivateCopy()->m_pSoftMask = pObject; | 39 void SetSoftMask(CPDF_Object* pObject); |
46 } | |
47 | 40 |
48 CPDF_Object* GetSoftMask() const { | 41 CPDF_Object* GetTR() const; |
49 const CPDF_GeneralStateData* pData = m_Ref.GetObject(); | 42 void SetTR(CPDF_Object* pObject); |
50 return pData ? pData->m_pSoftMask : nullptr; | |
51 } | |
52 | 43 |
53 void SetTR(CPDF_Object* pObject) { m_Ref.GetPrivateCopy()->m_pTR = pObject; } | 44 CPDF_TransferFunc* GetTransferFunc() const; |
| 45 void SetTransferFunc(CPDF_TransferFunc* pFunc); |
54 | 46 |
55 CPDF_Object* GetTR() const { return m_Ref.GetObject()->m_pTR; } | 47 void SetBlendMode(const CFX_ByteStringC& mode); |
56 | 48 |
57 void SetTransferFunc(CPDF_TransferFunc* pFunc) { | 49 const FX_FLOAT* GetSMaskMatrix() const; |
58 m_Ref.GetPrivateCopy()->m_pTransferFunc = pFunc; | 50 FX_FLOAT* GetMutableSMaskMatrix(); |
59 } | |
60 | 51 |
61 CPDF_TransferFunc* GetTransferFunc() const { | 52 int GetFillOP() const; |
62 return m_Ref.GetObject()->m_pTransferFunc; | 53 void SetFillOP(int op); |
63 } | |
64 | 54 |
65 void SetBlendMode(const CFX_ByteStringC& mode) { | 55 int GetStrokeOP() const; |
66 m_Ref.GetPrivateCopy()->SetBlendMode(mode); | 56 void SetStrokeOP(int op); |
67 } | |
68 | 57 |
69 const FX_FLOAT* GetSMaskMatrix() const { | 58 int GetOPMode() const; |
70 return m_Ref.GetObject()->m_SMaskMatrix; | 59 void SetOPMode(int mode); |
71 } | |
72 | 60 |
73 FX_FLOAT* GetMutableSMaskMatrix() { | 61 void SetBG(CPDF_Object* pObject); |
74 return m_Ref.GetPrivateCopy()->m_SMaskMatrix; | 62 void SetUCR(CPDF_Object* pObject); |
75 } | 63 void SetHT(CPDF_Object* pObject); |
76 | 64 |
77 void SetStrokeAlpha(FX_FLOAT alpha) { | 65 void SetFlatness(FX_FLOAT flatness); |
78 m_Ref.GetPrivateCopy()->m_StrokeAlpha = alpha; | 66 void SetSmoothness(FX_FLOAT smoothness); |
79 } | |
80 | 67 |
81 void SetFillAlpha(FX_FLOAT alpha) { | 68 void SetStrokeAdjust(FX_FLOAT adjust); |
82 m_Ref.GetPrivateCopy()->m_FillAlpha = alpha; | 69 FX_FLOAT GetStrokeAdjust() const; |
83 } | |
84 | 70 |
85 void SetFillOP(int op) { m_Ref.GetPrivateCopy()->m_FillOP = op; } | 71 void SetAlphaSource(int source); |
| 72 void SetTextKnockout(int knockout); |
86 | 73 |
87 int GetFillOP() const { return m_Ref.GetObject()->m_FillOP; } | 74 CFX_Matrix* GetMutableMatrix(); |
| 75 void SetMatrix(const CFX_Matrix& matrix); |
88 | 76 |
89 void SetStrokeOP(int op) { m_Ref.GetPrivateCopy()->m_StrokeOP = op; } | 77 void SetRenderIntent(const CFX_ByteString& ri); |
90 | |
91 int GetStrokeOP() const { return m_Ref.GetObject()->m_StrokeOP; } | |
92 | |
93 void SetOPMode(int mode) { m_Ref.GetPrivateCopy()->m_OPMode = mode; } | |
94 | |
95 int GetOPMode() const { return m_Ref.GetObject()->m_OPMode; } | |
96 | |
97 void SetBG(CPDF_Object* pObject) { m_Ref.GetPrivateCopy()->m_pBG = pObject; } | |
98 | |
99 void SetUCR(CPDF_Object* pObject) { | |
100 m_Ref.GetPrivateCopy()->m_pUCR = pObject; | |
101 } | |
102 | |
103 void SetHT(CPDF_Object* pObject) { m_Ref.GetPrivateCopy()->m_pHT = pObject; } | |
104 | |
105 void SetFlatness(FX_FLOAT flatness) { | |
106 m_Ref.GetPrivateCopy()->m_Flatness = flatness; | |
107 } | |
108 | |
109 void SetSmoothness(FX_FLOAT smoothness) { | |
110 m_Ref.GetPrivateCopy()->m_Smoothness = smoothness; | |
111 } | |
112 | |
113 void SetStrokeAdjust(FX_FLOAT adjust) { | |
114 m_Ref.GetPrivateCopy()->m_StrokeAdjust = adjust; | |
115 } | |
116 | |
117 FX_FLOAT GetStrokeAdjust() const { return m_Ref.GetObject()->m_StrokeAdjust; } | |
118 | |
119 void SetAlphaSource(int source) { | |
120 m_Ref.GetPrivateCopy()->m_AlphaSource = source; | |
121 } | |
122 | |
123 void SetTextKnockout(int knockout) { | |
124 m_Ref.GetPrivateCopy()->m_TextKnockout = knockout; | |
125 } | |
126 | |
127 void SetMatrix(const CFX_Matrix& matrix) { | |
128 m_Ref.GetPrivateCopy()->m_Matrix = matrix; | |
129 } | |
130 | |
131 CFX_Matrix* GetMutableMatrix() { return &m_Ref.GetPrivateCopy()->m_Matrix; } | |
132 | 78 |
133 operator bool() const { return !!m_Ref; } | 79 operator bool() const { return !!m_Ref; } |
134 | 80 |
135 private: | 81 private: |
136 CFX_CountRef<CPDF_GeneralStateData> m_Ref; | 82 class StateData { |
| 83 public: |
| 84 StateData(); |
| 85 StateData(const StateData& that); |
| 86 ~StateData(); |
| 87 |
| 88 void SetBlendMode(const CFX_ByteStringC& blend_mode); |
| 89 |
| 90 char m_BlendMode[16]; |
| 91 int m_BlendType; |
| 92 CPDF_Object* m_pSoftMask; |
| 93 FX_FLOAT m_SMaskMatrix[6]; |
| 94 FX_FLOAT m_StrokeAlpha; |
| 95 FX_FLOAT m_FillAlpha; |
| 96 CPDF_Object* m_pTR; |
| 97 CPDF_TransferFunc* m_pTransferFunc; |
| 98 CFX_Matrix m_Matrix; |
| 99 int m_RenderIntent; |
| 100 FX_BOOL m_StrokeAdjust; |
| 101 FX_BOOL m_AlphaSource; |
| 102 FX_BOOL m_TextKnockout; |
| 103 FX_BOOL m_StrokeOP; |
| 104 FX_BOOL m_FillOP; |
| 105 int m_OPMode; |
| 106 CPDF_Object* m_pBG; |
| 107 CPDF_Object* m_pUCR; |
| 108 CPDF_Object* m_pHT; |
| 109 FX_FLOAT m_Flatness; |
| 110 FX_FLOAT m_Smoothness; |
| 111 }; |
| 112 |
| 113 CFX_CountRef<StateData> m_Ref; |
137 }; | 114 }; |
138 | 115 |
139 #endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_GENERALSTATE_H_ | 116 #endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_GENERALSTATE_H_ |
OLD | NEW |