2019-12-18 16:23:12 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2019 Google LLC
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkSLSlide_DEFINED
|
|
|
|
#define SkSLSlide_DEFINED
|
|
|
|
|
|
|
|
#include "tools/viewer/Slide.h"
|
|
|
|
|
2020-01-02 16:55:24 +00:00
|
|
|
#include "include/effects/SkRuntimeEffect.h"
|
2020-03-06 20:23:54 +00:00
|
|
|
#include "include/gpu/GrContextOptions.h"
|
2019-12-18 16:23:12 +00:00
|
|
|
|
|
|
|
class SkSLSlide : public Slide {
|
|
|
|
public:
|
|
|
|
SkSLSlide();
|
|
|
|
|
|
|
|
// TODO: We need a way for primarily interactive slides to always be as large as the window
|
|
|
|
SkISize getDimensions() const override { return SkISize::MakeEmpty(); }
|
|
|
|
|
|
|
|
void draw(SkCanvas* canvas) override;
|
|
|
|
|
2019-12-18 20:44:27 +00:00
|
|
|
void load(SkScalar winWidth, SkScalar winHeight) override;
|
|
|
|
void unload() override;
|
2019-12-18 16:23:12 +00:00
|
|
|
|
|
|
|
private:
|
2020-03-06 20:23:54 +00:00
|
|
|
bool rebuild(GrContextOptions::ShaderErrorHandler*);
|
2019-12-18 20:44:27 +00:00
|
|
|
|
2019-12-18 16:23:12 +00:00
|
|
|
SkString fSkSL;
|
2020-03-06 20:23:54 +00:00
|
|
|
bool fCodeIsDirty;
|
2019-12-18 16:23:12 +00:00
|
|
|
sk_sp<SkRuntimeEffect> fEffect;
|
|
|
|
SkAutoTMalloc<char> fInputs;
|
2019-12-18 20:44:27 +00:00
|
|
|
SkTArray<sk_sp<SkShader>> fChildren;
|
|
|
|
|
|
|
|
// Named shaders that can be selected as inputs
|
|
|
|
SkTArray<std::pair<const char*, sk_sp<SkShader>>> fShaders;
|
2019-12-18 16:23:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|