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