Bug 610852 Check xRGB format for XShm Image r=karlt a=benjamin

This commit is contained in:
Ginn Chen 2010-11-24 15:36:46 +08:00
parent 79ff7cd658
commit 696c8578e7

View File

@ -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;
}