1 // Copyright 2017 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_FXGE_DIB_CFX_BITMAPCOMPOSER_H_ 8 #define CORE_FXGE_DIB_CFX_BITMAPCOMPOSER_H_ 9 10 #include <vector> 11 12 #include "core/fxcrt/fx_coordinates.h" 13 #include "core/fxcrt/fx_memory_wrappers.h" 14 #include "core/fxcrt/retain_ptr.h" 15 #include "core/fxcrt/unowned_ptr.h" 16 #include "core/fxge/dib/cfx_scanlinecompositor.h" 17 #include "core/fxge/dib/fx_dib.h" 18 #include "core/fxge/dib/scanlinecomposer_iface.h" 19 20 class CFX_ClipRgn; 21 class CFX_DIBitmap; 22 23 class CFX_BitmapComposer final : public ScanlineComposerIface { 24 public: 25 CFX_BitmapComposer(); 26 ~CFX_BitmapComposer() override; 27 28 void Compose(const RetainPtr<CFX_DIBitmap>& pDest, 29 const CFX_ClipRgn* pClipRgn, 30 int bitmap_alpha, 31 uint32_t mask_color, 32 const FX_RECT& dest_rect, 33 bool bVertical, 34 bool bFlipX, 35 bool bFlipY, 36 bool bRgbByteOrder, 37 BlendMode blend_mode); 38 39 // ScanlineComposerIface: 40 bool SetInfo(int width, 41 int height, 42 FXDIB_Format src_format, 43 pdfium::span<const uint32_t> src_palette) override; 44 45 void ComposeScanline(int line, 46 const uint8_t* scanline, 47 const uint8_t* scan_extra_alpha) override; 48 49 private: 50 void DoCompose(uint8_t* dest_scan, 51 const uint8_t* src_scan, 52 int dest_width, 53 const uint8_t* clip_scan, 54 const uint8_t* src_extra_alpha, 55 uint8_t* dst_extra_alpha); 56 void ComposeScanlineV(int line, 57 const uint8_t* scanline, 58 const uint8_t* scan_extra_alpha); 59 60 RetainPtr<CFX_DIBitmap> m_pBitmap; 61 UnownedPtr<const CFX_ClipRgn> m_pClipRgn; 62 FXDIB_Format m_SrcFormat; 63 int m_DestLeft; 64 int m_DestTop; 65 int m_DestWidth; 66 int m_DestHeight; 67 int m_BitmapAlpha; 68 uint32_t m_MaskColor; 69 RetainPtr<CFX_DIBitmap> m_pClipMask; 70 CFX_ScanlineCompositor m_Compositor; 71 bool m_bVertical; 72 bool m_bFlipX; 73 bool m_bFlipY; 74 bool m_bRgbByteOrder = false; 75 BlendMode m_BlendMode = BlendMode::kNormal; 76 std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_pScanlineV; 77 std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_pClipScanV; 78 std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_pAddClipScan; 79 std::vector<uint8_t, FxAllocAllocator<uint8_t>> m_pScanlineAlphaV; 80 }; 81 82 #endif // CORE_FXGE_DIB_CFX_BITMAPCOMPOSER_H_ 83