| 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 ObjectPaintInvalidator_h | 5 #ifndef ObjectPaintInvalidator_h |
| 6 #define ObjectPaintInvalidator_h | 6 #define ObjectPaintInvalidator_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "platform/graphics/PaintInvalidationReason.h" | 9 #include "platform/graphics/PaintInvalidationReason.h" |
| 10 #include "wtf/Allocator.h" | 10 #include "wtf/Allocator.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 void slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( | 36 void slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient( |
| 37 const DisplayItemClient& client, | 37 const DisplayItemClient& client, |
| 38 PaintInvalidationReason reason) { | 38 PaintInvalidationReason reason) { |
| 39 slowSetPaintingLayerNeedsRepaint(); | 39 slowSetPaintingLayerNeedsRepaint(); |
| 40 invalidateDisplayItemClient(client, reason); | 40 invalidateDisplayItemClient(client, reason); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void invalidateDisplayItemClientsIncludingNonCompositingDescendants( | 43 void invalidateDisplayItemClientsIncludingNonCompositingDescendants( |
| 44 PaintInvalidationReason); | 44 PaintInvalidationReason); |
| 45 | 45 |
| 46 void invalidatePaintOfPreviousPaintInvalidationRect( | 46 void invalidatePaintOfPreviousVisualRect( |
| 47 const LayoutBoxModelObject& paintInvalidationContainer, | 47 const LayoutBoxModelObject& paintInvalidationContainer, |
| 48 PaintInvalidationReason); | 48 PaintInvalidationReason); |
| 49 | 49 |
| 50 // The caller should ensure the painting layer has been setNeedsRepaint before | 50 // The caller should ensure the painting layer has been setNeedsRepaint before |
| 51 // calling this function. | 51 // calling this function. |
| 52 void invalidateDisplayItemClient(const DisplayItemClient&, | 52 void invalidateDisplayItemClient(const DisplayItemClient&, |
| 53 PaintInvalidationReason); | 53 PaintInvalidationReason); |
| 54 | 54 |
| 55 // Actually do the paint invalidate of rect r for this object which has been | 55 // Actually do the paint invalidate of rect r for this object which has been |
| 56 // computed in the coordinate space of the GraphicsLayer backing of | 56 // computed in the coordinate space of the GraphicsLayer backing of |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 PaintInvalidationReason invalidatePaintIfNeeded() { | 94 PaintInvalidationReason invalidatePaintIfNeeded() { |
| 95 return invalidatePaintIfNeededWithComputedReason( | 95 return invalidatePaintIfNeededWithComputedReason( |
| 96 computePaintInvalidationReason()); | 96 computePaintInvalidationReason()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 PaintInvalidationReason computePaintInvalidationReason(); | 99 PaintInvalidationReason computePaintInvalidationReason(); |
| 100 PaintInvalidationReason invalidatePaintIfNeededWithComputedReason( | 100 PaintInvalidationReason invalidatePaintIfNeededWithComputedReason( |
| 101 PaintInvalidationReason); | 101 PaintInvalidationReason); |
| 102 | 102 |
| 103 // This function tries to minimize the amount of invalidation generated by | 103 // This function tries to minimize the amount of invalidation generated by |
| 104 // invalidating the "difference" between |m_context.oldBounds| and | 104 // invalidating the "difference" between |m_context.oldVisualRect| and |
| 105 // |m_context.newBounds|. This means invalidating the union of the previous | 105 // |m_context.newVisualRect|. This means invalidating the union of the |
| 106 // rectangles but not their intersection. The use case is when an element only | 106 // previous rectangles excluding their intersection. The use case is when an |
| 107 // requires a paint invalidation (which means that its content didn't change) | 107 // element only requires a paint invalidation (which means that its content |
| 108 // and its bounds changed but its location didn't. If we don't meet the | 108 // didn't change) and its bounds changed but its location didn't. If we don't |
| 109 // criteria for an incremental paint, the alternative is a full paint | 109 // meet the criteria for an incremental paint, the alternative is a full paint |
| 110 // invalidation. Returns true if any paint invalidation is done. | 110 // invalidation. Returns true if any paint invalidation is done. |
| 111 bool incrementallyInvalidatePaint(); | 111 bool incrementallyInvalidatePaint(); |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 void invalidateSelectionIfNeeded(PaintInvalidationReason); | 114 void invalidateSelectionIfNeeded(PaintInvalidationReason); |
| 115 | 115 |
| 116 // This function generates a full invalidation, which means invalidating both | 116 // This function generates a full invalidation, which means invalidating both |
| 117 // |oldBounds| and |newBounds|. This is the default choice when generating an | 117 // |oldVisualRect| and |newVisualRect|. This is the default choice when |
| 118 // invalidation, as it is always correct, albeit it may force some extra | 118 // generating an invalidation, as it is always correct, albeit it may force |
| 119 // painting. | 119 // some extra painting. |
| 120 void fullyInvalidatePaint(PaintInvalidationReason, | 120 void fullyInvalidatePaint(PaintInvalidationReason, |
| 121 const LayoutRect& oldBounds, | 121 const LayoutRect& oldVisualRect, |
| 122 const LayoutRect& newBounds); | 122 const LayoutRect& newVisualRect); |
| 123 | 123 |
| 124 const PaintInvalidatorContext& m_context; | 124 const PaintInvalidatorContext& m_context; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 // TODO(crbug.com/457415): We should not allow paint invalidation out of paint | 127 // TODO(crbug.com/457415): We should not allow paint invalidation out of paint |
| 128 // invalidation state. | 128 // invalidation state. |
| 129 class DisablePaintInvalidationStateAsserts { | 129 class DisablePaintInvalidationStateAsserts { |
| 130 STACK_ALLOCATED(); | 130 STACK_ALLOCATED(); |
| 131 WTF_MAKE_NONCOPYABLE(DisablePaintInvalidationStateAsserts); | 131 WTF_MAKE_NONCOPYABLE(DisablePaintInvalidationStateAsserts); |
| 132 | 132 |
| 133 public: | 133 public: |
| 134 DisablePaintInvalidationStateAsserts(); | 134 DisablePaintInvalidationStateAsserts(); |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 AutoReset<bool> m_disabler; | 137 AutoReset<bool> m_disabler; |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 } // namespace blink | 140 } // namespace blink |
| 141 | 141 |
| 142 #endif | 142 #endif |
| OLD | NEW |