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(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 const gpu::SyncToken& sync_token) { |
120 cb->Run(sync_point, false); | 120 cb->Run(sync_token, false); |
121 } | 121 } |
122 | 122 |
123 } // namespace | 123 } // namespace |
124 | 124 |
125 AuraWindowCaptureMachine::AuraWindowCaptureMachine() | 125 AuraWindowCaptureMachine::AuraWindowCaptureMachine() |
126 : desktop_window_(NULL), | 126 : desktop_window_(NULL), |
127 timer_(true, true), | 127 timer_(true, true), |
128 screen_capture_(false), | 128 screen_capture_(false), |
129 weak_factory_(this) {} | 129 weak_factory_(this) {} |
130 | 130 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 capture_params_.requested_format.pixel_format); | 328 capture_params_.requested_format.pixel_format); |
329 DCHECK(!video_frame.get()); | 329 DCHECK(!video_frame.get()); |
330 cc::TextureMailbox texture_mailbox; | 330 cc::TextureMailbox texture_mailbox; |
331 scoped_ptr<cc::SingleReleaseCallback> release_callback; | 331 scoped_ptr<cc::SingleReleaseCallback> release_callback; |
332 result->TakeTexture(&texture_mailbox, &release_callback); | 332 result->TakeTexture(&texture_mailbox, &release_callback); |
333 DCHECK(texture_mailbox.IsTexture()); | 333 DCHECK(texture_mailbox.IsTexture()); |
334 if (!texture_mailbox.IsTexture()) | 334 if (!texture_mailbox.IsTexture()) |
335 return false; | 335 return false; |
336 video_frame = media::VideoFrame::WrapNativeTexture( | 336 video_frame = media::VideoFrame::WrapNativeTexture( |
337 media::PIXEL_FORMAT_ARGB, | 337 media::PIXEL_FORMAT_ARGB, |
338 gpu::MailboxHolder(texture_mailbox.mailbox(), texture_mailbox.target(), | 338 gpu::MailboxHolder(texture_mailbox.mailbox(), |
339 texture_mailbox.sync_point()), | 339 texture_mailbox.sync_token(), |
| 340 texture_mailbox.target()), |
340 base::Bind(&RunSingleReleaseCallback, base::Passed(&release_callback)), | 341 base::Bind(&RunSingleReleaseCallback, base::Passed(&release_callback)), |
341 result->size(), gfx::Rect(result->size()), result->size(), | 342 result->size(), gfx::Rect(result->size()), result->size(), |
342 base::TimeDelta()); | 343 base::TimeDelta()); |
343 capture_frame_cb.Run(video_frame, start_time, true); | 344 capture_frame_cb.Run(video_frame, start_time, true); |
344 return true; | 345 return true; |
345 } else { | 346 } else { |
346 DCHECK(video_frame.get()); | 347 DCHECK(video_frame.get()); |
347 } | 348 } |
348 | 349 |
349 // Compute the dest size we want after the letterboxing resize. Make the | 350 // 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, | 383 gl_helper->CreateReadbackPipelineYUV(GLHelper::SCALER_QUALITY_FAST, |
383 result_rect.size(), | 384 result_rect.size(), |
384 result_rect, | 385 result_rect, |
385 region_in_frame.size(), | 386 region_in_frame.size(), |
386 true, | 387 true, |
387 true)); | 388 true)); |
388 } | 389 } |
389 | 390 |
390 gfx::Point cursor_position_in_frame = UpdateCursorState(region_in_frame); | 391 gfx::Point cursor_position_in_frame = UpdateCursorState(region_in_frame); |
391 yuv_readback_pipeline_->ReadbackYUV( | 392 yuv_readback_pipeline_->ReadbackYUV( |
392 texture_mailbox.mailbox(), | 393 texture_mailbox.mailbox(), texture_mailbox.sync_token(), |
393 texture_mailbox.sync_point(), | 394 video_frame.get(), region_in_frame.origin(), |
394 video_frame.get(), | 395 base::Bind(&CopyOutputFinishedForVideo, weak_factory_.GetWeakPtr(), |
395 region_in_frame.origin(), | 396 start_time, capture_frame_cb, video_frame, |
396 base::Bind(&CopyOutputFinishedForVideo, | 397 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))); | 398 base::Passed(&release_callback))); |
404 return true; | 399 return true; |
405 } | 400 } |
406 | 401 |
407 gfx::Point AuraWindowCaptureMachine::UpdateCursorState( | 402 gfx::Point AuraWindowCaptureMachine::UpdateCursorState( |
408 const gfx::Rect& region_in_frame) { | 403 const gfx::Rect& region_in_frame) { |
409 const gfx::Rect window_bounds = desktop_window_->GetBoundsInScreen(); | 404 const gfx::Rect window_bounds = desktop_window_->GetBoundsInScreen(); |
410 gfx::Point cursor_position = aura::Env::GetInstance()->last_mouse_location(); | 405 gfx::Point cursor_position = aura::Env::GetInstance()->last_mouse_location(); |
411 if (!window_bounds.Contains(cursor_position)) { | 406 if (!window_bounds.Contains(cursor_position)) { |
412 // Return early if there is no need to draw the cursor. | 407 // 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(). | 507 // TODO(miu): The CopyOutputRequest should be made earlier, at WillCommit(). |
513 // http://crbug.com/492839 | 508 // http://crbug.com/492839 |
514 BrowserThread::PostTask( | 509 BrowserThread::PostTask( |
515 BrowserThread::UI, | 510 BrowserThread::UI, |
516 FROM_HERE, | 511 FROM_HERE, |
517 base::Bind(&AuraWindowCaptureMachine::Capture, weak_factory_.GetWeakPtr(), | 512 base::Bind(&AuraWindowCaptureMachine::Capture, weak_factory_.GetWeakPtr(), |
518 true)); | 513 true)); |
519 } | 514 } |
520 | 515 |
521 } // namespace content | 516 } // namespace content |
OLD | NEW |