| OLD | NEW | 
|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/single_thread_proxy.h" | 5 #include "cc/trees/single_thread_proxy.h" | 
| 6 | 6 | 
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" | 
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" | 
| 9 #include "cc/debug/benchmark_instrumentation.h" | 9 #include "cc/debug/benchmark_instrumentation.h" | 
| 10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 26   return make_scoped_ptr( | 26   return make_scoped_ptr( | 
| 27       new SingleThreadProxy(layer_tree_host, client)).PassAs<Proxy>(); | 27       new SingleThreadProxy(layer_tree_host, client)).PassAs<Proxy>(); | 
| 28 } | 28 } | 
| 29 | 29 | 
| 30 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host, | 30 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host, | 
| 31                                      LayerTreeHostSingleThreadClient* client) | 31                                      LayerTreeHostSingleThreadClient* client) | 
| 32     : Proxy(NULL), | 32     : Proxy(NULL), | 
| 33       layer_tree_host_(layer_tree_host), | 33       layer_tree_host_(layer_tree_host), | 
| 34       client_(client), | 34       client_(client), | 
| 35       next_frame_is_newly_committed_frame_(false), | 35       next_frame_is_newly_committed_frame_(false), | 
| 36       inside_draw_(false), | 36       inside_draw_(false) { | 
| 37       defer_commits_(false), |  | 
| 38       commit_was_deferred_(false), |  | 
| 39       commit_requested_(false), |  | 
| 40       weak_factory_(this) { |  | 
| 41   TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 37   TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 
| 42   DCHECK(Proxy::IsMainThread()); | 38   DCHECK(Proxy::IsMainThread()); | 
| 43   DCHECK(layer_tree_host); | 39   DCHECK(layer_tree_host); | 
| 44 | 40 | 
| 45   // Impl-side painting not supported without threaded compositing. | 41   // Impl-side painting not supported without threaded compositing. | 
| 46   CHECK(!layer_tree_host->settings().impl_side_painting) | 42   CHECK(!layer_tree_host->settings().impl_side_painting) | 
| 47       << "Threaded compositing must be enabled to use impl-side painting."; | 43       << "Threaded compositing must be enabled to use impl-side painting."; | 
| 48 } | 44 } | 
| 49 | 45 | 
| 50 void SingleThreadProxy::Start() { | 46 void SingleThreadProxy::Start() { | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 70 | 66 | 
| 71 bool SingleThreadProxy::IsStarted() const { | 67 bool SingleThreadProxy::IsStarted() const { | 
| 72   DCHECK(Proxy::IsMainThread()); | 68   DCHECK(Proxy::IsMainThread()); | 
| 73   return layer_tree_host_impl_; | 69   return layer_tree_host_impl_; | 
| 74 } | 70 } | 
| 75 | 71 | 
| 76 void SingleThreadProxy::SetLayerTreeHostClientReady() { | 72 void SingleThreadProxy::SetLayerTreeHostClientReady() { | 
| 77   TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); | 73   TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); | 
| 78   // Scheduling is controlled by the embedder in the single thread case, so | 74   // Scheduling is controlled by the embedder in the single thread case, so | 
| 79   // nothing to do. | 75   // nothing to do. | 
| 80   DCHECK(Proxy::IsMainThread()); |  | 
| 81   DebugScopedSetImplThread impl(this); |  | 
| 82   if (layer_tree_host_->settings().single_thread_proxy_scheduler && |  | 
| 83       !scheduler_on_impl_thread_) { |  | 
| 84     SchedulerSettings scheduler_settings(layer_tree_host_->settings()); |  | 
| 85     scheduler_on_impl_thread_ = Scheduler::Create(this, |  | 
| 86                                                   scheduler_settings, |  | 
| 87                                                   layer_tree_host_->id(), |  | 
| 88                                                   MainThreadTaskRunner()); |  | 
| 89     scheduler_on_impl_thread_->SetCanStart(); |  | 
| 90     scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |  | 
| 91   } |  | 
| 92 } | 76 } | 
| 93 | 77 | 
| 94 void SingleThreadProxy::SetVisible(bool visible) { | 78 void SingleThreadProxy::SetVisible(bool visible) { | 
| 95   TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); | 79   TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); | 
| 96   DebugScopedSetImplThread impl(this); | 80   DebugScopedSetImplThread impl(this); | 
| 97   layer_tree_host_impl_->SetVisible(visible); | 81   layer_tree_host_impl_->SetVisible(visible); | 
| 98   if (scheduler_on_impl_thread_) | 82 | 
| 99     scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |  | 
| 100   // Changing visibility could change ShouldComposite(). | 83   // Changing visibility could change ShouldComposite(). | 
| 101   UpdateBackgroundAnimateTicking(); | 84   UpdateBackgroundAnimateTicking(); | 
| 102 } | 85 } | 
| 103 | 86 | 
| 104 void SingleThreadProxy::CreateAndInitializeOutputSurface() { | 87 void SingleThreadProxy::CreateAndInitializeOutputSurface() { | 
| 105   TRACE_EVENT0( | 88   TRACE_EVENT0( | 
| 106       "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); | 89       "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); | 
| 107   DCHECK(Proxy::IsMainThread()); | 90   DCHECK(Proxy::IsMainThread()); | 
| 108   DCHECK(layer_tree_host_->output_surface_lost()); | 91   DCHECK(layer_tree_host_->output_surface_lost()); | 
| 109 | 92 | 
| 110   scoped_ptr<OutputSurface> output_surface = | 93   scoped_ptr<OutputSurface> output_surface = | 
| 111       layer_tree_host_->CreateOutputSurface(); | 94       layer_tree_host_->CreateOutputSurface(); | 
| 112 | 95 | 
| 113   renderer_capabilities_for_main_thread_ = RendererCapabilities(); | 96   renderer_capabilities_for_main_thread_ = RendererCapabilities(); | 
| 114 | 97 | 
| 115   bool success = !!output_surface; | 98   bool success = !!output_surface; | 
| 116   if (success) { | 99   if (success) { | 
| 117     DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 100     DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 
| 118     DebugScopedSetImplThread impl(this); | 101     DebugScopedSetImplThread impl(this); | 
| 119     layer_tree_host_->DeleteContentsTexturesOnImplThread( | 102     layer_tree_host_->DeleteContentsTexturesOnImplThread( | 
| 120         layer_tree_host_impl_->resource_provider()); | 103         layer_tree_host_impl_->resource_provider()); | 
| 121     success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); | 104     success = layer_tree_host_impl_->InitializeRenderer(output_surface.Pass()); | 
| 122   } | 105   } | 
| 123 | 106 | 
| 124   layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); | 107   layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); | 
| 125 | 108 | 
| 126   if (success) { | 109   if (!success) { | 
| 127     if (scheduler_on_impl_thread_) | 110     // Force another recreation attempt to happen by requesting another commit. | 
| 128       scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); | 111     SetNeedsCommit(); | 
| 129   } else if (Proxy::MainThreadTaskRunner()) { |  | 
| 130     Proxy::MainThreadTaskRunner()->PostTask( |  | 
| 131         FROM_HERE, |  | 
| 132         base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface, |  | 
| 133                    weak_factory_.GetWeakPtr())); |  | 
| 134   } | 112   } | 
| 135 } | 113 } | 
| 136 | 114 | 
| 137 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 115 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 
| 138   DCHECK(Proxy::IsMainThread()); | 116   DCHECK(Proxy::IsMainThread()); | 
| 139   DCHECK(!layer_tree_host_->output_surface_lost()); | 117   DCHECK(!layer_tree_host_->output_surface_lost()); | 
| 140   return renderer_capabilities_for_main_thread_; | 118   return renderer_capabilities_for_main_thread_; | 
| 141 } | 119 } | 
| 142 | 120 | 
| 143 void SingleThreadProxy::SetNeedsAnimate() { | 121 void SingleThreadProxy::SetNeedsAnimate() { | 
| 144   TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); | 122   TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); | 
| 145   DCHECK(Proxy::IsMainThread()); | 123   DCHECK(Proxy::IsMainThread()); | 
| 146   client_->ScheduleAnimation(); | 124   client_->ScheduleAnimation(); | 
| 147   SetNeedsCommit(); |  | 
| 148 } | 125 } | 
| 149 | 126 | 
| 150 void SingleThreadProxy::SetNeedsUpdateLayers() { | 127 void SingleThreadProxy::SetNeedsUpdateLayers() { | 
| 151   TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); | 128   TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); | 
| 152   DCHECK(Proxy::IsMainThread()); | 129   DCHECK(Proxy::IsMainThread()); | 
| 153   SetNeedsCommit(); | 130   client_->ScheduleComposite(); | 
| 154 } | 131 } | 
| 155 | 132 | 
| 156 void SingleThreadProxy::DoCommit(base::TimeTicks frame_begin_time) { | 133 void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { | 
| 157   TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); | 134   TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); | 
| 158   DCHECK(Proxy::IsMainThread()); | 135   DCHECK(Proxy::IsMainThread()); | 
| 159   layer_tree_host_->WillBeginMainFrame(); |  | 
| 160   layer_tree_host_->Layout(); |  | 
| 161   layer_tree_host_->UpdateClientAnimations(frame_begin_time); |  | 
| 162   layer_tree_host_->AnimateLayers(frame_begin_time); |  | 
| 163   commit_requested_ = false; |  | 
| 164 |  | 
| 165   if (PrioritizedResourceManager* contents_texture_manager = |  | 
| 166           layer_tree_host_->contents_texture_manager()) { |  | 
| 167     contents_texture_manager->UnlinkAndClearEvictedBackings(); |  | 
| 168     contents_texture_manager->SetMaxMemoryLimitBytes( |  | 
| 169         layer_tree_host_impl_->memory_allocation_limit_bytes()); |  | 
| 170     contents_texture_manager->SetExternalPriorityCutoff( |  | 
| 171         layer_tree_host_impl_->memory_allocation_priority_cutoff()); |  | 
| 172   } |  | 
| 173 |  | 
| 174   scoped_ptr<ResourceUpdateQueue> queue = |  | 
| 175       make_scoped_ptr(new ResourceUpdateQueue); |  | 
| 176 |  | 
| 177   layer_tree_host_->UpdateLayers(queue.get()); |  | 
| 178 |  | 
| 179   layer_tree_host_->WillCommit(); |  | 
| 180 |  | 
| 181   // Commit immediately. | 136   // Commit immediately. | 
| 182   { | 137   { | 
| 183     DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 138     DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 
| 184     DebugScopedSetImplThread impl(this); | 139     DebugScopedSetImplThread impl(this); | 
| 185 | 140 | 
| 186     // This CapturePostTasks should be destroyed before CommitComplete() is | 141     // This CapturePostTasks should be destroyed before CommitComplete() is | 
| 187     // called since that goes out to the embedder, and we want the embedder | 142     // called since that goes out to the embedder, and we want the embedder | 
| 188     // to receive its callbacks before that. | 143     // to receive its callbacks before that. | 
| 189     BlockingTaskRunner::CapturePostTasks blocked; | 144     BlockingTaskRunner::CapturePostTasks blocked; | 
| 190 | 145 | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 204             layer_tree_host_impl_->resource_provider()); | 159             layer_tree_host_impl_->resource_provider()); | 
| 205     update_controller->Finalize(); | 160     update_controller->Finalize(); | 
| 206 | 161 | 
| 207     if (layer_tree_host_impl_->EvictedUIResourcesExist()) | 162     if (layer_tree_host_impl_->EvictedUIResourcesExist()) | 
| 208       layer_tree_host_->RecreateUIResources(); | 163       layer_tree_host_->RecreateUIResources(); | 
| 209 | 164 | 
| 210     layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); | 165     layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); | 
| 211 | 166 | 
| 212     layer_tree_host_impl_->CommitComplete(); | 167     layer_tree_host_impl_->CommitComplete(); | 
| 213 | 168 | 
| 214     UpdateBackgroundAnimateTicking(); |  | 
| 215 |  | 
| 216 #if DCHECK_IS_ON | 169 #if DCHECK_IS_ON | 
| 217     // In the single-threaded case, the scale and scroll deltas should never be | 170     // In the single-threaded case, the scale and scroll deltas should never be | 
| 218     // touched on the impl layer tree. | 171     // touched on the impl layer tree. | 
| 219     scoped_ptr<ScrollAndScaleSet> scroll_info = | 172     scoped_ptr<ScrollAndScaleSet> scroll_info = | 
| 220         layer_tree_host_impl_->ProcessScrollDeltas(); | 173         layer_tree_host_impl_->ProcessScrollDeltas(); | 
| 221     DCHECK(!scroll_info->scrolls.size()); | 174     DCHECK(!scroll_info->scrolls.size()); | 
| 222     DCHECK_EQ(1.f, scroll_info->page_scale_delta); | 175     DCHECK_EQ(1.f, scroll_info->page_scale_delta); | 
| 223 #endif | 176 #endif | 
| 224 | 177 | 
| 225     RenderingStatsInstrumentation* stats_instrumentation = | 178     RenderingStatsInstrumentation* stats_instrumentation = | 
| 226         layer_tree_host_->rendering_stats_instrumentation(); | 179         layer_tree_host_->rendering_stats_instrumentation(); | 
| 227     BenchmarkInstrumentation::IssueMainThreadRenderingStatsEvent( | 180     BenchmarkInstrumentation::IssueMainThreadRenderingStatsEvent( | 
| 228         stats_instrumentation->main_thread_rendering_stats()); | 181         stats_instrumentation->main_thread_rendering_stats()); | 
| 229     stats_instrumentation->AccumulateAndClearMainThreadStats(); | 182     stats_instrumentation->AccumulateAndClearMainThreadStats(); | 
| 230   } | 183   } | 
| 231   layer_tree_host_->CommitComplete(); | 184   layer_tree_host_->CommitComplete(); | 
| 232   layer_tree_host_->DidBeginMainFrame(); |  | 
| 233   timing_history_.DidCommit(); |  | 
| 234 |  | 
| 235   next_frame_is_newly_committed_frame_ = true; | 185   next_frame_is_newly_committed_frame_ = true; | 
| 236 } | 186 } | 
| 237 | 187 | 
| 238 void SingleThreadProxy::SetNeedsCommit() { | 188 void SingleThreadProxy::SetNeedsCommit() { | 
| 239   DCHECK(Proxy::IsMainThread()); | 189   DCHECK(Proxy::IsMainThread()); | 
| 240   DebugScopedSetImplThread impl(this); |  | 
| 241   client_->ScheduleComposite(); | 190   client_->ScheduleComposite(); | 
| 242   if (scheduler_on_impl_thread_) |  | 
| 243     scheduler_on_impl_thread_->SetNeedsCommit(); |  | 
| 244   commit_requested_ = true; |  | 
| 245 } | 191 } | 
| 246 | 192 | 
| 247 void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { | 193 void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { | 
| 248   TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw"); | 194   TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw"); | 
| 249   DCHECK(Proxy::IsMainThread()); | 195   SetNeedsRedrawRectOnImplThread(damage_rect); | 
| 250   DebugScopedSetImplThread impl(this); |  | 
| 251   client_->ScheduleComposite(); | 196   client_->ScheduleComposite(); | 
| 252   SetNeedsRedrawRectOnImplThread(damage_rect); |  | 
| 253 } | 197 } | 
| 254 | 198 | 
| 255 void SingleThreadProxy::SetNextCommitWaitsForActivation() { | 199 void SingleThreadProxy::SetNextCommitWaitsForActivation() { | 
| 256   // There is no activation here other than commit. So do nothing. | 200   // There is no activation here other than commit. So do nothing. | 
| 257   DCHECK(Proxy::IsMainThread()); |  | 
| 258 } | 201 } | 
| 259 | 202 | 
| 260 void SingleThreadProxy::SetDeferCommits(bool defer_commits) { | 203 void SingleThreadProxy::SetDeferCommits(bool defer_commits) { | 
| 261   DCHECK(Proxy::IsMainThread()); | 204   // Thread-only feature. | 
| 262   // Deferring commits only makes sense if there's a scheduler. | 205   NOTREACHED(); | 
| 263   if (!scheduler_on_impl_thread_) |  | 
| 264     return; |  | 
| 265   if (defer_commits_ == defer_commits) |  | 
| 266     return; |  | 
| 267 |  | 
| 268   if (defer_commits) |  | 
| 269     TRACE_EVENT_ASYNC_BEGIN0("cc", "SingleThreadProxy::SetDeferCommits", this); |  | 
| 270   else |  | 
| 271     TRACE_EVENT_ASYNC_END0("cc", "SingleThreadProxy::SetDeferCommits", this); |  | 
| 272 |  | 
| 273   defer_commits_ = defer_commits; |  | 
| 274   if (!defer_commits_ && commit_was_deferred_) { |  | 
| 275     scheduler_on_impl_thread_->NotifyBeginMainFrameStarted(); |  | 
| 276     scheduler_on_impl_thread_->NotifyReadyToCommit(); |  | 
| 277     commit_was_deferred_ = false; |  | 
| 278   } |  | 
| 279 } | 206 } | 
| 280 | 207 | 
| 281 bool SingleThreadProxy::CommitRequested() const { | 208 bool SingleThreadProxy::CommitRequested() const { return false; } | 
| 282   DCHECK(Proxy::IsMainThread()); |  | 
| 283   return commit_requested_; |  | 
| 284 } |  | 
| 285 | 209 | 
| 286 bool SingleThreadProxy::BeginMainFrameRequested() const { | 210 bool SingleThreadProxy::BeginMainFrameRequested() const { return false; } | 
| 287   DCHECK(Proxy::IsMainThread()); |  | 
| 288   return commit_requested_; |  | 
| 289 } |  | 
| 290 | 211 | 
| 291 size_t SingleThreadProxy::MaxPartialTextureUpdates() const { | 212 size_t SingleThreadProxy::MaxPartialTextureUpdates() const { | 
| 292   return std::numeric_limits<size_t>::max(); | 213   return std::numeric_limits<size_t>::max(); | 
| 293 } | 214 } | 
| 294 | 215 | 
| 295 void SingleThreadProxy::Stop() { | 216 void SingleThreadProxy::Stop() { | 
| 296   TRACE_EVENT0("cc", "SingleThreadProxy::stop"); | 217   TRACE_EVENT0("cc", "SingleThreadProxy::stop"); | 
| 297   DCHECK(Proxy::IsMainThread()); | 218   DCHECK(Proxy::IsMainThread()); | 
| 298   { | 219   { | 
| 299     DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 220     DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 
| 300     DebugScopedSetImplThread impl(this); | 221     DebugScopedSetImplThread impl(this); | 
| 301 | 222 | 
| 302     BlockingTaskRunner::CapturePostTasks blocked; | 223     BlockingTaskRunner::CapturePostTasks blocked; | 
| 303     layer_tree_host_->DeleteContentsTexturesOnImplThread( | 224     layer_tree_host_->DeleteContentsTexturesOnImplThread( | 
| 304         layer_tree_host_impl_->resource_provider()); | 225         layer_tree_host_impl_->resource_provider()); | 
| 305     scheduler_on_impl_thread_.reset(); |  | 
| 306     layer_tree_host_impl_.reset(); | 226     layer_tree_host_impl_.reset(); | 
| 307   } | 227   } | 
| 308   layer_tree_host_ = NULL; | 228   layer_tree_host_ = NULL; | 
| 309 } | 229 } | 
| 310 | 230 | 
| 311 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 231 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 
| 312   TRACE_EVENT1( | 232   TRACE_EVENT1( | 
| 313       "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 233       "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 
| 314   DCHECK(Proxy::IsImplThread()); | 234   DCHECK(Proxy::IsImplThread()); | 
| 315   UpdateBackgroundAnimateTicking(); | 235   UpdateBackgroundAnimateTicking(); | 
| 316   if (scheduler_on_impl_thread_) |  | 
| 317     scheduler_on_impl_thread_->SetCanDraw(can_draw); |  | 
| 318 } | 236 } | 
| 319 | 237 | 
| 320 void SingleThreadProxy::NotifyReadyToActivate() { | 238 void SingleThreadProxy::NotifyReadyToActivate() { | 
| 321   // Impl-side painting only. | 239   // Thread-only feature. | 
| 322   NOTREACHED(); | 240   NOTREACHED(); | 
| 323 } | 241 } | 
| 324 | 242 | 
| 325 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { | 243 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { | 
| 326   client_->ScheduleComposite(); | 244   client_->ScheduleComposite(); | 
| 327   if (scheduler_on_impl_thread_) |  | 
| 328     scheduler_on_impl_thread_->SetNeedsRedraw(); |  | 
| 329 } | 245 } | 
| 330 | 246 | 
| 331 void SingleThreadProxy::SetNeedsAnimateOnImplThread() { | 247 void SingleThreadProxy::SetNeedsAnimateOnImplThread() { | 
| 332   SetNeedsRedrawOnImplThread(); | 248   SetNeedsRedrawOnImplThread(); | 
| 333 } | 249 } | 
| 334 | 250 | 
| 335 void SingleThreadProxy::SetNeedsManageTilesOnImplThread() { | 251 void SingleThreadProxy::SetNeedsManageTilesOnImplThread() { | 
| 336   // Impl-side painting only. | 252   // Thread-only/Impl-side-painting-only feature. | 
| 337   NOTREACHED(); | 253   NOTREACHED(); | 
| 338 } | 254 } | 
| 339 | 255 | 
| 340 void SingleThreadProxy::SetNeedsRedrawRectOnImplThread( | 256 void SingleThreadProxy::SetNeedsRedrawRectOnImplThread( | 
| 341     const gfx::Rect& damage_rect) { | 257     const gfx::Rect& damage_rect) { | 
|  | 258   // TODO(brianderson): Once we move render_widget scheduling into this class, | 
|  | 259   // we can treat redraw requests more efficiently than CommitAndRedraw | 
|  | 260   // requests. | 
| 342   layer_tree_host_impl_->SetViewportDamage(damage_rect); | 261   layer_tree_host_impl_->SetViewportDamage(damage_rect); | 
| 343   SetNeedsRedrawOnImplThread(); | 262   SetNeedsCommit(); | 
| 344 } | 263 } | 
| 345 | 264 | 
| 346 void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() { | 265 void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() { | 
| 347   // Impl-side painting only. | 266   // Impl-side painting only. | 
| 348   NOTREACHED(); | 267   NOTREACHED(); | 
| 349 } | 268 } | 
| 350 | 269 | 
| 351 void SingleThreadProxy::SetNeedsCommitOnImplThread() { | 270 void SingleThreadProxy::SetNeedsCommitOnImplThread() { | 
| 352   client_->ScheduleComposite(); | 271   client_->ScheduleComposite(); | 
| 353   if (scheduler_on_impl_thread_) |  | 
| 354     scheduler_on_impl_thread_->SetNeedsCommit(); |  | 
| 355 } | 272 } | 
| 356 | 273 | 
| 357 void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( | 274 void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( | 
| 358     scoped_ptr<AnimationEventsVector> events) { | 275     scoped_ptr<AnimationEventsVector> events) { | 
| 359   TRACE_EVENT0( | 276   TRACE_EVENT0( | 
| 360       "cc", "SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); | 277       "cc", "SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); | 
| 361   DCHECK(Proxy::IsImplThread()); | 278   DCHECK(Proxy::IsImplThread()); | 
| 362   DebugScopedSetMainThread main(this); | 279   DebugScopedSetMainThread main(this); | 
| 363   layer_tree_host_->SetAnimationEvents(events.Pass()); | 280   layer_tree_host_->SetAnimationEvents(events.Pass()); | 
| 364 } | 281 } | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 381 } | 298 } | 
| 382 | 299 | 
| 383 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } | 300 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } | 
| 384 | 301 | 
| 385 void SingleThreadProxy::UpdateRendererCapabilitiesOnImplThread() { | 302 void SingleThreadProxy::UpdateRendererCapabilitiesOnImplThread() { | 
| 386   DCHECK(IsImplThread()); | 303   DCHECK(IsImplThread()); | 
| 387   renderer_capabilities_for_main_thread_ = | 304   renderer_capabilities_for_main_thread_ = | 
| 388       layer_tree_host_impl_->GetRendererCapabilities().MainThreadCapabilities(); | 305       layer_tree_host_impl_->GetRendererCapabilities().MainThreadCapabilities(); | 
| 389 } | 306 } | 
| 390 | 307 | 
| 391 void SingleThreadProxy::DidActivatePendingTree() { |  | 
| 392   // Impl-side painting only. |  | 
| 393   NOTREACHED(); |  | 
| 394 } |  | 
| 395 |  | 
| 396 void SingleThreadProxy::DidManageTiles() { |  | 
| 397   // Impl-side painting only. |  | 
| 398   NOTREACHED(); |  | 
| 399 } |  | 
| 400 |  | 
| 401 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 308 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 
| 402   TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 309   TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 
| 403   { | 310   // Cause a commit so we can notice the lost context. | 
| 404     DebugScopedSetMainThread main(this); | 311   SetNeedsCommitOnImplThread(); | 
| 405     // This must happen before we notify the scheduler as it may try to recreate |  | 
| 406     // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. |  | 
| 407     layer_tree_host_->DidLoseOutputSurface(); |  | 
| 408   } |  | 
| 409   client_->DidAbortSwapBuffers(); | 312   client_->DidAbortSwapBuffers(); | 
| 410   if (scheduler_on_impl_thread_) |  | 
| 411     scheduler_on_impl_thread_->DidLoseOutputSurface(); |  | 
| 412 } | 313 } | 
| 413 | 314 | 
| 414 void SingleThreadProxy::DidSwapBuffersOnImplThread() { | 315 void SingleThreadProxy::DidSwapBuffersOnImplThread() { | 
| 415   TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersOnImplThread"); |  | 
| 416   if (scheduler_on_impl_thread_) |  | 
| 417     scheduler_on_impl_thread_->DidSwapBuffers(); |  | 
| 418   client_->DidPostSwapBuffers(); | 316   client_->DidPostSwapBuffers(); | 
| 419 } | 317 } | 
| 420 | 318 | 
| 421 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { | 319 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { | 
| 422   TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 320   TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 
| 423   if (scheduler_on_impl_thread_) | 321   client_->DidCompleteSwapBuffers(); | 
| 424     scheduler_on_impl_thread_->DidSwapBuffersComplete(); |  | 
| 425   layer_tree_host_->DidCompleteSwapBuffers(); |  | 
| 426 } | 322 } | 
| 427 | 323 | 
| 428 void SingleThreadProxy::BeginFrame(const BeginFrameArgs& args) { | 324 // Called by the legacy scheduling path (e.g. where render_widget does the | 
| 429   TRACE_EVENT0("cc", "SingleThreadProxy::BeginFrame"); | 325 // scheduling) | 
| 430   if (scheduler_on_impl_thread_) |  | 
| 431     scheduler_on_impl_thread_->BeginImplFrame(args); |  | 
| 432 } |  | 
| 433 |  | 
| 434 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { | 326 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { | 
| 435   TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately"); | 327   TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately"); | 
| 436   DCHECK(Proxy::IsMainThread()); | 328   DCHECK(Proxy::IsMainThread()); | 
| 437   DCHECK(!layer_tree_host_->output_surface_lost()); | 329   DCHECK(!layer_tree_host_->output_surface_lost()); | 
| 438 | 330 | 
| 439   DoCommit(frame_begin_time); | 331   layer_tree_host_->AnimateLayers(frame_begin_time); | 
|  | 332 | 
|  | 333   if (PrioritizedResourceManager* contents_texture_manager = | 
|  | 334           layer_tree_host_->contents_texture_manager()) { | 
|  | 335     contents_texture_manager->UnlinkAndClearEvictedBackings(); | 
|  | 336     contents_texture_manager->SetMaxMemoryLimitBytes( | 
|  | 337         layer_tree_host_impl_->memory_allocation_limit_bytes()); | 
|  | 338     contents_texture_manager->SetExternalPriorityCutoff( | 
|  | 339         layer_tree_host_impl_->memory_allocation_priority_cutoff()); | 
|  | 340   } | 
|  | 341 | 
|  | 342   scoped_ptr<ResourceUpdateQueue> queue = | 
|  | 343       make_scoped_ptr(new ResourceUpdateQueue); | 
|  | 344   layer_tree_host_->UpdateLayers(queue.get()); | 
|  | 345   layer_tree_host_->WillCommit(); | 
|  | 346   DoCommit(queue.Pass()); | 
|  | 347   layer_tree_host_->DidBeginMainFrame(); | 
| 440 | 348 | 
| 441   LayerTreeHostImpl::FrameData frame; | 349   LayerTreeHostImpl::FrameData frame; | 
| 442   DoComposite(frame_begin_time, &frame); | 350   if (DoComposite(frame_begin_time, &frame)) { | 
| 443 } | 351     { | 
|  | 352       DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 
|  | 353       DebugScopedSetImplThread impl(this); | 
| 444 | 354 | 
| 445 scoped_ptr<base::Value> SingleThreadProxy::AsValue() const { |  | 
| 446   scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |  | 
| 447   { |  | 
| 448     // The following line casts away const modifiers because it is just |  | 
| 449     // setting debug state. We still want the AsValue() function and its |  | 
| 450     // call chain to be const throughout. |  | 
| 451     DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); |  | 
| 452 |  | 
| 453     state->Set("layer_tree_host_impl", |  | 
| 454                layer_tree_host_impl_->AsValue().release()); |  | 
| 455   } |  | 
| 456   return state.PassAs<base::Value>(); |  | 
| 457 } |  | 
| 458 |  | 
| 459 void SingleThreadProxy::ForceSerializeOnSwapBuffers() { |  | 
| 460   { |  | 
| 461     DebugScopedSetImplThread impl(this); |  | 
| 462     if (layer_tree_host_impl_->renderer()) { |  | 
| 463       DCHECK(!layer_tree_host_->output_surface_lost()); |  | 
| 464       layer_tree_host_impl_->renderer()->DoNoOp(); |  | 
| 465     } |  | 
| 466   } |  | 
| 467 } |  | 
| 468 |  | 
| 469 bool SingleThreadProxy::ShouldComposite() const { |  | 
| 470   DCHECK(Proxy::IsImplThread()); |  | 
| 471   return layer_tree_host_impl_->visible() && |  | 
| 472          layer_tree_host_impl_->CanDraw(); |  | 
| 473 } |  | 
| 474 |  | 
| 475 void SingleThreadProxy::UpdateBackgroundAnimateTicking() { |  | 
| 476   DCHECK(Proxy::IsImplThread()); |  | 
| 477   layer_tree_host_impl_->UpdateBackgroundAnimateTicking( |  | 
| 478       !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); |  | 
| 479 } |  | 
| 480 |  | 
| 481 DrawResult SingleThreadProxy::DoComposite(base::TimeTicks frame_begin_time, |  | 
| 482                                           LayerTreeHostImpl::FrameData* frame) { |  | 
| 483   TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); |  | 
| 484   DCHECK(!layer_tree_host_->output_surface_lost()); |  | 
| 485 |  | 
| 486   { |  | 
| 487     DebugScopedSetImplThread impl(this); |  | 
| 488     base::AutoReset<bool> mark_inside(&inside_draw_, true); |  | 
| 489 |  | 
| 490     // We guard PrepareToDraw() with CanDraw() because it always returns a valid |  | 
| 491     // frame, so can only be used when such a frame is possible. Since |  | 
| 492     // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |  | 
| 493     // CanDraw() as well. |  | 
| 494     if (!ShouldComposite()) { |  | 
| 495       UpdateBackgroundAnimateTicking(); |  | 
| 496       return DRAW_ABORTED_CANT_DRAW; |  | 
| 497     } |  | 
| 498 |  | 
| 499     timing_history_.DidStartDrawing(); |  | 
| 500 |  | 
| 501     layer_tree_host_impl_->Animate( |  | 
| 502         layer_tree_host_impl_->CurrentFrameTimeTicks()); |  | 
| 503     UpdateBackgroundAnimateTicking(); |  | 
| 504 |  | 
| 505     if (!layer_tree_host_impl_->IsContextLost()) { |  | 
| 506       layer_tree_host_impl_->PrepareToDraw(frame); |  | 
| 507       layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); |  | 
| 508       layer_tree_host_impl_->DidDrawAllLayers(*frame); |  | 
| 509     } |  | 
| 510 |  | 
| 511     bool start_ready_animations = true; |  | 
| 512     layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |  | 
| 513 |  | 
| 514     layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); |  | 
| 515 |  | 
| 516     timing_history_.DidFinishDrawing(); |  | 
| 517   } |  | 
| 518 |  | 
| 519   { |  | 
| 520     DebugScopedSetImplThread impl(this); |  | 
| 521 |  | 
| 522     if (layer_tree_host_impl_->IsContextLost()) { |  | 
| 523       DidLoseOutputSurfaceOnImplThread(); |  | 
| 524     } else { |  | 
| 525       // This CapturePostTasks should be destroyed before | 355       // This CapturePostTasks should be destroyed before | 
| 526       // DidCommitAndDrawFrame() is called since that goes out to the embedder, | 356       // DidCommitAndDrawFrame() is called since that goes out to the embedder, | 
| 527       // and we want the embedder to receive its callbacks before that. | 357       // and we want the embedder to receive its callbacks before that. | 
| 528       // NOTE: This maintains consistent ordering with the ThreadProxy since | 358       // NOTE: This maintains consistent ordering with the ThreadProxy since | 
| 529       // the DidCommitAndDrawFrame() must be post-tasked from the impl thread | 359       // the DidCommitAndDrawFrame() must be post-tasked from the impl thread | 
| 530       // there as the main thread is not blocked, so any posted tasks inside | 360       // there as the main thread is not blocked, so any posted tasks inside | 
| 531       // the swap buffers will execute first. | 361       // the swap buffers will execute first. | 
| 532       DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 362       BlockingTaskRunner::CapturePostTasks blocked; | 
| 533 | 363 | 
| 534       BlockingTaskRunner::CapturePostTasks blocked; | 364       layer_tree_host_impl_->SwapBuffers(frame); | 
| 535       layer_tree_host_impl_->SwapBuffers(*frame); | 365     } | 
|  | 366     DidSwapFrame(); | 
|  | 367   } | 
|  | 368 } | 
|  | 369 | 
|  | 370 scoped_ptr<base::Value> SingleThreadProxy::AsValue() const { | 
|  | 371   scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 
|  | 372   { | 
|  | 373     // The following line casts away const modifiers because it is just | 
|  | 374     // setting debug state. We still want the AsValue() function and its | 
|  | 375     // call chain to be const throughout. | 
|  | 376     DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); | 
|  | 377 | 
|  | 378     state->Set("layer_tree_host_impl", | 
|  | 379                layer_tree_host_impl_->AsValue().release()); | 
|  | 380   } | 
|  | 381   return state.PassAs<base::Value>(); | 
|  | 382 } | 
|  | 383 | 
|  | 384 void SingleThreadProxy::ForceSerializeOnSwapBuffers() { | 
|  | 385   { | 
|  | 386     DebugScopedSetImplThread impl(this); | 
|  | 387     if (layer_tree_host_impl_->renderer()) { | 
|  | 388       DCHECK(!layer_tree_host_->output_surface_lost()); | 
|  | 389       layer_tree_host_impl_->renderer()->DoNoOp(); | 
| 536     } | 390     } | 
| 537   } | 391   } | 
| 538   DidCommitAndDrawFrame(); |  | 
| 539 |  | 
| 540   return DRAW_SUCCESS; |  | 
| 541 } | 392 } | 
| 542 | 393 | 
| 543 void SingleThreadProxy::DidCommitAndDrawFrame() { | 394 bool SingleThreadProxy::ShouldComposite() const { | 
|  | 395   DCHECK(Proxy::IsImplThread()); | 
|  | 396   return layer_tree_host_impl_->visible() && | 
|  | 397          layer_tree_host_impl_->CanDraw(); | 
|  | 398 } | 
|  | 399 | 
|  | 400 void SingleThreadProxy::UpdateBackgroundAnimateTicking() { | 
|  | 401   DCHECK(Proxy::IsImplThread()); | 
|  | 402   layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | 
|  | 403       !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); | 
|  | 404 } | 
|  | 405 | 
|  | 406 bool SingleThreadProxy::DoComposite( | 
|  | 407     base::TimeTicks frame_begin_time, | 
|  | 408     LayerTreeHostImpl::FrameData* frame) { | 
|  | 409   TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); | 
|  | 410   DCHECK(!layer_tree_host_->output_surface_lost()); | 
|  | 411 | 
|  | 412   bool lost_output_surface = false; | 
|  | 413   { | 
|  | 414     DebugScopedSetImplThread impl(this); | 
|  | 415     base::AutoReset<bool> mark_inside(&inside_draw_, true); | 
|  | 416 | 
|  | 417     // We guard PrepareToDraw() with CanDraw() because it always returns a valid | 
|  | 418     // frame, so can only be used when such a frame is possible. Since | 
|  | 419     // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on | 
|  | 420     // CanDraw() as well. | 
|  | 421     if (!ShouldComposite()) { | 
|  | 422       UpdateBackgroundAnimateTicking(); | 
|  | 423       return false; | 
|  | 424     } | 
|  | 425 | 
|  | 426     layer_tree_host_impl_->Animate( | 
|  | 427         layer_tree_host_impl_->CurrentFrameTimeTicks()); | 
|  | 428     UpdateBackgroundAnimateTicking(); | 
|  | 429 | 
|  | 430     if (!layer_tree_host_impl_->IsContextLost()) { | 
|  | 431       layer_tree_host_impl_->PrepareToDraw(frame); | 
|  | 432       layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); | 
|  | 433       layer_tree_host_impl_->DidDrawAllLayers(*frame); | 
|  | 434     } | 
|  | 435     lost_output_surface = layer_tree_host_impl_->IsContextLost(); | 
|  | 436 | 
|  | 437     bool start_ready_animations = true; | 
|  | 438     layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 
|  | 439 | 
|  | 440     layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); | 
|  | 441   } | 
|  | 442 | 
|  | 443   if (lost_output_surface) { | 
|  | 444     layer_tree_host_->DidLoseOutputSurface(); | 
|  | 445     return false; | 
|  | 446   } | 
|  | 447 | 
|  | 448   return true; | 
|  | 449 } | 
|  | 450 | 
|  | 451 void SingleThreadProxy::DidSwapFrame() { | 
| 544   if (next_frame_is_newly_committed_frame_) { | 452   if (next_frame_is_newly_committed_frame_) { | 
| 545     DebugScopedSetMainThread main(this); |  | 
| 546     next_frame_is_newly_committed_frame_ = false; | 453     next_frame_is_newly_committed_frame_ = false; | 
| 547     layer_tree_host_->DidCommitAndDrawFrame(); | 454     layer_tree_host_->DidCommitAndDrawFrame(); | 
| 548   } | 455   } | 
| 549 } | 456 } | 
| 550 | 457 | 
| 551 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 458 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 
| 552 | 459 | 
| 553 scoped_ptr<base::Value> SingleThreadProxy::SchedulerAsValueForTesting() { |  | 
| 554   DebugScopedSetImplThread impl(this); |  | 
| 555   if (!scheduler_on_impl_thread_) |  | 
| 556     return make_scoped_ptr(base::Value::CreateNullValue()).Pass(); |  | 
| 557   return scheduler_on_impl_thread_->AsValue().Pass(); |  | 
| 558 } |  | 
| 559 |  | 
| 560 void SingleThreadProxy::SetNeedsBeginFrame(bool enable) { |  | 
| 561   layer_tree_host_impl_->SetNeedsBeginFrame(enable); |  | 
| 562 } |  | 
| 563 |  | 
| 564 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { |  | 
| 565   layer_tree_host_impl_->WillBeginImplFrame(args); |  | 
| 566 } |  | 
| 567 |  | 
| 568 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { |  | 
| 569   TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); |  | 
| 570   if (defer_commits_) { |  | 
| 571     DCHECK(!commit_was_deferred_); |  | 
| 572     commit_was_deferred_ = true; |  | 
| 573     layer_tree_host_->DidDeferCommit(); |  | 
| 574     return; |  | 
| 575   } |  | 
| 576   timing_history_.DidBeginMainFrame(); |  | 
| 577 |  | 
| 578   DCHECK(scheduler_on_impl_thread_); |  | 
| 579   scheduler_on_impl_thread_->NotifyBeginMainFrameStarted(); |  | 
| 580   scheduler_on_impl_thread_->NotifyReadyToCommit(); |  | 
| 581 } |  | 
| 582 |  | 
| 583 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible() { |  | 
| 584   DebugScopedSetImplThread impl(this); |  | 
| 585   if (layer_tree_host_impl_->IsContextLost()) { |  | 
| 586     DidCommitAndDrawFrame(); |  | 
| 587     return DRAW_SUCCESS; |  | 
| 588   } |  | 
| 589 |  | 
| 590   LayerTreeHostImpl::FrameData frame; |  | 
| 591   return DoComposite(layer_tree_host_impl_->CurrentFrameTimeTicks(), &frame); |  | 
| 592 } |  | 
| 593 |  | 
| 594 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapForced() { |  | 
| 595   NOTREACHED(); |  | 
| 596   return INVALID_RESULT; |  | 
| 597 } |  | 
| 598 |  | 
| 599 void SingleThreadProxy::ScheduledActionCommit() { |  | 
| 600   DebugScopedSetMainThread main(this); |  | 
| 601   DoCommit(layer_tree_host_impl_->CurrentFrameTimeTicks()); |  | 
| 602 } |  | 
| 603 |  | 
| 604 void SingleThreadProxy::ScheduledActionAnimate() { |  | 
| 605   TRACE_EVENT0("cc", "ScheduledActionAnimate"); |  | 
| 606   layer_tree_host_impl_->Animate( |  | 
| 607       layer_tree_host_impl_->CurrentFrameTimeTicks()); |  | 
| 608 } |  | 
| 609 |  | 
| 610 void SingleThreadProxy::ScheduledActionUpdateVisibleTiles() { |  | 
| 611   // Impl-side painting only. |  | 
| 612   NOTREACHED(); |  | 
| 613 } |  | 
| 614 |  | 
| 615 void SingleThreadProxy::ScheduledActionActivatePendingTree() { |  | 
| 616   // Impl-side painting only. |  | 
| 617   NOTREACHED(); |  | 
| 618 } |  | 
| 619 |  | 
| 620 void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |  | 
| 621   DebugScopedSetMainThread main(this); |  | 
| 622   DCHECK(scheduler_on_impl_thread_); |  | 
| 623   // If possible, create the output surface in a post task.  Synchronously |  | 
| 624   // creating the output surface makes tests more awkward since this differs |  | 
| 625   // from the ThreadProxy behavior.  However, sometimes there is no |  | 
| 626   // task runner. |  | 
| 627   if (Proxy::MainThreadTaskRunner()) { |  | 
| 628     Proxy::MainThreadTaskRunner()->PostTask( |  | 
| 629         FROM_HERE, |  | 
| 630         base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface, |  | 
| 631                    weak_factory_.GetWeakPtr())); |  | 
| 632   } else { |  | 
| 633     CreateAndInitializeOutputSurface(); |  | 
| 634   } |  | 
| 635 } |  | 
| 636 |  | 
| 637 void SingleThreadProxy::ScheduledActionManageTiles() { |  | 
| 638   // Impl-side painting only. |  | 
| 639   NOTREACHED(); |  | 
| 640 } |  | 
| 641 |  | 
| 642 void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { |  | 
| 643 } |  | 
| 644 |  | 
| 645 base::TimeDelta SingleThreadProxy::DrawDurationEstimate() { |  | 
| 646   return timing_history_.DrawDurationEstimate(); |  | 
| 647 } |  | 
| 648 |  | 
| 649 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() { |  | 
| 650   return timing_history_.BeginMainFrameToCommitDurationEstimate(); |  | 
| 651 } |  | 
| 652 |  | 
| 653 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { |  | 
| 654   return timing_history_.CommitToActivateDurationEstimate(); |  | 
| 655 } |  | 
| 656 |  | 
| 657 void SingleThreadProxy::DidBeginImplFrameDeadline() { |  | 
| 658   layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); |  | 
| 659 } |  | 
| 660 |  | 
| 661 }  // namespace cc | 460 }  // namespace cc | 
| OLD | NEW | 
|---|