summaryrefslogtreecommitdiffstats
path: root/remoting/host
diff options
context:
space:
mode:
authorsimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 11:51:08 +0000
committersimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 11:51:08 +0000
commit467aca55f38b251b636f638d61408d420d570c11 (patch)
treefda9063580b467a4a21fd8f1a1bd317991ce1a0b /remoting/host
parentab0fb9834c6f3b3ee9d86a8c5a6ba3a5b69b2ac8 (diff)
downloadchromium_src-467aca55f38b251b636f638d61408d420d570c11.zip
chromium_src-467aca55f38b251b636f638d61408d420d570c11.tar.gz
chromium_src-467aca55f38b251b636f638d61408d420d570c11.tar.bz2
Tidy up after CL 6573005.
Replace width/height pairs with gfx::Size objects. Avoid overloading Capturer::InvalidateFullScreen. BUG=none TEST=none Review URL: http://codereview.chromium.org/6635039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r--remoting/host/capturer.cc14
-rw-r--r--remoting/host/capturer.h13
-rw-r--r--remoting/host/capturer_fake.cc20
-rw-r--r--remoting/host/capturer_fake.h3
-rw-r--r--remoting/host/capturer_fake_ascii.cc6
-rw-r--r--remoting/host/capturer_gdi.cc7
-rw-r--r--remoting/host/capturer_linux.cc6
-rw-r--r--remoting/host/capturer_mac.cc2
-rw-r--r--remoting/host/capturer_mac_unittest.cc4
-rw-r--r--remoting/host/event_executor_mac.cc5
-rw-r--r--remoting/host/event_executor_win.cc9
-rw-r--r--remoting/host/screen_recorder_unittest.cc10
12 files changed, 44 insertions, 55 deletions
diff --git a/remoting/host/capturer.cc b/remoting/host/capturer.cc
index fe9cb30..a138c05 100644
--- a/remoting/host/capturer.cc
+++ b/remoting/host/capturer.cc
@@ -14,8 +14,7 @@ Capturer::Capturer(MessageLoop* message_loop)
: pixel_format_(media::VideoFrame::INVALID),
current_buffer_(0),
message_loop_(message_loop),
- width_most_recent_(0),
- height_most_recent_(0) {
+ size_most_recent_(0, 0) {
}
Capturer::~Capturer() {
@@ -42,15 +41,15 @@ void Capturer::InvalidateRects(const InvalidRects& inval_rects) {
}
}
-void Capturer::InvalidateFullScreen(int width, int height) {
+void Capturer::InvalidateScreen(const gfx::Size& size) {
base::AutoLock auto_inval_rects_lock(inval_rects_lock_);
inval_rects_.clear();
- inval_rects_.insert(gfx::Rect(0, 0, width, height));
+ inval_rects_.insert(gfx::Rect(0, 0, size.width(), size.height()));
}
void Capturer::InvalidateFullScreen() {
- if (width_most_recent_ && height_most_recent_)
- InvalidateFullScreen(width_most_recent_, height_most_recent_);
+ if (size_most_recent_ != gfx::Size(0, 0))
+ InvalidateScreen(size_most_recent_);
}
void Capturer::CaptureInvalidRects(CaptureCompletedCallback* callback) {
@@ -75,8 +74,7 @@ void Capturer::FinishCapture(scoped_refptr<CaptureData> data,
// Select the next buffer to be the current buffer.
current_buffer_ = (current_buffer_ + 1) % kNumBuffers;
- width_most_recent_ = data->width();
- height_most_recent_ = data->height();
+ size_most_recent_ = data->size();
callback->Run(data);
delete callback;
diff --git a/remoting/host/capturer.h b/remoting/host/capturer.h
index 8c4216e..3444bcc 100644
--- a/remoting/host/capturer.h
+++ b/remoting/host/capturer.h
@@ -62,8 +62,7 @@ class Capturer {
void InvalidateRects(const InvalidRects& inval_rects);
// Invalidate the entire screen, of a given size.
- // TODO(hclam): No overload function!
- void InvalidateFullScreen(int width, int height);
+ void InvalidateScreen(const gfx::Size& size);
// Invalidate the entire screen, using the size of the most recently
// captured screen.
@@ -84,9 +83,8 @@ class Capturer {
// method is called.
virtual void CaptureInvalidRects(CaptureCompletedCallback* callback);
- // Get the width/height of the most recently captured screen.
- int width_most_recent() { return width_most_recent_; }
- int height_most_recent() { return height_most_recent_; }
+ // Get the size of the most recently captured screen.
+ const gfx::Size& size_most_recent() const { return size_most_recent_; }
protected:
explicit Capturer(MessageLoop* message_loop);
@@ -142,9 +140,8 @@ class Capturer {
// A lock protecting |inval_rects_| across threads.
base::Lock inval_rects_lock_;
- // The width and height of the most recently captured screen.
- int width_most_recent_;
- int height_most_recent_;
+ // The size of the most recently captured screen.
+ gfx::Size size_most_recent_;
};
} // namespace remoting
diff --git a/remoting/host/capturer_fake.cc b/remoting/host/capturer_fake.cc
index a574457..4db598e 100644
--- a/remoting/host/capturer_fake.cc
+++ b/remoting/host/capturer_fake.cc
@@ -38,13 +38,12 @@ CapturerFake::~CapturerFake() {
}
void CapturerFake::ScreenConfigurationChanged() {
- width_ = kWidth;
- height_ = kHeight;
- bytes_per_row_ = width_ * kBytesPerPixel;
+ size_ = gfx::Size(kWidth, kHeight);
+ bytes_per_row_ = size_.width() * kBytesPerPixel;
pixel_format_ = media::VideoFrame::RGB32;
// Create memory for the buffers.
- int buffer_size = height_ * bytes_per_row_;
+ int buffer_size = size_.height() * bytes_per_row_;
for (int i = 0; i < kNumBuffers; i++) {
buffers_[i].reset(new uint8[buffer_size]);
}
@@ -52,7 +51,7 @@ void CapturerFake::ScreenConfigurationChanged() {
void CapturerFake::CalculateInvalidRects() {
GenerateImage();
- InvalidateFullScreen(width_, height_);
+ InvalidateScreen(size_);
}
void CapturerFake::CaptureRects(const InvalidRects& rects,
@@ -62,8 +61,7 @@ void CapturerFake::CaptureRects(const InvalidRects& rects,
planes.strides[0] = bytes_per_row_;
scoped_refptr<CaptureData> capture_data(new CaptureData(planes,
- width_,
- height_,
+ size_,
pixel_format_));
capture_data->mutable_dirty_rects() = rects;
FinishCapture(capture_data, callback);
@@ -71,17 +69,17 @@ void CapturerFake::CaptureRects(const InvalidRects& rects,
void CapturerFake::GenerateImage() {
memset(buffers_[current_buffer_].get(), 0xff,
- width_ * height_ * kBytesPerPixel);
+ size_.width() * size_.height() * kBytesPerPixel);
uint8* row = buffers_[current_buffer_].get() +
- (box_pos_y_ * width_ + box_pos_x_) * kBytesPerPixel;
+ (box_pos_y_ * size_.width() + box_pos_x_) * kBytesPerPixel;
box_pos_x_ += box_speed_x_;
- if (box_pos_x_ + kBoxWidth >= width_ || box_pos_x_ == 0)
+ if (box_pos_x_ + kBoxWidth >= size_.width() || box_pos_x_ == 0)
box_speed_x_ = -box_speed_x_;
box_pos_y_ += box_speed_y_;
- if (box_pos_y_ + kBoxHeight >= height_ || box_pos_y_ == 0)
+ if (box_pos_y_ + kBoxHeight >= size_.height() || box_pos_y_ == 0)
box_speed_y_ = -box_speed_y_;
// Draw rectangle with the following colors in it's corners:
diff --git a/remoting/host/capturer_fake.h b/remoting/host/capturer_fake.h
index 420d30e..97a7b74e 100644
--- a/remoting/host/capturer_fake.h
+++ b/remoting/host/capturer_fake.h
@@ -29,8 +29,7 @@ class CapturerFake : public Capturer {
// Generates an image in the front buffer.
void GenerateImage();
- int width_;
- int height_;
+ gfx::Size size_;
int bytes_per_row_;
int box_pos_x_;
int box_pos_y_;
diff --git a/remoting/host/capturer_fake_ascii.cc b/remoting/host/capturer_fake_ascii.cc
index 8ea73c4..60656c0 100644
--- a/remoting/host/capturer_fake_ascii.cc
+++ b/remoting/host/capturer_fake_ascii.cc
@@ -45,10 +45,8 @@ void CapturerFakeAscii::CaptureRects(const InvalidRects& rects,
DataPlanes planes;
planes.data[0] = buffers_[current_buffer_].get();
planes.strides[0] = bytes_per_row_;
- scoped_refptr<CaptureData> capture_data(new CaptureData(planes,
- width_,
- height_,
- pixel_format_));
+ scoped_refptr<CaptureData> capture_data(new CaptureData(
+ planes, gfx::Size(width_, height_), pixel_format_));
FinishCapture(capture_data, callback);
}
diff --git a/remoting/host/capturer_gdi.cc b/remoting/host/capturer_gdi.cc
index 36c8945..a45aef4 100644
--- a/remoting/host/capturer_gdi.cc
+++ b/remoting/host/capturer_gdi.cc
@@ -121,7 +121,7 @@ void CapturerGdi::CalculateInvalidRects() {
capture_fullscreen_ = true;
if (capture_fullscreen_) {
- InvalidateFullScreen(current.size.width(), current.size.height());
+ InvalidateScreen(current.size);
capture_fullscreen_ = false;
return;
}
@@ -137,7 +137,7 @@ void CapturerGdi::CalculateInvalidRects() {
if ((current.size != prev.size) ||
(current.bytes_per_pixel != prev.bytes_per_pixel) ||
(current.bytes_per_row != prev.bytes_per_row)) {
- InvalidateFullScreen(current.size.width(), current.size.height());
+ InvalidateScreen(current.size);
return;
}
@@ -166,8 +166,7 @@ void CapturerGdi::CaptureRects(const InvalidRects& rects,
planes.strides[0] = buffer.bytes_per_row;
scoped_refptr<CaptureData> data(new CaptureData(planes,
- buffer.size.width(),
- buffer.size.height(),
+ buffer.size,
pixel_format_));
data->mutable_dirty_rects() = rects;
diff --git a/remoting/host/capturer_linux.cc b/remoting/host/capturer_linux.cc
index d37f0ab..a168358 100644
--- a/remoting/host/capturer_linux.cc
+++ b/remoting/host/capturer_linux.cc
@@ -235,7 +235,7 @@ void CapturerLinuxPimpl::CalculateInvalidRects() {
if (capture_fullscreen_) {
// TODO(hclam): Check the new dimension again.
- capturer_->InvalidateFullScreen(width_, height_);
+ capturer_->InvalidateScreen(gfx::Size(width_, height_));
capture_fullscreen_ = false;
} else {
capturer_->InvalidateRects(invalid_rects);
@@ -250,8 +250,8 @@ void CapturerLinuxPimpl::CaptureRects(
planes.data[0] = buffer;
planes.strides[0] = stride_;
- scoped_refptr<CaptureData> capture_data(
- new CaptureData(planes, width_, height_, media::VideoFrame::RGB32));
+ scoped_refptr<CaptureData> capture_data(new CaptureData(
+ planes, gfx::Size(width_, height_), media::VideoFrame::RGB32));
// Synchronize the current buffer with the last one since we do not capture
// the entire desktop. Note that encoder may be reading from the previous
diff --git a/remoting/host/capturer_mac.cc b/remoting/host/capturer_mac.cc
index 947c4e5..b95b545 100644
--- a/remoting/host/capturer_mac.cc
+++ b/remoting/host/capturer_mac.cc
@@ -115,7 +115,7 @@ void CapturerMac::CaptureRects(const InvalidRects& rects,
planes.strides[0] = bytes_per_row_;
scoped_refptr<CaptureData> data(
- new CaptureData(planes, width_, height_, pixel_format()));
+ new CaptureData(planes, gfx::Size(width_, height_), pixel_format()));
data->mutable_dirty_rects() = rects;
FinishCapture(data, callback);
}
diff --git a/remoting/host/capturer_mac_unittest.cc b/remoting/host/capturer_mac_unittest.cc
index 02db8da..b484b97 100644
--- a/remoting/host/capturer_mac_unittest.cc
+++ b/remoting/host/capturer_mac_unittest.cc
@@ -44,8 +44,8 @@ void CapturerCallback::CaptureDoneCallback(
int height = CGDisplayPixelsHigh(mainDevice);
EXPECT_EQ(rects_, capture_data->dirty_rects());
- EXPECT_EQ(width, capture_data->width());
- EXPECT_EQ(height, capture_data->height());
+ EXPECT_EQ(width, capture_data->size().width());
+ EXPECT_EQ(height, capture_data->size().height());
const DataPlanes &planes = capture_data->data_planes();
EXPECT_TRUE(planes.data[0] != NULL);
EXPECT_TRUE(planes.data[1] == NULL);
diff --git a/remoting/host/event_executor_mac.cc b/remoting/host/event_executor_mac.cc
index e28157a..12c0ce5 100644
--- a/remoting/host/event_executor_mac.cc
+++ b/remoting/host/event_executor_mac.cc
@@ -238,10 +238,9 @@ void EventExecutorMac::InjectMouseEvent(const MouseEvent* event, Task* done) {
// TODO(wez): This code assumes that MouseEvent(0,0) (top-left of client view)
// corresponds to local (0,0) (top-left of primary monitor). That won't in
// general be true on multi-monitor systems, though.
- int width = capturer_->width_most_recent();
- int height = capturer_->height_most_recent();
+ gfx::Size size = capturer_->size_most_recent();
if (event->x() >= 0 || event->y() >= 0 ||
- event->x() < width || event->y() < height) {
+ event->x() < size.width() || event->y() < size.height()) {
VLOG(3) << "Moving mouse to " << event->x() << "," << event->y();
diff --git a/remoting/host/event_executor_win.cc b/remoting/host/event_executor_win.cc
index 95da76b..b87119d 100644
--- a/remoting/host/event_executor_win.cc
+++ b/remoting/host/event_executor_win.cc
@@ -97,11 +97,10 @@ void EventExecutorWin::HandleMouse(const MouseEvent* event) {
INPUT input;
input.type = INPUT_MOUSE;
input.mi.time = 0;
- int screen_width = capturer_->width_most_recent();
- int screen_height = capturer_->height_most_recent();
- if ((screen_width > 0) && (screen_height > 0)) {
- input.mi.dx = static_cast<int>((x * 65535) / screen_width);
- input.mi.dy = static_cast<int>((y * 65535) / screen_height);
+ gfx::Size screen_size = capturer_->size_most_recent();
+ if ((screen_size.width() > 0) && (screen_size.height() > 0)) {
+ input.mi.dx = static_cast<int>((x * 65535) / screen_size.width());
+ input.mi.dy = static_cast<int>((y * 65535) / screen_size.height());
input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
SendInput(1, &input, sizeof(INPUT));
}
diff --git a/remoting/host/screen_recorder_unittest.cc b/remoting/host/screen_recorder_unittest.cc
index b4fa40a..979e961 100644
--- a/remoting/host/screen_recorder_unittest.cc
+++ b/remoting/host/screen_recorder_unittest.cc
@@ -115,8 +115,9 @@ TEST_F(ScreenRecorderTest, OneRecordCycle) {
planes.data[i] = reinterpret_cast<uint8*>(i);
planes.strides[i] = kWidth * 4;
}
- scoped_refptr<CaptureData> data(new CaptureData(planes, kWidth,
- kHeight, kFormat));
+ scoped_refptr<CaptureData> data(new CaptureData(planes,
+ gfx::Size(kWidth, kHeight),
+ kFormat));
EXPECT_CALL(capturer_, width()).WillRepeatedly(Return(kWidth));
EXPECT_CALL(capturer_, height()).WillRepeatedly(Return(kHeight));
EXPECT_CALL(capturer_, InvalidateFullScreen());
@@ -166,8 +167,9 @@ TEST_F(ScreenRecorderTest, StartAndStop) {
planes.data[i] = reinterpret_cast<uint8*>(i);
planes.strides[i] = kWidth * 4;
}
- scoped_refptr<CaptureData> data(new CaptureData(planes, kWidth,
- kHeight, kFormat));
+ scoped_refptr<CaptureData> data(new CaptureData(planes,
+ gfx::Size(kWidth, kHeight),
+ kFormat));
EXPECT_CALL(capturer_, width()).WillRepeatedly(Return(kWidth));
EXPECT_CALL(capturer_, height()).WillRepeatedly(Return(kHeight));
EXPECT_CALL(capturer_, InvalidateFullScreen());