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

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

Issue 2572843002: Return unique_ptr<>s from fxcodec/ (Closed)
Patch Set: std::move it 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
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/codec_int.h" 7 #include "core/fxcodec/codec/codec_int.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <utility>
11 12
12 #include "core/fxcodec/fx_codec.h" 13 #include "core/fxcodec/fx_codec.h"
13 #include "core/fxcrt/fx_ext.h" 14 #include "core/fxcrt/fx_ext.h"
15 #include "third_party/base/ptr_util.h"
14 #include "third_party/zlib_v128/zlib.h" 16 #include "third_party/zlib_v128/zlib.h"
15 17
16 extern "C" { 18 extern "C" {
17 static void* my_alloc_func(void* opaque, 19 static void* my_alloc_func(void* opaque,
18 unsigned int items, 20 unsigned int items,
19 unsigned int size) { 21 unsigned int size) {
20 return FX_Alloc2D(uint8_t, items, size); 22 return FX_Alloc2D(uint8_t, items, size);
21 } 23 }
22 static void my_free_func(void* opaque, void* address) { 24 static void my_free_func(void* opaque, void* address) {
23 FX_Free(address); 25 FX_Free(address);
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 } 766 }
765 } else { 767 } else {
766 FPDFAPI_FlateOutput(m_pFlate, m_pScanline, m_Pitch); 768 FPDFAPI_FlateOutput(m_pFlate, m_pScanline, m_Pitch);
767 } 769 }
768 return m_pScanline; 770 return m_pScanline;
769 } 771 }
770 uint32_t CCodec_FlateScanlineDecoder::GetSrcOffset() { 772 uint32_t CCodec_FlateScanlineDecoder::GetSrcOffset() {
771 return FPDFAPI_FlateGetTotalIn(m_pFlate); 773 return FPDFAPI_FlateGetTotalIn(m_pFlate);
772 } 774 }
773 775
774 CCodec_ScanlineDecoder* CCodec_FlateModule::CreateDecoder( 776 std::unique_ptr<CCodec_ScanlineDecoder> CCodec_FlateModule::CreateDecoder(
775 const uint8_t* src_buf, 777 const uint8_t* src_buf,
776 uint32_t src_size, 778 uint32_t src_size,
777 int width, 779 int width,
778 int height, 780 int height,
779 int nComps, 781 int nComps,
780 int bpc, 782 int bpc,
781 int predictor, 783 int predictor,
782 int Colors, 784 int Colors,
783 int BitsPerComponent, 785 int BitsPerComponent,
784 int Columns) { 786 int Columns) {
785 CCodec_FlateScanlineDecoder* pDecoder = new CCodec_FlateScanlineDecoder; 787 auto pDecoder = pdfium::MakeUnique<CCodec_FlateScanlineDecoder>();
786 pDecoder->Create(src_buf, src_size, width, height, nComps, bpc, predictor, 788 pDecoder->Create(src_buf, src_size, width, height, nComps, bpc, predictor,
787 Colors, BitsPerComponent, Columns); 789 Colors, BitsPerComponent, Columns);
788 return pDecoder; 790 return std::move(pDecoder);
789 } 791 }
792
790 uint32_t CCodec_FlateModule::FlateOrLZWDecode(bool bLZW, 793 uint32_t CCodec_FlateModule::FlateOrLZWDecode(bool bLZW,
791 const uint8_t* src_buf, 794 const uint8_t* src_buf,
792 uint32_t src_size, 795 uint32_t src_size,
793 bool bEarlyChange, 796 bool bEarlyChange,
794 int predictor, 797 int predictor,
795 int Colors, 798 int Colors,
796 int BitsPerComponent, 799 int BitsPerComponent,
797 int Columns, 800 int Columns,
798 uint32_t estimated_size, 801 uint32_t estimated_size,
799 uint8_t*& dest_buf, 802 uint8_t*& dest_buf,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 uint32_t src_size, 863 uint32_t src_size,
861 uint8_t** dest_buf, 864 uint8_t** dest_buf,
862 uint32_t* dest_size) { 865 uint32_t* dest_size) {
863 uint8_t* pSrcBuf = FX_Alloc(uint8_t, src_size); 866 uint8_t* pSrcBuf = FX_Alloc(uint8_t, src_size);
864 FXSYS_memcpy(pSrcBuf, src_buf, src_size); 867 FXSYS_memcpy(pSrcBuf, src_buf, src_size);
865 PNG_PredictorEncode(&pSrcBuf, &src_size); 868 PNG_PredictorEncode(&pSrcBuf, &src_size);
866 bool ret = Encode(pSrcBuf, src_size, dest_buf, dest_size); 869 bool ret = Encode(pSrcBuf, src_size, dest_buf, dest_size);
867 FX_Free(pSrcBuf); 870 FX_Free(pSrcBuf);
868 return ret; 871 return ret;
869 } 872 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698