From 9e25f8c40de3d6f4d11c5fabe09aba990b2a8e9e Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Sun, 4 Jul 2010 00:49:31 +0100 Subject: [PATCH] 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. --- cogl/cogl-pixel-array.c | 6 +++--- cogl/cogl-pixel-array.h | 16 ---------------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/cogl/cogl-pixel-array.c b/cogl/cogl-pixel-array.c index 574a71c0f..ba8d60fc2 100644 --- a/cogl/cogl-pixel-array.c +++ b/cogl/cogl-pixel-array.c @@ -87,8 +87,8 @@ cogl_malloc_pixel_array_vtable; COGL_BUFFER_DEFINE (PixelArray, pixel_array) -CoglPixelArray * -cogl_pixel_array_new (unsigned int size) +static CoglPixelArray * +_cogl_pixel_array_new (unsigned int size) { CoglPixelArray *pixel_array = g_slice_new0 (CoglPixelArray); CoglBuffer *buffer = COGL_BUFFER (pixel_array); @@ -148,7 +148,7 @@ cogl_pixel_array_new_with_size (unsigned int width, if (rowstride) *rowstride = stride; - buffer = cogl_pixel_array_new (height * stride); + buffer = _cogl_pixel_array_new (height * stride); if (G_UNLIKELY (buffer == COGL_INVALID_HANDLE)) return COGL_INVALID_HANDLE; diff --git a/cogl/cogl-pixel-array.h b/cogl/cogl-pixel-array.h index 3e17782d8..870ed9cbf 100644 --- a/cogl/cogl-pixel-array.h +++ b/cogl/cogl-pixel-array.h @@ -52,22 +52,6 @@ G_BEGIN_DECLS 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: * @width: width of the pixel array in pixels