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
3 // found in the LICENSE file.
5 #include "cc/layers/layer.h"
9 #include "base/atomic_sequence_num.h"
10 #include "base/location.h"
11 #include "base/metrics/histogram.h"
12 #include "base/single_thread_task_runner.h"
13 #include "base/time/time.h"
14 #include "base/trace_event/trace_event.h"
15 #include "cc/animation/animation.h"
16 #include "cc/animation/animation_events.h"
17 #include "cc/animation/animation_registrar.h"
18 #include "cc/animation/keyframed_animation_curve.h"
19 #include "cc/animation/layer_animation_controller.h"
20 #include "cc/base/simple_enclosed_region.h"
21 #include "cc/debug/frame_viewer_instrumentation.h"
22 #include "cc/layers/layer_client.h"
23 #include "cc/layers/layer_impl.h"
24 #include "cc/layers/scrollbar_layer_interface.h"
25 #include "cc/output/copy_output_request.h"
26 #include "cc/output/copy_output_result.h"
27 #include "cc/trees/layer_tree_host.h"
28 #include "cc/trees/layer_tree_impl.h"
29 #include "third_party/skia/include/core/SkImageFilter.h"
30 #include "ui/gfx/geometry/rect_conversions.h"
31 #include "ui/gfx/geometry/vector2d_conversions.h"
35 base::StaticAtomicSequenceNumber g_next_layer_id
;
37 scoped_refptr
<Layer
> Layer::Create() {
38 return make_scoped_refptr(new Layer());
42 : needs_push_properties_(false),
43 num_dependents_need_push_properties_(false),
44 stacking_order_changed_(false),
45 // Layer IDs start from 1.
46 layer_id_(g_next_layer_id
.GetNext() + 1),
47 ignore_set_needs_commit_(false),
48 sorting_context_id_(0),
50 layer_tree_host_(nullptr),
51 scroll_clip_layer_id_(INVALID_ID
),
52 num_descendants_that_draw_content_(0),
53 transform_tree_index_(-1),
54 opacity_tree_index_(-1),
56 should_flatten_transform_from_property_tree_(false),
57 should_scroll_on_main_thread_(false),
58 have_wheel_event_handlers_(false),
59 have_scroll_event_handlers_(false),
60 user_scrollable_horizontal_(true),
61 user_scrollable_vertical_(true),
62 is_root_for_isolated_group_(false),
63 is_container_for_fixed_position_layers_(false),
65 draws_content_(false),
66 hide_layer_and_subtree_(false),
67 masks_to_bounds_(false),
68 contents_opaque_(false),
70 should_flatten_transform_(true),
71 use_parent_backface_visibility_(false),
72 draw_checkerboard_for_missing_tiles_(false),
73 force_render_surface_(false),
74 transform_is_invertible_(true),
75 has_render_surface_(false),
76 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE
),
79 blend_mode_(SkXfermode::kSrcOver_Mode
),
80 scroll_parent_(nullptr),
81 clip_parent_(nullptr),
82 replica_layer_(nullptr),
85 frame_timing_requests_dirty_(false) {
86 layer_animation_controller_
= LayerAnimationController::Create(layer_id_
);
87 layer_animation_controller_
->AddValueObserver(this);
88 layer_animation_controller_
->set_value_provider(this);
92 // Our parent should be holding a reference to us so there should be no
93 // way for us to be destroyed while we still have a parent.
95 // Similarly we shouldn't have a layer tree host since it also keeps a
97 DCHECK(!layer_tree_host());
99 layer_animation_controller_
->RemoveValueObserver(this);
100 layer_animation_controller_
->remove_value_provider(this);
102 RemoveFromScrollTree();
103 RemoveFromClipTree();
105 // Remove the parent reference from all children and dependents.
107 if (mask_layer_
.get()) {
108 DCHECK_EQ(this, mask_layer_
->parent());
109 mask_layer_
->RemoveFromParent();
111 if (replica_layer_
.get()) {
112 DCHECK_EQ(this, replica_layer_
->parent());
113 replica_layer_
->RemoveFromParent();
117 void Layer::SetLayerTreeHost(LayerTreeHost
* host
) {
118 if (layer_tree_host_
== host
)
121 if (layer_tree_host_
)
122 layer_tree_host_
->property_trees()->needs_rebuild
= true;
124 layer_tree_host_
= host
;
126 // When changing hosts, the layer needs to commit its properties to the impl
127 // side for the new host.
128 SetNeedsPushProperties();
130 for (size_t i
= 0; i
< children_
.size(); ++i
)
131 children_
[i
]->SetLayerTreeHost(host
);
133 if (mask_layer_
.get())
134 mask_layer_
->SetLayerTreeHost(host
);
135 if (replica_layer_
.get())
136 replica_layer_
->SetLayerTreeHost(host
);
139 layer_animation_controller_
->SetAnimationRegistrar(
140 host
->animation_registrar());
142 if (host
->settings().layer_transforms_should_scale_layer_contents
)
143 reset_raster_scale_to_unknown();
146 if (host
&& layer_animation_controller_
->has_any_animation())
147 host
->SetNeedsCommit();
150 void Layer::SetNeedsUpdate() {
151 if (layer_tree_host_
&& !ignore_set_needs_commit_
)
152 layer_tree_host_
->SetNeedsUpdateLayers();
155 void Layer::SetNeedsCommit() {
156 if (!layer_tree_host_
)
159 SetNeedsPushProperties();
160 layer_tree_host_
->property_trees()->needs_rebuild
= true;
162 if (ignore_set_needs_commit_
)
165 layer_tree_host_
->SetNeedsCommit();
168 void Layer::SetNeedsCommitNoRebuild() {
169 if (!layer_tree_host_
)
172 SetNeedsPushProperties();
174 if (ignore_set_needs_commit_
)
177 layer_tree_host_
->SetNeedsCommit();
180 void Layer::SetNeedsFullTreeSync() {
181 if (!layer_tree_host_
)
184 layer_tree_host_
->SetNeedsFullTreeSync();
187 void Layer::SetNextCommitWaitsForActivation() {
188 if (!layer_tree_host_
)
191 layer_tree_host_
->SetNextCommitWaitsForActivation();
194 void Layer::SetNeedsPushProperties() {
195 if (needs_push_properties_
)
197 if (!parent_should_know_need_push_properties() && parent_
)
198 parent_
->AddDependentNeedsPushProperties();
199 needs_push_properties_
= true;
202 void Layer::AddDependentNeedsPushProperties() {
203 DCHECK_GE(num_dependents_need_push_properties_
, 0);
205 if (!parent_should_know_need_push_properties() && parent_
)
206 parent_
->AddDependentNeedsPushProperties();
208 num_dependents_need_push_properties_
++;
211 void Layer::RemoveDependentNeedsPushProperties() {
212 num_dependents_need_push_properties_
--;
213 DCHECK_GE(num_dependents_need_push_properties_
, 0);
215 if (!parent_should_know_need_push_properties() && parent_
)
216 parent_
->RemoveDependentNeedsPushProperties();
219 bool Layer::IsPropertyChangeAllowed() const {
220 if (!layer_tree_host_
)
223 if (!layer_tree_host_
->settings().strict_layer_property_change_checking
)
226 return !layer_tree_host_
->in_paint_layer_contents();
229 gfx::Rect
Layer::LayerRectToContentRect(const gfx::Rect
& layer_rect
) const {
230 gfx::Rect content_rect
= gfx::ScaleToEnclosingRect(
231 layer_rect
, contents_scale_x(), contents_scale_y());
232 // Intersect with content rect to avoid the extra pixel because for some
233 // values x and y, ceil((x / y) * y) may be x + 1.
234 content_rect
.Intersect(gfx::Rect(content_bounds()));
238 skia::RefPtr
<SkPicture
> Layer::GetPicture() const {
239 return skia::RefPtr
<SkPicture
>();
242 void Layer::SetParent(Layer
* layer
) {
243 DCHECK(!layer
|| !layer
->HasAncestor(this));
245 if (parent_should_know_need_push_properties()) {
247 parent_
->RemoveDependentNeedsPushProperties();
249 layer
->AddDependentNeedsPushProperties();
253 SetLayerTreeHost(parent_
? parent_
->layer_tree_host() : nullptr);
255 if (!layer_tree_host_
)
257 const LayerTreeSettings
& settings
= layer_tree_host_
->settings();
258 if (!settings
.layer_transforms_should_scale_layer_contents
)
261 reset_raster_scale_to_unknown();
262 if (mask_layer_
.get())
263 mask_layer_
->reset_raster_scale_to_unknown();
264 if (replica_layer_
.get() && replica_layer_
->mask_layer_
.get())
265 replica_layer_
->mask_layer_
->reset_raster_scale_to_unknown();
268 void Layer::AddChild(scoped_refptr
<Layer
> child
) {
269 InsertChild(child
, children_
.size());
272 void Layer::InsertChild(scoped_refptr
<Layer
> child
, size_t index
) {
273 DCHECK(IsPropertyChangeAllowed());
274 child
->RemoveFromParent();
275 AddDrawableDescendants(child
->NumDescendantsThatDrawContent() +
276 (child
->DrawsContent() ? 1 : 0));
277 child
->SetParent(this);
278 child
->stacking_order_changed_
= true;
280 index
= std::min(index
, children_
.size());
281 children_
.insert(children_
.begin() + index
, child
);
282 SetNeedsFullTreeSync();
285 void Layer::RemoveFromParent() {
286 DCHECK(IsPropertyChangeAllowed());
288 parent_
->RemoveChildOrDependent(this);
291 void Layer::RemoveChildOrDependent(Layer
* child
) {
292 if (mask_layer_
.get() == child
) {
293 mask_layer_
->SetParent(nullptr);
294 mask_layer_
= nullptr;
295 SetNeedsFullTreeSync();
298 if (replica_layer_
.get() == child
) {
299 replica_layer_
->SetParent(nullptr);
300 replica_layer_
= nullptr;
301 SetNeedsFullTreeSync();
305 for (LayerList::iterator iter
= children_
.begin();
306 iter
!= children_
.end();
308 if (iter
->get() != child
)
311 child
->SetParent(nullptr);
312 AddDrawableDescendants(-child
->NumDescendantsThatDrawContent() -
313 (child
->DrawsContent() ? 1 : 0));
314 children_
.erase(iter
);
315 SetNeedsFullTreeSync();
320 void Layer::ReplaceChild(Layer
* reference
, scoped_refptr
<Layer
> new_layer
) {
322 DCHECK_EQ(reference
->parent(), this);
323 DCHECK(IsPropertyChangeAllowed());
325 if (reference
== new_layer
.get())
328 int reference_index
= IndexOfChild(reference
);
329 if (reference_index
== -1) {
334 reference
->RemoveFromParent();
336 if (new_layer
.get()) {
337 new_layer
->RemoveFromParent();
338 InsertChild(new_layer
, reference_index
);
342 int Layer::IndexOfChild(const Layer
* reference
) {
343 for (size_t i
= 0; i
< children_
.size(); ++i
) {
344 if (children_
[i
].get() == reference
)
350 void Layer::SetBounds(const gfx::Size
& size
) {
351 DCHECK(IsPropertyChangeAllowed());
352 if (bounds() == size
)
356 if (!layer_tree_host_
)
359 if (ClipNode
* clip_node
= layer_tree_host_
->property_trees()->clip_tree
.Node(
360 clip_tree_index())) {
361 if (clip_node
->owner_id
== id()) {
362 clip_node
->data
.clip
.set_size(size
);
363 layer_tree_host_
->property_trees()->clip_tree
.set_needs_update(true);
367 SetNeedsCommitNoRebuild();
370 Layer
* Layer::RootLayer() {
372 while (layer
->parent())
373 layer
= layer
->parent();
377 void Layer::RemoveAllChildren() {
378 DCHECK(IsPropertyChangeAllowed());
379 while (children_
.size()) {
380 Layer
* layer
= children_
[0].get();
381 DCHECK_EQ(this, layer
->parent());
382 layer
->RemoveFromParent();
386 void Layer::SetChildren(const LayerList
& children
) {
387 DCHECK(IsPropertyChangeAllowed());
388 if (children
== children_
)
392 for (size_t i
= 0; i
< children
.size(); ++i
)
393 AddChild(children
[i
]);
396 bool Layer::HasAncestor(const Layer
* ancestor
) const {
397 for (const Layer
* layer
= parent(); layer
; layer
= layer
->parent()) {
398 if (layer
== ancestor
)
404 void Layer::RequestCopyOfOutput(
405 scoped_ptr
<CopyOutputRequest
> request
) {
406 DCHECK(IsPropertyChangeAllowed());
407 if (void* source
= request
->source()) {
408 auto it
= std::find_if(
409 copy_requests_
.begin(), copy_requests_
.end(),
410 [source
](const CopyOutputRequest
* x
) { return x
->source() == source
; });
411 if (it
!= copy_requests_
.end())
412 copy_requests_
.erase(it
);
414 if (request
->IsEmpty())
416 copy_requests_
.push_back(request
.Pass());
420 void Layer::SetBackgroundColor(SkColor background_color
) {
421 DCHECK(IsPropertyChangeAllowed());
422 if (background_color_
== background_color
)
424 background_color_
= background_color
;
428 SkColor
Layer::SafeOpaqueBackgroundColor() const {
429 SkColor color
= background_color();
430 if (SkColorGetA(color
) == 255 && !contents_opaque()) {
431 color
= SK_ColorTRANSPARENT
;
432 } else if (SkColorGetA(color
) != 255 && contents_opaque()) {
433 for (const Layer
* layer
= parent(); layer
;
434 layer
= layer
->parent()) {
435 color
= layer
->background_color();
436 if (SkColorGetA(color
) == 255)
439 if (SkColorGetA(color
) != 255)
440 color
= layer_tree_host_
->background_color();
441 if (SkColorGetA(color
) != 255)
442 color
= SkColorSetA(color
, 255);
447 void Layer::CalculateContentsScale(float ideal_contents_scale
,
448 float* contents_scale_x
,
449 float* contents_scale_y
,
450 gfx::Size
* content_bounds
) {
451 DCHECK(layer_tree_host_
);
453 *contents_scale_x
= 1;
454 *contents_scale_y
= 1;
455 *content_bounds
= bounds();
458 void Layer::SetMasksToBounds(bool masks_to_bounds
) {
459 DCHECK(IsPropertyChangeAllowed());
460 if (masks_to_bounds_
== masks_to_bounds
)
462 masks_to_bounds_
= masks_to_bounds
;
466 void Layer::SetMaskLayer(Layer
* mask_layer
) {
467 DCHECK(IsPropertyChangeAllowed());
468 if (mask_layer_
.get() == mask_layer
)
470 if (mask_layer_
.get()) {
471 DCHECK_EQ(this, mask_layer_
->parent());
472 mask_layer_
->RemoveFromParent();
474 mask_layer_
= mask_layer
;
475 if (mask_layer_
.get()) {
476 DCHECK(!mask_layer_
->parent());
477 mask_layer_
->RemoveFromParent();
478 mask_layer_
->SetParent(this);
479 mask_layer_
->SetIsMask(true);
481 SetNeedsFullTreeSync();
484 void Layer::SetReplicaLayer(Layer
* layer
) {
485 DCHECK(IsPropertyChangeAllowed());
486 if (replica_layer_
.get() == layer
)
488 if (replica_layer_
.get()) {
489 DCHECK_EQ(this, replica_layer_
->parent());
490 replica_layer_
->RemoveFromParent();
492 replica_layer_
= layer
;
493 if (replica_layer_
.get()) {
494 DCHECK(!replica_layer_
->parent());
495 replica_layer_
->RemoveFromParent();
496 replica_layer_
->SetParent(this);
498 SetNeedsFullTreeSync();
501 void Layer::SetFilters(const FilterOperations
& filters
) {
502 DCHECK(IsPropertyChangeAllowed());
503 if (filters_
== filters
)
509 bool Layer::FilterIsAnimating() const {
510 return layer_animation_controller_
->IsAnimatingProperty(Animation::FILTER
);
513 void Layer::SetBackgroundFilters(const FilterOperations
& filters
) {
514 DCHECK(IsPropertyChangeAllowed());
515 if (background_filters_
== filters
)
517 background_filters_
= filters
;
521 void Layer::SetOpacity(float opacity
) {
522 DCHECK(IsPropertyChangeAllowed());
523 if (opacity_
== opacity
)
529 bool Layer::OpacityIsAnimating() const {
530 return layer_animation_controller_
->IsAnimatingProperty(Animation::OPACITY
);
533 bool Layer::OpacityCanAnimateOnImplThread() const {
537 void Layer::SetBlendMode(SkXfermode::Mode blend_mode
) {
538 DCHECK(IsPropertyChangeAllowed());
539 if (blend_mode_
== blend_mode
)
542 // Allowing only blend modes that are defined in the CSS Compositing standard:
543 // http://dev.w3.org/fxtf/compositing-1/#blending
544 switch (blend_mode
) {
545 case SkXfermode::kSrcOver_Mode
:
546 case SkXfermode::kScreen_Mode
:
547 case SkXfermode::kOverlay_Mode
:
548 case SkXfermode::kDarken_Mode
:
549 case SkXfermode::kLighten_Mode
:
550 case SkXfermode::kColorDodge_Mode
:
551 case SkXfermode::kColorBurn_Mode
:
552 case SkXfermode::kHardLight_Mode
:
553 case SkXfermode::kSoftLight_Mode
:
554 case SkXfermode::kDifference_Mode
:
555 case SkXfermode::kExclusion_Mode
:
556 case SkXfermode::kMultiply_Mode
:
557 case SkXfermode::kHue_Mode
:
558 case SkXfermode::kSaturation_Mode
:
559 case SkXfermode::kColor_Mode
:
560 case SkXfermode::kLuminosity_Mode
:
561 // supported blend modes
563 case SkXfermode::kClear_Mode
:
564 case SkXfermode::kSrc_Mode
:
565 case SkXfermode::kDst_Mode
:
566 case SkXfermode::kDstOver_Mode
:
567 case SkXfermode::kSrcIn_Mode
:
568 case SkXfermode::kDstIn_Mode
:
569 case SkXfermode::kSrcOut_Mode
:
570 case SkXfermode::kDstOut_Mode
:
571 case SkXfermode::kSrcATop_Mode
:
572 case SkXfermode::kDstATop_Mode
:
573 case SkXfermode::kXor_Mode
:
574 case SkXfermode::kPlus_Mode
:
575 case SkXfermode::kModulate_Mode
:
576 // Porter Duff Compositing Operators are not yet supported
577 // http://dev.w3.org/fxtf/compositing-1/#porterduffcompositingoperators
582 blend_mode_
= blend_mode
;
586 void Layer::SetIsRootForIsolatedGroup(bool root
) {
587 DCHECK(IsPropertyChangeAllowed());
588 if (is_root_for_isolated_group_
== root
)
590 is_root_for_isolated_group_
= root
;
594 void Layer::SetContentsOpaque(bool opaque
) {
595 DCHECK(IsPropertyChangeAllowed());
596 if (contents_opaque_
== opaque
)
598 contents_opaque_
= opaque
;
602 void Layer::SetPosition(const gfx::PointF
& position
) {
603 DCHECK(IsPropertyChangeAllowed());
604 if (position_
== position
)
606 position_
= position
;
608 if (!layer_tree_host_
)
611 if (TransformNode
* transform_node
=
612 layer_tree_host_
->property_trees()->transform_tree
.Node(
613 transform_tree_index())) {
614 if (transform_node
->owner_id
== id()) {
615 transform_node
->data
.update_post_local_transform(position
,
617 transform_node
->data
.needs_local_transform_update
= true;
618 layer_tree_host_
->property_trees()->transform_tree
.set_needs_update(true);
619 SetNeedsCommitNoRebuild();
627 bool Layer::IsContainerForFixedPositionLayers() const {
628 if (!transform_
.IsIdentityOrTranslation())
630 if (parent_
&& !parent_
->transform_
.IsIdentityOrTranslation())
632 return is_container_for_fixed_position_layers_
;
635 bool Are2dAxisAligned(const gfx::Transform
& a
,
636 const gfx::Transform
& b
,
637 bool* is_invertible
) {
638 if (a
.IsScaleOrTranslation() && b
.IsScaleOrTranslation()) {
639 *is_invertible
= b
.IsInvertible();
643 gfx::Transform
inverse(gfx::Transform::kSkipInitialization
);
644 *is_invertible
= b
.GetInverse(&inverse
);
647 return inverse
.Preserves2dAxisAlignment();
650 void Layer::SetTransform(const gfx::Transform
& transform
) {
651 DCHECK(IsPropertyChangeAllowed());
652 if (transform_
== transform
)
655 if (layer_tree_host_
) {
656 if (TransformNode
* transform_node
=
657 layer_tree_host_
->property_trees()->transform_tree
.Node(
658 transform_tree_index())) {
659 if (transform_node
->owner_id
== id()) {
660 // We need to trigger a rebuild if we could have affected 2d axis
661 // alignment. We'll check to see if transform and transform_ are axis
662 // align with respect to one another.
663 bool invertible
= false;
664 bool preserves_2d_axis_alignment
=
665 Are2dAxisAligned(transform_
, transform
, &invertible
);
666 transform_node
->data
.local
= transform
;
667 transform_node
->data
.needs_local_transform_update
= true;
668 layer_tree_host_
->property_trees()->transform_tree
.set_needs_update(
670 if (preserves_2d_axis_alignment
)
671 SetNeedsCommitNoRebuild();
674 transform_
= transform
;
675 transform_is_invertible_
= invertible
;
681 transform_
= transform
;
682 transform_is_invertible_
= transform
.IsInvertible();
687 void Layer::SetTransformOrigin(const gfx::Point3F
& transform_origin
) {
688 DCHECK(IsPropertyChangeAllowed());
689 if (transform_origin_
== transform_origin
)
691 transform_origin_
= transform_origin
;
693 if (!layer_tree_host_
)
696 if (TransformNode
* transform_node
=
697 layer_tree_host_
->property_trees()->transform_tree
.Node(
698 transform_tree_index())) {
699 if (transform_node
->owner_id
== id()) {
700 transform_node
->data
.update_pre_local_transform(transform_origin
);
701 transform_node
->data
.update_post_local_transform(position(),
703 transform_node
->data
.needs_local_transform_update
= true;
704 layer_tree_host_
->property_trees()->transform_tree
.set_needs_update(true);
705 SetNeedsCommitNoRebuild();
713 bool Layer::AnimationsPreserveAxisAlignment() const {
714 return layer_animation_controller_
->AnimationsPreserveAxisAlignment();
717 bool Layer::TransformIsAnimating() const {
718 return layer_animation_controller_
->IsAnimatingProperty(Animation::TRANSFORM
);
721 void Layer::SetScrollParent(Layer
* parent
) {
722 DCHECK(IsPropertyChangeAllowed());
723 if (scroll_parent_
== parent
)
727 scroll_parent_
->RemoveScrollChild(this);
729 scroll_parent_
= parent
;
732 scroll_parent_
->AddScrollChild(this);
737 void Layer::AddScrollChild(Layer
* child
) {
738 if (!scroll_children_
)
739 scroll_children_
.reset(new std::set
<Layer
*>);
740 scroll_children_
->insert(child
);
744 void Layer::RemoveScrollChild(Layer
* child
) {
745 scroll_children_
->erase(child
);
746 if (scroll_children_
->empty())
747 scroll_children_
= nullptr;
751 void Layer::SetClipParent(Layer
* ancestor
) {
752 DCHECK(IsPropertyChangeAllowed());
753 if (clip_parent_
== ancestor
)
757 clip_parent_
->RemoveClipChild(this);
759 clip_parent_
= ancestor
;
762 clip_parent_
->AddClipChild(this);
767 void Layer::AddClipChild(Layer
* child
) {
769 clip_children_
.reset(new std::set
<Layer
*>);
770 clip_children_
->insert(child
);
774 void Layer::RemoveClipChild(Layer
* child
) {
775 clip_children_
->erase(child
);
776 if (clip_children_
->empty())
777 clip_children_
= nullptr;
781 void Layer::SetScrollOffset(const gfx::ScrollOffset
& scroll_offset
) {
782 DCHECK(IsPropertyChangeAllowed());
784 if (scroll_offset_
== scroll_offset
)
786 scroll_offset_
= scroll_offset
;
788 if (!layer_tree_host_
)
791 if (TransformNode
* transform_node
=
792 layer_tree_host_
->property_trees()->transform_tree
.Node(
793 transform_tree_index())) {
794 if (transform_node
->owner_id
== id()) {
795 transform_node
->data
.scroll_offset
=
796 gfx::ScrollOffsetToVector2dF(CurrentScrollOffset());
797 transform_node
->data
.needs_local_transform_update
= true;
798 layer_tree_host_
->property_trees()->transform_tree
.set_needs_update(true);
799 SetNeedsCommitNoRebuild();
807 void Layer::SetScrollCompensationAdjustment(
808 const gfx::Vector2dF
& scroll_compensation_adjustment
) {
809 if (scroll_compensation_adjustment_
== scroll_compensation_adjustment
)
811 scroll_compensation_adjustment_
= scroll_compensation_adjustment
;
815 gfx::Vector2dF
Layer::ScrollCompensationAdjustment() const {
816 return scroll_compensation_adjustment_
;
819 void Layer::SetScrollOffsetFromImplSide(
820 const gfx::ScrollOffset
& scroll_offset
) {
821 DCHECK(IsPropertyChangeAllowed());
822 // This function only gets called during a BeginMainFrame, so there
823 // is no need to call SetNeedsUpdate here.
824 DCHECK(layer_tree_host_
&& layer_tree_host_
->CommitRequested());
825 if (scroll_offset_
== scroll_offset
)
827 scroll_offset_
= scroll_offset
;
828 SetNeedsPushProperties();
830 bool needs_rebuild
= true;
831 if (TransformNode
* transform_node
=
832 layer_tree_host_
->property_trees()->transform_tree
.Node(
833 transform_tree_index())) {
834 if (transform_node
->owner_id
== id()) {
835 transform_node
->data
.scroll_offset
=
836 gfx::ScrollOffsetToVector2dF(CurrentScrollOffset());
837 transform_node
->data
.needs_local_transform_update
= true;
838 layer_tree_host_
->property_trees()->transform_tree
.set_needs_update(true);
839 needs_rebuild
= false;
844 layer_tree_host_
->property_trees()->needs_rebuild
= true;
846 if (!did_scroll_callback_
.is_null())
847 did_scroll_callback_
.Run();
848 // The callback could potentially change the layer structure:
849 // "this" may have been destroyed during the process.
852 void Layer::SetScrollClipLayerId(int clip_layer_id
) {
853 DCHECK(IsPropertyChangeAllowed());
854 if (scroll_clip_layer_id_
== clip_layer_id
)
856 scroll_clip_layer_id_
= clip_layer_id
;
860 void Layer::SetUserScrollable(bool horizontal
, bool vertical
) {
861 DCHECK(IsPropertyChangeAllowed());
862 if (user_scrollable_horizontal_
== horizontal
&&
863 user_scrollable_vertical_
== vertical
)
865 user_scrollable_horizontal_
= horizontal
;
866 user_scrollable_vertical_
= vertical
;
870 void Layer::SetShouldScrollOnMainThread(bool should_scroll_on_main_thread
) {
871 DCHECK(IsPropertyChangeAllowed());
872 if (should_scroll_on_main_thread_
== should_scroll_on_main_thread
)
874 should_scroll_on_main_thread_
= should_scroll_on_main_thread
;
878 void Layer::SetHaveWheelEventHandlers(bool have_wheel_event_handlers
) {
879 DCHECK(IsPropertyChangeAllowed());
880 if (have_wheel_event_handlers_
== have_wheel_event_handlers
)
882 have_wheel_event_handlers_
= have_wheel_event_handlers
;
886 void Layer::SetHaveScrollEventHandlers(bool have_scroll_event_handlers
) {
887 DCHECK(IsPropertyChangeAllowed());
888 if (have_scroll_event_handlers_
== have_scroll_event_handlers
)
890 have_scroll_event_handlers_
= have_scroll_event_handlers
;
894 void Layer::SetNonFastScrollableRegion(const Region
& region
) {
895 DCHECK(IsPropertyChangeAllowed());
896 if (non_fast_scrollable_region_
== region
)
898 non_fast_scrollable_region_
= region
;
902 void Layer::SetTouchEventHandlerRegion(const Region
& region
) {
903 DCHECK(IsPropertyChangeAllowed());
904 if (touch_event_handler_region_
== region
)
906 touch_event_handler_region_
= region
;
910 void Layer::SetScrollBlocksOn(ScrollBlocksOn scroll_blocks_on
) {
911 DCHECK(IsPropertyChangeAllowed());
912 if (scroll_blocks_on_
== scroll_blocks_on
)
914 scroll_blocks_on_
= scroll_blocks_on
;
918 void Layer::SetDrawCheckerboardForMissingTiles(bool checkerboard
) {
919 DCHECK(IsPropertyChangeAllowed());
920 if (draw_checkerboard_for_missing_tiles_
== checkerboard
)
922 draw_checkerboard_for_missing_tiles_
= checkerboard
;
926 void Layer::SetForceRenderSurface(bool force
) {
927 DCHECK(IsPropertyChangeAllowed());
928 if (force_render_surface_
== force
)
930 force_render_surface_
= force
;
934 void Layer::SetDoubleSided(bool double_sided
) {
935 DCHECK(IsPropertyChangeAllowed());
936 if (double_sided_
== double_sided
)
938 double_sided_
= double_sided
;
942 void Layer::Set3dSortingContextId(int id
) {
943 DCHECK(IsPropertyChangeAllowed());
944 if (id
== sorting_context_id_
)
946 sorting_context_id_
= id
;
950 void Layer::SetShouldFlattenTransform(bool should_flatten
) {
951 DCHECK(IsPropertyChangeAllowed());
952 if (should_flatten_transform_
== should_flatten
)
954 should_flatten_transform_
= should_flatten
;
958 void Layer::SetIsDrawable(bool is_drawable
) {
959 DCHECK(IsPropertyChangeAllowed());
960 if (is_drawable_
== is_drawable
)
963 is_drawable_
= is_drawable
;
964 UpdateDrawsContent(HasDrawableContent());
967 void Layer::SetHideLayerAndSubtree(bool hide
) {
968 DCHECK(IsPropertyChangeAllowed());
969 if (hide_layer_and_subtree_
== hide
)
972 hide_layer_and_subtree_
= hide
;
976 void Layer::SetNeedsDisplayRect(const gfx::Rect
& dirty_rect
) {
977 if (dirty_rect
.IsEmpty())
980 SetNeedsPushProperties();
981 update_rect_
.Union(dirty_rect
);
987 bool Layer::DescendantIsFixedToContainerLayer() const {
988 for (size_t i
= 0; i
< children_
.size(); ++i
) {
989 if (children_
[i
]->position_constraint_
.is_fixed_position() ||
990 children_
[i
]->DescendantIsFixedToContainerLayer())
996 void Layer::SetIsContainerForFixedPositionLayers(bool container
) {
997 if (is_container_for_fixed_position_layers_
== container
)
999 is_container_for_fixed_position_layers_
= container
;
1001 if (layer_tree_host_
&& layer_tree_host_
->CommitRequested())
1004 // Only request a commit if we have a fixed positioned descendant.
1005 if (DescendantIsFixedToContainerLayer())
1009 void Layer::SetPositionConstraint(const LayerPositionConstraint
& constraint
) {
1010 DCHECK(IsPropertyChangeAllowed());
1011 if (position_constraint_
== constraint
)
1013 position_constraint_
= constraint
;
1017 static void RunCopyCallbackOnMainThread(scoped_ptr
<CopyOutputRequest
> request
,
1018 scoped_ptr
<CopyOutputResult
> result
) {
1019 request
->SendResult(result
.Pass());
1022 static void PostCopyCallbackToMainThread(
1023 scoped_refptr
<base::SingleThreadTaskRunner
> main_thread_task_runner
,
1024 scoped_ptr
<CopyOutputRequest
> request
,
1025 scoped_ptr
<CopyOutputResult
> result
) {
1026 main_thread_task_runner
->PostTask(FROM_HERE
,
1027 base::Bind(&RunCopyCallbackOnMainThread
,
1028 base::Passed(&request
),
1029 base::Passed(&result
)));
1032 void Layer::PushPropertiesTo(LayerImpl
* layer
) {
1033 DCHECK(layer_tree_host_
);
1035 // If we did not SavePaintProperties() for the layer this frame, then push the
1036 // real property values, not the paint property values.
1037 bool use_paint_properties
= paint_properties_
.source_frame_number
==
1038 layer_tree_host_
->source_frame_number();
1040 layer
->SetTransformOrigin(transform_origin_
);
1041 layer
->SetBackgroundColor(background_color_
);
1042 layer
->SetBounds(use_paint_properties
? paint_properties_
.bounds
1044 layer
->SetContentBounds(content_bounds());
1045 layer
->SetContentsScale(contents_scale_x(), contents_scale_y());
1047 if (frame_viewer_instrumentation::IsTracingLayerTreeSnapshots())
1048 layer
->SetDebugInfo(TakeDebugInfo());
1050 layer
->SetDoubleSided(double_sided_
);
1051 layer
->SetDrawCheckerboardForMissingTiles(
1052 draw_checkerboard_for_missing_tiles_
);
1053 layer
->SetDrawsContent(DrawsContent());
1054 layer
->SetHideLayerAndSubtree(hide_layer_and_subtree_
);
1055 layer
->SetHasRenderSurface(has_render_surface_
|| layer
->HasCopyRequest());
1056 if (!layer
->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating())
1057 layer
->SetFilters(filters_
);
1058 DCHECK(!(FilterIsAnimating() && layer
->FilterIsAnimatingOnImplOnly()));
1059 layer
->SetBackgroundFilters(background_filters());
1060 layer
->SetMasksToBounds(masks_to_bounds_
);
1061 layer
->SetShouldScrollOnMainThread(should_scroll_on_main_thread_
);
1062 layer
->SetHaveWheelEventHandlers(have_wheel_event_handlers_
);
1063 layer
->SetHaveScrollEventHandlers(have_scroll_event_handlers_
);
1064 layer
->SetNonFastScrollableRegion(non_fast_scrollable_region_
);
1065 layer
->SetTouchEventHandlerRegion(touch_event_handler_region_
);
1066 layer
->SetScrollBlocksOn(scroll_blocks_on_
);
1067 layer
->SetContentsOpaque(contents_opaque_
);
1068 if (!layer
->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating())
1069 layer
->SetOpacity(opacity_
);
1070 DCHECK(!(OpacityIsAnimating() && layer
->OpacityIsAnimatingOnImplOnly()));
1071 layer
->SetBlendMode(blend_mode_
);
1072 layer
->SetIsRootForIsolatedGroup(is_root_for_isolated_group_
);
1073 layer
->SetPosition(position_
);
1074 layer
->SetIsContainerForFixedPositionLayers(
1075 IsContainerForFixedPositionLayers());
1076 layer
->SetPositionConstraint(position_constraint_
);
1077 layer
->SetShouldFlattenTransform(should_flatten_transform_
);
1078 layer
->set_should_flatten_transform_from_property_tree(
1079 should_flatten_transform_from_property_tree_
);
1080 layer
->SetUseParentBackfaceVisibility(use_parent_backface_visibility_
);
1081 if (!layer
->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating())
1082 layer
->SetTransformAndInvertibility(transform_
, transform_is_invertible_
);
1083 DCHECK(!(TransformIsAnimating() && layer
->TransformIsAnimatingOnImplOnly()));
1084 layer
->Set3dSortingContextId(sorting_context_id_
);
1085 layer
->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_
);
1086 layer
->set_transform_tree_index(transform_tree_index_
);
1087 layer
->set_opacity_tree_index(opacity_tree_index_
);
1088 layer
->set_clip_tree_index(clip_tree_index_
);
1089 layer
->set_offset_to_transform_parent(offset_to_transform_parent_
);
1091 layer
->SetScrollClipLayer(scroll_clip_layer_id_
);
1092 layer
->set_user_scrollable_horizontal(user_scrollable_horizontal_
);
1093 layer
->set_user_scrollable_vertical(user_scrollable_vertical_
);
1095 LayerImpl
* scroll_parent
= nullptr;
1096 if (scroll_parent_
) {
1097 scroll_parent
= layer
->layer_tree_impl()->LayerById(scroll_parent_
->id());
1098 DCHECK(scroll_parent
);
1101 layer
->SetScrollParent(scroll_parent
);
1102 if (scroll_children_
) {
1103 std::set
<LayerImpl
*>* scroll_children
= new std::set
<LayerImpl
*>;
1104 for (std::set
<Layer
*>::iterator it
= scroll_children_
->begin();
1105 it
!= scroll_children_
->end();
1107 DCHECK_EQ((*it
)->scroll_parent(), this);
1108 LayerImpl
* scroll_child
=
1109 layer
->layer_tree_impl()->LayerById((*it
)->id());
1110 DCHECK(scroll_child
);
1111 scroll_children
->insert(scroll_child
);
1113 layer
->SetScrollChildren(scroll_children
);
1115 layer
->SetScrollChildren(nullptr);
1118 LayerImpl
* clip_parent
= nullptr;
1121 layer
->layer_tree_impl()->LayerById(clip_parent_
->id());
1122 DCHECK(clip_parent
);
1125 layer
->SetClipParent(clip_parent
);
1126 if (clip_children_
) {
1127 std::set
<LayerImpl
*>* clip_children
= new std::set
<LayerImpl
*>;
1128 for (std::set
<Layer
*>::iterator it
= clip_children_
->begin();
1129 it
!= clip_children_
->end(); ++it
) {
1130 DCHECK_EQ((*it
)->clip_parent(), this);
1131 LayerImpl
* clip_child
= layer
->layer_tree_impl()->LayerById((*it
)->id());
1133 clip_children
->insert(clip_child
);
1135 layer
->SetClipChildren(clip_children
);
1137 layer
->SetClipChildren(nullptr);
1140 // When a scroll offset animation is interrupted the new scroll position on
1141 // the pending tree will clobber any impl-side scrolling occuring on the
1142 // active tree. To do so, avoid scrolling the pending tree along with it
1143 // instead of trying to undo that scrolling later.
1144 if (layer_animation_controller_
->scroll_offset_animation_was_interrupted())
1145 layer
->PushScrollOffsetFromMainThreadAndClobberActiveValue(scroll_offset_
);
1147 layer
->PushScrollOffsetFromMainThread(scroll_offset_
);
1148 layer
->SetScrollCompensationAdjustment(ScrollCompensationAdjustment());
1150 // Wrap the copy_requests_ in a PostTask to the main thread.
1151 ScopedPtrVector
<CopyOutputRequest
> main_thread_copy_requests
;
1152 for (ScopedPtrVector
<CopyOutputRequest
>::iterator it
= copy_requests_
.begin();
1153 it
!= copy_requests_
.end();
1155 scoped_refptr
<base::SingleThreadTaskRunner
> main_thread_task_runner
=
1156 layer_tree_host()->proxy()->MainThreadTaskRunner();
1157 scoped_ptr
<CopyOutputRequest
> original_request
= copy_requests_
.take(it
);
1158 const CopyOutputRequest
& original_request_ref
= *original_request
;
1159 scoped_ptr
<CopyOutputRequest
> main_thread_request
=
1160 CopyOutputRequest::CreateRelayRequest(
1161 original_request_ref
,
1162 base::Bind(&PostCopyCallbackToMainThread
,
1163 main_thread_task_runner
,
1164 base::Passed(&original_request
)));
1165 main_thread_copy_requests
.push_back(main_thread_request
.Pass());
1167 if (!copy_requests_
.empty() && layer_tree_host_
)
1168 layer_tree_host_
->property_trees()->needs_rebuild
= true;
1169 copy_requests_
.clear();
1170 layer
->PassCopyRequests(&main_thread_copy_requests
);
1172 // If the main thread commits multiple times before the impl thread actually
1173 // draws, then damage tracking will become incorrect if we simply clobber the
1174 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e.
1175 // union) any update changes that have occurred on the main thread.
1176 update_rect_
.Union(layer
->update_rect());
1177 layer
->SetUpdateRect(update_rect_
);
1179 layer
->SetStackingOrderChanged(stacking_order_changed_
);
1181 layer_animation_controller_
->PushAnimationUpdatesTo(
1182 layer
->layer_animation_controller());
1184 if (frame_timing_requests_dirty_
) {
1185 layer
->PassFrameTimingRequests(&frame_timing_requests_
);
1186 frame_timing_requests_dirty_
= false;
1189 // Reset any state that should be cleared for the next update.
1190 stacking_order_changed_
= false;
1191 update_rect_
= gfx::Rect();
1193 needs_push_properties_
= false;
1194 num_dependents_need_push_properties_
= 0;
1197 scoped_ptr
<LayerImpl
> Layer::CreateLayerImpl(LayerTreeImpl
* tree_impl
) {
1198 return LayerImpl::Create(tree_impl
, layer_id_
,
1199 new LayerImpl::SyncedScrollOffset
);
1202 bool Layer::DrawsContent() const {
1203 return draws_content_
;
1206 bool Layer::HasDrawableContent() const {
1207 return is_drawable_
;
1210 void Layer::UpdateDrawsContent(bool has_drawable_content
) {
1211 bool draws_content
= has_drawable_content
;
1212 DCHECK(is_drawable_
|| !has_drawable_content
);
1213 if (draws_content
== draws_content_
)
1216 if (HasDelegatedContent()) {
1217 // Layers with delegated content need to be treated as if they have as
1218 // many children as the number of layers they own delegated quads for.
1219 // Since we don't know this number right now, we choose one that acts like
1220 // infinity for our purposes.
1221 AddDrawableDescendants(draws_content
? 1000 : -1000);
1225 parent()->AddDrawableDescendants(draws_content
? 1 : -1);
1227 draws_content_
= draws_content
;
1231 int Layer::NumDescendantsThatDrawContent() const {
1232 return num_descendants_that_draw_content_
;
1235 void Layer::SavePaintProperties() {
1236 DCHECK(layer_tree_host_
);
1238 // TODO(reveman): Save all layer properties that we depend on not
1239 // changing until PushProperties() has been called. crbug.com/231016
1240 paint_properties_
.bounds
= bounds_
;
1241 paint_properties_
.source_frame_number
=
1242 layer_tree_host_
->source_frame_number();
1245 bool Layer::Update(ResourceUpdateQueue
* queue
,
1246 const OcclusionTracker
<Layer
>* occlusion
) {
1247 DCHECK(layer_tree_host_
);
1248 DCHECK_EQ(layer_tree_host_
->source_frame_number(),
1249 paint_properties_
.source_frame_number
) <<
1250 "SavePaintProperties must be called for any layer that is painted.";
1254 bool Layer::NeedMoreUpdates() {
1258 bool Layer::IsSuitableForGpuRasterization() const {
1262 scoped_refptr
<base::trace_event::ConvertableToTraceFormat
>
1263 Layer::TakeDebugInfo() {
1265 return client_
->TakeDebugInfo();
1270 void Layer::SetHasRenderSurface(bool has_render_surface
) {
1271 if (has_render_surface_
== has_render_surface
)
1273 has_render_surface_
= has_render_surface
;
1274 // We do not need SetNeedsCommit here, since this is only ever called
1275 // during a commit, from CalculateDrawProperties.
1276 SetNeedsPushProperties();
1279 void Layer::CreateRenderSurface() {
1280 DCHECK(!render_surface_
);
1281 render_surface_
= make_scoped_ptr(new RenderSurface(this));
1284 void Layer::ClearRenderSurface() {
1285 render_surface_
= nullptr;
1288 void Layer::ClearRenderSurfaceLayerList() {
1289 if (render_surface_
)
1290 render_surface_
->ClearLayerLists();
1293 gfx::ScrollOffset
Layer::ScrollOffsetForAnimation() const {
1294 return CurrentScrollOffset();
1297 // On<Property>Animated is called due to an ongoing accelerated animation.
1298 // Since this animation is also being run on the compositor thread, there
1299 // is no need to request a commit to push this value over, so the value is
1300 // set directly rather than by calling Set<Property>.
1301 void Layer::OnFilterAnimated(const FilterOperations
& filters
) {
1305 void Layer::OnOpacityAnimated(float opacity
) {
1307 if (layer_tree_host_
) {
1308 if (OpacityNode
* node
=
1309 layer_tree_host_
->property_trees()->opacity_tree
.Node(
1310 opacity_tree_index_
)) {
1311 if (node
->owner_id
== id())
1312 node
->data
= opacity
;
1317 void Layer::OnTransformAnimated(const gfx::Transform
& transform
) {
1318 if (transform_
== transform
)
1320 transform_
= transform
;
1321 transform_is_invertible_
= transform
.IsInvertible();
1322 if (layer_tree_host_
) {
1323 if (TransformNode
* node
=
1324 layer_tree_host_
->property_trees()->transform_tree
.Node(
1325 transform_tree_index_
)) {
1326 if (node
->owner_id
== id()) {
1327 node
->data
.local
= transform
;
1328 node
->data
.needs_local_transform_update
= true;
1329 node
->data
.is_animated
= true;
1330 layer_tree_host_
->property_trees()->transform_tree
.set_needs_update(
1337 void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset
& scroll_offset
) {
1338 // Do nothing. Scroll deltas will be sent from the compositor thread back
1339 // to the main thread in the same manner as during non-animated
1340 // compositor-driven scrolling.
1343 void Layer::OnAnimationWaitingForDeletion() {
1344 // Animations are only deleted during PushProperties.
1345 SetNeedsPushProperties();
1348 bool Layer::IsActive() const {
1352 bool Layer::AddAnimation(scoped_ptr
<Animation
> animation
) {
1353 if (!layer_animation_controller_
->animation_registrar())
1356 if (animation
->target_property() == Animation::SCROLL_OFFSET
&&
1357 !layer_animation_controller_
->animation_registrar()
1358 ->supports_scroll_animations())
1361 UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer",
1363 layer_animation_controller_
->AddAnimation(animation
.Pass());
1368 void Layer::PauseAnimation(int animation_id
, double time_offset
) {
1369 layer_animation_controller_
->PauseAnimation(
1370 animation_id
, base::TimeDelta::FromSecondsD(time_offset
));
1374 void Layer::RemoveAnimation(int animation_id
) {
1375 layer_animation_controller_
->RemoveAnimation(animation_id
);
1379 void Layer::RemoveAnimation(int animation_id
,
1380 Animation::TargetProperty property
) {
1381 layer_animation_controller_
->RemoveAnimation(animation_id
, property
);
1385 void Layer::SetLayerAnimationControllerForTest(
1386 scoped_refptr
<LayerAnimationController
> controller
) {
1387 layer_animation_controller_
->RemoveValueObserver(this);
1388 layer_animation_controller_
= controller
;
1389 layer_animation_controller_
->AddValueObserver(this);
1393 bool Layer::HasActiveAnimation() const {
1394 return layer_animation_controller_
->HasActiveAnimation();
1397 void Layer::AddLayerAnimationEventObserver(
1398 LayerAnimationEventObserver
* animation_observer
) {
1399 layer_animation_controller_
->AddEventObserver(animation_observer
);
1402 void Layer::RemoveLayerAnimationEventObserver(
1403 LayerAnimationEventObserver
* animation_observer
) {
1404 layer_animation_controller_
->RemoveEventObserver(animation_observer
);
1407 SimpleEnclosedRegion
Layer::VisibleContentOpaqueRegion() const {
1408 if (contents_opaque())
1409 return SimpleEnclosedRegion(visible_content_rect());
1410 return SimpleEnclosedRegion();
1413 ScrollbarLayerInterface
* Layer::ToScrollbarLayer() {
1417 RenderingStatsInstrumentation
* Layer::rendering_stats_instrumentation() const {
1418 return layer_tree_host_
->rendering_stats_instrumentation();
1421 void Layer::RemoveFromScrollTree() {
1422 if (scroll_children_
.get()) {
1423 std::set
<Layer
*> copy
= *scroll_children_
;
1424 for (std::set
<Layer
*>::iterator it
= copy
.begin(); it
!= copy
.end(); ++it
)
1425 (*it
)->SetScrollParent(nullptr);
1428 DCHECK(!scroll_children_
);
1429 SetScrollParent(nullptr);
1432 void Layer::RemoveFromClipTree() {
1433 if (clip_children_
.get()) {
1434 std::set
<Layer
*> copy
= *clip_children_
;
1435 for (std::set
<Layer
*>::iterator it
= copy
.begin(); it
!= copy
.end(); ++it
)
1436 (*it
)->SetClipParent(nullptr);
1439 DCHECK(!clip_children_
);
1440 SetClipParent(nullptr);
1443 void Layer::AddDrawableDescendants(int num
) {
1444 DCHECK_GE(num_descendants_that_draw_content_
, 0);
1445 DCHECK_GE(num_descendants_that_draw_content_
+ num
, 0);
1448 num_descendants_that_draw_content_
+= num
;
1451 parent()->AddDrawableDescendants(num
);
1454 void Layer::RunMicroBenchmark(MicroBenchmark
* benchmark
) {
1455 benchmark
->RunOnLayer(this);
1458 bool Layer::HasDelegatedContent() const {
1462 void Layer::SetFrameTimingRequests(
1463 const std::vector
<FrameTimingRequest
>& requests
) {
1464 frame_timing_requests_
= requests
;
1465 frame_timing_requests_dirty_
= true;
1469 void Layer::DidBeginTracing() {
1470 // We'll be dumping layer trees as part of trace, so make sure
1471 // PushPropertiesTo() propagates layer debug info to the impl
1472 // side -- otherwise this won't happen for the the layers that
1473 // remain unchanged since tracing started.
1474 SetNeedsPushProperties();