mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
Add _cogl_texture_get_type()
This adds an internal function to get the type of the underlying hardware texture for any CoglTexture. It can return one of three values to represent 2D textures, 3D textures or rectangle textures. The idea is that this can be used as a replacement for cogl_texture_get_gl_texture when only the target is required to make it a bit less GL-centric. The implementation adds a new virtual function which all of the texture backends now implement. The enum is in a public header because a later patch will want to use it from the CoglPipeline API. We may want to consider making the function public too later. Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
parent
9b87e8602c
commit
8012eee31f
@ -809,6 +809,12 @@ _cogl_atlas_texture_remove_reorganize_callback (GHookFunc callback,
|
||||
g_hook_destroy_link (&ctx->atlas_reorganize_callbacks, hook);
|
||||
}
|
||||
|
||||
static CoglTextureType
|
||||
_cogl_atlas_texture_get_type (CoglTexture *tex)
|
||||
{
|
||||
return COGL_TEXTURE_TYPE_2D;
|
||||
}
|
||||
|
||||
static const CoglTextureVtable
|
||||
cogl_atlas_texture_vtable =
|
||||
{
|
||||
@ -829,5 +835,6 @@ cogl_atlas_texture_vtable =
|
||||
_cogl_atlas_texture_get_gl_format,
|
||||
_cogl_atlas_texture_get_width,
|
||||
_cogl_atlas_texture_get_height,
|
||||
_cogl_atlas_texture_get_type,
|
||||
NULL /* is_foreign */
|
||||
};
|
||||
|
@ -416,6 +416,14 @@ _cogl_sub_texture_get_height (CoglTexture *tex)
|
||||
return sub_tex->sub_height;
|
||||
}
|
||||
|
||||
static CoglTextureType
|
||||
_cogl_sub_texture_get_type (CoglTexture *tex)
|
||||
{
|
||||
CoglSubTexture *sub_tex = COGL_SUB_TEXTURE (tex);
|
||||
|
||||
return _cogl_texture_get_type (sub_tex->full_texture);
|
||||
}
|
||||
|
||||
static const CoglTextureVtable
|
||||
cogl_sub_texture_vtable =
|
||||
{
|
||||
@ -436,5 +444,6 @@ cogl_sub_texture_vtable =
|
||||
_cogl_sub_texture_get_gl_format,
|
||||
_cogl_sub_texture_get_width,
|
||||
_cogl_sub_texture_get_height,
|
||||
_cogl_sub_texture_get_type,
|
||||
NULL /* is_foreign */
|
||||
};
|
||||
|
@ -1293,6 +1293,12 @@ _cogl_texture_2d_sliced_get_height (CoglTexture *tex)
|
||||
return COGL_TEXTURE_2D_SLICED (tex)->height;
|
||||
}
|
||||
|
||||
static CoglTextureType
|
||||
_cogl_texture_2d_sliced_get_type (CoglTexture *tex)
|
||||
{
|
||||
return COGL_TEXTURE_TYPE_2D;
|
||||
}
|
||||
|
||||
static const CoglTextureVtable
|
||||
cogl_texture_2d_sliced_vtable =
|
||||
{
|
||||
@ -1313,5 +1319,6 @@ cogl_texture_2d_sliced_vtable =
|
||||
_cogl_texture_2d_sliced_get_gl_format,
|
||||
_cogl_texture_2d_sliced_get_width,
|
||||
_cogl_texture_2d_sliced_get_height,
|
||||
_cogl_texture_2d_sliced_get_type,
|
||||
_cogl_texture_2d_sliced_is_foreign
|
||||
};
|
||||
|
@ -859,6 +859,12 @@ _cogl_texture_2d_is_foreign (CoglTexture *tex)
|
||||
return COGL_TEXTURE_2D (tex)->is_foreign;
|
||||
}
|
||||
|
||||
static CoglTextureType
|
||||
_cogl_texture_2d_get_type (CoglTexture *tex)
|
||||
{
|
||||
return COGL_TEXTURE_TYPE_2D;
|
||||
}
|
||||
|
||||
static const CoglTextureVtable
|
||||
cogl_texture_2d_vtable =
|
||||
{
|
||||
@ -879,5 +885,6 @@ cogl_texture_2d_vtable =
|
||||
_cogl_texture_2d_get_gl_format,
|
||||
_cogl_texture_2d_get_width,
|
||||
_cogl_texture_2d_get_height,
|
||||
_cogl_texture_2d_get_type,
|
||||
_cogl_texture_2d_is_foreign
|
||||
};
|
||||
|
@ -592,6 +592,12 @@ _cogl_texture_3d_get_height (CoglTexture *tex)
|
||||
return COGL_TEXTURE_3D (tex)->height;
|
||||
}
|
||||
|
||||
static CoglTextureType
|
||||
_cogl_texture_3d_get_type (CoglTexture *tex)
|
||||
{
|
||||
return COGL_TEXTURE_TYPE_3D;
|
||||
}
|
||||
|
||||
static const CoglTextureVtable
|
||||
cogl_texture_3d_vtable =
|
||||
{
|
||||
@ -612,5 +618,6 @@ cogl_texture_3d_vtable =
|
||||
_cogl_texture_3d_get_gl_format,
|
||||
_cogl_texture_3d_get_width,
|
||||
_cogl_texture_3d_get_height,
|
||||
_cogl_texture_3d_get_type,
|
||||
NULL /* is_foreign */
|
||||
};
|
||||
|
@ -121,6 +121,8 @@ struct _CoglTextureVtable
|
||||
int (* get_width) (CoglTexture *tex);
|
||||
int (* get_height) (CoglTexture *tex);
|
||||
|
||||
CoglTextureType (* get_type) (CoglTexture *tex);
|
||||
|
||||
gboolean (* is_foreign) (CoglTexture *tex);
|
||||
};
|
||||
|
||||
@ -274,4 +276,16 @@ _cogl_texture_spans_foreach_in_region (CoglSpan *x_spans,
|
||||
CoglMetaTextureCallback callback,
|
||||
void *user_data);
|
||||
|
||||
/*
|
||||
* _cogl_texture_get_type:
|
||||
* @texture: a #CoglTexture pointer
|
||||
*
|
||||
* Retrieves the texture type of the underlying hardware texture that
|
||||
* this #CoglTexture will use.
|
||||
*
|
||||
* Return value: The type of the hardware texture.
|
||||
*/
|
||||
CoglTextureType
|
||||
_cogl_texture_get_type (CoglTexture *texture);
|
||||
|
||||
#endif /* __COGL_TEXTURE_PRIVATE_H */
|
||||
|
@ -579,6 +579,12 @@ _cogl_texture_rectangle_is_foreign (CoglTexture *tex)
|
||||
return COGL_TEXTURE_RECTANGLE (tex)->is_foreign;
|
||||
}
|
||||
|
||||
static CoglTextureType
|
||||
_cogl_texture_rectangle_get_type (CoglTexture *tex)
|
||||
{
|
||||
return COGL_TEXTURE_TYPE_RECTANGLE;
|
||||
}
|
||||
|
||||
static const CoglTextureVtable
|
||||
cogl_texture_rectangle_vtable =
|
||||
{
|
||||
@ -599,5 +605,6 @@ cogl_texture_rectangle_vtable =
|
||||
_cogl_texture_rectangle_get_gl_format,
|
||||
_cogl_texture_rectangle_get_width,
|
||||
_cogl_texture_rectangle_get_height,
|
||||
_cogl_texture_rectangle_get_type,
|
||||
_cogl_texture_rectangle_is_foreign
|
||||
};
|
||||
|
@ -643,6 +643,12 @@ cogl_texture_get_gl_texture (CoglTexture *texture,
|
||||
out_gl_handle, out_gl_target);
|
||||
}
|
||||
|
||||
CoglTextureType
|
||||
_cogl_texture_get_type (CoglTexture *texture)
|
||||
{
|
||||
return texture->vtable->get_type (texture);
|
||||
}
|
||||
|
||||
void
|
||||
_cogl_texture_set_filters (CoglTexture *texture,
|
||||
GLenum min_filter,
|
||||
|
@ -78,6 +78,24 @@ typedef enum {
|
||||
COGL_TEXTURE_ERROR_TYPE
|
||||
} CoglTextureError;
|
||||
|
||||
/**
|
||||
* CoglTextureType:
|
||||
* @COGL_TEXTURE_TYPE_2D: A #CoglTexture2D
|
||||
* @COGL_TEXTURE_TYPE_3D: A #CoglTexture3D
|
||||
* @COGL_TEXTURE_TYPE_RECTANGLE: A #CoglTextureRectangle
|
||||
*
|
||||
* Constants representing the underlying hardware texture type of a
|
||||
* #CoglTexture.
|
||||
*
|
||||
* Stability: unstable
|
||||
* Since: 1.10
|
||||
*/
|
||||
typedef enum {
|
||||
COGL_TEXTURE_TYPE_2D,
|
||||
COGL_TEXTURE_TYPE_3D,
|
||||
COGL_TEXTURE_TYPE_RECTANGLE
|
||||
} CoglTextureType;
|
||||
|
||||
GQuark cogl_texture_error_quark (void);
|
||||
|
||||
/**
|
||||
|
@ -998,6 +998,18 @@ _cogl_texture_pixmap_x11_get_height (CoglTexture *tex)
|
||||
return tex_pixmap->height;
|
||||
}
|
||||
|
||||
static CoglTextureType
|
||||
_cogl_texture_pixmap_x11_get_type (CoglTexture *tex)
|
||||
{
|
||||
CoglTexturePixmapX11 *tex_pixmap = COGL_TEXTURE_PIXMAP_X11 (tex);
|
||||
CoglTexture *child_tex;
|
||||
|
||||
child_tex = _cogl_texture_pixmap_x11_get_texture (tex_pixmap);
|
||||
|
||||
/* Forward on to the child texture */
|
||||
return _cogl_texture_get_type (child_tex);
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_texture_pixmap_x11_free (CoglTexturePixmapX11 *tex_pixmap)
|
||||
{
|
||||
@ -1049,5 +1061,6 @@ cogl_texture_pixmap_x11_vtable =
|
||||
_cogl_texture_pixmap_x11_get_gl_format,
|
||||
_cogl_texture_pixmap_x11_get_width,
|
||||
_cogl_texture_pixmap_x11_get_height,
|
||||
_cogl_texture_pixmap_x11_get_type,
|
||||
NULL /* is_foreign */
|
||||
};
|
||||
|
@ -318,6 +318,7 @@ cogl_texture_get_format
|
||||
cogl_texture_is_sliced
|
||||
cogl_texture_get_data
|
||||
cogl_texture_set_region
|
||||
CoglTextureType
|
||||
|
||||
<SUBSECTION Private>
|
||||
COGL_TEXTURE_MAX_WASTE
|
||||
|
Loading…
Reference in New Issue
Block a user