| 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_DISPLAY_HANDLER_H_ | 5 #ifndef REMOTING_CLIENT_JNI_JNI_DISPLAY_HANDLER_H_ |
| 6 #define REMOTING_CLIENT_JNI_JNI_DISPLAY_HANDLER_H_ | 6 #define REMOTING_CLIENT_JNI_JNI_DISPLAY_HANDLER_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "remoting/client/jni/display_updater_factory.h" | 13 #include "remoting/client/jni/display_updater_factory.h" |
| 14 | 14 |
| 15 namespace remoting { | 15 namespace remoting { |
| 16 | 16 |
| 17 namespace protocol { | 17 namespace protocol { |
| 18 class CursorShapeInfo; | 18 class CursorShapeInfo; |
| 19 } // namespace protocol | 19 } // namespace protocol |
| 20 | 20 |
| 21 class ChromotingJniRuntime; | 21 class ChromotingJniRuntime; |
| 22 class JniVideoRenderer; | 22 class JniVideoRenderer; |
| 23 | 23 |
| 24 // Handles display operations. Must be called and deleted on the display thread | 24 // Handles display operations. Must be called and deleted on the display thread |
| 25 // unless otherwise noted. | 25 // unless otherwise noted. |
| 26 class JniDisplayHandler : public DisplayUpdaterFactory { | 26 class JniDisplayHandler : public DisplayUpdaterFactory { |
| 27 public: | 27 public: |
| 28 JniDisplayHandler(ChromotingJniRuntime* runtime, | 28 explicit JniDisplayHandler(ChromotingJniRuntime* runtime); |
| 29 base::android::ScopedJavaGlobalRef<jobject> java_display); | |
| 30 | 29 |
| 31 // Must be deleted on the display thread. | 30 // Must be deleted on the display thread. |
| 32 ~JniDisplayHandler() override; | 31 ~JniDisplayHandler() override; |
| 33 | 32 |
| 33 base::android::ScopedJavaLocalRef<jobject> GetJavaDisplay(); |
| 34 |
| 34 void UpdateCursorShape(const protocol::CursorShapeInfo& cursor_shape); | 35 void UpdateCursorShape(const protocol::CursorShapeInfo& cursor_shape); |
| 35 | 36 |
| 36 // DisplayUpdaterFactory overrides (functions can be called on any thread). | 37 // DisplayUpdaterFactory overrides (functions can be called on any thread). |
| 37 std::unique_ptr<protocol::CursorShapeStub> CreateCursorShapeStub() override; | 38 std::unique_ptr<protocol::CursorShapeStub> CreateCursorShapeStub() override; |
| 38 std::unique_ptr<JniVideoRenderer> CreateVideoRenderer() override; | 39 std::unique_ptr<JniVideoRenderer> CreateVideoRenderer() override; |
| 39 | 40 |
| 40 // Creates a new Bitmap object to store a video frame. Can be called on any | 41 // Creates a new Bitmap object to store a video frame. Can be called on any |
| 41 // thread. | 42 // thread. |
| 42 static base::android::ScopedJavaLocalRef<jobject> NewBitmap(int width, | 43 static base::android::ScopedJavaLocalRef<jobject> NewBitmap(int width, |
| 43 int height); | 44 int height); |
| 44 | 45 |
| 45 // Updates video frame bitmap. |bitmap| must be an instance of | 46 // Updates video frame bitmap. |bitmap| must be an instance of |
| 46 // android.graphics.Bitmap. | 47 // android.graphics.Bitmap. |
| 47 void UpdateFrameBitmap(base::android::ScopedJavaGlobalRef<jobject> bitmap); | 48 void UpdateFrameBitmap(base::android::ScopedJavaGlobalRef<jobject> bitmap); |
| 48 | 49 |
| 49 // Draws the latest image buffer onto the canvas. | 50 // Draws the latest image buffer onto the canvas. |
| 50 void RedrawCanvas(); | 51 void RedrawCanvas(); |
| 51 | 52 |
| 52 static bool RegisterJni(JNIEnv* env); | 53 static bool RegisterJni(JNIEnv* env); |
| 53 | 54 |
| 54 // Deletes this object on display thread. Can be called on any thread. | |
| 55 void Destroy(JNIEnv* env, | |
| 56 const base::android::JavaParamRef<jobject>& caller); | |
| 57 | |
| 58 // Schedule redraw. Can be called on any thread. | 55 // Schedule redraw. Can be called on any thread. |
| 59 void ScheduleRedraw(JNIEnv* env, | 56 void ScheduleRedraw(JNIEnv* env, |
| 60 const base::android::JavaParamRef<jobject>& caller); | 57 const base::android::JavaParamRef<jobject>& caller); |
| 61 | 58 |
| 62 private: | 59 private: |
| 63 ChromotingJniRuntime* runtime_; | 60 ChromotingJniRuntime* runtime_; |
| 64 | 61 |
| 65 base::android::ScopedJavaGlobalRef<jobject> java_display_; | 62 base::android::ScopedJavaGlobalRef<jobject> java_display_; |
| 66 base::WeakPtrFactory<JniDisplayHandler> weak_factory_; | 63 base::WeakPtrFactory<JniDisplayHandler> weak_factory_; |
| 67 | 64 |
| 68 DISALLOW_COPY_AND_ASSIGN(JniDisplayHandler); | 65 DISALLOW_COPY_AND_ASSIGN(JniDisplayHandler); |
| 69 }; | 66 }; |
| 70 | 67 |
| 71 } // namespace remoting | 68 } // namespace remoting |
| 72 | 69 |
| 73 #endif // REMOTING_CLIENT_JNI_JNI_DISPLAY_HANDLER_H_ | 70 #endif // REMOTING_CLIENT_JNI_JNI_DISPLAY_HANDLER_H_ |
| OLD | NEW |