From 789c541082be9fff627e4ad4966e5c3cf25181bf Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Wed, 6 Aug 2014 18:32:52 -0700 Subject: [PATCH] Backed out 2 changesets (bug 1048110) for various Android mochitest failures on a CLOSED TREE Backed out changeset 1cf6f4f27811 (bug 1048110) Backed out changeset b89f54e21c0b (bug 1048110) --- gfx/2d/BaseRect.h | 14 ----------- gfx/layers/Layers.h | 16 ++++++------- gfx/layers/client/ClientTiledThebesLayer.cpp | 23 ++++--------------- gfx/layers/client/TiledContentClient.cpp | 5 ---- gfx/layers/composite/CompositableHost.h | 11 ++++++++- gfx/layers/composite/ContentHost.cpp | 4 +++- gfx/layers/composite/ContentHost.h | 13 ++++++----- gfx/layers/composite/ImageHost.cpp | 3 ++- gfx/layers/composite/ImageHost.h | 3 ++- gfx/layers/composite/ThebesLayerComposite.cpp | 16 ++++++++++++- gfx/layers/composite/ThebesLayerComposite.h | 3 +++ gfx/layers/composite/TiledContentHost.cpp | 22 ++++++------------ gfx/layers/composite/TiledContentHost.h | 3 ++- layout/reftests/css-gradients/reftest.list | 2 +- 14 files changed, 64 insertions(+), 74 deletions(-) diff --git a/gfx/2d/BaseRect.h b/gfx/2d/BaseRect.h index 0b5a58248a5a..88f32cb4f2d0 100644 --- a/gfx/2d/BaseRect.h +++ b/gfx/2d/BaseRect.h @@ -204,20 +204,6 @@ struct BaseRect { } void Inflate(const SizeT& aSize) { Inflate(aSize.width, aSize.height); } - void InflateToMultiple(const SizeT& aMultiple) - { - T xMost = XMost(); - T yMost = YMost(); - - x = static_cast(floor(x / aMultiple.width)) * aMultiple.width; - y = static_cast(floor(y / aMultiple.height)) * aMultiple.height; - xMost = static_cast(ceil(x / aMultiple.width)) * aMultiple.width; - yMost = static_cast(ceil(y / aMultiple.height)) * aMultiple.height; - - width = xMost - x; - height = yMost - y; - } - void Deflate(T aD) { Deflate(aD, aD); } void Deflate(T aDx, T aDy) { diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 6ab050e17119..fe93bb44d70a 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -1434,14 +1434,6 @@ public: virtual int32_t GetMaxLayerSize() { return Manager()->GetMaxTextureSize(); } - /** - * Returns true if this layer's effective transform is not just - * a translation by integers, or if this layer or some ancestor layer - * is marked as having a transform that may change without a full layer - * transaction. - */ - bool MayResample(); - protected: Layer(LayerManager* aManager, void* aImplData); @@ -1490,6 +1482,14 @@ protected: const gfxRect& aSnapRect, gfx::Matrix* aResidualTransform); + /** + * Returns true if this layer's effective transform is not just + * a translation by integers, or if this layer or some ancestor layer + * is marked as having a transform that may change without a full layer + * transaction. + */ + bool MayResample(); + LayerManager* mManager; ContainerLayer* mParent; Layer* mNextSibling; diff --git a/gfx/layers/client/ClientTiledThebesLayer.cpp b/gfx/layers/client/ClientTiledThebesLayer.cpp index 369e276d5922..004c174d86e1 100644 --- a/gfx/layers/client/ClientTiledThebesLayer.cpp +++ b/gfx/layers/client/ClientTiledThebesLayer.cpp @@ -335,23 +335,8 @@ ClientTiledThebesLayer::RenderLayer() TILING_LOG("TILING %p: Initial valid region %s\n", this, Stringify(mValidRegion).c_str()); TILING_LOG("TILING %p: Initial low-precision valid region %s\n", this, Stringify(mLowPrecisionValidRegion).c_str()); - nsIntRegion neededRegion = mVisibleRegion; - if (MayResample()) { - // If we're resampling then bilinear filtering can read up to 1 pixel - // outside of our texture coords. Make the visible region a single rect, - // and pad it out by 1 pixel (restricted to tile boundaries) so that - // we always have valid content or transparent pixels to sample from. - nsIntRect bounds = neededRegion.GetBounds(); - nsIntRect wholeTiles = bounds; - wholeTiles.Inflate(nsIntSize(gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight())); - nsIntRect padded = bounds; - padded.Inflate(1); - padded.IntersectRect(padded, wholeTiles); - neededRegion = padded; - } - nsIntRegion invalidRegion; - invalidRegion.Sub(neededRegion, mValidRegion); + invalidRegion.Sub(mVisibleRegion, mValidRegion); if (invalidRegion.IsEmpty()) { EndPaint(); return; @@ -366,7 +351,7 @@ ClientTiledThebesLayer::RenderLayer() // In some cases we can take a fast path and just be done with it. if (UseFastPath()) { TILING_LOG("TILING %p: Taking fast-path\n", this); - mValidRegion = neededRegion; + mValidRegion = mVisibleRegion; mContentClient->mTiledBuffer.PaintThebes(mValidRegion, invalidRegion, callback, data); ClientManager()->Hold(this); mContentClient->UseTiledLayerBuffer(TiledContentClient::TILED_BUFFER); @@ -383,7 +368,7 @@ ClientTiledThebesLayer::RenderLayer() // Make sure that tiles that fall outside of the visible region or outside of the // critical displayport are discarded on the first update. Also make sure that we // only draw stuff inside the critical displayport on the first update. - mValidRegion.And(mValidRegion, neededRegion); + mValidRegion.And(mValidRegion, mVisibleRegion); if (!mPaintData.mCriticalDisplayPort.IsEmpty()) { mValidRegion.And(mValidRegion, LayerIntRect::ToUntyped(mPaintData.mCriticalDisplayPort)); invalidRegion.And(invalidRegion, LayerIntRect::ToUntyped(mPaintData.mCriticalDisplayPort)); @@ -402,7 +387,7 @@ ClientTiledThebesLayer::RenderLayer() if (gfxPrefs::UseLowPrecisionBuffer()) { // Calculate the invalid region for the low precision buffer. Make sure // to remove the valid high-precision area so we don't double-paint it. - lowPrecisionInvalidRegion.Sub(neededRegion, mLowPrecisionValidRegion); + lowPrecisionInvalidRegion.Sub(mVisibleRegion, mLowPrecisionValidRegion); lowPrecisionInvalidRegion.Sub(lowPrecisionInvalidRegion, mValidRegion); } TILING_LOG("TILING %p: Low-precision invalid region %s\n", this, Stringify(lowPrecisionInvalidRegion).c_str()); diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index 184d041adc3d..964b04d36d31 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -327,11 +327,6 @@ ClientTiledLayerBuffer::GetContentType(SurfaceMode* aMode) const content = gfxContentType::COLOR; } #endif - } else if (mode == SurfaceMode::SURFACE_OPAQUE) { - if (mThebesLayer->MayResample()) { - mode = SurfaceMode::SURFACE_SINGLE_CHANNEL_ALPHA; - content = gfxContentType::COLOR_ALPHA; - } } if (aMode) { diff --git a/gfx/layers/composite/CompositableHost.h b/gfx/layers/composite/CompositableHost.h index 33a2f4b16efe..8f6b3cddebb0 100644 --- a/gfx/layers/composite/CompositableHost.h +++ b/gfx/layers/composite/CompositableHost.h @@ -37,6 +37,14 @@ class DataSourceSurface; namespace layers { +// Some properties of a Layer required for tiling +struct TiledLayerProperties +{ + nsIntRegion mVisibleRegion; + nsIntRegion mValidRegion; + CSSToScreenScale mEffectiveResolution; +}; + class Layer; class SurfaceDescriptor; class Compositor; @@ -113,7 +121,8 @@ public: const gfx::Matrix4x4& aTransform, const gfx::Filter& aFilter, const gfx::Rect& aClipRect, - const nsIntRegion* aVisibleRegion = nullptr) = 0; + const nsIntRegion* aVisibleRegion = nullptr, + TiledLayerProperties* aLayerProperties = nullptr) = 0; /** * Update the content host. diff --git a/gfx/layers/composite/ContentHost.cpp b/gfx/layers/composite/ContentHost.cpp index 72d4dd7495d5..d54ec10a4467 100644 --- a/gfx/layers/composite/ContentHost.cpp +++ b/gfx/layers/composite/ContentHost.cpp @@ -27,6 +27,7 @@ namespace layers { ContentHostBase::ContentHostBase(const TextureInfo& aTextureInfo) : ContentHost(aTextureInfo) + , mPaintWillResample(false) , mInitialised(false) {} @@ -40,7 +41,8 @@ ContentHostBase::Composite(EffectChain& aEffectChain, const gfx::Matrix4x4& aTransform, const Filter& aFilter, const Rect& aClipRect, - const nsIntRegion* aVisibleRegion) + const nsIntRegion* aVisibleRegion, + TiledLayerProperties* aLayerProperties) { NS_ASSERTION(aVisibleRegion, "Requires a visible region"); diff --git a/gfx/layers/composite/ContentHost.h b/gfx/layers/composite/ContentHost.h index e5aa7156aa9d..40580fcea78a 100644 --- a/gfx/layers/composite/ContentHost.h +++ b/gfx/layers/composite/ContentHost.h @@ -64,16 +64,12 @@ public: const nsIntRegion& aOldValidRegionBack, nsIntRegion* aUpdatedRegionBack) = 0; - virtual void SetPaintWillResample(bool aResample) { mPaintWillResample = aResample; } - bool PaintWillResample() { return mPaintWillResample; } + virtual void SetPaintWillResample(bool aResample) { } protected: ContentHost(const TextureInfo& aTextureInfo) : CompositableHost(aTextureInfo) - , mPaintWillResample(false) {} - - bool mPaintWillResample; }; /** @@ -101,7 +97,10 @@ public: const gfx::Matrix4x4& aTransform, const gfx::Filter& aFilter, const gfx::Rect& aClipRect, - const nsIntRegion* aVisibleRegion = nullptr); + const nsIntRegion* aVisibleRegion = nullptr, + TiledLayerProperties* aLayerProperties = nullptr); + + virtual void SetPaintWillResample(bool aResample) { mPaintWillResample = aResample; } virtual NewTextureSource* GetTextureSource() = 0; virtual NewTextureSource* GetTextureSourceOnWhite() = 0; @@ -114,9 +113,11 @@ protected: return mBufferRect.TopLeft() - mBufferRotation; } + bool PaintWillResample() { return mPaintWillResample; } nsIntRect mBufferRect; nsIntPoint mBufferRotation; + bool mPaintWillResample; bool mInitialised; }; diff --git a/gfx/layers/composite/ImageHost.cpp b/gfx/layers/composite/ImageHost.cpp index 4e67991e23ec..2025fe0b493b 100644 --- a/gfx/layers/composite/ImageHost.cpp +++ b/gfx/layers/composite/ImageHost.cpp @@ -65,7 +65,8 @@ ImageHost::Composite(EffectChain& aEffectChain, const gfx::Matrix4x4& aTransform, const gfx::Filter& aFilter, const gfx::Rect& aClipRect, - const nsIntRegion* aVisibleRegion) + const nsIntRegion* aVisibleRegion, + TiledLayerProperties* aLayerProperties) { if (!GetCompositor()) { // should only happen when a tab is dragged to another window and diff --git a/gfx/layers/composite/ImageHost.h b/gfx/layers/composite/ImageHost.h index bae8ed772072..5002a00a52a7 100644 --- a/gfx/layers/composite/ImageHost.h +++ b/gfx/layers/composite/ImageHost.h @@ -50,7 +50,8 @@ public: const gfx::Matrix4x4& aTransform, const gfx::Filter& aFilter, const gfx::Rect& aClipRect, - const nsIntRegion* aVisibleRegion = nullptr) MOZ_OVERRIDE; + const nsIntRegion* aVisibleRegion = nullptr, + TiledLayerProperties* aLayerProperties = nullptr) MOZ_OVERRIDE; virtual void UseTextureHost(TextureHost* aTexture) MOZ_OVERRIDE; diff --git a/gfx/layers/composite/ThebesLayerComposite.cpp b/gfx/layers/composite/ThebesLayerComposite.cpp index e47aaeb4adca..3b4870f3f835 100644 --- a/gfx/layers/composite/ThebesLayerComposite.cpp +++ b/gfx/layers/composite/ThebesLayerComposite.cpp @@ -38,6 +38,7 @@ ThebesLayerComposite::ThebesLayerComposite(LayerManagerComposite *aManager) : ThebesLayer(aManager, nullptr) , LayerComposite(aManager) , mBuffer(nullptr) + , mRequiresTiledProperties(false) { MOZ_COUNT_CTOR(ThebesLayerComposite); mImplData = static_cast(this); @@ -134,6 +135,13 @@ ThebesLayerComposite::RenderLayer(const nsIntRect& aClipRect) const nsIntRegion& visibleRegion = GetEffectiveVisibleRegion(); + TiledLayerProperties tiledLayerProps; + if (mRequiresTiledProperties) { + tiledLayerProps.mVisibleRegion = visibleRegion; + tiledLayerProps.mEffectiveResolution = GetEffectiveResolution(); + tiledLayerProps.mValidRegion = mValidRegion; + } + mBuffer->SetPaintWillResample(MayResample()); mBuffer->Composite(effectChain, @@ -141,9 +149,15 @@ ThebesLayerComposite::RenderLayer(const nsIntRect& aClipRect) GetEffectiveTransform(), GetEffectFilter(), clipRect, - &visibleRegion); + &visibleRegion, + mRequiresTiledProperties ? &tiledLayerProps + : nullptr); mBuffer->BumpFlashCounter(); + if (mRequiresTiledProperties) { + mValidRegion = tiledLayerProps.mValidRegion; + } + mCompositeManager->GetCompositor()->MakeCurrent(); } diff --git a/gfx/layers/composite/ThebesLayerComposite.h b/gfx/layers/composite/ThebesLayerComposite.h index 0a09112cf82a..49fbc3994222 100644 --- a/gfx/layers/composite/ThebesLayerComposite.h +++ b/gfx/layers/composite/ThebesLayerComposite.h @@ -65,6 +65,8 @@ public: virtual LayerComposite* AsLayerComposite() MOZ_OVERRIDE { return this; } + void EnsureTiled() { mRequiresTiledProperties = true; } + virtual void InvalidateRegion(const nsIntRegion& aRegion) { NS_RUNTIMEABORT("ThebesLayerComposites can't fill invalidated regions"); @@ -90,6 +92,7 @@ private: private: RefPtr mBuffer; + bool mRequiresTiledProperties; }; } /* layers */ diff --git a/gfx/layers/composite/TiledContentHost.cpp b/gfx/layers/composite/TiledContentHost.cpp index 6d4aee59ce5c..13847958a083 100644 --- a/gfx/layers/composite/TiledContentHost.cpp +++ b/gfx/layers/composite/TiledContentHost.cpp @@ -241,6 +241,7 @@ TiledContentHost::Attach(Layer* aLayer, AttachFlags aFlags /* = NO_FLAGS */) { CompositableHost::Attach(aLayer, aCompositor, aFlags); + static_cast(aLayer)->EnsureTiled(); } void @@ -323,8 +324,11 @@ TiledContentHost::Composite(EffectChain& aEffectChain, const gfx::Matrix4x4& aTransform, const gfx::Filter& aFilter, const gfx::Rect& aClipRect, - const nsIntRegion* aVisibleRegion /* = nullptr */) + const nsIntRegion* aVisibleRegion /* = nullptr */, + TiledLayerProperties* aLayerProperties /* = nullptr */) { + MOZ_ASSERT(aLayerProperties, "aLayerProperties required for TiledContentHost"); + if (mPendingUpload) { mTiledBuffer.SetCompositor(mCompositor); mTiledBuffer.Upload(); @@ -370,25 +374,13 @@ TiledContentHost::Composite(EffectChain& aEffectChain, (aOpacity == 1.0f && backgroundColor.a == 1.0f) ? gfxPrefs::LowPrecisionOpacity() : 1.0f; - nsIntRegion tmpRegion; - const nsIntRegion* renderRegion; - if (PaintWillResample()) { - // If we're resampling, then the texture image will contain exactly the - // entire visible region's bounds, and we should draw it all in one quad - // to avoid unexpected aliasing. - tmpRegion = aVisibleRegion->GetBounds(); - renderRegion = &tmpRegion; - } else { - renderRegion = aVisibleRegion; - } - // Render the low and high precision buffers. RenderLayerBuffer(mLowPrecisionTiledBuffer, lowPrecisionOpacityReduction < 1.0f ? &backgroundColor : nullptr, aEffectChain, lowPrecisionOpacityReduction * aOpacity, - aFilter, aClipRect, *renderRegion, aTransform); + aFilter, aClipRect, aLayerProperties->mVisibleRegion, aTransform); RenderLayerBuffer(mTiledBuffer, nullptr, aEffectChain, aOpacity, aFilter, - aClipRect, *renderRegion, aTransform); + aClipRect, aLayerProperties->mVisibleRegion, aTransform); // Now release the old buffer if it had double-buffered tiles, as we can // guarantee that they're no longer on the screen (and so any locks that may diff --git a/gfx/layers/composite/TiledContentHost.h b/gfx/layers/composite/TiledContentHost.h index 1c29651a4551..db595e7d82f4 100644 --- a/gfx/layers/composite/TiledContentHost.h +++ b/gfx/layers/composite/TiledContentHost.h @@ -223,7 +223,8 @@ public: const gfx::Matrix4x4& aTransform, const gfx::Filter& aFilter, const gfx::Rect& aClipRect, - const nsIntRegion* aVisibleRegion = nullptr); + const nsIntRegion* aVisibleRegion = nullptr, + TiledLayerProperties* aLayerProperties = nullptr); virtual CompositableType GetType() { return CompositableType::BUFFER_TILED; } diff --git a/layout/reftests/css-gradients/reftest.list b/layout/reftests/css-gradients/reftest.list index 80cd71cf422a..61fa9c52b90d 100644 --- a/layout/reftests/css-gradients/reftest.list +++ b/layout/reftests/css-gradients/reftest.list @@ -68,7 +68,7 @@ fuzzy(3,7860) fuzzy-if(cocoaWidget,5,89041) fuzzy-if(azureSkiaGL,2,90000) == rad == radial-position-1a.html radial-position-1-ref.html == radial-position-1b.html radial-position-1-ref.html fuzzy-if(azureQuartz,4,22317) == radial-shape-closest-corner-1a.html radial-shape-closest-corner-1-ref.html -fuzzy(1,238) fuzzy-if(cocoaWidget,3,460) fuzzy-if(azureQuartz,4,22608) == radial-shape-closest-corner-1b.html radial-shape-closest-corner-1-ref.html +fuzzy(1,232) fuzzy-if(cocoaWidget,3,460) fuzzy-if(azureQuartz,4,22608) == radial-shape-closest-corner-1b.html radial-shape-closest-corner-1-ref.html fuzzy-if(azureQuartz,2,41171) == radial-shape-closest-corner-1c.html radial-shape-closest-corner-1-ref.html fuzzy-if(/^Windows\x20NT\x206\.2/.test(http.oscpu),1,5) fuzzy-if(Android,17,3880) == radial-shape-closest-side-1a.html radial-shape-closest-side-1-ref.html fuzzy-if(/^Windows\x20NT\x206\.2/.test(http.oscpu),1,5) fuzzy-if(Android,17,3880) == radial-shape-closest-side-1b.html radial-shape-closest-side-1-ref.html