Debian Codegraph @

tools/viewer/GMSlide.cpp

raw
1 /*
2 * Copyright 2016 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 "tools/viewer/GMSlide.h"
9
10 #include "include/core/SkString.h"
11 #include "include/core/SkSurfaceProps.h"
12
13 #include <memory>
14 #include <utility>
15
16 class SkCanvas;
17 class SkMetaData;
18
19 GMSlide::GMSlide(std::unique_ptr<skiagm::GM> gm) : fGM(std::move(gm)) {
20 fGM->setMode(skiagm::GM::kSample_Mode);
21
22 fName.printf("GM_%s", fGM->getName().c_str());
23 }
24
25 GMSlide::~GMSlide() = default;
26
27 void GMSlide::gpuTeardown() {
28 fGM->gpuTeardown();
29 }
30
31 void GMSlide::setSurfaceProps(SkSurfaceProps* props) {
32 fGM->modifySurfaceProps(props);
33 }
34
35 void GMSlide::draw(SkCanvas* canvas) {
36 SkString msg;
37
38 auto result = fGM->gpuSetup(canvas, &msg);
39 if (result != skiagm::GM::DrawResult::kOk) {
40 return;
41 }
42
43 fGM->draw(canvas, &msg);
44 }
45
46 bool GMSlide::animate(double nanos) { return fGM->animate(nanos); }
47
48 bool GMSlide::onChar(SkUnichar c) { return fGM->onChar(c); }
49
50 bool GMSlide::onGetControls(SkMetaData* controls) {
51 return fGM->getControls(controls);
52 }
53
54 void GMSlide::onSetControls(const SkMetaData& controls) {
55 fGM->setControls(controls);
56 }
57