FX_BOOL CPDF_ImageCache::GetCachedBitmap(CFX_DIBSource*& pBitmap, CFX_DIBSource*& pMask, FX_DWORD& MatteColor, CPDF_Dictionary* pPageResources, FX_BOOL bStdCS, FX_DWORD GroupFamily, FX_BOOL bLoadMask, CPDF_RenderStatus* pRenderStatus, FX_INT32 downsampleWidth, FX_INT32 downsampleHeight) { if (m_pCachedBitmap) { pBitmap = m_pCachedBitmap; pMask = m_pCachedMask; MatteColor = m_MatteColor; return TRUE; } if (!pRenderStatus) { return FALSE; } CPDF_RenderContext*pContext = pRenderStatus->GetContext(); CPDF_PageRenderCache* pPageRenderCache = pContext->m_pPageCache; m_dwTimeCount = pPageRenderCache->GetTimeCount(); CPDF_DIBSource* pSrc = FX_NEW CPDF_DIBSource; CPDF_DIBSource* pMaskSrc = NULL; if (!pSrc->Load(m_pDocument, m_pStream, &pMaskSrc, &MatteColor, pRenderStatus->m_pFormResource, pPageResources, bStdCS, GroupFamily, bLoadMask)) { delete pSrc; pBitmap = NULL; return FALSE; } m_MatteColor = MatteColor; #if !defined(_FPDFAPI_MINI_) if (pSrc->GetPitch() * pSrc->GetHeight() < FPDF_HUGE_IMAGE_SIZE) { m_pCachedBitmap = pSrc->Clone(); delete pSrc; } else { m_pCachedBitmap = pSrc; } if (pMaskSrc) { m_pCachedMask = pMaskSrc->Clone(); delete pMaskSrc; } #else if (pSrc->GetFormat() == FXDIB_8bppRgb && pSrc->GetPalette() && pSrc->GetHeight() * pSrc->GetWidth() * 3 < 1024) { #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ m_pCachedBitmap = pSrc->CloneConvert(FXDIB_Rgb32); #else m_pCachedBitmap = pSrc->CloneConvert(FXDIB_Rgb); #endif delete pSrc; } else if (pSrc->GetPitch() * pSrc->GetHeight() < 102400) { m_pCachedBitmap = pSrc->Clone(); delete pSrc; } else { m_pCachedBitmap = pSrc; } m_pCachedMask = pMaskSrc; #endif pBitmap = m_pCachedBitmap; pMask = m_pCachedMask; CalcSize(); return FALSE; }
bool CPDF_ImageCacheEntry::GetCachedBitmap(CFX_DIBSource*& pBitmap, CFX_DIBSource*& pMask, uint32_t& MatteColor, CPDF_Dictionary* pPageResources, bool bStdCS, uint32_t GroupFamily, bool bLoadMask, CPDF_RenderStatus* pRenderStatus, int32_t downsampleWidth, int32_t downsampleHeight) { if (m_pCachedBitmap) { pBitmap = m_pCachedBitmap; pMask = m_pCachedMask; MatteColor = m_MatteColor; return true; } if (!pRenderStatus) { return false; } CPDF_RenderContext* pContext = pRenderStatus->GetContext(); CPDF_PageRenderCache* pPageRenderCache = pContext->GetPageCache(); m_dwTimeCount = pPageRenderCache->GetTimeCount(); CPDF_DIBSource* pSrc = new CPDF_DIBSource; CPDF_DIBSource* pMaskSrc = nullptr; if (!pSrc->Load(m_pDocument, m_pStream, &pMaskSrc, &MatteColor, pRenderStatus->m_pFormResource, pPageResources, bStdCS, GroupFamily, bLoadMask)) { delete pSrc; pBitmap = nullptr; return false; } m_MatteColor = MatteColor; if (pSrc->GetPitch() * pSrc->GetHeight() < FPDF_HUGE_IMAGE_SIZE) { m_pCachedBitmap = pSrc->Clone(); delete pSrc; } else { m_pCachedBitmap = pSrc; } if (pMaskSrc) { m_pCachedMask = pMaskSrc->Clone(); delete pMaskSrc; } pBitmap = m_pCachedBitmap; pMask = m_pCachedMask; CalcSize(); return false; }