| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 "content/browser/media/capture/cursor_renderer_aura.h" | 5 #include "content/browser/media/capture/cursor_renderer_aura.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 void RenderCursorOnVideoFrame(media::VideoFrame* target) { | 75 void RenderCursorOnVideoFrame(media::VideoFrame* target) { |
| 76 cursor_renderer_->RenderOnVideoFrame(target); | 76 cursor_renderer_->RenderOnVideoFrame(target); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void SnapshotCursorState(gfx::Rect region_in_frame) { | 79 void SnapshotCursorState(gfx::Rect region_in_frame) { |
| 80 cursor_renderer_->SnapshotCursorState(region_in_frame); | 80 cursor_renderer_->SnapshotCursorState(region_in_frame); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void MoveMouseCursorWithinWindow() { | 83 void MoveMouseCursorWithinWindow() { |
| 84 gfx::Point point1(20, 20); | 84 gfx::Point point1(20, 20); |
| 85 ui::MouseEvent event1(ui::ET_MOUSE_MOVED, point1, point1, Now(), 0, 0); | 85 ui::MouseEvent event1( |
| 86 ui::ET_MOUSE_MOVED, point1, point1, Now(), 0, 0, |
| 87 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 86 cursor_renderer_->OnMouseEvent(&event1); | 88 cursor_renderer_->OnMouseEvent(&event1); |
| 87 gfx::Point point2(60, 60); | 89 gfx::Point point2(60, 60); |
| 88 ui::MouseEvent event2(ui::ET_MOUSE_MOVED, point2, point2, Now(), 0, 0); | 90 ui::MouseEvent event2( |
| 91 ui::ET_MOUSE_MOVED, point2, point2, Now(), 0, 0, |
| 92 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 89 cursor_renderer_->OnMouseEvent(&event2); | 93 cursor_renderer_->OnMouseEvent(&event2); |
| 90 aura::Env::GetInstance()->set_last_mouse_location(point2); | 94 aura::Env::GetInstance()->set_last_mouse_location(point2); |
| 91 } | 95 } |
| 92 | 96 |
| 93 void MoveMouseCursorWithinWindow(gfx::Point point) { | 97 void MoveMouseCursorWithinWindow(gfx::Point point) { |
| 94 ui::MouseEvent event(ui::ET_MOUSE_MOVED, point, point, Now(), 0, 0); | 98 ui::MouseEvent event( |
| 99 ui::ET_MOUSE_MOVED, point, point, Now(), 0, 0, |
| 100 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 95 cursor_renderer_->OnMouseEvent(&event); | 101 cursor_renderer_->OnMouseEvent(&event); |
| 96 aura::Env::GetInstance()->set_last_mouse_location(point); | 102 aura::Env::GetInstance()->set_last_mouse_location(point); |
| 97 } | 103 } |
| 98 | 104 |
| 99 void MoveMouseCursorOutsideWindow() { | 105 void MoveMouseCursorOutsideWindow() { |
| 100 gfx::Point point(1000, 1000); | 106 gfx::Point point(1000, 1000); |
| 101 ui::MouseEvent event1(ui::ET_MOUSE_MOVED, point, point, Now(), 0, 0); | 107 ui::MouseEvent event1( |
| 108 ui::ET_MOUSE_MOVED, point, point, Now(), 0, 0, |
| 109 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)); |
| 102 cursor_renderer_->OnMouseEvent(&event1); | 110 cursor_renderer_->OnMouseEvent(&event1); |
| 103 aura::Env::GetInstance()->set_last_mouse_location(point); | 111 aura::Env::GetInstance()->set_last_mouse_location(point); |
| 104 } | 112 } |
| 105 | 113 |
| 106 // A very simple test of whether there are any non-zero pixels | 114 // A very simple test of whether there are any non-zero pixels |
| 107 // in the region |rect| within |frame|. | 115 // in the region |rect| within |frame|. |
| 108 bool NonZeroPixelsInRegion(scoped_refptr<media::VideoFrame> frame, | 116 bool NonZeroPixelsInRegion(scoped_refptr<media::VideoFrame> frame, |
| 109 gfx::Rect rect) { | 117 gfx::Rect rect) { |
| 110 bool y_found = false, u_found = false, v_found = false; | 118 bool y_found = false, u_found = false, v_found = false; |
| 111 for (int y = rect.y(); y < rect.bottom(); ++y) { | 119 for (int y = rect.y(); y < rect.bottom(); ++y) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 249 |
| 242 // Cursor being displayed even if another window is activated. | 250 // Cursor being displayed even if another window is activated. |
| 243 std::unique_ptr<aura::Window> window2(aura::test::CreateTestWindowWithBounds( | 251 std::unique_ptr<aura::Window> window2(aura::test::CreateTestWindowWithBounds( |
| 244 gfx::Rect(0, 0, 800, 600), root_window())); | 252 gfx::Rect(0, 0, 800, 600), root_window())); |
| 245 wm::ActivateWindow(window2.get()); | 253 wm::ActivateWindow(window2.get()); |
| 246 SnapshotCursorState(gfx::Rect(0, 0, 800, 600)); | 254 SnapshotCursorState(gfx::Rect(0, 0, 800, 600)); |
| 247 EXPECT_TRUE(CursorDisplayed()); | 255 EXPECT_TRUE(CursorDisplayed()); |
| 248 } | 256 } |
| 249 | 257 |
| 250 } // namespace content | 258 } // namespace content |
| OLD | NEW |