Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Friends | List of all members
impeller::ShaderLibraryGLES Class Referencefinal

#include <shader_library_gles.h>

Inheritance diagram for impeller::ShaderLibraryGLES:
impeller::ShaderLibrary

Public Member Functions

 ~ShaderLibraryGLES () override
 
bool IsValid () const override
 
- Public Member Functions inherited from impeller::ShaderLibrary
virtual ~ShaderLibrary ()
 

Private Member Functions

std::shared_ptr< const ShaderFunctionGetFunction (std::string_view name, ShaderStage stage) override
 
void RegisterFunction (std::string name, ShaderStage stage, std::shared_ptr< fml::Mapping > code, RegistrationCallback callback) override
 
void UnregisterFunction (std::string name, ShaderStage stage) override
 

Friends

class ContextGLES
 

Additional Inherited Members

- Public Types inherited from impeller::ShaderLibrary
using RegistrationCallback = std::function< void(bool)>
 
- Protected Member Functions inherited from impeller::ShaderLibrary
 ShaderLibrary ()
 

Detailed Description

Definition at line 19 of file shader_library_gles.h.

Constructor & Destructor Documentation

◆ ~ShaderLibraryGLES()

impeller::ShaderLibraryGLES::~ShaderLibraryGLES ( )
overridedefault

Member Function Documentation

◆ GetFunction()

std::shared_ptr< const ShaderFunction > impeller::ShaderLibraryGLES::GetFunction ( std::string_view  name,
ShaderStage  stage 
)
overrideprivatevirtual

Implements impeller::ShaderLibrary.

Definition at line 94 of file shader_library_gles.cc.

96 {
97 ReaderLock lock(functions_mutex_);
98 const auto key = ShaderKey{name, stage};
99 if (auto found = functions_.find(key); found != functions_.end()) {
100 return found->second;
101 }
102 return nullptr;
103}
const char * name
Definition fuchsia.cc:50

◆ IsValid()

bool impeller::ShaderLibraryGLES::IsValid ( ) const
overridevirtual

Implements impeller::ShaderLibrary.

Definition at line 89 of file shader_library_gles.cc.

89 {
90 return is_valid_;
91}

◆ RegisterFunction()

void impeller::ShaderLibraryGLES::RegisterFunction ( std::string  name,
ShaderStage  stage,
std::shared_ptr< fml::Mapping code,
RegistrationCallback  callback 
)
overrideprivatevirtual

Reimplemented from impeller::ShaderLibrary.

Definition at line 106 of file shader_library_gles.cc.

109 {
110 if (!callback) {
111 callback = [](auto) {};
112 }
113 fml::ScopedCleanupClosure auto_fail([callback]() { callback(false); });
114 if (name.empty() || stage == ShaderStage::kUnknown || code == nullptr ||
115 code->GetMapping() == nullptr) {
116 VALIDATION_LOG << "Invalid runtime stage registration.";
117 return;
118 }
119 const auto key = ShaderKey{name, stage};
120 WriterLock lock(functions_mutex_);
121 if (functions_.count(key) != 0) {
122 VALIDATION_LOG << "Runtime stage named " << name
123 << " has already been registered.";
124 return;
125 }
126 functions_[key] = std::shared_ptr<ShaderFunctionGLES>(new ShaderFunctionGLES(
127 library_id_, //
128 stage, //
130 code //
131 ));
132 auto_fail.Release();
133 callback(true);
134}
Wraps a closure that is invoked in the destructor unless released by the caller.
Definition closure.h:32
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
static std::string GLESShaderNameToShaderKeyName(const std::string &name, ShaderStage stage)
#define VALIDATION_LOG
Definition validation.h:73

◆ UnregisterFunction()

void impeller::ShaderLibraryGLES::UnregisterFunction ( std::string  name,
ShaderStage  stage 
)
overrideprivatevirtual

Implements impeller::ShaderLibrary.

Definition at line 137 of file shader_library_gles.cc.

138 {
139 ReaderLock lock(functions_mutex_);
140
141 const auto key = ShaderKey{name, stage};
142
143 auto found = functions_.find(key);
144 if (found == functions_.end()) {
145 VALIDATION_LOG << "Library function named " << name
146 << " was not found, so it couldn't be unregistered.";
147 return;
148 }
149
150 functions_.erase(found);
151
152 return;
153}

Friends And Related Symbol Documentation

◆ ContextGLES

friend class ContextGLES
friend

Definition at line 28 of file shader_library_gles.h.


The documentation for this class was generated from the following files: