Home | History | Annotate | Download | only in dib
      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/ifx_scanlinecomposer.h"
     17 
     18 class CFX_ClipRgn;
     19 class CFX_DIBitmap;
     20 
     21 class CFX_BitmapComposer : public IFX_ScanlineComposer {
     22  public:
     23   CFX_BitmapComposer();
     24   ~CFX_BitmapComposer() override;
     25 
     26   void Compose(const RetainPtr<CFX_DIBitmap>& pDest,
     27                const CFX_ClipRgn* pClipRgn,
     28                int bitmap_alpha,
     29                uint32_t mask_color,
     30                const FX_RECT& dest_rect,
     31                bool bVertical,
     32                bool bFlipX,
     33                bool bFlipY,
     34                bool bRgbByteOrder,
     35                int alpha_flag,
     36                int blend_type);
     37 
     38   // IFX_ScanlineComposer
     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   int m_AlphaFlag;
     74   bool m_bRgbByteOrder;
     75   int m_BlendType;
     76   std::vector<uint8_t> m_pScanlineV;
     77   std::vector<uint8_t> m_pClipScanV;
     78   std::vector<uint8_t> m_pAddClipScan;
     79   std::vector<uint8_t> m_pScanlineAlphaV;
     80 };
     81 
     82 #endif  // CORE_FXGE_DIB_CFX_BITMAPCOMPOSER_H_
     83