From cde6a447b4d2108c9cd54d7c6ec8d1fe14be4796 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Sat, 30 Nov 2024 20:36:53 +0100 Subject: [PATCH] cogl: Move various vfuncs from DriverVtable to TextureDriver As they make more sense there. Maybe we could have a common OpenGLTextureDriver that would share the common texture_2d_* vfuncs but that can be done later. By moving those vfuncs to the TextureDriver, we can get rid of the texutre_2d nop driver implementations. Part-of: --- cogl/cogl/cogl-driver.h | 86 -------------- cogl/cogl/cogl-texture-2d-sliced.c | 20 ++-- cogl/cogl/cogl-texture-2d.c | 77 ++++++++----- cogl/cogl/cogl-texture-driver.h | 87 ++++++++++++++ .../driver/gl/cogl-texture-2d-gl-private.h | 79 +++++++------ cogl/cogl/driver/gl/cogl-texture-2d-gl.c | 87 +++++++------- cogl/cogl/driver/gl/gl/cogl-driver-gl.c | 10 -- .../driver/gl/gl/cogl-texture-driver-gl3.c | 19 ++++ cogl/cogl/driver/gl/gles/cogl-driver-gles.c | 16 --- .../gl/gles/cogl-texture-driver-gles2.c | 17 +++ cogl/cogl/driver/nop/cogl-driver-nop.c | 11 -- .../driver/nop/cogl-texture-2d-nop-private.h | 83 -------------- cogl/cogl/driver/nop/cogl-texture-2d-nop.c | 106 ------------------ cogl/cogl/meson.build | 2 - 14 files changed, 273 insertions(+), 427 deletions(-) delete mode 100644 cogl/cogl/driver/nop/cogl-texture-2d-nop-private.h delete mode 100644 cogl/cogl/driver/nop/cogl-texture-2d-nop.c diff --git a/cogl/cogl/cogl-driver.h b/cogl/cogl/cogl-driver.h index dfe1e0839..c1116fbb8 100644 --- a/cogl/cogl/cogl-driver.h +++ b/cogl/cogl/cogl-driver.h @@ -88,92 +88,6 @@ struct _CoglDriverVtable CoglFramebuffer *read_buffer, CoglFramebufferState state); - /* Destroys any driver specific resources associated with the given - * 2D texture. */ - void - (* texture_2d_free) (CoglTexture2D *tex_2d); - - /* Returns TRUE if the driver can support creating a 2D texture with - * the given geometry and specified internal format. - */ - gboolean - (* texture_2d_can_create) (CoglContext *ctx, - int width, - int height, - CoglPixelFormat internal_format); - - /* Initializes driver private state before allocating any specific - * storage for a 2D texture, where base texture and texture 2D - * members will already be initialized before passing control to - * the driver. - */ - void - (* texture_2d_init) (CoglTexture2D *tex_2d); - - /* Allocates (uninitialized) storage for the given texture according - * to the configured size and format of the texture */ - gboolean - (* texture_2d_allocate) (CoglTexture *tex, - GError **error); - - /* Initialize the specified region of storage of the given texture - * with the contents of the specified framebuffer region - */ - void - (* texture_2d_copy_from_framebuffer) (CoglTexture2D *tex_2d, - int src_x, - int src_y, - int width, - int height, - CoglFramebuffer *src_fb, - int dst_x, - int dst_y, - int level); - - /* If the given texture has a corresponding OpenGL texture handle - * then return that. - * - * This is optional - */ - unsigned int - (* texture_2d_get_gl_handle) (CoglTexture2D *tex_2d); - - /* Update all mipmap levels > 0 */ - void - (* texture_2d_generate_mipmap) (CoglTexture2D *tex_2d); - - /* Initialize the specified region of storage of the given texture - * with the contents of the specified bitmap region - * - * Since this may need to create the underlying storage first - * it may throw a NO_MEMORY error. - */ - gboolean - (* texture_2d_copy_from_bitmap) (CoglTexture2D *tex_2d, - int src_x, - int src_y, - int width, - int height, - CoglBitmap *bitmap, - int dst_x, - int dst_y, - int level, - GError **error); - - gboolean - (* texture_2d_is_get_data_supported) (CoglTexture2D *tex_2d); - - /* Reads back the full contents of the given texture and write it to - * @data in the given @format and with the given @rowstride. - * - * This is optional - */ - void - (* texture_2d_get_data) (CoglTexture2D *tex_2d, - CoglPixelFormat format, - int rowstride, - uint8_t *data); - /* Prepares for drawing by flushing the journal, framebuffer state, * pipeline state and attribute state. */ diff --git a/cogl/cogl/cogl-texture-2d-sliced.c b/cogl/cogl/cogl-texture-2d-sliced.c index 2a85025fe..4322b33c7 100644 --- a/cogl/cogl/cogl-texture-2d-sliced.c +++ b/cogl/cogl/cogl-texture-2d-sliced.c @@ -157,6 +157,8 @@ setup_spans (CoglContext *ctx, CoglPixelFormat internal_format, GError **error) { + CoglTextureDriverClass *tex_driver = + COGL_TEXTURE_DRIVER_GET_CLASS (ctx->texture_driver); int max_width; int max_height; int n_x_slices; @@ -175,10 +177,11 @@ setup_spans (CoglContext *ctx, CoglSpan span; /* Check if size supported else bail out */ - if (!ctx->driver_vtable->texture_2d_can_create (ctx, - max_width, - max_height, - internal_format)) + if (!tex_driver->texture_2d_can_create (ctx->texture_driver, + ctx, + max_width, + max_height, + internal_format)) { g_set_error (error, COGL_TEXTURE_ERROR, COGL_TEXTURE_ERROR_SIZE, "Sliced texture size of %d x %d not possible " @@ -213,10 +216,11 @@ setup_spans (CoglContext *ctx, else { /* Decrease the size of largest slice until supported by GL */ - while (!ctx->driver_vtable->texture_2d_can_create (ctx, - max_width, - max_height, - internal_format)) + while (!tex_driver->texture_2d_can_create (ctx->texture_driver, + ctx, + max_width, + max_height, + internal_format)) { /* Alternate between width and height */ if (max_width > max_height) diff --git a/cogl/cogl/cogl-texture-2d.c b/cogl/cogl/cogl-texture-2d.c index 94cbb16ef..2821998e3 100644 --- a/cogl/cogl/cogl-texture-2d.c +++ b/cogl/cogl/cogl-texture-2d.c @@ -57,8 +57,10 @@ cogl_texture_2d_dispose (GObject *object) { CoglTexture2D *tex_2d = COGL_TEXTURE_2D (object); CoglContext *ctx = cogl_texture_get_context (COGL_TEXTURE (tex_2d)); + CoglTextureDriverClass *tex_driver = + COGL_TEXTURE_DRIVER_GET_CLASS (ctx->texture_driver); - ctx->driver_vtable->texture_2d_free (tex_2d); + tex_driver->texture_2d_free (ctx->texture_driver, tex_2d); G_OBJECT_CLASS (cogl_texture_2d_parent_class)->dispose (object); } @@ -87,13 +89,16 @@ _cogl_texture_2d_create_base (CoglContext *ctx, "format", internal_format, "is-primitive", TRUE, NULL); + CoglTextureDriverClass *tex_driver = + COGL_TEXTURE_DRIVER_GET_CLASS (ctx->texture_driver); + tex_2d->mipmaps_dirty = TRUE; tex_2d->auto_mipmap = TRUE; tex_2d->is_get_data_supported = TRUE; tex_2d->gl_target = GL_TEXTURE_2D; - ctx->driver_vtable->texture_2d_init (tex_2d); + tex_driver->texture_2d_init (ctx->texture_driver, tex_2d); return COGL_TEXTURE (tex_2d); } @@ -103,8 +108,10 @@ _cogl_texture_2d_allocate (CoglTexture *tex, GError **error) { CoglContext *ctx = cogl_texture_get_context (tex); + CoglTextureDriverClass *tex_driver = + COGL_TEXTURE_DRIVER_GET_CLASS (ctx->texture_driver); - return ctx->driver_vtable->texture_2d_allocate (tex, error); + return tex_driver->texture_2d_allocate (ctx->texture_driver, tex, error); } void @@ -120,19 +127,22 @@ _cogl_texture_2d_copy_from_framebuffer (CoglTexture2D *tex_2d, { CoglTexture *tex = COGL_TEXTURE (tex_2d); CoglContext *ctx = cogl_texture_get_context (tex); + CoglTextureDriverClass *tex_driver = + COGL_TEXTURE_DRIVER_GET_CLASS (ctx->texture_driver); /* Assert that the storage for this texture has been allocated */ cogl_texture_allocate (tex, NULL); /* (abort on error) */ - ctx->driver_vtable->texture_2d_copy_from_framebuffer (tex_2d, - src_x, - src_y, - width, - height, - src_fb, - dst_x, - dst_y, - level); + tex_driver->texture_2d_copy_from_framebuffer (ctx->texture_driver, + tex_2d, + src_x, + src_y, + width, + height, + src_fb, + dst_x, + dst_y, + level); tex_2d->mipmaps_dirty = TRUE; } @@ -193,15 +203,17 @@ _cogl_texture_2d_get_gl_texture (CoglTexture *tex, { CoglContext *ctx = cogl_texture_get_context (tex); CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex); + CoglTextureDriverClass *tex_driver = + COGL_TEXTURE_DRIVER_GET_CLASS (ctx->texture_driver); - if (ctx->driver_vtable->texture_2d_get_gl_handle) + if (tex_driver->texture_2d_get_gl_handle) { GLuint handle; if (out_gl_target) *out_gl_target = tex_2d->gl_target; - handle = ctx->driver_vtable->texture_2d_get_gl_handle (tex_2d); + handle = tex_driver->texture_2d_get_gl_handle (ctx->texture_driver, tex_2d); if (out_gl_handle) *out_gl_handle = handle; @@ -222,6 +234,8 @@ _cogl_texture_2d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags) tex_2d->auto_mipmap && tex_2d->mipmaps_dirty) { CoglContext *ctx = cogl_texture_get_context (tex); + CoglTextureDriverClass *tex_driver = + COGL_TEXTURE_DRIVER_GET_CLASS (ctx->texture_driver); /* Since we are about to ask the GPU to generate mipmaps of tex, we * better make sure tex is up-to-date. @@ -232,7 +246,7 @@ _cogl_texture_2d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags) _cogl_texture_get_associated_framebuffers (tex)) ctx->glFlush (); - ctx->driver_vtable->texture_2d_generate_mipmap (tex_2d); + tex_driver->texture_2d_generate_mipmap (ctx->texture_driver, tex_2d); tex_2d->mipmaps_dirty = FALSE; } @@ -258,17 +272,20 @@ _cogl_texture_2d_set_region (CoglTexture *tex, { CoglContext *ctx = cogl_texture_get_context (tex); CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex); + CoglTextureDriverClass *tex_driver = + COGL_TEXTURE_DRIVER_GET_CLASS (ctx->texture_driver); - if (!ctx->driver_vtable->texture_2d_copy_from_bitmap (tex_2d, - src_x, - src_y, - width, - height, - bmp, - dst_x, - dst_y, - level, - error)) + if (!tex_driver->texture_2d_copy_from_bitmap (ctx->texture_driver, + tex_2d, + src_x, + src_y, + width, + height, + bmp, + dst_x, + dst_y, + level, + error)) { return FALSE; } @@ -283,8 +300,10 @@ _cogl_texture_2d_is_get_data_supported (CoglTexture *tex) { CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex); CoglContext *ctx = cogl_texture_get_context (tex); + CoglTextureDriverClass *tex_driver = + COGL_TEXTURE_DRIVER_GET_CLASS (ctx->texture_driver); - return ctx->driver_vtable->texture_2d_is_get_data_supported (tex_2d); + return tex_driver->texture_2d_is_get_data_supported (ctx->texture_driver, tex_2d); } static gboolean @@ -294,11 +313,13 @@ _cogl_texture_2d_get_data (CoglTexture *tex, uint8_t *data) { CoglContext *ctx = cogl_texture_get_context (tex); + CoglTextureDriverClass *tex_driver = + COGL_TEXTURE_DRIVER_GET_CLASS (ctx->texture_driver); - if (ctx->driver_vtable->texture_2d_get_data) + if (tex_driver->texture_2d_get_data) { CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex); - ctx->driver_vtable->texture_2d_get_data (tex_2d, format, rowstride, data); + tex_driver->texture_2d_get_data (ctx->texture_driver, tex_2d, format, rowstride, data); return TRUE; } else diff --git a/cogl/cogl/cogl-texture-driver.h b/cogl/cogl/cogl-texture-driver.h index 220096755..e894d94ff 100644 --- a/cogl/cogl/cogl-texture-driver.h +++ b/cogl/cogl/cogl-texture-driver.h @@ -157,4 +157,91 @@ struct _CoglTextureDriverClass CoglPixelFormat format, GLenum *closest_gl_format, GLenum *closest_gl_type); + + + /* Destroys any driver specific resources associated with the given + * 2D texture. */ + void (* texture_2d_free) (CoglTextureDriver *driver, + CoglTexture2D *tex_2d); + + /* Returns TRUE if the driver can support creating a 2D texture with + * the given geometry and specified internal format. + */ + gboolean (* texture_2d_can_create) (CoglTextureDriver *driver, + CoglContext *ctx, + int width, + int height, + CoglPixelFormat internal_format); + + /* Initializes driver private state before allocating any specific + * storage for a 2D texture, where base texture and texture 2D + * members will already be initialized before passing control to + * the driver. + */ + void (* texture_2d_init) (CoglTextureDriver *driver, + CoglTexture2D *tex_2d); + + /* Allocates (uninitialized) storage for the given texture according + * to the configured size and format of the texture */ + gboolean (* texture_2d_allocate) (CoglTextureDriver *driver, + CoglTexture *tex, + GError **error); + + /* Initialize the specified region of storage of the given texture + * with the contents of the specified framebuffer region + */ + void (* texture_2d_copy_from_framebuffer) (CoglTextureDriver *driver, + CoglTexture2D *tex_2d, + int src_x, + int src_y, + int width, + int height, + CoglFramebuffer *src_fb, + int dst_x, + int dst_y, + int level); + + /* If the given texture has a corresponding OpenGL texture handle + * then return that. + * + * This is optional + */ + unsigned int (* texture_2d_get_gl_handle) (CoglTextureDriver *driver, + CoglTexture2D *tex_2d); + + /* Update all mipmap levels > 0 */ + void (* texture_2d_generate_mipmap) (CoglTextureDriver *driver, + CoglTexture2D *tex_2d); + + /* Initialize the specified region of storage of the given texture + * with the contents of the specified bitmap region + * + * Since this may need to create the underlying storage first + * it may throw a NO_MEMORY error. + */ + gboolean (* texture_2d_copy_from_bitmap) (CoglTextureDriver *driver, + CoglTexture2D *tex_2d, + int src_x, + int src_y, + int width, + int height, + CoglBitmap *bitmap, + int dst_x, + int dst_y, + int level, + GError **error); + + gboolean (* texture_2d_is_get_data_supported) (CoglTextureDriver *driver, + CoglTexture2D *tex_2d); + + /* Reads back the full contents of the given texture and write it to + * @data in the given @format and with the given @rowstride. + * + * This is optional + */ + void (* texture_2d_get_data) (CoglTextureDriver *driver, + CoglTexture2D *tex_2d, + CoglPixelFormat format, + int rowstride, + uint8_t *data); }; diff --git a/cogl/cogl/driver/gl/cogl-texture-2d-gl-private.h b/cogl/cogl/driver/gl/cogl-texture-2d-gl-private.h index 881bcf08e..4c8758dea 100644 --- a/cogl/cogl/driver/gl/cogl-texture-2d-gl-private.h +++ b/cogl/cogl/driver/gl/cogl-texture-2d-gl-private.h @@ -36,22 +36,27 @@ #include "cogl/cogl-types.h" #include "cogl/cogl-context-private.h" #include "cogl/cogl-texture.h" +#include "cogl/cogl-texture-driver.h" void -_cogl_texture_2d_gl_free (CoglTexture2D *tex_2d); +_cogl_texture_2d_gl_free (CoglTextureDriver *driver, + CoglTexture2D *tex_2d); gboolean -_cogl_texture_2d_gl_can_create (CoglContext *ctx, - int width, - int height, - CoglPixelFormat internal_format); +_cogl_texture_2d_gl_can_create (CoglTextureDriver *driver, + CoglContext *ctx, + int width, + int height, + CoglPixelFormat internal_format); void -_cogl_texture_2d_gl_init (CoglTexture2D *tex_2d); +_cogl_texture_2d_gl_init (CoglTextureDriver *driver, + CoglTexture2D *tex_2d); gboolean -_cogl_texture_2d_gl_allocate (CoglTexture *tex, - GError **error); +_cogl_texture_2d_gl_allocate (CoglTextureDriver *driver, + CoglTexture *tex, + GError **error); #if defined (HAVE_EGL) gboolean @@ -81,39 +86,41 @@ _cogl_texture_2d_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex, GLenum wrap_mode_t); void -_cogl_texture_2d_gl_copy_from_framebuffer (CoglTexture2D *tex_2d, - int src_x, - int src_y, - int width, - int height, - CoglFramebuffer *src_fb, - int dst_x, - int dst_y, - int level); +_cogl_texture_2d_gl_copy_from_framebuffer (CoglTextureDriver *driver, + CoglTexture2D *tex_2d, + int src_x, + int src_y, + int width, + int height, + CoglFramebuffer *src_fb, + int dst_x, + int dst_y, + int level); unsigned int -_cogl_texture_2d_gl_get_gl_handle (CoglTexture2D *tex_2d); +_cogl_texture_2d_gl_get_gl_handle (CoglTextureDriver *driver, + CoglTexture2D *tex_2d); void -_cogl_texture_2d_gl_generate_mipmap (CoglTexture2D *tex_2d); +_cogl_texture_2d_gl_generate_mipmap (CoglTextureDriver *driver, + CoglTexture2D *tex_2d); gboolean -_cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d, - int src_x, - int src_y, - int width, - int height, - CoglBitmap *bitmap, - int dst_x, - int dst_y, - int level, - GError **error); - -gboolean -_cogl_texture_2d_gl_is_get_data_supported (CoglTexture2D *tex_2d); +_cogl_texture_2d_gl_copy_from_bitmap (CoglTextureDriver *driver, + CoglTexture2D *tex_2d, + int src_x, + int src_y, + int width, + int height, + CoglBitmap *bitmap, + int dst_x, + int dst_y, + int level, + GError **error); void -_cogl_texture_2d_gl_get_data (CoglTexture2D *tex_2d, - CoglPixelFormat format, - int rowstride, - uint8_t *data); +_cogl_texture_2d_gl_get_data (CoglTextureDriver *driver, + CoglTexture2D *tex_2d, + CoglPixelFormat format, + int rowstride, + uint8_t *data); diff --git a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c index 65d32c6d4..11f4be8af 100644 --- a/cogl/cogl/driver/gl/cogl-texture-2d-gl.c +++ b/cogl/cogl/driver/gl/cogl-texture-2d-gl.c @@ -60,7 +60,8 @@ #endif /* defined (HAVE_EGL) */ void -_cogl_texture_2d_gl_free (CoglTexture2D *tex_2d) +_cogl_texture_2d_gl_free (CoglTextureDriver *driver, + CoglTexture2D *tex_2d) { if (tex_2d->gl_texture) _cogl_delete_gl_texture (cogl_texture_get_context (COGL_TEXTURE (tex_2d)), @@ -73,10 +74,11 @@ _cogl_texture_2d_gl_free (CoglTexture2D *tex_2d) } gboolean -_cogl_texture_2d_gl_can_create (CoglContext *ctx, - int width, - int height, - CoglPixelFormat internal_format) +_cogl_texture_2d_gl_can_create (CoglTextureDriver *driver, + CoglContext *ctx, + int width, + int height, + CoglPixelFormat internal_format) { CoglTextureDriverClass *tex_driver = COGL_TEXTURE_DRIVER_GET_CLASS (ctx->texture_driver); @@ -109,7 +111,8 @@ _cogl_texture_2d_gl_can_create (CoglContext *ctx, } void -_cogl_texture_2d_gl_init (CoglTexture2D *tex_2d) +_cogl_texture_2d_gl_init (CoglTextureDriver *driver, + CoglTexture2D *tex_2d) { tex_2d->gl_texture = 0; @@ -145,7 +148,8 @@ allocate_with_size (CoglTexture2D *tex_2d, internal_format = _cogl_texture_determine_internal_format (tex, loader->src.sized.format); - if (!_cogl_texture_2d_gl_can_create (ctx, + if (!_cogl_texture_2d_gl_can_create (ctx->texture_driver, + ctx, width, height, internal_format)) @@ -216,7 +220,8 @@ allocate_from_bitmap (CoglTexture2D *tex_2d, internal_format = _cogl_texture_determine_internal_format (tex, cogl_bitmap_get_format (bmp)); - if (!_cogl_texture_2d_gl_can_create (ctx, + if (!_cogl_texture_2d_gl_can_create (ctx->texture_driver, + ctx, width, height, internal_format)) @@ -434,8 +439,9 @@ cogl_texture_2d_new_from_egl_image_external (CoglContext *ctx, #endif /* defined (HAVE_EGL) */ gboolean -_cogl_texture_2d_gl_allocate (CoglTexture *tex, - GError **error) +_cogl_texture_2d_gl_allocate (CoglTextureDriver *driver, + CoglTexture *tex, + GError **error) { CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex); CoglTextureLoader *loader = cogl_texture_get_loader (tex); @@ -526,15 +532,16 @@ _cogl_texture_2d_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex, } void -_cogl_texture_2d_gl_copy_from_framebuffer (CoglTexture2D *tex_2d, - int src_x, - int src_y, - int width, - int height, - CoglFramebuffer *src_fb, - int dst_x, - int dst_y, - int level) +_cogl_texture_2d_gl_copy_from_framebuffer (CoglTextureDriver *driver, + CoglTexture2D *tex_2d, + int src_x, + int src_y, + int width, + int height, + CoglFramebuffer *src_fb, + int dst_x, + int dst_y, + int level) { CoglTexture *tex = COGL_TEXTURE (tex_2d); CoglContext *ctx = cogl_texture_get_context (tex); @@ -559,28 +566,31 @@ _cogl_texture_2d_gl_copy_from_framebuffer (CoglTexture2D *tex_2d, } unsigned int -_cogl_texture_2d_gl_get_gl_handle (CoglTexture2D *tex_2d) +_cogl_texture_2d_gl_get_gl_handle (CoglTextureDriver *driver, + CoglTexture2D *tex_2d) { return tex_2d->gl_texture; } void -_cogl_texture_2d_gl_generate_mipmap (CoglTexture2D *tex_2d) +_cogl_texture_2d_gl_generate_mipmap (CoglTextureDriver *driver, + CoglTexture2D *tex_2d) { _cogl_texture_gl_generate_mipmaps (COGL_TEXTURE (tex_2d)); } gboolean -_cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d, - int src_x, - int src_y, - int width, - int height, - CoglBitmap *bmp, - int dst_x, - int dst_y, - int level, - GError **error) +_cogl_texture_2d_gl_copy_from_bitmap (CoglTextureDriver *driver, + CoglTexture2D *tex_2d, + int src_x, + int src_y, + int width, + int height, + CoglBitmap *bmp, + int dst_x, + int dst_y, + int level, + GError **error) { CoglTexture *tex = COGL_TEXTURE (tex_2d); CoglContext *ctx = cogl_texture_get_context (tex); @@ -632,17 +642,12 @@ _cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d, return status; } -gboolean -_cogl_texture_2d_gl_is_get_data_supported (CoglTexture2D *tex_2d) -{ - return tex_2d->is_get_data_supported; -} - void -_cogl_texture_2d_gl_get_data (CoglTexture2D *tex_2d, - CoglPixelFormat format, - int rowstride, - uint8_t *data) +_cogl_texture_2d_gl_get_data (CoglTextureDriver *driver, + CoglTexture2D *tex_2d, + CoglPixelFormat format, + int rowstride, + uint8_t *data) { CoglContext *ctx = cogl_texture_get_context (COGL_TEXTURE (tex_2d)); CoglTextureDriverClass *tex_driver = diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c index 06a7fb980..36ac7f906 100644 --- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c +++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c @@ -606,16 +606,6 @@ _cogl_driver_gl = _cogl_driver_update_features, _cogl_driver_gl_create_framebuffer_driver, _cogl_driver_gl_flush_framebuffer_state, - _cogl_texture_2d_gl_free, - _cogl_texture_2d_gl_can_create, - _cogl_texture_2d_gl_init, - _cogl_texture_2d_gl_allocate, - _cogl_texture_2d_gl_copy_from_framebuffer, - _cogl_texture_2d_gl_get_gl_handle, - _cogl_texture_2d_gl_generate_mipmap, - _cogl_texture_2d_gl_copy_from_bitmap, - _cogl_texture_2d_gl_is_get_data_supported, - _cogl_texture_2d_gl_get_data, _cogl_gl_flush_attributes_state, _cogl_clip_stack_gl_flush, _cogl_buffer_gl_create, diff --git a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl3.c b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl3.c index 806a24022..ce32c2486 100644 --- a/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl3.c +++ b/cogl/cogl/driver/gl/gl/cogl-texture-driver-gl3.c @@ -40,12 +40,14 @@ #include "cogl/cogl-bitmap.h" #include "cogl/cogl-bitmap-private.h" #include "cogl/cogl-texture-private.h" +#include "cogl/cogl-texture-2d-private.h" #include "cogl/cogl-pipeline.h" #include "cogl/cogl-context-private.h" #include "cogl/driver/gl/gl/cogl-texture-driver-gl3-private.h" #include "cogl/driver/gl/cogl-pipeline-opengl-private.h" #include "cogl/driver/gl/cogl-util-gl-private.h" #include "cogl/driver/gl/cogl-texture-gl-private.h" +#include "cogl/driver/gl/cogl-texture-2d-gl-private.h" #include "cogl/driver/gl/cogl-bitmap-gl-private.h" #include @@ -488,6 +490,13 @@ cogl_texture_driver_gl3_find_best_gl_get_data_format (CoglTextureDriver *driver, closest_gl_type); } +static gboolean +cogl_gl_texture_driver_is_get_data_supported (CoglTextureDriver *driver, + CoglTexture2D *tex_2d) +{ + return tex_2d->is_get_data_supported; +} + static void cogl_texture_driver_gl3_class_init (CoglTextureDriverGL3Class *klass) { @@ -501,6 +510,16 @@ cogl_texture_driver_gl3_class_init (CoglTextureDriverGL3Class *klass) driver_klass->size_supported = cogl_texture_driver_gl3_size_supported; driver_klass->format_supports_upload = cogl_texture_driver_gl3_upload_supported; driver_klass->find_best_gl_get_data_format = cogl_texture_driver_gl3_find_best_gl_get_data_format; + driver_klass->texture_2d_free = _cogl_texture_2d_gl_free; + driver_klass->texture_2d_can_create = _cogl_texture_2d_gl_can_create; + driver_klass->texture_2d_init = _cogl_texture_2d_gl_init; + driver_klass->texture_2d_allocate = _cogl_texture_2d_gl_allocate; + driver_klass->texture_2d_copy_from_framebuffer = _cogl_texture_2d_gl_copy_from_framebuffer; + driver_klass->texture_2d_get_gl_handle = _cogl_texture_2d_gl_get_gl_handle; + driver_klass->texture_2d_generate_mipmap = _cogl_texture_2d_gl_generate_mipmap; + driver_klass->texture_2d_copy_from_bitmap = _cogl_texture_2d_gl_copy_from_bitmap; + driver_klass->texture_2d_is_get_data_supported = cogl_gl_texture_driver_is_get_data_supported; + driver_klass->texture_2d_get_data = _cogl_texture_2d_gl_get_data; } static void diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c index edc27e45e..e01e917a6 100644 --- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c +++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c @@ -853,12 +853,6 @@ _cogl_driver_update_features (CoglContext *context, return TRUE; } -static gboolean -_cogl_driver_texture_2d_is_get_data_supported (CoglTexture2D *tex_2d) -{ - return FALSE; -} - const CoglDriverVtable _cogl_driver_gles = { @@ -872,16 +866,6 @@ _cogl_driver_gles = _cogl_driver_update_features, _cogl_driver_gl_create_framebuffer_driver, _cogl_driver_gl_flush_framebuffer_state, - _cogl_texture_2d_gl_free, - _cogl_texture_2d_gl_can_create, - _cogl_texture_2d_gl_init, - _cogl_texture_2d_gl_allocate, - _cogl_texture_2d_gl_copy_from_framebuffer, - _cogl_texture_2d_gl_get_gl_handle, - _cogl_texture_2d_gl_generate_mipmap, - _cogl_texture_2d_gl_copy_from_bitmap, - _cogl_driver_texture_2d_is_get_data_supported, - NULL, /* texture_2d_get_data */ _cogl_gl_flush_attributes_state, _cogl_clip_stack_gl_flush, _cogl_buffer_gl_create, diff --git a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles2.c b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles2.c index 88260f7a8..9bbb124db 100644 --- a/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles2.c +++ b/cogl/cogl/driver/gl/gles/cogl-texture-driver-gles2.c @@ -46,6 +46,7 @@ #include "cogl/driver/gl/cogl-pipeline-opengl-private.h" #include "cogl/driver/gl/cogl-util-gl-private.h" #include "cogl/driver/gl/cogl-texture-gl-private.h" +#include "cogl/driver/gl/cogl-texture-2d-gl-private.h" #include "cogl/driver/gl/cogl-bitmap-gl-private.h" #include @@ -559,6 +560,13 @@ cogl_texture_driver_gles2_find_best_gl_get_data_format (CoglTextureDriver *drive return COGL_PIXEL_FORMAT_RGBA_8888; } +static gboolean +cogl_gles2_texture_driver_texture_2d_is_get_data_supported (CoglTextureDriver *driver, + CoglTexture2D *tex_2d) +{ + return FALSE; +} + static void cogl_texture_driver_gles2_class_init (CoglTextureDriverGLES2Class *klass) { @@ -572,6 +580,15 @@ cogl_texture_driver_gles2_class_init (CoglTextureDriverGLES2Class *klass) driver_klass->size_supported = cogl_texture_driver_gles2_size_supported; driver_klass->format_supports_upload = cogl_texture_driver_gles2_upload_supported; driver_klass->find_best_gl_get_data_format = cogl_texture_driver_gles2_find_best_gl_get_data_format; + driver_klass->texture_2d_free = _cogl_texture_2d_gl_free; + driver_klass->texture_2d_can_create = _cogl_texture_2d_gl_can_create; + driver_klass->texture_2d_init = _cogl_texture_2d_gl_init; + driver_klass->texture_2d_allocate = _cogl_texture_2d_gl_allocate; + driver_klass->texture_2d_copy_from_framebuffer = _cogl_texture_2d_gl_copy_from_framebuffer; + driver_klass->texture_2d_get_gl_handle = _cogl_texture_2d_gl_get_gl_handle; + driver_klass->texture_2d_generate_mipmap = _cogl_texture_2d_gl_generate_mipmap; + driver_klass->texture_2d_copy_from_bitmap = _cogl_texture_2d_gl_copy_from_bitmap; + driver_klass->texture_2d_is_get_data_supported = cogl_gles2_texture_driver_texture_2d_is_get_data_supported; } static void diff --git a/cogl/cogl/driver/nop/cogl-driver-nop.c b/cogl/cogl/driver/nop/cogl-driver-nop.c index 19f020ad5..5602c08b4 100644 --- a/cogl/cogl/driver/nop/cogl-driver-nop.c +++ b/cogl/cogl/driver/nop/cogl-driver-nop.c @@ -36,7 +36,6 @@ #include "cogl/cogl-context-private.h" #include "cogl/cogl-feature-private.h" #include "cogl/cogl-renderer-private.h" -#include "cogl/driver/nop/cogl-texture-2d-nop-private.h" #define COGL_TYPE_NOP_FRAMEBUFFER (cogl_nop_framebuffer_get_type ()) G_DECLARE_FINAL_TYPE (CoglNopFramebuffer, cogl_nop_framebuffer, @@ -102,16 +101,6 @@ _cogl_driver_nop = _cogl_driver_update_features, _cogl_driver_nop_create_framebuffer_driver, NULL, - _cogl_texture_2d_nop_free, - _cogl_texture_2d_nop_can_create, - _cogl_texture_2d_nop_init, - _cogl_texture_2d_nop_allocate, - _cogl_texture_2d_nop_copy_from_framebuffer, - _cogl_texture_2d_nop_get_gl_handle, - _cogl_texture_2d_nop_generate_mipmap, - _cogl_texture_2d_nop_copy_from_bitmap, - NULL, /* texture_2d_is_get_data_supported */ - NULL, /* texture_2d_get_data */ NULL, NULL, }; diff --git a/cogl/cogl/driver/nop/cogl-texture-2d-nop-private.h b/cogl/cogl/driver/nop/cogl-texture-2d-nop-private.h deleted file mode 100644 index 47ba365a8..000000000 --- a/cogl/cogl/driver/nop/cogl-texture-2d-nop-private.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2012 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * - * - * Authors: - * Robert Bragg - */ - -#pragma once - -#include "cogl/cogl-types.h" -#include "cogl/cogl-context-private.h" -#include "cogl/cogl-texture.h" - -void -_cogl_texture_2d_nop_free (CoglTexture2D *tex_2d); - -gboolean -_cogl_texture_2d_nop_can_create (CoglContext *ctx, - int width, - int height, - CoglPixelFormat internal_format); - -void -_cogl_texture_2d_nop_init (CoglTexture2D *tex_2d); - -gboolean -_cogl_texture_2d_nop_allocate (CoglTexture *tex, - GError **error); - -void -_cogl_texture_2d_nop_copy_from_framebuffer (CoglTexture2D *tex_2d, - int src_x, - int src_y, - int width, - int height, - CoglFramebuffer *src_fb, - int dst_x, - int dst_y, - int level); - -unsigned int -_cogl_texture_2d_nop_get_gl_handle (CoglTexture2D *tex_2d); - -void -_cogl_texture_2d_nop_generate_mipmap (CoglTexture2D *tex_2d); - -gboolean -_cogl_texture_2d_nop_copy_from_bitmap (CoglTexture2D *tex_2d, - int src_x, - int src_y, - int width, - int height, - CoglBitmap *bitmap, - int dst_x, - int dst_y, - int level, - GError **error); diff --git a/cogl/cogl/driver/nop/cogl-texture-2d-nop.c b/cogl/cogl/driver/nop/cogl-texture-2d-nop.c deleted file mode 100644 index cb0f2bd05..000000000 --- a/cogl/cogl/driver/nop/cogl-texture-2d-nop.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Cogl - * - * A Low Level GPU Graphics and Utilities API - * - * Copyright (C) 2009,2010,2011,2012 Intel Corporation. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * - * - * Authors: - * Neil Roberts - * Robert Bragg - */ - -#include "config.h" - -#include - -#include "cogl/cogl-private.h" -#include "cogl/driver/nop/cogl-texture-2d-nop-private.h" -#include "cogl/cogl-texture-2d-private.h" - -void -_cogl_texture_2d_nop_free (CoglTexture2D *tex_2d) -{ -} - -gboolean -_cogl_texture_2d_nop_can_create (CoglContext *ctx, - int width, - int height, - CoglPixelFormat internal_format) -{ - return TRUE; -} - -void -_cogl_texture_2d_nop_init (CoglTexture2D *tex_2d) -{ -} - -gboolean -_cogl_texture_2d_nop_allocate (CoglTexture *tex, - GError **error) -{ - return TRUE; -} - -void -_cogl_texture_2d_nop_copy_from_framebuffer (CoglTexture2D *tex_2d, - int src_x, - int src_y, - int width, - int height, - CoglFramebuffer *src_fb, - int dst_x, - int dst_y, - int level) -{ -} - -unsigned int -_cogl_texture_2d_nop_get_gl_handle (CoglTexture2D *tex_2d) -{ - return 0; -} - -void -_cogl_texture_2d_nop_generate_mipmap (CoglTexture2D *tex_2d) -{ -} - -gboolean -_cogl_texture_2d_nop_copy_from_bitmap (CoglTexture2D *tex_2d, - int src_x, - int src_y, - int width, - int height, - CoglBitmap *bitmap, - int dst_x, - int dst_y, - int level, - GError **error) -{ - return TRUE; -} diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build index 237677744..fdd82bf10 100644 --- a/cogl/cogl/meson.build +++ b/cogl/cogl/meson.build @@ -64,8 +64,6 @@ cogl_nodist_headers = [ cogl_noop_driver_sources = [ 'driver/nop/cogl-driver-nop.c', - 'driver/nop/cogl-texture-2d-nop-private.h', - 'driver/nop/cogl-texture-2d-nop.c', ] cogl_gl_prototype_headers = [