From 696c8578e70f67e7e2938f3c1a065d439b60573d Mon Sep 17 00:00:00 2001 From: Ginn Chen Date: Wed, 24 Nov 2010 15:36:46 +0800 Subject: [PATCH] Bug 610852 Check xRGB format for XShm Image r=karlt a=benjamin --- widget/src/shared/nsShmImage.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/widget/src/shared/nsShmImage.cpp b/widget/src/shared/nsShmImage.cpp index 7d22721e88b3..d3ad64f196f0 100644 --- a/widget/src/shared/nsShmImage.cpp +++ b/widget/src/shared/nsShmImage.cpp @@ -110,11 +110,19 @@ nsShmImage::Create(const gfxIntSize& aSize, shm->mSize = aSize; switch (shm->mImage->depth) { case 24: - shm->mFormat = gfxASurface::ImageFormatRGB24; break; + // Only xRGB is supported. + if ((shm->mImage->red_mask == 0xff0000) && + (shm->mImage->green_mask == 0xff00) && + (shm->mImage->blue_mask == 0xff)) { + shm->mFormat = gfxASurface::ImageFormatRGB24; + break; + } + goto unsupported; case 16: shm->mFormat = gfxASurface::ImageFormatRGB16_565; break; + unsupported: default: - NS_WARNING("Unsupported XShm Image depth!"); + NS_WARNING("Unsupported XShm Image format!"); gShmAvailable = PR_FALSE; return nsnull; }