Flutter Engine
The Flutter Engine
|
An instance of an EGL context. More...
#include <context.h>
Public Types | |
enum class | LifecycleEvent { kDidMakeCurrent , kWillClearCurrent } |
using | LifecycleListener = std::function< void(LifecycleEvent)> |
Public Member Functions | |
~Context () | |
bool | IsValid () const |
Determines if a valid context could be created. The context still needs to be made current on the thread for it to be useful. More... | |
const EGLContext & | GetHandle () const |
Get the underlying handle to the EGL context. More... | |
bool | MakeCurrent (const Surface &surface) const |
Make the context current on the calling thread. It is the caller responsibility to ensure that any context previously current on the thread must be cleared via ClearCurrent . More... | |
bool | ClearCurrent () const |
Clear the thread association of this context. More... | |
std::optional< UniqueID > | AddLifecycleListener (const LifecycleListener &listener) |
Add a listener that gets invoked when the context is made and cleared current from the thread. Applications typically use this to manage workers that schedule OpenGL API calls that need to be careful about the context being current when called. More... | |
bool | RemoveLifecycleListener (UniqueID id) |
Remove a previously added context listener. More... | |
Friends | |
class | Display |
An instance of an EGL context.
An EGL context can only be used on a single thread at a given time. A thread can only have a single context current at any given time. Context cannot be created directly. Only a valid instance of an egl::Display can create a context.
using impeller::egl::Context::LifecycleListener = std::function<void(LifecycleEvent)> |
|
strong |
Context::~Context | ( | ) |
Definition at line 15 of file context.cc.
std::optional< UniqueID > Context::AddLifecycleListener | ( | const LifecycleListener & | listener | ) |
Add a listener that gets invoked when the context is made and cleared current from the thread. Applications typically use this to manage workers that schedule OpenGL API calls that need to be careful about the context being current when called.
[in] | listener | The listener |
RemoveLifecycleListener
to remove a previously added listener. Definition at line 74 of file context.cc.
bool Context::ClearCurrent | ( | ) | const |
Clear the thread association of this context.
Definition at line 61 of file context.cc.
const EGLContext & Context::GetHandle | ( | ) | const |
Get the underlying handle to the EGL context.
Definition at line 27 of file context.cc.
bool Context::IsValid | ( | ) | const |
Determines if a valid context could be created. The context still needs to be made current on the thread for it to be useful.
Definition at line 23 of file context.cc.
bool Context::MakeCurrent | ( | const Surface & | surface | ) | const |
Make the context current on the calling thread. It is the caller responsibility to ensure that any context previously current on the thread must be cleared via ClearCurrent
.
@important The config used to create the surface must match the config used to create this context instance.
[in] | surface | The surface to use to make the context current. |
Definition at line 45 of file context.cc.
bool Context::RemoveLifecycleListener | ( | UniqueID | id | ) |
Remove a previously added context listener.
[in] | id | The identifier obtained via a previous call to AddLifecycleListener . |
Definition at line 85 of file context.cc.