Permalink
Browse files

Fix byte ordering of cairo surfaces. It was wrong for big endian and …

…the RGB24 format was just plain wrong for everything.
  • Loading branch information...
rjw57-demo committed Oct 6, 2009
1 parent 9d61125 commit 1e48657f9c6819d651b1e0d657425de9fa3d0d98
Showing with 18 additions and 1 deletion.
  1. +18 −1 firtree/firtree-cairo-surface-sampler.cc
@@ -295,18 +295,35 @@ _firtree_cairo_surface_sampler_create_sample_function(FirtreeCairoSurfaceSampler
cairo_image_surface_get_format(p->cairo_surface);
FirtreeBufferFormat firtree_format = FIRTREE_FORMAT_LAST;
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
switch (format) {
case CAIRO_FORMAT_ARGB32:
firtree_format = FIRTREE_FORMAT_BGRA32_PREMULTIPLIED;
break;
case CAIRO_FORMAT_RGB24:
- firtree_format = FIRTREE_FORMAT_XBGR32;
+ firtree_format = FIRTREE_FORMAT_BGRX32;
break;
default:
g_debug("Unsupported Cairo image format.");
return NULL;
break;
}
+#elif G_BYTE_ORDER == G_BIG_ENDIAN
+ switch (format) {
+ case CAIRO_FORMAT_ARGB32:
+ firtree_format = FIRTREE_FORMAT_ARGB32_PREMULTIPLIED;
+ break;
+ case CAIRO_FORMAT_RGB24:
+ firtree_format = FIRTREE_FORMAT_XRGB32;
+ break;
+ default:
+ g_debug("Unsupported Cairo image format.");
+ return NULL;
+ break;
+ }
+#else
+ #error Unknown endianness.
+#endif
_firtree_cairo_surface_sampler_invalidate_llvm_cache(self);

0 comments on commit 1e48657

Please sign in to comment.