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_
shader_library.h
impeller::ShaderLibraryGLES::IsValid
bool IsValid() const override
Definition: shader_library_gles.cc:87
shader_key.h
impeller::ShaderLibrary::RegistrationCallback
std::function< void(bool)> RegistrationCallback
Definition: shader_library.h:30
impeller::ShaderLibrary
Definition: shader_library.h:20
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
impeller::ShaderLibraryGLES::~ShaderLibraryGLES
~ShaderLibraryGLES() override
impeller::ContextGLES
Definition: context_gles.h:22
impeller::ShaderFunctionMap
std::unordered_map< ShaderKey, std::shared_ptr< const ShaderFunction >, ShaderKey::Hash, ShaderKey::Equal > ShaderFunctionMap
Definition: shader_key.h:43
impeller::ShaderLibraryGLES
Definition: shader_library_gles.h:18
comparable.h
IPLR_GUARDED_BY
#define IPLR_GUARDED_BY(x)
Definition: thread_safety.h:19
impeller::UniqueID
Definition: comparable.h:16
thread.h
impeller
Definition: aiks_blend_unittests.cc:18