From 41539dd7f0793bd82ca35af06480132b45eb106e Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 18 Jul 2012 11:28:13 +0100 Subject: [PATCH] bitmap: Use the 'copy' blend mode when loading images on Quartz When loading images on Quartz, the image is rendered into a bitmap context using a buffer allocated with _cogl_bitmap_new_with_malloc_buffer. However this buffer is not initialised and by default Quartz will blend the source image with the destination so if there are transparent parts in the source image it will leave garbage in the destination. This patch changes the blend mode to 'copy' so that it won't try to blend. Before 5b785dd4 the buffer was cleared because it was allocated with g_malloc0 so it was working in that case. Presumably it should be more efficient to disable blending and avoid the clear though. https://bugzilla.gnome.org/show_bug.cgi?id=680124 Reviewed-by: Robert Bragg (cherry picked from commit 5ba7f4e6837a539d92cbe45491f79a8926fd6828) --- cogl/cogl-bitmap-pixbuf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cogl/cogl-bitmap-pixbuf.c b/cogl/cogl-bitmap-pixbuf.c index d30a8518e..ba31c56af 100644 --- a/cogl/cogl-bitmap-pixbuf.c +++ b/cogl/cogl-bitmap-pixbuf.c @@ -139,6 +139,8 @@ _cogl_bitmap_from_file (CoglContext *ctx, kCGImageAlphaPremultipliedFirst); CGColorSpaceRelease (color_space); + CGContextSetBlendMode (bitmap_context, kCGBlendModeCopy); + { const CGRect rect = {{0, 0}, {width, height}};