mirror of
https://github.com/brl/mutter.git
synced 2024-11-29 03:20:46 -05:00
texture-rectangle: update _new_with_size in line with master
This updates the cogl_texture_rectangle_new_with_size() api in line with master to be consistent with other texture constructors. This removes the internal_format and error arguments and allows the texture to be allocated lazily which means the texture can be configured with apis like cogl_texture_set_components() and cogl_texture_set_premultiplied() before it is allocated. Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
8cedb43249
commit
a77dc1319c
@ -193,46 +193,16 @@ _cogl_texture_rectangle_create_base (CoglContext *ctx,
|
|||||||
CoglTextureRectangle *
|
CoglTextureRectangle *
|
||||||
cogl_texture_rectangle_new_with_size (CoglContext *ctx,
|
cogl_texture_rectangle_new_with_size (CoglContext *ctx,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height)
|
||||||
CoglPixelFormat internal_format,
|
|
||||||
CoglError **error)
|
|
||||||
{
|
{
|
||||||
CoglTextureLoader *loader;
|
CoglTextureLoader *loader = _cogl_texture_create_loader ();
|
||||||
CoglTextureRectangle *tex_rect;
|
|
||||||
|
|
||||||
/* Since no data, we need some internal format */
|
|
||||||
if (internal_format == COGL_PIXEL_FORMAT_ANY)
|
|
||||||
internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
|
|
||||||
|
|
||||||
loader = _cogl_texture_create_loader ();
|
|
||||||
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED;
|
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_SIZED;
|
||||||
loader->src.sized.width = width;
|
loader->src.sized.width = width;
|
||||||
loader->src.sized.height = height;
|
loader->src.sized.height = height;
|
||||||
|
|
||||||
tex_rect = _cogl_texture_rectangle_create_base (ctx, width, height,
|
return _cogl_texture_rectangle_create_base (ctx, width, height,
|
||||||
internal_format, loader);
|
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||||
|
loader);
|
||||||
/* XXX: This api has been changed for Cogl 2.0 on the master branch
|
|
||||||
* to not take a CoglError to allow the storage to be allocated
|
|
||||||
* lazily but since Mutter uses this api we are currently
|
|
||||||
* maintaining the semantics of immediately allocating the storage
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* By default tex->premultiplied is set to TRUE and tex->components
|
|
||||||
* get initialized according to a given source-format in
|
|
||||||
* _cogl_texture_init(). Since this api has an internal-format
|
|
||||||
* argument for compatibility we need to make sure the
|
|
||||||
* ->premultiplied and ->components state are initialized according
|
|
||||||
* to the users given @internal_format. */
|
|
||||||
_cogl_texture_set_internal_format (COGL_TEXTURE (tex_rect), internal_format);
|
|
||||||
|
|
||||||
if (!cogl_texture_allocate (COGL_TEXTURE (tex_rect), error))
|
|
||||||
{
|
|
||||||
cogl_object_unref (tex_rect);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tex_rect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static CoglBool
|
static CoglBool
|
||||||
|
@ -81,13 +81,11 @@ cogl_is_texture_rectangle (void *object);
|
|||||||
* @ctx: A #CoglContext pointer
|
* @ctx: A #CoglContext pointer
|
||||||
* @width: The texture width to allocate
|
* @width: The texture width to allocate
|
||||||
* @height: The texture height to allocate
|
* @height: The texture height to allocate
|
||||||
* @internal_format: The desired internal texture format
|
|
||||||
* @error: An optional CoglError pointer for reporting exceptions
|
|
||||||
*
|
*
|
||||||
* Allocates a new #CoglTextureRectangle texture with a given @width,
|
* Creates a new #CoglTextureRectangle texture with a given @width,
|
||||||
* @height and @internal_format. This texture is a low-level texture
|
* and @height. This texture is a low-level texture that the GPU can
|
||||||
* that the GPU can sample from directly unlike high-level textures
|
* sample from directly unlike high-level textures such as
|
||||||
* such as #CoglTexture2DSliced and #CoglAtlasTexture.
|
* #CoglTexture2DSliced and #CoglAtlasTexture.
|
||||||
*
|
*
|
||||||
* <note>Unlike for #CoglTexture2D textures, coordinates for
|
* <note>Unlike for #CoglTexture2D textures, coordinates for
|
||||||
* #CoglTextureRectangle textures should not be normalized. So instead
|
* #CoglTextureRectangle textures should not be normalized. So instead
|
||||||
@ -102,15 +100,15 @@ cogl_is_texture_rectangle (void *object);
|
|||||||
* first check for the %COGL_FEATURE_ID_TEXTURE_RECTANGLE feature
|
* first check for the %COGL_FEATURE_ID_TEXTURE_RECTANGLE feature
|
||||||
* using cogl_has_feature().</note>
|
* using cogl_has_feature().</note>
|
||||||
*
|
*
|
||||||
* <note>For compatibility, unlike other texture constructors, this
|
* The storage for the texture is not allocated before this function
|
||||||
* api allocates texture storage synchronously and returns %NULL on
|
* returns. You can call cogl_texture_allocate() to explicitly
|
||||||
* failure so it is not possible to configure rectangle textures
|
* allocate the underlying storage or preferably let Cogl
|
||||||
* created with this api before allocation.</note>
|
* automatically allocate storage lazily when it may know more about
|
||||||
|
* how the texture is going to be used and can optimize how it is
|
||||||
|
* allocated.
|
||||||
*
|
*
|
||||||
* Return value: (transfer full): A pointer to a newly allocated
|
* Returns value: (transfer full): A pointer to a new #CoglTextureRectangle
|
||||||
* #CoglTextureRectangle texture or if the size was too large
|
* object with no storage allocated yet.
|
||||||
* or there wasn't enough memory %NULL is returned and @error
|
|
||||||
* set.
|
|
||||||
*
|
*
|
||||||
* Since: 1.10
|
* Since: 1.10
|
||||||
* Stability: unstable
|
* Stability: unstable
|
||||||
@ -118,9 +116,7 @@ cogl_is_texture_rectangle (void *object);
|
|||||||
CoglTextureRectangle *
|
CoglTextureRectangle *
|
||||||
cogl_texture_rectangle_new_with_size (CoglContext *ctx,
|
cogl_texture_rectangle_new_with_size (CoglContext *ctx,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height);
|
||||||
CoglPixelFormat internal_format,
|
|
||||||
CoglError **error);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_rectangle_new_from_bitmap:
|
* cogl_texture_rectangle_new_from_bitmap:
|
||||||
|
@ -2504,13 +2504,11 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
|
|||||||
glx_tex_pixmap->glx_tex = COGL_TEXTURE (
|
glx_tex_pixmap->glx_tex = COGL_TEXTURE (
|
||||||
cogl_texture_rectangle_new_with_size (ctx,
|
cogl_texture_rectangle_new_with_size (ctx,
|
||||||
tex->width,
|
tex->width,
|
||||||
tex->height,
|
tex->height));
|
||||||
texture_format,
|
|
||||||
&error));
|
|
||||||
|
|
||||||
_cogl_texture_set_internal_format (tex, texture_format);
|
_cogl_texture_set_internal_format (tex, texture_format);
|
||||||
|
|
||||||
if (glx_tex_pixmap->glx_tex)
|
if (cogl_texture_allocate (glx_tex_pixmap->glx_tex, &error))
|
||||||
COGL_NOTE (TEXTURE_PIXMAP, "Created a texture rectangle for %p",
|
COGL_NOTE (TEXTURE_PIXMAP, "Created a texture rectangle for %p",
|
||||||
tex_pixmap);
|
tex_pixmap);
|
||||||
else
|
else
|
||||||
|
@ -74,9 +74,7 @@ test_texture_no_allocate (void)
|
|||||||
{
|
{
|
||||||
CoglTextureRectangle *texture_rect =
|
CoglTextureRectangle *texture_rect =
|
||||||
cogl_texture_rectangle_new_with_size (test_ctx,
|
cogl_texture_rectangle_new_with_size (test_ctx,
|
||||||
64, 64,
|
64, 64);
|
||||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
|
||||||
NULL /* error */);
|
|
||||||
cogl_object_unref (texture_rect);
|
cogl_object_unref (texture_rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user