OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 bool Layer::IsPropertyChangeAllowed() const { | 195 bool Layer::IsPropertyChangeAllowed() const { |
196 if (!layer_tree_host_) | 196 if (!layer_tree_host_) |
197 return true; | 197 return true; |
198 | 198 |
199 if (!layer_tree_host_->settings().strict_layer_property_change_checking) | 199 if (!layer_tree_host_->settings().strict_layer_property_change_checking) |
200 return true; | 200 return true; |
201 | 201 |
202 return !layer_tree_host_->in_paint_layer_contents(); | 202 return !layer_tree_host_->in_paint_layer_contents(); |
203 } | 203 } |
204 | 204 |
205 gfx::Rect Layer::LayerRectToContentRect(const gfx::RectF& layer_rect) const { | 205 gfx::Rect Layer::LayerRectToContentRect(const gfx::Rect& layer_rect) const { |
206 gfx::RectF content_rect = | 206 gfx::Rect content_rect = gfx::ScaleToEnclosingRect( |
207 gfx::ScaleRect(layer_rect, contents_scale_x(), contents_scale_y()); | 207 layer_rect, contents_scale_x(), contents_scale_y()); |
208 // Intersect with content rect to avoid the extra pixel because for some | 208 // Intersect with content rect to avoid the extra pixel because for some |
209 // values x and y, ceil((x / y) * y) may be x + 1. | 209 // values x and y, ceil((x / y) * y) may be x + 1. |
210 content_rect.Intersect(gfx::Rect(content_bounds())); | 210 content_rect.Intersect(gfx::Rect(content_bounds())); |
211 return gfx::ToEnclosingRect(content_rect); | 211 return content_rect; |
212 } | 212 } |
213 | 213 |
214 skia::RefPtr<SkPicture> Layer::GetPicture() const { | 214 skia::RefPtr<SkPicture> Layer::GetPicture() const { |
215 return skia::RefPtr<SkPicture>(); | 215 return skia::RefPtr<SkPicture>(); |
216 } | 216 } |
217 | 217 |
218 void Layer::SetParent(Layer* layer) { | 218 void Layer::SetParent(Layer* layer) { |
219 DCHECK(!layer || !layer->HasAncestor(this)); | 219 DCHECK(!layer || !layer->HasAncestor(this)); |
220 | 220 |
221 if (parent_should_know_need_push_properties()) { | 221 if (parent_should_know_need_push_properties()) { |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 | 788 |
789 void Layer::SetHideLayerAndSubtree(bool hide) { | 789 void Layer::SetHideLayerAndSubtree(bool hide) { |
790 DCHECK(IsPropertyChangeAllowed()); | 790 DCHECK(IsPropertyChangeAllowed()); |
791 if (hide_layer_and_subtree_ == hide) | 791 if (hide_layer_and_subtree_ == hide) |
792 return; | 792 return; |
793 | 793 |
794 hide_layer_and_subtree_ = hide; | 794 hide_layer_and_subtree_ = hide; |
795 SetNeedsCommit(); | 795 SetNeedsCommit(); |
796 } | 796 } |
797 | 797 |
798 void Layer::SetNeedsDisplayRect(const gfx::RectF& dirty_rect) { | 798 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { |
799 if (dirty_rect.IsEmpty()) | 799 if (dirty_rect.IsEmpty()) |
800 return; | 800 return; |
801 | 801 |
802 SetNeedsPushProperties(); | 802 SetNeedsPushProperties(); |
803 update_rect_.Union(dirty_rect); | 803 update_rect_.Union(dirty_rect); |
804 | 804 |
805 if (DrawsContent()) | 805 if (DrawsContent()) |
806 SetNeedsUpdate(); | 806 SetNeedsUpdate(); |
807 } | 807 } |
808 | 808 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 update_rect_.Union(layer->update_rect()); | 996 update_rect_.Union(layer->update_rect()); |
997 layer->SetUpdateRect(update_rect_); | 997 layer->SetUpdateRect(update_rect_); |
998 | 998 |
999 layer->SetStackingOrderChanged(stacking_order_changed_); | 999 layer->SetStackingOrderChanged(stacking_order_changed_); |
1000 | 1000 |
1001 layer_animation_controller_->PushAnimationUpdatesTo( | 1001 layer_animation_controller_->PushAnimationUpdatesTo( |
1002 layer->layer_animation_controller()); | 1002 layer->layer_animation_controller()); |
1003 | 1003 |
1004 // Reset any state that should be cleared for the next update. | 1004 // Reset any state that should be cleared for the next update. |
1005 stacking_order_changed_ = false; | 1005 stacking_order_changed_ = false; |
1006 update_rect_ = gfx::RectF(); | 1006 update_rect_ = gfx::Rect(); |
1007 | 1007 |
1008 needs_push_properties_ = false; | 1008 needs_push_properties_ = false; |
1009 num_dependents_need_push_properties_ = 0; | 1009 num_dependents_need_push_properties_ = 0; |
1010 } | 1010 } |
1011 | 1011 |
1012 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 1012 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
1013 return LayerImpl::Create(tree_impl, layer_id_); | 1013 return LayerImpl::Create(tree_impl, layer_id_); |
1014 } | 1014 } |
1015 | 1015 |
1016 bool Layer::DrawsContent() const { | 1016 bool Layer::DrawsContent() const { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 | 1235 |
1236 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1236 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
1237 benchmark->RunOnLayer(this); | 1237 benchmark->RunOnLayer(this); |
1238 } | 1238 } |
1239 | 1239 |
1240 bool Layer::HasDelegatedContent() const { | 1240 bool Layer::HasDelegatedContent() const { |
1241 return false; | 1241 return false; |
1242 } | 1242 } |
1243 | 1243 |
1244 } // namespace cc | 1244 } // namespace cc |
OLD | NEW |