Closed Bug 1554499 Opened 6 years ago Closed 5 years ago

Refactor display item building so that building function knows the item index beforehand

Categories

(Core :: Web Painting, task, P3)

task

Tracking

()

RESOLVED FIXED
mozilla78
Tracking Status
firefox78 --- fixed

People

(Reporter: mikokm, Assigned: mikokm)

References

(Blocks 1 open bug)

Details

Attachments

(17 files, 5 obsolete files)

47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review

Currently display items have their index passed in as an arbitrary positioned constructor parameter. This index is then returned by CalculatePerFrameKey(), and MakeDisplayItem() uses it and the display item type to construct the per frame key for the display item.

This hack makes it difficult to implement the reuse of display items that can have index (= display item types that frame can have more than one of). We should refactor the display item creation, so that the callers requiring items with index need to pass it more explicitly.

My suggestion for this is to take the per-type logic within the virtual CalculatePerFrameKey, and move it to the static per-type callsites of MakeDisplayItem(or AppendToTop). Most item types only have one creation site, so this shouldn't result in much duplication, and we can add static helper functions as needed.

We'll probably also want a second variation of MakeDisplayItem that takes the computed index (MakeDisplayItemWithIndex?) so that we don't need to touch the callsites of items that aren't affected by this change.

Assignee: nobody → a.beingessner

This static method is assumed to have the same signature as the type's constructor,
and so we must have an implementation of ComputePerFrameKey for each constructor
a display item provides that is called by MakeDisplayItem. Notably this excludes
the MakeClone constructor for a lot of items.

There is a default varargs implementation on nsDisplayItem which everyone
inherits by default, so types which previously didn't overload this method
still don't need to.

Providing an implementation of ComputePerFrameKey on some display item type
shadows the varargs implementation, so one doesn't need to worry about overloading
one constructor but forgetting about another -- if you do, the compiler will only
see the overload and complain that the signature doesn't match.

One slightly annoying result of this is that display items which previously
inherited an overloaded implementation from a superclass now must provide
their own manual implementations. Although as far as I could tell, all of
those cases had a trivial implementation of key=0 (the super class supported
custom keys but the subclasses didn't make use of it).

In those cases I just hardcoded key=0, but it's possible that it would be
better to call into the superclass' implementation to be more robust to changes.

This distinguishes better between the overloaded aspect of the PerFrameKey and the
actual mixed value.

Pushed by abeingessner@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/789e5d3fcf18 change ComputePerFrameKey to be a static method. r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/1a6a6a38c987 Rename PerFrameKey -> PerFrameIndex for most methods r=mattwoodrow
Regressions: 1512068

investigating...

Flags: needinfo?(a.beingessner)

There are some r+ patches which didn't land and no activity in this bug for 2 weeks.
:Gankro, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(a.beingessner)

this is in my queue, there's just several higher priority things in the way (unless matt or miko really need/want this to make progress soon)

Flags: needinfo?(a.beingessner)

Unassigning myself as there seems to perpetually be higher priority webrender bugs to look into since we started shipping more to release... :/

Assignee: a.beingessner → nobody

Depends on D37804

Depends on D50186

Pushed by mikokm@gmail.com: https://hg.mozilla.org/integration/autoland/rev/133cddb65f59 change ComputePerFrameKey to be a static method. r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/a49d1c9e8b14 Rename PerFrameKey -> PerFrameIndex for most methods r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/f60fee484460 Add missing CalculatePerFrameIndex implementations r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/c802ab8cc730 Remove member variables that were previously only used to calculate per frame index r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/3a49bec95338 Store WebRenderAnimationData using display item type as key r=jrmuizel
Assignee: nobody → a.beingessner

miko's on it

Flags: needinfo?(a.beingessner) → needinfo?(mikokm)
Regressions: 1594381
Flags: needinfo?(mikokm)
Priority: P2 → P3

Assigning this to miko since he's working on this and not me.

Assignee: a.beingessner → mikokm

This clarifies that mPerFrameIndex is just a part of the key returned by GetPerFrameKey().

Depends on D74081

Attachment #9103497 - Attachment is obsolete: true
Attachment #9077555 - Attachment is obsolete: true
Attachment #9103499 - Attachment is obsolete: true
Attachment #9103498 - Attachment is obsolete: true
Attachment #9077554 - Attachment is obsolete: true
Pushed by mikokm@gmail.com: https://hg.mozilla.org/integration/autoland/rev/fe5dc2700bbe Part 1: Add MakeDisplayItemWithIndex r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/e8af75b90320 Part 2: Add nsDisplayList::AppendNewToBottomWithIndex() and nsDisplayList::AppendNewToTopWithIndex() r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/fba736154f5f Part 3: Rename SetPerFrameKey() to SetPerFrameIndex() and mKey to mPerFrameIndex r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/2a5158285cd5 Part 4: Remove index from nsDisplaySolidColor r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/cd01a403c04d Part 5: Remove index from nsDisplayTextOverflowMarker r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/75651ced7904 Part 6: Remove index from nsDisplayBackgroundImage, nsDisplayTableBackgroundImage, nsDisplayFixedPosition, nsDisplayTableFixedPosition r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/3986b6f09e62 Part 7: Remove index from nsDisplayCompositorHitTestInfo r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/3fcba0495040 Part 8: Remove index from nsDisplayMathMLCharForeground, nsDisplayMathMLBar, nsDisplayNotation r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/a6d9f235d7bb Part 9: Remove index from nsDisplayTransform r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/e75e94d2c712 Part 10: Remove index from nsDisplayTableThemedBackground r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/af84a5159a44 Part 11: Remove index from nsDisplayTableBackgroundColor r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/9cd738ed8e4f Part 12: Remove index from nsDisplayOwnLayer r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/24885f67361f Part 13: Remove index from nsDisplayWrapList r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/18a3148eff4b Part 14: Remove index from nsDisplayBlendContainer, nsDisplayTableBlendContainer, nsDisplayBlendMode, nsDisplayTableBlendMode r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/7f0a11b398ce Part 15: Use MakeDisplayItemWithIndex with nsDisplayCanvasBackgroundImage r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/5f9b5f39ff69 Part 16: Move table per frame index helpers to nsDisplayList.cpp r=mattwoodrow https://hg.mozilla.org/integration/autoland/rev/22b375ad5f36 Part 17: Remove CalculatePerFrameKey() r=mattwoodrow
Regressions: 1637149
No longer regressions: 1512068
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: