blob: 628265e53e103d9a485fd4d5c6dc76fc01c960a8 [file] [log] [blame]
joshualitt962cc982015-06-30 07:43:14 -07001/*
2 * Copyright 2015 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
9#include "VisualSKPBench.h"
10
cdaltone6d20242015-10-26 13:45:29 -070011#if SK_SUPPORT_GPU
12#include "GrContext.h"
13#endif
14
joshualitt962cc982015-06-30 07:43:14 -070015VisualSKPBench::VisualSKPBench(const char* name, const SkPicture* pic)
16 : fPic(SkRef(pic))
17 , fName(name) {
18 fUniqueName.printf("%s", name);
19}
20
21const char* VisualSKPBench::onGetName() {
22 return fName.c_str();
23}
24
25const char* VisualSKPBench::onGetUniqueName() {
26 return fUniqueName.c_str();
27}
28
29bool VisualSKPBench::isSuitableFor(Backend backend) {
30 return backend != kNonRendering_Backend;
31}
32
mtkleina1ebeb22015-10-01 09:43:39 -070033void VisualSKPBench::onDraw(int loops, SkCanvas* canvas) {
joshualitt962cc982015-06-30 07:43:14 -070034 for (int i = 0; i < loops; i++) {
35 canvas->drawPicture(fPic);
cdaltone6d20242015-10-26 13:45:29 -070036#if SK_SUPPORT_GPU
37 // Ensure the GrContext doesn't batch across draw loops.
38 if (GrContext* context = canvas->getGrContext()) {
39 context->flush();
40 }
41#endif
joshualitt962cc982015-06-30 07:43:14 -070042 }
43}