diff options
-rw-r--r-- | cogl/cogl-bitmap.c | 28 | ||||
-rw-r--r-- | cogl/cogl-buffer-private.h | 2 | ||||
-rw-r--r-- | cogl/cogl-buffer.c | 17 |
3 files changed, 19 insertions, 28 deletions
diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c index 43b2be56..355a2a25 100644 --- a/cogl/cogl-bitmap.c +++ b/cogl/cogl-bitmap.c @@ -437,23 +437,14 @@ _cogl_bitmap_bind (CoglBitmap *bitmap, bitmap->bound = TRUE; - /* If buffer is using a malloc fallback then we'll just use the - pointer directly */ - if (bitmap->buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT) - { - ptr = NULL; - - if (access == COGL_BUFFER_ACCESS_READ) - _cogl_buffer_bind (bitmap->buffer, - COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK); - else if (access == COGL_BUFFER_ACCESS_WRITE) - _cogl_buffer_bind (bitmap->buffer, - COGL_BUFFER_BIND_TARGET_PIXEL_PACK); - else - g_assert_not_reached (); - } + if (access == COGL_BUFFER_ACCESS_READ) + ptr = _cogl_buffer_bind (bitmap->buffer, + COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK); + else if (access == COGL_BUFFER_ACCESS_WRITE) + ptr = _cogl_buffer_bind (bitmap->buffer, + COGL_BUFFER_BIND_TARGET_PIXEL_PACK); else - ptr = bitmap->buffer->data; + g_assert_not_reached (); /* The data pointer actually stores the offset */ return GPOINTER_TO_INT (bitmap->data) + ptr; @@ -472,10 +463,7 @@ _cogl_bitmap_unbind (CoglBitmap *bitmap) /* If the bitmap wasn't created from a pixel array then the implementation of unbind is the same as unmap */ if (bitmap->buffer) - { - if (bitmap->buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT) - _cogl_buffer_unbind (bitmap->buffer); - } + _cogl_buffer_unbind (bitmap->buffer); else _cogl_bitmap_unmap (bitmap); } diff --git a/cogl/cogl-buffer-private.h b/cogl/cogl-buffer-private.h index cf913cf6..bed80504 100644 --- a/cogl/cogl-buffer-private.h +++ b/cogl/cogl-buffer-private.h @@ -120,7 +120,7 @@ _cogl_buffer_initialize (CoglBuffer *buffer, void _cogl_buffer_fini (CoglBuffer *buffer); -void +void * _cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target); diff --git a/cogl/cogl-buffer.c b/cogl/cogl-buffer.c index 5ed466a1..ebe8e610 100644 --- a/cogl/cogl-buffer.c +++ b/cogl/cogl-buffer.c @@ -351,28 +351,31 @@ _cogl_buffer_hints_to_gl_enum (CoglBufferUsageHint usage_hint, } #endif -void +void * _cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target) { - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + _COGL_GET_CONTEXT (ctx, NULL); - g_return_if_fail (buffer != NULL); + g_return_val_if_fail (buffer != NULL, NULL); /* Don't allow binding the buffer to multiple targets at the same time */ - g_return_if_fail (ctx->current_buffer[buffer->last_target] != buffer); + g_return_val_if_fail (ctx->current_buffer[buffer->last_target] != buffer, + NULL); /* Don't allow nesting binds to the same target */ - g_return_if_fail (ctx->current_buffer[target] == NULL); + g_return_val_if_fail (ctx->current_buffer[target] == NULL, NULL); buffer->last_target = target; + ctx->current_buffer[target] = buffer; if (buffer->flags & COGL_BUFFER_FLAG_BUFFER_OBJECT) { GLenum gl_target = convert_bind_target_to_gl_target (buffer->last_target); GE( glBindBuffer (gl_target, buffer->gl_handle) ); + return NULL; } - - ctx->current_buffer[target] = buffer; + else + return buffer->data; } void |