Backed out changeset 2959eddcd018, to fix oranges

This commit is contained in:
Oleg Romashin 2010-06-11 08:35:26 -04:00
parent cfe4ce6dd8
commit ff064189d9
9 changed files with 47 additions and 65 deletions

View File

@ -188,7 +188,7 @@ BasicPlanarYCbCrImage::GetAsSurface()
}
nsRefPtr<gfxImageSurface> imgSurface =
new gfxImageSurface(mBuffer, mSize,
mSize.width * gfxASurface::BytePerPixelFromFormat(gfxASurface::ImageFormatRGB24),
mSize.width * 4,
gfxASurface::ImageFormatRGB24);
if (!imgSurface) {
return nsnull;

View File

@ -68,7 +68,6 @@ 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;
@ -188,8 +187,6 @@ public:
PRInt32 KnownMemoryUsed() { return mBytesRecorded; }
static PRInt32 BytePerPixelFromFormat(gfxImageFormat format);
protected:
gfxASurface() : mSurface(nsnull), mFloatingRefs(0), mBytesRecorded(0), mSurfaceValid(PR_FALSE) { }

View File

@ -406,7 +406,6 @@ gfxASurface::ContentFromFormat(gfxImageFormat format)
case ImageFormatARGB32:
return CONTENT_COLOR_ALPHA;
case ImageFormatRGB24:
case ImageFormatRGB16_565:
return CONTENT_COLOR;
case ImageFormatA8:
case ImageFormatA1:
@ -418,23 +417,6 @@ 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[] = {

View File

@ -146,8 +146,6 @@ 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) {

View File

@ -171,6 +171,29 @@ 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
@ -179,13 +202,8 @@ 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 =
gfxXlibSurface::FindRenderFormat(display, imageFormat);
XRenderFindStandardFormat(display, xrenderFormatID);
if (xrenderFormat && sizeOk) {
pixmap = gdk_pixmap_new(nsnull, size.width, size.height,

View File

@ -194,11 +194,6 @@ 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();
@ -211,8 +206,29 @@ 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 =
gfxXlibSurface::FindRenderFormat(QX11Info().display(), imageFormat);
XRenderFindStandardFormat(QX11Info().display(), xrenderFormatID);
newSurface = new gfxXlibSurface((Display*)QX11Info().display(),
xrenderFormat,

View File

@ -158,28 +158,6 @@ 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;

View File

@ -105,8 +105,6 @@ _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:

View File

@ -210,8 +210,6 @@ _depth_to_gfximage_format(PRInt32 aDepth)
return gfxASurface::ImageFormatARGB32;
case 24:
return gfxASurface::ImageFormatRGB24;
case 16:
return gfxASurface::ImageFormatRGB16_565;
default:
return gfxASurface::ImageFormatUnknown;
}
@ -222,11 +220,8 @@ _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;
}