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_IMAGERENDERER_H_ 8 #define CORE_FPDFAPI_RENDER_CPDF_IMAGERENDERER_H_ 9 10 #include <memory> 11 12 #include "core/fpdfapi/render/cpdf_imageloader.h" 13 #include "core/fxcrt/fx_coordinates.h" 14 #include "core/fxcrt/unowned_ptr.h" 15 #include "core/fxge/dib/cfx_imagerenderer.h" 16 17 class CFX_DIBitmap; 18 class CFX_DIBSource; 19 class CFX_DefaultRenderDevice; 20 class CFX_ImageTransformer; 21 class CPDF_ImageObject; 22 class CPDF_PageObject; 23 class CPDF_Pattern; 24 class CPDF_RenderStatus; 25 26 class CPDF_ImageRenderer { 27 public: 28 CPDF_ImageRenderer(); 29 ~CPDF_ImageRenderer(); 30 31 bool Start(CPDF_RenderStatus* pStatus, 32 CPDF_ImageObject* pImageObject, 33 const CFX_Matrix* pObj2Device, 34 bool bStdCS, 35 int blendType); 36 37 bool Start(CPDF_RenderStatus* pStatus, 38 const RetainPtr<CFX_DIBSource>& pDIBSource, 39 FX_ARGB bitmap_argb, 40 int bitmap_alpha, 41 const CFX_Matrix* pImage2Device, 42 uint32_t flags, 43 bool bStdCS, 44 int blendType); 45 46 bool Continue(IFX_PauseIndicator* pPause); GetResult()47 bool GetResult() const { return m_Result; } 48 49 private: 50 bool StartBitmapAlpha(); 51 bool StartDIBSource(); 52 bool StartRenderDIBSource(); 53 bool StartLoadDIBSource(); 54 bool DrawMaskedImage(); 55 bool DrawPatternImage(const CFX_Matrix* pObj2Device); 56 bool NotDrawing() const; 57 FX_RECT GetDrawRect() const; 58 CFX_Matrix GetDrawMatrix(const FX_RECT& rect) const; 59 void CalculateDrawImage(CFX_DefaultRenderDevice* bitmap_device1, 60 CFX_DefaultRenderDevice* bitmap_device2, 61 const RetainPtr<CFX_DIBSource>& pDIBSource, 62 CFX_Matrix* pNewMatrix, 63 const FX_RECT& rect) const; 64 void HandleFilters(); 65 66 UnownedPtr<CPDF_RenderStatus> m_pRenderStatus; 67 UnownedPtr<CPDF_ImageObject> m_pImageObject; 68 int m_Status; 69 UnownedPtr<const CFX_Matrix> m_pObj2Device; 70 CFX_Matrix m_ImageMatrix; 71 CPDF_ImageLoader m_Loader; 72 RetainPtr<CFX_DIBSource> m_pDIBSource; 73 int m_BitmapAlpha; 74 bool m_bPatternColor; 75 UnownedPtr<CPDF_Pattern> m_pPattern; 76 FX_ARGB m_FillArgb; 77 uint32_t m_Flags; 78 std::unique_ptr<CFX_ImageTransformer> m_pTransformer; 79 std::unique_ptr<CFX_ImageRenderer> m_DeviceHandle; 80 bool m_bStdCS; 81 int m_BlendType; 82 bool m_Result; 83 }; 84 85 #endif // CORE_FPDFAPI_RENDER_CPDF_IMAGERENDERER_H_ 86