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

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

Issue 2389463002: [Remoting Android] Separate the display core from JniGlDisplayHandler (Closed)
Patch Set: Add override for ~Core() Created 4 years, 2 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 | « remoting/client/jni/jni_client.cc ('k') | remoting/client/jni/jni_gl_display_handler.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_JNI_GL_DISPLAY_HANDLER_H_ 5 #ifndef REMOTING_CLIENT_JNI_JNI_GL_DISPLAY_HANDLER_H_
6 #define REMOTING_CLIENT_JNI_JNI_GL_DISPLAY_HANDLER_H_ 6 #define REMOTING_CLIENT_JNI_JNI_GL_DISPLAY_HANDLER_H_
7 7
8 #include <EGL/egl.h> 8 #include <EGL/egl.h>
9 #include <jni.h> 9 #include <jni.h>
10 10
11 #include "base/android/scoped_java_ref.h" 11 #include "base/android/scoped_java_ref.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "remoting/client/gl_renderer.h" 14 #include "remoting/client/gl_renderer.h"
15 #include "remoting/client/gl_renderer_delegate.h" 15 #include "remoting/client/gl_renderer_delegate.h"
16 #include "remoting/client/queued_task_poster.h"
16 #include "remoting/protocol/cursor_shape_stub.h" 17 #include "remoting/protocol/cursor_shape_stub.h"
17 18
18 namespace remoting { 19 namespace remoting {
19 20
20 namespace protocol { 21 namespace protocol {
21 class VideoRenderer; 22 class VideoRenderer;
22 } // namespace protocol 23 } // namespace protocol
23 24
24 class ChromotingJniRuntime; 25 class ChromotingJniRuntime;
25 class DualBufferFrameConsumer; 26 class DualBufferFrameConsumer;
26 class EglThreadContext; 27 class EglThreadContext;
27 class QueuedTaskPoster;
28 28
29 // Handles OpenGL display operations. Draws desktop and cursor on the OpenGL 29 // Handles OpenGL display operations. Draws desktop and cursor on the OpenGL
30 // surface. 30 // surface. The handler should be used and destroyed on the UI thread. It also
31 // JNI functions should all be called on the UI thread. user must call 31 // has a core that works on the display thread.
32 // Initialize() after the handler is constructed and Invalidate() before the 32 class JniGlDisplayHandler {
33 // handler is destructed. The destructor must be called on the display thread.
34 // Please see GlDisplay.java for documentations.
35 // TODO(yuweih): Separate display thread logic into a core class.
36 class JniGlDisplayHandler : public protocol::CursorShapeStub,
37 public GlRendererDelegate {
38 public: 33 public:
39 JniGlDisplayHandler(ChromotingJniRuntime* runtime); 34 JniGlDisplayHandler(ChromotingJniRuntime* runtime,
40 35 const base::android::JavaRef<jobject>& java_client);
41 // Destructor must be called on the display thread. 36 ~JniGlDisplayHandler();
42 ~JniGlDisplayHandler() override;
43
44 // Must be called exactly once on the UI thread before using the handler.
45 void Initialize(const base::android::JavaRef<jobject>& java_client);
46
47 // Must be called on the UI thread before calling the destructor.
48 void Invalidate();
49 37
50 std::unique_ptr<protocol::CursorShapeStub> CreateCursorShapeStub(); 38 std::unique_ptr<protocol::CursorShapeStub> CreateCursorShapeStub();
51 std::unique_ptr<protocol::VideoRenderer> CreateVideoRenderer(); 39 std::unique_ptr<protocol::VideoRenderer> CreateVideoRenderer();
52 40
53 static bool RegisterJni(JNIEnv* env); 41 static bool RegisterJni(JNIEnv* env);
54 42
55 void OnSurfaceCreated( 43 void OnSurfaceCreated(
56 JNIEnv* env, 44 JNIEnv* env,
57 const base::android::JavaParamRef<jobject>& caller, 45 const base::android::JavaParamRef<jobject>& caller,
58 const base::android::JavaParamRef<jobject>& surface); 46 const base::android::JavaParamRef<jobject>& surface);
(...skipping 25 matching lines...) Expand all
84 bool visible); 72 bool visible);
85 73
86 void OnCursorInputFeedback( 74 void OnCursorInputFeedback(
87 JNIEnv* env, 75 JNIEnv* env,
88 const base::android::JavaParamRef<jobject>& caller, 76 const base::android::JavaParamRef<jobject>& caller,
89 float x, 77 float x,
90 float y, 78 float y,
91 float diameter); 79 float diameter);
92 80
93 private: 81 private:
94 // Queues a task. All queued tasks will be posted to the display thread after 82 class Core;
95 // the current task is finished.
96 // Do nothing if |ui_task_poster_| has already been released.
97 void PostSequentialTaskOnDisplayThread(const base::Closure& task);
98 83
99 // GlRendererDelegate interface. 84 // Callbacks from the core.
100 bool CanRenderFrame() override; 85 void OnRenderDone();
101 void OnFrameRendered() override; 86 void OnCanvasSizeChanged(int width, int height);
102 void OnSizeChanged(int width, int height) override;
103
104 // CursorShapeStub interface.
105 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override;
106
107 static void NotifyRenderDoneOnUiThread(
108 base::android::ScopedJavaGlobalRef<jobject> java_display);
109
110 void SurfaceCreatedOnDisplayThread(
111 base::android::ScopedJavaGlobalRef<jobject> surface);
112
113 void SurfaceDestroyedOnDisplayThread();
114
115 static void ChangeCanvasSizeOnUiThread(
116 base::android::ScopedJavaGlobalRef<jobject> java_display,
117 int width,
118 int height);
119 87
120 ChromotingJniRuntime* runtime_; 88 ChromotingJniRuntime* runtime_;
121 89
90 QueuedTaskPoster ui_task_poster_;
91
92 std::unique_ptr<Core> core_;
93
122 base::android::ScopedJavaGlobalRef<jobject> java_display_; 94 base::android::ScopedJavaGlobalRef<jobject> java_display_;
123 95
124 std::unique_ptr<EglThreadContext> egl_context_; 96 // Used on UI thread.
125
126 base::WeakPtr<DualBufferFrameConsumer> frame_consumer_;
127
128 // |renderer_| must be deleted earlier than |egl_context_|.
129 GlRenderer renderer_;
130
131 std::unique_ptr<QueuedTaskPoster> ui_task_poster_;
132
133 // Used on display thread.
134 base::WeakPtr<JniGlDisplayHandler> weak_ptr_;
135 base::WeakPtrFactory<JniGlDisplayHandler> weak_factory_; 97 base::WeakPtrFactory<JniGlDisplayHandler> weak_factory_;
136 DISALLOW_COPY_AND_ASSIGN(JniGlDisplayHandler); 98 DISALLOW_COPY_AND_ASSIGN(JniGlDisplayHandler);
137 }; 99 };
138 100
139 } // namespace remoting 101 } // namespace remoting
140 102
141 #endif // REMOTING_CLIENT_JNI_JNI_GL_DISPLAY_HANDLER_H_ 103 #endif // REMOTING_CLIENT_JNI_JNI_GL_DISPLAY_HANDLER_H_
OLDNEW
« no previous file with comments | « remoting/client/jni/jni_client.cc ('k') | remoting/client/jni/jni_gl_display_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698