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

Side by Side Diff: experimental/PdfViewer/pdfparser/native/SkPdfNativeObject.cpp

Issue 933523007: zlib/pdf: remove HaveFlate(), depend on preprocessor defines (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | gyp/skflate.gyp » ('j') | gyp/skflate.gyp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkPdfNativeObject.h" 8 #include "SkPdfNativeObject.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkFlate.h" 11 #include "SkFlate.h"
12 #include "SkPdfFont.h" 12 #include "SkPdfFont.h"
13 #include "SkPdfNativeTokenizer.h" 13 #include "SkPdfNativeTokenizer.h"
14 #include "SkPdfReporter.h" 14 #include "SkPdfReporter.h"
15 #include "SkStream.h" 15 #include "SkStream.h"
16 16
17 // TODO(edisonn): mac builder does not find the header ... but from headers is o k 17 // TODO(edisonn): mac builder does not find the header ... but from headers is o k
18 //#include "SkPdfStreamCommonDictionary_autogen.h" 18 //#include "SkPdfStreamCommonDictionary_autogen.h"
19 #include "SkPdfHeaders_autogen.h" 19 #include "SkPdfHeaders_autogen.h"
20 20
21 21
22 SkPdfNativeObject SkPdfNativeObject::kNull = SkPdfNativeObject::makeNull(); 22 SkPdfNativeObject SkPdfNativeObject::kNull = SkPdfNativeObject::makeNull();
23 23
24 bool SkPdfNativeObject::applyFlateDecodeFilter() { 24 bool SkPdfNativeObject::applyFlateDecodeFilter() {
25 if (!SkFlate::HaveFlate()) { 25 #ifdef SK_NO_FLATE
mtklein 2015/02/17 22:15:15 Just remove this? The code will fail to compile i
hal.canary 2015/02/17 22:35:44 Done.
26 SkPdfReport(kIgnoreError_SkPdfIssueSeverity, kNoFlateLibrary_SkPdfIssue, 26 SkPdfReport(kIgnoreError_SkPdfIssueSeverity, kNoFlateLibrary_SkPdfIssue,
27 "forgot to link with flate library?", NULL, NULL); 27 "forgot to link with flate library?", NULL, NULL);
28 return false; 28 return false;
29 } 29 #else // !SK_NO_FLATE
30
31 const unsigned char* old = fStr.fBuffer; 30 const unsigned char* old = fStr.fBuffer;
32 bool deleteOld = isStreamOwned(); 31 bool deleteOld = isStreamOwned();
33 32
34 SkMemoryStream skstream(fStr.fBuffer, fStr.fBytes >> 2, false); 33 SkMemoryStream skstream(fStr.fBuffer, fStr.fBytes >> 2, false);
35 SkDynamicMemoryWStream uncompressedData; 34 SkDynamicMemoryWStream uncompressedData;
36 35
37 if (SkFlate::Inflate(&skstream, &uncompressedData)) { 36 if (SkFlate::Inflate(&skstream, &uncompressedData)) {
38 fStr.fBytes = (uncompressedData.bytesWritten() << 2) + kOwnedStreamBit + 37 fStr.fBytes = (uncompressedData.bytesWritten() << 2) + kOwnedStreamBit +
39 kUnfilteredStreamBit; 38 kUnfilteredStreamBit;
40 fStr.fBuffer = (const unsigned char*)new unsigned char[uncompressedData. bytesWritten()]; 39 fStr.fBuffer = (const unsigned char*)new unsigned char[uncompressedData. bytesWritten()];
41 uncompressedData.copyTo((void*)fStr.fBuffer); 40 uncompressedData.copyTo((void*)fStr.fBuffer);
42 41
43 if (deleteOld) { 42 if (deleteOld) {
44 delete[] old; 43 delete[] old;
45 } 44 }
46 45
47 return true; 46 return true;
48 } else { 47 } else {
49 SkPdfReport(kIgnoreError_SkPdfIssueSeverity, kBadStream_SkPdfIssue, "inf late failed", this, NULL); 48 SkPdfReport(kIgnoreError_SkPdfIssueSeverity, kBadStream_SkPdfIssue, "inf late failed", this, NULL);
50 return false; 49 return false;
51 } 50 }
51 #endif // !SK_NO_FLATE
52 } 52 }
53 53
54 bool SkPdfNativeObject::applyDCTDecodeFilter() { 54 bool SkPdfNativeObject::applyDCTDecodeFilter() {
55 // applyDCTDecodeFilter will fail, and it won't allow any more filters. 55 // applyDCTDecodeFilter will fail, and it won't allow any more filters.
56 // technically, it would be possible, but not a real world scenario. 56 // technically, it would be possible, but not a real world scenario.
57 // in this way we create the image from the DCT stream directly. 57 // in this way we create the image from the DCT stream directly.
58 return false; 58 return false;
59 } 59 }
60 60
61 bool SkPdfNativeObject::applyFilter(const char* name) { 61 bool SkPdfNativeObject::applyFilter(const char* name) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 delete (SkBitmap*)fData; 125 delete (SkBitmap*)fData;
126 break; 126 break;
127 default: 127 default:
128 SkASSERT(false); 128 SkASSERT(false);
129 break; 129 break;
130 } 130 }
131 } 131 }
132 fData = NULL; 132 fData = NULL;
133 fDataType = kEmpty_Data; 133 fDataType = kEmpty_Data;
134 } 134 }
OLDNEW
« no previous file with comments | « no previous file | gyp/skflate.gyp » ('j') | gyp/skflate.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698