OLD | NEW |
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 28 matching lines...) Expand all Loading... |
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 SkPdfRenderer renderer; | 42 SkPdfRenderer renderer; |
43 SkString skpath; | 43 SkString skpath; |
44 skpath.append(path); | 44 skpath.append(path); |
45 renderer.load(skpath); | 45 renderer.load(skpath); |
46 if (renderer.loaded()) { | 46 if (renderer.loaded()) { |
47 pic = SkNEW(SkPicture); | 47 pic = SkNEW(SkPicture); |
48 SkCanvas* canvas = pic->beginRecording((int)renderer.MediaBox(0).wid
th(), (int)renderer.MediaBox(0).height()); | 48 SkCanvas* canvas = pic->beginRecording((int)renderer.MediaBox(0).wid
th(), (int)renderer.MediaBox(0).height()); |
49 renderer.renderPage(0, canvas); | 49 renderer.renderPage(0, canvas, renderer.MediaBox(0)); |
50 pic->endRecording(); | 50 pic->endRecording(); |
51 } | 51 } |
52 return pic; | 52 return pic; |
53 } | 53 } |
54 | 54 |
55 public: | 55 public: |
56 PdfFileViewer(const char name[] = NULL) : fFilename(name) { | 56 PdfFileViewer(const char name[] = NULL) : fFilename(name) { |
57 fPicture = NULL; | 57 fPicture = NULL; |
58 } | 58 } |
59 | 59 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 | 101 |
102 ////////////////////////////////////////////////////////////////////////////// | 102 ////////////////////////////////////////////////////////////////////////////// |
103 | 103 |
104 #if 0 | 104 #if 0 |
105 static SkView* MyFactory() { return new PdfFileViewer; } | 105 static SkView* MyFactory() { return new PdfFileViewer; } |
106 static SkViewRegister reg(MyFactory); | 106 static SkViewRegister reg(MyFactory); |
107 #endif | 107 #endif |
108 | 108 |
109 #endif // SAMPLE_PDF_FILE_VIEWER | 109 #endif // SAMPLE_PDF_FILE_VIEWER |
OLD | NEW |