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 "flutter/fml/macros.h"
13 #include "fml/mapping.h"
15 
16 namespace impeller {
17 
18 class Context;
19 class ShaderFunction;
20 
21 class ShaderLibrary : public std::enable_shared_from_this<ShaderLibrary> {
22  public:
23  virtual ~ShaderLibrary();
24 
25  virtual bool IsValid() const = 0;
26 
27  virtual std::shared_ptr<const ShaderFunction> GetFunction(
28  std::string_view name,
29  ShaderStage stage) = 0;
30 
31  using RegistrationCallback = std::function<void(bool)>;
32  virtual void RegisterFunction(std::string name,
33  ShaderStage stage,
34  std::shared_ptr<fml::Mapping> code,
35  RegistrationCallback callback);
36 
37  virtual void UnregisterFunction(std::string name, ShaderStage stage) = 0;
38 
39  protected:
40  ShaderLibrary();
41 
42  private:
43  ShaderLibrary(const ShaderLibrary&) = delete;
44 
45  ShaderLibrary& operator=(const ShaderLibrary&) = delete;
46 };
47 
48 } // namespace impeller
49 
50 #endif // FLUTTER_IMPELLER_RENDERER_SHADER_LIBRARY_H_
impeller::ShaderLibrary::GetFunction
virtual std::shared_ptr< const ShaderFunction > GetFunction(std::string_view name, ShaderStage stage)=0
impeller::ShaderLibrary::ShaderLibrary
ShaderLibrary()
impeller::ShaderLibrary::RegistrationCallback
std::function< void(bool)> RegistrationCallback
Definition: shader_library.h:31
impeller::ShaderLibrary
Definition: shader_library.h:21
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
impeller::ShaderLibrary::RegisterFunction
virtual void RegisterFunction(std::string name, ShaderStage stage, std::shared_ptr< fml::Mapping > code, RegistrationCallback callback)
Definition: shader_library.cc:13
impeller::ShaderLibrary::IsValid
virtual bool IsValid() const =0
impeller::ShaderLibrary::~ShaderLibrary
virtual ~ShaderLibrary()
impeller::ShaderLibrary::UnregisterFunction
virtual void UnregisterFunction(std::string name, ShaderStage stage)=0
shader_types.h
impeller
Definition: aiks_context.cc:10