Flutter Impeller
shader_library.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_IMPELLER_RENDERER_SHADER_LIBRARY_H_
6 #define FLUTTER_IMPELLER_RENDERER_SHADER_LIBRARY_H_
7 
8 #include <future>
9 #include <memory>
10 #include <string_view>
11 
12 #include "fml/mapping.h"
14 
15 namespace impeller {
16 
17 class Context;
18 class ShaderFunction;
19 
20 class ShaderLibrary : public std::enable_shared_from_this<ShaderLibrary> {
21  public:
22  virtual ~ShaderLibrary();
23 
24  virtual bool IsValid() const = 0;
25 
26  virtual std::shared_ptr<const ShaderFunction> GetFunction(
27  std::string_view name,
28  ShaderStage stage) = 0;
29 
30  using RegistrationCallback = std::function<void(bool)>;
31  virtual void RegisterFunction(std::string name,
32  ShaderStage stage,
33  std::shared_ptr<fml::Mapping> code,
34  RegistrationCallback callback);
35 
36  virtual void UnregisterFunction(std::string name, ShaderStage stage) = 0;
37 
38  protected:
40 
41  private:
42  ShaderLibrary(const ShaderLibrary&) = delete;
43 
44  ShaderLibrary& operator=(const ShaderLibrary&) = delete;
45 };
46 
47 } // namespace impeller
48 
49 #endif // FLUTTER_IMPELLER_RENDERER_SHADER_LIBRARY_H_
virtual void RegisterFunction(std::string name, ShaderStage stage, std::shared_ptr< fml::Mapping > code, RegistrationCallback callback)
virtual std::shared_ptr< const ShaderFunction > GetFunction(std::string_view name, ShaderStage stage)=0
virtual void UnregisterFunction(std::string name, ShaderStage stage)=0
virtual bool IsValid() const =0
std::function< void(bool)> RegistrationCallback