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