Changeset 229315 in webkit
- Timestamp:
- Mar 6, 2018 3:34:19 AM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r229309 r229315 1 2018-03-06 Zan Dobersek <zdobersek@igalia.com> 2 3 CoordinatedGraphicsScene: properly limit data specific to state commit operation 4 https://bugs.webkit.org/show_bug.cgi?id=183326 5 6 Reviewed by Sergio Villar Senin. 7 8 In the process of state commit in CoordinatedGraphicsScene, the released 9 image backings and backing stores with pending updates are stored in 10 Vector and HashSet objects, respectively. Instead of these two objects 11 being member variables on the CoordinatedGraphicsScene class, keep them 12 in the CommitScope structure that's limited to the operations done in 13 the commitSceneState() method. 14 15 The two member variables are dropped, and the CommitScope object is 16 passed by reference to any helper method that needs to append either 17 kind of object to the respective container. At the end of the state 18 commit, backing stores with pending updates have those updates applied, 19 and the two containers are cleared out as the CommitScope object is 20 destroyed. 21 22 * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp: 23 (WebKit::CoordinatedGraphicsScene::setLayerState): 24 (WebKit::CoordinatedGraphicsScene::prepareContentBackingStore): 25 (WebKit::CoordinatedGraphicsScene::resetBackingStoreSizeToLayerSize): 26 (WebKit::CoordinatedGraphicsScene::removeTilesIfNeeded): 27 (WebKit::CoordinatedGraphicsScene::updateTilesIfNeeded): 28 (WebKit::CoordinatedGraphicsScene::syncImageBackings): 29 (WebKit::CoordinatedGraphicsScene::updateImageBacking): 30 (WebKit::CoordinatedGraphicsScene::clearImageBackingContents): 31 (WebKit::CoordinatedGraphicsScene::removeImageBacking): 32 (WebKit::CoordinatedGraphicsScene::commitSceneState): 33 (WebKit::CoordinatedGraphicsScene::purgeGLResources): 34 (WebKit::CoordinatedGraphicsScene::removeReleasedImageBackingsIfNeeded): Deleted. 35 (WebKit::CoordinatedGraphicsScene::commitPendingBackingStoreOperations): Deleted. 36 * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h: 37 1 38 2018-03-05 Yusuke Suzuki <utatane.tea@gmail.com> 2 39 -
trunk/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
r228373 r229315 211 211 } 212 212 213 void CoordinatedGraphicsScene::setLayerState(CoordinatedLayerID id, const CoordinatedGraphicsLayerState& layerState )213 void CoordinatedGraphicsScene::setLayerState(CoordinatedLayerID id, const CoordinatedGraphicsLayerState& layerState, CommitScope& commitScope) 214 214 { 215 215 ASSERT(m_rootLayerID != InvalidCoordinatedLayerID); … … 282 282 layer->didCommitScrollOffset(layerState.committedScrollOffset); 283 283 284 prepareContentBackingStore(layer );284 prepareContentBackingStore(layer, commitScope); 285 285 286 286 // Apply Operations. 287 287 setLayerChildrenIfNeeded(layer, layerState); 288 288 createTilesIfNeeded(layer, layerState); 289 removeTilesIfNeeded(layer, layerState );290 updateTilesIfNeeded(layer, layerState );289 removeTilesIfNeeded(layer, layerState, commitScope); 290 updateTilesIfNeeded(layer, layerState, commitScope); 291 291 setLayerFiltersIfNeeded(layer, layerState); 292 292 setLayerAnimationsIfNeeded(layer, layerState); … … 345 345 } 346 346 347 void CoordinatedGraphicsScene::prepareContentBackingStore(TextureMapperLayer* layer )347 void CoordinatedGraphicsScene::prepareContentBackingStore(TextureMapperLayer* layer, CommitScope& commitScope) 348 348 { 349 349 if (!layerShouldHaveBackingStore(layer)) { … … 353 353 354 354 createBackingStoreIfNeeded(layer); 355 resetBackingStoreSizeToLayerSize(layer );355 resetBackingStoreSizeToLayerSize(layer, commitScope); 356 356 } 357 357 … … 375 375 } 376 376 377 void CoordinatedGraphicsScene::resetBackingStoreSizeToLayerSize(TextureMapperLayer* layer )377 void CoordinatedGraphicsScene::resetBackingStoreSizeToLayerSize(TextureMapperLayer* layer, CommitScope& commitScope) 378 378 { 379 379 RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer); 380 380 ASSERT(backingStore); 381 381 backingStore->setSize(layer->size()); 382 m_backingStoresWithPendingBuffers.add(backingStore);382 commitScope.backingStoresWithPendingBuffers.add(backingStore); 383 383 } 384 384 … … 397 397 } 398 398 399 void CoordinatedGraphicsScene::removeTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state )399 void CoordinatedGraphicsScene::removeTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state, CommitScope& commitScope) 400 400 { 401 401 if (state.tilesToRemove.isEmpty()) … … 409 409 backingStore->removeTile(tile); 410 410 411 m_backingStoresWithPendingBuffers.add(backingStore);412 } 413 414 void CoordinatedGraphicsScene::updateTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state )411 commitScope.backingStoresWithPendingBuffers.add(backingStore); 412 } 413 414 void CoordinatedGraphicsScene::updateTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state, CommitScope& commitScope) 415 415 { 416 416 if (state.tilesToUpdate.isEmpty()) … … 429 429 430 430 backingStore->updateTile(tile.tileID, surfaceUpdateInfo.updateRect, tile.tileRect, surfaceIt->value.copyRef(), surfaceUpdateInfo.surfaceOffset); 431 m_backingStoresWithPendingBuffers.add(backingStore);431 commitScope.backingStoresWithPendingBuffers.add(backingStore); 432 432 } 433 433 } … … 457 457 } 458 458 459 void CoordinatedGraphicsScene::syncImageBackings(const CoordinatedGraphicsState& state )459 void CoordinatedGraphicsScene::syncImageBackings(const CoordinatedGraphicsState& state, CommitScope& commitScope) 460 460 { 461 461 for (auto& image : state.imagesToRemove) 462 removeImageBacking(image );462 removeImageBacking(image, commitScope); 463 463 464 464 for (auto& image : state.imagesToCreate) … … 466 466 467 467 for (auto& image : state.imagesToUpdate) 468 updateImageBacking(image.first, image.second.copyRef() );468 updateImageBacking(image.first, image.second.copyRef(), commitScope); 469 469 470 470 for (auto& image : state.imagesToClear) 471 clearImageBackingContents(image );471 clearImageBackingContents(image, commitScope); 472 472 } 473 473 … … 478 478 } 479 479 480 void CoordinatedGraphicsScene::updateImageBacking(CoordinatedImageBackingID imageID, RefPtr<Nicosia::Buffer>&& buffer )480 void CoordinatedGraphicsScene::updateImageBacking(CoordinatedImageBackingID imageID, RefPtr<Nicosia::Buffer>&& buffer, CommitScope& commitScope) 481 481 { 482 482 ASSERT(m_imageBackings.contains(imageID)); … … 492 492 backingStore->updateTile(1 /* id */, rect, rect, WTFMove(buffer), rect.location()); 493 493 494 m_backingStoresWithPendingBuffers.add(backingStore);495 } 496 497 void CoordinatedGraphicsScene::clearImageBackingContents(CoordinatedImageBackingID imageID )494 commitScope.backingStoresWithPendingBuffers.add(backingStore); 495 } 496 497 void CoordinatedGraphicsScene::clearImageBackingContents(CoordinatedImageBackingID imageID, CommitScope& commitScope) 498 498 { 499 499 ASSERT(m_imageBackings.contains(imageID)); … … 501 501 RefPtr<CoordinatedBackingStore> backingStore = it->value; 502 502 backingStore->removeAllTiles(); 503 m_backingStoresWithPendingBuffers.add(backingStore);504 } 505 506 void CoordinatedGraphicsScene::removeImageBacking(CoordinatedImageBackingID imageID )503 commitScope.backingStoresWithPendingBuffers.add(backingStore); 504 } 505 506 void CoordinatedGraphicsScene::removeImageBacking(CoordinatedImageBackingID imageID, CommitScope& commitScope) 507 507 { 508 508 ASSERT(m_imageBackings.contains(imageID)); 509 509 510 510 // We don't want TextureMapperLayer refers a dangling pointer. 511 m_releasedImageBackings.append(m_imageBackings.take(imageID));511 commitScope.releasedImageBackings.append(m_imageBackings.take(imageID)); 512 512 } 513 513 … … 524 524 } 525 525 526 void CoordinatedGraphicsScene::removeReleasedImageBackingsIfNeeded()527 {528 m_releasedImageBackings.clear();529 }530 531 void CoordinatedGraphicsScene::commitPendingBackingStoreOperations()532 {533 for (auto& backingStore : m_backingStoresWithPendingBuffers)534 backingStore->commitTileOperations(*m_textureMapper);535 536 m_backingStoresWithPendingBuffers.clear();537 }538 539 526 void CoordinatedGraphicsScene::commitSceneState(const CoordinatedGraphicsState& state) 540 527 { 541 528 if (!m_client) 542 529 return; 530 531 CommitScope commitScope; 543 532 544 533 m_renderedContentsScrollPosition = state.scrollPosition; … … 550 539 setRootLayerID(state.rootCompositingLayer); 551 540 552 syncImageBackings(state );541 syncImageBackings(state, commitScope); 553 542 syncUpdateAtlases(state); 554 543 555 544 for (auto& layer : state.layersToUpdate) 556 setLayerState(layer.first, layer.second); 557 558 commitPendingBackingStoreOperations(); 559 removeReleasedImageBackingsIfNeeded(); 545 setLayerState(layer.first, layer.second, commitScope); 546 547 for (auto& backingStore : commitScope.backingStoresWithPendingBuffers) 548 backingStore->commitTileOperations(*m_textureMapper); 549 550 commitScope.releasedImageBackings.clear(); 551 commitScope.backingStoresWithPendingBuffers.clear(); 560 552 } 561 553 … … 592 584 593 585 m_imageBackings.clear(); 594 m_releasedImageBackings.clear();595 586 #if USE(COORDINATED_GRAPHICS_THREADED) 596 587 for (auto& proxy : m_platformLayerProxies.values()) … … 606 597 m_textureMapper = nullptr; 607 598 m_backingStores.clear(); 608 m_backingStoresWithPendingBuffers.clear();609 599 } 610 600 -
trunk/Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h
r225266 r229315 98 98 99 99 private: 100 struct CommitScope { 101 CommitScope() = default; 102 CommitScope(CommitScope&) = delete; 103 CommitScope& operator=(const CommitScope&) = delete; 104 105 Vector<RefPtr<CoordinatedBackingStore>> releasedImageBackings; 106 HashSet<RefPtr<CoordinatedBackingStore>> backingStoresWithPendingBuffers; 107 }; 108 100 109 void setRootLayerID(WebCore::CoordinatedLayerID); 101 110 void createLayers(const Vector<WebCore::CoordinatedLayerID>&); 102 111 void deleteLayers(const Vector<WebCore::CoordinatedLayerID>&); 103 void setLayerState(WebCore::CoordinatedLayerID, const WebCore::CoordinatedGraphicsLayerState& );112 void setLayerState(WebCore::CoordinatedLayerID, const WebCore::CoordinatedGraphicsLayerState&, CommitScope&); 104 113 void setLayerChildrenIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); 105 void updateTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState& );114 void updateTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&, CommitScope&); 106 115 void createTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); 107 void removeTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState& );116 void removeTilesIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&, CommitScope&); 108 117 void setLayerFiltersIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); 109 118 void setLayerAnimationsIfNeeded(WebCore::TextureMapperLayer*, const WebCore::CoordinatedGraphicsLayerState&); … … 115 124 void removeUpdateAtlas(uint32_t atlasID); 116 125 117 void syncImageBackings(const WebCore::CoordinatedGraphicsState& );126 void syncImageBackings(const WebCore::CoordinatedGraphicsState&, CommitScope&); 118 127 void createImageBacking(WebCore::CoordinatedImageBackingID); 119 void updateImageBacking(WebCore::CoordinatedImageBackingID, RefPtr<Nicosia::Buffer>&& );120 void clearImageBackingContents(WebCore::CoordinatedImageBackingID );121 void removeImageBacking(WebCore::CoordinatedImageBackingID );128 void updateImageBacking(WebCore::CoordinatedImageBackingID, RefPtr<Nicosia::Buffer>&&, CommitScope&); 129 void clearImageBackingContents(WebCore::CoordinatedImageBackingID, CommitScope&); 130 void removeImageBacking(WebCore::CoordinatedImageBackingID, CommitScope&); 122 131 123 132 WebCore::TextureMapperLayer* layerByID(WebCore::CoordinatedLayerID id) … … 140 149 141 150 void assignImageBackingToLayer(WebCore::TextureMapperLayer*, WebCore::CoordinatedImageBackingID); 142 void removeReleasedImageBackingsIfNeeded();143 151 void ensureRootLayer(); 144 void commitPendingBackingStoreOperations();145 152 146 void prepareContentBackingStore(WebCore::TextureMapperLayer* );153 void prepareContentBackingStore(WebCore::TextureMapperLayer*, CommitScope&); 147 154 void createBackingStoreIfNeeded(WebCore::TextureMapperLayer*); 148 155 void removeBackingStoreIfNeeded(WebCore::TextureMapperLayer*); 149 void resetBackingStoreSizeToLayerSize(WebCore::TextureMapperLayer* );156 void resetBackingStoreSizeToLayerSize(WebCore::TextureMapperLayer*, CommitScope&); 150 157 151 158 #if USE(COORDINATED_GRAPHICS_THREADED) … … 157 164 158 165 HashMap<WebCore::CoordinatedImageBackingID, RefPtr<CoordinatedBackingStore>> m_imageBackings; 159 Vector<RefPtr<CoordinatedBackingStore>> m_releasedImageBackings;160 161 166 HashMap<WebCore::TextureMapperLayer*, RefPtr<CoordinatedBackingStore>> m_backingStores; 162 HashSet<RefPtr<CoordinatedBackingStore>> m_backingStoresWithPendingBuffers;163 167 164 168 #if USE(COORDINATED_GRAPHICS_THREADED)
Note: See TracChangeset
for help on using the changeset viewer.