• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_TRANSFERFUNC_H_
8 #define CORE_FPDFAPI_PAGE_CPDF_TRANSFERFUNC_H_
9 
10 #include <vector>
11 
12 #include "core/fxcrt/observed_ptr.h"
13 #include "core/fxcrt/retain_ptr.h"
14 #include "core/fxcrt/unowned_ptr.h"
15 #include "core/fxge/fx_dib.h"
16 #include "third_party/base/span.h"
17 
18 class CPDF_Document;
19 class CFX_DIBBase;
20 
21 class CPDF_TransferFunc final : public Retainable, public Observable {
22  public:
23   template <typename T, typename... Args>
24   friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
25 
26   static constexpr size_t kChannelSampleSize = 256;
27 
28   FX_COLORREF TranslateColor(FX_COLORREF colorref) const;
29   RetainPtr<CFX_DIBBase> TranslateImage(const RetainPtr<CFX_DIBBase>& pSrc);
30 
GetDocument()31   const CPDF_Document* GetDocument() const { return m_pPDFDoc.Get(); }
32 
33   // Spans are |kChannelSampleSize| in size.
34   pdfium::span<const uint8_t> GetSamplesR() const;
35   pdfium::span<const uint8_t> GetSamplesG() const;
36   pdfium::span<const uint8_t> GetSamplesB() const;
37 
GetIdentity()38   bool GetIdentity() const { return m_bIdentity; }
39 
40  private:
41   CPDF_TransferFunc(CPDF_Document* pDoc,
42                     bool bIdentify,
43                     std::vector<uint8_t> samples_r,
44                     std::vector<uint8_t> samples_g,
45                     std::vector<uint8_t> samples_b);
46   ~CPDF_TransferFunc() override;
47 
48   UnownedPtr<CPDF_Document> const m_pPDFDoc;
49   const bool m_bIdentity;
50   const std::vector<uint8_t> m_SamplesR;
51   const std::vector<uint8_t> m_SamplesG;
52   const std::vector<uint8_t> m_SamplesB;
53 };
54 
55 #endif  // CORE_FPDFAPI_PAGE_CPDF_TRANSFERFUNC_H_
56