Bug 721489 - Make gfxSharedImageSurface divisible by 64 on mobile
authorBenoit Girard <b56girard@gmail.com>
Fri, 10 Feb 2012 15:13:02 -0500
changeset 92430 02a93a9ff51a5184fc9101ef2aebfc1c614a64f7
parent 92429 295fbbce99f057ba5b207025a90a76c163b72d25
child 92431 731ab9e54b5e48f35d7da1af101e9e807214ef72
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs721489
milestone13.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 721489 - Make gfxSharedImageSurface divisible by 64 on mobile
gfx/thebes/gfxSharedImageSurface.cpp
gfx/thebes/gfxSharedImageSurface.h
--- a/gfx/thebes/gfxSharedImageSurface.cpp
+++ b/gfx/thebes/gfxSharedImageSurface.cpp
@@ -75,17 +75,23 @@ gfxSharedImageSurface::IsSharedImage(gfx
 gfxSharedImageSurface::gfxSharedImageSurface(const gfxIntSize& aSize,
                                              gfxImageFormat aFormat,
                                              const Shmem& aShmem)
 {
     MOZ_COUNT_CTOR(gfxSharedImageSurface);
 
     mSize = aSize;
     mFormat = aFormat;
-    mStride = ComputeStride(aSize, aFormat);
+
+    int w = aSize.width;
+    int h = aSize.height;
+    if ((aSize.width%MOZ_IMG_MEM_ALIGN) != 0)
+      w = aSize.width + MOZ_IMG_MEM_ALIGN - (aSize.width%MOZ_IMG_MEM_ALIGN);
+    mStride = ComputeStride(gfxIntSize(w, h), aFormat);
+
     mShmem = aShmem;
     mData = aShmem.get<unsigned char>();
     cairo_surface_t *surface =
         cairo_image_surface_create_for_data(mData,
                                             (cairo_format_t)mFormat,
                                             mSize.width,
                                             mSize.height,
                                             mStride);
--- a/gfx/thebes/gfxSharedImageSurface.h
+++ b/gfx/thebes/gfxSharedImageSurface.h
@@ -34,16 +34,24 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef GFX_SHARED_IMAGESURFACE_H
 #define GFX_SHARED_IMAGESURFACE_H
 
+#if ANDROID
+ // Using an 64 align prevents us from crashing in driver
+ // code when doing RGB565 uploads. See bug 721489
+ #define MOZ_IMG_MEM_ALIGN 64
+#else
+ #define MOZ_IMG_MEM_ALIGN 1
+#endif
+
 #include "mozilla/ipc/Shmem.h"
 #include "mozilla/ipc/SharedMemory.h"
 
 #include "gfxASurface.h"
 #include "gfxImageSurface.h"
 
 class THEBES_API gfxSharedImageSurface : public gfxImageSurface {
     typedef mozilla::ipc::SharedMemory SharedMemory;
@@ -109,16 +117,24 @@ private:
            SharedMemory::SharedMemoryType aShmType)
     {
         if (!CheckSurfaceSize(aSize))
             return nsnull;
 
         Shmem shmem;
         long stride = ComputeStride(aSize, aFormat);
         size_t size = GetAlignedSize(aSize, stride);
+
+        int w = aSize.width;
+        int h = aSize.height;
+        if ((aSize.width%MOZ_IMG_MEM_ALIGN) != 0)
+          w = aSize.width + MOZ_IMG_MEM_ALIGN - (aSize.width%MOZ_IMG_MEM_ALIGN);
+        stride = ComputeStride(gfxIntSize(w, h), aFormat);
+        size = GetAlignedSize(aSize, stride);
+
         if (!Unsafe) {
             if (!aAllocator->AllocShmem(size, aShmType, &shmem))
                 return nsnull;
         } else {
             if (!aAllocator->AllocUnsafeShmem(size, aShmType, &shmem))
                 return nsnull;
         }