From bbca7c48111e4cac172ba1edd11cd2adc36a74fd Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Mon, 27 Sep 2010 19:59:43 -0500 Subject: [PATCH] Bug 599562: Allocate cross-process layers surfaces from SyS V shm instead of /dev/shm to avoid being arbitrarily capped on maemo5/N900. r=stuart a=blocking-fennec --- gfx/layers/ipc/ShadowLayers.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/gfx/layers/ipc/ShadowLayers.cpp b/gfx/layers/ipc/ShadowLayers.cpp index fcd7138a053..e1c324f0695 100644 --- a/gfx/layers/ipc/ShadowLayers.cpp +++ b/gfx/layers/ipc/ShadowLayers.cpp @@ -43,12 +43,15 @@ #include "gfxSharedImageSurface.h" +#include "mozilla/ipc/SharedMemorySysV.h" #include "mozilla/layers/PLayerChild.h" #include "mozilla/layers/PLayersChild.h" #include "mozilla/layers/PLayersParent.h" #include "ShadowLayers.h" #include "ShadowLayerChild.h" +using namespace mozilla::ipc; + namespace mozilla { namespace layers { @@ -382,6 +385,21 @@ OptimalFormatFor(gfxASurface::gfxContentType aContent) } } +static SharedMemory::SharedMemoryType +OptimalShmemType() +{ +#if defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_HAVE_SHAREDMEMORYSYSV) + // Use SysV memory because maemo5 on the N900 only allots 64MB to + // /dev/shm, even though it has 1GB(!!) of system memory. Sys V shm + // is allocated from a different pool. We don't want an arbitrary + // cap that's much much lower than available memory on the memory we + // use for layers. + return SharedMemory::TYPE_SYSV; +#else + return SharedMemory::TYPE_BASIC; +#endif +} + PRBool ShadowLayerForwarder::AllocDoubleBuffer(const gfxIntSize& aSize, gfxASurface::gfxContentType aContent, @@ -391,10 +409,12 @@ ShadowLayerForwarder::AllocDoubleBuffer(const gfxIntSize& aSize, NS_ABORT_IF_FALSE(HasShadowManager(), "no manager to forward to"); gfxASurface::gfxImageFormat format = OptimalFormatFor(aContent); + SharedMemory::SharedMemoryType shmemType = OptimalShmemType(); + nsRefPtr front = new gfxSharedImageSurface(); nsRefPtr back = new gfxSharedImageSurface(); - if (!front->Init(mShadowManager, aSize, format) || - !back->Init(mShadowManager, aSize, format)) + if (!front->Init(mShadowManager, aSize, format, shmemType) || + !back->Init(mShadowManager, aSize, format, shmemType)) return PR_FALSE; *aFrontBuffer = NULL; *aBackBuffer = NULL;