Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2014 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #include "SkCommandLineFlags.h" | |
| 9 #include "SkForceLinking.h" | |
| 10 #include "SkGraphics.h" | |
| 11 #include "SkOSFile.h" | |
| 12 #include "SkPicture.h" | |
| 13 #include "SkStream.h" | |
| 14 #include "SkString.h" | |
| 15 #include "SkTime.h" | |
| 16 | |
| 17 __SK_FORCE_IMAGE_DECODER_LINKING; | |
| 18 | |
| 19 // Just reading all the SKPs takes about 2 seconds for me, which is the same as about 100 loops of | |
| 20 // rerecording all the SKPs. So we default to --loops=900, which makes ~90% of our time spent in | |
| 21 // recording, and this should take ~20 seconds to run. | |
|
tomhudson
2014/01/13 11:55:27
How wildly different will this be on different pla
mtklein_C
2014/01/13 13:29:27
As wildly as CPUs and memory bandwidth vary. On m
| |
| 22 | |
| 23 DEFINE_string2(skps, r, "skps", "Directory containing SKPs to read and re-record ."); | |
| 24 DEFINE_int32(loops, 900, "Number of times to re-record each SKP."); | |
| 25 DEFINE_int32(flags, SkPicture::kUsePathBoundsForClip_RecordingFlag, "RecordingFl ags to use."); | |
| 26 DEFINE_bool(endRecording, true, "If false, don't time SkPicture::endRecording()" ); | |
|
tomhudson
2014/01/13 11:55:27
Why would you ever want to do that? endRecording()
mtklein_C
2014/01/13 13:29:27
Conceivably, we could move what's done there to an
| |
| 27 | |
| 28 int tool_main(int argc, char** argv); | |
|
tomhudson
2014/01/13 11:55:27
Looks like this is an iOS thing? I don't recall se
mtklein_C
2014/01/13 13:29:27
Yeah, all our tools do it. We have a little shell
| |
| 29 int tool_main(int argc, char** argv) { | |
| 30 SkCommandLineFlags::Parse(argc, argv); | |
| 31 SkAutoGraphics autoGraphics; | |
| 32 | |
| 33 SkOSFile::Iter it(FLAGS_skps[0], ".skp"); | |
| 34 SkString filename; | |
| 35 while (it.next(&filename)) { | |
| 36 const SkString path = SkOSPath::SkPathJoin(FLAGS_skps[0], filename.c_str ()); | |
| 37 | |
| 38 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path.c_str())); | |
| 39 if (!stream) { | |
| 40 SkDebugf("Could not read %s.\n", path.c_str()); | |
| 41 continue; | |
| 42 } | |
| 43 SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream)); | |
| 44 if (!src) { | |
| 45 SkDebugf("Could not read %s as an SkPicture.\n", path.c_str()); | |
| 46 continue; | |
| 47 } | |
| 48 | |
| 49 const SkMSec start = SkTime::GetMSecs(); | |
| 50 for (int i = 0; i < FLAGS_loops; i++) { | |
| 51 SkPicture dst; | |
| 52 src->draw(dst.beginRecording(src->width(), src->height(), FLAGS_flag s)); | |
| 53 if (FLAGS_endRecording) dst.endRecording(); | |
| 54 } | |
| 55 | |
| 56 const SkMSec elapsed = SkTime::GetMSecs() - start; | |
| 57 const double msPerLoop = elapsed / (double)FLAGS_loops; | |
| 58 printf("%4.2f\t%s\n", msPerLoop, filename.c_str()); | |
| 59 } | |
| 60 | |
| 61 return 0; | |
| 62 } | |
| 63 | |
| 64 #if !defined SK_BUILD_FOR_IOS | |
| 65 int main(int argc, char * const argv[]) { | |
| 66 return tool_main(argc, (char**) argv); | |
| 67 } | |
| 68 #endif | |
| OLD | NEW |