1 // Copyright 2016 The PDFium Authors 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_TRANSFERFUNC_H_ 8 #define CORE_FPDFAPI_PAGE_CPDF_TRANSFERFUNC_H_ 9 10 #include <stdint.h> 11 12 #include "core/fxcrt/fixed_uninit_data_vector.h" 13 #include "core/fxcrt/observed_ptr.h" 14 #include "core/fxcrt/retain_ptr.h" 15 #include "core/fxge/dib/fx_dib.h" 16 #include "third_party/base/span.h" 17 18 class CFX_DIBBase; 19 20 class CPDF_TransferFunc final : public Retainable, public Observable { 21 public: 22 CONSTRUCT_VIA_MAKE_RETAIN; 23 24 static constexpr size_t kChannelSampleSize = 256; 25 26 FX_COLORREF TranslateColor(FX_COLORREF colorref) const; 27 RetainPtr<CFX_DIBBase> TranslateImage(RetainPtr<CFX_DIBBase> pSrc); 28 29 // Spans are |kChannelSampleSize| in size. 30 pdfium::span<const uint8_t> GetSamplesR() const; 31 pdfium::span<const uint8_t> GetSamplesG() const; 32 pdfium::span<const uint8_t> GetSamplesB() const; 33 GetIdentity()34 bool GetIdentity() const { return m_bIdentity; } 35 36 private: 37 CPDF_TransferFunc(bool bIdentify, 38 FixedUninitDataVector<uint8_t> samples_r, 39 FixedUninitDataVector<uint8_t> samples_g, 40 FixedUninitDataVector<uint8_t> samples_b); 41 ~CPDF_TransferFunc() override; 42 43 const bool m_bIdentity; 44 const FixedUninitDataVector<uint8_t> m_SamplesR; 45 const FixedUninitDataVector<uint8_t> m_SamplesG; 46 const FixedUninitDataVector<uint8_t> m_SamplesB; 47 }; 48 49 #endif // CORE_FPDFAPI_PAGE_CPDF_TRANSFERFUNC_H_ 50