EglContext is an RAII wrapper for an EGLContext. EglContext is moveable but not copyable. See https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglIntro.xhtml for more info.
| 32 | // See https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglIntro.xhtml for |
| 33 | // more info. |
| 34 | class EglContext { |
| 35 | public: |
| 36 | // Creates an invalid EglContext. |
| 37 | EglContext() |
| 38 | : context_(EGL_NO_CONTEXT), |
| 39 | display_(EGL_NO_DISPLAY), |
| 40 | config_(EGL_NO_CONFIG_KHR), |
| 41 | has_ownership_(false) {} |
| 42 | |
| 43 | EglContext(EGLContext context, EGLDisplay display, EGLConfig config, |
| 44 | bool has_ownership) |
| 45 | : context_(context), |
| 46 | display_(display), |
| 47 | config_(config), |
| 48 | has_ownership_(has_ownership) {} |
| 49 | |
| 50 | // Move only |
| 51 | EglContext(EglContext&& other); |
| 52 | EglContext& operator=(EglContext&& other); |
| 53 | EglContext(const EglContext&) = delete; |
| 54 | EglContext& operator=(const EglContext&) = delete; |
| 55 | |
| 56 | ~EglContext() { Invalidate(); } |
| 57 | |
| 58 | EGLContext context() const { return context_; } |
| 59 | |
| 60 | EGLDisplay display() const { return display_; } |
| 61 | |
| 62 | EGLConfig config() const { return config_; } |
| 63 | |
| 64 | // Make this EglContext the current EGL context on this thread, replacing |
| 65 | // the existing current. |
| 66 | Status MakeCurrent(EGLSurface read, EGLSurface write); |
| 67 | |
| 68 | Status MakeCurrentSurfaceless() { |
| 69 | return MakeCurrent(EGL_NO_SURFACE, EGL_NO_SURFACE); |
| 70 | } |
| 71 | |
| 72 | // Returns true if this is the currently bound EGL context. |
| 73 | bool IsCurrent() const; |
| 74 | |
| 75 | // Returns true if this object actually owns corresponding EGL context |
| 76 | // and manages it's lifetime. |
| 77 | bool has_ownership() const { return has_ownership_; } |
| 78 | |
| 79 | private: |
| 80 | void Invalidate(); |
| 81 | |
| 82 | EGLContext context_; |
| 83 | EGLDisplay display_; |
| 84 | EGLConfig config_; |
| 85 | |
| 86 | bool has_ownership_; |
| 87 | }; |
| 88 | |
| 89 | // It uses the EGL_KHR_no_config_context extension to create a no config context |
| 90 | // since most modern hardware supports the extension. |
no outgoing calls
no test coverage detected