Index: cc/trees/layer_tree_host_impl.cc |
=================================================================== |
--- cc/trees/layer_tree_host_impl.cc (revision 214760) |
+++ 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" |
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
|
#include "ui/gfx/size_conversions.h" |
#include "ui/gfx/vector2d_conversions.h" |
@@ -1450,6 +1452,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(); |
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.
|
+ |
// 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. |
@@ -1515,6 +1522,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( |
@@ -2440,4 +2450,43 @@ |
SetFullRootLayerDamage(); |
} |
+void LayerTreeHostImpl::CreateUIResource( |
+ UIResourceId uid, |
enne (OOO)
2013/07/31 22:02:40
DCHECK_GT(uid, 0)?
powei
2013/08/01 00:05:10
Done.
|
+ scoped_refptr<UIResourceBitmap> bitmap) { |
+ 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.
|
+ |
+ // Allow for multiple creation requests with the same UIResourceId. The |
+ // previous resource is simply deleted. |
+ ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); |
+ 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
|
+ DeleteUIResource(uid); |
+ else |
+ id = resource_provider_->CreateResource( |
+ bitmap->GetSize(), GL_RGBA, ResourceProvider::TextureUsageAny); |
+ |
+ ui_resource_map_[uid] = id; |
+ 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.
|
+ 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 |