diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-03-28 09:31:32 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-28 16:42:55 +0000 |
commit | f0799fe84df4d86f25d342b03525f3016d674f86 (patch) | |
tree | d6839802a68b7b6ad6fb166179ede779c3560c75 /core/fpdfapi/render/cpdf_imagerenderer.cpp | |
parent | 31b08d4cdaa17d7a03f35e087096a77036af98ec (diff) | |
download | pdfium-f0799fe84df4d86f25d342b03525f3016d674f86.tar.xz |
Revert "Revert "Refcount all CFX_DIBSources (and subclasses) all the time.""
This reverts commit 31b08d4cdaa17d7a03f35e087096a77036af98ec.
Re-landing the patch after fixing skia build issue.
Change-Id: Ie7039890088b803a6ec5ce365d70f57277459b48
Reviewed-on: https://pdfium-review.googlesource.com/3245
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/render/cpdf_imagerenderer.cpp')
-rw-r--r-- | core/fpdfapi/render/cpdf_imagerenderer.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index d3778452a3..08f9165f8a 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -95,9 +95,9 @@ bool CPDF_ImageRenderer::StartRenderDIBSource() { !m_pImageObject->m_GeneralState.GetTransferFunc()->m_bIdentity) { m_pDIBSource = m_Loader.m_pBitmap = m_pImageObject->m_GeneralState.GetTransferFunc()->TranslateImage( - m_Loader.m_pBitmap, !m_Loader.m_bCached); + m_Loader.m_pBitmap); if (m_Loader.m_bCached && m_Loader.m_pMask) - m_Loader.m_pMask = m_Loader.m_pMask->Clone().release(); + m_Loader.m_pMask = m_Loader.m_pMask->Clone(); m_Loader.m_bCached = false; } } @@ -116,7 +116,7 @@ bool CPDF_ImageRenderer::StartRenderDIBSource() { m_pClone = m_pDIBSource->Clone(); m_pClone->ConvertColorScale(m_pRenderStatus->m_Options.m_BackColor, m_pRenderStatus->m_Options.m_ForeColor); - m_pDIBSource = m_pClone.get(); + m_pDIBSource = m_pClone; } m_Flags = 0; if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) @@ -209,7 +209,7 @@ bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, } bool CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, - const CFX_DIBSource* pDIBSource, + const CFX_RetainPtr<CFX_DIBSource>& pDIBSource, FX_ARGB bitmap_argb, int bitmap_alpha, const CFX_Matrix* pImage2Device, @@ -244,11 +244,12 @@ CFX_Matrix CPDF_ImageRenderer::GetDrawMatrix(const FX_RECT& rect) const { return new_matrix; } -void CPDF_ImageRenderer::CalculateDrawImage(CFX_FxgeDevice* pBitmapDevice1, - CFX_FxgeDevice* pBitmapDevice2, - const CFX_DIBSource* pDIBSource, - CFX_Matrix* pNewMatrix, - const FX_RECT& rect) const { +void CPDF_ImageRenderer::CalculateDrawImage( + CFX_FxgeDevice* pBitmapDevice1, + CFX_FxgeDevice* pBitmapDevice2, + const CFX_RetainPtr<CFX_DIBSource>& pDIBSource, + CFX_Matrix* pNewMatrix, + const FX_RECT& rect) const { CPDF_RenderStatus bitmap_render; bitmap_render.Initialize(m_pRenderStatus->m_pContext, pBitmapDevice2, nullptr, nullptr, nullptr, nullptr, nullptr, 0, @@ -403,7 +404,7 @@ bool CPDF_ImageRenderer::StartDIBSource() { } } #ifdef _SKIA_SUPPORT_ - CFX_DIBitmap* premultiplied = m_pDIBSource->Clone().release(); + CFX_RetainPtr<CFX_DIBitmap> premultiplied = m_pDIBSource->Clone(); if (m_pDIBSource->HasAlpha()) CFX_SkiaDeviceDriver::PreMultiply(premultiplied); if (m_pRenderStatus->m_pDevice->StartDIBitsWithBlend( @@ -480,10 +481,10 @@ bool CPDF_ImageRenderer::StartDIBSource() { FX_RECT dest_clip( dest_rect.left - image_rect.left, dest_rect.top - image_rect.top, dest_rect.right - image_rect.left, dest_rect.bottom - image_rect.top); - std::unique_ptr<CFX_DIBitmap> pStretched( - m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip)); + CFX_RetainPtr<CFX_DIBitmap> pStretched = + m_pDIBSource->StretchTo(dest_width, dest_height, m_Flags, &dest_clip); if (pStretched) { - m_pRenderStatus->CompositeDIBitmap(pStretched.get(), dest_rect.left, + m_pRenderStatus->CompositeDIBitmap(pStretched, dest_rect.left, dest_rect.top, m_FillArgb, m_BitmapAlpha, m_BlendType, false); } @@ -501,9 +502,9 @@ bool CPDF_ImageRenderer::StartBitmapAlpha() { FXFILL_WINDING); return false; } - CFX_MaybeOwned<CFX_DIBSource> pAlphaMask; + CFX_RetainPtr<CFX_DIBSource> pAlphaMask; if (m_pDIBSource->IsAlphaMask()) - pAlphaMask = const_cast<CFX_DIBSource*>(m_pDIBSource); + pAlphaMask = m_pDIBSource; else pAlphaMask = m_pDIBSource->CloneAlphaMask(); @@ -511,13 +512,13 @@ bool CPDF_ImageRenderer::StartBitmapAlpha() { FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) { int left; int top; - std::unique_ptr<CFX_DIBitmap> pTransformed = + CFX_RetainPtr<CFX_DIBitmap> pTransformed = pAlphaMask->TransformTo(&m_ImageMatrix, left, top); if (!pTransformed) return true; m_pRenderStatus->m_pDevice->SetBitMask( - pTransformed.get(), left, top, + pTransformed, left, top, ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha)); return false; } @@ -530,7 +531,7 @@ bool CPDF_ImageRenderer::StartBitmapAlpha() { int left = dest_width > 0 ? image_rect.left : image_rect.right; int top = dest_height > 0 ? image_rect.top : image_rect.bottom; m_pRenderStatus->m_pDevice->StretchBitMask( - pAlphaMask.Get(), left, top, dest_width, dest_height, + pAlphaMask, left, top, dest_width, dest_height, ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha)); return false; } @@ -540,7 +541,7 @@ bool CPDF_ImageRenderer::Continue(IFX_Pause* pPause) { if (m_pTransformer->Continue(pPause)) return true; - std::unique_ptr<CFX_DIBitmap> pBitmap(m_pTransformer->DetachBitmap()); + CFX_RetainPtr<CFX_DIBitmap> pBitmap = m_pTransformer->DetachBitmap(); if (!pBitmap) return false; @@ -548,14 +549,14 @@ bool CPDF_ImageRenderer::Continue(IFX_Pause* pPause) { if (m_BitmapAlpha != 255) m_FillArgb = FXARGB_MUL_ALPHA(m_FillArgb, m_BitmapAlpha); m_Result = m_pRenderStatus->m_pDevice->SetBitMask( - pBitmap.get(), m_pTransformer->result().left, - m_pTransformer->result().top, m_FillArgb); + pBitmap, m_pTransformer->result().left, m_pTransformer->result().top, + m_FillArgb); } else { if (m_BitmapAlpha != 255) pBitmap->MultiplyAlpha(m_BitmapAlpha); m_Result = m_pRenderStatus->m_pDevice->SetDIBitsWithBlend( - pBitmap.get(), m_pTransformer->result().left, - m_pTransformer->result().top, m_BlendType); + pBitmap, m_pTransformer->result().left, m_pTransformer->result().top, + m_BlendType); } return false; } |