OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ObjectPaintInvalidator_h |
| 6 #define ObjectPaintInvalidator_h |
| 7 |
| 8 #include "platform/graphics/PaintInvalidationReason.h" |
| 9 #include "wtf/Allocator.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 class LayoutObject; |
| 14 class LayoutRect; |
| 15 struct PaintInvalidatorContext; |
| 16 |
| 17 class ObjectPaintInvalidator { |
| 18 STACK_ALLOCATED(); |
| 19 public: |
| 20 ObjectPaintInvalidator(const LayoutObject& object, const PaintInvalidatorCon
text& context) |
| 21 : m_object(object), m_context(context) { } |
| 22 |
| 23 static void objectWillBeDestroyed(const LayoutObject&); |
| 24 |
| 25 PaintInvalidationReason invalidatePaintIfNeeded() { return invalidatePaintIf
NeededWithComputedReason(computePaintInvalidationReason()); } |
| 26 |
| 27 PaintInvalidationReason computePaintInvalidationReason(); |
| 28 PaintInvalidationReason invalidatePaintIfNeededWithComputedReason(PaintInval
idationReason); |
| 29 |
| 30 private: |
| 31 void invalidateSelectionIfNeeded(PaintInvalidationReason); |
| 32 |
| 33 // This function tries to minimize the amount of invalidation generated by i
nvalidating the "difference" between |
| 34 // |m_context.oldBounds| and |m_context.newBounds|. This means invalidating
the union of the previous rectangles |
| 35 // but not their intersection. The use case is when an element only requires
a paint invalidation (which means |
| 36 // that its content didn't change) and its bounds changed but its location d
idn't. |
| 37 // If we don't meet the criteria for an incremental paint, the alternative i
s a full paint invalidation. |
| 38 void incrementallyInvalidatePaint(); |
| 39 |
| 40 // This function generates a full invalidation, which means invalidating bot
h |oldBounds| and |newBounds|. |
| 41 // This is the default choice when generating an invalidation, as it is alwa
ys correct, albeit it may force some extra painting. |
| 42 void fullyInvalidatePaint(PaintInvalidationReason, const LayoutRect& oldBoun
ds, const LayoutRect& newBounds); |
| 43 |
| 44 const LayoutObject& m_object; |
| 45 const PaintInvalidatorContext& m_context; |
| 46 }; |
| 47 |
| 48 } // namespace blink |
| 49 |
| 50 #endif |
OLD | NEW |