Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Side by Side Diff: remoting/client/jni/egl_thread_context.h

Issue 2175913002: [Remoting Android] Make EglThreadContext create OpenGL ES 3 context (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's Feedback Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | remoting/client/jni/egl_thread_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef REMOTING_CLIENT_JNI_EGL_THREAD_CONTEXT_H_ 5 #ifndef REMOTING_CLIENT_JNI_EGL_THREAD_CONTEXT_H_
6 #define REMOTING_CLIENT_JNI_EGL_THREAD_CONTEXT_H_ 6 #define REMOTING_CLIENT_JNI_EGL_THREAD_CONTEXT_H_
7 7
8 #include <EGL/egl.h> 8 #include <EGL/egl.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/threading/thread_checker.h" 11 #include "base/threading/thread_checker.h"
12 12
13 namespace remoting { 13 namespace remoting {
14 14
15 // Establishes an EGL-OpenGL|ES2 context on current thread. Must be constructed, 15 // Establishes an EGL-OpenGL|ES 2 (if 3 is not supported) or 3 (backward
16 // used, and deleted on single thread (i.e. the display thread). Each thread can 16 // compatible with 2) context on current thread. Must be constructed, used, and
17 // have no more than one EglThreadContext. 17 // deleted on single thread (i.e. the display thread). Each thread can have no
18 // 18 // more than one EglThreadContext.
19 // An example use case:
20 // class DisplayHandler {
21 // void OnSurfaceCreated(ANativeWindow* surface) {
22 // context_.BindToWindow(surface);
23 // }
24 // void OnSurfaceDestroyed() {
25 // context_.BindToWindow(nullptr);
26 // }
27 // EglThreadContext context_;
28 // };
29 class EglThreadContext { 19 class EglThreadContext {
30 public: 20 public:
21 enum ClientVersion {
22 CLIENT_VERSION_UNKNOWN = 0,
23 CLIENT_VERSION_ES_2 = 2,
24 CLIENT_VERSION_ES_3 = 3
25 };
26
31 EglThreadContext(); 27 EglThreadContext();
32 ~EglThreadContext(); 28 ~EglThreadContext();
33 29
34 // Creates a surface on the given window and binds the context to the surface. 30 // Creates a surface on the given window and binds the context to the surface.
35 // Unbinds |window| last bound if |window| is NULL. 31 // Unbinds |window| last bound if |window| is NULL.
36 // EGLNativeWindowType is platform specific. E.g. ANativeWindow* on Android. 32 // EGLNativeWindowType is platform specific. E.g. ANativeWindow* on Android.
37 void BindToWindow(EGLNativeWindowType window); 33 void BindToWindow(EGLNativeWindowType window);
38 34
39 // Returns true IFF the context is bound to a window (i.e. current surface is 35 // Returns true if the context is bound to a window (i.e. current surface is
40 // not NULL). 36 // not NULL), false otherwise.
Lambros 2016/07/23 01:50:13 "false otherwise" is not needed; see https://googl
Yuwei 2016/07/25 17:59:41 Done.
41 bool IsWindowBound() const; 37 bool IsWindowBound() const;
42 38
43 // Posts EGL surface buffer to the window being bound. Window must be bound 39 // Posts EGL surface buffer to the window being bound.
44 // before calling this function. 40 // Returns true if the buffer is successfully swapped, false otherwise.
Lambros 2016/07/23 01:50:13 Same here.
Yuwei 2016/07/25 17:59:41 Done.
45 void SwapBuffers(); 41 bool SwapBuffers();
42
43 // Returns the current OpenGL ES client version of the EGL context. It will be
44 // either 2 or 3.
45 ClientVersion client_version() const {
46 return client_version_;
47 }
46 48
47 private: 49 private:
50 // Creates an EGLContext with given |renderable_type| and |client_version|.
51 // |renderable_type| and |client_version| must match with each other.
52 // E.g. renderable_type = EGL_OPENGL_ES3_BIT,
53 // client_version = CLIENT_VERSION_ES_3.
54 bool CreateContextWithClientVersion(int renderable_type,
55 ClientVersion client_version);
56
48 EGLDisplay display_ = EGL_NO_DISPLAY; 57 EGLDisplay display_ = EGL_NO_DISPLAY;
49 EGLConfig config_ = nullptr; 58 EGLConfig config_ = nullptr;
50 EGLSurface surface_ = EGL_NO_SURFACE; 59 EGLSurface surface_ = EGL_NO_SURFACE;
51 EGLContext context_ = EGL_NO_CONTEXT; 60 EGLContext context_ = EGL_NO_CONTEXT;
61 ClientVersion client_version_ = CLIENT_VERSION_UNKNOWN;
52 62
53 base::ThreadChecker thread_checker_; 63 base::ThreadChecker thread_checker_;
54 64
55 DISALLOW_COPY_AND_ASSIGN(EglThreadContext); 65 DISALLOW_COPY_AND_ASSIGN(EglThreadContext);
56 }; 66 };
57 67
58 } // namespace remoting 68 } // namespace remoting
59 69
60 #endif // REMOTING_CLIENT_JNI_EGL_THREAD_CONTEXT_H_ 70 #endif // REMOTING_CLIENT_JNI_EGL_THREAD_CONTEXT_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/client/jni/egl_thread_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698