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

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

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

Powered by Google App Engine
This is Rietveld 408576698