Bug 1372118 - Part3. Implement CreateWebRenderCommands for text, transform and background color. r=jrmuizel, r=kats

MozReview-Commit-ID: JRoSjygSFHc
This commit is contained in:
Ethan Lin
2017-06-30 17:23:20 -07:00
parent 596418d7bd
commit e03c8c6a53
5 changed files with 170 additions and 1 deletions

View File

@@ -4148,6 +4148,35 @@ nsDisplayBackgroundColor::BuildLayer(nsDisplayListBuilder* aBuilder,
return layer.forget();
}
bool
nsDisplayBackgroundColor::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
const StackingContextHelper& aSc,
nsTArray<WebRenderParentCommand>& aParentCommands,
mozilla::layers::WebRenderLayerManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder)
{
if (aManager->IsLayersFreeTransaction()) {
ContainerLayerParameters parameter;
if (GetLayerState(aDisplayListBuilder, aManager, parameter) != LAYER_ACTIVE) {
return false;
}
}
if (mColor == Color()) {
return true;
}
LayoutDeviceRect bounds = LayoutDeviceRect::FromAppUnits(
mBackgroundRect, mFrame->PresContext()->AppUnitsPerDevPixel());
WrRect transformedRect = aSc.ToRelativeWrRect(bounds);
aBuilder.PushRect(transformedRect,
transformedRect,
wr::ToWrColor(ToDeviceColor(mColor)));
return true;
}
void
nsDisplayBackgroundColor::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx)
@@ -7536,6 +7565,59 @@ nsDisplayTransform::ShouldBuildLayerEvenIfInvisible(nsDisplayListBuilder* aBuild
return MayBeAnimated(aBuilder) || mFrame->Combines3DTransformWithAncestors();
}
bool
nsDisplayTransform::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
const StackingContextHelper& aSc,
nsTArray<WebRenderParentCommand>& aParentCommands,
WebRenderLayerManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder)
{
Matrix4x4 newTransformMatrix = GetTransformForRendering();
gfx::Matrix4x4* transformForSC = &newTransformMatrix;
if (newTransformMatrix.IsIdentity()) {
// If the transform is an identity transform, strip it out so that WR
// doesn't turn this stacking context into a reference frame, as it
// affects positioning. Bug 1345577 tracks a better fix.
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()));
}
// TODO: generate animationsId for OMTA.
uint64_t animationsId = 0;
nsTArray<WrFilterOp> filters;
StackingContextHelper sc(aSc,
aBuilder,
bounds,
origin,
animationsId,
nullptr,
transformForSC,
filters);
aManager->CreateWebRenderCommandsFromDisplayList(mStoredList.GetChildren(),
aDisplayListBuilder,
sc,
aBuilder);
return true;
}
already_AddRefed<Layer> nsDisplayTransform::BuildLayer(nsDisplayListBuilder *aBuilder,
LayerManager *aManager,
const ContainerLayerParameters& aContainerParameters)