skia2/tools/viewer/SkSLSlide.h
Brian Osman f847f3106c In SkSLSlide, directly use Viewer's shader error handler
With the CPU backend, there is no GrContext on the canvas, so we were
sending errors to the default handler (SkDebugf + assert), so editing
shaders was impossible. Now they fail gracefully (and produce a popup
window with the message).

Change-Id: I29bad24f201be59ba1cec45f446a433c01cf86dc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297461
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-06-18 19:24:02 +00:00

41 lines
949 B
C++

/*
* 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"
#include "include/effects/SkRuntimeEffect.h"
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;
void load(SkScalar winWidth, SkScalar winHeight) override;
void unload() override;
private:
bool rebuild();
SkString fSkSL;
bool fCodeIsDirty;
sk_sp<SkRuntimeEffect> fEffect;
SkAutoTMalloc<char> fInputs;
SkTArray<sk_sp<SkShader>> fChildren;
// Named shaders that can be selected as inputs
SkTArray<std::pair<const char*, sk_sp<SkShader>>> fShaders;
};
#endif