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

Unified Diff: core/fxge/dib/fx_dib_transform.cpp

Issue 2572293002: More unique_ptr returns from DIB methods. (Closed)
Patch Set: win build 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/fxge/dib/fx_dib_main.cpp ('k') | core/fxge/fx_dib.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxge/dib/fx_dib_transform.cpp
diff --git a/core/fxge/dib/fx_dib_transform.cpp b/core/fxge/dib/fx_dib_transform.cpp
index e56e7fccbbfe587c587fb551a3b277c4d1d6a45b..1c29ada68f66ef3e545ae3b30cdabd2e0f43da6b 100644
--- a/core/fxge/dib/fx_dib_transform.cpp
+++ b/core/fxge/dib/fx_dib_transform.cpp
@@ -178,22 +178,23 @@ class CFX_BilinearMatrix : public CPDF_FixedMatrix {
y1 /= base;
}
};
-CFX_DIBitmap* CFX_DIBSource::SwapXY(bool bXFlip,
- bool bYFlip,
- const FX_RECT* pDestClip) const {
+
+std::unique_ptr<CFX_DIBitmap> CFX_DIBSource::SwapXY(
+ bool bXFlip,
+ bool bYFlip,
+ const FX_RECT* pDestClip) const {
FX_RECT dest_clip(0, 0, m_Height, m_Width);
- if (pDestClip) {
+ if (pDestClip)
dest_clip.Intersect(*pDestClip);
- }
- if (dest_clip.IsEmpty()) {
+ if (dest_clip.IsEmpty())
return nullptr;
- }
- CFX_DIBitmap* pTransBitmap = new CFX_DIBitmap;
- int result_height = dest_clip.Height(), result_width = dest_clip.Width();
- if (!pTransBitmap->Create(result_width, result_height, GetFormat())) {
- delete pTransBitmap;
+
+ auto pTransBitmap = pdfium::MakeUnique<CFX_DIBitmap>();
+ int result_height = dest_clip.Height();
+ int result_width = dest_clip.Width();
+ if (!pTransBitmap->Create(result_width, result_height, GetFormat()))
return nullptr;
- }
+
pTransBitmap->SetPalette(m_pPalette.get());
int dest_pitch = pTransBitmap->GetPitch();
uint8_t* dest_buf = pTransBitmap->GetBuffer();
@@ -276,6 +277,7 @@ CFX_DIBitmap* CFX_DIBSource::SwapXY(bool bXFlip,
}
return pTransBitmap;
}
+
#define FIX16_005 0.05f
FX_RECT FXDIB_SwapClipBox(FX_RECT& clip,
int width,
@@ -415,9 +417,8 @@ bool CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
return true;
if (m_Storer.GetBitmap()) {
- std::unique_ptr<CFX_DIBitmap> swapped(
+ m_Storer.Replace(
m_Storer.GetBitmap()->SwapXY(m_pMatrix->c > 0, m_pMatrix->b < 0));
- m_Storer.Replace(std::move(swapped));
}
return false;
}
« no previous file with comments | « core/fxge/dib/fx_dib_main.cpp ('k') | core/fxge/fx_dib.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698