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

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

Issue 2654413002: Stretching NativeViewHost, and misc tab capture fixes.
Patch Set: Gettin' it all working on ui/cocoa and MacViews too. 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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 deliver_frame_cb) { 545 deliver_frame_cb) {
546 DCHECK_CURRENTLY_ON(BrowserThread::UI); 546 DCHECK_CURRENTLY_ON(BrowserThread::UI);
547 547
548 auto* const view = 548 auto* const view =
549 static_cast<RenderWidgetHostViewBase*>(tracker_->GetTargetView()); 549 static_cast<RenderWidgetHostViewBase*>(tracker_->GetTargetView());
550 if (!view || !view->CanCopyToVideoFrame()) { 550 if (!view || !view->CanCopyToVideoFrame()) {
551 deliver_frame_cb.Run(base::TimeTicks(), gfx::Rect(), false); 551 deliver_frame_cb.Run(base::TimeTicks(), gfx::Rect(), false);
552 return; 552 return;
553 } 553 }
554 554
555 const gfx::Size view_size = view->GetViewBounds().size();
556 view->CopyFromCompositingSurfaceToVideoFrame( 555 view->CopyFromCompositingSurfaceToVideoFrame(
557 gfx::Rect(view_size), std::move(target), 556 gfx::Rect(), std::move(target),
558 base::Bind(&WebContentsCaptureMachine::DidCopyToVideoFrame, 557 base::Bind(&WebContentsCaptureMachine::DidCopyToVideoFrame,
559 weak_ptr_factory_.GetWeakPtr(), start_time, deliver_frame_cb)); 558 weak_ptr_factory_.GetWeakPtr(), start_time, deliver_frame_cb));
560 } 559 }
561 560
562 gfx::Size WebContentsCaptureMachine::ComputeOptimalViewSize() const { 561 gfx::Size WebContentsCaptureMachine::ComputeOptimalViewSize() const {
563 DCHECK_CURRENTLY_ON(BrowserThread::UI); 562 DCHECK_CURRENTLY_ON(BrowserThread::UI);
564 563
565 // TODO(miu): Propagate capture frame size changes as new "preferred size" 564 // TODO(miu): Propagate capture frame size changes as new "preferred size"
566 // updates, rather than just using the max frame size. 565 // updates, rather than just using the max frame size.
567 // http://crbug.com/350491 566 // http://crbug.com/350491
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 678
680 void WebContentsCaptureMachine::UpdateCaptureSize() { 679 void WebContentsCaptureMachine::UpdateCaptureSize() {
681 DCHECK_CURRENTLY_ON(BrowserThread::UI); 680 DCHECK_CURRENTLY_ON(BrowserThread::UI);
682 681
683 if (!oracle_proxy_) 682 if (!oracle_proxy_)
684 return; 683 return;
685 RenderWidgetHostView* const view = tracker_->GetTargetView(); 684 RenderWidgetHostView* const view = tracker_->GetTargetView();
686 if (!view) 685 if (!view)
687 return; 686 return;
688 687
689 // Convert the view's size from the DIP coordinate space to the pixel 688 // The capture size is not the view's size in DIP coordinates, but instead
690 // coordinate space. When the view is being rendered on a high-DPI display, 689 // based on the backing store. Thus, when a view is being rendered on a high-
691 // this allows the high-resolution image detail to propagate through to the 690 // DPI display, the high-resolution image detail will propagate through to the
692 // captured video. 691 // captured video.
693 const gfx::Size view_size = view->GetViewBounds().size(); 692 const gfx::Size physical_size =
694 const gfx::Size physical_size = gfx::ConvertSizeToPixel( 693 static_cast<RenderWidgetHostViewBase*>(view)->GetPhysicalBackingSize();
695 ui::GetScaleFactorForNativeView(view->GetNativeView()), view_size); 694 VLOG(1) << "Physical capture size of view is " << physical_size.ToString();
696 VLOG(1) << "Computed physical capture size (" << physical_size.ToString()
697 << ") from view size (" << view_size.ToString() << ").";
698
699 oracle_proxy_->UpdateCaptureSize(physical_size); 695 oracle_proxy_->UpdateCaptureSize(physical_size);
700 } 696 }
701 697
702 } // namespace 698 } // namespace
703 699
704 WebContentsVideoCaptureDevice::WebContentsVideoCaptureDevice( 700 WebContentsVideoCaptureDevice::WebContentsVideoCaptureDevice(
705 int render_process_id, 701 int render_process_id,
706 int main_render_frame_id, 702 int main_render_frame_id,
707 bool enable_auto_throttling) 703 bool enable_auto_throttling)
708 : core_(new media::ScreenCaptureDeviceCore( 704 : core_(new media::ScreenCaptureDeviceCore(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { 748 void WebContentsVideoCaptureDevice::StopAndDeAllocate() {
753 core_->StopAndDeAllocate(); 749 core_->StopAndDeAllocate();
754 } 750 }
755 751
756 void WebContentsVideoCaptureDevice::OnUtilizationReport(int frame_feedback_id, 752 void WebContentsVideoCaptureDevice::OnUtilizationReport(int frame_feedback_id,
757 double utilization) { 753 double utilization) {
758 core_->OnConsumerReportingUtilization(frame_feedback_id, utilization); 754 core_->OnConsumerReportingUtilization(frame_feedback_id, utilization);
759 } 755 }
760 756
761 } // namespace content 757 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/capture/cursor_renderer_aura.cc ('k') | content/browser/renderer_host/delegated_frame_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698