OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/media/capture/aura_window_capture_machine.h" | 5 #include "content/browser/media/capture/aura_window_capture_machine.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 media::VideoCaptureOracle::Event event; | 204 media::VideoCaptureOracle::Event event; |
205 if (event_time.is_null()) { | 205 if (event_time.is_null()) { |
206 event = media::VideoCaptureOracle::kActiveRefreshRequest; | 206 event = media::VideoCaptureOracle::kActiveRefreshRequest; |
207 event_time = start_time; | 207 event_time = start_time; |
208 } else { | 208 } else { |
209 event = media::VideoCaptureOracle::kCompositorUpdate; | 209 event = media::VideoCaptureOracle::kCompositorUpdate; |
210 } | 210 } |
211 if (oracle_proxy_->ObserveEventAndDecideCapture( | 211 if (oracle_proxy_->ObserveEventAndDecideCapture( |
212 event, gfx::Rect(), event_time, &frame, &capture_frame_cb)) { | 212 event, gfx::Rect(), event_time, &frame, &capture_frame_cb)) { |
213 std::unique_ptr<cc::CopyOutputRequest> request = | 213 std::unique_ptr<cc::CopyOutputRequest> request = |
214 cc::CopyOutputRequest::CreateRequest(base::Bind( | 214 cc::CopyOutputRequest::CreateRequest( |
215 &AuraWindowCaptureMachine::DidCopyOutput, | 215 base::Bind(&AuraWindowCaptureMachine::DidCopyOutput, |
216 weak_factory_.GetWeakPtr(), frame, event_time, start_time, | 216 weak_factory_.GetWeakPtr(), std::move(frame), event_time, |
217 capture_frame_cb)); | 217 start_time, capture_frame_cb)); |
218 gfx::Rect window_rect = gfx::Rect(desktop_window_->bounds().width(), | 218 gfx::Rect window_rect = gfx::Rect(desktop_window_->bounds().width(), |
219 desktop_window_->bounds().height()); | 219 desktop_window_->bounds().height()); |
220 request->set_area(window_rect); | 220 request->set_area(window_rect); |
221 desktop_window_->layer()->RequestCopyOfOutput(std::move(request)); | 221 desktop_window_->layer()->RequestCopyOfOutput(std::move(request)); |
222 } | 222 } |
223 } | 223 } |
224 | 224 |
225 void AuraWindowCaptureMachine::DidCopyOutput( | 225 void AuraWindowCaptureMachine::DidCopyOutput( |
226 scoped_refptr<media::VideoFrame> video_frame, | 226 scoped_refptr<media::VideoFrame> video_frame, |
227 base::TimeTicks event_time, | 227 base::TimeTicks event_time, |
(...skipping 25 matching lines...) Expand all Loading... |
253 } else { | 253 } else { |
254 IncrementDesktopCaptureCounter(succeeded | 254 IncrementDesktopCaptureCounter(succeeded |
255 ? FIRST_WINDOW_CAPTURE_SUCCEEDED | 255 ? FIRST_WINDOW_CAPTURE_SUCCEEDED |
256 : FIRST_WINDOW_CAPTURE_FAILED); | 256 : FIRST_WINDOW_CAPTURE_FAILED); |
257 } | 257 } |
258 } | 258 } |
259 | 259 |
260 // If ProcessCopyOutputResponse() failed, it will not run |capture_frame_cb|, | 260 // If ProcessCopyOutputResponse() failed, it will not run |capture_frame_cb|, |
261 // so do that now. | 261 // so do that now. |
262 if (!succeeded) | 262 if (!succeeded) |
263 capture_frame_cb.Run(video_frame, event_time, false); | 263 capture_frame_cb.Run(std::move(video_frame), event_time, false); |
264 } | 264 } |
265 | 265 |
266 bool AuraWindowCaptureMachine::ProcessCopyOutputResponse( | 266 bool AuraWindowCaptureMachine::ProcessCopyOutputResponse( |
267 scoped_refptr<media::VideoFrame> video_frame, | 267 scoped_refptr<media::VideoFrame> video_frame, |
268 base::TimeTicks event_time, | 268 base::TimeTicks event_time, |
269 const CaptureFrameCallback& capture_frame_cb, | 269 const CaptureFrameCallback& capture_frame_cb, |
270 std::unique_ptr<cc::CopyOutputResult> result) { | 270 std::unique_ptr<cc::CopyOutputResult> result) { |
271 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 271 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
272 | 272 |
273 if (!desktop_window_) { | 273 if (!desktop_window_) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 return true; | 344 return true; |
345 } | 345 } |
346 | 346 |
347 using CaptureFrameCallback = | 347 using CaptureFrameCallback = |
348 media::ThreadSafeCaptureOracle::CaptureFrameCallback; | 348 media::ThreadSafeCaptureOracle::CaptureFrameCallback; |
349 | 349 |
350 void AuraWindowCaptureMachine::CopyOutputFinishedForVideo( | 350 void AuraWindowCaptureMachine::CopyOutputFinishedForVideo( |
351 base::WeakPtr<AuraWindowCaptureMachine> machine, | 351 base::WeakPtr<AuraWindowCaptureMachine> machine, |
352 base::TimeTicks event_time, | 352 base::TimeTicks event_time, |
353 const CaptureFrameCallback& capture_frame_cb, | 353 const CaptureFrameCallback& capture_frame_cb, |
354 const scoped_refptr<media::VideoFrame>& target, | 354 scoped_refptr<media::VideoFrame> target, |
355 std::unique_ptr<cc::SingleReleaseCallback> release_callback, | 355 std::unique_ptr<cc::SingleReleaseCallback> release_callback, |
356 bool result) { | 356 bool result) { |
357 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 357 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
358 | 358 |
359 release_callback->Run(gpu::SyncToken(), false); | 359 release_callback->Run(gpu::SyncToken(), false); |
360 | 360 |
361 // Render the cursor and deliver the captured frame if the | 361 // Render the cursor and deliver the captured frame if the |
362 // AuraWindowCaptureMachine has not been stopped (i.e., the WeakPtr is | 362 // AuraWindowCaptureMachine has not been stopped (i.e., the WeakPtr is |
363 // still valid). | 363 // still valid). |
364 if (machine) { | 364 if (machine) { |
365 if (machine->cursor_renderer_ && result) | 365 if (machine->cursor_renderer_ && result) |
366 machine->cursor_renderer_->RenderOnVideoFrame(target); | 366 machine->cursor_renderer_->RenderOnVideoFrame(target); |
367 } else { | 367 } else { |
368 VLOG(1) << "Aborting capture: AuraWindowCaptureMachine has gone away."; | 368 VLOG(1) << "Aborting capture: AuraWindowCaptureMachine has gone away."; |
369 result = false; | 369 result = false; |
370 } | 370 } |
371 | 371 |
372 capture_frame_cb.Run(target, event_time, result); | 372 capture_frame_cb.Run(std::move(target), event_time, result); |
373 } | 373 } |
374 | 374 |
375 void AuraWindowCaptureMachine::OnWindowBoundsChanged( | 375 void AuraWindowCaptureMachine::OnWindowBoundsChanged( |
376 aura::Window* window, | 376 aura::Window* window, |
377 const gfx::Rect& old_bounds, | 377 const gfx::Rect& old_bounds, |
378 const gfx::Rect& new_bounds) { | 378 const gfx::Rect& new_bounds) { |
379 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 379 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
380 DCHECK(desktop_window_ && window == desktop_window_); | 380 DCHECK(desktop_window_ && window == desktop_window_); |
381 | 381 |
382 // Post a task to update capture size after first returning to the event loop. | 382 // Post a task to update capture size after first returning to the event loop. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 Capture(timestamp); | 437 Capture(timestamp); |
438 } | 438 } |
439 | 439 |
440 void AuraWindowCaptureMachine::OnCompositingShuttingDown( | 440 void AuraWindowCaptureMachine::OnCompositingShuttingDown( |
441 ui::Compositor* compositor) { | 441 ui::Compositor* compositor) { |
442 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 442 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
443 compositor->RemoveAnimationObserver(this); | 443 compositor->RemoveAnimationObserver(this); |
444 } | 444 } |
445 | 445 |
446 } // namespace content | 446 } // namespace content |
OLD | NEW |