summaryrefslogtreecommitdiff
path: root/core/fxcodec/jbig2/JBig2_Image.cpp
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-07-14 10:00:21 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-14 14:18:45 +0000
commitb6db208773e94b9d25f7dbd740859adbb8a60fdf (patch)
tree8f0426521a18b70303cea0fcccd8f29e3eeead24 /core/fxcodec/jbig2/JBig2_Image.cpp
parent2b918c8d05c922287efbc8858f029026cee31442 (diff)
downloadpdfium-b6db208773e94b9d25f7dbd740859adbb8a60fdf.tar.xz
More unique_ptrs in JBIG2 code part 2
This CL makes HDPATS in CJBig2_PatternDict be a vector of unique_ptr. Change-Id: Ib23aed6323d4a988b2eedc4bfe95f2098d32c188 Reviewed-on: https://pdfium-review.googlesource.com/7871 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcodec/jbig2/JBig2_Image.cpp')
-rw-r--r--core/fxcodec/jbig2/JBig2_Image.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/core/fxcodec/jbig2/JBig2_Image.cpp b/core/fxcodec/jbig2/JBig2_Image.cpp
index 8f935ceb1f..f026ce660b 100644
--- a/core/fxcodec/jbig2/JBig2_Image.cpp
+++ b/core/fxcodec/jbig2/JBig2_Image.cpp
@@ -9,6 +9,7 @@
#include "core/fxcodec/jbig2/JBig2_Image.h"
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_safe_types.h"
+#include "third_party/base/ptr_util.h"
namespace {
@@ -162,32 +163,37 @@ bool CJBig2_Image::composeFrom(int32_t x,
CJBig2_Image* pSrc,
JBig2ComposeOp op,
const FX_RECT* pSrcRect) {
- if (!m_pData) {
- return false;
- }
- return pSrc->composeTo(this, x, y, op, pSrcRect);
+ return m_pData ? pSrc->composeTo(this, x, y, op, pSrcRect) : false;
}
+
#define JBIG2_GETDWORD(buf) \
((uint32_t)(((buf)[0] << 24) | ((buf)[1] << 16) | ((buf)[2] << 8) | (buf)[3]))
-CJBig2_Image* CJBig2_Image::subImage(int32_t x,
- int32_t y,
- int32_t w,
- int32_t h) {
- int32_t m, n, j;
- uint8_t *pLineSrc, *pLineDst;
+
+std::unique_ptr<CJBig2_Image> CJBig2_Image::subImage(int32_t x,
+ int32_t y,
+ int32_t w,
+ int32_t h) {
+ int32_t m;
+ int32_t n;
+ int32_t j;
+ uint8_t* pLineSrc;
+ uint8_t* pLineDst;
uint32_t wTmp;
- uint8_t *pSrc, *pSrcEnd, *pDst, *pDstEnd;
- if (w == 0 || h == 0) {
+ uint8_t* pSrc;
+ uint8_t* pSrcEnd;
+ uint8_t* pDst;
+ uint8_t* pDstEnd;
+ if (w == 0 || h == 0)
return nullptr;
- }
- CJBig2_Image* pImage = new CJBig2_Image(w, h);
+
+ auto pImage = pdfium::MakeUnique<CJBig2_Image>(w, h);
if (!m_pData) {
pImage->fill(0);
return pImage;
}
- if (!pImage->m_pData) {
+ if (!pImage->m_pData)
return pImage;
- }
+
pLineSrc = m_pData + m_nStride * y;
pLineDst = pImage->m_pData;
m = (x >> 5) << 2;