OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Implementation notes: This needs to work on a variety of hardware | 5 // Implementation notes: This needs to work on a variety of hardware |
6 // configurations where the speed of the CPU and GPU greatly affect overall | 6 // configurations where the speed of the CPU and GPU greatly affect overall |
7 // performance. Spanning several threads, the process of capturing has been | 7 // performance. Spanning several threads, the process of capturing has been |
8 // split up into four conceptual stages: | 8 // split up into four conceptual stages: |
9 // | 9 // |
10 // 1. Reserve Buffer: Before a frame can be captured, a slot in the client's | 10 // 1. Reserve Buffer: Before a frame can be captured, a slot in the client's |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 251 |
252 // Computes the preferred size of the target RenderWidget for optimal capture. | 252 // Computes the preferred size of the target RenderWidget for optimal capture. |
253 gfx::Size ComputeOptimalTargetSize() const; | 253 gfx::Size ComputeOptimalTargetSize() const; |
254 | 254 |
255 // Response callback for RenderWidgetHost::CopyFromBackingStore(). | 255 // Response callback for RenderWidgetHost::CopyFromBackingStore(). |
256 void DidCopyFromBackingStore( | 256 void DidCopyFromBackingStore( |
257 const base::TimeTicks& start_time, | 257 const base::TimeTicks& start_time, |
258 const scoped_refptr<media::VideoFrame>& target, | 258 const scoped_refptr<media::VideoFrame>& target, |
259 const RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback& | 259 const RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback& |
260 deliver_frame_cb, | 260 deliver_frame_cb, |
261 bool success, | 261 const SkBitmap& bitmap, |
262 const SkBitmap& bitmap); | 262 const ReadbackResponse& response); |
263 | 263 |
264 // Response callback for RWHVP::CopyFromCompositingSurfaceToVideoFrame(). | 264 // Response callback for RWHVP::CopyFromCompositingSurfaceToVideoFrame(). |
265 void DidCopyFromCompositingSurfaceToVideoFrame( | 265 void DidCopyFromCompositingSurfaceToVideoFrame( |
266 const base::TimeTicks& start_time, | 266 const base::TimeTicks& start_time, |
267 const RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback& | 267 const RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback& |
268 deliver_frame_cb, | 268 deliver_frame_cb, |
269 bool success); | 269 bool success); |
270 | 270 |
271 // Remove the old subscription, and start a new one if |rwh| is not NULL. | 271 // Remove the old subscription, and start a new one if |rwh| is not NULL. |
272 void RenewFrameSubscription(RenderWidgetHost* rwh); | 272 void RenewFrameSubscription(RenderWidgetHost* rwh); |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 | 679 |
680 VLOG(1) << "Computed optimal target size: " << optimal_size.ToString(); | 680 VLOG(1) << "Computed optimal target size: " << optimal_size.ToString(); |
681 return optimal_size; | 681 return optimal_size; |
682 } | 682 } |
683 | 683 |
684 void WebContentsCaptureMachine::DidCopyFromBackingStore( | 684 void WebContentsCaptureMachine::DidCopyFromBackingStore( |
685 const base::TimeTicks& start_time, | 685 const base::TimeTicks& start_time, |
686 const scoped_refptr<media::VideoFrame>& target, | 686 const scoped_refptr<media::VideoFrame>& target, |
687 const RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback& | 687 const RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback& |
688 deliver_frame_cb, | 688 deliver_frame_cb, |
689 bool success, | 689 const SkBitmap& bitmap, |
690 const SkBitmap& bitmap) { | 690 const ReadbackResponse& response) { |
691 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 691 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
692 | 692 |
693 base::TimeTicks now = base::TimeTicks::Now(); | 693 base::TimeTicks now = base::TimeTicks::Now(); |
694 DCHECK(render_thread_.get()); | 694 DCHECK(render_thread_.get()); |
695 if (success) { | 695 if (response == READBACK_SUCCESS) { |
696 UMA_HISTOGRAM_TIMES("TabCapture.CopyTimeBitmap", now - start_time); | 696 UMA_HISTOGRAM_TIMES("TabCapture.CopyTimeBitmap", now - start_time); |
697 TRACE_EVENT_ASYNC_STEP_INTO0("mirroring", "Capture", target.get(), | 697 TRACE_EVENT_ASYNC_STEP_INTO0("mirroring", "Capture", target.get(), |
698 "Render"); | 698 "Render"); |
699 render_thread_->message_loop_proxy()->PostTask(FROM_HERE, base::Bind( | 699 render_thread_->message_loop_proxy()->PostTask(FROM_HERE, base::Bind( |
700 &RenderVideoFrame, bitmap, target, | 700 &RenderVideoFrame, bitmap, target, |
701 base::Bind(deliver_frame_cb, start_time))); | 701 base::Bind(deliver_frame_cb, start_time))); |
702 } else { | 702 } else { |
703 // Capture can fail due to transient issues, so just skip this frame. | 703 // Capture can fail due to transient issues, so just skip this frame. |
704 DVLOG(1) << "CopyFromBackingStore failed; skipping frame."; | 704 DVLOG(1) << "CopyFromBackingStore failed; skipping frame."; |
705 deliver_frame_cb.Run(start_time, false); | 705 deliver_frame_cb.Run(start_time, false); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 scoped_ptr<Client> client) { | 786 scoped_ptr<Client> client) { |
787 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 787 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
788 core_->AllocateAndStart(params, client.Pass()); | 788 core_->AllocateAndStart(params, client.Pass()); |
789 } | 789 } |
790 | 790 |
791 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { | 791 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { |
792 core_->StopAndDeAllocate(); | 792 core_->StopAndDeAllocate(); |
793 } | 793 } |
794 | 794 |
795 } // namespace content | 795 } // namespace content |
OLD | NEW |