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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // is obtained. | 46 // is obtained. |
47 // | 47 // |
48 // Turning on verbose logging will cause the effective frame rate to be logged | 48 // Turning on verbose logging will cause the effective frame rate to be logged |
49 // at 5-second intervals. | 49 // at 5-second intervals. |
50 | 50 |
51 #include "content/browser/media/capture/web_contents_video_capture_device.h" | 51 #include "content/browser/media/capture/web_contents_video_capture_device.h" |
52 | 52 |
53 #include "base/basictypes.h" | 53 #include "base/basictypes.h" |
54 #include "base/bind.h" | 54 #include "base/bind.h" |
55 #include "base/callback_helpers.h" | 55 #include "base/callback_helpers.h" |
| 56 #include "base/location.h" |
56 #include "base/logging.h" | 57 #include "base/logging.h" |
57 #include "base/memory/scoped_ptr.h" | 58 #include "base/memory/scoped_ptr.h" |
58 #include "base/memory/weak_ptr.h" | 59 #include "base/memory/weak_ptr.h" |
59 #include "base/message_loop/message_loop_proxy.h" | |
60 #include "base/metrics/histogram.h" | 60 #include "base/metrics/histogram.h" |
61 #include "base/sequenced_task_runner.h" | 61 #include "base/sequenced_task_runner.h" |
| 62 #include "base/single_thread_task_runner.h" |
62 #include "base/threading/thread.h" | 63 #include "base/threading/thread.h" |
63 #include "base/threading/thread_checker.h" | 64 #include "base/threading/thread_checker.h" |
64 #include "base/time/time.h" | 65 #include "base/time/time.h" |
65 #include "content/browser/media/capture/content_video_capture_device_core.h" | 66 #include "content/browser/media/capture/content_video_capture_device_core.h" |
66 #include "content/browser/media/capture/video_capture_oracle.h" | 67 #include "content/browser/media/capture/video_capture_oracle.h" |
67 #include "content/browser/media/capture/web_contents_capture_util.h" | 68 #include "content/browser/media/capture/web_contents_capture_util.h" |
68 #include "content/browser/media/capture/web_contents_tracker.h" | 69 #include "content/browser/media/capture/web_contents_tracker.h" |
69 #include "content/browser/renderer_host/render_widget_host_impl.h" | 70 #include "content/browser/renderer_host/render_widget_host_impl.h" |
70 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 71 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
71 #include "content/public/browser/browser_thread.h" | 72 #include "content/public/browser/browser_thread.h" |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 const SkBitmap& bitmap, | 627 const SkBitmap& bitmap, |
627 ReadbackResponse response) { | 628 ReadbackResponse response) { |
628 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 629 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
629 | 630 |
630 base::TimeTicks now = base::TimeTicks::Now(); | 631 base::TimeTicks now = base::TimeTicks::Now(); |
631 DCHECK(render_thread_.get()); | 632 DCHECK(render_thread_.get()); |
632 if (response == READBACK_SUCCESS) { | 633 if (response == READBACK_SUCCESS) { |
633 UMA_HISTOGRAM_TIMES("TabCapture.CopyTimeBitmap", now - start_time); | 634 UMA_HISTOGRAM_TIMES("TabCapture.CopyTimeBitmap", now - start_time); |
634 TRACE_EVENT_ASYNC_STEP_INTO0("gpu.capture", "Capture", target.get(), | 635 TRACE_EVENT_ASYNC_STEP_INTO0("gpu.capture", "Capture", target.get(), |
635 "Render"); | 636 "Render"); |
636 render_thread_->message_loop_proxy()->PostTask(FROM_HERE, base::Bind( | 637 render_thread_->task_runner()->PostTask( |
637 &RenderVideoFrame, bitmap, target, | 638 FROM_HERE, base::Bind(&RenderVideoFrame, bitmap, target, |
638 base::Bind(deliver_frame_cb, start_time))); | 639 base::Bind(deliver_frame_cb, start_time))); |
639 } else { | 640 } else { |
640 // Capture can fail due to transient issues, so just skip this frame. | 641 // Capture can fail due to transient issues, so just skip this frame. |
641 DVLOG(1) << "CopyFromBackingStore failed; skipping frame."; | 642 DVLOG(1) << "CopyFromBackingStore failed; skipping frame."; |
642 deliver_frame_cb.Run(start_time, false); | 643 deliver_frame_cb.Run(start_time, false); |
643 } | 644 } |
644 } | 645 } |
645 | 646 |
646 void WebContentsCaptureMachine::DidCopyFromCompositingSurfaceToVideoFrame( | 647 void WebContentsCaptureMachine::DidCopyFromCompositingSurfaceToVideoFrame( |
647 const base::TimeTicks& start_time, | 648 const base::TimeTicks& start_time, |
648 const RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback& | 649 const RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback& |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 scoped_ptr<Client> client) { | 739 scoped_ptr<Client> client) { |
739 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 740 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
740 core_->AllocateAndStart(params, client.Pass()); | 741 core_->AllocateAndStart(params, client.Pass()); |
741 } | 742 } |
742 | 743 |
743 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { | 744 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { |
744 core_->StopAndDeAllocate(); | 745 core_->StopAndDeAllocate(); |
745 } | 746 } |
746 | 747 |
747 } // namespace content | 748 } // namespace content |
OLD | NEW |