| 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
|
| + // "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
|
|
|