Closed Bug 2079470 Opened 1 month ago Closed 1 month ago

Experiment with with a skia GDI back-end.

Categories

(Core :: Printing: Output, task, P3)

task

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: emilio, Assigned: emilio)

References

Details

Attachments

(1 file, 4 external files)

No description provided.

This is one way (not sure the best way, see below) of preventing
lifetime issues with the proposed Skia GDI back-end in the next commit.

The issue is that GDI can't represent everything that Skia does, so the
way we try make the most out of GDI is doing some analysis at the end of
the page where we can decide what regions to rasterize and which ones to
emit DGI commands for. This is very similar to what Cairo does.

Now, the main issue here is that we have this bespoke copy-on-write of
surfaces that kind of assumes that SkImages don't outlive our snapshots,
unless we make them own their pixels.

We could also fix this on the GDI side, but it's finicky, because we
can't just get away with rasterizing the SkImage I think.

This works very similar to Cairo in the sense that it records the page,
analyzes and decides what to rasterize vs. provide commands for.

One known annoyance of this is that it needs the previous commit, and
that it uses SkPicture for recording, which is convenient but also
annoying.

It should not be hard to rejigger this to use the Gecko recording stuff
tho.

Type: defect → task

This also makes D331793 not needed at all. The Save/RestoreState
shenanigans seemed useful to be able to share resources like e.g. fonts
across pages...

WipeRecording was unused before this patch but is exactly what we want.

Depends on: 2080319
Attached file mixed.html —

This is a file I've been profiling against, apart from a copy of the single-page HTML spec.

This works very similar to Cairo, in the sense that it records the page,
analyzes and decides what to rasterize vs. provide commands for.
drawPage() is where the meat of the approach is, the rest is translation
to GDI commands.

In order to avoid pulling SkPicture as a dependency in a way that
complicates our borrowed SkImage optimizations (see D331792), we pass an
std::function around to Skia that gets called every time we need to
analyze / rasterize the page, and PrintTargetWindows is what takes care
of keeping the recordings around.

In my testing, in terms of quality, this tends to perform better than
Cairo, because Cairo has full-page rasterization fallback more often.

I've also profiled this with the single-page HTML spec, and some
miscellaneous pages like mixed.html (attached to the bug), and this is
faster in all cases (with the fix for bug 2080319).

The InlineTranslator changes are so that we can reuse registered
resources from previous pages (like fonts etc). It's not perfect,
because each replay of a given page doesn't reuse the state / resources
of the first pass of that very same page, which seems like it'd be
desirable. However it does allow for reusing resources across pages
which is where most of the wins are in practice, so I think it's good
enough. I'm open to better approaches there, but I'd rather land it and
iterate on it as needed, because this is in a state already better than
Cairo.

Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch
Depends on: 2082991
Depends on: 2083011
No longer depends on: 2083011
Regressions: 2083011
No longer depends on: 2082991
Regressions: 2082991
Regressions: 2083739
Depends on: 2083739
Duplicate of this bug: 2066036
No longer depends on: 2083739
Duplicate of this bug: 2036950
QA Whiteboard: [qa-triage-done-c161/b160]
Blocks: 2087939
Regressions: 2091728
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: