summaryrefslogtreecommitdiff
path: root/core/fxge/dib
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-12-14 19:48:47 -0800
committerCommit bot <commit-bot@chromium.org>2016-12-14 19:48:47 -0800
commitb8642f8a3c3a6d359c4e319b8ba91f8df6448a4f (patch)
treebc5443fec6a3bf35dd883a66cdfd056397998013 /core/fxge/dib
parentc7739322e5cdcc5779bdde2a1560ea3dee891e51 (diff)
downloadpdfium-b8642f8a3c3a6d359c4e319b8ba91f8df6448a4f.tar.xz
More unique_ptr returns from DIB methods.
Review-Url: https://codereview.chromium.org/2572293002
Diffstat (limited to 'core/fxge/dib')
-rw-r--r--core/fxge/dib/fx_dib_main.cpp10
-rw-r--r--core/fxge/dib/fx_dib_transform.cpp29
2 files changed, 20 insertions, 19 deletions
diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp
index f90cbc1a91..8e6366d5c0 100644
--- a/core/fxge/dib/fx_dib_main.cpp
+++ b/core/fxge/dib/fx_dib_main.cpp
@@ -1342,12 +1342,12 @@ bool CFX_DIBitmap::ConvertColorScale(uint32_t forecolor, uint32_t backcolor) {
return true;
}
-CFX_DIBitmap* CFX_DIBSource::FlipImage(bool bXFlip, bool bYFlip) const {
- CFX_DIBitmap* pFlipped = new CFX_DIBitmap;
- if (!pFlipped->Create(m_Width, m_Height, GetFormat())) {
- delete pFlipped;
+std::unique_ptr<CFX_DIBitmap> CFX_DIBSource::FlipImage(bool bXFlip,
+ bool bYFlip) const {
+ auto pFlipped = pdfium::MakeUnique<CFX_DIBitmap>();
+ if (!pFlipped->Create(m_Width, m_Height, GetFormat()))
return nullptr;
- }
+
pFlipped->SetPalette(m_pPalette.get());
uint8_t* pDestBuffer = pFlipped->GetBuffer();
int Bpp = m_bpp / 8;
diff --git a/core/fxge/dib/fx_dib_transform.cpp b/core/fxge/dib/fx_dib_transform.cpp
index e56e7fccbb..1c29ada68f 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;
}