"Initial commit to Gerrit"
[profile/ivi/cogl.git] / cogl / cogl-pixel-buffer.h
1 /*
2  * Cogl
3  *
4  * An object oriented GL/GLES Abstraction/Utility Layer
5  *
6  * Copyright (C) 2008,2009,2010 Intel Corporation.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20  *
21  *
22  *
23  * Authors:
24  *   Damien Lespiau <damien.lespiau@intel.com>
25  *   Robert Bragg <robert@linux.intel.com>
26  */
27
28 #if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
29 #error "Only <cogl/cogl.h> can be included directly."
30 #endif
31
32 #ifndef __COGL_PIXEL_BUFFER_H__
33 #define __COGL_PIXEL_BUFFER_H__
34
35 #include <glib.h>
36 #include <cogl/cogl-types.h>
37 #include <cogl/cogl-context.h>
38
39 G_BEGIN_DECLS
40
41 /* All of the cogl-pixel-buffer API is currently experimental so we
42  * suffix the actual symbols with _EXP so if somone is monitoring for
43  * ABI changes it will hopefully be clearer to them what's going on if
44  * any of the symbols dissapear at a later date.
45  */
46
47 #define COGL_PIXEL_BUFFER(buffer) ((CoglPixelBuffer *)(buffer))
48
49 #define cogl_pixel_buffer_new cogl_pixel_buffer_new_EXP
50 #define cogl_pixel_buffer_new_with_size cogl_pixel_buffer_new_with_size_EXP
51 #define cogl_is_pixel_buffer cogl_is_pixel_buffer_EXP
52 #if 0
53 #define cogl_pixel_buffer_set_region cogl_pixel_buffer_set_region_EXP
54 #endif
55
56 typedef struct _CoglPixelBuffer CoglPixelBuffer;
57
58 /**
59  * cogl_pixel_buffer_new:
60  * @context: A #CoglContext
61  * @size: The number of bytes to allocate for the pixel data.
62  * @data: An optional pointer to vertex data to upload immediately
63  *
64  * Declares a new #CoglPixelBuffer of @size bytes to contain arrays of
65  * pixels. Once declared, data can be set using cogl_buffer_set_data()
66  * or by mapping it into the application's address space using
67  * cogl_buffer_map().
68  *
69  * If @data isn't %NULL then @size bytes will be read from @data and
70  * immediately copied into the new buffer.
71  *
72  * Since: 1.10
73  * Stability: unstable
74  */
75 CoglPixelBuffer *
76 cogl_pixel_buffer_new (CoglContext *context,
77                        gsize size,
78                        const void *data);
79
80 /**
81  * cogl_is_pixel_buffer:
82  * @object: a #CoglObject to test
83  *
84  * Checks whether @handle is a pixel array.
85  *
86  * Return value: %TRUE if the @handle is a pixel array, and %FALSE
87  *   otherwise
88  *
89  * Since: 1.2
90  * Stability: Unstable
91  */
92 gboolean
93 cogl_is_pixel_buffer (void *object);
94
95 #if 0
96 /*
97  * cogl_pixel_buffer_set_region:
98  * @array: the #CoglHandle of a pixel array
99  * @data: pixel data to upload to @array
100  * @src_width: width in pixels of the region to update
101  * @src_height: height in pixels of the region to update
102  * @src_rowstride: row stride in bytes of the source array
103  * @dst_x: upper left destination horizontal coordinate
104  * @dst_y: upper left destination vertical coordinate
105  *
106  * Uploads new data into a pixel array. The source data pointed by @data can
107  * have a different stride than @array in which case the function will do the
108  * right thing for you. For performance reasons, it is recommended for the
109  * source data to have the same stride than @array.
110  *
111  * Return value: %TRUE if the upload succeeded, %FALSE otherwise
112  *
113  * Since: 1.2
114  * Stability: Unstable
115  */
116 gboolean
117 cogl_pixel_buffer_set_region (CoglHandle    array,
118                               guint8       *data,
119                               unsigned int  src_width,
120                               unsigned int  src_height,
121                               unsigned int  src_rowstride,
122                               unsigned int  dst_x,
123                               unsigned int  dst_y);
124 #endif
125
126 G_END_DECLS
127
128 #endif /* __COGL_PIXEL_BUFFER_H__ */