mirror of
https://github.com/brl/mutter.git
synced 2025-06-14 01:09:30 +00:00
Add a public cogl_bitmap_new_for_data
This creates a CoglBitmap which points into an existing buffer in system memory. That way it can be used to create a texture or to read pixel data into. The function replaces the existing internal function _cogl_bitmap_new_from_data but removes the destroy notify call back. If the application wants notification of destruction it can just use the cogl_object_set_user_data function as normal. Internally there is now a convenience function to create a bitmap for system memory and automatically free the buffer using that mechanism. The name of the function is inspired by cairo_image_surface_create_for_data which has similar semantics. Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
@ -33,43 +33,27 @@
|
||||
#include "cogl-bitmap.h"
|
||||
|
||||
/*
|
||||
* CoglBitmapDestroyNotify:
|
||||
* @data: The image data
|
||||
* @destroy_data: The callback closure data that was given to
|
||||
* _cogl_bitmap_new_from_data().
|
||||
* _cogl_bitmap_new_with_malloc_buffer:
|
||||
* @context: A #CoglContext
|
||||
* @width: width of the bitmap in pixels
|
||||
* @height: height of the bitmap in pixels
|
||||
* @format: the format of the pixels the array will store
|
||||
*
|
||||
* Function prototype that is used to destroy the bitmap data when
|
||||
* _cogl_bitmap_new_from_data() is called.
|
||||
*/
|
||||
typedef void (* CoglBitmapDestroyNotify) (guint8 *data, void *destroy_data);
|
||||
|
||||
/*
|
||||
* _cogl_bitmap_new_from_data:
|
||||
* @data: A pointer to the data. The bitmap will take ownership of this data.
|
||||
* @format: The format of the pixel data.
|
||||
* @width: The width of the bitmap.
|
||||
* @height: The height of the bitmap.
|
||||
* @rowstride: The rowstride of the bitmap (the number of bytes from
|
||||
* the start of one row of the bitmap to the next).
|
||||
* @destroy_fn: A function to be called when the bitmap is
|
||||
* destroyed. This should free @data. %NULL can be used instead if
|
||||
* no free is needed.
|
||||
* @destroy_fn_data: This pointer will get passed to @destroy_fn.
|
||||
* This is equivalent to cogl_bitmap_new_with_size() except that it
|
||||
* allocated the buffer using g_malloc() instead of creating a
|
||||
* #CoglPixelBuffer. The buffer will be automatically destroyed when
|
||||
* the bitmap is freed.
|
||||
*
|
||||
* Creates a bitmap using some existing data. The data is not copied
|
||||
* so the bitmap will take ownership of the data pointer. When the
|
||||
* bitmap is freed @destroy_fn will be called to free the data.
|
||||
* Return value: a #CoglPixelBuffer representing the newly created array
|
||||
*
|
||||
* Return value: A new %CoglBitmap.
|
||||
* Since: 1.10
|
||||
* Stability: Unstable
|
||||
*/
|
||||
CoglBitmap *
|
||||
_cogl_bitmap_new_from_data (guint8 *data,
|
||||
CoglPixelFormat format,
|
||||
int width,
|
||||
int height,
|
||||
int rowstride,
|
||||
CoglBitmapDestroyNotify destroy_fn,
|
||||
gpointer destroy_fn_data);
|
||||
_cogl_bitmap_new_with_malloc_buffer (CoglContext *context,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
CoglPixelFormat format);
|
||||
|
||||
/* The idea of this function is that it will create a bitmap that
|
||||
shares the actual data with another bitmap. This is needed for the
|
||||
|
Reference in New Issue
Block a user