зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 2 changesets (bug 1440966, bug 1438990) for reftest failures e.g. async-scrolling/bg-fixed-child-mask.html==async-scrolling/bg-fixed-child-mask-ref.html on a CLOSED TREE
Backed out changeset 1a8e77cb2c21 (bug 1440966) Backed out changeset 44b5d524c061 (bug 1438990)
This commit is contained in:
Родитель
d72dbac57c
Коммит
32c3cc16ad
|
@ -91,10 +91,11 @@ DisplayItemClip::IntersectWith(const DisplayItemClip& aOther)
|
|||
|
||||
void
|
||||
DisplayItemClip::ApplyTo(gfxContext* aContext,
|
||||
int32_t A2D)
|
||||
int32_t A2D,
|
||||
uint32_t aBegin, uint32_t aEnd)
|
||||
{
|
||||
ApplyRectTo(aContext, A2D);
|
||||
ApplyRoundedRectClipsTo(aContext, A2D, 0, mRoundedClipRects.Length());
|
||||
ApplyRoundedRectClipsTo(aContext, A2D, aBegin, aEnd);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -125,27 +126,30 @@ DisplayItemClip::ApplyRoundedRectClipsTo(gfxContext* aContext,
|
|||
void
|
||||
DisplayItemClip::FillIntersectionOfRoundedRectClips(gfxContext* aContext,
|
||||
const Color& aColor,
|
||||
int32_t aAppUnitsPerDevPixel) const
|
||||
int32_t aAppUnitsPerDevPixel,
|
||||
uint32_t aBegin,
|
||||
uint32_t aEnd) const
|
||||
{
|
||||
DrawTarget& aDrawTarget = *aContext->GetDrawTarget();
|
||||
|
||||
uint32_t end = mRoundedClipRects.Length();
|
||||
if (!end) {
|
||||
aEnd = std::min<uint32_t>(aEnd, mRoundedClipRects.Length());
|
||||
|
||||
if (aBegin >= aEnd) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Push clips for any rects that come BEFORE the rect at |aEnd - 1|, if any:
|
||||
ApplyRoundedRectClipsTo(aContext, aAppUnitsPerDevPixel, 0, end - 1);
|
||||
ApplyRoundedRectClipsTo(aContext, aAppUnitsPerDevPixel, aBegin, aEnd - 1);
|
||||
|
||||
// Now fill the rect at |aEnd - 1|:
|
||||
RefPtr<Path> roundedRect = MakeRoundedRectPath(aDrawTarget,
|
||||
aAppUnitsPerDevPixel,
|
||||
mRoundedClipRects[end - 1]);
|
||||
mRoundedClipRects[aEnd - 1]);
|
||||
ColorPattern color(ToDeviceColor(aColor));
|
||||
aDrawTarget.Fill(roundedRect, color);
|
||||
|
||||
// Finally, pop any clips that we may have pushed:
|
||||
for (uint32_t i = 0; i < end - 1; ++i) {
|
||||
for (uint32_t i = aBegin; i < aEnd - 1; ++i) {
|
||||
aContext->PopClip();
|
||||
}
|
||||
}
|
||||
|
@ -354,13 +358,16 @@ AccumulateRectDifference(const nsRect& aR1, const nsRect& aR2, const nsRect& aBo
|
|||
}
|
||||
|
||||
void
|
||||
DisplayItemClip::AddOffsetAndComputeDifference(const nsPoint& aOffset,
|
||||
DisplayItemClip::AddOffsetAndComputeDifference(uint32_t aStart,
|
||||
const nsPoint& aOffset,
|
||||
const nsRect& aBounds,
|
||||
const DisplayItemClip& aOther,
|
||||
uint32_t aOtherStart,
|
||||
const nsRect& aOtherBounds,
|
||||
nsRegion* aDifference)
|
||||
{
|
||||
if (mHaveClipRect != aOther.mHaveClipRect ||
|
||||
aStart != aOtherStart ||
|
||||
mRoundedClipRects.Length() != aOther.mRoundedClipRects.Length()) {
|
||||
aDifference->Or(*aDifference, aBounds);
|
||||
aDifference->Or(*aDifference, aOtherBounds);
|
||||
|
@ -371,7 +378,7 @@ DisplayItemClip::AddOffsetAndComputeDifference(const nsPoint& aOffset,
|
|||
aBounds.Union(aOtherBounds),
|
||||
aDifference);
|
||||
}
|
||||
for (uint32_t i = 0; i < mRoundedClipRects.Length(); ++i) {
|
||||
for (uint32_t i = aStart; i < mRoundedClipRects.Length(); ++i) {
|
||||
if (mRoundedClipRects[i] + aOffset != aOther.mRoundedClipRects[i]) {
|
||||
// The corners make it tricky so we'll just add both rects here.
|
||||
aDifference->Or(*aDifference, mRoundedClipRects[i].mRect.Intersect(aBounds));
|
||||
|
@ -380,10 +387,27 @@ DisplayItemClip::AddOffsetAndComputeDifference(const nsPoint& aOffset,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
DisplayItemClip::AppendRoundedRects(nsTArray<RoundedRect>* aArray) const
|
||||
uint32_t
|
||||
DisplayItemClip::GetCommonRoundedRectCount(const DisplayItemClip& aOther,
|
||||
uint32_t aMax) const
|
||||
{
|
||||
aArray->AppendElements(mRoundedClipRects.Elements(), mRoundedClipRects.Length());
|
||||
uint32_t end = std::min(std::min(mRoundedClipRects.Length(), size_t(aMax)),
|
||||
aOther.mRoundedClipRects.Length());
|
||||
uint32_t clipCount = 0;
|
||||
for (; clipCount < end; ++clipCount) {
|
||||
if (mRoundedClipRects[clipCount] !=
|
||||
aOther.mRoundedClipRects[clipCount]) {
|
||||
return clipCount;
|
||||
}
|
||||
}
|
||||
return clipCount;
|
||||
}
|
||||
|
||||
void
|
||||
DisplayItemClip::AppendRoundedRects(nsTArray<RoundedRect>* aArray, uint32_t aCount) const
|
||||
{
|
||||
size_t count = std::min(mRoundedClipRects.Length(), size_t(aCount));
|
||||
aArray->AppendElements(mRoundedClipRects.Elements(), count);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -81,7 +81,8 @@ public:
|
|||
// Apply this |DisplayItemClip| to the given gfxContext. Any saving of state
|
||||
// or clearing of other clips must be done by the caller.
|
||||
// See aBegin/aEnd note on ApplyRoundedRectsTo.
|
||||
void ApplyTo(gfxContext* aContext, int32_t A2D);
|
||||
void ApplyTo(gfxContext* aContext, int32_t A2D,
|
||||
uint32_t aBegin = 0, uint32_t aEnd = UINT32_MAX);
|
||||
|
||||
void ApplyRectTo(gfxContext* aContext, int32_t A2D) const;
|
||||
// Applies the rounded rects in this Clip to aContext
|
||||
|
@ -93,7 +94,9 @@ public:
|
|||
// Draw (fill) the rounded rects in this clip to aContext
|
||||
void FillIntersectionOfRoundedRectClips(gfxContext* aContext,
|
||||
const Color& aColor,
|
||||
int32_t aAppUnitsPerDevPixel) const;
|
||||
int32_t aAppUnitsPerDevPixel,
|
||||
uint32_t aBegin,
|
||||
uint32_t aEnd) const;
|
||||
// 'Draw' (create as a path, does not stroke or fill) aRoundRect to aContext
|
||||
already_AddRefed<Path> MakeRoundedRectPath(DrawTarget& aDrawTarget,
|
||||
int32_t A2D,
|
||||
|
@ -145,8 +148,8 @@ public:
|
|||
|
||||
// Adds the difference between Intersect(*this + aPoint, aBounds) and
|
||||
// Intersect(aOther, aOtherBounds) to aDifference (or a bounding-box thereof).
|
||||
void AddOffsetAndComputeDifference(const nsPoint& aPoint, const nsRect& aBounds,
|
||||
const DisplayItemClip& aOther, const nsRect& aOtherBounds,
|
||||
void AddOffsetAndComputeDifference(uint32_t aStart, const nsPoint& aPoint, const nsRect& aBounds,
|
||||
const DisplayItemClip& aOther, uint32_t aOtherStart, const nsRect& aOtherBounds,
|
||||
nsRegion* aDifference);
|
||||
|
||||
bool operator==(const DisplayItemClip& aOther) const {
|
||||
|
@ -169,8 +172,14 @@ public:
|
|||
|
||||
nsCString ToString() const;
|
||||
|
||||
/**
|
||||
* Find the largest N such that the first N rounded rects in 'this' are
|
||||
* equal to the first N rounded rects in aOther, and N <= aMax.
|
||||
*/
|
||||
uint32_t GetCommonRoundedRectCount(const DisplayItemClip& aOther,
|
||||
uint32_t aMax) const;
|
||||
uint32_t GetRoundedRectCount() const { return mRoundedClipRects.Length(); }
|
||||
void AppendRoundedRects(nsTArray<RoundedRect>* aArray) const;
|
||||
void AppendRoundedRects(nsTArray<RoundedRect>* aArray, uint32_t aCount) const;
|
||||
|
||||
void ToComplexClipRegions(int32_t aAppUnitsPerDevPixel,
|
||||
const layers::StackingContextHelper& aSc,
|
||||
|
|
|
@ -449,6 +449,7 @@ public:
|
|||
mShouldPaintOnContentSide(false),
|
||||
mDTCRequiresTargetConfirmation(false),
|
||||
mImage(nullptr),
|
||||
mCommonClipCount(-1),
|
||||
mNewChildLayersIndex(-1)
|
||||
{}
|
||||
|
||||
|
@ -660,10 +661,24 @@ public:
|
|||
* no part at all.
|
||||
*/
|
||||
DisplayItemClip mItemClip;
|
||||
/**
|
||||
* The first mCommonClipCount rounded rectangle clips are identical for
|
||||
* all items in the layer.
|
||||
* -1 if there are no items in the layer; must be >=0 by the time that this
|
||||
* data is popped from the stack.
|
||||
*/
|
||||
int32_t mCommonClipCount;
|
||||
/**
|
||||
* Index of this layer in mNewChildLayers.
|
||||
*/
|
||||
int32_t mNewChildLayersIndex;
|
||||
/*
|
||||
* Updates mCommonClipCount by checking for rounded rect clips in common
|
||||
* between the clip on a new item (aCurrentClip) and the common clips
|
||||
* on items already in the layer (the first mCommonClipCount rounded rects
|
||||
* in mItemClip).
|
||||
*/
|
||||
void UpdateCommonClipCount(const DisplayItemClip& aCurrentClip);
|
||||
/**
|
||||
* The region of visible content above the layer and below the
|
||||
* next PaintedLayerData currently in the stack, if any.
|
||||
|
@ -1370,8 +1385,12 @@ protected:
|
|||
* aLayer is the layer to be clipped.
|
||||
* relative to the container reference frame
|
||||
* aRoundedRectClipCount is used when building mask layers for PaintedLayers,
|
||||
* SetupMaskLayer will build a mask layer for only the first
|
||||
* aRoundedRectClipCount rounded rects in aClip
|
||||
* Returns the number of rounded rects included in the mask layer.
|
||||
*/
|
||||
void SetupMaskLayer(Layer *aLayer, const DisplayItemClip& aClip);
|
||||
uint32_t SetupMaskLayer(Layer *aLayer, const DisplayItemClip& aClip,
|
||||
uint32_t aRoundedRectClipCount = UINT32_MAX);
|
||||
|
||||
/**
|
||||
* If |aClip| has rounded corners, create a mask layer for them, and
|
||||
|
@ -1391,7 +1410,8 @@ protected:
|
|||
|
||||
already_AddRefed<Layer> CreateMaskLayer(
|
||||
Layer *aLayer, const DisplayItemClip& aClip,
|
||||
const Maybe<size_t>& aForAncestorMaskLayer);
|
||||
const Maybe<size_t>& aForAncestorMaskLayer,
|
||||
uint32_t aRoundedRectClipCount = UINT32_MAX);
|
||||
|
||||
/**
|
||||
* Get the display port for an AGR.
|
||||
|
@ -1478,6 +1498,8 @@ class PaintedDisplayItemLayerUserData : public LayerUserData
|
|||
{
|
||||
public:
|
||||
PaintedDisplayItemLayerUserData() :
|
||||
mMaskClipCount(0),
|
||||
mLastCommonClipCount(0),
|
||||
mForcedBackgroundColor(NS_RGBA(0,0,0,0)),
|
||||
mXScale(1.f), mYScale(1.f),
|
||||
mAppUnitsPerDevPixel(0),
|
||||
|
@ -1489,6 +1511,19 @@ public:
|
|||
|
||||
NS_INLINE_DECL_REFCOUNTING(PaintedDisplayItemLayerUserData);
|
||||
|
||||
/**
|
||||
* Record the number of clips in the PaintedLayer's mask layer.
|
||||
* Should not be reset when the layer is recycled since it is used to track
|
||||
* changes in the use of mask layers.
|
||||
*/
|
||||
uint32_t mMaskClipCount;
|
||||
|
||||
/**
|
||||
* Records the number of clips in the PaintedLayer's mask layer during
|
||||
* the previous paint. Used for invalidation.
|
||||
*/
|
||||
uint32_t mLastCommonClipCount;
|
||||
|
||||
/**
|
||||
* A color that should be painted over the bounds of the layer's visible
|
||||
* region before any other content is painted.
|
||||
|
@ -1605,6 +1640,7 @@ struct MaskLayerUserData : public LayerUserData
|
|||
, mAppUnitsPerDevPixel(-1)
|
||||
{ }
|
||||
MaskLayerUserData(const DisplayItemClip& aClip,
|
||||
uint32_t aRoundedRectClipCount,
|
||||
int32_t aAppUnitsPerDevPixel,
|
||||
const ContainerLayerParameters& aParams)
|
||||
: mScaleX(aParams.mXScale)
|
||||
|
@ -1612,7 +1648,7 @@ struct MaskLayerUserData : public LayerUserData
|
|||
, mOffset(aParams.mOffset)
|
||||
, mAppUnitsPerDevPixel(aAppUnitsPerDevPixel)
|
||||
{
|
||||
aClip.AppendRoundedRects(&mRoundedClipRects);
|
||||
aClip.AppendRoundedRects(&mRoundedClipRects, aRoundedRectClipCount);
|
||||
}
|
||||
|
||||
void operator=(MaskLayerUserData&& aOther)
|
||||
|
@ -2011,6 +2047,19 @@ FrameLayerBuilder::DidBeginRetainedLayerTransaction(LayerManager* aManager)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
FrameLayerBuilder::StoreOptimizedLayerForFrame(nsDisplayItem* aItem, Layer* aLayer)
|
||||
{
|
||||
if (!mRetainingManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
DisplayItemData* data = GetDisplayItemDataForManager(aItem, aLayer->Manager());
|
||||
NS_ASSERTION(data, "Must have already stored data for this item!");
|
||||
data->mOptLayer = aLayer;
|
||||
data->mItem = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
FrameLayerBuilder::DidEndTransaction()
|
||||
{
|
||||
|
@ -2451,6 +2500,7 @@ ContainerState::PreparePaintedLayerForUse(PaintedLayer* aLayer,
|
|||
|
||||
aData->mLastPaintOffset = GetTranslationForPaintedLayer(aLayer);
|
||||
aData->mHasExplicitLastPaintOffset = true;
|
||||
aData->mLastCommonClipCount = aData->mMaskClipCount;
|
||||
|
||||
// Set up transform so that 0,0 in the PaintedLayer corresponds to the
|
||||
// (pixel-snapped) top-left of the aAnimatedGeometryRoot.
|
||||
|
@ -2713,6 +2763,18 @@ PaintedLayerDataNode::FindOpaqueBackgroundColorInParentNode() const
|
|||
return mTree.UniformBackgroundColor();
|
||||
}
|
||||
|
||||
void
|
||||
PaintedLayerData::UpdateCommonClipCount(
|
||||
const DisplayItemClip& aCurrentClip)
|
||||
{
|
||||
if (mCommonClipCount >= 0) {
|
||||
mCommonClipCount = mItemClip.GetCommonRoundedRectCount(aCurrentClip, mCommonClipCount);
|
||||
} else {
|
||||
// first item in the layer
|
||||
mCommonClipCount = aCurrentClip.GetRoundedRectCount();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
PaintedLayerData::CanOptimizeToImageLayer(nsDisplayListBuilder* aBuilder)
|
||||
{
|
||||
|
@ -3179,6 +3241,16 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB
|
|||
mNewChildLayers[data->mNewChildLayersIndex].mLayer = paintedLayer.forget();
|
||||
}
|
||||
|
||||
for (auto& item : data->mAssignedDisplayItems) {
|
||||
MOZ_ASSERT(item.mItem->GetType() != DisplayItemType::TYPE_LAYER_EVENT_REGIONS);
|
||||
MOZ_ASSERT(item.mItem->GetType() != DisplayItemType::TYPE_COMPOSITOR_HITTEST_INFO);
|
||||
|
||||
InvalidateForLayerChange(item.mItem, data->mLayer, item.mDisplayItemData);
|
||||
mLayerBuilder->AddPaintedDisplayItem(data, item, *this,
|
||||
data->mAnimatedGeometryRootOffset);
|
||||
item.mDisplayItemData = nullptr;
|
||||
}
|
||||
|
||||
PaintedDisplayItemLayerUserData* userData = GetPaintedDisplayItemLayerUserData(data->mLayer);
|
||||
NS_ASSERTION(userData, "where did our user data go?");
|
||||
userData->mLastItemCount = data->mAssignedDisplayItems.Length();
|
||||
|
@ -3223,6 +3295,10 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB
|
|||
data->mLayer->SetVisibleRegion(LayerIntRegion());
|
||||
data->mLayer->InvalidateWholeLayer();
|
||||
data->mLayer->SetEventRegions(EventRegions());
|
||||
|
||||
for (auto& item : data->mAssignedDisplayItems) {
|
||||
mLayerBuilder->StoreOptimizedLayerForFrame(item.mItem, layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3233,15 +3309,6 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB
|
|||
FLB_LOG_PAINTED_LAYER_DECISION(data, " Selected painted layer=%p\n", layer.get());
|
||||
}
|
||||
|
||||
for (auto& item : data->mAssignedDisplayItems) {
|
||||
MOZ_ASSERT(item.mItem->GetType() != DisplayItemType::TYPE_LAYER_EVENT_REGIONS);
|
||||
MOZ_ASSERT(item.mItem->GetType() != DisplayItemType::TYPE_COMPOSITOR_HITTEST_INFO);
|
||||
|
||||
InvalidateForLayerChange(item.mItem, data->mLayer, item.mDisplayItemData);
|
||||
mLayerBuilder->AddPaintedDisplayItem(data, item, *this, layer);
|
||||
item.mDisplayItemData = nullptr;
|
||||
}
|
||||
|
||||
if (mLayerBuilder->IsBuildingRetainedLayers()) {
|
||||
newLayerEntry->mVisibleRegion = data->mVisibleRegion;
|
||||
newLayerEntry->mOpaqueRegion = data->mOpaqueRegion;
|
||||
|
@ -3294,7 +3361,22 @@ void ContainerState::FinishPaintedLayerData(PaintedLayerData& aData, FindOpaqueB
|
|||
data->mLayer->InvalidateWholeLayer();
|
||||
}
|
||||
userData->mForcedBackgroundColor = backgroundColor;
|
||||
SetupMaskLayer(layer, data->mItemClip);
|
||||
|
||||
// use a mask layer for rounded rect clipping.
|
||||
// data->mCommonClipCount may be -1 if we haven't put any actual
|
||||
// drawable items in this layer (i.e. it's only catching events).
|
||||
uint32_t commonClipCount;
|
||||
commonClipCount = std::max(0, data->mCommonClipCount);
|
||||
|
||||
// if the number of clips we are going to mask has decreased, then aLayer might have
|
||||
// cached graphics which assume the existence of a soon-to-be non-existent mask layer
|
||||
// in that case, invalidate the whole layer.
|
||||
if (commonClipCount < userData->mMaskClipCount) {
|
||||
PaintedLayer* painted = layer->AsPaintedLayer();
|
||||
painted->InvalidateWholeLayer();
|
||||
}
|
||||
|
||||
userData->mMaskClipCount = SetupMaskLayer(layer, data->mItemClip, commonClipCount);
|
||||
} else {
|
||||
// mask layer for image and color layers
|
||||
SetupMaskLayer(layer, data->mItemClip);
|
||||
|
@ -3937,7 +4019,8 @@ ContainerState::SetupMaskLayerForScrolledClip(Layer* aLayer,
|
|||
{
|
||||
if (aClip.GetRoundedRectCount() > 0) {
|
||||
Maybe<size_t> maskLayerIndex = Some(aLayer->GetAncestorMaskLayerCount());
|
||||
if (RefPtr<Layer> maskLayer = CreateMaskLayer(aLayer, aClip, maskLayerIndex)) {
|
||||
if (RefPtr<Layer> maskLayer = CreateMaskLayer(aLayer, aClip, maskLayerIndex,
|
||||
aClip.GetRoundedRectCount())) {
|
||||
aLayer->AddAncestorMaskLayer(maskLayer);
|
||||
return maskLayerIndex;
|
||||
}
|
||||
|
@ -4604,6 +4687,11 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList)
|
|||
static_cast<nsDisplayCompositorHitTestInfo*>(item);
|
||||
paintedLayerData->AccumulateHitTestInfo(this, hitTestInfo);
|
||||
} else {
|
||||
// check to see if the new item has rounded rect clips in common with
|
||||
// other items in the layer
|
||||
if (mManager->IsWidgetLayerManager()) {
|
||||
paintedLayerData->UpdateCommonClipCount(itemClip);
|
||||
}
|
||||
paintedLayerData->Accumulate(this, item, itemVisibleRect, itemClip, layerState, aList);
|
||||
|
||||
if (!paintedLayerData->mLayer) {
|
||||
|
@ -4732,9 +4820,11 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData)
|
|||
if (!combined.IsEmpty() || aData->mLayerState == LAYER_INACTIVE) {
|
||||
geometry = item->AllocateGeometry(mDisplayListBuilder);
|
||||
}
|
||||
aData->mClip.AddOffsetAndComputeDifference(shift, aData->mGeometry->ComputeInvalidationRegion(),
|
||||
clip, geometry ? geometry->ComputeInvalidationRegion() :
|
||||
aData->mGeometry->ComputeInvalidationRegion(),
|
||||
aData->mClip.AddOffsetAndComputeDifference(layerData->mMaskClipCount,
|
||||
shift, aData->mGeometry->ComputeInvalidationRegion(),
|
||||
clip, layerData->mLastCommonClipCount,
|
||||
geometry ? geometry->ComputeInvalidationRegion() :
|
||||
aData->mGeometry->ComputeInvalidationRegion(),
|
||||
&combined);
|
||||
|
||||
// Add in any rect that the frame specified
|
||||
|
@ -4767,7 +4857,7 @@ void
|
|||
FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData,
|
||||
AssignedDisplayItem& aItem,
|
||||
ContainerState& aContainerState,
|
||||
Layer* aLayer)
|
||||
const nsPoint& aTopLeft)
|
||||
{
|
||||
PaintedLayer* layer = aLayerData->mLayer;
|
||||
PaintedDisplayItemLayerUserData* paintedData =
|
||||
|
@ -4783,7 +4873,7 @@ FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData,
|
|||
// We need to grab these before updating the DisplayItemData because it will overwrite them.
|
||||
nsRegion clip;
|
||||
if (aItem.mClip.ComputeRegionInClips(&aItem.mDisplayItemData->GetClip(),
|
||||
aLayerData->mAnimatedGeometryRootOffset - paintedData->mLastAnimatedGeometryRootOrigin,
|
||||
aTopLeft - paintedData->mLastAnimatedGeometryRootOrigin,
|
||||
&clip)) {
|
||||
intClip = clip.GetBounds().ScaleToOutsidePixels(paintedData->mXScale,
|
||||
paintedData->mYScale,
|
||||
|
@ -4805,12 +4895,6 @@ FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData,
|
|||
data = StoreDataForFrame(aItem.mItem, layer, aItem.mLayerState, nullptr);
|
||||
}
|
||||
data->mInactiveManager = tempManager;
|
||||
// We optimized this PaintedLayer into a ColorLayer/ImageLayer. Store the optimized
|
||||
// layer here.
|
||||
if (aLayer != layer) {
|
||||
data->mOptLayer = aLayer;
|
||||
data->mItem = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (tempManager) {
|
||||
|
@ -5224,7 +5308,7 @@ ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry)
|
|||
// layer as an additional, separate clip.
|
||||
Maybe<size_t> nextIndex = Some(maskLayers.Length());
|
||||
RefPtr<Layer> maskLayer =
|
||||
CreateMaskLayer(aEntry->mLayer, *clip, nextIndex);
|
||||
CreateMaskLayer(aEntry->mLayer, *clip, nextIndex, clip->GetRoundedRectCount());
|
||||
if (maskLayer) {
|
||||
MOZ_ASSERT(metadata->HasScrollClip());
|
||||
metadata->ScrollClip().SetMaskLayerIndex(nextIndex);
|
||||
|
@ -5950,7 +6034,8 @@ FrameLayerBuilder::PaintItems(nsTArray<AssignedDisplayItem>& aItems,
|
|||
nsDisplayListBuilder* aBuilder,
|
||||
nsPresContext* aPresContext,
|
||||
const nsIntPoint& aOffset,
|
||||
float aXScale, float aYScale)
|
||||
float aXScale, float aYScale,
|
||||
int32_t aCommonClipCount)
|
||||
{
|
||||
DrawTarget& aDrawTarget = *aContext->GetDrawTarget();
|
||||
|
||||
|
@ -5999,7 +6084,9 @@ FrameLayerBuilder::PaintItems(nsTArray<AssignedDisplayItem>& aItems,
|
|||
if (currentClipIsSetInContext) {
|
||||
currentClip = *clip;
|
||||
aContext->Save();
|
||||
currentClip.ApplyTo(aContext, aPresContext->AppUnitsPerDevPixel());
|
||||
NS_ASSERTION(aCommonClipCount < 100,
|
||||
"Maybe you really do have more than a hundred clipping rounded rects, or maybe something has gone wrong.");
|
||||
currentClip.ApplyTo(aContext, aPresContext->AppUnitsPerDevPixel(), aCommonClipCount);
|
||||
aContext->NewPath();
|
||||
}
|
||||
}
|
||||
|
@ -6162,7 +6249,8 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer,
|
|||
|
||||
layerBuilder->PaintItems(userData->mItems, iterRect, aContext,
|
||||
builder, presContext,
|
||||
offset, userData->mXScale, userData->mYScale);
|
||||
offset, userData->mXScale, userData->mYScale,
|
||||
userData->mMaskClipCount);
|
||||
if (gfxPrefs::GfxLoggingPaintedPixelCountEnabled()) {
|
||||
aLayer->Manager()->AddPaintedPixelCount(iterRect.Area());
|
||||
}
|
||||
|
@ -6177,7 +6265,8 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer,
|
|||
|
||||
layerBuilder->PaintItems(userData->mItems, aRegionToDraw.GetBounds(), aContext,
|
||||
builder, presContext,
|
||||
offset, userData->mXScale, userData->mYScale);
|
||||
offset, userData->mXScale, userData->mYScale,
|
||||
userData->mMaskClipCount);
|
||||
if (gfxPrefs::GfxLoggingPaintedPixelCountEnabled()) {
|
||||
aLayer->Manager()->AddPaintedPixelCount(
|
||||
aRegionToDraw.GetBounds().Area());
|
||||
|
@ -6254,23 +6343,26 @@ CalculateBounds(const nsTArray<DisplayItemClip::RoundedRect>& aRects, int32_t aA
|
|||
return gfx::Rect(bounds.ToNearestPixels(aAppUnitsPerDevPixel));
|
||||
}
|
||||
|
||||
void
|
||||
uint32_t
|
||||
ContainerState::SetupMaskLayer(Layer *aLayer,
|
||||
const DisplayItemClip& aClip)
|
||||
const DisplayItemClip& aClip,
|
||||
uint32_t aRoundedRectClipCount)
|
||||
{
|
||||
// don't build an unnecessary mask
|
||||
if (aClip.GetRoundedRectCount() == 0) {
|
||||
return;
|
||||
if (aClip.GetRoundedRectCount() == 0 ||
|
||||
aRoundedRectClipCount == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
RefPtr<Layer> maskLayer =
|
||||
CreateMaskLayer(aLayer, aClip, Nothing());
|
||||
CreateMaskLayer(aLayer, aClip, Nothing(), aRoundedRectClipCount);
|
||||
|
||||
if (!maskLayer) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
aLayer->SetMaskLayer(maskLayer);
|
||||
return aRoundedRectClipCount;
|
||||
}
|
||||
|
||||
static MaskLayerUserData*
|
||||
|
@ -6295,7 +6387,8 @@ SetMaskLayerUserData(Layer* aMaskLayer)
|
|||
already_AddRefed<Layer>
|
||||
ContainerState::CreateMaskLayer(Layer *aLayer,
|
||||
const DisplayItemClip& aClip,
|
||||
const Maybe<size_t>& aForAncestorMaskLayer)
|
||||
const Maybe<size_t>& aForAncestorMaskLayer,
|
||||
uint32_t aRoundedRectClipCount)
|
||||
{
|
||||
// aLayer will never be the container layer created by an nsDisplayMask
|
||||
// because nsDisplayMask propagates the DisplayItemClip to its contents
|
||||
|
@ -6312,7 +6405,7 @@ ContainerState::CreateMaskLayer(Layer *aLayer,
|
|||
MaskLayerUserData* userData = GetMaskLayerUserData(maskLayer.get());
|
||||
|
||||
int32_t A2D = mContainerFrame->PresContext()->AppUnitsPerDevPixel();
|
||||
MaskLayerUserData newData(aClip, A2D, mParameters);
|
||||
MaskLayerUserData newData(aClip, aRoundedRectClipCount, A2D, mParameters);
|
||||
if (*userData == newData) {
|
||||
return maskLayer.forget();
|
||||
}
|
||||
|
@ -6392,7 +6485,9 @@ ContainerState::CreateMaskLayer(Layer *aLayer,
|
|||
// paint the clipping rects with alpha to create the mask
|
||||
aClip.FillIntersectionOfRoundedRectClips(context,
|
||||
Color(1.f, 1.f, 1.f, 1.f),
|
||||
newData.mAppUnitsPerDevPixel);
|
||||
newData.mAppUnitsPerDevPixel,
|
||||
0,
|
||||
aRoundedRectClipCount);
|
||||
|
||||
// build the image and container
|
||||
MOZ_ASSERT(aLayer->Manager() == mManager);
|
||||
|
|
|
@ -510,10 +510,10 @@ public:
|
|||
* aItem must have an underlying frame.
|
||||
* @param aTopLeft offset from active scrolled root to reference frame
|
||||
*/
|
||||
void AddPaintedDisplayItem(PaintedLayerData* aLayerData,
|
||||
void AddPaintedDisplayItem(PaintedLayerData* aLayer,
|
||||
AssignedDisplayItem& aAssignedDisplayItem,
|
||||
ContainerState& aContainerState,
|
||||
Layer* aLayer);
|
||||
const nsPoint& aTopLeft);
|
||||
|
||||
/**
|
||||
* Calls GetOldLayerForFrame on the underlying frame of the display item,
|
||||
|
@ -590,6 +590,14 @@ public:
|
|||
*/
|
||||
static gfxSize GetPaintedLayerScaleForFrame(nsIFrame* aFrame);
|
||||
|
||||
/**
|
||||
* Stores a Layer as the dedicated layer in the DisplayItemData for a given frame/key pair.
|
||||
*
|
||||
* Used when we optimize a PaintedLayer into an ImageLayer and want to retroactively update the
|
||||
* DisplayItemData so we can retrieve the layer from within layout.
|
||||
*/
|
||||
void StoreOptimizedLayerForFrame(nsDisplayItem* aItem, Layer* aLayer);
|
||||
|
||||
static void RemoveFrameFromLayerManager(const nsIFrame* aFrame,
|
||||
SmallPointerArray<DisplayItemData>& aArray);
|
||||
|
||||
|
@ -666,7 +674,8 @@ protected:
|
|||
nsDisplayListBuilder* aBuilder,
|
||||
nsPresContext* aPresContext,
|
||||
const nsIntPoint& aOffset,
|
||||
float aXScale, float aYScale);
|
||||
float aXScale, float aYScale,
|
||||
int32_t aCommonClipCount);
|
||||
|
||||
/**
|
||||
* We accumulate ClippedDisplayItem elements in a hashtable during
|
||||
|
|
Загрузка…
Ссылка в новой задаче