Index: experimental/PdfViewer/inc/SkPdfRenderer.h |
diff --git a/experimental/PdfViewer/SkPdfRenderer.h b/experimental/PdfViewer/inc/SkPdfRenderer.h |
similarity index 79% |
rename from experimental/PdfViewer/SkPdfRenderer.h |
rename to experimental/PdfViewer/inc/SkPdfRenderer.h |
index 51b564973ec9a023e60a48abee610370bac05a84..c978a739eca353b824712d5ab0c3df6b4f4c9f9f 100644 |
--- a/experimental/PdfViewer/SkPdfRenderer.h |
+++ b/experimental/PdfViewer/inc/SkPdfRenderer.h |
@@ -9,17 +9,16 @@ |
#ifndef SkPdfRenderer_DEFINED |
#define SkPdfRenderer_DEFINED |
-// TODO(edisonn): remove this dependency, and load only from a stream! |
-#include "SkString.h" |
+#include "SkTypes.h" |
class SkBitmap; |
class SkCanvas; |
class SkPdfNativeDoc; |
struct SkRect; |
class SkStream; |
-class SkString; |
// What kind of content to render. |
+// FIXME: Currently unused. |
enum SkPdfContent { |
kNoForms_SkPdfContent, |
kAll_SkPdfContent, |
@@ -30,26 +29,20 @@ enum SkPdfContent { |
* The SkPdfRenderer class is used to render a PDF into canvas. |
* |
*/ |
-class SkPdfRenderer { |
+class SkPdfRenderer : public SkNoncopyable { |
public: |
- SkPdfRenderer() : fPdfDoc(NULL) {} |
- virtual ~SkPdfRenderer() {unload();} |
- |
- // Render a specific page into the canvas, in a specific rectangle. |
- bool renderPage(int page, SkCanvas* canvas, const SkRect& dst) const; |
- |
- // TODO(edisonn): deprecated, should be removed! |
- bool load(const SkString inputFileName); |
- |
+ // Create a new renderer from a stream. |
// TODO(edisonn): replace it with a SkSmartStream which would know to to efficiently |
// deal with a HTTP stream. |
- bool load(SkStream* stream); |
+ // FIXME: Untested. |
+ static SkPdfRenderer* CreateFromStream(SkStream*); |
+ // Create a new renderer from a file. |
+ static SkPdfRenderer* CreateFromFile(const char* filename); |
- // Unloads the pdf document. |
- void unload(); |
+ ~SkPdfRenderer(); |
- // Returns true if we succesfully loaded a document. |
- bool loaded() const {return fPdfDoc != NULL && pages() > 0;} |
+ // Render a specific page into the canvas, in a specific rectangle. |
+ bool renderPage(int page, SkCanvas* canvas, const SkRect& dst) const; |
// Returns the number of pages in the loaded pdf. |
int pages() const; |
@@ -62,6 +55,8 @@ public: |
size_t bytesUsed() const; |
private: |
+ // Takes ownership of SkPdfNativeDoc. |
+ SkPdfRenderer(SkPdfNativeDoc*); |
SkPdfNativeDoc* fPdfDoc; |
}; |