edisonn@google.com | 222382b | 2013-07-10 22:33:10 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | |
edisonn@google.com | 15b1118 | 2013-07-11 14:43:15 +0000 | [diff] [blame] | 9 | #ifndef SkPdfRenderer_DEFINED |
| 10 | #define SkPdfRenderer_DEFINED |
edisonn@google.com | 222382b | 2013-07-10 22:33:10 +0000 | [diff] [blame] | 11 | |
edisonn@google.com | 147adb1 | 2013-07-24 15:56:19 +0000 | [diff] [blame^] | 12 | class SkBitmap; |
edisonn@google.com | 222382b | 2013-07-10 22:33:10 +0000 | [diff] [blame] | 13 | class SkCanvas; |
| 14 | class SkNativeParsedPDF; |
edisonn@google.com | 444e25a | 2013-07-11 15:20:50 +0000 | [diff] [blame] | 15 | class SkRect; |
edisonn@google.com | 147adb1 | 2013-07-24 15:56:19 +0000 | [diff] [blame^] | 16 | class SkStream; |
| 17 | |
| 18 | enum SkPdfContent { |
| 19 | kNoForms_SkPdfContent, |
| 20 | kAll_SkPdfContent, |
| 21 | }; |
edisonn@google.com | 222382b | 2013-07-10 22:33:10 +0000 | [diff] [blame] | 22 | |
| 23 | // TODO(edisonn): move in another file |
| 24 | class SkPdfRenderer : public SkRefCnt { |
| 25 | SkNativeParsedPDF* fPdfDoc; |
| 26 | public: |
| 27 | SkPdfRenderer() : fPdfDoc(NULL) {} |
| 28 | virtual ~SkPdfRenderer() {unload();} |
| 29 | |
| 30 | // TODO(edisonn): add options to render forms, or not |
edisonn@google.com | 444e25a | 2013-07-11 15:20:50 +0000 | [diff] [blame] | 31 | bool renderPage(int page, SkCanvas* canvas, const SkRect& dst) const; |
edisonn@google.com | 222382b | 2013-07-10 22:33:10 +0000 | [diff] [blame] | 32 | |
| 33 | bool load(const SkString inputFileName); |
edisonn@google.com | 147adb1 | 2013-07-24 15:56:19 +0000 | [diff] [blame^] | 34 | bool load(SkStream* stream); |
edisonn@google.com | 222382b | 2013-07-10 22:33:10 +0000 | [diff] [blame] | 35 | bool loaded() const {return fPdfDoc != NULL;} |
| 36 | int pages() const; |
| 37 | void unload(); |
| 38 | SkRect MediaBox(int page) const; |
edisonn@google.com | 7b328fd | 2013-07-11 12:53:06 +0000 | [diff] [blame] | 39 | size_t bytesUsed() const; |
edisonn@google.com | 222382b | 2013-07-10 22:33:10 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | void reportPdfRenderStats(); |
| 43 | |
edisonn@google.com | 147adb1 | 2013-07-24 15:56:19 +0000 | [diff] [blame^] | 44 | bool SkPDFNativeRenderToBitmap(SkStream* stream, |
| 45 | SkBitmap* output, |
| 46 | int page = 0, |
| 47 | SkPdfContent content = kAll_SkPdfContent, |
| 48 | double dpi = 72.0); |
| 49 | |
edisonn@google.com | 15b1118 | 2013-07-11 14:43:15 +0000 | [diff] [blame] | 50 | #endif // SkPdfRenderer_DEFINED |