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

Side by Side Diff: trunk/src/remoting/host/chromoting_param_traits.cc

Issue 151163002: Revert 248045 "Use webrtc::MouseCursorMonitor for cursor shapes" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/host/chromoting_param_traits.h" 5 #include "remoting/host/chromoting_param_traits.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
9 8
10 namespace IPC { 9 namespace IPC {
11 10
12 // static 11 // static
13 void ParamTraits<webrtc::DesktopVector>::Write(Message* m, 12 void ParamTraits<webrtc::DesktopVector>::Write(Message* m,
14 const webrtc::DesktopVector& p) { 13 const webrtc::DesktopVector& p) {
15 m->WriteInt(p.x()); 14 m->WriteInt(p.x());
16 m->WriteInt(p.y()); 15 m->WriteInt(p.y());
17 } 16 }
18 17
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 81 }
83 82
84 // static 83 // static
85 void ParamTraits<webrtc::DesktopRect>::Log(const webrtc::DesktopRect& p, 84 void ParamTraits<webrtc::DesktopRect>::Log(const webrtc::DesktopRect& p,
86 std::string* l) { 85 std::string* l) {
87 l->append(base::StringPrintf("webrtc::DesktopRect(%d, %d, %d, %d)", 86 l->append(base::StringPrintf("webrtc::DesktopRect(%d, %d, %d, %d)",
88 p.left(), p.top(), p.right(), p.bottom())); 87 p.left(), p.top(), p.right(), p.bottom()));
89 } 88 }
90 89
91 // static 90 // static
92 void ParamTraits<webrtc::MouseCursor>::Write(
93 Message* m,
94 const webrtc::MouseCursor& p) {
95 ParamTraits<webrtc::DesktopSize>::Write(m, p.image()->size());
96
97 // Data is serialized in such a way that size is exactly width * height *
98 // |kBytesPerPixel|.
99 std::string data;
100 uint8_t* current_row = p.image()->data();
101 for (int y = 0; y < p.image()->size().height(); ++y) {
102 data.append(current_row,
103 current_row + p.image()->size().width() *
104 webrtc::DesktopFrame::kBytesPerPixel);
105 current_row += p.image()->stride();
106 }
107 m->WriteData(reinterpret_cast<const char*>(p.image()->data()), data.size());
108
109 ParamTraits<webrtc::DesktopVector>::Write(m, p.hotspot());
110 }
111
112 // static
113 bool ParamTraits<webrtc::MouseCursor>::Read(
114 const Message* m,
115 PickleIterator* iter,
116 webrtc::MouseCursor* r) {
117 webrtc::DesktopSize size;
118 if (!ParamTraits<webrtc::DesktopSize>::Read(m, iter, &size) ||
119 size.width() <= 0 || size.width() > (SHRT_MAX / 2) ||
120 size.height() <= 0 || size.height() > (SHRT_MAX / 2)) {
121 return false;
122 }
123
124 const int expected_length =
125 size.width() * size.height() * webrtc::DesktopFrame::kBytesPerPixel;
126
127 const char* data;
128 int data_length;
129 if (!m->ReadData(iter, &data, &data_length) ||
130 data_length != expected_length) {
131 return false;
132 }
133
134 webrtc::DesktopVector hotspot;
135 if (!ParamTraits<webrtc::DesktopVector>::Read(m, iter, &hotspot))
136 return false;
137
138 webrtc::BasicDesktopFrame* image = new webrtc::BasicDesktopFrame(size);
139 memcpy(image->data(), data, data_length);
140
141 r->set_image(image);
142 r->set_hotspot(hotspot);
143 return true;
144 }
145
146 // static
147 void ParamTraits<webrtc::MouseCursor>::Log(
148 const webrtc::MouseCursor& p,
149 std::string* l) {
150 l->append(base::StringPrintf(
151 "webrtc::DesktopRect{image(%d, %d), hotspot(%d, %d)}",
152 p.image()->size().width(), p.image()->size().height(),
153 p.hotspot().x(), p.hotspot().y()));
154 }
155
156
157 // static
158 void ParamTraits<remoting::ScreenResolution>::Write( 91 void ParamTraits<remoting::ScreenResolution>::Write(
159 Message* m, 92 Message* m,
160 const remoting::ScreenResolution& p) { 93 const remoting::ScreenResolution& p) {
161 ParamTraits<webrtc::DesktopSize>::Write(m, p.dimensions()); 94 ParamTraits<webrtc::DesktopSize>::Write(m, p.dimensions());
162 ParamTraits<webrtc::DesktopVector>::Write(m, p.dpi()); 95 ParamTraits<webrtc::DesktopVector>::Write(m, p.dpi());
163 } 96 }
164 97
165 // static 98 // static
166 bool ParamTraits<remoting::ScreenResolution>::Read( 99 bool ParamTraits<remoting::ScreenResolution>::Read(
167 const Message* m, 100 const Message* m,
(...skipping 17 matching lines...) Expand all
185 void ParamTraits<remoting::ScreenResolution>::Log( 118 void ParamTraits<remoting::ScreenResolution>::Log(
186 const remoting::ScreenResolution& p, 119 const remoting::ScreenResolution& p,
187 std::string* l) { 120 std::string* l) {
188 l->append(base::StringPrintf("webrtc::ScreenResolution(%d, %d, %d, %d)", 121 l->append(base::StringPrintf("webrtc::ScreenResolution(%d, %d, %d, %d)",
189 p.dimensions().width(), p.dimensions().height(), 122 p.dimensions().width(), p.dimensions().height(),
190 p.dpi().x(), p.dpi().y())); 123 p.dpi().x(), p.dpi().y()));
191 } 124 }
192 125
193 } // namespace IPC 126 } // namespace IPC
194 127
OLDNEW
« no previous file with comments | « trunk/src/remoting/host/chromoting_param_traits.h ('k') | trunk/src/remoting/host/client_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698