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

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: Fixed nits and bugs, removed cruft, added test for Create/DeleteUIResource in LTHI Created 7 years, 4 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
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
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 // Active tree should have no requests in its queue.
1462 DCHECK_EQ(active_tree_->ui_resource_request_queue_size(), 0u);
enne (OOO) 2013/08/01 00:26:56 Ah, I meant to check this in LayerTreeImpl::PushPr
powei 2013/08/01 03:27:03 Done.
1463 // Process any requests in the UI resource queue. The request queue is given
1464 // in LayerTreeHost::FinishCommitOnImplThread. This must take place before
1465 // the swap.
1466 pending_tree_->ProcessUIResourceRequestQueue();
1467 // No more requests left in the queue.
1468 DCHECK_EQ(pending_tree_->ui_resource_request_queue_size(), 0u);
1469
1460 pending_tree_->PushPropertiesTo(active_tree_.get()); 1470 pending_tree_->PushPropertiesTo(active_tree_.get());
1461 1471
1462 // Now that we've synced everything from the pending tree to the active 1472 // 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 1473 // tree, rename the pending tree the recycle tree so we can reuse it on the
1464 // next sync. 1474 // next sync.
1465 pending_tree_.swap(recycle_tree_); 1475 pending_tree_.swap(recycle_tree_);
1466 1476
1467 active_tree_->SetRootLayerScrollOffsetDelegate( 1477 active_tree_->SetRootLayerScrollOffsetDelegate(
1468 root_layer_scroll_offset_delegate_); 1478 root_layer_scroll_offset_delegate_);
1469 active_tree_->DidBecomeActive(); 1479 active_tree_->DidBecomeActive();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 return actual; 1527 return actual;
1518 } 1528 }
1519 1529
1520 void LayerTreeHostImpl::ReleaseTreeResources() { 1530 void LayerTreeHostImpl::ReleaseTreeResources() {
1521 if (active_tree_->root_layer()) 1531 if (active_tree_->root_layer())
1522 SendReleaseResourcesRecursive(active_tree_->root_layer()); 1532 SendReleaseResourcesRecursive(active_tree_->root_layer());
1523 if (pending_tree_ && pending_tree_->root_layer()) 1533 if (pending_tree_ && pending_tree_->root_layer())
1524 SendReleaseResourcesRecursive(pending_tree_->root_layer()); 1534 SendReleaseResourcesRecursive(pending_tree_->root_layer());
1525 if (recycle_tree_ && recycle_tree_->root_layer()) 1535 if (recycle_tree_ && recycle_tree_->root_layer())
1526 SendReleaseResourcesRecursive(recycle_tree_->root_layer()); 1536 SendReleaseResourcesRecursive(recycle_tree_->root_layer());
1537
1538 // Remove all existing maps from UIResourceId to ResourceId.
1539 ui_resource_map_.clear();
1527 } 1540 }
1528 1541
1529 void LayerTreeHostImpl::CreateAndSetRenderer( 1542 void LayerTreeHostImpl::CreateAndSetRenderer(
1530 OutputSurface* output_surface, 1543 OutputSurface* output_surface,
1531 ResourceProvider* resource_provider, 1544 ResourceProvider* resource_provider,
1532 bool skip_gl_renderer) { 1545 bool skip_gl_renderer) {
1533 DCHECK(!renderer_); 1546 DCHECK(!renderer_);
1534 if (output_surface->capabilities().delegated_rendering) { 1547 if (output_surface->capabilities().delegated_rendering) {
1535 renderer_ = 1548 renderer_ =
1536 DelegatingRenderer::Create(this, output_surface, resource_provider); 1549 DelegatingRenderer::Create(this, output_surface, resource_provider);
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 const LayerTreeDebugState& new_debug_state) { 2455 const LayerTreeDebugState& new_debug_state) {
2443 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) 2456 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state))
2444 return; 2457 return;
2445 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) 2458 if (debug_state_.continuous_painting != new_debug_state.continuous_painting)
2446 paint_time_counter_->ClearHistory(); 2459 paint_time_counter_->ClearHistory();
2447 2460
2448 debug_state_ = new_debug_state; 2461 debug_state_ = new_debug_state;
2449 SetFullRootLayerDamage(); 2462 SetFullRootLayerDamage();
2450 } 2463 }
2451 2464
2465 void LayerTreeHostImpl::CreateUIResource(
2466 UIResourceId uid,
2467 scoped_refptr<UIResourceBitmap> bitmap) {
2468 DCHECK_GT(uid, 0);
2469 DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8);
2470
2471 // Allow for multiple creation requests with the same UIResourceId. The
2472 // previous resource is simply deleted.
2473 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2474 if (id)
2475 DeleteUIResource(uid);
2476 id = resource_provider_->CreateResource(
2477 bitmap->GetSize(), GL_RGBA, ResourceProvider::TextureUsageAny);
2478
2479 ui_resource_map_[uid] = id;
2480 resource_provider_->SetPixels(id,
2481 reinterpret_cast<uint8_t*>(bitmap->GetPixels()),
2482 gfx::Rect(bitmap->GetSize()),
2483 gfx::Rect(bitmap->GetSize()),
2484 gfx::Vector2d(0, 0));
2485 }
2486
2487 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
2488 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2489 if (id) {
2490 resource_provider_->DeleteResource(id);
2491 ui_resource_map_.erase(uid);
2492 }
2493 }
2494
2495 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
2496 UIResourceId uid) const {
2497 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
2498 if (iter != ui_resource_map_.end())
2499 return iter->second;
2500 return 0;
2501 }
2502
2452 } // namespace cc 2503 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698