From fc715c3c1d9c9c623c36ae9fc8b8aac0362e4c22 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Fri, 31 Mar 2017 10:22:11 -0400 Subject: Split fx_dib part 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move CFX_DIBSource to its own file. Also move the classes that inherit from it to their own headers. Their cpp's will be added in followup. Change-Id: Id2b53e124ea5445c558bfcf627bf526870cc92e8 Reviewed-on: https://pdfium-review.googlesource.com/3450 Reviewed-by: Tom Sepez Commit-Queue: Nicolás Peña --- core/fxge/dib/cfx_dibitmap.h | 135 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 core/fxge/dib/cfx_dibitmap.h (limited to 'core/fxge/dib/cfx_dibitmap.h') diff --git a/core/fxge/dib/cfx_dibitmap.h b/core/fxge/dib/cfx_dibitmap.h new file mode 100644 index 0000000000..9cb46afb53 --- /dev/null +++ b/core/fxge/dib/cfx_dibitmap.h @@ -0,0 +1,135 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FXGE_DIB_CFX_DIBITMAP_H_ +#define CORE_FXGE_DIB_CFX_DIBITMAP_H_ + +#include "core/fxcrt/cfx_retain_ptr.h" +#include "core/fxcrt/fx_basic.h" +#include "core/fxcrt/fx_coordinates.h" +#include "core/fxge/dib/cfx_dibsource.h" +#include "third_party/base/stl_util.h" + +class CFX_DIBitmap : public CFX_DIBSource { + public: + template + friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); + + ~CFX_DIBitmap() override; + + bool Create(int width, + int height, + FXDIB_Format format, + uint8_t* pBuffer = nullptr, + int pitch = 0); + + bool Copy(const CFX_RetainPtr& pSrc); + + // CFX_DIBSource + uint8_t* GetBuffer() const override; + const uint8_t* GetScanline(int line) const override; + void DownSampleScanline(int line, + uint8_t* dest_scan, + int dest_bpp, + int dest_width, + bool bFlipX, + int clip_left, + int clip_width) const override; + + void TakeOver(CFX_RetainPtr&& pSrcBitmap); + bool ConvertFormat(FXDIB_Format format); + void Clear(uint32_t color); + + uint32_t GetPixel(int x, int y) const; + void SetPixel(int x, int y, uint32_t color); + + bool LoadChannel(FXDIB_Channel destChannel, + const CFX_RetainPtr& pSrcBitmap, + FXDIB_Channel srcChannel); + bool LoadChannel(FXDIB_Channel destChannel, int value); + + bool MultiplyAlpha(int alpha); + bool MultiplyAlpha(const CFX_RetainPtr& pAlphaMask); + + bool TransferBitmap(int dest_left, + int dest_top, + int width, + int height, + const CFX_RetainPtr& pSrcBitmap, + int src_left, + int src_top); + + bool CompositeBitmap(int dest_left, + int dest_top, + int width, + int height, + const CFX_RetainPtr& pSrcBitmap, + int src_left, + int src_top, + int blend_type = FXDIB_BLEND_NORMAL, + const CFX_ClipRgn* pClipRgn = nullptr, + bool bRgbByteOrder = false, + void* pIccTransform = nullptr); + + bool TransferMask(int dest_left, + int dest_top, + int width, + int height, + const CFX_RetainPtr& pMask, + uint32_t color, + int src_left, + int src_top, + int alpha_flag = 0, + void* pIccTransform = nullptr); + + bool CompositeMask(int dest_left, + int dest_top, + int width, + int height, + const CFX_RetainPtr& pMask, + uint32_t color, + int src_left, + int src_top, + int blend_type = FXDIB_BLEND_NORMAL, + const CFX_ClipRgn* pClipRgn = nullptr, + bool bRgbByteOrder = false, + int alpha_flag = 0, + void* pIccTransform = nullptr); + + bool CompositeRect(int dest_left, + int dest_top, + int width, + int height, + uint32_t color, + int alpha_flag = 0, + void* pIccTransform = nullptr); + + bool ConvertColorScale(uint32_t forecolor, uint32_t backcolor); + +#if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_ + void PreMultiply(); +#endif +#if defined _SKIA_SUPPORT_PATHS_ + void UnPreMultiply(); +#endif + + protected: + CFX_DIBitmap(); + CFX_DIBitmap(const CFX_DIBitmap& src); + bool GetGrayData(void* pIccTransform = nullptr); + +#if defined _SKIA_SUPPORT_PATHS_ + enum class Format { kCleared, kPreMultiplied, kUnPreMultiplied }; +#endif + + uint8_t* m_pBuffer; +#if defined _SKIA_SUPPORT_PATHS_ + Format m_nFormat; +#endif + bool m_bExtBuf; +}; + +#endif // CORE_FXGE_DIB_CFX_DIBITMAP_H_ -- cgit v1.2.3