1 /* 2 * Copyright 2019 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 #ifndef SkSLSlide_DEFINED 9 #define SkSLSlide_DEFINED 10 11 #include "tools/viewer/Slide.h" 12 13 #include "include/effects/SkRuntimeEffect.h" 14 15 class SkSLSlide : public Slide { 16 public: 17 SkSLSlide(); 18 19 // TODO: We need a way for primarily interactive slides to always be as large as the window getDimensions()20 SkISize getDimensions() const override { return SkISize::MakeEmpty(); } 21 22 void draw(SkCanvas* canvas) override; 23 24 void load(SkScalar winWidth, SkScalar winHeight) override; 25 void unload() override; 26 27 private: 28 bool rebuild(); 29 30 SkString fSkSL; 31 sk_sp<SkRuntimeEffect> fEffect; 32 SkAutoTMalloc<char> fInputs; 33 SkTArray<sk_sp<SkShader>> fChildren; 34 35 // Named shaders that can be selected as inputs 36 SkTArray<std::pair<const char*, sk_sp<SkShader>>> fShaders; 37 }; 38 39 #endif 40