Add a context parameter to all of the texture driver virtuals
All of the texture driver virtual functions now take an explicit CoglContext parameter as a step towards removing the global context.
This commit is contained in:
parent
60812e6a0e
commit
d6ca75fbec
@ -196,7 +196,8 @@ _cogl_atlas_get_initial_size (CoglPixelFormat format,
|
|||||||
/* Some platforms might not support this large size so we'll
|
/* Some platforms might not support this large size so we'll
|
||||||
decrease the size until it can */
|
decrease the size until it can */
|
||||||
while (size > 1 &&
|
while (size > 1 &&
|
||||||
!ctx->texture_driver->size_supported (GL_TEXTURE_2D,
|
!ctx->texture_driver->size_supported (ctx,
|
||||||
|
GL_TEXTURE_2D,
|
||||||
gl_intformat,
|
gl_intformat,
|
||||||
gl_type,
|
gl_type,
|
||||||
size, size))
|
size, size))
|
||||||
@ -226,7 +227,8 @@ _cogl_atlas_create_map (CoglPixelFormat format,
|
|||||||
|
|
||||||
/* Keep trying increasingly larger atlases until we can fit all of
|
/* Keep trying increasingly larger atlases until we can fit all of
|
||||||
the textures */
|
the textures */
|
||||||
while (ctx->texture_driver->size_supported (GL_TEXTURE_2D,
|
while (ctx->texture_driver->size_supported (ctx,
|
||||||
|
GL_TEXTURE_2D,
|
||||||
gl_intformat,
|
gl_intformat,
|
||||||
gl_type,
|
gl_type,
|
||||||
map_width, map_height))
|
map_width, map_height))
|
||||||
|
@ -2062,7 +2062,7 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
|
|||||||
bpp = _cogl_pixel_format_get_bytes_per_pixel (read_format);
|
bpp = _cogl_pixel_format_get_bytes_per_pixel (read_format);
|
||||||
rowstride = cogl_bitmap_get_rowstride (tmp_bmp);
|
rowstride = cogl_bitmap_get_rowstride (tmp_bmp);
|
||||||
|
|
||||||
ctx->texture_driver->prep_gl_for_pixels_download (rowstride, bpp);
|
ctx->texture_driver->prep_gl_for_pixels_download (ctx, rowstride, bpp);
|
||||||
|
|
||||||
tmp_data = _cogl_bitmap_bind (tmp_bmp,
|
tmp_data = _cogl_bitmap_bind (tmp_bmp,
|
||||||
COGL_BUFFER_ACCESS_WRITE,
|
COGL_BUFFER_ACCESS_WRITE,
|
||||||
@ -2110,7 +2110,7 @@ cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
|
|||||||
|
|
||||||
bpp = _cogl_pixel_format_get_bytes_per_pixel (bmp_format);
|
bpp = _cogl_pixel_format_get_bytes_per_pixel (bmp_format);
|
||||||
|
|
||||||
ctx->texture_driver->prep_gl_for_pixels_download (rowstride, bpp);
|
ctx->texture_driver->prep_gl_for_pixels_download (ctx, rowstride, bpp);
|
||||||
|
|
||||||
pixels = _cogl_bitmap_bind (shared_bmp,
|
pixels = _cogl_bitmap_bind (shared_bmp,
|
||||||
COGL_BUFFER_ACCESS_WRITE,
|
COGL_BUFFER_ACCESS_WRITE,
|
||||||
|
@ -651,7 +651,8 @@ _cogl_texture_2d_sliced_slices_create (CoglContext *ctx,
|
|||||||
CoglSpan span;
|
CoglSpan span;
|
||||||
|
|
||||||
/* Check if size supported else bail out */
|
/* Check if size supported else bail out */
|
||||||
if (!ctx->texture_driver->size_supported (GL_TEXTURE_2D,
|
if (!ctx->texture_driver->size_supported (ctx,
|
||||||
|
GL_TEXTURE_2D,
|
||||||
gl_intformat,
|
gl_intformat,
|
||||||
gl_type,
|
gl_type,
|
||||||
max_width,
|
max_width,
|
||||||
@ -685,7 +686,8 @@ _cogl_texture_2d_sliced_slices_create (CoglContext *ctx,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Decrease the size of largest slice until supported by GL */
|
/* Decrease the size of largest slice until supported by GL */
|
||||||
while (!ctx->texture_driver->size_supported (GL_TEXTURE_2D,
|
while (!ctx->texture_driver->size_supported (ctx,
|
||||||
|
GL_TEXTURE_2D,
|
||||||
gl_intformat,
|
gl_intformat,
|
||||||
gl_type,
|
gl_type,
|
||||||
max_width,
|
max_width,
|
||||||
|
@ -127,7 +127,8 @@ _cogl_texture_2d_can_create (unsigned int width,
|
|||||||
&gl_type);
|
&gl_type);
|
||||||
|
|
||||||
/* Check that the driver can create a texture with that size */
|
/* Check that the driver can create a texture with that size */
|
||||||
if (!ctx->texture_driver->size_supported (GL_TEXTURE_2D,
|
if (!ctx->texture_driver->size_supported (ctx,
|
||||||
|
GL_TEXTURE_2D,
|
||||||
gl_intformat,
|
gl_intformat,
|
||||||
gl_type,
|
gl_type,
|
||||||
width,
|
width,
|
||||||
@ -202,7 +203,7 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
|
|||||||
tex_2d = _cogl_texture_2d_create_base (width, height, COGL_TEXTURE_NONE,
|
tex_2d = _cogl_texture_2d_create_base (width, height, COGL_TEXTURE_NONE,
|
||||||
internal_format);
|
internal_format);
|
||||||
|
|
||||||
ctx->texture_driver->gen (GL_TEXTURE_2D, 1, &tex_2d->gl_texture);
|
ctx->texture_driver->gen (ctx, GL_TEXTURE_2D, 1, &tex_2d->gl_texture);
|
||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
|
||||||
tex_2d->gl_texture,
|
tex_2d->gl_texture,
|
||||||
tex_2d->is_foreign);
|
tex_2d->is_foreign);
|
||||||
@ -278,8 +279,9 @@ _cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
|
|||||||
_cogl_bitmap_unmap (dst_bmp);
|
_cogl_bitmap_unmap (dst_bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->texture_driver->gen (GL_TEXTURE_2D, 1, &tex_2d->gl_texture);
|
ctx->texture_driver->gen (ctx, GL_TEXTURE_2D, 1, &tex_2d->gl_texture);
|
||||||
ctx->texture_driver->upload_to_gl (GL_TEXTURE_2D,
|
ctx->texture_driver->upload_to_gl (ctx,
|
||||||
|
GL_TEXTURE_2D,
|
||||||
tex_2d->gl_texture,
|
tex_2d->gl_texture,
|
||||||
FALSE,
|
FALSE,
|
||||||
dst_bmp,
|
dst_bmp,
|
||||||
@ -347,7 +349,7 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx,
|
|||||||
GLenum gl_int_format = 0;
|
GLenum gl_int_format = 0;
|
||||||
CoglTexture2D *tex_2d;
|
CoglTexture2D *tex_2d;
|
||||||
|
|
||||||
if (!ctx->texture_driver->allows_foreign_gl_target (GL_TEXTURE_2D))
|
if (!ctx->texture_driver->allows_foreign_gl_target (ctx, GL_TEXTURE_2D))
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
|
|
||||||
/* Make sure it is a valid GL texture object */
|
/* Make sure it is a valid GL texture object */
|
||||||
@ -474,7 +476,7 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
|
|||||||
tex_2d = _cogl_texture_2d_create_base (width, height, COGL_TEXTURE_NONE,
|
tex_2d = _cogl_texture_2d_create_base (width, height, COGL_TEXTURE_NONE,
|
||||||
format);
|
format);
|
||||||
|
|
||||||
ctx->texture_driver->gen (GL_TEXTURE_2D, 1, &tex_2d->gl_texture);
|
ctx->texture_driver->gen (ctx, GL_TEXTURE_2D, 1, &tex_2d->gl_texture);
|
||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
|
||||||
tex_2d->gl_texture,
|
tex_2d->gl_texture,
|
||||||
FALSE);
|
FALSE);
|
||||||
@ -716,7 +718,7 @@ _cogl_texture_2d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
|
|||||||
available we'll fallback to temporarily enabling
|
available we'll fallback to temporarily enabling
|
||||||
GL_GENERATE_MIPMAP and reuploading the first pixel */
|
GL_GENERATE_MIPMAP and reuploading the first pixel */
|
||||||
if (cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
|
if (cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
|
||||||
ctx->texture_driver->gl_generate_mipmaps (GL_TEXTURE_2D);
|
ctx->texture_driver->gl_generate_mipmaps (ctx, GL_TEXTURE_2D);
|
||||||
#if defined(HAVE_COGL_GLES) || defined(HAVE_COGL_GL)
|
#if defined(HAVE_COGL_GLES) || defined(HAVE_COGL_GL)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -784,7 +786,8 @@ _cogl_texture_2d_set_region (CoglTexture *tex,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send data to GL */
|
/* Send data to GL */
|
||||||
ctx->texture_driver->upload_subregion_to_gl (GL_TEXTURE_2D,
|
ctx->texture_driver->upload_subregion_to_gl (ctx,
|
||||||
|
GL_TEXTURE_2D,
|
||||||
tex_2d->gl_texture,
|
tex_2d->gl_texture,
|
||||||
FALSE,
|
FALSE,
|
||||||
src_x, src_y,
|
src_x, src_y,
|
||||||
@ -822,12 +825,13 @@ _cogl_texture_2d_get_data (CoglTexture *tex,
|
|||||||
&gl_format,
|
&gl_format,
|
||||||
&gl_type);
|
&gl_type);
|
||||||
|
|
||||||
ctx->texture_driver->prep_gl_for_pixels_download (rowstride, bpp);
|
ctx->texture_driver->prep_gl_for_pixels_download (ctx, rowstride, bpp);
|
||||||
|
|
||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
|
||||||
tex_2d->gl_texture,
|
tex_2d->gl_texture,
|
||||||
tex_2d->is_foreign);
|
tex_2d->is_foreign);
|
||||||
return ctx->texture_driver->gl_get_tex_image (GL_TEXTURE_2D,
|
return ctx->texture_driver->gl_get_tex_image (ctx,
|
||||||
|
GL_TEXTURE_2D,
|
||||||
gl_format,
|
gl_format,
|
||||||
gl_type,
|
gl_type,
|
||||||
data);
|
data);
|
||||||
|
@ -174,7 +174,8 @@ _cogl_texture_3d_can_create (CoglContext *ctx,
|
|||||||
&gl_type);
|
&gl_type);
|
||||||
|
|
||||||
/* Check that the driver can create a texture with that size */
|
/* Check that the driver can create a texture with that size */
|
||||||
if (!ctx->texture_driver->size_supported_3d (GL_TEXTURE_3D,
|
if (!ctx->texture_driver->size_supported_3d (ctx,
|
||||||
|
GL_TEXTURE_3D,
|
||||||
gl_intformat,
|
gl_intformat,
|
||||||
gl_type,
|
gl_type,
|
||||||
width,
|
width,
|
||||||
@ -224,7 +225,7 @@ cogl_texture_3d_new_with_size (CoglContext *ctx,
|
|||||||
width, height, depth,
|
width, height, depth,
|
||||||
internal_format);
|
internal_format);
|
||||||
|
|
||||||
ctx->texture_driver->gen (GL_TEXTURE_3D, 1, &tex_3d->gl_texture);
|
ctx->texture_driver->gen (ctx, GL_TEXTURE_3D, 1, &tex_3d->gl_texture);
|
||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_3D,
|
||||||
tex_3d->gl_texture,
|
tex_3d->gl_texture,
|
||||||
FALSE);
|
FALSE);
|
||||||
@ -296,9 +297,10 @@ _cogl_texture_3d_new_from_bitmap (CoglContext *ctx,
|
|||||||
_cogl_bitmap_unmap (dst_bmp);
|
_cogl_bitmap_unmap (dst_bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->texture_driver->gen (GL_TEXTURE_3D, 1, &tex_3d->gl_texture);
|
ctx->texture_driver->gen (ctx, GL_TEXTURE_3D, 1, &tex_3d->gl_texture);
|
||||||
|
|
||||||
ctx->texture_driver->upload_to_gl_3d (GL_TEXTURE_3D,
|
ctx->texture_driver->upload_to_gl_3d (ctx,
|
||||||
|
GL_TEXTURE_3D,
|
||||||
tex_3d->gl_texture,
|
tex_3d->gl_texture,
|
||||||
FALSE, /* is_foreign */
|
FALSE, /* is_foreign */
|
||||||
height,
|
height,
|
||||||
@ -510,7 +512,7 @@ _cogl_texture_3d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
|
|||||||
available we'll fallback to temporarily enabling
|
available we'll fallback to temporarily enabling
|
||||||
GL_GENERATE_MIPMAP and reuploading the first pixel */
|
GL_GENERATE_MIPMAP and reuploading the first pixel */
|
||||||
if (cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
|
if (cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
|
||||||
ctx->texture_driver->gl_generate_mipmaps (GL_TEXTURE_3D);
|
ctx->texture_driver->gl_generate_mipmaps (ctx, GL_TEXTURE_3D);
|
||||||
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
|
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
|
||||||
else if (ctx->driver != COGL_DRIVER_GLES2)
|
else if (ctx->driver != COGL_DRIVER_GLES2)
|
||||||
{
|
{
|
||||||
|
@ -34,9 +34,10 @@ struct _CoglTextureDriver
|
|||||||
* the driver will not allocate room for the mipmap tree.
|
* the driver will not allocate room for the mipmap tree.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
(* gen) (GLenum gl_target,
|
(* gen) (CoglContext *ctx,
|
||||||
GLsizei n,
|
GLenum gl_target,
|
||||||
GLuint *textures);
|
GLsizei n,
|
||||||
|
GLuint *textures);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This sets up the glPixelStore state for an upload to a destination with
|
* This sets up the glPixelStore state for an upload to a destination with
|
||||||
@ -46,7 +47,8 @@ struct _CoglTextureDriver
|
|||||||
* buffer which is why this interface is limited. The GL driver has a more
|
* buffer which is why this interface is limited. The GL driver has a more
|
||||||
* flexible version of this function that is uses internally */
|
* flexible version of this function that is uses internally */
|
||||||
void
|
void
|
||||||
(* prep_gl_for_pixels_upload) (int pixels_rowstride,
|
(* prep_gl_for_pixels_upload) (CoglContext *ctx,
|
||||||
|
int pixels_rowstride,
|
||||||
int pixels_bpp);
|
int pixels_bpp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -63,18 +65,19 @@ struct _CoglTextureDriver
|
|||||||
* XXX: sorry for the ridiculous number of arguments :-(
|
* XXX: sorry for the ridiculous number of arguments :-(
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
(* upload_subregion_to_gl) (GLenum gl_target,
|
(* upload_subregion_to_gl) (CoglContext *ctx,
|
||||||
GLuint gl_handle,
|
GLenum gl_target,
|
||||||
gboolean is_foreign,
|
GLuint gl_handle,
|
||||||
int src_x,
|
gboolean is_foreign,
|
||||||
int src_y,
|
int src_x,
|
||||||
int dst_x,
|
int src_y,
|
||||||
int dst_y,
|
int dst_x,
|
||||||
int width,
|
int dst_y,
|
||||||
int height,
|
int width,
|
||||||
CoglBitmap *source_bmp,
|
int height,
|
||||||
GLuint source_gl_format,
|
CoglBitmap *source_bmp,
|
||||||
GLuint source_gl_type);
|
GLuint source_gl_format,
|
||||||
|
GLuint source_gl_type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Replaces the contents of the GL texture with the entire bitmap. On
|
* Replaces the contents of the GL texture with the entire bitmap. On
|
||||||
@ -83,13 +86,14 @@ struct _CoglTextureDriver
|
|||||||
* alignment value because there is no GL_UNPACK_ROW_LENGTH
|
* alignment value because there is no GL_UNPACK_ROW_LENGTH
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
(* upload_to_gl) (GLenum gl_target,
|
(* upload_to_gl) (CoglContext *ctx,
|
||||||
GLuint gl_handle,
|
GLenum gl_target,
|
||||||
gboolean is_foreign,
|
GLuint gl_handle,
|
||||||
CoglBitmap *source_bmp,
|
gboolean is_foreign,
|
||||||
GLint internal_gl_format,
|
CoglBitmap *source_bmp,
|
||||||
GLuint source_gl_format,
|
GLint internal_gl_format,
|
||||||
GLuint source_gl_type);
|
GLuint source_gl_format,
|
||||||
|
GLuint source_gl_type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Replaces the contents of the GL texture with the entire bitmap. The
|
* Replaces the contents of the GL texture with the entire bitmap. The
|
||||||
@ -99,15 +103,16 @@ struct _CoglTextureDriver
|
|||||||
* height of the bitmap by the depth.
|
* height of the bitmap by the depth.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
(* upload_to_gl_3d) (GLenum gl_target,
|
(* upload_to_gl_3d) (CoglContext *ctx,
|
||||||
GLuint gl_handle,
|
GLenum gl_target,
|
||||||
gboolean is_foreign,
|
GLuint gl_handle,
|
||||||
GLint height,
|
gboolean is_foreign,
|
||||||
GLint depth,
|
GLint height,
|
||||||
CoglBitmap *source_bmp,
|
GLint depth,
|
||||||
GLint internal_gl_format,
|
CoglBitmap *source_bmp,
|
||||||
GLuint source_gl_format,
|
GLint internal_gl_format,
|
||||||
GLuint source_gl_type);
|
GLuint source_gl_format,
|
||||||
|
GLuint source_gl_type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This sets up the glPixelStore state for an download to a destination with
|
* This sets up the glPixelStore state for an download to a destination with
|
||||||
@ -117,7 +122,8 @@ struct _CoglTextureDriver
|
|||||||
* destination buffer, the GL driver has a more flexible version of
|
* destination buffer, the GL driver has a more flexible version of
|
||||||
* this function that it uses internally. */
|
* this function that it uses internally. */
|
||||||
void
|
void
|
||||||
(* prep_gl_for_pixels_download) (int pixels_rowstride,
|
(* prep_gl_for_pixels_download) (CoglContext *ctx,
|
||||||
|
int pixels_rowstride,
|
||||||
int pixels_bpp);
|
int pixels_bpp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -128,36 +134,39 @@ struct _CoglTextureDriver
|
|||||||
* _cogl_texture_draw_and_read () )
|
* _cogl_texture_draw_and_read () )
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
(* gl_get_tex_image) (GLenum gl_target,
|
(* gl_get_tex_image) (CoglContext *ctx,
|
||||||
GLenum dest_gl_format,
|
GLenum gl_target,
|
||||||
GLenum dest_gl_type,
|
GLenum dest_gl_format,
|
||||||
|
GLenum dest_gl_type,
|
||||||
guint8 *dest);
|
guint8 *dest);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It may depend on the driver as to what texture sizes are supported...
|
* It may depend on the driver as to what texture sizes are supported...
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
(* size_supported) (GLenum gl_target,
|
(* size_supported) (CoglContext *ctx,
|
||||||
|
GLenum gl_target,
|
||||||
GLenum gl_format,
|
GLenum gl_format,
|
||||||
GLenum gl_type,
|
GLenum gl_type,
|
||||||
int width,
|
int width,
|
||||||
int height);
|
int height);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
(* size_supported_3d) (GLenum gl_target,
|
(* size_supported_3d) (CoglContext *ctx,
|
||||||
|
GLenum gl_target,
|
||||||
GLenum gl_format,
|
GLenum gl_format,
|
||||||
GLenum gl_type,
|
GLenum gl_type,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
int depth);
|
int depth);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This driver abstraction is needed because GLES doesn't support setting
|
* This driver abstraction is needed because GLES doesn't support setting
|
||||||
* a texture border color.
|
* a texture border color.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
(* try_setting_gl_border_color) (
|
(* try_setting_gl_border_color) (CoglContext *ctx,
|
||||||
GLuint gl_target,
|
GLuint gl_target,
|
||||||
const GLfloat *transparent_color);
|
const GLfloat *transparent_color);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -166,7 +175,8 @@ struct _CoglTextureDriver
|
|||||||
* but GLES doesn't
|
* but GLES doesn't
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
(* allows_foreign_gl_target) (GLenum gl_target);
|
(* allows_foreign_gl_target) (CoglContext *ctx,
|
||||||
|
GLenum gl_target);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* glGenerateMipmap semantics may need to be emulated for some
|
* glGenerateMipmap semantics may need to be emulated for some
|
||||||
@ -174,7 +184,8 @@ struct _CoglTextureDriver
|
|||||||
* number of known texels.
|
* number of known texels.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
(* gl_generate_mipmaps) (GLenum texture_target);
|
(* gl_generate_mipmaps) (CoglContext *ctx,
|
||||||
|
GLenum texture_target);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The driver may impose constraints on what formats can be used to store
|
* The driver may impose constraints on what formats can be used to store
|
||||||
@ -184,9 +195,9 @@ struct _CoglTextureDriver
|
|||||||
*/
|
*/
|
||||||
CoglPixelFormat
|
CoglPixelFormat
|
||||||
(* find_best_gl_get_data_format) (CoglContext *context,
|
(* find_best_gl_get_data_format) (CoglContext *context,
|
||||||
CoglPixelFormat format,
|
CoglPixelFormat format,
|
||||||
GLenum *closest_gl_format,
|
GLenum *closest_gl_format,
|
||||||
GLenum *closest_gl_type);
|
GLenum *closest_gl_type);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __COGL_TEXTURE_DRIVER_H */
|
#endif /* __COGL_TEXTURE_DRIVER_H */
|
||||||
|
@ -135,7 +135,8 @@ _cogl_texture_rectangle_can_create (unsigned int width,
|
|||||||
&gl_type);
|
&gl_type);
|
||||||
|
|
||||||
/* Check that the driver can create a texture with that size */
|
/* Check that the driver can create a texture with that size */
|
||||||
if (!ctx->texture_driver->size_supported (GL_TEXTURE_RECTANGLE_ARB,
|
if (!ctx->texture_driver->size_supported (ctx,
|
||||||
|
GL_TEXTURE_RECTANGLE_ARB,
|
||||||
gl_intformat,
|
gl_intformat,
|
||||||
gl_type,
|
gl_type,
|
||||||
width,
|
width,
|
||||||
@ -206,7 +207,10 @@ cogl_texture_rectangle_new_with_size (CoglContext *ctx,
|
|||||||
tex_rect = _cogl_texture_rectangle_create_base (width, height,
|
tex_rect = _cogl_texture_rectangle_create_base (width, height,
|
||||||
internal_format);
|
internal_format);
|
||||||
|
|
||||||
ctx->texture_driver->gen (GL_TEXTURE_RECTANGLE_ARB, 1, &tex_rect->gl_texture);
|
ctx->texture_driver->gen (ctx,
|
||||||
|
GL_TEXTURE_RECTANGLE_ARB,
|
||||||
|
1, /* num textures */
|
||||||
|
&tex_rect->gl_texture);
|
||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
|
||||||
tex_rect->gl_texture,
|
tex_rect->gl_texture,
|
||||||
tex_rect->is_foreign);
|
tex_rect->is_foreign);
|
||||||
@ -255,8 +259,12 @@ _cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp,
|
|||||||
cogl_bitmap_get_height (bmp),
|
cogl_bitmap_get_height (bmp),
|
||||||
internal_format);
|
internal_format);
|
||||||
|
|
||||||
ctx->texture_driver->gen (GL_TEXTURE_RECTANGLE_ARB, 1, &tex_rect->gl_texture);
|
ctx->texture_driver->gen (ctx,
|
||||||
ctx->texture_driver->upload_to_gl (GL_TEXTURE_RECTANGLE_ARB,
|
GL_TEXTURE_RECTANGLE_ARB,
|
||||||
|
1, /* num textures */
|
||||||
|
&tex_rect->gl_texture);
|
||||||
|
ctx->texture_driver->upload_to_gl (ctx,
|
||||||
|
GL_TEXTURE_RECTANGLE_ARB,
|
||||||
tex_rect->gl_texture,
|
tex_rect->gl_texture,
|
||||||
FALSE,
|
FALSE,
|
||||||
dst_bmp,
|
dst_bmp,
|
||||||
@ -288,7 +296,8 @@ _cogl_texture_rectangle_new_from_foreign (GLuint gl_handle,
|
|||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NULL);
|
_COGL_GET_CONTEXT (ctx, NULL);
|
||||||
|
|
||||||
if (!ctx->texture_driver->allows_foreign_gl_target (GL_TEXTURE_RECTANGLE_ARB))
|
if (!ctx->texture_driver->allows_foreign_gl_target (ctx,
|
||||||
|
GL_TEXTURE_RECTANGLE_ARB))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Make sure it is a valid GL texture object */
|
/* Make sure it is a valid GL texture object */
|
||||||
@ -506,7 +515,8 @@ _cogl_texture_rectangle_set_region (CoglTexture *tex,
|
|||||||
&gl_type);
|
&gl_type);
|
||||||
|
|
||||||
/* Send data to GL */
|
/* Send data to GL */
|
||||||
ctx->texture_driver->upload_subregion_to_gl (GL_TEXTURE_RECTANGLE_ARB,
|
ctx->texture_driver->upload_subregion_to_gl (ctx,
|
||||||
|
GL_TEXTURE_RECTANGLE_ARB,
|
||||||
tex_rect->gl_texture,
|
tex_rect->gl_texture,
|
||||||
FALSE,
|
FALSE,
|
||||||
src_x, src_y,
|
src_x, src_y,
|
||||||
@ -542,12 +552,13 @@ _cogl_texture_rectangle_get_data (CoglTexture *tex,
|
|||||||
&gl_format,
|
&gl_format,
|
||||||
&gl_type);
|
&gl_type);
|
||||||
|
|
||||||
ctx->texture_driver->prep_gl_for_pixels_download (rowstride, bpp);
|
ctx->texture_driver->prep_gl_for_pixels_download (ctx, rowstride, bpp);
|
||||||
|
|
||||||
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
|
_cogl_bind_gl_texture_transient (GL_TEXTURE_RECTANGLE_ARB,
|
||||||
tex_rect->gl_texture,
|
tex_rect->gl_texture,
|
||||||
tex_rect->is_foreign);
|
tex_rect->is_foreign);
|
||||||
return ctx->texture_driver->gl_get_tex_image (GL_TEXTURE_RECTANGLE_ARB,
|
return ctx->texture_driver->gl_get_tex_image (ctx,
|
||||||
|
GL_TEXTURE_RECTANGLE_ARB,
|
||||||
gl_format,
|
gl_format,
|
||||||
gl_type,
|
gl_type,
|
||||||
data);
|
data);
|
||||||
|
@ -46,14 +46,13 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_gen (GLenum gl_target,
|
_cogl_texture_driver_gen (CoglContext *ctx,
|
||||||
GLsizei n,
|
GLenum gl_target,
|
||||||
GLuint *textures)
|
GLsizei n,
|
||||||
|
GLuint *textures)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
GE (ctx, glGenTextures (n, textures));
|
GE (ctx, glGenTextures (n, textures));
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
@ -86,14 +85,13 @@ _cogl_texture_driver_gen (GLenum gl_target,
|
|||||||
/* OpenGL - unlike GLES - can upload a sub region of pixel data from a larger
|
/* OpenGL - unlike GLES - can upload a sub region of pixel data from a larger
|
||||||
* source buffer */
|
* source buffer */
|
||||||
static void
|
static void
|
||||||
prep_gl_for_pixels_upload_full (int pixels_rowstride,
|
prep_gl_for_pixels_upload_full (CoglContext *ctx,
|
||||||
|
int pixels_rowstride,
|
||||||
int image_height,
|
int image_height,
|
||||||
int pixels_src_x,
|
int pixels_src_x,
|
||||||
int pixels_src_y,
|
int pixels_src_y,
|
||||||
int pixels_bpp)
|
int pixels_bpp)
|
||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
GE( ctx, glPixelStorei (GL_UNPACK_ROW_LENGTH,
|
GE( ctx, glPixelStorei (GL_UNPACK_ROW_LENGTH,
|
||||||
pixels_rowstride / pixels_bpp) );
|
pixels_rowstride / pixels_bpp) );
|
||||||
|
|
||||||
@ -107,23 +105,23 @@ prep_gl_for_pixels_upload_full (int pixels_rowstride,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_prep_gl_for_pixels_upload (int pixels_rowstride,
|
_cogl_texture_driver_prep_gl_for_pixels_upload (CoglContext *ctx,
|
||||||
|
int pixels_rowstride,
|
||||||
int pixels_bpp)
|
int pixels_bpp)
|
||||||
{
|
{
|
||||||
prep_gl_for_pixels_upload_full (pixels_rowstride, 0, 0, 0, pixels_bpp);
|
prep_gl_for_pixels_upload_full (ctx, pixels_rowstride, 0, 0, 0, pixels_bpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OpenGL - unlike GLES - can download pixel data into a sub region of
|
/* OpenGL - unlike GLES - can download pixel data into a sub region of
|
||||||
* a larger destination buffer */
|
* a larger destination buffer */
|
||||||
static void
|
static void
|
||||||
prep_gl_for_pixels_download_full (int pixels_rowstride,
|
prep_gl_for_pixels_download_full (CoglContext *ctx,
|
||||||
|
int pixels_rowstride,
|
||||||
int image_height,
|
int image_height,
|
||||||
int pixels_src_x,
|
int pixels_src_x,
|
||||||
int pixels_src_y,
|
int pixels_src_y,
|
||||||
int pixels_bpp)
|
int pixels_bpp)
|
||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
GE( ctx, glPixelStorei (GL_PACK_ROW_LENGTH, pixels_rowstride / pixels_bpp) );
|
GE( ctx, glPixelStorei (GL_PACK_ROW_LENGTH, pixels_rowstride / pixels_bpp) );
|
||||||
|
|
||||||
GE( ctx, glPixelStorei (GL_PACK_SKIP_PIXELS, pixels_src_x) );
|
GE( ctx, glPixelStorei (GL_PACK_SKIP_PIXELS, pixels_src_x) );
|
||||||
@ -136,14 +134,16 @@ prep_gl_for_pixels_download_full (int pixels_rowstride,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_prep_gl_for_pixels_download (int pixels_rowstride,
|
_cogl_texture_driver_prep_gl_for_pixels_download (CoglContext *ctx,
|
||||||
|
int pixels_rowstride,
|
||||||
int pixels_bpp)
|
int pixels_bpp)
|
||||||
{
|
{
|
||||||
prep_gl_for_pixels_download_full (pixels_rowstride, 0, 0, 0, pixels_bpp);
|
prep_gl_for_pixels_download_full (ctx, pixels_rowstride, 0, 0, 0, pixels_bpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_upload_subregion_to_gl (GLenum gl_target,
|
_cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
|
||||||
|
GLenum gl_target,
|
||||||
GLuint gl_handle,
|
GLuint gl_handle,
|
||||||
gboolean is_foreign,
|
gboolean is_foreign,
|
||||||
int src_x,
|
int src_x,
|
||||||
@ -160,12 +160,11 @@ _cogl_texture_driver_upload_subregion_to_gl (GLenum gl_target,
|
|||||||
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);
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
|
data = _cogl_bitmap_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 (cogl_bitmap_get_rowstride (source_bmp),
|
prep_gl_for_pixels_upload_full (ctx,
|
||||||
|
cogl_bitmap_get_rowstride (source_bmp),
|
||||||
0,
|
0,
|
||||||
src_x,
|
src_x,
|
||||||
src_y,
|
src_y,
|
||||||
@ -184,7 +183,8 @@ _cogl_texture_driver_upload_subregion_to_gl (GLenum gl_target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_upload_to_gl (GLenum gl_target,
|
_cogl_texture_driver_upload_to_gl (CoglContext *ctx,
|
||||||
|
GLenum gl_target,
|
||||||
GLuint gl_handle,
|
GLuint gl_handle,
|
||||||
gboolean is_foreign,
|
gboolean is_foreign,
|
||||||
CoglBitmap *source_bmp,
|
CoglBitmap *source_bmp,
|
||||||
@ -196,12 +196,11 @@ _cogl_texture_driver_upload_to_gl (GLenum gl_target,
|
|||||||
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);
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
|
data = _cogl_bitmap_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 (cogl_bitmap_get_rowstride (source_bmp),
|
prep_gl_for_pixels_upload_full (ctx,
|
||||||
|
cogl_bitmap_get_rowstride (source_bmp),
|
||||||
0, 0, 0, bpp);
|
0, 0, 0, bpp);
|
||||||
|
|
||||||
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
|
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
|
||||||
@ -219,7 +218,8 @@ _cogl_texture_driver_upload_to_gl (GLenum gl_target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_upload_to_gl_3d (GLenum gl_target,
|
_cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
|
||||||
|
GLenum gl_target,
|
||||||
GLuint gl_handle,
|
GLuint gl_handle,
|
||||||
gboolean is_foreign,
|
gboolean is_foreign,
|
||||||
GLint height,
|
GLint height,
|
||||||
@ -233,12 +233,11 @@ _cogl_texture_driver_upload_to_gl_3d (GLenum gl_target,
|
|||||||
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);
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
|
data = _cogl_bitmap_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 (cogl_bitmap_get_rowstride (source_bmp),
|
prep_gl_for_pixels_upload_full (ctx,
|
||||||
|
cogl_bitmap_get_rowstride (source_bmp),
|
||||||
(cogl_bitmap_get_height (source_bmp) /
|
(cogl_bitmap_get_height (source_bmp) /
|
||||||
depth),
|
depth),
|
||||||
0, 0, bpp);
|
0, 0, bpp);
|
||||||
@ -260,13 +259,12 @@ _cogl_texture_driver_upload_to_gl_3d (GLenum gl_target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cogl_texture_driver_gl_get_tex_image (GLenum gl_target,
|
_cogl_texture_driver_gl_get_tex_image (CoglContext *ctx,
|
||||||
GLenum dest_gl_format,
|
GLenum gl_target,
|
||||||
GLenum dest_gl_type,
|
GLenum dest_gl_format,
|
||||||
|
GLenum dest_gl_type,
|
||||||
guint8 *dest)
|
guint8 *dest)
|
||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
GE (ctx, glGetTexImage (gl_target,
|
GE (ctx, glGetTexImage (gl_target,
|
||||||
0, /* level */
|
0, /* level */
|
||||||
dest_gl_format,
|
dest_gl_format,
|
||||||
@ -276,18 +274,17 @@ _cogl_texture_driver_gl_get_tex_image (GLenum gl_target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cogl_texture_driver_size_supported_3d (GLenum gl_target,
|
_cogl_texture_driver_size_supported_3d (CoglContext *ctx,
|
||||||
|
GLenum gl_target,
|
||||||
GLenum gl_format,
|
GLenum gl_format,
|
||||||
GLenum gl_type,
|
GLenum gl_type,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
int depth)
|
int depth)
|
||||||
{
|
{
|
||||||
GLenum proxy_target;
|
GLenum proxy_target;
|
||||||
GLint new_width = 0;
|
GLint new_width = 0;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
if (gl_target == GL_TEXTURE_3D)
|
if (gl_target == GL_TEXTURE_3D)
|
||||||
proxy_target = GL_PROXY_TEXTURE_3D;
|
proxy_target = GL_PROXY_TEXTURE_3D;
|
||||||
else
|
else
|
||||||
@ -306,17 +303,16 @@ _cogl_texture_driver_size_supported_3d (GLenum gl_target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cogl_texture_driver_size_supported (GLenum gl_target,
|
_cogl_texture_driver_size_supported (CoglContext *ctx,
|
||||||
|
GLenum gl_target,
|
||||||
GLenum gl_format,
|
GLenum gl_format,
|
||||||
GLenum gl_type,
|
GLenum gl_type,
|
||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
GLenum proxy_target;
|
GLenum proxy_target;
|
||||||
GLint new_width = 0;
|
GLint new_width = 0;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
if (gl_target == GL_TEXTURE_2D)
|
if (gl_target == GL_TEXTURE_2D)
|
||||||
proxy_target = GL_PROXY_TEXTURE_2D;
|
proxy_target = GL_PROXY_TEXTURE_2D;
|
||||||
#if HAVE_COGL_GL
|
#if HAVE_COGL_GL
|
||||||
@ -339,12 +335,11 @@ _cogl_texture_driver_size_supported (GLenum gl_target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_try_setting_gl_border_color (
|
_cogl_texture_driver_try_setting_gl_border_color
|
||||||
GLuint gl_target,
|
(CoglContext *ctx,
|
||||||
const GLfloat *transparent_color)
|
GLuint gl_target,
|
||||||
|
const GLfloat *transparent_color)
|
||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
/* Use a transparent border color so that we can leave the
|
/* Use a transparent border color so that we can leave the
|
||||||
color buffer alone when using texture co-ordinates
|
color buffer alone when using texture co-ordinates
|
||||||
outside of the texture */
|
outside of the texture */
|
||||||
@ -353,7 +348,8 @@ _cogl_texture_driver_try_setting_gl_border_color (
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cogl_texture_driver_allows_foreign_gl_target (GLenum gl_target)
|
_cogl_texture_driver_allows_foreign_gl_target (CoglContext *ctx,
|
||||||
|
GLenum gl_target)
|
||||||
{
|
{
|
||||||
/* GL_ARB_texture_rectangle textures are supported if they are
|
/* GL_ARB_texture_rectangle textures are supported if they are
|
||||||
created from foreign because some chipsets have trouble with
|
created from foreign because some chipsets have trouble with
|
||||||
@ -369,10 +365,9 @@ _cogl_texture_driver_allows_foreign_gl_target (GLenum gl_target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_gl_generate_mipmaps (GLenum gl_target)
|
_cogl_texture_driver_gl_generate_mipmaps (CoglContext *ctx,
|
||||||
|
GLenum gl_target)
|
||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
GE( ctx, glGenerateMipmap (gl_target) );
|
GE( ctx, glGenerateMipmap (gl_target) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,14 +53,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_gen (GLenum gl_target,
|
_cogl_texture_driver_gen (CoglContext *ctx,
|
||||||
GLsizei n,
|
GLenum gl_target,
|
||||||
GLuint *textures)
|
GLsizei n,
|
||||||
|
GLuint *textures)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
GE (ctx, glGenTextures (n, textures));
|
GE (ctx, glGenTextures (n, textures));
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
@ -84,21 +83,24 @@ _cogl_texture_driver_gen (GLenum gl_target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_prep_gl_for_pixels_upload (int pixels_rowstride,
|
_cogl_texture_driver_prep_gl_for_pixels_upload (CoglContext *context,
|
||||||
|
int pixels_rowstride,
|
||||||
int pixels_bpp)
|
int pixels_bpp)
|
||||||
{
|
{
|
||||||
_cogl_texture_prep_gl_alignment_for_pixels_upload (pixels_rowstride);
|
_cogl_texture_prep_gl_alignment_for_pixels_upload (pixels_rowstride);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_prep_gl_for_pixels_download (int pixels_rowstride,
|
_cogl_texture_driver_prep_gl_for_pixels_download (CoglContext *ctx,
|
||||||
|
int pixels_rowstride,
|
||||||
int pixels_bpp)
|
int pixels_bpp)
|
||||||
{
|
{
|
||||||
_cogl_texture_prep_gl_alignment_for_pixels_download (pixels_rowstride);
|
_cogl_texture_prep_gl_alignment_for_pixels_download (pixels_rowstride);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CoglBitmap *
|
static CoglBitmap *
|
||||||
prepare_bitmap_alignment_for_upload (CoglBitmap *src_bmp)
|
prepare_bitmap_alignment_for_upload (CoglContext *ctx,
|
||||||
|
CoglBitmap *src_bmp)
|
||||||
{
|
{
|
||||||
CoglPixelFormat format = cogl_bitmap_get_format (src_bmp);
|
CoglPixelFormat format = cogl_bitmap_get_format (src_bmp);
|
||||||
int bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
|
int bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
|
||||||
@ -124,7 +126,8 @@ prepare_bitmap_alignment_for_upload (CoglBitmap *src_bmp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_upload_subregion_to_gl (GLenum gl_target,
|
_cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
|
||||||
|
GLenum gl_target,
|
||||||
GLuint gl_handle,
|
GLuint gl_handle,
|
||||||
gboolean is_foreign,
|
gboolean is_foreign,
|
||||||
int src_x,
|
int src_x,
|
||||||
@ -143,8 +146,6 @@ _cogl_texture_driver_upload_subregion_to_gl (GLenum gl_target,
|
|||||||
CoglBitmap *slice_bmp;
|
CoglBitmap *slice_bmp;
|
||||||
int rowstride;
|
int rowstride;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
/* If we are copying a sub region of the source bitmap then we need
|
/* If we are copying a sub region of the source bitmap then we need
|
||||||
to copy it because GLES does not support GL_UNPACK_ROW_LENGTH */
|
to copy it because GLES does not support GL_UNPACK_ROW_LENGTH */
|
||||||
if (src_x != 0 || src_y != 0 ||
|
if (src_x != 0 || src_y != 0 ||
|
||||||
@ -162,12 +163,12 @@ _cogl_texture_driver_upload_subregion_to_gl (GLenum gl_target,
|
|||||||
width, height);
|
width, height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
slice_bmp = prepare_bitmap_alignment_for_upload (source_bmp);
|
slice_bmp = prepare_bitmap_alignment_for_upload (ctx, source_bmp);
|
||||||
|
|
||||||
rowstride = cogl_bitmap_get_rowstride (slice_bmp);
|
rowstride = cogl_bitmap_get_rowstride (slice_bmp);
|
||||||
|
|
||||||
/* Setup gl alignment to match rowstride and top-left corner */
|
/* Setup gl alignment to match rowstride and top-left corner */
|
||||||
_cogl_texture_driver_prep_gl_for_pixels_upload (rowstride, bpp);
|
_cogl_texture_driver_prep_gl_for_pixels_upload (ctx, rowstride, bpp);
|
||||||
|
|
||||||
data = _cogl_bitmap_bind (slice_bmp, COGL_BUFFER_ACCESS_READ, 0);
|
data = _cogl_bitmap_bind (slice_bmp, COGL_BUFFER_ACCESS_READ, 0);
|
||||||
|
|
||||||
@ -186,7 +187,8 @@ _cogl_texture_driver_upload_subregion_to_gl (GLenum gl_target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_upload_to_gl (GLenum gl_target,
|
_cogl_texture_driver_upload_to_gl (CoglContext *ctx,
|
||||||
|
GLenum gl_target,
|
||||||
GLuint gl_handle,
|
GLuint gl_handle,
|
||||||
gboolean is_foreign,
|
gboolean is_foreign,
|
||||||
CoglBitmap *source_bmp,
|
CoglBitmap *source_bmp,
|
||||||
@ -202,13 +204,11 @@ _cogl_texture_driver_upload_to_gl (GLenum gl_target,
|
|||||||
CoglBitmap *bmp;
|
CoglBitmap *bmp;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
bmp = prepare_bitmap_alignment_for_upload (ctx, source_bmp);
|
||||||
|
|
||||||
bmp = prepare_bitmap_alignment_for_upload (source_bmp);
|
|
||||||
rowstride = cogl_bitmap_get_rowstride (bmp);
|
rowstride = cogl_bitmap_get_rowstride (bmp);
|
||||||
|
|
||||||
/* Setup gl alignment to match rowstride and top-left corner */
|
/* Setup gl alignment to match rowstride and top-left corner */
|
||||||
_cogl_texture_driver_prep_gl_for_pixels_upload (rowstride, bpp);
|
_cogl_texture_driver_prep_gl_for_pixels_upload (ctx, rowstride, bpp);
|
||||||
|
|
||||||
_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,8 @@ _cogl_texture_driver_upload_to_gl (GLenum gl_target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_upload_to_gl_3d (GLenum gl_target,
|
_cogl_texture_driver_upload_to_gl_3d (CoglContext *ctx,
|
||||||
|
GLenum gl_target,
|
||||||
GLuint gl_handle,
|
GLuint gl_handle,
|
||||||
gboolean is_foreign,
|
gboolean is_foreign,
|
||||||
GLint height,
|
GLint height,
|
||||||
@ -245,8 +246,6 @@ _cogl_texture_driver_upload_to_gl_3d (GLenum gl_target,
|
|||||||
int bmp_height = cogl_bitmap_get_height (source_bmp);
|
int bmp_height = cogl_bitmap_get_height (source_bmp);
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
|
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
|
||||||
|
|
||||||
/* If the rowstride or image height can't be specified with just
|
/* If the rowstride or image height can't be specified with just
|
||||||
@ -260,7 +259,7 @@ _cogl_texture_driver_upload_to_gl_3d (GLenum gl_target,
|
|||||||
CoglPixelFormat source_bmp_format = cogl_bitmap_get_format (source_bmp);
|
CoglPixelFormat source_bmp_format = cogl_bitmap_get_format (source_bmp);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
_cogl_texture_driver_prep_gl_for_pixels_upload (bmp_width * bpp, bpp);
|
_cogl_texture_driver_prep_gl_for_pixels_upload (ctx, bmp_width * bpp, bpp);
|
||||||
|
|
||||||
/* Initialize the texture with empty data and then upload each
|
/* Initialize the texture with empty data and then upload each
|
||||||
image with a sub-region update */
|
image with a sub-region update */
|
||||||
@ -314,7 +313,7 @@ _cogl_texture_driver_upload_to_gl_3d (GLenum gl_target,
|
|||||||
{
|
{
|
||||||
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
|
data = _cogl_bitmap_bind (source_bmp, COGL_BUFFER_ACCESS_READ, 0);
|
||||||
|
|
||||||
_cogl_texture_driver_prep_gl_for_pixels_upload (rowstride, bpp);
|
_cogl_texture_driver_prep_gl_for_pixels_upload (ctx, rowstride, bpp);
|
||||||
|
|
||||||
GE( ctx, glTexImage3D (gl_target,
|
GE( ctx, glTexImage3D (gl_target,
|
||||||
0, /* level */
|
0, /* level */
|
||||||
@ -335,26 +334,26 @@ _cogl_texture_driver_upload_to_gl_3d (GLenum gl_target,
|
|||||||
* fallback to a generic render + readpixels approach to downloading
|
* fallback to a generic render + readpixels approach to downloading
|
||||||
* texture data. (See _cogl_texture_draw_and_read() ) */
|
* texture data. (See _cogl_texture_draw_and_read() ) */
|
||||||
static gboolean
|
static gboolean
|
||||||
_cogl_texture_driver_gl_get_tex_image (GLenum gl_target,
|
_cogl_texture_driver_gl_get_tex_image (CoglContext *ctx,
|
||||||
GLenum dest_gl_format,
|
GLenum gl_target,
|
||||||
GLenum dest_gl_type,
|
GLenum dest_gl_format,
|
||||||
|
GLenum dest_gl_type,
|
||||||
guint8 *dest)
|
guint8 *dest)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cogl_texture_driver_size_supported_3d (GLenum gl_target,
|
_cogl_texture_driver_size_supported_3d (CoglContext *ctx,
|
||||||
|
GLenum gl_target,
|
||||||
GLenum gl_format,
|
GLenum gl_format,
|
||||||
GLenum gl_type,
|
GLenum gl_type,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
int depth)
|
int depth)
|
||||||
{
|
{
|
||||||
GLint max_size;
|
GLint max_size;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
/* GLES doesn't support a proxy texture target so let's at least
|
/* GLES doesn't support a proxy texture target so let's at least
|
||||||
check whether the size is greater than
|
check whether the size is greater than
|
||||||
GL_MAX_3D_TEXTURE_SIZE_OES */
|
GL_MAX_3D_TEXTURE_SIZE_OES */
|
||||||
@ -364,16 +363,15 @@ _cogl_texture_driver_size_supported_3d (GLenum gl_target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cogl_texture_driver_size_supported (GLenum gl_target,
|
_cogl_texture_driver_size_supported (CoglContext *ctx,
|
||||||
|
GLenum gl_target,
|
||||||
GLenum gl_format,
|
GLenum gl_format,
|
||||||
GLenum gl_type,
|
GLenum gl_type,
|
||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
GLint max_size;
|
GLint max_size;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
/* GLES doesn't support a proxy texture target so let's at least
|
/* GLES doesn't support a proxy texture target so let's at least
|
||||||
check whether the size is greater than GL_MAX_TEXTURE_SIZE */
|
check whether the size is greater than GL_MAX_TEXTURE_SIZE */
|
||||||
GE( ctx, glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_size) );
|
GE( ctx, glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_size) );
|
||||||
@ -382,15 +380,17 @@ _cogl_texture_driver_size_supported (GLenum gl_target,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_try_setting_gl_border_color (
|
_cogl_texture_driver_try_setting_gl_border_color
|
||||||
GLuint gl_target,
|
(CoglContext *ctx,
|
||||||
const GLfloat *transparent_color)
|
GLuint gl_target,
|
||||||
|
const GLfloat *transparent_color)
|
||||||
{
|
{
|
||||||
/* FAIL! */
|
/* FAIL! */
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cogl_texture_driver_allows_foreign_gl_target (GLenum gl_target)
|
_cogl_texture_driver_allows_foreign_gl_target (CoglContext *ctx,
|
||||||
|
GLenum gl_target)
|
||||||
{
|
{
|
||||||
/* Allow 2-dimensional textures only */
|
/* Allow 2-dimensional textures only */
|
||||||
if (gl_target != GL_TEXTURE_2D)
|
if (gl_target != GL_TEXTURE_2D)
|
||||||
@ -399,10 +399,9 @@ _cogl_texture_driver_allows_foreign_gl_target (GLenum gl_target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cogl_texture_driver_gl_generate_mipmaps (GLenum gl_target)
|
_cogl_texture_driver_gl_generate_mipmaps (CoglContext *ctx,
|
||||||
|
GLenum gl_target)
|
||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
if (ctx->driver == COGL_DRIVER_GLES2)
|
if (ctx->driver == COGL_DRIVER_GLES2)
|
||||||
GE( ctx, glGenerateMipmap (gl_target) );
|
GE( ctx, glGenerateMipmap (gl_target) );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user