Bug 1364525 - Ensure all scroll thumbs have an animations id. r=pchang

In order to have the scrollbar thumbs reflect the async scroll position, we're
going to re-use the API for OMTA. That is, we set an animation id on the
stacking context for the scroll thumb, and we'll update the transform on the
stacking context at composite time based on the async scroll position. For this
to work we need to ensure that the scroll thumb does in fact have an
animation id set on it.

MozReview-Commit-ID: 6TvRemxRUrR
This commit is contained in:
Kartikaya Gupta 2017-05-23 10:50:41 -04:00
Родитель cf3f50ea30
Коммит cd79f50c8d
3 изменённых файлов: 29 добавлений и 3 удалений

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

@ -205,14 +205,20 @@ Layer::~Layer()
{
}
void
Layer::EnsureAnimationsId()
{
if (!mCompositorAnimationsId) {
mCompositorAnimationsId = AnimationHelper::GetNextCompositorAnimationsId();
}
}
Animation*
Layer::AddAnimation()
{
// Here generates a new id when the first animation is added and
// this id is used to represent the animations in this layer.
if (!mCompositorAnimationsId) {
mCompositorAnimationsId = AnimationHelper::GetNextCompositorAnimationsId();
}
EnsureAnimationsId();
MOZ_LAYERS_LOG_IF_SHADOWABLE(
this, ("Layer::Mutated(%p) AddAnimation with id=%" PRIu64, this, mCompositorAnimationsId));

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

@ -1223,6 +1223,9 @@ public:
}
}
// Ensure that this layer has a valid (non-zero) animations id. This value is
// unique across layers.
void EnsureAnimationsId();
// Call AddAnimation to add a new animation to this layer from layout code.
// Caller must fill in all the properties of the returned animation.
// A later animation overrides an earlier one.

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

@ -90,6 +90,23 @@ WebRenderContainerLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
WrBridge()->AddWebRenderParentCommand(anim);
}
// If APZ is enabled and this layer is a scroll thumb, then it might need
// to move in the compositor to represent the async scroll position. So we
// ensure that there is an animations id set on it, we will use this to give
// WebRender updated transforms for composition.
if (WrManager()->AsyncPanZoomEnabled() &&
GetScrollThumbData().mDirection != ScrollDirection::NONE) {
// A scroll thumb better not have a transform animation already or we're
// going to end up clobbering it with APZ animating it too.
MOZ_ASSERT(transformForSC);
EnsureAnimationsId();
animationsId = GetCompositorAnimationsId();
// We need to set the transform in the stacking context to null for it to
// pick up and install the animation id.
transformForSC = nullptr;
}
ScrollingLayersHelper scroller(this, aBuilder, aSc);
StackingContextHelper sc(aSc, aBuilder, this, animationsId, opacityForSC, transformForSC);