[cogl/wip/rib/cogl-1.12: 47/142] bitmap-pixbuf: Fix the bitmap loader on Quartz



commit 15eb306dae50e526e4240a622eb55886d3003da8
Author: Neil Roberts <neil linux intel com>
Date:   Wed Mar 21 13:34:32 2012 +0000

    bitmap-pixbuf: Fix the bitmap loader on Quartz
    
    The code for loading a CoglBitmap from a file was missed when
    upgrading to the new cogl_bitmap_new_for_data function in commit
    d18b59d9e6 so it wouldn't compile. This changes it to use
    _cogl_bitmap_new_with_malloc_buffer to allocate the buffer.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672533
    
    Reviewed-by: Robert Bragg <robert linux intel com>
    
    (cherry picked from commit 5b785dd441a83024333e0a2f2b83d067f891194f)

 cogl/cogl-bitmap-pixbuf.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/cogl/cogl-bitmap-pixbuf.c b/cogl/cogl-bitmap-pixbuf.c
index 025a940..3fa8b50 100644
--- a/cogl/cogl-bitmap-pixbuf.c
+++ b/cogl/cogl-bitmap-pixbuf.c
@@ -68,6 +68,9 @@ _cogl_bitmap_from_file (const char  *filename,
   guint8 *out_data;
   CGColorSpaceRef color_space;
   CGContextRef bitmap_context;
+  CoglBitmap *bmp;
+
+  _COGL_GET_CONTEXT (ctx, NULL);
 
   g_assert (filename != NULL);
   g_assert (error == NULL || *error == NULL);
@@ -123,8 +126,13 @@ _cogl_bitmap_from_file (const char  *filename,
     }
 
   /* allocate buffer big enough to hold pixel data */
-  rowstride = 4 * width;
-  out_data = g_malloc0 (height * rowstride);
+  bmp = _cogl_bitmap_new_with_malloc_buffer (ctx,
+                                             width, height,
+                                             COGL_PIXEL_FORMAT_ARGB_8888);
+  rowstride = cogl_bitmap_get_rowstride (bmp);
+  out_data = _cogl_bitmap_map (bmp,
+                               COGL_BUFFER_ACCESS_WRITE,
+                               COGL_BUFFER_MAP_HINT_DISCARD);
 
   /* render to buffer */
   color_space = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB);
@@ -143,13 +151,10 @@ _cogl_bitmap_from_file (const char  *filename,
   CGImageRelease (image);
   CGContextRelease (bitmap_context);
 
+  _cogl_bitmap_unmap (bmp);
+
   /* store bitmap info */
-  return _cogl_bitmap_new_from_data (out_data,
-                                     COGL_PIXEL_FORMAT_ARGB_8888,
-                                     width, height,
-                                     rowstride,
-                                     (CoglBitmapDestroyNotify) g_free,
-                                     NULL);
+  return bmp;
 }
 
 #elif defined(USE_GDKPIXBUF)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]