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_SCANLINECOMPOSITOR_H_ 8 #define CORE_FXGE_DIB_CFX_SCANLINECOMPOSITOR_H_ 9 10 #include <memory> 11 12 #include "core/fxcrt/fx_memory_wrappers.h" 13 #include "core/fxge/fx_dib.h" 14 15 class CFX_ScanlineCompositor { 16 public: 17 CFX_ScanlineCompositor(); 18 ~CFX_ScanlineCompositor(); 19 20 bool Init(FXDIB_Format dest_format, 21 FXDIB_Format src_format, 22 int32_t width, 23 uint32_t* pSrcPalette, 24 uint32_t mask_color, 25 BlendMode blend_type, 26 bool bClip, 27 bool bRgbByteOrder); 28 29 void CompositeRgbBitmapLine(uint8_t* dest_scan, 30 const uint8_t* src_scan, 31 int width, 32 const uint8_t* clip_scan, 33 const uint8_t* src_extra_alpha, 34 uint8_t* dst_extra_alpha); 35 36 void CompositePalBitmapLine(uint8_t* dest_scan, 37 const uint8_t* src_scan, 38 int src_left, 39 int width, 40 const uint8_t* clip_scan, 41 const uint8_t* src_extra_alpha, 42 uint8_t* dst_extra_alpha); 43 44 void CompositeByteMaskLine(uint8_t* dest_scan, 45 const uint8_t* src_scan, 46 int width, 47 const uint8_t* clip_scan, 48 uint8_t* dst_extra_alpha); 49 50 void CompositeBitMaskLine(uint8_t* dest_scan, 51 const uint8_t* src_scan, 52 int src_left, 53 int width, 54 const uint8_t* clip_scan, 55 uint8_t* dst_extra_alpha); 56 57 private: 58 void InitSourcePalette(FXDIB_Format src_format, 59 FXDIB_Format dest_format, 60 const uint32_t* pSrcPalette); 61 62 void InitSourceMask(uint32_t mask_color); 63 64 int m_iTransparency; 65 FXDIB_Format m_SrcFormat; 66 FXDIB_Format m_DestFormat; 67 std::unique_ptr<uint32_t, FxFreeDeleter> m_pSrcPalette; 68 int m_MaskAlpha; 69 int m_MaskRed; 70 int m_MaskGreen; 71 int m_MaskBlue; 72 BlendMode m_BlendType = BlendMode::kNormal; 73 bool m_bRgbByteOrder = false; 74 }; 75 76 #endif // CORE_FXGE_DIB_CFX_SCANLINECOMPOSITOR_H_ 77