| 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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 layer_tree_host_->SetNeedsCommit(); | 145 layer_tree_host_->SetNeedsCommit(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void Layer::SetNeedsFullTreeSync() { | 148 void Layer::SetNeedsFullTreeSync() { |
| 149 if (!layer_tree_host_) | 149 if (!layer_tree_host_) |
| 150 return; | 150 return; |
| 151 | 151 |
| 152 layer_tree_host_->SetNeedsFullTreeSync(); | 152 layer_tree_host_->SetNeedsFullTreeSync(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 bool Layer::IsPropertyChangeAllowed() const { | 155 void Layer::SetNextCommitWaitsForActivation() { |
| 156 if (!layer_tree_host_) | 156 if (!layer_tree_host_) |
| 157 return true; | 157 return; |
| 158 | 158 |
| 159 if (!layer_tree_host_->settings().strict_layer_property_change_checking) | 159 layer_tree_host_->SetNextCommitWaitsForActivation(); |
| 160 return true; | |
| 161 | |
| 162 return !layer_tree_host_->in_paint_layer_contents(); | |
| 163 } | 160 } |
| 164 | 161 |
| 165 void Layer::SetNeedsPushProperties() { | 162 void Layer::SetNeedsPushProperties() { |
| 166 if (needs_push_properties_) | 163 if (needs_push_properties_) |
| 167 return; | 164 return; |
| 168 if (!parent_should_know_need_push_properties() && parent_) | 165 if (!parent_should_know_need_push_properties() && parent_) |
| 169 parent_->AddDependentNeedsPushProperties(); | 166 parent_->AddDependentNeedsPushProperties(); |
| 170 needs_push_properties_ = true; | 167 needs_push_properties_ = true; |
| 171 } | 168 } |
| 172 | 169 |
| 173 void Layer::AddDependentNeedsPushProperties() { | 170 void Layer::AddDependentNeedsPushProperties() { |
| 174 DCHECK_GE(num_dependents_need_push_properties_, 0); | 171 DCHECK_GE(num_dependents_need_push_properties_, 0); |
| 175 | 172 |
| 176 if (!parent_should_know_need_push_properties() && parent_) | 173 if (!parent_should_know_need_push_properties() && parent_) |
| 177 parent_->AddDependentNeedsPushProperties(); | 174 parent_->AddDependentNeedsPushProperties(); |
| 178 | 175 |
| 179 num_dependents_need_push_properties_++; | 176 num_dependents_need_push_properties_++; |
| 180 } | 177 } |
| 181 | 178 |
| 182 void Layer::RemoveDependentNeedsPushProperties() { | 179 void Layer::RemoveDependentNeedsPushProperties() { |
| 183 num_dependents_need_push_properties_--; | 180 num_dependents_need_push_properties_--; |
| 184 DCHECK_GE(num_dependents_need_push_properties_, 0); | 181 DCHECK_GE(num_dependents_need_push_properties_, 0); |
| 185 | 182 |
| 186 if (!parent_should_know_need_push_properties() && parent_) | 183 if (!parent_should_know_need_push_properties() && parent_) |
| 187 parent_->RemoveDependentNeedsPushProperties(); | 184 parent_->RemoveDependentNeedsPushProperties(); |
| 188 } | 185 } |
| 189 | 186 |
| 187 bool Layer::IsPropertyChangeAllowed() const { |
| 188 if (!layer_tree_host_) |
| 189 return true; |
| 190 |
| 191 if (!layer_tree_host_->settings().strict_layer_property_change_checking) |
| 192 return true; |
| 193 |
| 194 return !layer_tree_host_->in_paint_layer_contents(); |
| 195 } |
| 196 |
| 190 gfx::Rect Layer::LayerRectToContentRect(const gfx::RectF& layer_rect) const { | 197 gfx::Rect Layer::LayerRectToContentRect(const gfx::RectF& layer_rect) const { |
| 191 gfx::RectF content_rect = | 198 gfx::RectF content_rect = |
| 192 gfx::ScaleRect(layer_rect, contents_scale_x(), contents_scale_y()); | 199 gfx::ScaleRect(layer_rect, contents_scale_x(), contents_scale_y()); |
| 193 // Intersect with content rect to avoid the extra pixel because for some | 200 // Intersect with content rect to avoid the extra pixel because for some |
| 194 // values x and y, ceil((x / y) * y) may be x + 1. | 201 // values x and y, ceil((x / y) * y) may be x + 1. |
| 195 content_rect.Intersect(gfx::Rect(content_bounds())); | 202 content_rect.Intersect(gfx::Rect(content_bounds())); |
| 196 return gfx::ToEnclosingRect(content_rect); | 203 return gfx::ToEnclosingRect(content_rect); |
| 197 } | 204 } |
| 198 | 205 |
| 199 bool Layer::BlocksPendingCommit() const { | |
| 200 return false; | |
| 201 } | |
| 202 | |
| 203 skia::RefPtr<SkPicture> Layer::GetPicture() const { | 206 skia::RefPtr<SkPicture> Layer::GetPicture() const { |
| 204 return skia::RefPtr<SkPicture>(); | 207 return skia::RefPtr<SkPicture>(); |
| 205 } | 208 } |
| 206 | 209 |
| 207 bool Layer::CanClipSelf() const { | 210 bool Layer::CanClipSelf() const { |
| 208 return false; | 211 return false; |
| 209 } | 212 } |
| 210 | 213 |
| 211 bool Layer::BlocksPendingCommitRecursive() const { | |
| 212 if (BlocksPendingCommit()) | |
| 213 return true; | |
| 214 if (mask_layer() && mask_layer()->BlocksPendingCommitRecursive()) | |
| 215 return true; | |
| 216 if (replica_layer() && replica_layer()->BlocksPendingCommitRecursive()) | |
| 217 return true; | |
| 218 for (size_t i = 0; i < children_.size(); ++i) { | |
| 219 if (children_[i]->BlocksPendingCommitRecursive()) | |
| 220 return true; | |
| 221 } | |
| 222 return false; | |
| 223 } | |
| 224 | |
| 225 void Layer::SetParent(Layer* layer) { | 214 void Layer::SetParent(Layer* layer) { |
| 226 DCHECK(!layer || !layer->HasAncestor(this)); | 215 DCHECK(!layer || !layer->HasAncestor(this)); |
| 227 | 216 |
| 228 if (parent_should_know_need_push_properties()) { | 217 if (parent_should_know_need_push_properties()) { |
| 229 if (parent_) | 218 if (parent_) |
| 230 parent_->RemoveDependentNeedsPushProperties(); | 219 parent_->RemoveDependentNeedsPushProperties(); |
| 231 if (layer) | 220 if (layer) |
| 232 layer->AddDependentNeedsPushProperties(); | 221 layer->AddDependentNeedsPushProperties(); |
| 233 } | 222 } |
| 234 | 223 |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 (*it)->clip_parent_ = NULL; | 1092 (*it)->clip_parent_ = NULL; |
| 1104 } | 1093 } |
| 1105 | 1094 |
| 1106 if (clip_parent_) | 1095 if (clip_parent_) |
| 1107 clip_parent_->RemoveClipChild(this); | 1096 clip_parent_->RemoveClipChild(this); |
| 1108 | 1097 |
| 1109 clip_parent_ = NULL; | 1098 clip_parent_ = NULL; |
| 1110 } | 1099 } |
| 1111 | 1100 |
| 1112 } // namespace cc | 1101 } // namespace cc |
| OLD | NEW |