Bug 1239152 - skip memset since XShm is already initialized to zero. r=mchang
authorLee Salzman <lsalzman@mozilla.com>
Fri, 19 Feb 2016 16:14:02 -0500
changeset 284906 1205efecce10f87c04a9bf2bfb91c6b5cf5f2239
parent 284905 401bfec3e35aa6131936ceccd686ae3ab4a55f20
child 284907 553852728c21211eaff0daea611524612404bc24
push id30015
push userphilringnalda@gmail.com
push dateSun, 21 Feb 2016 01:23:31 +0000
treeherdermozilla-central@7bfe45ec123a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchang
bugs1239152
milestone47.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 1239152 - skip memset since XShm is already initialized to zero. r=mchang
widget/nsShmImage.cpp
--- a/widget/nsShmImage.cpp
+++ b/widget/nsShmImage.cpp
@@ -141,31 +141,29 @@ nsShmImage::CreateImage(const LayoutDevi
   mSize = aSize;
   mFormat = SurfaceFormat::UNKNOWN;
   switch (mImage->depth) {
   case 32:
     if ((mImage->red_mask == 0xff0000) &&
         (mImage->green_mask == 0xff00) &&
         (mImage->blue_mask == 0xff)) {
       mFormat = SurfaceFormat::B8G8R8A8;
-      memset(mImage->data, 0, mImage->bytes_per_line * mImage->height);
     }
     break;
   case 24:
-    // Only xRGB is supported.
+    // Only support the BGRX layout, and report it as BGRA to the compositor.
+    // The alpha channel will be discarded when we put the image.
     if ((mImage->red_mask == 0xff0000) &&
         (mImage->green_mask == 0xff00) &&
         (mImage->blue_mask == 0xff)) {
-      mFormat = SurfaceFormat::B8G8R8X8;
-      memset(mImage->data, 0xFF, mImage->bytes_per_line * mImage->height);
+      mFormat = SurfaceFormat::B8G8R8A8;
     }
     break;
   case 16:
     mFormat = SurfaceFormat::R5G6B5_UINT16;
-    memset(mImage->data, 0, mImage->bytes_per_line * mImage->height);
     break;
   }
 
   if (mFormat == SurfaceFormat::UNKNOWN) {
     NS_WARNING("Unsupported XShm Image format!");
     gShmAvailable = false;
     return false;
   }