| OLD | NEW |
| 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/jni/display_updater_factory.h" | |
| 17 #include "remoting/protocol/cursor_shape_stub.h" | 16 #include "remoting/protocol/cursor_shape_stub.h" |
| 18 | 17 |
| 19 namespace remoting { | 18 namespace remoting { |
| 20 | 19 |
| 20 namespace protocol { |
| 21 class VideoRenderer; |
| 22 } // namespace protocol |
| 23 |
| 21 class ChromotingJniRuntime; | 24 class ChromotingJniRuntime; |
| 22 class DualBufferFrameConsumer; | 25 class DualBufferFrameConsumer; |
| 23 class EglThreadContext; | 26 class EglThreadContext; |
| 24 class QueuedTaskPoster; | 27 class QueuedTaskPoster; |
| 25 | 28 |
| 26 // Handles OpenGL display operations. Draws desktop and cursor on the OpenGL | 29 // Handles OpenGL display operations. Draws desktop and cursor on the OpenGL |
| 27 // surface. | 30 // surface. |
| 28 // JNI functions should all be called on the UI thread. The display handler | 31 // JNI functions should all be called on the UI thread. user must call |
| 29 // itself should be deleted on the display thread. | 32 // Initialize() after the handler is constructed and Invalidate() before the |
| 33 // handler is destructed. The destructor must be called on the display thread. |
| 30 // Please see GlDisplay.java for documentations. | 34 // Please see GlDisplay.java for documentations. |
| 31 class JniGlDisplayHandler : public DisplayUpdaterFactory, | 35 // TODO(yuweih): Separate display thread logic into a core class. |
| 32 public protocol::CursorShapeStub, | 36 class JniGlDisplayHandler : public protocol::CursorShapeStub, |
| 33 public GlRendererDelegate { | 37 public GlRendererDelegate { |
| 34 public: | 38 public: |
| 35 JniGlDisplayHandler(ChromotingJniRuntime* runtime); | 39 JniGlDisplayHandler(ChromotingJniRuntime* runtime); |
| 40 |
| 41 // Destructor must be called on the display thread. |
| 36 ~JniGlDisplayHandler() override; | 42 ~JniGlDisplayHandler() override; |
| 37 | 43 |
| 38 // Sets the DesktopViewFactory for the Java client. | 44 // Must be called exactly once on the UI thread before using the handler. |
| 39 void InitializeClient( | 45 void Initialize(const base::android::JavaRef<jobject>& java_client); |
| 40 const base::android::JavaRef<jobject>& java_client); | |
| 41 | 46 |
| 42 // DisplayUpdaterFactory interface. | 47 // Must be called on the UI thread before calling the destructor. |
| 43 std::unique_ptr<protocol::CursorShapeStub> CreateCursorShapeStub() override; | 48 void Invalidate(); |
| 44 std::unique_ptr<protocol::VideoRenderer> CreateVideoRenderer() override; | 49 |
| 50 std::unique_ptr<protocol::CursorShapeStub> CreateCursorShapeStub(); |
| 51 std::unique_ptr<protocol::VideoRenderer> CreateVideoRenderer(); |
| 45 | 52 |
| 46 static bool RegisterJni(JNIEnv* env); | 53 static bool RegisterJni(JNIEnv* env); |
| 47 | 54 |
| 48 void OnSurfaceCreated( | 55 void OnSurfaceCreated( |
| 49 JNIEnv* env, | 56 JNIEnv* env, |
| 50 const base::android::JavaParamRef<jobject>& caller, | 57 const base::android::JavaParamRef<jobject>& caller, |
| 51 const base::android::JavaParamRef<jobject>& surface); | 58 const base::android::JavaParamRef<jobject>& surface); |
| 52 | 59 |
| 53 void OnSurfaceChanged(JNIEnv* env, | 60 void OnSurfaceChanged(JNIEnv* env, |
| 54 const base::android::JavaParamRef<jobject>& caller, | 61 const base::android::JavaParamRef<jobject>& caller, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 77 bool visible); | 84 bool visible); |
| 78 | 85 |
| 79 void OnCursorInputFeedback( | 86 void OnCursorInputFeedback( |
| 80 JNIEnv* env, | 87 JNIEnv* env, |
| 81 const base::android::JavaParamRef<jobject>& caller, | 88 const base::android::JavaParamRef<jobject>& caller, |
| 82 float x, | 89 float x, |
| 83 float y, | 90 float y, |
| 84 float diameter); | 91 float diameter); |
| 85 | 92 |
| 86 private: | 93 private: |
| 94 // Queues a task. All queued tasks will be posted to the display thread after |
| 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 |
| 87 // GlRendererDelegate interface. | 99 // GlRendererDelegate interface. |
| 88 bool CanRenderFrame() override; | 100 bool CanRenderFrame() override; |
| 89 void OnFrameRendered() override; | 101 void OnFrameRendered() override; |
| 90 void OnSizeChanged(int width, int height) override; | 102 void OnSizeChanged(int width, int height) override; |
| 91 | 103 |
| 92 // CursorShapeStub interface. | 104 // CursorShapeStub interface. |
| 93 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override; | 105 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override; |
| 94 | 106 |
| 95 static void NotifyRenderDoneOnUiThread( | 107 static void NotifyRenderDoneOnUiThread( |
| 96 base::android::ScopedJavaGlobalRef<jobject> java_display); | 108 base::android::ScopedJavaGlobalRef<jobject> java_display); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 120 | 132 |
| 121 // Used on display thread. | 133 // Used on display thread. |
| 122 base::WeakPtr<JniGlDisplayHandler> weak_ptr_; | 134 base::WeakPtr<JniGlDisplayHandler> weak_ptr_; |
| 123 base::WeakPtrFactory<JniGlDisplayHandler> weak_factory_; | 135 base::WeakPtrFactory<JniGlDisplayHandler> weak_factory_; |
| 124 DISALLOW_COPY_AND_ASSIGN(JniGlDisplayHandler); | 136 DISALLOW_COPY_AND_ASSIGN(JniGlDisplayHandler); |
| 125 }; | 137 }; |
| 126 | 138 |
| 127 } // namespace remoting | 139 } // namespace remoting |
| 128 | 140 |
| 129 #endif // REMOTING_CLIENT_JNI_JNI_GL_DISPLAY_HANDLER_H_ | 141 #endif // REMOTING_CLIENT_JNI_JNI_GL_DISPLAY_HANDLER_H_ |
| OLD | NEW |