Changeset 133270 in webkit
- Timestamp:
- Nov 2, 2012 12:22:59 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r133269 r133270 1 2012-11-02 Huang Dongsung <luxtella@company100.net> 2 3 Coordinated Graphics: Manage the lifecycle of shareable surfaces precisely. 4 https://bugs.webkit.org/show_bug.cgi?id=100797 5 6 Reviewed by Noam Rosenthal. 7 8 Internal Review by Gwang Yoon Hwang and Jae Hyun Park. 9 10 This patch makes UpdateAtlas manage the lifecycle of shareable surfaces 11 containing the updates in the way how CoordinatedTile manages the lifecycle of 12 tiles. Currently, UI Process creates the shareable surface when receiving an 13 UpdateTileForLayer message, but there is no exact point to remove the shareable 14 surface. Now, we introduce new two messages to handle the lifecycle: 15 CreateUpdateAtlas and RemoveUpdateAtlas. 16 17 This patch gives us two benefits. 18 1. Reduce file and mmap operations. Web Process does not need to duplicate a 19 file handle every tile update. UI Process does not need to create a 20 ShareableSurface every UpdateTileForLayer message. 21 2. Save memory. We can remove a ShareableSurface in UI Process when UpdateAtlas 22 in Web Process is removed. 23 24 * Shared/SurfaceUpdateInfo.cpp: 25 (WebKit::SurfaceUpdateInfo::encode): 26 (WebKit::SurfaceUpdateInfo::decode): 27 * Shared/SurfaceUpdateInfo.h: 28 (SurfaceUpdateInfo): 29 * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp: 30 (WebKit::LayerTreeCoordinatorProxy::updateTileForLayer): 31 (WebKit::LayerTreeCoordinatorProxy::createUpdateAtlas): 32 (WebKit): 33 (WebKit::LayerTreeCoordinatorProxy::removeUpdateAtlas): 34 (WebKit::LayerTreeCoordinatorProxy::purgeBackingStores): 35 * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h: 36 (LayerTreeCoordinatorProxy): 37 * UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in: 38 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp: 39 (WebCore::CoordinatedGraphicsLayer::beginContentUpdate): 40 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h: 41 (CoordinatedGraphicsLayerClient): 42 (CoordinatedGraphicsLayer): 43 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.cpp: 44 (WebKit::CoordinatedTile::updateBackBuffer): 45 * WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.h: 46 (CoordinatedTileClient): 47 * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp: 48 (WebKit::LayerTreeCoordinator::createUpdateAtlas): 49 (WebKit): 50 (WebKit::LayerTreeCoordinator::removeUpdateAtlas): 51 (WebKit::LayerTreeCoordinator::beginContentUpdate): 52 * WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h: 53 (LayerTreeCoordinator): 54 * WebProcess/WebPage/UpdateAtlas.cpp: 55 (WebKit::UpdateAtlas::UpdateAtlas): 56 (WebKit): 57 (WebKit::UpdateAtlas::~UpdateAtlas): 58 (WebKit::UpdateAtlas::beginPaintingOnAvailableBuffer): 59 * WebProcess/WebPage/UpdateAtlas.h: 60 (UpdateAtlasClient): 61 (WebKit): 62 (UpdateAtlas): 63 1 64 2012-11-02 Jinwoo Song <jinwoo7.song@samsung.com> 2 65 -
trunk/Source/WebKit2/Shared/SurfaceUpdateInfo.cpp
r132361 r133270 29 29 encoder.encode(updateRect); 30 30 encoder.encode(scaleFactor); 31 encoder.encode( surfaceHandle);31 encoder.encode(atlasID); 32 32 encoder.encode(surfaceOffset); 33 33 } … … 39 39 if (!decoder->decode(result.scaleFactor)) 40 40 return false; 41 if (!decoder->decode(result. surfaceHandle))41 if (!decoder->decode(result.atlasID)) 42 42 return false; 43 43 if (!decoder->decode(result.surfaceOffset)) -
trunk/Source/WebKit2/Shared/SurfaceUpdateInfo.h
r132361 r133270 21 21 #define SurfaceUpdateInfo_h 22 22 23 #include "ShareableSurface.h"24 23 #include <WebCore/IntRect.h> 25 24 #include <wtf/Noncopyable.h> … … 47 46 float scaleFactor; 48 47 49 // The handle of the shareable bitmap containing the updates. Will be null if there are noupdates.50 ShareableSurface::Handle surfaceHandle;48 // The id of the update atlas including the shareable bitmap containing the updates. 49 int atlasID; 51 50 52 51 // The offset in the bitmap where the rendered contents are. -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.cpp
r132861 r133270 65 65 void LayerTreeCoordinatorProxy::updateTileForLayer(int layerID, int tileID, const IntRect& targetRect, const WebKit::SurfaceUpdateInfo& updateInfo) 66 66 { 67 RefPtr<ShareableSurface> surface; 68 #if USE(GRAPHICS_SURFACE) 69 GraphicsSurfaceToken token = updateInfo.surfaceHandle.graphicsSurfaceToken(); 70 if (token.isValid()) { 71 HashMap<GraphicsSurfaceToken::BufferHandle, RefPtr<ShareableSurface> >::iterator it = m_surfaces.find(token.frontBufferHandle); 72 if (it == m_surfaces.end()) { 73 surface = ShareableSurface::create(updateInfo.surfaceHandle); 74 m_surfaces.add(token.frontBufferHandle, surface); 75 } else 76 surface = it->value; 77 } else 78 surface = ShareableSurface::create(updateInfo.surfaceHandle); 79 #else 80 surface = ShareableSurface::create(updateInfo.surfaceHandle); 81 #endif 82 dispatchUpdate(bind(&LayerTreeRenderer::updateTile, m_renderer.get(), layerID, tileID, LayerTreeRenderer::TileUpdate(updateInfo.updateRect, targetRect, surface, updateInfo.surfaceOffset))); 67 SurfaceMap::iterator it = m_surfaces.find(updateInfo.atlasID); 68 ASSERT(it != m_surfaces.end()); 69 dispatchUpdate(bind(&LayerTreeRenderer::updateTile, m_renderer.get(), layerID, tileID, LayerTreeRenderer::TileUpdate(updateInfo.updateRect, targetRect, it->value, updateInfo.surfaceOffset))); 83 70 } 84 71 … … 86 73 { 87 74 dispatchUpdate(bind(&LayerTreeRenderer::removeTile, m_renderer.get(), layerID, tileID)); 75 } 76 77 void LayerTreeCoordinatorProxy::createUpdateAtlas(int atlasID, const ShareableSurface::Handle& handle) 78 { 79 ASSERT(!m_surfaces.contains(atlasID)); 80 m_surfaces.add(atlasID, ShareableSurface::create(handle)); 81 } 82 83 void LayerTreeCoordinatorProxy::removeUpdateAtlas(int atlasID) 84 { 85 ASSERT(m_surfaces.contains(atlasID)); 86 m_surfaces.remove(atlasID); 88 87 } 89 88 … … 204 203 { 205 204 m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeCoordinator::PurgeBackingStores(), m_drawingAreaProxy->page()->pageID()); 206 #if USE(GRAPHICS_SURFACE)207 m_surfaces.clear();208 #endif209 205 } 210 206 -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.h
r133182 r133270 27 27 #include "DrawingAreaProxy.h" 28 28 #include "Region.h" 29 #include "ShareableSurface.h" 29 30 #include "SurfaceUpdateInfo.h" 30 31 #include "WebLayerTreeInfo.h" … … 65 66 void updateTileForLayer(int layerID, int tileID, const WebCore::IntRect&, const SurfaceUpdateInfo&); 66 67 void removeTileForLayer(int layerID, int tileID); 68 void createUpdateAtlas(int atlasID, const ShareableSurface::Handle&); 69 void removeUpdateAtlas(int atlasID); 67 70 void createDirectlyCompositedImage(int64_t, const WebKit::ShareableBitmap::Handle&); 68 71 void destroyDirectlyCompositedImage(int64_t); … … 91 94 float m_lastSentScale; 92 95 WebCore::FloatPoint m_lastSentTrajectoryVector; 93 #if USE(GRAPHICS_SURFACE) 94 HashMap<WebCore::GraphicsSurfaceToken::BufferHandle, RefPtr<ShareableSurface> > m_surfaces; 95 #endif 96 typedef HashMap<int /* atlasID */, RefPtr<ShareableSurface> > SurfaceMap; 97 SurfaceMap m_surfaces; 96 98 }; 97 99 -
trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/LayerTreeCoordinatorProxy.messages.in
r132742 r133270 30 30 UpdateTileForLayer(uint32_t layerID, int tileID, WebCore::IntRect targetRect, WebKit::SurfaceUpdateInfo updateInfo) 31 31 RemoveTileForLayer(uint32_t layerID, int tileID) 32 CreateUpdateAtlas(int atlasID, WebKit::ShareableSurface::Handle handle) 33 RemoveUpdateAtlas(int atlasID) 32 34 CreateDirectlyCompositedImage(int64_t key, WebKit::ShareableBitmap::Handle handle) 33 35 DestroyDirectlyCompositedImage(int64_t key) -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.cpp
r133182 r133270 638 638 } 639 639 640 PassOwnPtr<WebCore::GraphicsContext> CoordinatedGraphicsLayer::beginContentUpdate(const WebCore::IntSize& size, ShareableSurface::Handle& handle, WebCore::IntPoint& offset)641 { 642 return m_CoordinatedGraphicsLayerClient->beginContentUpdate(size, contentsOpaque() ? 0 : ShareableBitmap::SupportsAlpha, handle, offset);640 PassOwnPtr<WebCore::GraphicsContext> CoordinatedGraphicsLayer::beginContentUpdate(const WebCore::IntSize& size, int& atlas, WebCore::IntPoint& offset) 641 { 642 return m_CoordinatedGraphicsLayerClient->beginContentUpdate(size, contentsOpaque() ? 0 : ShareableBitmap::SupportsAlpha, atlas, offset); 643 643 } 644 644 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedGraphicsLayer.h
r133182 r133270 73 73 virtual void detachLayer(WebCore::CoordinatedGraphicsLayer*) = 0; 74 74 virtual void syncFixedLayers() = 0; 75 virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableSurface::Handle&, WebCore::IntPoint&) = 0;75 virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, int& atlasID, WebCore::IntPoint&) = 0; 76 76 }; 77 77 } … … 148 148 virtual void updateTile(int tileID, const WebKit::SurfaceUpdateInfo&, const IntRect&) OVERRIDE; 149 149 virtual void removeTile(int tileID) OVERRIDE; 150 virtual PassOwnPtr<GraphicsContext> beginContentUpdate(const IntSize&, WebKit::ShareableSurface::Handle&, IntPoint&) OVERRIDE;150 virtual PassOwnPtr<GraphicsContext> beginContentUpdate(const IntSize&, int& atlasID, IntPoint&) OVERRIDE; 151 151 152 152 void setCoordinatedGraphicsLayerClient(WebKit::CoordinatedGraphicsLayerClient*); -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.cpp
r131617 r133270 74 74 75 75 SurfaceUpdateInfo updateInfo; 76 OwnPtr<GraphicsContext> graphicsContext = m_client->beginContentUpdate(m_dirtyRect.size(), updateInfo. surfaceHandle, updateInfo.surfaceOffset);76 OwnPtr<GraphicsContext> graphicsContext = m_client->beginContentUpdate(m_dirtyRect.size(), updateInfo.atlasID, updateInfo.surfaceOffset); 77 77 if (!graphicsContext) 78 78 return Vector<IntRect>(); -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedTile.h
r124701 r133270 29 29 #if USE(TILED_BACKING_STORE) 30 30 31 #include "ShareableSurface.h"32 31 #include "Tile.h" 33 32 #include "TiledBackingStore.h" … … 80 79 virtual void updateTile(int tileID, const SurfaceUpdateInfo&, const WebCore::IntRect&) = 0; 81 80 virtual void removeTile(int tileID) = 0; 82 virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableSurface::Handle&, WebCore::IntPoint&) = 0;81 virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, int& atlasID, WebCore::IntPoint&) = 0; 83 82 }; 84 83 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.cpp
r132883 r133270 617 617 } 618 618 619 void LayerTreeCoordinator::createUpdateAtlas(int atlasID, const ShareableSurface::Handle& handle) 620 { 621 m_webPage->send(Messages::LayerTreeCoordinatorProxy::CreateUpdateAtlas(atlasID, handle)); 622 } 623 624 void LayerTreeCoordinator::removeUpdateAtlas(int atlasID) 625 { 626 m_webPage->send(Messages::LayerTreeCoordinatorProxy::RemoveUpdateAtlas(atlasID)); 627 } 628 619 629 WebCore::IntRect LayerTreeCoordinator::visibleContentsRect() const 620 630 { … … 700 710 } 701 711 702 PassOwnPtr<WebCore::GraphicsContext> LayerTreeCoordinator::beginContentUpdate(const WebCore::IntSize& size, ShareableBitmap::Flags flags, ShareableSurface::Handle& handle, WebCore::IntPoint& offset)712 PassOwnPtr<WebCore::GraphicsContext> LayerTreeCoordinator::beginContentUpdate(const WebCore::IntSize& size, ShareableBitmap::Flags flags, int& atlasID, WebCore::IntPoint& offset) 703 713 { 704 714 OwnPtr<WebCore::GraphicsContext> graphicsContext; … … 707 717 if (atlas->flags() == flags) { 708 718 // This will return null if there is no available buffer space. 709 graphicsContext = atlas->beginPaintingOnAvailableBuffer( handle, size, offset);719 graphicsContext = atlas->beginPaintingOnAvailableBuffer(atlasID, size, offset); 710 720 if (graphicsContext) 711 721 return graphicsContext.release(); … … 714 724 715 725 static const int ScratchBufferDimension = 1024; // Should be a power of two. 716 m_updateAtlases.append(adoptPtr(new UpdateAtlas( ScratchBufferDimension, flags)));726 m_updateAtlases.append(adoptPtr(new UpdateAtlas(this, ScratchBufferDimension, flags))); 717 727 scheduleReleaseInactiveAtlases(); 718 return m_updateAtlases.last()->beginPaintingOnAvailableBuffer( handle, size, offset);728 return m_updateAtlases.last()->beginPaintingOnAvailableBuffer(atlasID, size, offset); 719 729 } 720 730 -
trunk/Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/LayerTreeCoordinator.h
r133182 r133270 39 39 40 40 class LayerTreeCoordinator : public LayerTreeHost, WebCore::GraphicsLayerClient 41 , public CoordinatedGraphicsLayerClient 42 , public WebCore::GraphicsLayerFactory { 41 , public CoordinatedGraphicsLayerClient 42 , public UpdateAtlasClient 43 , public WebCore::GraphicsLayerFactory { 43 44 public: 44 45 static PassRefPtr<LayerTreeCoordinator> create(WebPage*); … … 94 95 virtual void syncFixedLayers(); 95 96 96 virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, ShareableSurface::Handle&, WebCore::IntPoint&); 97 virtual PassOwnPtr<WebCore::GraphicsContext> beginContentUpdate(const WebCore::IntSize&, ShareableBitmap::Flags, int& atlasID, WebCore::IntPoint&); 98 99 // UpdateAtlasClient 100 virtual void createUpdateAtlas(int atlasID, const ShareableSurface::Handle&); 101 virtual void removeUpdateAtlas(int atlasID); 97 102 98 103 #if ENABLE(REQUEST_ANIMATION_FRAME) -
trunk/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.cpp
r128473 r133270 31 31 namespace WebKit { 32 32 33 UpdateAtlas::UpdateAtlas(int dimension, ShareableBitmap::Flags flags) 34 : m_flags(flags) 33 UpdateAtlas::UpdateAtlas(UpdateAtlasClient* client, int dimension, ShareableBitmap::Flags flags) 34 : m_client(client) 35 , m_flags(flags) 35 36 , m_inactivityInSeconds(0) 37 , m_isVaild(true) 36 38 { 39 static int nextID = 0; 40 m_ID = ++nextID; 37 41 IntSize size = nextPowerOfTwo(IntSize(dimension, dimension)); 38 42 m_surface = ShareableSurface::create(size, flags, ShareableSurface::SupportsGraphicsSurface); 43 44 if (!m_surface->createHandle(m_handle)) { 45 m_isVaild = false; 46 return; 47 } 48 m_client->createUpdateAtlas(m_ID, m_handle); 49 } 50 51 UpdateAtlas::~UpdateAtlas() 52 { 53 if (m_isVaild) 54 m_client->removeUpdateAtlas(m_ID); 39 55 } 40 56 … … 52 68 } 53 69 54 PassOwnPtr<GraphicsContext> UpdateAtlas::beginPaintingOnAvailableBuffer( ShareableSurface::Handle& handle, const WebCore::IntSize& size, IntPoint& offset)70 PassOwnPtr<GraphicsContext> UpdateAtlas::beginPaintingOnAvailableBuffer(int& atlasID, const WebCore::IntSize& size, IntPoint& offset) 55 71 { 56 72 m_inactivityInSeconds = 0; … … 62 78 return PassOwnPtr<GraphicsContext>(); 63 79 64 if (!m_surface->createHandle(handle)) 65 return PassOwnPtr<WebCore::GraphicsContext>(); 80 if (!m_isVaild) 81 return PassOwnPtr<GraphicsContext>(); 82 83 atlasID = m_ID; 66 84 67 85 // FIXME: Use tri-state buffers, to allow faster updates. -
trunk/Source/WebKit2/WebProcess/WebPage/UpdateAtlas.h
r128473 r133270 33 33 namespace WebKit { 34 34 35 class UpdateAtlasClient { 36 public: 37 virtual void createUpdateAtlas(int atlasID, const ShareableSurface::Handle&) = 0; 38 virtual void removeUpdateAtlas(int atlasID) = 0; 39 }; 40 35 41 class UpdateAtlas { 36 42 WTF_MAKE_NONCOPYABLE(UpdateAtlas); 37 43 public: 38 UpdateAtlas(int dimension, ShareableBitmap::Flags); 44 UpdateAtlas(UpdateAtlasClient*, int dimension, ShareableBitmap::Flags); 45 ~UpdateAtlas(); 39 46 40 47 inline WebCore::IntSize size() const { return m_surface->size(); } 41 48 42 49 // Returns a null pointer of there is no available buffer. 43 PassOwnPtr<WebCore::GraphicsContext> beginPaintingOnAvailableBuffer( ShareableSurface::Handle&, const WebCore::IntSize&, WebCore::IntPoint& offset);50 PassOwnPtr<WebCore::GraphicsContext> beginPaintingOnAvailableBuffer(int& atlasID, const WebCore::IntSize&, WebCore::IntPoint& offset); 44 51 void didSwapBuffers(); 45 52 ShareableBitmap::Flags flags() const { return m_flags; } … … 61 68 62 69 private: 70 UpdateAtlasClient* m_client; 63 71 OwnPtr<GeneralAreaAllocator> m_areaAllocator; 64 72 ShareableBitmap::Flags m_flags; 65 73 RefPtr<ShareableSurface> m_surface; 74 ShareableSurface::Handle m_handle; 66 75 double m_inactivityInSeconds; 76 int m_ID; 77 bool m_isVaild; 67 78 }; 68 79
Note: See TracChangeset
for help on using the changeset viewer.