| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/compositor/layer.h" | 5 #include "ui/compositor/layer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 zoom_(1), | 89 zoom_(1), |
| 90 zoom_inset_(0), | 90 zoom_inset_(0), |
| 91 delegate_(NULL), | 91 delegate_(NULL), |
| 92 owner_(NULL), | 92 owner_(NULL), |
| 93 cc_layer_(NULL), | 93 cc_layer_(NULL), |
| 94 device_scale_factor_(1.0f) { | 94 device_scale_factor_(1.0f) { |
| 95 CreateCcLayer(); | 95 CreateCcLayer(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 Layer::~Layer() { | 98 Layer::~Layer() { |
| 99 FOR_EACH_OBSERVER(LayerObserver, observer_list_, LayerDestroyed(this)); | 99 for (auto& observer : observer_list_) |
| 100 observer.LayerDestroyed(this); |
| 100 | 101 |
| 101 // Destroying the animator may cause observers to use the layer (and | 102 // Destroying the animator may cause observers to use the layer (and |
| 102 // indirectly the WebLayer). Destroy the animator first so that the WebLayer | 103 // indirectly the WebLayer). Destroy the animator first so that the WebLayer |
| 103 // is still around. | 104 // is still around. |
| 104 SetAnimator(nullptr); | 105 SetAnimator(nullptr); |
| 105 if (compositor_) | 106 if (compositor_) |
| 106 compositor_->SetRootLayer(NULL); | 107 compositor_->SetRootLayer(NULL); |
| 107 if (parent_) | 108 if (parent_) |
| 108 parent_->Remove(this); | 109 parent_->Remove(this); |
| 109 if (layer_mask_) | 110 if (layer_mask_) |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 | 586 |
| 586 scoped_refptr<cc::SurfaceLayer> new_layer = | 587 scoped_refptr<cc::SurfaceLayer> new_layer = |
| 587 cc::SurfaceLayer::Create(satisfy_callback, require_callback); | 588 cc::SurfaceLayer::Create(satisfy_callback, require_callback); |
| 588 new_layer->SetSurfaceId(surface_id, scale, surface_size); | 589 new_layer->SetSurfaceId(surface_id, scale, surface_size); |
| 589 SwitchToLayer(new_layer); | 590 SwitchToLayer(new_layer); |
| 590 surface_layer_ = new_layer; | 591 surface_layer_ = new_layer; |
| 591 | 592 |
| 592 frame_size_in_dip_ = frame_size_in_dip; | 593 frame_size_in_dip_ = frame_size_in_dip; |
| 593 RecomputeDrawsContentAndUVRect(); | 594 RecomputeDrawsContentAndUVRect(); |
| 594 | 595 |
| 595 FOR_EACH_OBSERVER(LayerObserver, observer_list_, SurfaceChanged(this)); | 596 for (auto& observer : observer_list_) |
| 597 observer.SurfaceChanged(this); |
| 596 } | 598 } |
| 597 | 599 |
| 598 void Layer::SetShowSolidColorContent() { | 600 void Layer::SetShowSolidColorContent() { |
| 599 DCHECK_EQ(type_, LAYER_SOLID_COLOR); | 601 DCHECK_EQ(type_, LAYER_SOLID_COLOR); |
| 600 | 602 |
| 601 if (solid_color_layer_.get()) | 603 if (solid_color_layer_.get()) |
| 602 return; | 604 return; |
| 603 | 605 |
| 604 scoped_refptr<cc::SolidColorLayer> new_layer = cc::SolidColorLayer::Create(); | 606 scoped_refptr<cc::SolidColorLayer> new_layer = cc::SolidColorLayer::Create(); |
| 605 SwitchToLayer(new_layer); | 607 SwitchToLayer(new_layer); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 paint_region_.Clear(); | 790 paint_region_.Clear(); |
| 789 cc::DisplayItemListSettings settings; | 791 cc::DisplayItemListSettings settings; |
| 790 settings.use_cached_picture = false; | 792 settings.use_cached_picture = false; |
| 791 scoped_refptr<cc::DisplayItemList> display_list = | 793 scoped_refptr<cc::DisplayItemList> display_list = |
| 792 cc::DisplayItemList::Create(settings); | 794 cc::DisplayItemList::Create(settings); |
| 793 if (delegate_) { | 795 if (delegate_) { |
| 794 delegate_->OnPaintLayer( | 796 delegate_->OnPaintLayer( |
| 795 PaintContext(display_list.get(), device_scale_factor_, invalidation)); | 797 PaintContext(display_list.get(), device_scale_factor_, invalidation)); |
| 796 } | 798 } |
| 797 display_list->Finalize(); | 799 display_list->Finalize(); |
| 798 FOR_EACH_OBSERVER(LayerObserver, observer_list_, | 800 for (auto& observer : observer_list_) |
| 799 DidPaintLayer(this, invalidation)); | 801 observer.DidPaintLayer(this, invalidation); |
| 800 return display_list; | 802 return display_list; |
| 801 } | 803 } |
| 802 | 804 |
| 803 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } | 805 bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } |
| 804 | 806 |
| 805 size_t Layer::GetApproximateUnsharedMemoryUsage() const { | 807 size_t Layer::GetApproximateUnsharedMemoryUsage() const { |
| 806 // Most of the "picture memory" is shared with the cc::DisplayItemList, so | 808 // Most of the "picture memory" is shared with the cc::DisplayItemList, so |
| 807 // there's nothing significant to report here. | 809 // there's nothing significant to report here. |
| 808 return 0; | 810 return 0; |
| 809 } | 811 } |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 if (animator_) { | 1072 if (animator_) { |
| 1071 animator_->DetachLayerAndTimeline(compositor); | 1073 animator_->DetachLayerAndTimeline(compositor); |
| 1072 animator_->RemoveFromCollection(collection); | 1074 animator_->RemoveFromCollection(collection); |
| 1073 } | 1075 } |
| 1074 | 1076 |
| 1075 for (auto* child : children_) | 1077 for (auto* child : children_) |
| 1076 child->ResetCompositorForAnimatorsInTree(compositor); | 1078 child->ResetCompositorForAnimatorsInTree(compositor); |
| 1077 } | 1079 } |
| 1078 | 1080 |
| 1079 } // namespace ui | 1081 } // namespace ui |
| OLD | NEW |