From 58bf3de718e510648ee136c887be5b2d577644a7 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Wed, 12 Jul 2017 11:04:12 -0400 Subject: Cleanup ICC code part 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL switches void* to CLcmsCmm*, simplifies the ownership and destruction of CLcmsCmm, and reduces unnecessary function calling in fx_codec_icc.cpp. Change-Id: Ifdbf59dcdaede497d1684b161dd066726cf08ee3 Reviewed-on: https://pdfium-review.googlesource.com/7590 Reviewed-by: dsinclair Commit-Queue: Nicolás Peña --- core/fpdfapi/page/cpdf_iccprofile.cpp | 10 +++------- core/fpdfapi/page/cpdf_iccprofile.h | 9 ++++++--- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'core/fpdfapi') diff --git a/core/fpdfapi/page/cpdf_iccprofile.cpp b/core/fpdfapi/page/cpdf_iccprofile.cpp index afb505a7e6..0fa4be4b5a 100644 --- a/core/fpdfapi/page/cpdf_iccprofile.cpp +++ b/core/fpdfapi/page/cpdf_iccprofile.cpp @@ -8,7 +8,6 @@ #include "core/fpdfapi/cpdf_modulemgr.h" #include "core/fpdfapi/parser/cpdf_stream.h" -#include "core/fxcodec/codec/ccodec_iccmodule.h" namespace { @@ -29,12 +28,9 @@ CPDF_IccProfile::CPDF_IccProfile(CPDF_Stream* pStream, uint32_t nSrcComps = 0; auto* pIccModule = CPDF_ModuleMgr::Get()->GetIccModule(); - m_pTransform = pIccModule->CreateTransform_sRGB(pData, dwSize, nSrcComps); - if (m_pTransform) + m_Transform = pIccModule->CreateTransform_sRGB(pData, dwSize, &nSrcComps); + if (m_Transform) m_nSrcComponents = nSrcComps; } -CPDF_IccProfile::~CPDF_IccProfile() { - if (m_pTransform) - CPDF_ModuleMgr::Get()->GetIccModule()->DestroyTransform(m_pTransform); -} +CPDF_IccProfile::~CPDF_IccProfile() {} diff --git a/core/fpdfapi/page/cpdf_iccprofile.h b/core/fpdfapi/page/cpdf_iccprofile.h index a0cf744b9c..156fb595dc 100644 --- a/core/fpdfapi/page/cpdf_iccprofile.h +++ b/core/fpdfapi/page/cpdf_iccprofile.h @@ -7,6 +7,9 @@ #ifndef CORE_FPDFAPI_PAGE_CPDF_ICCPROFILE_H_ #define CORE_FPDFAPI_PAGE_CPDF_ICCPROFILE_H_ +#include + +#include "core/fxcodec/codec/ccodec_iccmodule.h" #include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/cfx_unowned_ptr.h" @@ -20,8 +23,8 @@ class CPDF_IccProfile : public CFX_Retainable { CPDF_Stream* GetStream() const { return m_pStream.Get(); } bool IsValid() const { return IsSRGB() || IsSupported(); } bool IsSRGB() const { return m_bsRGB; } - bool IsSupported() const { return !!m_pTransform; } - void* transform() { return m_pTransform; } + bool IsSupported() const { return !!m_Transform; } + CLcmsCmm* transform() { return m_Transform.get(); } uint32_t GetComponents() const { return m_nSrcComponents; } private: @@ -30,7 +33,7 @@ class CPDF_IccProfile : public CFX_Retainable { const bool m_bsRGB; CFX_UnownedPtr const m_pStream; - void* m_pTransform = nullptr; + std::unique_ptr m_Transform; uint32_t m_nSrcComponents = 0; }; -- cgit v1.2.3