Closed
Bug 586954
Opened 14 years ago
Closed 14 years ago
Speed up mask drawing
Categories
(Core :: SVG, defect)
Core
SVG
Tracking
()
RESOLVED
FIXED
mozilla2.0b8
People
(Reporter: mstange, Assigned: mstange)
References
Details
(Keywords: perf)
Attachments
(3 files, 2 obsolete files)
(deleted),
application/vnd.mozilla.xul+xml
|
Details | |
(deleted),
text/plain
|
Details | |
(deleted),
patch
|
Details | Diff | Splinter Review |
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.
Assignee | ||
Comment 1•14 years ago
|
||
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)
Assignee | ||
Comment 2•14 years ago
|
||
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)
Assignee | ||
Comment 3•14 years ago
|
||
Assignee | ||
Comment 4•14 years ago
|
||
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.
Assignee | ||
Comment 5•14 years ago
|
||
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.
Attachment #465623 -
Flags: review?(roc) → review+
Attachment #465625 -
Flags: review?(roc) → review+
Great stuff!
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.
Assignee | ||
Comment 8•14 years ago
|
||
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?
Yes.
Assignee | ||
Updated•14 years ago
|
Attachment #465623 -
Flags: approval2.0?
Assignee | ||
Updated•14 years ago
|
Attachment #465625 -
Flags: approval2.0?
Attachment #465623 -
Flags: approval2.0? → approval2.0+
Attachment #465625 -
Flags: approval2.0? → approval2.0+
Blocks: 584710
Markus, do you mind if someone else lands this for you?
Whiteboard: [needs landing]
Assignee | ||
Comment 11•14 years ago
|
||
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]
Assignee | ||
Comment 12•14 years ago
|
||
Maybe Cameron can look into those test failures!
Assignee | ||
Comment 14•14 years ago
|
||
Attachment #465625 -
Attachment is obsolete: true
Assignee | ||
Comment 15•14 years ago
|
||
Landed part 2:
http://hg.mozilla.org/mozilla-central/rev/15409ec3bf08
I've filed bug 610122 for part 1.
No longer blocks: 584710
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Whiteboard: [part 2 needs landing]
Target Milestone: --- → mozilla2.0b8
Assignee | ||
Updated•14 years ago
|
Attachment #465623 -
Attachment is obsolete: true
Comment 16•14 years ago
|
||
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.
Description
•