Bug 1316750, part 2 - Add CairoContentToCairoFormat helper to HelpersCairo.h. r=edwin
☠☠ backed out by 91b1add28ef6 ☠ ☠
authorJonathan Watt <jwatt@jwatt.org>
Mon, 14 Nov 2016 17:32:17 +0000
changeset 322395 e222819961af854aed85dfccc346b03e3de0d477
parent 322394 888f093ce01504fb472d0646d29c08bcc5ef7b75
child 322396 c0d0caa11f5a56edbede98532513861c61f7de34
push id83860
push userjwatt@jwatt.org
push dateMon, 14 Nov 2016 17:32:47 +0000
treeherdermozilla-inbound@c0d0caa11f5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersedwin
bugs1316750
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1316750, part 2 - Add CairoContentToCairoFormat helper to HelpersCairo.h. r=edwin
gfx/2d/HelpersCairo.h
--- a/gfx/2d/HelpersCairo.h
+++ b/gfx/2d/HelpersCairo.h
@@ -160,16 +160,33 @@ GfxFormatToCairoFormat(SurfaceFormat for
     case SurfaceFormat::R5G6B5_UINT16:
       return CAIRO_FORMAT_RGB16_565;
     default:
       gfxCriticalError() << "Unknown image format " << (int)format;
       return CAIRO_FORMAT_ARGB32;
   }
 }
 
+static inline cairo_format_t
+CairoContentToCairoFormat(cairo_content_t content)
+{
+  switch (content)
+  {
+    case CAIRO_CONTENT_COLOR:
+      return CAIRO_FORMAT_RGB24;
+    case CAIRO_CONTENT_ALPHA:
+      return CAIRO_FORMAT_A8;
+    case CAIRO_CONTENT_COLOR_ALPHA:
+      return CAIRO_FORMAT_ARGB32;
+    default:
+      gfxCriticalError() << "Unknown cairo content type " << (int)content;
+      return CAIRO_FORMAT_A8; // least likely to cause OOB reads
+  }
+}
+
 static inline cairo_content_t
 GfxFormatToCairoContent(SurfaceFormat format)
 {
   switch (format)
   {
     case SurfaceFormat::A8R8G8B8_UINT32:
       return CAIRO_CONTENT_COLOR_ALPHA;
     case SurfaceFormat::X8R8G8B8_UINT32: