OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2014 Google Inc. All rights reserved. | 3 * Copyright (C) 2014 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 static bool RequiresCompositingOrSquashing(CompositingReasons reasons) { | 159 static bool RequiresCompositingOrSquashing(CompositingReasons reasons) { |
160 #if DCHECK_IS_ON() | 160 #if DCHECK_IS_ON() |
161 bool fast_answer = reasons != kCompositingReasonNone; | 161 bool fast_answer = reasons != kCompositingReasonNone; |
162 bool slow_answer = RequiresCompositing(reasons) || RequiresSquashing(reasons); | 162 bool slow_answer = RequiresCompositing(reasons) || RequiresSquashing(reasons); |
163 DCHECK_EQ(slow_answer, fast_answer); | 163 DCHECK_EQ(slow_answer, fast_answer); |
164 #endif | 164 #endif |
165 return reasons != kCompositingReasonNone; | 165 return reasons != kCompositingReasonNone; |
166 } | 166 } |
167 | 167 |
168 static CompositingReasons SubtreeReasonsForCompositing( | 168 static CompositingReasons SubtreeReasonsForCompositing( |
169 const CompositingReasonFinder& compositing_reason_finder, | |
169 PaintLayer* layer, | 170 PaintLayer* layer, |
170 bool has_composited_descendants, | 171 bool has_composited_descendants, |
171 bool has3d_transformed_descendants) { | 172 bool has3d_transformed_descendants) { |
172 CompositingReasons subtree_reasons = kCompositingReasonNone; | 173 CompositingReasons subtree_reasons = kCompositingReasonNone; |
173 | 174 |
174 // When a layer has composited descendants, some effects, like 2d transforms, | 175 // When a layer has composited descendants, some effects, like 2d transforms, |
175 // filters, masks etc must be implemented via compositing so that they also | 176 // filters, masks etc must be implemented via compositing so that they also |
176 // apply to those composited descendants. | 177 // apply to those composited descendants. |
177 if (has_composited_descendants) { | 178 if (has_composited_descendants) { |
178 subtree_reasons |= layer->PotentialCompositingReasonsFromStyle() & | 179 subtree_reasons |= layer->PotentialCompositingReasonsFromStyle() & |
179 kCompositingReasonComboCompositedDescendants; | 180 kCompositingReasonComboCompositedDescendants; |
180 | 181 |
181 if (layer->ShouldIsolateCompositedDescendants()) { | 182 if (layer->ShouldIsolateCompositedDescendants()) { |
182 DCHECK(layer->StackingNode()->IsStackingContext()); | 183 DCHECK(layer->StackingNode()->IsStackingContext()); |
183 subtree_reasons |= kCompositingReasonIsolateCompositedDescendants; | 184 subtree_reasons |= kCompositingReasonIsolateCompositedDescendants; |
184 } | 185 } |
185 | 186 |
186 // FIXME: This should move into | 187 // FIXME: This should move into |
187 // CompositingReasonFinder::potentialCompositingReasonsFromStyle, but theres | 188 // CompositingReasonFinder::potentialCompositingReasonsFromStyle, but theres |
188 // a poor interaction with LayoutTextControlSingleLine, which sets this | 189 // a poor interaction with LayoutTextControlSingleLine, which sets this |
189 // hasOverflowClip directly. | 190 // hasOverflowClip directly. |
190 if (layer->GetLayoutObject().HasClipRelatedProperty()) | 191 if (layer->GetLayoutObject().HasClipRelatedProperty()) |
191 subtree_reasons |= kCompositingReasonClipsCompositingDescendants; | 192 subtree_reasons |= kCompositingReasonClipsCompositingDescendants; |
192 | 193 |
193 if (layer->GetLayoutObject().Style()->GetPosition() == EPosition::kFixed) | 194 // We ignore LCD text here because we are required to composite |
195 // scroll-dependant fixed position elements with composited descendants for | |
196 // correctness - even if we lose LCD. | |
197 const bool ignore_lcd_text = true; | |
198 if (layer->GetLayoutObject().Style()->GetPosition() == EPosition::kFixed && | |
chrishtr
2017/05/03 19:03:31
The change here will affect fixed-position element
smcgruer
2017/05/04 19:28:52
Intended, yes. My understanding was that we should
| |
199 compositing_reason_finder.RequiresCompositingForScrollDependentPosition( | |
200 layer, ignore_lcd_text)) { | |
194 subtree_reasons |= | 201 subtree_reasons |= |
195 kCompositingReasonPositionFixedWithCompositedDescendants; | 202 kCompositingReasonPositionFixedWithCompositedDescendants; |
203 } | |
196 } | 204 } |
197 | 205 |
198 // A layer with preserve-3d or perspective only needs to be composited if | 206 // A layer with preserve-3d or perspective only needs to be composited if |
199 // there are descendant layers that will be affected by the preserve-3d or | 207 // there are descendant layers that will be affected by the preserve-3d or |
200 // perspective. | 208 // perspective. |
201 if (has3d_transformed_descendants) { | 209 if (has3d_transformed_descendants) { |
202 subtree_reasons |= layer->PotentialCompositingReasonsFromStyle() & | 210 subtree_reasons |= layer->PotentialCompositingReasonsFromStyle() & |
203 kCompositingReasonCombo3DDescendants; | 211 kCompositingReasonCombo3DDescendants; |
204 } | 212 } |
205 | 213 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 // into their compositing ancestor's backing, and so are still considered | 498 // into their compositing ancestor's backing, and so are still considered |
491 // for overlap. | 499 // for overlap. |
492 if (child_recursion_data.compositing_ancestor_ && | 500 if (child_recursion_data.compositing_ancestor_ && |
493 !child_recursion_data.compositing_ancestor_->IsRootLayer()) | 501 !child_recursion_data.compositing_ancestor_->IsRootLayer()) |
494 overlap_map.Add(layer, abs_bounds, !has_composited_scrolling_ancestor); | 502 overlap_map.Add(layer, abs_bounds, !has_composited_scrolling_ancestor); |
495 | 503 |
496 // Now check for reasons to become composited that depend on the state of | 504 // Now check for reasons to become composited that depend on the state of |
497 // descendant layers. | 505 // descendant layers. |
498 CompositingReasons subtree_compositing_reasons = | 506 CompositingReasons subtree_compositing_reasons = |
499 SubtreeReasonsForCompositing( | 507 SubtreeReasonsForCompositing( |
500 layer, child_recursion_data.subtree_is_compositing_, | 508 compositing_reason_finder_, layer, |
509 child_recursion_data.subtree_is_compositing_, | |
501 any_descendant_has3d_transform); | 510 any_descendant_has3d_transform); |
502 reasons_to_composite |= subtree_compositing_reasons; | 511 reasons_to_composite |= subtree_compositing_reasons; |
503 if (!will_be_composited_or_squashed && can_be_composited && | 512 if (!will_be_composited_or_squashed && can_be_composited && |
504 RequiresCompositingOrSquashing(subtree_compositing_reasons)) { | 513 RequiresCompositingOrSquashing(subtree_compositing_reasons)) { |
505 child_recursion_data.compositing_ancestor_ = layer; | 514 child_recursion_data.compositing_ancestor_ = layer; |
506 // FIXME: this context push is effectively a no-op but needs to exist for | 515 // FIXME: this context push is effectively a no-op but needs to exist for |
507 // now, because the code is designed to push overlap information to the | 516 // now, because the code is designed to push overlap information to the |
508 // second-from-top context of the stack. | 517 // second-from-top context of the stack. |
509 overlap_map.BeginNewOverlapTestingContext(); | 518 overlap_map.BeginNewOverlapTestingContext(); |
510 overlap_map.Add(layer, absolute_descendant_bounding_box, | 519 overlap_map.Add(layer, absolute_descendant_bounding_box, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 descendant_has3d_transform |= | 557 descendant_has3d_transform |= |
549 any_descendant_has3d_transform || layer->Has3DTransform(); | 558 any_descendant_has3d_transform || layer->Has3DTransform(); |
550 } | 559 } |
551 | 560 |
552 // At this point we have finished collecting all reasons to composite this | 561 // At this point we have finished collecting all reasons to composite this |
553 // layer. | 562 // layer. |
554 layer->SetCompositingReasons(reasons_to_composite); | 563 layer->SetCompositingReasons(reasons_to_composite); |
555 } | 564 } |
556 | 565 |
557 } // namespace blink | 566 } // namespace blink |
OLD | NEW |