OLD | NEW |
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()) { | |
26 SkPdfReport(kIgnoreError_SkPdfIssueSeverity, kNoFlateLibrary_SkPdfIssue, | |
27 "forgot to link with flate library?", NULL, NULL); | |
28 return false; | |
29 } | |
30 | |
31 const unsigned char* old = fStr.fBuffer; | 25 const unsigned char* old = fStr.fBuffer; |
32 bool deleteOld = isStreamOwned(); | 26 bool deleteOld = isStreamOwned(); |
33 | 27 |
34 SkMemoryStream skstream(fStr.fBuffer, fStr.fBytes >> 2, false); | 28 SkMemoryStream skstream(fStr.fBuffer, fStr.fBytes >> 2, false); |
35 SkDynamicMemoryWStream uncompressedData; | 29 SkDynamicMemoryWStream uncompressedData; |
36 | 30 |
37 if (SkFlate::Inflate(&skstream, &uncompressedData)) { | 31 if (SkFlate::Inflate(&skstream, &uncompressedData)) { |
38 fStr.fBytes = (uncompressedData.bytesWritten() << 2) + kOwnedStreamBit + | 32 fStr.fBytes = (uncompressedData.bytesWritten() << 2) + kOwnedStreamBit + |
39 kUnfilteredStreamBit; | 33 kUnfilteredStreamBit; |
40 fStr.fBuffer = (const unsigned char*)new unsigned char[uncompressedData.
bytesWritten()]; | 34 fStr.fBuffer = (const unsigned char*)new unsigned char[uncompressedData.
bytesWritten()]; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 delete (SkBitmap*)fData; | 119 delete (SkBitmap*)fData; |
126 break; | 120 break; |
127 default: | 121 default: |
128 SkASSERT(false); | 122 SkASSERT(false); |
129 break; | 123 break; |
130 } | 124 } |
131 } | 125 } |
132 fData = NULL; | 126 fData = NULL; |
133 fDataType = kEmpty_Data; | 127 fDataType = kEmpty_Data; |
134 } | 128 } |
OLD | NEW |