OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 src += src_stride; | 50 src += src_stride; |
51 dest += dest_stride; | 51 dest += dest_stride; |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 // DesktopFrame wrapper that draws mouse on a frame and restores original | 55 // DesktopFrame wrapper that draws mouse on a frame and restores original |
56 // content before releasing the underlying frame. | 56 // content before releasing the underlying frame. |
57 class DesktopFrameWithCursor : public DesktopFrame { | 57 class DesktopFrameWithCursor : public DesktopFrame { |
58 public: | 58 public: |
59 // Takes ownership of |frame|. | 59 // Takes ownership of |frame|. |
60 DesktopFrameWithCursor(DesktopFrame* frame, | 60 DesktopFrameWithCursor(std::unique_ptr<DesktopFrame> frame, |
61 const MouseCursor& cursor, | 61 const MouseCursor& cursor, |
62 const DesktopVector& position); | 62 const DesktopVector& position); |
63 virtual ~DesktopFrameWithCursor(); | 63 virtual ~DesktopFrameWithCursor(); |
64 | 64 |
65 private: | 65 private: |
66 std::unique_ptr<DesktopFrame> original_frame_; | 66 std::unique_ptr<DesktopFrame> original_frame_; |
67 | 67 |
68 DesktopVector restore_position_; | 68 DesktopVector restore_position_; |
69 std::unique_ptr<DesktopFrame> restore_frame_; | 69 std::unique_ptr<DesktopFrame> restore_frame_; |
70 | 70 |
71 RTC_DISALLOW_COPY_AND_ASSIGN(DesktopFrameWithCursor); | 71 RTC_DISALLOW_COPY_AND_ASSIGN(DesktopFrameWithCursor); |
72 }; | 72 }; |
73 | 73 |
74 DesktopFrameWithCursor::DesktopFrameWithCursor(DesktopFrame* frame, | 74 DesktopFrameWithCursor::DesktopFrameWithCursor( |
75 const MouseCursor& cursor, | 75 std::unique_ptr<DesktopFrame> frame, |
76 const DesktopVector& position) | 76 const MouseCursor& cursor, |
77 : DesktopFrame(frame->size(), frame->stride(), | 77 const DesktopVector& position) |
78 frame->data(), frame->shared_memory()), | 78 : DesktopFrame(frame->size(), |
79 original_frame_(frame) { | 79 frame->stride(), |
| 80 frame->data(), |
| 81 frame->shared_memory()) { |
80 set_dpi(frame->dpi()); | 82 set_dpi(frame->dpi()); |
81 set_capture_time_ms(frame->capture_time_ms()); | 83 set_capture_time_ms(frame->capture_time_ms()); |
82 mutable_updated_region()->Swap(frame->mutable_updated_region()); | 84 mutable_updated_region()->Swap(frame->mutable_updated_region()); |
| 85 original_frame_ = std::move(frame); |
83 | 86 |
84 DesktopVector image_pos = position.subtract(cursor.hotspot()); | 87 DesktopVector image_pos = position.subtract(cursor.hotspot()); |
85 DesktopRect target_rect = DesktopRect::MakeSize(cursor.image()->size()); | 88 DesktopRect target_rect = DesktopRect::MakeSize(cursor.image()->size()); |
86 target_rect.Translate(image_pos); | 89 target_rect.Translate(image_pos); |
87 DesktopVector target_origin = target_rect.top_left(); | 90 DesktopVector target_origin = target_rect.top_left(); |
88 target_rect.IntersectWith(DesktopRect::MakeSize(size())); | 91 target_rect.IntersectWith(DesktopRect::MakeSize(size())); |
89 | 92 |
90 if (target_rect.is_empty()) | 93 if (target_rect.is_empty()) |
91 return; | 94 return; |
92 | 95 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 void DesktopAndCursorComposer::Capture(const DesktopRegion& region) { | 148 void DesktopAndCursorComposer::Capture(const DesktopRegion& region) { |
146 if (mouse_monitor_.get()) | 149 if (mouse_monitor_.get()) |
147 mouse_monitor_->Capture(); | 150 mouse_monitor_->Capture(); |
148 desktop_capturer_->Capture(region); | 151 desktop_capturer_->Capture(region); |
149 } | 152 } |
150 | 153 |
151 void DesktopAndCursorComposer::SetExcludedWindow(WindowId window) { | 154 void DesktopAndCursorComposer::SetExcludedWindow(WindowId window) { |
152 desktop_capturer_->SetExcludedWindow(window); | 155 desktop_capturer_->SetExcludedWindow(window); |
153 } | 156 } |
154 | 157 |
155 void DesktopAndCursorComposer::OnCaptureCompleted(DesktopFrame* frame) { | 158 void DesktopAndCursorComposer::OnCaptureCompleted( |
156 if (frame && cursor_.get() && cursor_state_ == MouseCursorMonitor::INSIDE) { | 159 std::unique_ptr<DesktopFrame> frame) { |
157 DesktopFrameWithCursor* frame_with_cursor = | 160 if (frame && cursor_ && cursor_state_ == MouseCursorMonitor::INSIDE) { |
158 new DesktopFrameWithCursor(frame, *cursor_, cursor_position_); | 161 frame = std::unique_ptr<DesktopFrameWithCursor>(new DesktopFrameWithCursor( |
159 frame = frame_with_cursor; | 162 std::move(frame), *cursor_, cursor_position_)); |
160 } | 163 } |
161 | 164 |
162 callback_->OnCaptureCompleted(frame); | 165 callback_->OnCaptureCompleted(std::move(frame)); |
163 } | 166 } |
164 | 167 |
165 void DesktopAndCursorComposer::OnMouseCursor(MouseCursor* cursor) { | 168 void DesktopAndCursorComposer::OnMouseCursor(MouseCursor* cursor) { |
166 cursor_.reset(cursor); | 169 cursor_.reset(cursor); |
167 } | 170 } |
168 | 171 |
169 void DesktopAndCursorComposer::OnMouseCursorPosition( | 172 void DesktopAndCursorComposer::OnMouseCursorPosition( |
170 MouseCursorMonitor::CursorState state, | 173 MouseCursorMonitor::CursorState state, |
171 const DesktopVector& position) { | 174 const DesktopVector& position) { |
172 cursor_state_ = state; | 175 cursor_state_ = state; |
173 cursor_position_ = position; | 176 cursor_position_ = position; |
174 } | 177 } |
175 | 178 |
176 } // namespace webrtc | 179 } // namespace webrtc |
OLD | NEW |