summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/host/BUILD.gn2
-rw-r--r--remoting/host/basic_desktop_environment.cc7
-rw-r--r--remoting/host/chromeos/aura_desktop_capturer.cc51
-rw-r--r--remoting/host/chromeos/mouse_cursor_monitor_aura.cc73
-rw-r--r--remoting/host/chromeos/mouse_cursor_monitor_aura.h15
-rw-r--r--remoting/host/chromeos/skia_bitmap_desktop_frame.cc38
-rw-r--r--remoting/host/chromeos/skia_bitmap_desktop_frame.h29
-rw-r--r--remoting/remoting_host.gypi2
-rw-r--r--remoting/remoting_host_srcs.gypi2
9 files changed, 145 insertions, 74 deletions
diff --git a/remoting/host/BUILD.gn b/remoting/host/BUILD.gn
index d46b14a..cd2318a 100644
--- a/remoting/host/BUILD.gn
+++ b/remoting/host/BUILD.gn
@@ -73,8 +73,6 @@ static_library("host") {
]
} else {
sources -= [
- "chromeos/mouse_cursor_monitor_aura.cc",
- "chromeos/mouse_cursor_monitor_aura.h",
"clipboard_x11.cc",
"input_injector_chromeos.cc",
"input_injector_chromeos.h",
diff --git a/remoting/host/basic_desktop_environment.cc b/remoting/host/basic_desktop_environment.cc
index 174248a..e7132f6 100644
--- a/remoting/host/basic_desktop_environment.cc
+++ b/remoting/host/basic_desktop_environment.cc
@@ -10,8 +10,6 @@
#include "remoting/host/audio_capturer.h"
#if defined(OS_CHROMEOS)
#include "remoting/host/chromeos/aura_desktop_capturer.h"
-#endif
-#if defined(OS_CHROMEOS) && defined(USE_OZONE)
#include "remoting/host/chromeos/mouse_cursor_monitor_aura.h"
#endif
#include "remoting/host/client_session_control.h"
@@ -48,9 +46,8 @@ scoped_ptr<ScreenControls> BasicDesktopEnvironment::CreateScreenControls() {
scoped_ptr<webrtc::MouseCursorMonitor>
BasicDesktopEnvironment::CreateMouseCursorMonitor() {
-#if defined(OS_CHROMEOS) && defined(USE_OZONE)
- return make_scoped_ptr(
- new MouseCursorMonitorAura(*desktop_capture_options_));
+#if defined(OS_CHROMEOS)
+ return make_scoped_ptr(new MouseCursorMonitorAura());
#else
return make_scoped_ptr(webrtc::MouseCursorMonitor::CreateForScreen(
*desktop_capture_options_, webrtc::kFullDesktopScreenId));
diff --git a/remoting/host/chromeos/aura_desktop_capturer.cc b/remoting/host/chromeos/aura_desktop_capturer.cc
index 386ccf2..28b5e03 100644
--- a/remoting/host/chromeos/aura_desktop_capturer.cc
+++ b/remoting/host/chromeos/aura_desktop_capturer.cc
@@ -7,8 +7,7 @@
#include "base/bind.h"
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
+#include "remoting/host/chromeos/skia_bitmap_desktop_frame.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
@@ -18,54 +17,6 @@
namespace remoting {
-namespace {
-
-// DesktopFrame implementation used by screen capture on ChromeOS.
-// Frame data is stored in a SkBitmap.
-class SkiaBitmapDesktopFrame : public webrtc::DesktopFrame {
- public:
- static SkiaBitmapDesktopFrame* Create(scoped_ptr<SkBitmap> bitmap);
- virtual ~SkiaBitmapDesktopFrame();
-
- private:
- SkiaBitmapDesktopFrame(webrtc::DesktopSize size,
- int stride,
- uint8_t* data,
- scoped_ptr<SkBitmap> bitmap);
-
- scoped_ptr<SkBitmap> bitmap_;
-
- DISALLOW_COPY_AND_ASSIGN(SkiaBitmapDesktopFrame);
-};
-
-// static
-SkiaBitmapDesktopFrame* SkiaBitmapDesktopFrame::Create(
- scoped_ptr<SkBitmap> bitmap) {
-
- webrtc::DesktopSize size(bitmap->width(), bitmap->height());
- DCHECK_EQ(kBGRA_8888_SkColorType, bitmap->info().colorType())
- << "DesktopFrame objects always hold RGBA data.";
-
- uint8_t* bitmap_data = reinterpret_cast<uint8_t*>(bitmap->getPixels());
-
- SkiaBitmapDesktopFrame* result = new SkiaBitmapDesktopFrame(
- size, bitmap->rowBytes(), bitmap_data, bitmap.Pass());
-
- return result;
-}
-
-SkiaBitmapDesktopFrame::SkiaBitmapDesktopFrame(webrtc::DesktopSize size,
- int stride,
- uint8_t* data,
- scoped_ptr<SkBitmap> bitmap)
- : DesktopFrame(size, stride, data, NULL), bitmap_(bitmap.Pass()) {
-}
-
-SkiaBitmapDesktopFrame::~SkiaBitmapDesktopFrame() {
-}
-
-} // namespace
-
AuraDesktopCapturer::AuraDesktopCapturer()
: callback_(NULL), desktop_window_(NULL), weak_factory_(this) {
}
diff --git a/remoting/host/chromeos/mouse_cursor_monitor_aura.cc b/remoting/host/chromeos/mouse_cursor_monitor_aura.cc
index 68b89a8..ad48f14 100644
--- a/remoting/host/chromeos/mouse_cursor_monitor_aura.cc
+++ b/remoting/host/chromeos/mouse_cursor_monitor_aura.cc
@@ -4,32 +4,85 @@
#include "remoting/host/chromeos/mouse_cursor_monitor_aura.h"
-#include "base/logging.h"
+#include "ash/shell.h"
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/location.h"
+#include "remoting/host/chromeos/skia_bitmap_desktop_frame.h"
+#include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h"
+#include "ui/aura/env.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_tree_host.h"
+#include "ui/base/cursor/cursors_aura.h"
namespace remoting {
-MouseCursorMonitorAura::MouseCursorMonitorAura(
- const webrtc::DesktopCaptureOptions& options)
+MouseCursorMonitorAura::MouseCursorMonitorAura()
: callback_(nullptr),
mode_(SHAPE_AND_POSITION) {
}
-MouseCursorMonitorAura::~MouseCursorMonitorAura() {
- NOTIMPLEMENTED();
-}
-
void MouseCursorMonitorAura::Init(Callback* callback, Mode mode) {
DCHECK(!callback_);
DCHECK(callback);
callback_ = callback;
mode_ = mode;
-
- NOTIMPLEMENTED();
}
void MouseCursorMonitorAura::Capture() {
- NOTIMPLEMENTED();
+ // Check if the cursor is different.
+ gfx::NativeCursor cursor =
+ ash::Shell::GetPrimaryRootWindow()->GetHost()->last_cursor();
+
+ if (cursor != last_cursor_) {
+ NotifyCursorChanged(cursor);
+ }
+
+ // Check if we need to update the location.
+ if (mode_ == SHAPE_AND_POSITION) {
+ gfx::Point position = aura::Env::GetInstance()->last_mouse_location();
+ if (position != last_mouse_location_) {
+ last_mouse_location_ = position;
+ callback_->OnMouseCursorPosition(
+ INSIDE, webrtc::DesktopVector(position.x(), position.y()));
+ }
+ }
+}
+
+void MouseCursorMonitorAura::NotifyCursorChanged(const ui::Cursor& cursor) {
+ scoped_ptr<SkBitmap> cursor_bitmap(new SkBitmap());
+ gfx::Point cursor_hotspot;
+ if (!ui::GetCursorBitmap(cursor, cursor_bitmap.get(), &cursor_hotspot)) {
+ LOG(ERROR) << "Failed to load bitmap for cursor type:"
+ << cursor.native_type();
+ return;
+ }
+
+ last_cursor_ = cursor;
+
+ // There is a bug (crbug.com/436993) in aura::GetCursorBitmap() such that it
+ // it would return a scale-factor-100 bitmap with a scale-factor-200 hotspot.
+ // This causes the hotspot to go out of range. As a result, we would need to
+ // manually downscale the hotspot.
+ float scale_factor = cursor.device_scale_factor();
+ cursor_hotspot.SetPoint(cursor_hotspot.x() / scale_factor,
+ cursor_hotspot.y() / scale_factor);
+
+ if (cursor_hotspot.x() >= cursor_bitmap->width() ||
+ cursor_hotspot.y() >= cursor_bitmap->height()) {
+ LOG(WARNING) << "Cursor hotspot is out of bounds for type: "
+ << cursor.native_type() << ". Setting to (0,0) instead";
+ cursor_hotspot.SetPoint(0, 0);
+ }
+
+ scoped_ptr<webrtc::DesktopFrame> image(
+ SkiaBitmapDesktopFrame::Create(cursor_bitmap.Pass()));
+ scoped_ptr<webrtc::MouseCursor> cursor_shape(new webrtc::MouseCursor(
+ image.release(),
+ webrtc::DesktopVector(cursor_hotspot.x(), cursor_hotspot.y())));
+
+ callback_->OnMouseCursor(cursor_shape.release());
}
} // namespace remoting
diff --git a/remoting/host/chromeos/mouse_cursor_monitor_aura.h b/remoting/host/chromeos/mouse_cursor_monitor_aura.h
index 687daf5..5176011 100644
--- a/remoting/host/chromeos/mouse_cursor_monitor_aura.h
+++ b/remoting/host/chromeos/mouse_cursor_monitor_aura.h
@@ -5,24 +5,29 @@
#ifndef REMOTING_HOST_CHROMEOS_MOUSE_CURSOR_MONITOR_AURA_H_
#define REMOTING_HOST_CHROMEOS_MOUSE_CURSOR_MONITOR_AURA_H_
-#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
#include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
+#include "ui/base/cursor/cursor.h"
+#include "ui/gfx/geometry/point.h"
namespace remoting {
-// A MouseCursorMonitor place holder implementation for Chrome OS with ozone.
-// TODO(kelvinp): Implement this (See crbug.com/431457).
+// Monitors changes in cursor shape and location. It can be constructed on any
+// thread but all public methods must be called on the capturer thread.
class MouseCursorMonitorAura : public webrtc::MouseCursorMonitor {
public:
- explicit MouseCursorMonitorAura(const webrtc::DesktopCaptureOptions& options);
- ~MouseCursorMonitorAura() override;
+ MouseCursorMonitorAura();
+ // webrtc::MouseCursorMonitor implementation.
void Init(Callback* callback, Mode mode) override;
void Capture() override;
private:
+ void NotifyCursorChanged(const ui::Cursor& cursor);
+
Callback* callback_;
Mode mode_;
+ ui::Cursor last_cursor_;
+ gfx::Point last_mouse_location_;
DISALLOW_COPY_AND_ASSIGN(MouseCursorMonitorAura);
};
diff --git a/remoting/host/chromeos/skia_bitmap_desktop_frame.cc b/remoting/host/chromeos/skia_bitmap_desktop_frame.cc
new file mode 100644
index 0000000..ed9b8ba
--- /dev/null
+++ b/remoting/host/chromeos/skia_bitmap_desktop_frame.cc
@@ -0,0 +1,38 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "remoting/host/chromeos/skia_bitmap_desktop_frame.h"
+
+namespace remoting {
+
+// static
+SkiaBitmapDesktopFrame* SkiaBitmapDesktopFrame::Create(
+ scoped_ptr<SkBitmap> bitmap) {
+
+ webrtc::DesktopSize size(bitmap->width(), bitmap->height());
+ DCHECK_EQ(kBGRA_8888_SkColorType, bitmap->info().colorType())
+ << "DesktopFrame objects always hold RGBA data.";
+
+ bitmap->lockPixels();
+ uint8_t* bitmap_data = reinterpret_cast<uint8_t*>(bitmap->getPixels());
+ bitmap->unlockPixels();
+
+ SkiaBitmapDesktopFrame* result = new SkiaBitmapDesktopFrame(
+ size, bitmap->rowBytes(), bitmap_data, bitmap.Pass());
+
+ return result;
+}
+
+SkiaBitmapDesktopFrame::SkiaBitmapDesktopFrame(webrtc::DesktopSize size,
+ int stride,
+ uint8_t* data,
+ scoped_ptr<SkBitmap> bitmap)
+ : DesktopFrame(size, stride, data, NULL), bitmap_(bitmap.Pass()) {
+}
+
+SkiaBitmapDesktopFrame::~SkiaBitmapDesktopFrame() {
+}
+
+} // namespace remoting \ No newline at end of file
diff --git a/remoting/host/chromeos/skia_bitmap_desktop_frame.h b/remoting/host/chromeos/skia_bitmap_desktop_frame.h
new file mode 100644
index 0000000..d2d9f7b
--- /dev/null
+++ b/remoting/host/chromeos/skia_bitmap_desktop_frame.h
@@ -0,0 +1,29 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/memory/scoped_ptr.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
+
+namespace remoting {
+
+// DesktopFrame implementation used by screen capture on ChromeOS.
+// Frame data is stored in a SkBitmap.
+class SkiaBitmapDesktopFrame : public webrtc::DesktopFrame {
+ public:
+ static SkiaBitmapDesktopFrame* Create(scoped_ptr<SkBitmap> bitmap);
+ virtual ~SkiaBitmapDesktopFrame();
+
+ private:
+ SkiaBitmapDesktopFrame(webrtc::DesktopSize size,
+ int stride,
+ uint8_t* data,
+ scoped_ptr<SkBitmap> bitmap);
+
+ scoped_ptr<SkBitmap> bitmap_;
+
+ DISALLOW_COPY_AND_ASSIGN(SkiaBitmapDesktopFrame);
+};
+
+} // namespace remoting
diff --git a/remoting/remoting_host.gypi b/remoting/remoting_host.gypi
index 8fbcdc8..436e6fe 100644
--- a/remoting/remoting_host.gypi
+++ b/remoting/remoting_host.gypi
@@ -121,8 +121,6 @@
'host/input_injector_chromeos.cc',
'host/input_injector_chromeos.h',
'host/local_input_monitor_chromeos.cc',
- 'host/chromeos/mouse_cursor_monitor_aura.cc',
- 'host/chromeos/mouse_cursor_monitor_aura.h',
],
}],
],
diff --git a/remoting/remoting_host_srcs.gypi b/remoting/remoting_host_srcs.gypi
index 871f10e..fabcc4e 100644
--- a/remoting/remoting_host_srcs.gypi
+++ b/remoting/remoting_host_srcs.gypi
@@ -30,6 +30,8 @@
'host/chromeos/message_box.h',
'host/chromeos/mouse_cursor_monitor_aura.cc',
'host/chromeos/mouse_cursor_monitor_aura.h',
+ 'host/chromeos/skia_bitmap_desktop_frame.cc',
+ 'host/chromeos/skia_bitmap_desktop_frame.h',
'host/chromium_port_allocator_factory.cc',
'host/chromium_port_allocator_factory.h',
'host/chromoting_host.cc',