OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifdef SK_BUILD_FOR_WIN32 | 9 #ifdef SK_BUILD_FOR_WIN32 |
10 #pragma warning(push) | 10 #pragma warning(push) |
11 #pragma warning(disable : 4530) | 11 #pragma warning(disable : 4530) |
12 #endif | 12 #endif |
13 | 13 |
14 #include "SkPDFRasterizer.h" | 14 #include "SkPDFRasterizer.h" |
15 #include "SkColorPriv.h" | 15 #include "SkColorPriv.h" |
16 | 16 |
17 #ifdef SK_BUILD_NATIVE_PDF_RENDERER | 17 #ifdef SK_BUILD_NATIVE_PDF_RENDERER |
18 #include "SkPdfRenderer.h" | 18 #include "SkPdfRenderer.h" |
19 #endif // SK_BUILD_NATIVE_PDF_RENDERER | 19 #endif // SK_BUILD_NATIVE_PDF_RENDERER |
20 | 20 |
21 #ifdef SK_BUILD_POPPLER | 21 #ifdef SK_BUILD_POPPLER |
22 #include <poppler-document.h> | 22 #include <poppler-document.h> |
23 #include <poppler-image.h> | 23 #include <poppler-image.h> |
24 #include <poppler-page.h> | 24 #include <poppler-page.h> |
25 #include <poppler-page-renderer.h> | 25 #include <poppler-page-renderer.h> |
26 #endif // SK_BUILD_POPPLER | 26 #endif // SK_BUILD_POPPLER |
27 | 27 |
28 #ifdef SK_BUILD_POPPLER | 28 #ifdef SK_BUILD_POPPLER |
29 bool SkPopplerRasterizePDF(SkStream* pdf, SkBitmap* output) { | 29 bool SkPopplerRasterizePDF(SkStream* pdf, SkBitmap* output) { |
| 30 SkAutoTDelete<SkStream> streamDeleter(pdf); |
30 size_t size = pdf->getLength(); | 31 size_t size = pdf->getLength(); |
31 SkAutoFree buffer(sk_malloc_throw(size)); | 32 SkAutoFree buffer(sk_malloc_throw(size)); |
32 pdf->read(buffer.get(), size); | 33 pdf->read(buffer.get(), size); |
33 | 34 |
34 SkAutoTDelete<poppler::document> doc( | 35 SkAutoTDelete<poppler::document> doc( |
35 poppler::document::load_from_raw_data((const char*)buffer.get(), size)); | 36 poppler::document::load_from_raw_data((const char*)buffer.get(), size)); |
36 if (!doc.get() || doc->is_locked()) { | 37 if (!doc.get() || doc->is_locked()) { |
37 return false; | 38 return false; |
38 } | 39 } |
39 | 40 |
(...skipping 34 matching lines...) Loading... |
74 } | 75 } |
75 | 76 |
76 output->swap(bitmap); | 77 output->swap(bitmap); |
77 | 78 |
78 return true; | 79 return true; |
79 } | 80 } |
80 #endif // SK_BUILD_POPPLER | 81 #endif // SK_BUILD_POPPLER |
81 | 82 |
82 #ifdef SK_BUILD_NATIVE_PDF_RENDERER | 83 #ifdef SK_BUILD_NATIVE_PDF_RENDERER |
83 bool SkNativeRasterizePDF(SkStream* pdf, SkBitmap* output) { | 84 bool SkNativeRasterizePDF(SkStream* pdf, SkBitmap* output) { |
| 85 SkAutoTDelete<SkStream> streamDeleter(pdf); |
84 return SkPDFNativeRenderToBitmap(pdf, output); | 86 return SkPDFNativeRenderToBitmap(pdf, output); |
85 } | 87 } |
86 #endif // SK_BUILD_NATIVE_PDF_RENDERER | 88 #endif // SK_BUILD_NATIVE_PDF_RENDERER |
OLD | NEW |