blob: 8a1a12e4e295987aaf02999b91435c3169c0ce7e [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_LIB_UI_PAINTING_FRAGMENT_SHADER_H_
#define FLUTTER_LIB_UI_PAINTING_FRAGMENT_SHADER_H_
#include "flutter/lib/ui/dart_wrapper.h"
#include "flutter/lib/ui/painting/image.h"
#include "flutter/lib/ui/painting/image_shader.h"
#include "flutter/lib/ui/painting/shader.h"
#include "third_party/skia/include/core/SkShader.h"
#include "third_party/skia/include/effects/SkRuntimeEffect.h"
#include "third_party/tonic/dart_library_natives.h"
#include "third_party/tonic/typed_data/typed_list.h"
#include <string>
#include <vector>
namespace tonic {
class DartLibraryNatives;
} // namespace tonic
namespace flutter {
class FragmentShader : public Shader {
DEFINE_WRAPPERTYPEINFO();
FML_FRIEND_MAKE_REF_COUNTED(FragmentShader);
public:
~FragmentShader() override;
static fml::RefPtr<FragmentShader> Create();
sk_sp<SkShader> shader(SkSamplingOptions) override;
void init(std::string sksl, bool debugPrintSksl);
void update(const tonic::Float32List& uniforms);
static void RegisterNatives(tonic::DartLibraryNatives* natives);
private:
FragmentShader();
void setShader();
// Since the shader source cannot be updated, the effect can be
// created once and re-used.
sk_sp<SkRuntimeEffect> runtime_effect_;
// A new shader is created every time update is called.
sk_sp<SkShader> shader_;
};
} // namespace flutter
#endif // FLUTTER_LIB_UI_PAINTING_FRAGMENT_SHADER_H_