Update/clean and apply the async-texture patch from bug #1144
This commit is contained in:
parent
df3667dd3a
commit
0866b07f30
@ -134,6 +134,26 @@ CoglHandle cogl_texture_new_from_foreign (GLuint gl_handle,
|
|||||||
GLuint y_pot_waste,
|
GLuint y_pot_waste,
|
||||||
CoglPixelFormat format);
|
CoglPixelFormat format);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_texture_new_from_bitmap:
|
||||||
|
* @handle: handle of the preloaded texture.
|
||||||
|
* @max_waste: maximum extra horizontal and|or vertical margin pixels to make
|
||||||
|
* texture fit GPU limitations.
|
||||||
|
* @auto_mipmap: enable or disable automatic generation of mipmap pyramid
|
||||||
|
* from the base level image whenever it is updated.
|
||||||
|
* @internal_format: the #CoglPixelFormat to use for the GPU storage of the
|
||||||
|
* texture.
|
||||||
|
*
|
||||||
|
* Create a cogl texture from a #CoglBitmap.
|
||||||
|
*
|
||||||
|
* Returns: a #CoglHandle to the newly created texture or COGL_INVALID_HANDLE
|
||||||
|
* if creating the texture failed.
|
||||||
|
*/
|
||||||
|
CoglHandle cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
|
||||||
|
gint max_waste,
|
||||||
|
gboolean auto_mipmap,
|
||||||
|
CoglPixelFormat internal_format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_is_texture:
|
* cogl_is_texture:
|
||||||
* @handle: A CoglHandle
|
* @handle: A CoglHandle
|
||||||
@ -385,6 +405,28 @@ void cogl_texture_polygon (CoglHandle handle,
|
|||||||
CoglTextureVertex *vertices,
|
CoglTextureVertex *vertices,
|
||||||
gboolean use_color);
|
gboolean use_color);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_bitmap_new_from_file:
|
||||||
|
* @filename: the file to load.
|
||||||
|
* @error: a #GError or %NULL.
|
||||||
|
*
|
||||||
|
* Load an image file from disk. This function can be safely called from
|
||||||
|
* within a thread.
|
||||||
|
*
|
||||||
|
* Returns: A #CoglBitmap to the new loaded image data, or %NULL if loading
|
||||||
|
* the image failed.
|
||||||
|
*/
|
||||||
|
CoglBitmap * cogl_bitmap_new_from_file (const gchar *filename,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cogl_bitmap_free:
|
||||||
|
* @bmp: a #CoglBitmap.
|
||||||
|
*
|
||||||
|
* Frees a #CoglBitmap.
|
||||||
|
*/
|
||||||
|
void cogl_bitmap_free (CoglBitmap *bmp);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __COGL_TEXTURE_H__ */
|
#endif /* __COGL_TEXTURE_H__ */
|
||||||
|
@ -28,6 +28,13 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CoglBitmap:
|
||||||
|
*
|
||||||
|
* Type used for storing image data.
|
||||||
|
*/
|
||||||
|
typedef struct _CoglBitmap CoglBitmap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CoglHandle:
|
* CoglHandle:
|
||||||
*
|
*
|
||||||
|
@ -148,3 +148,34 @@ _cogl_bitmap_copy_subregion (CoglBitmap *src,
|
|||||||
dstdata += dst->rowstride;
|
dstdata += dst->rowstride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CoglBitmap *
|
||||||
|
cogl_bitmap_new_from_file (const gchar *filename,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
CoglBitmap bmp;
|
||||||
|
|
||||||
|
g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
|
||||||
|
|
||||||
|
/* Try loading with imaging backend */
|
||||||
|
if (!_cogl_bitmap_from_file (&bmp, filename, error))
|
||||||
|
{
|
||||||
|
/* Try fallback */
|
||||||
|
if (!_cogl_bitmap_fallback_from_file (&bmp, filename))
|
||||||
|
return NULL;
|
||||||
|
else if (error && *error)
|
||||||
|
{
|
||||||
|
g_error_free (*error);
|
||||||
|
*error = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (CoglBitmap *) g_memdup (&bmp, sizeof (CoglBitmap));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cogl_bitmap_free (CoglBitmap *bmp)
|
||||||
|
{
|
||||||
|
g_free (bmp->data);
|
||||||
|
g_free (bmp);
|
||||||
|
}
|
||||||
|
@ -28,8 +28,6 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
typedef struct _CoglBitmap CoglBitmap;
|
|
||||||
|
|
||||||
struct _CoglBitmap
|
struct _CoglBitmap
|
||||||
{
|
{
|
||||||
guchar *data;
|
guchar *data;
|
||||||
|
@ -1323,30 +1323,13 @@ cogl_texture_new_from_data (guint width,
|
|||||||
}
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglHandle
|
||||||
cogl_texture_new_from_file (const gchar *filename,
|
cogl_texture_new_from_bitmap (CoglBitmap *bmp,
|
||||||
gint max_waste,
|
gint max_waste,
|
||||||
gboolean auto_mipmap,
|
gboolean auto_mipmap,
|
||||||
CoglPixelFormat internal_format,
|
CoglPixelFormat internal_format)
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
CoglBitmap bmp;
|
|
||||||
CoglTexture *tex;
|
CoglTexture *tex;
|
||||||
|
|
||||||
g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
|
|
||||||
|
|
||||||
/* Try loading with imaging backend */
|
|
||||||
if (!_cogl_bitmap_from_file (&bmp, filename, error))
|
|
||||||
{
|
|
||||||
/* Try fallback */
|
|
||||||
if (!_cogl_bitmap_fallback_from_file (&bmp, filename))
|
|
||||||
return COGL_INVALID_HANDLE;
|
|
||||||
else if (error && *error)
|
|
||||||
{
|
|
||||||
g_error_free (*error);
|
|
||||||
*error = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create new texture and fill with loaded data */
|
/* Create new texture and fill with loaded data */
|
||||||
tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture));
|
tex = (CoglTexture*) g_malloc ( sizeof (CoglTexture));
|
||||||
|
|
||||||
@ -1356,8 +1339,9 @@ cogl_texture_new_from_file (const gchar *filename,
|
|||||||
tex->is_foreign = FALSE;
|
tex->is_foreign = FALSE;
|
||||||
tex->auto_mipmap = auto_mipmap;
|
tex->auto_mipmap = auto_mipmap;
|
||||||
|
|
||||||
tex->bitmap = bmp;
|
tex->bitmap = *bmp;
|
||||||
tex->bitmap_owner = TRUE;
|
tex->bitmap_owner = TRUE;
|
||||||
|
bmp->data = NULL;
|
||||||
|
|
||||||
tex->slice_x_spans = NULL;
|
tex->slice_x_spans = NULL;
|
||||||
tex->slice_y_spans = NULL;
|
tex->slice_y_spans = NULL;
|
||||||
@ -1398,6 +1382,30 @@ cogl_texture_new_from_file (const gchar *filename,
|
|||||||
return _cogl_texture_handle_new (tex);
|
return _cogl_texture_handle_new (tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CoglHandle
|
||||||
|
cogl_texture_new_from_file (const gchar *filename,
|
||||||
|
gint max_waste,
|
||||||
|
gboolean auto_mipmap,
|
||||||
|
CoglPixelFormat internal_format,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
CoglBitmap *bmp;
|
||||||
|
CoglHandle handle;
|
||||||
|
|
||||||
|
g_return_val_if_fail (error == NULL || *error == NULL, COGL_INVALID_HANDLE);
|
||||||
|
|
||||||
|
if (!(bmp = cogl_bitmap_new_from_file (filename, error)))
|
||||||
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
|
handle = cogl_texture_new_from_bitmap (bmp,
|
||||||
|
max_waste,
|
||||||
|
auto_mipmap,
|
||||||
|
internal_format);
|
||||||
|
cogl_bitmap_free (bmp);
|
||||||
|
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
CoglHandle
|
CoglHandle
|
||||||
cogl_texture_new_from_foreign (GLuint gl_handle,
|
cogl_texture_new_from_foreign (GLuint gl_handle,
|
||||||
GLenum gl_target,
|
GLenum gl_target,
|
||||||
|
Loading…
Reference in New Issue
Block a user