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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 if (!output_surface) | 135 if (!output_surface) |
136 return false; | 136 return false; |
137 | 137 |
138 proxy_ = proxy.Pass(); | 138 proxy_ = proxy.Pass(); |
139 proxy_->Start(output_surface.Pass()); | 139 proxy_->Start(output_surface.Pass()); |
140 return true; | 140 return true; |
141 } | 141 } |
142 | 142 |
143 LayerTreeHost::~LayerTreeHost() { | 143 LayerTreeHost::~LayerTreeHost() { |
144 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 144 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
| 145 |
| 146 overhang_ui_resource_.reset(); |
| 147 |
145 if (root_layer_.get()) | 148 if (root_layer_.get()) |
146 root_layer_->SetLayerTreeHost(NULL); | 149 root_layer_->SetLayerTreeHost(NULL); |
147 | 150 |
148 if (proxy_) { | 151 if (proxy_) { |
149 DCHECK(proxy_->IsMainThread()); | 152 DCHECK(proxy_->IsMainThread()); |
150 proxy_->Stop(); | 153 proxy_->Stop(); |
151 } | 154 } |
152 | 155 |
153 s_num_layer_tree_instances--; | 156 s_num_layer_tree_instances--; |
154 RateLimiterMap::iterator it = rate_limiters_.begin(); | 157 RateLimiterMap::iterator it = rate_limiters_.begin(); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 } | 365 } |
363 | 366 |
364 if (!ui_resource_request_queue_.empty()) { | 367 if (!ui_resource_request_queue_.empty()) { |
365 sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_); | 368 sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_); |
366 ui_resource_request_queue_.clear(); | 369 ui_resource_request_queue_.clear(); |
367 // Process any ui resource requests in the queue. For impl-side-painting, | 370 // Process any ui resource requests in the queue. For impl-side-painting, |
368 // the queue is processed in LayerTreeHostImpl::ActivatePendingTree. | 371 // the queue is processed in LayerTreeHostImpl::ActivatePendingTree. |
369 if (!settings_.impl_side_painting) | 372 if (!settings_.impl_side_painting) |
370 sync_tree->ProcessUIResourceRequestQueue(); | 373 sync_tree->ProcessUIResourceRequestQueue(); |
371 } | 374 } |
| 375 if (overhang_ui_resource_) { |
| 376 host_impl->SetOverhangUIResource( |
| 377 overhang_ui_resource_->id(), |
| 378 overhang_ui_resource_->GetSize()); |
| 379 } |
372 | 380 |
373 DCHECK(!sync_tree->ViewportSizeInvalid()); | 381 DCHECK(!sync_tree->ViewportSizeInvalid()); |
374 | 382 |
375 if (new_impl_tree_has_no_evicted_resources) { | 383 if (new_impl_tree_has_no_evicted_resources) { |
376 if (sync_tree->ContentsTexturesPurged()) | 384 if (sync_tree->ContentsTexturesPurged()) |
377 sync_tree->ResetContentsTexturesPurged(); | 385 sync_tree->ResetContentsTexturesPurged(); |
378 } | 386 } |
379 | 387 |
380 if (!settings_.impl_side_painting) { | 388 if (!settings_.impl_side_painting) { |
381 // If we're not in impl-side painting, the tree is immediately | 389 // If we're not in impl-side painting, the tree is immediately |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 min_page_scale_factor == min_page_scale_factor_ && | 624 min_page_scale_factor == min_page_scale_factor_ && |
617 max_page_scale_factor == max_page_scale_factor_) | 625 max_page_scale_factor == max_page_scale_factor_) |
618 return; | 626 return; |
619 | 627 |
620 page_scale_factor_ = page_scale_factor; | 628 page_scale_factor_ = page_scale_factor; |
621 min_page_scale_factor_ = min_page_scale_factor; | 629 min_page_scale_factor_ = min_page_scale_factor; |
622 max_page_scale_factor_ = max_page_scale_factor; | 630 max_page_scale_factor_ = max_page_scale_factor; |
623 SetNeedsCommit(); | 631 SetNeedsCommit(); |
624 } | 632 } |
625 | 633 |
| 634 void LayerTreeHost::SetOverhangBitmap(const SkBitmap& bitmap) { |
| 635 DCHECK(bitmap.width() && bitmap.height()); |
| 636 DCHECK_EQ(bitmap.bytesPerPixel(), 4); |
| 637 |
| 638 scoped_refptr<UIResourceBitmap> overhang_ui_bitmap(UIResourceBitmap::Create( |
| 639 new uint8_t[bitmap.width() * bitmap.height() * bitmap.bytesPerPixel()], |
| 640 UIResourceBitmap::RGBA8, |
| 641 gfx::Size(bitmap.width(), bitmap.height()))); |
| 642 bitmap.copyPixelsTo( |
| 643 overhang_ui_bitmap->GetPixels(), |
| 644 bitmap.width() * bitmap.height() * bitmap.bytesPerPixel(), |
| 645 bitmap.width() * bitmap.bytesPerPixel()); |
| 646 overhang_ui_resource_ = ScopedUIResource::Create(this, overhang_ui_bitmap); |
| 647 } |
| 648 |
626 void LayerTreeHost::SetVisible(bool visible) { | 649 void LayerTreeHost::SetVisible(bool visible) { |
627 if (visible_ == visible) | 650 if (visible_ == visible) |
628 return; | 651 return; |
629 visible_ = visible; | 652 visible_ = visible; |
630 if (!visible) | 653 if (!visible) |
631 ReduceMemoryUsage(); | 654 ReduceMemoryUsage(); |
632 proxy_->SetVisible(visible); | 655 proxy_->SetVisible(visible); |
633 } | 656 } |
634 | 657 |
635 void LayerTreeHost::SetLatencyInfo(const ui::LatencyInfo& latency_info) { | 658 void LayerTreeHost::SetLatencyInfo(const ui::LatencyInfo& latency_info) { |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 void LayerTreeHost::DidLoseUIResources() { | 1190 void LayerTreeHost::DidLoseUIResources() { |
1168 // When output surface is lost, we need to recreate the resource. | 1191 // When output surface is lost, we need to recreate the resource. |
1169 for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin(); | 1192 for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin(); |
1170 iter != ui_resource_client_map_.end(); | 1193 iter != ui_resource_client_map_.end(); |
1171 ++iter) { | 1194 ++iter) { |
1172 UIResourceLost(iter->first); | 1195 UIResourceLost(iter->first); |
1173 } | 1196 } |
1174 } | 1197 } |
1175 | 1198 |
1176 } // namespace cc | 1199 } // namespace cc |
OLD | NEW |