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 22 matching lines...) Expand all Loading... |
33 #include "cc/output/copy_output_request.h" | 33 #include "cc/output/copy_output_request.h" |
34 #include "cc/output/delegating_renderer.h" | 34 #include "cc/output/delegating_renderer.h" |
35 #include "cc/output/gl_renderer.h" | 35 #include "cc/output/gl_renderer.h" |
36 #include "cc/output/software_renderer.h" | 36 #include "cc/output/software_renderer.h" |
37 #include "cc/quads/render_pass_draw_quad.h" | 37 #include "cc/quads/render_pass_draw_quad.h" |
38 #include "cc/quads/shared_quad_state.h" | 38 #include "cc/quads/shared_quad_state.h" |
39 #include "cc/quads/solid_color_draw_quad.h" | 39 #include "cc/quads/solid_color_draw_quad.h" |
40 #include "cc/resources/memory_history.h" | 40 #include "cc/resources/memory_history.h" |
41 #include "cc/resources/picture_layer_tiling.h" | 41 #include "cc/resources/picture_layer_tiling.h" |
42 #include "cc/resources/prioritized_resource_manager.h" | 42 #include "cc/resources/prioritized_resource_manager.h" |
| 43 #include "cc/resources/ui_resource_bitmap.h" |
43 #include "cc/scheduler/delay_based_time_source.h" | 44 #include "cc/scheduler/delay_based_time_source.h" |
44 #include "cc/scheduler/texture_uploader.h" | 45 #include "cc/scheduler/texture_uploader.h" |
45 #include "cc/trees/damage_tracker.h" | 46 #include "cc/trees/damage_tracker.h" |
46 #include "cc/trees/layer_tree_host.h" | 47 #include "cc/trees/layer_tree_host.h" |
47 #include "cc/trees/layer_tree_host_common.h" | 48 #include "cc/trees/layer_tree_host_common.h" |
48 #include "cc/trees/layer_tree_impl.h" | 49 #include "cc/trees/layer_tree_impl.h" |
49 #include "cc/trees/quad_culler.h" | 50 #include "cc/trees/quad_culler.h" |
50 #include "cc/trees/single_thread_proxy.h" | 51 #include "cc/trees/single_thread_proxy.h" |
51 #include "cc/trees/tree_synchronizer.h" | 52 #include "cc/trees/tree_synchronizer.h" |
52 #include "ui/gfx/size_conversions.h" | 53 #include "ui/gfx/size_conversions.h" |
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 if (pending_tree_->needs_full_tree_sync()) { | 1451 if (pending_tree_->needs_full_tree_sync()) { |
1451 active_tree_->SetRootLayer( | 1452 active_tree_->SetRootLayer( |
1452 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), | 1453 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), |
1453 active_tree_->DetachLayerTree(), | 1454 active_tree_->DetachLayerTree(), |
1454 active_tree_.get())); | 1455 active_tree_.get())); |
1455 } | 1456 } |
1456 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), | 1457 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), |
1457 active_tree_->root_layer()); | 1458 active_tree_->root_layer()); |
1458 DCHECK(!recycle_tree_); | 1459 DCHECK(!recycle_tree_); |
1459 | 1460 |
| 1461 // Process any requests in the UI resource queue. The request queue is given |
| 1462 // in LayerTreeHost::FinishCommitOnImplThread. This must take place before |
| 1463 // the swap. |
| 1464 pending_tree_->ProcessUIResourceRequestQueue(); |
| 1465 |
1460 pending_tree_->PushPropertiesTo(active_tree_.get()); | 1466 pending_tree_->PushPropertiesTo(active_tree_.get()); |
1461 | 1467 |
1462 // Now that we've synced everything from the pending tree to the active | 1468 // Now that we've synced everything from the pending tree to the active |
1463 // tree, rename the pending tree the recycle tree so we can reuse it on the | 1469 // tree, rename the pending tree the recycle tree so we can reuse it on the |
1464 // next sync. | 1470 // next sync. |
1465 pending_tree_.swap(recycle_tree_); | 1471 pending_tree_.swap(recycle_tree_); |
1466 | 1472 |
1467 active_tree_->SetRootLayerScrollOffsetDelegate( | 1473 active_tree_->SetRootLayerScrollOffsetDelegate( |
1468 root_layer_scroll_offset_delegate_); | 1474 root_layer_scroll_offset_delegate_); |
1469 active_tree_->DidBecomeActive(); | 1475 active_tree_->DidBecomeActive(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 return actual; | 1523 return actual; |
1518 } | 1524 } |
1519 | 1525 |
1520 void LayerTreeHostImpl::ReleaseTreeResources() { | 1526 void LayerTreeHostImpl::ReleaseTreeResources() { |
1521 if (active_tree_->root_layer()) | 1527 if (active_tree_->root_layer()) |
1522 SendReleaseResourcesRecursive(active_tree_->root_layer()); | 1528 SendReleaseResourcesRecursive(active_tree_->root_layer()); |
1523 if (pending_tree_ && pending_tree_->root_layer()) | 1529 if (pending_tree_ && pending_tree_->root_layer()) |
1524 SendReleaseResourcesRecursive(pending_tree_->root_layer()); | 1530 SendReleaseResourcesRecursive(pending_tree_->root_layer()); |
1525 if (recycle_tree_ && recycle_tree_->root_layer()) | 1531 if (recycle_tree_ && recycle_tree_->root_layer()) |
1526 SendReleaseResourcesRecursive(recycle_tree_->root_layer()); | 1532 SendReleaseResourcesRecursive(recycle_tree_->root_layer()); |
| 1533 |
| 1534 // Remove all existing maps from UIResourceId to ResourceId. |
| 1535 ui_resource_map_.clear(); |
1527 } | 1536 } |
1528 | 1537 |
1529 void LayerTreeHostImpl::CreateAndSetRenderer( | 1538 void LayerTreeHostImpl::CreateAndSetRenderer( |
1530 OutputSurface* output_surface, | 1539 OutputSurface* output_surface, |
1531 ResourceProvider* resource_provider, | 1540 ResourceProvider* resource_provider, |
1532 bool skip_gl_renderer) { | 1541 bool skip_gl_renderer) { |
1533 DCHECK(!renderer_); | 1542 DCHECK(!renderer_); |
1534 if (output_surface->capabilities().delegated_rendering) { | 1543 if (output_surface->capabilities().delegated_rendering) { |
1535 renderer_ = | 1544 renderer_ = |
1536 DelegatingRenderer::Create(this, output_surface, resource_provider); | 1545 DelegatingRenderer::Create(this, output_surface, resource_provider); |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2442 const LayerTreeDebugState& new_debug_state) { | 2451 const LayerTreeDebugState& new_debug_state) { |
2443 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) | 2452 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) |
2444 return; | 2453 return; |
2445 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) | 2454 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) |
2446 paint_time_counter_->ClearHistory(); | 2455 paint_time_counter_->ClearHistory(); |
2447 | 2456 |
2448 debug_state_ = new_debug_state; | 2457 debug_state_ = new_debug_state; |
2449 SetFullRootLayerDamage(); | 2458 SetFullRootLayerDamage(); |
2450 } | 2459 } |
2451 | 2460 |
| 2461 void LayerTreeHostImpl::CreateUIResource( |
| 2462 UIResourceId uid, |
| 2463 scoped_refptr<UIResourceBitmap> bitmap) { |
| 2464 DCHECK_GT(uid, 0); |
| 2465 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8); |
| 2466 |
| 2467 // Allow for multiple creation requests with the same UIResourceId. The |
| 2468 // previous resource is simply deleted. |
| 2469 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
| 2470 if (id) |
| 2471 DeleteUIResource(uid); |
| 2472 id = resource_provider_->CreateResource( |
| 2473 bitmap->GetSize(), GL_RGBA, ResourceProvider::TextureUsageAny); |
| 2474 |
| 2475 ui_resource_map_[uid] = id; |
| 2476 resource_provider_->SetPixels(id, |
| 2477 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), |
| 2478 gfx::Rect(bitmap->GetSize()), |
| 2479 gfx::Rect(bitmap->GetSize()), |
| 2480 gfx::Vector2d(0, 0)); |
| 2481 } |
| 2482 |
| 2483 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { |
| 2484 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
| 2485 if (id) { |
| 2486 resource_provider_->DeleteResource(id); |
| 2487 ui_resource_map_.erase(uid); |
| 2488 } |
| 2489 } |
| 2490 |
| 2491 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( |
| 2492 UIResourceId uid) const { |
| 2493 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); |
| 2494 if (iter != ui_resource_map_.end()) |
| 2495 return iter->second; |
| 2496 return 0; |
| 2497 } |
| 2498 |
2452 } // namespace cc | 2499 } // namespace cc |
OLD | NEW |