OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
5 * | 5 * |
6 * Other contributors: | 6 * Other contributors: |
7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 #include "wtf/StdLibExtras.h" | 90 #include "wtf/StdLibExtras.h" |
91 #include "wtf/text/CString.h" | 91 #include "wtf/text/CString.h" |
92 | 92 |
93 namespace blink { | 93 namespace blink { |
94 | 94 |
95 namespace { | 95 namespace { |
96 | 96 |
97 static CompositingQueryMode gCompositingQueryMode = | 97 static CompositingQueryMode gCompositingQueryMode = |
98 CompositingQueriesAreOnlyAllowedInCertainDocumentLifecyclePhases; | 98 CompositingQueriesAreOnlyAllowedInCertainDocumentLifecyclePhases; |
99 | 99 |
100 struct SameSizeAsPaintLayer : DisplayItemClient { | |
chrishtr
2016/01/28 18:04:29
Isn't there already one of these?
Xianzhu
2016/01/28 18:30:30
Here we have several ways count the vtable pointer
| |
101 int bitFields; | |
102 void* pointers[8]; | |
103 LayoutUnit layoutUnits[4]; | |
104 IntSize size; | |
105 OwnPtrWillBePersistent<PaintLayerScrollableArea> scrollableArea; | |
106 struct { | |
107 IntRect rect; | |
108 void* pointers[2]; | |
109 } ancestorCompositingInputs; | |
110 struct { | |
111 void* pointers[2]; | |
112 } clipper; | |
113 struct { | |
114 IntSize size; | |
115 void* pointer; | |
116 LayoutRect rect; | |
117 } previousPaintStatus; | |
118 }; | |
119 | |
120 static_assert(sizeof(PaintLayer) == sizeof(SameSizeAsPaintLayer), "PaintLayer sh ould stay small"); | |
121 | |
100 } // namespace | 122 } // namespace |
101 | 123 |
102 using namespace HTMLNames; | 124 using namespace HTMLNames; |
103 | 125 |
126 PaintLayerRareData::PaintLayerRareData() | |
127 : enclosingPaginationLayer(nullptr) | |
128 , potentialCompositingReasonsFromStyle(CompositingReasonNone) | |
129 , compositingReasons(CompositingReasonNone) | |
130 , groupedMapping(nullptr) | |
131 { | |
132 } | |
133 | |
134 PaintLayerRareData::~PaintLayerRareData() | |
135 { | |
136 } | |
137 | |
104 PaintLayer::PaintLayer(LayoutBoxModelObject* layoutObject, PaintLayerType type) | 138 PaintLayer::PaintLayer(LayoutBoxModelObject* layoutObject, PaintLayerType type) |
105 : m_layerType(type) | 139 : m_layerType(type) |
106 , m_hasSelfPaintingLayerDescendant(false) | 140 , m_hasSelfPaintingLayerDescendant(false) |
107 , m_hasSelfPaintingLayerDescendantDirty(false) | 141 , m_hasSelfPaintingLayerDescendantDirty(false) |
108 , m_isRootLayer(layoutObject->isLayoutView()) | 142 , m_isRootLayer(layoutObject->isLayoutView()) |
109 , m_visibleContentStatusDirty(true) | 143 , m_visibleContentStatusDirty(true) |
110 , m_hasVisibleContent(false) | 144 , m_hasVisibleContent(false) |
111 , m_visibleDescendantStatusDirty(false) | 145 , m_visibleDescendantStatusDirty(false) |
112 , m_hasVisibleDescendant(false) | 146 , m_hasVisibleDescendant(false) |
113 , m_hasVisibleNonLayerContent(false) | 147 , m_hasVisibleNonLayerContent(false) |
114 #if ENABLE(ASSERT) | 148 #if ENABLE(ASSERT) |
115 , m_needsPositionUpdate(true) | 149 , m_needsPositionUpdate(true) |
116 #endif | 150 #endif |
117 , m_3DTransformedDescendantStatusDirty(true) | 151 , m_3DTransformedDescendantStatusDirty(true) |
118 , m_has3DTransformedDescendant(false) | 152 , m_has3DTransformedDescendant(false) |
119 , m_containsDirtyOverlayScrollbars(false) | 153 , m_containsDirtyOverlayScrollbars(false) |
120 , m_hasFilterInfo(false) | 154 , m_hasFilterInfo(false) |
121 , m_needsAncestorDependentCompositingInputsUpdate(true) | 155 , m_needsAncestorDependentCompositingInputsUpdate(true) |
122 , m_needsDescendantDependentCompositingInputsUpdate(true) | 156 , m_needsDescendantDependentCompositingInputsUpdate(true) |
123 , m_childNeedsCompositingInputsUpdate(true) | 157 , m_childNeedsCompositingInputsUpdate(true) |
124 , m_hasCompositingDescendant(false) | 158 , m_hasCompositingDescendant(false) |
125 , m_hasNonCompositedChild(false) | 159 , m_hasNonCompositedChild(false) |
126 , m_shouldIsolateCompositedDescendants(false) | 160 , m_shouldIsolateCompositedDescendants(false) |
127 , m_lostGroupedMapping(false) | 161 , m_lostGroupedMapping(false) |
128 , m_needsRepaint(false) | 162 , m_needsRepaint(false) |
129 , m_previousPaintResult(PaintLayerPainter::FullyPainted) | 163 , m_previousPaintResult(PaintLayerPainter::FullyPainted) |
130 , m_needsPaintPhaseDescendantOutlines(false) | 164 , m_needsPaintPhaseDescendantOutlines(false) |
131 , m_needsPaintPhaseFloat(false) | 165 , m_needsPaintPhaseFloat(false) |
166 , m_hasDescendantWithClipPath(false) | |
167 , m_hasNonIsolatedDescendantWithBlendMode(false) | |
168 , m_hasAncestorWithClipPath(false) | |
132 , m_layoutObject(layoutObject) | 169 , m_layoutObject(layoutObject) |
133 , m_parent(0) | 170 , m_parent(0) |
134 , m_previous(0) | 171 , m_previous(0) |
135 , m_next(0) | 172 , m_next(0) |
136 , m_first(0) | 173 , m_first(0) |
137 , m_last(0) | 174 , m_last(0) |
138 , m_staticInlinePosition(0) | 175 , m_staticInlinePosition(0) |
139 , m_staticBlockPosition(0) | 176 , m_staticBlockPosition(0) |
140 , m_enclosingPaginationLayer(0) | |
141 , m_potentialCompositingReasonsFromStyle(CompositingReasonNone) | |
142 , m_compositingReasons(CompositingReasonNone) | |
143 , m_groupedMapping(0) | |
144 , m_clipper(*layoutObject) | 177 , m_clipper(*layoutObject) |
145 { | 178 { |
146 updateStackingNode(); | 179 updateStackingNode(); |
147 | 180 |
148 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); | 181 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); |
149 | 182 |
150 if (!layoutObject->slowFirstChild() && layoutObject->style()) { | 183 if (!layoutObject->slowFirstChild() && layoutObject->style()) { |
151 m_visibleContentStatusDirty = false; | 184 m_visibleContentStatusDirty = false; |
152 m_hasVisibleContent = layoutObject->style()->visibility() == VISIBLE; | 185 m_hasVisibleContent = layoutObject->style()->visibility() == VISIBLE; |
153 } | 186 } |
(...skipping 13 matching lines...) Expand all Loading... | |
167 if (groupedMapping()) { | 200 if (groupedMapping()) { |
168 DisableCompositingQueryAsserts disabler; | 201 DisableCompositingQueryAsserts disabler; |
169 setGroupedMapping(0, InvalidateLayerAndRemoveFromMapping); | 202 setGroupedMapping(0, InvalidateLayerAndRemoveFromMapping); |
170 } | 203 } |
171 | 204 |
172 // Child layers will be deleted by their corresponding layout objects, so | 205 // Child layers will be deleted by their corresponding layout objects, so |
173 // we don't need to delete them ourselves. | 206 // we don't need to delete them ourselves. |
174 | 207 |
175 clearCompositedLayerMapping(true); | 208 clearCompositedLayerMapping(true); |
176 | 209 |
177 if (m_reflectionInfo) | 210 if (PaintLayerReflectionInfo* reflectionInfo = this->reflectionInfo()) |
178 m_reflectionInfo->destroy(); | 211 reflectionInfo->destroy(); |
179 | 212 |
180 if (m_scrollableArea) | 213 if (m_scrollableArea) |
181 m_scrollableArea->dispose(); | 214 m_scrollableArea->dispose(); |
182 } | 215 } |
183 | 216 |
184 String PaintLayer::debugName() const | 217 String PaintLayer::debugName() const |
185 { | 218 { |
186 if (isReflection()) | 219 if (isReflection()) |
187 return layoutObject()->parent()->debugName() + " (reflection)"; | 220 return layoutObject()->parent()->debugName() + " (reflection)"; |
188 return layoutObject()->debugName(); | 221 return layoutObject()->debugName(); |
(...skipping 24 matching lines...) Expand all Loading... | |
213 compositor()->setNeedsCompositingUpdate(CompositingUpdateAfterCompositin gInputChange); | 246 compositor()->setNeedsCompositingUpdate(CompositingUpdateAfterCompositin gInputChange); |
214 | 247 |
215 // Although we're missing test coverage, we need to call | 248 // Although we're missing test coverage, we need to call |
216 // GraphicsLayer::setContentsToPlatformLayer with the new platform | 249 // GraphicsLayer::setContentsToPlatformLayer with the new platform |
217 // layer for this canvas. | 250 // layer for this canvas. |
218 // See http://crbug.com/349195 | 251 // See http://crbug.com/349195 |
219 if (hasCompositedLayerMapping()) | 252 if (hasCompositedLayerMapping()) |
220 compositedLayerMapping()->setNeedsGraphicsLayerUpdate(GraphicsLayerU pdateSubtree); | 253 compositedLayerMapping()->setNeedsGraphicsLayerUpdate(GraphicsLayerU pdateSubtree); |
221 } | 254 } |
222 | 255 |
223 if (m_compositedLayerMapping) | 256 if (CompositedLayerMapping* compositedLayerMapping = this->compositedLayerMa pping()) |
224 m_compositedLayerMapping->contentChanged(changeType); | 257 compositedLayerMapping->contentChanged(changeType); |
225 } | 258 } |
226 | 259 |
227 bool PaintLayer::paintsWithFilters() const | 260 bool PaintLayer::paintsWithFilters() const |
228 { | 261 { |
229 if (!layoutObject()->hasFilter()) | 262 if (!layoutObject()->hasFilter()) |
230 return false; | 263 return false; |
231 | 264 |
232 // https://code.google.com/p/chromium/issues/detail?id=343759 | 265 // https://code.google.com/p/chromium/issues/detail?id=343759 |
233 DisableCompositingQueryAsserts disabler; | 266 DisableCompositingQueryAsserts disabler; |
234 return !m_compositedLayerMapping || compositingState() != PaintsIntoOwnBacki ng; | 267 return !compositedLayerMapping() || compositingState() != PaintsIntoOwnBacki ng; |
235 } | 268 } |
236 | 269 |
237 bool PaintLayer::paintsWithBackdropFilters() const | 270 bool PaintLayer::paintsWithBackdropFilters() const |
238 { | 271 { |
239 if (!layoutObject()->hasBackdropFilter()) | 272 if (!layoutObject()->hasBackdropFilter()) |
240 return false; | 273 return false; |
241 | 274 |
242 // https://code.google.com/p/chromium/issues/detail?id=343759 | 275 // https://code.google.com/p/chromium/issues/detail?id=343759 |
243 DisableCompositingQueryAsserts disabler; | 276 DisableCompositingQueryAsserts disabler; |
244 return !m_compositedLayerMapping || compositingState() != PaintsIntoOwnBacki ng; | 277 return !compositedLayerMapping() || compositingState() != PaintsIntoOwnBacki ng; |
245 } | 278 } |
246 | 279 |
247 LayoutSize PaintLayer::subpixelAccumulation() const | 280 LayoutSize PaintLayer::subpixelAccumulation() const |
248 { | 281 { |
249 return m_subpixelAccumulation; | 282 return m_rareData ? m_rareData->subpixelAccumulation : LayoutSize(); |
250 } | 283 } |
251 | 284 |
252 void PaintLayer::setSubpixelAccumulation(const LayoutSize& size) | 285 void PaintLayer::setSubpixelAccumulation(const LayoutSize& size) |
253 { | 286 { |
254 m_subpixelAccumulation = size; | 287 if (m_rareData || !size.isZero()) |
288 ensureRareData().subpixelAccumulation = size; | |
255 } | 289 } |
256 | 290 |
257 void PaintLayer::updateLayerPositionsAfterLayout() | 291 void PaintLayer::updateLayerPositionsAfterLayout() |
258 { | 292 { |
259 TRACE_EVENT0("blink,benchmark", "PaintLayer::updateLayerPositionsAfterLayout "); | 293 TRACE_EVENT0("blink,benchmark", "PaintLayer::updateLayerPositionsAfterLayout "); |
260 | 294 |
261 m_clipper.clearClipRectsIncludingDescendants(); | 295 m_clipper.clearClipRectsIncludingDescendants(); |
262 updateLayerPositionRecursive(); | 296 updateLayerPositionRecursive(); |
263 | 297 |
264 { | 298 { |
265 // FIXME: Remove incremental compositing updates after fixing the chicke n/egg issues | 299 // FIXME: Remove incremental compositing updates after fixing the chicke n/egg issues |
266 // https://code.google.com/p/chromium/issues/detail?id=343756 | 300 // https://code.google.com/p/chromium/issues/detail?id=343756 |
267 DisableCompositingQueryAsserts disabler; | 301 DisableCompositingQueryAsserts disabler; |
268 updatePaginationRecursive(enclosingPaginationLayer()); | 302 updatePaginationRecursive(enclosingPaginationLayer()); |
269 } | 303 } |
270 } | 304 } |
271 | 305 |
272 void PaintLayer::updateLayerPositionRecursive() | 306 void PaintLayer::updateLayerPositionRecursive() |
273 { | 307 { |
274 updateLayerPosition(); | 308 updateLayerPosition(); |
275 | 309 |
276 if (m_reflectionInfo) | 310 if (m_rareData && m_rareData->reflectionInfo) |
277 m_reflectionInfo->reflection()->layout(); | 311 m_rareData->reflectionInfo->reflection()->layout(); |
278 | 312 |
279 // FIXME(400589): We would like to do this in PaintLayerScrollableArea::upda teAfterLayout, | 313 // FIXME(400589): We would like to do this in PaintLayerScrollableArea::upda teAfterLayout, |
280 // but it depends on the size computed by updateLayerPosition. | 314 // but it depends on the size computed by updateLayerPosition. |
281 if (m_scrollableArea) { | 315 if (m_scrollableArea) { |
282 if (ScrollAnimatorBase* scrollAnimator = m_scrollableArea->existingScrol lAnimator()) | 316 if (ScrollAnimatorBase* scrollAnimator = m_scrollableArea->existingScrol lAnimator()) |
283 scrollAnimator->updateAfterLayout(); | 317 scrollAnimator->updateAfterLayout(); |
284 } | 318 } |
285 | 319 |
286 // FIXME: We should be able to remove this call because we don't care about | 320 // FIXME: We should be able to remove this call because we don't care about |
287 // any descendant-dependent flags, but code somewhere else is reading these | 321 // any descendant-dependent flags, but code somewhere else is reading these |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 m_layoutObject->adjustPreviousPaintInvalidationForScrollIfNeeded(scrollD elta); | 385 m_layoutObject->adjustPreviousPaintInvalidationForScrollIfNeeded(scrollD elta); |
352 } | 386 } |
353 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) { | 387 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) { |
354 child->updateLayerPositionsAfterScrollRecursive(scrollDelta, | 388 child->updateLayerPositionsAfterScrollRecursive(scrollDelta, |
355 paintInvalidationContainerWasScrolled && !child->isPaintInvalidation Container()); | 389 paintInvalidationContainerWasScrolled && !child->isPaintInvalidation Container()); |
356 } | 390 } |
357 } | 391 } |
358 | 392 |
359 void PaintLayer::updateTransformationMatrix() | 393 void PaintLayer::updateTransformationMatrix() |
360 { | 394 { |
361 if (m_transform) { | 395 if (TransformationMatrix* transform = this->transform()) { |
362 LayoutBox* box = layoutBox(); | 396 LayoutBox* box = layoutBox(); |
363 ASSERT(box); | 397 ASSERT(box); |
364 m_transform->makeIdentity(); | 398 transform->makeIdentity(); |
365 box->style()->applyTransform(*m_transform, LayoutSize(box->pixelSnappedS ize()), ComputedStyle::IncludeTransformOrigin, ComputedStyle::IncludeMotionPath, ComputedStyle::IncludeIndependentTransformProperties); | 399 box->style()->applyTransform(*transform, LayoutSize(box->pixelSnappedSiz e()), ComputedStyle::IncludeTransformOrigin, ComputedStyle::IncludeMotionPath, C omputedStyle::IncludeIndependentTransformProperties); |
366 makeMatrixRenderable(*m_transform, compositor()->hasAcceleratedCompositi ng()); | 400 makeMatrixRenderable(*transform, compositor()->hasAcceleratedCompositing ()); |
367 } | 401 } |
368 } | 402 } |
369 | 403 |
370 void PaintLayer::updateTransform(const ComputedStyle* oldStyle, const ComputedSt yle& newStyle) | 404 void PaintLayer::updateTransform(const ComputedStyle* oldStyle, const ComputedSt yle& newStyle) |
371 { | 405 { |
372 if (oldStyle && newStyle.transformDataEquivalent(*oldStyle)) | 406 if (oldStyle && newStyle.transformDataEquivalent(*oldStyle)) |
373 return; | 407 return; |
374 | 408 |
375 // hasTransform() on the layoutObject is also true when there is transform-s tyle: preserve-3d or perspective set, | 409 // hasTransform() on the layoutObject is also true when there is transform-s tyle: preserve-3d or perspective set, |
376 // so check style too. | 410 // so check style too. |
377 bool hasTransform = layoutObject()->hasTransformRelatedProperty() && newStyl e.hasTransform(); | 411 bool hasTransform = layoutObject()->hasTransformRelatedProperty() && newStyl e.hasTransform(); |
378 bool had3DTransform = has3DTransform(); | 412 bool had3DTransform = has3DTransform(); |
379 | 413 |
380 bool hadTransform = m_transform; | 414 bool hadTransform = transform(); |
381 if (hasTransform != hadTransform) { | 415 if (hasTransform != hadTransform) { |
382 if (hasTransform) | 416 if (hasTransform) |
383 m_transform = adoptPtr(new TransformationMatrix); | 417 ensureRareData().transform = adoptPtr(new TransformationMatrix); |
384 else | 418 else |
385 m_transform.clear(); | 419 m_rareData->transform.clear(); |
386 | 420 |
387 // PaintLayers with transforms act as clip rects roots, so clear the cac hed clip rects here. | 421 // PaintLayers with transforms act as clip rects roots, so clear the cac hed clip rects here. |
388 m_clipper.clearClipRectsIncludingDescendants(); | 422 m_clipper.clearClipRectsIncludingDescendants(); |
389 } else if (hasTransform) { | 423 } else if (hasTransform) { |
390 m_clipper.clearClipRectsIncludingDescendants(AbsoluteClipRects); | 424 m_clipper.clearClipRectsIncludingDescendants(AbsoluteClipRects); |
391 } | 425 } |
392 | 426 |
393 updateTransformationMatrix(); | 427 updateTransformationMatrix(); |
394 | 428 |
395 if (had3DTransform != has3DTransform()) | 429 if (had3DTransform != has3DTransform()) |
(...skipping 15 matching lines...) Expand all Loading... | |
411 renderingContext = this; | 445 renderingContext = this; |
412 | 446 |
413 for (PaintLayer* current = enclosingLayerForContainingBlock(this); current & & current->shouldPreserve3D(); current = enclosingLayerForContainingBlock(curren t)) | 447 for (PaintLayer* current = enclosingLayerForContainingBlock(this); current & & current->shouldPreserve3D(); current = enclosingLayerForContainingBlock(curren t)) |
414 renderingContext = current; | 448 renderingContext = current; |
415 | 449 |
416 return renderingContext; | 450 return renderingContext; |
417 } | 451 } |
418 | 452 |
419 TransformationMatrix PaintLayer::currentTransform() const | 453 TransformationMatrix PaintLayer::currentTransform() const |
420 { | 454 { |
421 if (!m_transform) | 455 if (TransformationMatrix* transform = this->transform()) |
422 return TransformationMatrix(); | 456 return *transform; |
423 return *m_transform; | 457 return TransformationMatrix(); |
424 } | 458 } |
425 | 459 |
426 TransformationMatrix PaintLayer::renderableTransform(GlobalPaintFlags globalPain tFlags) const | 460 TransformationMatrix PaintLayer::renderableTransform(GlobalPaintFlags globalPain tFlags) const |
427 { | 461 { |
428 if (!m_transform) | 462 TransformationMatrix* transform = this->transform(); |
463 if (!transform) | |
429 return TransformationMatrix(); | 464 return TransformationMatrix(); |
430 | 465 |
431 if (globalPaintFlags & GlobalPaintFlattenCompositingLayers) { | 466 if (globalPaintFlags & GlobalPaintFlattenCompositingLayers) { |
432 TransformationMatrix matrix = *m_transform; | 467 TransformationMatrix matrix = *transform; |
433 makeMatrixRenderable(matrix, false /* flatten 3d */); | 468 makeMatrixRenderable(matrix, false /* flatten 3d */); |
434 return matrix; | 469 return matrix; |
435 } | 470 } |
436 | 471 |
437 return *m_transform; | 472 return *transform; |
438 } | 473 } |
439 | 474 |
440 void PaintLayer::convertFromFlowThreadToVisualBoundingBoxInAncestor(const PaintL ayer* ancestorLayer, LayoutRect& rect) const | 475 void PaintLayer::convertFromFlowThreadToVisualBoundingBoxInAncestor(const PaintL ayer* ancestorLayer, LayoutRect& rect) const |
441 { | 476 { |
442 PaintLayer* paginationLayer = enclosingPaginationLayer(); | 477 PaintLayer* paginationLayer = enclosingPaginationLayer(); |
443 ASSERT(paginationLayer); | 478 ASSERT(paginationLayer); |
444 LayoutFlowThread* flowThread = toLayoutFlowThread(paginationLayer->layoutObj ect()); | 479 LayoutFlowThread* flowThread = toLayoutFlowThread(paginationLayer->layoutObj ect()); |
445 | 480 |
446 // First make the flow thread rectangle relative to the flow thread, not to |layer|. | 481 // First make the flow thread rectangle relative to the flow thread, not to |layer|. |
447 LayoutPoint offsetWithinPaginationLayer; | 482 LayoutPoint offsetWithinPaginationLayer; |
(...skipping 10 matching lines...) Expand all Loading... | |
458 rect.moveBy(paginationLayer->visualOffsetFromAncestor(ancestorLayer)); | 493 rect.moveBy(paginationLayer->visualOffsetFromAncestor(ancestorLayer)); |
459 return; | 494 return; |
460 } | 495 } |
461 // The ancestor layer is inside the same pagination layer as |layer|, so we need to subtract | 496 // The ancestor layer is inside the same pagination layer as |layer|, so we need to subtract |
462 // the visual distance from the ancestor layer to the pagination layer. | 497 // the visual distance from the ancestor layer to the pagination layer. |
463 rect.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer)); | 498 rect.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer)); |
464 } | 499 } |
465 | 500 |
466 void PaintLayer::updatePaginationRecursive(bool needsPaginationUpdate) | 501 void PaintLayer::updatePaginationRecursive(bool needsPaginationUpdate) |
467 { | 502 { |
468 m_enclosingPaginationLayer = 0; | 503 if (m_rareData) |
504 m_rareData->enclosingPaginationLayer = nullptr; | |
469 | 505 |
470 if (layoutObject()->isLayoutFlowThread()) | 506 if (layoutObject()->isLayoutFlowThread()) |
471 needsPaginationUpdate = true; | 507 needsPaginationUpdate = true; |
472 | 508 |
473 if (needsPaginationUpdate) { | 509 if (needsPaginationUpdate) { |
474 // Each paginated layer has to paint on its own. There is no recurring i nto child layers. Each | 510 // Each paginated layer has to paint on its own. There is no recurring i nto child layers. Each |
475 // layer has to be checked individually and genuinely know if it is goin g to have to split | 511 // layer has to be checked individually and genuinely know if it is goin g to have to split |
476 // itself up when painting only its contents (and not any other descenda nt layers). We track an | 512 // itself up when painting only its contents (and not any other descenda nt layers). We track an |
477 // enclosingPaginationLayer instead of using a simple bit, since we want to be able to get back | 513 // enclosingPaginationLayer instead of using a simple bit, since we want to be able to get back |
478 // to that layer easily. | 514 // to that layer easily. |
479 if (LayoutFlowThread* containingFlowThread = layoutObject()->flowThreadC ontainingBlock()) | 515 if (LayoutFlowThread* containingFlowThread = layoutObject()->flowThreadC ontainingBlock()) |
480 m_enclosingPaginationLayer = containingFlowThread->layer(); | 516 ensureRareData().enclosingPaginationLayer = containingFlowThread->la yer(); |
481 } | 517 } |
482 | 518 |
483 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) | 519 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) |
484 child->updatePaginationRecursive(needsPaginationUpdate); | 520 child->updatePaginationRecursive(needsPaginationUpdate); |
485 } | 521 } |
486 | 522 |
487 void PaintLayer::clearPaginationRecursive() | 523 void PaintLayer::clearPaginationRecursive() |
488 { | 524 { |
489 m_enclosingPaginationLayer = 0; | 525 if (m_rareData) |
526 m_rareData->enclosingPaginationLayer = nullptr; | |
490 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) | 527 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) |
491 child->clearPaginationRecursive(); | 528 child->clearPaginationRecursive(); |
492 } | 529 } |
493 | 530 |
494 LayoutPoint PaintLayer::positionFromPaintInvalidationBacking(const LayoutObject* layoutObject, const LayoutBoxModelObject* paintInvalidationContainer, const Pai ntInvalidationState* paintInvalidationState) | 531 LayoutPoint PaintLayer::positionFromPaintInvalidationBacking(const LayoutObject* layoutObject, const LayoutBoxModelObject* paintInvalidationContainer, const Pai ntInvalidationState* paintInvalidationState) |
495 { | 532 { |
496 FloatPoint point = layoutObject->localToAncestorPoint(FloatPoint(), paintInv alidationContainer, 0, 0, paintInvalidationState); | 533 FloatPoint point = layoutObject->localToAncestorPoint(FloatPoint(), paintInv alidationContainer, 0, 0, paintInvalidationState); |
497 | 534 |
498 // FIXME: Eventually we are going to unify coordinates in GraphicsLayer spac e. | 535 // FIXME: Eventually we are going to unify coordinates in GraphicsLayer spac e. |
499 if (paintInvalidationContainer && paintInvalidationContainer->layer()->group edMapping()) | 536 if (paintInvalidationContainer && paintInvalidationContainer->layer()->group edMapping()) |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
766 localPoint += offset; | 803 localPoint += offset; |
767 } | 804 } |
768 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) { | 805 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) { |
769 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset(); | 806 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset(); |
770 localPoint -= scrollOffset; | 807 localPoint -= scrollOffset; |
771 } | 808 } |
772 | 809 |
773 bool positionOrOffsetChanged = false; | 810 bool positionOrOffsetChanged = false; |
774 if (layoutObject()->isInFlowPositioned()) { | 811 if (layoutObject()->isInFlowPositioned()) { |
775 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition(); | 812 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition(); |
776 positionOrOffsetChanged = newOffset != m_offsetForInFlowPosition; | 813 positionOrOffsetChanged = newOffset != offsetForInFlowPosition(); |
777 m_offsetForInFlowPosition = newOffset; | 814 if (m_rareData || !newOffset.isZero()) |
778 localPoint.move(m_offsetForInFlowPosition); | 815 ensureRareData().offsetForInFlowPosition = newOffset; |
779 } else { | 816 localPoint.move(newOffset); |
780 m_offsetForInFlowPosition = LayoutSize(); | 817 } else if (m_rareData) { |
818 m_rareData->offsetForInFlowPosition = LayoutSize(); | |
781 } | 819 } |
782 | 820 |
783 // FIXME: We'd really like to just get rid of the concept of a layer rectang le and rely on the layoutObjects. | 821 // FIXME: We'd really like to just get rid of the concept of a layer rectang le and rely on the layoutObjects. |
784 localPoint.moveBy(-inlineBoundingBoxOffset); | 822 localPoint.moveBy(-inlineBoundingBoxOffset); |
785 | 823 |
786 if (m_location != localPoint) { | 824 if (m_location != localPoint) { |
787 positionOrOffsetChanged = true; | 825 positionOrOffsetChanged = true; |
788 setNeedsRepaint(); | 826 setNeedsRepaint(); |
789 } | 827 } |
790 m_location = localPoint; | 828 m_location = localPoint; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
864 { | 902 { |
865 PaintLayer* curr = parent(); | 903 PaintLayer* curr = parent(); |
866 while (curr && !curr->isRootLayer() && !curr->layoutObject()->hasTransformRe latedProperty()) | 904 while (curr && !curr->isRootLayer() && !curr->layoutObject()->hasTransformRe latedProperty()) |
867 curr = curr->parent(); | 905 curr = curr->parent(); |
868 | 906 |
869 return curr; | 907 return curr; |
870 } | 908 } |
871 | 909 |
872 LayoutPoint PaintLayer::computeOffsetFromTransformedAncestor() const | 910 LayoutPoint PaintLayer::computeOffsetFromTransformedAncestor() const |
873 { | 911 { |
874 const AncestorDependentCompositingInputs& properties = ancestorDependentComp ositingInputs(); | |
875 | |
876 TransformState transformState(TransformState::ApplyTransformDirection, Float Point()); | 912 TransformState transformState(TransformState::ApplyTransformDirection, Float Point()); |
877 // FIXME: add a test that checks flipped writing mode and ApplyContainerFlip are correct. | 913 // FIXME: add a test that checks flipped writing mode and ApplyContainerFlip are correct. |
878 layoutObject()->mapLocalToAncestor(properties.transformAncestor ? properties .transformAncestor->layoutObject() : 0, transformState, ApplyContainerFlip); | 914 layoutObject()->mapLocalToAncestor(transformAncestor() ? transformAncestor() ->layoutObject() : nullptr, transformState, ApplyContainerFlip); |
879 transformState.flatten(); | 915 transformState.flatten(); |
880 return LayoutPoint(transformState.lastPlanarPoint()); | 916 return LayoutPoint(transformState.lastPlanarPoint()); |
881 } | 917 } |
882 | 918 |
883 PaintLayer* PaintLayer::compositingContainer() const | 919 PaintLayer* PaintLayer::compositingContainer() const |
884 { | 920 { |
885 if (!stackingNode()->isTreatedAsOrStackingContext()) | 921 if (!stackingNode()->isTreatedAsOrStackingContext()) |
886 return parent(); | 922 return parent(); |
887 if (PaintLayerStackingNode* ancestorStackingNode = stackingNode()->ancestorS tackingContextNode()) | 923 if (PaintLayerStackingNode* ancestorStackingNode = stackingNode()->ancestorS tackingContextNode()) |
888 return ancestorStackingNode->layer(); | 924 return ancestorStackingNode->layer(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
949 { | 985 { |
950 m_needsAncestorDependentCompositingInputsUpdate = true; | 986 m_needsAncestorDependentCompositingInputsUpdate = true; |
951 m_needsDescendantDependentCompositingInputsUpdate = true; | 987 m_needsDescendantDependentCompositingInputsUpdate = true; |
952 | 988 |
953 for (PaintLayer* current = this; current && !current->m_childNeedsCompositin gInputsUpdate; current = current->parent()) | 989 for (PaintLayer* current = this; current && !current->m_childNeedsCompositin gInputsUpdate; current = current->parent()) |
954 current->m_childNeedsCompositingInputsUpdate = true; | 990 current->m_childNeedsCompositingInputsUpdate = true; |
955 | 991 |
956 compositor()->setNeedsCompositingUpdate(CompositingUpdateAfterCompositingInp utChange); | 992 compositor()->setNeedsCompositingUpdate(CompositingUpdateAfterCompositingInp utChange); |
957 } | 993 } |
958 | 994 |
959 void PaintLayer::updateAncestorDependentCompositingInputs(const AncestorDependen tCompositingInputs& compositingInputs) | 995 void PaintLayer::updateAncestorDependentCompositingInputs(const AncestorDependen tCompositingInputs& compositingInputs, const RareAncestorDependentCompositingInp uts& rareCompositingInputs, bool hasAncestorWithClipPath) |
960 { | 996 { |
961 m_ancestorDependentCompositingInputs = compositingInputs; | 997 m_ancestorDependentCompositingInputs = compositingInputs; |
998 if (rareCompositingInputs.isDefault()) | |
999 m_rareAncestorDependentCompositingInputs.clear(); | |
1000 else | |
1001 m_rareAncestorDependentCompositingInputs = adoptPtr(new RareAncestorDepe ndentCompositingInputs(rareCompositingInputs)); | |
1002 m_hasAncestorWithClipPath = hasAncestorWithClipPath; | |
962 m_needsAncestorDependentCompositingInputsUpdate = false; | 1003 m_needsAncestorDependentCompositingInputsUpdate = false; |
963 } | 1004 } |
964 | 1005 |
965 void PaintLayer::updateDescendantDependentCompositingInputs(const DescendantDepe ndentCompositingInputs& compositingInputs) | 1006 void PaintLayer::updateDescendantDependentCompositingInputs(bool hasDescendantWi thClipPath, bool hasNonIsolatedDescendantWithBlendMode) |
966 { | 1007 { |
967 m_descendantDependentCompositingInputs = compositingInputs; | 1008 m_hasDescendantWithClipPath = hasDescendantWithClipPath; |
1009 m_hasNonIsolatedDescendantWithBlendMode = hasNonIsolatedDescendantWithBlendM ode; | |
968 m_needsDescendantDependentCompositingInputsUpdate = false; | 1010 m_needsDescendantDependentCompositingInputsUpdate = false; |
969 } | 1011 } |
970 | 1012 |
971 void PaintLayer::didUpdateCompositingInputs() | 1013 void PaintLayer::didUpdateCompositingInputs() |
972 { | 1014 { |
973 ASSERT(!needsCompositingInputsUpdate()); | 1015 ASSERT(!needsCompositingInputsUpdate()); |
974 m_childNeedsCompositingInputsUpdate = false; | 1016 m_childNeedsCompositingInputsUpdate = false; |
975 if (m_scrollableArea) | 1017 if (m_scrollableArea) |
976 m_scrollableArea->updateNeedsCompositedScrolling(); | 1018 m_scrollableArea->updateNeedsCompositedScrolling(); |
977 } | 1019 } |
978 | 1020 |
979 bool PaintLayer::hasNonIsolatedDescendantWithBlendMode() const | 1021 bool PaintLayer::hasNonIsolatedDescendantWithBlendMode() const |
980 { | 1022 { |
981 if (descendantDependentCompositingInputs().hasNonIsolatedDescendantWithBlend Mode) | 1023 ASSERT(!m_needsDescendantDependentCompositingInputsUpdate); |
1024 if (m_hasNonIsolatedDescendantWithBlendMode) | |
982 return true; | 1025 return true; |
983 if (layoutObject()->isSVGRoot()) | 1026 if (layoutObject()->isSVGRoot()) |
984 return toLayoutSVGRoot(layoutObject())->hasNonIsolatedBlendingDescendant s(); | 1027 return toLayoutSVGRoot(layoutObject())->hasNonIsolatedBlendingDescendant s(); |
985 return false; | 1028 return false; |
986 } | 1029 } |
987 | 1030 |
988 void PaintLayer::setCompositingReasons(CompositingReasons reasons, CompositingRe asons mask) | 1031 void PaintLayer::setCompositingReasons(CompositingReasons reasons, CompositingRe asons mask) |
989 { | 1032 { |
990 if ((compositingReasons() & mask) == (reasons & mask)) | 1033 CompositingReasons oldReasons = m_rareData ? m_rareData->compositingReasons : CompositingReasonNone; |
1034 if ((oldReasons & mask) == (reasons & mask)) | |
991 return; | 1035 return; |
992 m_compositingReasons = (reasons & mask) | (compositingReasons() & ~mask); | 1036 CompositingReasons newReasons = (reasons & mask) | (oldReasons & ~mask); |
1037 if (m_rareData || newReasons != CompositingReasonNone) | |
1038 ensureRareData().compositingReasons = newReasons; | |
993 } | 1039 } |
994 | 1040 |
995 void PaintLayer::setHasCompositingDescendant(bool hasCompositingDescendant) | 1041 void PaintLayer::setHasCompositingDescendant(bool hasCompositingDescendant) |
996 { | 1042 { |
997 if (m_hasCompositingDescendant == static_cast<unsigned>(hasCompositingDescen dant)) | 1043 if (m_hasCompositingDescendant == static_cast<unsigned>(hasCompositingDescen dant)) |
998 return; | 1044 return; |
999 | 1045 |
1000 m_hasCompositingDescendant = hasCompositingDescendant; | 1046 m_hasCompositingDescendant = hasCompositingDescendant; |
1001 | 1047 |
1002 if (hasCompositedLayerMapping()) | 1048 if (hasCompositedLayerMapping()) |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1223 layoutObject()->setShouldDoFullPaintInvalidationIncludingNonComposit ingDescendants(); | 1269 layoutObject()->setShouldDoFullPaintInvalidationIncludingNonComposit ingDescendants(); |
1224 } | 1270 } |
1225 } | 1271 } |
1226 | 1272 |
1227 m_clipper.clearClipRectsIncludingDescendants(); | 1273 m_clipper.clearClipRectsIncludingDescendants(); |
1228 | 1274 |
1229 PaintLayer* nextSib = nextSibling(); | 1275 PaintLayer* nextSib = nextSibling(); |
1230 | 1276 |
1231 // Remove the child reflection layer before moving other child layers. | 1277 // Remove the child reflection layer before moving other child layers. |
1232 // The reflection layer should not be moved to the parent. | 1278 // The reflection layer should not be moved to the parent. |
1233 if (m_reflectionInfo) | 1279 if (PaintLayerReflectionInfo* reflectionInfo = this->reflectionInfo()) |
1234 removeChild(m_reflectionInfo->reflectionLayer()); | 1280 removeChild(reflectionInfo->reflectionLayer()); |
1235 | 1281 |
1236 // Now walk our kids and reattach them to our parent. | 1282 // Now walk our kids and reattach them to our parent. |
1237 PaintLayer* current = m_first; | 1283 PaintLayer* current = m_first; |
1238 while (current) { | 1284 while (current) { |
1239 PaintLayer* next = current->nextSibling(); | 1285 PaintLayer* next = current->nextSibling(); |
1240 removeChild(current); | 1286 removeChild(current); |
1241 m_parent->addChild(current, nextSib); | 1287 m_parent->addChild(current, nextSib); |
1242 | 1288 |
1243 // FIXME: We should call a specialized version of this function. | 1289 // FIXME: We should call a specialized version of this function. |
1244 current->updateLayerPositionsAfterLayout(); | 1290 current->updateLayerPositionsAfterLayout(); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1367 | 1413 |
1368 void PaintLayer::didUpdateNeedsCompositedScrolling() | 1414 void PaintLayer::didUpdateNeedsCompositedScrolling() |
1369 { | 1415 { |
1370 updateSelfPaintingLayer(); | 1416 updateSelfPaintingLayer(); |
1371 } | 1417 } |
1372 | 1418 |
1373 void PaintLayer::updateReflectionInfo(const ComputedStyle* oldStyle) | 1419 void PaintLayer::updateReflectionInfo(const ComputedStyle* oldStyle) |
1374 { | 1420 { |
1375 ASSERT(!oldStyle || !layoutObject()->style()->reflectionDataEquivalent(oldSt yle)); | 1421 ASSERT(!oldStyle || !layoutObject()->style()->reflectionDataEquivalent(oldSt yle)); |
1376 if (layoutObject()->hasReflection()) { | 1422 if (layoutObject()->hasReflection()) { |
1377 if (!m_reflectionInfo) | 1423 ensureRareData().reflectionInfo = adoptPtr(new PaintLayerReflectionInfo( *layoutBox())); |
1378 m_reflectionInfo = adoptPtr(new PaintLayerReflectionInfo(*layoutBox( ))); | 1424 m_rareData->reflectionInfo->updateAfterStyleChange(oldStyle); |
1379 m_reflectionInfo->updateAfterStyleChange(oldStyle); | 1425 } else if (m_rareData && m_rareData->reflectionInfo) { |
1380 } else if (m_reflectionInfo) { | 1426 m_rareData->reflectionInfo->destroy(); |
1381 m_reflectionInfo->destroy(); | 1427 m_rareData->reflectionInfo = nullptr; |
1382 m_reflectionInfo = nullptr; | |
1383 } | 1428 } |
1384 } | 1429 } |
1385 | 1430 |
1386 void PaintLayer::updateStackingNode() | 1431 void PaintLayer::updateStackingNode() |
1387 { | 1432 { |
1388 ASSERT(!m_stackingNode); | 1433 ASSERT(!m_stackingNode); |
1389 if (requiresStackingNode()) | 1434 if (requiresStackingNode()) |
1390 m_stackingNode = adoptPtr(new PaintLayerStackingNode(this)); | 1435 m_stackingNode = adoptPtr(new PaintLayerStackingNode(this)); |
1391 else | 1436 else |
1392 m_stackingNode = nullptr; | 1437 m_stackingNode = nullptr; |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2017 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 2062 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
2018 return; | 2063 return; |
2019 | 2064 |
2020 setNeedsCompositingInputsUpdate(); | 2065 setNeedsCompositingInputsUpdate(); |
2021 } | 2066 } |
2022 | 2067 |
2023 void PaintLayer::addBlockSelectionGapsBounds(const LayoutRect& bounds) | 2068 void PaintLayer::addBlockSelectionGapsBounds(const LayoutRect& bounds) |
2024 { | 2069 { |
2025 if (RuntimeEnabledFeatures::selectionPaintingWithoutSelectionGapsEnabled()) | 2070 if (RuntimeEnabledFeatures::selectionPaintingWithoutSelectionGapsEnabled()) |
2026 return; | 2071 return; |
2027 m_blockSelectionGapsBounds.unite(enclosingIntRect(bounds)); | 2072 if (!bounds.isEmpty()) |
2073 ensureRareData().blockSelectionGapsBounds.unite(enclosingIntRect(bounds) ); | |
2028 blockSelectionGapsBoundsChanged(); | 2074 blockSelectionGapsBoundsChanged(); |
2029 } | 2075 } |
2030 | 2076 |
2031 void PaintLayer::clearBlockSelectionGapsBounds() | 2077 void PaintLayer::clearBlockSelectionGapsBounds() |
2032 { | 2078 { |
2033 if (RuntimeEnabledFeatures::selectionPaintingWithoutSelectionGapsEnabled()) | 2079 if (RuntimeEnabledFeatures::selectionPaintingWithoutSelectionGapsEnabled()) |
2034 return; | 2080 return; |
2035 m_blockSelectionGapsBounds = IntRect(); | 2081 if (m_rareData) |
2082 m_rareData->blockSelectionGapsBounds = IntRect(); | |
2036 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) | 2083 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) |
2037 child->clearBlockSelectionGapsBounds(); | 2084 child->clearBlockSelectionGapsBounds(); |
2038 blockSelectionGapsBoundsChanged(); | 2085 blockSelectionGapsBoundsChanged(); |
2039 } | 2086 } |
2040 | 2087 |
2041 void PaintLayer::invalidatePaintForBlockSelectionGaps() | 2088 void PaintLayer::invalidatePaintForBlockSelectionGaps() |
2042 { | 2089 { |
2043 if (RuntimeEnabledFeatures::selectionPaintingWithoutSelectionGapsEnabled()) | 2090 if (RuntimeEnabledFeatures::selectionPaintingWithoutSelectionGapsEnabled()) |
2044 return; | 2091 return; |
2045 | 2092 |
2046 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) { | 2093 for (PaintLayer* child = firstChild(); child; child = child->nextSibling()) { |
2047 // FIXME: We should not allow paint invalidation out of paint invalidati on state. crbug.com/457415 | 2094 // FIXME: We should not allow paint invalidation out of paint invalidati on state. crbug.com/457415 |
2048 DisablePaintInvalidationStateAsserts disabler; | 2095 DisablePaintInvalidationStateAsserts disabler; |
2049 child->invalidatePaintForBlockSelectionGaps(); | 2096 child->invalidatePaintForBlockSelectionGaps(); |
2050 } | 2097 } |
2051 | 2098 |
2052 if (m_blockSelectionGapsBounds.isEmpty()) | 2099 if (!m_rareData || m_rareData->blockSelectionGapsBounds.isEmpty()) |
2053 return; | 2100 return; |
2054 | 2101 |
2055 LayoutRect rect(m_blockSelectionGapsBounds); | 2102 LayoutRect rect(m_rareData->blockSelectionGapsBounds); |
2056 if (layoutObject()->hasOverflowClip()) { | 2103 if (layoutObject()->hasOverflowClip()) { |
2057 LayoutBox* box = layoutBox(); | 2104 LayoutBox* box = layoutBox(); |
2058 rect.move(-box->scrolledContentOffset()); | 2105 rect.move(-box->scrolledContentOffset()); |
2059 if (!scrollableArea()->usesCompositedScrolling()) | 2106 if (!scrollableArea()->usesCompositedScrolling()) |
2060 rect.intersect(box->overflowClipRect(LayoutPoint())); | 2107 rect.intersect(box->overflowClipRect(LayoutPoint())); |
2061 } | 2108 } |
2062 if (layoutObject()->hasClip()) | 2109 if (layoutObject()->hasClip()) |
2063 rect.intersect(toLayoutBox(layoutObject())->clipRect(LayoutPoint())); | 2110 rect.intersect(toLayoutBox(layoutObject())->clipRect(LayoutPoint())); |
2064 if (!rect.isEmpty()) { | 2111 if (!rect.isEmpty()) { |
2065 // FIXME: We should not allow paint invalidation out of paint invalidati on state. crbug.com/457415 | 2112 // FIXME: We should not allow paint invalidation out of paint invalidati on state. crbug.com/457415 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2263 return result; | 2310 return result; |
2264 } | 2311 } |
2265 | 2312 |
2266 CompositingState PaintLayer::compositingState() const | 2313 CompositingState PaintLayer::compositingState() const |
2267 { | 2314 { |
2268 ASSERT(isAllowedToQueryCompositingState()); | 2315 ASSERT(isAllowedToQueryCompositingState()); |
2269 | 2316 |
2270 // This is computed procedurally so there is no redundant state variable tha t | 2317 // This is computed procedurally so there is no redundant state variable tha t |
2271 // can get out of sync from the real actual compositing state. | 2318 // can get out of sync from the real actual compositing state. |
2272 | 2319 |
2273 if (m_groupedMapping) { | 2320 if (groupedMapping()) { |
2274 ASSERT(!m_compositedLayerMapping); | 2321 ASSERT(!compositedLayerMapping()); |
2275 return PaintsIntoGroupedBacking; | 2322 return PaintsIntoGroupedBacking; |
2276 } | 2323 } |
2277 | 2324 |
2278 if (!m_compositedLayerMapping) | 2325 if (!compositedLayerMapping()) |
2279 return NotComposited; | 2326 return NotComposited; |
2280 | 2327 |
2281 return PaintsIntoOwnBacking; | 2328 return PaintsIntoOwnBacking; |
2282 } | 2329 } |
2283 | 2330 |
2284 bool PaintLayer::isAllowedToQueryCompositingState() const | 2331 bool PaintLayer::isAllowedToQueryCompositingState() const |
2285 { | 2332 { |
2286 if (gCompositingQueryMode == CompositingQueriesAreAllowed || RuntimeEnabledF eatures::slimmingPaintV2Enabled()) | 2333 if (gCompositingQueryMode == CompositingQueriesAreAllowed || RuntimeEnabledF eatures::slimmingPaintV2Enabled()) |
2287 return true; | 2334 return true; |
2288 return layoutObject()->document().lifecycle().state() >= DocumentLifecycle:: InCompositingUpdate; | 2335 return layoutObject()->document().lifecycle().state() >= DocumentLifecycle:: InCompositingUpdate; |
2289 } | 2336 } |
2290 | 2337 |
2291 CompositedLayerMapping* PaintLayer::compositedLayerMapping() const | 2338 CompositedLayerMapping* PaintLayer::compositedLayerMapping() const |
2292 { | 2339 { |
2293 ASSERT(isAllowedToQueryCompositingState()); | 2340 ASSERT(isAllowedToQueryCompositingState()); |
2294 return m_compositedLayerMapping.get(); | 2341 return m_rareData ? m_rareData->compositedLayerMapping.get() : nullptr; |
2295 } | 2342 } |
2296 | 2343 |
2297 GraphicsLayer* PaintLayer::graphicsLayerBacking() const | 2344 GraphicsLayer* PaintLayer::graphicsLayerBacking() const |
2298 { | 2345 { |
2299 switch (compositingState()) { | 2346 switch (compositingState()) { |
2300 case NotComposited: | 2347 case NotComposited: |
2301 return 0; | 2348 return 0; |
2302 case PaintsIntoGroupedBacking: | 2349 case PaintsIntoGroupedBacking: |
2303 return groupedMapping()->squashingLayer(); | 2350 return groupedMapping()->squashingLayer(); |
2304 default: | 2351 default: |
2305 return compositedLayerMapping()->mainGraphicsLayer(); | 2352 return compositedLayerMapping()->mainGraphicsLayer(); |
2306 } | 2353 } |
2307 } | 2354 } |
2308 | 2355 |
2309 GraphicsLayer* PaintLayer::graphicsLayerBackingForScrolling() const | 2356 GraphicsLayer* PaintLayer::graphicsLayerBackingForScrolling() const |
2310 { | 2357 { |
2311 switch (compositingState()) { | 2358 switch (compositingState()) { |
2312 case NotComposited: | 2359 case NotComposited: |
2313 return 0; | 2360 return 0; |
2314 case PaintsIntoGroupedBacking: | 2361 case PaintsIntoGroupedBacking: |
2315 return groupedMapping()->squashingLayer(); | 2362 return groupedMapping()->squashingLayer(); |
2316 default: | 2363 default: |
2317 return compositedLayerMapping()->scrollingContentsLayer() ? compositedLa yerMapping()->scrollingContentsLayer() : compositedLayerMapping()->mainGraphicsL ayer(); | 2364 return compositedLayerMapping()->scrollingContentsLayer() ? compositedLa yerMapping()->scrollingContentsLayer() : compositedLayerMapping()->mainGraphicsL ayer(); |
2318 } | 2365 } |
2319 } | 2366 } |
2320 | 2367 |
2321 void PaintLayer::ensureCompositedLayerMapping() | 2368 void PaintLayer::ensureCompositedLayerMapping() |
2322 { | 2369 { |
2323 if (m_compositedLayerMapping) | 2370 if (m_rareData && m_rareData->compositedLayerMapping) |
2324 return; | 2371 return; |
2325 | 2372 |
2326 m_compositedLayerMapping = adoptPtr(new CompositedLayerMapping(*this)); | 2373 ensureRareData().compositedLayerMapping = adoptPtr(new CompositedLayerMappin g(*this)); |
2327 m_compositedLayerMapping->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdateSub tree); | 2374 m_rareData->compositedLayerMapping->setNeedsGraphicsLayerUpdate(GraphicsLaye rUpdateSubtree); |
2328 | 2375 |
2329 updateOrRemoveFilterEffectBuilder(); | 2376 updateOrRemoveFilterEffectBuilder(); |
2330 } | 2377 } |
2331 | 2378 |
2332 void PaintLayer::clearCompositedLayerMapping(bool layerBeingDestroyed) | 2379 void PaintLayer::clearCompositedLayerMapping(bool layerBeingDestroyed) |
2333 { | 2380 { |
2334 if (!layerBeingDestroyed) { | 2381 if (!layerBeingDestroyed) { |
2335 // We need to make sure our decendants get a geometry update. In princip le, | 2382 // We need to make sure our decendants get a geometry update. In princip le, |
2336 // we could call setNeedsGraphicsLayerUpdate on our children, but that w ould | 2383 // we could call setNeedsGraphicsLayerUpdate on our children, but that w ould |
2337 // require walking the z-order lists to find them. Instead, we over-inva lidate | 2384 // require walking the z-order lists to find them. Instead, we over-inva lidate |
2338 // by marking our parent as needing a geometry update. | 2385 // by marking our parent as needing a geometry update. |
2339 if (PaintLayer* compositingParent = enclosingLayerWithCompositedLayerMap ping(ExcludeSelf)) | 2386 if (PaintLayer* compositingParent = enclosingLayerWithCompositedLayerMap ping(ExcludeSelf)) |
2340 compositingParent->compositedLayerMapping()->setNeedsGraphicsLayerUp date(GraphicsLayerUpdateSubtree); | 2387 compositingParent->compositedLayerMapping()->setNeedsGraphicsLayerUp date(GraphicsLayerUpdateSubtree); |
2341 } | 2388 } |
2342 | 2389 |
2343 m_compositedLayerMapping.clear(); | 2390 if (m_rareData) |
2391 m_rareData->compositedLayerMapping.clear(); | |
2344 | 2392 |
2345 if (!layerBeingDestroyed) | 2393 if (!layerBeingDestroyed) |
2346 updateOrRemoveFilterEffectBuilder(); | 2394 updateOrRemoveFilterEffectBuilder(); |
2347 } | 2395 } |
2348 | 2396 |
2349 void PaintLayer::setGroupedMapping(CompositedLayerMapping* groupedMapping, SetGr oupMappingOptions options) | 2397 void PaintLayer::setGroupedMapping(CompositedLayerMapping* groupedMapping, SetGr oupMappingOptions options) |
2350 { | 2398 { |
2351 if (groupedMapping == m_groupedMapping) | 2399 CompositedLayerMapping* oldGroupedMapping = this->groupedMapping(); |
2400 if (groupedMapping == oldGroupedMapping) | |
2352 return; | 2401 return; |
2353 | 2402 |
2354 if (options == InvalidateLayerAndRemoveFromMapping && m_groupedMapping) { | 2403 if (options == InvalidateLayerAndRemoveFromMapping && oldGroupedMapping) { |
2355 m_groupedMapping->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdateSubtree ); | 2404 oldGroupedMapping->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdateSubtre e); |
2356 m_groupedMapping->removeLayerFromSquashingGraphicsLayer(this); | 2405 oldGroupedMapping->removeLayerFromSquashingGraphicsLayer(this); |
2357 } | 2406 } |
2358 m_groupedMapping = groupedMapping; | 2407 if (m_rareData || groupedMapping) |
2359 ASSERT(!m_groupedMapping || m_groupedMapping->verifyLayerInSquashingVector(t his)); | 2408 ensureRareData().groupedMapping = groupedMapping; |
2360 if (options == InvalidateLayerAndRemoveFromMapping && m_groupedMapping) | 2409 ASSERT(!groupedMapping || groupedMapping->verifyLayerInSquashingVector(this) ); |
2361 m_groupedMapping->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdateSubtree ); | 2410 if (options == InvalidateLayerAndRemoveFromMapping && groupedMapping) |
2411 groupedMapping->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdateSubtree); | |
2362 } | 2412 } |
2363 | 2413 |
2364 bool PaintLayer::hasCompositedMask() const | 2414 bool PaintLayer::hasCompositedMask() const |
2365 { | 2415 { |
2366 return m_compositedLayerMapping && m_compositedLayerMapping->hasMaskLayer(); | 2416 return m_rareData && m_rareData->compositedLayerMapping && m_rareData->compo sitedLayerMapping->hasMaskLayer(); |
2367 } | 2417 } |
2368 | 2418 |
2369 bool PaintLayer::hasCompositedClippingMask() const | 2419 bool PaintLayer::hasCompositedClippingMask() const |
2370 { | 2420 { |
2371 return m_compositedLayerMapping && m_compositedLayerMapping->hasChildClippin gMaskLayer(); | 2421 return m_rareData && m_rareData->compositedLayerMapping && m_rareData->compo sitedLayerMapping->hasChildClippingMaskLayer(); |
2372 } | 2422 } |
2373 | 2423 |
2374 bool PaintLayer::paintsWithTransform(GlobalPaintFlags globalPaintFlags) const | 2424 bool PaintLayer::paintsWithTransform(GlobalPaintFlags globalPaintFlags) const |
2375 { | 2425 { |
2376 return (transform() || layoutObject()->style()->position() == FixedPosition) && ((globalPaintFlags & GlobalPaintFlattenCompositingLayers) || compositingStat e() != PaintsIntoOwnBacking); | 2426 return (transform() || layoutObject()->style()->position() == FixedPosition) && ((globalPaintFlags & GlobalPaintFlattenCompositingLayers) || compositingStat e() != PaintsIntoOwnBacking); |
2377 } | 2427 } |
2378 | 2428 |
2379 bool PaintLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const | 2429 bool PaintLayer::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const |
2380 { | 2430 { |
2381 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) | 2431 if (!isSelfPaintingLayer() && !hasSelfPaintingLayerDescendant()) |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2495 { | 2545 { |
2496 if (!newStyle.hasFilter() && (!oldStyle || !oldStyle->hasFilter())) | 2546 if (!newStyle.hasFilter() && (!oldStyle || !oldStyle->hasFilter())) |
2497 return; | 2547 return; |
2498 | 2548 |
2499 updateOrRemoveFilterClients(); | 2549 updateOrRemoveFilterClients(); |
2500 updateOrRemoveFilterEffectBuilder(); | 2550 updateOrRemoveFilterEffectBuilder(); |
2501 } | 2551 } |
2502 | 2552 |
2503 bool PaintLayer::attemptDirectCompositingUpdate(StyleDifference diff, const Comp utedStyle* oldStyle) | 2553 bool PaintLayer::attemptDirectCompositingUpdate(StyleDifference diff, const Comp utedStyle* oldStyle) |
2504 { | 2554 { |
2505 CompositingReasons oldPotentialCompositingReasonsFromStyle = m_potentialComp ositingReasonsFromStyle; | 2555 CompositingReasons oldPotentialCompositingReasonsFromStyle = potentialCompos itingReasonsFromStyle(); |
2506 compositor()->updatePotentialCompositingReasonsFromStyle(this); | 2556 compositor()->updatePotentialCompositingReasonsFromStyle(this); |
2507 | 2557 |
2508 // This function implements an optimization for transforms and opacity. | 2558 // This function implements an optimization for transforms and opacity. |
2509 // A common pattern is for a touchmove handler to update the transform | 2559 // A common pattern is for a touchmove handler to update the transform |
2510 // and/or an opacity of an element every frame while the user moves their | 2560 // and/or an opacity of an element every frame while the user moves their |
2511 // finger across the screen. The conditions below recognize when the | 2561 // finger across the screen. The conditions below recognize when the |
2512 // compositing state is set up to receive a direct transform or opacity | 2562 // compositing state is set up to receive a direct transform or opacity |
2513 // update. | 2563 // update. |
2514 | 2564 |
2515 if (!diff.hasAtMostPropertySpecificDifferences(StyleDifference::TransformCha nged | StyleDifference::OpacityChanged)) | 2565 if (!diff.hasAtMostPropertySpecificDifferences(StyleDifference::TransformCha nged | StyleDifference::OpacityChanged)) |
2516 return false; | 2566 return false; |
2517 // The potentialCompositingReasonsFromStyle could have changed without | 2567 // The potentialCompositingReasonsFromStyle could have changed without |
2518 // a corresponding StyleDifference if an animation started or ended. | 2568 // a corresponding StyleDifference if an animation started or ended. |
2519 if (m_potentialCompositingReasonsFromStyle != oldPotentialCompositingReasons FromStyle) | 2569 if (potentialCompositingReasonsFromStyle() != oldPotentialCompositingReasons FromStyle) |
2520 return false; | 2570 return false; |
2521 // We could add support for reflections if we updated the transform on | 2571 // We could add support for reflections if we updated the transform on |
2522 // the reflection layers. | 2572 // the reflection layers. |
2523 if (layoutObject()->hasReflection()) | 2573 if (layoutObject()->hasReflection()) |
2524 return false; | 2574 return false; |
2525 // If we're unwinding a scheduleSVGFilterLayerUpdateHack(), then we can't | 2575 // If we're unwinding a scheduleSVGFilterLayerUpdateHack(), then we can't |
2526 // perform a direct compositing update because the filters code is going | 2576 // perform a direct compositing update because the filters code is going |
2527 // to produce different output this time around. We can remove this code | 2577 // to produce different output this time around. We can remove this code |
2528 // once we fix the chicken/egg bugs in the filters code and delete the | 2578 // once we fix the chicken/egg bugs in the filters code and delete the |
2529 // scheduleSVGFilterLayerUpdateHack(). | 2579 // scheduleSVGFilterLayerUpdateHack(). |
2530 if (layoutObject()->node() && layoutObject()->node()->svgFilterNeedsLayerUpd ate()) | 2580 if (layoutObject()->node() && layoutObject()->node()->svgFilterNeedsLayerUpd ate()) |
2531 return false; | 2581 return false; |
2532 if (!m_compositedLayerMapping) | 2582 if (!m_rareData || !m_rareData->compositedLayerMapping) |
2533 return false; | 2583 return false; |
2534 | 2584 |
2535 // To cut off almost all the work in the compositing update for | 2585 // To cut off almost all the work in the compositing update for |
2536 // this case, we treat inline transforms has having assumed overlap | 2586 // this case, we treat inline transforms has having assumed overlap |
2537 // (similar to how we treat animated transforms). Notice that we read | 2587 // (similar to how we treat animated transforms). Notice that we read |
2538 // CompositingReasonInlineTransform from the m_compositingReasons, which | 2588 // CompositingReasonInlineTransform from the m_compositingReasons, which |
2539 // means that the inline transform actually triggered assumed overlap in | 2589 // means that the inline transform actually triggered assumed overlap in |
2540 // the overlap map. | 2590 // the overlap map. |
2541 if (diff.transformChanged() && !(m_compositingReasons & CompositingReasonInl ineTransform)) | 2591 if (diff.transformChanged() && (!m_rareData || !(m_rareData->compositingReas ons & CompositingReasonInlineTransform))) |
2542 return false; | 2592 return false; |
2543 | 2593 |
2544 // We composite transparent Layers differently from non-transparent | 2594 // We composite transparent Layers differently from non-transparent |
2545 // Layers even when the non-transparent Layers are already a | 2595 // Layers even when the non-transparent Layers are already a |
2546 // stacking context. | 2596 // stacking context. |
2547 if (diff.opacityChanged() && m_layoutObject->style()->hasOpacity() != oldSty le->hasOpacity()) | 2597 if (diff.opacityChanged() && m_layoutObject->style()->hasOpacity() != oldSty le->hasOpacity()) |
2548 return false; | 2598 return false; |
2549 | 2599 |
2550 // Changes in pointer-events affect hit test visibility of the scrollable | 2600 // Changes in pointer-events affect hit test visibility of the scrollable |
2551 // area and its |m_scrollsOverflow| value which determines if the layer | 2601 // area and its |m_scrollsOverflow| value which determines if the layer |
2552 // requires composited scrolling or not. | 2602 // requires composited scrolling or not. |
2553 if (m_scrollableArea && m_layoutObject->style()->pointerEvents() != oldStyle ->pointerEvents()) | 2603 if (m_scrollableArea && m_layoutObject->style()->pointerEvents() != oldStyle ->pointerEvents()) |
2554 return false; | 2604 return false; |
2555 | 2605 |
2556 updateTransform(oldStyle, layoutObject()->styleRef()); | 2606 updateTransform(oldStyle, layoutObject()->styleRef()); |
2557 | 2607 |
2558 // FIXME: Consider introducing a smaller graphics layer update scope | 2608 // FIXME: Consider introducing a smaller graphics layer update scope |
2559 // that just handles transforms and opacity. GraphicsLayerUpdateLocal | 2609 // that just handles transforms and opacity. GraphicsLayerUpdateLocal |
2560 // will also program bounds, clips, and many other properties that could | 2610 // will also program bounds, clips, and many other properties that could |
2561 // not possibly have changed. | 2611 // not possibly have changed. |
2562 m_compositedLayerMapping->setNeedsGraphicsLayerUpdate(GraphicsLayerUpdateLoc al); | 2612 m_rareData->compositedLayerMapping->setNeedsGraphicsLayerUpdate(GraphicsLaye rUpdateLocal); |
2563 compositor()->setNeedsCompositingUpdate(CompositingUpdateAfterGeometryChange ); | 2613 compositor()->setNeedsCompositingUpdate(CompositingUpdateAfterGeometryChange ); |
2564 | 2614 |
2565 if (m_scrollableArea) | 2615 if (m_scrollableArea) |
2566 m_scrollableArea->updateAfterStyleChange(oldStyle); | 2616 m_scrollableArea->updateAfterStyleChange(oldStyle); |
2567 | 2617 |
2568 return true; | 2618 return true; |
2569 } | 2619 } |
2570 | 2620 |
2571 void PaintLayer::styleChanged(StyleDifference diff, const ComputedStyle* oldStyl e) | 2621 void PaintLayer::styleChanged(StyleDifference diff, const ComputedStyle* oldStyl e) |
2572 { | 2622 { |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2831 | 2881 |
2832 void showLayerTree(const blink::LayoutObject* layoutObject) | 2882 void showLayerTree(const blink::LayoutObject* layoutObject) |
2833 { | 2883 { |
2834 if (!layoutObject) { | 2884 if (!layoutObject) { |
2835 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); | 2885 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); |
2836 return; | 2886 return; |
2837 } | 2887 } |
2838 showLayerTree(layoutObject->enclosingLayer()); | 2888 showLayerTree(layoutObject->enclosingLayer()); |
2839 } | 2889 } |
2840 #endif | 2890 #endif |
OLD | NEW |