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 "core/fxcrt/span.h" 16 17 class CPDF_StreamAcc; 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 CPDF_IccProfile(RetainPtr<const CPDF_StreamAcc> stream_acc, 41 uint32_t expected_components); 42 ~CPDF_IccProfile() override; 43 44 // Keeps stream alive for the lifetime of this object, so `m_Transform` can 45 // safely access the stream data. 46 RetainPtr<const CPDF_StreamAcc> const m_pStreamAcc; 47 // Uses data from `m_pStreamAcc`. 48 std::unique_ptr<fxcodec::IccTransform> m_Transform; 49 const bool m_bsRGB; 50 uint32_t m_nSrcComponents = 0; 51 }; 52 53 #endif // CORE_FPDFAPI_PAGE_CPDF_ICCPROFILE_H_ 54