Open Bug 1060762 Opened 10 years ago Updated 2 years ago

calling gfxContext::Save and then gfxContext::Restore will unexpectedly trash the associated DrawTarget's matrix

Categories

(Core :: Graphics, defect)

defect

Tracking

()

People

(Reporter: jfkthame, Unassigned)

References

(Depends on 1 open bug)

Details

See bug 983985 comment 9.

The font code uses a skew on the DrawTarget's matrix to implement "fake italics". This matrix gets altered if we call Save() and then Restore() on the gfxContext, which happens if we need to render a missing-glyph hexbox.

It seems wrong for a simple Save/Restore pair to have such a side-effect.
Blocks: 983985
:bas, can you have a look at this and comment on the expected interaction (if any!) between gfxContext::Save/Restore and the DrawTarget's transform?

:jwatt, it looks like you also touched those methods fairly recently; this problem predates your work in bug 933019, but maybe you're familiar enough with the code to have some insight?
Flags: needinfo?(jwatt)
Flags: needinfo?(bas)
(In reply to Jonathan Kew (:jfkthame) from comment #0)
> See bug 983985 comment 9.
> 
> The font code uses a skew on the DrawTarget's matrix to implement "fake
> italics". This matrix gets altered if we call Save() and then Restore() on
> the gfxContext, which happens if we need to render a missing-glyph hexbox.
> 
> It seems wrong for a simple Save/Restore pair to have such a side-effect.

It's not wholly unexpected. The problem is partial conversion to Moz2D. The expected, correct behavior (although perhaps not intuitive) is that -any- usage of the Context may restore the transform that the context 'knew about' and override a transform set directly on the DrawTarget.

So DrawTarget's belonging to a context should only be used as DrawTargets in a coherent form where there's no interruption by using the context. This idea facilitates a 'bottom-up' Moz2D-ification where from the 'highest levels' on the callstack Moz2Dification works down so in the end usage of gfxContext is eliminated completely.
Flags: needinfo?(bas)
Bas, could we get rid of gfxContext::mTransform and just get the transform directly from the DT now that gfxContext is always backed by a DT?
Flags: needinfo?(jwatt) → needinfo?(bas)
(In reply to Jonathan Watt [:jwatt] from comment #3)
> Bas, could we get rid of gfxContext::mTransform and just get the transform
> directly from the DT now that gfxContext is always backed by a DT?

No, because the transform is adjusted relative to the destination context because of device offsets when you push a group with a clip.
Flags: needinfo?(bas)
Depends on: 1064055
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.