| 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 "SKPBench.h" | 8 #include "SKPBench.h" |
| 9 #include "SkCommandLineFlags.h" |
| 10 |
| 11 DECLARE_int32(benchTile); |
| 9 | 12 |
| 10 SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip,
SkScalar scale) | 13 SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip,
SkScalar scale) |
| 11 : fPic(SkRef(pic)) | 14 : fPic(SkRef(pic)) |
| 12 , fClip(clip) | 15 , fClip(clip) |
| 13 , fScale(scale) | 16 , fScale(scale) |
| 14 , fName(name) { | 17 , fName(name) { |
| 15 fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for
skiaperf.com traces. | 18 fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for
skiaperf.com traces. |
| 16 } | 19 } |
| 17 | 20 |
| 18 const char* SKPBench::onGetName() { | 21 const char* SKPBench::onGetName() { |
| 19 return fName.c_str(); | 22 return fName.c_str(); |
| 20 } | 23 } |
| 21 | 24 |
| 22 const char* SKPBench::onGetUniqueName() { | 25 const char* SKPBench::onGetUniqueName() { |
| 23 return fUniqueName.c_str(); | 26 return fUniqueName.c_str(); |
| 24 } | 27 } |
| 25 | 28 |
| 26 bool SKPBench::isSuitableFor(Backend backend) { | 29 bool SKPBench::isSuitableFor(Backend backend) { |
| 27 return backend != kNonRendering_Backend; | 30 return backend != kNonRendering_Backend; |
| 28 } | 31 } |
| 29 | 32 |
| 30 SkIPoint SKPBench::onGetSize() { | 33 SkIPoint SKPBench::onGetSize() { |
| 31 return SkIPoint::Make(fClip.width(), fClip.height()); | 34 return SkIPoint::Make(fClip.width(), fClip.height()); |
| 32 } | 35 } |
| 33 | 36 |
| 34 void SKPBench::onDraw(const int loops, SkCanvas* canvas) { | 37 void SKPBench::onDraw(const int loops, SkCanvas* canvas) { |
| 35 canvas->save(); | 38 SkIRect bounds; |
| 36 canvas->scale(fScale, fScale); | 39 SkAssertResult(canvas->getClipDeviceBounds(&bounds)); |
| 37 for (int i = 0; i < loops; i++) { | 40 |
| 38 fPic->playback(canvas); | 41 SkAutoCanvasRestore overall(canvas, true/*save now*/); |
| 39 canvas->flush(); | 42 canvas->scale(fScale, fScale); |
| 43 |
| 44 for (int i = 0; i < loops; i++) { |
| 45 for (int y = bounds.fTop; y < bounds.fBottom; y += FLAGS_benchTile) { |
| 46 for (int x = bounds.fLeft; x < bounds.fRight; x += FLAGS_benchTile)
{ |
| 47 SkAutoCanvasRestore perTile(canvas, true/*save now*/); |
| 48 canvas->clipRect(SkRect::Make( |
| 49 SkIRect::MakeXYWH(x, y, FLAGS_benchTile, FLAGS_bench
Tile))); |
| 50 fPic->playback(canvas); |
| 51 } |
| 40 } | 52 } |
| 41 canvas->restore(); | 53 canvas->flush(); |
| 54 } |
| 42 } | 55 } |
| OLD | NEW |