| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "cc/trees/layer_tree_host.h" | 34 #include "cc/trees/layer_tree_host.h" |
| 35 #include "cc/trees/layer_tree_impl.h" | 35 #include "cc/trees/layer_tree_impl.h" |
| 36 #include "third_party/skia/include/core/SkImageFilter.h" | 36 #include "third_party/skia/include/core/SkImageFilter.h" |
| 37 #include "ui/gfx/geometry/rect_conversions.h" | 37 #include "ui/gfx/geometry/rect_conversions.h" |
| 38 #include "ui/gfx/geometry/vector2d_conversions.h" | 38 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 39 | 39 |
| 40 namespace cc { | 40 namespace cc { |
| 41 | 41 |
| 42 base::StaticAtomicSequenceNumber g_next_layer_id; | 42 base::StaticAtomicSequenceNumber g_next_layer_id; |
| 43 | 43 |
| 44 Layer::Inputs::Inputs() |
| 45 : // Layer IDs start from 1. |
| 46 layer_id(g_next_layer_id.GetNext() + 1), |
| 47 masks_to_bounds(false), |
| 48 mask_layer(nullptr), |
| 49 replica_layer(nullptr), |
| 50 opacity(1.f), |
| 51 blend_mode(SkXfermode::kSrcOver_Mode), |
| 52 is_root_for_isolated_group(false), |
| 53 contents_opaque(false), |
| 54 is_drawable(false), |
| 55 double_sided(true), |
| 56 should_flatten_transform(true), |
| 57 sorting_context_id(0), |
| 58 use_parent_backface_visibility(false), |
| 59 background_color(0), |
| 60 scroll_clip_layer_id(INVALID_ID), |
| 61 user_scrollable_horizontal(true), |
| 62 user_scrollable_vertical(true), |
| 63 main_thread_scrolling_reasons( |
| 64 MainThreadScrollingReason::kNotScrollingOnMain), |
| 65 is_container_for_fixed_position_layers(false), |
| 66 mutable_properties(MutableProperty::kNone), |
| 67 scroll_parent(nullptr), |
| 68 clip_parent(nullptr), |
| 69 has_will_change_transform_hint(false), |
| 70 hide_layer_and_subtree(false), |
| 71 client(nullptr) {} |
| 72 |
| 73 Layer::Inputs::~Inputs() {} |
| 74 |
| 44 scoped_refptr<Layer> Layer::Create() { | 75 scoped_refptr<Layer> Layer::Create() { |
| 45 return make_scoped_refptr(new Layer()); | 76 return make_scoped_refptr(new Layer()); |
| 46 } | 77 } |
| 47 | 78 |
| 48 Layer::Layer() | 79 Layer::Layer() |
| 49 : // Layer IDs start from 1. | 80 : ignore_set_needs_commit_(false), |
| 50 layer_id_(g_next_layer_id.GetNext() + 1), | |
| 51 ignore_set_needs_commit_(false), | |
| 52 sorting_context_id_(0), | |
| 53 parent_(nullptr), | 81 parent_(nullptr), |
| 54 layer_tree_host_(nullptr), | 82 layer_tree_host_(nullptr), |
| 55 scroll_clip_layer_id_(INVALID_ID), | |
| 56 num_descendants_that_draw_content_(0), | 83 num_descendants_that_draw_content_(0), |
| 57 transform_tree_index_(-1), | 84 transform_tree_index_(-1), |
| 58 effect_tree_index_(-1), | 85 effect_tree_index_(-1), |
| 59 clip_tree_index_(-1), | 86 clip_tree_index_(-1), |
| 60 scroll_tree_index_(-1), | 87 scroll_tree_index_(-1), |
| 61 property_tree_sequence_number_(-1), | 88 property_tree_sequence_number_(-1), |
| 62 mutable_properties_(MutableProperty::kNone), | |
| 63 main_thread_scrolling_reasons_( | |
| 64 MainThreadScrollingReason::kNotScrollingOnMain), | |
| 65 should_flatten_transform_from_property_tree_(false), | 89 should_flatten_transform_from_property_tree_(false), |
| 66 user_scrollable_horizontal_(true), | |
| 67 user_scrollable_vertical_(true), | |
| 68 is_root_for_isolated_group_(false), | |
| 69 is_container_for_fixed_position_layers_(false), | |
| 70 is_drawable_(false), | |
| 71 draws_content_(false), | 90 draws_content_(false), |
| 72 hide_layer_and_subtree_(false), | |
| 73 masks_to_bounds_(false), | |
| 74 contents_opaque_(false), | |
| 75 double_sided_(true), | |
| 76 should_flatten_transform_(true), | |
| 77 use_parent_backface_visibility_(false), | |
| 78 use_local_transform_for_backface_visibility_(false), | 91 use_local_transform_for_backface_visibility_(false), |
| 79 should_check_backface_visibility_(false), | 92 should_check_backface_visibility_(false), |
| 80 force_render_surface_for_testing_(false), | 93 force_render_surface_for_testing_(false), |
| 81 subtree_property_changed_(false), | 94 subtree_property_changed_(false), |
| 82 layer_property_changed_(false), | 95 layer_property_changed_(false), |
| 83 has_will_change_transform_hint_(false), | |
| 84 background_color_(0), | |
| 85 safe_opaque_background_color_(0), | 96 safe_opaque_background_color_(0), |
| 86 opacity_(1.f), | |
| 87 blend_mode_(SkXfermode::kSrcOver_Mode), | |
| 88 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 97 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
| 89 scroll_parent_(nullptr), | |
| 90 clip_parent_(nullptr), | |
| 91 replica_layer_(nullptr), | |
| 92 client_(nullptr), | |
| 93 num_unclipped_descendants_(0) {} | 98 num_unclipped_descendants_(0) {} |
| 94 | 99 |
| 95 Layer::~Layer() { | 100 Layer::~Layer() { |
| 96 // Our parent should be holding a reference to us so there should be no | 101 // Our parent should be holding a reference to us so there should be no |
| 97 // way for us to be destroyed while we still have a parent. | 102 // way for us to be destroyed while we still have a parent. |
| 98 DCHECK(!parent()); | 103 DCHECK(!parent()); |
| 99 // Similarly we shouldn't have a layer tree host since it also keeps a | 104 // Similarly we shouldn't have a layer tree host since it also keeps a |
| 100 // reference to us. | 105 // reference to us. |
| 101 DCHECK(!layer_tree_host()); | 106 DCHECK(!layer_tree_host()); |
| 102 | 107 |
| 103 RemoveFromScrollTree(); | 108 RemoveFromScrollTree(); |
| 104 RemoveFromClipTree(); | 109 RemoveFromClipTree(); |
| 105 | 110 |
| 106 // Remove the parent reference from all children and dependents. | 111 // Remove the parent reference from all children and dependents. |
| 107 RemoveAllChildren(); | 112 RemoveAllChildren(); |
| 108 if (mask_layer_.get()) { | 113 if (inputs_.mask_layer.get()) { |
| 109 DCHECK_EQ(this, mask_layer_->parent()); | 114 DCHECK_EQ(this, inputs_.mask_layer->parent()); |
| 110 mask_layer_->RemoveFromParent(); | 115 inputs_.mask_layer->RemoveFromParent(); |
| 111 } | 116 } |
| 112 if (replica_layer_.get()) { | 117 if (inputs_.replica_layer.get()) { |
| 113 DCHECK_EQ(this, replica_layer_->parent()); | 118 DCHECK_EQ(this, inputs_.replica_layer->parent()); |
| 114 replica_layer_->RemoveFromParent(); | 119 inputs_.replica_layer->RemoveFromParent(); |
| 115 } | 120 } |
| 116 } | 121 } |
| 117 | 122 |
| 118 void Layer::SetLayerTreeHost(LayerTreeHost* host) { | 123 void Layer::SetLayerTreeHost(LayerTreeHost* host) { |
| 119 if (layer_tree_host_ == host) | 124 if (layer_tree_host_ == host) |
| 120 return; | 125 return; |
| 121 | 126 |
| 122 if (layer_tree_host_) { | 127 if (layer_tree_host_) { |
| 123 layer_tree_host_->property_trees()->RemoveIdFromIdToIndexMaps(id()); | 128 layer_tree_host_->property_trees()->RemoveIdFromIdToIndexMaps(id()); |
| 124 layer_tree_host_->property_trees()->needs_rebuild = true; | 129 layer_tree_host_->property_trees()->needs_rebuild = true; |
| 125 layer_tree_host_->UnregisterLayer(this); | 130 layer_tree_host_->UnregisterLayer(this); |
| 126 if (element_id_) { | 131 if (inputs_.element_id) { |
| 127 layer_tree_host_->animation_host()->UnregisterElement( | 132 layer_tree_host_->animation_host()->UnregisterElement( |
| 128 element_id_, ElementListType::ACTIVE); | 133 inputs_.element_id, ElementListType::ACTIVE); |
| 129 layer_tree_host_->RemoveFromElementMap(this); | 134 layer_tree_host_->RemoveFromElementMap(this); |
| 130 } | 135 } |
| 131 } | 136 } |
| 132 if (host) { | 137 if (host) { |
| 133 host->property_trees()->needs_rebuild = true; | 138 host->property_trees()->needs_rebuild = true; |
| 134 host->RegisterLayer(this); | 139 host->RegisterLayer(this); |
| 135 if (element_id_) { | 140 if (inputs_.element_id) { |
| 136 host->AddToElementMap(this); | 141 host->AddToElementMap(this); |
| 137 host->animation_host()->RegisterElement(element_id_, | 142 host->animation_host()->RegisterElement(inputs_.element_id, |
| 138 ElementListType::ACTIVE); | 143 ElementListType::ACTIVE); |
| 139 } | 144 } |
| 140 } | 145 } |
| 141 | 146 |
| 142 layer_tree_host_ = host; | 147 layer_tree_host_ = host; |
| 143 InvalidatePropertyTreesIndices(); | 148 InvalidatePropertyTreesIndices(); |
| 144 | 149 |
| 145 // When changing hosts, the layer needs to commit its properties to the impl | 150 // When changing hosts, the layer needs to commit its properties to the impl |
| 146 // side for the new host. | 151 // side for the new host. |
| 147 SetNeedsPushProperties(); | 152 SetNeedsPushProperties(); |
| 148 | 153 |
| 149 for (size_t i = 0; i < children_.size(); ++i) | 154 for (size_t i = 0; i < inputs_.children.size(); ++i) |
| 150 children_[i]->SetLayerTreeHost(host); | 155 inputs_.children[i]->SetLayerTreeHost(host); |
| 151 | 156 |
| 152 if (mask_layer_.get()) | 157 if (inputs_.mask_layer.get()) |
| 153 mask_layer_->SetLayerTreeHost(host); | 158 inputs_.mask_layer->SetLayerTreeHost(host); |
| 154 if (replica_layer_.get()) | 159 if (inputs_.replica_layer.get()) |
| 155 replica_layer_->SetLayerTreeHost(host); | 160 inputs_.replica_layer->SetLayerTreeHost(host); |
| 156 | 161 |
| 157 const bool has_any_animation = | 162 const bool has_any_animation = |
| 158 layer_tree_host_ ? layer_tree_host_->HasAnyAnimation(this) : false; | 163 layer_tree_host_ ? layer_tree_host_->HasAnyAnimation(this) : false; |
| 159 | 164 |
| 160 if (host && has_any_animation) | 165 if (host && has_any_animation) |
| 161 host->SetNeedsCommit(); | 166 host->SetNeedsCommit(); |
| 162 } | 167 } |
| 163 | 168 |
| 164 void Layer::SetNeedsUpdate() { | 169 void Layer::SetNeedsUpdate() { |
| 165 if (layer_tree_host_ && !ignore_set_needs_commit_) | 170 if (layer_tree_host_ && !ignore_set_needs_commit_) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 parent_ = layer; | 236 parent_ = layer; |
| 232 SetLayerTreeHost(parent_ ? parent_->layer_tree_host() : nullptr); | 237 SetLayerTreeHost(parent_ ? parent_->layer_tree_host() : nullptr); |
| 233 | 238 |
| 234 if (!layer_tree_host_) | 239 if (!layer_tree_host_) |
| 235 return; | 240 return; |
| 236 | 241 |
| 237 layer_tree_host_->property_trees()->needs_rebuild = true; | 242 layer_tree_host_->property_trees()->needs_rebuild = true; |
| 238 } | 243 } |
| 239 | 244 |
| 240 void Layer::AddChild(scoped_refptr<Layer> child) { | 245 void Layer::AddChild(scoped_refptr<Layer> child) { |
| 241 InsertChild(child, children_.size()); | 246 InsertChild(child, inputs_.children.size()); |
| 242 } | 247 } |
| 243 | 248 |
| 244 void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) { | 249 void Layer::InsertChild(scoped_refptr<Layer> child, size_t index) { |
| 245 DCHECK(IsPropertyChangeAllowed()); | 250 DCHECK(IsPropertyChangeAllowed()); |
| 246 child->RemoveFromParent(); | 251 child->RemoveFromParent(); |
| 247 AddDrawableDescendants(child->NumDescendantsThatDrawContent() + | 252 AddDrawableDescendants(child->NumDescendantsThatDrawContent() + |
| 248 (child->DrawsContent() ? 1 : 0)); | 253 (child->DrawsContent() ? 1 : 0)); |
| 249 child->SetParent(this); | 254 child->SetParent(this); |
| 250 child->SetSubtreePropertyChanged(); | 255 child->SetSubtreePropertyChanged(); |
| 251 | 256 |
| 252 index = std::min(index, children_.size()); | 257 index = std::min(index, inputs_.children.size()); |
| 253 children_.insert(children_.begin() + index, child); | 258 inputs_.children.insert(inputs_.children.begin() + index, child); |
| 254 SetNeedsFullTreeSync(); | 259 SetNeedsFullTreeSync(); |
| 255 } | 260 } |
| 256 | 261 |
| 257 void Layer::RemoveFromParent() { | 262 void Layer::RemoveFromParent() { |
| 258 DCHECK(IsPropertyChangeAllowed()); | 263 DCHECK(IsPropertyChangeAllowed()); |
| 259 if (parent_) | 264 if (parent_) |
| 260 parent_->RemoveChildOrDependent(this); | 265 parent_->RemoveChildOrDependent(this); |
| 261 } | 266 } |
| 262 | 267 |
| 263 void Layer::RemoveChildOrDependent(Layer* child) { | 268 void Layer::RemoveChildOrDependent(Layer* child) { |
| 264 if (mask_layer_.get() == child) { | 269 if (inputs_.mask_layer.get() == child) { |
| 265 mask_layer_->SetParent(nullptr); | 270 inputs_.mask_layer->SetParent(nullptr); |
| 266 mask_layer_ = nullptr; | 271 inputs_.mask_layer = nullptr; |
| 267 SetNeedsFullTreeSync(); | 272 SetNeedsFullTreeSync(); |
| 268 return; | 273 return; |
| 269 } | 274 } |
| 270 if (replica_layer_.get() == child) { | 275 if (inputs_.replica_layer.get() == child) { |
| 271 replica_layer_->SetParent(nullptr); | 276 inputs_.replica_layer->SetParent(nullptr); |
| 272 replica_layer_ = nullptr; | 277 inputs_.replica_layer = nullptr; |
| 273 SetNeedsFullTreeSync(); | 278 SetNeedsFullTreeSync(); |
| 274 return; | 279 return; |
| 275 } | 280 } |
| 276 | 281 |
| 277 for (LayerList::iterator iter = children_.begin(); | 282 for (LayerList::iterator iter = inputs_.children.begin(); |
| 278 iter != children_.end(); | 283 iter != inputs_.children.end(); ++iter) { |
| 279 ++iter) { | |
| 280 if (iter->get() != child) | 284 if (iter->get() != child) |
| 281 continue; | 285 continue; |
| 282 | 286 |
| 283 child->SetParent(nullptr); | 287 child->SetParent(nullptr); |
| 284 AddDrawableDescendants(-child->NumDescendantsThatDrawContent() - | 288 AddDrawableDescendants(-child->NumDescendantsThatDrawContent() - |
| 285 (child->DrawsContent() ? 1 : 0)); | 289 (child->DrawsContent() ? 1 : 0)); |
| 286 children_.erase(iter); | 290 inputs_.children.erase(iter); |
| 287 SetNeedsFullTreeSync(); | 291 SetNeedsFullTreeSync(); |
| 288 return; | 292 return; |
| 289 } | 293 } |
| 290 } | 294 } |
| 291 | 295 |
| 292 void Layer::ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer) { | 296 void Layer::ReplaceChild(Layer* reference, scoped_refptr<Layer> new_layer) { |
| 293 DCHECK(reference); | 297 DCHECK(reference); |
| 294 DCHECK_EQ(reference->parent(), this); | 298 DCHECK_EQ(reference->parent(), this); |
| 295 DCHECK(IsPropertyChangeAllowed()); | 299 DCHECK(IsPropertyChangeAllowed()); |
| 296 | 300 |
| 297 if (reference == new_layer.get()) | 301 if (reference == new_layer.get()) |
| 298 return; | 302 return; |
| 299 | 303 |
| 300 // Find the index of |reference| in |children_|. | 304 // Find the index of |reference| in |children_|. |
| 301 auto reference_it = | 305 auto reference_it = |
| 302 std::find_if(children_.begin(), children_.end(), | 306 std::find_if(inputs_.children.begin(), inputs_.children.end(), |
| 303 [reference](const scoped_refptr<Layer>& layer) { | 307 [reference](const scoped_refptr<Layer>& layer) { |
| 304 return layer.get() == reference; | 308 return layer.get() == reference; |
| 305 }); | 309 }); |
| 306 DCHECK(reference_it != children_.end()); | 310 DCHECK(reference_it != inputs_.children.end()); |
| 307 size_t reference_index = reference_it - children_.begin(); | 311 size_t reference_index = reference_it - inputs_.children.begin(); |
| 308 reference->RemoveFromParent(); | 312 reference->RemoveFromParent(); |
| 309 | 313 |
| 310 if (new_layer.get()) { | 314 if (new_layer.get()) { |
| 311 new_layer->RemoveFromParent(); | 315 new_layer->RemoveFromParent(); |
| 312 InsertChild(new_layer, reference_index); | 316 InsertChild(new_layer, reference_index); |
| 313 } | 317 } |
| 314 } | 318 } |
| 315 | 319 |
| 316 void Layer::SetBounds(const gfx::Size& size) { | 320 void Layer::SetBounds(const gfx::Size& size) { |
| 317 DCHECK(IsPropertyChangeAllowed()); | 321 DCHECK(IsPropertyChangeAllowed()); |
| 318 if (bounds() == size) | 322 if (bounds() == size) |
| 319 return; | 323 return; |
| 320 bounds_ = size; | 324 inputs_.bounds = size; |
| 321 | 325 |
| 322 if (!layer_tree_host_) | 326 if (!layer_tree_host_) |
| 323 return; | 327 return; |
| 324 | 328 |
| 325 if (masks_to_bounds()) | 329 if (masks_to_bounds()) |
| 326 SetSubtreePropertyChanged(); | 330 SetSubtreePropertyChanged(); |
| 327 SetNeedsCommit(); | 331 SetNeedsCommit(); |
| 328 } | 332 } |
| 329 | 333 |
| 330 Layer* Layer::RootLayer() { | 334 Layer* Layer::RootLayer() { |
| 331 Layer* layer = this; | 335 Layer* layer = this; |
| 332 while (layer->parent()) | 336 while (layer->parent()) |
| 333 layer = layer->parent(); | 337 layer = layer->parent(); |
| 334 return layer; | 338 return layer; |
| 335 } | 339 } |
| 336 | 340 |
| 337 void Layer::RemoveAllChildren() { | 341 void Layer::RemoveAllChildren() { |
| 338 DCHECK(IsPropertyChangeAllowed()); | 342 DCHECK(IsPropertyChangeAllowed()); |
| 339 while (children_.size()) { | 343 while (inputs_.children.size()) { |
| 340 Layer* layer = children_[0].get(); | 344 Layer* layer = inputs_.children[0].get(); |
| 341 DCHECK_EQ(this, layer->parent()); | 345 DCHECK_EQ(this, layer->parent()); |
| 342 layer->RemoveFromParent(); | 346 layer->RemoveFromParent(); |
| 343 } | 347 } |
| 344 } | 348 } |
| 345 | 349 |
| 346 void Layer::SetChildren(const LayerList& children) { | 350 void Layer::SetChildren(const LayerList& children) { |
| 347 DCHECK(IsPropertyChangeAllowed()); | 351 DCHECK(IsPropertyChangeAllowed()); |
| 348 if (children == children_) | 352 if (children == inputs_.children) |
| 349 return; | 353 return; |
| 350 | 354 |
| 351 RemoveAllChildren(); | 355 RemoveAllChildren(); |
| 352 for (size_t i = 0; i < children.size(); ++i) | 356 for (size_t i = 0; i < children.size(); ++i) |
| 353 AddChild(children[i]); | 357 AddChild(children[i]); |
| 354 } | 358 } |
| 355 | 359 |
| 356 bool Layer::HasAncestor(const Layer* ancestor) const { | 360 bool Layer::HasAncestor(const Layer* ancestor) const { |
| 357 for (const Layer* layer = parent(); layer; layer = layer->parent()) { | 361 for (const Layer* layer = parent(); layer; layer = layer->parent()) { |
| 358 if (layer == ancestor) | 362 if (layer == ancestor) |
| 359 return true; | 363 return true; |
| 360 } | 364 } |
| 361 return false; | 365 return false; |
| 362 } | 366 } |
| 363 | 367 |
| 364 void Layer::RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> request) { | 368 void Layer::RequestCopyOfOutput(std::unique_ptr<CopyOutputRequest> request) { |
| 365 DCHECK(IsPropertyChangeAllowed()); | 369 DCHECK(IsPropertyChangeAllowed()); |
| 366 if (void* source = request->source()) { | 370 if (void* source = request->source()) { |
| 367 auto it = | 371 auto it = |
| 368 std::find_if(copy_requests_.begin(), copy_requests_.end(), | 372 std::find_if(inputs_.copy_requests.begin(), inputs_.copy_requests.end(), |
| 369 [source](const std::unique_ptr<CopyOutputRequest>& x) { | 373 [source](const std::unique_ptr<CopyOutputRequest>& x) { |
| 370 return x->source() == source; | 374 return x->source() == source; |
| 371 }); | 375 }); |
| 372 if (it != copy_requests_.end()) | 376 if (it != inputs_.copy_requests.end()) |
| 373 copy_requests_.erase(it); | 377 inputs_.copy_requests.erase(it); |
| 374 } | 378 } |
| 375 if (request->IsEmpty()) | 379 if (request->IsEmpty()) |
| 376 return; | 380 return; |
| 377 copy_requests_.push_back(std::move(request)); | 381 inputs_.copy_requests.push_back(std::move(request)); |
| 378 SetSubtreePropertyChanged(); | 382 SetSubtreePropertyChanged(); |
| 379 SetNeedsCommit(); | 383 SetNeedsCommit(); |
| 380 } | 384 } |
| 381 | 385 |
| 382 void Layer::SetBackgroundColor(SkColor background_color) { | 386 void Layer::SetBackgroundColor(SkColor background_color) { |
| 383 DCHECK(IsPropertyChangeAllowed()); | 387 DCHECK(IsPropertyChangeAllowed()); |
| 384 if (background_color_ == background_color) | 388 if (inputs_.background_color == background_color) |
| 385 return; | 389 return; |
| 386 background_color_ = background_color; | 390 inputs_.background_color = background_color; |
| 387 SetNeedsCommit(); | 391 SetNeedsCommit(); |
| 388 } | 392 } |
| 389 | 393 |
| 390 void Layer::SetSafeOpaqueBackgroundColor(SkColor background_color) { | 394 void Layer::SetSafeOpaqueBackgroundColor(SkColor background_color) { |
| 391 DCHECK(IsPropertyChangeAllowed()); | 395 DCHECK(IsPropertyChangeAllowed()); |
| 392 if (safe_opaque_background_color_ == background_color) | 396 if (safe_opaque_background_color_ == background_color) |
| 393 return; | 397 return; |
| 394 safe_opaque_background_color_ = background_color; | 398 safe_opaque_background_color_ = background_color; |
| 395 SetNeedsPushProperties(); | 399 SetNeedsPushProperties(); |
| 396 } | 400 } |
| 397 | 401 |
| 398 SkColor Layer::SafeOpaqueBackgroundColor() const { | 402 SkColor Layer::SafeOpaqueBackgroundColor() const { |
| 399 if (contents_opaque()) | 403 if (contents_opaque()) |
| 400 return safe_opaque_background_color_; | 404 return safe_opaque_background_color_; |
| 401 SkColor color = background_color(); | 405 SkColor color = background_color(); |
| 402 if (SkColorGetA(color) == 255) | 406 if (SkColorGetA(color) == 255) |
| 403 color = SK_ColorTRANSPARENT; | 407 color = SK_ColorTRANSPARENT; |
| 404 return color; | 408 return color; |
| 405 } | 409 } |
| 406 | 410 |
| 407 void Layer::SetMasksToBounds(bool masks_to_bounds) { | 411 void Layer::SetMasksToBounds(bool masks_to_bounds) { |
| 408 DCHECK(IsPropertyChangeAllowed()); | 412 DCHECK(IsPropertyChangeAllowed()); |
| 409 if (masks_to_bounds_ == masks_to_bounds) | 413 if (inputs_.masks_to_bounds == masks_to_bounds) |
| 410 return; | 414 return; |
| 411 masks_to_bounds_ = masks_to_bounds; | 415 inputs_.masks_to_bounds = masks_to_bounds; |
| 412 SetNeedsCommit(); | 416 SetNeedsCommit(); |
| 413 SetSubtreePropertyChanged(); | 417 SetSubtreePropertyChanged(); |
| 414 } | 418 } |
| 415 | 419 |
| 416 void Layer::SetMaskLayer(Layer* mask_layer) { | 420 void Layer::SetMaskLayer(Layer* mask_layer) { |
| 417 DCHECK(IsPropertyChangeAllowed()); | 421 DCHECK(IsPropertyChangeAllowed()); |
| 418 if (mask_layer_.get() == mask_layer) | 422 if (inputs_.mask_layer.get() == mask_layer) |
| 419 return; | 423 return; |
| 420 if (mask_layer_.get()) { | 424 if (inputs_.mask_layer.get()) { |
| 421 DCHECK_EQ(this, mask_layer_->parent()); | 425 DCHECK_EQ(this, inputs_.mask_layer->parent()); |
| 422 mask_layer_->RemoveFromParent(); | 426 inputs_.mask_layer->RemoveFromParent(); |
| 423 } | 427 } |
| 424 mask_layer_ = mask_layer; | 428 inputs_.mask_layer = mask_layer; |
| 425 if (mask_layer_.get()) { | 429 if (inputs_.mask_layer.get()) { |
| 426 mask_layer_->RemoveFromParent(); | 430 inputs_.mask_layer->RemoveFromParent(); |
| 427 DCHECK(!mask_layer_->parent()); | 431 DCHECK(!inputs_.mask_layer->parent()); |
| 428 mask_layer_->SetParent(this); | 432 inputs_.mask_layer->SetParent(this); |
| 429 mask_layer_->SetIsMask(true); | 433 inputs_.mask_layer->SetIsMask(true); |
| 430 } | 434 } |
| 431 SetSubtreePropertyChanged(); | 435 SetSubtreePropertyChanged(); |
| 432 SetNeedsFullTreeSync(); | 436 SetNeedsFullTreeSync(); |
| 433 } | 437 } |
| 434 | 438 |
| 435 void Layer::SetReplicaLayer(Layer* layer) { | 439 void Layer::SetReplicaLayer(Layer* layer) { |
| 436 DCHECK(IsPropertyChangeAllowed()); | 440 DCHECK(IsPropertyChangeAllowed()); |
| 437 if (replica_layer_.get() == layer) | 441 if (inputs_.replica_layer.get() == layer) |
| 438 return; | 442 return; |
| 439 if (replica_layer_.get()) { | 443 if (inputs_.replica_layer.get()) { |
| 440 DCHECK_EQ(this, replica_layer_->parent()); | 444 DCHECK_EQ(this, inputs_.replica_layer->parent()); |
| 441 replica_layer_->RemoveFromParent(); | 445 inputs_.replica_layer->RemoveFromParent(); |
| 442 } | 446 } |
| 443 replica_layer_ = layer; | 447 inputs_.replica_layer = layer; |
| 444 if (replica_layer_.get()) { | 448 if (inputs_.replica_layer.get()) { |
| 445 DCHECK(!replica_layer_->parent()); | 449 DCHECK(!inputs_.replica_layer->parent()); |
| 446 replica_layer_->RemoveFromParent(); | 450 inputs_.replica_layer->RemoveFromParent(); |
| 447 replica_layer_->SetParent(this); | 451 inputs_.replica_layer->SetParent(this); |
| 448 } | 452 } |
| 449 SetSubtreePropertyChanged(); | 453 SetSubtreePropertyChanged(); |
| 450 SetNeedsFullTreeSync(); | 454 SetNeedsFullTreeSync(); |
| 451 } | 455 } |
| 452 | 456 |
| 453 void Layer::SetFilters(const FilterOperations& filters) { | 457 void Layer::SetFilters(const FilterOperations& filters) { |
| 454 DCHECK(IsPropertyChangeAllowed()); | 458 DCHECK(IsPropertyChangeAllowed()); |
| 455 if (filters_ == filters) | 459 if (inputs_.filters == filters) |
| 456 return; | 460 return; |
| 457 filters_ = filters; | 461 inputs_.filters = filters; |
| 458 SetSubtreePropertyChanged(); | 462 SetSubtreePropertyChanged(); |
| 459 SetNeedsCommit(); | 463 SetNeedsCommit(); |
| 460 } | 464 } |
| 461 | 465 |
| 462 bool Layer::FilterIsAnimating() const { | 466 bool Layer::FilterIsAnimating() const { |
| 463 DCHECK(layer_tree_host_); | 467 DCHECK(layer_tree_host_); |
| 464 return layer_tree_host_->IsAnimatingFilterProperty(this); | 468 return layer_tree_host_->IsAnimatingFilterProperty(this); |
| 465 } | 469 } |
| 466 | 470 |
| 467 bool Layer::HasPotentiallyRunningFilterAnimation() const { | 471 bool Layer::HasPotentiallyRunningFilterAnimation() const { |
| 468 return layer_tree_host_->HasPotentiallyRunningFilterAnimation(this); | 472 return layer_tree_host_->HasPotentiallyRunningFilterAnimation(this); |
| 469 } | 473 } |
| 470 | 474 |
| 471 void Layer::SetBackgroundFilters(const FilterOperations& filters) { | 475 void Layer::SetBackgroundFilters(const FilterOperations& filters) { |
| 472 DCHECK(IsPropertyChangeAllowed()); | 476 DCHECK(IsPropertyChangeAllowed()); |
| 473 if (background_filters_ == filters) | 477 if (inputs_.background_filters == filters) |
| 474 return; | 478 return; |
| 475 background_filters_ = filters; | 479 inputs_.background_filters = filters; |
| 476 SetLayerPropertyChanged(); | 480 SetLayerPropertyChanged(); |
| 477 SetNeedsCommit(); | 481 SetNeedsCommit(); |
| 478 } | 482 } |
| 479 | 483 |
| 480 void Layer::SetOpacity(float opacity) { | 484 void Layer::SetOpacity(float opacity) { |
| 481 DCHECK(IsPropertyChangeAllowed()); | 485 DCHECK(IsPropertyChangeAllowed()); |
| 482 DCHECK_GE(opacity, 0.f); | 486 DCHECK_GE(opacity, 0.f); |
| 483 DCHECK_LE(opacity, 1.f); | 487 DCHECK_LE(opacity, 1.f); |
| 484 | 488 |
| 485 if (opacity_ == opacity) | 489 if (inputs_.opacity == opacity) |
| 486 return; | 490 return; |
| 487 // We need to force a property tree rebuild when opacity changes from 1 to a | 491 // We need to force a property tree rebuild when opacity changes from 1 to a |
| 488 // non-1 value or vice-versa as render surfaces can change. | 492 // non-1 value or vice-versa as render surfaces can change. |
| 489 bool force_rebuild = opacity == 1.f || opacity_ == 1.f; | 493 bool force_rebuild = opacity == 1.f || inputs_.opacity == 1.f; |
| 490 opacity_ = opacity; | 494 inputs_.opacity = opacity; |
| 491 SetSubtreePropertyChanged(); | 495 SetSubtreePropertyChanged(); |
| 492 if (layer_tree_host_ && !force_rebuild) { | 496 if (layer_tree_host_ && !force_rebuild) { |
| 493 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 497 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
| 494 auto effect_id_to_index = property_trees->effect_id_to_index_map.find(id()); | 498 auto effect_id_to_index = property_trees->effect_id_to_index_map.find(id()); |
| 495 if (effect_id_to_index != property_trees->effect_id_to_index_map.end()) { | 499 if (effect_id_to_index != property_trees->effect_id_to_index_map.end()) { |
| 496 EffectNode* node = | 500 EffectNode* node = |
| 497 property_trees->effect_tree.Node(effect_id_to_index->second); | 501 property_trees->effect_tree.Node(effect_id_to_index->second); |
| 498 node->data.opacity = opacity; | 502 node->data.opacity = opacity; |
| 499 node->data.effect_changed = true; | 503 node->data.effect_changed = true; |
| 500 property_trees->effect_tree.set_needs_update(true); | 504 property_trees->effect_tree.set_needs_update(true); |
| 501 SetNeedsCommitNoRebuild(); | 505 SetNeedsCommitNoRebuild(); |
| 502 return; | 506 return; |
| 503 } | 507 } |
| 504 } | 508 } |
| 505 SetNeedsCommit(); | 509 SetNeedsCommit(); |
| 506 } | 510 } |
| 507 | 511 |
| 508 float Layer::EffectiveOpacity() const { | 512 float Layer::EffectiveOpacity() const { |
| 509 return hide_layer_and_subtree_ ? 0.f : opacity_; | 513 return inputs_.hide_layer_and_subtree ? 0.f : inputs_.opacity; |
| 510 } | 514 } |
| 511 | 515 |
| 512 bool Layer::OpacityIsAnimating() const { | 516 bool Layer::OpacityIsAnimating() const { |
| 513 DCHECK(layer_tree_host_); | 517 DCHECK(layer_tree_host_); |
| 514 return layer_tree_host_->IsAnimatingOpacityProperty(this); | 518 return layer_tree_host_->IsAnimatingOpacityProperty(this); |
| 515 } | 519 } |
| 516 | 520 |
| 517 bool Layer::HasPotentiallyRunningOpacityAnimation() const { | 521 bool Layer::HasPotentiallyRunningOpacityAnimation() const { |
| 518 return layer_tree_host_->HasPotentiallyRunningOpacityAnimation(this); | 522 return layer_tree_host_->HasPotentiallyRunningOpacityAnimation(this); |
| 519 } | 523 } |
| 520 | 524 |
| 521 bool Layer::OpacityCanAnimateOnImplThread() const { | 525 bool Layer::OpacityCanAnimateOnImplThread() const { |
| 522 return false; | 526 return false; |
| 523 } | 527 } |
| 524 | 528 |
| 525 bool Layer::AlwaysUseActiveTreeOpacity() const { | 529 bool Layer::AlwaysUseActiveTreeOpacity() const { |
| 526 return false; | 530 return false; |
| 527 } | 531 } |
| 528 | 532 |
| 529 void Layer::SetBlendMode(SkXfermode::Mode blend_mode) { | 533 void Layer::SetBlendMode(SkXfermode::Mode blend_mode) { |
| 530 DCHECK(IsPropertyChangeAllowed()); | 534 DCHECK(IsPropertyChangeAllowed()); |
| 531 if (blend_mode_ == blend_mode) | 535 if (inputs_.blend_mode == blend_mode) |
| 532 return; | 536 return; |
| 533 | 537 |
| 534 // Allowing only blend modes that are defined in the CSS Compositing standard: | 538 // Allowing only blend modes that are defined in the CSS Compositing standard: |
| 535 // http://dev.w3.org/fxtf/compositing-1/#blending | 539 // http://dev.w3.org/fxtf/compositing-1/#blending |
| 536 switch (blend_mode) { | 540 switch (blend_mode) { |
| 537 case SkXfermode::kSrcOver_Mode: | 541 case SkXfermode::kSrcOver_Mode: |
| 538 case SkXfermode::kScreen_Mode: | 542 case SkXfermode::kScreen_Mode: |
| 539 case SkXfermode::kOverlay_Mode: | 543 case SkXfermode::kOverlay_Mode: |
| 540 case SkXfermode::kDarken_Mode: | 544 case SkXfermode::kDarken_Mode: |
| 541 case SkXfermode::kLighten_Mode: | 545 case SkXfermode::kLighten_Mode: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 564 case SkXfermode::kDstATop_Mode: | 568 case SkXfermode::kDstATop_Mode: |
| 565 case SkXfermode::kXor_Mode: | 569 case SkXfermode::kXor_Mode: |
| 566 case SkXfermode::kPlus_Mode: | 570 case SkXfermode::kPlus_Mode: |
| 567 case SkXfermode::kModulate_Mode: | 571 case SkXfermode::kModulate_Mode: |
| 568 // Porter Duff Compositing Operators are not yet supported | 572 // Porter Duff Compositing Operators are not yet supported |
| 569 // http://dev.w3.org/fxtf/compositing-1/#porterduffcompositingoperators | 573 // http://dev.w3.org/fxtf/compositing-1/#porterduffcompositingoperators |
| 570 NOTREACHED(); | 574 NOTREACHED(); |
| 571 return; | 575 return; |
| 572 } | 576 } |
| 573 | 577 |
| 574 blend_mode_ = blend_mode; | 578 inputs_.blend_mode = blend_mode; |
| 575 SetNeedsCommit(); | 579 SetNeedsCommit(); |
| 576 SetSubtreePropertyChanged(); | 580 SetSubtreePropertyChanged(); |
| 577 } | 581 } |
| 578 | 582 |
| 579 void Layer::SetIsRootForIsolatedGroup(bool root) { | 583 void Layer::SetIsRootForIsolatedGroup(bool root) { |
| 580 DCHECK(IsPropertyChangeAllowed()); | 584 DCHECK(IsPropertyChangeAllowed()); |
| 581 if (is_root_for_isolated_group_ == root) | 585 if (inputs_.is_root_for_isolated_group == root) |
| 582 return; | 586 return; |
| 583 is_root_for_isolated_group_ = root; | 587 inputs_.is_root_for_isolated_group = root; |
| 584 SetNeedsCommit(); | 588 SetNeedsCommit(); |
| 585 } | 589 } |
| 586 | 590 |
| 587 void Layer::SetContentsOpaque(bool opaque) { | 591 void Layer::SetContentsOpaque(bool opaque) { |
| 588 DCHECK(IsPropertyChangeAllowed()); | 592 DCHECK(IsPropertyChangeAllowed()); |
| 589 if (contents_opaque_ == opaque) | 593 if (inputs_.contents_opaque == opaque) |
| 590 return; | 594 return; |
| 591 contents_opaque_ = opaque; | 595 inputs_.contents_opaque = opaque; |
| 592 SetNeedsCommit(); | 596 SetNeedsCommit(); |
| 593 SetSubtreePropertyChanged(); | 597 SetSubtreePropertyChanged(); |
| 594 } | 598 } |
| 595 | 599 |
| 596 void Layer::SetPosition(const gfx::PointF& position) { | 600 void Layer::SetPosition(const gfx::PointF& position) { |
| 597 DCHECK(IsPropertyChangeAllowed()); | 601 DCHECK(IsPropertyChangeAllowed()); |
| 598 if (position_ == position) | 602 if (inputs_.position == position) |
| 599 return; | 603 return; |
| 600 position_ = position; | 604 inputs_.position = position; |
| 601 | 605 |
| 602 if (!layer_tree_host_) | 606 if (!layer_tree_host_) |
| 603 return; | 607 return; |
| 604 | 608 |
| 605 SetSubtreePropertyChanged(); | 609 SetSubtreePropertyChanged(); |
| 606 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 610 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
| 607 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, | 611 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, |
| 608 id())) { | 612 id())) { |
| 609 DCHECK_EQ(transform_tree_index(), | 613 DCHECK_EQ(transform_tree_index(), |
| 610 property_trees->transform_id_to_index_map[id()]); | 614 property_trees->transform_id_to_index_map[id()]); |
| 611 TransformNode* transform_node = | 615 TransformNode* transform_node = |
| 612 property_trees->transform_tree.Node(transform_tree_index()); | 616 property_trees->transform_tree.Node(transform_tree_index()); |
| 613 transform_node->data.update_post_local_transform(position, | 617 transform_node->data.update_post_local_transform(position, |
| 614 transform_origin()); | 618 transform_origin()); |
| 615 transform_node->data.needs_local_transform_update = true; | 619 transform_node->data.needs_local_transform_update = true; |
| 616 transform_node->data.transform_changed = true; | 620 transform_node->data.transform_changed = true; |
| 617 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 621 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
| 618 SetNeedsCommitNoRebuild(); | 622 SetNeedsCommitNoRebuild(); |
| 619 return; | 623 return; |
| 620 } | 624 } |
| 621 | 625 |
| 622 SetNeedsCommit(); | 626 SetNeedsCommit(); |
| 623 } | 627 } |
| 624 | 628 |
| 625 bool Layer::IsContainerForFixedPositionLayers() const { | 629 bool Layer::IsContainerForFixedPositionLayers() const { |
| 626 if (!transform_.IsIdentityOrTranslation()) | 630 if (!inputs_.transform.IsIdentityOrTranslation()) |
| 627 return true; | 631 return true; |
| 628 if (parent_ && !parent_->transform_.IsIdentityOrTranslation()) | 632 if (parent_ && !parent_->inputs_.transform.IsIdentityOrTranslation()) |
| 629 return true; | 633 return true; |
| 630 return is_container_for_fixed_position_layers_; | 634 return inputs_.is_container_for_fixed_position_layers; |
| 631 } | 635 } |
| 632 | 636 |
| 633 bool Are2dAxisAligned(const gfx::Transform& a, const gfx::Transform& b) { | 637 bool Are2dAxisAligned(const gfx::Transform& a, const gfx::Transform& b) { |
| 634 if (a.IsScaleOrTranslation() && b.IsScaleOrTranslation()) { | 638 if (a.IsScaleOrTranslation() && b.IsScaleOrTranslation()) { |
| 635 return true; | 639 return true; |
| 636 } | 640 } |
| 637 | 641 |
| 638 gfx::Transform inverse(gfx::Transform::kSkipInitialization); | 642 gfx::Transform inverse(gfx::Transform::kSkipInitialization); |
| 639 if (b.GetInverse(&inverse)) { | 643 if (b.GetInverse(&inverse)) { |
| 640 inverse *= a; | 644 inverse *= a; |
| 641 return inverse.Preserves2dAxisAlignment(); | 645 return inverse.Preserves2dAxisAlignment(); |
| 642 } else { | 646 } else { |
| 643 // TODO(weiliangc): Should return false because b is not invertible. | 647 // TODO(weiliangc): Should return false because b is not invertible. |
| 644 return a.Preserves2dAxisAlignment(); | 648 return a.Preserves2dAxisAlignment(); |
| 645 } | 649 } |
| 646 } | 650 } |
| 647 | 651 |
| 648 void Layer::SetTransform(const gfx::Transform& transform) { | 652 void Layer::SetTransform(const gfx::Transform& transform) { |
| 649 DCHECK(IsPropertyChangeAllowed()); | 653 DCHECK(IsPropertyChangeAllowed()); |
| 650 if (transform_ == transform) | 654 if (inputs_.transform == transform) |
| 651 return; | 655 return; |
| 652 | 656 |
| 653 SetSubtreePropertyChanged(); | 657 SetSubtreePropertyChanged(); |
| 654 if (layer_tree_host_) { | 658 if (layer_tree_host_) { |
| 655 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 659 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
| 656 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, | 660 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, |
| 657 id())) { | 661 id())) { |
| 658 // We need to trigger a rebuild if we could have affected 2d axis | 662 // We need to trigger a rebuild if we could have affected 2d axis |
| 659 // alignment. We'll check to see if transform and transform_ are axis | 663 // alignment. We'll check to see if transform and inputs_.transform |
| 664 // are axis |
| 660 // align with respect to one another. | 665 // align with respect to one another. |
| 661 DCHECK_EQ(transform_tree_index(), | 666 DCHECK_EQ(transform_tree_index(), |
| 662 property_trees->transform_id_to_index_map[id()]); | 667 property_trees->transform_id_to_index_map[id()]); |
| 663 TransformNode* transform_node = | 668 TransformNode* transform_node = |
| 664 property_trees->transform_tree.Node(transform_tree_index()); | 669 property_trees->transform_tree.Node(transform_tree_index()); |
| 665 bool preserves_2d_axis_alignment = | 670 bool preserves_2d_axis_alignment = |
| 666 Are2dAxisAligned(transform_, transform); | 671 Are2dAxisAligned(inputs_.transform, transform); |
| 667 transform_node->data.local = transform; | 672 transform_node->data.local = transform; |
| 668 transform_node->data.needs_local_transform_update = true; | 673 transform_node->data.needs_local_transform_update = true; |
| 669 transform_node->data.transform_changed = true; | 674 transform_node->data.transform_changed = true; |
| 670 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 675 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
| 671 if (preserves_2d_axis_alignment) | 676 if (preserves_2d_axis_alignment) |
| 672 SetNeedsCommitNoRebuild(); | 677 SetNeedsCommitNoRebuild(); |
| 673 else | 678 else |
| 674 SetNeedsCommit(); | 679 SetNeedsCommit(); |
| 675 transform_ = transform; | 680 inputs_.transform = transform; |
| 676 return; | 681 return; |
| 677 } | 682 } |
| 678 } | 683 } |
| 679 | 684 |
| 680 transform_ = transform; | 685 inputs_.transform = transform; |
| 681 | 686 |
| 682 SetNeedsCommit(); | 687 SetNeedsCommit(); |
| 683 } | 688 } |
| 684 | 689 |
| 685 void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) { | 690 void Layer::SetTransformOrigin(const gfx::Point3F& transform_origin) { |
| 686 DCHECK(IsPropertyChangeAllowed()); | 691 DCHECK(IsPropertyChangeAllowed()); |
| 687 if (transform_origin_ == transform_origin) | 692 if (inputs_.transform_origin == transform_origin) |
| 688 return; | 693 return; |
| 689 transform_origin_ = transform_origin; | 694 inputs_.transform_origin = transform_origin; |
| 690 | 695 |
| 691 if (!layer_tree_host_) | 696 if (!layer_tree_host_) |
| 692 return; | 697 return; |
| 693 | 698 |
| 694 SetSubtreePropertyChanged(); | 699 SetSubtreePropertyChanged(); |
| 695 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 700 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
| 696 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, | 701 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, |
| 697 id())) { | 702 id())) { |
| 698 DCHECK_EQ(transform_tree_index(), | 703 DCHECK_EQ(transform_tree_index(), |
| 699 property_trees->transform_id_to_index_map[id()]); | 704 property_trees->transform_id_to_index_map[id()]); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 return layer_tree_host_->HasAnyAnimationTargetingProperty(this, property); | 748 return layer_tree_host_->HasAnyAnimationTargetingProperty(this, property); |
| 744 } | 749 } |
| 745 | 750 |
| 746 bool Layer::ScrollOffsetAnimationWasInterrupted() const { | 751 bool Layer::ScrollOffsetAnimationWasInterrupted() const { |
| 747 DCHECK(layer_tree_host_); | 752 DCHECK(layer_tree_host_); |
| 748 return layer_tree_host_->ScrollOffsetAnimationWasInterrupted(this); | 753 return layer_tree_host_->ScrollOffsetAnimationWasInterrupted(this); |
| 749 } | 754 } |
| 750 | 755 |
| 751 void Layer::SetScrollParent(Layer* parent) { | 756 void Layer::SetScrollParent(Layer* parent) { |
| 752 DCHECK(IsPropertyChangeAllowed()); | 757 DCHECK(IsPropertyChangeAllowed()); |
| 753 if (scroll_parent_ == parent) | 758 if (inputs_.scroll_parent == parent) |
| 754 return; | 759 return; |
| 755 | 760 |
| 756 if (scroll_parent_) | 761 if (inputs_.scroll_parent) |
| 757 scroll_parent_->RemoveScrollChild(this); | 762 inputs_.scroll_parent->RemoveScrollChild(this); |
| 758 | 763 |
| 759 scroll_parent_ = parent; | 764 inputs_.scroll_parent = parent; |
| 760 | 765 |
| 761 if (scroll_parent_) | 766 if (inputs_.scroll_parent) |
| 762 scroll_parent_->AddScrollChild(this); | 767 inputs_.scroll_parent->AddScrollChild(this); |
| 763 | 768 |
| 764 SetNeedsCommit(); | 769 SetNeedsCommit(); |
| 765 } | 770 } |
| 766 | 771 |
| 767 void Layer::AddScrollChild(Layer* child) { | 772 void Layer::AddScrollChild(Layer* child) { |
| 768 if (!scroll_children_) | 773 if (!scroll_children_) |
| 769 scroll_children_.reset(new std::set<Layer*>); | 774 scroll_children_.reset(new std::set<Layer*>); |
| 770 scroll_children_->insert(child); | 775 scroll_children_->insert(child); |
| 771 SetNeedsCommit(); | 776 SetNeedsCommit(); |
| 772 } | 777 } |
| 773 | 778 |
| 774 void Layer::RemoveScrollChild(Layer* child) { | 779 void Layer::RemoveScrollChild(Layer* child) { |
| 775 scroll_children_->erase(child); | 780 scroll_children_->erase(child); |
| 776 if (scroll_children_->empty()) | 781 if (scroll_children_->empty()) |
| 777 scroll_children_ = nullptr; | 782 scroll_children_ = nullptr; |
| 778 SetNeedsCommit(); | 783 SetNeedsCommit(); |
| 779 } | 784 } |
| 780 | 785 |
| 781 void Layer::SetClipParent(Layer* ancestor) { | 786 void Layer::SetClipParent(Layer* ancestor) { |
| 782 DCHECK(IsPropertyChangeAllowed()); | 787 DCHECK(IsPropertyChangeAllowed()); |
| 783 if (clip_parent_ == ancestor) | 788 if (inputs_.clip_parent == ancestor) |
| 784 return; | 789 return; |
| 785 | 790 |
| 786 if (clip_parent_) | 791 if (inputs_.clip_parent) |
| 787 clip_parent_->RemoveClipChild(this); | 792 inputs_.clip_parent->RemoveClipChild(this); |
| 788 | 793 |
| 789 clip_parent_ = ancestor; | 794 inputs_.clip_parent = ancestor; |
| 790 | 795 |
| 791 if (clip_parent_) | 796 if (inputs_.clip_parent) |
| 792 clip_parent_->AddClipChild(this); | 797 inputs_.clip_parent->AddClipChild(this); |
| 793 | 798 |
| 794 SetNeedsCommit(); | 799 SetNeedsCommit(); |
| 795 if (layer_tree_host_) | 800 if (layer_tree_host_) |
| 796 layer_tree_host_->SetNeedsMetaInfoRecomputation(true); | 801 layer_tree_host_->SetNeedsMetaInfoRecomputation(true); |
| 797 } | 802 } |
| 798 | 803 |
| 799 void Layer::AddClipChild(Layer* child) { | 804 void Layer::AddClipChild(Layer* child) { |
| 800 if (!clip_children_) | 805 if (!clip_children_) |
| 801 clip_children_.reset(new std::set<Layer*>); | 806 clip_children_.reset(new std::set<Layer*>); |
| 802 clip_children_->insert(child); | 807 clip_children_->insert(child); |
| 803 SetNeedsCommit(); | 808 SetNeedsCommit(); |
| 804 } | 809 } |
| 805 | 810 |
| 806 void Layer::RemoveClipChild(Layer* child) { | 811 void Layer::RemoveClipChild(Layer* child) { |
| 807 clip_children_->erase(child); | 812 clip_children_->erase(child); |
| 808 if (clip_children_->empty()) | 813 if (clip_children_->empty()) |
| 809 clip_children_ = nullptr; | 814 clip_children_ = nullptr; |
| 810 SetNeedsCommit(); | 815 SetNeedsCommit(); |
| 811 } | 816 } |
| 812 | 817 |
| 813 void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) { | 818 void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) { |
| 814 DCHECK(IsPropertyChangeAllowed()); | 819 DCHECK(IsPropertyChangeAllowed()); |
| 815 | 820 |
| 816 if (scroll_offset_ == scroll_offset) | 821 if (inputs_.scroll_offset == scroll_offset) |
| 817 return; | 822 return; |
| 818 scroll_offset_ = scroll_offset; | 823 inputs_.scroll_offset = scroll_offset; |
| 819 | 824 |
| 820 if (!layer_tree_host_) | 825 if (!layer_tree_host_) |
| 821 return; | 826 return; |
| 822 | 827 |
| 823 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 828 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
| 824 if (scroll_tree_index() != -1 && scrollable()) | 829 if (scroll_tree_index() != -1 && scrollable()) |
| 825 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset); | 830 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset); |
| 826 | 831 |
| 827 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, | 832 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, |
| 828 id())) { | 833 id())) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 839 | 844 |
| 840 SetNeedsCommit(); | 845 SetNeedsCommit(); |
| 841 } | 846 } |
| 842 | 847 |
| 843 void Layer::SetScrollOffsetFromImplSide( | 848 void Layer::SetScrollOffsetFromImplSide( |
| 844 const gfx::ScrollOffset& scroll_offset) { | 849 const gfx::ScrollOffset& scroll_offset) { |
| 845 DCHECK(IsPropertyChangeAllowed()); | 850 DCHECK(IsPropertyChangeAllowed()); |
| 846 // This function only gets called during a BeginMainFrame, so there | 851 // This function only gets called during a BeginMainFrame, so there |
| 847 // is no need to call SetNeedsUpdate here. | 852 // is no need to call SetNeedsUpdate here. |
| 848 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); | 853 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); |
| 849 if (scroll_offset_ == scroll_offset) | 854 if (inputs_.scroll_offset == scroll_offset) |
| 850 return; | 855 return; |
| 851 scroll_offset_ = scroll_offset; | 856 inputs_.scroll_offset = scroll_offset; |
| 852 SetNeedsPushProperties(); | 857 SetNeedsPushProperties(); |
| 853 | 858 |
| 854 bool needs_rebuild = true; | 859 bool needs_rebuild = true; |
| 855 | 860 |
| 856 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 861 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
| 857 if (scroll_tree_index() != -1 && scrollable()) | 862 if (scroll_tree_index() != -1 && scrollable()) |
| 858 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset); | 863 property_trees->scroll_tree.SetScrollOffset(id(), scroll_offset); |
| 859 | 864 |
| 860 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, | 865 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, |
| 861 id())) { | 866 id())) { |
| 862 DCHECK_EQ(transform_tree_index(), | 867 DCHECK_EQ(transform_tree_index(), |
| 863 property_trees->transform_id_to_index_map[id()]); | 868 property_trees->transform_id_to_index_map[id()]); |
| 864 TransformNode* transform_node = | 869 TransformNode* transform_node = |
| 865 property_trees->transform_tree.Node(transform_tree_index()); | 870 property_trees->transform_tree.Node(transform_tree_index()); |
| 866 transform_node->data.scroll_offset = CurrentScrollOffset(); | 871 transform_node->data.scroll_offset = CurrentScrollOffset(); |
| 867 transform_node->data.needs_local_transform_update = true; | 872 transform_node->data.needs_local_transform_update = true; |
| 868 property_trees->transform_tree.set_needs_update(true); | 873 property_trees->transform_tree.set_needs_update(true); |
| 869 needs_rebuild = false; | 874 needs_rebuild = false; |
| 870 } | 875 } |
| 871 | 876 |
| 872 if (needs_rebuild) | 877 if (needs_rebuild) |
| 873 property_trees->needs_rebuild = true; | 878 property_trees->needs_rebuild = true; |
| 874 | 879 |
| 875 if (!did_scroll_callback_.is_null()) | 880 if (!inputs_.did_scroll_callback.is_null()) |
| 876 did_scroll_callback_.Run(); | 881 inputs_.did_scroll_callback.Run(); |
| 877 // The callback could potentially change the layer structure: | 882 // The callback could potentially change the layer structure: |
| 878 // "this" may have been destroyed during the process. | 883 // "this" may have been destroyed during the process. |
| 879 } | 884 } |
| 880 | 885 |
| 881 void Layer::SetScrollClipLayerId(int clip_layer_id) { | 886 void Layer::SetScrollClipLayerId(int clip_layer_id) { |
| 882 DCHECK(IsPropertyChangeAllowed()); | 887 DCHECK(IsPropertyChangeAllowed()); |
| 883 if (scroll_clip_layer_id_ == clip_layer_id) | 888 if (inputs_.scroll_clip_layer_id == clip_layer_id) |
| 884 return; | 889 return; |
| 885 scroll_clip_layer_id_ = clip_layer_id; | 890 inputs_.scroll_clip_layer_id = clip_layer_id; |
| 886 SetNeedsCommit(); | 891 SetNeedsCommit(); |
| 887 } | 892 } |
| 888 | 893 |
| 889 Layer* Layer::scroll_clip_layer() const { | 894 Layer* Layer::scroll_clip_layer() const { |
| 890 return layer_tree_host()->LayerById(scroll_clip_layer_id_); | 895 return layer_tree_host()->LayerById(inputs_.scroll_clip_layer_id); |
| 891 } | 896 } |
| 892 | 897 |
| 893 void Layer::SetUserScrollable(bool horizontal, bool vertical) { | 898 void Layer::SetUserScrollable(bool horizontal, bool vertical) { |
| 894 DCHECK(IsPropertyChangeAllowed()); | 899 DCHECK(IsPropertyChangeAllowed()); |
| 895 if (user_scrollable_horizontal_ == horizontal && | 900 if (inputs_.user_scrollable_horizontal == horizontal && |
| 896 user_scrollable_vertical_ == vertical) | 901 inputs_.user_scrollable_vertical == vertical) |
| 897 return; | 902 return; |
| 898 user_scrollable_horizontal_ = horizontal; | 903 inputs_.user_scrollable_horizontal = horizontal; |
| 899 user_scrollable_vertical_ = vertical; | 904 inputs_.user_scrollable_vertical = vertical; |
| 900 SetNeedsCommit(); | 905 SetNeedsCommit(); |
| 901 } | 906 } |
| 902 | 907 |
| 903 void Layer::AddMainThreadScrollingReasons( | 908 void Layer::AddMainThreadScrollingReasons( |
| 904 uint32_t main_thread_scrolling_reasons) { | 909 uint32_t main_thread_scrolling_reasons) { |
| 905 DCHECK(IsPropertyChangeAllowed()); | 910 DCHECK(IsPropertyChangeAllowed()); |
| 906 DCHECK(main_thread_scrolling_reasons); | 911 DCHECK(main_thread_scrolling_reasons); |
| 907 uint32_t new_reasons = | 912 uint32_t new_reasons = |
| 908 main_thread_scrolling_reasons_ | main_thread_scrolling_reasons; | 913 inputs_.main_thread_scrolling_reasons | main_thread_scrolling_reasons; |
| 909 if (main_thread_scrolling_reasons_ == new_reasons) | 914 if (inputs_.main_thread_scrolling_reasons == new_reasons) |
| 910 return; | 915 return; |
| 911 main_thread_scrolling_reasons_ = new_reasons; | 916 inputs_.main_thread_scrolling_reasons = new_reasons; |
| 912 SetNeedsCommit(); | 917 SetNeedsCommit(); |
| 913 } | 918 } |
| 914 | 919 |
| 915 void Layer::ClearMainThreadScrollingReasons( | 920 void Layer::ClearMainThreadScrollingReasons( |
| 916 uint32_t main_thread_scrolling_reasons_to_clear) { | 921 uint32_t main_thread_scrolling_reasons_to_clear) { |
| 917 DCHECK(IsPropertyChangeAllowed()); | 922 DCHECK(IsPropertyChangeAllowed()); |
| 918 DCHECK(main_thread_scrolling_reasons_to_clear); | 923 DCHECK(main_thread_scrolling_reasons_to_clear); |
| 919 uint32_t new_reasons = | 924 uint32_t new_reasons = ~main_thread_scrolling_reasons_to_clear & |
| 920 ~main_thread_scrolling_reasons_to_clear & main_thread_scrolling_reasons_; | 925 inputs_.main_thread_scrolling_reasons; |
| 921 if (new_reasons == main_thread_scrolling_reasons_) | 926 if (new_reasons == inputs_.main_thread_scrolling_reasons) |
| 922 return; | 927 return; |
| 923 main_thread_scrolling_reasons_ = new_reasons; | 928 inputs_.main_thread_scrolling_reasons = new_reasons; |
| 924 SetNeedsCommit(); | 929 SetNeedsCommit(); |
| 925 } | 930 } |
| 926 | 931 |
| 927 void Layer::SetNonFastScrollableRegion(const Region& region) { | 932 void Layer::SetNonFastScrollableRegion(const Region& region) { |
| 928 DCHECK(IsPropertyChangeAllowed()); | 933 DCHECK(IsPropertyChangeAllowed()); |
| 929 if (non_fast_scrollable_region_ == region) | 934 if (inputs_.non_fast_scrollable_region == region) |
| 930 return; | 935 return; |
| 931 non_fast_scrollable_region_ = region; | 936 inputs_.non_fast_scrollable_region = region; |
| 932 SetNeedsCommit(); | 937 SetNeedsCommit(); |
| 933 } | 938 } |
| 934 | 939 |
| 935 void Layer::SetTouchEventHandlerRegion(const Region& region) { | 940 void Layer::SetTouchEventHandlerRegion(const Region& region) { |
| 936 DCHECK(IsPropertyChangeAllowed()); | 941 DCHECK(IsPropertyChangeAllowed()); |
| 937 if (touch_event_handler_region_ == region) | 942 if (inputs_.touch_event_handler_region == region) |
| 938 return; | 943 return; |
| 939 | 944 |
| 940 touch_event_handler_region_ = region; | 945 inputs_.touch_event_handler_region = region; |
| 941 SetNeedsCommit(); | 946 SetNeedsCommit(); |
| 942 } | 947 } |
| 943 | 948 |
| 944 void Layer::SetForceRenderSurfaceForTesting(bool force) { | 949 void Layer::SetForceRenderSurfaceForTesting(bool force) { |
| 945 DCHECK(IsPropertyChangeAllowed()); | 950 DCHECK(IsPropertyChangeAllowed()); |
| 946 if (force_render_surface_for_testing_ == force) | 951 if (force_render_surface_for_testing_ == force) |
| 947 return; | 952 return; |
| 948 force_render_surface_for_testing_ = force; | 953 force_render_surface_for_testing_ = force; |
| 949 SetNeedsCommit(); | 954 SetNeedsCommit(); |
| 950 } | 955 } |
| 951 | 956 |
| 952 void Layer::SetDoubleSided(bool double_sided) { | 957 void Layer::SetDoubleSided(bool double_sided) { |
| 953 DCHECK(IsPropertyChangeAllowed()); | 958 DCHECK(IsPropertyChangeAllowed()); |
| 954 if (double_sided_ == double_sided) | 959 if (inputs_.double_sided == double_sided) |
| 955 return; | 960 return; |
| 956 double_sided_ = double_sided; | 961 inputs_.double_sided = double_sided; |
| 957 SetNeedsCommit(); | 962 SetNeedsCommit(); |
| 958 SetSubtreePropertyChanged(); | 963 SetSubtreePropertyChanged(); |
| 959 } | 964 } |
| 960 | 965 |
| 961 void Layer::Set3dSortingContextId(int id) { | 966 void Layer::Set3dSortingContextId(int id) { |
| 962 DCHECK(IsPropertyChangeAllowed()); | 967 DCHECK(IsPropertyChangeAllowed()); |
| 963 if (id == sorting_context_id_) | 968 if (id == inputs_.sorting_context_id) |
| 964 return; | 969 return; |
| 965 sorting_context_id_ = id; | 970 inputs_.sorting_context_id = id; |
| 966 SetNeedsCommit(); | 971 SetNeedsCommit(); |
| 967 SetSubtreePropertyChanged(); | 972 SetSubtreePropertyChanged(); |
| 968 } | 973 } |
| 969 | 974 |
| 970 void Layer::SetTransformTreeIndex(int index) { | 975 void Layer::SetTransformTreeIndex(int index) { |
| 971 DCHECK(IsPropertyChangeAllowed()); | 976 DCHECK(IsPropertyChangeAllowed()); |
| 972 if (transform_tree_index_ == index) | 977 if (transform_tree_index_ == index) |
| 973 return; | 978 return; |
| 974 transform_tree_index_ = index; | 979 transform_tree_index_ = index; |
| 975 SetNeedsPushProperties(); | 980 SetNeedsPushProperties(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 | 1042 |
| 1038 void Layer::InvalidatePropertyTreesIndices() { | 1043 void Layer::InvalidatePropertyTreesIndices() { |
| 1039 int invalid_property_tree_index = -1; | 1044 int invalid_property_tree_index = -1; |
| 1040 SetTransformTreeIndex(invalid_property_tree_index); | 1045 SetTransformTreeIndex(invalid_property_tree_index); |
| 1041 SetClipTreeIndex(invalid_property_tree_index); | 1046 SetClipTreeIndex(invalid_property_tree_index); |
| 1042 SetEffectTreeIndex(invalid_property_tree_index); | 1047 SetEffectTreeIndex(invalid_property_tree_index); |
| 1043 } | 1048 } |
| 1044 | 1049 |
| 1045 void Layer::SetShouldFlattenTransform(bool should_flatten) { | 1050 void Layer::SetShouldFlattenTransform(bool should_flatten) { |
| 1046 DCHECK(IsPropertyChangeAllowed()); | 1051 DCHECK(IsPropertyChangeAllowed()); |
| 1047 if (should_flatten_transform_ == should_flatten) | 1052 if (inputs_.should_flatten_transform == should_flatten) |
| 1048 return; | 1053 return; |
| 1049 should_flatten_transform_ = should_flatten; | 1054 inputs_.should_flatten_transform = should_flatten; |
| 1050 SetNeedsCommit(); | 1055 SetNeedsCommit(); |
| 1051 SetSubtreePropertyChanged(); | 1056 SetSubtreePropertyChanged(); |
| 1052 } | 1057 } |
| 1053 | 1058 |
| 1054 void Layer::SetUseParentBackfaceVisibility(bool use) { | 1059 void Layer::SetUseParentBackfaceVisibility(bool use) { |
| 1055 DCHECK(IsPropertyChangeAllowed()); | 1060 DCHECK(IsPropertyChangeAllowed()); |
| 1056 if (use_parent_backface_visibility_ == use) | 1061 if (inputs_.use_parent_backface_visibility == use) |
| 1057 return; | 1062 return; |
| 1058 use_parent_backface_visibility_ = use; | 1063 inputs_.use_parent_backface_visibility = use; |
| 1059 SetNeedsPushProperties(); | 1064 SetNeedsPushProperties(); |
| 1060 } | 1065 } |
| 1061 | 1066 |
| 1062 void Layer::SetUseLocalTransformForBackfaceVisibility(bool use_local) { | 1067 void Layer::SetUseLocalTransformForBackfaceVisibility(bool use_local) { |
| 1063 if (use_local_transform_for_backface_visibility_ == use_local) | 1068 if (use_local_transform_for_backface_visibility_ == use_local) |
| 1064 return; | 1069 return; |
| 1065 use_local_transform_for_backface_visibility_ = use_local; | 1070 use_local_transform_for_backface_visibility_ = use_local; |
| 1066 SetNeedsPushProperties(); | 1071 SetNeedsPushProperties(); |
| 1067 } | 1072 } |
| 1068 | 1073 |
| 1069 void Layer::SetShouldCheckBackfaceVisibility( | 1074 void Layer::SetShouldCheckBackfaceVisibility( |
| 1070 bool should_check_backface_visibility) { | 1075 bool should_check_backface_visibility) { |
| 1071 if (should_check_backface_visibility_ == should_check_backface_visibility) | 1076 if (should_check_backface_visibility_ == should_check_backface_visibility) |
| 1072 return; | 1077 return; |
| 1073 should_check_backface_visibility_ = should_check_backface_visibility; | 1078 should_check_backface_visibility_ = should_check_backface_visibility; |
| 1074 SetNeedsPushProperties(); | 1079 SetNeedsPushProperties(); |
| 1075 } | 1080 } |
| 1076 | 1081 |
| 1077 void Layer::SetIsDrawable(bool is_drawable) { | 1082 void Layer::SetIsDrawable(bool is_drawable) { |
| 1078 DCHECK(IsPropertyChangeAllowed()); | 1083 DCHECK(IsPropertyChangeAllowed()); |
| 1079 if (is_drawable_ == is_drawable) | 1084 if (inputs_.is_drawable == is_drawable) |
| 1080 return; | 1085 return; |
| 1081 | 1086 |
| 1082 is_drawable_ = is_drawable; | 1087 inputs_.is_drawable = is_drawable; |
| 1083 UpdateDrawsContent(HasDrawableContent()); | 1088 UpdateDrawsContent(HasDrawableContent()); |
| 1084 } | 1089 } |
| 1085 | 1090 |
| 1086 void Layer::SetHideLayerAndSubtree(bool hide) { | 1091 void Layer::SetHideLayerAndSubtree(bool hide) { |
| 1087 DCHECK(IsPropertyChangeAllowed()); | 1092 DCHECK(IsPropertyChangeAllowed()); |
| 1088 if (hide_layer_and_subtree_ == hide) | 1093 if (inputs_.hide_layer_and_subtree == hide) |
| 1089 return; | 1094 return; |
| 1090 | 1095 |
| 1091 hide_layer_and_subtree_ = hide; | 1096 inputs_.hide_layer_and_subtree = hide; |
| 1092 SetNeedsCommit(); | 1097 SetNeedsCommit(); |
| 1093 SetSubtreePropertyChanged(); | 1098 SetSubtreePropertyChanged(); |
| 1094 } | 1099 } |
| 1095 | 1100 |
| 1096 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { | 1101 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { |
| 1097 if (dirty_rect.IsEmpty()) | 1102 if (dirty_rect.IsEmpty()) |
| 1098 return; | 1103 return; |
| 1099 | 1104 |
| 1100 SetNeedsPushProperties(); | 1105 SetNeedsPushProperties(); |
| 1101 update_rect_.Union(dirty_rect); | 1106 inputs_.update_rect.Union(dirty_rect); |
| 1102 | 1107 |
| 1103 if (DrawsContent()) | 1108 if (DrawsContent()) |
| 1104 SetNeedsUpdate(); | 1109 SetNeedsUpdate(); |
| 1105 } | 1110 } |
| 1106 | 1111 |
| 1107 bool Layer::DescendantIsFixedToContainerLayer() const { | 1112 bool Layer::DescendantIsFixedToContainerLayer() const { |
| 1108 for (size_t i = 0; i < children_.size(); ++i) { | 1113 for (size_t i = 0; i < inputs_.children.size(); ++i) { |
| 1109 if (children_[i]->position_constraint_.is_fixed_position() || | 1114 if (inputs_.children[i]->inputs_.position_constraint.is_fixed_position() || |
| 1110 children_[i]->DescendantIsFixedToContainerLayer()) | 1115 inputs_.children[i]->DescendantIsFixedToContainerLayer()) |
| 1111 return true; | 1116 return true; |
| 1112 } | 1117 } |
| 1113 return false; | 1118 return false; |
| 1114 } | 1119 } |
| 1115 | 1120 |
| 1116 void Layer::SetIsContainerForFixedPositionLayers(bool container) { | 1121 void Layer::SetIsContainerForFixedPositionLayers(bool container) { |
| 1117 if (is_container_for_fixed_position_layers_ == container) | 1122 if (inputs_.is_container_for_fixed_position_layers == container) |
| 1118 return; | 1123 return; |
| 1119 is_container_for_fixed_position_layers_ = container; | 1124 inputs_.is_container_for_fixed_position_layers = container; |
| 1120 | 1125 |
| 1121 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) | 1126 if (layer_tree_host_ && layer_tree_host_->CommitRequested()) |
| 1122 return; | 1127 return; |
| 1123 | 1128 |
| 1124 // Only request a commit if we have a fixed positioned descendant. | 1129 // Only request a commit if we have a fixed positioned descendant. |
| 1125 if (DescendantIsFixedToContainerLayer()) | 1130 if (DescendantIsFixedToContainerLayer()) |
| 1126 SetNeedsCommit(); | 1131 SetNeedsCommit(); |
| 1127 } | 1132 } |
| 1128 | 1133 |
| 1129 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { | 1134 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { |
| 1130 DCHECK(IsPropertyChangeAllowed()); | 1135 DCHECK(IsPropertyChangeAllowed()); |
| 1131 if (position_constraint_ == constraint) | 1136 if (inputs_.position_constraint == constraint) |
| 1132 return; | 1137 return; |
| 1133 position_constraint_ = constraint; | 1138 inputs_.position_constraint = constraint; |
| 1134 SetNeedsCommit(); | 1139 SetNeedsCommit(); |
| 1135 } | 1140 } |
| 1136 | 1141 |
| 1137 static void RunCopyCallbackOnMainThread( | 1142 static void RunCopyCallbackOnMainThread( |
| 1138 std::unique_ptr<CopyOutputRequest> request, | 1143 std::unique_ptr<CopyOutputRequest> request, |
| 1139 std::unique_ptr<CopyOutputResult> result) { | 1144 std::unique_ptr<CopyOutputResult> result) { |
| 1140 request->SendResult(std::move(result)); | 1145 request->SendResult(std::move(result)); |
| 1141 } | 1146 } |
| 1142 | 1147 |
| 1143 static void PostCopyCallbackToMainThread( | 1148 static void PostCopyCallbackToMainThread( |
| 1144 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, | 1149 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, |
| 1145 std::unique_ptr<CopyOutputRequest> request, | 1150 std::unique_ptr<CopyOutputRequest> request, |
| 1146 std::unique_ptr<CopyOutputResult> result) { | 1151 std::unique_ptr<CopyOutputResult> result) { |
| 1147 main_thread_task_runner->PostTask(FROM_HERE, | 1152 main_thread_task_runner->PostTask(FROM_HERE, |
| 1148 base::Bind(&RunCopyCallbackOnMainThread, | 1153 base::Bind(&RunCopyCallbackOnMainThread, |
| 1149 base::Passed(&request), | 1154 base::Passed(&request), |
| 1150 base::Passed(&result))); | 1155 base::Passed(&result))); |
| 1151 } | 1156 } |
| 1152 | 1157 |
| 1153 void Layer::PushPropertiesTo(LayerImpl* layer) { | 1158 void Layer::PushPropertiesTo(LayerImpl* layer) { |
| 1154 TRACE_EVENT0("cc", "Layer::PushPropertiesTo"); | 1159 TRACE_EVENT0("cc", "Layer::PushPropertiesTo"); |
| 1155 DCHECK(layer_tree_host_); | 1160 DCHECK(layer_tree_host_); |
| 1156 | 1161 |
| 1157 // If we did not SavePaintProperties() for the layer this frame, then push the | 1162 // If we did not SavePaintProperties() for the layer this frame, then push the |
| 1158 // real property values, not the paint property values. | 1163 // real property values, not the paint property values. |
| 1159 bool use_paint_properties = paint_properties_.source_frame_number == | 1164 bool use_paint_properties = paint_properties_.source_frame_number == |
| 1160 layer_tree_host_->source_frame_number(); | 1165 layer_tree_host_->source_frame_number(); |
| 1161 | 1166 |
| 1162 layer->SetBackgroundColor(background_color_); | 1167 layer->SetBackgroundColor(inputs_.background_color); |
| 1163 layer->SetSafeOpaqueBackgroundColor(safe_opaque_background_color_); | 1168 layer->SetSafeOpaqueBackgroundColor(safe_opaque_background_color_); |
| 1164 layer->SetBounds(use_paint_properties ? paint_properties_.bounds | 1169 layer->SetBounds(use_paint_properties ? paint_properties_.bounds |
| 1165 : bounds_); | 1170 : inputs_.bounds); |
| 1166 | 1171 |
| 1167 #if defined(NDEBUG) | 1172 #if defined(NDEBUG) |
| 1168 if (frame_viewer_instrumentation::IsTracingLayerTreeSnapshots()) | 1173 if (frame_viewer_instrumentation::IsTracingLayerTreeSnapshots()) |
| 1169 layer->SetDebugInfo(TakeDebugInfo()); | 1174 layer->SetDebugInfo(TakeDebugInfo()); |
| 1170 #else | 1175 #else |
| 1171 layer->SetDebugInfo(TakeDebugInfo()); | 1176 layer->SetDebugInfo(TakeDebugInfo()); |
| 1172 #endif | 1177 #endif |
| 1173 | 1178 |
| 1174 layer->SetTransformTreeIndex(transform_tree_index()); | 1179 layer->SetTransformTreeIndex(transform_tree_index()); |
| 1175 layer->SetEffectTreeIndex(effect_tree_index()); | 1180 layer->SetEffectTreeIndex(effect_tree_index()); |
| 1176 layer->SetClipTreeIndex(clip_tree_index()); | 1181 layer->SetClipTreeIndex(clip_tree_index()); |
| 1177 layer->SetScrollTreeIndex(scroll_tree_index()); | 1182 layer->SetScrollTreeIndex(scroll_tree_index()); |
| 1178 layer->set_offset_to_transform_parent(offset_to_transform_parent_); | 1183 layer->set_offset_to_transform_parent(offset_to_transform_parent_); |
| 1179 layer->SetDrawsContent(DrawsContent()); | 1184 layer->SetDrawsContent(DrawsContent()); |
| 1180 // subtree_property_changed_ is propagated to all descendants while building | 1185 // subtree_property_changed_ is propagated to all descendants while building |
| 1181 // property trees. So, it is enough to check it only for the current layer. | 1186 // property trees. So, it is enough to check it only for the current layer. |
| 1182 if (subtree_property_changed_ || layer_property_changed_) | 1187 if (subtree_property_changed_ || layer_property_changed_) |
| 1183 layer->NoteLayerPropertyChanged(); | 1188 layer->NoteLayerPropertyChanged(); |
| 1184 if (!FilterIsAnimating()) | 1189 if (!FilterIsAnimating()) |
| 1185 layer->SetFilters(filters_); | 1190 layer->SetFilters(inputs_.filters); |
| 1186 layer->SetMasksToBounds(masks_to_bounds_); | 1191 layer->SetMasksToBounds(inputs_.masks_to_bounds); |
| 1187 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 1192 layer->set_main_thread_scrolling_reasons( |
| 1188 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 1193 inputs_.main_thread_scrolling_reasons); |
| 1189 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 1194 layer->SetNonFastScrollableRegion(inputs_.non_fast_scrollable_region); |
| 1190 layer->SetContentsOpaque(contents_opaque_); | 1195 layer->SetTouchEventHandlerRegion(inputs_.touch_event_handler_region); |
| 1191 layer->SetBlendMode(blend_mode_); | 1196 layer->SetContentsOpaque(inputs_.contents_opaque); |
| 1192 layer->SetPosition(position_); | 1197 layer->SetBlendMode(inputs_.blend_mode); |
| 1198 layer->SetPosition(inputs_.position); |
| 1193 layer->set_should_flatten_transform_from_property_tree( | 1199 layer->set_should_flatten_transform_from_property_tree( |
| 1194 should_flatten_transform_from_property_tree_); | 1200 should_flatten_transform_from_property_tree_); |
| 1195 layer->set_draw_blend_mode(draw_blend_mode_); | 1201 layer->set_draw_blend_mode(draw_blend_mode_); |
| 1196 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 1202 layer->SetUseParentBackfaceVisibility(inputs_.use_parent_backface_visibility); |
| 1197 layer->SetUseLocalTransformForBackfaceVisibility( | 1203 layer->SetUseLocalTransformForBackfaceVisibility( |
| 1198 use_local_transform_for_backface_visibility_); | 1204 use_local_transform_for_backface_visibility_); |
| 1199 layer->SetShouldCheckBackfaceVisibility(should_check_backface_visibility_); | 1205 layer->SetShouldCheckBackfaceVisibility(should_check_backface_visibility_); |
| 1200 if (!TransformIsAnimating()) | 1206 if (!TransformIsAnimating()) |
| 1201 layer->SetTransform(transform_); | 1207 layer->SetTransform(inputs_.transform); |
| 1202 layer->Set3dSortingContextId(sorting_context_id_); | 1208 layer->Set3dSortingContextId(inputs_.sorting_context_id); |
| 1203 | 1209 |
| 1204 layer->SetScrollClipLayer(scroll_clip_layer_id_); | 1210 layer->SetScrollClipLayer(inputs_.scroll_clip_layer_id); |
| 1205 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 1211 layer->set_user_scrollable_horizontal(inputs_.user_scrollable_horizontal); |
| 1206 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 1212 layer->set_user_scrollable_vertical(inputs_.user_scrollable_vertical); |
| 1207 layer->SetElementId(element_id_); | 1213 layer->SetElementId(inputs_.element_id); |
| 1208 layer->SetMutableProperties(mutable_properties_); | 1214 layer->SetMutableProperties(inputs_.mutable_properties); |
| 1209 | 1215 |
| 1210 // When a scroll offset animation is interrupted the new scroll position on | 1216 // When a scroll offset animation is interrupted the new scroll position on |
| 1211 // the pending tree will clobber any impl-side scrolling occuring on the | 1217 // the pending tree will clobber any impl-side scrolling occuring on the |
| 1212 // active tree. To do so, avoid scrolling the pending tree along with it | 1218 // active tree. To do so, avoid scrolling the pending tree along with it |
| 1213 // instead of trying to undo that scrolling later. | 1219 // instead of trying to undo that scrolling later. |
| 1214 if (ScrollOffsetAnimationWasInterrupted()) | 1220 if (ScrollOffsetAnimationWasInterrupted()) |
| 1215 layer_tree_host() | 1221 layer_tree_host() |
| 1216 ->property_trees() | 1222 ->property_trees() |
| 1217 ->scroll_tree.SetScrollOffsetClobberActiveValue(layer->id()); | 1223 ->scroll_tree.SetScrollOffsetClobberActiveValue(layer->id()); |
| 1218 | 1224 |
| 1219 // If the main thread commits multiple times before the impl thread actually | 1225 // If the main thread commits multiple times before the impl thread actually |
| 1220 // draws, then damage tracking will become incorrect if we simply clobber the | 1226 // draws, then damage tracking will become incorrect if we simply clobber the |
| 1221 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 1227 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
| 1222 // union) any update changes that have occurred on the main thread. | 1228 // union) any update changes that have occurred on the main thread. |
| 1223 update_rect_.Union(layer->update_rect()); | 1229 inputs_.update_rect.Union(layer->update_rect()); |
| 1224 layer->SetUpdateRect(update_rect_); | 1230 layer->SetUpdateRect(inputs_.update_rect); |
| 1225 | 1231 |
| 1226 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); | 1232 layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); |
| 1227 layer->SetNeedsPushProperties(); | 1233 layer->SetNeedsPushProperties(); |
| 1228 | 1234 |
| 1229 // Reset any state that should be cleared for the next update. | 1235 // Reset any state that should be cleared for the next update. |
| 1230 subtree_property_changed_ = false; | 1236 subtree_property_changed_ = false; |
| 1231 layer_property_changed_ = false; | 1237 layer_property_changed_ = false; |
| 1232 update_rect_ = gfx::Rect(); | 1238 inputs_.update_rect = gfx::Rect(); |
| 1233 | 1239 |
| 1234 layer_tree_host()->RemoveLayerShouldPushProperties(this); | 1240 layer_tree_host()->RemoveLayerShouldPushProperties(this); |
| 1235 } | 1241 } |
| 1236 | 1242 |
| 1237 void Layer::TakeCopyRequests( | 1243 void Layer::TakeCopyRequests( |
| 1238 std::vector<std::unique_ptr<CopyOutputRequest>>* requests) { | 1244 std::vector<std::unique_ptr<CopyOutputRequest>>* requests) { |
| 1239 for (auto& it : copy_requests_) { | 1245 for (auto& it : inputs_.copy_requests) { |
| 1240 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 1246 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
| 1241 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); | 1247 layer_tree_host()->task_runner_provider()->MainThreadTaskRunner(); |
| 1242 std::unique_ptr<CopyOutputRequest> original_request = std::move(it); | 1248 std::unique_ptr<CopyOutputRequest> original_request = std::move(it); |
| 1243 const CopyOutputRequest& original_request_ref = *original_request; | 1249 const CopyOutputRequest& original_request_ref = *original_request; |
| 1244 std::unique_ptr<CopyOutputRequest> main_thread_request = | 1250 std::unique_ptr<CopyOutputRequest> main_thread_request = |
| 1245 CopyOutputRequest::CreateRelayRequest( | 1251 CopyOutputRequest::CreateRelayRequest( |
| 1246 original_request_ref, | 1252 original_request_ref, |
| 1247 base::Bind(&PostCopyCallbackToMainThread, main_thread_task_runner, | 1253 base::Bind(&PostCopyCallbackToMainThread, main_thread_task_runner, |
| 1248 base::Passed(&original_request))); | 1254 base::Passed(&original_request))); |
| 1249 if (main_thread_request->has_area()) { | 1255 if (main_thread_request->has_area()) { |
| 1250 main_thread_request->set_area(gfx::IntersectRects( | 1256 main_thread_request->set_area(gfx::IntersectRects( |
| 1251 main_thread_request->area(), gfx::Rect(bounds()))); | 1257 main_thread_request->area(), gfx::Rect(bounds()))); |
| 1252 } | 1258 } |
| 1253 requests->push_back(std::move(main_thread_request)); | 1259 requests->push_back(std::move(main_thread_request)); |
| 1254 } | 1260 } |
| 1255 | 1261 |
| 1256 copy_requests_.clear(); | 1262 inputs_.copy_requests.clear(); |
| 1257 } | 1263 } |
| 1258 | 1264 |
| 1259 void Layer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { | 1265 void Layer::SetTypeForProtoSerialization(proto::LayerNode* proto) const { |
| 1260 proto->set_type(proto::LayerNode::LAYER); | 1266 proto->set_type(proto::LayerNode::LAYER); |
| 1261 } | 1267 } |
| 1262 | 1268 |
| 1263 void Layer::ToLayerNodeProto(proto::LayerNode* proto) const { | 1269 void Layer::ToLayerNodeProto(proto::LayerNode* proto) const { |
| 1264 proto->set_id(layer_id_); | 1270 proto->set_id(inputs_.layer_id); |
| 1265 SetTypeForProtoSerialization(proto); | 1271 SetTypeForProtoSerialization(proto); |
| 1266 | 1272 |
| 1267 if (parent_) | 1273 if (parent_) |
| 1268 proto->set_parent_id(parent_->id()); | 1274 proto->set_parent_id(parent_->id()); |
| 1269 | 1275 |
| 1270 DCHECK_EQ(0, proto->children_size()); | 1276 DCHECK_EQ(0, proto->children_size()); |
| 1271 for (const auto& child : children_) { | 1277 for (const auto& child : inputs_.children) { |
| 1272 child->ToLayerNodeProto(proto->add_children()); | 1278 child->ToLayerNodeProto(proto->add_children()); |
| 1273 } | 1279 } |
| 1274 | 1280 |
| 1275 if (mask_layer_) | 1281 if (inputs_.mask_layer) |
| 1276 mask_layer_->ToLayerNodeProto(proto->mutable_mask_layer()); | 1282 inputs_.mask_layer->ToLayerNodeProto(proto->mutable_mask_layer()); |
| 1277 if (replica_layer_) | 1283 if (inputs_.replica_layer) |
| 1278 replica_layer_->ToLayerNodeProto(proto->mutable_replica_layer()); | 1284 inputs_.replica_layer->ToLayerNodeProto(proto->mutable_replica_layer()); |
| 1279 } | 1285 } |
| 1280 | 1286 |
| 1281 void Layer::ClearLayerTreePropertiesForDeserializationAndAddToMap( | 1287 void Layer::ClearLayerTreePropertiesForDeserializationAndAddToMap( |
| 1282 LayerIdMap* layer_map) { | 1288 LayerIdMap* layer_map) { |
| 1283 (*layer_map)[layer_id_] = this; | 1289 (*layer_map)[inputs_.layer_id] = this; |
| 1284 | 1290 |
| 1285 if (layer_tree_host_) | 1291 if (layer_tree_host_) |
| 1286 layer_tree_host_->UnregisterLayer(this); | 1292 layer_tree_host_->UnregisterLayer(this); |
| 1287 | 1293 |
| 1288 layer_tree_host_ = nullptr; | 1294 layer_tree_host_ = nullptr; |
| 1289 parent_ = nullptr; | 1295 parent_ = nullptr; |
| 1290 | 1296 |
| 1291 // Clear these properties for all the children and add them to the map. | 1297 // Clear these properties for all the children and add them to the map. |
| 1292 for (auto& child : children_) { | 1298 for (auto& child : inputs_.children) { |
| 1293 child->ClearLayerTreePropertiesForDeserializationAndAddToMap(layer_map); | 1299 child->ClearLayerTreePropertiesForDeserializationAndAddToMap(layer_map); |
| 1294 } | 1300 } |
| 1295 | 1301 |
| 1296 children_.clear(); | 1302 inputs_.children.clear(); |
| 1297 | 1303 |
| 1298 if (mask_layer_) { | 1304 if (inputs_.mask_layer) { |
| 1299 mask_layer_->ClearLayerTreePropertiesForDeserializationAndAddToMap( | 1305 inputs_.mask_layer->ClearLayerTreePropertiesForDeserializationAndAddToMap( |
| 1300 layer_map); | 1306 layer_map); |
| 1301 mask_layer_ = nullptr; | 1307 inputs_.mask_layer = nullptr; |
| 1302 } | 1308 } |
| 1303 | 1309 |
| 1304 if (replica_layer_) { | 1310 if (inputs_.replica_layer) { |
| 1305 replica_layer_->ClearLayerTreePropertiesForDeserializationAndAddToMap( | 1311 inputs_.replica_layer |
| 1306 layer_map); | 1312 ->ClearLayerTreePropertiesForDeserializationAndAddToMap(layer_map); |
| 1307 replica_layer_ = nullptr; | 1313 inputs_.replica_layer = nullptr; |
| 1308 } | 1314 } |
| 1309 } | 1315 } |
| 1310 | 1316 |
| 1311 void Layer::FromLayerNodeProto(const proto::LayerNode& proto, | 1317 void Layer::FromLayerNodeProto(const proto::LayerNode& proto, |
| 1312 const LayerIdMap& layer_map, | 1318 const LayerIdMap& layer_map, |
| 1313 LayerTreeHost* layer_tree_host) { | 1319 LayerTreeHost* layer_tree_host) { |
| 1314 DCHECK(!layer_tree_host_); | 1320 DCHECK(!layer_tree_host_); |
| 1315 DCHECK(children_.empty()); | 1321 DCHECK(inputs_.children.empty()); |
| 1316 DCHECK(!mask_layer_); | 1322 DCHECK(!inputs_.mask_layer); |
| 1317 DCHECK(!replica_layer_); | 1323 DCHECK(!inputs_.replica_layer); |
| 1318 DCHECK(layer_tree_host); | 1324 DCHECK(layer_tree_host); |
| 1319 DCHECK(proto.has_id()); | 1325 DCHECK(proto.has_id()); |
| 1320 | 1326 |
| 1321 layer_id_ = proto.id(); | 1327 inputs_.layer_id = proto.id(); |
| 1322 | 1328 |
| 1323 layer_tree_host_ = layer_tree_host; | 1329 layer_tree_host_ = layer_tree_host; |
| 1324 layer_tree_host_->RegisterLayer(this); | 1330 layer_tree_host_->RegisterLayer(this); |
| 1325 | 1331 |
| 1326 for (int i = 0; i < proto.children_size(); ++i) { | 1332 for (int i = 0; i < proto.children_size(); ++i) { |
| 1327 const proto::LayerNode& child_proto = proto.children(i); | 1333 const proto::LayerNode& child_proto = proto.children(i); |
| 1328 DCHECK(child_proto.has_type()); | 1334 DCHECK(child_proto.has_type()); |
| 1329 scoped_refptr<Layer> child = | 1335 scoped_refptr<Layer> child = |
| 1330 LayerProtoConverter::FindOrAllocateAndConstruct(child_proto, layer_map); | 1336 LayerProtoConverter::FindOrAllocateAndConstruct(child_proto, layer_map); |
| 1331 // The child must now refer to this layer as its parent, and must also have | 1337 // The child must now refer to this layer as its parent, and must also have |
| 1332 // the same LayerTreeHost. This must be done before deserializing children. | 1338 // the same LayerTreeHost. This must be done before deserializing children. |
| 1333 DCHECK(!child->parent_); | 1339 DCHECK(!child->parent_); |
| 1334 child->parent_ = this; | 1340 child->parent_ = this; |
| 1335 child->FromLayerNodeProto(child_proto, layer_map, layer_tree_host_); | 1341 child->FromLayerNodeProto(child_proto, layer_map, layer_tree_host_); |
| 1336 children_.push_back(child); | 1342 inputs_.children.push_back(child); |
| 1337 } | 1343 } |
| 1338 | 1344 |
| 1339 if (proto.has_mask_layer()) { | 1345 if (proto.has_mask_layer()) { |
| 1340 mask_layer_ = LayerProtoConverter::FindOrAllocateAndConstruct( | 1346 inputs_.mask_layer = LayerProtoConverter::FindOrAllocateAndConstruct( |
| 1341 proto.mask_layer(), layer_map); | 1347 proto.mask_layer(), layer_map); |
| 1342 mask_layer_->parent_ = this; | 1348 inputs_.mask_layer->parent_ = this; |
| 1343 mask_layer_->FromLayerNodeProto(proto.mask_layer(), layer_map, | 1349 inputs_.mask_layer->FromLayerNodeProto(proto.mask_layer(), layer_map, |
| 1344 layer_tree_host_); | 1350 layer_tree_host_); |
| 1345 } | 1351 } |
| 1346 | 1352 |
| 1347 if (proto.has_replica_layer()) { | 1353 if (proto.has_replica_layer()) { |
| 1348 replica_layer_ = LayerProtoConverter::FindOrAllocateAndConstruct( | 1354 inputs_.replica_layer = LayerProtoConverter::FindOrAllocateAndConstruct( |
| 1349 proto.replica_layer(), layer_map); | 1355 proto.replica_layer(), layer_map); |
| 1350 replica_layer_->parent_ = this; | 1356 inputs_.replica_layer->parent_ = this; |
| 1351 replica_layer_->FromLayerNodeProto(proto.replica_layer(), layer_map, | 1357 inputs_.replica_layer->FromLayerNodeProto(proto.replica_layer(), layer_map, |
| 1352 layer_tree_host_); | 1358 layer_tree_host_); |
| 1353 } | 1359 } |
| 1354 } | 1360 } |
| 1355 | 1361 |
| 1356 void Layer::ToLayerPropertiesProto(proto::LayerUpdate* layer_update) { | 1362 void Layer::ToLayerPropertiesProto(proto::LayerUpdate* layer_update) { |
| 1357 // Always set properties metadata for serialized layers. | 1363 // Always set properties metadata for serialized layers. |
| 1358 proto::LayerProperties* proto = layer_update->add_layers(); | 1364 proto::LayerProperties* proto = layer_update->add_layers(); |
| 1359 proto->set_id(layer_id_); | 1365 proto->set_id(inputs_.layer_id); |
| 1360 LayerSpecificPropertiesToProto(proto); | 1366 LayerSpecificPropertiesToProto(proto); |
| 1361 } | 1367 } |
| 1362 | 1368 |
| 1363 void Layer::FromLayerPropertiesProto(const proto::LayerProperties& proto) { | 1369 void Layer::FromLayerPropertiesProto(const proto::LayerProperties& proto) { |
| 1364 DCHECK(proto.has_id()); | 1370 DCHECK(proto.has_id()); |
| 1365 DCHECK_EQ(layer_id_, proto.id()); | 1371 DCHECK_EQ(inputs_.layer_id, proto.id()); |
| 1366 FromLayerSpecificPropertiesProto(proto); | 1372 FromLayerSpecificPropertiesProto(proto); |
| 1367 } | 1373 } |
| 1368 | 1374 |
| 1369 void Layer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto) { | 1375 void Layer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto) { |
| 1370 proto::BaseLayerProperties* base = proto->mutable_base(); | 1376 proto::BaseLayerProperties* base = proto->mutable_base(); |
| 1371 | 1377 |
| 1372 bool use_paint_properties = layer_tree_host_ && | 1378 bool use_paint_properties = layer_tree_host_ && |
| 1373 paint_properties_.source_frame_number == | 1379 paint_properties_.source_frame_number == |
| 1374 layer_tree_host_->source_frame_number(); | 1380 layer_tree_host_->source_frame_number(); |
| 1375 | 1381 |
| 1376 Point3FToProto(transform_origin_, base->mutable_transform_origin()); | 1382 Point3FToProto(inputs_.transform_origin, base->mutable_transform_origin()); |
| 1377 base->set_background_color(background_color_); | 1383 base->set_background_color(inputs_.background_color); |
| 1378 base->set_safe_opaque_background_color(safe_opaque_background_color_); | 1384 base->set_safe_opaque_background_color(safe_opaque_background_color_); |
| 1379 SizeToProto(use_paint_properties ? paint_properties_.bounds : bounds_, | 1385 SizeToProto(use_paint_properties ? paint_properties_.bounds : inputs_.bounds, |
| 1380 base->mutable_bounds()); | 1386 base->mutable_bounds()); |
| 1381 | 1387 |
| 1382 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. | 1388 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. |
| 1383 | 1389 |
| 1384 base->set_transform_free_index(transform_tree_index_); | 1390 base->set_transform_free_index(transform_tree_index_); |
| 1385 base->set_effect_tree_index(effect_tree_index_); | 1391 base->set_effect_tree_index(effect_tree_index_); |
| 1386 base->set_clip_tree_index(clip_tree_index_); | 1392 base->set_clip_tree_index(clip_tree_index_); |
| 1387 base->set_scroll_tree_index(scroll_tree_index_); | 1393 base->set_scroll_tree_index(scroll_tree_index_); |
| 1388 Vector2dFToProto(offset_to_transform_parent_, | 1394 Vector2dFToProto(offset_to_transform_parent_, |
| 1389 base->mutable_offset_to_transform_parent()); | 1395 base->mutable_offset_to_transform_parent()); |
| 1390 base->set_double_sided(double_sided_); | 1396 base->set_double_sided(inputs_.double_sided); |
| 1391 base->set_draws_content(draws_content_); | 1397 base->set_draws_content(draws_content_); |
| 1392 base->set_hide_layer_and_subtree(hide_layer_and_subtree_); | 1398 base->set_hide_layer_and_subtree(inputs_.hide_layer_and_subtree); |
| 1393 base->set_subtree_property_changed(subtree_property_changed_); | 1399 base->set_subtree_property_changed(subtree_property_changed_); |
| 1394 base->set_layer_property_changed(layer_property_changed_); | 1400 base->set_layer_property_changed(layer_property_changed_); |
| 1395 | 1401 |
| 1396 // TODO(nyquist): Add support for serializing FilterOperations for | 1402 // TODO(nyquist): Add support for serializing FilterOperations for |
| 1397 // |filters_| and |background_filters_|. See crbug.com/541321. | 1403 // |filters_| and |background_filters_|. See crbug.com/541321. |
| 1398 | 1404 |
| 1399 base->set_masks_to_bounds(masks_to_bounds_); | 1405 base->set_masks_to_bounds(inputs_.masks_to_bounds); |
| 1400 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 1406 base->set_main_thread_scrolling_reasons( |
| 1401 RegionToProto(non_fast_scrollable_region_, | 1407 inputs_.main_thread_scrolling_reasons); |
| 1408 RegionToProto(inputs_.non_fast_scrollable_region, |
| 1402 base->mutable_non_fast_scrollable_region()); | 1409 base->mutable_non_fast_scrollable_region()); |
| 1403 RegionToProto(touch_event_handler_region_, | 1410 RegionToProto(inputs_.touch_event_handler_region, |
| 1404 base->mutable_touch_event_handler_region()); | 1411 base->mutable_touch_event_handler_region()); |
| 1405 base->set_contents_opaque(contents_opaque_); | 1412 base->set_contents_opaque(inputs_.contents_opaque); |
| 1406 base->set_opacity(opacity_); | 1413 base->set_opacity(inputs_.opacity); |
| 1407 base->set_blend_mode(SkXfermodeModeToProto(blend_mode_)); | 1414 base->set_blend_mode(SkXfermodeModeToProto(inputs_.blend_mode)); |
| 1408 base->set_is_root_for_isolated_group(is_root_for_isolated_group_); | 1415 base->set_is_root_for_isolated_group(inputs_.is_root_for_isolated_group); |
| 1409 PointFToProto(position_, base->mutable_position()); | 1416 PointFToProto(inputs_.position, base->mutable_position()); |
| 1410 base->set_is_container_for_fixed_position_layers( | 1417 base->set_is_container_for_fixed_position_layers( |
| 1411 is_container_for_fixed_position_layers_); | 1418 inputs_.is_container_for_fixed_position_layers); |
| 1412 position_constraint_.ToProtobuf(base->mutable_position_constraint()); | 1419 inputs_.position_constraint.ToProtobuf(base->mutable_position_constraint()); |
| 1413 base->set_should_flatten_transform(should_flatten_transform_); | 1420 base->set_should_flatten_transform(inputs_.should_flatten_transform); |
| 1414 base->set_should_flatten_transform_from_property_tree( | 1421 base->set_should_flatten_transform_from_property_tree( |
| 1415 should_flatten_transform_from_property_tree_); | 1422 should_flatten_transform_from_property_tree_); |
| 1416 base->set_draw_blend_mode(SkXfermodeModeToProto(draw_blend_mode_)); | 1423 base->set_draw_blend_mode(SkXfermodeModeToProto(draw_blend_mode_)); |
| 1417 base->set_use_parent_backface_visibility(use_parent_backface_visibility_); | 1424 base->set_use_parent_backface_visibility( |
| 1418 TransformToProto(transform_, base->mutable_transform()); | 1425 inputs_.use_parent_backface_visibility); |
| 1419 base->set_sorting_context_id(sorting_context_id_); | 1426 TransformToProto(inputs_.transform, base->mutable_transform()); |
| 1427 base->set_sorting_context_id(inputs_.sorting_context_id); |
| 1420 base->set_num_descendants_that_draw_content( | 1428 base->set_num_descendants_that_draw_content( |
| 1421 num_descendants_that_draw_content_); | 1429 num_descendants_that_draw_content_); |
| 1422 | 1430 |
| 1423 base->set_scroll_clip_layer_id(scroll_clip_layer_id_); | 1431 base->set_scroll_clip_layer_id(inputs_.scroll_clip_layer_id); |
| 1424 base->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 1432 base->set_user_scrollable_horizontal(inputs_.user_scrollable_horizontal); |
| 1425 base->set_user_scrollable_vertical(user_scrollable_vertical_); | 1433 base->set_user_scrollable_vertical(inputs_.user_scrollable_vertical); |
| 1426 | 1434 |
| 1427 int scroll_parent_id = scroll_parent_ ? scroll_parent_->id() : INVALID_ID; | 1435 int scroll_parent_id = |
| 1436 inputs_.scroll_parent ? inputs_.scroll_parent->id() : INVALID_ID; |
| 1428 base->set_scroll_parent_id(scroll_parent_id); | 1437 base->set_scroll_parent_id(scroll_parent_id); |
| 1429 | 1438 |
| 1430 if (scroll_children_) { | 1439 if (scroll_children_) { |
| 1431 for (auto* child : *scroll_children_) | 1440 for (auto* child : *scroll_children_) |
| 1432 base->add_scroll_children_ids(child->id()); | 1441 base->add_scroll_children_ids(child->id()); |
| 1433 } | 1442 } |
| 1434 | 1443 |
| 1435 int clip_parent_id = clip_parent_ ? clip_parent_->id() : INVALID_ID; | 1444 int clip_parent_id = |
| 1445 inputs_.clip_parent ? inputs_.clip_parent->id() : INVALID_ID; |
| 1436 base->set_clip_parent_id(clip_parent_id); | 1446 base->set_clip_parent_id(clip_parent_id); |
| 1437 | 1447 |
| 1438 if (clip_children_) { | 1448 if (clip_children_) { |
| 1439 for (auto* child : *clip_children_) | 1449 for (auto* child : *clip_children_) |
| 1440 base->add_clip_children_ids(child->id()); | 1450 base->add_clip_children_ids(child->id()); |
| 1441 } | 1451 } |
| 1442 | 1452 |
| 1443 ScrollOffsetToProto(scroll_offset_, base->mutable_scroll_offset()); | 1453 ScrollOffsetToProto(inputs_.scroll_offset, base->mutable_scroll_offset()); |
| 1444 | 1454 |
| 1445 // TODO(nyquist): Figure out what to do with CopyRequests. | 1455 // TODO(nyquist): Figure out what to do with CopyRequests. |
| 1446 // See crbug.com/570374. | 1456 // See crbug.com/570374. |
| 1447 | 1457 |
| 1448 RectToProto(update_rect_, base->mutable_update_rect()); | 1458 RectToProto(inputs_.update_rect, base->mutable_update_rect()); |
| 1449 | 1459 |
| 1450 // TODO(nyquist): Figure out what to do with ElementAnimations. | 1460 // TODO(nyquist): Figure out what to do with ElementAnimations. |
| 1451 // See crbug.com/570376. | 1461 // See crbug.com/570376. |
| 1452 | 1462 |
| 1453 update_rect_ = gfx::Rect(); | 1463 inputs_.update_rect = gfx::Rect(); |
| 1454 | 1464 |
| 1455 base->set_has_will_change_transform_hint(has_will_change_transform_hint_); | 1465 base->set_has_will_change_transform_hint( |
| 1466 inputs_.has_will_change_transform_hint); |
| 1456 } | 1467 } |
| 1457 | 1468 |
| 1458 void Layer::FromLayerSpecificPropertiesProto( | 1469 void Layer::FromLayerSpecificPropertiesProto( |
| 1459 const proto::LayerProperties& proto) { | 1470 const proto::LayerProperties& proto) { |
| 1460 DCHECK(proto.has_base()); | 1471 DCHECK(proto.has_base()); |
| 1461 DCHECK(layer_tree_host_); | 1472 DCHECK(layer_tree_host_); |
| 1462 const proto::BaseLayerProperties& base = proto.base(); | 1473 const proto::BaseLayerProperties& base = proto.base(); |
| 1463 | 1474 |
| 1464 transform_origin_ = ProtoToPoint3F(base.transform_origin()); | 1475 inputs_.transform_origin = ProtoToPoint3F(base.transform_origin()); |
| 1465 background_color_ = base.background_color(); | 1476 inputs_.background_color = base.background_color(); |
| 1466 safe_opaque_background_color_ = base.safe_opaque_background_color(); | 1477 safe_opaque_background_color_ = base.safe_opaque_background_color(); |
| 1467 bounds_ = ProtoToSize(base.bounds()); | 1478 inputs_.bounds = ProtoToSize(base.bounds()); |
| 1468 | 1479 |
| 1469 transform_tree_index_ = base.transform_free_index(); | 1480 transform_tree_index_ = base.transform_free_index(); |
| 1470 effect_tree_index_ = base.effect_tree_index(); | 1481 effect_tree_index_ = base.effect_tree_index(); |
| 1471 clip_tree_index_ = base.clip_tree_index(); | 1482 clip_tree_index_ = base.clip_tree_index(); |
| 1472 scroll_tree_index_ = base.scroll_tree_index(); | 1483 scroll_tree_index_ = base.scroll_tree_index(); |
| 1473 offset_to_transform_parent_ = | 1484 offset_to_transform_parent_ = |
| 1474 ProtoToVector2dF(base.offset_to_transform_parent()); | 1485 ProtoToVector2dF(base.offset_to_transform_parent()); |
| 1475 double_sided_ = base.double_sided(); | 1486 inputs_.double_sided = base.double_sided(); |
| 1476 draws_content_ = base.draws_content(); | 1487 draws_content_ = base.draws_content(); |
| 1477 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); | 1488 inputs_.hide_layer_and_subtree = base.hide_layer_and_subtree(); |
| 1478 subtree_property_changed_ = base.subtree_property_changed(); | 1489 subtree_property_changed_ = base.subtree_property_changed(); |
| 1479 layer_property_changed_ = base.layer_property_changed(); | 1490 layer_property_changed_ = base.layer_property_changed(); |
| 1480 masks_to_bounds_ = base.masks_to_bounds(); | 1491 inputs_.masks_to_bounds = base.masks_to_bounds(); |
| 1481 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); | 1492 inputs_.main_thread_scrolling_reasons = base.main_thread_scrolling_reasons(); |
| 1482 non_fast_scrollable_region_ = | 1493 inputs_.non_fast_scrollable_region = |
| 1483 RegionFromProto(base.non_fast_scrollable_region()); | 1494 RegionFromProto(base.non_fast_scrollable_region()); |
| 1484 touch_event_handler_region_ = | 1495 inputs_.touch_event_handler_region = |
| 1485 RegionFromProto(base.touch_event_handler_region()); | 1496 RegionFromProto(base.touch_event_handler_region()); |
| 1486 contents_opaque_ = base.contents_opaque(); | 1497 inputs_.contents_opaque = base.contents_opaque(); |
| 1487 opacity_ = base.opacity(); | 1498 inputs_.opacity = base.opacity(); |
| 1488 blend_mode_ = SkXfermodeModeFromProto(base.blend_mode()); | 1499 inputs_.blend_mode = SkXfermodeModeFromProto(base.blend_mode()); |
| 1489 is_root_for_isolated_group_ = base.is_root_for_isolated_group(); | 1500 inputs_.is_root_for_isolated_group = base.is_root_for_isolated_group(); |
| 1490 position_ = ProtoToPointF(base.position()); | 1501 inputs_.position = ProtoToPointF(base.position()); |
| 1491 is_container_for_fixed_position_layers_ = | 1502 inputs_.is_container_for_fixed_position_layers = |
| 1492 base.is_container_for_fixed_position_layers(); | 1503 base.is_container_for_fixed_position_layers(); |
| 1493 position_constraint_.FromProtobuf(base.position_constraint()); | 1504 inputs_.position_constraint.FromProtobuf(base.position_constraint()); |
| 1494 should_flatten_transform_ = base.should_flatten_transform(); | 1505 inputs_.should_flatten_transform = base.should_flatten_transform(); |
| 1495 should_flatten_transform_from_property_tree_ = | 1506 should_flatten_transform_from_property_tree_ = |
| 1496 base.should_flatten_transform_from_property_tree(); | 1507 base.should_flatten_transform_from_property_tree(); |
| 1497 draw_blend_mode_ = SkXfermodeModeFromProto(base.draw_blend_mode()); | 1508 draw_blend_mode_ = SkXfermodeModeFromProto(base.draw_blend_mode()); |
| 1498 use_parent_backface_visibility_ = base.use_parent_backface_visibility(); | 1509 inputs_.use_parent_backface_visibility = |
| 1499 transform_ = ProtoToTransform(base.transform()); | 1510 base.use_parent_backface_visibility(); |
| 1500 sorting_context_id_ = base.sorting_context_id(); | 1511 inputs_.transform = ProtoToTransform(base.transform()); |
| 1512 inputs_.sorting_context_id = base.sorting_context_id(); |
| 1501 num_descendants_that_draw_content_ = base.num_descendants_that_draw_content(); | 1513 num_descendants_that_draw_content_ = base.num_descendants_that_draw_content(); |
| 1502 | 1514 |
| 1503 scroll_clip_layer_id_ = base.scroll_clip_layer_id(); | 1515 inputs_.scroll_clip_layer_id = base.scroll_clip_layer_id(); |
| 1504 user_scrollable_horizontal_ = base.user_scrollable_horizontal(); | 1516 inputs_.user_scrollable_horizontal = base.user_scrollable_horizontal(); |
| 1505 user_scrollable_vertical_ = base.user_scrollable_vertical(); | 1517 inputs_.user_scrollable_vertical = base.user_scrollable_vertical(); |
| 1506 | 1518 |
| 1507 scroll_parent_ = base.scroll_parent_id() == INVALID_ID | 1519 inputs_.scroll_parent = |
| 1508 ? nullptr | 1520 base.scroll_parent_id() == INVALID_ID |
| 1509 : layer_tree_host_->LayerById(base.scroll_parent_id()); | 1521 ? nullptr |
| 1522 : layer_tree_host_->LayerById(base.scroll_parent_id()); |
| 1510 | 1523 |
| 1511 // If there have been scroll children entries in previous deserializations, | 1524 // If there have been scroll children entries in previous deserializations, |
| 1512 // clear out the set. If there have been none, initialize the set of children. | 1525 // clear out the set. If there have been none, initialize the set of children. |
| 1513 // After this, the set is in the correct state to only add the new children. | 1526 // After this, the set is in the correct state to only add the new children. |
| 1514 // If the set of children has not changed, for now this code still rebuilds | 1527 // If the set of children has not changed, for now this code still rebuilds |
| 1515 // the set. | 1528 // the set. |
| 1516 if (scroll_children_) | 1529 if (scroll_children_) |
| 1517 scroll_children_->clear(); | 1530 scroll_children_->clear(); |
| 1518 else if (base.scroll_children_ids_size() > 0) | 1531 else if (base.scroll_children_ids_size() > 0) |
| 1519 scroll_children_.reset(new std::set<Layer*>); | 1532 scroll_children_.reset(new std::set<Layer*>); |
| 1520 for (int i = 0; i < base.scroll_children_ids_size(); ++i) { | 1533 for (int i = 0; i < base.scroll_children_ids_size(); ++i) { |
| 1521 int child_id = base.scroll_children_ids(i); | 1534 int child_id = base.scroll_children_ids(i); |
| 1522 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id); | 1535 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id); |
| 1523 scroll_children_->insert(child.get()); | 1536 scroll_children_->insert(child.get()); |
| 1524 } | 1537 } |
| 1525 | 1538 |
| 1526 clip_parent_ = base.clip_parent_id() == INVALID_ID | 1539 inputs_.clip_parent = |
| 1527 ? nullptr | 1540 base.clip_parent_id() == INVALID_ID |
| 1528 : layer_tree_host_->LayerById(base.clip_parent_id()); | 1541 ? nullptr |
| 1542 : layer_tree_host_->LayerById(base.clip_parent_id()); |
| 1529 | 1543 |
| 1530 // If there have been clip children entries in previous deserializations, | 1544 // If there have been clip children entries in previous deserializations, |
| 1531 // clear out the set. If there have been none, initialize the set of children. | 1545 // clear out the set. If there have been none, initialize the set of children. |
| 1532 // After this, the set is in the correct state to only add the new children. | 1546 // After this, the set is in the correct state to only add the new children. |
| 1533 // If the set of children has not changed, for now this code still rebuilds | 1547 // If the set of children has not changed, for now this code still rebuilds |
| 1534 // the set. | 1548 // the set. |
| 1535 if (clip_children_) | 1549 if (clip_children_) |
| 1536 clip_children_->clear(); | 1550 clip_children_->clear(); |
| 1537 else if (base.clip_children_ids_size() > 0) | 1551 else if (base.clip_children_ids_size() > 0) |
| 1538 clip_children_.reset(new std::set<Layer*>); | 1552 clip_children_.reset(new std::set<Layer*>); |
| 1539 for (int i = 0; i < base.clip_children_ids_size(); ++i) { | 1553 for (int i = 0; i < base.clip_children_ids_size(); ++i) { |
| 1540 int child_id = base.clip_children_ids(i); | 1554 int child_id = base.clip_children_ids(i); |
| 1541 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id); | 1555 scoped_refptr<Layer> child = layer_tree_host_->LayerById(child_id); |
| 1542 clip_children_->insert(child.get()); | 1556 clip_children_->insert(child.get()); |
| 1543 } | 1557 } |
| 1544 | 1558 |
| 1545 scroll_offset_ = ProtoToScrollOffset(base.scroll_offset()); | 1559 inputs_.scroll_offset = ProtoToScrollOffset(base.scroll_offset()); |
| 1546 | 1560 |
| 1547 update_rect_.Union(ProtoToRect(base.update_rect())); | 1561 inputs_.update_rect.Union(ProtoToRect(base.update_rect())); |
| 1548 | 1562 |
| 1549 has_will_change_transform_hint_ = base.has_will_change_transform_hint(); | 1563 inputs_.has_will_change_transform_hint = |
| 1564 base.has_will_change_transform_hint(); |
| 1550 } | 1565 } |
| 1551 | 1566 |
| 1552 std::unique_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 1567 std::unique_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
| 1553 return LayerImpl::Create(tree_impl, layer_id_); | 1568 return LayerImpl::Create(tree_impl, inputs_.layer_id); |
| 1554 } | 1569 } |
| 1555 | 1570 |
| 1556 bool Layer::DrawsContent() const { | 1571 bool Layer::DrawsContent() const { |
| 1557 return draws_content_; | 1572 return draws_content_; |
| 1558 } | 1573 } |
| 1559 | 1574 |
| 1560 bool Layer::HasDrawableContent() const { | 1575 bool Layer::HasDrawableContent() const { |
| 1561 return is_drawable_; | 1576 return inputs_.is_drawable; |
| 1562 } | 1577 } |
| 1563 | 1578 |
| 1564 void Layer::UpdateDrawsContent(bool has_drawable_content) { | 1579 void Layer::UpdateDrawsContent(bool has_drawable_content) { |
| 1565 bool draws_content = has_drawable_content; | 1580 bool draws_content = has_drawable_content; |
| 1566 DCHECK(is_drawable_ || !has_drawable_content); | 1581 DCHECK(inputs_.is_drawable || !has_drawable_content); |
| 1567 if (draws_content == draws_content_) | 1582 if (draws_content == draws_content_) |
| 1568 return; | 1583 return; |
| 1569 | 1584 |
| 1570 if (parent()) | 1585 if (parent()) |
| 1571 parent()->AddDrawableDescendants(draws_content ? 1 : -1); | 1586 parent()->AddDrawableDescendants(draws_content ? 1 : -1); |
| 1572 | 1587 |
| 1573 draws_content_ = draws_content; | 1588 draws_content_ = draws_content; |
| 1574 SetNeedsCommit(); | 1589 SetNeedsCommit(); |
| 1575 } | 1590 } |
| 1576 | 1591 |
| 1577 int Layer::NumDescendantsThatDrawContent() const { | 1592 int Layer::NumDescendantsThatDrawContent() const { |
| 1578 return num_descendants_that_draw_content_; | 1593 return num_descendants_that_draw_content_; |
| 1579 } | 1594 } |
| 1580 | 1595 |
| 1581 void Layer::SavePaintProperties() { | 1596 void Layer::SavePaintProperties() { |
| 1582 DCHECK(layer_tree_host_); | 1597 DCHECK(layer_tree_host_); |
| 1583 | 1598 |
| 1584 // TODO(reveman): Save all layer properties that we depend on not | 1599 // TODO(reveman): Save all layer properties that we depend on not |
| 1585 // changing until PushProperties() has been called. crbug.com/231016 | 1600 // changing until PushProperties() has been called. crbug.com/231016 |
| 1586 paint_properties_.bounds = bounds_; | 1601 paint_properties_.bounds = inputs_.bounds; |
| 1587 paint_properties_.source_frame_number = | 1602 paint_properties_.source_frame_number = |
| 1588 layer_tree_host_->source_frame_number(); | 1603 layer_tree_host_->source_frame_number(); |
| 1589 } | 1604 } |
| 1590 | 1605 |
| 1591 bool Layer::Update() { | 1606 bool Layer::Update() { |
| 1592 DCHECK(layer_tree_host_); | 1607 DCHECK(layer_tree_host_); |
| 1593 DCHECK_EQ(layer_tree_host_->source_frame_number(), | 1608 DCHECK_EQ(layer_tree_host_->source_frame_number(), |
| 1594 paint_properties_.source_frame_number) << | 1609 paint_properties_.source_frame_number) << |
| 1595 "SavePaintProperties must be called for any layer that is painted."; | 1610 "SavePaintProperties must be called for any layer that is painted."; |
| 1596 return false; | 1611 return false; |
| 1597 } | 1612 } |
| 1598 | 1613 |
| 1599 bool Layer::IsSuitableForGpuRasterization() const { | 1614 bool Layer::IsSuitableForGpuRasterization() const { |
| 1600 return true; | 1615 return true; |
| 1601 } | 1616 } |
| 1602 | 1617 |
| 1603 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 1618 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 1604 Layer::TakeDebugInfo() { | 1619 Layer::TakeDebugInfo() { |
| 1605 if (client_) | 1620 if (inputs_.client) |
| 1606 return client_->TakeDebugInfo(this); | 1621 return inputs_.client->TakeDebugInfo(this); |
| 1607 else | 1622 else |
| 1608 return nullptr; | 1623 return nullptr; |
| 1609 } | 1624 } |
| 1610 | 1625 |
| 1611 void Layer::SetSubtreePropertyChanged() { | 1626 void Layer::SetSubtreePropertyChanged() { |
| 1612 if (subtree_property_changed_) | 1627 if (subtree_property_changed_) |
| 1613 return; | 1628 return; |
| 1614 subtree_property_changed_ = true; | 1629 subtree_property_changed_ = true; |
| 1615 SetNeedsPushProperties(); | 1630 SetNeedsPushProperties(); |
| 1616 } | 1631 } |
| 1617 | 1632 |
| 1618 void Layer::SetLayerPropertyChanged() { | 1633 void Layer::SetLayerPropertyChanged() { |
| 1619 if (layer_property_changed_) | 1634 if (layer_property_changed_) |
| 1620 return; | 1635 return; |
| 1621 layer_property_changed_ = true; | 1636 layer_property_changed_ = true; |
| 1622 SetNeedsPushProperties(); | 1637 SetNeedsPushProperties(); |
| 1623 } | 1638 } |
| 1624 | 1639 |
| 1625 gfx::ScrollOffset Layer::ScrollOffsetForAnimation() const { | 1640 gfx::ScrollOffset Layer::ScrollOffsetForAnimation() const { |
| 1626 return CurrentScrollOffset(); | 1641 return CurrentScrollOffset(); |
| 1627 } | 1642 } |
| 1628 | 1643 |
| 1629 // On<Property>Animated is called due to an ongoing accelerated animation. | 1644 // On<Property>Animated is called due to an ongoing accelerated animation. |
| 1630 // Since this animation is also being run on the compositor thread, there | 1645 // Since this animation is also being run on the compositor thread, there |
| 1631 // is no need to request a commit to push this value over, so the value is | 1646 // is no need to request a commit to push this value over, so the value is |
| 1632 // set directly rather than by calling Set<Property>. | 1647 // set directly rather than by calling Set<Property>. |
| 1633 void Layer::OnFilterAnimated(const FilterOperations& filters) { | 1648 void Layer::OnFilterAnimated(const FilterOperations& filters) { |
| 1634 filters_ = filters; | 1649 inputs_.filters = filters; |
| 1635 } | 1650 } |
| 1636 | 1651 |
| 1637 void Layer::OnOpacityAnimated(float opacity) { | 1652 void Layer::OnOpacityAnimated(float opacity) { |
| 1638 DCHECK_GE(opacity, 0.f); | 1653 DCHECK_GE(opacity, 0.f); |
| 1639 DCHECK_LE(opacity, 1.f); | 1654 DCHECK_LE(opacity, 1.f); |
| 1640 | 1655 |
| 1641 if (opacity_ == opacity) | 1656 if (inputs_.opacity == opacity) |
| 1642 return; | 1657 return; |
| 1643 opacity_ = opacity; | 1658 inputs_.opacity = opacity; |
| 1644 // Changing the opacity may make a previously hidden layer visible, so a new | 1659 // Changing the opacity may make a previously hidden layer visible, so a new |
| 1645 // recording may be needed. | 1660 // recording may be needed. |
| 1646 SetNeedsUpdate(); | 1661 SetNeedsUpdate(); |
| 1647 if (layer_tree_host_) { | 1662 if (layer_tree_host_) { |
| 1648 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 1663 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
| 1649 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, | 1664 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, |
| 1650 id())) { | 1665 id())) { |
| 1651 DCHECK_EQ(effect_tree_index(), | 1666 DCHECK_EQ(effect_tree_index(), |
| 1652 property_trees->effect_id_to_index_map[id()]); | 1667 property_trees->effect_id_to_index_map[id()]); |
| 1653 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); | 1668 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); |
| 1654 node->data.opacity = opacity; | 1669 node->data.opacity = opacity; |
| 1655 property_trees->effect_tree.set_needs_update(true); | 1670 property_trees->effect_tree.set_needs_update(true); |
| 1656 } | 1671 } |
| 1657 } | 1672 } |
| 1658 } | 1673 } |
| 1659 | 1674 |
| 1660 void Layer::OnTransformAnimated(const gfx::Transform& transform) { | 1675 void Layer::OnTransformAnimated(const gfx::Transform& transform) { |
| 1661 if (transform_ == transform) | 1676 if (inputs_.transform == transform) |
| 1662 return; | 1677 return; |
| 1663 transform_ = transform; | 1678 inputs_.transform = transform; |
| 1664 // Changing the transform may change the visible part of this layer, so a new | 1679 // Changing the transform may change the visible part of this layer, so a new |
| 1665 // recording may be needed. | 1680 // recording may be needed. |
| 1666 SetNeedsUpdate(); | 1681 SetNeedsUpdate(); |
| 1667 if (layer_tree_host_) { | 1682 if (layer_tree_host_) { |
| 1668 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 1683 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
| 1669 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, | 1684 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, |
| 1670 id())) { | 1685 id())) { |
| 1671 DCHECK_EQ(transform_tree_index(), | 1686 DCHECK_EQ(transform_tree_index(), |
| 1672 property_trees->transform_id_to_index_map[id()]); | 1687 property_trees->transform_id_to_index_map[id()]); |
| 1673 TransformNode* node = | 1688 TransformNode* node = |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 has_potential_animation || OpacityCanAnimateOnImplThread(); | 1759 has_potential_animation || OpacityCanAnimateOnImplThread(); |
| 1745 property_trees->effect_tree.set_needs_update(true); | 1760 property_trees->effect_tree.set_needs_update(true); |
| 1746 } | 1761 } |
| 1747 | 1762 |
| 1748 bool Layer::HasActiveAnimationForTesting() const { | 1763 bool Layer::HasActiveAnimationForTesting() const { |
| 1749 return layer_tree_host_ ? layer_tree_host_->HasActiveAnimationForTesting(this) | 1764 return layer_tree_host_ ? layer_tree_host_->HasActiveAnimationForTesting(this) |
| 1750 : false; | 1765 : false; |
| 1751 } | 1766 } |
| 1752 | 1767 |
| 1753 void Layer::SetHasWillChangeTransformHint(bool has_will_change) { | 1768 void Layer::SetHasWillChangeTransformHint(bool has_will_change) { |
| 1754 if (has_will_change_transform_hint_ == has_will_change) | 1769 if (inputs_.has_will_change_transform_hint == has_will_change) |
| 1755 return; | 1770 return; |
| 1756 has_will_change_transform_hint_ = has_will_change; | 1771 inputs_.has_will_change_transform_hint = has_will_change; |
| 1757 SetNeedsCommit(); | 1772 SetNeedsCommit(); |
| 1758 } | 1773 } |
| 1759 | 1774 |
| 1760 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { | 1775 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { |
| 1761 return nullptr; | 1776 return nullptr; |
| 1762 } | 1777 } |
| 1763 | 1778 |
| 1764 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { | 1779 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { |
| 1765 return layer_tree_host_->rendering_stats_instrumentation(); | 1780 return layer_tree_host_->rendering_stats_instrumentation(); |
| 1766 } | 1781 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1797 if (parent()) | 1812 if (parent()) |
| 1798 parent()->AddDrawableDescendants(num); | 1813 parent()->AddDrawableDescendants(num); |
| 1799 } | 1814 } |
| 1800 | 1815 |
| 1801 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1816 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 1802 benchmark->RunOnLayer(this); | 1817 benchmark->RunOnLayer(this); |
| 1803 } | 1818 } |
| 1804 | 1819 |
| 1805 void Layer::SetElementId(ElementId id) { | 1820 void Layer::SetElementId(ElementId id) { |
| 1806 DCHECK(IsPropertyChangeAllowed()); | 1821 DCHECK(IsPropertyChangeAllowed()); |
| 1807 if (element_id_ == id) | 1822 if (inputs_.element_id == id) |
| 1808 return; | 1823 return; |
| 1809 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1824 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1810 "Layer::SetElementId", "element", id.AsValue().release()); | 1825 "Layer::SetElementId", "element", id.AsValue().release()); |
| 1811 if (element_id_ && layer_tree_host()) { | 1826 if (inputs_.element_id && layer_tree_host()) { |
| 1812 layer_tree_host()->animation_host()->UnregisterElement( | 1827 layer_tree_host()->animation_host()->UnregisterElement( |
| 1813 element_id_, ElementListType::ACTIVE); | 1828 inputs_.element_id, ElementListType::ACTIVE); |
| 1814 layer_tree_host()->RemoveFromElementMap(this); | 1829 layer_tree_host()->RemoveFromElementMap(this); |
| 1815 } | 1830 } |
| 1816 | 1831 |
| 1817 element_id_ = id; | 1832 inputs_.element_id = id; |
| 1818 | 1833 |
| 1819 if (element_id_ && layer_tree_host()) { | 1834 if (inputs_.element_id && layer_tree_host()) { |
| 1820 layer_tree_host()->animation_host()->RegisterElement( | 1835 layer_tree_host()->animation_host()->RegisterElement( |
| 1821 element_id_, ElementListType::ACTIVE); | 1836 inputs_.element_id, ElementListType::ACTIVE); |
| 1822 layer_tree_host()->AddToElementMap(this); | 1837 layer_tree_host()->AddToElementMap(this); |
| 1823 } | 1838 } |
| 1824 | 1839 |
| 1825 SetNeedsCommit(); | 1840 SetNeedsCommit(); |
| 1826 } | 1841 } |
| 1827 | 1842 |
| 1828 void Layer::SetMutableProperties(uint32_t properties) { | 1843 void Layer::SetMutableProperties(uint32_t properties) { |
| 1829 DCHECK(IsPropertyChangeAllowed()); | 1844 DCHECK(IsPropertyChangeAllowed()); |
| 1830 if (mutable_properties_ == properties) | 1845 if (inputs_.mutable_properties == properties) |
| 1831 return; | 1846 return; |
| 1832 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1847 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1833 "Layer::SetMutableProperties", "properties", properties); | 1848 "Layer::SetMutableProperties", "properties", properties); |
| 1834 mutable_properties_ = properties; | 1849 inputs_.mutable_properties = properties; |
| 1835 SetNeedsCommit(); | 1850 SetNeedsCommit(); |
| 1836 } | 1851 } |
| 1837 | 1852 |
| 1838 void Layer::DidBeginTracing() { | 1853 void Layer::DidBeginTracing() { |
| 1839 // We'll be dumping layer trees as part of trace, so make sure | 1854 // We'll be dumping layer trees as part of trace, so make sure |
| 1840 // PushPropertiesTo() propagates layer debug info to the impl | 1855 // PushPropertiesTo() propagates layer debug info to the impl |
| 1841 // side -- otherwise this won't happen for the the layers that | 1856 // side -- otherwise this won't happen for the the layers that |
| 1842 // remain unchanged since tracing started. | 1857 // remain unchanged since tracing started. |
| 1843 SetNeedsPushProperties(); | 1858 SetNeedsPushProperties(); |
| 1844 } | 1859 } |
| 1845 | 1860 |
| 1846 int Layer::num_copy_requests_in_target_subtree() { | 1861 int Layer::num_copy_requests_in_target_subtree() { |
| 1847 return layer_tree_host() | 1862 return layer_tree_host() |
| 1848 ->property_trees() | 1863 ->property_trees() |
| 1849 ->effect_tree.Node(effect_tree_index()) | 1864 ->effect_tree.Node(effect_tree_index()) |
| 1850 ->data.num_copy_requests_in_subtree; | 1865 ->data.num_copy_requests_in_subtree; |
| 1851 } | 1866 } |
| 1852 | 1867 |
| 1853 gfx::Transform Layer::screen_space_transform() const { | 1868 gfx::Transform Layer::screen_space_transform() const { |
| 1854 DCHECK_NE(transform_tree_index_, -1); | 1869 DCHECK_NE(transform_tree_index_, -1); |
| 1855 return draw_property_utils::ScreenSpaceTransform( | 1870 return draw_property_utils::ScreenSpaceTransform( |
| 1856 this, layer_tree_host_->property_trees()->transform_tree); | 1871 this, layer_tree_host_->property_trees()->transform_tree); |
| 1857 } | 1872 } |
| 1858 | 1873 |
| 1859 } // namespace cc | 1874 } // namespace cc |
| OLD | NEW |