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