From 81fcde731fe44ef5a11748536a2d6404906c80ff Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 29 Jun 2018 20:45:59 +0000 Subject: Use pdfium::span with CPDF_IccProfile and friends. Change-Id: I88d3e86a1dad75ef9c6bfb3401af6606479031a7 Reviewed-on: https://pdfium-review.googlesource.com/36634 Commit-Queue: Lei Zhang Reviewed-by: Henrique Nakashima --- core/fpdfapi/page/cpdf_docpagedata.cpp | 4 ++-- core/fpdfapi/page/cpdf_iccprofile.cpp | 12 ++++++------ core/fpdfapi/page/cpdf_iccprofile.h | 5 ++--- 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'core/fpdfapi/page') diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp index 49d44b3368..6744e0f6a7 100644 --- a/core/fpdfapi/page/cpdf_docpagedata.cpp +++ b/core/fpdfapi/page/cpdf_docpagedata.cpp @@ -442,8 +442,8 @@ RetainPtr CPDF_DocPageData::GetIccProfile( if (it_copied_stream != m_IccProfileMap.end()) return it_copied_stream->second; } - auto pProfile = pdfium::MakeRetain( - pProfileStream, pAccessor->GetData(), pAccessor->GetSize()); + auto pProfile = + pdfium::MakeRetain(pProfileStream, pAccessor->GetSpan()); m_IccProfileMap[pProfileStream] = pProfile; m_HashProfileMap[bsDigest] = pProfileStream; return pProfile; diff --git a/core/fpdfapi/page/cpdf_iccprofile.cpp b/core/fpdfapi/page/cpdf_iccprofile.cpp index ef1b9ef434..94270b110b 100644 --- a/core/fpdfapi/page/cpdf_iccprofile.cpp +++ b/core/fpdfapi/page/cpdf_iccprofile.cpp @@ -12,23 +12,23 @@ namespace { -bool DetectSRGB(const uint8_t* pData, uint32_t dwSize) { - return dwSize == 3144 && memcmp(pData + 0x190, "sRGB IEC61966-2.1", 17) == 0; +bool DetectSRGB(pdfium::span span) { + return span.size() == 3144 && + memcmp(span.data() + 0x190, "sRGB IEC61966-2.1", 17) == 0; } } // namespace CPDF_IccProfile::CPDF_IccProfile(const CPDF_Stream* pStream, - const uint8_t* pData, - uint32_t dwSize) - : m_bsRGB(DetectSRGB(pData, dwSize)), m_pStream(pStream) { + pdfium::span span) + : m_bsRGB(DetectSRGB(span)), m_pStream(pStream) { if (m_bsRGB) { m_nSrcComponents = 3; return; } auto* pIccModule = CPDF_ModuleMgr::Get()->GetIccModule(); - m_Transform = pIccModule->CreateTransform_sRGB(pData, dwSize); + m_Transform = pIccModule->CreateTransform_sRGB(span); if (m_Transform) m_nSrcComponents = m_Transform->components(); } diff --git a/core/fpdfapi/page/cpdf_iccprofile.h b/core/fpdfapi/page/cpdf_iccprofile.h index a5c9f6dbfe..a9e11700f1 100644 --- a/core/fpdfapi/page/cpdf_iccprofile.h +++ b/core/fpdfapi/page/cpdf_iccprofile.h @@ -11,6 +11,7 @@ #include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/unowned_ptr.h" +#include "third_party/base/span.h" class CLcmsCmm; class CPDF_Stream; @@ -28,9 +29,7 @@ class CPDF_IccProfile : public Retainable { uint32_t GetComponents() const { return m_nSrcComponents; } private: - CPDF_IccProfile(const CPDF_Stream* pStream, - const uint8_t* pData, - uint32_t dwSize); + CPDF_IccProfile(const CPDF_Stream* pStream, pdfium::span span); ~CPDF_IccProfile() override; const bool m_bsRGB; -- cgit v1.2.3