Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 18191020: UI Resource Manager (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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.
1318 UIResourceRequestQueue empty_queue;
1319 if (pending_tree())
1320 pending_tree()->set_ui_resource_request_queue(empty_queue);
1321
1313 // TODO(jamesr): The renderer_ check is needed to make some of the 1322 // TODO(jamesr): The renderer_ check is needed to make some of the
1314 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or 1323 // LayerTreeHostContextTest tests pass, but shouldn't be necessary (or
1315 // important) in production. We should adjust the test to not need this. 1324 // important) in production. We should adjust the test to not need this.
1316 if (renderer_) 1325 if (renderer_)
1317 client_->DidLoseOutputSurfaceOnImplThread(); 1326 client_->DidLoseOutputSurfaceOnImplThread();
1318 } 1327 }
1319 1328
1320 void LayerTreeHostImpl::Readback(void* pixels, 1329 void LayerTreeHostImpl::Readback(void* pixels,
1321 gfx::Rect rect_in_device_viewport) { 1330 gfx::Rect rect_in_device_viewport) {
1322 DCHECK(renderer_); 1331 DCHECK(renderer_);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), 1423 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(),
1415 active_tree_->DetachLayerTree(), 1424 active_tree_->DetachLayerTree(),
1416 active_tree_.get())); 1425 active_tree_.get()));
1417 } 1426 }
1418 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), 1427 TreeSynchronizer::PushProperties(pending_tree_->root_layer(),
1419 active_tree_->root_layer()); 1428 active_tree_->root_layer());
1420 DCHECK(!recycle_tree_); 1429 DCHECK(!recycle_tree_);
1421 1430
1422 pending_tree_->PushPropertiesTo(active_tree_.get()); 1431 pending_tree_->PushPropertiesTo(active_tree_.get());
1423 1432
1433 // Process any requests in the UI resource queue. The request queue is given
1434 // in LayerTreeHost::FinishCommitOnImplThread. This must take place before
1435 // the swap.
1436 pending_tree_->ProcessUIResourceRequestQueue();
1437
1424 // Now that we've synced everything from the pending tree to the active 1438 // 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 1439 // tree, rename the pending tree the recycle tree so we can reuse it on the
1426 // next sync. 1440 // next sync.
1427 pending_tree_.swap(recycle_tree_); 1441 pending_tree_.swap(recycle_tree_);
1428 1442
1429 active_tree_->SetRootLayerScrollOffsetDelegate( 1443 active_tree_->SetRootLayerScrollOffsetDelegate(
1430 root_layer_scroll_offset_delegate_); 1444 root_layer_scroll_offset_delegate_);
1431 active_tree_->DidBecomeActive(); 1445 active_tree_->DidBecomeActive();
1432 1446
1433 // Reduce wasted memory now that unlinked resources are guaranteed not 1447 // Reduce wasted memory now that unlinked resources are guaranteed not
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 const LayerTreeDebugState& new_debug_state) { 2418 const LayerTreeDebugState& new_debug_state) {
2405 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) 2419 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state))
2406 return; 2420 return;
2407 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) 2421 if (debug_state_.continuous_painting != new_debug_state.continuous_painting)
2408 paint_time_counter_->ClearHistory(); 2422 paint_time_counter_->ClearHistory();
2409 2423
2410 debug_state_ = new_debug_state; 2424 debug_state_ = new_debug_state;
2411 SetFullRootLayerDamage(); 2425 SetFullRootLayerDamage();
2412 } 2426 }
2413 2427
2428 void LayerTreeHostImpl::CreateUIResource(
2429 UIResourceId uid,
2430 scoped_refptr<UIResourceBitmap> bitmap) {
2431 DCHECK(bitmap->GetFormat() == UIResourceBitmap::RGBA8);
2432
2433 ResourceProvider::ResourceId id = resource_provider_->CreateResource(
2434 bitmap->GetSize(), GL_RGBA, ResourceProvider::TextureUsageAny);
2435
2436 DCHECK(ui_resource_map_.find(uid) == ui_resource_map_.end());
2437 ui_resource_map_[uid] = id;
2438 gfx::Size bitmap_size = bitmap->GetSize();
2439 resource_provider_->SetPixels(id,
2440 reinterpret_cast<uint8_t*>(bitmap->GetPixels()),
2441 gfx::Rect(bitmap_size),
2442 gfx::Rect(bitmap_size),
2443 gfx::Vector2d(0, 0));
2444 }
2445
2446 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
2447 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2448 if (id) {
2449 resource_provider_->DeleteResource(id);
2450 ui_resource_map_.erase(uid);
2451 }
2452 }
2453
2454 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
2455 UIResourceId uid) const {
2456 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
2457 if (iter != ui_resource_map_.end())
2458 return iter->second;
2459 return 0;
2460 }
2461
2414 } // namespace cc 2462 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698