Bug 1386553 - Move boundary calculations from each item's CreateWebRenderCommands to StackingContextHelper constructor. r=kats

MozReview-Commit-ID: 7PJIghki2g2

--HG--
extra : rebase_source : cc54e11719239814eee6f6e6f7360fbc0d10f0ad
This commit is contained in:
Ethan Lin 2017-08-03 17:41:41 +08:00
Родитель b680d61073
Коммит 2f3e874c80
3 изменённых файлов: 67 добавлений и 75 удалений

Просмотреть файл

@ -7,6 +7,7 @@
#include "mozilla/layers/WebRenderLayer.h"
#include "UnitTransforms.h"
#include "nsDisplayList.h"
namespace mozilla {
namespace layers {
@ -17,33 +18,6 @@ StackingContextHelper::StackingContextHelper()
// mOrigin remains at 0,0
}
StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParentSC,
wr::DisplayListBuilder& aBuilder,
LayerRect aBoundForSC,
LayerPoint aOrigin,
uint64_t aAnimationsId,
float* aOpacityPtr,
gfx::Matrix4x4* aTransformPtr,
const nsTArray<wr::WrFilterOp>& aFilters,
const gfx::CompositionOp& aMixBlendMode)
: mBuilder(&aBuilder)
{
wr::LayoutRect scBounds = aParentSC.ToRelativeLayoutRect(aBoundForSC);
if (aTransformPtr) {
mTransform = *aTransformPtr;
}
mBuilder->PushStackingContext(scBounds,
aAnimationsId,
aOpacityPtr,
aTransformPtr,
wr::TransformStyle::Flat,
wr::ToMixBlendMode(aMixBlendMode),
aFilters);
mOrigin = aOrigin;
}
StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParentSC,
wr::DisplayListBuilder& aBuilder,
WebRenderLayer* aLayer,
@ -88,6 +62,47 @@ StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParen
mOrigin = aLayer->Bounds().TopLeft();
}
StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParentSC,
wr::DisplayListBuilder& aBuilder,
nsDisplayListBuilder* aDisplayListBuilder,
nsDisplayItem* aItem,
nsDisplayList* aDisplayList,
gfx::Matrix4x4Typed<LayerPixel, LayerPixel>* aBoundTransform,
uint64_t aAnimationsId,
float* aOpacityPtr,
gfx::Matrix4x4* aTransformPtr,
const nsTArray<wr::WrFilterOp>& aFilters,
const gfx::CompositionOp& aMixBlendMode)
: mBuilder(&aBuilder)
{
nsRect itemBounds = aDisplayList->GetClippedBoundsWithRespectToASR(aDisplayListBuilder, aItem->GetActiveScrolledRoot());
nsRect childrenVisible = aItem->GetVisibleRectForChildren();
nsRect visibleRect = itemBounds.Intersect(childrenVisible);
float appUnitsPerDevPixel = aItem->Frame()->PresContext()->AppUnitsPerDevPixel();
LayerRect bounds = ViewAs<LayerPixel>(LayoutDeviceRect::FromAppUnits(visibleRect, appUnitsPerDevPixel),
PixelCastJustification::WebRenderHasUnitResolution);
// WR will only apply the 'translate' of the transform, so we need to do the scale/rotation manually.
if (aBoundTransform && !aBoundTransform->IsIdentity()) {
bounds.MoveTo(aBoundTransform->TransformPoint(bounds.TopLeft()));
}
wr::LayoutRect scBounds = aParentSC.ToRelativeLayoutRect(bounds);
if (aTransformPtr) {
mTransform = *aTransformPtr;
}
mBuilder->PushStackingContext(scBounds,
aAnimationsId,
aOpacityPtr,
aTransformPtr,
wr::TransformStyle::Flat,
wr::ToMixBlendMode(aMixBlendMode),
aFilters);
mOrigin = bounds.TopLeft();
}
StackingContextHelper::~StackingContextHelper()
{
if (mBuilder) {

Просмотреть файл

@ -12,6 +12,10 @@
#include "mozilla/webrender/WebRenderTypes.h"
#include "Units.h"
class nsDisplayListBuilder;
class nsDisplayItem;
class nsDisplayList;
namespace mozilla {
namespace layers {
@ -45,8 +49,10 @@ public:
// The constructor for layers-free mode.
StackingContextHelper(const StackingContextHelper& aParentSC,
wr::DisplayListBuilder& aBuilder,
LayerRect aBoundForSC,
LayerPoint aOrigin,
nsDisplayListBuilder* aDisplayListBuilder,
nsDisplayItem* aItem,
nsDisplayList* aDisplayList,
gfx::Matrix4x4Typed<LayerPixel, LayerPixel>* aBoundTransform,
uint64_t aAnimationsId,
float* aOpacityPtr,
gfx::Matrix4x4* aTransformPtr,

Просмотреть файл

@ -6118,13 +6118,6 @@ nsDisplayOpacity::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuil
mozilla::layers::WebRenderLayerManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder)
{
nsRect itemBounds = mList.GetClippedBoundsWithRespectToASR(aDisplayListBuilder, mActiveScrolledRoot);
nsRect childrenVisible = GetVisibleRectForChildren();
nsRect visibleRect = itemBounds.Intersect(childrenVisible);
float appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
LayerRect bounds = ViewAs<LayerPixel>(LayoutDeviceRect::FromAppUnits(visibleRect, appUnitsPerDevPixel),
PixelCastJustification::WebRenderHasUnitResolution);
LayerPoint origin = bounds.TopLeft();
float* opacityForSC = &mOpacity;
RefPtr<WebRenderAnimationData> animationData = aManager->CreateOrRecycleWebRenderUserData<WebRenderAnimationData>(this);
@ -6149,8 +6142,10 @@ nsDisplayOpacity::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuil
nsTArray<mozilla::wr::WrFilterOp> filters;
StackingContextHelper sc(aSc,
aBuilder,
bounds,
origin,
aDisplayListBuilder,
this,
&mList,
nullptr,
animationsId,
opacityForSC,
nullptr,
@ -6203,16 +6198,9 @@ nsDisplayBlendMode::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBu
mozilla::layers::WebRenderLayerManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder)
{
nsRect itemBounds = mList.GetClippedBoundsWithRespectToASR(aDisplayListBuilder, mActiveScrolledRoot);
nsRect childrenVisible = GetVisibleRectForChildren();
nsRect visibleRect = itemBounds.Intersect(childrenVisible);
float appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
LayerRect bounds = ViewAs<LayerPixel>(LayoutDeviceRect::FromAppUnits(visibleRect, appUnitsPerDevPixel),
PixelCastJustification::WebRenderHasUnitResolution);
LayerPoint origin = bounds.TopLeft();
nsTArray<mozilla::wr::WrFilterOp> filters;
StackingContextHelper sc(aSc, aBuilder, bounds, origin, 0, nullptr, nullptr,
StackingContextHelper sc(aSc, aBuilder, aDisplayListBuilder, this,
&mList, nullptr, 0, nullptr, nullptr,
filters, nsCSSRendering::GetGFXBlendMode(mBlendMode));
return nsDisplayWrapList::CreateWebRenderCommands(aBuilder, sc, aParentCommands,
@ -6336,15 +6324,8 @@ nsDisplayBlendContainer::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder
mozilla::layers::WebRenderLayerManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder)
{
nsRect itemBounds = mList.GetClippedBoundsWithRespectToASR(aDisplayListBuilder, mActiveScrolledRoot);
nsRect childrenVisible = GetVisibleRectForChildren();
nsRect visibleRect = itemBounds.Intersect(childrenVisible);
float appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
LayerRect bounds = ViewAs<LayerPixel>(LayoutDeviceRect::FromAppUnits(visibleRect, appUnitsPerDevPixel),
PixelCastJustification::WebRenderHasUnitResolution);
LayerPoint origin = bounds.TopLeft();
StackingContextHelper sc(aSc, aBuilder, bounds, origin, 0, nullptr, nullptr);
StackingContextHelper sc(aSc, aBuilder, aDisplayListBuilder, this,
&mList, nullptr, 0, nullptr, nullptr);
return nsDisplayWrapList::CreateWebRenderCommands(aBuilder, sc, aParentCommands,
aManager, aDisplayListBuilder);
@ -7791,23 +7772,6 @@ nsDisplayTransform::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBu
transformForSC = nullptr;
}
nsRect itemBounds = mStoredList.GetChildren()->GetClippedBoundsWithRespectToASR(aDisplayListBuilder, mActiveScrolledRoot);
nsRect childrenVisible = GetVisibleRectForChildren();
nsRect visibleRect = itemBounds.Intersect(childrenVisible);
float appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
LayerRect bounds = ViewAs<LayerPixel>(LayoutDeviceRect::FromAppUnits(visibleRect, appUnitsPerDevPixel),
PixelCastJustification::WebRenderHasUnitResolution);
LayerPoint origin = bounds.TopLeft();
gfx::Matrix4x4Typed<LayerPixel, LayerPixel> boundTransform = ViewAs< gfx::Matrix4x4Typed<LayerPixel, LayerPixel> >(newTransformMatrix);
boundTransform._41 = 0.0f;
boundTransform._42 = 0.0f;
boundTransform._43 = 0.0f;
if (!boundTransform.IsIdentity()) {
// WR will only apply the 'translate' of the transform, so we need to do the scale/rotation manually.
bounds.MoveTo(boundTransform.TransformPoint(bounds.TopLeft()));
}
RefPtr<WebRenderAnimationData> animationData = aManager->CreateOrRecycleWebRenderUserData<WebRenderAnimationData>(this);
AnimationInfo& animationInfo = animationData->GetAnimationInfo();
@ -7835,11 +7799,18 @@ nsDisplayTransform::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBu
aManager->WrBridge()->AddWebRenderParentCommand(anim);
}
gfx::Matrix4x4Typed<LayerPixel, LayerPixel> boundTransform = ViewAs< gfx::Matrix4x4Typed<LayerPixel, LayerPixel> >(newTransformMatrix);
boundTransform._41 = 0.0f;
boundTransform._42 = 0.0f;
boundTransform._43 = 0.0f;
nsTArray<mozilla::wr::WrFilterOp> filters;
StackingContextHelper sc(aSc,
aBuilder,
bounds,
origin,
aDisplayListBuilder,
this,
mStoredList.GetChildren(),
&boundTransform,
animationsId,
nullptr,
transformForSC,