| OLD | NEW |
| (Empty) |
| 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 | |
| 9 #ifndef SkPdfRenderer_DEFINED | |
| 10 #define SkPdfRenderer_DEFINED | |
| 11 | |
| 12 #include "SkTypes.h" | |
| 13 | |
| 14 class SkBitmap; | |
| 15 class SkCanvas; | |
| 16 class SkPdfNativeDoc; | |
| 17 struct SkRect; | |
| 18 class SkStream; | |
| 19 | |
| 20 // What kind of content to render. | |
| 21 // FIXME: Currently unused. | |
| 22 enum SkPdfContent { | |
| 23 kNoForms_SkPdfContent, | |
| 24 kAll_SkPdfContent, | |
| 25 }; | |
| 26 | |
| 27 /** \class SkPdfRenderer | |
| 28 * | |
| 29 * The SkPdfRenderer class is used to render a PDF into canvas. | |
| 30 * | |
| 31 */ | |
| 32 class SkPdfRenderer : SkNoncopyable { | |
| 33 public: | |
| 34 // Create a new renderer from a stream. | |
| 35 // TODO(edisonn): replace it with a SkSmartStream which would know to to eff
iciently | |
| 36 // deal with a HTTP stream. | |
| 37 // FIXME: Untested. | |
| 38 // Does not affect ownership of SkStream. | |
| 39 static SkPdfRenderer* CreateFromStream(SkStream*); | |
| 40 // Create a new renderer from a file. | |
| 41 static SkPdfRenderer* CreateFromFile(const char* filename); | |
| 42 | |
| 43 ~SkPdfRenderer(); | |
| 44 | |
| 45 // Render a specific page into the canvas, in a specific rectangle. | |
| 46 bool renderPage(int page, SkCanvas* canvas, const SkRect& dst) const; | |
| 47 | |
| 48 // Returns the number of pages in the loaded pdf. | |
| 49 int pages() const; | |
| 50 | |
| 51 // Returns the MediaBox of a page. Can be used by client to crate a canvas. | |
| 52 SkRect MediaBox(int page) const; | |
| 53 | |
| 54 // TODO(edisonn): for testing only, probably it should be removed, unless so
me client wants to | |
| 55 // let users know how much memory the PDF needs. | |
| 56 size_t bytesUsed() const; | |
| 57 | |
| 58 private: | |
| 59 // Takes ownership of SkPdfNativeDoc. | |
| 60 SkPdfRenderer(SkPdfNativeDoc*); | |
| 61 SkPdfNativeDoc* fPdfDoc; | |
| 62 }; | |
| 63 | |
| 64 // For testing only, reports stats about rendering, like how many operations fai
led, or are NYI, ... | |
| 65 void reportPdfRenderStats(); | |
| 66 | |
| 67 // Renders a page of a pdf in a bitmap. | |
| 68 // Does not affect ownership of stream. | |
| 69 bool SkPDFNativeRenderToBitmap(SkStream* stream, | |
| 70 SkBitmap* output, | |
| 71 int page = 0, | |
| 72 SkPdfContent content = kAll_SkPdfContent, | |
| 73 double dpi = 72.0); | |
| 74 | |
| 75 // TODO(edisonn): add options to render forms, checkboxes, ... | |
| 76 // TODO(edisonn): Add API for Forms viewing and editing | |
| 77 // e.g. SkBitmap getPage(int page); | |
| 78 // int formsCount(); | |
| 79 // SkForm getForm(int formID); // SkForm(SkRect, .. other data) | |
| 80 // TODO (edisonn): Add intend when loading pdf, for example: for viewing, for pa
rsing content, ... | |
| 81 | |
| 82 #endif // SkPdfRenderer_DEFINED | |
| OLD | NEW |