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

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: 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
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 // more than one EglThreadContext.
18 // 19 //
19 // An example use case: 20 // An example use case:
Lambros 2016/07/22 20:36:07 Does this example offer any value above the real i
Yuwei 2016/07/22 21:22:39 Remove this?
20 // class DisplayHandler { 21 // class DisplayHandler {
21 // void OnSurfaceCreated(ANativeWindow* surface) { 22 // void OnSurfaceCreated(ANativeWindow* surface) {
23 // if (context_.GetClientVersion() > 2) {
24 // renderer_.reset(new BetterRenderer());
25 // } else {
26 // renderer_.reset(new SoftwareRenderer());
27 // }
22 // context_.BindToWindow(surface); 28 // context_.BindToWindow(surface);
23 // } 29 // }
24 // void OnSurfaceDestroyed() { 30 // void OnSurfaceDestroyed() {
25 // context_.BindToWindow(nullptr); 31 // context_.BindToWindow(nullptr);
26 // } 32 // }
27 // EglThreadContext context_; 33 // EglThreadContext context_;
34 // unique_ptr<VideoRenderer> renderer_;
28 // }; 35 // };
29 class EglThreadContext { 36 class EglThreadContext {
30 public: 37 public:
31 EglThreadContext(); 38 EglThreadContext();
32 ~EglThreadContext(); 39 ~EglThreadContext();
33 40
34 // Creates a surface on the given window and binds the context to the surface. 41 // Creates a surface on the given window and binds the context to the surface.
35 // Unbinds |window| last bound if |window| is NULL. 42 // Unbinds |window| last bound if |window| is NULL.
36 // EGLNativeWindowType is platform specific. E.g. ANativeWindow* on Android. 43 // EGLNativeWindowType is platform specific. E.g. ANativeWindow* on Android.
37 void BindToWindow(EGLNativeWindowType window); 44 void BindToWindow(EGLNativeWindowType window);
38 45
39 // Returns true IFF the context is bound to a window (i.e. current surface is 46 // Returns true IFF the context is bound to a window (i.e. current surface is
Sergey Ulanov 2016/07/22 20:12:34 s/IFF/if/ Not everybody is familiar with this ter
Yuwei 2016/07/22 21:22:39 Done.
40 // not NULL). 47 // not NULL).
41 bool IsWindowBound() const; 48 bool IsWindowBound() const;
42 49
43 // Posts EGL surface buffer to the window being bound. Window must be bound 50 // Posts EGL surface buffer to the window being bound.
44 // before calling this function. 51 // Returns true IFF the buffer is successfully swapped.
Sergey Ulanov 2016/07/22 20:12:34 s/IFF/if/ (also it's not abbreviation, so it shoul
Yuwei 2016/07/22 21:22:39 Done.
45 void SwapBuffers(); 52 bool SwapBuffers();
53
54 // Returns the current OpenGL ES client version of the EGL context. It will be
55 // either 2 or 3.
56 int GetClientVersion() const;
Lambros 2016/07/22 20:36:07 This is a simple getter so call it client_version(
Yuwei 2016/07/22 21:22:39 inlined. It will be used in JniGlDisplayHandler a
46 57
47 private: 58 private:
59 // renderable_type:
Sergey Ulanov 2016/07/22 20:12:34 document this parameter? or maybe replace it with
Lambros 2016/07/22 20:36:07 This comment is confusing. Can you write it as Eng
Yuwei 2016/07/22 21:22:40 Changed the comment a little bit... EGLContext and
60 // client_version: Either 2 or 3. Specifying whether OpenGL ES 2 or OpenGL ES
61 // 3 context should be created.
62 bool CreateContextWithClientVersion(unsigned int renderable_type,
Sergey Ulanov 2016/07/22 20:12:34 Please use int instead of unsigned int. See https:
Yuwei 2016/07/22 21:22:40 Done.
63 int client_version);
64
48 EGLDisplay display_ = EGL_NO_DISPLAY; 65 EGLDisplay display_ = EGL_NO_DISPLAY;
49 EGLConfig config_ = nullptr; 66 EGLConfig config_ = nullptr;
50 EGLSurface surface_ = EGL_NO_SURFACE; 67 EGLSurface surface_ = EGL_NO_SURFACE;
51 EGLContext context_ = EGL_NO_CONTEXT; 68 EGLContext context_ = EGL_NO_CONTEXT;
69 int client_version_ = 0;
Sergey Ulanov 2016/07/22 20:12:34 nit: maybe useful to declare enum for GL version
Lambros 2016/07/22 20:36:07 Do you need to store version here? Couldn't you ca
Yuwei 2016/07/22 21:22:39 GetClientVersion() just returns client_version_...
Yuwei 2016/07/22 21:22:39 Done.
52 70
53 base::ThreadChecker thread_checker_; 71 base::ThreadChecker thread_checker_;
54 72
55 DISALLOW_COPY_AND_ASSIGN(EglThreadContext); 73 DISALLOW_COPY_AND_ASSIGN(EglThreadContext);
56 }; 74 };
57 75
58 } // namespace remoting 76 } // namespace remoting
59 77
60 #endif // REMOTING_CLIENT_JNI_EGL_THREAD_CONTEXT_H_ 78 #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') | remoting/client/jni/egl_thread_context.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698