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