Bug 1222171 - Re-establish equivalence between gfxImageFormat and cairo_format_t. r=mstange. a=ritu
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 05 Nov 2015 13:44:00 -0800
changeset 306082 3de3ef8b8b3d80bb39e4f32667bf663f01cec8af
parent 306081 9e0819a359d50a5c6ac85d3abf221dcacd40df05
child 306083 f5b36c7a56c0a711bb0fc07be19be7885ba76489
push id1017
push userkwierso@gmail.com
push dateThu, 04 Feb 2016 19:38:35 +0000
treeherdermozilla-release@f5b36c7a56c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, ritu
bugs1222171
milestone44.0
Bug 1222171 - Re-establish equivalence between gfxImageFormat and cairo_format_t. r=mstange. a=ritu It would be nice to add static assertions for this equivalence but I don't want to have to include cairo.h in gfxTypes.h. (Indeed, that's why gfxImageFormatToCairoFormat and gfxCairoFormatToImageFormat are macros in the first place).
gfx/thebes/gfxTypes.h
--- a/gfx/thebes/gfxTypes.h
+++ b/gfx/thebes/gfxTypes.h
@@ -42,34 +42,38 @@ enum class gfxBreakPriority {
   eNoBreak       = 0,
   eWordWrapBreak,
   eNormalBreak
 };
 
 /**
   * The format for an image surface. For all formats with alpha data, 0
   * means transparent, 1 or 255 means fully opaque.
+  *
+  * XXX: it's vital that the values here match the values in cairo_format_t,
+  * otherwise gfxCairoFormatToImageFormat() and gfxImageFormatToCairoFormat()
+  * won't work.
   */
 enum class gfxImageFormat {
-  ARGB32, ///< ARGB data in native endianness, using premultiplied alpha
-  RGB24,  ///< xRGB data in native endianness
-  A8,     ///< Only an alpha channel
-  RGB16_565,  ///< RGB_565 data in native endianness
+  ARGB32    = 0, ///< ARGB data in native endianness, using premultiplied alpha
+  RGB24     = 1, ///< xRGB data in native endianness
+  A8        = 2, ///< Only an alpha channel
+  RGB16_565 = 4, ///< RGB_565 data in native endianness
   Unknown
 };
 
 // XXX: temporary
 // This works because the gfxImageFormat enum is defined so as to match the
-// _cairo_format enum.
+// cairo_format_t enum.
 #define gfxCairoFormatToImageFormat(aFormat) \
     ((gfxImageFormat)aFormat)
 
 // XXX: temporary
 // This works because the gfxImageFormat enum is defined so as to match the
-// _cairo_format enum.
+// cairo_format_t enum.
 #define gfxImageFormatToCairoFormat(aFormat) \
     ((cairo_format_t)aFormat)
 
 enum class gfxSurfaceType {
   Image,
   PDF,
   PS,
   Xlib,