| 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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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     base::MessageLoop::current()->PostTask( | 750     layer_tree_host_->Composite(gfx::FrameTime::Now()); | 
| 751         FROM_HERE, base::Bind(&RenderWidgetCompositor::SynchronousCommit, |  | 
| 752                               weak_factory_.GetWeakPtr())); |  | 
| 753   } else { | 751   } else { | 
| 754     layer_tree_host_->SetNeedsCommit(); | 752     layer_tree_host_->SetNeedsCommit(); | 
| 755   } | 753   } | 
| 756 } | 754 } | 
| 757 | 755 | 
| 758 void RenderWidgetCompositor::SynchronousCommit() { |  | 
| 759   DCHECK(CommitIsSynchronous()); |  | 
| 760   layer_tree_host_->Composite(gfx::FrameTime::Now()); |  | 
| 761 } |  | 
| 762 |  | 
| 763 void RenderWidgetCompositor::finishAllRendering() { | 756 void RenderWidgetCompositor::finishAllRendering() { | 
| 764   layer_tree_host_->FinishAllRendering(); | 757   layer_tree_host_->FinishAllRendering(); | 
| 765 } | 758 } | 
| 766 | 759 | 
| 767 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { | 760 void RenderWidgetCompositor::setDeferCommits(bool defer_commits) { | 
| 768   layer_tree_host_->SetDeferCommits(defer_commits); | 761   layer_tree_host_->SetDeferCommits(defer_commits); | 
| 769 } | 762 } | 
| 770 | 763 | 
| 771 int RenderWidgetCompositor::layerTreeId() const { | 764 int RenderWidgetCompositor::layerTreeId() const { | 
| 772   return layer_tree_host_->id(); | 765   return layer_tree_host_->id(); | 
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 918       << "Failed to create a fallback OutputSurface."; | 911       << "Failed to create a fallback OutputSurface."; | 
| 919 | 912 | 
| 920   base::MessageLoop::current()->PostTask( | 913   base::MessageLoop::current()->PostTask( | 
| 921       FROM_HERE, base::Bind(&RenderWidgetCompositor::RequestNewOutputSurface, | 914       FROM_HERE, base::Bind(&RenderWidgetCompositor::RequestNewOutputSurface, | 
| 922                             weak_factory_.GetWeakPtr())); | 915                             weak_factory_.GetWeakPtr())); | 
| 923 } | 916 } | 
| 924 | 917 | 
| 925 void RenderWidgetCompositor::WillCommit() { | 918 void RenderWidgetCompositor::WillCommit() { | 
| 926   if (!layout_and_paint_async_callback_) | 919   if (!layout_and_paint_async_callback_) | 
| 927     return; | 920     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; | 
| 928   layout_and_paint_async_callback_->didLayoutAndPaint(); | 935   layout_and_paint_async_callback_->didLayoutAndPaint(); | 
| 929   layout_and_paint_async_callback_ = nullptr; | 936   layout_and_paint_async_callback_ = nullptr; | 
| 930 } | 937 } | 
| 931 | 938 | 
| 932 void RenderWidgetCompositor::DidCommit() { | 939 void RenderWidgetCompositor::DidCommit() { | 
| 933   DCHECK(!temporary_copy_output_request_); | 940   DCHECK(!temporary_copy_output_request_); | 
| 934   widget_->DidCommitCompositorFrame(); | 941   widget_->DidCommitCompositorFrame(); | 
| 935   widget_->didBecomeReadyForAdditionalInput(); | 942   widget_->didBecomeReadyForAdditionalInput(); | 
| 936   compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); | 943   compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); | 
| 937 } | 944 } | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 967   cc::ContextProvider* provider = | 974   cc::ContextProvider* provider = | 
| 968       compositor_deps_->GetSharedMainThreadContextProvider(); | 975       compositor_deps_->GetSharedMainThreadContextProvider(); | 
| 969   // provider can be NULL after the GPU process crashed enough times and we | 976   // provider can be NULL after the GPU process crashed enough times and we | 
| 970   // don't want to restart it any more (falling back to software). | 977   // don't want to restart it any more (falling back to software). | 
| 971   if (!provider) | 978   if (!provider) | 
| 972     return; | 979     return; | 
| 973   provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 980   provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 
| 974 } | 981 } | 
| 975 | 982 | 
| 976 }  // namespace content | 983 }  // namespace content | 
| OLD | NEW | 
|---|