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)19GMSlide::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()27void GMSlide::gpuTeardown() { 28 fGM->gpuTeardown(); 29 } 30 draw(SkCanvas * canvas)31void 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)43bool GMSlide::animate(double nanos) { return fGM->animate(nanos); } 44 onChar(SkUnichar c)45bool GMSlide::onChar(SkUnichar c) { return fGM->onChar(c); } 46 onGetControls(SkMetaData * controls)47bool GMSlide::onGetControls(SkMetaData* controls) { 48 return fGM->getControls(controls); 49 } 50 onSetControls(const SkMetaData & controls)51void GMSlide::onSetControls(const SkMetaData& controls) { 52 fGM->setControls(controls); 53 } 54 55