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

Side by Side Diff: tools/bench_record.cpp

Issue 195793010: Add a means of extracting active operations from SkPicture (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Fix bug & add unit test Created 6 years, 9 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 | « tests/PictureTest.cpp ('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 * 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 7
8 #include "SkCommandLineFlags.h" 8 #include "SkCommandLineFlags.h"
9 #include "SkForceLinking.h" 9 #include "SkForceLinking.h"
10 #include "SkGraphics.h" 10 #include "SkGraphics.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 static void bench_record(SkPicture* src, const char* name, PictureFactory pictur eFactory) { 71 static void bench_record(SkPicture* src, const char* name, PictureFactory pictur eFactory) {
72 const SkMSec start = SkTime::GetMSecs(); 72 const SkMSec start = SkTime::GetMSecs();
73 const int width = src ? src->width() : FLAGS_nullSize; 73 const int width = src ? src->width() : FLAGS_nullSize;
74 const int height = src ? src->height() : FLAGS_nullSize; 74 const int height = src ? src->height() : FLAGS_nullSize;
75 75
76 for (int i = 0; i < FLAGS_loops; i++) { 76 for (int i = 0; i < FLAGS_loops; i++) {
77 int recordingFlags = FLAGS_flags; 77 int recordingFlags = FLAGS_flags;
78 SkAutoTUnref<SkPicture> dst(pictureFactory(width, height, &recordingFlag s)); 78 SkAutoTUnref<SkPicture> dst(pictureFactory(width, height, &recordingFlag s));
79 SkCanvas* canvas = dst->beginRecording(width, height, recordingFlags); 79 SkCanvas* canvas = dst->beginRecording(width, height, recordingFlags);
80 if (src) src->draw(canvas); 80 if (NULL != src) {
81 if (FLAGS_endRecording) dst->endRecording(); 81 src->draw(canvas);
82 }
83 if (FLAGS_endRecording) {
84 dst->endRecording();
85 }
82 } 86 }
83 87
84 const SkMSec elapsed = SkTime::GetMSecs() - start; 88 const SkMSec elapsed = SkTime::GetMSecs() - start;
85 const double msPerLoop = elapsed / (double)FLAGS_loops; 89 const double msPerLoop = elapsed / (double)FLAGS_loops;
86 printf("%.2g\t%s\n", msPerLoop, name); 90 printf("%.2g\t%s\n", msPerLoop, name);
87 } 91 }
88 92
89 int tool_main(int argc, char** argv); 93 int tool_main(int argc, char** argv);
90 int tool_main(int argc, char** argv) { 94 int tool_main(int argc, char** argv) {
91 SkCommandLineFlags::Parse(argc, argv); 95 SkCommandLineFlags::Parse(argc, argv);
92 SkAutoGraphics autoGraphics; 96 SkAutoGraphics autoGraphics;
93 97
94 PictureFactory pictureFactory = parse_FLAGS_bbh(); 98 PictureFactory pictureFactory = parse_FLAGS_bbh();
95 if (pictureFactory == NULL) { 99 if (pictureFactory == NULL) {
96 return 1; 100 return 1;
97 } 101 }
98 bench_record(NULL, "NULL", pictureFactory); 102 bench_record(NULL, "NULL", pictureFactory);
99 if (FLAGS_skps.isEmpty()) return 0; 103 if (FLAGS_skps.isEmpty()) {
104 return 0;
105 }
100 106
101 SkOSFile::Iter it(FLAGS_skps[0], ".skp"); 107 SkOSFile::Iter it(FLAGS_skps[0], ".skp");
102 SkString filename; 108 SkString filename;
103 bool failed = false; 109 bool failed = false;
104 while (it.next(&filename)) { 110 while (it.next(&filename)) {
105 const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str ()); 111 const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str ());
106 112
107 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str())); 113 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str()));
108 if (!stream) { 114 if (!stream) {
109 SkDebugf("Could not read %s.\n", path.c_str()); 115 SkDebugf("Could not read %s.\n", path.c_str());
110 failed = true; 116 failed = true;
111 continue; 117 continue;
112 } 118 }
113 SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream)); 119 SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream));
114 if (!src) { 120 if (!src) {
115 SkDebugf("Could not read %s as an SkPicture.\n", path.c_str()); 121 SkDebugf("Could not read %s as an SkPicture.\n", path.c_str());
116 failed = true; 122 failed = true;
117 continue; 123 continue;
118 } 124 }
119 bench_record(src, filename.c_str(), pictureFactory); 125 bench_record(src, filename.c_str(), pictureFactory);
120 } 126 }
121 return failed ? 1 : 0; 127 return failed ? 1 : 0;
122 } 128 }
123 129
124 #if !defined SK_BUILD_FOR_IOS 130 #if !defined SK_BUILD_FOR_IOS
125 int main(int argc, char * const argv[]) { 131 int main(int argc, char * const argv[]) {
126 return tool_main(argc, (char**) argv); 132 return tool_main(argc, (char**) argv);
127 } 133 }
128 #endif 134 #endif
OLDNEW
« no previous file with comments | « tests/PictureTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698