Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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; |
|
ccameron
2013/08/26 23:54:32
I haven't seen this way for naming a parameter bef
danakj
2013/08/27 00:30:03
This is generally how we pass bool literals, ie we
| |
| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 619 page_scale_factor_ = page_scale_factor; | 620 page_scale_factor_ = page_scale_factor; |
| 620 min_page_scale_factor_ = min_page_scale_factor; | 621 min_page_scale_factor_ = min_page_scale_factor; |
| 621 max_page_scale_factor_ = max_page_scale_factor; | 622 max_page_scale_factor_ = max_page_scale_factor; |
| 622 SetNeedsCommit(); | 623 SetNeedsCommit(); |
| 623 } | 624 } |
| 624 | 625 |
| 625 void LayerTreeHost::SetVisible(bool visible) { | 626 void LayerTreeHost::SetVisible(bool visible) { |
| 626 if (visible_ == visible) | 627 if (visible_ == visible) |
| 627 return; | 628 return; |
| 628 visible_ = visible; | 629 visible_ = visible; |
| 629 if (!visible) | 630 if (!visible) { |
| 630 ReduceMemoryUsage(); | 631 ReduceMemoryUsage(); |
| 632 } else { | |
| 633 // Recreate the UI resources since they were evicted when SetVisible(false). | |
| 634 bool resource_lost = false; | |
| 635 RecreateUIResources(resource_lost); | |
| 636 } | |
| 631 proxy_->SetVisible(visible); | 637 proxy_->SetVisible(visible); |
| 632 } | 638 } |
| 633 | 639 |
| 634 void LayerTreeHost::SetLatencyInfo(const ui::LatencyInfo& latency_info) { | 640 void LayerTreeHost::SetLatencyInfo(const ui::LatencyInfo& latency_info) { |
| 635 latency_info_.MergeWith(latency_info); | 641 latency_info_.MergeWith(latency_info); |
| 636 } | 642 } |
| 637 | 643 |
| 638 void LayerTreeHost::StartPageScaleAnimation(gfx::Vector2d target_offset, | 644 void LayerTreeHost::StartPageScaleAnimation(gfx::Vector2d target_offset, |
| 639 bool use_anchor, | 645 bool use_anchor, |
| 640 float scale, | 646 float scale, |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1148 if (iter == ui_resource_client_map_.end()) | 1154 if (iter == ui_resource_client_map_.end()) |
| 1149 return; | 1155 return; |
| 1150 | 1156 |
| 1151 UIResourceRequest request; | 1157 UIResourceRequest request; |
| 1152 request.type = UIResourceRequest::UIResourceDelete; | 1158 request.type = UIResourceRequest::UIResourceDelete; |
| 1153 request.id = uid; | 1159 request.id = uid; |
| 1154 ui_resource_request_queue_.push_back(request); | 1160 ui_resource_request_queue_.push_back(request); |
| 1155 ui_resource_client_map_.erase(uid); | 1161 ui_resource_client_map_.erase(uid); |
| 1156 } | 1162 } |
| 1157 | 1163 |
| 1158 void LayerTreeHost::UIResourceLost(UIResourceId uid) { | 1164 void LayerTreeHost::RecreateUIResources(bool resource_lost) { |
| 1159 UIResourceClientMap::iterator iter = ui_resource_client_map_.find(uid); | |
| 1160 if (iter == ui_resource_client_map_.end()) | |
| 1161 return; | |
| 1162 | |
| 1163 UIResourceRequest request; | |
| 1164 bool resource_lost = true; | |
| 1165 request.type = UIResourceRequest::UIResourceCreate; | |
| 1166 request.id = uid; | |
| 1167 request.bitmap = iter->second->GetBitmap(uid, resource_lost); | |
| 1168 DCHECK(request.bitmap.get()); | |
| 1169 ui_resource_request_queue_.push_back(request); | |
| 1170 } | |
| 1171 | |
| 1172 void LayerTreeHost::DidLoseUIResources() { | |
| 1173 // When output surface is lost, we need to recreate the resource. | 1165 // When output surface is lost, we need to recreate the resource. |
| 1174 for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin(); | 1166 for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin(); |
| 1175 iter != ui_resource_client_map_.end(); | 1167 iter != ui_resource_client_map_.end(); |
| 1176 ++iter) { | 1168 ++iter) { |
| 1177 UIResourceLost(iter->first); | 1169 UIResourceId uid = iter->first; |
| 1170 UIResourceRequest request; | |
| 1171 request.type = UIResourceRequest::UIResourceCreate; | |
| 1172 request.id = uid; | |
| 1173 request.bitmap = iter->second->GetBitmap(uid, resource_lost); | |
| 1174 DCHECK(request.bitmap.get()); | |
| 1175 ui_resource_request_queue_.push_back(request); | |
| 1178 } | 1176 } |
| 1179 } | 1177 } |
| 1180 | 1178 |
| 1181 } // namespace cc | 1179 } // namespace cc |
| OLD | NEW |