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

Side by Side Diff: third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp

Issue 2872423002: Tweak PaintInvalidationReasons (Closed)
Patch Set: Rebaseline-cl Created 3 years, 7 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 // 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 InvalidatePaintIncludingNonCompositingDescendants() { 207 InvalidatePaintIncludingNonCompositingDescendants() {
208 // Since we're only painting non-composited layers, we know that they all 208 // Since we're only painting non-composited layers, we know that they all
209 // share the same paintInvalidationContainer. 209 // share the same paintInvalidationContainer.
210 const LayoutBoxModelObject& paint_invalidation_container = 210 const LayoutBoxModelObject& paint_invalidation_container =
211 object_.ContainerForPaintInvalidation(); 211 object_.ContainerForPaintInvalidation();
212 SlowSetPaintingLayerNeedsRepaint(); 212 SlowSetPaintingLayerNeedsRepaint();
213 TraverseNonCompositingDescendantsInPaintOrder( 213 TraverseNonCompositingDescendantsInPaintOrder(
214 object_, [&paint_invalidation_container](const LayoutObject& object) { 214 object_, [&paint_invalidation_container](const LayoutObject& object) {
215 SetPaintingLayerNeedsRepaintDuringTraverse(object); 215 SetPaintingLayerNeedsRepaintDuringTraverse(object);
216 ObjectPaintInvalidator(object).InvalidatePaintOfPreviousVisualRect( 216 ObjectPaintInvalidator(object).InvalidatePaintOfPreviousVisualRect(
217 paint_invalidation_container, kPaintInvalidationSubtree); 217 paint_invalidation_container, PaintInvalidationReason::kSubtree);
218 }); 218 });
219 } 219 }
220 220
221 void ObjectPaintInvalidator:: 221 void ObjectPaintInvalidator::
222 InvalidatePaintIncludingNonSelfPaintingLayerDescendantsInternal( 222 InvalidatePaintIncludingNonSelfPaintingLayerDescendantsInternal(
223 const LayoutBoxModelObject& paint_invalidation_container) { 223 const LayoutBoxModelObject& paint_invalidation_container) {
224 InvalidatePaintOfPreviousVisualRect(paint_invalidation_container, 224 InvalidatePaintOfPreviousVisualRect(paint_invalidation_container,
225 kPaintInvalidationSubtree); 225 PaintInvalidationReason::kSubtree);
226 for (LayoutObject* child = object_.SlowFirstChild(); child; 226 for (LayoutObject* child = object_.SlowFirstChild(); child;
227 child = child->NextSibling()) { 227 child = child->NextSibling()) {
228 if (!child->HasLayer() || 228 if (!child->HasLayer() ||
229 !ToLayoutBoxModelObject(child)->Layer()->IsSelfPaintingLayer()) 229 !ToLayoutBoxModelObject(child)->Layer()->IsSelfPaintingLayer())
230 ObjectPaintInvalidator(*child) 230 ObjectPaintInvalidator(*child)
231 .InvalidatePaintIncludingNonSelfPaintingLayerDescendantsInternal( 231 .InvalidatePaintIncludingNonSelfPaintingLayerDescendantsInternal(
232 paint_invalidation_container); 232 paint_invalidation_container);
233 } 233 }
234 } 234 }
235 235
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 // here. It is already taken into account. 317 // here. It is already taken into account.
318 squashing_layer->SetNeedsDisplayInRect(EnclosingIntRect(rect), reason, 318 squashing_layer->SetNeedsDisplayInRect(EnclosingIntRect(rect), reason,
319 object_); 319 object_);
320 } 320 }
321 } else if (object_.CompositedScrollsWithRespectTo( 321 } else if (object_.CompositedScrollsWithRespectTo(
322 paint_invalidation_container)) { 322 paint_invalidation_container)) {
323 layer.GetCompositedLayerMapping()->SetScrollingContentsNeedDisplayInRect( 323 layer.GetCompositedLayerMapping()->SetScrollingContentsNeedDisplayInRect(
324 rect, reason, object_); 324 rect, reason, object_);
325 } else if (paint_invalidation_container.UsesCompositedScrolling()) { 325 } else if (paint_invalidation_container.UsesCompositedScrolling()) {
326 DCHECK(object_ == paint_invalidation_container); 326 DCHECK(object_ == paint_invalidation_container);
327 if (reason == kPaintInvalidationBackgroundOnScrollingContentsLayer || 327 if (reason ==
328 reason == kPaintInvalidationCaret) { 328 PaintInvalidationReason::kBackgroundOnScrollingContentsLayer ||
329 reason == PaintInvalidationReason::kCaret) {
329 layer.GetCompositedLayerMapping()->SetScrollingContentsNeedDisplayInRect( 330 layer.GetCompositedLayerMapping()->SetScrollingContentsNeedDisplayInRect(
330 rect, reason, object_); 331 rect, reason, object_);
331 } else { 332 } else {
332 layer.GetCompositedLayerMapping() 333 layer.GetCompositedLayerMapping()
333 ->SetNonScrollingContentsNeedDisplayInRect(rect, reason, object_); 334 ->SetNonScrollingContentsNeedDisplayInRect(rect, reason, object_);
334 } 335 }
335 } else { 336 } else {
336 // Otherwise invalidate everything. 337 // Otherwise invalidate everything.
337 layer.GetCompositedLayerMapping()->SetContentsNeedDisplayInRect( 338 layer.GetCompositedLayerMapping()->SetContentsNeedDisplayInRect(
338 rect, reason, object_); 339 rect, reason, object_);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 406
406 const LayoutBoxModelObject& paint_invalidation_container = 407 const LayoutBoxModelObject& paint_invalidation_container =
407 object_.ContainerForPaintInvalidation(); 408 object_.ContainerForPaintInvalidation();
408 LayoutRect dirty_rect_on_backing = dirty_rect; 409 LayoutRect dirty_rect_on_backing = dirty_rect;
409 PaintLayer::MapRectToPaintInvalidationBacking( 410 PaintLayer::MapRectToPaintInvalidationBacking(
410 object_, paint_invalidation_container, dirty_rect_on_backing); 411 object_, paint_invalidation_container, dirty_rect_on_backing);
411 dirty_rect_on_backing.Move(object_.ScrollAdjustmentForPaintInvalidation( 412 dirty_rect_on_backing.Move(object_.ScrollAdjustmentForPaintInvalidation(
412 paint_invalidation_container)); 413 paint_invalidation_container));
413 InvalidatePaintUsingContainer(paint_invalidation_container, 414 InvalidatePaintUsingContainer(paint_invalidation_container,
414 dirty_rect_on_backing, 415 dirty_rect_on_backing,
415 kPaintInvalidationRectangle); 416 PaintInvalidationReason::kRectangle);
416 417
417 SlowSetPaintingLayerNeedsRepaint(); 418 SlowSetPaintingLayerNeedsRepaint();
418 if (display_item_client) 419 if (display_item_client) {
419 InvalidateDisplayItemClient(*display_item_client, 420 InvalidateDisplayItemClient(*display_item_client,
420 kPaintInvalidationRectangle); 421 PaintInvalidationReason::kRectangle);
421 else 422 } else {
422 object_.InvalidateDisplayItemClients(kPaintInvalidationRectangle); 423 object_.InvalidateDisplayItemClients(PaintInvalidationReason::kRectangle);
424 }
423 425
424 return dirty_rect_on_backing; 426 return dirty_rect_on_backing;
425 } 427 }
426 428
427 void ObjectPaintInvalidator::SlowSetPaintingLayerNeedsRepaint() { 429 void ObjectPaintInvalidator::SlowSetPaintingLayerNeedsRepaint() {
428 if (PaintLayer* painting_layer = object_.PaintingLayer()) 430 if (PaintLayer* painting_layer = object_.PaintingLayer())
429 painting_layer->SetNeedsRepaint(); 431 painting_layer->SetNeedsRepaint();
430 } 432 }
431 433
432 LayoutPoint ObjectPaintInvalidator::LocationInBacking() const { 434 LayoutPoint ObjectPaintInvalidator::LocationInBacking() const {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 bool background_obscuration_changed = false; 522 bool background_obscuration_changed = false;
521 bool background_obscured = object_.BackgroundIsKnownToBeObscured(); 523 bool background_obscured = object_.BackgroundIsKnownToBeObscured();
522 if (background_obscured != object_.PreviousBackgroundObscured()) { 524 if (background_obscured != object_.PreviousBackgroundObscured()) {
523 object_.GetMutableForPainting().SetPreviousBackgroundObscured( 525 object_.GetMutableForPainting().SetPreviousBackgroundObscured(
524 background_obscured); 526 background_obscured);
525 background_obscuration_changed = true; 527 background_obscuration_changed = true;
526 } 528 }
527 529
528 if (context_.forced_subtree_invalidation_flags & 530 if (context_.forced_subtree_invalidation_flags &
529 PaintInvalidatorContext::kForcedSubtreeFullInvalidation) 531 PaintInvalidatorContext::kForcedSubtreeFullInvalidation)
530 return kPaintInvalidationSubtree; 532 return PaintInvalidationReason::kSubtree;
531 533
532 if (object_.ShouldDoFullPaintInvalidation()) 534 if (object_.ShouldDoFullPaintInvalidation())
533 return object_.FullPaintInvalidationReason(); 535 return object_.FullPaintInvalidationReason();
534 536
535 if (context_.old_visual_rect.IsEmpty() && object_.VisualRect().IsEmpty()) 537 if (context_.old_visual_rect.IsEmpty() && object_.VisualRect().IsEmpty())
536 return kPaintInvalidationNone; 538 return PaintInvalidationReason::kNone;
537 539
538 if (background_obscuration_changed) 540 if (background_obscuration_changed)
539 return kPaintInvalidationBackgroundObscurationChange; 541 return PaintInvalidationReason::kBackground;
540 542
541 if (object_.PaintedOutputOfObjectHasNoEffectRegardlessOfSize()) 543 if (object_.PaintedOutputOfObjectHasNoEffectRegardlessOfSize())
542 return kPaintInvalidationNone; 544 return PaintInvalidationReason::kNone;
543 545
544 // Force full paint invalidation if the outline may be affected by descendants 546 // Force full paint invalidation if the outline may be affected by descendants
545 // and this object is marked for checking paint invalidation for any reason. 547 // and this object is marked for checking paint invalidation for any reason.
546 if (object_.OutlineMayBeAffectedByDescendants() || 548 if (object_.OutlineMayBeAffectedByDescendants() ||
547 object_.PreviousOutlineMayBeAffectedByDescendants()) { 549 object_.PreviousOutlineMayBeAffectedByDescendants()) {
548 object_.GetMutableForPainting() 550 object_.GetMutableForPainting()
549 .UpdatePreviousOutlineMayBeAffectedByDescendants(); 551 .UpdatePreviousOutlineMayBeAffectedByDescendants();
550 return kPaintInvalidationOutline; 552 return PaintInvalidationReason::kOutline;
551 } 553 }
552 554
553 // If the size is zero on one of our bounds then we know we're going to have 555 // If the size is zero on one of our bounds then we know we're going to have
554 // to do a full invalidation of either old bounds or new bounds. 556 // to do a full invalidation of either old bounds or new bounds.
555 if (context_.old_visual_rect.IsEmpty()) 557 if (context_.old_visual_rect.IsEmpty())
556 return kPaintInvalidationBecameVisible; 558 return PaintInvalidationReason::kAppeared;
557 if (object_.VisualRect().IsEmpty()) 559 if (object_.VisualRect().IsEmpty())
558 return kPaintInvalidationBecameInvisible; 560 return PaintInvalidationReason::kDisappeared;
559 561
560 // If we shifted, we don't know the exact reason so we are conservative and 562 // If we shifted, we don't know the exact reason so we are conservative and
561 // trigger a full invalidation. Shifting could be caused by some layout 563 // trigger a full invalidation. Shifting could be caused by some layout
562 // property (left / top) or some in-flow layoutObject inserted / removed 564 // property (left / top) or some in-flow layoutObject inserted / removed
563 // before us in the tree. 565 // before us in the tree.
564 if (object_.VisualRect().Location() != context_.old_visual_rect.Location()) 566 if (object_.VisualRect().Location() != context_.old_visual_rect.Location())
565 return kPaintInvalidationBoundsChange; 567 return PaintInvalidationReason::kGeometry;
566 568
567 if (context_.new_location != context_.old_location) 569 if (context_.new_location != context_.old_location)
568 return kPaintInvalidationLocationChange; 570 return PaintInvalidationReason::kGeometry;
569 571
570 // Incremental invalidation is only applicable to LayoutBoxes. Return 572 // Incremental invalidation is only applicable to LayoutBoxes. Return
571 // PaintInvalidationIncremental no matter if oldVisualRect and newVisualRect 573 // PaintInvalidationIncremental no matter if oldVisualRect and newVisualRect
572 // are equal because a LayoutBox may need paint invalidation if its border box 574 // are equal because a LayoutBox may need paint invalidation if its border box
573 // changes. BoxPaintInvalidator may also override this reason with a full 575 // changes. BoxPaintInvalidator may also override this reason with a full
574 // paint invalidation reason if needed. 576 // paint invalidation reason if needed.
575 if (object_.IsBox()) 577 if (object_.IsBox())
576 return kPaintInvalidationIncremental; 578 return PaintInvalidationReason::kIncremental;
577 579
578 if (context_.old_visual_rect != object_.VisualRect()) 580 if (context_.old_visual_rect != object_.VisualRect())
579 return kPaintInvalidationBoundsChange; 581 return PaintInvalidationReason::kGeometry;
580 582
581 return kPaintInvalidationNone; 583 return PaintInvalidationReason::kNone;
582 } 584 }
583 585
584 DISABLE_CFI_PERF 586 DISABLE_CFI_PERF
585 void ObjectPaintInvalidatorWithContext::InvalidateSelectionIfNeeded( 587 void ObjectPaintInvalidatorWithContext::InvalidateSelectionIfNeeded(
586 PaintInvalidationReason reason) { 588 PaintInvalidationReason reason) {
587 // Update selection rect when we are doing full invalidation with geometry 589 // Update selection rect when we are doing full invalidation with geometry
588 // change (in case that the object is moved, composite status changed, etc.) 590 // change (in case that the object is moved, composite status changed, etc.)
589 // or shouldInvalidationSelection is set (in case that the selection itself 591 // or shouldInvalidationSelection is set (in case that the selection itself
590 // changed). 592 // changed).
591 bool full_invalidation = IsImmediateFullPaintInvalidationReason(reason); 593 bool full_invalidation = IsImmediateFullPaintInvalidationReason(reason);
(...skipping 14 matching lines...) Expand all
606 if (context_.NeedsVisualRectUpdate(object_)) { 608 if (context_.NeedsVisualRectUpdate(object_)) {
607 new_selection_rect = object_.LocalSelectionRect(); 609 new_selection_rect = object_.LocalSelectionRect();
608 context_.MapLocalRectToVisualRectInBacking(object_, new_selection_rect); 610 context_.MapLocalRectToVisualRectInBacking(object_, new_selection_rect);
609 } else { 611 } else {
610 new_selection_rect = old_selection_rect; 612 new_selection_rect = old_selection_rect;
611 } 613 }
612 614
613 SetSelectionVisualRect(object_, new_selection_rect); 615 SetSelectionVisualRect(object_, new_selection_rect);
614 616
615 if (!full_invalidation) { 617 if (!full_invalidation) {
616 FullyInvalidatePaint(kPaintInvalidationSelection, old_selection_rect, 618 FullyInvalidatePaint(PaintInvalidationReason::kSelection,
617 new_selection_rect); 619 old_selection_rect, new_selection_rect);
618 context_.painting_layer->SetNeedsRepaint(); 620 context_.painting_layer->SetNeedsRepaint();
619 object_.InvalidateDisplayItemClients(kPaintInvalidationSelection); 621 object_.InvalidateDisplayItemClients(PaintInvalidationReason::kSelection);
620 } 622 }
621 } 623 }
622 624
623 DISABLE_CFI_PERF 625 DISABLE_CFI_PERF
624 PaintInvalidationReason 626 PaintInvalidationReason
625 ObjectPaintInvalidatorWithContext::InvalidatePaintWithComputedReason( 627 ObjectPaintInvalidatorWithContext::InvalidatePaintWithComputedReason(
626 PaintInvalidationReason reason) { 628 PaintInvalidationReason reason) {
627 // We need to invalidate the selection before checking for whether we are 629 // We need to invalidate the selection before checking for whether we are
628 // doing a full invalidation. This is because we need to update the previous 630 // doing a full invalidation. This is because we need to update the previous
629 // selection rect regardless. 631 // selection rect regardless.
630 InvalidateSelectionIfNeeded(reason); 632 InvalidateSelectionIfNeeded(reason);
631 633
632 switch (reason) { 634 switch (reason) {
633 case kPaintInvalidationNone: 635 case PaintInvalidationReason::kNone:
634 // There are corner cases that the display items need to be invalidated 636 // There are corner cases that the display items need to be invalidated
635 // for paint offset mutation, but incurs no pixel difference (i.e. bounds 637 // for paint offset mutation, but incurs no pixel difference (i.e. bounds
636 // stay the same) so no rect-based invalidation is issued. See 638 // stay the same) so no rect-based invalidation is issued. See
637 // crbug.com/508383 and crbug.com/515977. 639 // crbug.com/508383 and crbug.com/515977.
638 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && 640 if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() &&
639 (context_.forced_subtree_invalidation_flags & 641 (context_.forced_subtree_invalidation_flags &
640 PaintInvalidatorContext::kForcedSubtreeInvalidationChecking) && 642 PaintInvalidatorContext::kForcedSubtreeInvalidationChecking) &&
641 !object_.IsSVGChild()) { 643 !object_.IsSVGChild()) {
642 // For SPv1, we conservatively assume the object changed paint offset 644 // For SPv1, we conservatively assume the object changed paint offset
643 // except for non-root SVG whose paint offset is always zero. 645 // except for non-root SVG whose paint offset is always zero.
644 reason = kPaintInvalidationLocationChange; 646 reason = PaintInvalidationReason::kGeometry;
645 break; 647 break;
646 } 648 }
647 649
648 if (object_.IsSVG() && 650 if (object_.IsSVG() &&
649 (context_.forced_subtree_invalidation_flags & 651 (context_.forced_subtree_invalidation_flags &
650 PaintInvalidatorContext::kForcedSubtreeSVGResourceChange)) { 652 PaintInvalidatorContext::kForcedSubtreeSVGResourceChange)) {
651 reason = kPaintInvalidationSVGResourceChange; 653 reason = PaintInvalidationReason::kSVGResource;
652 break; 654 break;
653 } 655 }
654 return kPaintInvalidationNone; 656 return PaintInvalidationReason::kNone;
655 case kPaintInvalidationDelayedFull: 657 case PaintInvalidationReason::kDelayedFull:
656 return kPaintInvalidationDelayedFull; 658 return PaintInvalidationReason::kDelayedFull;
657 default: 659 default:
658 DCHECK(IsImmediateFullPaintInvalidationReason(reason)); 660 DCHECK(IsImmediateFullPaintInvalidationReason(reason));
659 // This allows descendants to know the computed reason if it's different 661 // This allows descendants to know the computed reason if it's different
660 // from the original reason before paint invalidation. 662 // from the original reason before paint invalidation.
661 object_.GetMutableForPainting() 663 object_.GetMutableForPainting()
662 .SetShouldDoFullPaintInvalidationWithoutGeometryChange(reason); 664 .SetShouldDoFullPaintInvalidationWithoutGeometryChange(reason);
663 FullyInvalidatePaint(reason, context_.old_visual_rect, 665 FullyInvalidatePaint(reason, context_.old_visual_rect,
664 object_.VisualRect()); 666 object_.VisualRect());
665 } 667 }
666 668
667 context_.painting_layer->SetNeedsRepaint(); 669 context_.painting_layer->SetNeedsRepaint();
668 object_.InvalidateDisplayItemClients(reason); 670 object_.InvalidateDisplayItemClients(reason);
669 return reason; 671 return reason;
670 } 672 }
671 673
672 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() 674 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts()
673 : disabler_(&g_disable_paint_invalidation_state_asserts, true) {} 675 : disabler_(&g_disable_paint_invalidation_state_asserts, true) {}
674 676
675 } // namespace blink 677 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698