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