imported patch memset.patch
authorMason Chang <mchang@mozilla.com>
Tue, 26 Jul 2016 21:32:24 -0700
changeset 809184 d17c8fdd1395831063cc29e65de736f2bd32b197
parent 808634 462dc6b44adb4573e8ce6b0dd688c206ebd516f7
child 809185 32a50cce6e0b5d517ac444e2265283629666f8d8
push id136081
push usermchang@mozilla.com
push dateWed, 27 Jul 2016 15:39:43 +0000
treeherdertry@32a50cce6e0b [default view] [failures only]
milestone50.0a1
imported patch memset.patch
gfx/ipc/SharedDIBWin.cpp
gfx/ipc/SharedDIBWin.h
mozglue/build/WindowsDllBlocklist.cpp
--- a/gfx/ipc/SharedDIBWin.cpp
+++ b/gfx/ipc/SharedDIBWin.cpp
@@ -56,17 +56,17 @@ SharedDIBWin::Create(HDC aHdc, uint32_t 
   // create the offscreen shared dib
   BITMAPV4HEADER bmih;
   uint32_t size = SetupBitmapHeader(aWidth, aHeight, aTransparent, &bmih);
 
   nsresult rv = SharedDIB::Create(size);
   if (NS_FAILED(rv))
     return rv;
 
-  if (NS_FAILED(SetupSurface(aHdc, &bmih))) {
+  if (NS_FAILED(SetupSurface(aHdc, &bmih, aTransparent))) {
     Close();
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 nsresult
@@ -77,17 +77,17 @@ SharedDIBWin::Attach(Handle aHandle, uin
 
   BITMAPV4HEADER bmih;
   SetupBitmapHeader(aWidth, aHeight, aTransparent, &bmih);
 
   nsresult rv = SharedDIB::Attach(aHandle, 0);
   if (NS_FAILED(rv))
     return rv;
 
-  if (NS_FAILED(SetupSurface(nullptr, &bmih))) {
+  if (NS_FAILED(SetupSurface(nullptr, &bmih, aTransparent))) {
     Close();
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 uint32_t
@@ -109,31 +109,36 @@ SharedDIBWin::SetupBitmapHeader(uint32_t
 
   if (aTransparent)
     aHeader->bV4AlphaMask     = 0xFF000000;
 
   return (kHeaderBytes + (-aHeader->bV4Height * aHeader->bV4Width * kBytesPerPixel));
 }
 
 nsresult
-SharedDIBWin::SetupSurface(HDC aHdc, BITMAPV4HEADER *aHdr)
+SharedDIBWin::SetupSurface(HDC aHdc, BITMAPV4HEADER *aHdr, bool aTransparent)
 {
   mSharedHdc = ::CreateCompatibleDC(aHdc);
 
   if (!mSharedHdc)
     return NS_ERROR_FAILURE;
 
   mSharedBmp = ::CreateDIBSection(mSharedHdc,
                                   (BITMAPINFO*)aHdr,
                                   DIB_RGB_COLORS,
                                   &mBitmapBits,
                                   mShMem->handle(),
                                   kHeaderBytes);
   if (!mSharedBmp)
     return NS_ERROR_FAILURE;
 
+  // Since the DIB is top to bottom, invert height here.
+  // SKIA requires RGBX surfaces to have an alpha value of 0xFF.
+  uint8_t clearValue = aTransparent ? 0 : 0xFF;
+  memset(mBitmapBits, clearValue, aHdr->bV4Width * -aHdr->bV4Height * 4);
+
   mOldObj = SelectObject(mSharedHdc, mSharedBmp);
 
   return NS_OK;
 }
 
 } // gfx
 } // mozilla
--- a/gfx/ipc/SharedDIBWin.h
+++ b/gfx/ipc/SharedDIBWin.h
@@ -42,15 +42,15 @@ public:
 private:
   HDC                 mSharedHdc;
   HBITMAP             mSharedBmp;
   HGDIOBJ             mOldObj;
   void*               mBitmapBits;
 
   uint32_t SetupBitmapHeader(uint32_t aWidth, uint32_t aHeight,
                              bool aTransparent, BITMAPV4HEADER *aHeader);
-  nsresult SetupSurface(HDC aHdc, BITMAPV4HEADER *aHdr);
+  nsresult SetupSurface(HDC aHdc, BITMAPV4HEADER *aHdr, bool aTransparent);
 };
 
 } // gfx
 } // mozilla
 
 #endif
--- a/mozglue/build/WindowsDllBlocklist.cpp
+++ b/mozglue/build/WindowsDllBlocklist.cpp
@@ -761,17 +761,17 @@ DllBlocklist_Initialize()
     return;
   }
   sBlocklistInitAttempted = true;
 
   if (GetModuleHandleA("user32.dll")) {
     sUser32BeforeBlocklist = true;
   }
   // Catch any missing DELAYLOADS for user32.dll
-  MOZ_ASSERT(!sUser32BeforeBlocklist);
+  //MOZ_ASSERT(!sUser32BeforeBlocklist);
 
   NtDllIntercept.Init("ntdll.dll");
 
   ReentrancySentinel::InitializeStatics();
 
   // We specifically use a detour, because there are cases where external
   // code also tries to hook LdrLoadDll, and doesn't know how to relocate our
   // nop space patches. (Bug 951827)