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 result = fGM->gpuSetup(canvas, &msg); 35 if (result != skiagm::GM::DrawResult::kOk) { 36 return; 37 } 38 39 fGM->draw(canvas, &msg); 40 } 41 animate(double nanos)42bool GMSlide::animate(double nanos) { return fGM->animate(nanos); } 43 onChar(SkUnichar c)44bool GMSlide::onChar(SkUnichar c) { return fGM->onChar(c); } 45 onGetControls(SkMetaData * controls)46bool GMSlide::onGetControls(SkMetaData* controls) { 47 return fGM->getControls(controls); 48 } 49 onSetControls(const SkMetaData & controls)50void GMSlide::onSetControls(const SkMetaData& controls) { 51 fGM->setControls(controls); 52 } 53 54