Changeset 106891 in webkit
- Timestamp:
- Feb 6, 2012 6:24:29 PM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r106889 r106891 1 2012-02-06 James Robinson <jamesr@chromium.org> 2 3 [chromium] canvas demo is slow due to unnecessary resource cleanups 4 https://bugs.webkit.org/show_bug.cgi?id=77135 5 6 Reviewed by Kenneth Russell. 7 8 This defers dropping a ManagedTexture until it is evicted by the manager, the layer is destroyed, the 9 TextureManager is destroyed, or the layer is added to a CCLayerTreeHost that has a different texture manager. In 10 particular, removing a layer from a CCLayerTreeHost and then adding it back to the same host does not drop any 11 ManagedTextures unless the manager has to evict it for other reasons. This provides a big speedup on sites that 12 rebuild the compositing tree frequently. 13 14 New unit test added for ManagedTexture / TextureManager interaction. 15 16 * platform/graphics/chromium/Canvas2DLayerChromium.cpp: 17 (WebCore::Canvas2DLayerChromium::setLayerTreeHost): 18 (WebCore::Canvas2DLayerChromium::setTextureManager): 19 * platform/graphics/chromium/Canvas2DLayerChromium.h: 20 (Canvas2DLayerChromium): 21 * platform/graphics/chromium/LayerChromium.cpp: 22 (WebCore::LayerChromium::setLayerTreeHost): 23 * platform/graphics/chromium/LayerChromium.h: 24 (LayerChromium): 25 * platform/graphics/chromium/ManagedTexture.cpp: 26 (WebCore::ManagedTexture::setTextureManager): 27 (WebCore): 28 (WebCore::ManagedTexture::steal): 29 (WebCore::ManagedTexture::clear): 30 * platform/graphics/chromium/ManagedTexture.h: 31 (ManagedTexture): 32 * platform/graphics/chromium/RenderSurfaceChromium.h: 33 (RenderSurfaceChromium): 34 * platform/graphics/chromium/TiledLayerChromium.cpp: 35 (WebCore::TiledLayerChromium::setLayerTreeHost): 36 (WebCore): 37 (WebCore::TiledLayerChromium::prepareToUpdateTiles): 38 * platform/graphics/chromium/TiledLayerChromium.h: 39 1 40 2012-02-06 Kentaro Hara <haraken@chromium.org> 2 41 -
trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp
r106601 r106891 120 120 void Canvas2DLayerChromium::setLayerTreeHost(CCLayerTreeHost* host) 121 121 { 122 if (layerTreeHost() != host) 123 setTextureManager(host ? host->contentsTextureManager() : 0); 122 CanvasLayerChromium::setLayerTreeHost(host); 124 123 125 CanvasLayerChromium::setLayerTreeHost(host); 124 if (m_useDoubleBuffering && host) 125 setTextureManager(host->contentsTextureManager()); 126 126 } 127 127 128 128 void Canvas2DLayerChromium::setTextureManager(TextureManager* textureManager) 129 129 { 130 if (textureManager && m_useDoubleBuffering) 130 if (m_frontTexture) 131 m_frontTexture->setTextureManager(textureManager); 132 else 131 133 m_frontTexture = ManagedTexture::create(textureManager); 132 else133 m_frontTexture.clear();134 134 } 135 135 … … 167 167 } 168 168 169 void Canvas2DLayerChromium::cleanupResources()170 {171 if (m_useDoubleBuffering)172 m_frontTexture.clear();173 }174 175 169 } 176 170 -
trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h
r106500 r106891 62 62 virtual void pushPropertiesTo(CCLayerImpl*); 63 63 virtual void unreserveContentsTexture(); 64 virtual void cleanupResources();65 64 66 65 void setCanvas(SkCanvas*); … … 69 68 Canvas2DLayerChromium(GraphicsContext3D*, const IntSize&); 70 69 71 // Visible for testing so we can bypass setLayerTreeHost.72 70 friend class Canvas2DLayerChromiumTest; 73 71 void setTextureManager(TextureManager*); -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
r106383 r106891 93 93 } 94 94 95 void LayerChromium::cleanupResources()96 {97 }98 99 95 void LayerChromium::setIsNonCompositedContent(bool isNonCompositedContent) 100 96 { … … 106 102 if (m_layerTreeHost == host) 107 103 return; 108 109 // If we're changing hosts then we need to free up any resources110 // allocated by the old host.111 if (m_layerTreeHost)112 cleanupResources();113 104 114 105 m_layerTreeHost = host; -
trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h
r106383 r106891 215 215 LayerChromium(); 216 216 217 // This is called to clean up resources being held in the same context as218 // layerRendererContext(). Subclasses should override this method if they219 // hold context-dependent resources such as textures.220 virtual void cleanupResources();221 222 217 bool isPaintedAxisAlignedInScreen() const; 223 218 -
trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.cpp
r106840 r106891 62 62 } 63 63 64 void ManagedTexture::setTextureManager(TextureManager* manager) 65 { 66 if (manager == m_textureManager) 67 return; 68 69 if (m_textureManager) 70 m_textureManager->unregisterTexture(this); 71 m_textureManager = manager; 72 clear(); 73 if (m_textureManager) 74 m_textureManager->registerTexture(this); 75 } 76 64 77 bool ManagedTexture::isValid(const IntSize& size, unsigned format) 65 78 { … … 120 133 { 121 134 OwnPtr<ManagedTexture> texture = adoptPtr(new ManagedTexture(m_textureManager, m_token, m_size, m_format, m_textureId)); 135 clear(); 136 return texture.release(); 137 } 138 139 void ManagedTexture::clear() 140 { 122 141 m_token = 0; 123 142 m_size = IntSize(); 124 143 m_format = 0; 125 144 m_textureId = 0; 126 return texture.release();127 145 } 128 129 146 130 147 } -
trunk/Source/WebCore/platform/graphics/chromium/ManagedTexture.h
r106840 r106891 47 47 ~ManagedTexture(); 48 48 49 void setTextureManager(TextureManager*); 49 50 void clearManager() { m_textureManager = 0; } 50 51 … … 73 74 ManagedTexture(TextureManager*, TextureToken, IntSize, unsigned format, unsigned textureId); 74 75 76 void clear(); 77 75 78 TextureManager* m_textureManager; 76 79 TextureToken m_token; -
trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h
r106383 r106891 52 52 bool prepareContentsTexture(); 53 53 void releaseContentsTexture(); 54 void cleanupResources();55 54 void draw(const IntRect& targetSurfaceRect); 56 55 -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
r106870 r106891 93 93 } 94 94 95 void TiledLayerChromium::cleanupResources()96 {97 LayerChromium::cleanupResources();98 99 m_tiler->reset();100 m_paintRect = IntRect();101 m_requestedUpdateTilesRect = IntRect();102 }103 104 95 void TiledLayerChromium::updateTileSizeAndTilingOption() 105 96 { … … 274 265 return 0; 275 266 return layerTreeHost()->contentsTextureManager(); 267 } 268 269 void TiledLayerChromium::setLayerTreeHost(CCLayerTreeHost* host) 270 { 271 if (host && host != layerTreeHost()) { 272 for (CCLayerTilingData::TileMap::const_iterator iter = m_tiler->tiles().begin(); iter != m_tiler->tiles().end(); ++iter) { 273 UpdatableTile* tile = static_cast<UpdatableTile*>(iter->second.get()); 274 tile->managedTexture()->setTextureManager(host->contentsTextureManager()); 275 } 276 } 277 LayerChromium::setLayerTreeHost(host); 276 278 } 277 279 … … 386 388 if (!backgroundCoversViewport()) 387 389 m_skipsDraw = true; 388 cleanupResources(); 390 m_tiler->reset(); 391 m_paintRect = IntRect(); 392 m_requestedUpdateTilesRect = IntRect(); 389 393 } 390 394 return; -
trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
r106700 r106891 59 59 virtual void setIsNonCompositedContent(bool); 60 60 61 virtual void setLayerTreeHost(CCLayerTreeHost*); 62 61 63 // Reserves all existing and valid tile textures to protect them from being 62 64 // recycled by the texture manager. … … 70 72 TiledLayerChromium(); 71 73 72 virtual void cleanupResources();73 74 void updateTileSizeAndTilingOption(); 74 75 void updateBounds(); -
trunk/Source/WebKit/chromium/ChangeLog
r106887 r106891 1 2012-02-06 James Robinson <jamesr@chromium.org> 2 3 [chromium] canvas demo is slow due to unnecessary resource cleanups 4 https://bugs.webkit.org/show_bug.cgi?id=77135 5 6 Reviewed by Kenneth Russell. 7 8 * tests/Canvas2DLayerChromiumTest.cpp: 9 (WebCore::Canvas2DLayerChromiumTest::fullLifecycleTest): 10 * tests/TextureManagerTest.cpp: 11 * tests/TiledLayerChromiumTest.cpp: 12 1 13 2012-02-06 Julien Chaffraix <jchaffraix@webkit.org> 2 14 -
trunk/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp
r106383 r106891 76 76 class Canvas2DLayerChromiumTest : public Test { 77 77 protected: 78 // This indirection is needed because individual tests aren't friends of Canvas2DLayerChromium.79 void setTextureManager(Canvas2DLayerChromium* layer, TextureManager* manager)80 {81 layer->setTextureManager(manager);82 }83 84 78 void fullLifecycleTest(bool threaded) 85 79 { … … 134 128 RefPtr<Canvas2DLayerChromium> canvas = Canvas2DLayerChromium::create(mainContext.get(), size); 135 129 canvas->setIsDrawable(true); 136 setTextureManager(canvas.get(),textureManager.get());130 canvas->setTextureManager(textureManager.get()); 137 131 canvas->setBounds(IntSize(600, 300)); 138 132 canvas->setTextureId(backTextureId); -
trunk/Source/WebKit/chromium/tests/TextureManagerTest.cpp
r106840 r106891 265 265 } 266 266 267 TEST_F(TextureManagerTest, textureMovedToNewManager) 268 { 269 OwnPtr<TextureManager> textureManagerOne = createTextureManager(1, 1); 270 OwnPtr<TextureManager> textureManagerTwo = createTextureManager(1, 1); 271 OwnPtr<ManagedTexture> managedTexture = ManagedTexture::create(textureManagerOne.get()); 272 273 IntSize size(50, 50); 274 unsigned format = GraphicsContext3D::RGBA; 275 276 // Texture is initially invalid, but we should be able to reserve. 277 EXPECT_FALSE(managedTexture->isValid(size, format)); 278 EXPECT_TRUE(managedTexture->reserve(size, format)); 279 EXPECT_TRUE(managedTexture->isValid(size, format)); 280 281 // Setting to the same manager should be a no-op. 282 managedTexture->setTextureManager(textureManagerOne.get()); 283 EXPECT_TRUE(managedTexture->isValid(size, format)); 284 285 // Setting to a different manager should invalidate the texture. 286 managedTexture->setTextureManager(textureManagerTwo.get()); 287 288 EXPECT_FALSE(managedTexture->isValid(size, format)); 289 EXPECT_TRUE(managedTexture->reserve(size, format)); 290 EXPECT_TRUE(managedTexture->isValid(size, format)); 291 } 292 267 293 } // namespace -
trunk/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp
r106870 r106891 460 460 461 461 ccLayerTreeHost->commitComplete(); 462 textureManager->unprotectAllTextures(); // CCLayerTreeHost::commitComplete() normally does this, but since we're mocking out the manager we have to do it. 462 463 463 464 // Remove the child layer.
Note: See TracChangeset
for help on using the changeset viewer.