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" |
53 #include "gpu/GLES2/gl2extchromium.h" | |
52 #include "ui/gfx/size_conversions.h" | 54 #include "ui/gfx/size_conversions.h" |
53 #include "ui/gfx/vector2d_conversions.h" | 55 #include "ui/gfx/vector2d_conversions.h" |
54 | 56 |
55 namespace { | 57 namespace { |
56 | 58 |
57 void DidVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) { | 59 void DidVisibilityChange(cc::LayerTreeHostImpl* id, bool visible) { |
58 if (visible) { | 60 if (visible) { |
59 TRACE_EVENT_ASYNC_BEGIN1("webkit", | 61 TRACE_EVENT_ASYNC_BEGIN1("webkit", |
60 "LayerTreeHostImpl::SetVisible", | 62 "LayerTreeHostImpl::SetVisible", |
61 id, | 63 id, |
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1303 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f; | 1305 top_controls_manager_ ? top_controls_manager_->content_top_offset() : 0.f; |
1304 return gfx::SizeF(dip_size.width(), | 1306 return gfx::SizeF(dip_size.width(), |
1305 dip_size.height() - top_offset - overdraw_bottom_height_); | 1307 dip_size.height() - top_offset - overdraw_bottom_height_); |
1306 } | 1308 } |
1307 | 1309 |
1308 const LayerTreeSettings& LayerTreeHostImpl::Settings() const { | 1310 const LayerTreeSettings& LayerTreeHostImpl::Settings() const { |
1309 return settings(); | 1311 return settings(); |
1310 } | 1312 } |
1311 | 1313 |
1312 void LayerTreeHostImpl::DidLoseOutputSurface() { | 1314 void LayerTreeHostImpl::DidLoseOutputSurface() { |
1315 // Remove all existing maps from UIResourceId to ResourceId. | |
1316 ui_resource_map_.clear(); | |
1317 // Also remove any requests in the pending queue. Reasons: | |
1318 // 1. If the request was a creation, then the main thread will issue a special | |
aelias_OOO_until_Jul13
2013/07/26 23:57:31
It won't reissue creations so this is incorrect.
powei
2013/07/30 21:47:00
The main thread issues a "lost resource" creation
aelias_OOO_until_Jul13
2013/07/30 22:28:44
But the main thread is avoiding re-creation reques
powei
2013/07/30 22:37:50
For impl-side painting, the main thread actually c
aelias_OOO_until_Jul13
2013/07/30 23:04:29
Good point. The main thread has a pointer to the
| |
1319 // "resource lost" re-creation. | |
1320 // 2. If the request was a deletion, then the request is moot since the | |
1321 // resource no longer exists. | |
1322 if (pending_tree()) | |
1323 pending_tree()->set_ui_resource_request_queue(UIResourceRequestQueue()); | |
1324 | |
1313 // TODO(jamesr): The renderer_ check is needed to make some of the | 1325 // TODO(jamesr): The renderer_ check is needed to make some of the |
1314 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or | 1326 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or |
1315 // important) in production. We should adjust the test to not need this. | 1327 // important) in production. We should adjust the test to not need this. |
1316 if (renderer_) | 1328 if (renderer_) |
1317 client_->DidLoseOutputSurfaceOnImplThread(); | 1329 client_->DidLoseOutputSurfaceOnImplThread(); |
1318 } | 1330 } |
1319 | 1331 |
1320 void LayerTreeHostImpl::Readback(void* pixels, | 1332 void LayerTreeHostImpl::Readback(void* pixels, |
1321 gfx::Rect rect_in_device_viewport) { | 1333 gfx::Rect rect_in_device_viewport) { |
1322 DCHECK(renderer_); | 1334 DCHECK(renderer_); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1414 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), | 1426 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), |
1415 active_tree_->DetachLayerTree(), | 1427 active_tree_->DetachLayerTree(), |
1416 active_tree_.get())); | 1428 active_tree_.get())); |
1417 } | 1429 } |
1418 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), | 1430 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), |
1419 active_tree_->root_layer()); | 1431 active_tree_->root_layer()); |
1420 DCHECK(!recycle_tree_); | 1432 DCHECK(!recycle_tree_); |
1421 | 1433 |
1422 pending_tree_->PushPropertiesTo(active_tree_.get()); | 1434 pending_tree_->PushPropertiesTo(active_tree_.get()); |
1423 | 1435 |
1436 // Process any requests in the UI resource queue. The request queue is given | |
1437 // in LayerTreeHost::FinishCommitOnImplThread. This must take place before | |
1438 // the swap. | |
1439 pending_tree_->ProcessUIResourceRequestQueue(); | |
1440 | |
1424 // Now that we've synced everything from the pending tree to the active | 1441 // Now that we've synced everything from the pending tree to the active |
1425 // tree, rename the pending tree the recycle tree so we can reuse it on the | 1442 // tree, rename the pending tree the recycle tree so we can reuse it on the |
1426 // next sync. | 1443 // next sync. |
1427 pending_tree_.swap(recycle_tree_); | 1444 pending_tree_.swap(recycle_tree_); |
1428 | 1445 |
1429 active_tree_->SetRootLayerScrollOffsetDelegate( | 1446 active_tree_->SetRootLayerScrollOffsetDelegate( |
1430 root_layer_scroll_offset_delegate_); | 1447 root_layer_scroll_offset_delegate_); |
1431 active_tree_->DidBecomeActive(); | 1448 active_tree_->DidBecomeActive(); |
1432 | 1449 |
1433 // Reduce wasted memory now that unlinked resources are guaranteed not | 1450 // Reduce wasted memory now that unlinked resources are guaranteed not |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2404 const LayerTreeDebugState& new_debug_state) { | 2421 const LayerTreeDebugState& new_debug_state) { |
2405 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) | 2422 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) |
2406 return; | 2423 return; |
2407 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) | 2424 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) |
2408 paint_time_counter_->ClearHistory(); | 2425 paint_time_counter_->ClearHistory(); |
2409 | 2426 |
2410 debug_state_ = new_debug_state; | 2427 debug_state_ = new_debug_state; |
2411 SetFullRootLayerDamage(); | 2428 SetFullRootLayerDamage(); |
2412 } | 2429 } |
2413 | 2430 |
2431 void LayerTreeHostImpl::CreateUIResource( | |
2432 UIResourceId uid, | |
2433 scoped_refptr<UIResourceBitmap> bitmap) { | |
2434 DCHECK(bitmap->GetFormat() == UIResourceBitmap::RGBA8); | |
2435 | |
2436 ResourceProvider::ResourceId id = resource_provider_->CreateResource( | |
2437 bitmap->GetSize(), GL_RGBA, ResourceProvider::TextureUsageAny); | |
2438 | |
2439 DCHECK(ui_resource_map_.find(uid) == ui_resource_map_.end()); | |
2440 ui_resource_map_[uid] = id; | |
2441 gfx::Size bitmap_size = bitmap->GetSize(); | |
2442 resource_provider_->SetPixels(id, | |
2443 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), | |
2444 gfx::Rect(bitmap_size), | |
2445 gfx::Rect(bitmap_size), | |
2446 gfx::Vector2d(0, 0)); | |
2447 } | |
2448 | |
2449 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { | |
2450 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); | |
2451 if (id) { | |
2452 resource_provider_->DeleteResource(id); | |
2453 ui_resource_map_.erase(uid); | |
2454 } | |
2455 } | |
2456 | |
2457 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( | |
2458 UIResourceId uid) const { | |
2459 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); | |
2460 if (iter != ui_resource_map_.end()) | |
2461 return iter->second; | |
2462 return 0; | |
2463 } | |
2464 | |
2414 } // namespace cc | 2465 } // namespace cc |
OLD | NEW |