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