[maemo-commits] [maemo-commits] r17409 - in projects/haf/trunk/clutter: clutter/cogl/common debian
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Thu Feb 12 17:16:11 EET 2009
- Previous message: [maemo-commits] r17408 - in projects/haf/trunk/libmatchbox2: . matchbox/core
- Next message: [maemo-commits] r17410 - in projects/haf/trunk/dosfstools/debian: . patches
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: gw
Date: 2009-02-12 17:16:07 +0200 (Thu, 12 Feb 2009)
New Revision: 17409
Modified:
projects/haf/trunk/clutter/clutter/cogl/common/cogl-bitmap-fallback.c
projects/haf/trunk/clutter/clutter/cogl/common/cogl-bitmap-pixbuf.c
projects/haf/trunk/clutter/debian/changelog
Log:
* Fixed RGBA texture pixmaps in X11-texture-pixmap (format conversion hell)
Modified: projects/haf/trunk/clutter/clutter/cogl/common/cogl-bitmap-fallback.c
===================================================================
--- projects/haf/trunk/clutter/clutter/cogl/common/cogl-bitmap-fallback.c 2009-02-12 12:34:59 UTC (rev 17408)
+++ projects/haf/trunk/clutter/clutter/cogl/common/cogl-bitmap-fallback.c 2009-02-12 15:16:07 UTC (rev 17409)
@@ -184,7 +184,7 @@
_cogl_unpremult_alpha_last (const guchar *src, guchar *dst)
{
guchar alpha = src[3];
-
+
dst[0] = ((((gulong) src[0] >> 16) & 0xff) * 255 ) / alpha;
dst[1] = ((((gulong) src[1] >> 8) & 0xff) * 255 ) / alpha;
dst[2] = ((((gulong) src[2] >> 0) & 0xff) * 255 ) / alpha;
@@ -195,7 +195,7 @@
_cogl_unpremult_alpha_first (const guchar *src, guchar *dst)
{
guchar alpha = src[0];
-
+
dst[0] = alpha;
dst[1] = ((((gulong) src[1] >> 16) & 0xff) * 255 ) / alpha;
dst[2] = ((((gulong) src[2] >> 8) & 0xff) * 255 ) / alpha;
@@ -207,24 +207,24 @@
{
if (src == dst)
return FALSE;
-
+
switch (src & COGL_UNORDERED_MASK)
{
case COGL_PIXEL_FORMAT_G_8:
case COGL_PIXEL_FORMAT_RGB_888:
case COGL_PIXEL_FORMAT_RGBA_8888:
case COGL_PIXEL_FORMAT_RGB_565:
-
- if ((dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_24 &&
- (dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_32 &&
- (dst & COGL_UNORDERED_MASK) != COGL_PIXEL_FORMAT_G_8)
+
+ if ((dst & COGL_PIXEL_SIZE_MASK) != COGL_PIXEL_FORMAT_24 &&
+ (dst & COGL_PIXEL_SIZE_MASK) != COGL_PIXEL_FORMAT_32 &&
+ (dst & COGL_PIXEL_SIZE_MASK) != COGL_PIXEL_FORMAT_G_8)
return FALSE;
break;
-
+
default:
return FALSE;
}
-
+
return TRUE;
}
@@ -245,11 +245,11 @@
gint dst_bpp;
gint x,y;
guchar temp_rgba[4] = {0,0,0,0};
-
+
/* Make sure conversion supported */
if (!_cogl_bitmap_fallback_can_convert (bmp->format, dst_format))
return FALSE;
-
+
src_bpp = _cogl_get_format_bpp (bmp->format);
dst_bpp = _cogl_get_format_bpp (dst_format);
@@ -258,18 +258,18 @@
dst_bmp->rowstride = sizeof(guchar) * dst_bpp * dst_bmp->width;
dst_bmp->format = ((bmp->format & COGL_PREMULT_BIT) |
(dst_format & COGL_UNPREMULT_MASK));
-
+
/* Allocate a new buffer to hold converted data */
dst_bmp->data = g_malloc (sizeof(guchar)
* dst_bmp->height
* dst_bmp->rowstride);
-
+
/* FIXME: Optimize */
for (y = 0; y < bmp->height; y++)
{
src = (guchar*)bmp->data + y * bmp->rowstride;
dst = (guchar*)dst_bmp->data + y * dst_bmp->rowstride;
-
+
for (x = 0; x < bmp->width; x++)
{
/* FIXME: Would be nice to at least remove this inner
@@ -298,7 +298,7 @@
default:
break;
}
-
+
switch (dst_format & COGL_UNPREMULT_MASK)
{
case COGL_PIXEL_FORMAT_G_8:
@@ -318,12 +318,12 @@
default:
break;
}
-
+
src += src_bpp;
dst += dst_bpp;
}
}
-
+
return TRUE;
}
@@ -335,28 +335,28 @@
guchar *dst;
gint bpp;
gint x,y;
-
+
/* Make sure format supported for un-premultiplication */
if (!_cogl_bitmap_fallback_can_unpremult (bmp->format))
return FALSE;
-
+
bpp = _cogl_get_format_bpp (bmp->format);
-
+
/* Initialize destination bitmap */
*dst_bmp = *bmp;
dst_bmp->format = (bmp->format & COGL_UNPREMULT_MASK);
-
+
/* Allocate a new buffer to hold converted data */
dst_bmp->data = g_malloc (sizeof(guchar)
* dst_bmp->height
* dst_bmp->rowstride);
-
+
/* FIXME: Optimize */
for (y = 0; y < bmp->height; y++)
{
src = (guchar*)bmp->data + y * bmp->rowstride;
dst = (guchar*)dst_bmp->data + y * dst_bmp->rowstride;
-
+
for (x = 0; x < bmp->width; x++)
{
/* FIXME: Would be nice to at least remove this inner
@@ -376,12 +376,12 @@
else
_cogl_unpremult_alpha_last (src, dst);
}
-
+
src += bpp;
dst += bpp;
}
}
-
+
return TRUE;
}
Modified: projects/haf/trunk/clutter/clutter/cogl/common/cogl-bitmap-pixbuf.c
===================================================================
--- projects/haf/trunk/clutter/clutter/cogl/common/cogl-bitmap-pixbuf.c 2009-02-12 12:34:59 UTC (rev 17408)
+++ projects/haf/trunk/clutter/clutter/cogl/common/cogl-bitmap-pixbuf.c 2009-02-12 15:16:07 UTC (rev 17409)
@@ -60,35 +60,45 @@
gint src_bpp;
gint dst_bpp;
gboolean swap_bgr;
-
- swap_bgr = (bmp->format & COGL_BGR_BIT) != (dst_format & COGL_BGR_BIT);
+
+ /* FIXME: we could do some fancy preprocessor magic here so
+ * support formats in a much more sensible way?
+ *
+ * #define RGB888_GREEN(X) (x[1])
+ * #define RGB888_SET(X,R,G,B) X[0]=R;X[1]=G;X[2]=B;
+ * #define ...
+ * #define SWAP(A,B,FMT_FROM,FMT_TO) \
+ * for (x...) FMT_TO##_SET(X, FMT_FROM##GREEN, etc.)
+ */
+
+ swap_bgr = (bmp->format & COGL_BGR_BIT) != (dst_format & COGL_BGR_BIT);
src_bpp = _cogl_get_format_bpp (bmp->format);
dst_bpp = _cogl_get_format_bpp (dst_format);
-
+
/* special case for 16-bit X canvas that is faster than fallback */
- if ((bmp->format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGB_565 &&
- (dst_format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGB_888)
+ if ((bmp->format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGB_565 &&
+ (dst_format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGB_888)
{
-
+
/* Initialize destination bitmap */
*dst_bmp = *bmp;
dst_bmp->rowstride = sizeof(guchar) * dst_bpp * dst_bmp->width;
dst_bmp->format = ((bmp->format & COGL_PREMULT_BIT) |
(dst_format & COGL_UNPREMULT_MASK));
-
+
/* Allocate a new buffer to hold converted data */
dst_bmp->data = g_malloc (sizeof(guchar)
* dst_bmp->height
- * dst_bmp->rowstride);
+ * dst_bmp->rowstride);
if (swap_bgr) {
- for (ypos=0; ypos<bmp->height; ypos++)
+ for (ypos=0; ypos<bmp->height; ypos++)
{
guchar *src = (guchar*)bmp->data + ypos * bmp->rowstride;
guchar *dst = (guchar*)dst_bmp->data + ypos * dst_bmp->rowstride;
for (xpos=0; xpos<bmp->width; xpos++)
{
- gushort *c = (gushort*)src;
+ gushort *c = (gushort*)src;
dst[0] = (((*c >> 8) & 0xf8) | ((*c >> 5) & 0x7));
dst[1] = (((*c >> 3) & 0xfc) | ((*c >> 9) & 0x3));
dst[2] = (((*c << 3) & 0xf8) | ((*c >> 2) & 0x7));
@@ -97,7 +107,7 @@
}
}
} else {
- for (ypos=0; ypos<bmp->height; ypos++)
+ for (ypos=0; ypos<bmp->height; ypos++)
{
guchar *src = (guchar*)bmp->data + ypos * bmp->rowstride;
guchar *dst = (guchar*)dst_bmp->data + ypos * dst_bmp->rowstride;
@@ -111,184 +121,184 @@
dst += 3;
}
}
- }
+ }
return TRUE;
}
/* to 16 bit conversion without alpha */
if (((bmp->format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGB_888 ||
- (bmp->format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_8888) &&
- (dst_format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGB_565)
+ (bmp->format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_8888) &&
+ (dst_format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGB_565)
{
/* Initialize destination bitmap */
*dst_bmp = *bmp;
dst_bmp->rowstride = sizeof(guchar) * dst_bpp * dst_bmp->width;
dst_bmp->format = ((bmp->format & COGL_PREMULT_BIT) |
(dst_format & COGL_UNPREMULT_MASK));
-
+
/* Allocate a new buffer to hold converted data */
dst_bmp->data = g_malloc (sizeof(guchar)
* dst_bmp->height
- * dst_bmp->rowstride);
+ * dst_bmp->rowstride);
if (!swap_bgr) {
- for (ypos=0; ypos<bmp->height; ypos++)
+ for (ypos=0; ypos<bmp->height; ypos++)
{
guchar *src = (guchar*)bmp->data + ypos * bmp->rowstride;
gushort *dst = (gushort*)((guchar*)dst_bmp->data + ypos * dst_bmp->rowstride);
for (xpos=0; xpos<bmp->width; xpos++)
- {
- *dst = (src[2] >> 3) |
+ {
+ *dst = (src[2] >> 3) |
((src[1] & 0xFC) << 3) |
- ((src[0] & 0xF8) << 8);
+ ((src[0] & 0xF8) << 8);
src += src_bpp;
dst ++;
}
}
} else {
- for (ypos=0; ypos<bmp->height; ypos++)
+ for (ypos=0; ypos<bmp->height; ypos++)
{
guchar *src = (guchar*)bmp->data + ypos * bmp->rowstride;
gushort *dst = (gushort*)((guchar*)dst_bmp->data + ypos * dst_bmp->rowstride);
for (xpos=0; xpos<bmp->width; xpos++)
- {
- *dst = (src[0] >> 3) |
+ {
+ *dst = (src[0] >> 3) |
((src[1] & 0xFC) << 3) |
- ((src[2] & 0xF8) << 8);
+ ((src[2] & 0xF8) << 8);
src += src_bpp;
dst ++;
}
}
- }
- return TRUE;
+ }
+ return TRUE;
}
/* to 16 bit conversion WITH alpha */
- if ((bmp->format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_8888 &&
- (dst_format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_4444)
+ if ((bmp->format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_8888 &&
+ (dst_format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_4444)
{
/* Initialize destination bitmap */
*dst_bmp = *bmp;
dst_bmp->rowstride = sizeof(guchar) * dst_bpp * dst_bmp->width;
dst_bmp->format = ((bmp->format & COGL_PREMULT_BIT) |
(dst_format & COGL_UNPREMULT_MASK));
-
+
/* Allocate a new buffer to hold converted data */
dst_bmp->data = g_malloc (sizeof(guchar)
* dst_bmp->height
- * dst_bmp->rowstride);
+ * dst_bmp->rowstride);
if (!swap_bgr) {
- for (ypos=0; ypos<bmp->height; ypos++)
+ for (ypos=0; ypos<bmp->height; ypos++)
{
guchar *src = (guchar*)bmp->data + ypos * bmp->rowstride;
gushort *dst = (gushort*)((guchar*)dst_bmp->data + ypos * dst_bmp->rowstride);
for (xpos=0; xpos<bmp->width; xpos++)
{
- *dst = (src[3] >> 4) |
+ *dst = (src[3] >> 4) |
(src[2] & 0xF0) |
- ((src[1] & 0xF0) << 4) |
+ ((src[1] & 0xF0) << 4) |
((src[0] & 0xF0) << 8);
src += 4;
dst ++;
}
}
} else {
- for (ypos=0; ypos<bmp->height; ypos++)
+ for (ypos=0; ypos<bmp->height; ypos++)
{
guchar *src = (guchar*)bmp->data + ypos * bmp->rowstride;
gushort *dst = (gushort*)((guchar*)dst_bmp->data + ypos * dst_bmp->rowstride);
for (xpos=0; xpos<bmp->width; xpos++)
- {
- *dst = (src[1] >> 4) |
+ {
+ *dst = (src[1] >> 4) |
(src[2] & 0xF0) |
- ((src[3] & 0xF0) << 4) |
+ ((src[3] & 0xF0) << 4) |
((src[0] & 0xF0) << 8);
src += 4;
dst ++;
}
}
- }
- return TRUE;
+ }
+ return TRUE;
}
/* to 16 bit conversion WITH 1 bit alpha */
- if ((bmp->format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_8888 &&
- (dst_format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_5551)
+ if ((bmp->format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_8888 &&
+ (dst_format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_5551)
{
/* Initialize destination bitmap */
*dst_bmp = *bmp;
dst_bmp->rowstride = sizeof(guchar) * dst_bpp * dst_bmp->width;
dst_bmp->format = ((bmp->format & COGL_PREMULT_BIT) |
(dst_format & COGL_UNPREMULT_MASK));
-
+
/* Allocate a new buffer to hold converted data */
dst_bmp->data = g_malloc (sizeof(guchar)
* dst_bmp->height
- * dst_bmp->rowstride);
+ * dst_bmp->rowstride);
if (!swap_bgr) {
- for (ypos=0; ypos<bmp->height; ypos++)
+ for (ypos=0; ypos<bmp->height; ypos++)
{
guchar *src = (guchar*)bmp->data + ypos * bmp->rowstride;
gushort *dst = (gushort*)((guchar*)dst_bmp->data + ypos * dst_bmp->rowstride);
for (xpos=0; xpos<bmp->width; xpos++)
{
/* for reversed bit pattern in 5551
- *dst = (src[3] >> 3) |
+ *dst = (src[3] >> 3) |
((src[2] & 0xF8) << 2) |
- ((src[1] & 0xF8) << 7) |
+ ((src[1] & 0xF8) << 7) |
((src[0] & 0x80) << 8);*/
- *dst = ((src[0] & 0xF8) << 8) |
+ *dst = ((src[0] & 0xF8) << 8) |
((src[1] & 0xF8) << 3) |
- ((src[2] & 0xF8) >> 2) |
+ ((src[2] & 0xF8) >> 2) |
(src[3] >> 7);
src += 4;
dst ++;
}
}
} else {
- for (ypos=0; ypos<bmp->height; ypos++)
+ for (ypos=0; ypos<bmp->height; ypos++)
{
guchar *src = (guchar*)bmp->data + ypos * bmp->rowstride;
gushort *dst = (gushort*)((guchar*)dst_bmp->data + ypos * dst_bmp->rowstride);
for (xpos=0; xpos<bmp->width; xpos++)
- {
+ {
/*for reversed bit pattern in 5551
- *dst = (src[1] >> 3) |
+ *dst = (src[1] >> 3) |
((src[2] & 0xF8) << 2) |
- ((src[3] & 0xF8) << 7) |
+ ((src[3] & 0xF8) << 7) |
((src[0] & 0x80) << 8);*/
- *dst = ((src[2] & 0xF8) << 8) |
+ *dst = ((src[2] & 0xF8) << 8) |
((src[1] & 0xF8) << 3) |
- ((src[0] & 0xF8) >> 2) |
+ ((src[0] & 0xF8) >> 2) |
(src[3] >> 7);
src += 4;
dst ++;
}
}
- }
- return TRUE;
- }
+ }
+ return TRUE;
+ }
/* special case for RGBA -> RGB (used in hildon-desktop at least once) */
- if ((bmp->format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_8888 &&
- (dst_format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGB_888)
+ if ((bmp->format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_8888 &&
+ (dst_format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGB_888)
{
/* Initialize destination bitmap */
*dst_bmp = *bmp;
dst_bmp->rowstride = sizeof(guchar) * dst_bpp * dst_bmp->width;
dst_bmp->format = ((bmp->format & COGL_PREMULT_BIT) |
(dst_format & COGL_UNPREMULT_MASK));
-
+
/* Allocate a new buffer to hold converted data */
dst_bmp->data = g_malloc (sizeof(guchar)
* dst_bmp->height
- * dst_bmp->rowstride);
+ * dst_bmp->rowstride);
if (!swap_bgr) {
- for (ypos=0; ypos<bmp->height; ypos++)
+ for (ypos=0; ypos<bmp->height; ypos++)
{
guchar *src = (guchar*)bmp->data + ypos * bmp->rowstride;
guchar *dst = (guchar*)dst_bmp->data + ypos * dst_bmp->rowstride;
for (xpos=0; xpos<bmp->width; xpos++)
- {
+ {
dst[0] = src[0];
dst[1] = src[1];
dst[2] = src[2];
@@ -297,7 +307,7 @@
}
}
} else {
- for (ypos=0; ypos<bmp->height; ypos++)
+ for (ypos=0; ypos<bmp->height; ypos++)
{
guchar *src = (guchar*)bmp->data + ypos * bmp->rowstride;
guchar *dst = (guchar*)dst_bmp->data + ypos * dst_bmp->rowstride;
@@ -310,9 +320,42 @@
dst += dst_bpp;
}
}
- }
+ }
return TRUE;
}
+ /* case for RGBA->BGRA swapping */
+ if ((bmp->format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_8888 &&
+ (dst_format & COGL_UNORDERED_MASK)==COGL_PIXEL_FORMAT_RGBA_8888 &&
+ (bmp->format & COGL_BGR_BIT) != (dst_format & COGL_BGR_BIT))
+ {
+ /* Initialize destination bitmap */
+ *dst_bmp = *bmp;
+ dst_bmp->rowstride = sizeof(guchar) * dst_bpp * dst_bmp->width;
+ dst_bmp->format = ((bmp->format & COGL_PREMULT_BIT) |
+ (dst_format & COGL_UNPREMULT_MASK));
+
+ /* Allocate a new buffer to hold converted data */
+ dst_bmp->data = g_malloc (sizeof(guchar)
+ * dst_bmp->height
+ * dst_bmp->rowstride);
+
+ for (ypos=0; ypos<bmp->height; ypos++)
+ {
+ guchar *src = (guchar*)bmp->data + ypos * bmp->rowstride;
+ guchar *dst = (guchar*)dst_bmp->data + ypos * dst_bmp->rowstride;
+ for (xpos=0; xpos<bmp->width; xpos++)
+ {
+ dst[0] = src[2];
+ dst[1] = src[1];
+ dst[2] = src[0];
+ dst[3] = src[3];
+ src += src_bpp;
+ dst += dst_bpp;
+ }
+ }
+
+ return TRUE;
+ }
return FALSE;
}
@@ -327,16 +370,16 @@
* image */
void
_cogl_bitmap_check_alpha(CoglBitmap *bmp,
- gboolean *has_transparent,
+ gboolean *has_transparent,
gboolean *has_semi,
gboolean *has_opaque)
{
- gulong ctransparent = 0;
+ gulong ctransparent = 0;
gulong csemi = 0;
gulong copaque = 0;
gulong ctotal = 0;
guint xpos, ypos;
-
+
if (!bmp)
{
if (has_transparent) *has_transparent = TRUE;
@@ -345,7 +388,7 @@
return;
}
- if ((bmp->format & COGL_AFIRST_BIT) || (bmp->format & COGL_PREMULT_BIT))
+ if ((bmp->format & COGL_AFIRST_BIT) || (bmp->format & COGL_PREMULT_BIT))
{
g_warning("%s: Cannot cope with strangely ordered bitmaps", G_STRLOC);
if (has_transparent) *has_transparent = TRUE;
@@ -359,42 +402,42 @@
if (has_transparent) *has_transparent = FALSE;
if (has_semi) *has_semi = FALSE;
if (has_opaque) *has_opaque = TRUE;
- }
-
- if (_cogl_get_format_bpp (bmp->format) != 4)
+ }
+
+ if (_cogl_get_format_bpp (bmp->format) != 4)
{
g_warning("%s: Expecting only 32 bit bitmaps here", G_STRLOC);
return;
}
-
- for (ypos=0; ypos<bmp->height; ypos++)
+
+ for (ypos=0; ypos<bmp->height; ypos++)
{
guchar *src = (guchar*)(bmp->data) + ypos * bmp->rowstride + 3;
for (xpos=0; xpos<bmp->width; xpos++)
{
- /* If we're doing this, we'd be using 4 bit alpha anyway,
+ /* If we're doing this, we'd be using 4 bit alpha anyway,
* so allow ourselves some leeway in what we call transparent
* and opaque.
* as far as I know, C standard doesn't say a bool has to be
* between 0 and 1, so I use ternary to make sure. I *hope*
- * this gets optimised out */
+ * this gets optimised out */
ctransparent += ((*src) < 32) ? 1 : 0;
copaque += ((*src) >= 224) ? 1 : 0;
src += 4;
}
}
-
+
/* Now another fudge check... we only say we have something
* if there are >2% of the pixels set in that way */
-
+
ctotal = bmp->width*bmp->height;
csemi = ctotal - (ctransparent + copaque);
-
- if (has_transparent)
+
+ if (has_transparent)
*has_transparent = ctransparent > ctotal/50;
- if (has_semi)
+ if (has_semi)
*has_semi = csemi > ctotal/50;
- if (has_opaque)
+ if (has_opaque)
*has_opaque = copaque > ctotal/50;
}
@@ -403,14 +446,14 @@
CoglPixelFormat
_cogl_bitmap_get_16bit_format(CoglBitmap *bmp)
{
- if (bmp->format & COGL_A_BIT)
+ if (bmp->format & COGL_A_BIT)
{
/* kinda slow and ugly, but we have multiple formats we could use.
* we need to look at the image and see what pixel format
* suits it best, to get the max colour bits */
gboolean has_transparent, has_semi, has_opaque;
- _cogl_bitmap_check_alpha(bmp,
- &has_transparent,
+ _cogl_bitmap_check_alpha(bmp,
+ &has_transparent,
&has_semi,
&has_opaque);
if (has_semi)
@@ -550,15 +593,15 @@
gint last_row_size;
guchar *pixels;
guchar *out_data;
-
+
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (bmp == NULL) return FALSE;
-
+
/* Load from file using GdkPixbuf */
pixbuf = gdk_pixbuf_new_from_file (filename, error);
if (pixbuf == NULL) return FALSE;
-
+
/* Get pixbuf properties */
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
color_space = gdk_pixbuf_get_colorspace (pixbuf);
@@ -567,10 +610,10 @@
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
n_channels = gdk_pixbuf_get_n_channels (pixbuf);
-
+
/* The docs say this is the right way */
last_row_size = width * ((n_channels * bits_per_sample + 7) / 8);
-
+
/* According to current docs this should be true and so
* the translation to cogl pixel format below valid */
g_assert (bits_per_sample == 8);
@@ -579,7 +622,7 @@
g_assert (n_channels == 4);
else
g_assert (n_channels == 3);
-
+
/* Translate to cogl pixel format */
switch (color_space)
{
@@ -589,24 +632,24 @@
COGL_PIXEL_FORMAT_RGBA_8888 :
COGL_PIXEL_FORMAT_RGB_888;
break;
-
+
default:
/* Ouch, spec changed! */
g_object_unref (pixbuf);
return FALSE;
}
-
+
/* FIXME: Any way to destroy pixbuf but retain pixel data? */
-
+
pixels = gdk_pixbuf_get_pixels (pixbuf);
out_data = (guchar*) g_malloc (height * rowstride);
-
+
/* Copy the data... we need to do special things for the last row */
memcpy (out_data, pixels, rowstride*(height-1) + last_row_size);
-
+
/* Destroy GdkPixbuf object */
g_object_unref (pixbuf);
-
+
/* Store bitmap info */
bmp->data = out_data; /* The stored data the same alignment constraints as a
* gdkpixbuf but stores a full rowstride in the last
@@ -616,7 +659,7 @@
bmp->width = width;
bmp->height = height;
bmp->rowstride = rowstride;
-
+
return TRUE;
}
@@ -633,15 +676,15 @@
gint width;
gint height;
guchar *pixels;
-
+
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
if (bmp == NULL) return FALSE;
-
+
/* Load from file using stb */
pixels = stbi_load (filename, &width, &height, &stb_pixel_format, STBI_rgb_alpha);
if (pixels == NULL) return FALSE;
-
+
/* Store bitmap info */
bmp->data = g_memdup (pixels, height * width * 4);
bmp->format = COGL_PIXEL_FORMAT_RGBA_8888;
Modified: projects/haf/trunk/clutter/debian/changelog
===================================================================
--- projects/haf/trunk/clutter/debian/changelog 2009-02-12 12:34:59 UTC (rev 17408)
+++ projects/haf/trunk/clutter/debian/changelog 2009-02-12 15:16:07 UTC (rev 17409)
@@ -1,6 +1,7 @@
clutter (0.8.2-0maemo17~unreleased) unstable; urgency=low
* Removed needless print for scratchbox
+ * Fixed RGBA texture pixmaps in X11-texture-pixmap (format conversion hell)
-- Gordon Williams <gordon.williams at collabora.co.uk> Wed, 11 Feb 2009 09:24:53 +0200
- Previous message: [maemo-commits] r17408 - in projects/haf/trunk/libmatchbox2: . matchbox/core
- Next message: [maemo-commits] r17410 - in projects/haf/trunk/dosfstools/debian: . patches
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
