summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render/cpdf_imagerenderer.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-14 14:15:14 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-14 14:15:14 -0800
commit72c1bda4efaf0121e13b794cb886acd9806b6c89 (patch)
tree42930bca08650730ef2aba728799c9428edab79e /core/fpdfapi/render/cpdf_imagerenderer.cpp
parent5e4388ef805b1666a1064e4dc73f4f1e792aa041 (diff)
downloadpdfium-72c1bda4efaf0121e13b794cb886acd9806b6c89.tar.xz
Return unique_ptr from GetAlphaMask.
Rename GetAlphaMask => CloneAlphaMask since it does more than get. Rename CopyAlphaMask => SetAlphaMask, as it copies IN, not OUT. ditto for CopyPalette => SetPalette. BUG= Review-Url: https://codereview.chromium.org/2572243002
Diffstat (limited to 'core/fpdfapi/render/cpdf_imagerenderer.cpp')
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp42
1 files changed, 23 insertions, 19 deletions
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index 5ca7ea842f..a5b1238eaf 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -25,6 +25,7 @@
#include "core/fpdfapi/render/cpdf_transferfunc.h"
#include "core/fpdfapi/render/render_int.h"
#include "core/fpdfdoc/cpdf_occontext.h"
+#include "core/fxcrt/cfx_maybe_owned.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxge/cfx_fxgedevice.h"
#include "core/fxge/cfx_pathdata.h"
@@ -499,34 +500,37 @@ bool CPDF_ImageRenderer::StartBitmapAlpha() {
FXFILL_WINDING);
return false;
}
- const CFX_DIBSource* pAlphaMask =
- m_pDIBSource->IsAlphaMask() ? m_pDIBSource : m_pDIBSource->GetAlphaMask();
+ CFX_MaybeOwned<CFX_DIBSource> pAlphaMask;
+ if (m_pDIBSource->IsAlphaMask())
+ pAlphaMask = const_cast<CFX_DIBSource*>(m_pDIBSource);
+ else
+ pAlphaMask = m_pDIBSource->CloneAlphaMask();
+
if (FXSYS_fabs(m_ImageMatrix.b) >= 0.5f ||
FXSYS_fabs(m_ImageMatrix.c) >= 0.5f) {
- int left, top;
- std::unique_ptr<CFX_DIBitmap> pTransformed(
- pAlphaMask->TransformTo(&m_ImageMatrix, left, top));
+ int left;
+ int top;
+ std::unique_ptr<CFX_DIBitmap> pTransformed =
+ pAlphaMask->TransformTo(&m_ImageMatrix, left, top);
if (!pTransformed)
return true;
m_pRenderStatus->m_pDevice->SetBitMask(
pTransformed.get(), left, top,
ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha));
- } else {
- CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect();
- FX_RECT image_rect = image_rect_f.GetOuterRect();
- int dest_width =
- m_ImageMatrix.a > 0 ? image_rect.Width() : -image_rect.Width();
- int dest_height =
- m_ImageMatrix.d > 0 ? -image_rect.Height() : image_rect.Height();
- 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, left, top, dest_width, dest_height,
- ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha));
+ return false;
}
- if (m_pDIBSource != pAlphaMask)
- delete pAlphaMask;
+ CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect();
+ FX_RECT image_rect = image_rect_f.GetOuterRect();
+ int dest_width =
+ m_ImageMatrix.a > 0 ? image_rect.Width() : -image_rect.Width();
+ int dest_height =
+ m_ImageMatrix.d > 0 ? -image_rect.Height() : image_rect.Height();
+ 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,
+ ArgbEncode(0xff, m_BitmapAlpha, m_BitmapAlpha, m_BitmapAlpha));
return false;
}