diff --git a/gfx/layers/client/ClientTiledPaintedLayer.cpp b/gfx/layers/client/ClientTiledPaintedLayer.cpp index 01ac573fb3d..806fb5678b7 100644 --- a/gfx/layers/client/ClientTiledPaintedLayer.cpp +++ b/gfx/layers/client/ClientTiledPaintedLayer.cpp @@ -28,6 +28,7 @@ ClientTiledPaintedLayer::ClientTiledPaintedLayer(ClientLayerManager* const aMana ClientLayerManager::PaintedLayerCreationHint aCreationHint) : PaintedLayer(aManager, static_cast(this), aCreationHint) , mContentClient() + , mHaveSingleTiledContentClient(false) { MOZ_COUNT_CTOR(ClientTiledPaintedLayer); mPaintData.mLastScrollOffset = ParentLayerPoint(0, 0); @@ -411,18 +412,26 @@ ClientTiledPaintedLayer::RenderLayer() void *data = ClientManager()->GetPaintedLayerCallbackData(); IntSize layerSize = mVisibleRegion.ToUnknownRegion().GetBounds().Size(); - if (mContentClient && !mContentClient->SupportsLayerSize(layerSize, ClientManager())) { + IntSize tileSize(gfxPlatform::GetPlatform()->GetTileWidth(), + gfxPlatform::GetPlatform()->GetTileHeight()); + + bool wantSingleTiledContentClient = + (mCreationHint == LayerManager::NONE || layerSize <= tileSize) && + SingleTiledContentClient::ClientSupportsLayerSize(layerSize, ClientManager()) && + gfxPrefs::LayersSingleTileEnabled(); + + if (mContentClient && mHaveSingleTiledContentClient && !wantSingleTiledContentClient) { mContentClient = nullptr; mValidRegion.SetEmpty(); } if (!mContentClient) { - if (mCreationHint == LayerManager::NONE && - SingleTiledContentClient::ClientSupportsLayerSize(layerSize, ClientManager()) && - gfxPrefs::LayersSingleTileEnabled()) { + if (wantSingleTiledContentClient) { mContentClient = new SingleTiledContentClient(this, ClientManager()); + mHaveSingleTiledContentClient = true; } else { mContentClient = new MultiTiledContentClient(this, ClientManager()); + mHaveSingleTiledContentClient = false; } mContentClient->Connect(); diff --git a/gfx/layers/client/ClientTiledPaintedLayer.h b/gfx/layers/client/ClientTiledPaintedLayer.h index cda3867a3e0..f4c3f2a8a9b 100644 --- a/gfx/layers/client/ClientTiledPaintedLayer.h +++ b/gfx/layers/client/ClientTiledPaintedLayer.h @@ -133,6 +133,9 @@ private: void EndPaint(); RefPtr mContentClient; + // Flag to indicate if mContentClient is a SingleTiledContentClient. This is + // only valid when mContentClient is non-null. + bool mHaveSingleTiledContentClient; nsIntRegion mLowPrecisionValidRegion; BasicTiledLayerPaintData mPaintData; }; diff --git a/gfx/layers/client/SingleTiledContentClient.cpp b/gfx/layers/client/SingleTiledContentClient.cpp index 2b9bd7d3132..bc6d636b0ce 100644 --- a/gfx/layers/client/SingleTiledContentClient.cpp +++ b/gfx/layers/client/SingleTiledContentClient.cpp @@ -46,12 +46,6 @@ SingleTiledContentClient::ClientSupportsLayerSize(const gfx::IntSize& aSize, Cli return aSize.width <= maxTextureSize && aSize.height <= maxTextureSize; } -bool -SingleTiledContentClient::SupportsLayerSize(const gfx::IntSize& aSize, ClientLayerManager* aManager) const -{ - return ClientSupportsLayerSize(aSize, aManager); -} - ClientSingleTiledLayerBuffer::ClientSingleTiledLayerBuffer(ClientTiledPaintedLayer* aPaintedLayer, CompositableClient* aCompositableClient, ClientLayerManager* aManager) diff --git a/gfx/layers/client/SingleTiledContentClient.h b/gfx/layers/client/SingleTiledContentClient.h index e2869976af5..2486f83cea5 100644 --- a/gfx/layers/client/SingleTiledContentClient.h +++ b/gfx/layers/client/SingleTiledContentClient.h @@ -127,8 +127,6 @@ public: virtual ClientTiledLayerBuffer* GetTiledBuffer() override { return mTiledBuffer; } virtual ClientTiledLayerBuffer* GetLowPrecisionTiledBuffer() override { return nullptr; } - virtual bool SupportsLayerSize(const gfx::IntSize& aSize, ClientLayerManager* aManager) const override; - private: RefPtr mTiledBuffer; }; diff --git a/gfx/layers/client/TiledContentClient.h b/gfx/layers/client/TiledContentClient.h index c53b396fa3c..e6f31e269e9 100644 --- a/gfx/layers/client/TiledContentClient.h +++ b/gfx/layers/client/TiledContentClient.h @@ -628,9 +628,6 @@ public: }; virtual void UpdatedBuffer(TiledBufferType aType) = 0; - virtual bool SupportsLayerSize(const gfx::IntSize& aSize, ClientLayerManager* aManager) const - { return true; } - private: const char* mName; }; diff --git a/layout/reftests/invalidation/reftest.list b/layout/reftests/invalidation/reftest.list index 19ded376d91..68e4e3e872a 100644 --- a/layout/reftests/invalidation/reftest.list +++ b/layout/reftests/invalidation/reftest.list @@ -51,7 +51,7 @@ pref(layout.animated-image-layers.enabled,true) skip-if(Android||gtkWidget) == t != clipped-animated-transform-1.html about:blank != paintedlayer-recycling-1.html about:blank != paintedlayer-recycling-2.html about:blank -!= paintedlayer-recycling-3.html about:blank +pref(layers.single-tile.enabled,false) != paintedlayer-recycling-3.html about:blank != paintedlayer-recycling-4.html about:blank != paintedlayer-recycling-5.html about:blank != paintedlayer-recycling-6.html about:blank @@ -67,7 +67,7 @@ pref(layout.animated-image-layers.enabled,true) skip-if(Android||gtkWidget) == t != layer-splitting-7.html about:blank fuzzy-if(gtkWidget,2,4) fuzzy-if(asyncPan,2,3955) fuzzy-if(OSX,179,30) == image-scrolling-zoom-1.html image-scrolling-zoom-1-ref.html != image-scrolling-zoom-1-ref.html image-scrolling-zoom-1-notref.html -!= fast-scrolling.html about:blank +pref(layers.single-tile.enabled,false) != fast-scrolling.html about:blank != fractional-transform-1.html about:blank != fractional-transform-2.html about:blank != fractional-transform-3.html about:blank diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 1082106d72d..758d9f58010 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4379,6 +4379,7 @@ pref("layers.draw-tile-borders", false); pref("layers.draw-bigimage-borders", false); pref("layers.frame-counter", false); pref("layers.enable-tiles", false); +pref("layers.single-tile.enabled", true); pref("layers.tiled-drawtarget.enabled", false); pref("layers.low-precision-buffer", false); pref("layers.progressive-paint", false);