Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: remoting/host/chromeos/aura_desktop_capturer.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "cc/output/copy_output_request.h" 10 #include "cc/output/copy_output_request.h"
(...skipping 24 matching lines...) Expand all
35 DCHECK(desktop_window_) << "Failed to retrieve the Aura Shell root window"; 35 DCHECK(desktop_window_) << "Failed to retrieve the Aura Shell root window";
36 } 36 }
37 #endif 37 #endif
38 38
39 DCHECK(!callback_) << "Start() can only be called once"; 39 DCHECK(!callback_) << "Start() can only be called once";
40 callback_ = callback; 40 callback_ = callback;
41 DCHECK(callback_); 41 DCHECK(callback_);
42 } 42 }
43 43
44 void AuraDesktopCapturer::Capture(const webrtc::DesktopRegion&) { 44 void AuraDesktopCapturer::Capture(const webrtc::DesktopRegion&) {
45 scoped_ptr<cc::CopyOutputRequest> request = 45 std::unique_ptr<cc::CopyOutputRequest> request =
46 cc::CopyOutputRequest::CreateBitmapRequest( 46 cc::CopyOutputRequest::CreateBitmapRequest(base::Bind(
47 base::Bind( 47 &AuraDesktopCapturer::OnFrameCaptured, weak_factory_.GetWeakPtr()));
48 &AuraDesktopCapturer::OnFrameCaptured,
49 weak_factory_.GetWeakPtr()));
50 48
51 gfx::Rect window_rect(desktop_window_->bounds().size()); 49 gfx::Rect window_rect(desktop_window_->bounds().size());
52 50
53 request->set_area(window_rect); 51 request->set_area(window_rect);
54 desktop_window_->layer()->RequestCopyOfOutput(std::move(request)); 52 desktop_window_->layer()->RequestCopyOfOutput(std::move(request));
55 } 53 }
56 54
57 void AuraDesktopCapturer::OnFrameCaptured( 55 void AuraDesktopCapturer::OnFrameCaptured(
58 scoped_ptr<cc::CopyOutputResult> result) { 56 std::unique_ptr<cc::CopyOutputResult> result) {
59 if (result->IsEmpty()) { 57 if (result->IsEmpty()) {
60 callback_->OnCaptureCompleted(nullptr); 58 callback_->OnCaptureCompleted(nullptr);
61 return; 59 return;
62 } 60 }
63 61
64 DCHECK(result->HasBitmap()); 62 DCHECK(result->HasBitmap());
65 63
66 scoped_ptr<SkBitmap> bitmap = result->TakeBitmap(); 64 std::unique_ptr<SkBitmap> bitmap = result->TakeBitmap();
67 65
68 scoped_ptr<webrtc::DesktopFrame> frame( 66 std::unique_ptr<webrtc::DesktopFrame> frame(
69 SkiaBitmapDesktopFrame::Create(std::move(bitmap))); 67 SkiaBitmapDesktopFrame::Create(std::move(bitmap)));
70 68
71 // |VideoFramePump| will not encode the frame if |updated_region| is empty. 69 // |VideoFramePump| will not encode the frame if |updated_region| is empty.
72 const webrtc::DesktopRect& rect = webrtc::DesktopRect::MakeWH( 70 const webrtc::DesktopRect& rect = webrtc::DesktopRect::MakeWH(
73 frame->size().width(), frame->size().height()); 71 frame->size().width(), frame->size().height());
74 72
75 // TODO(kelvinp): Set Frame DPI according to the screen resolution. 73 // TODO(kelvinp): Set Frame DPI according to the screen resolution.
76 // See cc::Layer::contents_scale_(x|y)() and frame->set_depi(). 74 // See cc::Layer::contents_scale_(x|y)() and frame->set_depi().
77 frame->mutable_updated_region()->SetRect(rect); 75 frame->mutable_updated_region()->SetRect(rect);
78 76
79 callback_->OnCaptureCompleted(frame.release()); 77 callback_->OnCaptureCompleted(frame.release());
80 } 78 }
81 79
82 } // namespace remoting 80 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromeos/aura_desktop_capturer.h ('k') | remoting/host/chromeos/aura_desktop_capturer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698