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

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, 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
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"
enne (OOO) 2013/07/31 22:02:40 What is this include for? I'm a little skeptical o
powei 2013/08/01 00:05:10 Done. Removed. My old way of creating resource r
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 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(), 1445 TreeSynchronizer::SynchronizeTrees(pending_tree_->root_layer(),
1444 active_tree_->DetachLayerTree(), 1446 active_tree_->DetachLayerTree(),
1445 active_tree_.get())); 1447 active_tree_.get()));
1446 } 1448 }
1447 TreeSynchronizer::PushProperties(pending_tree_->root_layer(), 1449 TreeSynchronizer::PushProperties(pending_tree_->root_layer(),
1448 active_tree_->root_layer()); 1450 active_tree_->root_layer());
1449 DCHECK(!recycle_tree_); 1451 DCHECK(!recycle_tree_);
1450 1452
1451 pending_tree_->PushPropertiesTo(active_tree_.get()); 1453 pending_tree_->PushPropertiesTo(active_tree_.get());
1452 1454
1455 // Process any requests in the UI resource queue. The request queue is given
1456 // in LayerTreeHost::FinishCommitOnImplThread. This must take place before
1457 // the swap.
1458 pending_tree_->ProcessUIResourceRequestQueue();
enne (OOO) 2013/07/31 22:02:40 For sanity's sake, what about doing this before pe
powei 2013/08/01 00:05:10 Done.
1459
1453 // Now that we've synced everything from the pending tree to the active 1460 // Now that we've synced everything from the pending tree to the active
1454 // tree, rename the pending tree the recycle tree so we can reuse it on the 1461 // tree, rename the pending tree the recycle tree so we can reuse it on the
1455 // next sync. 1462 // next sync.
1456 pending_tree_.swap(recycle_tree_); 1463 pending_tree_.swap(recycle_tree_);
1457 1464
1458 active_tree_->SetRootLayerScrollOffsetDelegate( 1465 active_tree_->SetRootLayerScrollOffsetDelegate(
1459 root_layer_scroll_offset_delegate_); 1466 root_layer_scroll_offset_delegate_);
1460 active_tree_->DidBecomeActive(); 1467 active_tree_->DidBecomeActive();
1461 1468
1462 // Reduce wasted memory now that unlinked resources are guaranteed not 1469 // Reduce wasted memory now that unlinked resources are guaranteed not
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 return actual; 1515 return actual;
1509 } 1516 }
1510 1517
1511 void LayerTreeHostImpl::ReleaseTreeResources() { 1518 void LayerTreeHostImpl::ReleaseTreeResources() {
1512 if (active_tree_->root_layer()) 1519 if (active_tree_->root_layer())
1513 SendReleaseResourcesRecursive(active_tree_->root_layer()); 1520 SendReleaseResourcesRecursive(active_tree_->root_layer());
1514 if (pending_tree_ && pending_tree_->root_layer()) 1521 if (pending_tree_ && pending_tree_->root_layer())
1515 SendReleaseResourcesRecursive(pending_tree_->root_layer()); 1522 SendReleaseResourcesRecursive(pending_tree_->root_layer());
1516 if (recycle_tree_ && recycle_tree_->root_layer()) 1523 if (recycle_tree_ && recycle_tree_->root_layer())
1517 SendReleaseResourcesRecursive(recycle_tree_->root_layer()); 1524 SendReleaseResourcesRecursive(recycle_tree_->root_layer());
1525
1526 // Remove all existing maps from UIResourceId to ResourceId.
1527 ui_resource_map_.clear();
1518 } 1528 }
1519 1529
1520 void LayerTreeHostImpl::CreateAndSetRenderer( 1530 void LayerTreeHostImpl::CreateAndSetRenderer(
1521 OutputSurface* output_surface, 1531 OutputSurface* output_surface,
1522 ResourceProvider* resource_provider, 1532 ResourceProvider* resource_provider,
1523 bool skip_gl_renderer) { 1533 bool skip_gl_renderer) {
1524 DCHECK(!renderer_); 1534 DCHECK(!renderer_);
1525 if (output_surface->capabilities().delegated_rendering) { 1535 if (output_surface->capabilities().delegated_rendering) {
1526 renderer_ = 1536 renderer_ =
1527 DelegatingRenderer::Create(this, output_surface, resource_provider); 1537 DelegatingRenderer::Create(this, output_surface, resource_provider);
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 const LayerTreeDebugState& new_debug_state) { 2443 const LayerTreeDebugState& new_debug_state) {
2434 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) 2444 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state))
2435 return; 2445 return;
2436 if (debug_state_.continuous_painting != new_debug_state.continuous_painting) 2446 if (debug_state_.continuous_painting != new_debug_state.continuous_painting)
2437 paint_time_counter_->ClearHistory(); 2447 paint_time_counter_->ClearHistory();
2438 2448
2439 debug_state_ = new_debug_state; 2449 debug_state_ = new_debug_state;
2440 SetFullRootLayerDamage(); 2450 SetFullRootLayerDamage();
2441 } 2451 }
2442 2452
2453 void LayerTreeHostImpl::CreateUIResource(
2454 UIResourceId uid,
enne (OOO) 2013/07/31 22:02:40 DCHECK_GT(uid, 0)?
powei 2013/08/01 00:05:10 Done.
2455 scoped_refptr<UIResourceBitmap> bitmap) {
2456 DCHECK(bitmap->GetFormat() == UIResourceBitmap::RGBA8);
aelias_OOO_until_Jul13 2013/07/31 21:00:30 DCHECK_EQ(UIResourceBitmap::RGBA8, bitmap->GetForm
powei 2013/07/31 21:29:39 Done.
2457
2458 // Allow for multiple creation requests with the same UIResourceId. The
2459 // previous resource is simply deleted.
2460 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2461 if (id)
enne (OOO) 2013/07/31 22:02:40 style nit: {} for both the if and the else
powei 2013/08/01 00:05:10 Done. Only the if remains. The else conditional
2462 DeleteUIResource(uid);
2463 else
2464 id = resource_provider_->CreateResource(
2465 bitmap->GetSize(), GL_RGBA, ResourceProvider::TextureUsageAny);
2466
2467 ui_resource_map_[uid] = id;
2468 gfx::Size bitmap_size = bitmap->GetSize();
aelias_OOO_until_Jul13 2013/07/31 21:00:30 nit: no need for this temp variable
powei 2013/07/31 21:29:39 Done.
2469 resource_provider_->SetPixels(id,
2470 reinterpret_cast<uint8_t*>(bitmap->GetPixels()),
2471 gfx::Rect(bitmap_size),
2472 gfx::Rect(bitmap_size),
2473 gfx::Vector2d(0, 0));
2474 }
2475
2476 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
2477 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2478 if (id) {
2479 resource_provider_->DeleteResource(id);
2480 ui_resource_map_.erase(uid);
2481 }
2482 }
2483
2484 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
2485 UIResourceId uid) const {
2486 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
2487 if (iter != ui_resource_map_.end())
2488 return iter->second;
2489 return 0;
2490 }
2491
2443 } // namespace cc 2492 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698