1 // 2 // Copyright 2018 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 7 // ContextEGL.h: Context class for GL on Android/ChromeOS. Wraps a RendererEGL. 8 9 #ifndef LIBANGLE_RENDERER_GL_EGL_CONTEXTEGL_H_ 10 #define LIBANGLE_RENDERER_GL_EGL_CONTEXTEGL_H_ 11 12 #include "libANGLE/renderer/gl/ContextGL.h" 13 #include "libANGLE/renderer/gl/egl/RendererEGL.h" 14 15 namespace rx 16 { 17 18 struct ExternalContextState; 19 20 class ContextEGL : public ContextGL 21 { 22 public: 23 ContextEGL(const gl::State &state, 24 gl::ErrorSet *errorSet, 25 const std::shared_ptr<RendererEGL> &renderer, 26 RobustnessVideoMemoryPurgeStatus robustnessVideoMemoryPurgeStatus); 27 ~ContextEGL() override; 28 29 angle::Result onMakeCurrent(const gl::Context *context) override; 30 angle::Result onUnMakeCurrent(const gl::Context *context) override; 31 32 void acquireExternalContext(const gl::Context *context) override; 33 void releaseExternalContext(const gl::Context *context) override; 34 35 EGLContext getContext() const; 36 37 private: 38 std::shared_ptr<RendererEGL> mRendererEGL; 39 std::unique_ptr<ExternalContextState> mExtState; 40 41 // Used to restore the default FBO's ID on unmaking an external context 42 // current, as when making an external context current ANGLE sets the 43 // default FBO's ID to that bound in the external context. 44 GLuint mPrevDefaultFramebufferID = 0; 45 46 // onMakeCurrent() can be called when this context is already current, which 47 // introduces complexities for the case where this context is wrapping an 48 // external context. This variable is used to ensure that in this case we 49 // save state from the native context only when first transitioning this 50 // context to be current. It is true for the duration of time between an 51 // onMakeCurrent() call and an onUnMakeCurrent() call (note: there is no 52 // "nesting" of onUnMakeCurrent() calls, i.e., no matter how many 53 // onMakeCurrent() calls have occurred consecutively, an onUnMakeCurrent() 54 // call transitions this context away from being current). 55 bool mIsCurrent = false; 56 }; 57 } // namespace rx 58 59 #endif // LIBANGLE_RENDERER_GL_EGL_RENDEREREGL_H_ 60