From c92e26defaa636b0d2ec9b9de0f88c6153ad7ed3 Mon Sep 17 00:00:00 2001 From: npm Date: Mon, 28 Nov 2016 11:38:37 -0800 Subject: Merge CPDF_ImageLoader with its handle Review-Url: https://codereview.chromium.org/2524403002 --- core/fpdfapi/render/cpdf_imageloader.cpp | 122 +++++++++---------------------- core/fpdfapi/render/cpdf_imageloader.h | 7 +- 2 files changed, 38 insertions(+), 91 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/render/cpdf_imageloader.cpp b/core/fpdfapi/render/cpdf_imageloader.cpp index e36a3f1b9c..3fb85dae40 100644 --- a/core/fpdfapi/render/cpdf_imageloader.cpp +++ b/core/fpdfapi/render/cpdf_imageloader.cpp @@ -13,54 +13,35 @@ #include "core/fpdfapi/render/render_int.h" #include "core/fxcrt/fx_basic.h" -class CPDF_ImageLoaderHandle { - public: - CPDF_ImageLoaderHandle(); - ~CPDF_ImageLoaderHandle(); - - bool Start(CPDF_ImageLoader* pImageLoader, - const CPDF_ImageObject* pImage, - CPDF_PageRenderCache* pCache, - bool bStdCS, - uint32_t GroupFamily, - bool bLoadMask, - CPDF_RenderStatus* pRenderStatus, - int32_t nDownsampleWidth, - int32_t nDownsampleHeight); - bool Continue(IFX_Pause* pPause); - - private: - void HandleFailure(); - - CPDF_ImageLoader* m_pImageLoader; - CPDF_PageRenderCache* m_pCache; - CPDF_ImageObject* m_pImage; - int32_t m_nDownsampleWidth; - int32_t m_nDownsampleHeight; -}; +CPDF_ImageLoader::CPDF_ImageLoader() + : m_pBitmap(nullptr), + m_pMask(nullptr), + m_MatteColor(0), + m_bCached(false), + m_nDownsampleWidth(0), + m_nDownsampleHeight(0), + m_pCache(nullptr), + m_pImage(nullptr) {} -CPDF_ImageLoaderHandle::CPDF_ImageLoaderHandle() { - m_pImageLoader = nullptr; - m_pCache = nullptr; - m_pImage = nullptr; +CPDF_ImageLoader::~CPDF_ImageLoader() { + if (!m_bCached) { + delete m_pBitmap; + delete m_pMask; + } } -CPDF_ImageLoaderHandle::~CPDF_ImageLoaderHandle() {} - -bool CPDF_ImageLoaderHandle::Start(CPDF_ImageLoader* pImageLoader, - const CPDF_ImageObject* pImage, - CPDF_PageRenderCache* pCache, - bool bStdCS, - uint32_t GroupFamily, - bool bLoadMask, - CPDF_RenderStatus* pRenderStatus, - int32_t nDownsampleWidth, - int32_t nDownsampleHeight) { - m_pImageLoader = pImageLoader; - m_pCache = pCache; - m_pImage = const_cast(pImage); +bool CPDF_ImageLoader::Start(const CPDF_ImageObject* pImage, + CPDF_PageRenderCache* pCache, + bool bStdCS, + uint32_t GroupFamily, + bool bLoadMask, + CPDF_RenderStatus* pRenderStatus, + int32_t nDownsampleWidth, + int32_t nDownsampleHeight) { m_nDownsampleWidth = nDownsampleWidth; m_nDownsampleHeight = nDownsampleHeight; + m_pCache = pCache; + m_pImage = const_cast(pImage); bool ret; if (pCache) { ret = pCache->StartGetCachedBitmap( @@ -76,7 +57,7 @@ bool CPDF_ImageLoaderHandle::Start(CPDF_ImageLoader* pImageLoader, return ret; } -bool CPDF_ImageLoaderHandle::Continue(IFX_Pause* pPause) { +bool CPDF_ImageLoader::Continue(IFX_Pause* pPause) { bool ret = m_pCache ? m_pCache->Continue(pPause) : m_pImage->GetImage()->Continue(pPause); if (!ret) @@ -84,53 +65,18 @@ bool CPDF_ImageLoaderHandle::Continue(IFX_Pause* pPause) { return ret; } -void CPDF_ImageLoaderHandle::HandleFailure() { +void CPDF_ImageLoader::HandleFailure() { if (m_pCache) { CPDF_ImageCacheEntry* entry = m_pCache->GetCurImageCacheEntry(); - m_pImageLoader->m_bCached = true; - m_pImageLoader->m_pBitmap = entry->DetachBitmap(); - m_pImageLoader->m_pMask = entry->DetachMask(); - m_pImageLoader->m_MatteColor = entry->m_MatteColor; + m_bCached = true; + m_pBitmap = entry->DetachBitmap(); + m_pMask = entry->DetachMask(); + m_MatteColor = entry->m_MatteColor; return; } CPDF_Image* pImage = m_pImage->GetImage(); - m_pImageLoader->m_bCached = false; - m_pImageLoader->m_pBitmap = pImage->DetachBitmap(); - m_pImageLoader->m_pMask = pImage->DetachMask(); - m_pImageLoader->m_MatteColor = pImage->m_MatteColor; -} - -CPDF_ImageLoader::CPDF_ImageLoader() - : m_pBitmap(nullptr), - m_pMask(nullptr), - m_MatteColor(0), - m_bCached(false), - m_nDownsampleWidth(0), - m_nDownsampleHeight(0) {} - -CPDF_ImageLoader::~CPDF_ImageLoader() { - if (!m_bCached) { - delete m_pBitmap; - delete m_pMask; - } -} - -bool CPDF_ImageLoader::Start(const CPDF_ImageObject* pImage, - CPDF_PageRenderCache* pCache, - bool bStdCS, - uint32_t GroupFamily, - bool bLoadMask, - CPDF_RenderStatus* pRenderStatus, - int32_t nDownsampleWidth, - int32_t nDownsampleHeight) { - m_nDownsampleWidth = nDownsampleWidth; - m_nDownsampleHeight = nDownsampleHeight; - m_pLoadHandle.reset(new CPDF_ImageLoaderHandle); - return m_pLoadHandle->Start(this, pImage, pCache, bStdCS, GroupFamily, - bLoadMask, pRenderStatus, m_nDownsampleWidth, - m_nDownsampleHeight); -} - -bool CPDF_ImageLoader::Continue(IFX_Pause* pPause) { - return m_pLoadHandle->Continue(pPause); + m_bCached = false; + m_pBitmap = pImage->DetachBitmap(); + m_pMask = pImage->DetachMask(); + m_MatteColor = pImage->m_MatteColor; } diff --git a/core/fpdfapi/render/cpdf_imageloader.h b/core/fpdfapi/render/cpdf_imageloader.h index da578a321f..a270c45bbf 100644 --- a/core/fpdfapi/render/cpdf_imageloader.h +++ b/core/fpdfapi/render/cpdf_imageloader.h @@ -12,7 +12,6 @@ #include "core/fxcrt/fx_basic.h" #include "core/fxge/fx_dib.h" -class CPDF_ImageLoaderHandle; class CPDF_ImageObject; class CPDF_PageRenderCache; class CPDF_RenderStatus; @@ -38,10 +37,12 @@ class CPDF_ImageLoader { bool m_bCached; private: + void HandleFailure(); + int32_t m_nDownsampleWidth; int32_t m_nDownsampleHeight; - - std::unique_ptr m_pLoadHandle; + CPDF_PageRenderCache* m_pCache; + CPDF_ImageObject* m_pImage; }; #endif // CORE_FPDFAPI_RENDER_CPDF_IMAGELOADER_H_ -- cgit v1.2.3