• 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_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 CPDF_Dictionary;
17 class CPDF_Document;
18 class CPDF_PageObject;
19 class CPDF_PageObjectHolder;
20 class CPDF_PageRenderCache;
21 class CPDF_RenderOptions;
22 class CFX_DIBitmap;
23 class CFX_Matrix;
24 class CFX_RenderDevice;
25 
26 class CPDF_RenderContext {
27  public:
28   class Layer {
29    public:
30     Layer();
31     Layer(const Layer& that);
32     ~Layer();
33 
34     UnownedPtr<CPDF_PageObjectHolder> m_pObjectHolder;
35     CFX_Matrix m_Matrix;
36   };
37 
38   CPDF_RenderContext(CPDF_Document* pDoc,
39                      CPDF_Dictionary* pPageResources,
40                      CPDF_PageRenderCache* pPageCache);
41   ~CPDF_RenderContext();
42 
43   void AppendLayer(CPDF_PageObjectHolder* pObjectHolder,
44                    const CFX_Matrix* pObject2Device);
45 
46   void Render(CFX_RenderDevice* pDevice,
47               const CPDF_RenderOptions* pOptions,
48               const CFX_Matrix* pLastMatrix);
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(const 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.Get(); }
GetPageResources()64   CPDF_Dictionary* GetPageResources() const { return m_pPageResources.Get(); }
GetPageCache()65   CPDF_PageRenderCache* GetPageCache() const { return m_pPageCache.Get(); }
66 
67  protected:
68   UnownedPtr<CPDF_Document> const m_pDocument;
69   RetainPtr<CPDF_Dictionary> const m_pPageResources;
70   UnownedPtr<CPDF_PageRenderCache> const m_pPageCache;
71   std::vector<Layer> m_Layers;
72 };
73 
74 #endif  // CORE_FPDFAPI_RENDER_CPDF_RENDERCONTEXT_H_
75