Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: content/browser/media/capture/web_contents_video_capture_device.cc

Issue 2688413007: Add display::GetDisplayNearestView (Closed)
Patch Set: add missing files Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "content/browser/media/capture/web_contents_video_capture_device.h" 5 #include "content/browser/media/capture/web_contents_video_capture_device.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 } 603 }
604 } 604 }
605 605
606 // If the ratio between physical and logical pixels is greater than 1:1, 606 // If the ratio between physical and logical pixels is greater than 1:1,
607 // shrink |optimal_size| by that amount. Then, when external code resizes the 607 // shrink |optimal_size| by that amount. Then, when external code resizes the
608 // render widget to the "preferred size," the widget will be physically 608 // render widget to the "preferred size," the widget will be physically
609 // rendered at the exact capture size, thereby eliminating unnecessary scaling 609 // rendered at the exact capture size, thereby eliminating unnecessary scaling
610 // operations in the graphics pipeline. 610 // operations in the graphics pipeline.
611 if (auto* rwhv = tracker_->GetTargetView()) { 611 if (auto* rwhv = tracker_->GetTargetView()) {
612 const gfx::NativeView view = rwhv->GetNativeView(); 612 const gfx::NativeView view = rwhv->GetNativeView();
613 const float scale = ui::GetScaleFactorForNativeView(view); 613 const float scale = GetScaleFactorForNativeView(view);
614 if (scale > 1.0f) { 614 if (scale > 1.0f) {
615 const gfx::Size shrunk_size = 615 const gfx::Size shrunk_size =
616 gfx::ScaleToFlooredSize(optimal_size, 1.0f / scale); 616 gfx::ScaleToFlooredSize(optimal_size, 1.0f / scale);
617 if (shrunk_size.width() > 0 && shrunk_size.height() > 0) 617 if (shrunk_size.width() > 0 && shrunk_size.height() > 0)
618 optimal_size = shrunk_size; 618 optimal_size = shrunk_size;
619 } 619 }
620 } 620 }
621 621
622 VLOG(1) << "Computed optimal target size: " << optimal_size.ToString(); 622 VLOG(1) << "Computed optimal target size: " << optimal_size.ToString();
623 return optimal_size; 623 return optimal_size;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 RenderWidgetHostView* const view = tracker_->GetTargetView(); 685 RenderWidgetHostView* const view = tracker_->GetTargetView();
686 if (!view) 686 if (!view)
687 return; 687 return;
688 688
689 // Convert the view's size from the DIP coordinate space to the pixel 689 // Convert the view's size from the DIP coordinate space to the pixel
690 // coordinate space. When the view is being rendered on a high-DPI display, 690 // coordinate space. When the view is being rendered on a high-DPI display,
691 // this allows the high-resolution image detail to propagate through to the 691 // this allows the high-resolution image detail to propagate through to the
692 // captured video. 692 // captured video.
693 const gfx::Size view_size = view->GetViewBounds().size(); 693 const gfx::Size view_size = view->GetViewBounds().size();
694 const gfx::Size physical_size = gfx::ConvertSizeToPixel( 694 const gfx::Size physical_size = gfx::ConvertSizeToPixel(
695 ui::GetScaleFactorForNativeView(view->GetNativeView()), view_size); 695 view->GetNativeView()->GetScaleFactorForNativeView(), view_size);
696 VLOG(1) << "Computed physical capture size (" << physical_size.ToString() 696 VLOG(1) << "Computed physical capture size (" << physical_size.ToString()
697 << ") from view size (" << view_size.ToString() << ")."; 697 << ") from view size (" << view_size.ToString() << ").";
698 698
699 oracle_proxy_->UpdateCaptureSize(physical_size); 699 oracle_proxy_->UpdateCaptureSize(physical_size);
700 } 700 }
701 701
702 } // namespace 702 } // namespace
703 703
704 WebContentsVideoCaptureDevice::WebContentsVideoCaptureDevice( 704 WebContentsVideoCaptureDevice::WebContentsVideoCaptureDevice(
705 int render_process_id, 705 int render_process_id,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { 752 void WebContentsVideoCaptureDevice::StopAndDeAllocate() {
753 core_->StopAndDeAllocate(); 753 core_->StopAndDeAllocate();
754 } 754 }
755 755
756 void WebContentsVideoCaptureDevice::OnUtilizationReport(int frame_feedback_id, 756 void WebContentsVideoCaptureDevice::OnUtilizationReport(int frame_feedback_id,
757 double utilization) { 757 double utilization) {
758 core_->OnConsumerReportingUtilization(frame_feedback_id, utilization); 758 core_->OnConsumerReportingUtilization(frame_feedback_id, utilization);
759 } 759 }
760 760
761 } // namespace content 761 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698