diff --git a/modules/desktop_capture/desktop_and_cursor_composer.cc b/modules/desktop_capture/desktop_and_cursor_composer.cc index 7ff983c2d1..dd688ac5f2 100644 --- a/modules/desktop_capture/desktop_and_cursor_composer.cc +++ b/modules/desktop_capture/desktop_and_cursor_composer.cc @@ -105,11 +105,12 @@ DesktopFrameWithCursor::DesktopFrameWithCursor( if (!previous_cursor_rect.equals(cursor_rect_)) { mutable_updated_region()->AddRect(cursor_rect_); - - // Only add the previous cursor if it is inside the frame. - // (it can be outside the frame if the desktop has been resized). - if (original_frame_->rect().ContainsRect(previous_cursor_rect)) - mutable_updated_region()->AddRect(previous_cursor_rect); + // TODO(crbug:1323241) Update this code to properly handle the case where + // |previous_cursor_rect| is outside of the boundaries of |frame|. + // Any boundary check has to take into account the fact that + // |previous_cursor_rect| can be in DPI or in pixels, based on the platform + // we're running on. + mutable_updated_region()->AddRect(previous_cursor_rect); } else if (cursor_changed) { mutable_updated_region()->AddRect(cursor_rect_); } diff --git a/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc b/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc index 4d879a740e..179e002bc5 100644 --- a/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc +++ b/modules/desktop_capture/desktop_and_cursor_composer_unittest.cc @@ -105,15 +105,6 @@ MouseCursor* CreateTestCursor(DesktopVector hotspot) { return new MouseCursor(image.release(), hotspot); } -std::vector GetUpdatedRegions(const DesktopFrame& frame) { - std::vector result; - for (webrtc::DesktopRegion::Iterator i(frame.updated_region()); !i.IsAtEnd(); - i.Advance()) { - result.push_back(i.rect()); - } - return result; -} - class FakeScreenCapturer : public DesktopCapturer { public: FakeScreenCapturer() {} @@ -436,32 +427,6 @@ TEST_F(DesktopAndCursorComposerNoCursorMonitorTest, EXPECT_TRUE(frame_->updated_region().Equals(expected_region)); } -TEST_F(DesktopAndCursorComposerNoCursorMonitorTest, - UpdatedRegionDoesNotIncludeOldCursorIfOutOfBounds) { - blender_.OnMouseCursor(CreateTestCursor(DesktopVector(0, 0))); - - std::unique_ptr first_frame( - SharedDesktopFrame::Wrap(CreateTestFrame(1000, 1000))); - blender_.OnMouseCursorPosition(DesktopVector(900, 900)); - fake_screen_->SetNextFrame(first_frame->Share()); - - blender_.CaptureFrame(); - - // Second frame is smaller than first frame, and the first cursor is outside - // of the bounds of the new frame, so it should not be in the updated region. - std::unique_ptr second_frame( - SharedDesktopFrame::Wrap(CreateTestFrame(500, 500))); - auto second_cursor_rect = - DesktopRect::MakeXYWH(400, 400, kCursorWidth, kCursorHeight); - blender_.OnMouseCursorPosition(DesktopVector(400, 400)); - fake_screen_->SetNextFrame(second_frame->Share()); - blender_.CaptureFrame(); - - DesktopRegion expected_region; - expected_region.AddRect(second_cursor_rect); - EXPECT_THAT(GetUpdatedRegions(*frame_), ElementsAre(second_cursor_rect)); -} - TEST_F(DesktopAndCursorComposerNoCursorMonitorTest, UpdatedRegionIncludesOldAndNewCursorRectsIfShapeChanged) { std::unique_ptr frame(