Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Unified Diff: remoting/host/chromoting_param_traits.cc

Issue 92473002: Use webrtc::MouseCursorMonitor for cursor shapes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed obsolete #include. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/chromoting_param_traits.h ('k') | remoting/host/client_session.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/chromoting_param_traits.cc
diff --git a/remoting/host/chromoting_param_traits.cc b/remoting/host/chromoting_param_traits.cc
index 8b10a7f764308bca6d501b4399a94be2f7891ea4..8050dc19859375fa76c4ae51da96b72739f3de03 100644
--- a/remoting/host/chromoting_param_traits.cc
+++ b/remoting/host/chromoting_param_traits.cc
@@ -5,6 +5,7 @@
#include "remoting/host/chromoting_param_traits.h"
#include "base/strings/stringprintf.h"
+#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
namespace IPC {
@@ -88,6 +89,72 @@ void ParamTraits<webrtc::DesktopRect>::Log(const webrtc::DesktopRect& p,
}
// static
+void ParamTraits<webrtc::MouseCursor>::Write(
+ Message* m,
+ const webrtc::MouseCursor& p) {
+ ParamTraits<webrtc::DesktopSize>::Write(m, p.image()->size());
+
+ // Data is serialized in such a way that size is exactly width * height *
+ // |kBytesPerPixel|.
+ std::string data;
+ uint8_t* current_row = p.image()->data();
+ for (int y = 0; y < p.image()->size().height(); ++y) {
+ data.append(current_row,
+ current_row + p.image()->size().width() *
+ webrtc::DesktopFrame::kBytesPerPixel);
+ current_row += p.image()->stride();
+ }
+ m->WriteData(reinterpret_cast<const char*>(p.image()->data()), data.size());
+
+ ParamTraits<webrtc::DesktopVector>::Write(m, p.hotspot());
+}
+
+// static
+bool ParamTraits<webrtc::MouseCursor>::Read(
+ const Message* m,
+ PickleIterator* iter,
+ webrtc::MouseCursor* r) {
+ webrtc::DesktopSize size;
+ if (!ParamTraits<webrtc::DesktopSize>::Read(m, iter, &size) ||
+ size.width() <= 0 || size.width() > (SHRT_MAX / 2) ||
+ size.height() <= 0 || size.height() > (SHRT_MAX / 2)) {
+ return false;
+ }
+
+ const int expected_length =
+ size.width() * size.height() * webrtc::DesktopFrame::kBytesPerPixel;
+
+ const char* data;
+ int data_length;
+ if (!m->ReadData(iter, &data, &data_length) ||
+ data_length != expected_length) {
+ return false;
+ }
+
+ webrtc::DesktopVector hotspot;
+ if (!ParamTraits<webrtc::DesktopVector>::Read(m, iter, &hotspot))
+ return false;
Cris Neckar 2014/01/23 20:16:32 In the constructor for MouseCursor there is an ass
Wez 2014/01/23 20:56:18 In general it's valid to have a hotspot outside a
Sergey Ulanov 2014/01/23 21:32:14 Neither the capturers nor the PPB_MouseCursor inte
+
+ webrtc::BasicDesktopFrame* image = new webrtc::BasicDesktopFrame(size);
+ memcpy(image->data(), data, data_length);
+
+ r->set_image(image);
+ r->set_hotspot(hotspot);
+ return true;
+}
+
+// static
+void ParamTraits<webrtc::MouseCursor>::Log(
+ const webrtc::MouseCursor& p,
+ std::string* l) {
+ l->append(base::StringPrintf(
+ "webrtc::DesktopRect{image(%d, %d), hotspot(%d, %d)}",
+ p.image()->size().width(), p.image()->size().height(),
+ p.hotspot().x(), p.hotspot().y()));
+}
+
+
+// static
void ParamTraits<remoting::ScreenResolution>::Write(
Message* m,
const remoting::ScreenResolution& p) {
« no previous file with comments | « remoting/host/chromoting_param_traits.h ('k') | remoting/host/client_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698