• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 * Copyright 2014 Google Inc.
9 *
10 * Use of this source code is governed by a BSD-style license that can be
11 * found in the LICENSE file.
12 */
13 
14 #include "include/core/SkCanvas.h"
15 #include "include/gpu/GrDirectContext.h"
16 #include "include/gpu/GrRecordingContext.h"
17 #include "tools/viewer/GMSlide.h"
18 
GMSlide(std::unique_ptr<skiagm::GM> gm)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());
23 }
24 
25 GMSlide::~GMSlide() = default;
26 
gpuTeardown()27 void GMSlide::gpuTeardown() {
28     fGM->gpuTeardown();
29 }
30 
draw(SkCanvas * canvas)31 void GMSlide::draw(SkCanvas* canvas) {
32     SkString msg;
33 
34     auto direct = GrAsDirectContext(canvas->recordingContext());
35     auto result = fGM->gpuSetup(direct, canvas, &msg);
36     if (result != skiagm::GM::DrawResult::kOk) {
37         return;
38     }
39 
40     fGM->draw(canvas, &msg);
41 }
42 
animate(double nanos)43 bool GMSlide::animate(double nanos) { return fGM->animate(nanos); }
44 
onChar(SkUnichar c)45 bool GMSlide::onChar(SkUnichar c) { return fGM->onChar(c); }
46 
onGetControls(SkMetaData * controls)47 bool GMSlide::onGetControls(SkMetaData* controls) {
48     return fGM->getControls(controls);
49 }
50 
onSetControls(const SkMetaData & controls)51 void GMSlide::onSetControls(const SkMetaData& controls) {
52     fGM->setControls(controls);
53 }
54 
55