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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 } | 647 } |
648 if (view_size != last_view_size_) { | 648 if (view_size != last_view_size_) { |
649 last_view_size_ = view_size; | 649 last_view_size_ = view_size; |
650 | 650 |
651 // Measure the number of kilopixels. | 651 // Measure the number of kilopixels. |
652 UMA_HISTOGRAM_COUNTS_10000( | 652 UMA_HISTOGRAM_COUNTS_10000( |
653 "TabCapture.ViewChangeKiloPixels", | 653 "TabCapture.ViewChangeKiloPixels", |
654 view_size.width() * view_size.height() / 1024); | 654 view_size.width() * view_size.height() / 1024); |
655 } | 655 } |
656 | 656 |
657 if (!view->IsSurfaceAvailableForCopy()) { | 657 if (view->CanCopyToVideoFrame()) { |
658 // Fallback to the more expensive renderer-side copy if the surface and | |
659 // backing store are not accessible. | |
660 rwh->GetSnapshotFromRenderer( | |
661 gfx::Rect(), | |
662 base::Bind(&WebContentsCaptureMachine::DidCopyFromBackingStore, | |
663 weak_ptr_factory_.GetWeakPtr(), | |
664 start_time, target, deliver_frame_cb)); | |
665 } else if (view->CanCopyToVideoFrame()) { | |
666 view->CopyFromCompositingSurfaceToVideoFrame( | 658 view->CopyFromCompositingSurfaceToVideoFrame( |
667 gfx::Rect(view_size), | 659 gfx::Rect(view_size), |
668 target, | 660 target, |
669 base::Bind(&WebContentsCaptureMachine:: | 661 base::Bind(&WebContentsCaptureMachine:: |
670 DidCopyFromCompositingSurfaceToVideoFrame, | 662 DidCopyFromCompositingSurfaceToVideoFrame, |
671 weak_ptr_factory_.GetWeakPtr(), | 663 weak_ptr_factory_.GetWeakPtr(), |
672 start_time, deliver_frame_cb)); | 664 start_time, deliver_frame_cb)); |
673 } else { | 665 } else { |
674 rwh->CopyFromBackingStore( | 666 rwh->CopyFromBackingStore( |
675 gfx::Rect(), | 667 gfx::Rect(), |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 scoped_ptr<Client> client) { | 818 scoped_ptr<Client> client) { |
827 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 819 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
828 core_->AllocateAndStart(params, client.Pass()); | 820 core_->AllocateAndStart(params, client.Pass()); |
829 } | 821 } |
830 | 822 |
831 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { | 823 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { |
832 core_->StopAndDeAllocate(); | 824 core_->StopAndDeAllocate(); |
833 } | 825 } |
834 | 826 |
835 } // namespace content | 827 } // namespace content |
OLD | NEW |