From e6ff2ebfaa19421c8d932f4d275548156ae2e13c Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 24 Aug 2018 21:55:46 +0000 Subject: Rename CFX_DIBSource to CFX_DIBBase. It is not a source from which you can get CFX_DIBs, but rather a base class from which all DIBs inherit. Do the same thing for the CPDF_DIBSource wrapper class. Mechanical change apart from adding a one-line comment in cfx_dibbase.h Change-Id: Id2bde87813ca301d9fafc55ce08d703dfc6a7184 Reviewed-on: https://pdfium-review.googlesource.com/41352 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fpdfapi/render/cpdf_dibbase.h | 163 +++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 core/fpdfapi/render/cpdf_dibbase.h (limited to 'core/fpdfapi/render/cpdf_dibbase.h') diff --git a/core/fpdfapi/render/cpdf_dibbase.h b/core/fpdfapi/render/cpdf_dibbase.h new file mode 100644 index 0000000000..a1008470b6 --- /dev/null +++ b/core/fpdfapi/render/cpdf_dibbase.h @@ -0,0 +1,163 @@ +// 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_FPDFAPI_RENDER_CPDF_DIBBASE_H_ +#define CORE_FPDFAPI_RENDER_CPDF_DIBBASE_H_ + +#include +#include +#include + +#include "core/fpdfapi/page/cpdf_clippath.h" +#include "core/fpdfapi/page/cpdf_countedobject.h" +#include "core/fpdfapi/page/cpdf_graphicstates.h" +#include "core/fpdfapi/parser/cpdf_stream_acc.h" +#include "core/fpdfapi/render/cpdf_imageloader.h" +#include "core/fpdfapi/render/cpdf_rendercontext.h" +#include "core/fpdfapi/render/cpdf_renderoptions.h" +#include "core/fxcrt/retain_ptr.h" +#include "core/fxcrt/unowned_ptr.h" +#include "core/fxge/cfx_defaultrenderdevice.h" +#include "core/fxge/dib/cfx_dibbase.h" + +class CCodec_Jbig2Context; +class CCodec_ScanlineDecoder; +class CPDF_Color; +class CPDF_Dictionary; +class CPDF_Document; +class CPDF_Stream; + +struct DIB_COMP_DATA { + float m_DecodeMin; + float m_DecodeStep; + int m_ColorKeyMin; + int m_ColorKeyMax; +}; + +#define FPDF_HUGE_IMAGE_SIZE 60000000 + +class CPDF_DIBBase : public CFX_DIBBase { + public: + enum class LoadState : uint8_t { kFail, kSuccess, kContinue }; + + template + friend RetainPtr pdfium::MakeRetain(Args&&... args); + + bool Load(CPDF_Document* pDoc, const CPDF_Stream* pStream); + + // CFX_DIBBase + bool SkipToScanline(int line, PauseIndicatorIface* pPause) const override; + 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; + + const CPDF_ColorSpace* GetColorSpace() const { return m_pColorSpace.Get(); } + uint32_t GetMatteColor() const { return m_MatteColor; } + + LoadState StartLoadDIBBase(CPDF_Document* pDoc, + const CPDF_Stream* pStream, + bool bHasMask, + const CPDF_Dictionary* pFormResources, + CPDF_Dictionary* pPageResources, + bool bStdCS, + uint32_t GroupFamily, + bool bLoadMask); + LoadState ContinueLoadDIBBase(PauseIndicatorIface* pPause); + RetainPtr DetachMask(); + + bool IsJBigImage() const; + + private: + CPDF_DIBBase(); + ~CPDF_DIBBase() override; + + LoadState StartLoadMask(); + LoadState StartLoadMaskDIB(); + bool ContinueToLoadMask(); + LoadState ContinueLoadMaskDIB(PauseIndicatorIface* pPause); + bool LoadColorInfo(const CPDF_Dictionary* pFormResources, + const CPDF_Dictionary* pPageResources); + bool GetDecodeAndMaskArray(bool* bDefaultDecode, bool* bColorKey); + RetainPtr LoadJpxBitmap(); + void LoadPalette(); + LoadState CreateDecoder(); + bool CreateDCTDecoder(const uint8_t* src_data, + uint32_t src_size, + const CPDF_Dictionary* pParams); + void TranslateScanline24bpp(uint8_t* dest_scan, + const uint8_t* src_scan) const; + bool TranslateScanline24bppDefaultDecode(uint8_t* dest_scan, + const uint8_t* src_scan) const; + void ValidateDictParam(); + void DownSampleScanline1Bit(int orig_Bpp, + int dest_Bpp, + uint32_t src_width, + const uint8_t* pSrcLine, + uint8_t* dest_scan, + int dest_width, + bool bFlipX, + int clip_left, + int clip_width) const; + void DownSampleScanline8Bit(int orig_Bpp, + int dest_Bpp, + uint32_t src_width, + const uint8_t* pSrcLine, + uint8_t* dest_scan, + int dest_width, + bool bFlipX, + int clip_left, + int clip_width) const; + void DownSampleScanline32Bit(int orig_Bpp, + int dest_Bpp, + uint32_t src_width, + const uint8_t* pSrcLine, + uint8_t* dest_scan, + int dest_width, + bool bFlipX, + int clip_left, + int clip_width) const; + bool TransMask() const; + + UnownedPtr m_pDocument; + UnownedPtr m_pStream; + UnownedPtr m_pDict; + RetainPtr m_pStreamAcc; + UnownedPtr m_pColorSpace; + uint32_t m_Family = 0; + uint32_t m_bpc = 0; + uint32_t m_bpc_orig = 0; + uint32_t m_nComponents = 0; + uint32_t m_GroupFamily = 0; + uint32_t m_MatteColor = 0; + bool m_bLoadMask = false; + bool m_bDefaultDecode = true; + bool m_bImageMask = false; + bool m_bDoBpcCheck = true; + bool m_bColorKey = false; + bool m_bHasMask = false; + bool m_bStdCS = false; + std::vector m_CompData; + std::unique_ptr m_pLineBuf; + std::unique_ptr m_pMaskedLine; + RetainPtr m_pCachedBitmap; + RetainPtr m_pMask; + RetainPtr m_pGlobalStream; + std::unique_ptr m_pDecoder; + + // Must come after |m_pCachedBitmap|. + std::unique_ptr m_pJbig2Context; + + UnownedPtr m_pMaskStream; + LoadState m_Status = LoadState::kFail; +}; + +#endif // CORE_FPDFAPI_RENDER_CPDF_DIBBASE_H_ -- cgit v1.2.3