On Tue, Nov 24, 2015 at 7:05 PM, Robert O'Callahan <rob...@ocallahan.org> wrote:
>>
>> It still seems like, where possible, we should switch from passing
>> around an nsRenderingContext or a gfxContext to passing around a
>> DrawTarget.  (Presumably starting from leaf functions and moving
>> up.)
>
> Yes.

I spent some time trying to do this, and it's harder than you might
think. A lot of the leaf functions are using gfxContext in complicated
ways. I'm trying with the small number that don't seem too bad but
even they are challenging to me (as a newbie to this stuff). I suspect
a lot of the easy cases have already been converted.

One interesting thing I found is that a *lot* of the functions that
take an nsRenderingContext or gfxContext do so because they end up
passing it into text run code -- gfxTextRun uses a gfxContext, via
gfxTextRunFactory::Parameters::mContext. However, only a few things
from the gfxContext are used by the text run code:

- gfxContext::mDT is only used in gfxGDIFont::GetGlyphWidth().

- gfxContext::GetCairo() is called in numerous places. This function
is weird, and Matt Woodrow suggested it could probably be split into
two parts. It seems like its usage usually boils down to using the
"reference" Cairo context (gfxContext::mRefCairo) for font scaling.

- gfxContext::GetRoundOffsetsToPixels() is called in a couple of
places. It calls CurrentMatrix().HasNonTranslation().

- gfxFont::CalcXScale() is called from PostShapingFixup(). It calls
gfxContext::UserToDevice() which uses gfxContext::mTransform.

I think that's it. It feels like it should be possible to simplify
this, but I can't quite work out how.

Nick
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to