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

Side by Side Diff: samplecode/SamplePdfFileViewer.cpp

Issue 18507004: sample app: fix break in pdf viewer (podofo was replaced by native parser) (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gyp/SampleApp.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifdef SAMPLE_PDF_FILE_VIEWER 9 #ifdef SAMPLE_PDF_FILE_VIEWER
10 10
(...skipping 11 matching lines...) Expand all
22 #include "SkRandom.h" 22 #include "SkRandom.h"
23 #include "SkRegion.h" 23 #include "SkRegion.h"
24 #include "SkShader.h" 24 #include "SkShader.h"
25 #include "SkUtils.h" 25 #include "SkUtils.h"
26 #include "SkColorPriv.h" 26 #include "SkColorPriv.h"
27 #include "SkColorFilter.h" 27 #include "SkColorFilter.h"
28 #include "SkTime.h" 28 #include "SkTime.h"
29 #include "SkTypeface.h" 29 #include "SkTypeface.h"
30 #include "SkXfermode.h" 30 #include "SkXfermode.h"
31 31
32 #include "SkPodofoParsedPDF.h" 32 #include "SkPdfRenderer.h"
33 33
34 class PdfFileViewer : public SampleView { 34 class PdfFileViewer : public SampleView {
35 private: 35 private:
36 SkString fFilename; 36 SkString fFilename;
37 SkPicture* fPicture; // TODO(edisonn): multiple pages, one page / picture, make it an array 37 SkPicture* fPicture; // TODO(edisonn): multiple pages, one page / picture, make it an array
38 38
39 static SkPicture* LoadPdf(const char path[]) { 39 static SkPicture* LoadPdf(const char path[]) {
40 SkPicture* pic = NULL; 40 SkPicture* pic = NULL;
41 41
42 SkPodofoParsedPDF doc(path); 42 SkPdfRenderer renderer;
43 if (doc.pages()) { 43 SkString skpath;
44 skpath.append(path);
45 renderer.load(skpath);
46 if (renderer.loaded()) {
44 pic = SkNEW(SkPicture); 47 pic = SkNEW(SkPicture);
45 SkCanvas* canvas = pic->beginRecording((int)doc.width(0), (int)doc.h eight(0)); 48 SkCanvas* canvas = pic->beginRecording((int)renderer.MediaBox(0).wid th(), (int)renderer.MediaBox(0).height());
46 doc.drawPage(0, canvas); 49 renderer.renderPage(0, canvas);
47 pic->endRecording(); 50 pic->endRecording();
48 } 51 }
49 return pic; 52 return pic;
50 } 53 }
51 54
52 public: 55 public:
53 PdfFileViewer(const char name[] = NULL) : fFilename(name) { 56 PdfFileViewer(const char name[] = NULL) : fFilename(name) {
54 fPicture = NULL; 57 fPicture = NULL;
55 } 58 }
56 59
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 100 }
98 101
99 ////////////////////////////////////////////////////////////////////////////// 102 //////////////////////////////////////////////////////////////////////////////
100 103
101 #if 0 104 #if 0
102 static SkView* MyFactory() { return new PdfFileViewer; } 105 static SkView* MyFactory() { return new PdfFileViewer; }
103 static SkViewRegister reg(MyFactory); 106 static SkViewRegister reg(MyFactory);
104 #endif 107 #endif
105 108
106 #endif // SAMPLE_PDF_FILE_VIEWER 109 #endif // SAMPLE_PDF_FILE_VIEWER
OLDNEW
« no previous file with comments | « gyp/SampleApp.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698