mirror of
https://github.com/brl/mutter.git
synced 2024-11-12 17:27:03 -05:00
rename CoglPixelBuffer to CoglPixelArray
This renames CoglPixelBuffer to CoglPixelArray to be consistent with the new CoglVertexArray API.
This commit is contained in:
parent
cafeb02531
commit
521d9ca203
@ -65,7 +65,7 @@ cogl_public_h = \
|
||||
$(srcdir)/cogl-offscreen.h \
|
||||
$(srcdir)/cogl-primitives.h \
|
||||
$(srcdir)/cogl-path.h \
|
||||
$(srcdir)/cogl-pixel-buffer.h \
|
||||
$(srcdir)/cogl-pixel-array.h \
|
||||
$(srcdir)/cogl-shader.h \
|
||||
$(srcdir)/cogl-texture.h \
|
||||
$(srcdir)/cogl-types.h \
|
||||
@ -108,8 +108,8 @@ cogl_sources_c = \
|
||||
$(srcdir)/cogl-color.c \
|
||||
$(srcdir)/cogl-buffer-private.h \
|
||||
$(srcdir)/cogl-buffer.c \
|
||||
$(srcdir)/cogl-pixel-buffer-private.h \
|
||||
$(srcdir)/cogl-pixel-buffer.c \
|
||||
$(srcdir)/cogl-pixel-array-private.h \
|
||||
$(srcdir)/cogl-pixel-array.c \
|
||||
$(srcdir)/cogl-vertex-buffer-private.h \
|
||||
$(srcdir)/cogl-vertex-buffer.c \
|
||||
$(srcdir)/cogl-matrix.c \
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include "cogl-util.h"
|
||||
#include "cogl-context.h"
|
||||
#include "cogl-handle.h"
|
||||
#include "cogl-pixel-buffer-private.h"
|
||||
#include "cogl-pixel-array-private.h"
|
||||
|
||||
/*
|
||||
* GL/GLES compatibility defines for the buffer API:
|
||||
|
@ -22,10 +22,11 @@
|
||||
*
|
||||
* Authors:
|
||||
* Damien Lespiau <damien.lespiau@intel.com>
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#ifndef __COGL_PIXEL_BUFFER_PRIVATE_H__
|
||||
#define __COGL_PIXEL_BUFFER_PRIVATE_H__
|
||||
#ifndef __COGL_PIXEL_ARRAY_PRIVATE_H__
|
||||
#define __COGL_PIXEL_ARRAY_PRIVATE_H__
|
||||
|
||||
#include "cogl-handle.h"
|
||||
#include "cogl-buffer-private.h"
|
||||
@ -34,28 +35,28 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define COGL_PIXEL_BUFFER(buffer) ((CoglPixelBuffer *)(buffer))
|
||||
#define COGL_PIXEL_ARRAY(array) ((CoglPixelArray *)(array))
|
||||
|
||||
#define COGL_PIXEL_BUFFER_SET_FLAG(buffer, flag) \
|
||||
((buffer)->flags |= (COGL_PIXEL_BUFFER_FLAG_ ## flag))
|
||||
#define COGL_PIXEL_ARRAY_SET_FLAG(array, flag) \
|
||||
((array)->flags |= (COGL_PIXEL_ARRAY_FLAG_ ## flag))
|
||||
|
||||
#define COGL_PIXEL_BUFFER_CLEAR_FLAG(buffer, flag) \
|
||||
((buffer)->flags &= ~(COGL_PIXEL_BUFFER_FLAG_ ## flag))
|
||||
#define COGL_PIXEL_ARRAY_CLEAR_FLAG(array, flag) \
|
||||
((array)->flags &= ~(COGL_PIXEL_ARRAY_FLAG_ ## flag))
|
||||
|
||||
#define COGL_PIXEL_BUFFER_FLAG_IS_SET(buffer, flag) \
|
||||
((buffer)->flags & (COGL_PIXEL_BUFFER_FLAG_ ## flag))
|
||||
#define COGL_PIXEL_ARRAY_FLAG_IS_SET(array, flag) \
|
||||
((array)->flags & (COGL_PIXEL_ARRAY_FLAG_ ## flag))
|
||||
|
||||
typedef enum _CoglPixelBufferFlags
|
||||
typedef enum _CoglPixelArrayFlags
|
||||
{
|
||||
COGL_PIXEL_BUFFER_FLAG_NONE = 0,
|
||||
COGL_PIXEL_BUFFER_FLAG_STORE_CREATED = 1 << 0,
|
||||
} CoglPixelBufferFlags;
|
||||
COGL_PIXEL_ARRAY_FLAG_NONE = 0,
|
||||
COGL_PIXEL_ARRAY_FLAG_STORE_CREATED = 1 << 0,
|
||||
} CoglPixelArrayFlags;
|
||||
|
||||
struct _CoglPixelBuffer
|
||||
struct _CoglPixelArray
|
||||
{
|
||||
CoglBuffer _parent;
|
||||
|
||||
CoglPixelBufferFlags flags;
|
||||
CoglPixelArrayFlags flags;
|
||||
|
||||
GLenum gl_target;
|
||||
CoglPixelFormat format;
|
||||
@ -66,8 +67,8 @@ struct _CoglPixelBuffer
|
||||
};
|
||||
|
||||
GQuark
|
||||
_cogl_handle_pixel_buffer_get_type (void);
|
||||
_cogl_handle_pixel_array_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __COGL_PIXEL_BUFFER_PRIVATE_H__ */
|
||||
#endif /* __COGL_PIXEL_ARRAY_PRIVATE_H__ */
|
@ -22,10 +22,11 @@
|
||||
*
|
||||
* Authors:
|
||||
* Damien Lespiau <damien.lespiau@intel.com>
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
/* For an overview of the functionality implemented here, please see
|
||||
* cogl-pixel-buffer.h, which contains the gtk-doc section overview for the
|
||||
* cogl-pixel-array.h, which contains the gtk-doc section overview for the
|
||||
* Pixel Buffers API.
|
||||
*/
|
||||
|
||||
@ -42,8 +43,8 @@
|
||||
#include "cogl-util.h"
|
||||
#include "cogl-context.h"
|
||||
#include "cogl-object.h"
|
||||
#include "cogl-pixel-buffer-private.h"
|
||||
#include "cogl-pixel-buffer.h"
|
||||
#include "cogl-pixel-array-private.h"
|
||||
#include "cogl-pixel-array.h"
|
||||
|
||||
/*
|
||||
* GL/GLES compatibility defines for the buffer API:
|
||||
@ -75,22 +76,22 @@
|
||||
#endif
|
||||
|
||||
static void
|
||||
_cogl_pixel_buffer_free (CoglPixelBuffer *buffer);
|
||||
_cogl_pixel_array_free (CoglPixelArray *buffer);
|
||||
|
||||
#if !defined (COGL_HAS_GLES)
|
||||
static const CoglBufferVtable
|
||||
cogl_pixel_buffer_vtable;
|
||||
cogl_pixel_array_vtable;
|
||||
#endif
|
||||
static const CoglBufferVtable
|
||||
cogl_malloc_pixel_buffer_vtable;
|
||||
cogl_malloc_pixel_array_vtable;
|
||||
|
||||
COGL_BUFFER_DEFINE (PixelBuffer, pixel_buffer)
|
||||
COGL_BUFFER_DEFINE (PixelArray, pixel_array)
|
||||
|
||||
CoglPixelBuffer *
|
||||
cogl_pixel_buffer_new (unsigned int size)
|
||||
CoglPixelArray *
|
||||
cogl_pixel_array_new (unsigned int size)
|
||||
{
|
||||
CoglPixelBuffer *pixel_buffer = g_slice_new0 (CoglPixelBuffer);
|
||||
CoglBuffer *buffer = COGL_BUFFER (pixel_buffer);
|
||||
CoglPixelArray *pixel_array = g_slice_new0 (CoglPixelArray);
|
||||
CoglBuffer *buffer = COGL_BUFFER (pixel_array);
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, COGL_INVALID_HANDLE);
|
||||
|
||||
@ -105,7 +106,7 @@ cogl_pixel_buffer_new (unsigned int size)
|
||||
if (cogl_features_available (COGL_FEATURE_PBOS))
|
||||
{
|
||||
/* PBOS */
|
||||
buffer->vtable = &cogl_pixel_buffer_vtable;
|
||||
buffer->vtable = &cogl_pixel_array_vtable;
|
||||
|
||||
GE( glGenBuffers (1, &buffer->gl_handle) );
|
||||
COGL_BUFFER_SET_FLAG (buffer, BUFFER_OBJECT);
|
||||
@ -114,54 +115,54 @@ cogl_pixel_buffer_new (unsigned int size)
|
||||
#endif
|
||||
{
|
||||
/* malloc fallback subclass */
|
||||
buffer->vtable = &cogl_malloc_pixel_buffer_vtable;
|
||||
buffer->vtable = &cogl_malloc_pixel_array_vtable;
|
||||
|
||||
/* create the buffer here as there's no point for a lazy allocation in
|
||||
* the malloc case */
|
||||
buffer->data = g_malloc (size);
|
||||
}
|
||||
|
||||
pixel_buffer->flags = COGL_PIXEL_BUFFER_FLAG_NONE;
|
||||
pixel_array->flags = COGL_PIXEL_ARRAY_FLAG_NONE;
|
||||
|
||||
/* return COGL_INVALID_HANDLE; */
|
||||
return _cogl_pixel_buffer_object_new (pixel_buffer);
|
||||
return _cogl_pixel_array_object_new (pixel_array);
|
||||
}
|
||||
|
||||
CoglPixelBuffer *
|
||||
cogl_pixel_buffer_new_for_size (unsigned int width,
|
||||
unsigned int height,
|
||||
CoglPixelFormat format,
|
||||
unsigned int *rowstride)
|
||||
CoglPixelArray *
|
||||
cogl_pixel_array_new_for_size (unsigned int width,
|
||||
unsigned int height,
|
||||
CoglPixelFormat format,
|
||||
unsigned int *rowstride)
|
||||
{
|
||||
CoglPixelBuffer *buffer;
|
||||
CoglPixelBuffer *pixel_buffer;
|
||||
CoglPixelArray *buffer;
|
||||
CoglPixelArray *pixel_array;
|
||||
unsigned int stride;
|
||||
|
||||
/* creating a buffer to store "any" format does not make sense */
|
||||
if (G_UNLIKELY (format == COGL_PIXEL_FORMAT_ANY))
|
||||
return COGL_INVALID_HANDLE;
|
||||
|
||||
/* for now we fallback to cogl_pixel_buffer_new, later, we could ask
|
||||
/* for now we fallback to cogl_pixel_array_new, later, we could ask
|
||||
* libdrm a tiled buffer for instance */
|
||||
stride = width * _cogl_get_format_bpp (format);
|
||||
if (rowstride)
|
||||
*rowstride = stride;
|
||||
|
||||
buffer = cogl_pixel_buffer_new (height * stride);
|
||||
buffer = cogl_pixel_array_new (height * stride);
|
||||
if (G_UNLIKELY (buffer == COGL_INVALID_HANDLE))
|
||||
return COGL_INVALID_HANDLE;
|
||||
|
||||
pixel_buffer = COGL_PIXEL_BUFFER (buffer);
|
||||
pixel_buffer->width = width;
|
||||
pixel_buffer->height = height;
|
||||
pixel_buffer->format = format;
|
||||
pixel_buffer->stride = stride;
|
||||
pixel_array = COGL_PIXEL_ARRAY (buffer);
|
||||
pixel_array->width = width;
|
||||
pixel_array->height = height;
|
||||
pixel_array->format = format;
|
||||
pixel_array->stride = stride;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_pixel_buffer_free (CoglPixelBuffer *buffer)
|
||||
_cogl_pixel_array_free (CoglPixelArray *buffer)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
@ -170,15 +171,15 @@ _cogl_pixel_buffer_free (CoglPixelBuffer *buffer)
|
||||
|
||||
GE( glDeleteBuffers (1, &(COGL_BUFFER (buffer)->gl_handle)) );
|
||||
|
||||
g_slice_free (CoglPixelBuffer, buffer);
|
||||
g_slice_free (CoglPixelArray, buffer);
|
||||
}
|
||||
|
||||
#if !defined (COGL_HAS_GLES)
|
||||
static guint8 *
|
||||
_cogl_pixel_buffer_map (CoglBuffer *buffer,
|
||||
CoglBufferAccess access)
|
||||
_cogl_pixel_array_map (CoglBuffer *buffer,
|
||||
CoglBufferAccess access)
|
||||
{
|
||||
CoglPixelBuffer *pixel_buffer = COGL_PIXEL_BUFFER (buffer);
|
||||
CoglPixelArray *pixel_array = COGL_PIXEL_ARRAY (buffer);
|
||||
GLenum gl_target;
|
||||
guint8 *data;
|
||||
|
||||
@ -186,21 +187,21 @@ _cogl_pixel_buffer_map (CoglBuffer *buffer,
|
||||
|
||||
/* we determine the target lazily, on the first map */
|
||||
gl_target = GL_PIXEL_UNPACK_BUFFER;
|
||||
pixel_buffer->gl_target = gl_target;
|
||||
pixel_array->gl_target = gl_target;
|
||||
|
||||
_cogl_buffer_bind (buffer, gl_target);
|
||||
|
||||
/* create an empty store if we don't have one yet. creating the store
|
||||
* lazily allows the user of the CoglBuffer to set a hint before the
|
||||
* store is created. */
|
||||
if (!COGL_PIXEL_BUFFER_FLAG_IS_SET (pixel_buffer, STORE_CREATED))
|
||||
if (!COGL_PIXEL_ARRAY_FLAG_IS_SET (pixel_array, STORE_CREATED))
|
||||
{
|
||||
GE( glBufferData (gl_target,
|
||||
buffer->size,
|
||||
NULL,
|
||||
_cogl_buffer_hints_to_gl_enum (buffer->usage_hint,
|
||||
buffer->update_hint)) );
|
||||
COGL_PIXEL_BUFFER_SET_FLAG (pixel_buffer, STORE_CREATED);
|
||||
COGL_PIXEL_ARRAY_SET_FLAG (pixel_array, STORE_CREATED);
|
||||
}
|
||||
|
||||
GE_RET( data, glMapBuffer (gl_target,
|
||||
@ -214,76 +215,76 @@ _cogl_pixel_buffer_map (CoglBuffer *buffer,
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_pixel_buffer_unmap (CoglBuffer *buffer)
|
||||
_cogl_pixel_array_unmap (CoglBuffer *buffer)
|
||||
{
|
||||
CoglPixelBuffer *pixel_buffer = COGL_PIXEL_BUFFER (buffer);
|
||||
CoglPixelArray *pixel_array = COGL_PIXEL_ARRAY (buffer);
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
||||
|
||||
_cogl_buffer_bind (buffer, pixel_buffer->gl_target);
|
||||
_cogl_buffer_bind (buffer, pixel_array->gl_target);
|
||||
|
||||
GE( glUnmapBuffer (pixel_buffer->gl_target) );
|
||||
GE( glUnmapBuffer (pixel_array->gl_target) );
|
||||
COGL_BUFFER_CLEAR_FLAG (buffer, MAPPED);
|
||||
|
||||
_cogl_buffer_bind (NULL, pixel_buffer->gl_target);
|
||||
_cogl_buffer_bind (NULL, pixel_array->gl_target);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_cogl_pixel_buffer_set_data (CoglBuffer *buffer,
|
||||
unsigned int offset,
|
||||
const guint8 *data,
|
||||
unsigned int size)
|
||||
_cogl_pixel_array_set_data (CoglBuffer *buffer,
|
||||
unsigned int offset,
|
||||
const guint8 *data,
|
||||
unsigned int size)
|
||||
{
|
||||
CoglPixelBuffer *pixel_buffer = COGL_PIXEL_BUFFER (buffer);
|
||||
CoglPixelArray *pixel_array = COGL_PIXEL_ARRAY (buffer);
|
||||
|
||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
||||
|
||||
pixel_buffer->gl_target = GL_PIXEL_UNPACK_BUFFER;
|
||||
pixel_array->gl_target = GL_PIXEL_UNPACK_BUFFER;
|
||||
|
||||
_cogl_buffer_bind (buffer, pixel_buffer->gl_target);
|
||||
_cogl_buffer_bind (buffer, pixel_array->gl_target);
|
||||
|
||||
/* create an empty store if we don't have one yet. creating the store
|
||||
* lazily allows the user of the CoglBuffer to set a hint before the
|
||||
* store is created. */
|
||||
if (!COGL_PIXEL_BUFFER_FLAG_IS_SET (pixel_buffer, STORE_CREATED))
|
||||
if (!COGL_PIXEL_ARRAY_FLAG_IS_SET (pixel_array, STORE_CREATED))
|
||||
{
|
||||
GE( glBufferData (pixel_buffer->gl_target,
|
||||
GE( glBufferData (pixel_array->gl_target,
|
||||
buffer->size,
|
||||
NULL,
|
||||
_cogl_buffer_hints_to_gl_enum (buffer->usage_hint,
|
||||
buffer->update_hint)) );
|
||||
COGL_PIXEL_BUFFER_SET_FLAG (pixel_buffer, STORE_CREATED);
|
||||
COGL_PIXEL_ARRAY_SET_FLAG (pixel_array, STORE_CREATED);
|
||||
}
|
||||
|
||||
GE( glBufferSubData (pixel_buffer->gl_target, offset, size, data) );
|
||||
GE( glBufferSubData (pixel_array->gl_target, offset, size, data) );
|
||||
|
||||
_cogl_buffer_bind (NULL, pixel_buffer->gl_target);
|
||||
_cogl_buffer_bind (NULL, pixel_array->gl_target);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
gboolean
|
||||
cogl_pixel_buffer_set_region (CoglPixelBuffer *buffer,
|
||||
guint8 *data,
|
||||
unsigned int src_width,
|
||||
unsigned int src_height,
|
||||
unsigned int src_rowstride,
|
||||
unsigned int dst_x,
|
||||
unsigned int dst_y)
|
||||
cogl_pixel_array_set_region (CoglPixelArray *buffer,
|
||||
guint8 *data,
|
||||
unsigned int src_width,
|
||||
unsigned int src_height,
|
||||
unsigned int src_rowstride,
|
||||
unsigned int dst_x,
|
||||
unsigned int dst_y)
|
||||
{
|
||||
if (!cogl_is_pixel_buffer (buffer))
|
||||
if (!cogl_is_pixel_array (buffer))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static const CoglBufferVtable cogl_pixel_buffer_vtable =
|
||||
static const CoglBufferVtable cogl_pixel_array_vtable =
|
||||
{
|
||||
_cogl_pixel_buffer_map,
|
||||
_cogl_pixel_buffer_unmap,
|
||||
_cogl_pixel_buffer_set_data,
|
||||
_cogl_pixel_array_map,
|
||||
_cogl_pixel_array_unmap,
|
||||
_cogl_pixel_array_set_data,
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -292,32 +293,32 @@ static const CoglBufferVtable cogl_pixel_buffer_vtable =
|
||||
*/
|
||||
|
||||
static guint8 *
|
||||
_cogl_malloc_pixel_buffer_map (CoglBuffer *buffer,
|
||||
CoglBufferAccess access)
|
||||
_cogl_malloc_pixel_array_map (CoglBuffer *buffer,
|
||||
CoglBufferAccess access)
|
||||
{
|
||||
COGL_BUFFER_SET_FLAG (buffer, MAPPED);
|
||||
return buffer->data;
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_malloc_pixel_buffer_unmap (CoglBuffer *buffer)
|
||||
_cogl_malloc_pixel_array_unmap (CoglBuffer *buffer)
|
||||
{
|
||||
COGL_BUFFER_CLEAR_FLAG (buffer, MAPPED);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_cogl_malloc_pixel_buffer_set_data (CoglBuffer *buffer,
|
||||
unsigned int offset,
|
||||
const guint8 *data,
|
||||
unsigned int size)
|
||||
_cogl_malloc_pixel_array_set_data (CoglBuffer *buffer,
|
||||
unsigned int offset,
|
||||
const guint8 *data,
|
||||
unsigned int size)
|
||||
{
|
||||
memcpy (buffer->data + offset, data, size);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static const CoglBufferVtable cogl_malloc_pixel_buffer_vtable =
|
||||
static const CoglBufferVtable cogl_malloc_pixel_array_vtable =
|
||||
{
|
||||
_cogl_malloc_pixel_buffer_map,
|
||||
_cogl_malloc_pixel_buffer_unmap,
|
||||
_cogl_malloc_pixel_buffer_set_data,
|
||||
_cogl_malloc_pixel_array_map,
|
||||
_cogl_malloc_pixel_array_unmap,
|
||||
_cogl_malloc_pixel_array_set_data,
|
||||
};
|
147
cogl/cogl-pixel-array.h
Normal file
147
cogl/cogl-pixel-array.h
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2008,2009,2010 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Damien Lespiau <damien.lespiau@intel.com>
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
#error "Only <cogl/cogl.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __COGL_PIXEL_ARRAY_H__
|
||||
#define __COGL_PIXEL_ARRAY_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <cogl/cogl-types.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* All of the cogl-pixel-array API is currently experimental so we
|
||||
* suffix the actual symbols with _EXP so if somone is monitoring for
|
||||
* ABI changes it will hopefully be clearer to them what's going on if
|
||||
* any of the symbols dissapear at a later date.
|
||||
*/
|
||||
|
||||
#define cogl_pixel_array_new cogl_pixel_array_new_EXP
|
||||
#define cogl_pixel_array_new_for_size cogl_pixel_array_new_for_size_EXP
|
||||
#define cogl_is_pixel_array cogl_is_pixel_array_EXP
|
||||
#if 0
|
||||
#define cogl_pixel_array_set_region cogl_pixel_array_set_region_EXP
|
||||
#endif
|
||||
|
||||
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_for_size:
|
||||
* @width: width of the pixel array in pixels
|
||||
* @height: height of the pixel array in pixels
|
||||
* @format: the format of the pixels the array will store
|
||||
* @stride: if not %NULL the function will return the stride of the array
|
||||
* in bytes
|
||||
*
|
||||
* Creates a new array to store pixel data.
|
||||
*
|
||||
* <note>COGL will try its best to provide a hardware array you can map,
|
||||
* write into and effectively do a zero copy upload when creating a texture
|
||||
* from it with cogl_texture_new_from_buffer(). For various reasons, such
|
||||
* arrays are likely to have a stride larger than width * bytes_per_pixel. The
|
||||
* user must take the stride into account when writing into it.</note>
|
||||
*
|
||||
* Return value: a #CoglPixelArray representing the newly created array or
|
||||
* %NULL on failure
|
||||
*
|
||||
* Since: 1.2
|
||||
* Stability: Unstable
|
||||
*/
|
||||
CoglPixelArray *
|
||||
cogl_pixel_array_new_for_size (unsigned int width,
|
||||
unsigned int height,
|
||||
CoglPixelFormat format,
|
||||
unsigned int *stride);
|
||||
|
||||
/**
|
||||
* cogl_is_pixel_array:
|
||||
* @object: a #CoglObject to test
|
||||
*
|
||||
* Checks whether @handle is a pixel array.
|
||||
*
|
||||
* Return value: %TRUE if the @handle is a pixel array, and %FALSE
|
||||
* otherwise
|
||||
*
|
||||
* Since: 1.2
|
||||
* Stability: Unstable
|
||||
*/
|
||||
gboolean
|
||||
cogl_is_pixel_array (void *object);
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* cogl_pixel_array_set_region:
|
||||
* @array: the #CoglHandle of a pixel array
|
||||
* @data: pixel data to upload to @array
|
||||
* @src_width: width in pixels of the region to update
|
||||
* @src_height: height in pixels of the region to update
|
||||
* @src_rowstride: row stride in bytes of the source array
|
||||
* @dst_x: upper left destination horizontal coordinate
|
||||
* @dst_y: upper left destination vertical coordinate
|
||||
*
|
||||
* Uploads new data into a pixel array. The source data pointed by @data can
|
||||
* have a different stride than @array in which case the function will do the
|
||||
* right thing for you. For performance reasons, it is recommended for the
|
||||
* source data to have the same stride than @array.
|
||||
*
|
||||
* Return value: %TRUE if the upload succeeded, %FALSE otherwise
|
||||
*
|
||||
* Since: 1.2
|
||||
* Stability: Unstable
|
||||
*/
|
||||
gboolean
|
||||
cogl_pixel_array_set_region (CoglHandle array,
|
||||
guint8 *data,
|
||||
unsigned int src_width,
|
||||
unsigned int src_height,
|
||||
unsigned int src_rowstride,
|
||||
unsigned int dst_x,
|
||||
unsigned int dst_y);
|
||||
#endif
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __COGL_PIXEL_ARRAY_H__ */
|
@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Cogl
|
||||
*
|
||||
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||
*
|
||||
* Copyright (C) 2008,2009 Intel Corporation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Authors:
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
|
||||
#error "Only <cogl/cogl.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#ifndef __COGL_PIXEL_BUFFER_H__
|
||||
#define __COGL_PIXEL_BUFFER_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <cogl/cogl-types.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* All of the cogl-pixel-buffer API is currently experimental so we
|
||||
* suffix the actual symbols with _EXP so if somone is monitoring for
|
||||
* ABI changes it will hopefully be clearer to them what's going on if
|
||||
* any of the symbols dissapear at a later date.
|
||||
*/
|
||||
|
||||
#define cogl_pixel_buffer_new cogl_pixel_buffer_new_EXP
|
||||
#define cogl_pixel_buffer_new_for_size cogl_pixel_buffer_new_for_size_EXP
|
||||
#define cogl_is_pixel_buffer cogl_is_pixel_buffer_EXP
|
||||
#if 0
|
||||
#define cogl_pixel_buffer_set_region cogl_pixel_buffer_set_region_EXP
|
||||
#endif
|
||||
|
||||
typedef struct _CoglPixelBuffer CoglPixelBuffer;
|
||||
|
||||
/**
|
||||
* cogl_pixel_buffer_new:
|
||||
* @size: size of the buffer in bytes
|
||||
*
|
||||
* Creates a new buffer to store pixel data. You can create a new texture from
|
||||
* this buffer using cogl_texture_new_from_buffer().
|
||||
*
|
||||
* Return value: a #CoglPixelBuffer representing the newly created buffer or
|
||||
* %NULL on failure
|
||||
*
|
||||
* Since: 1.2
|
||||
* Stability: Unstable
|
||||
*/
|
||||
CoglPixelBuffer *
|
||||
cogl_pixel_buffer_new (unsigned int size);
|
||||
|
||||
/**
|
||||
* cogl_pixel_buffer_new_for_size:
|
||||
* @width: width of the pixel buffer in pixels
|
||||
* @height: height of the pixel buffer in pixels
|
||||
* @format: the format of the pixels the buffer will store
|
||||
* @stride: if not %NULL the function will return the stride of the buffer
|
||||
* in bytes
|
||||
*
|
||||
* Creates a new buffer to store pixel data.
|
||||
*
|
||||
* <note>COGL will try its best to provide a hardware buffer you can map,
|
||||
* write into and effectively do a zero copy upload when creating a texture
|
||||
* from it with cogl_texture_new_from_buffer(). For various reasons, such
|
||||
* buffers are likely to have a stride larger than width * bytes_per_pixel. The
|
||||
* user must take the stride into account when writing into it.</note>
|
||||
*
|
||||
* Return value: a #CoglPixelBuffer representing the newly created buffer or
|
||||
* %NULL on failure
|
||||
*
|
||||
* Since: 1.2
|
||||
* Stability: Unstable
|
||||
*/
|
||||
CoglPixelBuffer *
|
||||
cogl_pixel_buffer_new_for_size (unsigned int width,
|
||||
unsigned int height,
|
||||
CoglPixelFormat format,
|
||||
unsigned int *stride);
|
||||
|
||||
/**
|
||||
* cogl_is_pixel_buffer:
|
||||
* @object: a #CoglObject to test
|
||||
*
|
||||
* Checks whether @handle is a pixel buffer.
|
||||
*
|
||||
* Return value: %TRUE if the @handle is a pixel buffer, and %FALSE
|
||||
* otherwise
|
||||
*
|
||||
* Since: 1.2
|
||||
* Stability: Unstable
|
||||
*/
|
||||
gboolean
|
||||
cogl_is_pixel_buffer (void *object);
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* cogl_pixel_buffer_set_region:
|
||||
* @buffer: the #CoglHandle of a pixel buffer
|
||||
* @data: pixel data to upload to @buffer
|
||||
* @src_width: width in pixels of the region to update
|
||||
* @src_height: height in pixels of the region to update
|
||||
* @src_rowstride: row stride in bytes of the source buffer
|
||||
* @dst_x: upper left destination horizontal coordinate
|
||||
* @dst_y: upper left destination vertical coordinate
|
||||
*
|
||||
* Uploads new data into a pixel buffer. The source data pointed by @data can
|
||||
* have a different stride than @buffer in which case the function will do the
|
||||
* right thing for you. For performance reasons, it is recommended for the
|
||||
* source data to have the same stride than @buffer.
|
||||
*
|
||||
* Return value: %TRUE if the upload succeeded, %FALSE otherwise
|
||||
*
|
||||
* Since: 1.2
|
||||
* Stability: Unstable
|
||||
*/
|
||||
gboolean
|
||||
cogl_pixel_buffer_set_region (CoglHandle buffer,
|
||||
guint8 *data,
|
||||
unsigned int src_width,
|
||||
unsigned int src_height,
|
||||
unsigned int src_rowstride,
|
||||
unsigned int dst_x,
|
||||
unsigned int dst_y);
|
||||
#endif
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __COGL_PIXEL_BUFFER_H__ */
|
@ -36,7 +36,7 @@
|
||||
#include "cogl-bitmap.h"
|
||||
#include "cogl-bitmap-private.h"
|
||||
#include "cogl-buffer-private.h"
|
||||
#include "cogl-pixel-buffer-private.h"
|
||||
#include "cogl-pixel-array-private.h"
|
||||
#include "cogl-texture-private.h"
|
||||
#include "cogl-texture-driver.h"
|
||||
#include "cogl-texture-2d-sliced-private.h"
|
||||
@ -540,7 +540,7 @@ cogl_texture_new_from_buffer_EXP (CoglHandle buffer,
|
||||
{
|
||||
CoglHandle texture;
|
||||
CoglBuffer *cogl_buffer;
|
||||
CoglPixelBuffer *pixel_buffer;
|
||||
CoglPixelArray *pixel_array;
|
||||
|
||||
g_return_val_if_fail (cogl_is_buffer (buffer), COGL_INVALID_HANDLE);
|
||||
|
||||
@ -548,23 +548,23 @@ cogl_texture_new_from_buffer_EXP (CoglHandle buffer,
|
||||
return COGL_INVALID_HANDLE;
|
||||
|
||||
cogl_buffer = COGL_BUFFER (buffer);
|
||||
pixel_buffer = COGL_PIXEL_BUFFER (buffer);
|
||||
pixel_array = COGL_PIXEL_ARRAY (buffer);
|
||||
|
||||
/* Rowstride from CoglBuffer or even width * bpp if not given */
|
||||
if (rowstride == 0)
|
||||
rowstride = pixel_buffer->stride;
|
||||
rowstride = pixel_array->stride;
|
||||
if (rowstride == 0)
|
||||
rowstride = width * _cogl_get_format_bpp (format);
|
||||
|
||||
/* use the CoglBuffer height and width as last resort */
|
||||
if (width == 0)
|
||||
width = pixel_buffer->width;
|
||||
width = pixel_array->width;
|
||||
if (height == 0)
|
||||
height = pixel_buffer->height;
|
||||
height = pixel_array->height;
|
||||
if (width == 0 || height == 0)
|
||||
{
|
||||
/* no width or height specified, neither at creation time (because the
|
||||
* buffer was created by cogl_pixel_buffer_new()) nor when calling this
|
||||
* array was created by cogl_pixel_array_new()) nor when calling this
|
||||
* function */
|
||||
return COGL_INVALID_HANDLE;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@
|
||||
|
||||
#if defined (COGL_ENABLE_EXPERIMENTAL_API)
|
||||
#include <cogl/cogl-buffer.h>
|
||||
#include <cogl/cogl-pixel-buffer.h>
|
||||
#include <cogl/cogl-pixel-array.h>
|
||||
#include <cogl/cogl-vector.h>
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user