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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 // If the ratio between physical and logical pixels is greater than 1:1, | 660 // If the ratio between physical and logical pixels is greater than 1:1, |
661 // shrink |optimal_size| by that amount. Then, when external code resizes the | 661 // shrink |optimal_size| by that amount. Then, when external code resizes the |
662 // render widget to the "preferred size," the widget will be physically | 662 // render widget to the "preferred size," the widget will be physically |
663 // rendered at the exact capture size, thereby eliminating unnecessary scaling | 663 // rendered at the exact capture size, thereby eliminating unnecessary scaling |
664 // operations in the graphics pipeline. | 664 // operations in the graphics pipeline. |
665 RenderWidgetHost* const rwh = tracker_->GetTargetRenderWidgetHost(); | 665 RenderWidgetHost* const rwh = tracker_->GetTargetRenderWidgetHost(); |
666 RenderWidgetHostView* const rwhv = rwh ? rwh->GetView() : NULL; | 666 RenderWidgetHostView* const rwhv = rwh ? rwh->GetView() : NULL; |
667 if (rwhv) { | 667 if (rwhv) { |
668 const gfx::NativeView view = rwhv->GetNativeView(); | 668 const gfx::NativeView view = rwhv->GetNativeView(); |
669 gfx::Screen* const screen = gfx::Screen::GetScreenFor(view); | 669 gfx::Screen* const screen = gfx::Screen::GetScreenFor(view); |
670 if (screen->IsDIPEnabled()) { | 670 const gfx::Display display = screen->GetDisplayNearestWindow(view); |
671 const gfx::Display display = screen->GetDisplayNearestWindow(view); | 671 const float scale = display.device_scale_factor(); |
672 const float scale = display.device_scale_factor(); | 672 if (scale > 1.0f) { |
673 if (scale > 1.0f) { | 673 const gfx::Size shrunk_size( |
674 const gfx::Size shrunk_size( | 674 gfx::ToFlooredSize(gfx::ScaleSize(optimal_size, 1.0f / scale))); |
675 gfx::ToFlooredSize(gfx::ScaleSize(optimal_size, 1.0f / scale))); | 675 if (shrunk_size.width() > 0 && shrunk_size.height() > 0) |
676 if (shrunk_size.width() > 0 && shrunk_size.height() > 0) | 676 optimal_size = shrunk_size; |
677 optimal_size = shrunk_size; | |
678 } | |
679 } | 677 } |
680 } | 678 } |
681 | 679 |
682 VLOG(1) << "Computed optimal target size: " << optimal_size.ToString(); | 680 VLOG(1) << "Computed optimal target size: " << optimal_size.ToString(); |
683 return optimal_size; | 681 return optimal_size; |
684 } | 682 } |
685 | 683 |
686 void WebContentsCaptureMachine::DidCopyFromBackingStore( | 684 void WebContentsCaptureMachine::DidCopyFromBackingStore( |
687 const base::TimeTicks& start_time, | 685 const base::TimeTicks& start_time, |
688 const scoped_refptr<media::VideoFrame>& target, | 686 const scoped_refptr<media::VideoFrame>& target, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 scoped_ptr<Client> client) { | 786 scoped_ptr<Client> client) { |
789 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 787 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
790 core_->AllocateAndStart(params, client.Pass()); | 788 core_->AllocateAndStart(params, client.Pass()); |
791 } | 789 } |
792 | 790 |
793 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { | 791 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { |
794 core_->StopAndDeAllocate(); | 792 core_->StopAndDeAllocate(); |
795 } | 793 } |
796 | 794 |
797 } // namespace content | 795 } // namespace content |
OLD | NEW |