9#include "flutter/fml/closure.h"
51ShaderLibraryGLES::ShaderLibraryGLES(
52 const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries) {
54 auto iterator = [&functions, library_id = library_id_](
auto type,
61 functions[ShaderKey{key_name, stage}] = std::shared_ptr<ShaderFunctionGLES>(
62 new ShaderFunctionGLES(library_id,
70 for (
auto library : shader_libraries) {
71 auto blob_library = ShaderArchive{std::move(library)};
72 if (!blob_library.IsValid()) {
76 blob_library.IterateAllShaders(iterator);
79 functions_ = functions;
92std::shared_ptr<const ShaderFunction> ShaderLibraryGLES::GetFunction(
93 std::string_view
name,
97 if (
auto found = functions_.find(
key); found != functions_.end()) {
104void ShaderLibraryGLES::RegisterFunction(std::string
name,
106 std::shared_ptr<fml::Mapping>
code,
113 code->GetMapping() ==
nullptr) {
117 const auto key = ShaderKey{
name, stage};
118 WriterLock lock(functions_mutex_);
119 if (functions_.count(
key) != 0) {
121 <<
" has already been registered.";
124 functions_[
key] = std::shared_ptr<ShaderFunctionGLES>(
new ShaderFunctionGLES(
135void ShaderLibraryGLES::UnregisterFunction(std::string
name,
137 ReaderLock lock(functions_mutex_);
139 const auto key = ShaderKey{
name, stage};
141 auto found = functions_.find(
key);
142 if (found == functions_.end()) {
144 <<
" was not found, so it couldn't be unregistered.";
148 functions_.erase(found);
Wraps a closure that is invoked in the destructor unless released by the caller.
~ShaderLibraryGLES() override
bool IsValid() const override
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
#define FML_UNREACHABLE()
DEF_SWITCHES_START aot vmservice shared library name
static std::string GLESShaderNameToShaderKeyName(const std::string &name, ShaderStage stage)
constexpr ShaderStage ToShaderStage(RuntimeShaderStage stage)
std::unordered_map< ShaderKey, std::shared_ptr< const ShaderFunction >, ShaderKey::Hash, ShaderKey::Equal > ShaderFunctionMap