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

Unified Diff: trunk/src/cc/trees/layer_tree_host.cc

Issue 23740010: Revert 223162 "Update the nine patch layer to use UI resources" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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 | « trunk/src/cc/trees/layer_tree_host.h ('k') | trunk/src/cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/cc/trees/layer_tree_host.cc
===================================================================
--- trunk/src/cc/trees/layer_tree_host.cc (revision 223178)
+++ trunk/src/cc/trees/layer_tree_host.cc (working copy)
@@ -61,32 +61,9 @@
RendererCapabilities::~RendererCapabilities() {}
-UIResourceRequest::UIResourceRequest(UIResourceRequestType type,
- UIResourceId id)
- : type_(type), id_(id) {}
+UIResourceRequest::UIResourceRequest()
+ : type(UIResourceInvalidRequest), id(0), bitmap(NULL) {}
-UIResourceRequest::UIResourceRequest(UIResourceRequestType type,
- UIResourceId id,
- const UIResourceBitmap& bitmap)
- : type_(type), id_(id), bitmap_(new UIResourceBitmap(bitmap)) {}
-
-UIResourceRequest::UIResourceRequest(const UIResourceRequest& request) {
- (*this) = request;
-}
-
-UIResourceRequest& UIResourceRequest::operator=(
- const UIResourceRequest& request) {
- type_ = request.type_;
- id_ = request.id_;
- if (request.bitmap_) {
- bitmap_ = make_scoped_ptr(new UIResourceBitmap(*request.bitmap_.get()));
- } else {
- bitmap_.reset();
- }
-
- return *this;
-}
-
UIResourceRequest::~UIResourceRequest() {}
bool LayerTreeHost::AnyLayerTreeHostInstanceExists() {
@@ -399,7 +376,7 @@
if (overhang_ui_resource_) {
host_impl->SetOverhangUIResource(
overhang_ui_resource_->id(),
- GetUIResourceSize(overhang_ui_resource_->id()));
+ overhang_ui_resource_->GetSize());
}
DCHECK(!sync_tree->ViewportSizeInvalid());
@@ -657,16 +634,16 @@
DCHECK(bitmap.width() && bitmap.height());
DCHECK_EQ(bitmap.bytesPerPixel(), 4);
- SkBitmap bitmap_copy;
- if (bitmap.isImmutable()) {
- bitmap_copy = bitmap;
- } else {
- bitmap.copyTo(&bitmap_copy, bitmap.config());
- bitmap_copy.setImmutable();
- }
-
- overhang_ui_resource_ = ScopedUIResource::Create(
- this, UIResourceBitmap(bitmap_copy, UIResourceBitmap::REPEAT));
+ scoped_refptr<UIResourceBitmap> overhang_ui_bitmap(UIResourceBitmap::Create(
+ new uint8_t[bitmap.width() * bitmap.height() * bitmap.bytesPerPixel()],
+ UIResourceBitmap::RGBA8,
+ UIResourceBitmap::REPEAT,
+ gfx::Size(bitmap.width(), bitmap.height())));
+ bitmap.copyPixelsTo(
+ overhang_ui_bitmap->GetPixels(),
+ bitmap.width() * bitmap.height() * bitmap.bytesPerPixel(),
+ bitmap.width() * bitmap.bytesPerPixel());
+ overhang_ui_resource_ = ScopedUIResource::Create(this, overhang_ui_bitmap);
}
void LayerTreeHost::SetVisible(bool visible) {
@@ -1169,22 +1146,18 @@
UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) {
DCHECK(client);
- UIResourceId next_id = next_ui_resource_id_++;
- DCHECK(ui_resource_client_map_.find(next_id) ==
- ui_resource_client_map_.end());
-
+ UIResourceRequest request;
bool resource_lost = false;
- UIResourceRequest request(UIResourceRequest::UIResourceCreate,
- next_id,
- client->GetBitmap(next_id, resource_lost));
- ui_resource_request_queue_.push_back(request);
+ request.type = UIResourceRequest::UIResourceCreate;
+ request.id = next_ui_resource_id_++;
- UIResourceClientData data;
- data.client = client;
- data.size = request.GetBitmap().GetSize();
+ DCHECK(ui_resource_client_map_.find(request.id) ==
+ ui_resource_client_map_.end());
- ui_resource_client_map_[request.GetId()] = data;
- return request.GetId();
+ request.bitmap = client->GetBitmap(request.id, resource_lost);
+ ui_resource_request_queue_.push_back(request);
+ ui_resource_client_map_[request.id] = client;
+ return request.id;
}
// Deletes a UI resource. May safely be called more than once.
@@ -1193,9 +1166,11 @@
if (iter == ui_resource_client_map_.end())
return;
- UIResourceRequest request(UIResourceRequest::UIResourceDelete, uid);
+ UIResourceRequest request;
+ request.type = UIResourceRequest::UIResourceDelete;
+ request.id = uid;
ui_resource_request_queue_.push_back(request);
- ui_resource_client_map_.erase(iter);
+ ui_resource_client_map_.erase(uid);
}
void LayerTreeHost::RecreateUIResources() {
@@ -1203,23 +1178,14 @@
iter != ui_resource_client_map_.end();
++iter) {
UIResourceId uid = iter->first;
- const UIResourceClientData& data = iter->second;
+ UIResourceRequest request;
+ request.type = UIResourceRequest::UIResourceCreate;
+ request.id = uid;
bool resource_lost = true;
- UIResourceRequest request(UIResourceRequest::UIResourceCreate,
- uid,
- data.client->GetBitmap(uid, resource_lost));
+ request.bitmap = iter->second->GetBitmap(uid, resource_lost);
+ DCHECK(request.bitmap.get());
ui_resource_request_queue_.push_back(request);
}
}
-// Returns the size of a resource given its id.
-gfx::Size LayerTreeHost::GetUIResourceSize(UIResourceId uid) const {
- UIResourceClientMap::const_iterator iter = ui_resource_client_map_.find(uid);
- if (iter == ui_resource_client_map_.end())
- return gfx::Size();
-
- const UIResourceClientData& data = iter->second;
- return data.size;
-}
-
} // namespace cc
« no previous file with comments | « trunk/src/cc/trees/layer_tree_host.h ('k') | trunk/src/cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698