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

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

Issue 2022563002: Remove display item scope (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 #if DCHECK_IS_ON() 76 #if DCHECK_IS_ON()
77 // Verify noop begin/end pairs have been removed. 77 // Verify noop begin/end pairs have been removed.
78 if (m_newDisplayItemList.size() >= 2 && displayItem.isEnd()) { 78 if (m_newDisplayItemList.size() >= 2 && displayItem.isEnd()) {
79 const auto& beginDisplayItem = m_newDisplayItemList[m_newDisplayItemList .size() - 2]; 79 const auto& beginDisplayItem = m_newDisplayItemList[m_newDisplayItemList .size() - 2];
80 if (beginDisplayItem.isBegin() && beginDisplayItem.getType() != DisplayI tem::Subsequence && !beginDisplayItem.drawsContent()) 80 if (beginDisplayItem.isBegin() && beginDisplayItem.getType() != DisplayI tem::Subsequence && !beginDisplayItem.drawsContent())
81 DCHECK(!displayItem.isEndAndPairedWith(beginDisplayItem.getType())); 81 DCHECK(!displayItem.isEndAndPairedWith(beginDisplayItem.getType()));
82 } 82 }
83 #endif 83 #endif
84 84
85 if (!m_scopeStack.isEmpty()) 85 if (skippingCache())
86 displayItem.setScope(m_scopeStack.last()); 86 displayItem.setSkippedCache();
87 87
88 #if DCHECK_IS_ON() 88 #if DCHECK_IS_ON()
89 size_t index = findMatchingItemFromIndex(displayItem.nonCachedId(), m_newDis playItemIndicesByClient, m_newDisplayItemList); 89 size_t index = findMatchingItemFromIndex(displayItem.nonCachedId(), m_newDis playItemIndicesByClient, m_newDisplayItemList);
90 if (index != kNotFound) { 90 if (index != kNotFound) {
91 #ifndef NDEBUG 91 #ifndef NDEBUG
92 showDebugData(); 92 showDebugData();
93 WTFLogAlways("DisplayItem %s has duplicated id with previous %s (index=% d)\n", 93 WTFLogAlways("DisplayItem %s has duplicated id with previous %s (index=% d)\n",
94 displayItem.asDebugString().utf8().data(), m_newDisplayItemList[inde x].asDebugString().utf8().data(), static_cast<int>(index)); 94 displayItem.asDebugString().utf8().data(), m_newDisplayItemList[inde x].asDebugString().utf8().data(), static_cast<int>(index));
95 #endif 95 #endif
96 NOTREACHED(); 96 NOTREACHED();
97 } 97 }
98 addItemToIndexIfNeeded(displayItem, m_newDisplayItemList.size() - 1, m_newDi splayItemIndicesByClient); 98 addItemToIndexIfNeeded(displayItem, m_newDisplayItemList.size() - 1, m_newDi splayItemIndicesByClient);
99 #endif // DCHECK_IS_ON() 99 #endif // DCHECK_IS_ON()
100 100
101 if (skippingCache())
102 displayItem.setSkippedCache();
103
104 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 101 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
105 m_newPaintChunks.incrementDisplayItemIndex(behaviorOfItemType(displayIte m.getType())); 102 m_newPaintChunks.incrementDisplayItemIndex(behaviorOfItemType(displayIte m.getType()));
106 } 103 }
107 104
108 void PaintController::updateCurrentPaintChunkProperties(const PaintChunkProperti es& newProperties) 105 void PaintController::updateCurrentPaintChunkProperties(const PaintChunkProperti es& newProperties)
109 { 106 {
110 m_newPaintChunks.updateCurrentPaintChunkProperties(newProperties); 107 m_newPaintChunks.updateCurrentPaintChunkProperties(newProperties);
111 } 108 }
112 109
113 const PaintChunkProperties& PaintController::currentPaintChunkProperties() const 110 const PaintChunkProperties& PaintController::currentPaintChunkProperties() const
114 { 111 {
115 return m_newPaintChunks.currentPaintChunkProperties(); 112 return m_newPaintChunks.currentPaintChunkProperties();
116 } 113 }
117 114
118 void PaintController::beginScope()
119 {
120 SECURITY_DCHECK(m_nextScope < UINT_MAX);
121 m_scopeStack.append(m_nextScope++);
122 beginSkippingCache();
123 }
124
125 void PaintController::endScope()
126 {
127 m_scopeStack.removeLast();
128 endSkippingCache();
129 }
130
131 void PaintController::displayItemClientWasInvalidated(const DisplayItemClient& c lient) 115 void PaintController::displayItemClientWasInvalidated(const DisplayItemClient& c lient)
132 { 116 {
133 #if DCHECK_IS_ON() 117 #if DCHECK_IS_ON()
134 // Slimming paint v1 CompositedLayerMapping may invalidate client on extra l ayers. 118 // Slimming paint v1 CompositedLayerMapping may invalidate client on extra l ayers.
135 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() || clientCacheIsValid(c lient)) 119 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() || clientCacheIsValid(c lient))
136 m_invalidations.append(client.debugName()); 120 m_invalidations.append(client.debugName());
137 121
138 // Should not invalidate already painted clients. 122 // Should not invalidate already painted clients.
139 DCHECK(!m_newDisplayItemIndicesByClient.contains(&client)); 123 DCHECK(!m_newDisplayItemIndicesByClient.contains(&client));
140 #endif 124 #endif
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 return context.nextItemToIndex++; 220 return context.nextItemToIndex++;
237 if (item.isCacheable()) 221 if (item.isCacheable())
238 addItemToIndexIfNeeded(item, context.nextItemToIndex - m_currentPain tArtifact.getDisplayItemList().begin(), context.displayItemIndicesByClient); 222 addItemToIndexIfNeeded(item, context.nextItemToIndex - m_currentPain tArtifact.getDisplayItemList().begin(), context.displayItemIndicesByClient);
239 } 223 }
240 return currentEnd; 224 return currentEnd;
241 } 225 }
242 226
243 void PaintController::copyCachedSubsequence(const DisplayItemList& currentList, DisplayItemList::iterator& currentIt, DisplayItemList& updatedList, SkPictureGpu Analyzer& gpuAnalyzer) 227 void PaintController::copyCachedSubsequence(const DisplayItemList& currentList, DisplayItemList::iterator& currentIt, DisplayItemList& updatedList, SkPictureGpu Analyzer& gpuAnalyzer)
244 { 228 {
245 DCHECK(currentIt->getType() == DisplayItem::Subsequence); 229 DCHECK(currentIt->getType() == DisplayItem::Subsequence);
246 DCHECK(!currentIt->scope()); 230 DisplayItem::Id endSubsequenceId(currentIt->client(), DisplayItem::EndSubseq uence);
247 DisplayItem::Id endSubsequenceId(currentIt->client(), DisplayItem::EndSubseq uence, 0);
248 do { 231 do {
249 // We should always find the EndSubsequence display item. 232 // We should always find the EndSubsequence display item.
250 DCHECK(currentIt != m_currentPaintArtifact.getDisplayItemList().end()); 233 DCHECK(currentIt != m_currentPaintArtifact.getDisplayItemList().end());
251 DCHECK(currentIt->hasValidClient()); 234 DCHECK(currentIt->hasValidClient());
252 updatedList.appendByMoving(*currentIt, currentList.visualRect(currentIt - m_currentPaintArtifact.getDisplayItemList().begin()), gpuAnalyzer); 235 updatedList.appendByMoving(*currentIt, currentList.visualRect(currentIt - m_currentPaintArtifact.getDisplayItemList().begin()), gpuAnalyzer);
253 ++currentIt; 236 ++currentIt;
254 } while (!endSubsequenceId.matches(updatedList.last())); 237 } while (!endSubsequenceId.matches(updatedList.last()));
255 } 238 }
256 239
257 static IntRect visualRectForDisplayItem(const DisplayItem& displayItem, const La youtSize& offsetFromLayoutObject) 240 static IntRect visualRectForDisplayItem(const DisplayItem& displayItem, const La youtSize& offsetFromLayoutObject)
(...skipping 15 matching lines...) Expand all
273 // and the average number of (Drawing|Subsequence)DisplayItems per client. 256 // and the average number of (Drawing|Subsequence)DisplayItems per client.
274 // 257 //
275 void PaintController::commitNewDisplayItems(const LayoutSize& offsetFromLayoutOb ject) 258 void PaintController::commitNewDisplayItems(const LayoutSize& offsetFromLayoutOb ject)
276 { 259 {
277 TRACE_EVENT2("blink,benchmark", "PaintController::commitNewDisplayItems", 260 TRACE_EVENT2("blink,benchmark", "PaintController::commitNewDisplayItems",
278 "current_display_list_size", (int)m_currentPaintArtifact.getDisplayItemL ist().size(), 261 "current_display_list_size", (int)m_currentPaintArtifact.getDisplayItemL ist().size(),
279 "num_non_cached_new_items", (int)m_newDisplayItemList.size() - m_numCach edNewItems); 262 "num_non_cached_new_items", (int)m_newDisplayItemList.size() - m_numCach edNewItems);
280 m_numCachedNewItems = 0; 263 m_numCachedNewItems = 0;
281 264
282 // These data structures are used during painting only. 265 // These data structures are used during painting only.
283 DCHECK(m_scopeStack.isEmpty());
284 m_scopeStack.clear();
285 m_nextScope = 1;
286 DCHECK(!skippingCache()); 266 DCHECK(!skippingCache());
287 #if DCHECK_IS_ON() 267 #if DCHECK_IS_ON()
288 m_newDisplayItemIndicesByClient.clear(); 268 m_newDisplayItemIndicesByClient.clear();
289 m_clientsWithPaintOffsetInvalidations.clear(); 269 m_clientsWithPaintOffsetInvalidations.clear();
290 m_invalidations.clear(); 270 m_invalidations.clear();
291 #endif 271 #endif
292 272
293 SkPictureGpuAnalyzer gpuAnalyzer; 273 SkPictureGpuAnalyzer gpuAnalyzer;
294 274
295 if (m_currentPaintArtifact.isEmpty()) { 275 if (m_currentPaintArtifact.isEmpty()) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 431 }
452 432
453 DCHECK(newIt->getType() == DisplayItem::Subsequence); 433 DCHECK(newIt->getType() == DisplayItem::Subsequence);
454 434
455 #ifndef NDEBUG 435 #ifndef NDEBUG
456 CString messagePrefix = String::format("(In CachedSubsequence of %s)", newIt ->clientDebugString().utf8().data()).utf8(); 436 CString messagePrefix = String::format("(In CachedSubsequence of %s)", newIt ->clientDebugString().utf8().data()).utf8();
457 #else 437 #else
458 CString messagePrefix = "(In CachedSubsequence)"; 438 CString messagePrefix = "(In CachedSubsequence)";
459 #endif 439 #endif
460 440
461 DisplayItem::Id endSubsequenceId(newIt->client(), DisplayItem::EndSubsequenc e, 0); 441 DisplayItem::Id endSubsequenceId(newIt->client(), DisplayItem::EndSubsequenc e);
462 while (true) { 442 while (true) {
463 DCHECK(newIt != m_newDisplayItemList.end()); 443 DCHECK(newIt != m_newDisplayItemList.end());
464 if (newIt->isCached()) 444 if (newIt->isCached())
465 checkUnderInvalidation(newIt, currentIt); 445 checkUnderInvalidation(newIt, currentIt);
466 else 446 else
467 checkCachedDisplayItemIsUnchanged(messagePrefix.data(), *newIt, *cur rentIt); 447 checkCachedDisplayItemIsUnchanged(messagePrefix.data(), *newIt, *cur rentIt);
468 448
469 if (endSubsequenceId.matches(*newIt)) 449 if (endSubsequenceId.matches(*newIt))
470 break; 450 break;
471 451
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 536
557 void PaintController::showDebugData() const 537 void PaintController::showDebugData() const
558 { 538 {
559 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri ng(m_currentPaintArtifact.getDisplayItemList()).utf8().data()); 539 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri ng(m_currentPaintArtifact.getDisplayItemList()).utf8().data());
560 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m _newDisplayItemList).utf8().data()); 540 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m _newDisplayItemList).utf8().data());
561 } 541 }
562 542
563 #endif // ifndef NDEBUG 543 #endif // ifndef NDEBUG
564 544
565 } // namespace blink 545 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698