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

Unified 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: Added DCHECK of resource queue size to PushPropertiesTo 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl.cc
===================================================================
--- cc/trees/layer_tree_host_impl.cc (revision 214824)
+++ cc/trees/layer_tree_host_impl.cc (working copy)
@@ -40,6 +40,7 @@
#include "cc/resources/memory_history.h"
#include "cc/resources/picture_layer_tiling.h"
#include "cc/resources/prioritized_resource_manager.h"
+#include "cc/resources/ui_resource_bitmap.h"
#include "cc/scheduler/delay_based_time_source.h"
#include "cc/scheduler/texture_uploader.h"
#include "cc/trees/damage_tracker.h"
@@ -1457,6 +1458,11 @@
active_tree_->root_layer());
DCHECK(!recycle_tree_);
+ // Process any requests in the UI resource queue. The request queue is given
+ // in LayerTreeHost::FinishCommitOnImplThread. This must take place before
+ // the swap.
+ pending_tree_->ProcessUIResourceRequestQueue();
+
pending_tree_->PushPropertiesTo(active_tree_.get());
// Now that we've synced everything from the pending tree to the active
@@ -1524,6 +1530,9 @@
SendReleaseResourcesRecursive(pending_tree_->root_layer());
if (recycle_tree_ && recycle_tree_->root_layer())
SendReleaseResourcesRecursive(recycle_tree_->root_layer());
+
+ // Remove all existing maps from UIResourceId to ResourceId.
+ ui_resource_map_.clear();
}
void LayerTreeHostImpl::CreateAndSetRenderer(
@@ -2449,4 +2458,42 @@
SetFullRootLayerDamage();
}
+void LayerTreeHostImpl::CreateUIResource(
+ UIResourceId uid,
+ scoped_refptr<UIResourceBitmap> bitmap) {
+ DCHECK_GT(uid, 0);
+ DCHECK_EQ(bitmap->GetFormat(), UIResourceBitmap::RGBA8);
+
+ // Allow for multiple creation requests with the same UIResourceId. The
+ // previous resource is simply deleted.
+ ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
+ if (id)
+ DeleteUIResource(uid);
+ id = resource_provider_->CreateResource(
+ bitmap->GetSize(), GL_RGBA, ResourceProvider::TextureUsageAny);
+
+ ui_resource_map_[uid] = id;
+ resource_provider_->SetPixels(id,
+ reinterpret_cast<uint8_t*>(bitmap->GetPixels()),
+ gfx::Rect(bitmap->GetSize()),
+ gfx::Rect(bitmap->GetSize()),
+ gfx::Vector2d(0, 0));
+}
+
+void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
+ ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
+ if (id) {
+ resource_provider_->DeleteResource(id);
+ ui_resource_map_.erase(uid);
+ }
+}
+
+ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
+ UIResourceId uid) const {
+ UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
+ if (iter != ui_resource_map_.end())
+ return iter->second;
+ return 0;
+}
+
} // namespace cc
« 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