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

Side by Side Diff: trunk/src/remoting/protocol/mouse_input_filter.cc

Issue 24217003: Revert 224101 "Remove dependency on Skia from chromoting client." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/protocol/mouse_input_filter.h" 5 #include "remoting/protocol/mouse_input_filter.h"
6 6
7 #include "remoting/proto/event.pb.h" 7 #include "remoting/proto/event.pb.h"
8 8
9 namespace remoting { 9 namespace remoting {
10 namespace protocol { 10 namespace protocol {
11 11
12 MouseInputFilter::MouseInputFilter() { 12 MouseInputFilter::MouseInputFilter() {
13 } 13 }
14 14
15 MouseInputFilter::MouseInputFilter(InputStub* input_stub) 15 MouseInputFilter::MouseInputFilter(InputStub* input_stub)
16 : InputFilter(input_stub) { 16 : InputFilter(input_stub) {
17 input_max_.setEmpty();
18 output_max_.setEmpty();
17 } 19 }
18 20
19 MouseInputFilter::~MouseInputFilter() { 21 MouseInputFilter::~MouseInputFilter() {
20 } 22 }
21 23
22 void MouseInputFilter::InjectMouseEvent(const MouseEvent& event) { 24 void MouseInputFilter::InjectMouseEvent(const MouseEvent& event) {
23 if (input_max_.is_empty() || output_max_.is_empty()) 25 if (input_max_.isEmpty() || output_max_.isEmpty())
24 return; 26 return;
25 27
26 // We scale based on the maximum input & output coordinates, rather than the 28 // We scale based on the maximum input & output coordinates, rather than the
27 // input and output sizes, so that it's possible to reach the edge of the 29 // input and output sizes, so that it's possible to reach the edge of the
28 // output when up-scaling. We also take care to round up or down correctly, 30 // output when up-scaling. We also take care to round up or down correctly,
29 // which is important when down-scaling. 31 // which is important when down-scaling.
30 MouseEvent out_event(event); 32 MouseEvent out_event(event);
31 if (out_event.has_x()) { 33 if (out_event.has_x()) {
32 int x = out_event.x() * output_max_.width(); 34 int x = out_event.x() * output_max_.width();
33 x = (x + input_max_.width() / 2) / input_max_.width(); 35 x = (x + input_max_.width() / 2) / input_max_.width();
34 out_event.set_x(std::max(0, std::min(output_max_.width(), x))); 36 out_event.set_x(std::max(0, std::min(output_max_.width(), x)));
35 } 37 }
36 if (out_event.has_y()) { 38 if (out_event.has_y()) {
37 int y = out_event.y() * output_max_.height(); 39 int y = out_event.y() * output_max_.height();
38 y = (y + input_max_.height() / 2) / input_max_.height(); 40 y = (y + input_max_.height() / 2) / input_max_.height();
39 out_event.set_y(std::max(0, std::min(output_max_.height(), y))); 41 out_event.set_y(std::max(0, std::min(output_max_.height(), y)));
40 } 42 }
41 43
42 InputFilter::InjectMouseEvent(out_event); 44 InputFilter::InjectMouseEvent(out_event);
43 } 45 }
44 46
45 void MouseInputFilter::set_input_size(const webrtc::DesktopSize& size) { 47 void MouseInputFilter::set_input_size(const SkISize& size) {
46 input_max_.set(size.width() - 1, size.height() - 1); 48 input_max_ = SkISize::Make(size.width() - 1, size.height() - 1);
47 } 49 }
48 50
49 void MouseInputFilter::set_output_size(const webrtc::DesktopSize& size) { 51 void MouseInputFilter::set_output_size(const SkISize& size) {
50 output_max_.set(size.width() - 1, size.height() - 1); 52 output_max_ = SkISize::Make(size.width() - 1, size.height() - 1);
51 } 53 }
52 54
53 } // namespace protocol 55 } // namespace protocol
54 } // namespace remoting 56 } // namespace remoting
OLDNEW
« no previous file with comments | « trunk/src/remoting/protocol/mouse_input_filter.h ('k') | trunk/src/remoting/protocol/mouse_input_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698