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" |
11 #include "core/layout/compositing/CompositedLayerMapping.h" | 11 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 12 #include "core/paint/FindPaintOffsetAndVisualRectNeedingUpdate.h" |
12 #include "core/paint/PaintInvalidator.h" | 13 #include "core/paint/PaintInvalidator.h" |
13 #include "core/paint/PaintLayer.h" | 14 #include "core/paint/PaintLayer.h" |
14 #include "platform/HostWindow.h" | 15 #include "platform/HostWindow.h" |
15 #include "platform/graphics/GraphicsLayer.h" | 16 #include "platform/graphics/GraphicsLayer.h" |
16 | 17 |
17 namespace blink { | 18 namespace blink { |
18 | 19 |
19 static bool gDisablePaintInvalidationStateAsserts = false; | 20 static bool gDisablePaintInvalidationStateAsserts = false; |
20 | 21 |
21 typedef HashMap<const LayoutObject*, LayoutRect> SelectionVisualRectMap; | 22 typedef HashMap<const LayoutObject*, LayoutRect> SelectionVisualRectMap; |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 573 |
573 if (m_context.oldVisualRect != m_object.visualRect()) | 574 if (m_context.oldVisualRect != m_object.visualRect()) |
574 return PaintInvalidationBoundsChange; | 575 return PaintInvalidationBoundsChange; |
575 | 576 |
576 return PaintInvalidationNone; | 577 return PaintInvalidationNone; |
577 } | 578 } |
578 | 579 |
579 DISABLE_CFI_PERF | 580 DISABLE_CFI_PERF |
580 void ObjectPaintInvalidatorWithContext::invalidateSelectionIfNeeded( | 581 void ObjectPaintInvalidatorWithContext::invalidateSelectionIfNeeded( |
581 PaintInvalidationReason reason) { | 582 PaintInvalidationReason reason) { |
582 // Update selection rect when we are doing full invalidation (in case that the | 583 // Update selection rect when we are doing full invalidation with geometry |
583 // object is moved, composite status changed, etc.) or | 584 // change (in case that the object is moved, composite status changed, etc.) |
584 // shouldInvalidationSelection is set (in case that the selection itself | 585 // or shouldInvalidationSelection is set (in case that the selection itself |
585 // changed). | 586 // changed). |
586 bool fullInvalidation = isImmediateFullPaintInvalidationReason(reason); | 587 bool fullInvalidation = isImmediateFullPaintInvalidationReason(reason); |
587 if (!fullInvalidation && !m_object.shouldInvalidateSelection()) | 588 if (!fullInvalidation && !m_object.shouldInvalidateSelection()) |
588 return; | 589 return; |
589 | 590 |
590 DCHECK(m_object.hasSelectionVisualRect() == | 591 DCHECK(m_object.hasSelectionVisualRect() == |
591 selectionVisualRectMap().contains(&m_object)); | 592 selectionVisualRectMap().contains(&m_object)); |
592 LayoutRect oldSelectionRect; | 593 LayoutRect oldSelectionRect; |
593 if (m_object.hasSelectionVisualRect()) | 594 if (m_object.hasSelectionVisualRect()) |
594 oldSelectionRect = selectionVisualRectMap().at(&m_object); | 595 oldSelectionRect = selectionVisualRectMap().at(&m_object); |
595 LayoutRect newSelectionRect = m_object.localSelectionRect(); | 596 |
596 m_context.mapLocalRectToVisualRectInBacking(m_object, newSelectionRect); | 597 LayoutRect newSelectionRect; |
| 598 #if DCHECK_IS_ON() |
| 599 FindVisualRectNeedingUpdateScope finder(m_object, m_context, oldSelectionRect, |
| 600 newSelectionRect); |
| 601 #endif |
| 602 if (m_context.needsVisualRectUpdate(m_object)) { |
| 603 newSelectionRect = m_object.localSelectionRect(); |
| 604 m_context.mapLocalRectToVisualRectInBacking(m_object, newSelectionRect); |
| 605 } else { |
| 606 newSelectionRect = oldSelectionRect; |
| 607 } |
597 | 608 |
598 setSelectionVisualRect(m_object, newSelectionRect); | 609 setSelectionVisualRect(m_object, newSelectionRect); |
599 | 610 |
600 if (!fullInvalidation) { | 611 if (!fullInvalidation) { |
601 fullyInvalidatePaint(PaintInvalidationSelection, oldSelectionRect, | 612 fullyInvalidatePaint(PaintInvalidationSelection, oldSelectionRect, |
602 newSelectionRect); | 613 newSelectionRect); |
603 m_context.paintingLayer->setNeedsRepaint(); | 614 m_context.paintingLayer->setNeedsRepaint(); |
604 m_object.invalidateDisplayItemClients(PaintInvalidationSelection); | 615 m_object.invalidateDisplayItemClients(PaintInvalidationSelection); |
605 } | 616 } |
606 } | 617 } |
(...skipping 29 matching lines...) Expand all Loading... |
636 reason = PaintInvalidationSVGResourceChange; | 647 reason = PaintInvalidationSVGResourceChange; |
637 break; | 648 break; |
638 } | 649 } |
639 return PaintInvalidationNone; | 650 return PaintInvalidationNone; |
640 case PaintInvalidationDelayedFull: | 651 case PaintInvalidationDelayedFull: |
641 return PaintInvalidationDelayedFull; | 652 return PaintInvalidationDelayedFull; |
642 default: | 653 default: |
643 DCHECK(isImmediateFullPaintInvalidationReason(reason)); | 654 DCHECK(isImmediateFullPaintInvalidationReason(reason)); |
644 // This allows descendants to know the computed reason if it's different | 655 // This allows descendants to know the computed reason if it's different |
645 // from the original reason before paint invalidation. | 656 // from the original reason before paint invalidation. |
646 m_object.getMutableForPainting().setShouldDoFullPaintInvalidation(reason); | 657 m_object.getMutableForPainting() |
| 658 .setShouldDoFullPaintInvalidationWithoutGeometryChange(reason); |
647 fullyInvalidatePaint(reason, m_context.oldVisualRect, | 659 fullyInvalidatePaint(reason, m_context.oldVisualRect, |
648 m_object.visualRect()); | 660 m_object.visualRect()); |
649 } | 661 } |
650 | 662 |
651 m_context.paintingLayer->setNeedsRepaint(); | 663 m_context.paintingLayer->setNeedsRepaint(); |
652 m_object.invalidateDisplayItemClients(reason); | 664 m_object.invalidateDisplayItemClients(reason); |
653 return reason; | 665 return reason; |
654 } | 666 } |
655 | 667 |
656 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() | 668 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() |
657 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} | 669 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} |
658 | 670 |
659 } // namespace blink | 671 } // namespace blink |
OLD | NEW |