Commit Graph

6 Commits

Author SHA1 Message Date
Neil Roberts
d18b59d9e6 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>
2012-03-14 12:19:56 +00:00
Neil Roberts
1397a2da19 Make _cogl_bitmap_get_{width,height,format,rowstride} public
This are now marked as public experimental

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 18:47:52 +00:00
Neil Roberts
1b47ff0dfe bitmap: Support pre/unpre-multiplying any format
If the fast-path inplace premult conversion can't be used then it will
now fallback to unpacking the buffer into a row of guint16s and use
the generic conversion.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:46:59 +00:00
Neil Roberts
031dd661c0 bitmap: Add a function to convert into an existing buffer
This adds _cogl_bitmap_convert_into_bitmap which is the same as
_cogl_bitmap_convert except that it writes into an existing bitmap
instead of allocating a new one. _cogl_bitmap_convert now just
allocates a buffer and calls the new function. This is used in
_cogl_read_pixels to avoid allocating a second intermediate buffer
when the pixel format to store in is not GL_RGBA.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:46:57 +00:00
Neil Roberts
f4cd5aceb9 _cogl_bitmap_convert: Also handle premult conversions
If we are going to unpack the data into a known format anyway we might
as well do the premult conversion instead of delaying it to do
in-place. This helps because not all formats with alpha channels are
handled by the in-place premult conversion code. This removes the
_cogl_bitmap_convert_format_and_premult function so that now
_cogl_bitmap_convert is a completely general purpose function that can
convert from anything to anything. _cogl_bitmap_convert now includes a
fast path for when the base formats are the same and the premult
conversion can be handled with the in-place code so that we don't need
to unpack and can just copy the bitmap instead.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:44:52 +00:00
Neil Roberts
8ce5f5ade8 bitmap: Remove the split between 'image library' and 'fallback'
Previously the bitmap code was setup so that there could be an image
library used to convert between formats and then some 'fallback' code
when the image library can't handle the conversion. However there was
never any implementation of the conversion in the image library so the
fallback was always used. I don't think this split really makes sense
so this patch renames cogl-bitmap-fallback to cogl-bitmap-conversion
and removes the stub conversion functions in the image library.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:44:52 +00:00