• 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_GENERALSTATE_H_
8 #define CORE_FPDFAPI_PAGE_CPDF_GENERALSTATE_H_
9 
10 #include "core/fxcrt/fx_coordinates.h"
11 #include "core/fxcrt/fx_string.h"
12 #include "core/fxcrt/shared_copy_on_write.h"
13 #include "core/fxcrt/unowned_ptr.h"
14 #include "core/fxge/fx_dib.h"
15 
16 class CPDF_Object;
17 class CPDF_TransferFunc;
18 
19 class CPDF_GeneralState {
20  public:
21   CPDF_GeneralState();
22   CPDF_GeneralState(const CPDF_GeneralState& that);
23   ~CPDF_GeneralState();
24 
Emplace()25   void Emplace() { m_Ref.Emplace(); }
HasRef()26   bool HasRef() const { return !!m_Ref; }
27 
28   void SetRenderIntent(const ByteString& ri);
29 
30   ByteString GetBlendMode() const;
31   int GetBlendType() const;
32   void SetBlendType(int type);
33 
34   float GetFillAlpha() const;
35   void SetFillAlpha(float alpha);
36 
37   float GetStrokeAlpha() const;
38   void SetStrokeAlpha(float alpha);
39 
40   CPDF_Object* GetSoftMask() const;
41   void SetSoftMask(CPDF_Object* pObject);
42 
43   CPDF_Object* GetTR() const;
44   void SetTR(CPDF_Object* pObject);
45 
46   RetainPtr<CPDF_TransferFunc> GetTransferFunc() const;
47   void SetTransferFunc(const RetainPtr<CPDF_TransferFunc>& pFunc);
48 
49   void SetBlendMode(const ByteString& mode);
50 
51   const CFX_Matrix* GetSMaskMatrix() const;
52   void SetSMaskMatrix(const CFX_Matrix& matrix);
53 
54   bool GetFillOP() const;
55   void SetFillOP(bool op);
56 
57   bool GetStrokeOP() const;
58   void SetStrokeOP(bool op);
59 
60   int GetOPMode() const;
61   void SetOPMode(int mode);
62 
63   void SetBG(CPDF_Object* pObject);
64   void SetUCR(CPDF_Object* pObject);
65   void SetHT(CPDF_Object* pObject);
66 
67   void SetFlatness(float flatness);
68   void SetSmoothness(float smoothness);
69 
70   bool GetStrokeAdjust() const;
71   void SetStrokeAdjust(bool adjust);
72 
73   void SetAlphaSource(bool source);
74   void SetTextKnockout(bool knockout);
75 
76   void SetMatrix(const CFX_Matrix& matrix);
77   CFX_Matrix* GetMutableMatrix();
78 
79  private:
80   class StateData : public Retainable {
81    public:
82     StateData();
83     StateData(const StateData& that);
84     ~StateData() override;
85 
86     ByteString m_BlendMode;
87     int m_BlendType;
88     UnownedPtr<CPDF_Object> m_pSoftMask;
89     CFX_Matrix m_SMaskMatrix;
90     float m_StrokeAlpha;
91     float m_FillAlpha;
92     UnownedPtr<CPDF_Object> m_pTR;
93     RetainPtr<CPDF_TransferFunc> m_pTransferFunc;
94     CFX_Matrix m_Matrix;
95     int m_RenderIntent;
96     bool m_StrokeAdjust;
97     bool m_AlphaSource;
98     bool m_TextKnockout;
99     bool m_StrokeOP;
100     bool m_FillOP;
101     int m_OPMode;
102     UnownedPtr<CPDF_Object> m_pBG;
103     UnownedPtr<CPDF_Object> m_pUCR;
104     UnownedPtr<CPDF_Object> m_pHT;
105     float m_Flatness;
106     float m_Smoothness;
107   };
108 
109   SharedCopyOnWrite<StateData> m_Ref;
110 };
111 
112 #endif  // CORE_FPDFAPI_PAGE_CPDF_GENERALSTATE_H_
113