Home | History | Annotate | Download | only in render
      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_Page;
     19 class CPDF_PageObject;
     20 class CPDF_PageObjectHolder;
     21 class CPDF_PageRenderCache;
     22 class CPDF_RenderOptions;
     23 class CFX_DIBitmap;
     24 class CFX_Matrix;
     25 class CFX_RenderDevice;
     26 
     27 class CPDF_RenderContext {
     28  public:
     29   class Layer {
     30    public:
     31     Layer();
     32     Layer(const Layer& that);
     33     ~Layer();
     34 
     35     UnownedPtr<CPDF_PageObjectHolder> m_pObjectHolder;
     36     CFX_Matrix m_Matrix;
     37   };
     38 
     39   explicit CPDF_RenderContext(CPDF_Page* pPage);
     40   CPDF_RenderContext(CPDF_Document* pDoc, 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* pFinalMatrix);
     49 
     50   void Render(CFX_RenderDevice* pDevice,
     51               const CPDF_PageObject* pStopObj,
     52               const CPDF_RenderOptions* pOptions,
     53               const CFX_Matrix* pFinalMatrix);
     54 
     55   void GetBackground(const RetainPtr<CFX_DIBitmap>& pBuffer,
     56                      const CPDF_PageObject* pObj,
     57                      const CPDF_RenderOptions* pOptions,
     58                      CFX_Matrix* pFinalMatrix);
     59 
     60   size_t CountLayers() const { return m_Layers.size(); }
     61   Layer* GetLayer(uint32_t index) { return &m_Layers[index]; }
     62 
     63   CPDF_Document* GetDocument() const { return m_pDocument.Get(); }
     64   CPDF_Dictionary* GetPageResources() const { return m_pPageResources.Get(); }
     65   CPDF_PageRenderCache* GetPageCache() const { return m_pPageCache.Get(); }
     66 
     67  protected:
     68   UnownedPtr<CPDF_Document> const m_pDocument;
     69   UnownedPtr<CPDF_Dictionary> m_pPageResources;
     70   UnownedPtr<CPDF_PageRenderCache> m_pPageCache;
     71   std::vector<Layer> m_Layers;
     72 };
     73 
     74 #endif  // CORE_FPDFAPI_RENDER_CPDF_RENDERCONTEXT_H_
     75