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

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: 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 210393)
+++ 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"
@@ -1298,6 +1300,20 @@
}
void LayerTreeHostImpl::DidLoseOutputSurface() {
+ // When output surface is lost, notify the client of the lost and remove
+ // exisiting entries.
enne (OOO) 2013/07/22 23:09:15 typo: exisiting => existing
powei 2013/07/24 02:28:29 Done.
+ for (UIResourceMap::iterator iter = ui_resource_map_.begin();
+ iter != ui_resource_map_.end();
+ iter++) {
+ client_->UIResourceLostOnImplThread(iter->first);
enne (OOO) 2013/07/22 23:09:15 I am still a little confused about this path. It
aelias_OOO_until_Jul13 2013/07/23 00:06:48 I agree with Enne, the loop should be in LayerTree
powei 2013/07/24 02:28:29 Done.
powei 2013/07/24 02:28:29 Done.
+ }
+ // Remove all map from existing UIResourceId to ResourceId.
+ ui_resource_map_.clear();
+ // Remove all pending UI resource requests because there might be
+ // deletion requests, which can no longer be honored (or already
+ // gone anyways).
+ ui_resource_request_queue_.clear();
+
// 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.
@@ -1430,6 +1446,19 @@
stats.total_rasterize_time_for_now_bins_on_pending_tree);
}
+ while (ui_resource_request_queue_.size() > 0) {
+ UIResourceRequest req = ui_resource_request_queue_.front();
+ ui_resource_request_queue_.pop_front();
+ switch (req.type) {
+ case UIResourceCreate:
+ CreateUIResource(req.id, req.bitmap);
enne (OOO) 2013/07/22 23:09:15 In general activation is gated on having all of yo
aelias_OOO_until_Jul13 2013/07/23 00:06:48 Yes, the assumption is that for v1 of this patch,
powei 2013/07/24 02:28:29 Done.
powei 2013/07/24 02:28:29 Done.
+ break;
+ case UIResourceDelete:
+ DeleteUIResource(req.id);
+ break;
+ }
+ }
+
client_->DidActivatePendingTree();
}
@@ -2362,4 +2391,39 @@
debug_state_ = debug_state;
}
+void LayerTreeHostImpl::CreateUIResource(
+ UIResourceId uid,
+ scoped_refptr<UIResourceBitmap> bitmap) {
+ ResourceProvider::ResourceId id =
+ resource_provider_->CreateGLTexture(bitmap->GetSize(),
enne (OOO) 2013/07/22 23:09:15 CreateGLTexture in LayerTreeHostImpl? What if ther
powei 2013/07/24 02:28:29 Done.
+ GL_RGBA,
enne (OOO) 2013/07/22 23:09:15 Should you DCHECK that bitmap's format is RGBA8 an
powei 2013/07/24 02:28:29 Done.
+ GL_TEXTURE_POOL_UNMANAGED_CHROMIUM,
+ ResourceProvider::TextureUsageAny);
+
+ ui_resource_map_[uid] = id;
enne (OOO) 2013/07/22 23:09:15 Can you DCHECK that it doesn't previously exist?
powei 2013/07/24 02:28:29 Done.
+ 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 {
+ if (ui_resource_map_.find(uid) != ui_resource_map_.end()) {
enne (OOO) 2013/07/22 23:09:15 If you're going to find and then do something with
powei 2013/07/24 02:28:29 Done.
+ return ui_resource_map_.find(uid)->second;
+ }
+ return 0;
+}
+
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698