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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 void ObjectPaintInvalidatorWithContext::invalidatePaintRectangleWithContext( | 489 void ObjectPaintInvalidatorWithContext::invalidatePaintRectangleWithContext( |
490 const LayoutRect& rect, | 490 const LayoutRect& rect, |
491 PaintInvalidationReason reason) { | 491 PaintInvalidationReason reason) { |
492 if (rect.isEmpty()) | 492 if (rect.isEmpty()) |
493 return; | 493 return; |
494 | 494 |
495 // If the parent has fully invalidated and its visual rect covers this object | 495 // If the parent has fully invalidated and its visual rect covers this object |
496 // on the same backing, skip the invalidation. | 496 // on the same backing, skip the invalidation. |
497 if (parentFullyInvalidatedOnSameBacking() && | 497 if (parentFullyInvalidatedOnSameBacking() && |
498 (m_context.parentContext->oldVisualRect.contains(rect) || | 498 (m_context.parentContext->oldVisualRect.contains(rect) || |
499 m_context.parentContext->newVisualRect.contains(rect))) | 499 m_object.parent()->visualRect().contains(rect))) |
500 return; | 500 return; |
501 | 501 |
502 invalidatePaintUsingContainer(*m_context.paintInvalidationContainer, rect, | 502 invalidatePaintUsingContainer(*m_context.paintInvalidationContainer, rect, |
503 reason); | 503 reason); |
504 } | 504 } |
505 | 505 |
506 DISABLE_CFI_PERF | 506 DISABLE_CFI_PERF |
507 PaintInvalidationReason | 507 PaintInvalidationReason |
508 ObjectPaintInvalidatorWithContext::computePaintInvalidationReason() { | 508 ObjectPaintInvalidatorWithContext::computePaintInvalidationReason() { |
509 // This is before any early return to ensure the background obscuration status | 509 // This is before any early return to ensure the background obscuration status |
510 // is saved. | 510 // is saved. |
511 bool backgroundObscurationChanged = false; | 511 bool backgroundObscurationChanged = false; |
512 bool backgroundObscured = m_object.backgroundIsKnownToBeObscured(); | 512 bool backgroundObscured = m_object.backgroundIsKnownToBeObscured(); |
513 if (backgroundObscured != m_object.previousBackgroundObscured()) { | 513 if (backgroundObscured != m_object.previousBackgroundObscured()) { |
514 m_object.getMutableForPainting().setPreviousBackgroundObscured( | 514 m_object.getMutableForPainting().setPreviousBackgroundObscured( |
515 backgroundObscured); | 515 backgroundObscured); |
516 backgroundObscurationChanged = true; | 516 backgroundObscurationChanged = true; |
517 } | 517 } |
518 | 518 |
519 if (m_context.forcedSubtreeInvalidationFlags & | 519 if (m_context.forcedSubtreeInvalidationFlags & |
520 PaintInvalidatorContext::ForcedSubtreeFullInvalidation) | 520 PaintInvalidatorContext::ForcedSubtreeFullInvalidation) |
521 return PaintInvalidationSubtree; | 521 return PaintInvalidationSubtree; |
522 | 522 |
523 if (m_object.shouldDoFullPaintInvalidation()) | 523 if (m_object.shouldDoFullPaintInvalidation()) |
524 return m_object.fullPaintInvalidationReason(); | 524 return m_object.fullPaintInvalidationReason(); |
525 | 525 |
526 if (m_context.oldVisualRect.isEmpty() && m_context.newVisualRect.isEmpty()) | 526 if (m_context.oldVisualRect.isEmpty() && m_object.visualRect().isEmpty()) |
527 return PaintInvalidationNone; | 527 return PaintInvalidationNone; |
528 | 528 |
529 if (backgroundObscurationChanged) | 529 if (backgroundObscurationChanged) |
530 return PaintInvalidationBackgroundObscurationChange; | 530 return PaintInvalidationBackgroundObscurationChange; |
531 | 531 |
532 if (m_object.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) | 532 if (m_object.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) |
533 return PaintInvalidationNone; | 533 return PaintInvalidationNone; |
534 | 534 |
535 // Force full paint invalidation if the outline may be affected by descendants | 535 // Force full paint invalidation if the outline may be affected by descendants |
536 // and this object is marked for checking paint invalidation for any reason. | 536 // and this object is marked for checking paint invalidation for any reason. |
537 if (m_object.outlineMayBeAffectedByDescendants() || | 537 if (m_object.outlineMayBeAffectedByDescendants() || |
538 m_object.previousOutlineMayBeAffectedByDescendants()) { | 538 m_object.previousOutlineMayBeAffectedByDescendants()) { |
539 m_object.getMutableForPainting() | 539 m_object.getMutableForPainting() |
540 .updatePreviousOutlineMayBeAffectedByDescendants(); | 540 .updatePreviousOutlineMayBeAffectedByDescendants(); |
541 return PaintInvalidationOutline; | 541 return PaintInvalidationOutline; |
542 } | 542 } |
543 | 543 |
544 // If the size is zero on one of our bounds then we know we're going to have | 544 // If the size is zero on one of our bounds then we know we're going to have |
545 // to do a full invalidation of either old bounds or new bounds. | 545 // to do a full invalidation of either old bounds or new bounds. |
546 if (m_context.oldVisualRect.isEmpty()) | 546 if (m_context.oldVisualRect.isEmpty()) |
547 return PaintInvalidationBecameVisible; | 547 return PaintInvalidationBecameVisible; |
548 if (m_context.newVisualRect.isEmpty()) | 548 if (m_object.visualRect().isEmpty()) |
549 return PaintInvalidationBecameInvisible; | 549 return PaintInvalidationBecameInvisible; |
550 | 550 |
551 // If we shifted, we don't know the exact reason so we are conservative and | 551 // If we shifted, we don't know the exact reason so we are conservative and |
552 // trigger a full invalidation. Shifting could be caused by some layout | 552 // trigger a full invalidation. Shifting could be caused by some layout |
553 // property (left / top) or some in-flow layoutObject inserted / removed | 553 // property (left / top) or some in-flow layoutObject inserted / removed |
554 // before us in the tree. | 554 // before us in the tree. |
555 if (m_context.newVisualRect.location() != m_context.oldVisualRect.location()) | 555 if (m_object.visualRect().location() != m_context.oldVisualRect.location()) |
556 return PaintInvalidationBoundsChange; | 556 return PaintInvalidationBoundsChange; |
557 | 557 |
558 if (m_context.newLocation != m_context.oldLocation) | 558 if (m_context.newLocation != m_context.oldLocation) |
559 return PaintInvalidationLocationChange; | 559 return PaintInvalidationLocationChange; |
560 | 560 |
561 // Incremental invalidation is only applicable to LayoutBoxes. Return | 561 // Incremental invalidation is only applicable to LayoutBoxes. Return |
562 // PaintInvalidationIncremental no matter if oldVisualRect and newVisualRect | 562 // PaintInvalidationIncremental no matter if oldVisualRect and newVisualRect |
563 // are equal because a LayoutBox may need paint invalidation if its border box | 563 // are equal because a LayoutBox may need paint invalidation if its border box |
564 // changes. BoxPaintInvalidator may also override this reason with a full | 564 // changes. BoxPaintInvalidator may also override this reason with a full |
565 // paint invalidation reason if needed. | 565 // paint invalidation reason if needed. |
566 if (m_object.isBox()) | 566 if (m_object.isBox()) |
567 return PaintInvalidationIncremental; | 567 return PaintInvalidationIncremental; |
568 | 568 |
569 if (m_context.oldVisualRect != m_context.newVisualRect) | 569 if (m_context.oldVisualRect != m_object.visualRect()) |
570 return PaintInvalidationBoundsChange; | 570 return PaintInvalidationBoundsChange; |
571 | 571 |
572 return PaintInvalidationNone; | 572 return PaintInvalidationNone; |
573 } | 573 } |
574 | 574 |
575 DISABLE_CFI_PERF | 575 DISABLE_CFI_PERF |
576 void ObjectPaintInvalidatorWithContext::invalidateSelectionIfNeeded( | 576 void ObjectPaintInvalidatorWithContext::invalidateSelectionIfNeeded( |
577 PaintInvalidationReason reason) { | 577 PaintInvalidationReason reason) { |
578 // Update selection rect when we are doing full invalidation (in case that the | 578 // Update selection rect when we are doing full invalidation (in case that the |
579 // object is moved, composite status changed, etc.) or | 579 // object is moved, composite status changed, etc.) or |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 PaintInvalidatorContext::ForcedSubtreeSVGResourceChange)) { | 636 PaintInvalidatorContext::ForcedSubtreeSVGResourceChange)) { |
637 reason = PaintInvalidationSVGResourceChange; | 637 reason = PaintInvalidationSVGResourceChange; |
638 break; | 638 break; |
639 } | 639 } |
640 return PaintInvalidationNone; | 640 return PaintInvalidationNone; |
641 case PaintInvalidationDelayedFull: | 641 case PaintInvalidationDelayedFull: |
642 return PaintInvalidationDelayedFull; | 642 return PaintInvalidationDelayedFull; |
643 default: | 643 default: |
644 DCHECK(isImmediateFullPaintInvalidationReason(reason)); | 644 DCHECK(isImmediateFullPaintInvalidationReason(reason)); |
645 fullyInvalidatePaint(reason, m_context.oldVisualRect, | 645 fullyInvalidatePaint(reason, m_context.oldVisualRect, |
646 m_context.newVisualRect); | 646 m_object.visualRect()); |
647 } | 647 } |
648 | 648 |
649 m_context.paintingLayer->setNeedsRepaint(); | 649 m_context.paintingLayer->setNeedsRepaint(); |
650 m_object.invalidateDisplayItemClients(reason); | 650 m_object.invalidateDisplayItemClients(reason); |
651 return reason; | 651 return reason; |
652 } | 652 } |
653 | 653 |
654 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() | 654 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() |
655 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} | 655 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} |
656 | 656 |
657 } // namespace blink | 657 } // namespace blink |
OLD | NEW |