Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: cc/layers/layer.cc

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

Powered by Google App Engine
This is Rietveld 408576698