Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp |
| diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp b/third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp |
| index 2bd50f9f069be0fbb67935efaa0307b0bfae05d1..8efce90b767e63221abde10ce89019e21e04cf55 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp |
| +++ b/third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp |
| @@ -141,9 +141,8 @@ void PaintController::invalidateClient(const DisplayItemClient& client) |
| void PaintController::invalidateUntracked(const DisplayItemClient& client) |
| { |
| // This can be called during painting, but we can't invalidate already painted clients. |
| + client.setDisplayItemsCached(DisplayItemClient::kInvalidCacheGeneration); |
| ASSERT(!m_newDisplayItemIndicesByClient.contains(&client)); |
| - updateValidlyCachedClientsIfNeeded(); |
| - m_validlyCachedClients.remove(&client); |
| } |
| void PaintController::invalidateAll() |
| @@ -151,8 +150,7 @@ void PaintController::invalidateAll() |
| // Can only be called during layout/paintInvalidation, not during painting. |
| ASSERT(m_newDisplayItemList.isEmpty()); |
| m_currentPaintArtifact.reset(); |
| - m_validlyCachedClients.clear(); |
| - m_validlyCachedClientsDirty = false; |
| + m_currentCacheGeneration = DisplayItemClient::kInvalidCacheGeneration; |
| if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && m_trackedPaintInvalidationObjects) |
| m_trackedPaintInvalidationObjects->append("##ALL##"); |
| @@ -160,10 +158,10 @@ void PaintController::invalidateAll() |
| bool PaintController::clientCacheIsValid(const DisplayItemClient& client) const |
| { |
| - if (skippingCache()) |
| + ASSERT(DisplayItemClient::isAlive(client)); |
| + if (!canUseClientCacheStatus() || skippingCache()) |
| return false; |
| - updateValidlyCachedClientsIfNeeded(); |
| - return m_validlyCachedClients.contains(&client); |
| + return client.displayItemsAreCached(m_currentCacheGeneration); |
| } |
| void PaintController::invalidatePaintOffset(const DisplayItemClient& client) |
| @@ -239,12 +237,10 @@ DisplayItemList::iterator PaintController::findOutOfOrderCachedItemForward(const |
| for (; context.nextItemToIndex != currentEnd; ++context.nextItemToIndex) { |
| const DisplayItem& item = *context.nextItemToIndex; |
| ASSERT(item.hasValidClient()); |
| - if (item.isCacheable() && clientCacheIsValid(item.client())) { |
| - if (id.matches(item)) |
| - return context.nextItemToIndex++; |
| - |
| + if (id.matches(item)) |
| + return context.nextItemToIndex++; |
| + if (item.isCacheable()) |
| addItemToIndexIfNeeded(item, context.nextItemToIndex - m_currentPaintArtifact.displayItemList().begin(), context.displayItemIndicesByClient); |
| - } |
| } |
| return currentEnd; |
| } |
| @@ -292,9 +288,6 @@ void PaintController::commitNewDisplayItemsInternal() |
| "num_non_cached_new_items", (int)m_newDisplayItemList.size() - m_numCachedNewItems); |
| m_numCachedNewItems = 0; |
| - if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| - m_clientsCheckedPaintInvalidation.clear(); |
| - |
| // These data structures are used during painting only. |
| ASSERT(m_scopeStack.isEmpty()); |
| m_scopeStack.clear(); |
| @@ -313,12 +306,10 @@ void PaintController::commitNewDisplayItemsInternal() |
| #endif |
| m_currentPaintArtifact.displayItemList().swap(m_newDisplayItemList); |
| m_currentPaintArtifact.paintChunks() = m_newPaintChunks.releasePaintChunks(); |
| - m_validlyCachedClientsDirty = true; |
| + updateCacheGeneration(); |
| return; |
| } |
| - updateValidlyCachedClientsIfNeeded(); |
| - |
| // Stores indices to valid DrawingDisplayItems in m_currentDisplayItems that have not been matched |
| // by CachedDisplayItems during synchronized matching. The indexed items will be matched |
| // by later out-of-order CachedDisplayItems in m_newDisplayItemList. This ensures that when |
| @@ -340,7 +331,7 @@ void PaintController::commitNewDisplayItemsInternal() |
| if (newDisplayItemHasCachedType) { |
| ASSERT(newDisplayItem.isCached()); |
| - ASSERT(clientCacheIsValid(newDisplayItem.client()) || (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && !paintOffsetWasInvalidated(newDisplayItem.client()))); |
| + // ASSERT(clientCacheIsValid(newDisplayItem.client()) || (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && !paintOffsetWasInvalidated(newDisplayItem.client()))); |
|
pdr.
2016/01/04 21:19:30
Drive by: did you forget this?
|
| if (!isSynchronized) { |
| currentIt = findOutOfOrderCachedItem(newDisplayItemId, outOfOrderIndexContext); |
| @@ -371,11 +362,11 @@ void PaintController::commitNewDisplayItemsInternal() |
| ASSERT(updatedList.last().type() == DisplayItem::EndSubsequence); |
| } |
| } else { |
| - ASSERT(!newDisplayItem.isDrawing() |
| + /*ASSERT(!newDisplayItem.isDrawing() |
|
pdr.
2016/01/04 21:19:30
Drive by: did you forget this?
|
| || newDisplayItem.skippedCache() |
| || !clientCacheIsValid(newDisplayItem.client()) |
| || (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && paintOffsetWasInvalidated(newDisplayItem.client()))); |
| - |
| + */ |
| updatedList.appendByMoving(*newIt); |
| if (isSynchronized) |
| @@ -397,7 +388,7 @@ void PaintController::commitNewDisplayItemsInternal() |
| m_currentPaintArtifact.paintChunks() = m_newPaintChunks.releasePaintChunks(); |
| m_newDisplayItemList.clear(); |
| - m_validlyCachedClientsDirty = true; |
| + updateCacheGeneration(); |
| } |
| size_t PaintController::approximateUnsharedMemoryUsage() const |
| @@ -425,22 +416,27 @@ size_t PaintController::approximateUnsharedMemoryUsage() const |
| return memoryUsage; |
| } |
| -void PaintController::updateValidlyCachedClientsIfNeeded() const |
| +unsigned PaintController::nextCacheGeneration() |
| { |
| - if (!m_validlyCachedClientsDirty) |
| - return; |
| + static unsigned cacheGeneration = DisplayItemClient::kInvalidCacheGeneration; |
| + ++cacheGeneration; |
| + if (cacheGeneration == DisplayItemClient::kInvalidCacheGeneration) { |
| + // TODO(wangxianzhu): We'll reuse an old cache generation. Should invalidate all |
| + // clients that are still using the old generation. |
| + ++cacheGeneration; |
| + } |
| + return cacheGeneration; |
| +} |
| - m_validlyCachedClients.clear(); |
| - m_validlyCachedClientsDirty = false; |
| +void PaintController::updateCacheGeneration() |
| +{ |
| + if (!canUseClientCacheStatus()) |
| + return; |
| - const DisplayItemClient* lastAddedClient = nullptr; |
| - for (const DisplayItem& displayItem : m_currentPaintArtifact.displayItemList()) { |
| - if (&displayItem.client() == lastAddedClient) |
| - continue; |
| - if (displayItem.isCacheable()) { |
| - lastAddedClient = &displayItem.client(); |
| - m_validlyCachedClients.add(lastAddedClient); |
| - } |
| + m_currentCacheGeneration = nextCacheGeneration(); |
| + for (const auto& item : displayItemList()) { |
| + if (item.isCacheable()) |
| + item.client().setDisplayItemsCached(m_currentCacheGeneration); |
| } |
| } |
| @@ -507,7 +503,7 @@ void PaintController::checkCachedDisplayItemIsUnchanged(const char* messagePrefi |
| ASSERT_NOT_REACHED(); |
| } |
| - if (newItem.isCacheable() && !m_validlyCachedClients.contains(&newItem.client())) { |
| + if (newItem.isCacheable()) { /////// EEE && !m_validlyCachedClients.contains(&newItem.client())) { |
|
pdr.
2016/01/04 21:19:30
Drive by: did you forget this?
|
| showUnderInvalidationError(messagePrefix, "ERROR: under-invalidation: invalidated in cached subsequence", &newItem, &oldItem); |
| ASSERT_NOT_REACHED(); |
| } |
| @@ -556,8 +552,10 @@ WTF::String PaintController::displayItemListAsDebugString(const DisplayItemList& |
| stringBuilder.append(",\n"); |
| stringBuilder.append(String::format("{index: %d, ", (int)i)); |
| displayItem.dumpPropertiesAsDebugString(stringBuilder); |
| - stringBuilder.append(", cacheIsValid: "); |
| - stringBuilder.append(clientCacheIsValid(displayItem.client()) ? "true" : "false"); |
| + if (displayItem.hasValidClient()) { |
| + stringBuilder.append(", cacheIsValid: "); |
| + stringBuilder.append(clientCacheIsValid(displayItem.client()) ? "true" : "false"); |
| + } |
| stringBuilder.append('}'); |
| } |
| return stringBuilder.toString(); |