Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 1e48657f9c6819d651b1e0d657425de9fa3d0d98 1 parent 9d61125
rjw57-demo authored October 06, 2009

Showing 1 changed file with 18 additions and 1 deletion. Show diff stats Hide diff stats

  1. 19  firtree/firtree-cairo-surface-sampler.cc
19  firtree/firtree-cairo-surface-sampler.cc
@@ -295,18 +295,35 @@ _firtree_cairo_surface_sampler_create_sample_function(FirtreeCairoSurfaceSampler
295 295
 	    cairo_image_surface_get_format(p->cairo_surface);
296 296
 
297 297
 	FirtreeBufferFormat firtree_format = FIRTREE_FORMAT_LAST;
  298
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
298 299
 	switch (format) {
299 300
 	case CAIRO_FORMAT_ARGB32:
300 301
 		firtree_format = FIRTREE_FORMAT_BGRA32_PREMULTIPLIED;
301 302
 		break;
302 303
 	case CAIRO_FORMAT_RGB24:
303  
-		firtree_format = FIRTREE_FORMAT_XBGR32;
  304
+		firtree_format = FIRTREE_FORMAT_BGRX32;
304 305
 		break;
305 306
 	default:
306 307
 		g_debug("Unsupported Cairo image format.");
307 308
 		return NULL;
308 309
 		break;
309 310
 	}
  311
+#elif G_BYTE_ORDER == G_BIG_ENDIAN
  312
+	switch (format) {
  313
+	case CAIRO_FORMAT_ARGB32:
  314
+		firtree_format = FIRTREE_FORMAT_ARGB32_PREMULTIPLIED;
  315
+		break;
  316
+	case CAIRO_FORMAT_RGB24:
  317
+		firtree_format = FIRTREE_FORMAT_XRGB32;
  318
+		break;
  319
+	default:
  320
+		g_debug("Unsupported Cairo image format.");
  321
+		return NULL;
  322
+		break;
  323
+	}
  324
+#else
  325
+	#error Unknown endianness.
  326
+#endif
310 327
 
311 328
 	_firtree_cairo_surface_sampler_invalidate_llvm_cache(self);
312 329
 

0 notes on commit 1e48657

Please sign in to comment.
Something went wrong with that request. Please try again.