diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 49253dba06c..4628d0d375c 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -1614,30 +1614,27 @@ AppUnitsPerDevPixel(nsDisplayItem* aItem) * parent's coordinate system */ static void -SetVisibleRegionForLayer(Layer* aLayer, const nsIntRegion& aLayerVisibleRegion, - const nsIntRect& aRestrictToRect) +SetVisibleRegionForLayer(Layer* aLayer, const nsIntRect* aLayerVisibleRect, + const nsIntRect& aOuterVisibleRect) { gfx3DMatrix transform; To3DMatrix(aLayer->GetTransform(), transform); // if 'transform' is not invertible, then nothing will be displayed // for the layer, so it doesn't really matter what we do here - gfxRect itemVisible(aRestrictToRect.x, aRestrictToRect.y, - aRestrictToRect.width, aRestrictToRect.height); - nsIntRect childBounds = aLayerVisibleRegion.GetBounds(); - gfxRect childGfxBounds(childBounds.x, childBounds.y, - childBounds.width, childBounds.height); - gfxRect layerVisible = transform.Inverse().ProjectRectBounds(itemVisible); - layerVisible = layerVisible.Intersect(childGfxBounds); + gfxRect outerVisible(aOuterVisibleRect.x, aOuterVisibleRect.y, + aOuterVisibleRect.width, aOuterVisibleRect.height); + gfxRect layerVisible = transform.Inverse().ProjectRectBounds(outerVisible); layerVisible.RoundOut(); nsIntRect visibleRect; if (!gfxUtils::GfxRectToIntRect(layerVisible, &visibleRect)) { aLayer->SetVisibleRegion(nsIntRegion()); } else { - nsIntRegion rgn; - rgn.And(aLayerVisibleRegion, visibleRect); - aLayer->SetVisibleRegion(rgn); + if (aLayerVisibleRect) { + visibleRect.IntersectRect(visibleRect, *aLayerVisibleRect); + } + aLayer->SetVisibleRegion(nsIntRegion(visibleRect)); } } @@ -2655,7 +2652,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList, } itemVisibleRect.MoveBy(mParameters.mOffset); if (item->SetVisibleRegionOnLayer()) { - SetVisibleRegionForLayer(ownLayer, ownLayer->GetVisibleRegion(), itemVisibleRect); + SetVisibleRegionForLayer(ownLayer, nullptr, itemVisibleRect); } // rounded rectangle clipping using mask layers @@ -3537,7 +3534,7 @@ FrameLayerBuilder::BuildContainerLayerFor(nsDisplayListBuilder* aBuilder, pixBounds.MoveBy(nsIntPoint(scaleParameters.mOffset.x, scaleParameters.mOffset.y)); if (aParameters.mAncestorClipRect && !(aFlags & CONTAINER_NOT_CLIPPED_BY_ANCESTORS)) { - SetVisibleRegionForLayer(containerLayer, nsIntRegion(pixBounds), + SetVisibleRegionForLayer(containerLayer, &pixBounds, *aParameters.mAncestorClipRect); } else { containerLayer->SetVisibleRegion(pixBounds); diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 1fd4507b431..099eafcb592 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -2035,7 +2035,6 @@ nsDisplayBackgroundImage::ConfigureLayer(ImageLayer* aLayer, const nsIntPoint& a transform.Scale(mDestRect.width/imageSize.width, mDestRect.height/imageSize.height); aLayer->SetBaseTransform(gfx::Matrix4x4::From2D(transform)); - aLayer->SetVisibleRegion(nsIntRect(0, 0, imageSize.width, imageSize.height)); } void diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index 202ab118f88..384ed0ab03b 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -2635,6 +2635,12 @@ public: return &mList; } virtual nsDisplayList* GetChildren() MOZ_OVERRIDE { return &mList; } + /** + * All our subclasses BuildLayers call + * FrameLayerBuilder::BuildContainerLayerFor, which + * sets the visible region of the layer correctly. + */ + virtual bool SetVisibleRegionOnLayer() { return false; } virtual int32_t ZIndex() const MOZ_OVERRIDE { @@ -2903,8 +2909,6 @@ public: nsRegion* aVisibleRegion, const nsRect& aAllowVisibleRegionExpansion) MOZ_OVERRIDE; - virtual bool SetVisibleRegionOnLayer() MOZ_OVERRIDE { return !(mFlags & GENERATE_SCROLLABLE_LAYER); } - virtual bool ShouldBuildLayerEvenIfInvisible(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE; virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder, bool* aSnap) MOZ_OVERRIDE; @@ -3040,8 +3044,6 @@ public: virtual nsIFrame* GetScrollFrame() { return mScrollFrame; } virtual nsIFrame* GetScrolledFrame() { return mScrolledFrame; } - virtual bool SetVisibleRegionOnLayer() MOZ_OVERRIDE { return false; } - #ifdef MOZ_DUMP_PAINTING virtual void WriteDebugInfo(nsACString& aTo) MOZ_OVERRIDE; #endif @@ -3421,8 +3423,6 @@ public: bool aLogAnimations = false); bool CanUseAsyncAnimations(nsDisplayListBuilder* aBuilder) MOZ_OVERRIDE; - virtual bool SetVisibleRegionOnLayer() MOZ_OVERRIDE { return false; } - #ifdef MOZ_DUMP_PAINTING virtual void WriteDebugInfo(nsACString& aTo) MOZ_OVERRIDE; #endif diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp index 4b6137eaaa5..c7b957720e0 100644 --- a/layout/generic/nsHTMLCanvasFrame.cpp +++ b/layout/generic/nsHTMLCanvasFrame.cpp @@ -271,7 +271,6 @@ nsHTMLCanvasFrame::BuildLayer(nsDisplayListBuilder* aBuilder, transform.Scale(r.Width()/canvasSize.width, r.Height()/canvasSize.height); layer->SetBaseTransform(gfx::Matrix4x4::From2D(transform)); layer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(this)); - layer->SetVisibleRegion(nsIntRect(0, 0, canvasSize.width, canvasSize.height)); return layer.forget(); } diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index d285a76b933..b66a9fa3528 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1425,7 +1425,6 @@ nsDisplayImage::ConfigureLayer(ImageLayer *aLayer, const nsIntPoint& aOffset) transform.Scale(destRect.Width()/imageWidth, destRect.Height()/imageHeight); aLayer->SetBaseTransform(gfx::Matrix4x4::From2D(transform)); - aLayer->SetVisibleRegion(nsIntRect(0, 0, imageWidth, imageHeight)); } void diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 665052143ca..68bedf0f1ee 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -1612,7 +1612,6 @@ nsObjectFrame::BuildLayer(nsDisplayListBuilder* aBuilder, transform.Translate(p.x, p.y); layer->SetBaseTransform(Matrix4x4::From2D(transform)); - layer->SetVisibleRegion(ThebesIntRect(IntRect(IntPoint(0, 0), size))); return layer.forget(); } diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index ce5377baccf..a3cf2a1015a 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -219,7 +219,6 @@ nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder, transform.Translate(p.x, p.y); transform.Scale(r.Width()/frameSize.width, r.Height()/frameSize.height); layer->SetBaseTransform(gfx::Matrix4x4::From2D(transform)); - layer->SetVisibleRegion(nsIntRect(0, 0, frameSize.width, frameSize.height)); nsRefPtr result = layer.forget(); return result.forget(); } diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index 10211ab9430..aad641feac4 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -873,7 +873,6 @@ RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder, } static_cast(layer.get())->SetReferentId(id); nsIntPoint offset = GetContentRectLayerOffset(aFrame, aBuilder); - layer->SetVisibleRegion(aVisibleRect - offset); // We can only have an offset if we're a child of an inactive // container, but our display item is LAYER_ACTIVE_FORCE which // forces all layers above to be active. @@ -926,7 +925,6 @@ RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder, mBackgroundColor, aManager, aFrame); } - mContainer->SetVisibleRegion(aVisibleRect); return nsRefPtr(mContainer).forget(); } diff --git a/layout/xul/nsImageBoxFrame.cpp b/layout/xul/nsImageBoxFrame.cpp index 41be366af77..c35bf63ff72 100644 --- a/layout/xul/nsImageBoxFrame.cpp +++ b/layout/xul/nsImageBoxFrame.cpp @@ -406,8 +406,6 @@ nsDisplayXULImage::ConfigureLayer(ImageLayer* aLayer, const nsIntPoint& aOffset) transform.Scale(destRect.Width()/imageWidth, destRect.Height()/imageHeight); aLayer->SetBaseTransform(gfx::Matrix4x4::From2D(transform)); - - aLayer->SetVisibleRegion(nsIntRect(0, 0, imageWidth, imageHeight)); } already_AddRefed