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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 // shrink |optimal_size| by that amount. Then, when external code resizes the | 683 // shrink |optimal_size| by that amount. Then, when external code resizes the |
684 // render widget to the "preferred size," the widget will be physically | 684 // render widget to the "preferred size," the widget will be physically |
685 // rendered at the exact capture size, thereby eliminating unnecessary scaling | 685 // rendered at the exact capture size, thereby eliminating unnecessary scaling |
686 // operations in the graphics pipeline. | 686 // operations in the graphics pipeline. |
687 RenderWidgetHost* const rwh = tracker_->GetTargetRenderWidgetHost(); | 687 RenderWidgetHost* const rwh = tracker_->GetTargetRenderWidgetHost(); |
688 RenderWidgetHostView* const rwhv = rwh ? rwh->GetView() : NULL; | 688 RenderWidgetHostView* const rwhv = rwh ? rwh->GetView() : NULL; |
689 if (rwhv) { | 689 if (rwhv) { |
690 const gfx::NativeView view = rwhv->GetNativeView(); | 690 const gfx::NativeView view = rwhv->GetNativeView(); |
691 const float scale = ui::GetScaleFactorForNativeView(view); | 691 const float scale = ui::GetScaleFactorForNativeView(view); |
692 if (scale > 1.0f) { | 692 if (scale > 1.0f) { |
693 const gfx::Size shrunk_size( | 693 const gfx::Size shrunk_size = |
694 gfx::ToFlooredSize(gfx::ScaleSize(optimal_size, 1.0f / scale))); | 694 gfx::ScaleToFlooredSize(optimal_size, 1.0f / scale); |
695 if (shrunk_size.width() > 0 && shrunk_size.height() > 0) | 695 if (shrunk_size.width() > 0 && shrunk_size.height() > 0) |
696 optimal_size = shrunk_size; | 696 optimal_size = shrunk_size; |
697 } | 697 } |
698 } | 698 } |
699 | 699 |
700 VLOG(1) << "Computed optimal target size: " << optimal_size.ToString(); | 700 VLOG(1) << "Computed optimal target size: " << optimal_size.ToString(); |
701 return optimal_size; | 701 return optimal_size; |
702 } | 702 } |
703 | 703 |
704 void WebContentsCaptureMachine::DidCopyFromBackingStore( | 704 void WebContentsCaptureMachine::DidCopyFromBackingStore( |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 scoped_ptr<Client> client) { | 836 scoped_ptr<Client> client) { |
837 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 837 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
838 core_->AllocateAndStart(params, client.Pass()); | 838 core_->AllocateAndStart(params, client.Pass()); |
839 } | 839 } |
840 | 840 |
841 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { | 841 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { |
842 core_->StopAndDeAllocate(); | 842 core_->StopAndDeAllocate(); |
843 } | 843 } |
844 | 844 |
845 } // namespace content | 845 } // namespace content |
OLD | NEW |