From aea08d0bde00ec76f8b657ab0aabd9288e67e298 Mon Sep 17 00:00:00 2001 From: Sotaro Ikeda Date: Thu, 30 Jan 2014 11:17:10 -0500 Subject: [PATCH] Bug 964976 - Prevent crash of unsupported pixel format gralloc allocation. r=nical --- gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp index 884d780bb148..73bbf11c52c5 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp +++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp @@ -172,6 +172,9 @@ PixelFormatForImageFormat(gfxImageFormat aFormat) return android::PIXEL_FORMAT_RGBX_8888; case gfxImageFormat::RGB16_565: return android::PIXEL_FORMAT_RGB_565; + case gfxImageFormat::A8: + NS_WARNING("gralloc does not support gfxImageFormat::A8"); + return android::PIXEL_FORMAT_UNKNOWN; default: MOZ_CRASH("Unknown gralloc pixel format"); } @@ -430,6 +433,10 @@ ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfx::IntSize& aSize, PGrallocBufferChild* gc; bool defaultRBSwap; + if (PixelFormatForContentType(aContent) == android::PIXEL_FORMAT_UNKNOWN) { + return false; + } + if (aCaps & USING_GL_RENDERING_ONLY) { gc = AllocGrallocBuffer(aSize, PixelFormatForContentType(aContent),