mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1022612. Part 27: Make FrameLayerBuilder responsible for setting all layer visible regions. r=mattwoodrow
Calling Layer::SetVisibleRegion multiple times in a transaction can result in unnecessary IPC traffic. This patch removes Intersect(childGfxBounds). This is only needed to restrict the visible region to something sane for 3D transforms, and this will be fixed up in a later patch. --HG-- extra : rebase_source : 4518bc060fa2c28dacdb7d3aaeca55a148dfe762
This commit is contained in:
parent
b3bb433621
commit
6b9e0b532c
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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<Layer> result = layer.forget();
|
||||
return result.forget();
|
||||
}
|
||||
|
@ -873,7 +873,6 @@ RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||
}
|
||||
static_cast<RefLayer*>(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<Layer>(mContainer).forget();
|
||||
}
|
||||
|
@ -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<ImageContainer>
|
||||
|
Loading…
Reference in New Issue
Block a user