mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
pixel-array: Only allow allocation of arrays with a 2D size
This removes cogl_pixel_array_new which just took a size in bytes. Without the image size and pixel format then the driver often doesn't have enough information to allocate optimal GPU memory that can be textured from directly. This is because GPUs often have ways to spatially alter the layout of a texture to improve cache access patterns which may require special alignment and padding dependant in the images width, height and bpp. Although currently we are limited by OpenGL because it doesn't let us pass on the width and height when allocating a PBO, the hope is that we can define a better extension at some point.
This commit is contained in:
parent
daa34aeb0e
commit
9e25f8c40d
@ -87,8 +87,8 @@ cogl_malloc_pixel_array_vtable;
|
|||||||
|
|
||||||
COGL_BUFFER_DEFINE (PixelArray, pixel_array)
|
COGL_BUFFER_DEFINE (PixelArray, pixel_array)
|
||||||
|
|
||||||
CoglPixelArray *
|
static CoglPixelArray *
|
||||||
cogl_pixel_array_new (unsigned int size)
|
_cogl_pixel_array_new (unsigned int size)
|
||||||
{
|
{
|
||||||
CoglPixelArray *pixel_array = g_slice_new0 (CoglPixelArray);
|
CoglPixelArray *pixel_array = g_slice_new0 (CoglPixelArray);
|
||||||
CoglBuffer *buffer = COGL_BUFFER (pixel_array);
|
CoglBuffer *buffer = COGL_BUFFER (pixel_array);
|
||||||
@ -148,7 +148,7 @@ cogl_pixel_array_new_with_size (unsigned int width,
|
|||||||
if (rowstride)
|
if (rowstride)
|
||||||
*rowstride = stride;
|
*rowstride = stride;
|
||||||
|
|
||||||
buffer = cogl_pixel_array_new (height * stride);
|
buffer = _cogl_pixel_array_new (height * stride);
|
||||||
if (G_UNLIKELY (buffer == COGL_INVALID_HANDLE))
|
if (G_UNLIKELY (buffer == COGL_INVALID_HANDLE))
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
|
@ -52,22 +52,6 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
typedef struct _CoglPixelArray CoglPixelArray;
|
typedef struct _CoglPixelArray CoglPixelArray;
|
||||||
|
|
||||||
/**
|
|
||||||
* cogl_pixel_array_new:
|
|
||||||
* @size: size of the array in bytes
|
|
||||||
*
|
|
||||||
* Creates a new array to store pixel data. You can create a new texture from
|
|
||||||
* this array using cogl_texture_new_from_buffer().
|
|
||||||
*
|
|
||||||
* Return value: a #CoglPixelArray representing the newly created array or
|
|
||||||
* %NULL on failure
|
|
||||||
*
|
|
||||||
* Since: 1.2
|
|
||||||
* Stability: Unstable
|
|
||||||
*/
|
|
||||||
CoglPixelArray *
|
|
||||||
cogl_pixel_array_new (unsigned int size);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_pixel_array_new_with_size:
|
* cogl_pixel_array_new_with_size:
|
||||||
* @width: width of the pixel array in pixels
|
* @width: width of the pixel array in pixels
|
||||||
|
Loading…
Reference in New Issue
Block a user