Backed out changeset c6cec6e8dbac (bug 980436) for crashes; CLOSED TREE
authorEd Morley <emorley@mozilla.com>
Fri, 07 Mar 2014 17:53:39 +0000
changeset 172584 360307f9ee38190700497475d468c490bdf21e95
parent 172583 0ee66295c251081d9b3e22e61fce472a86f219c2
child 172585 4ca0584a77439c8b6e6b8dade793e08972c175fd
push id26365
push userryanvm@gmail.com
push dateFri, 07 Mar 2014 20:37:53 +0000
treeherdermozilla-central@cd67334b34c5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs980436
milestone30.0a1
backs outc6cec6e8dbac7e3e5777e30cb57e151d65766e56
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
Backed out changeset c6cec6e8dbac (bug 980436) for crashes; CLOSED TREE
widget/windows/nsDragService.cpp
--- a/widget/windows/nsDragService.cpp
+++ b/widget/windows/nsDragService.cpp
@@ -36,18 +36,16 @@
 #include "nsDirectoryServiceDefs.h"
 #include "nsUnicharUtils.h"
 #include "gfxASurface.h"
 #include "gfxContext.h"
 #include "nsRect.h"
 #include "nsMathUtils.h"
 #include "gfxWindowsPlatform.h"
 #include "mozilla/gfx/2D.h"
-#include "mozilla/gfx/DataSurfaceHelpers.h"
-#include "mozilla/gfx/Tools.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
 //-------------------------------------------------------------------------
 //
 // DragService constructor
 //
@@ -91,43 +89,37 @@ nsDragService::CreateDragImage(nsIDOMNod
 
   uint32_t bmWidth = dragRect.width, bmHeight = dragRect.height;
 
   if (bmWidth == 0 || bmHeight == 0)
     return false;
 
   psdi->crColorKey = CLR_NONE;
 
-  RefPtr<DataSourceSurface> dataSurface =
-    Factory::CreateDataSourceSurface(IntSize(bmWidth, bmHeight),
-                                     SurfaceFormat::B8G8R8A8);
-  NS_ENSURE_TRUE(dataSurface, false);
-
+  RefPtr<DataSourceSurface> data = surface->GetDataSurface();
   DataSourceSurface::MappedSurface map;
-  if (!dataSurface->Map(DataSourceSurface::MapType::READ_WRITE, &map)) {
+  if (!data->Map(DataSourceSurface::READ, &map)) {
     return false;
   }
 
-  RefPtr<DrawTarget> dt =
-    Factory::CreateDrawTargetForData(BackendType::CAIRO,
-                                     map.mData,
-                                     dataSurface->GetSize(),
-                                     map.mStride,
-                                     dataSurface->GetFormat());
-  if (!dt) {
-    dataSurface->Unmap();
+  nsRefPtr<gfxImageSurface> imgSurface = new gfxImageSurface(
+    gfxIntSize(bmWidth, bmHeight), 
+    gfxImageFormat::ARGB32);
+  if (!imgSurface)
     return false;
-  }
 
-  dt->DrawSurface(surface,
-                  Rect(0, 0, dataSurface->GetSize().width, dataSurface->GetSize().height),
-                  Rect(0, 0, surface->GetSize().width, surface->GetSize().height),
-                  DrawSurfaceOptions(),
-                  DrawOptions(1.0f, CompositionOp::OP_SOURCE));
-  dt->Flush();
+  RefPtr<DrawTarget> dt =
+    gfxPlatform::GetPlatform()->
+      CreateDrawTargetForSurface(imgSurface, IntSize(bmWidth, bmHeight));
+  if (!dt)
+    return false;
+
+  dt->FillRect(Rect(0, 0, bmWidth, bmHeight),
+               SurfacePattern(surface, ExtendMode::CLAMP),
+               DrawOptions(1.0f, CompositionOp::OP_SOURCE));
 
   BITMAPV5HEADER bmih;
   memset((void*)&bmih, 0, sizeof(BITMAPV5HEADER));
   bmih.bV5Size        = sizeof(BITMAPV5HEADER);
   bmih.bV5Width       = bmWidth;
   bmih.bV5Height      = -(int32_t)bmHeight; // flip vertical
   bmih.bV5Planes      = 1;
   bmih.bV5BitCount    = 32;
@@ -139,19 +131,17 @@ nsDragService::CreateDragImage(nsIDOMNod
 
   HDC hdcSrc = CreateCompatibleDC(nullptr);
   void *lpBits = nullptr;
   if (hdcSrc) {
     psdi->hbmpDragImage = 
     ::CreateDIBSection(hdcSrc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
                        (void**)&lpBits, nullptr, 0);
     if (psdi->hbmpDragImage && lpBits) {
-      CopySurfaceDataToPackedArray(map.mData, static_cast<uint8_t*>(lpBits),
-                                   dataSurface->GetSize(), map.mStride,
-                                   BytesPerPixel(dataSurface->GetFormat()));
+      memcpy(lpBits,imgSurface->Data(),(bmWidth*bmHeight*4));
     }
 
     psdi->sizeDragImage.cx = bmWidth;
     psdi->sizeDragImage.cy = bmHeight;
 
     // Mouse position in center
     if (mScreenX == -1 || mScreenY == -1) {
       psdi->ptOffset.x = (uint32_t)((float)bmWidth/2.0f);
@@ -161,17 +151,17 @@ nsDragService::CreateDragImage(nsIDOMNod
       ConvertToUnscaledDevPixels(pc, &sx, &sy);
       psdi->ptOffset.x = sx - dragRect.x;
       psdi->ptOffset.y = sy - dragRect.y;
     }
 
     DeleteDC(hdcSrc);
   }
 
-  dataSurface->Unmap();
+  data->Unmap();
 
   return psdi->hbmpDragImage != nullptr;
 }
 
 //-------------------------------------------------------------------------
 NS_IMETHODIMP
 nsDragService::InvokeDragSession(nsIDOMNode *aDOMNode,
                                  nsISupportsArray *anArrayTransferables,