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

Side by Side Diff: tools/render_pictures_main.cpp

Issue 466733004: Update tools for use of picture stats in GPU optimization decision (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « tools/bench_pictures_main.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 2012 Google Inc. 2 * Copyright 2012 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 "LazyDecodeBitmap.h" 8 #include "LazyDecodeBitmap.h"
9 #include "CopyTilesRenderer.h" 9 #include "CopyTilesRenderer.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } else if (FLAGS_writeEncodedImages) { 165 } else if (FLAGS_writeEncodedImages) {
166 SkASSERT(!FLAGS_writePath.isEmpty()); 166 SkASSERT(!FLAGS_writePath.isEmpty());
167 reset_image_file_base_name(inputFilename); 167 reset_image_file_base_name(inputFilename);
168 proc = &write_image_to_file; 168 proc = &write_image_to_file;
169 } else { 169 } else {
170 proc = &SkImageDecoder::DecodeMemory; 170 proc = &SkImageDecoder::DecodeMemory;
171 } 171 }
172 172
173 SkDebugf("deserializing... %s\n", inputPath.c_str()); 173 SkDebugf("deserializing... %s\n", inputPath.c_str());
174 174
175 SkPicture* picture = SkPicture::CreateFromStream(&inputStream, proc); 175 SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, pr oc));
176 176
177 if (NULL == picture) { 177 if (NULL == picture) {
178 SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str()); 178 SkDebugf("Could not read an SkPicture from %s\n", inputPath.c_str());
179 return false; 179 return false;
180 } 180 }
181 181
182 if (FLAGS_preprocess) {
183 // Because the GPU preprocessing step relies on the in-memory picture
184 // statistics we need to rerecord the picture here
185 SkPictureRecorder recorder;
186 picture->draw(recorder.beginRecording(picture->width(), picture->height( ), NULL, 0));
187 picture.reset(recorder.endRecording());
188 }
189
182 while (FLAGS_bench_record) { 190 while (FLAGS_bench_record) {
183 SkPictureRecorder recorder; 191 SkPictureRecorder recorder;
184 picture->draw(recorder.beginRecording(picture->width(), picture->height( ), NULL, 0)); 192 picture->draw(recorder.beginRecording(picture->width(), picture->height( ), NULL, 0));
185 SkAutoTUnref<SkPicture> other(recorder.endRecording()); 193 SkAutoTUnref<SkPicture> other(recorder.endRecording());
186 } 194 }
187 195
188 SkDebugf("drawing... [%i %i] %s\n", picture->width(), picture->height(), 196 SkDebugf("drawing... [%i %i] %s\n", picture->width(), picture->height(),
189 inputPath.c_str()); 197 inputPath.c_str());
190 198
191 renderer.init(picture, &writePathString, &mismatchPathString, &inputFilename , 199 renderer.init(picture, &writePathString, &mismatchPathString, &inputFilename ,
192 FLAGS_writeChecksumBasedFilenames); 200 FLAGS_writeChecksumBasedFilenames);
193 201
194 if (FLAGS_preprocess) { 202 if (FLAGS_preprocess) {
195 if (NULL != renderer.getCanvas()) { 203 if (NULL != renderer.getCanvas()) {
196 renderer.getCanvas()->EXPERIMENTAL_optimize(renderer.getPicture()); 204 renderer.getCanvas()->EXPERIMENTAL_optimize(renderer.getPicture());
197 } 205 }
198 } 206 }
199 207
200 renderer.setup(); 208 renderer.setup();
201 renderer.enableWrites(); 209 renderer.enableWrites();
202 210
203 bool success = renderer.render(out); 211 bool success = renderer.render(out);
204 if (!success) { 212 if (!success) {
205 SkDebugf("Failed to render %s\n", inputFilename.c_str()); 213 SkDebugf("Failed to render %s\n", inputFilename.c_str());
206 } 214 }
207 215
208 renderer.end(); 216 renderer.end();
209 217
210 SkDELETE(picture);
211 return success; 218 return success;
212 } 219 }
213 220
214 static inline int getByte(uint32_t value, int index) { 221 static inline int getByte(uint32_t value, int index) {
215 SkASSERT(0 <= index && index < 4); 222 SkASSERT(0 <= index && index < 4);
216 return (value >> (index * 8)) & 0xFF; 223 return (value >> (index * 8)) & 0xFF;
217 } 224 }
218 225
219 static int MaxByteDiff(uint32_t v1, uint32_t v2) { 226 static int MaxByteDiff(uint32_t v1, uint32_t v2) {
220 return SkMax32(SkMax32(abs(getByte(v1, 0) - getByte(v2, 0)), abs(getByte(v1, 1) - getByte(v2, 1))), 227 return SkMax32(SkMax32(abs(getByte(v1, 0) - getByte(v2, 0)), abs(getByte(v1, 1) - getByte(v2, 1))),
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]); 489 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]);
483 } 490 }
484 return 0; 491 return 0;
485 } 492 }
486 493
487 #if !defined SK_BUILD_FOR_IOS 494 #if !defined SK_BUILD_FOR_IOS
488 int main(int argc, char * const argv[]) { 495 int main(int argc, char * const argv[]) {
489 return tool_main(argc, (char**) argv); 496 return tool_main(argc, (char**) argv);
490 } 497 }
491 #endif 498 #endif
OLDNEW
« no previous file with comments | « tools/bench_pictures_main.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698