| 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(std::unique_ptr<DesktopFrame> frame, | 60 DesktopFrameWithCursor(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( | 74 DesktopFrameWithCursor::DesktopFrameWithCursor(DesktopFrame* frame, |
| 75 std::unique_ptr<DesktopFrame> frame, | 75 const MouseCursor& cursor, |
| 76 const MouseCursor& cursor, | 76 const DesktopVector& position) |
| 77 const DesktopVector& position) | 77 : DesktopFrame(frame->size(), frame->stride(), |
| 78 : DesktopFrame(frame->size(), | 78 frame->data(), frame->shared_memory()), |
| 79 frame->stride(), | 79 original_frame_(frame) { |
| 80 frame->data(), | |
| 81 frame->shared_memory()) { | |
| 82 set_dpi(frame->dpi()); | 80 set_dpi(frame->dpi()); |
| 83 set_capture_time_ms(frame->capture_time_ms()); | 81 set_capture_time_ms(frame->capture_time_ms()); |
| 84 mutable_updated_region()->Swap(frame->mutable_updated_region()); | 82 mutable_updated_region()->Swap(frame->mutable_updated_region()); |
| 85 original_frame_ = std::move(frame); | |
| 86 | 83 |
| 87 DesktopVector image_pos = position.subtract(cursor.hotspot()); | 84 DesktopVector image_pos = position.subtract(cursor.hotspot()); |
| 88 DesktopRect target_rect = DesktopRect::MakeSize(cursor.image()->size()); | 85 DesktopRect target_rect = DesktopRect::MakeSize(cursor.image()->size()); |
| 89 target_rect.Translate(image_pos); | 86 target_rect.Translate(image_pos); |
| 90 DesktopVector target_origin = target_rect.top_left(); | 87 DesktopVector target_origin = target_rect.top_left(); |
| 91 target_rect.IntersectWith(DesktopRect::MakeSize(size())); | 88 target_rect.IntersectWith(DesktopRect::MakeSize(size())); |
| 92 | 89 |
| 93 if (target_rect.is_empty()) | 90 if (target_rect.is_empty()) |
| 94 return; | 91 return; |
| 95 | 92 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 void DesktopAndCursorComposer::Capture(const DesktopRegion& region) { | 145 void DesktopAndCursorComposer::Capture(const DesktopRegion& region) { |
| 149 if (mouse_monitor_.get()) | 146 if (mouse_monitor_.get()) |
| 150 mouse_monitor_->Capture(); | 147 mouse_monitor_->Capture(); |
| 151 desktop_capturer_->Capture(region); | 148 desktop_capturer_->Capture(region); |
| 152 } | 149 } |
| 153 | 150 |
| 154 void DesktopAndCursorComposer::SetExcludedWindow(WindowId window) { | 151 void DesktopAndCursorComposer::SetExcludedWindow(WindowId window) { |
| 155 desktop_capturer_->SetExcludedWindow(window); | 152 desktop_capturer_->SetExcludedWindow(window); |
| 156 } | 153 } |
| 157 | 154 |
| 158 void DesktopAndCursorComposer::OnCaptureResult( | 155 void DesktopAndCursorComposer::OnCaptureCompleted(DesktopFrame* frame) { |
| 159 DesktopCapturer::Result result, | 156 if (frame && cursor_.get() && cursor_state_ == MouseCursorMonitor::INSIDE) { |
| 160 std::unique_ptr<DesktopFrame> frame) { | 157 DesktopFrameWithCursor* frame_with_cursor = |
| 161 if (frame && cursor_ && cursor_state_ == MouseCursorMonitor::INSIDE) { | 158 new DesktopFrameWithCursor(frame, *cursor_, cursor_position_); |
| 162 frame = std::unique_ptr<DesktopFrameWithCursor>(new DesktopFrameWithCursor( | 159 frame = frame_with_cursor; |
| 163 std::move(frame), *cursor_, cursor_position_)); | |
| 164 } | 160 } |
| 165 | 161 |
| 166 callback_->OnCaptureResult(result, std::move(frame)); | 162 callback_->OnCaptureCompleted(frame); |
| 167 } | 163 } |
| 168 | 164 |
| 169 void DesktopAndCursorComposer::OnMouseCursor(MouseCursor* cursor) { | 165 void DesktopAndCursorComposer::OnMouseCursor(MouseCursor* cursor) { |
| 170 cursor_.reset(cursor); | 166 cursor_.reset(cursor); |
| 171 } | 167 } |
| 172 | 168 |
| 173 void DesktopAndCursorComposer::OnMouseCursorPosition( | 169 void DesktopAndCursorComposer::OnMouseCursorPosition( |
| 174 MouseCursorMonitor::CursorState state, | 170 MouseCursorMonitor::CursorState state, |
| 175 const DesktopVector& position) { | 171 const DesktopVector& position) { |
| 176 cursor_state_ = state; | 172 cursor_state_ = state; |
| 177 cursor_position_ = position; | 173 cursor_position_ = position; |
| 178 } | 174 } |
| 179 | 175 |
| 180 } // namespace webrtc | 176 } // namespace webrtc |
| OLD | NEW |