Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(793)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp

Issue 2080593002: Revert of Let FrameView track object paint invalidations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@TrackInvalidation
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "platform/graphics/paint/PaintController.h" 5 #include "platform/graphics/paint/PaintController.h"
6 6
7 #include "platform/TraceEvent.h" 7 #include "platform/TraceEvent.h"
8 #include "platform/graphics/GraphicsLayer.h" 8 #include "platform/graphics/GraphicsLayer.h"
9 #include "platform/graphics/paint/DrawingDisplayItem.h" 9 #include "platform/graphics/paint/DrawingDisplayItem.h"
10 #include "third_party/skia/include/core/SkPictureAnalyzer.h" 10 #include "third_party/skia/include/core/SkPictureAnalyzer.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void PaintController::updateCurrentPaintChunkProperties(const PaintChunkProperti es& newProperties) 105 void PaintController::updateCurrentPaintChunkProperties(const PaintChunkProperti es& newProperties)
106 { 106 {
107 m_newPaintChunks.updateCurrentPaintChunkProperties(newProperties); 107 m_newPaintChunks.updateCurrentPaintChunkProperties(newProperties);
108 } 108 }
109 109
110 const PaintChunkProperties& PaintController::currentPaintChunkProperties() const 110 const PaintChunkProperties& PaintController::currentPaintChunkProperties() const
111 { 111 {
112 return m_newPaintChunks.currentPaintChunkProperties(); 112 return m_newPaintChunks.currentPaintChunkProperties();
113 } 113 }
114 114
115 void PaintController::displayItemClientWasInvalidated(const DisplayItemClient& c lient)
116 {
117 #if DCHECK_IS_ON()
118 // Slimming paint v1 CompositedLayerMapping may invalidate client on extra l ayers.
119 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() || clientCacheIsValid(c lient))
120 m_invalidations.append(client.debugName());
121
122 // Should not invalidate already painted clients.
123 DCHECK(!m_newDisplayItemIndicesByClient.contains(&client));
124 #endif
125 }
126
115 void PaintController::invalidateAll() 127 void PaintController::invalidateAll()
116 { 128 {
117 // Can only be called during layout/paintInvalidation, not during painting. 129 // Can only be called during layout/paintInvalidation, not during painting.
118 DCHECK(m_newDisplayItemList.isEmpty()); 130 DCHECK(m_newDisplayItemList.isEmpty());
119 m_currentPaintArtifact.reset(); 131 m_currentPaintArtifact.reset();
120 m_currentCacheGeneration.invalidate(); 132 m_currentCacheGeneration.invalidate();
121 } 133 }
122 134
123 bool PaintController::clientCacheIsValid(const DisplayItemClient& client) const 135 bool PaintController::clientCacheIsValid(const DisplayItemClient& client) const
124 { 136 {
125 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 137 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
126 CHECK(client.isAlive()); 138 CHECK(client.isAlive());
127 #endif 139 #endif
128 if (skippingCache()) 140 if (skippingCache())
129 return false; 141 return false;
130 return client.displayItemsAreCached(m_currentCacheGeneration); 142 return client.displayItemsAreCached(m_currentCacheGeneration);
131 } 143 }
132 144
145 void PaintController::invalidatePaintOffset(const DisplayItemClient& client)
146 {
147 DCHECK(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled());
148 displayItemClientWasInvalidated(client);
149 client.setDisplayItemsUncached();
150
151 #if DCHECK_IS_ON()
152 DCHECK(!paintOffsetWasInvalidated(client));
153 m_clientsWithPaintOffsetInvalidations.add(&client);
154 #endif
155 }
156
157 #if DCHECK_IS_ON()
158 bool PaintController::paintOffsetWasInvalidated(const DisplayItemClient& client) const
159 {
160 DCHECK(RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled());
161 return m_clientsWithPaintOffsetInvalidations.contains(&client);
162 }
163 #endif
164
133 size_t PaintController::findMatchingItemFromIndex(const DisplayItem::Id& id, con st DisplayItemIndicesByClientMap& displayItemIndicesByClient, const DisplayItemL ist& list) 165 size_t PaintController::findMatchingItemFromIndex(const DisplayItem::Id& id, con st DisplayItemIndicesByClientMap& displayItemIndicesByClient, const DisplayItemL ist& list)
134 { 166 {
135 DisplayItemIndicesByClientMap::const_iterator it = displayItemIndicesByClien t.find(&id.client); 167 DisplayItemIndicesByClientMap::const_iterator it = displayItemIndicesByClien t.find(&id.client);
136 if (it == displayItemIndicesByClient.end()) 168 if (it == displayItemIndicesByClient.end())
137 return kNotFound; 169 return kNotFound;
138 170
139 const Vector<size_t>& indices = it->value; 171 const Vector<size_t>& indices = it->value;
140 for (size_t index : indices) { 172 for (size_t index : indices) {
141 const DisplayItem& existingItem = list[index]; 173 const DisplayItem& existingItem = list[index];
142 DCHECK(!existingItem.hasValidClient() || existingItem.client() == id.cli ent); 174 DCHECK(!existingItem.hasValidClient() || existingItem.client() == id.cli ent);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 { 262 {
231 TRACE_EVENT2("blink,benchmark", "PaintController::commitNewDisplayItems", 263 TRACE_EVENT2("blink,benchmark", "PaintController::commitNewDisplayItems",
232 "current_display_list_size", (int)m_currentPaintArtifact.getDisplayItemL ist().size(), 264 "current_display_list_size", (int)m_currentPaintArtifact.getDisplayItemL ist().size(),
233 "num_non_cached_new_items", (int)m_newDisplayItemList.size() - m_numCach edNewItems); 265 "num_non_cached_new_items", (int)m_newDisplayItemList.size() - m_numCach edNewItems);
234 m_numCachedNewItems = 0; 266 m_numCachedNewItems = 0;
235 267
236 // These data structures are used during painting only. 268 // These data structures are used during painting only.
237 DCHECK(!skippingCache()); 269 DCHECK(!skippingCache());
238 #if DCHECK_IS_ON() 270 #if DCHECK_IS_ON()
239 m_newDisplayItemIndicesByClient.clear(); 271 m_newDisplayItemIndicesByClient.clear();
272 m_clientsWithPaintOffsetInvalidations.clear();
273 m_invalidations.clear();
240 #endif 274 #endif
241 275
242 SkPictureGpuAnalyzer gpuAnalyzer; 276 SkPictureGpuAnalyzer gpuAnalyzer;
243 277
244 if (m_currentPaintArtifact.isEmpty()) { 278 if (m_currentPaintArtifact.isEmpty()) {
245 #if DCHECK_IS_ON() 279 #if DCHECK_IS_ON()
246 for (const auto& item : m_newDisplayItemList) 280 for (const auto& item : m_newDisplayItemList)
247 DCHECK(!item.isCached()); 281 DCHECK(!item.isCached());
248 #endif 282 #endif
249 283
(...skipping 22 matching lines...) Expand all
272 DisplayItemList::iterator currentIt = m_currentPaintArtifact.getDisplayItemL ist().begin(); 306 DisplayItemList::iterator currentIt = m_currentPaintArtifact.getDisplayItemL ist().begin();
273 DisplayItemList::iterator currentEnd = m_currentPaintArtifact.getDisplayItem List().end(); 307 DisplayItemList::iterator currentEnd = m_currentPaintArtifact.getDisplayItem List().end();
274 for (DisplayItemList::iterator newIt = m_newDisplayItemList.begin(); newIt ! = m_newDisplayItemList.end(); ++newIt) { 308 for (DisplayItemList::iterator newIt = m_newDisplayItemList.begin(); newIt ! = m_newDisplayItemList.end(); ++newIt) {
275 const DisplayItem& newDisplayItem = *newIt; 309 const DisplayItem& newDisplayItem = *newIt;
276 const DisplayItem::Id newDisplayItemId = newDisplayItem.nonCachedId(); 310 const DisplayItem::Id newDisplayItemId = newDisplayItem.nonCachedId();
277 bool newDisplayItemHasCachedType = newDisplayItem.getType() != newDispla yItemId.type; 311 bool newDisplayItemHasCachedType = newDisplayItem.getType() != newDispla yItemId.type;
278 312
279 bool isSynchronized = currentIt != currentEnd && newDisplayItemId.matche s(*currentIt); 313 bool isSynchronized = currentIt != currentEnd && newDisplayItemId.matche s(*currentIt);
280 314
281 if (newDisplayItemHasCachedType) { 315 if (newDisplayItemHasCachedType) {
316 #if DCHECK_IS_ON()
282 DCHECK(newDisplayItem.isCached()); 317 DCHECK(newDisplayItem.isCached());
283 DCHECK(clientCacheIsValid(newDisplayItem.client())); 318 DCHECK(clientCacheIsValid(newDisplayItem.client()) || (RuntimeEnable dFeatures::slimmingPaintInvalidationEnabled() && !paintOffsetWasInvalidated(newD isplayItem.client())));
319 #endif
284 if (!isSynchronized) { 320 if (!isSynchronized) {
285 currentIt = findOutOfOrderCachedItem(newDisplayItemId, outOfOrde rIndexContext); 321 currentIt = findOutOfOrderCachedItem(newDisplayItemId, outOfOrde rIndexContext);
286 322
287 if (currentIt == currentEnd) { 323 if (currentIt == currentEnd) {
288 #ifndef NDEBUG 324 #ifndef NDEBUG
289 showDebugData(); 325 showDebugData();
290 WTFLogAlways("%s not found in m_currentDisplayItemList\n", n ewDisplayItem.asDebugString().utf8().data()); 326 WTFLogAlways("%s not found in m_currentDisplayItemList\n", n ewDisplayItem.asDebugString().utf8().data());
291 #endif 327 #endif
292 NOTREACHED(); 328 NOTREACHED();
293 // We did not find the cached display item. This should be i mpossible, but may occur if there is a bug 329 // We did not find the cached display item. This should be i mpossible, but may occur if there is a bug
(...skipping 11 matching lines...) Expand all
305 if (newDisplayItem.isCachedDrawing()) { 341 if (newDisplayItem.isCachedDrawing()) {
306 updatedList.appendByMoving(*currentIt, m_currentPaintArtifact.ge tDisplayItemList().visualRect(currentIt - m_currentPaintArtifact.getDisplayItemL ist().begin()), 342 updatedList.appendByMoving(*currentIt, m_currentPaintArtifact.ge tDisplayItemList().visualRect(currentIt - m_currentPaintArtifact.getDisplayItemL ist().begin()),
307 gpuAnalyzer); 343 gpuAnalyzer);
308 ++currentIt; 344 ++currentIt;
309 } else { 345 } else {
310 DCHECK(newDisplayItem.getType() == DisplayItem::CachedSubsequenc e); 346 DCHECK(newDisplayItem.getType() == DisplayItem::CachedSubsequenc e);
311 copyCachedSubsequence(m_currentPaintArtifact.getDisplayItemList( ), currentIt, updatedList, gpuAnalyzer); 347 copyCachedSubsequence(m_currentPaintArtifact.getDisplayItemList( ), currentIt, updatedList, gpuAnalyzer);
312 DCHECK(updatedList.last().getType() == DisplayItem::EndSubsequen ce); 348 DCHECK(updatedList.last().getType() == DisplayItem::EndSubsequen ce);
313 } 349 }
314 } else { 350 } else {
351 #if DCHECK_IS_ON()
315 DCHECK(!newDisplayItem.isDrawing() 352 DCHECK(!newDisplayItem.isDrawing()
316 || newDisplayItem.skippedCache() 353 || newDisplayItem.skippedCache()
317 || !clientCacheIsValid(newDisplayItem.client())); 354 || !clientCacheIsValid(newDisplayItem.client())
355 || (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() & & paintOffsetWasInvalidated(newDisplayItem.client())));
356 #endif
318 357
319 updatedList.appendByMoving(*newIt, visualRectForDisplayItem(*newIt, offsetFromLayoutObject), gpuAnalyzer); 358 updatedList.appendByMoving(*newIt, visualRectForDisplayItem(*newIt, offsetFromLayoutObject), gpuAnalyzer);
320 359
321 if (isSynchronized) 360 if (isSynchronized)
322 ++currentIt; 361 ++currentIt;
323 } 362 }
324 // Items before currentIt should have been copied so we don't need to in dex them. 363 // Items before currentIt should have been copied so we don't need to in dex them.
325 if (currentIt - outOfOrderIndexContext.nextItemToIndex > 0) 364 if (currentIt - outOfOrderIndexContext.nextItemToIndex > 0)
326 outOfOrderIndexContext.nextItemToIndex = currentIt; 365 outOfOrderIndexContext.nextItemToIndex = currentIt;
327 } 366 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 531
493 void PaintController::showDebugData() const 532 void PaintController::showDebugData() const
494 { 533 {
495 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri ng(m_currentPaintArtifact.getDisplayItemList()).utf8().data()); 534 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri ng(m_currentPaintArtifact.getDisplayItemList()).utf8().data());
496 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m _newDisplayItemList).utf8().data()); 535 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m _newDisplayItemList).utf8().data());
497 } 536 }
498 537
499 #endif // ifndef NDEBUG 538 #endif // ifndef NDEBUG
500 539
501 } // namespace blink 540 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698