Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GMBench.cpp
Go to the documentation of this file.
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 "bench/GMBench.h"
9
12
13GMBench::GMBench(std::unique_ptr<skiagm::GM> gm) : fGM(std::move(gm)) {
14 fGM->setMode(skiagm::GM::kBench_Mode);
15
16 fName.printf("GM_%s", fGM->getName().c_str());
17}
18
19const char* GMBench::onGetName() {
20 return fName.c_str();
21}
22
26
28 SkString msg;
29 if (fGM->gpuSetup(canvas, &msg) != skiagm::DrawResult::kOk) {
30 fGpuSetupFailed = true;
31 }
32
33 fGM->onceBeforeDraw();
34}
35
37 fGM->gpuTeardown();
38
39 // The same GM will be reused with multiple GrContexts. Let the next GrContext start
40 // afresh.
41 fGpuSetupFailed = false;
42}
43
44void GMBench::onDraw(int loops, SkCanvas* canvas) {
45 if (fGpuSetupFailed) {
46 return;
47 }
48
49 fGM->drawBackground(canvas);
50 for (int i = 0; i < loops; ++i) {
51 fGM->drawContent(canvas);
52 }
53}
54
56 return fGM->getISize();
57}
const char * backend
void onPerCanvasPostDraw(SkCanvas *) override
Definition GMBench.cpp:36
SkISize onGetSize() override
Definition GMBench.cpp:55
GMBench(std::unique_ptr< skiagm::GM > gm)
Definition GMBench.cpp:13
void onDraw(int loops, SkCanvas *) override
Definition GMBench.cpp:44
const char * onGetName() override
Definition GMBench.cpp:19
void onPerCanvasPreDraw(SkCanvas *) override
Definition GMBench.cpp:27
bool isSuitableFor(Backend backend) override
Definition GMBench.cpp:23
void printf(const char format[],...) SK_PRINTF_LIKE(2
Definition SkString.cpp:534
const char * c_str() const
Definition SkString.h:133
@ kBench_Mode
Definition gm.h:121
Definition ref_ptr.h:256