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

Side by Side Diff: core/fxcodec/codec/fx_codec_progress.cpp

Issue 2534953004: Return unique_ptrs from CFX_DIBitmap::Clone(). (Closed)
Patch Set: nits 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 unified diff | Download patch
« no previous file with comments | « core/fpdfapi/render/render_int.h ('k') | core/fxge/agg/fx_agg_driver.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fxcodec/codec/ccodec_progressivedecoder.h" 7 #include "core/fxcodec/codec/ccodec_progressivedecoder.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory>
10 11
11 #include "core/fxcodec/fx_codec.h" 12 #include "core/fxcodec/fx_codec.h"
12 #include "core/fxge/fx_dib.h" 13 #include "core/fxge/fx_dib.h"
13 #include "third_party/base/numerics/safe_math.h" 14 #include "third_party/base/numerics/safe_math.h"
14 15
15 #define FXCODEC_BLOCK_SIZE 4096 16 #define FXCODEC_BLOCK_SIZE 4096
16 17
17 namespace { 18 namespace {
18 19
19 #if _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ 20 #if _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_
(...skipping 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 delete pDIBitmap; 2255 delete pDIBitmap;
2255 m_pDeviceBitmap = nullptr; 2256 m_pDeviceBitmap = nullptr;
2256 m_pFile = nullptr; 2257 m_pFile = nullptr;
2257 m_status = FXCODEC_STATUS_ERROR; 2258 m_status = FXCODEC_STATUS_ERROR;
2258 return m_status; 2259 return m_status;
2259 } 2260 }
2260 CFX_DIBitmap* pClipBitmap = 2261 CFX_DIBitmap* pClipBitmap =
2261 (m_clipBox.left == 0 && m_clipBox.top == 0 && 2262 (m_clipBox.left == 0 && m_clipBox.top == 0 &&
2262 m_clipBox.right == m_SrcWidth && m_clipBox.bottom == m_SrcHeight) 2263 m_clipBox.right == m_SrcWidth && m_clipBox.bottom == m_SrcHeight)
2263 ? pDIBitmap 2264 ? pDIBitmap
2264 : pDIBitmap->Clone(&m_clipBox); 2265 : pDIBitmap->Clone(&m_clipBox).release();
2265 if (pDIBitmap != pClipBitmap) { 2266 if (pDIBitmap != pClipBitmap) {
2266 delete pDIBitmap; 2267 delete pDIBitmap;
2267 } 2268 }
2268 if (!pClipBitmap) { 2269 if (!pClipBitmap) {
2269 m_pDeviceBitmap = nullptr; 2270 m_pDeviceBitmap = nullptr;
2270 m_pFile = nullptr; 2271 m_pFile = nullptr;
2271 m_status = FXCODEC_STATUS_ERR_MEMORY; 2272 m_status = FXCODEC_STATUS_ERR_MEMORY;
2272 return m_status; 2273 return m_status;
2273 } 2274 }
2274 CFX_DIBitmap* pFormatBitmap = nullptr; 2275 CFX_DIBitmap* pFormatBitmap = nullptr;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2339 } 2340 }
2340 if (pClipBitmap != pFormatBitmap) { 2341 if (pClipBitmap != pFormatBitmap) {
2341 delete pClipBitmap; 2342 delete pClipBitmap;
2342 } 2343 }
2343 if (!pFormatBitmap) { 2344 if (!pFormatBitmap) {
2344 m_pDeviceBitmap = nullptr; 2345 m_pDeviceBitmap = nullptr;
2345 m_pFile = nullptr; 2346 m_pFile = nullptr;
2346 m_status = FXCODEC_STATUS_ERR_MEMORY; 2347 m_status = FXCODEC_STATUS_ERR_MEMORY;
2347 return m_status; 2348 return m_status;
2348 } 2349 }
2349 CFX_DIBitmap* pStrechBitmap = pFormatBitmap->StretchTo( 2350 std::unique_ptr<CFX_DIBitmap> pStrechBitmap = pFormatBitmap->StretchTo(
2350 m_sizeX, m_sizeY, m_bInterpol ? FXDIB_INTERPOL : FXDIB_DOWNSAMPLE); 2351 m_sizeX, m_sizeY, m_bInterpol ? FXDIB_INTERPOL : FXDIB_DOWNSAMPLE);
2351 delete pFormatBitmap; 2352 delete pFormatBitmap;
2352 pFormatBitmap = nullptr; 2353 pFormatBitmap = nullptr;
2353 if (!pStrechBitmap) { 2354 if (!pStrechBitmap) {
2354 m_pDeviceBitmap = nullptr; 2355 m_pDeviceBitmap = nullptr;
2355 m_pFile = nullptr; 2356 m_pFile = nullptr;
2356 m_status = FXCODEC_STATUS_ERR_MEMORY; 2357 m_status = FXCODEC_STATUS_ERR_MEMORY;
2357 return m_status; 2358 return m_status;
2358 } 2359 }
2359 m_pDeviceBitmap->TransferBitmap(m_startX, m_startY, m_sizeX, m_sizeY, 2360 m_pDeviceBitmap->TransferBitmap(m_startX, m_startY, m_sizeX, m_sizeY,
2360 pStrechBitmap, 0, 0); 2361 pStrechBitmap.get(), 0, 0);
2361 delete pStrechBitmap;
2362 pStrechBitmap = nullptr;
2363 m_pDeviceBitmap = nullptr; 2362 m_pDeviceBitmap = nullptr;
2364 m_pFile = nullptr; 2363 m_pFile = nullptr;
2365 m_status = FXCODEC_STATUS_DECODE_FINISH; 2364 m_status = FXCODEC_STATUS_DECODE_FINISH;
2366 return m_status; 2365 return m_status;
2367 } 2366 }
2368 default: 2367 default:
2369 return FXCODEC_STATUS_ERROR; 2368 return FXCODEC_STATUS_ERROR;
2370 } 2369 }
2371 } 2370 }
2372 2371
2373 CCodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() { 2372 CCodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() {
2374 return new CCodec_ProgressiveDecoder(this); 2373 return new CCodec_ProgressiveDecoder(this);
2375 } 2374 }
OLDNEW
« no previous file with comments | « core/fpdfapi/render/render_int.h ('k') | core/fxge/agg/fx_agg_driver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698