2b5989005c
Adds a "viewer" option to the build system that brings in tooling code and sample code. Adds a very simple "MakeSlide" binding that knows how to create the WavyPathText sample slide. Adds viewer.html with code to animate viewer slides. This can hopefully be the starting point for future work on bringing viewer to CanvasKit. Change-Id: Ia26e08726384b40b3f544fe8254f430dc9db08db Reviewed-on: https://skia-review.googlesource.com/c/skia/+/278892 Reviewed-by: Kevin Lubick <kjlubick@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
31 lines
885 B
C++
31 lines
885 B
C++
/*
|
|
* Copyright 2020 Google LLC
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include <emscripten.h>
|
|
#include <emscripten/bind.h>
|
|
#include "tools/viewer/SampleSlide.h"
|
|
#include <string>
|
|
|
|
using namespace emscripten;
|
|
|
|
EMSCRIPTEN_BINDINGS(Viewer) {
|
|
function("MakeSlide", optional_override([](std::string name)->sk_sp<Slide> {
|
|
if (name == "WavyPathText") {
|
|
extern Sample* MakeWavyPathTextSample();
|
|
return sk_make_sp<SampleSlide>(MakeWavyPathTextSample);
|
|
}
|
|
return nullptr;
|
|
}));
|
|
class_<Slide>("Slide")
|
|
.smart_ptr<sk_sp<Slide>>("sk_sp<Slide>")
|
|
.function("load", &Slide::load)
|
|
.function("animate", &Slide::animate)
|
|
.function("draw", optional_override([](Slide& self, SkCanvas& canvas) {
|
|
self.draw(&canvas);
|
|
}));
|
|
}
|