OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/renderer/gpu/render_widget_compositor.h" | 5 #include "content/renderer/gpu/render_widget_compositor.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 } | 698 } |
699 } | 699 } |
700 | 700 |
701 void RenderWidgetCompositor::compositeAndReadbackAsync( | 701 void RenderWidgetCompositor::compositeAndReadbackAsync( |
702 blink::WebCompositeAndReadbackAsyncCallback* callback) { | 702 blink::WebCompositeAndReadbackAsyncCallback* callback) { |
703 DCHECK(!temporary_copy_output_request_); | 703 DCHECK(!temporary_copy_output_request_); |
704 temporary_copy_output_request_ = | 704 temporary_copy_output_request_ = |
705 cc::CopyOutputRequest::CreateBitmapRequest( | 705 cc::CopyOutputRequest::CreateBitmapRequest( |
706 base::Bind(&CompositeAndReadbackAsyncCallback, callback)); | 706 base::Bind(&CompositeAndReadbackAsyncCallback, callback)); |
707 // Force a commit to happen. The temporary copy output request will | 707 // Force a commit to happen. The temporary copy output request will |
708 // be installed after layout which will happen as a part of the commit, when | 708 // be installed after layout which will happen as a part of the commit, for |
709 // there is guaranteed to be a root layer. | 709 // widgets that delay the creation of their output surface. |
710 bool threaded = !!compositor_deps_->GetCompositorImplThreadTaskRunner().get(); | 710 bool threaded = !!compositor_deps_->GetCompositorImplThreadTaskRunner().get(); |
711 if (!threaded && | 711 if (!threaded && |
712 !layer_tree_host_->settings().single_thread_proxy_scheduler) { | 712 !layer_tree_host_->settings().single_thread_proxy_scheduler) { |
713 layer_tree_host_->Composite(gfx::FrameTime::Now()); | 713 layer_tree_host_->Composite(gfx::FrameTime::Now()); |
714 } else { | 714 } else { |
715 layer_tree_host_->SetNeedsCommit(); | 715 layer_tree_host_->SetNeedsCommit(); |
716 } | 716 } |
717 } | 717 } |
718 | 718 |
719 void RenderWidgetCompositor::finishAllRendering() { | 719 void RenderWidgetCompositor::finishAllRendering() { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 } | 791 } |
792 | 792 |
793 void RenderWidgetCompositor::BeginMainFrameNotExpectedSoon() { | 793 void RenderWidgetCompositor::BeginMainFrameNotExpectedSoon() { |
794 compositor_deps_->GetRendererScheduler()->BeginFrameNotExpectedSoon(); | 794 compositor_deps_->GetRendererScheduler()->BeginFrameNotExpectedSoon(); |
795 } | 795 } |
796 | 796 |
797 void RenderWidgetCompositor::Layout() { | 797 void RenderWidgetCompositor::Layout() { |
798 widget_->webwidget()->layout(); | 798 widget_->webwidget()->layout(); |
799 | 799 |
800 if (temporary_copy_output_request_) { | 800 if (temporary_copy_output_request_) { |
801 DCHECK(layer_tree_host_->root_layer()); | 801 // For WebViewImpl, this will always have a root layer. For other widgets, |
802 layer_tree_host_->root_layer()->RequestCopyOfOutput( | 802 // the widget may be closed before servicing this request, so ignore it. |
803 temporary_copy_output_request_.Pass()); | 803 if (cc::Layer* root_layer = layer_tree_host_->root_layer()) { |
| 804 root_layer->RequestCopyOfOutput(temporary_copy_output_request_.Pass()); |
| 805 } else { |
| 806 temporary_copy_output_request_->SendEmptyResult(); |
| 807 temporary_copy_output_request_ = nullptr; |
| 808 } |
804 } | 809 } |
805 } | 810 } |
806 | 811 |
807 void RenderWidgetCompositor::ApplyViewportDeltas( | 812 void RenderWidgetCompositor::ApplyViewportDeltas( |
808 const gfx::Vector2dF& inner_delta, | 813 const gfx::Vector2dF& inner_delta, |
809 const gfx::Vector2dF& outer_delta, | 814 const gfx::Vector2dF& outer_delta, |
810 const gfx::Vector2dF& elastic_overscroll_delta, | 815 const gfx::Vector2dF& elastic_overscroll_delta, |
811 float page_scale, | 816 float page_scale, |
812 float top_controls_delta) { | 817 float top_controls_delta) { |
813 widget_->webwidget()->applyViewportDeltas( | 818 widget_->webwidget()->applyViewportDeltas( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 cc::ContextProvider* provider = | 915 cc::ContextProvider* provider = |
911 compositor_deps_->GetSharedMainThreadContextProvider(); | 916 compositor_deps_->GetSharedMainThreadContextProvider(); |
912 // provider can be NULL after the GPU process crashed enough times and we | 917 // provider can be NULL after the GPU process crashed enough times and we |
913 // don't want to restart it any more (falling back to software). | 918 // don't want to restart it any more (falling back to software). |
914 if (!provider) | 919 if (!provider) |
915 return; | 920 return; |
916 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 921 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
917 } | 922 } |
918 | 923 |
919 } // namespace content | 924 } // namespace content |
OLD | NEW |