Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Unified Diff: core/fpdfapi/render/cpdf_imagerenderer.cpp

Issue 2572243002: Return unique_ptr from GetAlphaMask. (Closed)
Patch Set: rebase, nits, typo. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfapi/page/cpdf_image.cpp ('k') | core/fxge/dib/fx_dib_convert.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/render/cpdf_imagerenderer.cpp
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index 5ca7ea842f0d86440ca3d14b50092f9add9f3cb9..a5b1238eafd1aee10d9d2fc1c6ce9662aab81548 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;
}
« no previous file with comments | « core/fpdfapi/page/cpdf_image.cpp ('k') | core/fxge/dib/fx_dib_convert.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698