Changeset 134873 in webkit
- Timestamp:
- Nov 15, 2012 6:24:31 PM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/CMakeLists.txt
r132228 r134873 495 495 WebProcess/WebPage/WebUndoStep.cpp 496 496 497 WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.cpp 497 498 WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp 498 499 WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.cpp -
trunk/Source/WebKit2/ChangeLog
r134868 r134873 1 2012-11-15 Huang Dongsung <luxtella@company100.net> 2 3 Coordinated Graphics: Refactor code related to directly composited images. 4 https://bugs.webkit.org/show_bug.cgi?id=101023 5 6 Reviewed by Noam Rosenthal. 7 8 Internal Review by Gwang Yoon Hwang and Jae Hyun Park. 9 10 Currently, LayerTreeCoordinator manages composited images using 11 ShareableBitmap. This patch introduces CoordinatedImageBacking which 12 plays a role in managing composited images. CoordinatedImageBacking makes us 13 gather code related to a directly composited image into a single class. 14 15 We create only one CoordinatedImageBacking per image. For example, in the leaves 16 demo, we create only 3 textures of leaves. 17 18 * CMakeLists.txt: 19 * Shared/WebLayerTreeInfo.h: 20 (WebKit::WebLayerInfo::WebLayerInfo): 21 (WebLayerInfo): 22 * Target.pri: 23 * UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp: 24 (WebKit::CoordinatedBackingStoreTile::swapBuffers): 25 * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp: 26 (WebKit::LayerTreeCoordinatorProxy::createImageBacking): 27 (WebKit::LayerTreeCoordinatorProxy::updateImageBacking): 28 (WebKit): 29 (WebKit::LayerTreeCoordinatorProxy::removeImageBacking): 30 * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h: 31 (LayerTreeCoordinatorProxy): 32 * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in: 33 * UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp: 34 (WebKit::LayerTreeRenderer::setLayerState): 35 (WebKit::LayerTreeRenderer::createImageBacking): 36 (WebKit::LayerTreeRenderer::updateImageBacking): 37 (WebKit::LayerTreeRenderer::removeImageBacking): 38 (WebKit): 39 (WebKit::LayerTreeRenderer::assignImageBackingToLayer): 40 (WebKit::LayerTreeRenderer::removeReleasedImageBackingsIfNeeded): 41 (WebKit::LayerTreeRenderer::flushLayerChanges): 42 (WebKit::LayerTreeRenderer::purgeGLResources): 43 * UIProcess/CoordinatedGraphics/LayerTreeRenderer.h: 44 (LayerTreeRenderer): 45 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp: 46 (WebCore::CoordinatedGraphicsLayer::setContentsToImage): 47 (WebCore::CoordinatedGraphicsLayer::syncImageBacking): 48 (WebCore::CoordinatedGraphicsLayer::releaseImageBackingIfNeeded): 49 (WebCore::CoordinatedGraphicsLayer::beginContentUpdate): 50 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h: 51 (CoordinatedGraphicsLayerClient): 52 (CoordinatedGraphicsLayer): 53 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.cpp: Added. 54 (WebKit): 55 (WebKit::CoordinatedImageBacking::getCoordinatedImageBackingID): 56 (WebKit::CoordinatedImageBacking::create): 57 (WebKit::CoordinatedImageBacking::CoordinatedImageBacking): 58 (WebKit::CoordinatedImageBacking::~CoordinatedImageBacking): 59 (WebKit::CoordinatedImageBacking::addLayerClient): 60 (WebKit::CoordinatedImageBacking::removeLayerClient): 61 (WebKit::CoordinatedImageBacking::markDirty): 62 (WebKit::CoordinatedImageBacking::update): 63 (WebKit::CoordinatedImageBacking::releaseSurfaceIfNeeded): 64 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.h: Added. 65 (WebCore): 66 (WebKit): 67 (CoordinatedImageBacking): 68 (Coordinator): 69 (WebKit::CoordinatedImageBacking::id): 70 * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp: 71 (WebKit::LayerTreeCoordinator::flushPendingLayerChanges): 72 (WebKit::LayerTreeCoordinator::createImageBackingIfNeeded): 73 (WebKit::LayerTreeCoordinator::createImageBacking): 74 (WebKit::LayerTreeCoordinator::updateImageBacking): 75 (WebKit::LayerTreeCoordinator::removeImageBacking): 76 (WebKit::LayerTreeCoordinator::flushPendingImageBackingChanges): 77 (WebKit::LayerTreeCoordinator::purgeBackingStores): 78 * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h: 79 (LayerTreeCoordinator): 80 1 81 2012-11-15 Huang Dongsung <luxtella@company100.net> 2 82 -
trunk/Source/WebKit2/Shared/WebLayerTreeInfo.h
r133605 r134873 28 28 #include "FloatSize.h" 29 29 #include "GraphicsLayer.h" 30 #include "ShareableBitmap.h"31 30 32 31 namespace WebKit { … … 35 34 enum { InvalidWebLayerID = 0 }; 36 35 36 typedef uintptr_t CoordinatedImageBackingID; 37 enum { InvalidCoordinatedImageBackingID = 0 }; 38 37 39 // NOTE: WebLayerInfo should only use POD types, as to make serialization faster. 38 40 struct WebLayerInfo { … … 40 42 : replica(InvalidWebLayerID) 41 43 , mask(InvalidWebLayerID) 42 , image BackingStoreID(0)44 , imageID(InvalidCoordinatedImageBackingID) 43 45 , opacity(0) 44 46 , flags(0) { } … … 46 48 WebLayerID replica; 47 49 WebLayerID mask; 48 int64_t imageBackingStoreID;50 CoordinatedImageBackingID imageID; 49 51 50 52 WebCore::FloatPoint pos; -
trunk/Source/WebKit2/Target.pri
r133736 r134873 370 370 WebProcess/WebPage/FindController.h \ 371 371 WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h \ 372 WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.h \ 372 373 WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.h \ 373 374 WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h \ … … 751 752 WebProcess/WebPage/FindController.cpp \ 752 753 WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp \ 754 WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.cpp \ 753 755 WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.cpp \ 754 756 WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp \ -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp
r134676 r134873 50 50 } 51 51 52 ASSERT(textureMapper->maxTextureSize() >= std::max(m_tileRect.size().width(), m_tileRect.size().height())); 52 53 if (shouldReset) 53 54 texture->reset(m_tileRect.size(), m_surface->flags() & ShareableBitmap::SupportsAlpha ? BitmapTexture::SupportsAlpha : 0); -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp
r134375 r134873 128 128 } 129 129 130 void LayerTreeCoordinatorProxy::createDirectlyCompositedImage(int64_t key, const WebKit::ShareableBitmap::Handle& handle) 131 { 132 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle); 133 dispatchUpdate(bind(&LayerTreeRenderer::createImage, m_renderer.get(), key, bitmap)); 134 } 135 136 void LayerTreeCoordinatorProxy::destroyDirectlyCompositedImage(int64_t key) 137 { 138 dispatchUpdate(bind(&LayerTreeRenderer::destroyImage, m_renderer.get(), key)); 130 void LayerTreeCoordinatorProxy::createImageBacking(CoordinatedImageBackingID imageID) 131 { 132 dispatchUpdate(bind(&LayerTreeRenderer::createImageBacking, m_renderer.get(), imageID)); 133 } 134 135 void LayerTreeCoordinatorProxy::updateImageBacking(CoordinatedImageBackingID imageID, const ShareableSurface::Handle& handle) 136 { 137 dispatchUpdate(bind(&LayerTreeRenderer::updateImageBacking, m_renderer.get(), imageID, ShareableSurface::create(handle))); 138 } 139 140 void LayerTreeCoordinatorProxy::removeImageBacking(CoordinatedImageBackingID imageID) 141 { 142 dispatchUpdate(bind(&LayerTreeRenderer::removeImageBacking, m_renderer.get(), imageID)); 139 143 } 140 144 -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h
r134375 r134873 68 68 void createUpdateAtlas(int atlasID, const ShareableSurface::Handle&); 69 69 void removeUpdateAtlas(int atlasID); 70 void createDirectlyCompositedImage(int64_t, const WebKit::ShareableBitmap::Handle&); 71 void destroyDirectlyCompositedImage(int64_t); 70 void createImageBacking(CoordinatedImageBackingID); 71 void updateImageBacking(CoordinatedImageBackingID, const ShareableSurface::Handle&); 72 void removeImageBacking(CoordinatedImageBackingID); 72 73 void didReceiveLayerTreeCoordinatorProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&); 73 74 void updateViewport(); -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in
r134375 r134873 32 32 CreateUpdateAtlas(int atlasID, WebKit::ShareableSurface::Handle handle) 33 33 RemoveUpdateAtlas(int atlasID) 34 CreateDirectlyCompositedImage(int64_t key, WebKit::ShareableBitmap::Handle handle) 35 DestroyDirectlyCompositedImage(int64_t key) 34 CreateImageBacking(uintptr_t imageID) 35 UpdateImageBacking(uintptr_t imageID, WebKit::ShareableSurface::Handle handle) 36 RemoveImageBacking(uintptr_t imageID) 36 37 DidRenderFrame(WebCore::IntSize contentsSize, WebCore::IntRect coveredRect) 37 38 DidChangeScrollPosition(WebCore::IntPoint position) -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.cpp
r134375 r134873 1 1 /* 2 2 Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 3 Copyright (C) 2012 Company 100, Inc. 3 4 4 5 This library is free software; you can redistribute it and/or … … 28 29 #include "LayerTreeCoordinatorProxy.h" 29 30 #include "MessageID.h" 30 #include "ShareableBitmap.h"31 31 #include "TextureMapper.h" 32 32 #include "TextureMapperBackingStore.h" … … 303 303 m_fixedLayers.remove(id); 304 304 305 assignImage ToLayer(layer, layerInfo.imageBackingStoreID);305 assignImageBackingToLayer(layer, layerInfo.imageID); 306 306 307 307 // Never make the root layer clip. … … 417 417 } 418 418 419 void LayerTreeRenderer::createImage(int64_t imageID, PassRefPtr<ShareableBitmap> weakBitmap) 420 { 421 RefPtr<ShareableBitmap> bitmap = weakBitmap; 422 RefPtr<TextureMapperTiledBackingStore> backingStore = TextureMapperTiledBackingStore::create(); 423 m_directlyCompositedImages.set(imageID, backingStore); 424 backingStore->updateContents(m_textureMapper.get(), bitmap->createImage().get(), BitmapTexture::UpdateCannotModifyOriginalImageData); 425 } 426 427 void LayerTreeRenderer::destroyImage(int64_t imageID) 428 { 429 m_directlyCompositedImages.remove(imageID); 430 } 431 432 void LayerTreeRenderer::assignImageToLayer(GraphicsLayer* layer, int64_t imageID) 433 { 434 if (!imageID) { 419 void LayerTreeRenderer::createImageBacking(CoordinatedImageBackingID imageID) 420 { 421 ASSERT(!m_imageBackings.contains(imageID)); 422 RefPtr<CoordinatedBackingStore> backingStore(CoordinatedBackingStore::create()); 423 m_imageBackings.add(imageID, backingStore.release()); 424 } 425 426 void LayerTreeRenderer::updateImageBacking(CoordinatedImageBackingID imageID, PassRefPtr<ShareableSurface> surface) 427 { 428 ASSERT(m_imageBackings.contains(imageID)); 429 ImageBackingMap::iterator it = m_imageBackings.find(imageID); 430 RefPtr<CoordinatedBackingStore> backingStore = it->value; 431 432 // CoordinatedImageBacking is realized to CoordinatedBackingStore with only one tile in UI Process. 433 backingStore->createTile(1 /* id */, 1 /* scale */); 434 IntRect rect(IntPoint::zero(), surface->size()); 435 // See CoordinatedGraphicsLayer::shouldDirectlyCompositeImage() 436 ASSERT(2000 >= std::max(rect.width(), rect.height())); 437 backingStore->setSize(rect.size()); 438 backingStore->updateTile(1 /* id */, rect, rect, surface, rect.location()); 439 440 m_backingStoresWithPendingBuffers.add(backingStore); 441 } 442 443 void LayerTreeRenderer::removeImageBacking(CoordinatedImageBackingID imageID) 444 { 445 ASSERT(m_imageBackings.contains(imageID)); 446 447 // We don't want TextureMapperLayer refers a dangling pointer. 448 ImageBackingMap::iterator it = m_imageBackings.find(imageID); 449 m_releasedImageBackings.append(it->value); 450 m_imageBackings.remove(imageID); 451 } 452 453 void LayerTreeRenderer::assignImageBackingToLayer(GraphicsLayer* layer, CoordinatedImageBackingID imageID) 454 { 455 if (imageID == InvalidCoordinatedImageBackingID) { 435 456 layer->setContentsToMedia(0); 436 457 return; 437 458 } 438 439 HashMap<int64_t, RefPtr<TextureMapperBackingStore> >::iterator it = m_directlyCompositedImages.find(imageID); 440 ASSERT(it != m_directlyCompositedImages.end()); 459 ImageBackingMap::iterator it = m_imageBackings.find(imageID); 460 ASSERT(it != m_imageBackings.end()); 441 461 layer->setContentsToMedia(it->value.get()); 462 } 463 464 void LayerTreeRenderer::removeReleasedImageBackingsIfNeeded() 465 { 466 m_releasedImageBackings.clear(); 442 467 } 443 468 … … 460 485 m_rootLayer->flushCompositingState(FloatRect()); 461 486 commitTileOperations(); 487 removeReleasedImageBackingsIfNeeded(); 462 488 463 489 // The pending tiles state is on its way for the screen, tell the web process to render the next one. … … 516 542 layer->clearBackingStoresRecursive(); 517 543 518 m_ directlyCompositedImages.clear();544 m_imageBackings.clear(); 519 545 #if USE(GRAPHICS_SURFACE) 520 546 m_surfaceBackingStores.clear(); -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeRenderer.h
r134375 r134873 90 90 void updateTile(WebLayerID, int, const TileUpdate&); 91 91 void flushLayerChanges(); 92 void createImage(int64_t, PassRefPtr<ShareableBitmap>); 93 void destroyImage(int64_t); 92 void createImageBacking(CoordinatedImageBackingID); 93 void updateImageBacking(CoordinatedImageBackingID, PassRefPtr<ShareableSurface>); 94 void removeImageBacking(CoordinatedImageBackingID); 94 95 void setLayerAnimations(WebLayerID, const WebCore::GraphicsLayerAnimations&); 95 96 void setAnimationsLocked(bool); … … 120 121 void adjustPositionForFixedLayers(); 121 122 122 void assignImageToLayer(WebCore::GraphicsLayer*, int64_t imageID); 123 void assignImageBackingToLayer(WebCore::GraphicsLayer*, CoordinatedImageBackingID); 124 void removeReleasedImageBackingsIfNeeded(); 123 125 void ensureRootLayer(); 124 126 void ensureLayer(WebLayerID); … … 140 142 141 143 OwnPtr<WebCore::TextureMapper> m_textureMapper; 142 HashMap<int64_t, RefPtr<WebCore::TextureMapperBackingStore> > m_directlyCompositedImages; 144 145 typedef HashMap<CoordinatedImageBackingID, RefPtr<CoordinatedBackingStore> > ImageBackingMap; 146 ImageBackingMap m_imageBackings; 147 Vector<RefPtr<CoordinatedBackingStore> > m_releasedImageBackings; 148 143 149 HashSet<RefPtr<CoordinatedBackingStore> > m_backingStoresWithPendingBuffers; 144 150 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp
r134868 r134873 1 1 /* 2 2 Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 3 Copyright (C) 2012 Company 100, Inc. 3 4 4 5 This library is free software; you can redistribute it and/or … … 352 353 // This assumption is true in Qt, GTK and EFL. 353 354 NativeImagePtr newNativeImagePtr = image->nativeImageForCurrentFrame(); 354 if (!newNativeImagePtr) 355 return; 355 ASSERT(newNativeImagePtr); 356 356 357 357 if (newNativeImagePtr == m_compositedNativeImagePtr) … … 474 474 m_shouldSyncImageBacking = false; 475 475 476 releaseImageBackingIfNeeded();477 478 476 if (m_compositedNativeImagePtr) { 479 477 ASSERT(!m_mainBackingStore); 480 478 ASSERT(m_compositedImage); 481 479 482 m_layerInfo.imageBackingStoreID = m_coordinator->adoptImageBackingStore(m_compositedImage.get()); 483 } 484 485 // This method changes m_layerInfo.imageBackingStoreID. 480 bool imageInstanceReplaced = m_coordinatedImageBacking && (m_coordinatedImageBacking->id() != CoordinatedImageBacking::getCoordinatedImageBackingID(m_compositedImage.get())); 481 if (imageInstanceReplaced) 482 releaseImageBackingIfNeeded(); 483 484 if (!m_coordinatedImageBacking) { 485 m_coordinatedImageBacking = m_coordinator->createImageBackingIfNeeded(m_compositedImage.get()); 486 m_coordinatedImageBacking->addLayerClient(this); 487 m_layerInfo.imageID = m_coordinatedImageBacking->id(); 488 } 489 490 m_coordinatedImageBacking->markDirty(); 491 } else 492 releaseImageBackingIfNeeded(); 493 494 // syncImageBacking() changed m_layerInfo.imageID. 486 495 didChangeLayerState(); 487 496 } … … 555 564 void CoordinatedGraphicsLayer::releaseImageBackingIfNeeded() 556 565 { 557 if (!m_ layerInfo.imageBackingStoreID)566 if (!m_coordinatedImageBacking) 558 567 return; 559 568 560 569 ASSERT(m_coordinator); 561 m_coordinator->releaseImageBackingStore(m_layerInfo.imageBackingStoreID); 562 m_layerInfo.imageBackingStoreID = 0; 570 m_coordinatedImageBacking->removeLayerClient(this); 571 m_coordinatedImageBacking.clear(); 572 m_layerInfo.imageID = InvalidCoordinatedImageBackingID; 563 573 } 564 574 … … 666 676 } 667 677 668 PassOwnPtr< WebCore::GraphicsContext> CoordinatedGraphicsLayer::beginContentUpdate(const WebCore::IntSize& size, int& atlas, WebCore::IntPoint& offset)678 PassOwnPtr<GraphicsContext> CoordinatedGraphicsLayer::beginContentUpdate(const IntSize& size, int& atlas, IntPoint& offset) 669 679 { 670 680 if (!m_coordinator) -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h
r134868 r134873 22 22 #define CoordinatedGraphicsLayer_h 23 23 24 #include "CoordinatedImageBacking.h" 24 25 #include "CoordinatedTile.h" 25 26 #include "FloatPoint3D.h" … … 57 58 virtual WebCore::IntRect visibleContentsRect() const = 0; 58 59 virtual bool layerTreeTileUpdatesAllowed() const = 0; 59 virtual int64_t adoptImageBackingStore(WebCore::Image*) = 0; 60 virtual void releaseImageBackingStore(int64_t) = 0; 60 virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) = 0; 61 61 virtual void syncLayerState(WebLayerID, const WebLayerInfo&) = 0; 62 62 virtual void syncLayerChildren(WebLayerID, const Vector<WebLayerID>&) = 0; … … 217 217 RefPtr<Image> m_compositedImage; 218 218 NativeImagePtr m_compositedNativeImagePtr; 219 RefPtr<WebKit::CoordinatedImageBacking> m_coordinatedImageBacking; 219 220 220 221 PlatformLayer* m_canvasPlatformLayer; -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp
r134663 r134873 269 269 m_rootLayer->flushCompositingStateForThisLayerOnly(); 270 270 271 purgeReleasedImages();271 flushPendingImageBackingChanges(); 272 272 273 273 if (m_shouldSyncRootLayer) { … … 440 440 } 441 441 442 void LayerTreeCoordinator::purgeReleasedImages()443 {444 if (!m_isPurging) {445 for (size_t i = 0; i < m_releasedDirectlyCompositedImages.size(); ++i)446 m_webPage->send(Messages::LayerTreeCoordinatorProxy::DestroyDirectlyCompositedImage(m_releasedDirectlyCompositedImages[i]));447 }448 m_releasedDirectlyCompositedImages.clear();449 }450 451 442 void LayerTreeCoordinator::layerFlushTimerFired(Timer<LayerTreeCoordinator>*) 452 443 { … … 476 467 } 477 468 478 int64_t LayerTreeCoordinator::adoptImageBackingStore(Image* image) 479 { 480 if (!image) 481 return InvalidWebLayerID; 482 483 int64_t key = 0; 484 485 #if PLATFORM(QT) 486 QPixmap* nativeImage = image->nativeImageForCurrentFrame(); 487 488 if (!nativeImage) 489 return InvalidWebLayerID; 490 491 key = nativeImage->cacheKey(); 492 #elif USE(CAIRO) 493 NativeImageCairo* nativeImage = image->nativeImageForCurrentFrame(); 494 if (!nativeImage) 495 return InvalidWebLayerID; 496 // This can be safely done since we own the reference. 497 // A corresponding cairo_surface_destroy() is ensured in releaseImageBackingStore(). 498 cairo_surface_t* cairoSurface = cairo_surface_reference(nativeImage->surface()); 499 key = reinterpret_cast<int64_t>(cairoSurface); 500 #endif 501 502 HashMap<int64_t, int>::iterator it = m_directlyCompositedImageRefCounts.find(key); 503 504 if (it != m_directlyCompositedImageRefCounts.end()) { 505 ++(it->value); 506 return key; 507 } 508 509 // Check if we were going to release this image during the next flush. 510 size_t releasedIndex = m_releasedDirectlyCompositedImages.find(key); 511 if (releasedIndex == notFound) { 512 RefPtr<ShareableBitmap> bitmap = ShareableBitmap::createShareable(image->size(), (image->currentFrameHasAlpha() ? ShareableBitmap::SupportsAlpha : 0)); 513 { 514 OwnPtr<WebCore::GraphicsContext> graphicsContext = bitmap->createGraphicsContext(); 515 graphicsContext->drawImage(image, ColorSpaceDeviceRGB, IntPoint::zero()); 516 } 517 ShareableBitmap::Handle handle; 518 bitmap->createHandle(handle); 519 m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateDirectlyCompositedImage(key, handle)); 469 PassRefPtr<CoordinatedImageBacking> LayerTreeCoordinator::createImageBackingIfNeeded(Image* image) 470 { 471 CoordinatedImageBackingID imageID = CoordinatedImageBacking::getCoordinatedImageBackingID(image); 472 ImageBackingMap::iterator it = m_imageBackings.find(imageID); 473 RefPtr<CoordinatedImageBacking> imageBacking; 474 if (it == m_imageBackings.end()) { 475 imageBacking = CoordinatedImageBacking::create(this, image); 476 m_imageBackings.add(imageID, imageBacking); 520 477 } else 521 m_releasedDirectlyCompositedImages.remove(releasedIndex); 522 523 m_directlyCompositedImageRefCounts.add(key, 1); 524 return key; 525 } 526 527 void LayerTreeCoordinator::releaseImageBackingStore(int64_t key) 528 { 529 if (!key) 530 return; 531 HashMap<int64_t, int>::iterator it = m_directlyCompositedImageRefCounts.find(key); 532 if (it == m_directlyCompositedImageRefCounts.end()) 533 return; 534 535 it->value--; 536 537 if (it->value) 538 return; 539 540 #if USE(CAIRO) 541 // Complement the referencing in adoptImageBackingStore(). 542 cairo_surface_t* cairoSurface = reinterpret_cast<cairo_surface_t*>(key); 543 cairo_surface_destroy(cairoSurface); 544 #endif 545 546 m_directlyCompositedImageRefCounts.remove(it); 547 m_releasedDirectlyCompositedImages.append(key); 548 scheduleLayerFlush(); 549 } 550 478 imageBacking = it->value; 479 480 return imageBacking; 481 } 482 483 void LayerTreeCoordinator::createImageBacking(CoordinatedImageBackingID imageID) 484 { 485 m_shouldSyncFrame = true; 486 m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateImageBacking(imageID)); 487 } 488 489 void LayerTreeCoordinator::updateImageBacking(CoordinatedImageBackingID imageID, const ShareableSurface::Handle& handle) 490 { 491 m_shouldSyncFrame = true; 492 m_webPage->send(Messages::LayerTreeCoordinatorProxy::UpdateImageBacking(imageID, handle)); 493 } 494 495 void LayerTreeCoordinator::removeImageBacking(CoordinatedImageBackingID imageID) 496 { 497 if (m_isPurging) 498 return; 499 500 ASSERT(m_imageBackings.contains(imageID)); 501 m_shouldSyncFrame = true; 502 m_imageBackings.remove(imageID); 503 m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveImageBacking(imageID)); 504 } 505 506 void LayerTreeCoordinator::flushPendingImageBackingChanges() 507 { 508 ImageBackingMap::iterator end = m_imageBackings.end(); 509 for (ImageBackingMap::iterator iter = m_imageBackings.begin(); iter != end; ++iter) 510 iter->value->update(); 511 } 551 512 552 513 void LayerTreeCoordinator::notifyAnimationStarted(const WebCore::GraphicsLayer*, double /* time */) … … 698 659 (*it)->purgeBackingStores(); 699 660 700 purgeReleasedImages(); 701 702 ASSERT(!m_directlyCompositedImageRefCounts.size()); 703 ASSERT(!m_releasedDirectlyCompositedImages.size()); 661 m_imageBackings.clear(); 704 662 m_updateAtlases.clear(); 705 663 } -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h
r134663 r134873 24 24 25 25 #include "CoordinatedGraphicsLayer.h" 26 #include "CoordinatedImageBacking.h" 26 27 #include "LayerTreeContext.h" 27 28 #include "LayerTreeHost.h" … … 40 41 class LayerTreeCoordinator : public LayerTreeHost, WebCore::GraphicsLayerClient 41 42 , public CoordinatedGraphicsLayerClient 43 , public CoordinatedImageBacking::Coordinator 42 44 , public UpdateAtlasClient 43 45 , public WebCore::GraphicsLayerFactory { … … 68 70 virtual void resumeRendering() { m_isSuspended = false; scheduleLayerFlush(); } 69 71 virtual void deviceScaleFactorDidChange() { } 70 virtual int64_t adoptImageBackingStore(WebCore::Image*); 71 virtual void releaseImageBackingStore(int64_t); 72 virtual PassRefPtr<CoordinatedImageBacking> createImageBackingIfNeeded(WebCore::Image*) OVERRIDE; 72 73 73 74 virtual void createTile(WebLayerID, int tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&); … … 113 114 virtual void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect& clipRect); 114 115 116 // CoordinatedImageBacking::Coordinator 117 virtual void createImageBacking(CoordinatedImageBackingID) OVERRIDE; 118 virtual void updateImageBacking(CoordinatedImageBackingID, const ShareableSurface::Handle&) OVERRIDE; 119 virtual void removeImageBacking(CoordinatedImageBackingID) OVERRIDE; 120 121 void flushPendingImageBackingChanges(); 122 115 123 // GraphicsLayerFactory 116 124 virtual PassOwnPtr<WebCore::GraphicsLayer> createGraphicsLayer(WebCore::GraphicsLayerClient*) OVERRIDE; … … 126 134 void lockAnimations(); 127 135 void unlockAnimations(); 128 void purgeReleasedImages();129 136 130 137 void layerFlushTimerFired(WebCore::Timer<LayerTreeCoordinator>*); … … 147 154 HashSet<WebCore::CoordinatedGraphicsLayer*> m_registeredLayers; 148 155 Vector<WebLayerID> m_detachedLayers; 149 HashMap<int64_t, int> m_directlyCompositedImageRefCounts;150 Vector<int64_t> m_releasedDirectlyCompositedImages;156 typedef HashMap<CoordinatedImageBackingID, RefPtr<CoordinatedImageBacking> > ImageBackingMap; 157 ImageBackingMap m_imageBackings; 151 158 Vector<OwnPtr<UpdateAtlas> > m_updateAtlases; 152 159
Note: See TracChangeset
for help on using the changeset viewer.