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

Unified Diff: samplecode/SamplePdfFileViewer.cpp

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 | « gyp/pdfviewer_lib.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SamplePdfFileViewer.cpp
diff --git a/samplecode/SamplePdfFileViewer.cpp b/samplecode/SamplePdfFileViewer.cpp
index fc8b0f0acd5613b4d1f082f9c4e61e70bd56e170..55c7002fa8e4a4810f7f232b065e5e6559f59008 100644
--- a/samplecode/SamplePdfFileViewer.cpp
+++ b/samplecode/SamplePdfFileViewer.cpp
@@ -37,18 +37,16 @@ private:
SkPicture* fPicture; // TODO(edisonn): multiple pages, one page / picture, make it an array
static SkPicture* LoadPdf(const char path[]) {
- SkPicture* pic = NULL;
-
- SkPdfRenderer renderer;
- SkString skpath;
- skpath.append(path);
- renderer.load(skpath);
- if (renderer.loaded()) {
- pic = SkNEW(SkPicture);
- SkCanvas* canvas = pic->beginRecording((int)renderer.MediaBox(0).width(), (int)renderer.MediaBox(0).height());
- renderer.renderPage(0, canvas, renderer.MediaBox(0));
- pic->endRecording();
+ SkAutoTDelete<SkPdfRenderer> renderer(SkPdfRenderer::CreateFromFile(path));
+ if (NULL == renderer.get()) {
+ return NULL;
}
+
+ SkPicture* pic = SkNEW(SkPicture);
+ SkCanvas* canvas = pic->beginRecording((int) renderer->MediaBox(0).width(),
+ (int) renderer->MediaBox(0).height());
+ renderer->renderPage(0, canvas, renderer->MediaBox(0));
+ pic->endRecording();
return pic;
}
« no previous file with comments | « gyp/pdfviewer_lib.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698