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

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

Issue 2608663003: Pdfium Patch to restore PS Path (Closed)
Patch Set: Created 3 years, 11 months 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/fxcodec/codec/fx_codec_fax.cpp ('k') | core/fxcodec/codec/fx_codec_jpeg.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/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>
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 bool ret = true; 838 bool ret = true;
839 if (predictor_type == 2) { 839 if (predictor_type == 2) {
840 ret = PNG_Predictor(dest_buf, dest_size, Colors, BitsPerComponent, Columns); 840 ret = PNG_Predictor(dest_buf, dest_size, Colors, BitsPerComponent, Columns);
841 } else if (predictor_type == 1) { 841 } else if (predictor_type == 1) {
842 ret = 842 ret =
843 TIFF_Predictor(dest_buf, dest_size, Colors, BitsPerComponent, Columns); 843 TIFF_Predictor(dest_buf, dest_size, Colors, BitsPerComponent, Columns);
844 } 844 }
845 return ret ? offset : FX_INVALID_OFFSET; 845 return ret ? offset : FX_INVALID_OFFSET;
846 } 846 }
847 847
848 // static
848 bool CCodec_FlateModule::Encode(const uint8_t* src_buf, 849 bool CCodec_FlateModule::Encode(const uint8_t* src_buf,
849 uint32_t src_size, 850 uint32_t src_size,
850 uint8_t** dest_buf, 851 uint8_t** dest_buf,
851 uint32_t* dest_size) { 852 uint32_t* dest_size) {
852 *dest_size = src_size + src_size / 1000 + 12; 853 *dest_size = src_size + src_size / 1000 + 12;
853 *dest_buf = FX_Alloc(uint8_t, *dest_size); 854 *dest_buf = FX_Alloc(uint8_t, *dest_size);
854 unsigned long temp_size = *dest_size; 855 unsigned long temp_size = *dest_size;
855 if (!FPDFAPI_FlateCompress(*dest_buf, &temp_size, src_buf, src_size)) 856 if (!FPDFAPI_FlateCompress(*dest_buf, &temp_size, src_buf, src_size))
856 return false; 857 return false;
857 858
858 *dest_size = (uint32_t)temp_size; 859 *dest_size = (uint32_t)temp_size;
859 return true; 860 return true;
860 } 861 }
861 862
863 // static
862 bool CCodec_FlateModule::PngEncode(const uint8_t* src_buf, 864 bool CCodec_FlateModule::PngEncode(const uint8_t* src_buf,
863 uint32_t src_size, 865 uint32_t src_size,
864 uint8_t** dest_buf, 866 uint8_t** dest_buf,
865 uint32_t* dest_size) { 867 uint32_t* dest_size) {
866 uint8_t* pSrcBuf = FX_Alloc(uint8_t, src_size); 868 uint8_t* pSrcBuf = FX_Alloc(uint8_t, src_size);
867 FXSYS_memcpy(pSrcBuf, src_buf, src_size); 869 FXSYS_memcpy(pSrcBuf, src_buf, src_size);
868 PNG_PredictorEncode(&pSrcBuf, &src_size); 870 PNG_PredictorEncode(&pSrcBuf, &src_size);
869 bool ret = Encode(pSrcBuf, src_size, dest_buf, dest_size); 871 bool ret = Encode(pSrcBuf, src_size, dest_buf, dest_size);
870 FX_Free(pSrcBuf); 872 FX_Free(pSrcBuf);
871 return ret; 873 return ret;
872 } 874 }
OLDNEW
« no previous file with comments | « core/fxcodec/codec/fx_codec_fax.cpp ('k') | core/fxcodec/codec/fx_codec_jpeg.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698