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

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

Issue 1379883003: Create PaintChunk and begin writing code to build paint chunks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: correct comment 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/DisplayItemList.h" 6 #include "platform/graphics/paint/DisplayItemList.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/paint/DrawingDisplayItem.h" 10 #include "platform/graphics/paint/DrawingDisplayItem.h"
11 11
12 #ifndef NDEBUG 12 #ifndef NDEBUG
13 #include "platform/graphics/LoggingCanvas.h" 13 #include "platform/graphics/LoggingCanvas.h"
14 #include "wtf/text/StringBuilder.h" 14 #include "wtf/text/StringBuilder.h"
15 #include <stdio.h> 15 #include <stdio.h>
16 #endif 16 #endif
17 17
18 namespace blink { 18 namespace blink {
19 19
20 const DisplayItems& DisplayItemList::displayItems() const 20 const DisplayItems& DisplayItemList::displayItems() const
21 { 21 {
22 ASSERT(m_newDisplayItems.isEmpty()); 22 ASSERT(m_newDisplayItems.isEmpty());
23 return m_currentDisplayItems; 23 return m_currentDisplayItems;
24 } 24 }
25 25
26 const Vector<PaintChunk>& DisplayItemList::paintChunks() const
27 {
28 ASSERT(m_newPaintChunks.isInInitialState());
29 return m_currentPaintChunks;
30 }
31
26 bool DisplayItemList::lastDisplayItemIsNoopBegin() const 32 bool DisplayItemList::lastDisplayItemIsNoopBegin() const
27 { 33 {
28 if (m_newDisplayItems.isEmpty()) 34 if (m_newDisplayItems.isEmpty())
29 return false; 35 return false;
30 36
31 const auto& lastDisplayItem = m_newDisplayItems.last(); 37 const auto& lastDisplayItem = m_newDisplayItems.last();
32 return lastDisplayItem.isBegin() && !lastDisplayItem.drawsContent(); 38 return lastDisplayItem.isBegin() && !lastDisplayItem.drawsContent();
33 } 39 }
34 40
35 void DisplayItemList::removeLastDisplayItem() 41 void DisplayItemList::removeLastDisplayItem()
36 { 42 {
37 if (m_newDisplayItems.isEmpty()) 43 if (m_newDisplayItems.isEmpty())
38 return; 44 return;
39 45
40 #if ENABLE(ASSERT) 46 #if ENABLE(ASSERT)
41 // Also remove the index pointing to the removed display item. 47 // Also remove the index pointing to the removed display item.
42 DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndicesByClient .find(m_newDisplayItems.last().client()); 48 DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndicesByClient .find(m_newDisplayItems.last().client());
43 if (it != m_newDisplayItemIndicesByClient.end()) { 49 if (it != m_newDisplayItemIndicesByClient.end()) {
44 Vector<size_t>& indices = it->value; 50 Vector<size_t>& indices = it->value;
45 if (!indices.isEmpty() && indices.last() == (m_newDisplayItems.size() - 1)) 51 if (!indices.isEmpty() && indices.last() == (m_newDisplayItems.size() - 1))
46 indices.removeLast(); 52 indices.removeLast();
47 } 53 }
48 #endif 54 #endif
49 m_newDisplayItems.removeLast(); 55 m_newDisplayItems.removeLast();
56
57 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
58 m_newPaintChunks.decrementDisplayItemIndex();
50 } 59 }
51 60
52 void DisplayItemList::processNewItem(DisplayItem& displayItem) 61 void DisplayItemList::processNewItem(DisplayItem& displayItem)
53 { 62 {
54 ASSERT(!m_constructionDisabled); 63 ASSERT(!m_constructionDisabled);
55 ASSERT(!skippingCache() || !displayItem.isCached()); 64 ASSERT(!skippingCache() || !displayItem.isCached());
56 65
57 if (displayItem.isCached()) 66 if (displayItem.isCached())
58 ++m_numCachedItems; 67 ++m_numCachedItems;
59 68
(...skipping 17 matching lines...) Expand all
77 WTFLogAlways("DisplayItem %s has duplicated id with previous %s (index=% d)\n", 86 WTFLogAlways("DisplayItem %s has duplicated id with previous %s (index=% d)\n",
78 displayItem.asDebugString().utf8().data(), m_newDisplayItems[index]. asDebugString().utf8().data(), static_cast<int>(index)); 87 displayItem.asDebugString().utf8().data(), m_newDisplayItems[index]. asDebugString().utf8().data(), static_cast<int>(index));
79 #endif 88 #endif
80 ASSERT_NOT_REACHED(); 89 ASSERT_NOT_REACHED();
81 } 90 }
82 addItemToIndexIfNeeded(displayItem, m_newDisplayItems.size() - 1, m_newDispl ayItemIndicesByClient); 91 addItemToIndexIfNeeded(displayItem, m_newDisplayItems.size() - 1, m_newDispl ayItemIndicesByClient);
83 #endif // ENABLE(ASSERT) 92 #endif // ENABLE(ASSERT)
84 93
85 if (skippingCache()) 94 if (skippingCache())
86 displayItem.setSkippedCache(); 95 displayItem.setSkippedCache();
96
97 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
98 m_newPaintChunks.incrementDisplayItemIndex();
99 }
100
101 void DisplayItemList::updateCurrentPaintProperties(const PaintProperties& newPai ntProperties)
102 {
103 m_newPaintChunks.updateCurrentPaintProperties(newPaintProperties);
87 } 104 }
88 105
89 void DisplayItemList::beginScope() 106 void DisplayItemList::beginScope()
90 { 107 {
91 ASSERT_WITH_SECURITY_IMPLICATION(m_nextScope < UINT_MAX); 108 ASSERT_WITH_SECURITY_IMPLICATION(m_nextScope < UINT_MAX);
92 m_scopeStack.append(m_nextScope++); 109 m_scopeStack.append(m_nextScope++);
93 beginSkippingCache(); 110 beginSkippingCache();
94 } 111 }
95 112
96 void DisplayItemList::endScope() 113 void DisplayItemList::endScope()
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 #if ENABLE(ASSERT) 282 #if ENABLE(ASSERT)
266 m_newDisplayItemIndicesByClient.clear(); 283 m_newDisplayItemIndicesByClient.clear();
267 #endif 284 #endif
268 285
269 if (m_currentDisplayItems.isEmpty()) { 286 if (m_currentDisplayItems.isEmpty()) {
270 #if ENABLE(ASSERT) 287 #if ENABLE(ASSERT)
271 for (const auto& item : m_newDisplayItems) 288 for (const auto& item : m_newDisplayItems)
272 ASSERT(!item.isCached()); 289 ASSERT(!item.isCached());
273 #endif 290 #endif
274 m_currentDisplayItems.swap(m_newDisplayItems); 291 m_currentDisplayItems.swap(m_newDisplayItems);
292 m_currentPaintChunks = m_newPaintChunks.releasePaintChunks();
275 m_validlyCachedClientsDirty = true; 293 m_validlyCachedClientsDirty = true;
276 m_numCachedItems = 0; 294 m_numCachedItems = 0;
277 return; 295 return;
278 } 296 }
279 297
280 updateValidlyCachedClientsIfNeeded(); 298 updateValidlyCachedClientsIfNeeded();
281 299
282 // Stores indices to valid DrawingDisplayItems in m_currentDisplayItems that have not been matched 300 // Stores indices to valid DrawingDisplayItems in m_currentDisplayItems that have not been matched
283 // by CachedDisplayItems during synchronized matching. The indexed items wil l be matched 301 // by CachedDisplayItems during synchronized matching. The indexed items wil l be matched
284 // by later out-of-order CachedDisplayItems in m_newDisplayItems. This ensur es that when 302 // by later out-of-order CachedDisplayItems in m_newDisplayItems. This ensur es that when
285 // out-of-order CachedDisplayItems occur, we only traverse at most once over m_currentDisplayItems 303 // out-of-order CachedDisplayItems occur, we only traverse at most once over m_currentDisplayItems
286 // looking for potential matches. Thus we can ensure that the algorithm runs in linear time. 304 // looking for potential matches. Thus we can ensure that the algorithm runs in linear time.
287 OutOfOrderIndexContext outOfOrderIndexContext(m_currentDisplayItems.begin()) ; 305 OutOfOrderIndexContext outOfOrderIndexContext(m_currentDisplayItems.begin()) ;
288 306
289 // TODO(jbroman): Consider revisiting this heuristic. 307 // TODO(jbroman): Consider revisiting this heuristic.
290 DisplayItems updatedList(std::max(m_currentDisplayItems.usedCapacityInBytes( ), m_newDisplayItems.usedCapacityInBytes())); 308 DisplayItems updatedList(std::max(m_currentDisplayItems.usedCapacityInBytes( ), m_newDisplayItems.usedCapacityInBytes()));
309 Vector<PaintChunk> updatedPaintChunks;
291 DisplayItems::iterator currentIt = m_currentDisplayItems.begin(); 310 DisplayItems::iterator currentIt = m_currentDisplayItems.begin();
292 DisplayItems::iterator currentEnd = m_currentDisplayItems.end(); 311 DisplayItems::iterator currentEnd = m_currentDisplayItems.end();
293 for (DisplayItems::iterator newIt = m_newDisplayItems.begin(); newIt != m_ne wDisplayItems.end(); ++newIt) { 312 for (DisplayItems::iterator newIt = m_newDisplayItems.begin(); newIt != m_ne wDisplayItems.end(); ++newIt) {
294 const DisplayItem& newDisplayItem = *newIt; 313 const DisplayItem& newDisplayItem = *newIt;
295 const DisplayItem::Id newDisplayItemId = newDisplayItem.nonCachedId(); 314 const DisplayItem::Id newDisplayItemId = newDisplayItem.nonCachedId();
296 bool newDisplayItemHasCachedType = newDisplayItem.type() != newDisplayIt emId.type; 315 bool newDisplayItemHasCachedType = newDisplayItem.type() != newDisplayIt emId.type;
297 316
298 bool isSynchronized = currentIt != currentEnd && newDisplayItemId.matche s(*currentIt); 317 bool isSynchronized = currentIt != currentEnd && newDisplayItemId.matche s(*currentIt);
299 318
300 if (newDisplayItemHasCachedType) { 319 if (newDisplayItemHasCachedType) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // Items before currentIt should have been copied so we don't need to in dex them. 362 // Items before currentIt should have been copied so we don't need to in dex them.
344 if (currentIt - outOfOrderIndexContext.nextItemToIndex > 0) 363 if (currentIt - outOfOrderIndexContext.nextItemToIndex > 0)
345 outOfOrderIndexContext.nextItemToIndex = currentIt; 364 outOfOrderIndexContext.nextItemToIndex = currentIt;
346 } 365 }
347 366
348 #if ENABLE(ASSERT) 367 #if ENABLE(ASSERT)
349 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled()) 368 if (RuntimeEnabledFeatures::slimmingPaintUnderInvalidationCheckingEnabled())
350 checkNoRemainingCachedDisplayItems(); 369 checkNoRemainingCachedDisplayItems();
351 #endif // ENABLE(ASSERT) 370 #endif // ENABLE(ASSERT)
352 371
372 // TODO(jbroman): When subsequence caching applies to SPv2, we'll need to
373 // merge the paint chunks as well.
374 m_currentPaintChunks = m_newPaintChunks.releasePaintChunks();
375
353 m_newDisplayItems.clear(); 376 m_newDisplayItems.clear();
354 m_validlyCachedClientsDirty = true; 377 m_validlyCachedClientsDirty = true;
355 m_currentDisplayItems.swap(updatedList); 378 m_currentDisplayItems.swap(updatedList);
356 m_numCachedItems = 0; 379 m_numCachedItems = 0;
357 380
358 #if ENABLE(ASSERT) 381 #if ENABLE(ASSERT)
359 m_clientsWithPaintOffsetInvalidations.clear(); 382 m_clientsWithPaintOffsetInvalidations.clear();
360 #endif 383 #endif
361 } 384 }
362 385
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 570
548 void DisplayItemList::replay(GraphicsContext& context) 571 void DisplayItemList::replay(GraphicsContext& context)
549 { 572 {
550 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay"); 573 TRACE_EVENT0("blink,benchmark", "DisplayItemList::replay");
551 ASSERT(m_newDisplayItems.isEmpty()); 574 ASSERT(m_newDisplayItems.isEmpty());
552 for (DisplayItem& displayItem : m_currentDisplayItems) 575 for (DisplayItem& displayItem : m_currentDisplayItems)
553 displayItem.replay(context); 576 displayItem.replay(context);
554 } 577 }
555 578
556 } // namespace blink 579 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698