aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/VisualBench/VisualSKPBench.cpp
blob: 628265e53e103d9a485fd4d5c6dc76fc01c960a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Copyright 2015 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 *
 */

#include "VisualSKPBench.h"

#if SK_SUPPORT_GPU
#include "GrContext.h"
#endif

VisualSKPBench::VisualSKPBench(const char* name, const SkPicture* pic)
    : fPic(SkRef(pic))
    , fName(name) {
    fUniqueName.printf("%s", name);
}

const char* VisualSKPBench::onGetName() {
    return fName.c_str();
}

const char* VisualSKPBench::onGetUniqueName() {
    return fUniqueName.c_str();
}

bool VisualSKPBench::isSuitableFor(Backend backend) {
    return backend != kNonRendering_Backend;
}

void VisualSKPBench::onDraw(int loops, SkCanvas* canvas) {
    for (int i = 0; i < loops; i++) {
        canvas->drawPicture(fPic);
#if SK_SUPPORT_GPU
        // Ensure the GrContext doesn't batch across draw loops.
        if (GrContext* context = canvas->getGrContext()) {
            context->flush();
        }
#endif
    }
}