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

Side by Side Diff: content/renderer/gpu/render_widget_compositor.cc

Issue 1126313004: Let layoutAndPaintAsync() schedule commit asynchronously (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Format Created 5 years, 7 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
« no previous file with comments | « content/renderer/gpu/render_widget_compositor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 ScheduleCommit(); 740 ScheduleCommit();
741 } 741 }
742 742
743 bool RenderWidgetCompositor::CommitIsSynchronous() const { 743 bool RenderWidgetCompositor::CommitIsSynchronous() const {
744 return !compositor_deps_->GetCompositorImplThreadTaskRunner().get() && 744 return !compositor_deps_->GetCompositorImplThreadTaskRunner().get() &&
745 !layer_tree_host_->settings().single_thread_proxy_scheduler; 745 !layer_tree_host_->settings().single_thread_proxy_scheduler;
746 } 746 }
747 747
748 void RenderWidgetCompositor::ScheduleCommit() { 748 void RenderWidgetCompositor::ScheduleCommit() {
749 if (CommitIsSynchronous()) { 749 if (CommitIsSynchronous()) {
750 layer_tree_host_->Composite(gfx::FrameTime::Now()); 750 base::MessageLoop::current()->PostTask(
751 FROM_HERE, base::Bind(&RenderWidgetCompositor::SynchronousCommit,
752 weak_factory_.GetWeakPtr()));
751 } else { 753 } else {
752 layer_tree_host_->SetNeedsCommit(); 754 layer_tree_host_->SetNeedsCommit();
753 } 755 }
754 } 756 }
755 757
758 void RenderWidgetCompositor::SynchronousCommit() {
759 DCHECK(CommitIsSynchronous());
760 layer_tree_host_->Composite(gfx::FrameTime::Now());
761 }
762
756 void RenderWidgetCompositor::finishAllRendering() { 763 void RenderWidgetCompositor::finishAllRendering() {
757 layer_tree_host_->FinishAllRendering(); 764 layer_tree_host_->FinishAllRendering();
758 } 765 }
759 766
760 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { 767 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) {
761 layer_tree_host_->SetDeferCommits(defer_commits); 768 layer_tree_host_->SetDeferCommits(defer_commits);
762 } 769 }
763 770
764 int RenderWidgetCompositor::layerTreeId() const { 771 int RenderWidgetCompositor::layerTreeId() const {
765 return layer_tree_host_->id(); 772 return layer_tree_host_->id();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 << "Failed to create a fallback OutputSurface."; 918 << "Failed to create a fallback OutputSurface.";
912 919
913 base::MessageLoop::current()->PostTask( 920 base::MessageLoop::current()->PostTask(
914 FROM_HERE, base::Bind(&RenderWidgetCompositor::RequestNewOutputSurface, 921 FROM_HERE, base::Bind(&RenderWidgetCompositor::RequestNewOutputSurface,
915 weak_factory_.GetWeakPtr())); 922 weak_factory_.GetWeakPtr()));
916 } 923 }
917 924
918 void RenderWidgetCompositor::WillCommit() { 925 void RenderWidgetCompositor::WillCommit() {
919 if (!layout_and_paint_async_callback_) 926 if (!layout_and_paint_async_callback_)
920 return; 927 return;
921
922 if (CommitIsSynchronous()) {
923 // The caller expects the callback to be called asynchronously.
924 base::MessageLoop::current()->PostTask(
925 FROM_HERE, base::Bind(&RenderWidgetCompositor::DidLayoutAndPaintAsync,
926 weak_factory_.GetWeakPtr()));
927 } else {
928 DidLayoutAndPaintAsync();
929 }
930 }
931
932 void RenderWidgetCompositor::DidLayoutAndPaintAsync() {
933 if (!layout_and_paint_async_callback_)
934 return;
935 layout_and_paint_async_callback_->didLayoutAndPaint(); 928 layout_and_paint_async_callback_->didLayoutAndPaint();
936 layout_and_paint_async_callback_ = nullptr; 929 layout_and_paint_async_callback_ = nullptr;
937 } 930 }
938 931
939 void RenderWidgetCompositor::DidCommit() { 932 void RenderWidgetCompositor::DidCommit() {
940 DCHECK(!temporary_copy_output_request_); 933 DCHECK(!temporary_copy_output_request_);
941 widget_->DidCommitCompositorFrame(); 934 widget_->DidCommitCompositorFrame();
942 widget_->didBecomeReadyForAdditionalInput(); 935 widget_->didBecomeReadyForAdditionalInput();
943 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); 936 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor();
944 } 937 }
(...skipping 29 matching lines...) Expand all
974 cc::ContextProvider* provider = 967 cc::ContextProvider* provider =
975 compositor_deps_->GetSharedMainThreadContextProvider(); 968 compositor_deps_->GetSharedMainThreadContextProvider();
976 // provider can be NULL after the GPU process crashed enough times and we 969 // provider can be NULL after the GPU process crashed enough times and we
977 // don't want to restart it any more (falling back to software). 970 // don't want to restart it any more (falling back to software).
978 if (!provider) 971 if (!provider)
979 return; 972 return;
980 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); 973 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM();
981 } 974 }
982 975
983 } // namespace content 976 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gpu/render_widget_compositor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698