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

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

Issue 23475021: [cc] Consolidate UI resource destruction and recreation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 return host_impl.Pass(); 428 return host_impl.Pass();
429 } 429 }
430 430
431 void LayerTreeHost::DidLoseOutputSurface() { 431 void LayerTreeHost::DidLoseOutputSurface() {
432 TRACE_EVENT0("cc", "LayerTreeHost::DidLoseOutputSurface"); 432 TRACE_EVENT0("cc", "LayerTreeHost::DidLoseOutputSurface");
433 DCHECK(proxy_->IsMainThread()); 433 DCHECK(proxy_->IsMainThread());
434 434
435 if (output_surface_lost_) 435 if (output_surface_lost_)
436 return; 436 return;
437 437
438 DidLoseUIResources(); 438 bool resource_lost = true;
439 RecreateUIResources(resource_lost);
439 440
440 num_failed_recreate_attempts_ = 0; 441 num_failed_recreate_attempts_ = 0;
441 output_surface_lost_ = true; 442 output_surface_lost_ = true;
442 SetNeedsCommit(); 443 SetNeedsCommit();
443 } 444 }
444 445
445 bool LayerTreeHost::CompositeAndReadback(void* pixels, 446 bool LayerTreeHost::CompositeAndReadback(void* pixels,
446 gfx::Rect rect_in_device_viewport) { 447 gfx::Rect rect_in_device_viewport) {
447 trigger_idle_updates_ = false; 448 trigger_idle_updates_ = false;
448 bool ret = proxy_->CompositeAndReadback(pixels, rect_in_device_viewport); 449 bool ret = proxy_->CompositeAndReadback(pixels, rect_in_device_viewport);
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 if (iter == ui_resource_client_map_.end()) 1144 if (iter == ui_resource_client_map_.end())
1144 return; 1145 return;
1145 1146
1146 UIResourceRequest request; 1147 UIResourceRequest request;
1147 request.type = UIResourceRequest::UIResourceDelete; 1148 request.type = UIResourceRequest::UIResourceDelete;
1148 request.id = uid; 1149 request.id = uid;
1149 ui_resource_request_queue_.push_back(request); 1150 ui_resource_request_queue_.push_back(request);
1150 ui_resource_client_map_.erase(uid); 1151 ui_resource_client_map_.erase(uid);
1151 } 1152 }
1152 1153
1153 void LayerTreeHost::UIResourceLost(UIResourceId uid) { 1154 void LayerTreeHost::RecreateUIResources(bool resource_lost) {
1154 UIResourceClientMap::iterator iter = ui_resource_client_map_.find(uid);
1155 if (iter == ui_resource_client_map_.end())
1156 return;
1157
1158 UIResourceRequest request;
1159 bool resource_lost = true;
1160 request.type = UIResourceRequest::UIResourceCreate;
1161 request.id = uid;
1162 request.bitmap = iter->second->GetBitmap(uid, resource_lost);
1163 DCHECK(request.bitmap.get());
1164 ui_resource_request_queue_.push_back(request);
1165 }
1166
1167 void LayerTreeHost::DidLoseUIResources() {
1168 // When output surface is lost, we need to recreate the resource.
1169 for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin(); 1155 for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin();
1170 iter != ui_resource_client_map_.end(); 1156 iter != ui_resource_client_map_.end();
1171 ++iter) { 1157 ++iter) {
1172 UIResourceLost(iter->first); 1158 UIResourceId uid = iter->first;
1159 UIResourceRequest request;
1160 request.type = UIResourceRequest::UIResourceCreate;
1161 request.id = uid;
1162 request.bitmap = iter->second->GetBitmap(uid, resource_lost);
1163 DCHECK(request.bitmap.get());
1164 ui_resource_request_queue_.push_back(request);
1173 } 1165 }
1174 } 1166 }
1175 1167
1176 } // namespace cc 1168 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698