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

Side by Side Diff: cc/layers/ui_resource_layer.cc

Issue 664173002: Prevent recreation of UI resource holder when created with resource ID (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/ui_resource_layer.h" 5 #include "cc/layers/ui_resource_layer.h"
6 6
7 #include "cc/layers/ui_resource_layer_impl.h" 7 #include "cc/layers/ui_resource_layer_impl.h"
8 #include "cc/resources/prioritized_resource.h" 8 #include "cc/resources/prioritized_resource.h"
9 #include "cc/resources/resource_update.h" 9 #include "cc/resources/resource_update.h"
10 #include "cc/resources/resource_update_queue.h" 10 #include "cc/resources/resource_update_queue.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 if (host == layer_tree_host()) 105 if (host == layer_tree_host())
106 return; 106 return;
107 107
108 Layer::SetLayerTreeHost(host); 108 Layer::SetLayerTreeHost(host);
109 109
110 // Recreate the resource hold against the new LTH. 110 // Recreate the resource hold against the new LTH.
111 RecreateUIResourceHolder(); 111 RecreateUIResourceHolder();
112 } 112 }
113 113
114 void UIResourceLayer::RecreateUIResourceHolder() { 114 void UIResourceLayer::RecreateUIResourceHolder() {
115 UIResourceId ui_resource_id = 0;
awoloszyn 2014/10/21 14:29:41 If someone calls SetBitmap with an empty bitmap, w
Changwan Ryu 2014/10/21 17:28:57 Good idea. I overlooked it. Done.
116 if (ui_resource_holder_.get())
117 ui_resource_id = ui_resource_holder_->id();
118
115 ui_resource_holder_ = nullptr; 119 ui_resource_holder_ = nullptr;
awoloszyn 2014/10/21 14:29:41 Something like // ui_resource_holder_ = nullptr; (
Changwan Ryu 2014/10/21 17:28:57 Done.
116 if (layer_tree_host() && !bitmap_.empty()) { 120 if (layer_tree_host() && !bitmap_.empty()) {
117 ui_resource_holder_ = 121 ui_resource_holder_ =
118 ScopedUIResourceHolder::Create(layer_tree_host(), bitmap_); 122 ScopedUIResourceHolder::Create(layer_tree_host(), bitmap_);
123 } else if (ui_resource_id != 0) {
124 ui_resource_holder_ = SharedUIResourceHolder::Create(ui_resource_id);
119 } 125 }
120 UpdateDrawsContent(HasDrawableContent()); 126 UpdateDrawsContent(HasDrawableContent());
121 } 127 }
122 128
123 void UIResourceLayer::SetBitmap(const SkBitmap& skbitmap) { 129 void UIResourceLayer::SetBitmap(const SkBitmap& skbitmap) {
124 bitmap_ = skbitmap; 130 bitmap_ = skbitmap;
125 131
126 RecreateUIResourceHolder(); 132 RecreateUIResourceHolder();
127 SetNeedsCommit(); 133 SetNeedsCommit();
128 } 134 }
(...skipping 28 matching lines...) Expand all
157 gfx::Size image_size = 163 gfx::Size image_size =
158 layer_tree_host()->GetUIResourceSize(ui_resource_holder_->id()); 164 layer_tree_host()->GetUIResourceSize(ui_resource_holder_->id());
159 layer_impl->SetUIResourceId(ui_resource_holder_->id()); 165 layer_impl->SetUIResourceId(ui_resource_holder_->id());
160 layer_impl->SetImageBounds(image_size); 166 layer_impl->SetImageBounds(image_size);
161 layer_impl->SetUV(uv_top_left_, uv_bottom_right_); 167 layer_impl->SetUV(uv_top_left_, uv_bottom_right_);
162 layer_impl->SetVertexOpacity(vertex_opacity_); 168 layer_impl->SetVertexOpacity(vertex_opacity_);
163 } 169 }
164 } 170 }
165 171
166 } // namespace cc 172 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698