From 28c11b78939dcf9261a248c40235efd892bf32a3 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Tue, 9 Jul 2013 12:05:04 -0400 Subject: [PATCH] Backout a17b6115cdd7 for causing reftest failures --- gfx/layers/Layers.h | 14 ------------ gfx/layers/basic/BasicColorLayer.cpp | 23 ++++++++++++-------- gfx/layers/client/ClientColorLayer.cpp | 2 +- gfx/layers/composite/ColorLayerComposite.cpp | 6 ++--- gfx/layers/d3d10/ColorLayerD3D10.cpp | 23 +++++++++++--------- gfx/layers/d3d9/ColorLayerD3D9.cpp | 10 ++++----- gfx/layers/ipc/LayerTransaction.ipdlh | 2 +- gfx/layers/ipc/LayerTransactionParent.cpp | 2 -- gfx/layers/opengl/ColorLayerOGL.cpp | 4 +++- layout/base/FrameLayerBuilder.cpp | 10 +++++++-- 10 files changed, 48 insertions(+), 48 deletions(-) diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 52d31597910..de24fe51e33 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -1563,19 +1563,6 @@ public: } } - void SetBounds(const nsIntRect& aBounds) - { - if (!mBounds.IsEqualEdges(aBounds)) { - mBounds = aBounds; - Mutated(); - } - } - - const nsIntRect& GetBounds() - { - return mBounds; - } - // This getter can be used anytime. virtual const gfxRGBA& GetColor() { return mColor; } @@ -1596,7 +1583,6 @@ protected: virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix); - nsIntRect mBounds; gfxRGBA mColor; }; diff --git a/gfx/layers/basic/BasicColorLayer.cpp b/gfx/layers/basic/BasicColorLayer.cpp index 74ebc024bdf..6afccccd731 100644 --- a/gfx/layers/basic/BasicColorLayer.cpp +++ b/gfx/layers/basic/BasicColorLayer.cpp @@ -34,18 +34,14 @@ public: { if (IsHidden()) return; - gfxContextAutoSaveRestore contextSR(aContext); AutoSetOperator setOperator(aContext, GetOperator()); - - aContext->SetColor(mColor); - - nsIntRect bounds = GetBounds(); - aContext->NewPath(); - aContext->Rectangle(gfxRect(bounds.x, bounds.y, bounds.width, bounds.height)); - - FillWithMask(aContext, GetEffectiveOpacity(), aMaskLayer); + PaintColorTo(mColor, GetEffectiveOpacity(), aContext, aMaskLayer); } + static void PaintColorTo(gfxRGBA aColor, float aOpacity, + gfxContext* aContext, + Layer* aMaskLayer); + protected: BasicLayerManager* BasicManager() { @@ -53,6 +49,15 @@ protected: } }; +/*static*/ void +BasicColorLayer::PaintColorTo(gfxRGBA aColor, float aOpacity, + gfxContext* aContext, + Layer* aMaskLayer) +{ + aContext->SetColor(aColor); + PaintWithMask(aContext, aOpacity, aMaskLayer); +} + already_AddRefed BasicLayerManager::CreateColorLayer() { diff --git a/gfx/layers/client/ClientColorLayer.cpp b/gfx/layers/client/ClientColorLayer.cpp index a7b84164ff1..11f68f96c04 100644 --- a/gfx/layers/client/ClientColorLayer.cpp +++ b/gfx/layers/client/ClientColorLayer.cpp @@ -40,7 +40,7 @@ public: virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs) { - aAttrs = ColorLayerAttributes(GetColor(), GetBounds()); + aAttrs = ColorLayerAttributes(GetColor()); } virtual Layer* AsLayer() { return this; } diff --git a/gfx/layers/composite/ColorLayerComposite.cpp b/gfx/layers/composite/ColorLayerComposite.cpp index 0cc0c996bdf..d9a82a8ea75 100644 --- a/gfx/layers/composite/ColorLayerComposite.cpp +++ b/gfx/layers/composite/ColorLayerComposite.cpp @@ -20,12 +20,12 @@ ColorLayerComposite::RenderLayer(const nsIntPoint& aOffset, color.g, color.b, color.a)); - nsIntRect boundRect = GetBounds(); + nsIntRect visibleRect = GetEffectiveVisibleRegion().GetBounds(); LayerManagerComposite::AddMaskEffect(GetMaskLayer(), effects); - gfx::Rect rect(boundRect.x, boundRect.y, - boundRect.width, boundRect.height); + gfx::Rect rect(visibleRect.x, visibleRect.y, + visibleRect.width, visibleRect.height); gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height); diff --git a/gfx/layers/d3d10/ColorLayerD3D10.cpp b/gfx/layers/d3d10/ColorLayerD3D10.cpp index 0c1d14ec0d0..7eabc8b855f 100644 --- a/gfx/layers/d3d10/ColorLayerD3D10.cpp +++ b/gfx/layers/d3d10/ColorLayerD3D10.cpp @@ -42,18 +42,21 @@ ColorLayerD3D10::RenderLayer() ID3D10EffectTechnique *technique = SelectShader(SHADER_SOLID | LoadMaskTexture()); - nsIntRect bounds = GetBounds(); + nsIntRegionRectIterator iter(mVisibleRegion); - effect()->GetVariableByName("vLayerQuad")->AsVector()->SetFloatVector( - ShaderConstantRectD3D10( - (float)bounds.x, - (float)bounds.y, - (float)bounds.width, - (float)bounds.height) - ); + const nsIntRect *iterRect; + while ((iterRect = iter.Next())) { + effect()->GetVariableByName("vLayerQuad")->AsVector()->SetFloatVector( + ShaderConstantRectD3D10( + (float)iterRect->x, + (float)iterRect->y, + (float)iterRect->width, + (float)iterRect->height) + ); - technique->GetPassByIndex(0)->Apply(0); - device()->Draw(4, 0); + technique->GetPassByIndex(0)->Apply(0); + device()->Draw(4, 0); + } } } /* layers */ diff --git a/gfx/layers/d3d9/ColorLayerD3D9.cpp b/gfx/layers/d3d9/ColorLayerD3D9.cpp index 1782a133d97..e959cf18840 100644 --- a/gfx/layers/d3d9/ColorLayerD3D9.cpp +++ b/gfx/layers/d3d9/ColorLayerD3D9.cpp @@ -23,14 +23,14 @@ RenderColorLayerD3D9(ColorLayer* aLayer, LayerManagerD3D9 *aManager) return; } - nsIntRect bounds = aLayer->GetBounds(); + nsIntRect visibleRect = aLayer->GetEffectiveVisibleRegion().GetBounds(); aManager->device()->SetVertexShaderConstantF( CBvLayerQuad, - ShaderConstantRect(bounds.x, - bounds.y, - bounds.width, - bounds.height), + ShaderConstantRect(visibleRect.x, + visibleRect.y, + visibleRect.width, + visibleRect.height), 1); const gfx3DMatrix& transform = aLayer->GetEffectiveTransform(); diff --git a/gfx/layers/ipc/LayerTransaction.ipdlh b/gfx/layers/ipc/LayerTransaction.ipdlh index 5f7ebed1add..763f9d611b7 100644 --- a/gfx/layers/ipc/LayerTransaction.ipdlh +++ b/gfx/layers/ipc/LayerTransaction.ipdlh @@ -203,7 +203,7 @@ struct ContainerLayerAttributes { float inheritedXScale; float inheritedYScale; }; -struct ColorLayerAttributes { LayerColor color; nsIntRect bounds; }; +struct ColorLayerAttributes { LayerColor color; }; struct CanvasLayerAttributes { GraphicsFilterType filter; nsIntRect bounds; }; struct RefLayerAttributes { int64_t id; }; struct ImageLayerAttributes { GraphicsFilterType filter; gfxIntSize scaleToSize; ScaleMode scaleMode; }; diff --git a/gfx/layers/ipc/LayerTransactionParent.cpp b/gfx/layers/ipc/LayerTransactionParent.cpp index ca98273d631..b15c7956b10 100644 --- a/gfx/layers/ipc/LayerTransactionParent.cpp +++ b/gfx/layers/ipc/LayerTransactionParent.cpp @@ -299,8 +299,6 @@ LayerTransactionParent::RecvUpdate(const InfallibleTArray& cset, static_cast(layer)->SetColor( specific.get_ColorLayerAttributes().color().value()); - static_cast(layer)->SetBounds( - specific.get_ColorLayerAttributes().bounds()); break; case Specific::TCanvasLayerAttributes: diff --git a/gfx/layers/opengl/ColorLayerOGL.cpp b/gfx/layers/opengl/ColorLayerOGL.cpp index 5f759f20208..f4126fe1908 100644 --- a/gfx/layers/opengl/ColorLayerOGL.cpp +++ b/gfx/layers/opengl/ColorLayerOGL.cpp @@ -20,6 +20,8 @@ RenderColorLayer(ColorLayer* aLayer, LayerManagerOGL *aManager, // XXX we might be able to improve performance by using glClear + nsIntRect visibleRect = aLayer->GetEffectiveVisibleRegion().GetBounds(); + /* Multiply color by the layer opacity, as the shader * ignores layer opacity and expects a final color to * write to the color buffer. This saves a needless @@ -35,7 +37,7 @@ RenderColorLayer(ColorLayer* aLayer, LayerManagerOGL *aManager, ShaderProgramOGL *program = aManager->GetProgram(ColorLayerProgramType, aLayer->GetMaskLayer()); program->Activate(); - program->SetLayerQuadRect(aLayer->GetBounds()); + program->SetLayerQuadRect(visibleRect); program->SetLayerTransform(aLayer->GetEffectiveTransform()); program->SetRenderOffset(aOffset); program->SetRenderColor(color); diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index cc78031848b..c8f0f50f25c 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -1579,9 +1579,15 @@ ContainerState::PopThebesLayerData() colorLayer->SetBaseTransform(data->mLayer->GetBaseTransform()); colorLayer->SetPostScale(data->mLayer->GetPostXScale(), data->mLayer->GetPostYScale()); + // Clip colorLayer to its visible region, since ColorLayers are + // allowed to paint outside the visible region. Here we rely on the + // fact that uniform display items fill rectangles; obviously the + // area to fill must contain the visible region, and because it's + // a rectangle, it must therefore contain the visible region's GetBounds. + // Note that the visible region is already clipped appropriately. nsIntRect visibleRect = data->mVisibleRegion.GetBounds(); - visibleRect.MoveBy(-GetTranslationForThebesLayer(data->mLayer)); - colorLayer->SetBounds(visibleRect); + visibleRect.MoveBy(mParameters.mOffset); + colorLayer->SetClipRect(&visibleRect); layer = colorLayer; }