OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/paint/ObjectPaintInvalidator.h" | 5 #include "core/paint/ObjectPaintInvalidator.h" |
6 | 6 |
7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
9 #include "core/layout/LayoutView.h" | 9 #include "core/layout/LayoutView.h" |
10 #include "core/layout/api/LayoutPartItem.h" | 10 #include "core/layout/api/LayoutPartItem.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // Note: the subpixel accumulation of layer() does not need to be added | 279 // Note: the subpixel accumulation of layer() does not need to be added |
280 // here. It is already taken into account. | 280 // here. It is already taken into account. |
281 squashingLayer->setNeedsDisplayInRect(enclosingIntRect(rect), reason, | 281 squashingLayer->setNeedsDisplayInRect(enclosingIntRect(rect), reason, |
282 m_object); | 282 m_object); |
283 } | 283 } |
284 } else if (m_object.compositedScrollsWithRespectTo( | 284 } else if (m_object.compositedScrollsWithRespectTo( |
285 paintInvalidationContainer)) { | 285 paintInvalidationContainer)) { |
286 layer.compositedLayerMapping()->setScrollingContentsNeedDisplayInRect( | 286 layer.compositedLayerMapping()->setScrollingContentsNeedDisplayInRect( |
287 rect, reason, m_object); | 287 rect, reason, m_object); |
288 } else if (paintInvalidationContainer.usesCompositedScrolling()) { | 288 } else if (paintInvalidationContainer.usesCompositedScrolling()) { |
289 if (layer.compositedLayerMapping() | 289 DCHECK(m_object == paintInvalidationContainer); |
290 ->backgroundPaintsOntoScrollingContentsLayer()) { | 290 if (reason == PaintInvalidationBackgroundOnScrollingContentsLayer) { |
291 // TODO(flackr): Get a correct rect in the context of the scrolling | |
292 // contents layer to update rather than updating the entire rect. | |
293 const LayoutRect& scrollingContentsRect = | |
294 toLayoutBox(m_object).layoutOverflowRect(); | |
295 layer.compositedLayerMapping()->setScrollingContentsNeedDisplayInRect( | 291 layer.compositedLayerMapping()->setScrollingContentsNeedDisplayInRect( |
296 scrollingContentsRect, reason, m_object); | 292 rect, reason, m_object); |
297 layer.setNeedsRepaint(); | 293 } else { |
298 invalidateDisplayItemClient( | 294 layer.compositedLayerMapping()->setNonScrollingContentsNeedDisplayInRect( |
299 *layer.compositedLayerMapping()->scrollingContentsLayer(), reason); | 295 rect, reason, m_object); |
300 } | 296 } |
301 layer.compositedLayerMapping()->setNonScrollingContentsNeedDisplayInRect( | |
302 rect, reason, m_object); | |
303 } else { | 297 } else { |
304 // Otherwise invalidate everything. | 298 // Otherwise invalidate everything. |
305 layer.compositedLayerMapping()->setContentsNeedDisplayInRect(rect, reason, | 299 layer.compositedLayerMapping()->setContentsNeedDisplayInRect(rect, reason, |
306 m_object); | 300 m_object); |
307 } | 301 } |
308 } | 302 } |
309 | 303 |
310 void ObjectPaintInvalidator::invalidatePaintUsingContainer( | 304 void ObjectPaintInvalidator::invalidatePaintUsingContainer( |
311 const LayoutBoxModelObject& paintInvalidationContainer, | 305 const LayoutBoxModelObject& paintInvalidationContainer, |
312 const LayoutRect& dirtyRect, | 306 const LayoutRect& dirtyRect, |
(...skipping 25 matching lines...) Expand all Loading... |
338 &m_object, paintInvalidationContainer)); | 332 &m_object, paintInvalidationContainer)); |
339 TRACE_EVENT2( | 333 TRACE_EVENT2( |
340 TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), | 334 TRACE_DISABLED_BY_DEFAULT("blink.invalidation"), |
341 "LayoutObject::invalidatePaintUsingContainer()", "object", | 335 "LayoutObject::invalidatePaintUsingContainer()", "object", |
342 m_object.debugName().ascii(), "info", | 336 m_object.debugName().ascii(), "info", |
343 jsonObjectForPaintInvalidationInfo( | 337 jsonObjectForPaintInvalidationInfo( |
344 dirtyRect, paintInvalidationReasonToString(invalidationReason))); | 338 dirtyRect, paintInvalidationReasonToString(invalidationReason))); |
345 | 339 |
346 // This conditional handles situations where non-rooted (and hence | 340 // This conditional handles situations where non-rooted (and hence |
347 // non-composited) frames are painted, such as SVG images. | 341 // non-composited) frames are painted, such as SVG images. |
348 if (!paintInvalidationContainer.isPaintInvalidationContainer()) | 342 if (!paintInvalidationContainer.isPaintInvalidationContainer()) { |
349 invalidatePaintRectangleOnWindow(paintInvalidationContainer, | 343 invalidatePaintRectangleOnWindow(paintInvalidationContainer, |
350 enclosingIntRect(dirtyRect)); | 344 enclosingIntRect(dirtyRect)); |
| 345 } |
351 | 346 |
352 if (paintInvalidationContainer.view()->usesCompositing() && | 347 if (paintInvalidationContainer.view()->usesCompositing() && |
353 paintInvalidationContainer.isPaintInvalidationContainer()) | 348 paintInvalidationContainer.isPaintInvalidationContainer()) { |
354 setBackingNeedsPaintInvalidationInRect(paintInvalidationContainer, | 349 setBackingNeedsPaintInvalidationInRect(paintInvalidationContainer, |
355 dirtyRect, invalidationReason); | 350 dirtyRect, invalidationReason); |
| 351 } |
356 } | 352 } |
357 | 353 |
358 LayoutRect ObjectPaintInvalidator::invalidatePaintRectangle( | 354 LayoutRect ObjectPaintInvalidator::invalidatePaintRectangle( |
359 const LayoutRect& dirtyRect, | 355 const LayoutRect& dirtyRect, |
360 DisplayItemClient* displayItemClient) { | 356 DisplayItemClient* displayItemClient) { |
361 CHECK(m_object.isRooted()); | 357 CHECK(m_object.isRooted()); |
362 | 358 |
363 if (dirtyRect.isEmpty()) | 359 if (dirtyRect.isEmpty()) |
364 return LayoutRect(); | 360 return LayoutRect(); |
365 | 361 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 // property (left / top) or some in-flow layoutObject inserted / removed | 477 // property (left / top) or some in-flow layoutObject inserted / removed |
482 // before us in the tree. | 478 // before us in the tree. |
483 if (m_context.newVisualRect.location() != m_context.oldVisualRect.location()) | 479 if (m_context.newVisualRect.location() != m_context.oldVisualRect.location()) |
484 return PaintInvalidationBoundsChange; | 480 return PaintInvalidationBoundsChange; |
485 | 481 |
486 if (m_context.newLocation != m_context.oldLocation) | 482 if (m_context.newLocation != m_context.oldLocation) |
487 return PaintInvalidationLocationChange; | 483 return PaintInvalidationLocationChange; |
488 | 484 |
489 // Incremental invalidation is only applicable to LayoutBoxes. Return | 485 // Incremental invalidation is only applicable to LayoutBoxes. Return |
490 // PaintInvalidationIncremental no matter if oldVisualRect and newVisualRect | 486 // PaintInvalidationIncremental no matter if oldVisualRect and newVisualRect |
491 // are equal | 487 // are equal because a LayoutBox may need paint invalidation if its border box |
492 // because a LayoutBox may need paint invalidation if its border box changes. | 488 // changes. BoxPaintInvalidator may also override this reason with a full |
| 489 // paint invalidation reason if needed. |
493 if (m_object.isBox()) | 490 if (m_object.isBox()) |
494 return PaintInvalidationIncremental; | 491 return PaintInvalidationIncremental; |
495 | 492 |
496 if (m_context.oldVisualRect != m_context.newVisualRect) | 493 if (m_context.oldVisualRect != m_context.newVisualRect) |
497 return PaintInvalidationBoundsChange; | 494 return PaintInvalidationBoundsChange; |
498 | 495 |
499 return PaintInvalidationNone; | 496 return PaintInvalidationNone; |
500 } | 497 } |
501 | 498 |
502 void ObjectPaintInvalidatorWithContext::invalidateSelectionIfNeeded( | 499 void ObjectPaintInvalidatorWithContext::invalidateSelectionIfNeeded( |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 | 577 |
581 m_context.paintingLayer->setNeedsRepaint(); | 578 m_context.paintingLayer->setNeedsRepaint(); |
582 m_object.invalidateDisplayItemClients(reason); | 579 m_object.invalidateDisplayItemClients(reason); |
583 return reason; | 580 return reason; |
584 } | 581 } |
585 | 582 |
586 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() | 583 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() |
587 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} | 584 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} |
588 | 585 |
589 } // namespace blink | 586 } // namespace blink |
OLD | NEW |