mirror of
https://github.com/brl/mutter.git
synced 2024-12-27 13:22:15 +00:00
texture: assert set_region size <= src size
This improves the documentation for cogl_texture_set_region() and cogl_texture_set_region_from_bitmap() to explain that the region can't be larger than the source data and also adds runtime assertions that such a request isn't made. Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
aa59dc5e8d
commit
ba02f70961
@ -676,6 +676,11 @@ cogl_texture_set_region_from_bitmap (CoglTexture *texture,
|
||||
{
|
||||
gboolean ret;
|
||||
|
||||
_COGL_RETURN_VAL_IF_FAIL ((_cogl_bitmap_get_width (bmp) - src_x)
|
||||
>= dst_width, FALSE);
|
||||
_COGL_RETURN_VAL_IF_FAIL ((_cogl_bitmap_get_height (bmp) - src_y)
|
||||
>= dst_height, FALSE);
|
||||
|
||||
/* Shortcut out early if the image is empty */
|
||||
if (dst_width == 0 || dst_height == 0)
|
||||
return TRUE;
|
||||
@ -713,6 +718,9 @@ cogl_texture_set_region (CoglTexture *texture,
|
||||
CoglBitmap *source_bmp;
|
||||
gboolean ret;
|
||||
|
||||
_COGL_RETURN_VAL_IF_FAIL ((width - src_x) >= dst_width, FALSE);
|
||||
_COGL_RETURN_VAL_IF_FAIL ((height - src_y) >= dst_height, FALSE);
|
||||
|
||||
/* Check for valid format */
|
||||
if (format == COGL_PIXEL_FORMAT_ANY)
|
||||
return FALSE;
|
||||
|
@ -366,8 +366,10 @@ cogl_texture_get_data (CoglTexture *texture,
|
||||
* @src_y: upper left coordinate to use from source data.
|
||||
* @dst_x: upper left destination horizontal coordinate.
|
||||
* @dst_y: upper left destination vertical coordinate.
|
||||
* @dst_width: width of destination region to write.
|
||||
* @dst_height: height of destination region to write.
|
||||
* @dst_width: width of destination region to write. (Must be less
|
||||
* than or equal to @width)
|
||||
* @dst_height: height of destination region to write. (Must be less
|
||||
* than or equal to @height)
|
||||
* @width: width of source data buffer.
|
||||
* @height: height of source data buffer.
|
||||
* @format: the #CoglPixelFormat used in the source buffer.
|
||||
@ -375,9 +377,11 @@ cogl_texture_get_data (CoglTexture *texture,
|
||||
* specified)
|
||||
* @data: the actual pixel data.
|
||||
*
|
||||
* Sets the pixels in a rectangular subregion of @handle from an in-memory
|
||||
* Sets the pixels in a rectangular subregion of @texture from an in-memory
|
||||
* buffer containing pixel data.
|
||||
*
|
||||
* <note>The region set can't be larger than the source @data</note>
|
||||
*
|
||||
* Return value: %TRUE if the subregion upload was successful, and
|
||||
* %FALSE otherwise
|
||||
*/
|
||||
@ -406,13 +410,18 @@ cogl_texture_set_region (CoglTexture *texture,
|
||||
* @src_y: upper left coordinate to use from the source bitmap
|
||||
* @dst_x: upper left destination horizontal coordinate.
|
||||
* @dst_y: upper left destination vertical coordinate.
|
||||
* @dst_width: width of destination region to write.
|
||||
* @dst_height: height of destination region to write.
|
||||
* @dst_width: width of destination region to write. (Must be less
|
||||
* than or equal to the bitmap width)
|
||||
* @dst_height: height of destination region to write. (Must be less
|
||||
* than or equal to the bitmap height)
|
||||
* @bitmap: The source bitmap to read from
|
||||
*
|
||||
* Copies a specified source region from @bitmap to the position
|
||||
* (@src_x, @src_y) of the given destination texture @handle.
|
||||
*
|
||||
* <note>The region updated can't be larger than the source
|
||||
* bitmap</note>
|
||||
*
|
||||
* Return value: %TRUE if the subregion upload was successful, and
|
||||
* %FALSE otherwise
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user