diff options
author | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-10 11:51:08 +0000 |
---|---|---|
committer | simonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-10 11:51:08 +0000 |
commit | 467aca55f38b251b636f638d61408d420d570c11 (patch) | |
tree | fda9063580b467a4a21fd8f1a1bd317991ce1a0b /remoting | |
parent | ab0fb9834c6f3b3ee9d86a8c5a6ba3a5b69b2ac8 (diff) | |
download | chromium_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')
-rw-r--r-- | remoting/base/capture_data.cc | 7 | ||||
-rw-r--r-- | remoting/base/capture_data.h | 17 | ||||
-rw-r--r-- | remoting/base/codec_test.cc | 2 | ||||
-rw-r--r-- | remoting/base/encoder_row_based.cc | 16 | ||||
-rw-r--r-- | remoting/base/encoder_row_based.h | 3 | ||||
-rw-r--r-- | remoting/base/encoder_vp8.cc | 48 | ||||
-rw-r--r-- | remoting/base/encoder_vp8.h | 7 | ||||
-rw-r--r-- | remoting/host/capturer.cc | 14 | ||||
-rw-r--r-- | remoting/host/capturer.h | 13 | ||||
-rw-r--r-- | remoting/host/capturer_fake.cc | 20 | ||||
-rw-r--r-- | remoting/host/capturer_fake.h | 3 | ||||
-rw-r--r-- | remoting/host/capturer_fake_ascii.cc | 6 | ||||
-rw-r--r-- | remoting/host/capturer_gdi.cc | 7 | ||||
-rw-r--r-- | remoting/host/capturer_linux.cc | 6 | ||||
-rw-r--r-- | remoting/host/capturer_mac.cc | 2 | ||||
-rw-r--r-- | remoting/host/capturer_mac_unittest.cc | 4 | ||||
-rw-r--r-- | remoting/host/event_executor_mac.cc | 5 | ||||
-rw-r--r-- | remoting/host/event_executor_win.cc | 9 | ||||
-rw-r--r-- | remoting/host/screen_recorder_unittest.cc | 10 |
19 files changed, 85 insertions, 114 deletions
diff --git a/remoting/base/capture_data.cc b/remoting/base/capture_data.cc index 8bf464d..15f312e 100644 --- a/remoting/base/capture_data.cc +++ b/remoting/base/capture_data.cc @@ -14,11 +14,10 @@ DataPlanes::DataPlanes() { } CaptureData::CaptureData(const DataPlanes &data_planes, - int width, - int height, + const gfx::Size& size, media::VideoFrame::Format format) : - data_planes_(data_planes), dirty_rects_(), - width_(width), height_(height), pixel_format_(format) { + data_planes_(data_planes), dirty_rects_(), size_(size), + pixel_format_(format) { } CaptureData::~CaptureData() {} diff --git a/remoting/base/capture_data.h b/remoting/base/capture_data.h index dd6c4b9..1922c9c 100644 --- a/remoting/base/capture_data.h +++ b/remoting/base/capture_data.h @@ -27,8 +27,7 @@ struct DataPlanes { class CaptureData : public base::RefCountedThreadSafe<CaptureData> { public: CaptureData(const DataPlanes &data_planes, - int width, - int height, + const gfx::Size& size, media::VideoFrame::Format format); // Get the data_planes data of the last capture. @@ -38,15 +37,8 @@ class CaptureData : public base::RefCountedThreadSafe<CaptureData> { // written into |rects|. const InvalidRects& dirty_rects() const { return dirty_rects_; } - // TODO(simonmorris): The next two methods should be replaced by a - // gfx::Size size(), and objects that store that size should also - // use a gfx::Size to do so. - - // Get the width of the image captured. - int width() const { return width_; } - - // Get the height of the image captured. - int height() const { return height_; } + // Return the size of the image captured. + gfx::Size size() const { return size_; } // Get the pixel format of the image captured. media::VideoFrame::Format pixel_format() const { return pixel_format_; } @@ -57,8 +49,7 @@ class CaptureData : public base::RefCountedThreadSafe<CaptureData> { private: const DataPlanes data_planes_; InvalidRects dirty_rects_; - int width_; - int height_; + gfx::Size size_; media::VideoFrame::Format pixel_format_; friend class base::RefCountedThreadSafe<CaptureData>; diff --git a/remoting/base/codec_test.cc b/remoting/base/codec_test.cc index bfa2d64..38593fb 100644 --- a/remoting/base/codec_test.cc +++ b/remoting/base/codec_test.cc @@ -256,7 +256,7 @@ scoped_refptr<CaptureData> PrepareEncodeData(media::VideoFrame::Format format, planes.strides[0] = kWidth * kBytesPerPixel; scoped_refptr<CaptureData> data = - new CaptureData(planes, kWidth, kHeight, format); + new CaptureData(planes, gfx::Size(kWidth, kHeight), format); return data; } diff --git a/remoting/base/encoder_row_based.cc b/remoting/base/encoder_row_based.cc index 6159207a..d740e27 100644 --- a/remoting/base/encoder_row_based.cc +++ b/remoting/base/encoder_row_based.cc @@ -42,8 +42,7 @@ EncoderRowBased::EncoderRowBased(Compressor* compressor, VideoPacketFormat::Encoding encoding) : encoding_(encoding), compressor_(compressor), - screen_width_(0), - screen_height_(0), + screen_size_(0, 0), packet_size_(kPacketSize) { } @@ -52,8 +51,7 @@ EncoderRowBased::EncoderRowBased(Compressor* compressor, int packet_size) : encoding_(encoding), compressor_(compressor), - screen_width_(0), - screen_height_(0), + screen_size_(0, 0), packet_size_(packet_size) { } @@ -151,12 +149,10 @@ void EncoderRowBased::PrepareUpdateStart(const gfx::Rect& rect, format->set_width(rect.width()); format->set_height(rect.height()); format->set_encoding(encoding_); - if ((capture_data_->width() != screen_width_) || - (capture_data_->height() != screen_height_)) { - screen_width_ = capture_data_->width(); - screen_height_ = capture_data_->height(); - format->set_screen_width(screen_width_); - format->set_screen_height(screen_height_); + if (capture_data_->size() != screen_size_) { + screen_size_ = capture_data_->size(); + format->set_screen_width(screen_size_.width()); + format->set_screen_height(screen_size_.height()); } } diff --git a/remoting/base/encoder_row_based.h b/remoting/base/encoder_row_based.h index fe7f49c..d453ffb 100644 --- a/remoting/base/encoder_row_based.h +++ b/remoting/base/encoder_row_based.h @@ -62,8 +62,7 @@ class EncoderRowBased : public Encoder { scoped_ptr<DataAvailableCallback> callback_; // The most recent screen size. - int screen_width_; - int screen_height_; + gfx::Size screen_size_; int packet_size_; }; diff --git a/remoting/base/encoder_vp8.cc b/remoting/base/encoder_vp8.cc index 8d09d544..b0f35cb 100644 --- a/remoting/base/encoder_vp8.cc +++ b/remoting/base/encoder_vp8.cc @@ -33,8 +33,7 @@ EncoderVp8::EncoderVp8() active_map_width_(0), active_map_height_(0), last_timestamp_(0), - width_(0), - height_(0) { + size_(0, 0) { } EncoderVp8::~EncoderVp8() { @@ -44,9 +43,8 @@ EncoderVp8::~EncoderVp8() { } } -bool EncoderVp8::Init(int width, int height) { - width_ = width; - height_ = height; +bool EncoderVp8::Init(const gfx::Size& size) { + size_ = size; codec_.reset(new vpx_codec_ctx_t()); image_.reset(new vpx_image_t()); memset(image_.get(), 0, sizeof(vpx_image_t)); @@ -54,20 +52,20 @@ bool EncoderVp8::Init(int width, int height) { image_->fmt = VPX_IMG_FMT_YV12; // libvpx seems to require both to be assigned. - image_->d_w = width; - image_->w = width; - image_->d_h = height; - image_->h = height; + image_->d_w = size.width(); + image_->w = size.width(); + image_->d_h = size.height(); + image_->h = size.height(); // YUV image size is 1.5 times of a plane. Multiplication is performed first // to avoid rounding error. - const int plane_size = width * height; - const int size = plane_size * 3 / 2; + const int plane_size = size.width() * size.height(); + const int yuv_image_size = plane_size * 3 / 2; - yuv_image_.reset(new uint8[size]); + yuv_image_.reset(new uint8[yuv_image_size]); // Reset image value to 128 so we just need to fill in the y plane. - memset(yuv_image_.get(), 128, size); + memset(yuv_image_.get(), 128, yuv_image_size); // Fill in the information for |image_|. unsigned char* image = reinterpret_cast<unsigned char*>(yuv_image_.get()); @@ -91,15 +89,15 @@ bool EncoderVp8::Init(int width, int height) { return false; // Initialize active map. - active_map_width_ = (width + kMacroBlockSize - 1) / kMacroBlockSize; - active_map_height_ = (height + kMacroBlockSize - 1) / kMacroBlockSize; + active_map_width_ = (size.width() + kMacroBlockSize - 1) / kMacroBlockSize; + active_map_height_ = (size.height() + kMacroBlockSize - 1) / kMacroBlockSize; active_map_.reset(new uint8[active_map_width_ * active_map_height_]); // TODO(hclam): Tune the parameters to better suit the application. - config.rc_target_bitrate = width * height * config.rc_target_bitrate - / config.g_w / config.g_h; - config.g_w = width; - config.g_h = height; + config.rc_target_bitrate = size.width() * size.height() * + config.rc_target_bitrate / config.g_w / config.g_h; + config.g_w = size.width(); + config.g_h = size.height(); config.g_pass = VPX_RC_ONE_PASS; config.g_profile = 1; config.g_threads = 1; @@ -147,7 +145,8 @@ bool EncoderVp8::PrepareImage(scoped_refptr<CaptureData> capture_data, const InvalidRects& rects = capture_data->dirty_rects(); const uint8* in = capture_data->data_planes().data[0]; const int in_stride = capture_data->data_planes().strides[0]; - const int plane_size = capture_data->width() * capture_data->height(); + const int plane_size = + capture_data->size().width() * capture_data->size().height(); uint8* y_out = yuv_image_.get(); uint8* u_out = yuv_image_.get() + plane_size; uint8* v_out = yuv_image_.get() + plane_size + plane_size / 4; @@ -204,9 +203,8 @@ void EncoderVp8::PrepareActiveMap( void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data, bool key_frame, DataAvailableCallback* data_available_callback) { - if (!initialized_ || (capture_data->width() != width_) || - (capture_data->height() != height_)) { - bool ret = Init(capture_data->width(), capture_data->height()); + if (!initialized_ || (capture_data->size() != size_)) { + bool ret = Init(capture_data->size()); // TODO(hclam): Handle error better. DCHECK(ret) << "Initialization of encoder failed"; initialized_ = ret; @@ -269,8 +267,8 @@ void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data, message->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8); message->set_flags(VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET | VideoPacket::LAST_PARTITION); - message->mutable_format()->set_screen_width(capture_data->width()); - message->mutable_format()->set_screen_height(capture_data->height()); + message->mutable_format()->set_screen_width(capture_data->size().width()); + message->mutable_format()->set_screen_height(capture_data->size().height()); for (size_t i = 0; i < updated_rects.size(); ++i) { Rect* rect = message->add_dirty_rects(); rect->set_x(updated_rects[i].x()); diff --git a/remoting/base/encoder_vp8.h b/remoting/base/encoder_vp8.h index 2bf73dc..8fdbbc2 100644 --- a/remoting/base/encoder_vp8.h +++ b/remoting/base/encoder_vp8.h @@ -27,7 +27,7 @@ class EncoderVp8 : public Encoder { private: // Initialize the encoder. Returns true if successful. - bool Init(int width, int height); + bool Init(const gfx::Size& size); // Prepare |image_| for encoding. Write updated rectangles into // |updated_rects|. Returns true if successful. @@ -51,9 +51,8 @@ class EncoderVp8 : public Encoder { // Buffer for storing the yuv image. scoped_array<uint8> yuv_image_; - // The current frame dimensions. - int width_; - int height_; + // The current frame size. + gfx::Size size_; DISALLOW_COPY_AND_ASSIGN(EncoderVp8); }; 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()); |