Closed Bug 586954 Opened 14 years ago Closed 14 years ago

Speed up mask drawing

Categories

(Core :: SVG, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla2.0b8

People

(Reporter: mstange, Assigned: mstange)

References

Details

(Keywords: perf)

Attachments

(3 files, 2 obsolete files)

Drawing small masked elements is extremely slow when the redraw region is big, because every mask draw operation allocates, zeros out and releases two surfaces the size of the clip region. These surface allocations happen in nsSVGMaskFrame::ComputeMaskAlpha and nsSVGIntegrationUtils::PaintFramesWithEffects. Both methods use PushGroup in a wasteful manner.
Instead of drawing into a giant surface and copying a small correctly sized rect into another surface, we can just draw into the correctly sized surface directly.
Attachment #465623 - Flags: review?(roc)
PushGroup allocates a surface the size of the clip extents, so we just set a sensible clip before calling PushGroup.
Attachment #465625 - Flags: review?(roc)
Attached file performance testcase (deleted) —
To run the testcase, allow JavaScript to resize existing windows in Preferences -> Content -> JavaScript Advanced and run this command from the error console: open("https://bugzilla.mozilla.org/attachment.cgi?id=465979", "", "chrome=1") The patches in this bug move the number from 7 FPS to 20 FPS to 60 FPS in my debug build.
In fact, part 2 alone already speeds it up to almost 60 FPS because the clip rect also applies to the mask alpha. But I think we still want part 1.
Actually I realized there's a problem in patch 2. If there is complex transform matrix set in the context, the clip call will set a non-rectangular clip, which is unnecessarily expensive to deal with. We probably need to move ClipToContain http://mxr.mozilla.org/mozilla-central/source/gfx/layers/basic/BasicLayers.cpp#337 (or something like it) into gfxContext and use it here.
I haven't been able to construct a testcase where that makes a difference. Can I land the simple patch and file a new bug for ClipToContain?
Attachment #465623 - Flags: approval2.0?
Attachment #465625 - Flags: approval2.0?
Markus, do you mind if someone else lands this for you?
Whiteboard: [needs landing]
I don't mind but I can do it myself today. Unfortunately I've discovered that part 1 causes reftest failures so I'm only going to land part 2 until I've found out what causes them. Landing only part 2 will speed up the mask-on-html case almost as much as landing both parts (see comment 5) but won't speed up mask-on-svg. The failures are in the four mask tests in layout/reftests/svg/svg-integration: == mask-html-01.xhtml mask-html-01-ref.svg == mask-html-01-extref-01.xhtml mask-html-01-ref.svg == mask-html-01-extref-02.xhtml mask-html-01-ref.svg == mask-html-zoomed-01.xhtml mask-html-01-ref.svg The only thing that differs seems to be the alpha component of the masked images; it looks like different rounding...
Whiteboard: [needs landing] → [part 2 needs landing]
Attached file reftest failures caused by part 1 (deleted) —
Maybe Cameron can look into those test failures!
Attached patch part 2, updated to trunk (deleted) — Splinter Review
Attachment #465625 - Attachment is obsolete: true
Blocks: 610122
No longer blocks: 584710
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Whiteboard: [part 2 needs landing]
Target Milestone: --- → mozilla2.0b8
Attachment #465623 - Attachment is obsolete: true
What is the bug # for Comment 7? Shouldn't it be a dependency of this one?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: