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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 const CaptureFrameCallback& capture_frame_cb, | 100 const CaptureFrameCallback& capture_frame_cb, |
101 const scoped_refptr<media::VideoFrame>& target, | 101 const scoped_refptr<media::VideoFrame>& target, |
102 const SkBitmap& cursor_bitmap, | 102 const SkBitmap& cursor_bitmap, |
103 const gfx::Point& cursor_position, | 103 const gfx::Point& cursor_position, |
104 scoped_ptr<cc::SingleReleaseCallback> release_callback, | 104 scoped_ptr<cc::SingleReleaseCallback> release_callback, |
105 bool result) { | 105 bool result) { |
106 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 106 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
107 | 107 |
108 if (!cursor_bitmap.isNull()) | 108 if (!cursor_bitmap.isNull()) |
109 RenderCursorOnVideoFrame(target, cursor_bitmap, cursor_position); | 109 RenderCursorOnVideoFrame(target, cursor_bitmap, cursor_position); |
110 release_callback->Run(0, false); | 110 release_callback->Run(0, gpu::SyncToken(), false); |
111 | 111 |
112 // Only deliver the captured frame if the AuraWindowCaptureMachine has not | 112 // Only deliver the captured frame if the AuraWindowCaptureMachine has not |
113 // been stopped (i.e., the WeakPtr is still valid). | 113 // been stopped (i.e., the WeakPtr is still valid). |
114 if (machine.get()) | 114 if (machine.get()) |
115 capture_frame_cb.Run(target, start_time, result); | 115 capture_frame_cb.Run(target, start_time, result); |
116 } | 116 } |
117 | 117 |
118 void RunSingleReleaseCallback(scoped_ptr<cc::SingleReleaseCallback> cb, | 118 void RunSingleReleaseCallback(scoped_ptr<cc::SingleReleaseCallback> cb, |
119 uint32 sync_point) { | 119 uint32 sync_point, |
120 cb->Run(sync_point, false); | 120 const gpu::SyncToken& sync_token) { |
| 121 cb->Run(sync_point, sync_token, false); |
121 } | 122 } |
122 | 123 |
123 } // namespace | 124 } // namespace |
124 | 125 |
125 AuraWindowCaptureMachine::AuraWindowCaptureMachine() | 126 AuraWindowCaptureMachine::AuraWindowCaptureMachine() |
126 : desktop_window_(NULL), | 127 : desktop_window_(NULL), |
127 timer_(true, true), | 128 timer_(true, true), |
128 screen_capture_(false), | 129 screen_capture_(false), |
129 weak_factory_(this) {} | 130 weak_factory_(this) {} |
130 | 131 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 capture_params_.requested_format.pixel_format); | 329 capture_params_.requested_format.pixel_format); |
329 DCHECK(!video_frame.get()); | 330 DCHECK(!video_frame.get()); |
330 cc::TextureMailbox texture_mailbox; | 331 cc::TextureMailbox texture_mailbox; |
331 scoped_ptr<cc::SingleReleaseCallback> release_callback; | 332 scoped_ptr<cc::SingleReleaseCallback> release_callback; |
332 result->TakeTexture(&texture_mailbox, &release_callback); | 333 result->TakeTexture(&texture_mailbox, &release_callback); |
333 DCHECK(texture_mailbox.IsTexture()); | 334 DCHECK(texture_mailbox.IsTexture()); |
334 if (!texture_mailbox.IsTexture()) | 335 if (!texture_mailbox.IsTexture()) |
335 return false; | 336 return false; |
336 video_frame = media::VideoFrame::WrapNativeTexture( | 337 video_frame = media::VideoFrame::WrapNativeTexture( |
337 media::PIXEL_FORMAT_ARGB, | 338 media::PIXEL_FORMAT_ARGB, |
338 gpu::MailboxHolder(texture_mailbox.mailbox(), texture_mailbox.target(), | 339 gpu::MailboxHolder( |
339 texture_mailbox.sync_point()), | 340 texture_mailbox.mailbox(), texture_mailbox.sync_point(), |
| 341 texture_mailbox.sync_token(), texture_mailbox.target()), |
340 base::Bind(&RunSingleReleaseCallback, base::Passed(&release_callback)), | 342 base::Bind(&RunSingleReleaseCallback, base::Passed(&release_callback)), |
341 result->size(), gfx::Rect(result->size()), result->size(), | 343 result->size(), gfx::Rect(result->size()), result->size(), |
342 base::TimeDelta()); | 344 base::TimeDelta()); |
343 capture_frame_cb.Run(video_frame, start_time, true); | 345 capture_frame_cb.Run(video_frame, start_time, true); |
344 return true; | 346 return true; |
345 } else { | 347 } else { |
346 DCHECK(video_frame.get()); | 348 DCHECK(video_frame.get()); |
347 } | 349 } |
348 | 350 |
349 // Compute the dest size we want after the letterboxing resize. Make the | 351 // Compute the dest size we want after the letterboxing resize. Make the |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 gl_helper->CreateReadbackPipelineYUV(GLHelper::SCALER_QUALITY_FAST, | 384 gl_helper->CreateReadbackPipelineYUV(GLHelper::SCALER_QUALITY_FAST, |
383 result_rect.size(), | 385 result_rect.size(), |
384 result_rect, | 386 result_rect, |
385 region_in_frame.size(), | 387 region_in_frame.size(), |
386 true, | 388 true, |
387 true)); | 389 true)); |
388 } | 390 } |
389 | 391 |
390 gfx::Point cursor_position_in_frame = UpdateCursorState(region_in_frame); | 392 gfx::Point cursor_position_in_frame = UpdateCursorState(region_in_frame); |
391 yuv_readback_pipeline_->ReadbackYUV( | 393 yuv_readback_pipeline_->ReadbackYUV( |
392 texture_mailbox.mailbox(), | 394 texture_mailbox.mailbox(), texture_mailbox.sync_point(), |
393 texture_mailbox.sync_point(), | 395 texture_mailbox.sync_token(), video_frame.get(), region_in_frame.origin(), |
394 video_frame.get(), | 396 base::Bind(&CopyOutputFinishedForVideo, weak_factory_.GetWeakPtr(), |
395 region_in_frame.origin(), | 397 start_time, capture_frame_cb, video_frame, |
396 base::Bind(&CopyOutputFinishedForVideo, | 398 scaled_cursor_bitmap_, cursor_position_in_frame, |
397 weak_factory_.GetWeakPtr(), | |
398 start_time, | |
399 capture_frame_cb, | |
400 video_frame, | |
401 scaled_cursor_bitmap_, | |
402 cursor_position_in_frame, | |
403 base::Passed(&release_callback))); | 399 base::Passed(&release_callback))); |
404 return true; | 400 return true; |
405 } | 401 } |
406 | 402 |
407 gfx::Point AuraWindowCaptureMachine::UpdateCursorState( | 403 gfx::Point AuraWindowCaptureMachine::UpdateCursorState( |
408 const gfx::Rect& region_in_frame) { | 404 const gfx::Rect& region_in_frame) { |
409 const gfx::Rect window_bounds = desktop_window_->GetBoundsInScreen(); | 405 const gfx::Rect window_bounds = desktop_window_->GetBoundsInScreen(); |
410 gfx::Point cursor_position = aura::Env::GetInstance()->last_mouse_location(); | 406 gfx::Point cursor_position = aura::Env::GetInstance()->last_mouse_location(); |
411 if (!window_bounds.Contains(cursor_position)) { | 407 if (!window_bounds.Contains(cursor_position)) { |
412 // Return early if there is no need to draw the cursor. | 408 // Return early if there is no need to draw the cursor. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 // TODO(miu): The CopyOutputRequest should be made earlier, at WillCommit(). | 508 // TODO(miu): The CopyOutputRequest should be made earlier, at WillCommit(). |
513 // http://crbug.com/492839 | 509 // http://crbug.com/492839 |
514 BrowserThread::PostTask( | 510 BrowserThread::PostTask( |
515 BrowserThread::UI, | 511 BrowserThread::UI, |
516 FROM_HERE, | 512 FROM_HERE, |
517 base::Bind(&AuraWindowCaptureMachine::Capture, weak_factory_.GetWeakPtr(), | 513 base::Bind(&AuraWindowCaptureMachine::Capture, weak_factory_.GetWeakPtr(), |
518 true)); | 514 true)); |
519 } | 515 } |
520 | 516 |
521 } // namespace content | 517 } // namespace content |
OLD | NEW |