Give buffer/bitmap bind functions gl infix

The buffer and bitmap _bind() functions are GL specific so to clarify
that, this patch adds a _gl infix to these functions, though it doesn't
yet move the implementations out into gl specific files.

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit 6371fbb9637d88ff187dfb6c4bcd18468ba44d19)
This commit is contained in:
Robert Bragg 2012-09-19 21:59:19 +01:00
parent 91a02e9107
commit bcf6a61d0b
9 changed files with 57 additions and 52 deletions

View File

@ -169,18 +169,21 @@ void
_cogl_bitmap_unmap (CoglBitmap *bitmap); _cogl_bitmap_unmap (CoglBitmap *bitmap);
/* These two are replacements for map and unmap that should used when /* These two are replacements for map and unmap that should used when
the pointer is going to be passed to GL for pixel packing or * the pointer is going to be passed to GL for pixel packing or
unpacking. The address might not be valid for reading if the bitmap * unpacking. The address might not be valid for reading if the bitmap
was created with new_from_buffer but it will however be good to * was created with new_from_buffer but it will however be good to
pass to glTexImage2D for example. The access should be READ for * pass to glTexImage2D for example. The access should be READ for
unpacking and WRITE for packing. It can not be both */ * unpacking and WRITE for packing. It can not be both
*
* TODO: split this bind/unbind functions out into a GL specific file
*/
uint8_t * uint8_t *
_cogl_bitmap_bind (CoglBitmap *bitmap, _cogl_bitmap_gl_bind (CoglBitmap *bitmap,
CoglBufferAccess access, CoglBufferAccess access,
CoglBufferMapHint hints); CoglBufferMapHint hints);
void void
_cogl_bitmap_unbind (CoglBitmap *bitmap); _cogl_bitmap_gl_unbind (CoglBitmap *bitmap);
CoglContext * CoglContext *
_cogl_bitmap_get_context (CoglBitmap *bitmap); _cogl_bitmap_get_context (CoglBitmap *bitmap);

View File

@ -411,7 +411,7 @@ _cogl_bitmap_unmap (CoglBitmap *bitmap)
} }
uint8_t * uint8_t *
_cogl_bitmap_bind (CoglBitmap *bitmap, _cogl_bitmap_gl_bind (CoglBitmap *bitmap,
CoglBufferAccess access, CoglBufferAccess access,
CoglBufferMapHint hints) CoglBufferMapHint hints)
{ {
@ -419,7 +419,7 @@ _cogl_bitmap_bind (CoglBitmap *bitmap,
/* Divert to another bitmap if this data is shared */ /* Divert to another bitmap if this data is shared */
if (bitmap->shared_bmp) if (bitmap->shared_bmp)
return _cogl_bitmap_bind (bitmap->shared_bmp, access, hints); return _cogl_bitmap_gl_bind (bitmap->shared_bmp, access, hints);
g_assert (!bitmap->bound); g_assert (!bitmap->bound);
@ -436,10 +436,10 @@ _cogl_bitmap_bind (CoglBitmap *bitmap,
bitmap->bound = TRUE; bitmap->bound = TRUE;
if (access == COGL_BUFFER_ACCESS_READ) if (access == COGL_BUFFER_ACCESS_READ)
ptr = _cogl_buffer_bind (bitmap->buffer, ptr = _cogl_buffer_gl_bind (bitmap->buffer,
COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK); COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK);
else if (access == COGL_BUFFER_ACCESS_WRITE) else if (access == COGL_BUFFER_ACCESS_WRITE)
ptr = _cogl_buffer_bind (bitmap->buffer, ptr = _cogl_buffer_gl_bind (bitmap->buffer,
COGL_BUFFER_BIND_TARGET_PIXEL_PACK); COGL_BUFFER_BIND_TARGET_PIXEL_PACK);
else else
g_assert_not_reached (); g_assert_not_reached ();
@ -449,12 +449,12 @@ _cogl_bitmap_bind (CoglBitmap *bitmap,
} }
void void
_cogl_bitmap_unbind (CoglBitmap *bitmap) _cogl_bitmap_gl_unbind (CoglBitmap *bitmap)
{ {
/* Divert to another bitmap if this data is shared */ /* Divert to another bitmap if this data is shared */
if (bitmap->shared_bmp) if (bitmap->shared_bmp)
{ {
_cogl_bitmap_unbind (bitmap->shared_bmp); _cogl_bitmap_gl_unbind (bitmap->shared_bmp);
return; return;
} }
@ -464,7 +464,7 @@ _cogl_bitmap_unbind (CoglBitmap *bitmap)
/* If the bitmap wasn't created from a pixel array then the /* If the bitmap wasn't created from a pixel array then the
implementation of unbind is the same as unmap */ implementation of unbind is the same as unmap */
if (bitmap->buffer) if (bitmap->buffer)
_cogl_buffer_unbind (bitmap->buffer); _cogl_buffer_gl_unbind (bitmap->buffer);
else else
_cogl_bitmap_unmap (bitmap); _cogl_bitmap_unmap (bitmap);
} }

View File

@ -123,12 +123,14 @@ _cogl_buffer_initialize (CoglBuffer *buffer,
void void
_cogl_buffer_fini (CoglBuffer *buffer); _cogl_buffer_fini (CoglBuffer *buffer);
/* TODO: split these GL specific bind and unbind functions out into
* some GL specific file. */
void * void *
_cogl_buffer_bind (CoglBuffer *buffer, _cogl_buffer_gl_bind (CoglBuffer *buffer,
CoglBufferBindTarget target); CoglBufferBindTarget target);
void void
_cogl_buffer_unbind (CoglBuffer *buffer); _cogl_buffer_gl_unbind (CoglBuffer *buffer);
CoglBufferUsageHint CoglBufferUsageHint
_cogl_buffer_get_usage_hint (CoglBuffer *buffer); _cogl_buffer_get_usage_hint (CoglBuffer *buffer);

View File

@ -367,7 +367,7 @@ _cogl_buffer_access_to_gl_enum (CoglBufferAccess access)
} }
void * void *
_cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target) _cogl_buffer_gl_bind (CoglBuffer *buffer, CoglBufferBindTarget target)
{ {
void *ret; void *ret;
@ -384,7 +384,7 @@ _cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target)
} }
void void
_cogl_buffer_unbind (CoglBuffer *buffer) _cogl_buffer_gl_unbind (CoglBuffer *buffer)
{ {
CoglContext *ctx = buffer->context; CoglContext *ctx = buffer->context;

View File

@ -1591,7 +1591,7 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
width, width,
bpp); bpp);
tmp_data = _cogl_bitmap_bind (tmp_bmp, tmp_data = _cogl_bitmap_gl_bind (tmp_bmp,
COGL_BUFFER_ACCESS_WRITE, COGL_BUFFER_ACCESS_WRITE,
COGL_BUFFER_MAP_HINT_DISCARD); COGL_BUFFER_MAP_HINT_DISCARD);
@ -1599,7 +1599,7 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
gl_format, gl_type, gl_format, gl_type,
tmp_data) ); tmp_data) );
_cogl_bitmap_unbind (tmp_bmp); _cogl_bitmap_gl_unbind (tmp_bmp);
succeeded = _cogl_bitmap_convert_into_bitmap (tmp_bmp, bitmap); succeeded = _cogl_bitmap_convert_into_bitmap (tmp_bmp, bitmap);
@ -1642,7 +1642,7 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
width, width,
bpp); bpp);
pixels = _cogl_bitmap_bind (shared_bmp, pixels = _cogl_bitmap_gl_bind (shared_bmp,
COGL_BUFFER_ACCESS_WRITE, COGL_BUFFER_ACCESS_WRITE,
0 /* hints */); 0 /* hints */);
@ -1651,7 +1651,7 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
gl_format, gl_type, gl_format, gl_type,
pixels) ); pixels) );
_cogl_bitmap_unbind (shared_bmp); _cogl_bitmap_gl_unbind (shared_bmp);
/* Convert to the premult format specified by the caller /* Convert to the premult format specified by the caller
in-place. This will do nothing if the premult status is already in-place. This will do nothing if the premult status is already

View File

@ -312,7 +312,7 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer,
attribute_buffer = cogl_attribute_get_buffer (attribute); attribute_buffer = cogl_attribute_get_buffer (attribute);
buffer = COGL_BUFFER (attribute_buffer); buffer = COGL_BUFFER (attribute_buffer);
base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER); base = _cogl_buffer_gl_bind (buffer, COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER);
switch (attribute->name_state->name_id) switch (attribute->name_state->name_id)
{ {
@ -388,7 +388,7 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer,
g_warning ("Unrecognised attribute type 0x%08x", attribute->type); g_warning ("Unrecognised attribute type 0x%08x", attribute->type);
} }
_cogl_buffer_unbind (buffer); _cogl_buffer_gl_unbind (buffer);
} }
apply_attribute_enable_updates (ctx, pipeline); apply_attribute_enable_updates (ctx, pipeline);

View File

@ -1066,7 +1066,7 @@ _cogl_framebuffer_gl_draw_indexed_attributes (CoglFramebuffer *framebuffer,
attributes, n_attributes); attributes, n_attributes);
buffer = COGL_BUFFER (cogl_indices_get_buffer (indices)); buffer = COGL_BUFFER (cogl_indices_get_buffer (indices));
base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_INDEX_BUFFER); base = _cogl_buffer_gl_bind (buffer, COGL_BUFFER_BIND_TARGET_INDEX_BUFFER);
buffer_offset = cogl_indices_get_offset (indices); buffer_offset = cogl_indices_get_offset (indices);
index_size = sizeof_index_type (cogl_indices_get_type (indices)); index_size = sizeof_index_type (cogl_indices_get_type (indices));
@ -1089,5 +1089,5 @@ _cogl_framebuffer_gl_draw_indexed_attributes (CoglFramebuffer *framebuffer,
indices_gl_type, indices_gl_type,
base + buffer_offset + index_size * first_vertex)); base + buffer_offset + index_size * first_vertex));
_cogl_buffer_unbind (buffer); _cogl_buffer_gl_unbind (buffer);
} }

View File

@ -169,7 +169,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp); CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp);
int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format); int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format);
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0); data = _cogl_bitmap_gl_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
/* Setup gl alignment to match rowstride and top-left corner */ /* Setup gl alignment to match rowstride and top-left corner */
prep_gl_for_pixels_upload_full (ctx, prep_gl_for_pixels_upload_full (ctx,
@ -188,7 +188,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
source_gl_type, source_gl_type,
data) ); data) );
_cogl_bitmap_unbind (source_bmp); _cogl_bitmap_gl_unbind (source_bmp);
} }
static void static void
@ -205,7 +205,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp); CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp);
int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format); int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format);
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0); data = _cogl_bitmap_gl_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
/* Setup gl alignment to match rowstride and top-left corner */ /* Setup gl alignment to match rowstride and top-left corner */
prep_gl_for_pixels_upload_full (ctx, prep_gl_for_pixels_upload_full (ctx,
@ -223,7 +223,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
source_gl_type, source_gl_type,
data) ); data) );
_cogl_bitmap_unbind (source_bmp); _cogl_bitmap_gl_unbind (source_bmp);
} }
static void static void
@ -242,7 +242,7 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp); CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp);
int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format); int bpp = _cogl_pixel_format_get_bytes_per_pixel (source_format);
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0); data = _cogl_bitmap_gl_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
/* Setup gl alignment to match rowstride and top-left corner */ /* Setup gl alignment to match rowstride and top-left corner */
prep_gl_for_pixels_upload_full (ctx, prep_gl_for_pixels_upload_full (ctx,
@ -264,7 +264,7 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
source_gl_type, source_gl_type,
data) ); data) );
_cogl_bitmap_unbind (source_bmp); _cogl_bitmap_gl_unbind (source_bmp);
} }
static CoglBool static CoglBool

View File

@ -217,7 +217,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
/* Setup gl alignment to match rowstride and top-left corner */ /* Setup gl alignment to match rowstride and top-left corner */
prep_gl_for_pixels_upload_full (ctx, rowstride, src_x, src_y, bpp); prep_gl_for_pixels_upload_full (ctx, rowstride, src_x, src_y, bpp);
data = _cogl_bitmap_bind (slice_bmp, COGL_BUFFER_ACCESS_READ, 0); data = _cogl_bitmap_gl_bind (slice_bmp, COGL_BUFFER_ACCESS_READ, 0);
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign); _cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
@ -228,7 +228,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
source_gl_type, source_gl_type,
data) ); data) );
_cogl_bitmap_unbind (slice_bmp); _cogl_bitmap_gl_unbind (slice_bmp);
cogl_object_unref (slice_bmp); cogl_object_unref (slice_bmp);
} }
@ -259,7 +259,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign); _cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
data = _cogl_bitmap_bind (bmp, COGL_BUFFER_ACCESS_READ, 0); data = _cogl_bitmap_gl_bind (bmp, COGL_BUFFER_ACCESS_READ, 0);
GE( ctx, glTexImage2D (gl_target, 0, GE( ctx, glTexImage2D (gl_target, 0,
internal_gl_format, internal_gl_format,
@ -269,7 +269,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
source_gl_type, source_gl_type,
data) ); data) );
_cogl_bitmap_unbind (bmp); _cogl_bitmap_gl_unbind (bmp);
cogl_object_unref (bmp); cogl_object_unref (bmp);
} }
@ -336,7 +336,7 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
bmp_width, bmp_width,
height); height);
data = _cogl_bitmap_bind (bmp, data = _cogl_bitmap_gl_bind (bmp,
COGL_BUFFER_ACCESS_READ, 0); COGL_BUFFER_ACCESS_READ, 0);
GE( ctx, glTexSubImage3D (gl_target, GE( ctx, glTexSubImage3D (gl_target,
@ -351,14 +351,14 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
source_gl_type, source_gl_type,
data) ); data) );
_cogl_bitmap_unbind (bmp); _cogl_bitmap_gl_unbind (bmp);
} }
cogl_object_unref (bmp); cogl_object_unref (bmp);
} }
else else
{ {
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0); data = _cogl_bitmap_gl_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
_cogl_texture_driver_prep_gl_for_pixels_upload (ctx, rowstride, bpp); _cogl_texture_driver_prep_gl_for_pixels_upload (ctx, rowstride, bpp);
@ -373,7 +373,7 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
source_gl_type, source_gl_type,
data) ); data) );
_cogl_bitmap_unbind (source_bmp); _cogl_bitmap_gl_unbind (source_bmp);
} }
} }