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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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->IsSurfaceAvailableForCopy()) { |
658 // Fallback to the more expensive renderer-side copy if the surface and | 658 bool success = false; |
659 // backing store are not accessible. | 659 SkBitmap empty_bitmap; |
660 rwh->GetSnapshotFromRenderer( | 660 DidCopyFromBackingStore( |
piman
2014/04/24 23:17:06
Is reentrancy ok?
danakj
2014/04/24 23:22:33
Ya, I believe so. There's no state change in this
| |
661 gfx::Rect(), | 661 start_time, target, deliver_frame_cb, success, empty_bitmap); |
662 base::Bind(&WebContentsCaptureMachine::DidCopyFromBackingStore, | |
663 weak_ptr_factory_.GetWeakPtr(), | |
664 start_time, target, deliver_frame_cb)); | |
665 } else if (view->CanCopyToVideoFrame()) { | 662 } else if (view->CanCopyToVideoFrame()) { |
666 view->CopyFromCompositingSurfaceToVideoFrame( | 663 view->CopyFromCompositingSurfaceToVideoFrame( |
667 gfx::Rect(view_size), | 664 gfx::Rect(view_size), |
668 target, | 665 target, |
669 base::Bind(&WebContentsCaptureMachine:: | 666 base::Bind(&WebContentsCaptureMachine:: |
670 DidCopyFromCompositingSurfaceToVideoFrame, | 667 DidCopyFromCompositingSurfaceToVideoFrame, |
671 weak_ptr_factory_.GetWeakPtr(), | 668 weak_ptr_factory_.GetWeakPtr(), |
672 start_time, deliver_frame_cb)); | 669 start_time, deliver_frame_cb)); |
673 } else { | 670 } else { |
674 rwh->CopyFromBackingStore( | 671 rwh->CopyFromBackingStore( |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 scoped_ptr<Client> client) { | 823 scoped_ptr<Client> client) { |
827 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 824 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
828 core_->AllocateAndStart(params, client.Pass()); | 825 core_->AllocateAndStart(params, client.Pass()); |
829 } | 826 } |
830 | 827 |
831 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { | 828 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { |
832 core_->StopAndDeAllocate(); | 829 core_->StopAndDeAllocate(); |
833 } | 830 } |
834 | 831 |
835 } // namespace content | 832 } // namespace content |
OLD | NEW |