Backed out changeset fe2afc55a0d1 (bug 950368) for shutdown crashes on B2G
authorEd Morley <emorley@mozilla.com>
Wed, 05 Mar 2014 17:10:38 +0000
changeset 189271 6ae5d97fc882f784625c49d89778ded07817e85f
parent 189270 e88cd5f09c3d89ccef18cf95f3da589db3587749
child 189272 544d3e2f8f7b8173086643ddcd928b3273ebb777
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs950368
milestone30.0a1
backs outfe2afc55a0d1d231c7aef79d8d5fc8ef206bc43e
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 fe2afc55a0d1 (bug 950368) for shutdown crashes on B2G
browser/components/shell/src/nsWindowsShellService.cpp
gfx/thebes/gfxImageSurface.h
--- a/browser/components/shell/src/nsWindowsShellService.cpp
+++ b/browser/components/shell/src/nsWindowsShellService.cpp
@@ -1,17 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "imgIContainer.h"
 #include "imgIRequest.h"
-#include "mozilla/gfx/2D.h"
-#include "mozilla/RefPtr.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMHTMLImageElement.h"
 #include "nsIImageLoadingContent.h"
 #include "nsIPrefService.h"
 #include "nsIPrefLocalizedString.h"
 #include "nsIServiceManager.h"
 #include "nsIStringBundle.h"
 #include "nsNetUtil.h"
@@ -52,18 +50,16 @@
   (val == ERROR_SUCCESS)
 
 #define REG_FAILED(val) \
   (val != ERROR_SUCCESS)
 
 #define NS_TASKBAR_CONTRACTID "@mozilla.org/windows-taskbar;1"
 
 using mozilla::IsWin8OrLater;
-using namespace mozilla;
-using namespace mozilla::gfx;
 
 NS_IMPL_ISUPPORTS2(nsWindowsShellService, nsIWindowsShellService, nsIShellService)
 
 static nsresult
 OpenKeyForReading(HKEY aKeyRoot, const nsAString& aKeyName, HKEY* aKey)
 {
   const nsString &flatName = PromiseFlatString(aKeyName);
 
@@ -748,51 +744,42 @@ nsWindowsShellService::SetShouldCheckDef
   return prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck);
 }
 
 static nsresult
 WriteBitmap(nsIFile* aFile, imgIContainer* aImage)
 {
   nsresult rv;
 
-  nsRefPtr<gfxASurface> thebesSurface =
+  nsRefPtr<gfxASurface> surface =
     aImage->GetFrame(imgIContainer::FRAME_FIRST,
                      imgIContainer::FLAG_SYNC_DECODE);
-  NS_ENSURE_TRUE(thebesSurface, NS_ERROR_FAILURE);
+  NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE);
 
-  nsRefPtr<gfxImageSurface> thebesImageSurface =
-    thebesSurface->GetAsReadableARGB32ImageSurface();
-  NS_ENSURE_TRUE(thebesImageSurface, NS_ERROR_FAILURE);
-
-  RefPtr<DataSourceSurface> dataSurface =
-    thebesImageSurface->CopyToB8G8R8A8DataSourceSurface();
-  NS_ENSURE_TRUE(dataSurface, NS_ERROR_FAILURE);
+  nsRefPtr<gfxImageSurface> image(surface->GetAsReadableARGB32ImageSurface());
+  NS_ENSURE_TRUE(image, NS_ERROR_FAILURE);
 
-  DataSourceSurface::MappedSurface map;
-  dataSurface->Map(DataSourceSurface::MapType::READ, &map);
-  if (!map.mData) {
-    return NS_ERROR_FAILURE;
-  }
+  int32_t width = image->Width();
+  int32_t height = image->Height();
 
-  int32_t width = dataSurface->GetSize().width;
-  int32_t height = dataSurface->GetSize().height;
-  int32_t bytesPerPixel = 4 * sizeof(uint8_t);
-  uint32_t bytesPerRow = bytesPerPixel * width;
-  uint32_t length = map.mStride * height;
+  uint8_t* bits = image->Data();
+  uint32_t length = image->GetDataSize();
+  uint32_t bpr = uint32_t(image->Stride());
+  int32_t bitCount = bpr/width;
 
   // initialize these bitmap structs which we will later
   // serialize directly to the head of the bitmap file
   BITMAPINFOHEADER bmi;
   bmi.biSize = sizeof(BITMAPINFOHEADER);
   bmi.biWidth = width;
   bmi.biHeight = height;
   bmi.biPlanes = 1;
-  bmi.biBitCount = (WORD)bytesPerPixel*8;
+  bmi.biBitCount = (WORD)bitCount*8;
   bmi.biCompression = BI_RGB;
-  bmi.biSizeImage = bytesPerRow * height;
+  bmi.biSizeImage = length;
   bmi.biXPelsPerMeter = 0;
   bmi.biYPelsPerMeter = 0;
   bmi.biClrUsed = 0;
   bmi.biClrImportant = 0;
 
   BITMAPFILEHEADER bf;
   bf.bfType = 0x4D42; // 'BM'
   bf.bfReserved1 = 0;
@@ -812,19 +799,19 @@ WriteBitmap(nsIFile* aFile, imgIContaine
     stream->Write((const char*)&bf, sizeof(BITMAPFILEHEADER), &written);
     if (written == sizeof(BITMAPFILEHEADER)) {
       stream->Write((const char*)&bmi, sizeof(BITMAPINFOHEADER), &written);
       if (written == sizeof(BITMAPINFOHEADER)) {
         // write out the image data backwards because the desktop won't
         // show bitmaps with negative heights for top-to-bottom
         uint32_t i = length;
         do {
-          i -= map.mStride;
-          stream->Write(((const char*)map.mData) + i, bytesPerRow, &written);
-          if (written == bytesPerRow) {
+          i -= bpr;
+          stream->Write(((const char*)bits) + i, bpr, &written);
+          if (written == bpr) {
             rv = NS_OK;
           } else {
             rv = NS_ERROR_FAILURE;
             break;
           }
         } while (i != 0);
       }
     }
--- a/gfx/thebes/gfxImageSurface.h
+++ b/gfx/thebes/gfxImageSurface.h
@@ -107,19 +107,18 @@ public:
     /**
      * Fast copy to a source surface; returns TRUE if successful, FALSE otherwise
      * Assumes that the format of this surface is compatible with aSurface
      */
     bool CopyTo (mozilla::gfx::SourceSurface *aSurface);
 
     /**
      * Copy to a Moz2D DataSourceSurface.
-     * Marked as virtual so that browsercomps can access this method.
      */
-    virtual mozilla::TemporaryRef<mozilla::gfx::DataSourceSurface> CopyToB8G8R8A8DataSourceSurface();
+    mozilla::TemporaryRef<mozilla::gfx::DataSourceSurface> CopyToB8G8R8A8DataSourceSurface();
 
     /* return new Subimage with pointing to original image starting from aRect.pos
      * and size of aRect.size. New subimage keeping current image reference
      */
     already_AddRefed<gfxSubimageSurface> GetSubimage(const gfxRect& aRect);
 
     virtual already_AddRefed<gfxImageSurface> GetAsImageSurface();