| 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 | 9 |
| 10 SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip,
SkScalar scale) | 10 SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip,
SkScalar scale) |
| 11 : fPic(SkRef(pic)) | 11 : fPic(SkRef(pic)) |
| 12 , fClip(clip) | 12 , fClip(clip) |
| 13 , fScale(scale) { | 13 , fScale(scale) |
| 14 fName.printf("%s_%.2g", name, scale); | 14 , fName(name) { |
| 15 fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for
skiaperf.com traces. |
| 15 } | 16 } |
| 16 | 17 |
| 17 const char* SKPBench::onGetName() { | 18 const char* SKPBench::onGetName() { |
| 18 return fName.c_str(); | 19 return fName.c_str(); |
| 19 } | 20 } |
| 20 | 21 |
| 22 const char* SKPBench::onGetUniqueName() { |
| 23 return fUniqueName.c_str(); |
| 24 } |
| 25 |
| 21 bool SKPBench::isSuitableFor(Backend backend) { | 26 bool SKPBench::isSuitableFor(Backend backend) { |
| 22 return backend != kNonRendering_Backend; | 27 return backend != kNonRendering_Backend; |
| 23 } | 28 } |
| 24 | 29 |
| 25 SkIPoint SKPBench::onGetSize() { | 30 SkIPoint SKPBench::onGetSize() { |
| 26 return SkIPoint::Make(fClip.width(), fClip.height()); | 31 return SkIPoint::Make(fClip.width(), fClip.height()); |
| 27 } | 32 } |
| 28 | 33 |
| 29 void SKPBench::onDraw(const int loops, SkCanvas* canvas) { | 34 void SKPBench::onDraw(const int loops, SkCanvas* canvas) { |
| 30 canvas->save(); | 35 canvas->save(); |
| 31 canvas->scale(fScale, fScale); | 36 canvas->scale(fScale, fScale); |
| 32 for (int i = 0; i < loops; i++) { | 37 for (int i = 0; i < loops; i++) { |
| 33 fPic->playback(canvas); | 38 fPic->playback(canvas); |
| 34 canvas->flush(); | 39 canvas->flush(); |
| 35 } | 40 } |
| 36 canvas->restore(); | 41 canvas->restore(); |
| 37 } | 42 } |
| OLD | NEW |