1 // Copyright 2016 The PDFium Authors 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_RENDER_CPDF_RENDERCONTEXT_H_ 8 #define CORE_FPDFAPI_RENDER_CPDF_RENDERCONTEXT_H_ 9 10 #include <vector> 11 12 #include "core/fxcrt/fx_coordinates.h" 13 #include "core/fxcrt/retain_ptr.h" 14 #include "core/fxcrt/unowned_ptr.h" 15 16 class CFX_DIBitmap; 17 class CFX_Matrix; 18 class CFX_RenderDevice; 19 class CPDF_Dictionary; 20 class CPDF_Document; 21 class CPDF_PageImageCache; 22 class CPDF_PageObject; 23 class CPDF_PageObjectHolder; 24 class CPDF_RenderOptions; 25 26 class CPDF_RenderContext { 27 public: 28 class Layer { 29 public: 30 Layer(CPDF_PageObjectHolder* pHolder, const CFX_Matrix& matrix); 31 Layer(const Layer& that); 32 ~Layer(); 33 GetObjectHolder()34 CPDF_PageObjectHolder* GetObjectHolder() { return m_pObjectHolder; } GetMatrix()35 const CFX_Matrix& GetMatrix() const { return m_Matrix; } 36 37 private: 38 UnownedPtr<CPDF_PageObjectHolder> const m_pObjectHolder; 39 const CFX_Matrix m_Matrix; 40 }; 41 42 CPDF_RenderContext(CPDF_Document* pDoc, 43 RetainPtr<CPDF_Dictionary> pPageResources, 44 CPDF_PageImageCache* pPageCache); 45 ~CPDF_RenderContext(); 46 47 void AppendLayer(CPDF_PageObjectHolder* pObjectHolder, 48 const CFX_Matrix& mtObject2Device); 49 50 void Render(CFX_RenderDevice* pDevice, 51 const CPDF_PageObject* pStopObj, 52 const CPDF_RenderOptions* pOptions, 53 const CFX_Matrix* pLastMatrix); 54 55 void GetBackground(RetainPtr<CFX_DIBitmap> pBuffer, 56 const CPDF_PageObject* pObj, 57 const CPDF_RenderOptions* pOptions, 58 const CFX_Matrix& mtFinal); 59 CountLayers()60 size_t CountLayers() const { return m_Layers.size(); } GetLayer(uint32_t index)61 Layer* GetLayer(uint32_t index) { return &m_Layers[index]; } 62 GetDocument()63 CPDF_Document* GetDocument() const { return m_pDocument; } GetPageResources()64 const CPDF_Dictionary* GetPageResources() const { 65 return m_pPageResources.Get(); 66 } GetMutablePageResources()67 RetainPtr<CPDF_Dictionary> GetMutablePageResources() { 68 return m_pPageResources; 69 } GetPageCache()70 CPDF_PageImageCache* GetPageCache() const { return m_pPageCache; } 71 72 private: 73 UnownedPtr<CPDF_Document> const m_pDocument; 74 RetainPtr<CPDF_Dictionary> const m_pPageResources; 75 UnownedPtr<CPDF_PageImageCache> const m_pPageCache; 76 std::vector<Layer> m_Layers; 77 }; 78 79 #endif // CORE_FPDFAPI_RENDER_CPDF_RENDERCONTEXT_H_ 80