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

Side by Side Diff: content/browser/renderer_host/delegated_frame_host.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/renderer_host/delegated_frame_host.h" 5 #include "content/browser/renderer_host/delegated_frame_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 if (!CanCopyToVideoFrame()) { 159 if (!CanCopyToVideoFrame()) {
160 callback.Run(gfx::Rect(), false); 160 callback.Run(gfx::Rect(), false);
161 return; 161 return;
162 } 162 }
163 163
164 std::unique_ptr<cc::CopyOutputRequest> request = 164 std::unique_ptr<cc::CopyOutputRequest> request =
165 cc::CopyOutputRequest::CreateRequest(base::Bind( 165 cc::CopyOutputRequest::CreateRequest(base::Bind(
166 &DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo, 166 &DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo,
167 AsWeakPtr(), // For caching the ReadbackYUVInterface on this class. 167 AsWeakPtr(), // For caching the ReadbackYUVInterface on this class.
168 nullptr, target, callback)); 168 nullptr, target, callback));
169 request->set_area(src_subrect); 169 if (!src_subrect.IsEmpty())
170 request->set_area(src_subrect);
170 RequestCopyOfOutput(std::move(request)); 171 RequestCopyOfOutput(std::move(request));
171 } 172 }
172 173
173 bool DelegatedFrameHost::CanCopyToBitmap() const { 174 bool DelegatedFrameHost::CanCopyToBitmap() const {
174 return compositor_ && 175 return compositor_ &&
175 client_->DelegatedFrameHostGetLayer()->has_external_content(); 176 client_->DelegatedFrameHostGetLayer()->has_external_content();
176 } 177 }
177 178
178 bool DelegatedFrameHost::CanCopyToVideoFrame() const { 179 bool DelegatedFrameHost::CanCopyToVideoFrame() const {
179 return compositor_ && 180 return compositor_ &&
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 if (current_frame_size_in_dip_.height() < 293 if (current_frame_size_in_dip_.height() <
293 client_->DelegatedFrameHostDesiredSizeInDIP().height()) { 294 client_->DelegatedFrameHostDesiredSizeInDIP().height()) {
294 bottom_gutter_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); 295 bottom_gutter_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
295 bottom_gutter_->SetColor(GetGutterColor()); 296 bottom_gutter_->SetColor(GetGutterColor());
296 int width = current_frame_size_in_dip_.width(); 297 int width = current_frame_size_in_dip_.width();
297 int height = client_->DelegatedFrameHostDesiredSizeInDIP().height() - 298 int height = client_->DelegatedFrameHostDesiredSizeInDIP().height() -
298 current_frame_size_in_dip_.height(); 299 current_frame_size_in_dip_.height();
299 bottom_gutter_->SetBounds( 300 bottom_gutter_->SetBounds(
300 gfx::Rect(0, current_frame_size_in_dip_.height(), width, height)); 301 gfx::Rect(0, current_frame_size_in_dip_.height(), width, height));
301 client_->DelegatedFrameHostGetLayer()->Add(bottom_gutter_.get()); 302 client_->DelegatedFrameHostGetLayer()->Add(bottom_gutter_.get());
302
303 } else { 303 } else {
304 bottom_gutter_.reset(); 304 bottom_gutter_.reset();
305 } 305 }
306 } 306 }
307 307
308 gfx::Size DelegatedFrameHost::GetRequestedRendererSize() const { 308 gfx::Size DelegatedFrameHost::GetRequestedRendererSize() const {
309 if (resize_lock_) 309 if (resize_lock_)
310 return resize_lock_->expected_size(); 310 return resize_lock_->expected_size();
311 else 311 else
312 return client_->DelegatedFrameHostDesiredSizeInDIP(); 312 return client_->DelegatedFrameHostDesiredSizeInDIP();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // DelegatedFrameHost (e.g., a call to CopyFromCompositingSurface() for 364 // DelegatedFrameHost (e.g., a call to CopyFromCompositingSurface() for
365 // screenshots) since those copy requests do not specify |frame_subscriber()| 365 // screenshots) since those copy requests do not specify |frame_subscriber()|
366 // as a source. 366 // as a source.
367 request->set_source(frame_subscriber()->GetSourceIdForCopyRequest()); 367 request->set_source(frame_subscriber()->GetSourceIdForCopyRequest());
368 if (subscriber_texture.get()) { 368 if (subscriber_texture.get()) {
369 request->SetTextureMailbox(cc::TextureMailbox( 369 request->SetTextureMailbox(cc::TextureMailbox(
370 subscriber_texture->mailbox(), subscriber_texture->sync_token(), 370 subscriber_texture->mailbox(), subscriber_texture->sync_token(),
371 subscriber_texture->target())); 371 subscriber_texture->target()));
372 } 372 }
373 373
374 if (local_surface_id_.is_valid()) { 374 RequestCopyOfOutput(std::move(request));
375 // To avoid unnecessary composites, go directly to the Surface rather than
376 // through RequestCopyOfOutput (which goes through the browser
377 // compositor).
378 if (!request_copy_of_output_callback_for_testing_.is_null())
379 request_copy_of_output_callback_for_testing_.Run(std::move(request));
380 else
381 surface_factory_->RequestCopyOfSurface(std::move(request));
382 } else {
383 request->set_area(gfx::Rect(current_frame_size_in_dip_));
384 RequestCopyOfOutput(std::move(request));
385 }
386 } 375 }
387 376
388 void DelegatedFrameHost::SwapDelegatedFrame(uint32_t compositor_frame_sink_id, 377 void DelegatedFrameHost::SwapDelegatedFrame(uint32_t compositor_frame_sink_id,
389 cc::CompositorFrame frame) { 378 cc::CompositorFrame frame) {
390 #if defined(OS_CHROMEOS) 379 #if defined(OS_CHROMEOS)
391 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled()); 380 DCHECK(!resize_lock_ || !client_->IsAutoResizeEnabled());
392 #endif 381 #endif
393 float frame_device_scale_factor = frame.metadata.device_scale_factor; 382 float frame_device_scale_factor = frame.metadata.device_scale_factor;
394 383
395 DCHECK(!frame.render_pass_list.empty()); 384 DCHECK(!frame.render_pass_list.empty());
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 // with too much entropy (which can drastically increase CPU utilization). 703 // with too much entropy (which can drastically increase CPU utilization).
715 // When up-scaling, always use "best" because the quality improvement is 704 // When up-scaling, always use "best" because the quality improvement is
716 // huge with insignificant performance penalty. Note that this strategy 705 // huge with insignificant performance penalty. Note that this strategy
717 // differs from single-frame snapshot capture. 706 // differs from single-frame snapshot capture.
718 display_compositor::GLHelper::ScalerQuality quality = 707 display_compositor::GLHelper::ScalerQuality quality =
719 ((result_rect.size().width() < region_in_frame.size().width()) && 708 ((result_rect.size().width() < region_in_frame.size().width()) &&
720 (result_rect.size().height() < region_in_frame.size().height())) 709 (result_rect.size().height() < region_in_frame.size().height()))
721 ? display_compositor::GLHelper::SCALER_QUALITY_BEST 710 ? display_compositor::GLHelper::SCALER_QUALITY_BEST
722 : display_compositor::GLHelper::SCALER_QUALITY_FAST; 711 : display_compositor::GLHelper::SCALER_QUALITY_FAST;
723 712
713 DVLOG(1) << "Re-creating YUV readback pipeline for source rect "
714 << result_rect.ToString() << " and destination size "
715 << region_in_frame.size().ToString();
716
724 dfh->yuv_readback_pipeline_.reset(gl_helper->CreateReadbackPipelineYUV( 717 dfh->yuv_readback_pipeline_.reset(gl_helper->CreateReadbackPipelineYUV(
725 quality, result_rect.size(), result_rect, region_in_frame.size(), true, 718 quality, result_rect.size(), result_rect, region_in_frame.size(), true,
726 true)); 719 true));
727 yuv_readback_pipeline = dfh->yuv_readback_pipeline_.get(); 720 yuv_readback_pipeline = dfh->yuv_readback_pipeline_.get();
728 } 721 }
729 722
730 ignore_result(scoped_callback_runner.Release()); 723 ignore_result(scoped_callback_runner.Release());
731 ignore_result(scoped_return_subscriber_texture.Release()); 724 ignore_result(scoped_return_subscriber_texture.Release());
732 725
733 base::Callback<void(bool result)> finished_callback = base::Bind( 726 base::Callback<void(bool result)> finished_callback = base::Bind(
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 849
857 void DelegatedFrameHost::LockResources() { 850 void DelegatedFrameHost::LockResources() {
858 DCHECK(local_surface_id_.is_valid()); 851 DCHECK(local_surface_id_.is_valid());
859 delegated_frame_evictor_->LockFrame(); 852 delegated_frame_evictor_->LockFrame();
860 } 853 }
861 854
862 void DelegatedFrameHost::RequestCopyOfOutput( 855 void DelegatedFrameHost::RequestCopyOfOutput(
863 std::unique_ptr<cc::CopyOutputRequest> request) { 856 std::unique_ptr<cc::CopyOutputRequest> request) {
864 if (!request_copy_of_output_callback_for_testing_.is_null()) { 857 if (!request_copy_of_output_callback_for_testing_.is_null()) {
865 request_copy_of_output_callback_for_testing_.Run(std::move(request)); 858 request_copy_of_output_callback_for_testing_.Run(std::move(request));
859 return;
860 }
861
862 // If a specific area has not been requested, set one to ensure correct
863 // clipping occurs.
864 if (!request->has_area())
865 request->set_area(gfx::Rect(current_frame_size_in_dip_));
866
867 // To avoid unnecessary browser composites, try to go directly to the Surface
868 // rather than through the Layer.
869 if (local_surface_id_.is_valid()) {
870 // Surfaces interpret the request area in terms of their own coordinate
871 // system, so adjust by the scale factor, if necessary.
872 if (current_scale_factor_ != 1.0) {
873 request->set_area(gfx::ScaleToEnclosingRect(
874 request->area(), current_scale_factor_, current_scale_factor_));
875 }
876 surface_factory_->RequestCopyOfSurface(std::move(request));
866 } else { 877 } else {
867 client_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput( 878 client_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput(
868 std::move(request)); 879 std::move(request));
869 } 880 }
870 } 881 }
871 882
872 void DelegatedFrameHost::UnlockResources() { 883 void DelegatedFrameHost::UnlockResources() {
873 DCHECK(local_surface_id_.is_valid()); 884 DCHECK(local_surface_id_.is_valid());
874 delegated_frame_evictor_->UnlockFrame(); 885 delegated_frame_evictor_->UnlockFrame();
875 } 886 }
876 887
877 } // namespace content 888 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/delegated_frame_host.h ('k') | content/browser/renderer_host/render_widget_host_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698