Chromium Code Reviews| Index: remoting/client/jni/egl_thread_context.h |
| diff --git a/remoting/client/jni/egl_thread_context.h b/remoting/client/jni/egl_thread_context.h |
| index f8f2b8e89cd3b862f49b8fc26024d13fe442f81d..0b62d5fd250b07dba9fc48b9f60581add392b029 100644 |
| --- a/remoting/client/jni/egl_thread_context.h |
| +++ b/remoting/client/jni/egl_thread_context.h |
| @@ -12,22 +12,18 @@ |
| namespace remoting { |
| -// Establishes an EGL-OpenGL|ES2 context on current thread. Must be constructed, |
| -// used, and deleted on single thread (i.e. the display thread). Each thread can |
| -// have no more than one EglThreadContext. |
| -// |
| -// An example use case: |
| -// class DisplayHandler { |
| -// void OnSurfaceCreated(ANativeWindow* surface) { |
| -// context_.BindToWindow(surface); |
| -// } |
| -// void OnSurfaceDestroyed() { |
| -// context_.BindToWindow(nullptr); |
| -// } |
| -// EglThreadContext context_; |
| -// }; |
| +// Establishes an EGL-OpenGL|ES 2 (if 3 is not supported) or 3 (backward |
| +// compatible with 2) context on current thread. Must be constructed, used, and |
| +// deleted on single thread (i.e. the display thread). Each thread can have no |
| +// more than one EglThreadContext. |
| class EglThreadContext { |
| public: |
| + enum ClientVersion { |
|
Sergey Ulanov
2016/07/25 19:47:11
nit: use enum class and remove CLIENT_VERSION_ pre
Sergey Ulanov
2016/07/25 19:47:11
Call this GlVersion?
Yuwei
2016/07/25 20:59:51
Done.
Yuwei
2016/07/25 20:59:51
Done.
|
| + CLIENT_VERSION_UNKNOWN = 0, |
| + CLIENT_VERSION_ES_2 = 2, |
| + CLIENT_VERSION_ES_3 = 3 |
| + }; |
| + |
| EglThreadContext(); |
| ~EglThreadContext(); |
| @@ -36,19 +32,33 @@ class EglThreadContext { |
| // EGLNativeWindowType is platform specific. E.g. ANativeWindow* on Android. |
| void BindToWindow(EGLNativeWindowType window); |
| - // Returns true IFF the context is bound to a window (i.e. current surface is |
| + // Returns true if the context is bound to a window (i.e. current surface is |
| // not NULL). |
| bool IsWindowBound() const; |
| - // Posts EGL surface buffer to the window being bound. Window must be bound |
| - // before calling this function. |
| - void SwapBuffers(); |
| + // Posts EGL surface buffer to the window being bound. |
| + // Returns true if the buffer is successfully swapped. |
| + bool SwapBuffers(); |
| + |
| + // Returns the current OpenGL ES client version of the EGL context. It will be |
| + // either 2 or 3. |
| + ClientVersion client_version() const { |
| + return client_version_; |
| + } |
| private: |
| + // Creates an EGLContext with given |renderable_type| and |client_version|. |
| + // |renderable_type| and |client_version| must match with each other. |
| + // E.g. renderable_type = EGL_OPENGL_ES3_BIT, |
| + // client_version = CLIENT_VERSION_ES_3. |
| + bool CreateContextWithClientVersion(int renderable_type, |
| + ClientVersion client_version); |
| + |
| EGLDisplay display_ = EGL_NO_DISPLAY; |
| EGLConfig config_ = nullptr; |
| EGLSurface surface_ = EGL_NO_SURFACE; |
| EGLContext context_ = EGL_NO_CONTEXT; |
| + ClientVersion client_version_ = CLIENT_VERSION_UNKNOWN; |
| base::ThreadChecker thread_checker_; |