| 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 #include "remoting/client/jni/jni_display_handler.h" | 5 #include "remoting/client/jni/jni_display_handler.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 task_runner_->PostTask(FROM_HERE, | 48 task_runner_->PostTask(FROM_HERE, |
| 49 base::Bind(&JniDisplayHandler::UpdateCursorShape, | 49 base::Bind(&JniDisplayHandler::UpdateCursorShape, |
| 50 display_handler_, | 50 display_handler_, |
| 51 cursor_shape)); | 51 cursor_shape)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // JniDisplayHandler definitions. | 54 // JniDisplayHandler definitions. |
| 55 JniDisplayHandler::JniDisplayHandler(ChromotingJniRuntime* runtime) | 55 JniDisplayHandler::JniDisplayHandler(ChromotingJniRuntime* runtime) |
| 56 : runtime_(runtime), | 56 : runtime_(runtime), |
| 57 weak_factory_(this) { | 57 weak_factory_(this) { |
| 58 weak_ptr_ = weak_factory_.GetWeakPtr(); |
| 58 JNIEnv* env = base::android::AttachCurrentThread(); | 59 JNIEnv* env = base::android::AttachCurrentThread(); |
| 59 java_display_.Reset(Java_Display_createJavaDisplayObject( | 60 java_display_.Reset(Java_Display_createJavaDisplayObject( |
| 60 env, reinterpret_cast<intptr_t>(this))); | 61 env, reinterpret_cast<intptr_t>(this))); |
| 61 } | 62 } |
| 62 | 63 |
| 63 JniDisplayHandler::~JniDisplayHandler() { | 64 JniDisplayHandler::~JniDisplayHandler() { |
| 64 DCHECK(runtime_->display_task_runner()->BelongsToCurrentThread()); | 65 DCHECK(runtime_->display_task_runner()->BelongsToCurrentThread()); |
| 65 Java_Display_invalidate(base::android::AttachCurrentThread(), | 66 Java_Display_invalidate(base::android::AttachCurrentThread(), |
| 66 java_display_.obj()); | 67 java_display_.obj()); |
| 67 } | 68 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 88 base::android::ScopedJavaLocalRef<jobject> buffer( | 89 base::android::ScopedJavaLocalRef<jobject> buffer( |
| 89 env, env->NewDirectByteBuffer(data, cursor_total_bytes)); | 90 env, env->NewDirectByteBuffer(data, cursor_total_bytes)); |
| 90 Java_Display_updateCursorShape( | 91 Java_Display_updateCursorShape( |
| 91 env, java_display_.obj(), cursor_shape.width(), cursor_shape.height(), | 92 env, java_display_.obj(), cursor_shape.width(), cursor_shape.height(), |
| 92 cursor_shape.hotspot_x(), cursor_shape.hotspot_y(), buffer.obj()); | 93 cursor_shape.hotspot_x(), cursor_shape.hotspot_y(), buffer.obj()); |
| 93 } | 94 } |
| 94 | 95 |
| 95 std::unique_ptr<protocol::CursorShapeStub> | 96 std::unique_ptr<protocol::CursorShapeStub> |
| 96 JniDisplayHandler::CreateCursorShapeStub() { | 97 JniDisplayHandler::CreateCursorShapeStub() { |
| 97 return base::WrapUnique( | 98 return base::WrapUnique( |
| 98 new DisplayCursorShapeStub(weak_factory_.GetWeakPtr(), | 99 new DisplayCursorShapeStub(weak_ptr_, runtime_->display_task_runner())); |
| 99 runtime_->display_task_runner())); | |
| 100 } | 100 } |
| 101 | 101 |
| 102 std::unique_ptr<protocol::VideoRenderer> | 102 std::unique_ptr<protocol::VideoRenderer> |
| 103 JniDisplayHandler::CreateVideoRenderer() { | 103 JniDisplayHandler::CreateVideoRenderer() { |
| 104 return base::WrapUnique( | 104 return base::WrapUnique( |
| 105 new JniVideoRenderer(runtime_, weak_factory_.GetWeakPtr())); | 105 new JniVideoRenderer(runtime_, weak_ptr_)); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // static | 108 // static |
| 109 base::android::ScopedJavaLocalRef<jobject> JniDisplayHandler::NewBitmap( | 109 base::android::ScopedJavaLocalRef<jobject> JniDisplayHandler::NewBitmap( |
| 110 int width, | 110 int width, |
| 111 int height) { | 111 int height) { |
| 112 JNIEnv* env = base::android::AttachCurrentThread(); | 112 JNIEnv* env = base::android::AttachCurrentThread(); |
| 113 return Java_Display_newBitmap(env, width, height); | 113 return Java_Display_newBitmap(env, width, height); |
| 114 } | 114 } |
| 115 | 115 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 130 | 130 |
| 131 // static | 131 // static |
| 132 bool JniDisplayHandler::RegisterJni(JNIEnv* env) { | 132 bool JniDisplayHandler::RegisterJni(JNIEnv* env) { |
| 133 return RegisterNativesImpl(env); | 133 return RegisterNativesImpl(env); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void JniDisplayHandler::ScheduleRedraw( | 136 void JniDisplayHandler::ScheduleRedraw( |
| 137 JNIEnv* env, | 137 JNIEnv* env, |
| 138 const base::android::JavaParamRef<jobject>& caller) { | 138 const base::android::JavaParamRef<jobject>& caller) { |
| 139 runtime_->display_task_runner()->PostTask( | 139 runtime_->display_task_runner()->PostTask( |
| 140 FROM_HERE, base::Bind(&JniDisplayHandler::RedrawCanvas, | 140 FROM_HERE, base::Bind(&JniDisplayHandler::RedrawCanvas, weak_ptr_)); |
| 141 weak_factory_.GetWeakPtr())); | |
| 142 } | 141 } |
| 143 | 142 |
| 144 } // namespace remoting | 143 } // namespace remoting |
| OLD | NEW |