| 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 consumer's | 10 // 1. Reserve Buffer: Before a frame can be captured, a slot in the consumer's |
| (...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 // Measure the number of kilopixels. | 982 // Measure the number of kilopixels. |
| 983 UMA_HISTOGRAM_COUNTS_10000( | 983 UMA_HISTOGRAM_COUNTS_10000( |
| 984 "TabCapture.ViewChangeKiloPixels", | 984 "TabCapture.ViewChangeKiloPixels", |
| 985 view_size.width() * view_size.height() / 1024); | 985 view_size.width() * view_size.height() / 1024); |
| 986 } | 986 } |
| 987 } | 987 } |
| 988 | 988 |
| 989 TRACE_EVENT_ASYNC_BEGIN1("mirroring", "Capture", this, | 989 TRACE_EVENT_ASYNC_BEGIN1("mirroring", "Capture", this, |
| 990 "frame_number", frame_number); | 990 "frame_number", frame_number); |
| 991 | 991 |
| 992 if (!view->IsSurfaceAvailableForCopy()) { | 992 if (view && view->CanCopyToVideoFrame()) { |
| 993 // Fallback to the more expensive renderer-side copy if the surface and | |
| 994 // backing store are not accessible. | |
| 995 rwh->GetSnapshotFromRenderer( | |
| 996 gfx::Rect(), | |
| 997 base::Bind(&BackingStoreCopier::DidCopyFromBackingStore, | |
| 998 base::Unretained(this), frame_number, | |
| 999 base::Time::Now(), callback)); | |
| 1000 } else if (view && view->CanCopyToVideoFrame()) { | |
| 1001 gfx::Size view_size = view->GetViewBounds().size(); | 993 gfx::Size view_size = view->GetViewBounds().size(); |
| 1002 | 994 |
| 1003 view->CopyFromCompositingSurfaceToVideoFrame( | 995 view->CopyFromCompositingSurfaceToVideoFrame( |
| 1004 gfx::Rect(view_size), | 996 gfx::Rect(view_size), |
| 1005 target, | 997 target, |
| 1006 base::Bind( | 998 base::Bind( |
| 1007 &BackingStoreCopier::DidCopyFromCompositingSurfaceToVideoFrame, | 999 &BackingStoreCopier::DidCopyFromCompositingSurfaceToVideoFrame, |
| 1008 base::Unretained(this), frame_number, | 1000 base::Unretained(this), frame_number, |
| 1009 base::Time::Now(), callback)); | 1001 base::Time::Now(), callback)); |
| 1010 } else { | 1002 } else { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 capturer_->SetConsumer(NULL); | 1112 capturer_->SetConsumer(NULL); |
| 1121 capturer_->DeAllocate(); | 1113 capturer_->DeAllocate(); |
| 1122 } | 1114 } |
| 1123 | 1115 |
| 1124 const media::VideoCaptureDevice::Name& | 1116 const media::VideoCaptureDevice::Name& |
| 1125 WebContentsVideoCaptureDevice::device_name() { | 1117 WebContentsVideoCaptureDevice::device_name() { |
| 1126 return device_name_; | 1118 return device_name_; |
| 1127 } | 1119 } |
| 1128 | 1120 |
| 1129 } // namespace content | 1121 } // namespace content |
| OLD | NEW |