~noskcaj/ubuntu/trusty/cogl/1.16.2

« back to all changes in this revision

Viewing changes to cogl/cogl-driver.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha, Jeremy Bicha, Rico Tzschichholz
  • Date: 2013-02-26 16:43:25 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130226164325-t4z9rylpa20v0p6q
Tags: 1.13.4-0ubuntu1
[ Jeremy Bicha ]
* New upstream release
  - soname bump
* debian/control.in:
  - Bump minimum glib to 2.32
  - Drop obsolete breaks/replaces
  - Bump libclutter-1.0-dev breaks for soname transition
* debian/libcogl-dev.install:
  - Add some missing files

[ Rico Tzschichholz ]
* debian/control.in:
  - Build-depend on libxrandr-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#define __COGL_DRIVER_H
26
26
 
27
27
#include "cogl-context.h"
 
28
#include "cogl-offscreen.h"
 
29
#include "cogl-framebuffer-private.h"
 
30
#include "cogl-attribute-private.h"
28
31
 
29
32
typedef struct _CoglDriverVtable CoglDriverVtable;
30
33
 
31
34
struct _CoglDriverVtable
32
35
{
 
36
  /* TODO: factor this out since this is OpenGL specific and
 
37
   * so can be ignored by non-OpenGL drivers. */
33
38
  CoglBool
34
39
  (* pixel_format_from_gl_internal) (CoglContext *context,
35
40
                                     GLenum gl_int_format,
36
41
                                     CoglPixelFormat *out_format);
37
42
 
 
43
  /* TODO: factor this out since this is OpenGL specific and
 
44
   * so can be ignored by non-OpenGL drivers. */
38
45
  CoglPixelFormat
39
46
  (* pixel_format_to_gl) (CoglContext *context,
40
47
                          CoglPixelFormat format,
44
51
 
45
52
  CoglBool
46
53
  (* update_features) (CoglContext *context,
47
 
                       GError **error);
 
54
                       CoglError **error);
 
55
 
 
56
  CoglBool
 
57
  (* offscreen_allocate) (CoglOffscreen *offscreen,
 
58
                          CoglError **error);
 
59
 
 
60
  void
 
61
  (* offscreen_free) (CoglOffscreen *offscreen);
 
62
 
 
63
  void
 
64
  (* framebuffer_flush_state) (CoglFramebuffer *draw_buffer,
 
65
                               CoglFramebuffer *read_buffer,
 
66
                               CoglFramebufferState state);
 
67
 
 
68
  void
 
69
  (* framebuffer_clear) (CoglFramebuffer *framebuffer,
 
70
                         unsigned long buffers,
 
71
                         float red,
 
72
                         float green,
 
73
                         float blue,
 
74
                         float alpha);
 
75
 
 
76
  void
 
77
  (* framebuffer_query_bits) (CoglFramebuffer *framebuffer,
 
78
                              CoglFramebufferBits *bits);
 
79
 
 
80
  void
 
81
  (* framebuffer_finish) (CoglFramebuffer *framebuffer);
 
82
 
 
83
  void
 
84
  (* framebuffer_discard_buffers) (CoglFramebuffer *framebuffer,
 
85
                                   unsigned long buffers);
 
86
 
 
87
  void
 
88
  (* framebuffer_draw_attributes) (CoglFramebuffer *framebuffer,
 
89
                                   CoglPipeline *pipeline,
 
90
                                   CoglVerticesMode mode,
 
91
                                   int first_vertex,
 
92
                                   int n_vertices,
 
93
                                   CoglAttribute **attributes,
 
94
                                   int n_attributes,
 
95
                                   CoglDrawFlags flags);
 
96
 
 
97
  void
 
98
  (* framebuffer_draw_indexed_attributes) (CoglFramebuffer *framebuffer,
 
99
                                           CoglPipeline *pipeline,
 
100
                                           CoglVerticesMode mode,
 
101
                                           int first_vertex,
 
102
                                           int n_vertices,
 
103
                                           CoglIndices *indices,
 
104
                                           CoglAttribute **attributes,
 
105
                                           int n_attributes,
 
106
                                           CoglDrawFlags flags);
 
107
 
 
108
  CoglBool
 
109
  (* framebuffer_read_pixels_into_bitmap) (CoglFramebuffer *framebuffer,
 
110
                                           int x,
 
111
                                           int y,
 
112
                                           CoglReadPixelsFlags source,
 
113
                                           CoglBitmap *bitmap,
 
114
                                           CoglError **error);
 
115
 
 
116
  /* Destroys any driver specific resources associated with the given
 
117
   * 2D texture. */
 
118
  void
 
119
  (* texture_2d_free) (CoglTexture2D *tex_2d);
 
120
 
 
121
  /* Returns TRUE if the driver can support creating a 2D texture with
 
122
   * the given geometry and specified internal format.
 
123
   */
 
124
  CoglBool
 
125
  (* texture_2d_can_create) (CoglContext *ctx,
 
126
                             int width,
 
127
                             int height,
 
128
                             CoglPixelFormat internal_format);
 
129
 
 
130
  /* Initializes driver private state before allocating any specific
 
131
   * storage for a 2D texture, where base texture and texture 2D
 
132
   * members will already be initialized before passing control to
 
133
   * the driver.
 
134
   */
 
135
  void
 
136
  (* texture_2d_init) (CoglTexture2D *tex_2d);
 
137
 
 
138
  /* Allocates (uninitialized) storage for the given texture according
 
139
   * to the configured size and format of the texture */
 
140
  CoglBool
 
141
  (* texture_2d_allocate) (CoglTexture *tex,
 
142
                           CoglError **error);
 
143
 
 
144
  /* Instantiates a new CoglTexture2D object with storage initialized
 
145
   * with the contents of the given bitmap, using the specified
 
146
   * internal format.
 
147
   */
 
148
  CoglTexture2D *
 
149
  (* texture_2d_new_from_bitmap) (CoglBitmap *bmp,
 
150
                                  CoglPixelFormat internal_format,
 
151
                                  CoglError **error);
 
152
 
 
153
#if defined (COGL_HAS_EGL_SUPPORT) && defined (EGL_KHR_image_base)
 
154
  /* Instantiates a new CoglTexture2D object with storage initialized
 
155
   * with the contents of the given EGL image.
 
156
   *
 
157
   * This is optional for drivers to support
 
158
   */
 
159
  CoglTexture2D *
 
160
  (* egl_texture_2d_new_from_image) (CoglContext *ctx,
 
161
                                     int width,
 
162
                                     int height,
 
163
                                     CoglPixelFormat format,
 
164
                                     EGLImageKHR image,
 
165
                                     CoglError **error);
 
166
#endif
 
167
 
 
168
  /* Initialize the specified region of storage of the given texture
 
169
   * with the contents of the specified framebuffer region
 
170
   */
 
171
  void
 
172
  (* texture_2d_copy_from_framebuffer) (CoglTexture2D *tex_2d,
 
173
                                        int src_x,
 
174
                                        int src_y,
 
175
                                        int width,
 
176
                                        int height,
 
177
                                        CoglFramebuffer *src_fb,
 
178
                                        int dst_x,
 
179
                                        int dst_y,
 
180
                                        int level);
 
181
 
 
182
  /* If the given texture has a corresponding OpenGL texture handle
 
183
   * then return that.
 
184
   *
 
185
   * This is optional
 
186
   */
 
187
  unsigned int
 
188
  (* texture_2d_get_gl_handle) (CoglTexture2D *tex_2d);
 
189
 
 
190
  /* Update all mipmap levels > 0 */
 
191
  void
 
192
  (* texture_2d_generate_mipmap) (CoglTexture2D *tex_2d);
 
193
 
 
194
  /* Initialize the specified region of storage of the given texture
 
195
   * with the contents of the specified bitmap region
 
196
   *
 
197
   * Since this may need to create the underlying storage first
 
198
   * it may throw a NO_MEMORY error.
 
199
   */
 
200
  CoglBool
 
201
  (* texture_2d_copy_from_bitmap) (CoglTexture2D *tex_2d,
 
202
                                   int src_x,
 
203
                                   int src_y,
 
204
                                   int width,
 
205
                                   int height,
 
206
                                   CoglBitmap *bitmap,
 
207
                                   int dst_x,
 
208
                                   int dst_y,
 
209
                                   int level,
 
210
                                   CoglError **error);
 
211
 
 
212
  /* Reads back the full contents of the given texture and write it to
 
213
   * @data in the given @format and with the given @rowstride.
 
214
   *
 
215
   * This is optional
 
216
   */
 
217
  void
 
218
  (* texture_2d_get_data) (CoglTexture2D *tex_2d,
 
219
                           CoglPixelFormat format,
 
220
                           int rowstride,
 
221
                           uint8_t *data);
 
222
 
 
223
  /* Prepares for drawing by flushing the journal, framebuffer state,
 
224
   * pipeline state and attribute state.
 
225
   */
 
226
  void
 
227
  (* flush_attributes_state) (CoglFramebuffer *framebuffer,
 
228
                              CoglPipeline *pipeline,
 
229
                              CoglFlushLayerState *layer_state,
 
230
                              CoglDrawFlags flags,
 
231
                              CoglAttribute **attributes,
 
232
                              int n_attributes);
 
233
 
 
234
  /* Flushes the clip stack to the GPU using a combination of the
 
235
   * stencil buffer, scissor and clip plane state.
 
236
   */
 
237
  void
 
238
  (* clip_stack_flush) (CoglClipStack *stack, CoglFramebuffer *framebuffer);
 
239
 
 
240
  /* Enables the driver to create some meta data to represent a buffer
 
241
   * but with no corresponding storage allocated yet.
 
242
   */
 
243
  void
 
244
  (* buffer_create) (CoglBuffer *buffer);
 
245
 
 
246
  void
 
247
  (* buffer_destroy) (CoglBuffer *buffer);
 
248
 
 
249
  /* Maps a buffer into the CPU */
 
250
  void *
 
251
  (* buffer_map_range) (CoglBuffer *buffer,
 
252
                        size_t offset,
 
253
                        size_t size,
 
254
                        CoglBufferAccess access,
 
255
                        CoglBufferMapHint hints,
 
256
                        CoglError **error);
 
257
 
 
258
  /* Unmaps a buffer */
 
259
  void
 
260
  (* buffer_unmap) (CoglBuffer *buffer);
 
261
 
 
262
  /* Uploads data to the buffer without needing to map it necessarily
 
263
   */
 
264
  CoglBool
 
265
  (* buffer_set_data) (CoglBuffer *buffer,
 
266
                       unsigned int offset,
 
267
                       const void *data,
 
268
                       unsigned int size,
 
269
                       CoglError **error);
48
270
};
49
271
 
 
272
#define COGL_DRIVER_ERROR (_cogl_driver_error_quark ())
 
273
 
 
274
typedef enum { /*< prefix=COGL_DRIVER_ERROR >*/
 
275
  COGL_DRIVER_ERROR_UNKNOWN_VERSION,
 
276
  COGL_DRIVER_ERROR_INVALID_VERSION,
 
277
  COGL_DRIVER_ERROR_NO_SUITABLE_DRIVER_FOUND,
 
278
  COGL_DRIVER_ERROR_FAILED_TO_LOAD_LIBRARY
 
279
} CoglDriverError;
 
280
 
 
281
uint32_t
 
282
_cogl_driver_error_quark (void);
 
283
 
50
284
#endif /* __COGL_DRIVER_H */
51
285