blob: 66466ef5883f289ff7f8c92329953f10d0e5df9e [file] [log] [blame]
Chris Dalton2b598902020-03-25 10:50:35 -06001/*
2 * Copyright 2020 Google LLC
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#include <emscripten.h>
9#include <emscripten/bind.h>
Chris Dalton8ce842d2020-04-01 14:46:16 -060010#include "include/core/SkCanvas.h"
Chris Dalton2b598902020-03-25 10:50:35 -060011#include "tools/viewer/SampleSlide.h"
12#include <string>
13
14using namespace emscripten;
15
16EMSCRIPTEN_BINDINGS(Viewer) {
17 function("MakeSlide", optional_override([](std::string name)->sk_sp<Slide> {
18 if (name == "WavyPathText") {
19 extern Sample* MakeWavyPathTextSample();
20 return sk_make_sp<SampleSlide>(MakeWavyPathTextSample);
21 }
22 return nullptr;
23 }));
24 class_<Slide>("Slide")
25 .smart_ptr<sk_sp<Slide>>("sk_sp<Slide>")
26 .function("load", &Slide::load)
27 .function("animate", &Slide::animate)
28 .function("draw", optional_override([](Slide& self, SkCanvas& canvas) {
29 self.draw(&canvas);
30 }));
31}