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

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositingRequirementsUpdater.cpp

Issue 2393673004: reflow comments in core/layout/compositing,core/observer (Closed)
Patch Set: comments (heh!) Created 4 years, 2 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 /* 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 #endif 139 #endif
140 return reasons != CompositingReasonNone; 140 return reasons != CompositingReasonNone;
141 } 141 }
142 142
143 static CompositingReasons subtreeReasonsForCompositing( 143 static CompositingReasons subtreeReasonsForCompositing(
144 PaintLayer* layer, 144 PaintLayer* layer,
145 bool hasCompositedDescendants, 145 bool hasCompositedDescendants,
146 bool has3DTransformedDescendants) { 146 bool has3DTransformedDescendants) {
147 CompositingReasons subtreeReasons = CompositingReasonNone; 147 CompositingReasons subtreeReasons = CompositingReasonNone;
148 148
149 // When a layer has composited descendants, some effects, like 2d transforms, filters, masks etc must be implemented 149 // When a layer has composited descendants, some effects, like 2d transforms,
150 // via compositing so that they also apply to those composited descendants. 150 // filters, masks etc must be implemented via compositing so that they also
151 // apply to those composited descendants.
151 if (hasCompositedDescendants) { 152 if (hasCompositedDescendants) {
152 subtreeReasons |= layer->potentialCompositingReasonsFromStyle() & 153 subtreeReasons |= layer->potentialCompositingReasonsFromStyle() &
153 CompositingReasonComboCompositedDescendants; 154 CompositingReasonComboCompositedDescendants;
154 155
155 if (layer->shouldIsolateCompositedDescendants()) { 156 if (layer->shouldIsolateCompositedDescendants()) {
156 ASSERT(layer->stackingNode()->isStackingContext()); 157 ASSERT(layer->stackingNode()->isStackingContext());
157 subtreeReasons |= CompositingReasonIsolateCompositedDescendants; 158 subtreeReasons |= CompositingReasonIsolateCompositedDescendants;
158 } 159 }
159 160
160 // FIXME: This should move into CompositingReasonFinder::potentialCompositin gReasonsFromStyle, but 161 // FIXME: This should move into
161 // theres a poor interaction with LayoutTextControlSingleLine, which sets th is hasOverflowClip directly. 162 // CompositingReasonFinder::potentialCompositingReasonsFromStyle, but theres
163 // a poor interaction with LayoutTextControlSingleLine, which sets this
164 // hasOverflowClip directly.
162 if (layer->layoutObject()->hasClipRelatedProperty()) 165 if (layer->layoutObject()->hasClipRelatedProperty())
163 subtreeReasons |= CompositingReasonClipsCompositingDescendants; 166 subtreeReasons |= CompositingReasonClipsCompositingDescendants;
164 167
165 if (layer->layoutObject()->style()->position() == FixedPosition) 168 if (layer->layoutObject()->style()->position() == FixedPosition)
166 subtreeReasons |= CompositingReasonPositionFixedWithCompositedDescendants; 169 subtreeReasons |= CompositingReasonPositionFixedWithCompositedDescendants;
167 } 170 }
168 171
169 // A layer with preserve-3d or perspective only needs to be composited if ther e are descendant layers that 172 // A layer with preserve-3d or perspective only needs to be composited if
170 // will be affected by the preserve-3d or perspective. 173 // there are descendant layers that will be affected by the preserve-3d or
174 // perspective.
171 if (has3DTransformedDescendants) 175 if (has3DTransformedDescendants)
172 subtreeReasons |= layer->potentialCompositingReasonsFromStyle() & 176 subtreeReasons |= layer->potentialCompositingReasonsFromStyle() &
173 CompositingReasonCombo3DDescendants; 177 CompositingReasonCombo3DDescendants;
174 178
175 return subtreeReasons; 179 return subtreeReasons;
176 } 180 }
177 181
178 CompositingRequirementsUpdater::CompositingRequirementsUpdater( 182 CompositingRequirementsUpdater::CompositingRequirementsUpdater(
179 LayoutView& layoutView, 183 LayoutView& layoutView,
180 CompositingReasonFinder& compositingReasonFinder) 184 CompositingReasonFinder& compositingReasonFinder)
181 : m_layoutView(layoutView), 185 : m_layoutView(layoutView),
182 m_compositingReasonFinder(compositingReasonFinder) {} 186 m_compositingReasonFinder(compositingReasonFinder) {}
183 187
184 CompositingRequirementsUpdater::~CompositingRequirementsUpdater() {} 188 CompositingRequirementsUpdater::~CompositingRequirementsUpdater() {}
185 189
186 void CompositingRequirementsUpdater::update(PaintLayer* root) { 190 void CompositingRequirementsUpdater::update(PaintLayer* root) {
187 TRACE_EVENT0("blink", "CompositingRequirementsUpdater::updateRecursive"); 191 TRACE_EVENT0("blink", "CompositingRequirementsUpdater::updateRecursive");
188 192
189 // Go through the layers in presentation order, so that we can compute which L ayers need compositing layers. 193 // Go through the layers in presentation order, so that we can compute which
190 // FIXME: we could maybe do this and the hierarchy update in one pass, but the parenting logic would be more complex. 194 // Layers need compositing layers.
195 // FIXME: we could maybe do this and the hierarchy update in one pass, but the
196 // parenting logic would be more complex.
191 RecursionData recursionData(root); 197 RecursionData recursionData(root);
192 OverlapMap overlapTestRequestMap; 198 OverlapMap overlapTestRequestMap;
193 bool saw3DTransform = false; 199 bool saw3DTransform = false;
194 200
195 // FIXME: Passing these unclippedDescendants down and keeping track 201 // FIXME: Passing these unclippedDescendants down and keeping track
196 // of them dynamically, we are requiring a full tree walk. This 202 // of them dynamically, we are requiring a full tree walk. This
197 // should be removed as soon as proper overlap testing based on 203 // should be removed as soon as proper overlap testing based on
198 // scrolling and animation bounds is implemented (crbug.com/252472). 204 // scrolling and animation bounds is implemented (crbug.com/252472).
199 Vector<PaintLayer*> unclippedDescendants; 205 Vector<PaintLayer*> unclippedDescendants;
200 IntRect absoluteDescendantBoundingBox; 206 IntRect absoluteDescendantBoundingBox;
(...skipping 29 matching lines...) Expand all
230 layer->layoutObject()->styleRef().hasViewportConstrainedPosition()) 236 layer->layoutObject()->styleRef().hasViewportConstrainedPosition())
231 directReasons |= CompositingReasonScrollDependentPosition; 237 directReasons |= CompositingReasonScrollDependentPosition;
232 238
233 bool canBeComposited = compositor->canBeComposited(layer); 239 bool canBeComposited = compositor->canBeComposited(layer);
234 if (canBeComposited) { 240 if (canBeComposited) {
235 reasonsToComposite |= directReasons; 241 reasonsToComposite |= directReasons;
236 242
237 if (layer->isRootLayer() && compositor->rootShouldAlwaysComposite()) 243 if (layer->isRootLayer() && compositor->rootShouldAlwaysComposite())
238 reasonsToComposite |= CompositingReasonRoot; 244 reasonsToComposite |= CompositingReasonRoot;
239 245
240 // Add CompositingReasonOverflowScrollingTouch for layers that do not alread y have it but need it. 246 // Add CompositingReasonOverflowScrollingTouch for layers that do not
241 // Note that m_compositingReasonFinder.directReasons(layer) already includes CompositingReasonOverflowScrollingTouch for 247 // already have it but need it.
242 // anything that has layer->needsCompositedScrolling() true. That is, for ca ses where we explicitly decide not to have LCD 248 // Note that m_compositingReasonFinder.directReasons(layer) already includes
243 // text or cases where the layer will still support LCD text even if the lay er is composited. 249 // CompositingReasonOverflowScrollingTouch for anything that has
250 // layer->needsCompositedScrolling() true. That is, for cases where we
251 // explicitly decide not to have LCD text or cases where the layer will
252 // still support LCD text even if the layer is composited.
244 if (reasonsToComposite && layer->scrollsOverflow() && 253 if (reasonsToComposite && layer->scrollsOverflow() &&
245 !layer->needsCompositedScrolling()) { 254 !layer->needsCompositedScrolling()) {
246 // We can get here for a scroller that will be composited for some other r eason and hence will already 255 // We can get here for a scroller that will be composited for some other
247 // use grayscale AA text. We recheck for needsCompositedScrolling ignoring LCD to correctly add the 256 // reason and hence will already use grayscale AA text. We recheck for
248 // CompositingReasonOverflowScrollingTouch reason to layers that can suppo rt it with grayscale AA text. 257 // needsCompositedScrolling ignoring LCD to correctly add the
258 // CompositingReasonOverflowScrollingTouch reason to layers that can
259 // support it with grayscale AA text.
249 layer->getScrollableArea()->updateNeedsCompositedScrolling( 260 layer->getScrollableArea()->updateNeedsCompositedScrolling(
250 PaintLayerScrollableArea::IgnoreLCDText); 261 PaintLayerScrollableArea::IgnoreLCDText);
251 if (layer->needsCompositedScrolling()) 262 if (layer->needsCompositedScrolling())
252 reasonsToComposite |= CompositingReasonOverflowScrollingTouch; 263 reasonsToComposite |= CompositingReasonOverflowScrollingTouch;
253 } 264 }
254 } 265 }
255 266
256 if ((reasonsToComposite & CompositingReasonOverflowScrollingTouch) && 267 if ((reasonsToComposite & CompositingReasonOverflowScrollingTouch) &&
257 !layer->isRootLayer()) 268 !layer->isRootLayer())
258 currentRecursionData.m_hasCompositedScrollingAncestor = true; 269 currentRecursionData.m_hasCompositedScrollingAncestor = true;
259 270
260 // Next, accumulate reasons related to overlap. 271 // Next, accumulate reasons related to overlap.
261 // If overlap testing is used, this reason will be overridden. If overlap test ing is not 272 // If overlap testing is used, this reason will be overridden. If overlap
262 // used, we must assume we overlap if there is anything composited behind us i n paint-order. 273 // testing is not used, we must assume we overlap if there is anything
274 // composited behind us in paint-order.
263 CompositingReasons overlapCompositingReason = 275 CompositingReasons overlapCompositingReason =
264 currentRecursionData.m_subtreeIsCompositing 276 currentRecursionData.m_subtreeIsCompositing
265 ? CompositingReasonAssumedOverlap 277 ? CompositingReasonAssumedOverlap
266 : CompositingReasonNone; 278 : CompositingReasonNone;
267 279
268 if (currentRecursionData.m_hasCompositedScrollingAncestor) { 280 if (currentRecursionData.m_hasCompositedScrollingAncestor) {
269 Vector<size_t> unclippedDescendantsToRemove; 281 Vector<size_t> unclippedDescendantsToRemove;
270 for (size_t i = 0; i < unclippedDescendants.size(); i++) { 282 for (size_t i = 0; i < unclippedDescendants.size(); i++) {
271 PaintLayer* unclippedDescendant = unclippedDescendants.at(i); 283 PaintLayer* unclippedDescendant = unclippedDescendants.at(i);
272 // If we've reached the containing block of one of the unclipped 284 // If we've reached the containing block of one of the unclipped
273 // descendants, that element is no longer relevant to whether or not we 285 // descendants, that element is no longer relevant to whether or not we
274 // should opt in. Unfortunately we can't easily remove from the list 286 // should opt in. Unfortunately we can't easily remove from the list
275 // while we're iterating, so we have to store it for later removal. 287 // while we're iterating, so we have to store it for later removal.
276 if (unclippedDescendant->layoutObject()->containingBlock() == 288 if (unclippedDescendant->layoutObject()->containingBlock() ==
277 layer->layoutObject()) { 289 layer->layoutObject()) {
278 unclippedDescendantsToRemove.append(i); 290 unclippedDescendantsToRemove.append(i);
279 continue; 291 continue;
280 } 292 }
281 if (layer->scrollsWithRespectTo(unclippedDescendant)) 293 if (layer->scrollsWithRespectTo(unclippedDescendant))
282 reasonsToComposite |= CompositingReasonAssumedOverlap; 294 reasonsToComposite |= CompositingReasonAssumedOverlap;
283 } 295 }
284 296
285 // Remove irrelevant unclipped descendants in reverse order so our stored 297 // Remove irrelevant unclipped descendants in reverse order so our stored
286 // indices remain valid. 298 // indices remain valid.
287 for (size_t i = 0; i < unclippedDescendantsToRemove.size(); i++) 299 for (size_t i = 0; i < unclippedDescendantsToRemove.size(); i++)
288 unclippedDescendants.remove(unclippedDescendantsToRemove.at( 300 unclippedDescendants.remove(unclippedDescendantsToRemove.at(
289 unclippedDescendantsToRemove.size() - i - 1)); 301 unclippedDescendantsToRemove.size() - i - 1));
290 302
291 if (layer->clipParent()) { 303 if (layer->clipParent()) {
292 // TODO(schenney): We only need to promote when the clipParent is not a de scendant of the ancestor scroller, 304 // TODO(schenney): We only need to promote when the clipParent is not a
293 // which we do not check for here. Hence we might be promoting needlessly. 305 // descendant of the ancestor scroller, which we do not check for here.
306 // Hence we might be promoting needlessly.
294 unclippedDescendants.append(layer); 307 unclippedDescendants.append(layer);
295 } 308 }
296 } 309 }
297 310
298 const IntRect& absBounds = layer->clippedAbsoluteBoundingBox(); 311 const IntRect& absBounds = layer->clippedAbsoluteBoundingBox();
299 absoluteDescendantBoundingBox = absBounds; 312 absoluteDescendantBoundingBox = absBounds;
300 313
301 if (currentRecursionData.m_testingOverlap && 314 if (currentRecursionData.m_testingOverlap &&
302 !requiresCompositingOrSquashing(directReasons)) 315 !requiresCompositingOrSquashing(directReasons))
303 overlapCompositingReason = overlapMap.overlapsLayers(absBounds) 316 overlapCompositingReason = overlapMap.overlapsLayers(absBounds)
304 ? CompositingReasonOverlap 317 ? CompositingReasonOverlap
305 : CompositingReasonNone; 318 : CompositingReasonNone;
306 319
307 reasonsToComposite |= overlapCompositingReason; 320 reasonsToComposite |= overlapCompositingReason;
308 321
309 // The children of this layer don't need to composite, unless there is 322 // The children of this layer don't need to composite, unless there is
310 // a compositing layer among them, so start by inheriting the compositing 323 // a compositing layer among them, so start by inheriting the compositing
311 // ancestor with m_subtreeIsCompositing set to false. 324 // ancestor with m_subtreeIsCompositing set to false.
312 RecursionData childRecursionData = currentRecursionData; 325 RecursionData childRecursionData = currentRecursionData;
313 childRecursionData.m_subtreeIsCompositing = false; 326 childRecursionData.m_subtreeIsCompositing = false;
314 327
315 bool willBeCompositedOrSquashed = 328 bool willBeCompositedOrSquashed =
316 canBeComposited && requiresCompositingOrSquashing(reasonsToComposite); 329 canBeComposited && requiresCompositingOrSquashing(reasonsToComposite);
317 if (willBeCompositedOrSquashed) { 330 if (willBeCompositedOrSquashed) {
318 // This layer now acts as the ancestor for kids. 331 // This layer now acts as the ancestor for kids.
319 childRecursionData.m_compositingAncestor = layer; 332 childRecursionData.m_compositingAncestor = layer;
320 333
321 // Here we know that all children and the layer's own contents can blindly p aint into 334 // Here we know that all children and the layer's own contents can blindly
322 // this layer's backing, until a descendant is composited. So, we don't need to check 335 // paint into this layer's backing, until a descendant is composited. So, we
323 // for overlap with anything behind this layer. 336 // don't need to check for overlap with anything behind this layer.
324 overlapMap.beginNewOverlapTestingContext(); 337 overlapMap.beginNewOverlapTestingContext();
325 // This layer is going to be composited, so children can safely ignore the f act that there's an 338 // This layer is going to be composited, so children can safely ignore the
326 // animation running behind this layer, meaning they can rely on the overlap map testing again. 339 // fact that there's an animation running behind this layer, meaning they
340 // can rely on the overlap map testing again.
327 childRecursionData.m_testingOverlap = true; 341 childRecursionData.m_testingOverlap = true;
328 } 342 }
329 343
330 #if ENABLE(ASSERT) 344 #if ENABLE(ASSERT)
331 LayerListMutationDetector mutationChecker(layer->stackingNode()); 345 LayerListMutationDetector mutationChecker(layer->stackingNode());
332 #endif 346 #endif
333 347
334 bool anyDescendantHas3DTransform = false; 348 bool anyDescendantHas3DTransform = false;
335 bool willHaveForegroundLayer = false; 349 bool willHaveForegroundLayer = false;
336 350
337 if (layer->stackingNode()->isStackingContext()) { 351 if (layer->stackingNode()->isStackingContext()) {
338 PaintLayerStackingNodeIterator iterator(*layer->stackingNode(), 352 PaintLayerStackingNodeIterator iterator(*layer->stackingNode(),
339 NegativeZOrderChildren); 353 NegativeZOrderChildren);
340 while (PaintLayerStackingNode* curNode = iterator.next()) { 354 while (PaintLayerStackingNode* curNode = iterator.next()) {
341 IntRect absoluteChildDescendantBoundingBox; 355 IntRect absoluteChildDescendantBoundingBox;
342 updateRecursive(layer, curNode->layer(), overlapMap, childRecursionData, 356 updateRecursive(layer, curNode->layer(), overlapMap, childRecursionData,
343 anyDescendantHas3DTransform, unclippedDescendants, 357 anyDescendantHas3DTransform, unclippedDescendants,
344 absoluteChildDescendantBoundingBox); 358 absoluteChildDescendantBoundingBox);
345 absoluteDescendantBoundingBox.unite(absoluteChildDescendantBoundingBox); 359 absoluteDescendantBoundingBox.unite(absoluteChildDescendantBoundingBox);
346 360
347 // If we have to make a layer for this child, make one now so we can have a contents layer 361 // If we have to make a layer for this child, make one now so we can have
348 // (since we need to ensure that the -ve z-order child renders underneath our contents). 362 // a contents layer (since we need to ensure that the -ve z-order child
363 // renders underneath our contents).
349 if (childRecursionData.m_subtreeIsCompositing) { 364 if (childRecursionData.m_subtreeIsCompositing) {
350 reasonsToComposite |= CompositingReasonNegativeZIndexChildren; 365 reasonsToComposite |= CompositingReasonNegativeZIndexChildren;
351 366
352 if (!willBeCompositedOrSquashed) { 367 if (!willBeCompositedOrSquashed) {
353 // make layer compositing 368 // make layer compositing
354 childRecursionData.m_compositingAncestor = layer; 369 childRecursionData.m_compositingAncestor = layer;
355 overlapMap.beginNewOverlapTestingContext(); 370 overlapMap.beginNewOverlapTestingContext();
356 willBeCompositedOrSquashed = true; 371 willBeCompositedOrSquashed = true;
357 willHaveForegroundLayer = true; 372 willHaveForegroundLayer = true;
358 373
359 // FIXME: temporary solution for the first negative z-index composited child: 374 // FIXME: temporary solution for the first negative z-index composited
360 // re-compute the absBounds for the child so that we can add th e 375 // child: re-compute the absBounds for the child so that we can add
361 // negative z-index child's bounds to the new overlap context. 376 // the negative z-index child's bounds to the new overlap context.
362 overlapMap.beginNewOverlapTestingContext(); 377 overlapMap.beginNewOverlapTestingContext();
363 overlapMap.add(curNode->layer(), 378 overlapMap.add(curNode->layer(),
364 curNode->layer()->clippedAbsoluteBoundingBox()); 379 curNode->layer()->clippedAbsoluteBoundingBox());
365 overlapMap.finishCurrentOverlapTestingContext(); 380 overlapMap.finishCurrentOverlapTestingContext();
366 } 381 }
367 } 382 }
368 } 383 }
369 } 384 }
370 385
371 if (willHaveForegroundLayer) { 386 if (willHaveForegroundLayer) {
372 ASSERT(willBeCompositedOrSquashed); 387 ASSERT(willBeCompositedOrSquashed);
373 // A foreground layer effectively is a new backing for all subsequent childr en, so 388 // A foreground layer effectively is a new backing for all subsequent
374 // we don't need to test for overlap with anything behind this. So, we can f inish 389 // children, so we don't need to test for overlap with anything behind this.
375 // the previous context that was accumulating rects for the negative z-index 390 // So, we can finish the previous context that was accumulating rects for
376 // children, and start with a fresh new empty context. 391 // the negative z-index children, and start with a fresh new empty context.
377 overlapMap.finishCurrentOverlapTestingContext(); 392 overlapMap.finishCurrentOverlapTestingContext();
378 overlapMap.beginNewOverlapTestingContext(); 393 overlapMap.beginNewOverlapTestingContext();
379 // This layer is going to be composited, so children can safely ignore the f act that there's an 394 // This layer is going to be composited, so children can safely ignore the
380 // animation running behind this layer, meaning they can rely on the overlap map testing again 395 // fact that there's an animation running behind this layer, meaning they
396 // can rely on the overlap map testing again.
381 childRecursionData.m_testingOverlap = true; 397 childRecursionData.m_testingOverlap = true;
382 } 398 }
383 399
384 PaintLayerStackingNodeIterator iterator( 400 PaintLayerStackingNodeIterator iterator(
385 *layer->stackingNode(), NormalFlowChildren | PositiveZOrderChildren); 401 *layer->stackingNode(), NormalFlowChildren | PositiveZOrderChildren);
386 while (PaintLayerStackingNode* curNode = iterator.next()) { 402 while (PaintLayerStackingNode* curNode = iterator.next()) {
387 IntRect absoluteChildDescendantBoundingBox; 403 IntRect absoluteChildDescendantBoundingBox;
388 updateRecursive(layer, curNode->layer(), overlapMap, childRecursionData, 404 updateRecursive(layer, curNode->layer(), overlapMap, childRecursionData,
389 anyDescendantHas3DTransform, unclippedDescendants, 405 anyDescendantHas3DTransform, unclippedDescendants,
390 absoluteChildDescendantBoundingBox); 406 absoluteChildDescendantBoundingBox);
391 absoluteDescendantBoundingBox.unite(absoluteChildDescendantBoundingBox); 407 absoluteDescendantBoundingBox.unite(absoluteChildDescendantBoundingBox);
392 } 408 }
393 409
394 // Now that the subtree has been traversed, we can check for compositing reaso ns that depended on the state of the subtree. 410 // Now that the subtree has been traversed, we can check for compositing
411 // reasons that depended on the state of the subtree.
395 412
396 if (layer->stackingNode()->isStackingContext()) { 413 if (layer->stackingNode()->isStackingContext()) {
397 layer->setShouldIsolateCompositedDescendants( 414 layer->setShouldIsolateCompositedDescendants(
398 childRecursionData.m_hasUnisolatedCompositedBlendingDescendant); 415 childRecursionData.m_hasUnisolatedCompositedBlendingDescendant);
399 } else { 416 } else {
400 layer->setShouldIsolateCompositedDescendants(false); 417 layer->setShouldIsolateCompositedDescendants(false);
401 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = 418 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant =
402 childRecursionData.m_hasUnisolatedCompositedBlendingDescendant; 419 childRecursionData.m_hasUnisolatedCompositedBlendingDescendant;
403 } 420 }
404 421
405 // Subsequent layers in the parent's stacking context may also need to composi te. 422 // Subsequent layers in the parent's stacking context may also need to
423 // composite.
406 if (childRecursionData.m_subtreeIsCompositing) 424 if (childRecursionData.m_subtreeIsCompositing)
407 currentRecursionData.m_subtreeIsCompositing = true; 425 currentRecursionData.m_subtreeIsCompositing = true;
408 426
409 // Set the flag to say that this SC has compositing children. 427 // Set the flag to say that this SC has compositing children.
410 layer->setHasCompositingDescendant(childRecursionData.m_subtreeIsCompositing); 428 layer->setHasCompositingDescendant(childRecursionData.m_subtreeIsCompositing);
411 429
412 if (layer->isRootLayer()) { 430 if (layer->isRootLayer()) {
413 // The root layer needs to be composited if anything else in the tree is com posited. 431 // The root layer needs to be composited if anything else in the tree is
414 // Otherwise, we can disable compositing entirely. 432 // composited. Otherwise, we can disable compositing entirely.
415 if (childRecursionData.m_subtreeIsCompositing || 433 if (childRecursionData.m_subtreeIsCompositing ||
416 requiresCompositingOrSquashing(reasonsToComposite) || 434 requiresCompositingOrSquashing(reasonsToComposite) ||
417 compositor->rootShouldAlwaysComposite()) { 435 compositor->rootShouldAlwaysComposite()) {
418 reasonsToComposite |= CompositingReasonRoot; 436 reasonsToComposite |= CompositingReasonRoot;
419 currentRecursionData.m_subtreeIsCompositing = true; 437 currentRecursionData.m_subtreeIsCompositing = true;
420 } else { 438 } else {
421 compositor->setCompositingModeEnabled(false); 439 compositor->setCompositingModeEnabled(false);
422 reasonsToComposite = CompositingReasonNone; 440 reasonsToComposite = CompositingReasonNone;
423 } 441 }
424 } else { 442 } else {
425 // All layers (even ones that aren't being composited) need to get added to 443 // All layers (even ones that aren't being composited) need to get added to
426 // the overlap map. Layers that are not separately composited will paint int o their 444 // the overlap map. Layers that are not separately composited will paint
427 // compositing ancestor's backing, and so are still considered for overlap. 445 // into their compositing ancestor's backing, and so are still considered
446 // for overlap.
428 if (childRecursionData.m_compositingAncestor && 447 if (childRecursionData.m_compositingAncestor &&
429 !childRecursionData.m_compositingAncestor->isRootLayer()) 448 !childRecursionData.m_compositingAncestor->isRootLayer())
430 overlapMap.add(layer, absBounds); 449 overlapMap.add(layer, absBounds);
431 450
432 // Now check for reasons to become composited that depend on the state of de scendant layers. 451 // Now check for reasons to become composited that depend on the state of
452 // descendant layers.
433 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing( 453 CompositingReasons subtreeCompositingReasons = subtreeReasonsForCompositing(
434 layer, childRecursionData.m_subtreeIsCompositing, 454 layer, childRecursionData.m_subtreeIsCompositing,
435 anyDescendantHas3DTransform); 455 anyDescendantHas3DTransform);
436 reasonsToComposite |= subtreeCompositingReasons; 456 reasonsToComposite |= subtreeCompositingReasons;
437 if (!willBeCompositedOrSquashed && canBeComposited && 457 if (!willBeCompositedOrSquashed && canBeComposited &&
438 requiresCompositingOrSquashing(subtreeCompositingReasons)) { 458 requiresCompositingOrSquashing(subtreeCompositingReasons)) {
439 childRecursionData.m_compositingAncestor = layer; 459 childRecursionData.m_compositingAncestor = layer;
440 // FIXME: this context push is effectively a no-op but needs to exist for 460 // FIXME: this context push is effectively a no-op but needs to exist for
441 // now, because the code is designed to push overlap information to the 461 // now, because the code is designed to push overlap information to the
442 // second-from-top context of the stack. 462 // second-from-top context of the stack.
443 overlapMap.beginNewOverlapTestingContext(); 463 overlapMap.beginNewOverlapTestingContext();
444 overlapMap.add(layer, absoluteDescendantBoundingBox); 464 overlapMap.add(layer, absoluteDescendantBoundingBox);
445 willBeCompositedOrSquashed = true; 465 willBeCompositedOrSquashed = true;
446 } 466 }
447 467
448 if (willBeCompositedOrSquashed) 468 if (willBeCompositedOrSquashed)
449 reasonsToComposite |= layer->potentialCompositingReasonsFromStyle() & 469 reasonsToComposite |= layer->potentialCompositingReasonsFromStyle() &
450 CompositingReasonInlineTransform; 470 CompositingReasonInlineTransform;
451 471
452 if (willBeCompositedOrSquashed && 472 if (willBeCompositedOrSquashed &&
453 layer->layoutObject()->style()->hasBlendMode()) 473 layer->layoutObject()->style()->hasBlendMode())
454 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = true; 474 currentRecursionData.m_hasUnisolatedCompositedBlendingDescendant = true;
455 475
456 // Tell the parent it has compositing descendants. 476 // Tell the parent it has compositing descendants.
457 if (willBeCompositedOrSquashed) 477 if (willBeCompositedOrSquashed)
458 currentRecursionData.m_subtreeIsCompositing = true; 478 currentRecursionData.m_subtreeIsCompositing = true;
459 479
460 // Turn overlap testing off for later layers if it's already off, or if we h ave an animating transform. 480 // Turn overlap testing off for later layers if it's already off, or if we
461 // Note that if the layer clips its descendants, there's no reason to propag ate the child animation to the parent layers. That's because 481 // have an animating transform. Note that if the layer clips its
462 // we know for sure the animation is contained inside the clipping rectangle , which is already added to the overlap map. 482 // descendants, there's no reason to propagate the child animation to the
483 // parent layers. That's because we know for sure the animation is contained
484 // inside the clipping rectangle, which is already added to the overlap map.
463 bool isCompositedClippingLayer = 485 bool isCompositedClippingLayer =
464 canBeComposited && 486 canBeComposited &&
465 (reasonsToComposite & CompositingReasonClipsCompositingDescendants); 487 (reasonsToComposite & CompositingReasonClipsCompositingDescendants);
466 bool isCompositedWithInlineTransform = 488 bool isCompositedWithInlineTransform =
467 reasonsToComposite & CompositingReasonInlineTransform; 489 reasonsToComposite & CompositingReasonInlineTransform;
468 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) || 490 if ((!childRecursionData.m_testingOverlap && !isCompositedClippingLayer) ||
469 layer->layoutObject()->style()->hasCurrentTransformAnimation() || 491 layer->layoutObject()->style()->hasCurrentTransformAnimation() ||
470 isCompositedWithInlineTransform) 492 isCompositedWithInlineTransform)
471 currentRecursionData.m_testingOverlap = false; 493 currentRecursionData.m_testingOverlap = false;
472 494
473 if (childRecursionData.m_compositingAncestor == layer) 495 if (childRecursionData.m_compositingAncestor == layer)
474 overlapMap.finishCurrentOverlapTestingContext(); 496 overlapMap.finishCurrentOverlapTestingContext();
475 497
476 descendantHas3DTransform |= 498 descendantHas3DTransform |=
477 anyDescendantHas3DTransform || layer->has3DTransform(); 499 anyDescendantHas3DTransform || layer->has3DTransform();
478 } 500 }
479 501
480 // At this point we have finished collecting all reasons to composite this lay er. 502 // At this point we have finished collecting all reasons to composite this
503 // layer.
481 layer->setCompositingReasons(reasonsToComposite); 504 layer->setCompositingReasons(reasonsToComposite);
482 } 505 }
483 506
484 } // namespace blink 507 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698