| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 24 matching lines...) Expand all Loading... |
| 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() | 282 #if DCHECK_IS_ON() |
| 317 DCHECK(newDisplayItem.isCached()); | 283 DCHECK(newDisplayItem.isCached()); |
| 318 DCHECK(clientCacheIsValid(newDisplayItem.client()) || (RuntimeEnable
dFeatures::slimmingPaintInvalidationEnabled() && !paintOffsetWasInvalidated(newD
isplayItem.client()))); | 284 DCHECK(clientCacheIsValid(newDisplayItem.client())); |
| 319 #endif | 285 #endif |
| 320 if (!isSynchronized) { | 286 if (!isSynchronized) { |
| 321 currentIt = findOutOfOrderCachedItem(newDisplayItemId, outOfOrde
rIndexContext); | 287 currentIt = findOutOfOrderCachedItem(newDisplayItemId, outOfOrde
rIndexContext); |
| 322 | 288 |
| 323 if (currentIt == currentEnd) { | 289 if (currentIt == currentEnd) { |
| 324 #ifndef NDEBUG | 290 #ifndef NDEBUG |
| 325 showDebugData(); | 291 showDebugData(); |
| 326 WTFLogAlways("%s not found in m_currentDisplayItemList\n", n
ewDisplayItem.asDebugString().utf8().data()); | 292 WTFLogAlways("%s not found in m_currentDisplayItemList\n", n
ewDisplayItem.asDebugString().utf8().data()); |
| 327 #endif | 293 #endif |
| 328 NOTREACHED(); | 294 NOTREACHED(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 344 ++currentIt; | 310 ++currentIt; |
| 345 } else { | 311 } else { |
| 346 DCHECK(newDisplayItem.getType() == DisplayItem::CachedSubsequenc
e); | 312 DCHECK(newDisplayItem.getType() == DisplayItem::CachedSubsequenc
e); |
| 347 copyCachedSubsequence(m_currentPaintArtifact.getDisplayItemList(
), currentIt, updatedList, gpuAnalyzer); | 313 copyCachedSubsequence(m_currentPaintArtifact.getDisplayItemList(
), currentIt, updatedList, gpuAnalyzer); |
| 348 DCHECK(updatedList.last().getType() == DisplayItem::EndSubsequen
ce); | 314 DCHECK(updatedList.last().getType() == DisplayItem::EndSubsequen
ce); |
| 349 } | 315 } |
| 350 } else { | 316 } else { |
| 351 #if DCHECK_IS_ON() | 317 #if DCHECK_IS_ON() |
| 352 DCHECK(!newDisplayItem.isDrawing() | 318 DCHECK(!newDisplayItem.isDrawing() |
| 353 || newDisplayItem.skippedCache() | 319 || newDisplayItem.skippedCache() |
| 354 || !clientCacheIsValid(newDisplayItem.client()) | 320 || !clientCacheIsValid(newDisplayItem.client())); |
| 355 || (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() &
& paintOffsetWasInvalidated(newDisplayItem.client()))); | |
| 356 #endif | 321 #endif |
| 357 | 322 |
| 358 updatedList.appendByMoving(*newIt, visualRectForDisplayItem(*newIt,
offsetFromLayoutObject), gpuAnalyzer); | 323 updatedList.appendByMoving(*newIt, visualRectForDisplayItem(*newIt,
offsetFromLayoutObject), gpuAnalyzer); |
| 359 | 324 |
| 360 if (isSynchronized) | 325 if (isSynchronized) |
| 361 ++currentIt; | 326 ++currentIt; |
| 362 } | 327 } |
| 363 // Items before currentIt should have been copied so we don't need to in
dex them. | 328 // Items before currentIt should have been copied so we don't need to in
dex them. |
| 364 if (currentIt - outOfOrderIndexContext.nextItemToIndex > 0) | 329 if (currentIt - outOfOrderIndexContext.nextItemToIndex > 0) |
| 365 outOfOrderIndexContext.nextItemToIndex = currentIt; | 330 outOfOrderIndexContext.nextItemToIndex = currentIt; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 | 496 |
| 532 void PaintController::showDebugData() const | 497 void PaintController::showDebugData() const |
| 533 { | 498 { |
| 534 WTFLogAlways("current display item list: [%s]\n", displayItemListAsDebugStri
ng(m_currentPaintArtifact.getDisplayItemList()).utf8().data()); | 499 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()); | 500 WTFLogAlways("new display item list: [%s]\n", displayItemListAsDebugString(m
_newDisplayItemList).utf8().data()); |
| 536 } | 501 } |
| 537 | 502 |
| 538 #endif // ifndef NDEBUG | 503 #endif // ifndef NDEBUG |
| 539 | 504 |
| 540 } // namespace blink | 505 } // namespace blink |
| OLD | NEW |