1 // Copyright 2016 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_FPDFAPI_PAGE_CPDF_TRANSFERFUNCDIB_H_ 8 #define CORE_FPDFAPI_PAGE_CPDF_TRANSFERFUNCDIB_H_ 9 10 #include <vector> 11 12 #include "core/fxcrt/retain_ptr.h" 13 #include "core/fxge/dib/cfx_dibbase.h" 14 #include "third_party/base/span.h" 15 16 class CPDF_TransferFunc; 17 18 class CPDF_TransferFuncDIB final : public CFX_DIBBase { 19 public: 20 template <typename T, typename... Args> 21 friend RetainPtr<T> pdfium::MakeRetain(Args&&... args); 22 23 void TranslateScanline(const uint8_t* src_buf, 24 std::vector<uint8_t>* dest_buf) const; 25 void TranslateDownSamples(uint8_t* dest_buf, 26 const uint8_t* src_buf, 27 int pixels, 28 int Bpp) const; 29 30 private: 31 CPDF_TransferFuncDIB(const RetainPtr<CFX_DIBBase>& pSrc, 32 const RetainPtr<CPDF_TransferFunc>& pTransferFunc); 33 ~CPDF_TransferFuncDIB() override; 34 35 // CFX_DIBBase: 36 const uint8_t* GetScanline(int line) const override; 37 void DownSampleScanline(int line, 38 uint8_t* dest_scan, 39 int dest_bpp, 40 int dest_width, 41 bool bFlipX, 42 int clip_left, 43 int clip_width) const override; 44 45 FXDIB_Format GetDestFormat() const; 46 47 RetainPtr<CFX_DIBBase> const m_pSrc; 48 mutable std::vector<uint8_t> m_Scanline; 49 RetainPtr<CPDF_TransferFunc> const m_pTransferFunc; 50 const pdfium::span<const uint8_t> m_RampR; 51 const pdfium::span<const uint8_t> m_RampG; 52 const pdfium::span<const uint8_t> m_RampB; 53 }; 54 55 #endif // CORE_FPDFAPI_PAGE_CPDF_TRANSFERFUNCDIB_H_ 56