| 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 #ifndef PaintInvalidator_h | 5 #ifndef PaintInvalidator_h |
| 6 #define PaintInvalidator_h | 6 #define PaintInvalidator_h |
| 7 | 7 |
| 8 #include "core/layout/PaintInvalidationState.h" | 8 #include "platform/geometry/LayoutRect.h" |
| 9 #include "wtf/Optional.h" | |
| 10 #include "wtf/Vector.h" | 9 #include "wtf/Vector.h" |
| 11 | 10 |
| 12 namespace blink { | 11 namespace blink { |
| 13 | 12 |
| 14 class FrameView; | 13 class FrameView; |
| 14 class LayoutBoxModelObject; |
| 15 class LayoutObject; | 15 class LayoutObject; |
| 16 class PaintLayer; |
| 16 struct PaintPropertyTreeBuilderContext; | 17 struct PaintPropertyTreeBuilderContext; |
| 17 | 18 |
| 18 // TODO(wangxianzhu): Move applicable PaintInvalidationState code into PaintInva
lidator. | 19 struct PaintInvalidatorContext { |
| 19 using PaintInvalidatorContext = PaintInvalidationState; | 20 PaintInvalidatorContext(const PaintPropertyTreeBuilderContext& treeBuilderCo
ntext) |
| 21 : treeBuilderContext(treeBuilderContext) { } |
| 22 |
| 23 PaintInvalidatorContext(const PaintPropertyTreeBuilderContext& treeBuilderCo
ntext, const PaintInvalidatorContext& parentContext) |
| 24 : treeBuilderContext(treeBuilderContext) |
| 25 , forcedSubtreeInvalidationFlags(parentContext.forcedSubtreeInvalidation
Flags) |
| 26 , paintInvalidationContainer(parentContext.paintInvalidationContainer) |
| 27 , paintInvalidationContainerForStackedContents(parentContext.paintInvali
dationContainerForStackedContents) |
| 28 , paintingLayer(parentContext.paintingLayer) |
| 29 { } |
| 30 |
| 31 // This method is temporary to adapt PaintInvalidatorContext and the legacy
PaintInvalidationState |
| 32 // for code shared by old code and new code. |
| 33 virtual void mapLocalRectToPaintInvalidationBacking(const LayoutObject&, Lay
outRect&) const; |
| 34 |
| 35 const PaintPropertyTreeBuilderContext& treeBuilderContext; |
| 36 |
| 37 enum ForcedSubtreeInvalidationFlag { |
| 38 ForcedSubtreeInvalidationChecking = 1 << 0, |
| 39 ForcedSubtreeInvalidationRectUpdate = 1 << 1, |
| 40 ForcedSubtreeFullInvalidation = 1 << 2, |
| 41 ForcedSubtreeFullInvalidationForStackedContents = 1 << 3, |
| 42 }; |
| 43 unsigned forcedSubtreeInvalidationFlags = 0; |
| 44 |
| 45 // The following fields can be null only before PaintInvalidator::updateCont
ext(). |
| 46 |
| 47 // The current paint invalidation container for normal flow objects. |
| 48 // It is the enclosing composited object. |
| 49 const LayoutBoxModelObject* paintInvalidationContainer = nullptr; |
| 50 |
| 51 // The current paint invalidation container for stacked contents (stacking c
ontexts or positioned objects). |
| 52 // It is the nearest ancestor composited object which establishes a stacking
context. |
| 53 // See Source/core/paint/README.md ### PaintInvalidationState for details on
how stacked contents' |
| 54 // paint invalidation containers differ. |
| 55 const LayoutBoxModelObject* paintInvalidationContainerForStackedContents = n
ullptr; |
| 56 |
| 57 PaintLayer* paintingLayer = nullptr; |
| 58 |
| 59 LayoutRect oldBounds; |
| 60 LayoutRect newBounds; |
| 61 LayoutPoint oldLocation; |
| 62 LayoutPoint newLocation; |
| 63 }; |
| 20 | 64 |
| 21 class PaintInvalidator { | 65 class PaintInvalidator { |
| 22 public: | 66 public: |
| 23 // TODO(wangxianzhu): Avoid Optional<> by using copy-and-update pattern for
PaintInvalidatorContext. | 67 void invalidatePaintIfNeeded(FrameView&, PaintInvalidatorContext&); |
| 24 void invalidatePaintIfNeeded(FrameView&, const PaintPropertyTreeBuilderConte
xt&, Optional<PaintInvalidatorContext>&); | 68 void invalidatePaintIfNeeded(const LayoutObject&, PaintInvalidatorContext&); |
| 25 void invalidatePaintIfNeeded(const LayoutObject&, const PaintPropertyTreeBui
lderContext&, const PaintInvalidatorContext&, Optional<PaintInvalidatorContext>&
); | |
| 26 | 69 |
| 27 // Process objects needing paint invalidation on the next frame. | 70 // Process objects needing paint invalidation on the next frame. |
| 28 // See the definition of PaintInvalidationDelayedFull for more details. | 71 // See the definition of PaintInvalidationDelayedFull for more details. |
| 29 void processPendingDelayedPaintInvalidations(); | 72 void processPendingDelayedPaintInvalidations(); |
| 30 | 73 |
| 31 private: | 74 private: |
| 32 Vector<const LayoutObject*> m_pendingDelayedPaintInvalidations; | 75 Vector<const LayoutObject*> m_pendingDelayedPaintInvalidations; |
| 33 }; | 76 }; |
| 34 | 77 |
| 35 } // namespace blink | 78 } // namespace blink |
| 36 | 79 |
| 37 #endif // PaintInvalidator_h | 80 #endif // PaintInvalidator_h |
| OLD | NEW |