Changeset 107236 in webkit
- Timestamp:
- Feb 9, 2012 6:38:44 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r107234 r107236 1 2012-02-09 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> 2 3 [Qt] Control the lifetime of TiledBackingStores in WebGraphicsLayer. 4 https://bugs.webkit.org/show_bug.cgi?id=78005 5 6 Reviewed by Noam Rosenthal. 7 8 This makes sure that no empty tiles are generated for layers without contents and that 9 no interaction is made with the TiledBackingStore until we got a WebGraphicsLayerClient. 10 11 - Create the main TiledBackingStore only when the layer has drawsContent and has no 12 directly composited image 13 - Removed recreateBackingStoreIfNeeded and do the (re)creation of the backing stores 14 in updateContentBuffers 15 - Call purgeBackingStores on registered layers instead of passing it down the layer tree 16 17 * WebProcess/WebCoreSupport/WebGraphicsLayer.cpp: 18 (WebCore::WebGraphicsLayer::WebGraphicsLayer): 19 (WebCore::WebGraphicsLayer::~WebGraphicsLayer): 20 (WebCore::WebGraphicsLayer::setDrawsContent): 21 (WebCore::WebGraphicsLayer::setNeedsDisplayInRect): 22 (WebCore::WebGraphicsLayer::syncCompositingStateForThisLayerOnly): 23 (WebCore::WebGraphicsLayer::setVisibleContentRectTrajectoryVector): 24 (WebCore::WebGraphicsLayer::tiledBackingStoreContentsRect): 25 (WebCore::WebGraphicsLayer::updateContentBuffers): 26 (WebCore::WebGraphicsLayer::purgeBackingStores): 27 (WebCore::WebGraphicsLayer::setWebGraphicsLayerClient): 28 (WebCore::WebGraphicsLayer::computeTransformedVisibleRect): 29 * WebProcess/WebCoreSupport/WebGraphicsLayer.h: 30 (WebGraphicsLayer): 31 * WebProcess/WebPage/qt/LayerTreeHostQt.cpp: 32 (WebKit::LayerTreeHostQt::LayerTreeHostQt): 33 (WebKit::LayerTreeHostQt::flushPendingLayerChanges): 34 (WebKit): 35 (WebKit::LayerTreeHostQt::purgeBackingStores): 36 * WebProcess/WebPage/qt/LayerTreeHostQt.h: 37 (LayerTreeHostQt): 38 1 39 2012-02-08 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> 2 40 -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.cpp
r107234 r107236 89 89 #if USE(TILED_BACKING_STORE) 90 90 , m_webGraphicsLayerClient(0) 91 , m_mainBackingStore(adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this))))92 91 , m_contentsScale(1.f) 93 92 #endif 94 93 { 95 m_mainBackingStore->setContentsScale(1.0);96 94 static WebLayerID nextLayerID = 1; 97 95 m_layerInfo.id = nextLayerID++; … … 103 101 layerByIDMap().remove(id()); 104 102 105 // This would tell the UI process to release the backing store. 106 setContentsToImage(0); 107 108 if (m_webGraphicsLayerClient) 103 if (m_webGraphicsLayerClient) { 104 purgeBackingStores(); 109 105 m_webGraphicsLayerClient->detachLayer(this); 106 } 110 107 } 111 108 … … 248 245 GraphicsLayer::setDrawsContent(b); 249 246 250 if (b)251 setNeedsDisplay();252 247 notifyChange(); 253 248 } … … 404 399 void WebGraphicsLayer::setNeedsDisplayInRect(const FloatRect& rect) 405 400 { 406 recreateBackingStoreIfNeeded();407 m_mainBackingStore->invalidate(IntRect(rect));401 if (m_mainBackingStore) 402 m_mainBackingStore->invalidate(IntRect(rect)); 408 403 notifyChange(); 409 404 } … … 463 458 m_layerInfo.children.append(toWebLayerID(children()[i])); 464 459 465 ASSERT(m_webGraphicsLayerClient);466 if (m_layerInfo.imageIsUpdated && m_image && !m_layerInfo.imageBackingStoreID)467 m_layerInfo.imageBackingStoreID = m_webGraphicsLayerClient->adoptImageBackingStore(m_image.get());468 469 460 m_webGraphicsLayerClient->didSyncCompositingStateForLayer(m_layerInfo); 470 461 m_modified = false; … … 489 480 void WebGraphicsLayer::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector) 490 481 { 491 m_mainBackingStore->setVisibleRectTrajectoryVector(trajectoryVector); 482 if (m_mainBackingStore) 483 m_mainBackingStore->setVisibleRectTrajectoryVector(trajectoryVector); 492 484 } 493 485 … … 529 521 IntRect WebGraphicsLayer::tiledBackingStoreContentsRect() 530 522 { 531 if (!drawsContent())532 return IntRect();533 523 return IntRect(0, 0, size().width(), size().height()); 534 524 } … … 576 566 void WebGraphicsLayer::updateContentBuffers() 577 567 { 578 // Backing-stores for directly composited images is handled in LayerTreeHost. 579 if (m_image) 580 return; 581 582 if (!drawsContent()) 583 return; 568 // The remote image might have been released by purgeBackingStores. 569 if (m_image) { 570 if (!m_layerInfo.imageBackingStoreID) { 571 m_layerInfo.imageBackingStoreID = m_webGraphicsLayerClient->adoptImageBackingStore(m_image.get()); 572 m_layerInfo.imageIsUpdated = true; 573 } 574 } 575 576 if (!drawsContent()) { 577 m_mainBackingStore.clear(); 578 m_previousBackingStore.clear(); 579 return; 580 } 584 581 585 582 m_inUpdateMode = true; 586 m_mainBackingStore->updateTileBuffers(); 587 m_inUpdateMode = false; 588 } 589 590 void WebGraphicsLayer::purgeBackingStores() 591 { 592 for (size_t i = 0; i < children().size(); ++i) { 593 WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]); 594 layer->purgeBackingStores(); 595 } 596 597 if (WebGraphicsLayer* mask = toWebGraphicsLayer(maskLayer())) 598 mask->purgeBackingStores(); 599 600 if (m_mainBackingStore) 601 m_mainBackingStore.clear(); 602 603 if (!m_layerInfo.imageBackingStoreID) 604 return; 605 606 m_webGraphicsLayerClient->releaseImageBackingStore(m_layerInfo.imageBackingStoreID); 607 m_layerInfo.imageBackingStoreID = 0; 608 } 609 610 void WebGraphicsLayer::recreateBackingStoreIfNeeded() 611 { 612 for (size_t i = 0; i < children().size(); ++i) { 613 WebGraphicsLayer* layer = toWebGraphicsLayer(this->children()[i]); 614 layer->recreateBackingStoreIfNeeded(); 615 } 616 if (WebGraphicsLayer* mask = toWebGraphicsLayer(maskLayer())) 617 mask->recreateBackingStoreIfNeeded(); 618 583 // This is the only place we (re)create the main tiled backing store, 584 // once we have a remote client and we are ready to send our data to the UI process. 619 585 if (!m_mainBackingStore) { 620 586 m_mainBackingStore = adoptPtr(new TiledBackingStore(this, TiledBackingStoreRemoteTileBackend::create(this))); 621 587 m_mainBackingStore->setContentsScale(m_contentsScale); 622 588 } 623 624 if (m_image) 625 setContentsNeedsDisplay(); 589 m_mainBackingStore->updateTileBuffers(); 590 m_inUpdateMode = false; 591 } 592 593 void WebGraphicsLayer::purgeBackingStores() 594 { 595 m_mainBackingStore.clear(); 596 m_previousBackingStore.clear(); 597 598 if (m_layerInfo.imageBackingStoreID) { 599 m_webGraphicsLayerClient->releaseImageBackingStore(m_layerInfo.imageBackingStoreID); 600 m_layerInfo.imageBackingStoreID = 0; 601 } 626 602 } 627 603 … … 640 616 } 641 617 642 // Have to force detach from remote layer here if layer tile client changes. 643 if (m_webGraphicsLayerClient) 618 // We have to release resources on the UI process here if the remote client has changed or is removed. 619 if (m_webGraphicsLayerClient) { 620 purgeBackingStores(); 644 621 m_webGraphicsLayerClient->detachLayer(this); 622 } 645 623 m_webGraphicsLayerClient = client; 646 624 if (client) … … 659 637 m_layerTransform.combineTransforms(parent() ? toWebGraphicsLayer(parent())->m_layerTransform.combinedForChildren() : TransformationMatrix()); 660 638 // The combined transform will be used in tiledBackingStoreVisibleRect. 661 m_mainBackingStore->adjustVisibleRect(); 639 if (m_mainBackingStore) 640 m_mainBackingStore->adjustVisibleRect(); 662 641 } 663 642 #endif -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebGraphicsLayer.h
r107234 r107236 141 141 void updateContentBuffers(); 142 142 void purgeBackingStores(); 143 void recreateBackingStoreIfNeeded();144 143 #endif 145 144 -
trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp
r107233 r107236 75 75 , m_layerFlushTimer(this, &LayerTreeHostQt::layerFlushTimerFired) 76 76 , m_layerFlushSchedulingEnabled(true) 77 , m_shouldRecreateBackingStore(false)78 77 { 79 78 // Create a root layer. … … 222 221 bool LayerTreeHostQt::flushPendingLayerChanges() 223 222 { 224 recreateBackingStoreIfNeeded();225 226 223 bool didSync = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes(); 227 224 m_nonCompositedContentLayer->syncCompositingStateForThisLayerOnly(); … … 412 409 m_webPage->send(Messages::LayerTreeHostProxy::UpdateTileForLayer(layerID, tileID, updateInfo)); 413 410 } 411 414 412 void LayerTreeHostQt::removeTile(WebLayerID layerID, int tileID) 415 413 { … … 448 446 void LayerTreeHostQt::purgeBackingStores() 449 447 { 450 m_shouldRecreateBackingStore = true;451 WebGraphicsLayer* webRootLayer = toWebGraphicsLayer(m_rootLayer.get());452 webRootLayer->purgeBackingStores();448 HashSet<WebCore::WebGraphicsLayer*>::iterator end = m_registeredLayers.end(); 449 for (HashSet<WebCore::WebGraphicsLayer*>::iterator it = m_registeredLayers.begin(); it != end; ++it) 450 (*it)->purgeBackingStores(); 453 451 454 452 ASSERT(!m_directlyCompositedImageRefCounts.size()); 455 }456 457 void LayerTreeHostQt::recreateBackingStoreIfNeeded()458 {459 if (!m_shouldRecreateBackingStore)460 return;461 462 m_shouldRecreateBackingStore = false;463 WebGraphicsLayer* webRootLayer = toWebGraphicsLayer(m_rootLayer.get());464 webRootLayer->recreateBackingStoreIfNeeded();465 453 } 466 454 #endif -
trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.h
r107233 r107236 98 98 void performScheduledLayerFlush(); 99 99 void sendLayersToUI(); 100 void recreateBackingStoreIfNeeded();101 100 102 101 OwnPtr<WebCore::GraphicsLayer> m_rootLayer; … … 125 124 WebCore::Timer<LayerTreeHostQt> m_layerFlushTimer; 126 125 bool m_layerFlushSchedulingEnabled; 127 bool m_shouldRecreateBackingStore;128 126 }; 129 127
Note: See TracChangeset
for help on using the changeset viewer.