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

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: Switched to resource client instead of callback 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
Index: cc/trees/layer_tree_host_impl.cc
===================================================================
--- cc/trees/layer_tree_host_impl.cc (revision 213649)
+++ 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"
@@ -49,6 +50,7 @@
#include "cc/trees/quad_culler.h"
#include "cc/trees/single_thread_proxy.h"
#include "cc/trees/tree_synchronizer.h"
+#include "gpu/GLES2/gl2extchromium.h"
#include "ui/gfx/size_conversions.h"
#include "ui/gfx/vector2d_conversions.h"
@@ -1310,6 +1312,16 @@
}
void LayerTreeHostImpl::DidLoseOutputSurface() {
+ // Remove all existing maps from UIResourceId to ResourceId.
+ ui_resource_map_.clear();
+ // Also remove any requests in the pending queue. Reasons:
+ // 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
+ // "resource lost" re-creation.
+ // 2. If the request was a deletion, then the request is moot since the
+ // resource no longer exists.
+ if (pending_tree())
+ pending_tree()->set_ui_resource_request_queue(UIResourceRequestQueue());
+
// TODO(jamesr): The renderer_ check is needed to make some of the
// LayerTreeHostContextTest tests pass, but shouldn't be necessary (or
// important) in production. We should adjust the test to not need this.
@@ -1421,6 +1433,11 @@
pending_tree_->PushPropertiesTo(active_tree_.get());
+ // 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();
+
// Now that we've synced everything from the pending tree to the active
// tree, rename the pending tree the recycle tree so we can reuse it on the
// next sync.
@@ -2411,4 +2428,38 @@
SetFullRootLayerDamage();
}
+void LayerTreeHostImpl::CreateUIResource(
+ UIResourceId uid,
+ scoped_refptr<UIResourceBitmap> bitmap) {
+ DCHECK(bitmap->GetFormat() == UIResourceBitmap::RGBA8);
+
+ ResourceProvider::ResourceId id = resource_provider_->CreateResource(
+ bitmap->GetSize(), GL_RGBA, ResourceProvider::TextureUsageAny);
+
+ DCHECK(ui_resource_map_.find(uid) == ui_resource_map_.end());
+ ui_resource_map_[uid] = id;
+ gfx::Size bitmap_size = bitmap->GetSize();
+ resource_provider_->SetPixels(id,
+ reinterpret_cast<uint8_t*>(bitmap->GetPixels()),
+ gfx::Rect(bitmap_size),
+ gfx::Rect(bitmap_size),
+ 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

Powered by Google App Engine
This is Rietveld 408576698