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