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

Side by Side Diff: cc/trees/layer_tree_host.cc

Issue 22870016: Update the nine patch layer to use UI resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compilation error fixes 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 unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <stack> 8 #include <stack>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 if (iter == ui_resource_client_map_.end()) 1148 if (iter == ui_resource_client_map_.end())
1149 return; 1149 return;
1150 1150
1151 UIResourceRequest request; 1151 UIResourceRequest request;
1152 request.type = UIResourceRequest::UIResourceDelete; 1152 request.type = UIResourceRequest::UIResourceDelete;
1153 request.id = uid; 1153 request.id = uid;
1154 ui_resource_request_queue_.push_back(request); 1154 ui_resource_request_queue_.push_back(request);
1155 ui_resource_client_map_.erase(uid); 1155 ui_resource_client_map_.erase(uid);
1156 } 1156 }
1157 1157
1158 // Deletes a UI resource. May safely be called more than once.
danakj 2013/08/27 15:42:48 Remove this?
powei 2013/08/27 22:39:28 Done.
1159 gfx::Size LayerTreeHost::GetUIResourceSize(UIResourceId uid) {
1160 UIResourceClientMap::iterator iter = ui_resource_client_map_.find(uid);
danakj 2013/08/27 15:42:48 nit: s/iter/it/
powei 2013/08/27 22:39:28 Done.
1161 if (iter == ui_resource_client_map_.end())
1162 return gfx::Size();
1163
1164 DCHECK(iter->second);
1165
1166 bool resource_lost = false;
1167 scoped_refptr<UIResourceBitmap> bitmap =
1168 iter->second->GetBitmap(uid, resource_lost);
danakj 2013/08/27 15:42:48 can you use a local variable const& or non-const&
powei 2013/08/27 22:39:28 Done.
1169
1170 DCHECK(bitmap.get());
1171
1172 return bitmap->GetSize();
1173 }
1174
1158 void LayerTreeHost::UIResourceLost(UIResourceId uid) { 1175 void LayerTreeHost::UIResourceLost(UIResourceId uid) {
1159 UIResourceClientMap::iterator iter = ui_resource_client_map_.find(uid); 1176 UIResourceClientMap::iterator iter = ui_resource_client_map_.find(uid);
1160 if (iter == ui_resource_client_map_.end()) 1177 if (iter == ui_resource_client_map_.end())
1161 return; 1178 return;
1162 1179
1163 UIResourceRequest request; 1180 UIResourceRequest request;
1164 bool resource_lost = true; 1181 bool resource_lost = true;
1165 request.type = UIResourceRequest::UIResourceCreate; 1182 request.type = UIResourceRequest::UIResourceCreate;
1166 request.id = uid; 1183 request.id = uid;
1167 request.bitmap = iter->second->GetBitmap(uid, resource_lost); 1184 request.bitmap = iter->second->GetBitmap(uid, resource_lost);
1168 DCHECK(request.bitmap.get()); 1185 DCHECK(request.bitmap.get());
1169 ui_resource_request_queue_.push_back(request); 1186 ui_resource_request_queue_.push_back(request);
1170 } 1187 }
1171 1188
1172 void LayerTreeHost::DidLoseUIResources() { 1189 void LayerTreeHost::DidLoseUIResources() {
1173 // When output surface is lost, we need to recreate the resource. 1190 // When output surface is lost, we need to recreate the resource.
1174 for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin(); 1191 for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin();
1175 iter != ui_resource_client_map_.end(); 1192 iter != ui_resource_client_map_.end();
1176 ++iter) { 1193 ++iter) {
1177 UIResourceLost(iter->first); 1194 UIResourceLost(iter->first);
1178 } 1195 }
1179 } 1196 }
1180 1197
1181 } // namespace cc 1198 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698