Expected value of kN32_SkColorType?

66 views
Skip to first unread message

Gauthier Ambard

unread,
Oct 12, 2021, 3:07:20 AM10/12/21
to skia-d...@googlegroups.com, Rohit Rao, Olivier Robin
Hi,

I am working on Chrome on iOS. When building, kN32_SkColorType is equal to kBGRA_8888_SkColorType and not kRGBA_8888_SkColorType as I am expecting.

When using it on a bitmap, the resulting image has Red and Blue inverted, which seems to indicate that the correct value should be RBG.
Should the value of kN32_SkColorType be computed automatically or is it something to configure?

Thanks,
Gauthier

Brian Salomon

unread,
Oct 12, 2021, 9:18:47 AM10/12/21
to skia-d...@googlegroups.com, Rohit Rao, Olivier Robin
There are preprocessor macros that control whether kN32_SkColorType is equal to kRGBA_8888_SkColorType or kBGRA_8888_SkColorType. In Chromium this is set here:


That said, kN32 is really historical, from when Skia's software rasterizer could only support one or the other color type. It's been kept around for backwards compatibility but we recommend explicitly using kRGBA or kBGRA.

Brian


--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/CAFpJR86m6sHRN_5070qph48xcpgoruDePGcS7Fwup5EZ2Z68gg%40mail.gmail.com.


--

Brian Salomon | Office Hours: go/bsalomon-office | bsal...@google.com

Gauthier Ambard

unread,
Oct 12, 2021, 11:04:17 AM10/12/21
to skia-d...@googlegroups.com, Rohit Rao, Olivier Robin
Thanks for your answer and the pointer!
I am hitting this check (CHECK_EQ(bitmap_.colorType(), kN32_SkColorType);). Is it still relevant if kN32 is historical?

Gauthier

Brian Osman

unread,
Oct 12, 2021, 11:13:41 AM10/12/21
to skia-d...@googlegroups.com, Rohit Rao, Olivier Robin
That check seems to originate from this bug, which suggests that there is still code somewhere in chromium assuming N32 size (and layout) of pixels. Skia doesn't really care (any normal drawing operation will work fine regardless of the color type), but if chromium itself has code that gets raw pointers to the pixel data and then operates on that - the assertion may still be necessary.

Gauthier Ambard

unread,
Oct 12, 2021, 11:17:34 AM10/12/21
to skia-d...@googlegroups.com, Rohit Rao, Olivier Robin
Ok, thanks for the clarification!

Gauthier

Reply all
Reply to author
Forward
0 new messages