mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
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:
parent
91a02e9107
commit
bcf6a61d0b
@ -169,18 +169,21 @@ void
|
||||
_cogl_bitmap_unmap (CoglBitmap *bitmap);
|
||||
|
||||
/* 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
|
||||
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
|
||||
pass to glTexImage2D for example. The access should be READ for
|
||||
unpacking and WRITE for packing. It can not be both */
|
||||
* 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
|
||||
* was created with new_from_buffer but it will however be good to
|
||||
* pass to glTexImage2D for example. The access should be READ for
|
||||
* unpacking and WRITE for packing. It can not be both
|
||||
*
|
||||
* TODO: split this bind/unbind functions out into a GL specific file
|
||||
*/
|
||||
uint8_t *
|
||||
_cogl_bitmap_bind (CoglBitmap *bitmap,
|
||||
CoglBufferAccess access,
|
||||
CoglBufferMapHint hints);
|
||||
_cogl_bitmap_gl_bind (CoglBitmap *bitmap,
|
||||
CoglBufferAccess access,
|
||||
CoglBufferMapHint hints);
|
||||
|
||||
void
|
||||
_cogl_bitmap_unbind (CoglBitmap *bitmap);
|
||||
_cogl_bitmap_gl_unbind (CoglBitmap *bitmap);
|
||||
|
||||
CoglContext *
|
||||
_cogl_bitmap_get_context (CoglBitmap *bitmap);
|
||||
|
@ -411,15 +411,15 @@ _cogl_bitmap_unmap (CoglBitmap *bitmap)
|
||||
}
|
||||
|
||||
uint8_t *
|
||||
_cogl_bitmap_bind (CoglBitmap *bitmap,
|
||||
CoglBufferAccess access,
|
||||
CoglBufferMapHint hints)
|
||||
_cogl_bitmap_gl_bind (CoglBitmap *bitmap,
|
||||
CoglBufferAccess access,
|
||||
CoglBufferMapHint hints)
|
||||
{
|
||||
uint8_t *ptr;
|
||||
|
||||
/* Divert to another bitmap if this data is shared */
|
||||
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);
|
||||
|
||||
@ -436,11 +436,11 @@ _cogl_bitmap_bind (CoglBitmap *bitmap,
|
||||
bitmap->bound = TRUE;
|
||||
|
||||
if (access == COGL_BUFFER_ACCESS_READ)
|
||||
ptr = _cogl_buffer_bind (bitmap->buffer,
|
||||
COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK);
|
||||
ptr = _cogl_buffer_gl_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);
|
||||
ptr = _cogl_buffer_gl_bind (bitmap->buffer,
|
||||
COGL_BUFFER_BIND_TARGET_PIXEL_PACK);
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
|
||||
@ -449,12 +449,12 @@ _cogl_bitmap_bind (CoglBitmap *bitmap,
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_bitmap_unbind (CoglBitmap *bitmap)
|
||||
_cogl_bitmap_gl_unbind (CoglBitmap *bitmap)
|
||||
{
|
||||
/* Divert to another bitmap if this data is shared */
|
||||
if (bitmap->shared_bmp)
|
||||
{
|
||||
_cogl_bitmap_unbind (bitmap->shared_bmp);
|
||||
_cogl_bitmap_gl_unbind (bitmap->shared_bmp);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -464,7 +464,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)
|
||||
_cogl_buffer_unbind (bitmap->buffer);
|
||||
_cogl_buffer_gl_unbind (bitmap->buffer);
|
||||
else
|
||||
_cogl_bitmap_unmap (bitmap);
|
||||
}
|
||||
|
@ -123,12 +123,14 @@ _cogl_buffer_initialize (CoglBuffer *buffer,
|
||||
void
|
||||
_cogl_buffer_fini (CoglBuffer *buffer);
|
||||
|
||||
/* TODO: split these GL specific bind and unbind functions out into
|
||||
* some GL specific file. */
|
||||
void *
|
||||
_cogl_buffer_bind (CoglBuffer *buffer,
|
||||
CoglBufferBindTarget target);
|
||||
_cogl_buffer_gl_bind (CoglBuffer *buffer,
|
||||
CoglBufferBindTarget target);
|
||||
|
||||
void
|
||||
_cogl_buffer_unbind (CoglBuffer *buffer);
|
||||
_cogl_buffer_gl_unbind (CoglBuffer *buffer);
|
||||
|
||||
CoglBufferUsageHint
|
||||
_cogl_buffer_get_usage_hint (CoglBuffer *buffer);
|
||||
|
@ -367,7 +367,7 @@ _cogl_buffer_access_to_gl_enum (CoglBufferAccess access)
|
||||
}
|
||||
|
||||
void *
|
||||
_cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target)
|
||||
_cogl_buffer_gl_bind (CoglBuffer *buffer, CoglBufferBindTarget target)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
@ -384,7 +384,7 @@ _cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target)
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_buffer_unbind (CoglBuffer *buffer)
|
||||
_cogl_buffer_gl_unbind (CoglBuffer *buffer)
|
||||
{
|
||||
CoglContext *ctx = buffer->context;
|
||||
|
||||
|
@ -1591,15 +1591,15 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
|
||||
width,
|
||||
bpp);
|
||||
|
||||
tmp_data = _cogl_bitmap_bind (tmp_bmp,
|
||||
COGL_BUFFER_ACCESS_WRITE,
|
||||
COGL_BUFFER_MAP_HINT_DISCARD);
|
||||
tmp_data = _cogl_bitmap_gl_bind (tmp_bmp,
|
||||
COGL_BUFFER_ACCESS_WRITE,
|
||||
COGL_BUFFER_MAP_HINT_DISCARD);
|
||||
|
||||
GE( ctx, glReadPixels (x, y, width, height,
|
||||
gl_format, gl_type,
|
||||
tmp_data) );
|
||||
|
||||
_cogl_bitmap_unbind (tmp_bmp);
|
||||
_cogl_bitmap_gl_unbind (tmp_bmp);
|
||||
|
||||
succeeded = _cogl_bitmap_convert_into_bitmap (tmp_bmp, bitmap);
|
||||
|
||||
@ -1642,16 +1642,16 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
|
||||
width,
|
||||
bpp);
|
||||
|
||||
pixels = _cogl_bitmap_bind (shared_bmp,
|
||||
COGL_BUFFER_ACCESS_WRITE,
|
||||
0 /* hints */);
|
||||
pixels = _cogl_bitmap_gl_bind (shared_bmp,
|
||||
COGL_BUFFER_ACCESS_WRITE,
|
||||
0 /* hints */);
|
||||
|
||||
GE( ctx, glReadPixels (x, y,
|
||||
width, height,
|
||||
gl_format, gl_type,
|
||||
pixels) );
|
||||
|
||||
_cogl_bitmap_unbind (shared_bmp);
|
||||
_cogl_bitmap_gl_unbind (shared_bmp);
|
||||
|
||||
/* Convert to the premult format specified by the caller
|
||||
in-place. This will do nothing if the premult status is already
|
||||
|
@ -312,7 +312,7 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer,
|
||||
|
||||
attribute_buffer = cogl_attribute_get_buffer (attribute);
|
||||
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)
|
||||
{
|
||||
@ -388,7 +388,7 @@ _cogl_gl_flush_attributes_state (CoglFramebuffer *framebuffer,
|
||||
g_warning ("Unrecognised attribute type 0x%08x", attribute->type);
|
||||
}
|
||||
|
||||
_cogl_buffer_unbind (buffer);
|
||||
_cogl_buffer_gl_unbind (buffer);
|
||||
}
|
||||
|
||||
apply_attribute_enable_updates (ctx, pipeline);
|
||||
|
@ -1066,7 +1066,7 @@ _cogl_framebuffer_gl_draw_indexed_attributes (CoglFramebuffer *framebuffer,
|
||||
attributes, n_attributes);
|
||||
|
||||
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);
|
||||
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,
|
||||
base + buffer_offset + index_size * first_vertex));
|
||||
|
||||
_cogl_buffer_unbind (buffer);
|
||||
_cogl_buffer_gl_unbind (buffer);
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
|
||||
CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp);
|
||||
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 */
|
||||
prep_gl_for_pixels_upload_full (ctx,
|
||||
@ -188,7 +188,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
|
||||
source_gl_type,
|
||||
data) );
|
||||
|
||||
_cogl_bitmap_unbind (source_bmp);
|
||||
_cogl_bitmap_gl_unbind (source_bmp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -205,7 +205,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
|
||||
CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp);
|
||||
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 */
|
||||
prep_gl_for_pixels_upload_full (ctx,
|
||||
@ -223,7 +223,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
|
||||
source_gl_type,
|
||||
data) );
|
||||
|
||||
_cogl_bitmap_unbind (source_bmp);
|
||||
_cogl_bitmap_gl_unbind (source_bmp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -242,7 +242,7 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
|
||||
CoglPixelFormat source_format = cogl_bitmap_get_format (source_bmp);
|
||||
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 */
|
||||
prep_gl_for_pixels_upload_full (ctx,
|
||||
@ -264,7 +264,7 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
|
||||
source_gl_type,
|
||||
data) );
|
||||
|
||||
_cogl_bitmap_unbind (source_bmp);
|
||||
_cogl_bitmap_gl_unbind (source_bmp);
|
||||
}
|
||||
|
||||
static CoglBool
|
||||
|
@ -217,7 +217,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
|
||||
/* Setup gl alignment to match rowstride and top-left corner */
|
||||
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);
|
||||
|
||||
@ -228,7 +228,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
|
||||
source_gl_type,
|
||||
data) );
|
||||
|
||||
_cogl_bitmap_unbind (slice_bmp);
|
||||
_cogl_bitmap_gl_unbind (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);
|
||||
|
||||
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,
|
||||
internal_gl_format,
|
||||
@ -269,7 +269,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
|
||||
source_gl_type,
|
||||
data) );
|
||||
|
||||
_cogl_bitmap_unbind (bmp);
|
||||
_cogl_bitmap_gl_unbind (bmp);
|
||||
|
||||
cogl_object_unref (bmp);
|
||||
}
|
||||
@ -336,8 +336,8 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
|
||||
bmp_width,
|
||||
height);
|
||||
|
||||
data = _cogl_bitmap_bind (bmp,
|
||||
COGL_BUFFER_ACCESS_READ, 0);
|
||||
data = _cogl_bitmap_gl_bind (bmp,
|
||||
COGL_BUFFER_ACCESS_READ, 0);
|
||||
|
||||
GE( ctx, glTexSubImage3D (gl_target,
|
||||
0, /* level */
|
||||
@ -351,14 +351,14 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
|
||||
source_gl_type,
|
||||
data) );
|
||||
|
||||
_cogl_bitmap_unbind (bmp);
|
||||
_cogl_bitmap_gl_unbind (bmp);
|
||||
}
|
||||
|
||||
cogl_object_unref (bmp);
|
||||
}
|
||||
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);
|
||||
|
||||
@ -373,7 +373,7 @@ _cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
|
||||
source_gl_type,
|
||||
data) );
|
||||
|
||||
_cogl_bitmap_unbind (source_bmp);
|
||||
_cogl_bitmap_gl_unbind (source_bmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user