| 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 class JniGlDisplayHandler : public protocol::CursorShapeStub, |
| 32 public protocol::CursorShapeStub, | |
| 33 public GlRendererDelegate { | 36 public GlRendererDelegate { |
| 34 public: | 37 public: |
| 35 JniGlDisplayHandler(ChromotingJniRuntime* runtime); | 38 JniGlDisplayHandler(ChromotingJniRuntime* runtime); |
| 39 |
| 40 // Destructor must be called on the display thread. |
| 36 ~JniGlDisplayHandler() override; | 41 ~JniGlDisplayHandler() override; |
| 37 | 42 |
| 38 // Sets the DesktopViewFactory for the Java client. | 43 // Must be called exactly once on the UI thread before using the handler. |
| 39 void InitializeClient( | 44 void Initialize(const base::android::JavaRef<jobject>& java_client); |
| 40 const base::android::JavaRef<jobject>& java_client); | |
| 41 | 45 |
| 42 // DisplayUpdaterFactory interface. | 46 // Must be called on the UI thread before calling the destructor. |
| 43 std::unique_ptr<protocol::CursorShapeStub> CreateCursorShapeStub() override; | 47 void Invalidate(); |
| 44 std::unique_ptr<protocol::VideoRenderer> CreateVideoRenderer() override; | 48 |
| 49 std::unique_ptr<protocol::CursorShapeStub> CreateCursorShapeStub(); |
| 50 std::unique_ptr<protocol::VideoRenderer> CreateVideoRenderer(); |
| 45 | 51 |
| 46 static bool RegisterJni(JNIEnv* env); | 52 static bool RegisterJni(JNIEnv* env); |
| 47 | 53 |
| 48 void OnSurfaceCreated( | 54 void OnSurfaceCreated( |
| 49 JNIEnv* env, | 55 JNIEnv* env, |
| 50 const base::android::JavaParamRef<jobject>& caller, | 56 const base::android::JavaParamRef<jobject>& caller, |
| 51 const base::android::JavaParamRef<jobject>& surface); | 57 const base::android::JavaParamRef<jobject>& surface); |
| 52 | 58 |
| 53 void OnSurfaceChanged(JNIEnv* env, | 59 void OnSurfaceChanged(JNIEnv* env, |
| 54 const base::android::JavaParamRef<jobject>& caller, | 60 const base::android::JavaParamRef<jobject>& caller, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 77 bool visible); | 83 bool visible); |
| 78 | 84 |
| 79 void OnCursorInputFeedback( | 85 void OnCursorInputFeedback( |
| 80 JNIEnv* env, | 86 JNIEnv* env, |
| 81 const base::android::JavaParamRef<jobject>& caller, | 87 const base::android::JavaParamRef<jobject>& caller, |
| 82 float x, | 88 float x, |
| 83 float y, | 89 float y, |
| 84 float diameter); | 90 float diameter); |
| 85 | 91 |
| 86 private: | 92 private: |
| 93 // Queues a task. All queued tasks will be posted to the display thread after |
| 94 // the current task is finished. |
| 95 // Do nothing if |ui_task_poster_| has already been released. |
| 96 void QueueTaskOnDisplayThread(const base::Closure& task); |
| 97 |
| 87 // GlRendererDelegate interface. | 98 // GlRendererDelegate interface. |
| 88 bool CanRenderFrame() override; | 99 bool CanRenderFrame() override; |
| 89 void OnFrameRendered() override; | 100 void OnFrameRendered() override; |
| 90 void OnSizeChanged(int width, int height) override; | 101 void OnSizeChanged(int width, int height) override; |
| 91 | 102 |
| 92 // CursorShapeStub interface. | 103 // CursorShapeStub interface. |
| 93 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override; | 104 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override; |
| 94 | 105 |
| 95 static void NotifyRenderDoneOnUiThread( | 106 static void NotifyRenderDoneOnUiThread( |
| 96 base::android::ScopedJavaGlobalRef<jobject> java_display); | 107 base::android::ScopedJavaGlobalRef<jobject> java_display); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 120 | 131 |
| 121 // Used on display thread. | 132 // Used on display thread. |
| 122 base::WeakPtr<JniGlDisplayHandler> weak_ptr_; | 133 base::WeakPtr<JniGlDisplayHandler> weak_ptr_; |
| 123 base::WeakPtrFactory<JniGlDisplayHandler> weak_factory_; | 134 base::WeakPtrFactory<JniGlDisplayHandler> weak_factory_; |
| 124 DISALLOW_COPY_AND_ASSIGN(JniGlDisplayHandler); | 135 DISALLOW_COPY_AND_ASSIGN(JniGlDisplayHandler); |
| 125 }; | 136 }; |
| 126 | 137 |
| 127 } // namespace remoting | 138 } // namespace remoting |
| 128 | 139 |
| 129 #endif // REMOTING_CLIENT_JNI_JNI_GL_DISPLAY_HANDLER_H_ | 140 #endif // REMOTING_CLIENT_JNI_JNI_GL_DISPLAY_HANDLER_H_ |
| OLD | NEW |