mirror of
https://github.com/brl/mutter.git
synced 2025-02-16 21:34:09 +00: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;
|
int bmp_height;
|
||||||
CoglPixelFormat bmp_format;
|
CoglPixelFormat bmp_format;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
|
||||||
|
|
||||||
_COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), COGL_INVALID_HANDLE);
|
_COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), COGL_INVALID_HANDLE);
|
||||||
|
|
||||||
bmp_width = cogl_bitmap_get_width (bmp);
|
bmp_width = cogl_bitmap_get_width (bmp);
|
||||||
|
@ -142,4 +142,7 @@ _cogl_bitmap_bind (CoglBitmap *bitmap,
|
|||||||
void
|
void
|
||||||
_cogl_bitmap_unbind (CoglBitmap *bitmap);
|
_cogl_bitmap_unbind (CoglBitmap *bitmap);
|
||||||
|
|
||||||
|
CoglContext *
|
||||||
|
_cogl_bitmap_get_context (CoglBitmap *bitmap);
|
||||||
|
|
||||||
#endif /* __COGL_BITMAP_H */
|
#endif /* __COGL_BITMAP_H */
|
||||||
|
@ -38,6 +38,10 @@
|
|||||||
struct _CoglBitmap
|
struct _CoglBitmap
|
||||||
{
|
{
|
||||||
CoglHandleObject _parent;
|
CoglHandleObject _parent;
|
||||||
|
|
||||||
|
/* Pointer back to the context that this bitmap was created with */
|
||||||
|
CoglContext *context;
|
||||||
|
|
||||||
CoglPixelFormat format;
|
CoglPixelFormat format;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
@ -73,6 +77,9 @@ _cogl_bitmap_free (CoglBitmap *bmp)
|
|||||||
if (bmp->buffer)
|
if (bmp->buffer)
|
||||||
cogl_object_unref (bmp->buffer);
|
cogl_object_unref (bmp->buffer);
|
||||||
|
|
||||||
|
if (bmp->context)
|
||||||
|
cogl_object_unref (bmp->context);
|
||||||
|
|
||||||
g_slice_free (CoglBitmap, bmp);
|
g_slice_free (CoglBitmap, bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,10 +111,8 @@ _cogl_bitmap_copy (CoglBitmap *src_bmp)
|
|||||||
int width = cogl_bitmap_get_width (src_bmp);
|
int width = cogl_bitmap_get_width (src_bmp);
|
||||||
int height = cogl_bitmap_get_height (src_bmp);
|
int height = cogl_bitmap_get_height (src_bmp);
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NULL);
|
|
||||||
|
|
||||||
dst_bmp =
|
dst_bmp =
|
||||||
_cogl_bitmap_new_with_malloc_buffer (ctx,
|
_cogl_bitmap_new_with_malloc_buffer (src_bmp->context,
|
||||||
width, height,
|
width, height,
|
||||||
src_format);
|
src_format);
|
||||||
|
|
||||||
@ -188,6 +193,7 @@ cogl_bitmap_new_for_data (CoglContext *context,
|
|||||||
g_return_val_if_fail (cogl_is_context (context), NULL);
|
g_return_val_if_fail (cogl_is_context (context), NULL);
|
||||||
|
|
||||||
bmp = g_slice_new (CoglBitmap);
|
bmp = g_slice_new (CoglBitmap);
|
||||||
|
bmp->context = cogl_object_ref (context);
|
||||||
bmp->format = format;
|
bmp->format = format;
|
||||||
bmp->width = width;
|
bmp->width = width;
|
||||||
bmp->height = height;
|
bmp->height = height;
|
||||||
@ -235,9 +241,7 @@ _cogl_bitmap_new_shared (CoglBitmap *shared_bmp,
|
|||||||
{
|
{
|
||||||
CoglBitmap *bmp;
|
CoglBitmap *bmp;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NULL);
|
bmp = cogl_bitmap_new_for_data (shared_bmp->context,
|
||||||
|
|
||||||
bmp = cogl_bitmap_new_for_data (ctx,
|
|
||||||
width, height,
|
width, height,
|
||||||
format,
|
format,
|
||||||
rowstride,
|
rowstride,
|
||||||
@ -474,3 +478,9 @@ _cogl_bitmap_unbind (CoglBitmap *bitmap)
|
|||||||
else
|
else
|
||||||
_cogl_bitmap_unmap (bitmap);
|
_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
|
/* If 3D or rectangle textures aren't supported then these should
|
||||||
just silently return NULL */
|
just silently return NULL */
|
||||||
context->default_gl_texture_3d_tex =
|
context->default_gl_texture_3d_tex =
|
||||||
_cogl_texture_3d_new_from_bitmap (context,
|
_cogl_texture_3d_new_from_bitmap (default_texture_bitmap,
|
||||||
default_texture_bitmap,
|
|
||||||
1, /* height */
|
1, /* height */
|
||||||
1, /* depth */
|
1, /* depth */
|
||||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||||
|
@ -880,11 +880,12 @@ _cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap *bmp,
|
|||||||
GLenum gl_format;
|
GLenum gl_format;
|
||||||
GLenum gl_type;
|
GLenum gl_type;
|
||||||
int width, height;
|
int width, height;
|
||||||
|
CoglContext *ctx;
|
||||||
_COGL_GET_CONTEXT (ctx, NULL);
|
|
||||||
|
|
||||||
_COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL);
|
_COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL);
|
||||||
|
|
||||||
|
ctx = _cogl_bitmap_get_context (bmp);
|
||||||
|
|
||||||
width = cogl_bitmap_get_width (bmp);
|
width = cogl_bitmap_get_width (bmp);
|
||||||
height = cogl_bitmap_get_height (bmp);
|
height = cogl_bitmap_get_height (bmp);
|
||||||
|
|
||||||
|
@ -225,11 +225,12 @@ _cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
|
|||||||
GLenum gl_format;
|
GLenum gl_format;
|
||||||
GLenum gl_type;
|
GLenum gl_type;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
CoglContext *ctx;
|
||||||
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
|
||||||
|
|
||||||
_COGL_RETURN_VAL_IF_FAIL (bmp != NULL, COGL_INVALID_HANDLE);
|
_COGL_RETURN_VAL_IF_FAIL (bmp != NULL, COGL_INVALID_HANDLE);
|
||||||
|
|
||||||
|
ctx = _cogl_bitmap_get_context (bmp);
|
||||||
|
|
||||||
internal_format =
|
internal_format =
|
||||||
_cogl_texture_determine_internal_format (cogl_bitmap_get_format (bmp),
|
_cogl_texture_determine_internal_format (cogl_bitmap_get_format (bmp),
|
||||||
internal_format);
|
internal_format);
|
||||||
|
@ -81,8 +81,7 @@ struct _CoglTexture3D
|
|||||||
* there was an error.
|
* there was an error.
|
||||||
*/
|
*/
|
||||||
CoglTexture3D *
|
CoglTexture3D *
|
||||||
_cogl_texture_3d_new_from_bitmap (CoglContext *context,
|
_cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp,
|
||||||
CoglBitmap *bmp,
|
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
unsigned int depth,
|
unsigned int depth,
|
||||||
CoglPixelFormat internal_format,
|
CoglPixelFormat internal_format,
|
||||||
|
@ -236,8 +236,7 @@ cogl_texture_3d_new_with_size (CoglContext *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CoglTexture3D *
|
CoglTexture3D *
|
||||||
_cogl_texture_3d_new_from_bitmap (CoglContext *ctx,
|
_cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp,
|
||||||
CoglBitmap *bmp,
|
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
unsigned int depth,
|
unsigned int depth,
|
||||||
CoglPixelFormat internal_format,
|
CoglPixelFormat internal_format,
|
||||||
@ -251,6 +250,9 @@ _cogl_texture_3d_new_from_bitmap (CoglContext *ctx,
|
|||||||
GLenum gl_format;
|
GLenum gl_format;
|
||||||
GLenum gl_type;
|
GLenum gl_type;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
CoglContext *ctx;
|
||||||
|
|
||||||
|
ctx = _cogl_bitmap_get_context (bmp);
|
||||||
|
|
||||||
bmp_width = cogl_bitmap_get_width (bmp);
|
bmp_width = cogl_bitmap_get_width (bmp);
|
||||||
bmp_format = cogl_bitmap_get_format (bmp);
|
bmp_format = cogl_bitmap_get_format (bmp);
|
||||||
@ -396,8 +398,7 @@ cogl_texture_3d_new_from_data (CoglContext *context,
|
|||||||
rowstride,
|
rowstride,
|
||||||
(guint8 *) data);
|
(guint8 *) data);
|
||||||
|
|
||||||
ret = _cogl_texture_3d_new_from_bitmap (context,
|
ret = _cogl_texture_3d_new_from_bitmap (bitmap,
|
||||||
bitmap,
|
|
||||||
height,
|
height,
|
||||||
depth,
|
depth,
|
||||||
internal_format,
|
internal_format,
|
||||||
|
@ -230,11 +230,12 @@ _cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp,
|
|||||||
GLenum gl_intformat;
|
GLenum gl_intformat;
|
||||||
GLenum gl_format;
|
GLenum gl_format;
|
||||||
GLenum gl_type;
|
GLenum gl_type;
|
||||||
|
CoglContext *ctx;
|
||||||
_COGL_GET_CONTEXT (ctx, NULL);
|
|
||||||
|
|
||||||
_COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL);
|
_COGL_RETURN_VAL_IF_FAIL (cogl_is_bitmap (bmp), NULL);
|
||||||
|
|
||||||
|
ctx = _cogl_bitmap_get_context (bmp);
|
||||||
|
|
||||||
internal_format =
|
internal_format =
|
||||||
_cogl_texture_determine_internal_format (cogl_bitmap_get_format (bmp),
|
_cogl_texture_determine_internal_format (cogl_bitmap_get_format (bmp),
|
||||||
internal_format);
|
internal_format);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user