mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-19 09:30:44 +00:00
Bug 545632 - Add 16bpp format support enabler. r=jmuizelaar
This commit is contained in:
parent
127e306e75
commit
2f5e014ed0
@ -188,7 +188,7 @@ BasicPlanarYCbCrImage::GetAsSurface()
|
||||
}
|
||||
nsRefPtr<gfxImageSurface> imgSurface =
|
||||
new gfxImageSurface(mBuffer, mSize,
|
||||
mSize.width * 4,
|
||||
mSize.width * gfxASurface::BytePerPixelFromFormat(gfxASurface::ImageFormatRGB24),
|
||||
gfxASurface::ImageFormatRGB24);
|
||||
if (!imgSurface) {
|
||||
return nsnull;
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
ImageFormatRGB24, ///< xRGB data in native endianness
|
||||
ImageFormatA8, ///< Only an alpha channel
|
||||
ImageFormatA1, ///< Packed transparency information (one byte refers to 8 pixels)
|
||||
ImageFormatRGB16_565, ///< RGB_565 data in native endianness
|
||||
ImageFormatUnknown
|
||||
} gfxImageFormat;
|
||||
|
||||
@ -187,6 +188,8 @@ public:
|
||||
|
||||
PRInt32 KnownMemoryUsed() { return mBytesRecorded; }
|
||||
|
||||
static PRInt32 BytePerPixelFromFormat(gfxImageFormat format);
|
||||
|
||||
protected:
|
||||
gfxASurface() : mSurface(nsnull), mFloatingRefs(0), mBytesRecorded(0), mSurfaceValid(PR_FALSE) { }
|
||||
|
||||
|
@ -406,6 +406,7 @@ gfxASurface::ContentFromFormat(gfxImageFormat format)
|
||||
case ImageFormatARGB32:
|
||||
return CONTENT_COLOR_ALPHA;
|
||||
case ImageFormatRGB24:
|
||||
case ImageFormatRGB16_565:
|
||||
return CONTENT_COLOR;
|
||||
case ImageFormatA8:
|
||||
case ImageFormatA1:
|
||||
@ -417,6 +418,23 @@ gfxASurface::ContentFromFormat(gfxImageFormat format)
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32
|
||||
gfxASurface::BytePerPixelFromFormat(gfxImageFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case ImageFormatARGB32:
|
||||
case ImageFormatRGB24:
|
||||
return 4;
|
||||
case ImageFormatRGB16_565:
|
||||
return 2;
|
||||
case ImageFormatA8:
|
||||
return 1;
|
||||
default:
|
||||
NS_WARNING("Unknown byte per pixel value for Image format");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Memory reporting **/
|
||||
|
||||
static const char *sSurfaceNamesForSurfaceType[] = {
|
||||
|
@ -146,6 +146,8 @@ gfxImageSurface::ComputeStride() const
|
||||
stride = mSize.width * 4;
|
||||
else if (mFormat == ImageFormatRGB24)
|
||||
stride = mSize.width * 4;
|
||||
else if (mFormat == ImageFormatRGB16_565)
|
||||
stride = mSize.width * 2;
|
||||
else if (mFormat == ImageFormatA8)
|
||||
stride = mSize.width;
|
||||
else if (mFormat == ImageFormatA1) {
|
||||
|
@ -171,29 +171,6 @@ gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size,
|
||||
sizeOk = PR_FALSE;
|
||||
|
||||
#ifdef MOZ_X11
|
||||
int glitzf;
|
||||
int xrenderFormatID;
|
||||
switch (imageFormat) {
|
||||
case gfxASurface::ImageFormatARGB32:
|
||||
glitzf = 0; // GLITZ_STANDARD_ARGB32;
|
||||
xrenderFormatID = PictStandardARGB32;
|
||||
break;
|
||||
case gfxASurface::ImageFormatRGB24:
|
||||
glitzf = 1; // GLITZ_STANDARD_RGB24;
|
||||
xrenderFormatID = PictStandardRGB24;
|
||||
break;
|
||||
case gfxASurface::ImageFormatA8:
|
||||
glitzf = 2; // GLITZ_STANDARD_A8;
|
||||
xrenderFormatID = PictStandardA8;
|
||||
break;
|
||||
case gfxASurface::ImageFormatA1:
|
||||
glitzf = 3; // GLITZ_STANDARD_A1;
|
||||
xrenderFormatID = PictStandardA1;
|
||||
break;
|
||||
default:
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// XXX we really need a different interface here, something that passes
|
||||
// in more context, including the display and/or target surface type that
|
||||
// we should try to match
|
||||
@ -202,8 +179,13 @@ gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size,
|
||||
return nsnull;
|
||||
|
||||
GdkPixmap* pixmap = nsnull;
|
||||
// try to optimize it for 16bpp default screen
|
||||
if (gfxASurface::ImageFormatRGB24 == imageFormat
|
||||
&& 16 == gdk_visual_get_system()->depth)
|
||||
imageFormat = gfxASurface::ImageFormatRGB16_565;
|
||||
|
||||
XRenderPictFormat* xrenderFormat =
|
||||
XRenderFindStandardFormat(display, xrenderFormatID);
|
||||
gfxXlibSurface::FindRenderFormat(display, imageFormat);
|
||||
|
||||
if (xrenderFormat && sizeOk) {
|
||||
pixmap = gdk_pixmap_new(nsnull, size.width, size.height,
|
||||
|
@ -194,6 +194,11 @@ gfxQtPlatform::CreateOffscreenSurface(const gfxIntSize& size,
|
||||
{
|
||||
nsRefPtr<gfxASurface> newSurface = nsnull;
|
||||
|
||||
// try to optimize it for 16bpp screen
|
||||
if (gfxASurface::ImageFormatRGB24 == imageFormat
|
||||
&& 16 == QX11Info().depth())
|
||||
imageFormat = gfxASurface::ImageFormatRGB16_565;
|
||||
|
||||
if (mRenderMode == RENDER_QPAINTER) {
|
||||
newSurface = new gfxQPainterSurface(size, gfxASurface::ContentFromFormat(imageFormat));
|
||||
return newSurface.forget();
|
||||
@ -206,29 +211,8 @@ gfxQtPlatform::CreateOffscreenSurface(const gfxIntSize& size,
|
||||
}
|
||||
|
||||
#ifdef MOZ_X11
|
||||
int xrenderFormatID = -1;
|
||||
switch (imageFormat) {
|
||||
case gfxASurface::ImageFormatARGB32:
|
||||
xrenderFormatID = PictStandardARGB32;
|
||||
break;
|
||||
case gfxASurface::ImageFormatRGB24:
|
||||
xrenderFormatID = PictStandardRGB24;
|
||||
break;
|
||||
case gfxASurface::ImageFormatA8:
|
||||
xrenderFormatID = PictStandardA8;
|
||||
break;
|
||||
case gfxASurface::ImageFormatA1:
|
||||
xrenderFormatID = PictStandardA1;
|
||||
break;
|
||||
default:
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// XXX we really need a different interface here, something that passes
|
||||
// in more context, including the display and/or target surface type that
|
||||
// we should try to match
|
||||
XRenderPictFormat* xrenderFormat =
|
||||
XRenderFindStandardFormat(QX11Info().display(), xrenderFormatID);
|
||||
gfxXlibSurface::FindRenderFormat(QX11Info().display(), imageFormat);
|
||||
|
||||
newSurface = new gfxXlibSurface((Display*)QX11Info().display(),
|
||||
xrenderFormat,
|
||||
|
@ -158,6 +158,28 @@ gfxXlibSurface::FindRenderFormat(Display *dpy, gfxImageFormat format)
|
||||
case ImageFormatRGB24:
|
||||
return XRenderFindStandardFormat (dpy, PictStandardRGB24);
|
||||
break;
|
||||
case ImageFormatRGB16_565: {
|
||||
// PictStandardRGB16_565 is not standard Xrender format
|
||||
// we should try to find related visual
|
||||
// and find xrender format by visual
|
||||
Visual *visual = NULL;
|
||||
Screen *screen = DefaultScreenOfDisplay(dpy);
|
||||
int j;
|
||||
for (j = 0; j < screen->ndepths; j++) {
|
||||
Depth *d = &screen->depths[j];
|
||||
if (d->depth == 16 && d->nvisuals && &d->visuals[0]) {
|
||||
if (d->visuals[0].red_mask == 0xf800 &&
|
||||
d->visuals[0].green_mask == 0x7e0 &&
|
||||
d->visuals[0].blue_mask == 0x1f)
|
||||
visual = &d->visuals[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!visual)
|
||||
return NULL;
|
||||
return XRenderFindVisualFormat(dpy, visual);
|
||||
break;
|
||||
}
|
||||
case ImageFormatA8:
|
||||
return XRenderFindStandardFormat (dpy, PictStandardA8);
|
||||
break;
|
||||
|
@ -105,6 +105,8 @@ _qimage_from_gfximage_format (gfxASurface::gfxImageFormat aFormat)
|
||||
return QImage::Format_ARGB32_Premultiplied;
|
||||
case gfxASurface::ImageFormatRGB24:
|
||||
return QImage::Format_RGB32;
|
||||
case gfxASurface::ImageFormatRGB16_565:
|
||||
return QImage::Format_RGB16;
|
||||
case gfxASurface::ImageFormatA8:
|
||||
return QImage::Format_Indexed8;
|
||||
case gfxASurface::ImageFormatA1:
|
||||
|
@ -210,6 +210,8 @@ _depth_to_gfximage_format(PRInt32 aDepth)
|
||||
return gfxASurface::ImageFormatARGB32;
|
||||
case 24:
|
||||
return gfxASurface::ImageFormatRGB24;
|
||||
case 16:
|
||||
return gfxASurface::ImageFormatRGB16_565;
|
||||
default:
|
||||
return gfxASurface::ImageFormatUnknown;
|
||||
}
|
||||
@ -220,8 +222,11 @@ _gfximage_to_qformat(gfxASurface::gfxImageFormat aFormat)
|
||||
{
|
||||
switch (aFormat) {
|
||||
case gfxASurface::ImageFormatARGB32:
|
||||
return QImage::Format_ARGB32_Premultiplied;
|
||||
case gfxASurface::ImageFormatRGB24:
|
||||
return QImage::Format_ARGB32;
|
||||
case gfxASurface::ImageFormatRGB16_565:
|
||||
return QImage::Format_RGB16;
|
||||
default:
|
||||
return QImage::Format_Invalid;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user