| Index: remoting/client/jni/jni_display_handler.cc
|
| diff --git a/remoting/client/jni/jni_display_handler.cc b/remoting/client/jni/jni_display_handler.cc
|
| index e139e7bc3ab7578af1345d9402a27e9e3a595c42..cd51e52a2d415883374cfc676f06e23e893d4c13 100644
|
| --- a/remoting/client/jni/jni_display_handler.cc
|
| +++ b/remoting/client/jni/jni_display_handler.cc
|
| @@ -10,6 +10,7 @@
|
| #include "base/memory/ptr_util.h"
|
| #include "base/stl_util.h"
|
| #include "jni/Display_jni.h"
|
| +#include "remoting/client/cursor_shape_stub_proxy.h"
|
| #include "remoting/client/jni/chromoting_jni_runtime.h"
|
| #include "remoting/client/jni/jni_client.h"
|
| #include "remoting/client/jni/jni_video_renderer.h"
|
| @@ -24,33 +25,6 @@ const int kBytesPerPixel = 4;
|
|
|
| namespace remoting {
|
|
|
| -// CursorShapeStub with a lifetime separated from JniDisplayHandler.
|
| -class DisplayCursorShapeStub : public protocol::CursorShapeStub {
|
| - public:
|
| - DisplayCursorShapeStub(
|
| - base::WeakPtr<JniDisplayHandler> display,
|
| - scoped_refptr<base::SingleThreadTaskRunner> task_runner);
|
| - void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override;
|
| - private:
|
| - base::WeakPtr<JniDisplayHandler> display_handler_;
|
| - scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
| -};
|
| -
|
| -DisplayCursorShapeStub::DisplayCursorShapeStub(
|
| - base::WeakPtr<JniDisplayHandler> display,
|
| - scoped_refptr<base::SingleThreadTaskRunner> task_runner) :
|
| - display_handler_(display),
|
| - task_runner_(task_runner) {
|
| -}
|
| -
|
| -void DisplayCursorShapeStub::SetCursorShape(
|
| - const protocol::CursorShapeInfo& cursor_shape) {
|
| - task_runner_->PostTask(FROM_HERE,
|
| - base::Bind(&JniDisplayHandler::UpdateCursorShape,
|
| - display_handler_,
|
| - cursor_shape));
|
| -}
|
| -
|
| // JniDisplayHandler definitions.
|
| JniDisplayHandler::JniDisplayHandler(ChromotingJniRuntime* runtime)
|
| : runtime_(runtime),
|
| @@ -73,30 +47,10 @@ void JniDisplayHandler::InitializeClient(
|
| java_display_.obj(), java_client.obj());
|
| }
|
|
|
| -void JniDisplayHandler::UpdateCursorShape(
|
| - const protocol::CursorShapeInfo& cursor_shape) {
|
| - DCHECK(runtime_->display_task_runner()->BelongsToCurrentThread());
|
| -
|
| - // const_cast<> is safe as long as the Java updateCursorShape() method copies
|
| - // the data out of the buffer without mutating it, and doesn't keep any
|
| - // reference to the buffer afterwards. Unfortunately, there seems to be no way
|
| - // to create a read-only ByteBuffer from a pointer-to-const.
|
| - char* data = string_as_array(const_cast<std::string*>(&cursor_shape.data()));
|
| - int cursor_total_bytes =
|
| - cursor_shape.width() * cursor_shape.height() * kBytesPerPixel;
|
| -
|
| - JNIEnv* env = base::android::AttachCurrentThread();
|
| - base::android::ScopedJavaLocalRef<jobject> buffer(
|
| - env, env->NewDirectByteBuffer(data, cursor_total_bytes));
|
| - Java_Display_updateCursorShape(
|
| - env, java_display_.obj(), cursor_shape.width(), cursor_shape.height(),
|
| - cursor_shape.hotspot_x(), cursor_shape.hotspot_y(), buffer.obj());
|
| -}
|
| -
|
| std::unique_ptr<protocol::CursorShapeStub>
|
| JniDisplayHandler::CreateCursorShapeStub() {
|
| - return base::WrapUnique(
|
| - new DisplayCursorShapeStub(weak_ptr_, runtime_->display_task_runner()));
|
| + return base::WrapUnique(new CursorShapeStubProxy(
|
| + weak_ptr_, runtime_->display_task_runner()));
|
| }
|
|
|
| std::unique_ptr<protocol::VideoRenderer>
|
| @@ -140,4 +94,24 @@ void JniDisplayHandler::ScheduleRedraw(
|
| FROM_HERE, base::Bind(&JniDisplayHandler::RedrawCanvas, weak_ptr_));
|
| }
|
|
|
| +void JniDisplayHandler::SetCursorShape(
|
| + const protocol::CursorShapeInfo& cursor_shape) {
|
| + DCHECK(runtime_->display_task_runner()->BelongsToCurrentThread());
|
| +
|
| + // const_cast<> is safe as long as the Java updateCursorShape() method copies
|
| + // the data out of the buffer without mutating it, and doesn't keep any
|
| + // reference to the buffer afterwards. Unfortunately, there seems to be no way
|
| + // to create a read-only ByteBuffer from a pointer-to-const.
|
| + char* data = string_as_array(const_cast<std::string*>(&cursor_shape.data()));
|
| + int cursor_total_bytes =
|
| + cursor_shape.width() * cursor_shape.height() * kBytesPerPixel;
|
| +
|
| + JNIEnv* env = base::android::AttachCurrentThread();
|
| + base::android::ScopedJavaLocalRef<jobject> buffer(
|
| + env, env->NewDirectByteBuffer(data, cursor_total_bytes));
|
| + Java_Display_updateCursorShape(
|
| + env, java_display_.obj(), cursor_shape.width(), cursor_shape.height(),
|
| + cursor_shape.hotspot_x(), cursor_shape.hotspot_y(), buffer.obj());
|
| +}
|
| +
|
| } // namespace remoting
|
|
|