xref: /aosp_15_r20/external/pdfium/core/fpdfapi/page/cpdf_iccprofile.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2017 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_ICCPROFILE_H_
8 #define CORE_FPDFAPI_PAGE_CPDF_ICCPROFILE_H_
9 
10 #include <stdint.h>
11 
12 #include <memory>
13 
14 #include "core/fxcrt/retain_ptr.h"
15 #include "third_party/base/containers/span.h"
16 
17 class CPDF_Stream;
18 
19 namespace fxcodec {
20 class IccTransform;
21 }  // namespace fxcodec
22 
23 class CPDF_IccProfile final : public Retainable {
24  public:
25   CONSTRUCT_VIA_MAKE_RETAIN;
26 
IsValid()27   bool IsValid() const { return IsSRGB() || IsSupported(); }
IsSRGB()28   bool IsSRGB() const { return m_bsRGB; }
IsSupported()29   bool IsSupported() const { return !!m_Transform; }
GetComponents()30   uint32_t GetComponents() const { return m_nSrcComponents; }
31 
32   bool IsNormal() const;
33   void Translate(pdfium::span<const float> pSrcValues,
34                  pdfium::span<float> pDestValues);
35   void TranslateScanline(pdfium::span<uint8_t> pDest,
36                          pdfium::span<const uint8_t> pSrc,
37                          int pixels);
38 
39  private:
40   // Keeps stream alive for the duration of the CPDF_IccProfile.
41   CPDF_IccProfile(RetainPtr<const CPDF_Stream> pStream,
42                   pdfium::span<const uint8_t> span);
43   ~CPDF_IccProfile() override;
44 
45   const bool m_bsRGB;
46   uint32_t m_nSrcComponents = 0;
47   RetainPtr<const CPDF_Stream> const m_pStream;  // Used by `m_Transform`.
48   std::unique_ptr<fxcodec::IccTransform> m_Transform;
49 };
50 
51 #endif  // CORE_FPDFAPI_PAGE_CPDF_ICCPROFILE_H_
52