5#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_REACTOR_GLES_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_REACTOR_GLES_H_
86 using Ref = std::shared_ptr<ReactorGLES>;
219 [[nodiscard]]
bool React();
223 std::optional<GLuint>
name;
224 std::optional<std::string> pending_debug_label;
225 bool pending_collection =
false;
227 LiveHandle() =
default;
229 explicit LiveHandle(std::optional<GLuint> p_name) :
name(p_name) {}
231 constexpr bool IsLive()
const {
return name.has_value(); }
234 std::unique_ptr<ProcTableGLES> proc_table_;
236 Mutex ops_execution_mutex_;
237 mutable Mutex ops_mutex_;
238 std::vector<Operation> ops_ IPLR_GUARDED_BY(ops_mutex_);
242 using LiveHandles = std::unordered_map<HandleGLES,
246 mutable RWMutex handles_mutex_;
247 LiveHandles handles_ IPLR_GUARDED_BY(handles_mutex_);
249 mutable Mutex workers_mutex_;
250 mutable std::map<WorkerID, std::weak_ptr<Worker>> workers_ IPLR_GUARDED_BY(
253 bool can_set_debug_labels_ =
false;
254 bool is_valid_ =
false;
258 bool HasPendingOperations() const;
260 bool CanReactOnCurrentThread() const;
262 bool ConsolidateHandles();
266 void SetupDebugGroups();
static void operation(T operation, uint32_t &a, uint32_t b, uint32_t c, uint32_t d, uint32_t x, uint8_t s, uint32_t t)
A delegate implemented by a thread on which an OpenGL context is current. There may be multiple worke...
virtual bool CanReactorReactOnCurrentThreadNow(const ReactorGLES &reactor) const =0
Determines the ability of the worker to service a reaction on the current thread. The OpenGL context ...
virtual ~Worker()=default
The reactor attempts to make thread-safe usage of OpenGL ES easier to reason about.
std::optional< GLuint > GetGLHandle(const HandleGLES &handle) const
Returns the OpenGL handle for a reactor handle if one is available. This is typically only safe to ca...
ReactorGLES(std::unique_ptr< ProcTableGLES > gl)
Create a new reactor. There are expensive and only one per application instance is necessary.
void CollectHandle(HandleGLES handle)
Collect a reactor handle.
std::function< void(const ReactorGLES &reactor)> Operation
bool React()
Perform a reaction on the current thread if able.
~ReactorGLES()
Destroy a reactor.
const ProcTableGLES & GetProcTable() const
Get the OpenGL proc. table the reactor uses to manage handles.
std::shared_ptr< ReactorGLES > Ref
HandleGLES CreateHandle(HandleType type)
Create a reactor handle.
void SetDebugLabel(const HandleGLES &handle, std::string label)
Set the debug label on a reactor handle.
bool AddOperation(Operation operation)
Adds an operation that the reactor runs on a worker that ensures that an OpenGL context is current.
bool RemoveWorker(WorkerID id)
Remove a previously added worker from the reactor. If the reactor has no workers, pending added opera...
WorkerID AddWorker(std::weak_ptr< Worker > worker)
Adds a worker to the reactor. Each new worker must ensure that the context it manages is the same as ...
bool IsValid() const
If this is a valid reactor. Invalid reactors must be discarded immediately.
Dart_NativeFunction function
static uint32_t Hash(uint32_t key)
DEF_SWITCHES_START aot vmservice shared library name
#define IPLR_REQUIRES(...)