| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "remoting/host/chromeos/aura_desktop_capturer.h" | 5 #include "remoting/host/chromeos/aura_desktop_capturer.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
| 9 #include "cc/output/copy_output_result.h" | 11 #include "cc/output/copy_output_result.h" |
| 10 #include "remoting/host/chromeos/skia_bitmap_desktop_frame.h" | 12 #include "remoting/host/chromeos/skia_bitmap_desktop_frame.h" |
| 11 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 12 #include "ui/aura/window_tree_host.h" | 14 #include "ui/aura/window_tree_host.h" |
| 13 | 15 |
| 14 #if defined(USE_ASH) | 16 #if defined(USE_ASH) |
| 15 #include "ash/shell.h" | 17 #include "ash/shell.h" |
| 16 #endif | 18 #endif |
| (...skipping 25 matching lines...) Expand all Loading... |
| 42 void AuraDesktopCapturer::Capture(const webrtc::DesktopRegion&) { | 44 void AuraDesktopCapturer::Capture(const webrtc::DesktopRegion&) { |
| 43 scoped_ptr<cc::CopyOutputRequest> request = | 45 scoped_ptr<cc::CopyOutputRequest> request = |
| 44 cc::CopyOutputRequest::CreateBitmapRequest( | 46 cc::CopyOutputRequest::CreateBitmapRequest( |
| 45 base::Bind( | 47 base::Bind( |
| 46 &AuraDesktopCapturer::OnFrameCaptured, | 48 &AuraDesktopCapturer::OnFrameCaptured, |
| 47 weak_factory_.GetWeakPtr())); | 49 weak_factory_.GetWeakPtr())); |
| 48 | 50 |
| 49 gfx::Rect window_rect(desktop_window_->bounds().size()); | 51 gfx::Rect window_rect(desktop_window_->bounds().size()); |
| 50 | 52 |
| 51 request->set_area(window_rect); | 53 request->set_area(window_rect); |
| 52 desktop_window_->layer()->RequestCopyOfOutput(request.Pass()); | 54 desktop_window_->layer()->RequestCopyOfOutput(std::move(request)); |
| 53 } | 55 } |
| 54 | 56 |
| 55 void AuraDesktopCapturer::OnFrameCaptured( | 57 void AuraDesktopCapturer::OnFrameCaptured( |
| 56 scoped_ptr<cc::CopyOutputResult> result) { | 58 scoped_ptr<cc::CopyOutputResult> result) { |
| 57 if (result->IsEmpty()) { | 59 if (result->IsEmpty()) { |
| 58 callback_->OnCaptureCompleted(nullptr); | 60 callback_->OnCaptureCompleted(nullptr); |
| 59 return; | 61 return; |
| 60 } | 62 } |
| 61 | 63 |
| 62 DCHECK(result->HasBitmap()); | 64 DCHECK(result->HasBitmap()); |
| 63 | 65 |
| 64 scoped_ptr<SkBitmap> bitmap = result->TakeBitmap(); | 66 scoped_ptr<SkBitmap> bitmap = result->TakeBitmap(); |
| 65 | 67 |
| 66 scoped_ptr<webrtc::DesktopFrame> frame( | 68 scoped_ptr<webrtc::DesktopFrame> frame( |
| 67 SkiaBitmapDesktopFrame::Create(bitmap.Pass())); | 69 SkiaBitmapDesktopFrame::Create(std::move(bitmap))); |
| 68 | 70 |
| 69 // |VideoFramePump| will not encode the frame if |updated_region| is empty. | 71 // |VideoFramePump| will not encode the frame if |updated_region| is empty. |
| 70 const webrtc::DesktopRect& rect = webrtc::DesktopRect::MakeWH( | 72 const webrtc::DesktopRect& rect = webrtc::DesktopRect::MakeWH( |
| 71 frame->size().width(), frame->size().height()); | 73 frame->size().width(), frame->size().height()); |
| 72 | 74 |
| 73 // TODO(kelvinp): Set Frame DPI according to the screen resolution. | 75 // TODO(kelvinp): Set Frame DPI according to the screen resolution. |
| 74 // See cc::Layer::contents_scale_(x|y)() and frame->set_depi(). | 76 // See cc::Layer::contents_scale_(x|y)() and frame->set_depi(). |
| 75 frame->mutable_updated_region()->SetRect(rect); | 77 frame->mutable_updated_region()->SetRect(rect); |
| 76 | 78 |
| 77 callback_->OnCaptureCompleted(frame.release()); | 79 callback_->OnCaptureCompleted(frame.release()); |
| 78 } | 80 } |
| 79 | 81 |
| 80 } // namespace remoting | 82 } // namespace remoting |
| OLD | NEW |