blob: cd7d4b00e1c9a316158c20b3517f8666ee814110 [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)
13 , fScale(scale) {
14 fName.printf("%s_%.2g", name, scale);
15}
16
17const char* SKPBench::onGetName() {
18 return fName.c_str();
19}
20
21bool SKPBench::isSuitableFor(Backend backend) {
22 return backend != kNonRendering_Backend;
23}
24
25SkIPoint SKPBench::onGetSize() {
26 return SkIPoint::Make(fClip.width(), fClip.height());
27}
28
29void SKPBench::onDraw(const int loops, SkCanvas* canvas) {
30 canvas->save();
31 canvas->scale(fScale, fScale);
32 for (int i = 0; i < loops; i++) {
33 fPic->draw(canvas);
34 canvas->flush();
35 }
36 canvas->restore();
37}