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

Side by Side Diff: experimental/tools/multipage_pdf_profiler.cpp

Issue 769423002: work in progress (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « experimental/tools/gmtoskp.cpp ('k') | gm/smallimage.cpp » ('j') | 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 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "SkCanvas.h" 7 #include "SkCanvas.h"
8 #include "SkDocument.h" 8 #include "SkDocument.h"
9 #include "SkForceLinking.h" 9 #include "SkForceLinking.h"
10 #include "SkGraphics.h" 10 #include "SkGraphics.h"
11 #include "SkNullCanvas.h" 11 #include "SkNullCanvas.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkStream.h" 13 #include "SkStream.h"
14 #include "SkTemplates.h" 14 #include "SkTemplates.h"
15 #include "PageCachingDocument.h"
15 #include "ProcStats.h" 16 #include "ProcStats.h"
16 #include "flags/SkCommandLineFlags.h" 17 #include "flags/SkCommandLineFlags.h"
17 18
18 #ifdef SK_ENABLE_NEW_SKPDF_BACKEND
19 #include "skpdf.h"
20 #endif
21
22 DEFINE_string2(readPath, 19 DEFINE_string2(readPath,
23 r, 20 r,
24 "", 21 "",
25 "(Required) The path to a .skp Skia Picture file."); 22 "(Required) The path to a .skp Skia Picture file.");
26 DEFINE_string2(writePath, w, "", "If set, write PDF output to this file."); 23 DEFINE_string2(writePath, w, "", "If set, write PDF output to this file.");
27 DEFINE_bool(newPdf, false, "Use the new PDF backend."); 24 DEFINE_bool(cachePages, false, "Use a PageCachingDocument.");
28 DEFINE_bool(nullCanvas, true, "Render to a SkNullCanvas as a control."); 25 DEFINE_bool(nullCanvas, true, "Render to a SkNullCanvas as a control.");
29 26
30 __SK_FORCE_IMAGE_DECODER_LINKING; 27 __SK_FORCE_IMAGE_DECODER_LINKING;
31 28
32 namespace { 29 namespace {
33 class NullWStream : public SkWStream { 30 class NullWStream : public SkWStream {
34 public: 31 public:
35 NullWStream() : fBytesWritten(0) { 32 NullWStream() : fBytesWritten(0) {
36 } 33 }
37 virtual bool write(const void*, size_t size) SK_OVERRIDE { 34 virtual bool write(const void*, size_t size) SK_OVERRIDE {
38 fBytesWritten += size; 35 fBytesWritten += size;
39 return true; 36 return true;
40 } 37 }
41 virtual size_t bytesWritten() const SK_OVERRIDE { 38 virtual size_t bytesWritten() const SK_OVERRIDE {
42 return fBytesWritten; 39 return fBytesWritten;
43 } 40 }
44 size_t fBytesWritten; 41 size_t fBytesWritten;
45 }; 42 };
46 43
47 SkDocument* CreatePDFDocument(SkWStream* out) { 44 SkDocument* CreatePDFDocument(SkWStream* out) {
48 #ifdef SK_ENABLE_NEW_SKPDF_BACKEND 45 if (FLAGS_cachePages) {
49 if (FLAGS_newPdf) { 46 return CreatePageCachingDocument(out);
50 return skpdf::CreatePDFDocument(out); 47 } else {
48 return SkDocument::CreatePDF(out);
51 } 49 }
52 #endif
53 return SkDocument::CreatePDF(out);
54 } 50 }
55 } // namespace 51 } // namespace
56 52
57 int main(int argc, char** argv) { 53 int main(int argc, char** argv) {
58 SkCommandLineFlags::Parse(argc, argv); 54 SkCommandLineFlags::Parse(argc, argv);
59 if (FLAGS_readPath.isEmpty()) { 55 if (FLAGS_readPath.isEmpty()) {
60 SkDebugf("Error: missing requires --readPath option\n"); 56 SkDebugf("Error: missing requires --readPath option\n");
61 return 1; 57 return 1;
62 } 58 }
63 const char* path = FLAGS_readPath[0]; 59 const char* path = FLAGS_readPath[0];
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } else { 108 } else {
113 int w = SkTMin(kLetterWidth, width - (x * kLetterWidth)); 109 int w = SkTMin(kLetterWidth, width - (x * kLetterWidth));
114 int h = SkTMin(kLetterHeight, height - (y * kLetterHeight)); 110 int h = SkTMin(kLetterHeight, height - (y * kLetterHeight));
115 canvas = pdfDocument->beginPage(w, h); 111 canvas = pdfDocument->beginPage(w, h);
116 } 112 }
117 { 113 {
118 SkAutoCanvasRestore autoCanvasRestore(canvas, true); 114 SkAutoCanvasRestore autoCanvasRestore(canvas, true);
119 canvas->clipRect(letterRect); 115 canvas->clipRect(letterRect);
120 canvas->translate(SkIntToScalar(-kLetterWidth * x), 116 canvas->translate(SkIntToScalar(-kLetterWidth * x),
121 SkIntToScalar(-kLetterHeight * y)); 117 SkIntToScalar(-kLetterHeight * y));
122 canvas->drawPicture(picture); 118 picture->playback(canvas);
119 //canvas->drawPicture(picture);
123 } 120 }
124 canvas->flush(); 121 canvas->flush();
125 if (!FLAGS_nullCanvas) { 122 if (!FLAGS_nullCanvas) {
126 pdfDocument->endPage(); 123 pdfDocument->endPage();
127 } 124 }
128 } 125 }
129 } 126 }
130 if (!FLAGS_nullCanvas) { 127 if (!FLAGS_nullCanvas) {
131 pdfDocument->close(); 128 pdfDocument->close();
132 pdfDocument.reset(NULL); 129 pdfDocument.reset(NULL);
133 } 130 }
134 printf(SK_SIZE_T_SPECIFIER "\t%4d\n", 131 printf(SK_SIZE_T_SPECIFIER "\t%4d\n",
135 inputStream.getLength(), 132 inputStream.getLength(),
136 sk_tools::getMaxResidentSetSizeMB()); 133 sk_tools::getMaxResidentSetSizeMB());
137 return 0; 134 return 0;
138 } 135 }
OLDNEW
« no previous file with comments | « experimental/tools/gmtoskp.cpp ('k') | gm/smallimage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698