diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 8d6ec2b7bfad..42f7de5ff3d4 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -1466,7 +1466,11 @@ ContainerLayer::DefaultComputeEffectiveTransforms(const Matrix4x4& aTransformToS ComputeEffectiveTransformsForChildren(idealTransform); } - ComputeEffectiveTransformForMaskLayers(aTransformToSurface); + if (idealTransform.CanDraw2D()) { + ComputeEffectiveTransformForMaskLayers(aTransformToSurface); + } else { + ComputeEffectiveTransformForMaskLayers(Matrix4x4()); + } } void diff --git a/gfx/layers/basic/BasicCompositor.cpp b/gfx/layers/basic/BasicCompositor.cpp index 12433ea33211..8a069478d0aa 100644 --- a/gfx/layers/basic/BasicCompositor.cpp +++ b/gfx/layers/basic/BasicCompositor.cpp @@ -397,25 +397,6 @@ RoundOut(Rect r) return IntRect(r.x, r.y, r.width, r.height); } -static void -SetupMask(const EffectChain& aEffectChain, - DrawTarget* aDest, - const IntPoint& aOffset, - RefPtr& aMaskSurface, - Matrix& aMaskTransform) -{ - if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) { - EffectMask *effectMask = static_cast(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get()); - aMaskSurface = effectMask->mMaskTexture->AsSourceBasic()->GetSurface(aDest); - if (!aMaskSurface) { - gfxWarning() << "Invalid sourceMask effect"; - } - MOZ_ASSERT(effectMask->mMaskTransform.Is2D(), "How did we end up with a 3D transform here?!"); - aMaskTransform = effectMask->mMaskTransform.As2D(); - aMaskTransform.PostTranslate(-aOffset.x, -aOffset.y); - } -} - void BasicCompositor::DrawQuad(const gfx::Rect& aRect, const gfx::Rect& aClipRect, @@ -461,8 +442,7 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect, // When we apply the 3D transformation, we do it against a temporary // surface, so undo the coordinate offset. - new3DTransform = aTransform; - new3DTransform.PreTranslate(aRect.x, aRect.y, 0); + new3DTransform = Matrix4x4::Translation(aRect.x, aRect.y, 0) * aTransform; } buffer->PushClipRect(aClipRect); @@ -472,8 +452,16 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect, RefPtr sourceMask; Matrix maskTransform; - if (aTransform.Is2D()) { - SetupMask(aEffectChain, dest, offset, sourceMask, maskTransform); + if (aEffectChain.mSecondaryEffects[EffectTypes::MASK]) { + EffectMask *effectMask = static_cast(aEffectChain.mSecondaryEffects[EffectTypes::MASK].get()); + sourceMask = effectMask->mMaskTexture->AsSourceBasic()->GetSurface(dest); + if (!sourceMask) { + gfxWarning() << "Invalid sourceMask effect"; + } + MOZ_ASSERT(effectMask->mMaskTransform.Is2D(), "How did we end up with a 3D transform here?!"); + MOZ_ASSERT(!effectMask->mIs3D); + maskTransform = effectMask->mMaskTransform.As2D(); + maskTransform.PostTranslate(-offset.x, -offset.y); } CompositionOp blendMode = CompositionOp::OP_OVER; @@ -580,40 +568,8 @@ BasicCompositor::DrawQuad(const gfx::Rect& aRect, Transform(temp, source, new3DTransform, transformBounds.TopLeft()); - SetupMask(aEffectChain, buffer, offset, sourceMask, maskTransform); - - // Adjust for the fact that our content now start at 0,0 instead - // of the top left of transformBounds. transformBounds.MoveTo(0, 0); - maskTransform.PostTranslate(-transformBounds.x, -transformBounds.y); - - if (sourceMask) { - // Transform the source by it's normal transform, and then the inverse - // of the mask transform so that it's in the mask's untransformed - // coordinate space. - Matrix old = buffer->GetTransform(); - Matrix sourceTransform = old; - - Matrix inverseMask = maskTransform; - inverseMask.Invert(); - - sourceTransform *= inverseMask; - - SurfacePattern source(temp, ExtendMode::CLAMP, sourceTransform); - - buffer->PushClipRect(transformBounds); - - // Mask in the untransformed coordinate space, and then transform - // by the mask transform to put the result back into destination - // coords. - buffer->SetTransform(maskTransform); - buffer->MaskSurface(source, sourceMask, Point(0, 0)); - buffer->SetTransform(old); - - buffer->PopClip(); - } else { - buffer->DrawSurface(temp, transformBounds, transformBounds); - } + buffer->DrawSurface(temp, transformBounds, transformBounds); } buffer->PopClip(); diff --git a/layout/reftests/layers/mask-layer-transform-ref.html b/layout/reftests/layers/mask-layer-transform-ref.html deleted file mode 100644 index 54cd38607f95..000000000000 --- a/layout/reftests/layers/mask-layer-transform-ref.html +++ /dev/null @@ -1,8 +0,0 @@ - - -
-
-
- - - diff --git a/layout/reftests/layers/mask-layer-transform.html b/layout/reftests/layers/mask-layer-transform.html deleted file mode 100644 index 0a809c50bde9..000000000000 --- a/layout/reftests/layers/mask-layer-transform.html +++ /dev/null @@ -1,10 +0,0 @@ - - -
-
-
-
-
- - - diff --git a/layout/reftests/layers/reftest.list b/layout/reftests/layers/reftest.list index 397753ced6b4..fbeed320eac4 100644 --- a/layout/reftests/layers/reftest.list +++ b/layout/reftests/layers/reftest.list @@ -19,4 +19,3 @@ skip-if(!asyncPan) != pull-background-displayport-4.html about:blank # fails wit skip-if(!asyncPan) != pull-background-displayport-5.html about:blank skip-if(!asyncPan) != pull-background-displayport-6.html about:blank # fails with non-overlay scrollbars and event regions due to bug 1148515 fuzzy(2,30150) == opacity-blending.html opacity-blending-ref.html -fuzzy(1,5) == mask-layer-transform.html mask-layer-transform-ref.html