| OLD | NEW |
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 return NULL; | 55 return NULL; |
| 56 } | 56 } |
| 57 | 57 |
| 58 static void bench_record(SkPicture* src, const char* name, SkBBHFactory* bbhFact
ory) { | 58 static void bench_record(SkPicture* src, const char* name, SkBBHFactory* bbhFact
ory) { |
| 59 const SkMSec start = SkTime::GetMSecs(); | 59 const SkMSec start = SkTime::GetMSecs(); |
| 60 const int width = src ? src->width() : FLAGS_nullSize; | 60 const int width = src ? src->width() : FLAGS_nullSize; |
| 61 const int height = src ? src->height() : FLAGS_nullSize; | 61 const int height = src ? src->height() : FLAGS_nullSize; |
| 62 | 62 |
| 63 for (int i = 0; i < FLAGS_loops; i++) { | 63 for (int i = 0; i < FLAGS_loops; i++) { |
| 64 if (FLAGS_skr) { | 64 if (FLAGS_skr) { |
| 65 using EXPERIMENTAL::SkRecording; | 65 EXPERIMENTAL::SkRecording recording(width, height); |
| 66 SkRecording* recording = SkRecording::Create(width, height); | |
| 67 if (NULL != src) { | 66 if (NULL != src) { |
| 68 src->draw(recording->canvas()); | 67 src->draw(recording.canvas()); |
| 69 } | 68 } |
| 70 SkDELETE(SkRecording::Delete(recording)); // delete the SkPlayback*
. | 69 // Release and delete the SkPlayback so that recording optimizes its
SkRecord. |
| 70 SkDELETE(recording.releasePlayback()); |
| 71 } else { | 71 } else { |
| 72 SkPictureRecorder recorder; | 72 SkPictureRecorder recorder; |
| 73 SkCanvas* canvas = recorder.beginRecording(width, height, bbhFactory
, FLAGS_flags); | 73 SkCanvas* canvas = recorder.beginRecording(width, height, bbhFactory
, FLAGS_flags); |
| 74 if (NULL != src) { | 74 if (NULL != src) { |
| 75 src->draw(canvas); | 75 src->draw(canvas); |
| 76 } | 76 } |
| 77 if (FLAGS_endRecording) { | 77 if (FLAGS_endRecording) { |
| 78 SkAutoTUnref<SkPicture> dst(recorder.endRecording()); | 78 SkAutoTUnref<SkPicture> dst(recorder.endRecording()); |
| 79 } | 79 } |
| 80 } | 80 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 bench_record(src, filename.c_str(), bbhFactory.get()); | 127 bench_record(src, filename.c_str(), bbhFactory.get()); |
| 128 } | 128 } |
| 129 return failed ? 1 : 0; | 129 return failed ? 1 : 0; |
| 130 } | 130 } |
| 131 | 131 |
| 132 #if !defined SK_BUILD_FOR_IOS | 132 #if !defined SK_BUILD_FOR_IOS |
| 133 int main(int argc, char * const argv[]) { | 133 int main(int argc, char * const argv[]) { |
| 134 return tool_main(argc, (char**) argv); | 134 return tool_main(argc, (char**) argv); |
| 135 } | 135 } |
| 136 #endif | 136 #endif |
| OLD | NEW |