blob: 9d822d9a2516180982ac746743878cdf13a448ca [file] [log] [blame]
mtklein92007582014-08-01 07:46:52 -07001/*
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
10SKPBench::SKPBench(const char* name, const SkPicture* pic, const SkIRect& clip, SkScalar scale)
11 : fPic(SkRef(pic))
12 , fClip(clip)
mtklein96289052014-09-10 12:05:59 -070013 , fScale(scale)
14 , fName(name) {
15 fUniqueName.printf("%s_%.2g", name, scale); // Scale makes this unqiue for skiaperf.com traces.
mtklein92007582014-08-01 07:46:52 -070016}
17
18const char* SKPBench::onGetName() {
19 return fName.c_str();
20}
21
mtklein96289052014-09-10 12:05:59 -070022const char* SKPBench::onGetUniqueName() {
23 return fUniqueName.c_str();
24}
25
mtklein92007582014-08-01 07:46:52 -070026bool SKPBench::isSuitableFor(Backend backend) {
27 return backend != kNonRendering_Backend;
28}
29
30SkIPoint SKPBench::onGetSize() {
31 return SkIPoint::Make(fClip.width(), fClip.height());
32}
33
34void SKPBench::onDraw(const int loops, SkCanvas* canvas) {
35 canvas->save();
36 canvas->scale(fScale, fScale);
37 for (int i = 0; i < loops; i++) {
robertphillipsc5ba71d2014-09-04 08:42:50 -070038 fPic->playback(canvas);
mtklein92007582014-08-01 07:46:52 -070039 canvas->flush();
40 }
41 canvas->restore();
42}