Closed Bug 1216851 Opened 9 years ago Closed 9 years ago

Optimize text with an opacity style set to avoid pushing a group

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox44 --- affected
firefox45 --- fixed

People

(Reporter: mattwoodrow, Assigned: mattwoodrow)

Details

Attachments

(2 files)

We seem to frequently get (inactive) opacity layers in the front end that contain only text. We can avoid this by folding the opacity value down into the text display item and including it in the colour we render the text. We'd probably need to skip this if the text contains complex extra (that require multiple draw passes) like underlines, selection and shadows. We need to implement CanApplyOpacity() and ApplyOpacity() on the nsDisplayText display item, store the opacity on the item (if we decide its ok), and then pass it into nsTextFrame::DrawText.
Are there issues with multiple nsDisplayText display items that might overlap each other, inside a single element with opacity? Or are you thinking of doing this only for a single nsDisplayText?
The current code [1] will attempt to flatten up to 3 child display items, as long as they all support this, and don't overlap each other. [1] http://mxr.mozilla.org/mozilla-central/source/layout/base/nsDisplayList.cpp#3947
The "don't overlap" test sounds good enough for me. At least as long as there aren't fun things text does with self-overlapping within a single run of text that wouldn't be handled by drawing with rgba colors.
Attached patch flatten-text-opacity (deleted) — Splinter Review
Assignee: nobody → matt.woodrow
Attachment #8677729 - Flags: review?(roc)
Comment on attachment 8677729 [details] [diff] [review] flatten-text-opacity Review of attachment 8677729 [details] [diff] [review]: ----------------------------------------------------------------- ::: layout/base/nsDisplayList.cpp @@ +3927,5 @@ > for (; numChildren < ArrayLength(children) && child; numChildren++, child = child->GetAbove()) { > + if (child->GetType() == nsDisplayItem::TYPE_LAYER_EVENT_REGIONS) { > + numChildren--; > + continue; > + } Wot? Remove this before landing
Attachment #8677729 - Flags: review?(roc) → review+
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #5) > Comment on attachment 8677729 [details] [diff] [review] > flatten-text-opacity > > Review of attachment 8677729 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: layout/base/nsDisplayList.cpp > @@ +3927,5 @@ > > for (; numChildren < ArrayLength(children) && child; numChildren++, child = child->GetAbove()) { > > + if (child->GetType() == nsDisplayItem::TYPE_LAYER_EVENT_REGIONS) { > > + numChildren--; > > + continue; > > + } > > Wot? Remove this before landing This was intentional. I don't think we want nsDisplayLayerEventRegions contributing to our count of 3 items, and we don't want to check for intersections with it either. I'll split it out and put it up as a separate patch though.
Comment on attachment 8677739 [details] [diff] [review] Don't include EventRegions in our limit of 3 items to optimize Review of attachment 8677739 [details] [diff] [review]: ----------------------------------------------------------------- Right OK
Attachment #8677739 - Flags: review?(roc) → review+
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Flags: needinfo?(matt.woodrow)
removing the b2g 2.5 flag since this commit has been reverted due to an incorrect merge, sorry for the confusion
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: