Flutter Impeller
shader_library_gles.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_BACKEND_GLES_SHADER_LIBRARY_GLES_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_SHADER_LIBRARY_GLES_H_
7 
8 #include <memory>
9 
10 #include "flutter/fml/mapping.h"
12 #include "impeller/base/thread.h"
15 
16 namespace impeller {
17 
18 class ShaderLibraryGLES final : public ShaderLibrary {
19  public:
20  // |ShaderLibrary|
21  ~ShaderLibraryGLES() override;
22 
23  // |ShaderLibrary|
24  bool IsValid() const override;
25 
26  private:
27  friend class ContextGLES;
28  const UniqueID library_id_;
29  mutable RWMutex functions_mutex_;
30  ShaderFunctionMap functions_ IPLR_GUARDED_BY(functions_mutex_);
31  bool is_valid_ = false;
32 
33  explicit ShaderLibraryGLES(
34  const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries);
35 
36  // |ShaderLibrary|
37  std::shared_ptr<const ShaderFunction> GetFunction(std::string_view name,
38  ShaderStage stage) override;
39 
40  // |ShaderLibrary|
41  void RegisterFunction(std::string name,
42  ShaderStage stage,
43  std::shared_ptr<fml::Mapping> code,
44  RegistrationCallback callback) override;
45 
46  // |ShaderLibrary|
47  void UnregisterFunction(std::string name, ShaderStage stage) override;
48 
49  ShaderLibraryGLES(const ShaderLibraryGLES&) = delete;
50 
51  ShaderLibraryGLES& operator=(const ShaderLibraryGLES&) = delete;
52 };
53 
54 } // namespace impeller
55 
56 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_SHADER_LIBRARY_GLES_H_
bool IsValid() const override
std::function< void(bool)> RegistrationCallback
std::unordered_map< ShaderKey, std::shared_ptr< const ShaderFunction >, ShaderKey::Hash, ShaderKey::Equal > ShaderFunctionMap
Definition: shader_key.h:43
#define IPLR_GUARDED_BY(x)
Definition: thread_safety.h:19