Bug 1699890 - Forcibly create a display item for backgroud-color animations even if it's transparent at the moment. r=boris,miko

Otherwise we keep restyling for the animations on the main thread and trying
to create display items for them.

Differential Revision: https://phabricator.services.mozilla.com/D115441
This commit is contained in:
Hiroyuki Ikezoe 2021-05-25 01:58:19 +00:00
Родитель 9a5d9feeba
Коммит 6b494767d9
5 изменённых файлов: 42 добавлений и 18 удалений

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

@ -1050,9 +1050,10 @@ promise_test(async t => {
await waitForAnimationReadyToRestyle(animation);
await waitForPaints();
assert_animation_is_not_running_on_compositor(animation,
'Opaque background image stops background-color animations from running ' +
'on the compositor');
// Bug 1712246. We should optimize this case eventually.
//assert_animation_is_not_running_on_compositor(animation,
// 'Opaque background image stops background-color animations from running ' +
// 'on the compositor');
}, 'Opaque background image stops background-color animations from running ' +
' on the compositor');

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

@ -2122,6 +2122,27 @@ waitForAllPaints(() => {
'should not be throttled if root is animating opacity');
await ensureElementRemoval(container);
});
add_task_if_omta_enabled(async function transparent_background_color_animations() {
const div = addDiv(null);
const animation =
div.animate({ backgroundColor: [ 'rgb(0, 200, 0, 0)',
'rgb(200, 0, 0, 0.1)' ] },
{ duration: 100 * MS_PER_SEC,
// An easing function producing zero in the first half of
// the duration.
easing: 'cubic-bezier(1, 0, 1, 0)' });
await waitForAnimationReadyToRestyle(animation);
ok(SpecialPowers.wrap(animation).isRunningOnCompositor);
const markers = await observeStyling(5);
is(markers.length, 0,
'transparent background-color animation should not update styles on ' +
'the main thread');
await ensureElementRemoval(div);
});
});
</script>

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

@ -2559,7 +2559,12 @@ bool nsIFrame::DisplayBackgroundUnconditional(nsDisplayListBuilder* aBuilder,
// true.
if (hitTesting || aForceBackground ||
!StyleBackground()->IsTransparent(this) ||
StyleDisplay()->HasAppearance()) {
StyleDisplay()->HasAppearance() ||
// We do forcibly create a display item for background color animations
// even if the current background-color is transparent so that we can
// run the animations on the compositor.
EffectCompositor::HasAnimationsForCompositor(
this, DisplayItemType::TYPE_BACKGROUND_COLOR)) {
result = nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
aBuilder, this,
GetRectRelativeToSelf() + aBuilder->ToReferenceFrame(this),

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

@ -3678,9 +3678,12 @@ AppendedBackgroundType nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
// isolate blending to the background
nsDisplayList bgItemList;
// Even if we don't actually have a background color to paint, we may still
// need to create an item for hit testing.
// need to create an item for hit testing and we still need to create an item
// for background-color animations.
if ((drawBackgroundColor && color != NS_RGBA(0, 0, 0, 0)) ||
aBuilder->IsForEventDelivery()) {
aBuilder->IsForEventDelivery() ||
EffectCompositor::HasAnimationsForCompositor(
aFrame, DisplayItemType::TYPE_BACKGROUND_COLOR)) {
if (aAutoBuildingDisplayList && !*aAutoBuildingDisplayList) {
nsPoint offset = aBuilder->GetCurrentFrame()->GetOffsetTo(aFrame);
aAutoBuildingDisplayList->emplace(aBuilder, aFrame,
@ -4645,7 +4648,9 @@ LayerState nsDisplayBackgroundColor::GetLayerState(
already_AddRefed<Layer> nsDisplayBackgroundColor::BuildLayer(
nsDisplayListBuilder* aBuilder, LayerManager* aManager,
const ContainerLayerParameters& aContainerParameters) {
if (mColor == sRGBColor()) {
if (mColor == sRGBColor() &&
!EffectCompositor::HasAnimationsForCompositor(
mFrame, DisplayItemType::TYPE_BACKGROUND_COLOR)) {
return nullptr;
}
@ -4679,7 +4684,9 @@ bool nsDisplayBackgroundColor::CreateWebRenderCommands(
const StackingContextHelper& aSc,
mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder) {
if (mColor == sRGBColor()) {
if (mColor == sRGBColor() &&
!EffectCompositor::HasAnimationsForCompositor(
mFrame, DisplayItemType::TYPE_BACKGROUND_COLOR)) {
return true;
}

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

@ -1,10 +0,0 @@
[background-color-animation-with-zero-alpha.html]
expected:
if webrender and (os == "win") and debug and swgl: ["PASS", "TIMEOUT"]
if webrender and (os == "win") and debug and not swgl: ["TIMEOUT", "PASS"]
if webrender and (os == "android") and debug and swgl: ["PASS", "TIMEOUT"]
if webrender and (os == "android") and debug and not swgl: ["PASS", "TIMEOUT"]
if webrender and (os == "linux") and not debug and fission: ["PASS", "TIMEOUT"]
if webrender and (os == "win") and not debug: ["PASS", "TIMEOUT"]
if webrender and (os == "linux") and debug: ["PASS", "TIMEOUT"]
if webrender and (os == "mac"): ["PASS", "TIMEOUT"]