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 cached_managed_memory_policy_( | 181 cached_managed_memory_policy_( |
182 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), | 182 PrioritizedResourceManager::DefaultMemoryAllocationLimit(), |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 void LayerTreeHostImpl::CommitComplete() { | 245 void LayerTreeHostImpl::CommitComplete() { |
246 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); | 246 TRACE_EVENT0("cc", "LayerTreeHostImpl::CommitComplete"); |
247 | 247 |
248 // Impl-side painting needs an update immediately post-commit to have the | 248 // Impl-side painting needs an update immediately post-commit to have the |
249 // opportunity to create tilings. Other paths can call UpdateDrawProperties | 249 // opportunity to create tilings. Other paths can call UpdateDrawProperties |
250 // more lazily when needed prior to drawing. | 250 // more lazily when needed prior to drawing. |
251 if (settings_.impl_side_painting) { | 251 if (settings_.impl_side_painting) { |
252 pending_tree_->set_needs_update_draw_properties(); | 252 pending_tree_->set_needs_update_draw_properties(); |
253 pending_tree_->UpdateDrawProperties(); | 253 pending_tree_->UpdateDrawProperties(); |
254 // Start working on newly created tiles immediately if needed. | 254 // Start working on newly created tiles immediately if needed. |
255 ManageTiles(); | 255 if (!ManageTiles()) |
enne (OOO)
2013/08/06 23:35:16
It seems like TileManager should be able to activa
brianderson
2013/08/07 01:55:51
In this patch, I avoid back to back activations by
| |
256 client_->NotifyReadyToActivate(); | |
256 } else { | 257 } else { |
257 active_tree_->set_needs_update_draw_properties(); | 258 active_tree_->set_needs_update_draw_properties(); |
258 } | 259 } |
259 | 260 |
260 client_->SendManagedMemoryStats(); | 261 client_->SendManagedMemoryStats(); |
261 } | 262 } |
262 | 263 |
263 bool LayerTreeHostImpl::CanDraw() const { | 264 bool LayerTreeHostImpl::CanDraw() const { |
264 // Note: If you are changing this function or any other function that might | 265 // Note: If you are changing this function or any other function that might |
265 // affect the result of CanDraw, make sure to call | 266 // affect the result of CanDraw, make sure to call |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, | 310 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, |
310 base::Time wall_clock_time) { | 311 base::Time wall_clock_time) { |
311 if (input_handler_client_) | 312 if (input_handler_client_) |
312 input_handler_client_->Animate(monotonic_time); | 313 input_handler_client_->Animate(monotonic_time); |
313 AnimatePageScale(monotonic_time); | 314 AnimatePageScale(monotonic_time); |
314 AnimateLayers(monotonic_time, wall_clock_time); | 315 AnimateLayers(monotonic_time, wall_clock_time); |
315 AnimateScrollbars(monotonic_time); | 316 AnimateScrollbars(monotonic_time); |
316 AnimateTopControls(monotonic_time); | 317 AnimateTopControls(monotonic_time); |
317 } | 318 } |
318 | 319 |
319 void LayerTreeHostImpl::ManageTiles() { | 320 bool LayerTreeHostImpl::ManageTiles() { |
320 if (!tile_manager_) | 321 if (!tile_manager_) |
321 return; | 322 return false; |
322 if (!manage_tiles_needed_) | 323 if (!manage_tiles_needed_) |
323 return; | 324 return false; |
enne (OOO)
2013/08/06 23:35:16
This false seems a little sketchy. If you call Ma
brianderson
2013/08/07 01:55:51
Ok. It seems like I need to fix some of the corner
enne (OOO)
2013/08/07 15:44:19
Maybe the problem here is just the comment. Manag
brianderson
2013/08/07 18:41:57
Thanks for the background. I would like to avoid c
enne (OOO)
2013/08/07 19:48:48
I wasn't suggesting to move the early out, just to
brianderson
2013/08/07 20:12:29
Ah, I understand your original comment now and it
| |
324 manage_tiles_needed_ = false; | 325 manage_tiles_needed_ = false; |
325 tile_manager_->ManageTiles(); | 326 tile_manager_->ManageTiles(); |
326 | 327 |
327 size_t memory_required_bytes; | 328 size_t memory_required_bytes; |
328 size_t memory_nice_to_have_bytes; | 329 size_t memory_nice_to_have_bytes; |
329 size_t memory_used_bytes; | 330 size_t memory_used_bytes; |
330 tile_manager_->GetMemoryStats(&memory_required_bytes, | 331 tile_manager_->GetMemoryStats(&memory_required_bytes, |
331 &memory_nice_to_have_bytes, | 332 &memory_nice_to_have_bytes, |
332 &memory_used_bytes); | 333 &memory_used_bytes); |
333 SendManagedMemoryStats(memory_required_bytes, | 334 SendManagedMemoryStats(memory_required_bytes, |
334 memory_nice_to_have_bytes, | 335 memory_nice_to_have_bytes, |
335 memory_used_bytes); | 336 memory_used_bytes); |
337 return true; | |
336 } | 338 } |
337 | 339 |
338 void LayerTreeHostImpl::StartPageScaleAnimation(gfx::Vector2d target_offset, | 340 void LayerTreeHostImpl::StartPageScaleAnimation(gfx::Vector2d target_offset, |
339 bool anchor_point, | 341 bool anchor_point, |
340 float page_scale, | 342 float page_scale, |
341 base::TimeTicks start_time, | 343 base::TimeTicks start_time, |
342 base::TimeDelta duration) { | 344 base::TimeDelta duration) { |
343 if (!RootScrollLayer()) | 345 if (!RootScrollLayer()) |
344 return; | 346 return; |
345 | 347 |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1055 | 1057 |
1056 void LayerTreeHostImpl::DidInitializeVisibleTile() { | 1058 void LayerTreeHostImpl::DidInitializeVisibleTile() { |
1057 // TODO(reveman): Determine tiles that changed and only damage | 1059 // TODO(reveman): Determine tiles that changed and only damage |
1058 // what's necessary. | 1060 // what's necessary. |
1059 SetFullRootLayerDamage(); | 1061 SetFullRootLayerDamage(); |
1060 if (client_) | 1062 if (client_) |
1061 client_->DidInitializeVisibleTileOnImplThread(); | 1063 client_->DidInitializeVisibleTileOnImplThread(); |
1062 } | 1064 } |
1063 | 1065 |
1064 void LayerTreeHostImpl::NotifyReadyToActivate() { | 1066 void LayerTreeHostImpl::NotifyReadyToActivate() { |
1065 if (pending_tree_) { | 1067 client_->NotifyReadyToActivate(); |
1066 need_to_update_visible_tiles_before_draw_ = true; | |
1067 ActivatePendingTree(); | |
1068 } | |
1069 } | 1068 } |
1070 | 1069 |
1071 bool LayerTreeHostImpl::ShouldClearRootRenderPass() const { | 1070 bool LayerTreeHostImpl::ShouldClearRootRenderPass() const { |
1072 return settings_.should_clear_root_render_pass; | 1071 return settings_.should_clear_root_render_pass; |
1073 } | 1072 } |
1074 | 1073 |
1075 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { | 1074 void LayerTreeHostImpl::SetMemoryPolicy(const ManagedMemoryPolicy& policy) { |
1076 SetManagedMemoryPolicy(policy, zero_budget_); | 1075 SetManagedMemoryPolicy(policy, zero_budget_); |
1077 } | 1076 } |
1078 | 1077 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1303 bool LayerTreeHostImpl::IsContextLost() { | 1302 bool LayerTreeHostImpl::IsContextLost() { |
1304 DCHECK(proxy_->IsImplThread()); | 1303 DCHECK(proxy_->IsImplThread()); |
1305 return renderer_ && renderer_->IsContextLost(); | 1304 return renderer_ && renderer_->IsContextLost(); |
1306 } | 1305 } |
1307 | 1306 |
1308 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const { | 1307 const RendererCapabilities& LayerTreeHostImpl::GetRendererCapabilities() const { |
1309 return renderer_->Capabilities(); | 1308 return renderer_->Capabilities(); |
1310 } | 1309 } |
1311 | 1310 |
1312 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { | 1311 bool LayerTreeHostImpl::SwapBuffers(const LayerTreeHostImpl::FrameData& frame) { |
1313 if (frame.has_no_damage) | 1312 if (frame.has_no_damage || output_surface_lost_) |
1314 return false; | 1313 return false; |
1315 renderer_->SwapBuffers(); | 1314 renderer_->SwapBuffers(); |
1316 active_tree_->ClearLatencyInfo(); | 1315 active_tree_->ClearLatencyInfo(); |
1317 return true; | 1316 return true; |
1318 } | 1317 } |
1319 | 1318 |
1320 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { | 1319 void LayerTreeHostImpl::SetNeedsBeginFrame(bool enable) { |
1321 if (output_surface_) | 1320 if (output_surface_) |
1322 output_surface_->SetNeedsBeginFrame(enable); | 1321 output_surface_->SetNeedsBeginFrame(enable); |
1323 } | 1322 } |
(...skipping 22 matching lines...) Expand all Loading... | |
1346 } | 1345 } |
1347 | 1346 |
1348 const LayerTreeSettings& LayerTreeHostImpl::Settings() const { | 1347 const LayerTreeSettings& LayerTreeHostImpl::Settings() const { |
1349 return settings(); | 1348 return settings(); |
1350 } | 1349 } |
1351 | 1350 |
1352 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1351 void LayerTreeHostImpl::DidLoseOutputSurface() { |
1353 // TODO(jamesr): The renderer_ check is needed to make some of the | 1352 // TODO(jamesr): The renderer_ check is needed to make some of the |
1354 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or | 1353 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or |
1355 // important) in production. We should adjust the test to not need this. | 1354 // important) in production. We should adjust the test to not need this. |
1355 output_surface_lost_ = true; | |
1356 if (renderer_) | 1356 if (renderer_) |
1357 client_->DidLoseOutputSurfaceOnImplThread(); | 1357 client_->DidLoseOutputSurfaceOnImplThread(); |
1358 } | 1358 } |
1359 | 1359 |
1360 void LayerTreeHostImpl::Readback(void* pixels, | 1360 void LayerTreeHostImpl::Readback(void* pixels, |
1361 gfx::Rect rect_in_device_viewport) { | 1361 gfx::Rect rect_in_device_viewport) { |
1362 DCHECK(renderer_); | 1362 DCHECK(renderer_); |
1363 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport); | 1363 renderer_->GetFramebufferPixels(pixels, rect_in_device_viewport); |
1364 } | 1364 } |
1365 | 1365 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1440 TRACE_EVENT_ASYNC_STEP1( | 1440 TRACE_EVENT_ASYNC_STEP1( |
1441 "cc", | 1441 "cc", |
1442 "PendingTree", pending_tree_.get(), "activate", | 1442 "PendingTree", pending_tree_.get(), "activate", |
1443 "state", TracedValue::FromValue(ActivationStateAsValue().release())); | 1443 "state", TracedValue::FromValue(ActivationStateAsValue().release())); |
1444 } | 1444 } |
1445 | 1445 |
1446 void LayerTreeHostImpl::ActivatePendingTree() { | 1446 void LayerTreeHostImpl::ActivatePendingTree() { |
1447 CHECK(pending_tree_); | 1447 CHECK(pending_tree_); |
1448 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", pending_tree_.get()); | 1448 TRACE_EVENT_ASYNC_END0("cc", "PendingTree", pending_tree_.get()); |
1449 | 1449 |
1450 need_to_update_visible_tiles_before_draw_ = true; | |
1451 | |
1450 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); | 1452 active_tree_->SetRootLayerScrollOffsetDelegate(NULL); |
1451 active_tree_->PushPersistedState(pending_tree_.get()); | 1453 active_tree_->PushPersistedState(pending_tree_.get()); |
1452 if (pending_tree_->needs_full_tree_sync()) { | 1454 if (pending_tree_->needs_full_tree_sync()) { |
1453 active_tree_->SetRootLayer( | 1455 active_tree_->SetRootLayer( |
1454 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), | 1456 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), |
1455 active_tree_->DetachLayerTree(), | 1457 active_tree_->DetachLayerTree(), |
1456 active_tree_.get())); | 1458 active_tree_.get())); |
1457 } | 1459 } |
1458 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), | 1460 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), |
1459 active_tree_->root_layer()); | 1461 active_tree_->root_layer()); |
1460 DCHECK(!recycle_tree_); | 1462 DCHECK(!recycle_tree_); |
1461 | 1463 |
1462 // Process any requests in the UI resource queue. The request queue is given | 1464 // Process any requests in the UI resource queue. The request queue is given |
1463 // in LayerTreeHost::FinishCommitOnImplThread. This must take place before | 1465 // in LayerTreeHost::FinishCommitOnImplThread. This must take place before |
1464 // the swap. | 1466 // the swap. |
1465 pending_tree_->ProcessUIResourceRequestQueue(); | 1467 pending_tree_->ProcessUIResourceRequestQueue(); |
1466 | 1468 |
1467 pending_tree_->PushPropertiesTo(active_tree_.get()); | 1469 pending_tree_->PushPropertiesTo(active_tree_.get()); |
1468 | 1470 |
1469 // Now that we've synced everything from the pending tree to the active | 1471 // Now that we've synced everything from the pending tree to the active |
1470 // tree, rename the pending tree the recycle tree so we can reuse it on the | 1472 // tree, rename the pending tree the recycle tree so we can reuse it on the |
1471 // next sync. | 1473 // next sync. |
1472 pending_tree_.swap(recycle_tree_); | 1474 pending_tree_.swap(recycle_tree_); |
1473 | 1475 |
1474 active_tree_->SetRootLayerScrollOffsetDelegate( | 1476 active_tree_->SetRootLayerScrollOffsetDelegate( |
1475 root_layer_scroll_offset_delegate_); | 1477 root_layer_scroll_offset_delegate_); |
1476 active_tree_->DidBecomeActive(); | 1478 active_tree_->DidBecomeActive(); |
1477 | 1479 |
1480 client_->DidActivatePendingTree(); | |
1481 if (!tree_activation_callback_.is_null()) | |
1482 tree_activation_callback_.Run(); | |
1483 | |
1478 // Reduce wasted memory now that unlinked resources are guaranteed not | 1484 // Reduce wasted memory now that unlinked resources are guaranteed not |
1479 // to be used. | 1485 // to be used. |
1480 client_->ReduceWastedContentsTextureMemoryOnImplThread(); | 1486 client_->ReduceWastedContentsTextureMemoryOnImplThread(); |
1481 | 1487 |
1482 client_->OnCanDrawStateChanged(CanDraw()); | 1488 client_->OnCanDrawStateChanged(CanDraw()); |
1483 client_->OnHasPendingTreeStateChanged(pending_tree_); | 1489 client_->OnHasPendingTreeStateChanged(pending_tree_); |
1484 client_->SetNeedsRedrawOnImplThread(); | 1490 client_->SetNeedsRedrawOnImplThread(); |
1485 client_->RenewTreePriority(); | 1491 client_->RenewTreePriority(); |
1486 | 1492 |
1487 if (debug_state_.continuous_painting) { | 1493 if (debug_state_.continuous_painting) { |
1488 const RenderingStats& stats = | 1494 const RenderingStats& stats = |
1489 rendering_stats_instrumentation_->GetRenderingStats(); | 1495 rendering_stats_instrumentation_->GetRenderingStats(); |
1490 paint_time_counter_->SavePaintTime( | 1496 paint_time_counter_->SavePaintTime( |
1491 stats.total_paint_time + stats.total_record_time + | 1497 stats.total_paint_time + stats.total_record_time + |
1492 stats.total_rasterize_time_for_now_bins_on_pending_tree); | 1498 stats.total_rasterize_time_for_now_bins_on_pending_tree); |
1493 } | 1499 } |
1494 | |
1495 client_->DidActivatePendingTree(); | |
1496 if (!tree_activation_callback_.is_null()) | |
1497 tree_activation_callback_.Run(); | |
1498 } | 1500 } |
1499 | 1501 |
1500 void LayerTreeHostImpl::SetVisible(bool visible) { | 1502 void LayerTreeHostImpl::SetVisible(bool visible) { |
1501 DCHECK(proxy_->IsImplThread()); | 1503 DCHECK(proxy_->IsImplThread()); |
1502 | 1504 |
1503 if (visible_ == visible) | 1505 if (visible_ == visible) |
1504 return; | 1506 return; |
1505 visible_ = visible; | 1507 visible_ = visible; |
1506 DidVisibilityChange(this, visible_); | 1508 DidVisibilityChange(this, visible_); |
1507 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); | 1509 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1595 // before we destroy the old resource provider. | 1597 // before we destroy the old resource provider. |
1596 ReleaseTreeResources(); | 1598 ReleaseTreeResources(); |
1597 if (resource_provider_) | 1599 if (resource_provider_) |
1598 resource_provider_->DidLoseOutputSurface(); | 1600 resource_provider_->DidLoseOutputSurface(); |
1599 | 1601 |
1600 // Note: order is important here. | 1602 // Note: order is important here. |
1601 renderer_.reset(); | 1603 renderer_.reset(); |
1602 tile_manager_.reset(); | 1604 tile_manager_.reset(); |
1603 resource_provider_.reset(); | 1605 resource_provider_.reset(); |
1604 output_surface_.reset(); | 1606 output_surface_.reset(); |
1607 output_surface_lost_ = true; | |
1605 | 1608 |
1606 if (!output_surface->BindToClient(this)) | 1609 if (!output_surface->BindToClient(this)) |
1607 return false; | 1610 return false; |
1608 | 1611 |
1609 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( | 1612 scoped_ptr<ResourceProvider> resource_provider = ResourceProvider::Create( |
1610 output_surface.get(), settings_.highp_threshold_min); | 1613 output_surface.get(), settings_.highp_threshold_min); |
1611 if (!resource_provider) | 1614 if (!resource_provider) |
1612 return false; | 1615 return false; |
1613 | 1616 |
1614 if (output_surface->capabilities().deferred_gl_initialization) | 1617 if (output_surface->capabilities().deferred_gl_initialization) |
(...skipping 25 matching lines...) Expand all Loading... | |
1640 } | 1643 } |
1641 | 1644 |
1642 int max_frames_pending = | 1645 int max_frames_pending = |
1643 output_surface->capabilities().max_frames_pending; | 1646 output_surface->capabilities().max_frames_pending; |
1644 if (max_frames_pending <= 0) | 1647 if (max_frames_pending <= 0) |
1645 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; | 1648 max_frames_pending = OutputSurface::DEFAULT_MAX_FRAMES_PENDING; |
1646 output_surface->SetMaxFramesPending(max_frames_pending); | 1649 output_surface->SetMaxFramesPending(max_frames_pending); |
1647 | 1650 |
1648 resource_provider_ = resource_provider.Pass(); | 1651 resource_provider_ = resource_provider.Pass(); |
1649 output_surface_ = output_surface.Pass(); | 1652 output_surface_ = output_surface.Pass(); |
1653 output_surface_lost_ = false; | |
1650 | 1654 |
1651 client_->OnCanDrawStateChanged(CanDraw()); | 1655 client_->OnCanDrawStateChanged(CanDraw()); |
1652 | 1656 |
1653 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs | 1657 // See note in LayerTreeImpl::UpdateDrawProperties. Renderer needs |
1654 // to be initialized to get max texture size. | 1658 // to be initialized to get max texture size. |
1655 active_tree_->set_needs_update_draw_properties(); | 1659 active_tree_->set_needs_update_draw_properties(); |
1656 if (pending_tree_) | 1660 if (pending_tree_) |
1657 pending_tree_->set_needs_update_draw_properties(); | 1661 pending_tree_->set_needs_update_draw_properties(); |
1658 | 1662 |
1659 return true; | 1663 return true; |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2190 for (size_t i = 0; i < layer_impl->children().size(); ++i) | 2194 for (size_t i = 0; i < layer_impl->children().size(); ++i) |
2191 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); | 2195 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); |
2192 } | 2196 } |
2193 | 2197 |
2194 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { | 2198 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { |
2195 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); | 2199 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); |
2196 | 2200 |
2197 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); | 2201 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); |
2198 scroll_info->page_scale_delta = active_tree_->page_scale_delta(); | 2202 scroll_info->page_scale_delta = active_tree_->page_scale_delta(); |
2199 active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); | 2203 active_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); |
2204 if (pending_tree_) | |
2205 pending_tree_->set_sent_page_scale_delta(scroll_info->page_scale_delta); | |
enne (OOO)
2013/08/06 23:35:16
Sent page scale delta should always be 1 on the pe
brianderson
2013/08/07 01:55:51
What prompted the page scale delta changes was tha
| |
2200 | 2206 |
2201 return scroll_info.Pass(); | 2207 return scroll_info.Pass(); |
2202 } | 2208 } |
2203 | 2209 |
2204 void LayerTreeHostImpl::SetFullRootLayerDamage() { | 2210 void LayerTreeHostImpl::SetFullRootLayerDamage() { |
2205 SetViewportDamage(gfx::Rect(device_viewport_size_)); | 2211 SetViewportDamage(gfx::Rect(device_viewport_size_)); |
2206 } | 2212 } |
2207 | 2213 |
2208 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks time) { | 2214 void LayerTreeHostImpl::AnimatePageScale(base::TimeTicks time) { |
2209 if (!page_scale_animation_ || !RootScrollLayer()) | 2215 if (!page_scale_animation_ || !RootScrollLayer()) |
2210 return; | 2216 return; |
2211 | 2217 |
2212 double monotonic_time = (time - base::TimeTicks()).InSecondsF(); | 2218 double monotonic_time = (time - base::TimeTicks()).InSecondsF(); |
2213 gfx::Vector2dF scroll_total = RootScrollLayer()->scroll_offset() + | 2219 gfx::Vector2dF scroll_total = RootScrollLayer()->scroll_offset() + |
2214 RootScrollLayer()->ScrollDelta(); | 2220 RootScrollLayer()->ScrollDelta(); |
2215 | 2221 |
2216 active_tree_->SetPageScaleDelta( | 2222 active_tree_->SetPageScaleDelta( |
2217 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / | 2223 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / |
2218 active_tree_->page_scale_factor()); | 2224 active_tree_->page_scale_factor()); |
2225 if (pending_tree_) { | |
2226 pending_tree_->SetPageScaleDelta( | |
2227 page_scale_animation_->PageScaleFactorAtTime(monotonic_time) / | |
2228 pending_tree_->page_scale_factor()); | |
2229 } | |
2230 | |
2219 gfx::Vector2dF next_scroll = | 2231 gfx::Vector2dF next_scroll = |
2220 page_scale_animation_->ScrollOffsetAtTime(monotonic_time); | 2232 page_scale_animation_->ScrollOffsetAtTime(monotonic_time); |
2221 | 2233 |
2222 RootScrollLayer()->ScrollBy(next_scroll - scroll_total); | 2234 RootScrollLayer()->ScrollBy(next_scroll - scroll_total); |
2223 client_->SetNeedsRedrawOnImplThread(); | 2235 client_->SetNeedsRedrawOnImplThread(); |
2224 | 2236 |
2225 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { | 2237 if (page_scale_animation_->IsAnimationCompleteAtTime(monotonic_time)) { |
2226 page_scale_animation_.reset(); | 2238 page_scale_animation_.reset(); |
2227 client_->SetNeedsCommitOnImplThread(); | 2239 client_->SetNeedsCommitOnImplThread(); |
2228 client_->RenewTreePriority(); | 2240 client_->RenewTreePriority(); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2495 | 2507 |
2496 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | 2508 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
2497 UIResourceId uid) const { | 2509 UIResourceId uid) const { |
2498 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | 2510 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
2499 if (iter != ui_resource_map_.end()) | 2511 if (iter != ui_resource_map_.end()) |
2500 return iter->second; | 2512 return iter->second; |
2501 return 0; | 2513 return 0; |
2502 } | 2514 } |
2503 | 2515 |
2504 } // namespace cc | 2516 } // namespace cc |
OLD | NEW |