| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 PaintInvalidationReason invalidatePaintIfNeeded() { | 98 PaintInvalidationReason invalidatePaintIfNeeded() { |
| 99 return invalidatePaintIfNeededWithComputedReason( | 99 return invalidatePaintIfNeededWithComputedReason( |
| 100 computePaintInvalidationReason()); | 100 computePaintInvalidationReason()); |
| 101 } | 101 } |
| 102 | 102 |
| 103 PaintInvalidationReason computePaintInvalidationReason(); | 103 PaintInvalidationReason computePaintInvalidationReason(); |
| 104 PaintInvalidationReason invalidatePaintIfNeededWithComputedReason( | 104 PaintInvalidationReason invalidatePaintIfNeededWithComputedReason( |
| 105 PaintInvalidationReason); | 105 PaintInvalidationReason); |
| 106 | 106 |
| 107 // This function tries to minimize the amount of invalidation generated by | |
| 108 // invalidating the "difference" between |m_context.oldVisualRect| and | |
| 109 // |m_context.newVisualRect|. This means invalidating the union of the | |
| 110 // previous rectangles excluding their intersection. The use case is when an | |
| 111 // element only requires a paint invalidation (which means that its content | |
| 112 // didn't change) and its bounds changed but its location didn't. If we don't | |
| 113 // meet the criteria for an incremental paint, the alternative is a full paint | |
| 114 // invalidation. Returns true if any paint invalidation is done. | |
| 115 bool incrementallyInvalidatePaint(); | |
| 116 | |
| 117 private: | |
| 118 void invalidateSelectionIfNeeded(PaintInvalidationReason); | |
| 119 | |
| 120 // This function generates a full invalidation, which means invalidating both | 107 // This function generates a full invalidation, which means invalidating both |
| 121 // |oldVisualRect| and |newVisualRect|. This is the default choice when | 108 // |oldVisualRect| and |newVisualRect|. This is the default choice when |
| 122 // generating an invalidation, as it is always correct, albeit it may force | 109 // generating an invalidation, as it is always correct, albeit it may force |
| 123 // some extra painting. | 110 // some extra painting. |
| 124 void fullyInvalidatePaint(PaintInvalidationReason, | 111 void fullyInvalidatePaint(PaintInvalidationReason, |
| 125 const LayoutRect& oldVisualRect, | 112 const LayoutRect& oldVisualRect, |
| 126 const LayoutRect& newVisualRect); | 113 const LayoutRect& newVisualRect); |
| 127 | 114 |
| 115 private: |
| 116 void invalidateSelectionIfNeeded(PaintInvalidationReason); |
| 117 |
| 128 const PaintInvalidatorContext& m_context; | 118 const PaintInvalidatorContext& m_context; |
| 129 }; | 119 }; |
| 130 | 120 |
| 131 // TODO(crbug.com/457415): We should not allow paint invalidation out of paint | 121 // TODO(crbug.com/457415): We should not allow paint invalidation out of paint |
| 132 // invalidation state. | 122 // invalidation state. |
| 133 class DisablePaintInvalidationStateAsserts { | 123 class DisablePaintInvalidationStateAsserts { |
| 134 STACK_ALLOCATED(); | 124 STACK_ALLOCATED(); |
| 135 WTF_MAKE_NONCOPYABLE(DisablePaintInvalidationStateAsserts); | 125 WTF_MAKE_NONCOPYABLE(DisablePaintInvalidationStateAsserts); |
| 136 | 126 |
| 137 public: | 127 public: |
| 138 DisablePaintInvalidationStateAsserts(); | 128 DisablePaintInvalidationStateAsserts(); |
| 139 | 129 |
| 140 private: | 130 private: |
| 141 AutoReset<bool> m_disabler; | 131 AutoReset<bool> m_disabler; |
| 142 }; | 132 }; |
| 143 | 133 |
| 144 } // namespace blink | 134 } // namespace blink |
| 145 | 135 |
| 146 #endif | 136 #endif |
| OLD | NEW |