mirror of
https://github.com/brl/mutter.git
synced 2025-02-26 09:44:10 +00:00
cogl: Port Bitmap away from CoglObject
We still need to use set_qdata_full as CoglBitmapPixbuf would free the data itself by unrefing the pixbuf Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3193>
This commit is contained in:
parent
3c6c6a0ea5
commit
c1e6948e42
@ -129,7 +129,7 @@ clutter_canvas_finalize (GObject *gobject)
|
|||||||
|
|
||||||
if (priv->buffer != NULL)
|
if (priv->buffer != NULL)
|
||||||
{
|
{
|
||||||
cogl_object_unref (priv->buffer);
|
g_object_unref (priv->buffer);
|
||||||
priv->buffer = NULL;
|
priv->buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ clutter_canvas_invalidate (ClutterContent *content)
|
|||||||
|
|
||||||
if (priv->buffer != NULL)
|
if (priv->buffer != NULL)
|
||||||
{
|
{
|
||||||
cogl_object_unref (priv->buffer);
|
g_object_unref (priv->buffer);
|
||||||
priv->buffer = NULL;
|
priv->buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2824,7 +2824,7 @@ clutter_stage_paint_to_buffer (ClutterStage *stage,
|
|||||||
COGL_READ_PIXELS_COLOR_BUFFER,
|
COGL_READ_PIXELS_COLOR_BUFFER,
|
||||||
bitmap);
|
bitmap);
|
||||||
|
|
||||||
cogl_object_unref (bitmap);
|
g_object_unref (bitmap);
|
||||||
g_object_unref (framebuffer);
|
g_object_unref (framebuffer);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -2928,7 +2928,7 @@ clutter_stage_capture_view_into (ClutterStage *stage,
|
|||||||
COGL_READ_PIXELS_COLOR_BUFFER,
|
COGL_READ_PIXELS_COLOR_BUFFER,
|
||||||
bitmap);
|
bitmap);
|
||||||
|
|
||||||
cogl_object_unref (bitmap);
|
g_object_unref (bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -556,7 +556,7 @@ _cogl_atlas_texture_convert_bitmap_for_upload (CoglAtlasTexture *atlas_tex,
|
|||||||
cogl_bitmap_get_height (upload_bmp),
|
cogl_bitmap_get_height (upload_bmp),
|
||||||
cogl_bitmap_get_rowstride (upload_bmp));
|
cogl_bitmap_get_rowstride (upload_bmp));
|
||||||
|
|
||||||
cogl_object_unref (upload_bmp);
|
g_object_unref (upload_bmp);
|
||||||
|
|
||||||
return override_bmp;
|
return override_bmp;
|
||||||
}
|
}
|
||||||
@ -599,7 +599,7 @@ _cogl_atlas_texture_set_region (CoglTexture *tex,
|
|||||||
upload_bmp,
|
upload_bmp,
|
||||||
error);
|
error);
|
||||||
|
|
||||||
cogl_object_unref (upload_bmp);
|
g_object_unref (upload_bmp);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -836,7 +836,7 @@ allocate_from_bitmap (CoglAtlasTexture *atlas_tex,
|
|||||||
internal_format,
|
internal_format,
|
||||||
error))
|
error))
|
||||||
{
|
{
|
||||||
cogl_object_unref (upload_bmp);
|
g_object_unref (upload_bmp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,11 +853,11 @@ allocate_from_bitmap (CoglAtlasTexture *atlas_tex,
|
|||||||
error))
|
error))
|
||||||
{
|
{
|
||||||
_cogl_atlas_texture_remove_from_atlas (atlas_tex);
|
_cogl_atlas_texture_remove_from_atlas (atlas_tex);
|
||||||
cogl_object_unref (upload_bmp);
|
g_object_unref (upload_bmp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_object_unref (upload_bmp);
|
g_object_unref (upload_bmp);
|
||||||
|
|
||||||
_cogl_texture_set_allocated (tex, internal_format, width, height);
|
_cogl_texture_set_allocated (tex, internal_format, width, height);
|
||||||
|
|
||||||
@ -891,11 +891,11 @@ cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp)
|
|||||||
{
|
{
|
||||||
CoglTextureLoader *loader;
|
CoglTextureLoader *loader;
|
||||||
|
|
||||||
g_return_val_if_fail (cogl_is_bitmap (bmp), NULL);
|
g_return_val_if_fail (COGL_IS_BITMAP (bmp), NULL);
|
||||||
|
|
||||||
loader = _cogl_texture_create_loader ();
|
loader = _cogl_texture_create_loader ();
|
||||||
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP;
|
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP;
|
||||||
loader->src.bitmap.bitmap = cogl_object_ref (bmp);
|
loader->src.bitmap.bitmap = g_object_ref (bmp);
|
||||||
|
|
||||||
return _cogl_atlas_texture_create_base (_cogl_bitmap_get_context (bmp),
|
return _cogl_atlas_texture_create_base (_cogl_bitmap_get_context (bmp),
|
||||||
cogl_bitmap_get_width (bmp),
|
cogl_bitmap_get_width (bmp),
|
||||||
@ -933,7 +933,7 @@ cogl_atlas_texture_new_from_data (CoglContext *ctx,
|
|||||||
|
|
||||||
atlas_tex = cogl_atlas_texture_new_from_bitmap (bmp);
|
atlas_tex = cogl_atlas_texture_new_from_bitmap (bmp);
|
||||||
|
|
||||||
cogl_object_unref (bmp);
|
g_object_unref (bmp);
|
||||||
|
|
||||||
if (atlas_tex &&
|
if (atlas_tex &&
|
||||||
!cogl_texture_allocate (COGL_TEXTURE (atlas_tex), error))
|
!cogl_texture_allocate (COGL_TEXTURE (atlas_tex), error))
|
||||||
|
@ -333,7 +333,7 @@ _cogl_atlas_create_texture (CoglAtlas *atlas,
|
|||||||
tex = NULL;
|
tex = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_object_unref (clear_bmp);
|
g_object_unref (clear_bmp);
|
||||||
|
|
||||||
g_free (clear_data);
|
g_free (clear_data);
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ _cogl_bitmap_convert (CoglBitmap *src_bmp,
|
|||||||
|
|
||||||
if (!_cogl_bitmap_convert_into_bitmap (src_bmp, dst_bmp, error))
|
if (!_cogl_bitmap_convert_into_bitmap (src_bmp, dst_bmp, error))
|
||||||
{
|
{
|
||||||
cogl_object_unref (dst_bmp);
|
g_object_unref (dst_bmp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,7 +596,7 @@ _cogl_bitmap_convert_for_upload (CoglBitmap *src_bmp,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dst_bmp = cogl_object_ref (src_bmp);
|
dst_bmp = g_object_ref (src_bmp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -612,7 +612,7 @@ _cogl_bitmap_convert_for_upload (CoglBitmap *src_bmp,
|
|||||||
if (closest_format != src_format)
|
if (closest_format != src_format)
|
||||||
dst_bmp = _cogl_bitmap_convert (src_bmp, closest_format, error);
|
dst_bmp = _cogl_bitmap_convert (src_bmp, closest_format, error);
|
||||||
else
|
else
|
||||||
dst_bmp = cogl_object_ref (src_bmp);
|
dst_bmp = g_object_ref (src_bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dst_bmp;
|
return dst_bmp;
|
||||||
|
@ -32,13 +32,12 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include "cogl/cogl-object-private.h"
|
|
||||||
#include "cogl/cogl-buffer.h"
|
#include "cogl/cogl-buffer.h"
|
||||||
#include "cogl/cogl-bitmap.h"
|
#include "cogl/cogl-bitmap.h"
|
||||||
|
|
||||||
struct _CoglBitmap
|
struct _CoglBitmap
|
||||||
{
|
{
|
||||||
CoglObject _parent;
|
GObject parent_instance;
|
||||||
|
|
||||||
/* Pointer back to the context that this bitmap was created with */
|
/* Pointer back to the context that this bitmap was created with */
|
||||||
CoglContext *context;
|
CoglContext *context;
|
||||||
|
@ -37,28 +37,42 @@
|
|||||||
#include "cogl/cogl-buffer-private.h"
|
#include "cogl/cogl-buffer-private.h"
|
||||||
#include "cogl/cogl-pixel-buffer.h"
|
#include "cogl/cogl-pixel-buffer.h"
|
||||||
#include "cogl/cogl-context-private.h"
|
#include "cogl/cogl-context-private.h"
|
||||||
#include "cogl/cogl-gtype-private.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static void _cogl_bitmap_free (CoglBitmap *bmp);
|
static GQuark bitmap_free_key = 0;
|
||||||
|
|
||||||
COGL_OBJECT_DEFINE (Bitmap, bitmap);
|
G_DEFINE_TYPE (CoglBitmap, cogl_bitmap, G_TYPE_OBJECT);
|
||||||
COGL_GTYPE_DEFINE_CLASS (Bitmap, bitmap);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_bitmap_free (CoglBitmap *bmp)
|
cogl_bitmap_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
|
CoglBitmap *bmp = COGL_BITMAP (object);
|
||||||
|
|
||||||
g_assert (!bmp->mapped);
|
g_assert (!bmp->mapped);
|
||||||
g_assert (!bmp->bound);
|
g_assert (!bmp->bound);
|
||||||
|
|
||||||
if (bmp->shared_bmp)
|
if (bmp->shared_bmp)
|
||||||
cogl_object_unref (bmp->shared_bmp);
|
g_object_unref (bmp->shared_bmp);
|
||||||
|
|
||||||
if (bmp->buffer)
|
if (bmp->buffer)
|
||||||
cogl_object_unref (bmp->buffer);
|
cogl_object_unref (bmp->buffer);
|
||||||
|
|
||||||
g_free (bmp);
|
|
||||||
|
G_OBJECT_CLASS (cogl_bitmap_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cogl_bitmap_init (CoglBitmap *bitmap)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cogl_bitmap_class_init (CoglBitmapClass *class)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||||
|
|
||||||
|
object_class->dispose = cogl_bitmap_dispose;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@ -106,7 +120,7 @@ _cogl_bitmap_copy (CoglBitmap *src_bmp,
|
|||||||
width, height,
|
width, height,
|
||||||
error))
|
error))
|
||||||
{
|
{
|
||||||
cogl_object_unref (dst_bmp);
|
g_object_unref (dst_bmp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +196,7 @@ cogl_bitmap_new_for_data (CoglContext *context,
|
|||||||
if (rowstride == 0)
|
if (rowstride == 0)
|
||||||
rowstride = width * cogl_pixel_format_get_bytes_per_pixel (format, 0);
|
rowstride = width * cogl_pixel_format_get_bytes_per_pixel (format, 0);
|
||||||
|
|
||||||
bmp = g_new0 (CoglBitmap, 1);
|
bmp = g_object_new (COGL_TYPE_BITMAP, NULL);
|
||||||
bmp->context = context;
|
bmp->context = context;
|
||||||
bmp->format = format;
|
bmp->format = format;
|
||||||
bmp->width = width;
|
bmp->width = width;
|
||||||
@ -194,7 +208,7 @@ cogl_bitmap_new_for_data (CoglContext *context,
|
|||||||
bmp->shared_bmp = NULL;
|
bmp->shared_bmp = NULL;
|
||||||
bmp->buffer = NULL;
|
bmp->buffer = NULL;
|
||||||
|
|
||||||
return _cogl_bitmap_object_new (bmp);
|
return bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglBitmap *
|
CoglBitmap *
|
||||||
@ -204,7 +218,7 @@ _cogl_bitmap_new_with_malloc_buffer (CoglContext *context,
|
|||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
static CoglUserDataKey bitmap_free_key;
|
bitmap_free_key = g_quark_from_static_string ("-cogl-bitmap-malloc-buffer-key");
|
||||||
int bpp;
|
int bpp;
|
||||||
int rowstride;
|
int rowstride;
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
@ -231,10 +245,10 @@ _cogl_bitmap_new_with_malloc_buffer (CoglContext *context,
|
|||||||
format,
|
format,
|
||||||
rowstride,
|
rowstride,
|
||||||
data);
|
data);
|
||||||
cogl_object_set_user_data (COGL_OBJECT (bitmap),
|
g_object_set_qdata_full (G_OBJECT (bitmap),
|
||||||
&bitmap_free_key,
|
bitmap_free_key,
|
||||||
data,
|
data,
|
||||||
g_free);
|
g_free);
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
@ -254,7 +268,7 @@ _cogl_bitmap_new_shared (CoglBitmap *shared_bmp,
|
|||||||
rowstride,
|
rowstride,
|
||||||
NULL /* data */);
|
NULL /* data */);
|
||||||
|
|
||||||
bmp->shared_bmp = cogl_object_ref (shared_bmp);
|
bmp->shared_bmp = g_object_ref (shared_bmp);
|
||||||
|
|
||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
|
@ -49,23 +49,22 @@ typedef struct _CoglBitmap CoglBitmap;
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_bitmap_get_gtype:
|
* CoglBitmap:
|
||||||
*
|
*
|
||||||
* Returns: a #GType that can be used with the GLib type system.
|
* Functions for loading images
|
||||||
*/
|
|
||||||
COGL_EXPORT
|
|
||||||
GType cogl_bitmap_get_gtype (void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SECTION:cogl-bitmap
|
|
||||||
* @short_description: Functions for loading images
|
|
||||||
*
|
*
|
||||||
* Cogl allows loading image data into memory as CoglBitmaps without
|
* Cogl allows loading image data into memory as CoglBitmaps without
|
||||||
* loading them immediately into GPU textures.
|
* loading them immediately into GPU textures.
|
||||||
*
|
|
||||||
* #CoglBitmap is available since Cogl 1.0
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define COGL_TYPE_BITMAP (cogl_bitmap_get_type ())
|
||||||
|
|
||||||
|
COGL_EXPORT
|
||||||
|
G_DECLARE_FINAL_TYPE (CoglBitmap,
|
||||||
|
cogl_bitmap,
|
||||||
|
COGL,
|
||||||
|
BITMAP,
|
||||||
|
GObject)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_bitmap_new_from_buffer: (skip)
|
* cogl_bitmap_new_from_buffer: (skip)
|
||||||
@ -197,18 +196,6 @@ cogl_bitmap_get_rowstride (CoglBitmap *bitmap);
|
|||||||
COGL_EXPORT CoglPixelBuffer *
|
COGL_EXPORT CoglPixelBuffer *
|
||||||
cogl_bitmap_get_buffer (CoglBitmap *bitmap);
|
cogl_bitmap_get_buffer (CoglBitmap *bitmap);
|
||||||
|
|
||||||
/**
|
|
||||||
* cogl_is_bitmap:
|
|
||||||
* @object: a #CoglObject pointer
|
|
||||||
*
|
|
||||||
* Checks whether @object is a #CoglBitmap
|
|
||||||
*
|
|
||||||
* Return value: %TRUE if the passed @object represents a bitmap,
|
|
||||||
* and %FALSE otherwise
|
|
||||||
*/
|
|
||||||
COGL_EXPORT gboolean
|
|
||||||
cogl_is_bitmap (void *object);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* COGL_BITMAP_ERROR:
|
* COGL_BITMAP_ERROR:
|
||||||
*
|
*
|
||||||
|
@ -1559,7 +1559,7 @@ cogl_framebuffer_read_pixels (CoglFramebuffer *framebuffer,
|
|||||||
COGL_READ_PIXELS_COLOR_BUFFER,
|
COGL_READ_PIXELS_COLOR_BUFFER,
|
||||||
bitmap,
|
bitmap,
|
||||||
NULL);
|
NULL);
|
||||||
cogl_object_unref (bitmap);
|
g_object_unref (bitmap);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1251,7 +1251,7 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
|
|||||||
* x, y,
|
* x, y,
|
||||||
* COGL_READ_PIXELS_COLOR_BUFFER,
|
* COGL_READ_PIXELS_COLOR_BUFFER,
|
||||||
* bitmap);
|
* bitmap);
|
||||||
* cogl_object_unref (bitmap);
|
* g_object_unref (bitmap);
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* Return value: %TRUE if the read succeeded or %FALSE otherwise.
|
* Return value: %TRUE if the read succeeded or %FALSE otherwise.
|
||||||
|
@ -270,12 +270,12 @@ _cogl_texture_2d_sliced_set_waste (CoglTexture2DSliced *tex_2ds,
|
|||||||
0, /* level */
|
0, /* level */
|
||||||
error))
|
error))
|
||||||
{
|
{
|
||||||
cogl_object_unref (waste_bmp);
|
g_object_unref (waste_bmp);
|
||||||
_cogl_bitmap_unmap (source_bmp);
|
_cogl_bitmap_unmap (source_bmp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_object_unref (waste_bmp);
|
g_object_unref (waste_bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_y)
|
if (need_y)
|
||||||
@ -330,12 +330,12 @@ _cogl_texture_2d_sliced_set_waste (CoglTexture2DSliced *tex_2ds,
|
|||||||
0, /* level */
|
0, /* level */
|
||||||
error))
|
error))
|
||||||
{
|
{
|
||||||
cogl_object_unref (waste_bmp);
|
g_object_unref (waste_bmp);
|
||||||
_cogl_bitmap_unmap (source_bmp);
|
_cogl_bitmap_unmap (source_bmp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_object_unref (waste_bmp);
|
g_object_unref (waste_bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
_cogl_bitmap_unmap (source_bmp);
|
_cogl_bitmap_unmap (source_bmp);
|
||||||
@ -891,11 +891,11 @@ cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap *bmp,
|
|||||||
{
|
{
|
||||||
CoglTextureLoader *loader;
|
CoglTextureLoader *loader;
|
||||||
|
|
||||||
g_return_val_if_fail (cogl_is_bitmap (bmp), NULL);
|
g_return_val_if_fail (COGL_IS_BITMAP (bmp), NULL);
|
||||||
|
|
||||||
loader = _cogl_texture_create_loader ();
|
loader = _cogl_texture_create_loader ();
|
||||||
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP;
|
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP;
|
||||||
loader->src.bitmap.bitmap = cogl_object_ref (bmp);
|
loader->src.bitmap.bitmap = g_object_ref (bmp);
|
||||||
|
|
||||||
return _cogl_texture_2d_sliced_create_base (_cogl_bitmap_get_context (bmp),
|
return _cogl_texture_2d_sliced_create_base (_cogl_bitmap_get_context (bmp),
|
||||||
cogl_bitmap_get_width (bmp),
|
cogl_bitmap_get_width (bmp),
|
||||||
@ -935,7 +935,7 @@ cogl_texture_2d_sliced_new_from_data (CoglContext *ctx,
|
|||||||
|
|
||||||
tex_2ds = cogl_texture_2d_sliced_new_from_bitmap (bmp, max_waste);
|
tex_2ds = cogl_texture_2d_sliced_new_from_bitmap (bmp, max_waste);
|
||||||
|
|
||||||
cogl_object_unref (bmp);
|
g_object_unref (bmp);
|
||||||
|
|
||||||
if (tex_2ds &&
|
if (tex_2ds &&
|
||||||
!cogl_texture_allocate (COGL_TEXTURE (tex_2ds), error))
|
!cogl_texture_allocate (COGL_TEXTURE (tex_2ds), error))
|
||||||
@ -1008,7 +1008,7 @@ allocate_from_bitmap (CoglTexture2DSliced *tex_2ds,
|
|||||||
internal_format,
|
internal_format,
|
||||||
error))
|
error))
|
||||||
{
|
{
|
||||||
cogl_object_unref (upload_bmp);
|
g_object_unref (upload_bmp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1017,11 +1017,11 @@ allocate_from_bitmap (CoglTexture2DSliced *tex_2ds,
|
|||||||
error))
|
error))
|
||||||
{
|
{
|
||||||
free_slices (tex_2ds);
|
free_slices (tex_2ds);
|
||||||
cogl_object_unref (upload_bmp);
|
g_object_unref (upload_bmp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_object_unref (upload_bmp);
|
g_object_unref (upload_bmp);
|
||||||
|
|
||||||
_cogl_texture_set_allocated (tex, internal_format, width, height);
|
_cogl_texture_set_allocated (tex, internal_format, width, height);
|
||||||
|
|
||||||
@ -1256,7 +1256,7 @@ _cogl_texture_2d_sliced_set_region (CoglTexture *tex,
|
|||||||
dst_width, dst_height,
|
dst_width, dst_height,
|
||||||
upload_bmp,
|
upload_bmp,
|
||||||
error);
|
error);
|
||||||
cogl_object_unref (upload_bmp);
|
g_object_unref (upload_bmp);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp)
|
|||||||
|
|
||||||
loader = _cogl_texture_create_loader ();
|
loader = _cogl_texture_create_loader ();
|
||||||
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP;
|
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_BITMAP;
|
||||||
loader->src.bitmap.bitmap = cogl_object_ref (bmp);
|
loader->src.bitmap.bitmap = g_object_ref (bmp);
|
||||||
|
|
||||||
return _cogl_texture_2d_create_base (_cogl_bitmap_get_context (bmp),
|
return _cogl_texture_2d_create_base (_cogl_bitmap_get_context (bmp),
|
||||||
cogl_bitmap_get_width (bmp),
|
cogl_bitmap_get_width (bmp),
|
||||||
@ -206,7 +206,7 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
|
|||||||
|
|
||||||
tex_2d = cogl_texture_2d_new_from_bitmap (bmp);
|
tex_2d = cogl_texture_2d_new_from_bitmap (bmp);
|
||||||
|
|
||||||
cogl_object_unref (bmp);
|
g_object_unref (bmp);
|
||||||
|
|
||||||
if (tex_2d &&
|
if (tex_2d &&
|
||||||
!cogl_texture_allocate (COGL_TEXTURE (tex_2d), error))
|
!cogl_texture_allocate (COGL_TEXTURE (tex_2d), error))
|
||||||
|
@ -152,7 +152,7 @@ _cogl_texture_free_loader (CoglTexture *texture)
|
|||||||
case COGL_TEXTURE_SOURCE_TYPE_EGL_IMAGE_EXTERNAL:
|
case COGL_TEXTURE_SOURCE_TYPE_EGL_IMAGE_EXTERNAL:
|
||||||
break;
|
break;
|
||||||
case COGL_TEXTURE_SOURCE_TYPE_BITMAP:
|
case COGL_TEXTURE_SOURCE_TYPE_BITMAP:
|
||||||
cogl_object_unref (loader->src.bitmap.bitmap);
|
g_object_unref (loader->src.bitmap.bitmap);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
g_free (loader);
|
g_free (loader);
|
||||||
@ -457,7 +457,7 @@ _cogl_texture_set_region (CoglTexture *texture,
|
|||||||
level,
|
level,
|
||||||
error);
|
error);
|
||||||
|
|
||||||
cogl_object_unref (source_bmp);
|
g_object_unref (source_bmp);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -594,7 +594,7 @@ get_texture_bits_via_offscreen (CoglTexture *meta_texture,
|
|||||||
|
|
||||||
g_clear_error (&ignore_error);
|
g_clear_error (&ignore_error);
|
||||||
|
|
||||||
cogl_object_unref (bitmap);
|
g_object_unref (bitmap);
|
||||||
|
|
||||||
g_object_unref (framebuffer);
|
g_object_unref (framebuffer);
|
||||||
|
|
||||||
@ -876,7 +876,7 @@ cogl_texture_get_data (CoglTexture *texture,
|
|||||||
*/
|
*/
|
||||||
if (!tg_data.success)
|
if (!tg_data.success)
|
||||||
{
|
{
|
||||||
cogl_object_unref (target_bmp);
|
g_object_unref (target_bmp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -902,10 +902,10 @@ cogl_texture_get_data (CoglTexture *texture,
|
|||||||
byte_size = 0;
|
byte_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_object_unref (new_bmp);
|
g_object_unref (new_bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_object_unref (target_bmp);
|
g_object_unref (target_bmp);
|
||||||
|
|
||||||
return byte_size;
|
return byte_size;
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
|
|||||||
|
|
||||||
_cogl_bitmap_set_format (bitmap, format);
|
_cogl_bitmap_set_format (bitmap, format);
|
||||||
|
|
||||||
cogl_object_unref (tmp_bmp);
|
g_object_unref (tmp_bmp);
|
||||||
|
|
||||||
if (!succeeded)
|
if (!succeeded)
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
@ -578,7 +578,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
|
|||||||
width, height,
|
width, height,
|
||||||
rowstride);
|
rowstride);
|
||||||
else
|
else
|
||||||
shared_bmp = cogl_object_ref (bitmap);
|
shared_bmp = g_object_ref (bitmap);
|
||||||
|
|
||||||
bpp = cogl_pixel_format_get_bytes_per_pixel (bmp_format, 0);
|
bpp = cogl_pixel_format_get_bytes_per_pixel (bmp_format, 0);
|
||||||
|
|
||||||
@ -596,7 +596,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
|
|||||||
* to know if there was a problem */
|
* to know if there was a problem */
|
||||||
if (internal_error)
|
if (internal_error)
|
||||||
{
|
{
|
||||||
cogl_object_unref (shared_bmp);
|
g_object_unref (shared_bmp);
|
||||||
g_propagate_error (error, internal_error);
|
g_propagate_error (error, internal_error);
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
@ -615,7 +615,7 @@ cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
|
|||||||
_cogl_bitmap_convert_premult_status (shared_bmp, format, error))
|
_cogl_bitmap_convert_premult_status (shared_bmp, format, error))
|
||||||
succeeded = TRUE;
|
succeeded = TRUE;
|
||||||
|
|
||||||
cogl_object_unref (shared_bmp);
|
g_object_unref (shared_bmp);
|
||||||
|
|
||||||
if (!succeeded)
|
if (!succeeded)
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
|
@ -245,13 +245,13 @@ allocate_from_bitmap (CoglTexture2D *tex_2d,
|
|||||||
gl_type,
|
gl_type,
|
||||||
error))
|
error))
|
||||||
{
|
{
|
||||||
cogl_object_unref (upload_bmp);
|
g_object_unref (upload_bmp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
tex_2d->gl_internal_format = gl_intformat;
|
tex_2d->gl_internal_format = gl_intformat;
|
||||||
|
|
||||||
cogl_object_unref (upload_bmp);
|
g_object_unref (upload_bmp);
|
||||||
|
|
||||||
tex_2d->internal_format = internal_format;
|
tex_2d->internal_format = internal_format;
|
||||||
|
|
||||||
@ -606,7 +606,7 @@ _cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d,
|
|||||||
gl_type,
|
gl_type,
|
||||||
error);
|
error);
|
||||||
|
|
||||||
cogl_object_unref (upload_bmp);
|
g_object_unref (upload_bmp);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ prepare_bitmap_alignment_for_upload (CoglContext *ctx,
|
|||||||
|
|
||||||
if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_UNPACK_SUBIMAGE) ||
|
if (_cogl_has_private_feature (ctx, COGL_PRIVATE_FEATURE_UNPACK_SUBIMAGE) ||
|
||||||
src_rowstride == 0)
|
src_rowstride == 0)
|
||||||
return cogl_object_ref (src_bmp);
|
return g_object_ref (src_bmp);
|
||||||
|
|
||||||
/* Work out the alignment of the source rowstride */
|
/* Work out the alignment of the source rowstride */
|
||||||
alignment = 1 << (ffs (src_rowstride) - 1);
|
alignment = 1 << (ffs (src_rowstride) - 1);
|
||||||
@ -173,7 +173,7 @@ prepare_bitmap_alignment_for_upload (CoglContext *ctx,
|
|||||||
/* If the aligned data equals the rowstride then we can upload from
|
/* If the aligned data equals the rowstride then we can upload from
|
||||||
the bitmap directly using GL_UNPACK_ALIGNMENT */
|
the bitmap directly using GL_UNPACK_ALIGNMENT */
|
||||||
if (((width * bpp + alignment - 1) & ~(alignment - 1)) == src_rowstride)
|
if (((width * bpp + alignment - 1) & ~(alignment - 1)) == src_rowstride)
|
||||||
return cogl_object_ref (src_bmp);
|
return g_object_ref (src_bmp);
|
||||||
/* Otherwise we need to copy the bitmap to pack the alignment
|
/* Otherwise we need to copy the bitmap to pack the alignment
|
||||||
because GLES has no GL_ROW_LENGTH */
|
because GLES has no GL_ROW_LENGTH */
|
||||||
else
|
else
|
||||||
@ -238,7 +238,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
|
|||||||
width, height,
|
width, height,
|
||||||
error))
|
error))
|
||||||
{
|
{
|
||||||
cogl_object_unref (slice_bmp);
|
g_object_unref (slice_bmp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
|
|||||||
if (internal_error)
|
if (internal_error)
|
||||||
{
|
{
|
||||||
g_propagate_error (error, internal_error);
|
g_propagate_error (error, internal_error);
|
||||||
cogl_object_unref (slice_bmp);
|
g_object_unref (slice_bmp);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +330,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
|
|||||||
|
|
||||||
_cogl_bitmap_gl_unbind (slice_bmp);
|
_cogl_bitmap_gl_unbind (slice_bmp);
|
||||||
|
|
||||||
cogl_object_unref (slice_bmp);
|
g_object_unref (slice_bmp);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -382,7 +382,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
|
|||||||
* problems... */
|
* problems... */
|
||||||
if (internal_error)
|
if (internal_error)
|
||||||
{
|
{
|
||||||
cogl_object_unref (bmp);
|
g_object_unref (bmp);
|
||||||
g_propagate_error (error, internal_error);
|
g_propagate_error (error, internal_error);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -403,7 +403,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
|
|||||||
|
|
||||||
_cogl_bitmap_gl_unbind (bmp);
|
_cogl_bitmap_gl_unbind (bmp);
|
||||||
|
|
||||||
cogl_object_unref (bmp);
|
g_object_unref (bmp);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -865,7 +865,7 @@ copy_shared_framebuffer_cpu (CoglOnscreen *onscreen,
|
|||||||
dumb_bitmap))
|
dumb_bitmap))
|
||||||
g_warning ("Failed to CPU-copy to a secondary GPU output");
|
g_warning ("Failed to CPU-copy to a secondary GPU output");
|
||||||
|
|
||||||
cogl_object_unref (dumb_bitmap);
|
g_object_unref (dumb_bitmap);
|
||||||
|
|
||||||
secondary_gpu_state->cpu.current_dumb_fb = buffer_dumb;
|
secondary_gpu_state->cpu.current_dumb_fb = buffer_dumb;
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||||
|
|
||||||
|
static GQuark pixbuf_key = 0;
|
||||||
|
|
||||||
static inline ClutterActor *
|
static inline ClutterActor *
|
||||||
clutter_test_utils_create_texture_from_file (const char *filename,
|
clutter_test_utils_create_texture_from_file (const char *filename,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -34,7 +36,7 @@ clutter_test_create_bitmap_from_file (CoglContext *ctx,
|
|||||||
const char *filename,
|
const char *filename,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
static CoglUserDataKey pixbuf_key;
|
pixbuf_key = g_quark_from_static_string ("-cogl-bitmap-pixbuf-key");
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
gboolean has_alpha;
|
gboolean has_alpha;
|
||||||
GdkColorspace color_space;
|
GdkColorspace color_space;
|
||||||
@ -101,10 +103,10 @@ clutter_test_create_bitmap_from_file (CoglContext *ctx,
|
|||||||
rowstride,
|
rowstride,
|
||||||
gdk_pixbuf_get_pixels (pixbuf));
|
gdk_pixbuf_get_pixels (pixbuf));
|
||||||
|
|
||||||
cogl_object_set_user_data (COGL_OBJECT (bmp),
|
g_object_set_qdata_full (G_OBJECT (bmp),
|
||||||
&pixbuf_key,
|
pixbuf_key,
|
||||||
pixbuf,
|
pixbuf,
|
||||||
g_object_unref);
|
g_object_unref);
|
||||||
|
|
||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
@ -125,7 +127,7 @@ clutter_test_texture_2d_sliced_new_from_file (CoglContext *ctx,
|
|||||||
|
|
||||||
tex_2ds = cogl_texture_2d_sliced_new_from_bitmap (bmp, COGL_TEXTURE_MAX_WASTE);
|
tex_2ds = cogl_texture_2d_sliced_new_from_bitmap (bmp, COGL_TEXTURE_MAX_WASTE);
|
||||||
|
|
||||||
cogl_object_unref (bmp);
|
g_object_unref (bmp);
|
||||||
|
|
||||||
return tex_2ds;
|
return tex_2ds;
|
||||||
}
|
}
|
||||||
@ -146,7 +148,7 @@ clutter_test_texture_2d_new_from_file (CoglContext *ctx,
|
|||||||
|
|
||||||
tex_2d = cogl_texture_2d_new_from_bitmap (bmp);
|
tex_2d = cogl_texture_2d_new_from_bitmap (bmp);
|
||||||
|
|
||||||
cogl_object_unref (bmp);
|
g_object_unref (bmp);
|
||||||
|
|
||||||
return tex_2d;
|
return tex_2d;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ test_utils_texture_new_from_data (CoglContext *ctx,
|
|||||||
|
|
||||||
tex = test_utils_texture_new_from_bitmap (bmp, flags, TRUE);
|
tex = test_utils_texture_new_from_bitmap (bmp, flags, TRUE);
|
||||||
|
|
||||||
cogl_object_unref (bmp);
|
g_object_unref (bmp);
|
||||||
|
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ test_pixel_buffer_map (void)
|
|||||||
-1.0f, 1.0f,
|
-1.0f, 1.0f,
|
||||||
1.0f, -1.0f);
|
1.0f, -1.0f);
|
||||||
|
|
||||||
cogl_object_unref (bitmap);
|
g_object_unref (bitmap);
|
||||||
cogl_object_unref (texture);
|
cogl_object_unref (texture);
|
||||||
cogl_object_unref (pipeline);
|
cogl_object_unref (pipeline);
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ test_pixel_buffer_set_data (void)
|
|||||||
-1.0f, 1.0f,
|
-1.0f, 1.0f,
|
||||||
1.0f, -1.0f);
|
1.0f, -1.0f);
|
||||||
|
|
||||||
cogl_object_unref (bitmap);
|
g_object_unref (bitmap);
|
||||||
cogl_object_unref (texture);
|
cogl_object_unref (texture);
|
||||||
cogl_object_unref (pipeline);
|
cogl_object_unref (pipeline);
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ test_pixel_buffer_sub_region (void)
|
|||||||
-1.0f, 1.0f,
|
-1.0f, 1.0f,
|
||||||
1.0f, -1.0f);
|
1.0f, -1.0f);
|
||||||
|
|
||||||
cogl_object_unref (bitmap);
|
g_object_unref (bitmap);
|
||||||
cogl_object_unref (texture);
|
cogl_object_unref (texture);
|
||||||
cogl_object_unref (pipeline);
|
cogl_object_unref (pipeline);
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ make_texture (uint32_t color,
|
|||||||
CoglPixelFormat src_format,
|
CoglPixelFormat src_format,
|
||||||
MakeTextureFlags flags)
|
MakeTextureFlags flags)
|
||||||
{
|
{
|
||||||
static CoglUserDataKey bitmap_free_key;
|
|
||||||
CoglTexture2D *tex_2d;
|
CoglTexture2D *tex_2d;
|
||||||
guchar *tex_data = gen_tex_data (color);
|
guchar *tex_data = gen_tex_data (color);
|
||||||
CoglBitmap *bmp = cogl_bitmap_new_for_data (test_ctx,
|
CoglBitmap *bmp = cogl_bitmap_new_for_data (test_ctx,
|
||||||
@ -58,10 +57,6 @@ make_texture (uint32_t color,
|
|||||||
src_format,
|
src_format,
|
||||||
QUAD_WIDTH * 4,
|
QUAD_WIDTH * 4,
|
||||||
tex_data);
|
tex_data);
|
||||||
cogl_object_set_user_data (COGL_OBJECT (bmp),
|
|
||||||
&bitmap_free_key,
|
|
||||||
tex_data,
|
|
||||||
g_free);
|
|
||||||
|
|
||||||
tex_2d = cogl_texture_2d_new_from_bitmap (bmp);
|
tex_2d = cogl_texture_2d_new_from_bitmap (bmp);
|
||||||
|
|
||||||
@ -70,7 +65,7 @@ make_texture (uint32_t color,
|
|||||||
else if (flags & TEXTURE_FLAG_SET_UNPREMULTIPLIED)
|
else if (flags & TEXTURE_FLAG_SET_UNPREMULTIPLIED)
|
||||||
cogl_texture_set_premultiplied (tex_2d, FALSE);
|
cogl_texture_set_premultiplied (tex_2d, FALSE);
|
||||||
|
|
||||||
cogl_object_unref (bmp);
|
g_object_unref (bmp);
|
||||||
|
|
||||||
return tex_2d;
|
return tex_2d;
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ capture_view_into (ClutterStageView *view,
|
|||||||
COGL_READ_PIXELS_COLOR_BUFFER,
|
COGL_READ_PIXELS_COLOR_BUFFER,
|
||||||
bitmap);
|
bitmap);
|
||||||
|
|
||||||
cogl_object_unref (bitmap);
|
g_object_unref (bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -403,7 +403,7 @@ shm_buffer_attach (MetaWaylandBuffer *buffer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cogl_object_unref (bitmap);
|
g_object_unref (bitmap);
|
||||||
|
|
||||||
wl_shm_buffer_end_access (shm_buffer);
|
wl_shm_buffer_end_access (shm_buffer);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user