Closed Bug 1186546 Opened 9 years ago Closed 8 years ago

DrawTargetCG::FillRect allocates an unnecessary surface when tiling device-pixel aligned surfaces

Categories

(Core :: Graphics, defect)

All
macOS
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX
Tracking Status
firefox42 --- affected

People

(Reporter: mstange, Assigned: mstange)

References

Details

(Whiteboard: gfx-noted)

Attachments

(1 file, 3 obsolete files)

Attached patch patch (obsolete) — Splinter Review
This shows up as build_tile in profiles; it's called by CG when drawing repeated surfaces. However, when we're device-pixel aligned, it's not necessary to allocate an intermediate surface, so CG is just doing unnecessary work in that case. We can work around this by calling DrawSurface in a loop on our side. This won't give us repeat sampling at the tile edges, but CG doesn't give us that anyway.
Blocks: 1154311
Whiteboard: gfx-noted
Flags: needinfo?(mchang)
I forgot to push a clip in this patch. It needs a PushClipRect(deviceRect) after the first SetTransform call and a PopClip() before the second SetTransform call.
Just did some profiling and measurements, and this patch doesn't help much :(. Some timings while scrolling bug 1172841. Without patch: // Refreshing the page Draw Scaled Image time: 66.852088 Draw Scaled Image time: 69.202409 Draw Scaled Image time: 67.071342 Draw Scaled Image time: 67.323160 Scrolling to bottom: // Very noisy due to human hand scrolling 690.590693 632.590209 681.383573
Flags: needinfo?(mchang)
With patch // Refresh Draw Scaled Image time: 79.320642 Draw Scaled Image time: 68.486225 Draw Scaled Image time: 72.478783 Draw Scaled Image time: 67.550486 // Scrolling 701.223834 660.411152 819.329177
With CGContextDrawTiledImage from bug 1154311. // Refresh Draw Scaled Image time: 69.213240 Draw Scaled Image time: 70.717759 Draw Scaled Image time: 65.031977 Draw Scaled Image time: 65.165359 // Scrolling 615.527478 654.345563 664.044687
I think the problem is that in profiles, build_tile doesn't show up according to instruments. This is what I'm getting from instruments with an inverted call tree: Inverted call tree Running Time Self (ms) Symbol Name 360.0ms 22.2% 360.0 argb32_mark 360.0ms 22.2% 0.0 RIPLayerBltShape 360.0ms 22.2% 0.0 ripc_Render 360.0ms 22.2% 0.0 ripc_DrawRects 360.0ms 22.2% 0.0 CGContextFillRects 360.0ms 22.2% 0.0 mozilla::gfx::DrawTargetCG::FillRect(mozilla::gfx::RectTyped<mozilla::gfx::UnknownUnits> const&, mozilla::gfx::Pattern const&, mozilla::gfx::DrawOptions const&) 360.0ms 22.2% 0.0 mozilla::gfx::DrawTargetTiled::FillRect(mozilla::gfx::RectTyped<mozilla::gfx::UnknownUnits> const&, mozilla::gfx::Pattern const&, mozilla::gfx::DrawOptions const&) 360.0ms 22.2% 0.0 DrawScaledImage(gfxDrawable*, gfxContext*, mozilla::gfx::RectTyped<mozilla::gfx::UnknownUnits>, mozilla::gfx::RectTyped<mozilla::gfx::UnknownUnits>, GraphicsFilter const&, mozilla::gfx::SurfaceFormat, double)
Attached patch Fixed patch (obsolete) — Splinter Review
From comment 1.
Can you get a profile with the patch?
Flags: needinfo?(mchang)
(In reply to Mason Chang [:mchang] from comment #8) > http://people.mozilla.org/~bgirard/cleopatra/ > #report=5e472a081cc94e1b9600ba62053d5a0180c826f0 As usual, your CoreGraphics symbols are garbage. Can you do what you did with instruments?
Or maybe it's good enough. It doesn't look like mstange's fast path is being hit. Are the patches you're testing up some place?
Ahh, yeah mstange's fast path wasn't being hit because of: if (aPattern.mExtendMode != ExtendMode::REPEAT || !aPattern.mSamplingRect.IsEmpty() || // We're not using a sampling rect here aPattern.mMatrix.IsSingular() || !mTransform.IsRectilinear()) { return false; } But the numbers didn't move much.
Ahh should say, because we are using a sampling rect here, that's just the size of the whole scaled image surface. But even using the fast path, the numbers didn't move much.
Attached patch patchSplinter Review
This one might be better.
Attachment #8637360 - Attachment is obsolete: true
Attachment #8637949 - Attachment is obsolete: true
Attachment #8638051 - Attachment is obsolete: true
We're not using DrawTargetCG any more so this optimization is not worth putting effort into.
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: