From bcd53c5432b6bd04fb268e32c26b167d3ce0b983 Mon Sep 17 00:00:00 2001 From: "enne@google.com" Date: Mon, 30 Jan 2012 22:10:07 +0000 Subject: [PATCH] [chromium] Always pre-reserve scrollbar and scroll corner textures https://bugs.webkit.org/show_bug.cgi?id=77251 Reviewed by James Robinson. Source/WebCore: Add a flag to LayerChromium that says that a layer's textures should always be reserved. Prior to painting layers, find all layers marked as such and reserve their textures. This will prevent texture memory limits from being hit before the root layer's scrollbars are reserved and painted. * platform/graphics/chromium/LayerChromium.cpp: (WebCore::LayerChromium::LayerChromium): * platform/graphics/chromium/LayerChromium.h: (LayerChromium): (WebCore::LayerChromium::reserveTextures): (WebCore::LayerChromium::setAlwaysReserveTextures): (WebCore::LayerChromium::alwaysReserveTextures): * platform/graphics/chromium/TiledLayerChromium.cpp: (WebCore::TiledLayerChromium::reserveTextures): * platform/graphics/chromium/TiledLayerChromium.h: (): * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: (WebCore::CCLayerTreeHost::updateLayers): (WebCore::CCLayerTreeHost::reserveTextures): (WebCore): * platform/graphics/chromium/cc/CCLayerTreeHost.h: (): Source/WebKit/chromium: * src/NonCompositedContentHost.cpp: (WebKit::reserveScrollbarLayers): (WebKit): (WebKit::NonCompositedContentHost::setViewport): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106289 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 31 ++++++++++++++++++++++ .../platform/graphics/chromium/LayerChromium.cpp | 1 + .../platform/graphics/chromium/LayerChromium.h | 7 +++++ .../graphics/chromium/TiledLayerChromium.cpp | 25 +++++++++++++++++ .../graphics/chromium/TiledLayerChromium.h | 2 ++ .../graphics/chromium/cc/CCLayerTreeHost.cpp | 15 +++++++++++ .../graphics/chromium/cc/CCLayerTreeHost.h | 2 ++ Source/WebKit/chromium/ChangeLog | 12 +++++++++ .../chromium/src/NonCompositedContentHost.cpp | 20 ++++++++++++++ 9 files changed, 115 insertions(+) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 00e97c1..5b99cf3 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,34 @@ +2012-01-30 Adrienne Walker + + [chromium] Always pre-reserve scrollbar and scroll corner textures + https://bugs.webkit.org/show_bug.cgi?id=77251 + + Reviewed by James Robinson. + + Add a flag to LayerChromium that says that a layer's textures should + always be reserved. Prior to painting layers, find all layers marked + as such and reserve their textures. This will prevent texture memory + limits from being hit before the root layer's scrollbars are reserved + and painted. + + * platform/graphics/chromium/LayerChromium.cpp: + (WebCore::LayerChromium::LayerChromium): + * platform/graphics/chromium/LayerChromium.h: + (LayerChromium): + (WebCore::LayerChromium::reserveTextures): + (WebCore::LayerChromium::setAlwaysReserveTextures): + (WebCore::LayerChromium::alwaysReserveTextures): + * platform/graphics/chromium/TiledLayerChromium.cpp: + (WebCore::TiledLayerChromium::reserveTextures): + * platform/graphics/chromium/TiledLayerChromium.h: + (): + * platform/graphics/chromium/cc/CCLayerTreeHost.cpp: + (WebCore::CCLayerTreeHost::updateLayers): + (WebCore::CCLayerTreeHost::reserveTextures): + (WebCore): + * platform/graphics/chromium/cc/CCLayerTreeHost.h: + (): + 2012-01-30 Beth Dakin Speculative 32-bit build-fix. diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp index 4a92751..1f23cfb 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp @@ -72,6 +72,7 @@ LayerChromium::LayerChromium() , m_usesLayerClipping(false) , m_isNonCompositedContent(false) , m_preserves3D(false) + , m_alwaysReserveTextures(false) , m_replicaLayer(0) , m_drawOpacity(0) , m_targetRenderSurface(0) diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.h b/Source/WebCore/platform/graphics/chromium/LayerChromium.h index 685de0c..945ee8e 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/LayerChromium.h @@ -197,6 +197,12 @@ public: CCLayerTreeHost* layerTreeHost() const { return m_layerTreeHost.get(); } + // Reserve any textures needed for this layer. + virtual void reserveTextures() { } + + void setAlwaysReserveTextures(bool alwaysReserveTextures) { m_alwaysReserveTextures = alwaysReserveTextures; } + bool alwaysReserveTextures() const { return m_alwaysReserveTextures; } + protected: LayerChromium(); @@ -264,6 +270,7 @@ private: bool m_usesLayerClipping; bool m_isNonCompositedContent; bool m_preserves3D; + bool m_alwaysReserveTextures; TransformationMatrix m_transform; TransformationMatrix m_sublayerTransform; diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp index 271858e..17f14fc 100644 --- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp @@ -451,6 +451,31 @@ void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int } } +void TiledLayerChromium::reserveTextures() +{ + updateBounds(); + + const IntRect& layerRect = visibleLayerRect(); + if (layerRect.isEmpty() || !m_tiler->numTiles()) + return; + + int left, top, right, bottom; + m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom); + + for (int j = top; j <= bottom; ++j) { + for (int i = left; i <= right; ++i) { + UpdatableTile* tile = tileAt(i, j); + if (!tile) + tile = createTile(i, j); + + if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat)) + tile->m_dirtyRect = m_tiler->tileRect(tile); + + if (!tile->managedTexture()->reserve(m_tiler->tileSize(), m_textureFormat)) + return; + } + } +} void TiledLayerChromium::prepareToUpdate(const IntRect& layerRect) { diff --git a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h index 1f9f695..18e029c 100644 --- a/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h +++ b/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h @@ -61,6 +61,8 @@ public: // recycled by the texture manager. void protectTileTextures(const IntRect& layerRect); + virtual void reserveTextures(); + protected: TiledLayerChromium(); diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp index b992360..62d6ce2 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.cpp @@ -379,6 +379,8 @@ void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer) CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(rootLayer, rootLayer, identityMatrix, identityMatrix, m_updateList, rootRenderSurface->layerList(), layerRendererCapabilities().maxTextureSize); } + reserveTextures(); + paintLayerContents(m_updateList, PaintVisible); if (!m_triggerIdlePaints) return; @@ -397,6 +399,19 @@ void CCLayerTreeHost::updateLayers(LayerChromium* rootLayer) m_contentsTextureManager->setMaxMemoryLimitBytes(maxLimitBytes); } +void CCLayerTreeHost::reserveTextures() +{ + // Use BackToFront since it's cheap and this isn't order-dependent. + typedef CCLayerIterator CCLayerIteratorType; + + CCLayerIteratorType end = CCLayerIteratorType::end(&m_updateList); + for (CCLayerIteratorType it = CCLayerIteratorType::begin(&m_updateList); it != end; ++it) { + if (it.representsTargetRenderSurface() || !it->alwaysReserveTextures()) + continue; + it->reserveTextures(); + } +} + // static void CCLayerTreeHost::paintContentsIfDirty(LayerChromium* layer, PaintType paintType) { diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h index d92adc1..81b5f25 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h @@ -210,6 +210,8 @@ private: void paintMaskAndReplicaForRenderSurface(LayerChromium*, PaintType); void updateLayers(LayerChromium*); + // Pre-reserve textures for any layer marked "always reserve textures" + void reserveTextures(); void clearPendingUpdate(); int m_compositorIdentifier; diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index 701078e..d7aebd9 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,15 @@ +2012-01-30 Adrienne Walker + + [chromium] Always pre-reserve scrollbar and scroll corner textures + https://bugs.webkit.org/show_bug.cgi?id=77251 + + Reviewed by James Robinson. + + * src/NonCompositedContentHost.cpp: + (WebKit::reserveScrollbarLayers): + (WebKit): + (WebKit::NonCompositedContentHost::setViewport): + 2012-01-30 Ryosuke Niwa Roll Chromium DEPS from 119623 to 119700. diff --git a/Source/WebKit/chromium/src/NonCompositedContentHost.cpp b/Source/WebKit/chromium/src/NonCompositedContentHost.cpp index 7bcb98a..5f43a9a 100644 --- a/Source/WebKit/chromium/src/NonCompositedContentHost.cpp +++ b/Source/WebKit/chromium/src/NonCompositedContentHost.cpp @@ -78,6 +78,20 @@ void NonCompositedContentHost::setScrollLayer(WebCore::GraphicsLayer* layer) ASSERT(scrollLayer()); } +static void reserveScrollbarLayers(WebCore::LayerChromium* layer, WebCore::LayerChromium* clipLayer) +{ + // Scrollbars and corners are known to be attached outside the root clip + // rect, so skip the clipLayer subtree. + if (layer == clipLayer) + return; + + for (size_t i = 0; i < layer->children().size(); ++i) + reserveScrollbarLayers(layer->children()[i].get(), clipLayer); + + if (layer->drawsContent()) + layer->setAlwaysReserveTextures(true); +} + void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, const WebCore::IntSize& contentsSize, const WebCore::IntPoint& scrollPosition, float pageScale, int layerAdjustX) { if (!scrollLayer()) @@ -106,6 +120,12 @@ void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, if (m_graphicsLayer->pageScaleFactor() != pageScale) m_graphicsLayer->deviceOrPageScaleFactorChanged(); + + WebCore::LayerChromium* clipLayer = scrollLayer()->parent(); + WebCore::LayerChromium* rootLayer = clipLayer; + while (rootLayer->parent()) + rootLayer = rootLayer->parent(); + reserveScrollbarLayers(rootLayer, clipLayer); } WebCore::LayerChromium* NonCompositedContentHost::scrollLayer() -- 2.7.4