Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Unified Diff: experimental/PdfViewer/inc/SkPdfRenderer.h

Issue 59493011: Pdfviewer refactoring. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Move include/ to inc/ Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/PdfViewer/SkPdfRenderer.cpp ('k') | experimental/PdfViewer/pdf_viewer_main.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
};
« no previous file with comments | « experimental/PdfViewer/SkPdfRenderer.cpp ('k') | experimental/PdfViewer/pdf_viewer_main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698