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/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // construct a DebugScopedSetImplThread object. There is no need to do | 100 // construct a DebugScopedSetImplThread object. There is no need to do |
101 // this in multi-threaded mode since the real thread id's will be | 101 // this in multi-threaded mode since the real thread id's will be |
102 // correct. In fact, setting fake thread id's interferes with the real | 102 // correct. In fact, setting fake thread id's interferes with the real |
103 // thread id's and causes breakage. | 103 // thread id's and causes breakage. |
104 scoped_ptr<DebugScopedSetImplThread> set_impl_thread; | 104 scoped_ptr<DebugScopedSetImplThread> set_impl_thread; |
105 if (!layer_tree_host_impl_->proxy()->HasImplThread()) { | 105 if (!layer_tree_host_impl_->proxy()->HasImplThread()) { |
106 set_impl_thread.reset( | 106 set_impl_thread.reset( |
107 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); | 107 new DebugScopedSetImplThread(layer_tree_host_impl_->proxy())); |
108 } | 108 } |
109 | 109 |
110 // TODO(enne): This should probably happen post-animate. | |
111 if (layer_tree_host_impl_->pending_tree()) { | 110 if (layer_tree_host_impl_->pending_tree()) { |
112 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); | 111 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); |
113 | 112 |
114 if (layer_tree_host_impl_->pending_tree()) { | 113 if (layer_tree_host_impl_->pending_tree()) { |
115 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); | 114 layer_tree_host_impl_->pending_tree()->UpdateDrawProperties(); |
116 layer_tree_host_impl_->ManageTiles(); | 115 layer_tree_host_impl_->ManageTiles(); |
117 } | 116 } |
118 } | 117 } |
119 | 118 |
120 layer_tree_host_impl_->Animate( | 119 layer_tree_host_impl_->Animate( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 rendering_stats_instrumentation)); | 162 rendering_stats_instrumentation)); |
164 } | 163 } |
165 | 164 |
166 LayerTreeHostImpl::LayerTreeHostImpl( | 165 LayerTreeHostImpl::LayerTreeHostImpl( |
167 const LayerTreeSettings& settings, | 166 const LayerTreeSettings& settings, |
168 LayerTreeHostImplClient* client, | 167 LayerTreeHostImplClient* client, |
169 Proxy* proxy, | 168 Proxy* proxy, |
170 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 169 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
171 : client_(client), | 170 : client_(client), |
172 proxy_(proxy), | 171 proxy_(proxy), |
| 172 output_surface_lost_(true), |
173 input_handler_client_(NULL), | 173 input_handler_client_(NULL), |
174 did_lock_scrolling_layer_(false), | 174 did_lock_scrolling_layer_(false), |
175 should_bubble_scrolls_(false), | 175 should_bubble_scrolls_(false), |
176 wheel_scrolling_(false), | 176 wheel_scrolling_(false), |
177 manage_tiles_needed_(false), | 177 manage_tiles_needed_(false), |
178 root_layer_scroll_offset_delegate_(NULL), | 178 root_layer_scroll_offset_delegate_(NULL), |
179 settings_(settings), | 179 settings_(settings), |
180 visible_(true), | 180 visible_(true), |
181 managed_memory_policy_( | 181 managed_memory_policy_( |
182 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), | 182 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 void LayerTreeHostImpl::CommitComplete() { | 244 void LayerTreeHostImpl::CommitComplete() { |
245 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); | 245 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); |
246 | 246 |
247 // Impl-side painting needs an update immediately post-commit to have the | 247 // Impl-side painting needs an update immediately post-commit to have the |
248 // opportunity to create tilings. Other paths can call UpdateDrawProperties | 248 // opportunity to create tilings. Other paths can call UpdateDrawProperties |
249 // more lazily when needed prior to drawing. | 249 // more lazily when needed prior to drawing. |
250 if (settings_.impl_side_painting) { | 250 if (settings_.impl_side_painting) { |
251 pending_tree_->set_needs_update_draw_properties(); | 251 pending_tree_->set_needs_update_draw_properties(); |
252 pending_tree_->UpdateDrawProperties(); | 252 pending_tree_->UpdateDrawProperties(); |
253 // Start working on newly created tiles immediately if needed. | 253 // Start working on newly created tiles immediately if needed. |
254 ManageTiles(); | 254 if (!ManageTiles()) |
| 255 client_->NotifyReadyToActivate(); |
255 } else { | 256 } else { |
256 active_tree_->set_needs_update_draw_properties(); | 257 active_tree_->set_needs_update_draw_properties(); |
257 } | 258 } |
258 | 259 |
259 client_->SendManagedMemoryStats(); | 260 client_->SendManagedMemoryStats(); |
260 } | 261 } |
261 | 262 |
262 bool LayerTreeHostImpl::CanDraw() const { | 263 bool LayerTreeHostImpl::CanDraw() const { |
263 // Note: If you are changing this function or any other function that might | 264 // Note: If you are changing this function or any other function that might |
264 // affect the result of CanDraw, make sure to call | 265 // affect the result of CanDraw, make sure to call |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, | 309 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, |
309 base::Time wall_clock_time) { | 310 base::Time wall_clock_time) { |
310 if (input_handler_client_) | 311 if (input_handler_client_) |
311 input_handler_client_->Animate(monotonic_time); | 312 input_handler_client_->Animate(monotonic_time); |
312 AnimatePageScale(monotonic_time); | 313 AnimatePageScale(monotonic_time); |
313 AnimateLayers(monotonic_time, wall_clock_time); | 314 AnimateLayers(monotonic_time, wall_clock_time); |
314 AnimateScrollbars(monotonic_time); | 315 AnimateScrollbars(monotonic_time); |
315 AnimateTopControls(monotonic_time); | 316 AnimateTopControls(monotonic_time); |
316 } | 317 } |
317 | 318 |
318 void LayerTreeHostImpl::ManageTiles() { | 319 bool LayerTreeHostImpl::ManageTiles() { |
319 if (!tile_manager_) | 320 if (!tile_manager_) |
320 return; | 321 return false; |
321 if (!manage_tiles_needed_) | 322 if (!manage_tiles_needed_) |
322 return; | 323 return false; |
323 manage_tiles_needed_ = false; | 324 manage_tiles_needed_ = false; |
324 tile_manager_->ManageTiles(); | 325 tile_manager_->ManageTiles(); |
325 | 326 |
326 size_t memory_required_bytes; | 327 size_t memory_required_bytes; |
327 size_t memory_nice_to_have_bytes; | 328 size_t memory_nice_to_have_bytes; |
328 size_t memory_used_bytes; | 329 size_t memory_used_bytes; |
329 tile_manager_->GetMemoryStats(&memory_required_bytes, | 330 tile_manager_->GetMemoryStats(&memory_required_bytes, |
330 &memory_nice_to_have_bytes, | 331 &memory_nice_to_have_bytes, |
331 &memory_used_bytes); | 332 &memory_used_bytes); |
332 SendManagedMemoryStats(memory_required_bytes, | 333 SendManagedMemoryStats(memory_required_bytes, |
333 memory_nice_to_have_bytes, | 334 memory_nice_to_have_bytes, |
334 memory_used_bytes); | 335 memory_used_bytes); |
| 336 return true; |
335 } | 337 } |
336 | 338 |
337 void LayerTreeHostImpl::StartPageScaleAnimation(gfx::Vector2d target_offset, | 339 void LayerTreeHostImpl::StartPageScaleAnimation(gfx::Vector2d target_offset, |
338 bool anchor_point, | 340 bool anchor_point, |
339 float page_scale, | 341 float page_scale, |
340 base::TimeTicks start_time, | 342 base::TimeTicks start_time, |
341 base::TimeDelta duration) { | 343 base::TimeDelta duration) { |
342 if (!RootScrollLayer()) | 344 if (!RootScrollLayer()) |
343 return; | 345 return; |
344 | 346 |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 | 1055 |
1054 void LayerTreeHostImpl::DidInitializeVisibleTile() { | 1056 void LayerTreeHostImpl::DidInitializeVisibleTile() { |
1055 // TODO(reveman): Determine tiles that changed and only damage | 1057 // TODO(reveman): Determine tiles that changed and only damage |
1056 // what's necessary. | 1058 // what's necessary. |
1057 SetFullRootLayerDamage(); | 1059 SetFullRootLayerDamage(); |
1058 if (client_) | 1060 if (client_) |
1059 client_->DidInitializeVisibleTileOnImplThread(); | 1061 client_->DidInitializeVisibleTileOnImplThread(); |
1060 } | 1062 } |
1061 | 1063 |
1062 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1064 void LayerTreeHostImpl::NotifyReadyToActivate() { |
1063 if (pending_tree_) { | 1065 client_->NotifyReadyToActivate(); |
1064 need_to_update_visible_tiles_before_draw_ = true; | |
1065 ActivatePendingTree(); | |
1066 } | |
1067 } | 1066 } |
1068 | 1067 |
1069 bool LayerTreeHostImpl::ShouldClearRootRenderPass() const { | 1068 bool LayerTreeHostImpl::ShouldClearRootRenderPass() const { |
1070 return settings_.should_clear_root_render_pass; | 1069 return settings_.should_clear_root_render_pass; |
1071 } | 1070 } |
1072 | 1071 |
1073 void LayerTreeHostImpl::SetMemoryPolicy( | 1072 void LayerTreeHostImpl::SetMemoryPolicy( |
1074 const ManagedMemoryPolicy& policy, | 1073 const ManagedMemoryPolicy& policy, |
1075 bool discard_backbuffer_when_not_visible) { | 1074 bool discard_backbuffer_when_not_visible) { |
1076 if (policy.bytes_limit_when_visible) { | 1075 if (policy.bytes_limit_when_visible) { |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 bool LayerTreeHostImpl::IsContextLost() { | 1301 bool LayerTreeHostImpl::IsContextLost() { |
1303 DCHECK(proxy_->IsImplThread()); | 1302 DCHECK(proxy_->IsImplThread()); |
1304 return renderer_ && renderer_->IsContextLost(); | 1303 return renderer_ && renderer_->IsContextLost(); |
1305 } | 1304 } |
1306 | 1305 |
1307 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const { | 1306 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const { |
1308 return renderer_->Capabilities(); | 1307 return renderer_->Capabilities(); |
1309 } | 1308 } |
1310 | 1309 |
1311 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { | 1310 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { |
1312 if (frame.has_no_damage) | 1311 if (frame.has_no_damage || output_surface_lost_) |
1313 return false; | 1312 return false; |
1314 renderer_->SwapBuffers(); | 1313 renderer_->SwapBuffers(); |
1315 active_tree_->ClearLatencyInfo(); | 1314 active_tree_->ClearLatencyInfo(); |
1316 return true; | 1315 return true; |
1317 } | 1316 } |
1318 | 1317 |
1319 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { | 1318 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { |
1320 if (output_surface_) | 1319 if (output_surface_) |
1321 output_surface_->SetNeedsBeginFrame(enable); | 1320 output_surface_->SetNeedsBeginFrame(enable); |
1322 } | 1321 } |
(...skipping 22 matching lines...) Expand all Loading... |
1345 } | 1344 } |
1346 | 1345 |
1347 const LayerTreeSettings& LayerTreeHostImpl::Settings() const { | 1346 const LayerTreeSettings& LayerTreeHostImpl::Settings() const { |
1348 return settings(); | 1347 return settings(); |
1349 } | 1348 } |
1350 | 1349 |
1351 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1350 void LayerTreeHostImpl::DidLoseOutputSurface() { |
1352 // TODO(jamesr): The renderer_ check is needed to make some of the | 1351 // TODO(jamesr): The renderer_ check is needed to make some of the |
1353 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or | 1352 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or |
1354 // important) in production. We should adjust the test to not need this. | 1353 // important) in production. We should adjust the test to not need this. |
| 1354 output_surface_lost_ = true; |
1355 if (renderer_) | 1355 if (renderer_) |
1356 client_->DidLoseOutputSurfaceOnImplThread(); | 1356 client_->DidLoseOutputSurfaceOnImplThread(); |
1357 } | 1357 } |
1358 | 1358 |
1359 void LayerTreeHostImpl::Readback(void* pixels, | 1359 void LayerTreeHostImpl::Readback(void* pixels, |
1360 gfx::Rect rect_in_device_viewport) { | 1360 gfx::Rect rect_in_device_viewport) { |
1361 DCHECK(renderer_); | 1361 DCHECK(renderer_); |
1362 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport); | 1362 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport); |
1363 } | 1363 } |
1364 | 1364 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 TRACE_EVENT_ASYNC_STEP1( | 1439 TRACE_EVENT_ASYNC_STEP1( |
1440 "cc", | 1440 "cc", |
1441 "PendingTree", pending_tree_.get(), "activate", | 1441 "PendingTree", pending_tree_.get(), "activate", |
1442 "state", TracedValue::FromValue(ActivationStateAsValue().release())); | 1442 "state", TracedValue::FromValue(ActivationStateAsValue().release())); |
1443 } | 1443 } |
1444 | 1444 |
1445 void LayerTreeHostImpl::ActivatePendingTree() { | 1445 void LayerTreeHostImpl::ActivatePendingTree() { |
1446 CHECK(pending_tree_); | 1446 CHECK(pending_tree_); |
1447 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", pending_tree_.get()); | 1447 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", pending_tree_.get()); |
1448 | 1448 |
| 1449 need_to_update_visible_tiles_before_draw_ = true; |
| 1450 |
1449 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | 1451 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
1450 active_tree_->PushPersistedState(pending_tree_.get()); | 1452 active_tree_->PushPersistedState(pending_tree_.get()); |
1451 if (pending_tree_->needs_full_tree_sync()) { | 1453 if (pending_tree_->needs_full_tree_sync()) { |
1452 active_tree_->SetRootLayer( | 1454 active_tree_->SetRootLayer( |
1453 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), | 1455 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), |
1454 active_tree_->DetachLayerTree(), | 1456 active_tree_->DetachLayerTree(), |
1455 active_tree_.get())); | 1457 active_tree_.get())); |
1456 } | 1458 } |
1457 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), | 1459 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), |
1458 active_tree_->root_layer()); | 1460 active_tree_->root_layer()); |
1459 DCHECK(!recycle_tree_); | 1461 DCHECK(!recycle_tree_); |
1460 | 1462 |
1461 // Process any requests in the UI resource queue. The request queue is given | 1463 // Process any requests in the UI resource queue. The request queue is given |
1462 // in LayerTreeHost::FinishCommitOnImplThread. This must take place before | 1464 // in LayerTreeHost::FinishCommitOnImplThread. This must take place before |
1463 // the swap. | 1465 // the swap. |
1464 pending_tree_->ProcessUIResourceRequestQueue(); | 1466 pending_tree_->ProcessUIResourceRequestQueue(); |
1465 | 1467 |
1466 pending_tree_->PushPropertiesTo(active_tree_.get()); | 1468 pending_tree_->PushPropertiesTo(active_tree_.get()); |
1467 | 1469 |
1468 // Now that we've synced everything from the pending tree to the active | 1470 // Now that we've synced everything from the pending tree to the active |
1469 // tree, rename the pending tree the recycle tree so we can reuse it on the | 1471 // tree, rename the pending tree the recycle tree so we can reuse it on the |
1470 // next sync. | 1472 // next sync. |
1471 pending_tree_.swap(recycle_tree_); | 1473 pending_tree_.swap(recycle_tree_); |
1472 | 1474 |
1473 active_tree_->SetRootLayerScrollOffsetDelegate( | 1475 active_tree_->SetRootLayerScrollOffsetDelegate( |
1474 root_layer_scroll_offset_delegate_); | 1476 root_layer_scroll_offset_delegate_); |
1475 active_tree_->DidBecomeActive(); | 1477 active_tree_->DidBecomeActive(); |
1476 | 1478 |
| 1479 client_->DidActivatePendingTree(); |
| 1480 if (!tree_activation_callback_.is_null()) |
| 1481 tree_activation_callback_.Run(); |
| 1482 |
1477 // Reduce wasted memory now that unlinked resources are guaranteed not | 1483 // Reduce wasted memory now that unlinked resources are guaranteed not |
1478 // to be used. | 1484 // to be used. |
1479 client_->ReduceWastedContentsTextureMemoryOnImplThread(); | 1485 client_->ReduceWastedContentsTextureMemoryOnImplThread(); |
1480 | 1486 |
1481 client_->OnCanDrawStateChanged(CanDraw()); | 1487 client_->OnCanDrawStateChanged(CanDraw()); |
1482 client_->OnHasPendingTreeStateChanged(pending_tree_); | 1488 client_->OnHasPendingTreeStateChanged(pending_tree_); |
1483 client_->SetNeedsRedrawOnImplThread(); | 1489 client_->SetNeedsRedrawOnImplThread(); |
1484 client_->RenewTreePriority(); | 1490 client_->RenewTreePriority(); |
1485 | 1491 |
1486 if (debug_state_.continuous_painting) { | 1492 if (debug_state_.continuous_painting) { |
1487 const RenderingStats& stats = | 1493 const RenderingStats& stats = |
1488 rendering_stats_instrumentation_->GetRenderingStats(); | 1494 rendering_stats_instrumentation_->GetRenderingStats(); |
1489 paint_time_counter_->SavePaintTime( | 1495 paint_time_counter_->SavePaintTime( |
1490 stats.total_paint_time + stats.total_record_time + | 1496 stats.total_paint_time + stats.total_record_time + |
1491 stats.total_rasterize_time_for_now_bins_on_pending_tree); | 1497 stats.total_rasterize_time_for_now_bins_on_pending_tree); |
1492 } | 1498 } |
1493 | |
1494 client_->DidActivatePendingTree(); | |
1495 if (!tree_activation_callback_.is_null()) | |
1496 tree_activation_callback_.Run(); | |
1497 } | 1499 } |
1498 | 1500 |
1499 void LayerTreeHostImpl::SetVisible(bool visible) { | 1501 void LayerTreeHostImpl::SetVisible(bool visible) { |
1500 DCHECK(proxy_->IsImplThread()); | 1502 DCHECK(proxy_->IsImplThread()); |
1501 | 1503 |
1502 if (visible_ == visible) | 1504 if (visible_ == visible) |
1503 return; | 1505 return; |
1504 visible_ = visible; | 1506 visible_ = visible; |
1505 DidVisibilityChange(this, visible_); | 1507 DidVisibilityChange(this, visible_); |
1506 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); | 1508 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 // before we destroy the old resource provider. | 1599 // before we destroy the old resource provider. |
1598 ReleaseTreeResources(); | 1600 ReleaseTreeResources(); |
1599 if (resource_provider_) | 1601 if (resource_provider_) |
1600 resource_provider_->DidLoseOutputSurface(); | 1602 resource_provider_->DidLoseOutputSurface(); |
1601 | 1603 |
1602 // Note: order is important here. | 1604 // Note: order is important here. |
1603 renderer_.reset(); | 1605 renderer_.reset(); |
1604 tile_manager_.reset(); | 1606 tile_manager_.reset(); |
1605 resource_provider_.reset(); | 1607 resource_provider_.reset(); |
1606 output_surface_.reset(); | 1608 output_surface_.reset(); |
| 1609 output_surface_lost_ = true; |
1607 | 1610 |
1608 if (!output_surface->BindToClient(this)) | 1611 if (!output_surface->BindToClient(this)) |
1609 return false; | 1612 return false; |
1610 | 1613 |
1611 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( | 1614 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( |
1612 output_surface.get(), settings_.highp_threshold_min); | 1615 output_surface.get(), settings_.highp_threshold_min); |
1613 if (!resource_provider) | 1616 if (!resource_provider) |
1614 return false; | 1617 return false; |
1615 | 1618 |
1616 if (output_surface->capabilities().deferred_gl_initialization) | 1619 if (output_surface->capabilities().deferred_gl_initialization) |
(...skipping 25 matching lines...) Expand all Loading... |
1642 } | 1645 } |
1643 | 1646 |
1644 int max_frames_pending = | 1647 int max_frames_pending = |
1645 output_surface->capabilities().max_frames_pending; | 1648 output_surface->capabilities().max_frames_pending; |
1646 if (max_frames_pending <= 0) | 1649 if (max_frames_pending <= 0) |
1647 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | 1650 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; |
1648 output_surface->SetMaxFramesPending(max_frames_pending); | 1651 output_surface->SetMaxFramesPending(max_frames_pending); |
1649 | 1652 |
1650 resource_provider_ = resource_provider.Pass(); | 1653 resource_provider_ = resource_provider.Pass(); |
1651 output_surface_ = output_surface.Pass(); | 1654 output_surface_ = output_surface.Pass(); |
| 1655 output_surface_lost_ = false; |
1652 | 1656 |
1653 client_->OnCanDrawStateChanged(CanDraw()); | 1657 client_->OnCanDrawStateChanged(CanDraw()); |
1654 | 1658 |
1655 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs | 1659 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs |
1656 // to be initialized to get max texture size. | 1660 // to be initialized to get max texture size. |
1657 active_tree_->set_needs_update_draw_properties(); | 1661 active_tree_->set_needs_update_draw_properties(); |
1658 if (pending_tree_) | 1662 if (pending_tree_) |
1659 pending_tree_->set_needs_update_draw_properties(); | 1663 pending_tree_->set_needs_update_draw_properties(); |
1660 | 1664 |
1661 return true; | 1665 return true; |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2185 for (size_t i = 0; i < layer_impl->children().size(); ++i) | 2189 for (size_t i = 0; i < layer_impl->children().size(); ++i) |
2186 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); | 2190 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); |
2187 } | 2191 } |
2188 | 2192 |
2189 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { | 2193 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { |
2190 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); | 2194 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); |
2191 | 2195 |
2192 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); | 2196 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); |
2193 scroll_info->page_scale_delta = active_tree_->page_scale_delta(); | 2197 scroll_info->page_scale_delta = active_tree_->page_scale_delta(); |
2194 active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); | 2198 active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); |
| 2199 if (pending_tree_) |
| 2200 pending_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); |
2195 | 2201 |
2196 return scroll_info.Pass(); | 2202 return scroll_info.Pass(); |
2197 } | 2203 } |
2198 | 2204 |
2199 void LayerTreeHostImpl::SetFullRootLayerDamage() { | 2205 void LayerTreeHostImpl::SetFullRootLayerDamage() { |
2200 SetViewportDamage(gfx::Rect(device_viewport_size_)); | 2206 SetViewportDamage(gfx::Rect(device_viewport_size_)); |
2201 } | 2207 } |
2202 | 2208 |
2203 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks time) { | 2209 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks time) { |
| 2210 TRACE_EVENT0("cc", "AnimatePageScale"); |
2204 if (!page_scale_animation_ || !RootScrollLayer()) | 2211 if (!page_scale_animation_ || !RootScrollLayer()) |
2205 return; | 2212 return; |
| 2213 TRACE_EVENT0("cc", "AnimatePageScaleExists"); |
2206 | 2214 |
2207 double monotonic_time = (time - base::TimeTicks()).InSecondsF(); | 2215 double monotonic_time = (time - base::TimeTicks()).InSecondsF(); |
2208 gfx::Vector2dF scroll_total = RootScrollLayer()->scroll_offset() + | 2216 gfx::Vector2dF scroll_total = RootScrollLayer()->scroll_offset() + |
2209 RootScrollLayer()->ScrollDelta(); | 2217 RootScrollLayer()->ScrollDelta(); |
2210 | 2218 |
2211 active_tree_->SetPageScaleDelta( | 2219 active_tree_->SetPageScaleDelta( |
2212 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / | 2220 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / |
2213 active_tree_->page_scale_factor()); | 2221 active_tree_->page_scale_factor()); |
| 2222 if (pending_tree_) { |
| 2223 pending_tree_->SetPageScaleDelta( |
| 2224 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / |
| 2225 pending_tree_->page_scale_factor()); |
| 2226 } |
| 2227 |
2214 gfx::Vector2dF next_scroll = | 2228 gfx::Vector2dF next_scroll = |
2215 page_scale_animation_->ScrollOffsetAtTime(monotonic_time); | 2229 page_scale_animation_->ScrollOffsetAtTime(monotonic_time); |
2216 | 2230 |
2217 RootScrollLayer()->ScrollBy(next_scroll - scroll_total); | 2231 RootScrollLayer()->ScrollBy(next_scroll - scroll_total); |
2218 client_->SetNeedsRedrawOnImplThread(); | 2232 client_->SetNeedsRedrawOnImplThread(); |
2219 | 2233 |
2220 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { | 2234 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { |
2221 page_scale_animation_.reset(); | 2235 page_scale_animation_.reset(); |
2222 client_->SetNeedsCommitOnImplThread(); | 2236 client_->SetNeedsCommitOnImplThread(); |
2223 client_->RenewTreePriority(); | 2237 client_->RenewTreePriority(); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2490 | 2504 |
2491 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2505 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
2492 UIResourceId uid) const { | 2506 UIResourceId uid) const { |
2493 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2507 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
2494 if (iter != ui_resource_map_.end()) | 2508 if (iter != ui_resource_map_.end()) |
2495 return iter->second; | 2509 return iter->second; |
2496 return 0; | 2510 return 0; |
2497 } | 2511 } |
2498 | 2512 |
2499 } // namespace cc | 2513 } // namespace cc |
OLD | NEW |