Bug 1254151 - use B8G8R8X8 for 24 bit depth visuals in nsShmImage with Cairo. r=jrmuizel a=ritu
authorLee Salzman <lsalzman@mozilla.com>
Tue, 08 Mar 2016 11:18:13 -0500
changeset 323429 8a2c0e4cb8680945d1ec08f24fff175ad897df82
parent 323428 a581625cd4888fc1cfbfebaffec9a8a9c144998e
child 323430 5ba3d463ebffddf5994ab1c57e0811ce4e9414a8
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, ritu
bugs1254151
milestone47.0a2
Bug 1254151 - use B8G8R8X8 for 24 bit depth visuals in nsShmImage with Cairo. r=jrmuizel a=ritu MozReview-Commit-ID: 81QthQUYijY
widget/nsShmImage.cpp
--- a/widget/nsShmImage.cpp
+++ b/widget/nsShmImage.cpp
@@ -158,32 +158,36 @@ bool
 nsShmImage::CreateImage(const IntSize& aSize)
 {
   MOZ_ASSERT(mDisplay && mVisual);
 
   if (!InitExtension()) {
     return false;
   }
 
+  BackendType backend = gfxPlatform::GetPlatform()->GetDefaultContentBackend();
+
   mFormat = SurfaceFormat::UNKNOWN;
   switch (mDepth) {
   case 32:
     if (mVisual->red_mask == 0xff0000 &&
         mVisual->green_mask == 0xff00 &&
         mVisual->blue_mask == 0xff) {
       mFormat = SurfaceFormat::B8G8R8A8;
     }
     break;
   case 24:
     // Only support the BGRX layout, and report it as BGRA to the compositor.
     // The alpha channel will be discarded when we put the image.
+    // Cairo/pixman lacks some fast paths for compositing BGRX onto BGRA, so
+    // just report it as BGRX directly in that case.
     if (mVisual->red_mask == 0xff0000 &&
         mVisual->green_mask == 0xff00 &&
         mVisual->blue_mask == 0xff) {
-      mFormat = SurfaceFormat::B8G8R8A8;
+      mFormat = backend == BackendType::CAIRO ? SurfaceFormat::B8G8R8X8 : SurfaceFormat::B8G8R8A8;
     }
     break;
   case 16:
     if (mVisual->red_mask == 0xf800 &&
         mVisual->green_mask == 0x07e0 &&
         mVisual->blue_mask == 0x1f) {
       mFormat = SurfaceFormat::R5G6B5_UINT16;
     }