mirror of
https://github.com/brl/mutter.git
synced 2024-11-12 17:27:03 -05:00
bitmap: Store a pointer to the context
This adds a context member to CoglBitmap which stores the context it was created with. That way it can be used in texture constructors which use a bitmap. There is also an internal private function to get the context out of the bitmap which all of the texture constructors now use. _cogl_texture_3d_new_from_bitmap has had its context parameter removed so that it more closely matches the other bitmap constructors. Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
parent
be9d5b34c6
commit
e7df2dbf79
@ -735,8 +735,6 @@ _cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp,
|
||||
int bmp_height;
|
||||
CoglPixelFormat bmp_format;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||
|
||||
_COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), COGL_INVALID_HANDLE);
|
||||
|
||||
bmp_width = cogl_bitmap_get_width (bmp);
|
||||
|
@ -142,4 +142,7 @@ _cogl_bitmap_bind (CoglBitmap *bitmap,
|
||||
void
|
||||
_cogl_bitmap_unbind (CoglBitmap *bitmap);
|
||||
|
||||
CoglContext *
|
||||
_cogl_bitmap_get_context (CoglBitmap *bitmap);
|
||||
|
||||
#endif /* __COGL_BITMAP_H */
|
||||
|
@ -38,6 +38,10 @@
|
||||
struct _CoglBitmap
|
||||
{
|
||||
CoglHandleObject _parent;
|
||||
|
||||
/* Pointer back to the context that this bitmap was created with */
|
||||
CoglContext *context;
|
||||
|
||||
CoglPixelFormat format;
|
||||
int width;
|
||||
int height;
|
||||
@ -73,6 +77,9 @@ _cogl_bitmap_free (CoglBitmap *bmp)
|
||||
if (bmp->buffer)
|
||||
cogl_object_unref (bmp->buffer);
|
||||
|
||||
if (bmp->context)
|
||||
cogl_object_unref (bmp->context);
|
||||
|
||||
g_slice_free (CoglBitmap, bmp);
|
||||
}
|
||||
|
||||
@ -104,10 +111,8 @@ _cogl_bitmap_copy (CoglBitmap *src_bmp)
|
||||
int width = cogl_bitmap_get_width (src_bmp);
|
||||
int height = cogl_bitmap_get_height (src_bmp);
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NULL);
|
||||
|
||||
dst_bmp =
|
||||
_cogl_bitmap_new_with_malloc_buffer (ctx,
|
||||
_cogl_bitmap_new_with_malloc_buffer (src_bmp->context,
|
||||
width, height,
|
||||
src_format);
|
||||
|
||||
@ -188,6 +193,7 @@ cogl_bitmap_new_for_data (CoglContext *context,
|
||||
g_return_val_if_fail (cogl_is_context (context), NULL);
|
||||
|
||||
bmp = g_slice_new (CoglBitmap);
|
||||
bmp->context = cogl_object_ref (context);
|
||||
bmp->format = format;
|
||||
bmp->width = width;
|
||||
bmp->height = height;
|
||||
@ -235,9 +241,7 @@ _cogl_bitmap_new_shared (CoglBitmap *shared_bmp,
|
||||
{
|
||||
CoglBitmap *bmp;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NULL);
|
||||
|
||||
bmp = cogl_bitmap_new_for_data (ctx,
|
||||
bmp = cogl_bitmap_new_for_data (shared_bmp->context,
|
||||
width, height,
|
||||
format,
|
||||
rowstride,
|
||||
@ -474,3 +478,9 @@ _cogl_bitmap_unbind (CoglBitmap *bitmap)
|
||||
else
|
||||
_cogl_bitmap_unmap (bitmap);
|
||||
}
|
||||
|
||||
CoglContext *
|
||||
_cogl_bitmap_get_context (CoglBitmap *bitmap)
|
||||
{
|
||||
return bitmap->context;
|
||||
}
|
||||
|
@ -405,8 +405,7 @@ cogl_context_new (CoglDisplay *display,
|
||||
/* If 3D or rectangle textures aren't supported then these should
|
||||
just silently return NULL */
|
||||
context->default_gl_texture_3d_tex =
|
||||
_cogl_texture_3d_new_from_bitmap (context,
|
||||
default_texture_bitmap,
|
||||
_cogl_texture_3d_new_from_bitmap (default_texture_bitmap,
|
||||
1, /* height */
|
||||
1, /* depth */
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||
|
@ -880,11 +880,12 @@ _cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap *bmp,
|
||||
GLenum gl_format;
|
||||
GLenum gl_type;
|
||||
int width, height;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NULL);
|
||||
CoglContext *ctx;
|
||||
|
||||
_COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL);
|
||||
|
||||
ctx = _cogl_bitmap_get_context (bmp);
|
||||
|
||||
width = cogl_bitmap_get_width (bmp);
|
||||
height = cogl_bitmap_get_height (bmp);
|
||||
|
||||
|
@ -225,11 +225,12 @@ _cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
|
||||
GLenum gl_format;
|
||||
GLenum gl_type;
|
||||
guint8 *data;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||
CoglContext *ctx;
|
||||
|
||||
_COGL_RETURN_VAL_IF_FAIL (bmp != NULL, COGL_INVALID_HANDLE);
|
||||
|
||||
ctx = _cogl_bitmap_get_context (bmp);
|
||||
|
||||
internal_format =
|
||||
_cogl_texture_determine_internal_format (cogl_bitmap_get_format (bmp),
|
||||
internal_format);
|
||||
|
@ -81,8 +81,7 @@ struct _CoglTexture3D
|
||||
* there was an error.
|
||||
*/
|
||||
CoglTexture3D *
|
||||
_cogl_texture_3d_new_from_bitmap (CoglContext *context,
|
||||
CoglBitmap *bmp,
|
||||
_cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp,
|
||||
unsigned int height,
|
||||
unsigned int depth,
|
||||
CoglPixelFormat internal_format,
|
||||
|
@ -236,8 +236,7 @@ cogl_texture_3d_new_with_size (CoglContext *ctx,
|
||||
}
|
||||
|
||||
CoglTexture3D *
|
||||
_cogl_texture_3d_new_from_bitmap (CoglContext *ctx,
|
||||
CoglBitmap *bmp,
|
||||
_cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp,
|
||||
unsigned int height,
|
||||
unsigned int depth,
|
||||
CoglPixelFormat internal_format,
|
||||
@ -251,6 +250,9 @@ _cogl_texture_3d_new_from_bitmap (CoglContext *ctx,
|
||||
GLenum gl_format;
|
||||
GLenum gl_type;
|
||||
guint8 *data;
|
||||
CoglContext *ctx;
|
||||
|
||||
ctx = _cogl_bitmap_get_context (bmp);
|
||||
|
||||
bmp_width = cogl_bitmap_get_width (bmp);
|
||||
bmp_format = cogl_bitmap_get_format (bmp);
|
||||
@ -396,8 +398,7 @@ cogl_texture_3d_new_from_data (CoglContext *context,
|
||||
rowstride,
|
||||
(guint8 *) data);
|
||||
|
||||
ret = _cogl_texture_3d_new_from_bitmap (context,
|
||||
bitmap,
|
||||
ret = _cogl_texture_3d_new_from_bitmap (bitmap,
|
||||
height,
|
||||
depth,
|
||||
internal_format,
|
||||
|
@ -230,11 +230,12 @@ _cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp,
|
||||
GLenum gl_intformat;
|
||||
GLenum gl_format;
|
||||
GLenum gl_type;
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NULL);
|
||||
CoglContext *ctx;
|
||||
|
||||
_COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL);
|
||||
|
||||
ctx = _cogl_bitmap_get_context (bmp);
|
||||
|
||||
internal_format =
|
||||
_cogl_texture_determine_internal_format (cogl_bitmap_get_format (bmp),
|
||||
internal_format);
|
||||
|
Loading…
Reference in New Issue
Block a user