2016-04-08 14:24:09 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkCanvas.h"
|
2020-07-01 18:45:24 +00:00
|
|
|
#include "include/gpu/GrDirectContext.h"
|
|
|
|
#include "include/gpu/GrRecordingContext.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/viewer/GMSlide.h"
|
2016-04-08 14:24:09 +00:00
|
|
|
|
2019-08-12 20:39:24 +00:00
|
|
|
GMSlide::GMSlide(std::unique_ptr<skiagm::GM> gm) : fGM(std::move(gm)) {
|
2020-06-25 17:26:22 +00:00
|
|
|
fGM->setMode(skiagm::GM::kSample_Mode);
|
|
|
|
|
2019-08-12 20:39:24 +00:00
|
|
|
fName.printf("GM_%s", fGM->getName());
|
2016-04-08 14:24:09 +00:00
|
|
|
}
|
|
|
|
|
2019-07-08 18:55:15 +00:00
|
|
|
GMSlide::~GMSlide() = default;
|
2016-04-08 14:24:09 +00:00
|
|
|
|
2020-06-26 14:10:49 +00:00
|
|
|
void GMSlide::gpuTeardown() {
|
|
|
|
fGM->gpuTeardown();
|
|
|
|
}
|
|
|
|
|
2016-04-08 14:24:09 +00:00
|
|
|
void GMSlide::draw(SkCanvas* canvas) {
|
2020-06-23 20:08:08 +00:00
|
|
|
SkString msg;
|
|
|
|
|
2020-07-07 14:27:55 +00:00
|
|
|
auto direct = GrAsDirectContext(canvas->recordingContext());
|
2020-07-01 18:45:24 +00:00
|
|
|
auto result = fGM->gpuSetup(direct, canvas, &msg);
|
2020-06-25 17:26:22 +00:00
|
|
|
if (result != skiagm::GM::DrawResult::kOk) {
|
|
|
|
return;
|
|
|
|
}
|
2020-06-23 20:08:08 +00:00
|
|
|
|
2020-06-25 17:26:22 +00:00
|
|
|
fGM->draw(canvas, &msg);
|
2016-04-08 14:24:09 +00:00
|
|
|
}
|
2016-04-08 19:51:45 +00:00
|
|
|
|
2019-07-11 20:32:53 +00:00
|
|
|
bool GMSlide::animate(double nanos) { return fGM->animate(nanos); }
|
2017-02-14 20:16:46 +00:00
|
|
|
|
2019-07-08 18:55:15 +00:00
|
|
|
bool GMSlide::onChar(SkUnichar c) { return fGM->onChar(c); }
|
2018-05-15 14:09:52 +00:00
|
|
|
|
|
|
|
bool GMSlide::onGetControls(SkMetaData* controls) {
|
|
|
|
return fGM->getControls(controls);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GMSlide::onSetControls(const SkMetaData& controls) {
|
|
|
|
fGM->setControls(controls);
|
|
|
|
}
|
|
|
|
|