Bug 1378602 - Part3. Add OMTA support for nsDisplayTransform and nsDisplayOpacity. r=kats
MozReview-Commit-ID: CP4WEZgy83a
--- a/gfx/layers/wr/WebRenderUserData.cpp
+++ b/gfx/layers/wr/WebRenderUserData.cpp
@@ -164,10 +164,16 @@ WebRenderFallbackData::GetGeometry()
}
void
WebRenderFallbackData::SetGeometry(nsAutoPtr<nsDisplayItemGeometry> aGeometry)
{
mGeometry = aGeometry;
}
+WebRenderAnimationData::WebRenderAnimationData(WebRenderLayerManager* aWRManager)
+ : WebRenderUserData(aWRManager),
+ mAnimationInfo(aWRManager)
+{
+}
+
} // namespace layers
} // namespace mozilla
--- a/gfx/layers/wr/WebRenderUserData.h
+++ b/gfx/layers/wr/WebRenderUserData.h
@@ -3,16 +3,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GFX_WEBRENDERUSERDATA_H
#define GFX_WEBRENDERUSERDATA_H
#include "mozilla/layers/StackingContextHelper.h"
#include "mozilla/webrender/WebRenderAPI.h"
+#include "mozilla/layers/AnimationInfo.h"
class nsDisplayItemGeometry;
namespace mozilla {
namespace layers {
class ImageClient;
class ImageContainer;
class WebRenderBridgeChild;
@@ -28,16 +29,17 @@ public:
: mWRManager(aWRManager)
{ }
virtual WebRenderImageData* AsImageData() { return nullptr; }
enum class UserDataType {
eImage,
eFallback,
+ eAnimation,
};
virtual UserDataType GetType() = 0;
protected:
virtual ~WebRenderUserData() {}
WebRenderBridgeChild* WrBridge() const;
@@ -95,12 +97,26 @@ public:
nsRect GetBounds() { return mBounds; }
void SetBounds(const nsRect& aRect) { mBounds = aRect; }
protected:
nsAutoPtr<nsDisplayItemGeometry> mGeometry;
nsRect mBounds;
};
+class WebRenderAnimationData : public WebRenderUserData
+{
+public:
+ explicit WebRenderAnimationData(WebRenderLayerManager* aWRManager);
+ virtual ~WebRenderAnimationData() {}
+
+ virtual UserDataType GetType() override { return UserDataType::eAnimation; }
+ static UserDataType Type() { return UserDataType::eAnimation; }
+ AnimationInfo& GetAnimationInfo() { return mAnimationInfo; }
+
+protected:
+ AnimationInfo mAnimationInfo;
+};
+
} // namespace layers
} // namespace mozilla
#endif /* GFX_WEBRENDERUSERDATA_H */
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -6054,26 +6054,45 @@ nsDisplayOpacity::CreateWebRenderCommand
{
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();
-
- // TODO: generate animationsId for OMTA.
+ float* opacityForSC = &mOpacity;
+
+ RefPtr<WebRenderAnimationData> animationData = aManager->CreateOrRecycleWebRenderUserData<WebRenderAnimationData>(this);
+ AnimationInfo& animationInfo = animationData->GetAnimationInfo();
+ AddAnimationsForProperty(Frame(), aDisplayListBuilder,
+ this, eCSSProperty_opacity,
+ animationInfo, false);
+ animationInfo.StartPendingAnimations(aManager->GetAnimationReadyTime());
uint64_t animationsId = 0;
+
+ if (gfxPrefs::WebRenderOMTAEnabled() &&
+ !animationInfo.GetAnimations().IsEmpty()) {
+ animationsId = animationInfo.GetCompositorAnimationsId();
+ opacityForSC = nullptr;
+ OptionalOpacity opacityForCompositor = mOpacity;
+
+ OpAddCompositorAnimations
+ anim(CompositorAnimations(animationInfo.GetAnimations(), animationsId),
+ void_t(), opacityForCompositor);
+ aManager->WrBridge()->AddWebRenderParentCommand(anim);
+ }
+
nsTArray<WrFilterOp> filters;
StackingContextHelper sc(aSc,
aBuilder,
bounds,
origin,
animationsId,
- &mOpacity,
+ opacityForSC,
nullptr,
filters);
aManager->CreateWebRenderCommandsFromDisplayList(&mList,
aDisplayListBuilder,
sc,
aBuilder);
return true;
@@ -7604,18 +7623,44 @@ nsDisplayTransform::CreateWebRenderComma
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.
+ RefPtr<WebRenderAnimationData> animationData = aManager->CreateOrRecycleWebRenderUserData<WebRenderAnimationData>(this);
+
+ AnimationInfo& animationInfo = animationData->GetAnimationInfo();
+ AddAnimationsForProperty(Frame(), aDisplayListBuilder,
+ this, eCSSProperty_transform,
+ animationInfo, false);
+ animationInfo.StartPendingAnimations(aManager->GetAnimationReadyTime());
uint64_t animationsId = 0;
+
+ if (gfxPrefs::WebRenderOMTAEnabled() &&
+ !animationInfo.GetAnimations().IsEmpty()) {
+ animationsId = animationInfo.GetCompositorAnimationsId();
+
+ // Update transfrom as nullptr in stacking context if there exists
+ // transform animation, the transform value will be resolved
+ // after animation sampling on the compositor
+ transformForSC = nullptr;
+
+ // Pass default transform to compositor in case gecko fails to
+ // get animated value after animation sampling.
+ OptionalTransform transformForCompositor = newTransformMatrix;
+
+ OpAddCompositorAnimations
+ anim(CompositorAnimations(animationInfo.GetAnimations(), animationsId),
+ transformForCompositor, void_t());
+ aManager->WrBridge()->AddWebRenderParentCommand(anim);
+ }
+
nsTArray<WrFilterOp> filters;
StackingContextHelper sc(aSc,
aBuilder,
bounds,
origin,
animationsId,
nullptr,
transformForSC,