cogl: Fallback to set_data when mapping a buffer to fill it
In the journal code and when generating the stroke path the vertices are generated on the fly and stored in a CoglBuffer using cogl_buffer_map. However cogl_buffer_map is allowed to fail but it wasn't checking for a NULL return value. In particular on GLES it will always fail because glMapBuffer is only provided by an extension. This adds a new pair of internal functions called _cogl_buffer_{un,}map_for_fill_or_fallback which wrap cogl_buffer_map. If the map fails then it will instead return a pointer into a GByteArray attached to the context. When the buffer is unmapped the array is copied into the buffer using cogl_buffer_set_data.
This commit is contained in:
@ -56,9 +56,10 @@ struct _CoglBufferVtable
|
||||
|
||||
typedef enum _CoglBufferFlags
|
||||
{
|
||||
COGL_BUFFER_FLAG_NONE = 0,
|
||||
COGL_BUFFER_FLAG_BUFFER_OBJECT = 1UL << 0, /* real openGL buffer object */
|
||||
COGL_BUFFER_FLAG_MAPPED = 1UL << 1
|
||||
COGL_BUFFER_FLAG_NONE = 0,
|
||||
COGL_BUFFER_FLAG_BUFFER_OBJECT = 1UL << 0, /* real openGL buffer object */
|
||||
COGL_BUFFER_FLAG_MAPPED = 1UL << 1,
|
||||
COGL_BUFFER_FLAG_MAPPED_FALLBACK = 1UL << 2
|
||||
} CoglBufferFlags;
|
||||
|
||||
typedef enum {
|
||||
@ -145,6 +146,18 @@ _cogl_buffer_immutable_ref (CoglBuffer *buffer);
|
||||
void
|
||||
_cogl_buffer_immutable_unref (CoglBuffer *buffer);
|
||||
|
||||
/* This is a wrapper around cogl_buffer_map for internal use when we
|
||||
want to map the buffer for write only to replace the entire
|
||||
contents. If the map fails then it will fallback to writing to a
|
||||
temporary buffer. When _cogl_buffer_unmap_for_fill_or_fallback is
|
||||
called the temporary buffer will be copied into the array. Note
|
||||
that these calls share a global array so they can not be nested. */
|
||||
void *
|
||||
_cogl_buffer_map_for_fill_or_fallback (CoglBuffer *buffer);
|
||||
|
||||
void
|
||||
_cogl_buffer_unmap_for_fill_or_fallback (CoglBuffer *buffer);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __COGL_BUFFER_PRIVATE_H__ */
|
||||
|
Reference in New Issue
Block a user