Index: remoting/client/jni/jni_gl_display_handler.h |
diff --git a/remoting/client/jni/jni_gl_display_handler.h b/remoting/client/jni/jni_gl_display_handler.h |
index 540fb09e5de4391d7c40cd730f064eb3ab23319e..7dbba87e2188804707e6457533c71d5f50c901db 100644 |
--- a/remoting/client/jni/jni_gl_display_handler.h |
+++ b/remoting/client/jni/jni_gl_display_handler.h |
@@ -13,6 +13,7 @@ |
#include "base/memory/weak_ptr.h" |
#include "remoting/client/gl_renderer.h" |
#include "remoting/client/gl_renderer_delegate.h" |
+#include "remoting/client/queued_task_poster.h" |
#include "remoting/protocol/cursor_shape_stub.h" |
namespace remoting { |
@@ -24,28 +25,15 @@ class VideoRenderer; |
class ChromotingJniRuntime; |
class DualBufferFrameConsumer; |
class EglThreadContext; |
-class QueuedTaskPoster; |
// Handles OpenGL display operations. Draws desktop and cursor on the OpenGL |
-// surface. |
-// JNI functions should all be called on the UI thread. user must call |
-// Initialize() after the handler is constructed and Invalidate() before the |
-// handler is destructed. The destructor must be called on the display thread. |
-// Please see GlDisplay.java for documentations. |
-// TODO(yuweih): Separate display thread logic into a core class. |
-class JniGlDisplayHandler : public protocol::CursorShapeStub, |
- public GlRendererDelegate { |
+// surface. The handler should be used and destroyed on the UI thread. It also |
+// has a core that works on the display thread. |
+class JniGlDisplayHandler { |
public: |
- JniGlDisplayHandler(ChromotingJniRuntime* runtime); |
- |
- // Destructor must be called on the display thread. |
- ~JniGlDisplayHandler() override; |
- |
- // Must be called exactly once on the UI thread before using the handler. |
- void Initialize(const base::android::JavaRef<jobject>& java_client); |
Yuwei
2016/10/01 00:23:55
Merged Initialize with the constructor since it do
|
- |
- // Must be called on the UI thread before calling the destructor. |
- void Invalidate(); |
+ JniGlDisplayHandler(ChromotingJniRuntime* runtime, |
+ const base::android::JavaRef<jobject>& java_client); |
+ ~JniGlDisplayHandler(); |
std::unique_ptr<protocol::CursorShapeStub> CreateCursorShapeStub(); |
std::unique_ptr<protocol::VideoRenderer> CreateVideoRenderer(); |
@@ -91,47 +79,21 @@ class JniGlDisplayHandler : public protocol::CursorShapeStub, |
float diameter); |
private: |
- // Queues a task. All queued tasks will be posted to the display thread after |
- // the current task is finished. |
- // Do nothing if |ui_task_poster_| has already been released. |
- void PostSequentialTaskOnDisplayThread(const base::Closure& task); |
- |
- // GlRendererDelegate interface. |
- bool CanRenderFrame() override; |
- void OnFrameRendered() override; |
- void OnSizeChanged(int width, int height) override; |
- |
- // CursorShapeStub interface. |
- void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override; |
- |
- static void NotifyRenderDoneOnUiThread( |
- base::android::ScopedJavaGlobalRef<jobject> java_display); |
+ class Core; |
- void SurfaceCreatedOnDisplayThread( |
- base::android::ScopedJavaGlobalRef<jobject> surface); |
- |
- void SurfaceDestroyedOnDisplayThread(); |
- |
- static void ChangeCanvasSizeOnUiThread( |
- base::android::ScopedJavaGlobalRef<jobject> java_display, |
- int width, |
- int height); |
+ // Callbacks from the core. |
+ void OnRenderDone(); |
+ void OnCanvasSizeChanged(int width, int height); |
ChromotingJniRuntime* runtime_; |
- base::android::ScopedJavaGlobalRef<jobject> java_display_; |
- |
- std::unique_ptr<EglThreadContext> egl_context_; |
- |
- base::WeakPtr<DualBufferFrameConsumer> frame_consumer_; |
+ QueuedTaskPoster ui_task_poster_; |
- // |renderer_| must be deleted earlier than |egl_context_|. |
- GlRenderer renderer_; |
+ std::unique_ptr<Core> core_; |
- std::unique_ptr<QueuedTaskPoster> ui_task_poster_; |
+ base::android::ScopedJavaGlobalRef<jobject> java_display_; |
- // Used on display thread. |
- base::WeakPtr<JniGlDisplayHandler> weak_ptr_; |
+ // Used on UI thread. |
base::WeakPtrFactory<JniGlDisplayHandler> weak_factory_; |
DISALLOW_COPY_AND_ASSIGN(JniGlDisplayHandler); |
}; |