From b6e3d231ef2c28df1e5149cb16ad7046ebb0714e Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 15 Aug 2018 19:02:38 +0000 Subject: Make CPDF_RenderStatus::Initialize() saner. Move mandatory arguments to ctor. Replace long list of positional parameters with setter methods. Make Initialize() return void since it can't fail. Change-Id: I490118923855158891cf45eecd5de1e922a3a1fe Reviewed-on: https://pdfium-review.googlesource.com/40170 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fpdfapi/render/cpdf_renderstatus.h | 46 ++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'core/fpdfapi/render/cpdf_renderstatus.h') diff --git a/core/fpdfapi/render/cpdf_renderstatus.h b/core/fpdfapi/render/cpdf_renderstatus.h index 92b96f9bec..b15c1d1482 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.h +++ b/core/fpdfapi/render/cpdf_renderstatus.h @@ -29,6 +29,7 @@ class CPDF_Object; class CPDF_PageObject; class CPDF_PageObjectHolder; class CPDF_PathObject; +class CPDF_RenderContext; class CPDF_ShadingObject; class CPDF_ShadingPattern; class CPDF_TilingPattern; @@ -39,24 +40,27 @@ class CPDF_Type3Font; class CPDF_RenderStatus { public: - CPDF_RenderStatus(); + CPDF_RenderStatus(CPDF_RenderContext* pContext, CFX_RenderDevice* pDevice); ~CPDF_RenderStatus(); - bool Initialize(class CPDF_RenderContext* pContext, - CFX_RenderDevice* pDevice, - const CFX_Matrix* pDeviceMatrix, - const CPDF_PageObject* pStopObj, - const CPDF_RenderStatus* pParentStatus, - const CPDF_GraphicStates* pInitialStates, - const CPDF_RenderOptions* pOptions, - const CPDF_Transparency& transparency, - bool bDropObjects, - const CPDF_Dictionary* pFormResource = nullptr, - bool bStdCS = false, - CPDF_Type3Char* pType3Char = nullptr, - FX_ARGB fill_color = 0, - uint32_t GroupFamily = 0, - bool bLoadMask = false); + // Called prior to Initialize(). + void SetOptions(const CPDF_RenderOptions& options) { m_Options = options; } + void SetDeviceMatrix(const CFX_Matrix& matrix) { m_DeviceMatrix = matrix; } + void SetStopObject(const CPDF_PageObject* pStopObj) { m_pStopObj = pStopObj; } + void SetFormResource(const CPDF_Dictionary* pRes) { m_pFormResource = pRes; } + void SetType3Char(CPDF_Type3Char* pType3Char) { m_pType3Char = pType3Char; } + void SetFillColor(FX_ARGB color) { m_T3FillColor = color; } + void SetDropObjects(bool bDropObjects) { m_bDropObjects = bDropObjects; } + void SetLoadMask(bool bLoadMask) { m_bLoadMask = bLoadMask; } + void SetStdCS(bool bStdCS) { m_bStdCS = bStdCS; } + void SetGroupFamily(uint32_t family) { m_GroupFamily = family; } + void SetTransparency(const CPDF_Transparency& transparency) { + m_Transparency = transparency; + } + + void Initialize(const CPDF_RenderStatus* pParentStatus, + const CPDF_GraphicStates* pInitialStates); + void RenderObjectList(const CPDF_PageObjectHolder* pObjectHolder, const CFX_Matrix* pObj2Device); void RenderSingleObject(CPDF_PageObject* pObj, const CFX_Matrix* pObj2Device); @@ -77,7 +81,7 @@ class CPDF_RenderStatus { } CPDF_Dictionary* GetPageResource() const { return m_pPageResource.Get(); } CFX_RenderDevice* GetRenderDevice() const { return m_pDevice; } - const CPDF_RenderOptions* GetRenderOptions() const { return &m_Options; } + const CPDF_RenderOptions& GetRenderOptions() const { return m_Options; } #if defined _SKIA_SUPPORT_ void DebugVerifyDeviceIsPreMultiplied() const; @@ -171,21 +175,21 @@ class CPDF_RenderStatus { UnownedPtr m_pFormResource; UnownedPtr m_pPageResource; std::vector m_Type3FontCache; - UnownedPtr m_pContext; + UnownedPtr const m_pContext; bool m_bStopped = false; - CFX_RenderDevice* m_pDevice = nullptr; + CFX_RenderDevice* const m_pDevice; CFX_Matrix m_DeviceMatrix; CPDF_ClipPath m_LastClipPath; const CPDF_PageObject* m_pCurObj = nullptr; const CPDF_PageObject* m_pStopObj = nullptr; CPDF_GraphicStates m_InitialStates; std::unique_ptr m_pImageRenderer; - bool m_bPrint = false; CPDF_Transparency m_Transparency; + bool m_bPrint = false; bool m_bDropObjects = false; bool m_bStdCS = false; - uint32_t m_GroupFamily = 0; bool m_bLoadMask = false; + uint32_t m_GroupFamily = 0; UnownedPtr m_pType3Char; FX_ARGB m_T3FillColor = 0; int m_curBlend = FXDIB_BLEND_NORMAL; -- cgit v1.2.3