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

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

Issue 1416053003: Let synchronized painting generate correct paint invalidation rects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: For landing Created 5 years, 2 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 "config.h" 5 #include "config.h"
6 #include "platform/graphics/paint/PaintController.h" 6 #include "platform/graphics/paint/PaintController.h"
7 7
8 #include "platform/NotImplemented.h" 8 #include "platform/NotImplemented.h"
9 #include "platform/TraceEvent.h" 9 #include "platform/TraceEvent.h"
10 #include "platform/graphics/GraphicsLayer.h" 10 #include "platform/graphics/GraphicsLayer.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 m_scopeStack.append(m_nextScope++); 105 m_scopeStack.append(m_nextScope++);
106 beginSkippingCache(); 106 beginSkippingCache();
107 } 107 }
108 108
109 void PaintController::endScope() 109 void PaintController::endScope()
110 { 110 {
111 m_scopeStack.removeLast(); 111 m_scopeStack.removeLast();
112 endSkippingCache(); 112 endSkippingCache();
113 } 113 }
114 114
115 void PaintController::invalidate(const DisplayItemClientWrapper& client, PaintIn validationReason paintInvalidationReason, const IntRect& previousPaintInvalidati onRect, const IntRect& newPaintInvalidationRect) 115 void PaintController::invalidate(const DisplayItemClientWrapper& client, PaintIn validationReason paintInvalidationReason, const IntRect* visualRect)
116 { 116 {
117 invalidateClient(client); 117 invalidateClient(client);
118 118
119 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { 119 if (visualRect) {
120 Invalidation invalidation = { previousPaintInvalidationRect, paintInvali dationReason }; 120 // TODO(wkorman): cache visualRect for the client.
121 if (!previousPaintInvalidationRect.isEmpty())
122 m_invalidations.append(invalidation);
123 if (newPaintInvalidationRect != previousPaintInvalidationRect && !newPai ntInvalidationRect.isEmpty()) {
124 invalidation.rect = newPaintInvalidationRect;
125 m_invalidations.append(invalidation);
126 }
127 } 121 }
128 } 122 }
129 123
130 void PaintController::invalidateClient(const DisplayItemClientWrapper& client) 124 void PaintController::invalidateClient(const DisplayItemClientWrapper& client)
131 { 125 {
126 #if ENABLE(ASSERT)
127 m_invalidations.append(client.debugName());
128 #endif
129
132 invalidateUntracked(client.displayItemClient()); 130 invalidateUntracked(client.displayItemClient());
133 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && m_trackedPaintInvali dationObjects) 131 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && m_trackedPaintInvali dationObjects)
134 m_trackedPaintInvalidationObjects->append(client.debugName()); 132 m_trackedPaintInvalidationObjects->append(client.debugName());
135 } 133 }
136 134
137 void PaintController::invalidateUntracked(DisplayItemClient client) 135 void PaintController::invalidateUntracked(DisplayItemClient client)
138 { 136 {
139 // This can be called during painting, but we can't invalidate already paint ed clients. 137 // This can be called during painting, but we can't invalidate already paint ed clients.
140 ASSERT(!m_newDisplayItemIndicesByClient.contains(client)); 138 ASSERT(!m_newDisplayItemIndicesByClient.contains(client));
141 updateValidlyCachedClientsIfNeeded(); 139 updateValidlyCachedClientsIfNeeded();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // repainted ones, and appending new items. 260 // repainted ones, and appending new items.
263 // - For cached drawing display item, copy the corresponding cached DrawingDispl ayItem; 261 // - For cached drawing display item, copy the corresponding cached DrawingDispl ayItem;
264 // - For cached subsequence display item, copy the cached display items between the 262 // - For cached subsequence display item, copy the cached display items between the
265 // corresponding SubsequenceDisplayItem and EndSubsequenceDisplayItem (incl.); 263 // corresponding SubsequenceDisplayItem and EndSubsequenceDisplayItem (incl.);
266 // - Otherwise, copy the new display item. 264 // - Otherwise, copy the new display item.
267 // 265 //
268 // The algorithm is O(|m_currentDisplayItemList| + |m_newDisplayItemList|). 266 // The algorithm is O(|m_currentDisplayItemList| + |m_newDisplayItemList|).
269 // Coefficients are related to the ratio of out-of-order CachedDisplayItems 267 // Coefficients are related to the ratio of out-of-order CachedDisplayItems
270 // and the average number of (Drawing|Subsequence)DisplayItems per client. 268 // and the average number of (Drawing|Subsequence)DisplayItems per client.
271 // 269 //
272 void PaintController::commitNewDisplayItems(GraphicsLayer* graphicsLayer) 270 void PaintController::commitNewDisplayItems()
273 { 271 {
274 TRACE_EVENT2("blink,benchmark", "PaintController::commitNewDisplayItems", 272 TRACE_EVENT2("blink,benchmark", "PaintController::commitNewDisplayItems",
275 "current_display_list_size", (int)m_currentPaintArtifact.displayItemList ().size(), 273 "current_display_list_size", (int)m_currentPaintArtifact.displayItemList ().size(),
276 "num_non_cached_new_items", (int)m_newDisplayItemList.size() - m_numCach edItems); 274 "num_non_cached_new_items", (int)m_newDisplayItemList.size() - m_numCach edItems);
277 275
278 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { 276 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()
279 if (!m_newDisplayItemList.isEmpty() && m_newDisplayItemList.last().type( ) == DisplayItem::CachedDisplayItemList) { 277 && !m_newDisplayItemList.isEmpty()
280 // The whole display item list is cached. 278 && m_newDisplayItemList.last().type() == DisplayItem::CachedDisplayItemL ist) {
281 ASSERT(m_newDisplayItemList.size() == 1 279 // The whole display item list is cached.
282 || (m_newDisplayItemList.size() == 2 && m_newDisplayItemList[0]. type() == DisplayItem::DebugRedFill)); 280 ASSERT(m_newDisplayItemList.size() == 1
283 ASSERT(m_invalidations.isEmpty()); 281 || (m_newDisplayItemList.size() == 2 && m_newDisplayItemList[0].type () == DisplayItem::DebugRedFill));
284 ASSERT(m_clientsCheckedPaintInvalidation.isEmpty()); 282 ASSERT(m_invalidations.isEmpty());
285 m_newDisplayItemList.clear(); 283 ASSERT(m_clientsCheckedPaintInvalidation.isEmpty());
286 m_newPaintChunks.clear(); 284 m_newDisplayItemList.clear();
287 return; 285 m_newPaintChunks.clear();
288 } 286 return;
289 for (const auto& invalidation : m_invalidations) 287 }
290 graphicsLayer->setNeedsDisplayInRect(invalidation.rect, invalidation .invalidationReason); 288 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
291 m_invalidations.clear();
292 m_clientsCheckedPaintInvalidation.clear(); 289 m_clientsCheckedPaintInvalidation.clear();
293 }
294 290
295 // These data structures are used during painting only. 291 // These data structures are used during painting only.
296 ASSERT(m_scopeStack.isEmpty()); 292 ASSERT(m_scopeStack.isEmpty());
297 m_scopeStack.clear(); 293 m_scopeStack.clear();
298 m_nextScope = 1; 294 m_nextScope = 1;
299 ASSERT(!skippingCache()); 295 ASSERT(!skippingCache());
300 #if ENABLE(ASSERT) 296 #if ENABLE(ASSERT)
301 m_newDisplayItemIndicesByClient.clear(); 297 m_newDisplayItemIndicesByClient.clear();
302 m_clientsWithPaintOffsetInvalidations.clear(); 298 m_clientsWithPaintOffsetInvalidations.clear();
299 m_invalidations.clear();
303 #endif 300 #endif
304 301
305 if (m_currentPaintArtifact.isEmpty()) { 302 if (m_currentPaintArtifact.isEmpty()) {
306 #if ENABLE(ASSERT) 303 #if ENABLE(ASSERT)
307 for (const auto& item : m_newDisplayItemList) 304 for (const auto& item : m_newDisplayItemList)
308 ASSERT(!item.isCached()); 305 ASSERT(!item.isCached());
309 #endif 306 #endif
310 m_currentPaintArtifact.displayItemList().swap(m_newDisplayItemList); 307 m_currentPaintArtifact.displayItemList().swap(m_newDisplayItemList);
311 m_currentPaintArtifact.paintChunks() = m_newPaintChunks.releasePaintChun ks(); 308 m_currentPaintArtifact.paintChunks() = m_newPaintChunks.releasePaintChun ks();
312 m_validlyCachedClientsDirty = true; 309 m_validlyCachedClientsDirty = true;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 562
566 void PaintController::showDebugData() const 563 void PaintController::showDebugData() const
567 { 564 {
568 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri ng(m_currentPaintArtifact.displayItemList()).utf8().data()); 565 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri ng(m_currentPaintArtifact.displayItemList()).utf8().data());
569 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m _newDisplayItemList).utf8().data()); 566 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m _newDisplayItemList).utf8().data());
570 } 567 }
571 568
572 #endif // ifndef NDEBUG 569 #endif // ifndef NDEBUG
573 570
574 } // namespace blink 571 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698