Re: Single- vs. double-precision FP in gfx types

2016-01-04 Thread Nicholas Nethercote
On Wed, Dec 9, 2015 at 3:49 PM, Nicholas Nethercote
 wrote:
>>
>> 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:

I found a good way to handle this, which let me convert 228
occurrences of gfxContext and nsRenderingContext (~13% of them) in the
tree to DrawTarget. Details in
https://bugzilla.mozilla.org/show_bug.cgi?id=1231550, the patch for
which I just landed on inbound.

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


Re: Single- vs. double-precision FP in gfx types

2015-12-09 Thread Nicholas Nethercote
On Tue, Dec 8, 2015 at 4:34 PM, Nicholas Nethercote
 wrote:
>
> 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::GetCairo() is called in numerous places.

I was able to find a bunch of functions that only needed
gfxContext::mRefCairo and so I've changed them to take a |cairo_t*|
instead of a |gfxContext*|, which clears things up a bit:
https://bugzilla.mozilla.org/show_bug.cgi?id=1231550

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


Re: Single- vs. double-precision FP in gfx types

2015-12-09 Thread Nicholas Nethercote
On Wed, Dec 9, 2015 at 3:49 PM, Nicholas Nethercote
 wrote:
>>
>> 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:
>
> I was able to find a bunch of functions that only needed
> gfxContext::mRefCairo and so I've changed them to take a |cairo_t*|
> instead of a |gfxContext*|, which clears things up a bit:
> https://bugzilla.mozilla.org/show_bug.cgi?id=1231550

I subsequently did something similar with all the other text/font
code, in the same bug. I'm on the fence about the usefulness of this
change.

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


Re: Single- vs. double-precision FP in gfx types

2015-12-08 Thread Nicholas Nethercote
On Tue, Nov 24, 2015 at 7:05 PM, Robert O'Callahan  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


Re: Single- vs. double-precision FP in gfx types

2015-11-24 Thread Robert O'Callahan
On Wed, Nov 25, 2015 at 11:59 AM, Nicholas Nethercote <
n.netherc...@gmail.com> wrote:

> On Mon, Nov 23, 2015 at 8:14 PM, Robert O'Callahan 
> wrote:
> >>
> >> One major remaining Moz2Dification step is the conversion of thebes
> >> types such as gfxSize, gfxPoint, gfxRect, and gfxMatrix to their Moz2D
> >> equivalents.
> >
> > I think for now we should focus on replacing usage of gfxContext with
> > DrawTarget. I think that's more important than unifying those types.
>
> Why is that more important? (Not doubting, just curious.)
>

It actually reduces run-time overhead. Also, the gfxContext API is
significantly different to the DrawTarget API so eliminating it reduces the
knowledge burden significantly.

Rob
-- 
lbir ye,ea yer.tnietoehr  rdn rdsme,anea lurpr  edna e hnysnenh hhe uresyf
toD
selthor  stor  edna  siewaoeodm  or v sstvr  esBa  kbvted,t
rdsme,aoreseoouoto
o l euetiuruewFa  kbn e hnystoivateweh uresyf tulsa rehr  rdm  or rnea
lurpr
.a war hsrer holsa rodvted,t  nenh hneireseoouot.tniesiewaoeivatewt sstvr
esn
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Single- vs. double-precision FP in gfx types

2015-11-24 Thread Nicholas Nethercote
On Mon, Nov 23, 2015 at 8:14 PM, Robert O'Callahan  wrote:
>>
>> One major remaining Moz2Dification step is the conversion of thebes
>> types such as gfxSize, gfxPoint, gfxRect, and gfxMatrix to their Moz2D
>> equivalents.
>
> I think for now we should focus on replacing usage of gfxContext with
> DrawTarget. I think that's more important than unifying those types.

Why is that more important? (Not doubting, just curious.)

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


Re: Single- vs. double-precision FP in gfx types

2015-11-24 Thread L. David Baron
On Wednesday 2015-11-25 12:49 +1300, Robert O'Callahan wrote:
> On Wed, Nov 25, 2015 at 11:59 AM, Nicholas Nethercote <
> n.netherc...@gmail.com> wrote:
> 
> > On Mon, Nov 23, 2015 at 8:14 PM, Robert O'Callahan 
> > wrote:
> > >>
> > >> One major remaining Moz2Dification step is the conversion of thebes
> > >> types such as gfxSize, gfxPoint, gfxRect, and gfxMatrix to their Moz2D
> > >> equivalents.
> > >
> > > I think for now we should focus on replacing usage of gfxContext with
> > > DrawTarget. I think that's more important than unifying those types.
> >
> > Why is that more important? (Not doubting, just curious.)
> >
> 
> It actually reduces run-time overhead. Also, the gfxContext API is
> significantly different to the DrawTarget API so eliminating it reduces the
> knowledge burden significantly.

Presumably it's equally important to replace the remaining
nsRenderingContext usage with DrawTarget?

(nsRenderingContext was the previous API before gfxContext.)

-David

-- 
턞   L. David Baron http://dbaron.org/   턂
턢   Mozilla  https://www.mozilla.org/   턂
 Before I built a wall I'd ask to know
 What I was walling in or walling out,
 And to whom I was like to give offense.
   - Robert Frost, Mending Wall (1914)


signature.asc
Description: Digital signature
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Single- vs. double-precision FP in gfx types

2015-11-24 Thread L. David Baron
On Tuesday 2015-11-24 18:21 -0800, L. David Baron wrote:
> Presumably it's equally important to replace the remaining
> nsRenderingContext usage with DrawTarget?
> 
> (nsRenderingContext was the previous API before gfxContext.)

Er, never mind; I guess that's sort of a stupid question at this
point, since nsRenderingContext has mostly been gutted.

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.)

-David

-- 
턞   L. David Baron http://dbaron.org/   턂
턢   Mozilla  https://www.mozilla.org/   턂
 Before I built a wall I'd ask to know
 What I was walling in or walling out,
 And to whom I was like to give offense.
   - Robert Frost, Mending Wall (1914)


signature.asc
Description: Digital signature
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Single- vs. double-precision FP in gfx types

2015-11-24 Thread Robert O'Callahan
On Wed, Nov 25, 2015 at 3:24 PM, L. David Baron  wrote:

> On Tuesday 2015-11-24 18:21 -0800, L. David Baron wrote:
> > Presumably it's equally important to replace the remaining
> > nsRenderingContext usage with DrawTarget?
> >
> > (nsRenderingContext was the previous API before gfxContext.)
>
> Er, never mind; I guess that's sort of a stupid question at this
> point, since nsRenderingContext has mostly been gutted.
>
> 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.

Rob
-- 
lbir ye,ea yer.tnietoehr  rdn rdsme,anea lurpr  edna e hnysnenh hhe uresyf
toD
selthor  stor  edna  siewaoeodm  or v sstvr  esBa  kbvted,t
rdsme,aoreseoouoto
o l euetiuruewFa  kbn e hnystoivateweh uresyf tulsa rehr  rdm  or rnea
lurpr
.a war hsrer holsa rodvted,t  nenh hneireseoouot.tniesiewaoeivatewt sstvr
esn
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Re: Single- vs. double-precision FP in gfx types

2015-11-23 Thread Robert O'Callahan
On Tue, Nov 24, 2015 at 4:45 PM, Nicholas Nethercote  wrote:

> One major remaining Moz2Dification step is the conversion of thebes
> types such as gfxSize, gfxPoint, gfxRect, and gfxMatrix to their Moz2D
> equivalents. But this is largely blocked by the fact that the thebes
> types use double-precision FP values while the Moz2D types use
> single-precision FP values.
>
> The difference in precision doesn't matter... except when it does.
> Here are four cases I've seen where a proposed change has been blocked
> by this issue:
>
> https://bugzilla.mozilla.org/show_bug.cgi?id=984278#c10
> https://bugzilla.mozilla.org/show_bug.cgi?id=1224093#c2
> https://bugzilla.mozilla.org/show_bug.cgi?id=1222325#c0
> https://bugzilla.mozilla.org/show_bug.cgi?id=1216396#c5
>
> It seems like the strategy so far has been to just make the changes,
> and then insert double-precision when it seems like it's necessary --
> the existence gfx::RectDouble is evidence of this. But it's hard to
> know when it is necessary.
>
> Another possibility would be to just change the Moz2D types to use
> double-precision, which presumably would avoid problems like the above
> ones. But I suspect that will have some opposition, perhaps for
> performance reasons and perhaps because Moz2D's use of
> single-precision mirrors some of the graphics APIs that Moz2D
> interfaces with.
>
> I'd love to find a way to break the current impasse, because
> Moz2Dification will never be completed otherwise; it has certainly
> halted my efforts on that task.
>

I think for now we should focus on replacing usage of gfxContext with
DrawTarget. I think that's more important than unifying those types.

Rob
-- 
lbir ye,ea yer.tnietoehr  rdn rdsme,anea lurpr  edna e hnysnenh hhe uresyf
toD
selthor  stor  edna  siewaoeodm  or v sstvr  esBa  kbvted,t
rdsme,aoreseoouoto
o l euetiuruewFa  kbn e hnystoivateweh uresyf tulsa rehr  rdm  or rnea
lurpr
.a war hsrer holsa rodvted,t  nenh hneireseoouot.tniesiewaoeivatewt sstvr
esn
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform


Single- vs. double-precision FP in gfx types

2015-11-23 Thread Nicholas Nethercote
Hi,

One major remaining Moz2Dification step is the conversion of thebes
types such as gfxSize, gfxPoint, gfxRect, and gfxMatrix to their Moz2D
equivalents. But this is largely blocked by the fact that the thebes
types use double-precision FP values while the Moz2D types use
single-precision FP values.

The difference in precision doesn't matter... except when it does.
Here are four cases I've seen where a proposed change has been blocked
by this issue:

https://bugzilla.mozilla.org/show_bug.cgi?id=984278#c10
https://bugzilla.mozilla.org/show_bug.cgi?id=1224093#c2
https://bugzilla.mozilla.org/show_bug.cgi?id=1222325#c0
https://bugzilla.mozilla.org/show_bug.cgi?id=1216396#c5

It seems like the strategy so far has been to just make the changes,
and then insert double-precision when it seems like it's necessary --
the existence gfx::RectDouble is evidence of this. But it's hard to
know when it is necessary.

Another possibility would be to just change the Moz2D types to use
double-precision, which presumably would avoid problems like the above
ones. But I suspect that will have some opposition, perhaps for
performance reasons and perhaps because Moz2D's use of
single-precision mirrors some of the graphics APIs that Moz2D
interfaces with.

I'd love to find a way to break the current impasse, because
Moz2Dification will never be completed otherwise; it has certainly
halted my efforts on that task.

Thanks.

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