• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "build/build_config.h"
13 #include "core/fxcrt/fx_coordinates.h"
14 #include "core/fxcrt/retain_ptr.h"
15 #include "core/fxcrt/unowned_ptr.h"
16 
17 class CFX_DIBitmap;
18 class CFX_Matrix;
19 class CFX_RenderDevice;
20 class CPDF_Dictionary;
21 class CPDF_Document;
22 class CPDF_PageImageCache;
23 class CPDF_PageObject;
24 class CPDF_PageObjectHolder;
25 class CPDF_RenderOptions;
26 
27 class CPDF_RenderContext {
28  public:
29   class Layer {
30    public:
31     Layer(CPDF_PageObjectHolder* pHolder, const CFX_Matrix& matrix);
32     Layer(const Layer& that);
33     ~Layer();
34 
GetObjectHolder()35     CPDF_PageObjectHolder* GetObjectHolder() { return m_pObjectHolder; }
GetMatrix()36     const CFX_Matrix& GetMatrix() const { return m_Matrix; }
37 
38    private:
39     UnownedPtr<CPDF_PageObjectHolder> const m_pObjectHolder;
40     const CFX_Matrix m_Matrix;
41   };
42 
43   CPDF_RenderContext(CPDF_Document* pDoc,
44                      RetainPtr<CPDF_Dictionary> pPageResources,
45                      CPDF_PageImageCache* pPageCache);
46   ~CPDF_RenderContext();
47 
48   void AppendLayer(CPDF_PageObjectHolder* pObjectHolder,
49                    const CFX_Matrix& mtObject2Device);
50 
51   void Render(CFX_RenderDevice* pDevice,
52               const CPDF_PageObject* pStopObj,
53               const CPDF_RenderOptions* pOptions,
54               const CFX_Matrix* pLastMatrix);
55 
56   void GetBackgroundToDevice(CFX_RenderDevice* device,
57                              const CPDF_PageObject* object,
58                              const CPDF_RenderOptions* options,
59                              const CFX_Matrix& matrix);
60 #if BUILDFLAG(IS_WIN)
61   void GetBackgroundToBitmap(RetainPtr<CFX_DIBitmap> bitmap,
62                              const CPDF_PageObject* object,
63                              const CFX_Matrix& matrix);
64 #endif
65 
CountLayers()66   size_t CountLayers() const { return m_Layers.size(); }
GetLayer(uint32_t index)67   Layer* GetLayer(uint32_t index) { return &m_Layers[index]; }
68 
GetDocument()69   CPDF_Document* GetDocument() const { return m_pDocument; }
GetPageResources()70   const CPDF_Dictionary* GetPageResources() const {
71     return m_pPageResources.Get();
72   }
GetMutablePageResources()73   RetainPtr<CPDF_Dictionary> GetMutablePageResources() {
74     return m_pPageResources;
75   }
GetPageCache()76   CPDF_PageImageCache* GetPageCache() const { return m_pPageCache; }
77 
78  private:
79   UnownedPtr<CPDF_Document> const m_pDocument;
80   RetainPtr<CPDF_Dictionary> const m_pPageResources;
81   UnownedPtr<CPDF_PageImageCache> const m_pPageCache;
82   std::vector<Layer> m_Layers;
83 };
84 
85 #endif  // CORE_FPDFAPI_RENDER_CPDF_RENDERCONTEXT_H_
86