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 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 DCHECK(!temporary_copy_output_request_ && !layout_and_paint_async_callback_); | 733 DCHECK(!temporary_copy_output_request_ && !layout_and_paint_async_callback_); |
734 temporary_copy_output_request_ = | 734 temporary_copy_output_request_ = |
735 cc::CopyOutputRequest::CreateBitmapRequest( | 735 cc::CopyOutputRequest::CreateBitmapRequest( |
736 base::Bind(&CompositeAndReadbackAsyncCallback, callback)); | 736 base::Bind(&CompositeAndReadbackAsyncCallback, callback)); |
737 // Force a commit to happen. The temporary copy output request will | 737 // Force a commit to happen. The temporary copy output request will |
738 // be installed after layout which will happen as a part of the commit, for | 738 // be installed after layout which will happen as a part of the commit, for |
739 // widgets that delay the creation of their output surface. | 739 // widgets that delay the creation of their output surface. |
740 ScheduleCommit(); | 740 ScheduleCommit(); |
741 } | 741 } |
742 | 742 |
743 bool RenderWidgetCompositor::CommitIsSynchronous() const { | 743 bool RenderWidgetCompositor::CommitIsSynchronous() const |
no sievers
2015/05/07 17:57:56
nit: move brace back up
Xianzhu
2015/05/07 18:05:36
Done.
| |
744 { | |
744 return !compositor_deps_->GetCompositorImplThreadTaskRunner().get() && | 745 return !compositor_deps_->GetCompositorImplThreadTaskRunner().get() && |
745 !layer_tree_host_->settings().single_thread_proxy_scheduler; | 746 !layer_tree_host_->settings().single_thread_proxy_scheduler; |
746 } | 747 } |
747 | 748 |
748 void RenderWidgetCompositor::ScheduleCommit() { | 749 void RenderWidgetCompositor::ScheduleCommit() { |
749 if (CommitIsSynchronous()) { | 750 if (CommitIsSynchronous()) { |
750 layer_tree_host_->Composite(gfx::FrameTime::Now()); | 751 base::MessageLoop::current()->PostTask( |
752 FROM_HERE, base::Bind(&RenderWidgetCompositor::SynchronousCommit, | |
753 weak_factory_.GetWeakPtr())); | |
751 } else { | 754 } else { |
752 layer_tree_host_->SetNeedsCommit(); | 755 layer_tree_host_->SetNeedsCommit(); |
753 } | 756 } |
754 } | 757 } |
755 | 758 |
759 void RenderWidgetCompositor::SynchronousCommit() { | |
760 DCHECK(CommitIsSynchronous()); | |
761 layer_tree_host_->Composite(gfx::FrameTime::Now()); | |
762 } | |
763 | |
756 void RenderWidgetCompositor::finishAllRendering() { | 764 void RenderWidgetCompositor::finishAllRendering() { |
757 layer_tree_host_->FinishAllRendering(); | 765 layer_tree_host_->FinishAllRendering(); |
758 } | 766 } |
759 | 767 |
760 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { | 768 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { |
761 layer_tree_host_->SetDeferCommits(defer_commits); | 769 layer_tree_host_->SetDeferCommits(defer_commits); |
762 } | 770 } |
763 | 771 |
764 int RenderWidgetCompositor::layerTreeId() const { | 772 int RenderWidgetCompositor::layerTreeId() const { |
765 return layer_tree_host_->id(); | 773 return layer_tree_host_->id(); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
911 << "Failed to create a fallback OutputSurface."; | 919 << "Failed to create a fallback OutputSurface."; |
912 | 920 |
913 base::MessageLoop::current()->PostTask( | 921 base::MessageLoop::current()->PostTask( |
914 FROM_HERE, base::Bind(&RenderWidgetCompositor::RequestNewOutputSurface, | 922 FROM_HERE, base::Bind(&RenderWidgetCompositor::RequestNewOutputSurface, |
915 weak_factory_.GetWeakPtr())); | 923 weak_factory_.GetWeakPtr())); |
916 } | 924 } |
917 | 925 |
918 void RenderWidgetCompositor::WillCommit() { | 926 void RenderWidgetCompositor::WillCommit() { |
919 if (!layout_and_paint_async_callback_) | 927 if (!layout_and_paint_async_callback_) |
920 return; | 928 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(); | 929 layout_and_paint_async_callback_->didLayoutAndPaint(); |
936 layout_and_paint_async_callback_ = nullptr; | 930 layout_and_paint_async_callback_ = nullptr; |
937 } | 931 } |
938 | 932 |
939 void RenderWidgetCompositor::DidCommit() { | 933 void RenderWidgetCompositor::DidCommit() { |
940 DCHECK(!temporary_copy_output_request_); | 934 DCHECK(!temporary_copy_output_request_); |
941 widget_->DidCommitCompositorFrame(); | 935 widget_->DidCommitCompositorFrame(); |
942 widget_->didBecomeReadyForAdditionalInput(); | 936 widget_->didBecomeReadyForAdditionalInput(); |
943 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); | 937 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); |
944 } | 938 } |
(...skipping 29 matching lines...) Expand all Loading... | |
974 cc::ContextProvider* provider = | 968 cc::ContextProvider* provider = |
975 compositor_deps_->GetSharedMainThreadContextProvider(); | 969 compositor_deps_->GetSharedMainThreadContextProvider(); |
976 // provider can be NULL after the GPU process crashed enough times and we | 970 // 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). | 971 // don't want to restart it any more (falling back to software). |
978 if (!provider) | 972 if (!provider) |
979 return; | 973 return; |
980 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 974 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
981 } | 975 } |
982 | 976 |
983 } // namespace content | 977 } // namespace content |
OLD | NEW |