| 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/proto/control.pb.h" |
| 14 |
| 15 namespace remoting { |
| 16 |
| 17 // Handles display operations. Must be called and deleted on the display thread |
| 18 // unless otherwise noted. |
| 19 class JniDisplayHandler { |
| 20 public: |
| 21 JniDisplayHandler(scoped_refptr<base::SingleThreadTaskRunner> display_runner, |
| 22 base::android::ScopedJavaGlobalRef<jobject> java_display); |
| 23 |
| 24 // Must be deleted on the display thread. |
| 25 ~JniDisplayHandler(); |
| 26 |
| 27 // Creates a new Bitmap object to store a video frame. Can be called on any |
| 28 // thread. |
| 29 static base::android::ScopedJavaLocalRef<jobject> NewBitmap(int width, |
| 30 int height); |
| 31 |
| 32 // Updates video frame bitmap. |bitmap| must be an instance of |
| 33 // android.graphics.Bitmap. |
| 34 void UpdateFrameBitmap(base::android::ScopedJavaGlobalRef<jobject> bitmap); |
| 35 |
| 36 // Updates cursor shape. |
| 37 void UpdateCursorShape(const protocol::CursorShapeInfo& cursor_shape); |
| 38 |
| 39 // Draws the latest image buffer onto the canvas. |
| 40 void RedrawCanvas(); |
| 41 |
| 42 // Returns a display thread weak pointer to the object. |
| 43 base::WeakPtr<JniDisplayHandler> GetWeakPtr(); |
| 44 |
| 45 static bool RegisterJni(JNIEnv* env); |
| 46 |
| 47 // Deletes this object on display thread. Can be called on any thread. |
| 48 void Destroy(JNIEnv* env, |
| 49 const base::android::JavaParamRef<jobject>& caller); |
| 50 |
| 51 // Schedule redraw. Can be called on any thread. |
| 52 void ScheduleRedraw(JNIEnv* env, |
| 53 const base::android::JavaParamRef<jobject>& caller); |
| 54 |
| 55 private: |
| 56 scoped_refptr<base::SingleThreadTaskRunner> display_runner_; |
| 57 |
| 58 base::android::ScopedJavaGlobalRef<jobject> java_display_; |
| 59 base::WeakPtrFactory<JniDisplayHandler> weak_factory_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(JniDisplayHandler); |
| 62 }; |
| 63 |
| 64 } // namespace remoting |
| 65 |
| 66 #endif // REMOTING_CLIENT_JNI_JNI_DISPLAY_HANDLER_H_ |
| OLD | NEW |