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 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 visible_(true), | 123 visible_(true), |
124 page_scale_factor_(1.f), | 124 page_scale_factor_(1.f), |
125 min_page_scale_factor_(1.f), | 125 min_page_scale_factor_(1.f), |
126 max_page_scale_factor_(1.f), | 126 max_page_scale_factor_(1.f), |
127 has_gpu_rasterization_trigger_(false), | 127 has_gpu_rasterization_trigger_(false), |
128 content_is_suitable_for_gpu_rasterization_(true), | 128 content_is_suitable_for_gpu_rasterization_(true), |
129 gpu_rasterization_histogram_recorded_(false), | 129 gpu_rasterization_histogram_recorded_(false), |
130 background_color_(SK_ColorWHITE), | 130 background_color_(SK_ColorWHITE), |
131 has_transparent_background_(false), | 131 has_transparent_background_(false), |
132 partial_texture_update_requests_(0), | 132 partial_texture_update_requests_(0), |
| 133 did_complete_scale_animation_(false), |
133 in_paint_layer_contents_(false), | 134 in_paint_layer_contents_(false), |
134 total_frames_used_for_lcd_text_metrics_(0), | 135 total_frames_used_for_lcd_text_metrics_(0), |
135 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 136 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
136 next_commit_forces_redraw_(false), | 137 next_commit_forces_redraw_(false), |
137 shared_bitmap_manager_(shared_bitmap_manager), | 138 shared_bitmap_manager_(shared_bitmap_manager), |
138 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 139 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
139 surface_id_namespace_(0u), | 140 surface_id_namespace_(0u), |
140 next_surface_sequence_(1u) { | 141 next_surface_sequence_(1u) { |
141 if (settings_.accelerated_animation_enabled) | 142 if (settings_.accelerated_animation_enabled) |
142 animation_registrar_ = AnimationRegistrar::Create(); | 143 animation_registrar_ = AnimationRegistrar::Create(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 proxy_->Start(); | 177 proxy_->Start(); |
177 if (settings_.accelerated_animation_enabled) { | 178 if (settings_.accelerated_animation_enabled) { |
178 animation_registrar_->set_supports_scroll_animations( | 179 animation_registrar_->set_supports_scroll_animations( |
179 proxy_->SupportsImplScrolling()); | 180 proxy_->SupportsImplScrolling()); |
180 } | 181 } |
181 } | 182 } |
182 | 183 |
183 LayerTreeHost::~LayerTreeHost() { | 184 LayerTreeHost::~LayerTreeHost() { |
184 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 185 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
185 | 186 |
186 overhang_ui_resource_ = nullptr; | |
187 | |
188 if (root_layer_.get()) | 187 if (root_layer_.get()) |
189 root_layer_->SetLayerTreeHost(NULL); | 188 root_layer_->SetLayerTreeHost(NULL); |
190 | 189 |
191 DCHECK(swap_promise_monitor_.empty()); | 190 DCHECK(swap_promise_monitor_.empty()); |
192 | 191 |
193 BreakSwapPromises(SwapPromise::COMMIT_FAILS); | 192 BreakSwapPromises(SwapPromise::COMMIT_FAILS); |
194 | 193 |
195 if (proxy_) { | 194 if (proxy_) { |
196 DCHECK(proxy_->IsMainThread()); | 195 DCHECK(proxy_->IsMainThread()); |
197 proxy_->Stop(); | 196 proxy_->Stop(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 host_impl->SetDebugState(debug_state_); | 352 host_impl->SetDebugState(debug_state_); |
354 if (pending_page_scale_animation_) { | 353 if (pending_page_scale_animation_) { |
355 sync_tree->SetPendingPageScaleAnimation( | 354 sync_tree->SetPendingPageScaleAnimation( |
356 pending_page_scale_animation_.Pass()); | 355 pending_page_scale_animation_.Pass()); |
357 } | 356 } |
358 | 357 |
359 if (!ui_resource_request_queue_.empty()) { | 358 if (!ui_resource_request_queue_.empty()) { |
360 sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_); | 359 sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_); |
361 ui_resource_request_queue_.clear(); | 360 ui_resource_request_queue_.clear(); |
362 } | 361 } |
363 if (overhang_ui_resource_) { | |
364 host_impl->SetOverhangUIResource( | |
365 overhang_ui_resource_->id(), | |
366 GetUIResourceSize(overhang_ui_resource_->id())); | |
367 } | |
368 | 362 |
369 DCHECK(!sync_tree->ViewportSizeInvalid()); | 363 DCHECK(!sync_tree->ViewportSizeInvalid()); |
370 | 364 |
371 if (new_impl_tree_has_no_evicted_resources) { | 365 if (new_impl_tree_has_no_evicted_resources) { |
372 if (sync_tree->ContentsTexturesPurged()) | 366 if (sync_tree->ContentsTexturesPurged()) |
373 sync_tree->ResetContentsTexturesPurged(); | 367 sync_tree->ResetContentsTexturesPurged(); |
374 } | 368 } |
375 | 369 |
376 sync_tree->set_has_ever_been_drawn(false); | 370 sync_tree->set_has_ever_been_drawn(false); |
377 | 371 |
(...skipping 18 matching lines...) Expand all Loading... |
396 root_layer_->AddChild(hud_layer_); | 390 root_layer_->AddChild(hud_layer_); |
397 } else if (hud_layer_.get()) { | 391 } else if (hud_layer_.get()) { |
398 hud_layer_->RemoveFromParent(); | 392 hud_layer_->RemoveFromParent(); |
399 hud_layer_ = NULL; | 393 hud_layer_ = NULL; |
400 } | 394 } |
401 } | 395 } |
402 | 396 |
403 void LayerTreeHost::CommitComplete() { | 397 void LayerTreeHost::CommitComplete() { |
404 source_frame_number_++; | 398 source_frame_number_++; |
405 client_->DidCommit(); | 399 client_->DidCommit(); |
| 400 if (did_complete_scale_animation_) { |
| 401 client_->DidCompletePageScaleAnimation(); |
| 402 did_complete_scale_animation_ = false; |
| 403 } |
406 } | 404 } |
407 | 405 |
408 void LayerTreeHost::SetOutputSurface(scoped_ptr<OutputSurface> surface) { | 406 void LayerTreeHost::SetOutputSurface(scoped_ptr<OutputSurface> surface) { |
409 TRACE_EVENT0("cc", "LayerTreeHost::SetOutputSurface"); | 407 TRACE_EVENT0("cc", "LayerTreeHost::SetOutputSurface"); |
410 DCHECK(output_surface_lost_); | 408 DCHECK(output_surface_lost_); |
411 DCHECK(surface); | 409 DCHECK(surface); |
412 | 410 |
413 proxy_->SetOutputSurface(surface.Pass()); | 411 proxy_->SetOutputSurface(surface.Pass()); |
414 } | 412 } |
415 | 413 |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 min_page_scale_factor == min_page_scale_factor_ && | 706 min_page_scale_factor == min_page_scale_factor_ && |
709 max_page_scale_factor == max_page_scale_factor_) | 707 max_page_scale_factor == max_page_scale_factor_) |
710 return; | 708 return; |
711 | 709 |
712 page_scale_factor_ = page_scale_factor; | 710 page_scale_factor_ = page_scale_factor; |
713 min_page_scale_factor_ = min_page_scale_factor; | 711 min_page_scale_factor_ = min_page_scale_factor; |
714 max_page_scale_factor_ = max_page_scale_factor; | 712 max_page_scale_factor_ = max_page_scale_factor; |
715 SetNeedsCommit(); | 713 SetNeedsCommit(); |
716 } | 714 } |
717 | 715 |
718 void LayerTreeHost::SetOverhangBitmap(const SkBitmap& bitmap) { | |
719 DCHECK(bitmap.width() && bitmap.height()); | |
720 DCHECK_EQ(bitmap.bytesPerPixel(), 4); | |
721 | |
722 SkBitmap bitmap_copy; | |
723 if (bitmap.isImmutable()) { | |
724 bitmap_copy = bitmap; | |
725 } else { | |
726 bitmap.copyTo(&bitmap_copy); | |
727 bitmap_copy.setImmutable(); | |
728 } | |
729 | |
730 UIResourceBitmap overhang_bitmap(bitmap_copy); | |
731 overhang_bitmap.SetWrapMode(UIResourceBitmap::REPEAT); | |
732 overhang_ui_resource_ = ScopedUIResource::Create(this, overhang_bitmap); | |
733 } | |
734 | |
735 void LayerTreeHost::SetVisible(bool visible) { | 716 void LayerTreeHost::SetVisible(bool visible) { |
736 if (visible_ == visible) | 717 if (visible_ == visible) |
737 return; | 718 return; |
738 visible_ = visible; | 719 visible_ = visible; |
739 if (!visible) | 720 if (!visible) |
740 ReduceMemoryUsage(); | 721 ReduceMemoryUsage(); |
741 proxy_->SetVisible(visible); | 722 proxy_->SetVisible(visible); |
742 } | 723 } |
743 | 724 |
744 void LayerTreeHost::SetThrottleFrameProduction(bool throttle) { | 725 void LayerTreeHost::SetThrottleFrameProduction(bool throttle) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 | 762 |
782 DCHECK(!root_layer()->parent()); | 763 DCHECK(!root_layer()->parent()); |
783 | 764 |
784 bool result = UpdateLayers(root_layer(), queue); | 765 bool result = UpdateLayers(root_layer(), queue); |
785 | 766 |
786 micro_benchmark_controller_.DidUpdateLayers(); | 767 micro_benchmark_controller_.DidUpdateLayers(); |
787 | 768 |
788 return result || next_commit_forces_redraw_; | 769 return result || next_commit_forces_redraw_; |
789 } | 770 } |
790 | 771 |
| 772 void LayerTreeHost::DidCompletePageScaleAnimation() { |
| 773 did_complete_scale_animation_ = true; |
| 774 } |
| 775 |
791 static Layer* FindFirstScrollableLayer(Layer* layer) { | 776 static Layer* FindFirstScrollableLayer(Layer* layer) { |
792 if (!layer) | 777 if (!layer) |
793 return NULL; | 778 return NULL; |
794 | 779 |
795 if (layer->scrollable()) | 780 if (layer->scrollable()) |
796 return layer; | 781 return layer; |
797 | 782 |
798 for (size_t i = 0; i < layer->children().size(); ++i) { | 783 for (size_t i = 0; i < layer->children().size(); ++i) { |
799 Layer* found = FindFirstScrollableLayer(layer->children()[i].get()); | 784 Layer* found = FindFirstScrollableLayer(layer->children()[i].get()); |
800 if (found) | 785 if (found) |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 bool children_need_begin_frames) const { | 1372 bool children_need_begin_frames) const { |
1388 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames); | 1373 proxy_->SetChildrenNeedBeginFrames(children_need_begin_frames); |
1389 } | 1374 } |
1390 | 1375 |
1391 void LayerTreeHost::SendBeginFramesToChildren( | 1376 void LayerTreeHost::SendBeginFramesToChildren( |
1392 const BeginFrameArgs& args) const { | 1377 const BeginFrameArgs& args) const { |
1393 client_->SendBeginFramesToChildren(args); | 1378 client_->SendBeginFramesToChildren(args); |
1394 } | 1379 } |
1395 | 1380 |
1396 } // namespace cc | 1381 } // namespace cc |
OLD | NEW |