OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 PaintController_h | 5 #ifndef PaintController_h |
6 #define PaintController_h | 6 #define PaintController_h |
7 | 7 |
8 #include "platform/PlatformExport.h" | 8 #include "platform/PlatformExport.h" |
9 #include "platform/RuntimeEnabledFeatures.h" | 9 #include "platform/RuntimeEnabledFeatures.h" |
10 #include "platform/geometry/IntRect.h" | 10 #include "platform/geometry/IntRect.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 { | 48 { |
49 // New display items should be committed before PaintController is destr
ucted. | 49 // New display items should be committed before PaintController is destr
ucted. |
50 DCHECK(m_newDisplayItemList.isEmpty()); | 50 DCHECK(m_newDisplayItemList.isEmpty()); |
51 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS | 51 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS |
52 DisplayItemClient::endShouldKeepAliveAllClients(this); | 52 DisplayItemClient::endShouldKeepAliveAllClients(this); |
53 #endif | 53 #endif |
54 } | 54 } |
55 | 55 |
56 void invalidateAll(); | 56 void invalidateAll(); |
57 | 57 |
| 58 // Record when paint offsets change during paint. |
| 59 void invalidatePaintOffset(const DisplayItemClient&); |
| 60 #if DCHECK_IS_ON() |
| 61 bool paintOffsetWasInvalidated(const DisplayItemClient&) const; |
| 62 #endif |
| 63 |
58 // These methods are called during painting. | 64 // These methods are called during painting. |
59 | 65 |
60 // Provide a new set of paint chunk properties to apply to recorded display | 66 // Provide a new set of paint chunk properties to apply to recorded display |
61 // items, for Slimming Paint v2. | 67 // items, for Slimming Paint v2. |
62 void updateCurrentPaintChunkProperties(const PaintChunkProperties&); | 68 void updateCurrentPaintChunkProperties(const PaintChunkProperties&); |
63 | 69 |
64 // Retrieve the current paint properties. | 70 // Retrieve the current paint properties. |
65 const PaintChunkProperties& currentPaintChunkProperties() const; | 71 const PaintChunkProperties& currentPaintChunkProperties() const; |
66 | 72 |
67 template <typename DisplayItemClass, typename... Args> | 73 template <typename DisplayItemClass, typename... Args> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // Returns displayItemList added using createAndAppend() since beginning or | 140 // Returns displayItemList added using createAndAppend() since beginning or |
135 // the last commitNewDisplayItems(). Use with care. | 141 // the last commitNewDisplayItems(). Use with care. |
136 DisplayItemList& newDisplayItemList() { return m_newDisplayItemList; } | 142 DisplayItemList& newDisplayItemList() { return m_newDisplayItemList; } |
137 | 143 |
138 void appendDebugDrawingAfterCommit(const DisplayItemClient&, PassRefPtr<SkPi
cture>, const LayoutSize& offsetFromLayoutObject); | 144 void appendDebugDrawingAfterCommit(const DisplayItemClient&, PassRefPtr<SkPi
cture>, const LayoutSize& offsetFromLayoutObject); |
139 | 145 |
140 #ifndef NDEBUG | 146 #ifndef NDEBUG |
141 void showDebugData() const; | 147 void showDebugData() const; |
142 #endif | 148 #endif |
143 | 149 |
| 150 // This is called only if we are tracking paint invalidation for testing, or
DCHECK_IS_ON() |
| 151 // for error checking and debugging. |
| 152 void displayItemClientWasInvalidated(const DisplayItemClient&); |
| 153 |
144 #if DCHECK_IS_ON() | 154 #if DCHECK_IS_ON() |
| 155 bool hasInvalidations() { return !m_invalidations.isEmpty(); } |
| 156 #endif |
| 157 |
| 158 #if DCHECK_IS_ON() |
145 void assertDisplayItemClientsAreLive(); | 159 void assertDisplayItemClientsAreLive(); |
146 #endif | 160 #endif |
147 | 161 |
148 protected: | 162 protected: |
149 PaintController() | 163 PaintController() |
150 : m_newDisplayItemList(kInitialDisplayItemListCapacityBytes) | 164 : m_newDisplayItemList(kInitialDisplayItemListCapacityBytes) |
151 , m_constructionDisabled(false) | 165 , m_constructionDisabled(false) |
152 , m_subsequenceCachingDisabled(false) | 166 , m_subsequenceCachingDisabled(false) |
153 , m_textPainted(false) | 167 , m_textPainted(false) |
154 , m_imagePainted(false) | 168 , m_imagePainted(false) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 void updateCacheGeneration(); | 200 void updateCacheGeneration(); |
187 | 201 |
188 // The last complete paint artifact. | 202 // The last complete paint artifact. |
189 // In SPv2, this includes paint chunks as well as display items. | 203 // In SPv2, this includes paint chunks as well as display items. |
190 PaintArtifact m_currentPaintArtifact; | 204 PaintArtifact m_currentPaintArtifact; |
191 | 205 |
192 // Data being used to build the next paint artifact. | 206 // Data being used to build the next paint artifact. |
193 DisplayItemList m_newDisplayItemList; | 207 DisplayItemList m_newDisplayItemList; |
194 PaintChunker m_newPaintChunks; | 208 PaintChunker m_newPaintChunks; |
195 | 209 |
| 210 #if DCHECK_IS_ON() |
| 211 // Set of clients which had paint offset changes since the last commit. This
is used for |
| 212 // ensuring paint offsets are only updated once and are the same in all phas
es. |
| 213 HashSet<const DisplayItemClient*> m_clientsWithPaintOffsetInvalidations; |
| 214 #endif |
| 215 |
196 // Allow display item construction to be disabled to isolate the costs of co
nstruction | 216 // Allow display item construction to be disabled to isolate the costs of co
nstruction |
197 // in performance metrics. | 217 // in performance metrics. |
198 bool m_constructionDisabled; | 218 bool m_constructionDisabled; |
199 | 219 |
200 // Allow subsequence caching to be disabled to test the cost of display item
caching. | 220 // Allow subsequence caching to be disabled to test the cost of display item
caching. |
201 bool m_subsequenceCachingDisabled; | 221 bool m_subsequenceCachingDisabled; |
202 | 222 |
203 // Indicates this PaintController has ever had text. It is never reset to fa
lse. | 223 // Indicates this PaintController has ever had text. It is never reset to fa
lse. |
204 bool m_textPainted; | 224 bool m_textPainted; |
205 bool m_imagePainted; | 225 bool m_imagePainted; |
206 | 226 |
207 int m_skippingCacheCount; | 227 int m_skippingCacheCount; |
208 | 228 |
209 int m_numCachedNewItems; | 229 int m_numCachedNewItems; |
210 | 230 |
211 #if DCHECK_IS_ON() | 231 #if DCHECK_IS_ON() |
| 232 // Record the debug names of invalidated clients for assertion and debugging
. |
| 233 Vector<String> m_invalidations; |
| 234 |
212 // This is used to check duplicated ids during add(). We could also check | 235 // This is used to check duplicated ids during add(). We could also check |
213 // during commitNewDisplayItems(), but checking during add() helps developer | 236 // during commitNewDisplayItems(), but checking during add() helps developer |
214 // easily find where the duplicated ids are from. | 237 // easily find where the duplicated ids are from. |
215 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; | 238 DisplayItemIndicesByClientMap m_newDisplayItemIndicesByClient; |
216 #endif | 239 #endif |
217 | 240 |
218 DisplayItemCacheGeneration m_currentCacheGeneration; | 241 DisplayItemCacheGeneration m_currentCacheGeneration; |
219 }; | 242 }; |
220 | 243 |
221 } // namespace blink | 244 } // namespace blink |
222 | 245 |
223 #endif // PaintController_h | 246 #endif // PaintController_h |
OLD | NEW |