texture: Add a context pointer to each texture
As part of our on-going goal to remove our dependence on a global Cogl context this patch adds a pointer to the context to each CoglTexture so that the various texture apis no longer need to use _COGL_GET_CONTEXT. Reviewed-by: Neil Roberts <neil@linux.intel.com> (cherry picked from commit 83131072eea395f18ab0525ea2446f443a6033b1)
This commit is contained in:
parent
ea3d8eca91
commit
0f0ee4a909
@ -685,6 +685,7 @@ _cogl_atlas_texture_new_with_size (unsigned int width,
|
|||||||
atlas_tex->atlas = NULL;
|
atlas_tex->atlas = NULL;
|
||||||
|
|
||||||
_cogl_texture_init (COGL_TEXTURE (atlas_tex),
|
_cogl_texture_init (COGL_TEXTURE (atlas_tex),
|
||||||
|
ctx,
|
||||||
&cogl_atlas_texture_vtable);
|
&cogl_atlas_texture_vtable);
|
||||||
|
|
||||||
atlas_tex->sub_texture = NULL;
|
atlas_tex->sub_texture = NULL;
|
||||||
|
@ -230,7 +230,7 @@ cogl_sub_texture_new (CoglContext *ctx,
|
|||||||
|
|
||||||
tex = COGL_TEXTURE (sub_tex);
|
tex = COGL_TEXTURE (sub_tex);
|
||||||
|
|
||||||
_cogl_texture_init (tex, &cogl_sub_texture_vtable);
|
_cogl_texture_init (tex, ctx, &cogl_sub_texture_vtable);
|
||||||
|
|
||||||
/* If the next texture is also a sub texture we can avoid one level
|
/* If the next texture is also a sub texture we can avoid one level
|
||||||
of indirection by referencing the full texture of that texture
|
of indirection by referencing the full texture of that texture
|
||||||
|
@ -175,8 +175,7 @@ _cogl_texture_2d_sliced_set_waste (CoglTexture2DSliced *tex_2ds,
|
|||||||
int dst_y)
|
int dst_y)
|
||||||
{
|
{
|
||||||
CoglBool need_x, need_y;
|
CoglBool need_x, need_y;
|
||||||
|
CoglContext *ctx = COGL_TEXTURE (tex_2ds)->context;
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
/* If the x_span is sliced and the upload touches the
|
/* If the x_span is sliced and the upload touches the
|
||||||
rightmost pixels then fill the waste with copies of the
|
rightmost pixels then fill the waste with copies of the
|
||||||
@ -818,7 +817,7 @@ _cogl_texture_2d_sliced_init_base (CoglContext *ctx,
|
|||||||
{
|
{
|
||||||
CoglTexture *tex = COGL_TEXTURE (tex_2ds);
|
CoglTexture *tex = COGL_TEXTURE (tex_2ds);
|
||||||
|
|
||||||
_cogl_texture_init (tex, &cogl_texture_2d_sliced_vtable);
|
_cogl_texture_init (tex, ctx, &cogl_texture_2d_sliced_vtable);
|
||||||
|
|
||||||
tex_2ds->slice_x_spans = NULL;
|
tex_2ds->slice_x_spans = NULL;
|
||||||
tex_2ds->slice_y_spans = NULL;
|
tex_2ds->slice_y_spans = NULL;
|
||||||
@ -1243,10 +1242,8 @@ _cogl_texture_2d_sliced_set_region (CoglTexture *tex,
|
|||||||
CoglBitmap *bmp)
|
CoglBitmap *bmp)
|
||||||
{
|
{
|
||||||
CoglTexture2DSliced *tex_2ds = COGL_TEXTURE_2D_SLICED (tex);
|
CoglTexture2DSliced *tex_2ds = COGL_TEXTURE_2D_SLICED (tex);
|
||||||
GLenum gl_format;
|
GLenum gl_format;
|
||||||
GLenum gl_type;
|
GLenum gl_type;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
bmp = _cogl_texture_prepare_for_upload (bmp,
|
bmp = _cogl_texture_prepare_for_upload (bmp,
|
||||||
cogl_texture_get_format (tex),
|
cogl_texture_get_format (tex),
|
||||||
|
@ -69,8 +69,7 @@ _cogl_texture_2d_set_wrap_mode_parameters (CoglTexture *tex,
|
|||||||
GLenum wrap_mode_p)
|
GLenum wrap_mode_p)
|
||||||
{
|
{
|
||||||
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
||||||
|
CoglContext *ctx = tex->context;
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
/* Only set the wrap mode if it's different from the current value
|
/* Only set the wrap mode if it's different from the current value
|
||||||
to avoid too many GL calls. Texture 2D doesn't make use of the r
|
to avoid too many GL calls. Texture 2D doesn't make use of the r
|
||||||
@ -104,7 +103,8 @@ _cogl_texture_2d_free (CoglTexture2D *tex_2d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CoglBool
|
static CoglBool
|
||||||
_cogl_texture_2d_can_create (unsigned int width,
|
_cogl_texture_2d_can_create (CoglContext *ctx,
|
||||||
|
unsigned int width,
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
CoglPixelFormat internal_format)
|
CoglPixelFormat internal_format)
|
||||||
{
|
{
|
||||||
@ -112,8 +112,6 @@ _cogl_texture_2d_can_create (unsigned int width,
|
|||||||
GLenum gl_format;
|
GLenum gl_format;
|
||||||
GLenum gl_type;
|
GLenum gl_type;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
/* If NPOT textures aren't supported then the size must be a power
|
/* If NPOT textures aren't supported then the size must be a power
|
||||||
of two */
|
of two */
|
||||||
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
|
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_BASIC) &&
|
||||||
@ -150,14 +148,15 @@ _cogl_texture_2d_set_auto_mipmap (CoglTexture *tex,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CoglTexture2D *
|
static CoglTexture2D *
|
||||||
_cogl_texture_2d_create_base (unsigned int width,
|
_cogl_texture_2d_create_base (CoglContext *ctx,
|
||||||
unsigned int height,
|
int width,
|
||||||
CoglPixelFormat internal_format)
|
int height,
|
||||||
|
CoglPixelFormat internal_format)
|
||||||
{
|
{
|
||||||
CoglTexture2D *tex_2d = g_new (CoglTexture2D, 1);
|
CoglTexture2D *tex_2d = g_new (CoglTexture2D, 1);
|
||||||
CoglTexture *tex = COGL_TEXTURE (tex_2d);
|
CoglTexture *tex = COGL_TEXTURE (tex_2d);
|
||||||
|
|
||||||
_cogl_texture_init (tex, &cogl_texture_2d_vtable);
|
_cogl_texture_init (tex, ctx, &cogl_texture_2d_vtable);
|
||||||
|
|
||||||
tex_2d->width = width;
|
tex_2d->width = width;
|
||||||
tex_2d->height = height;
|
tex_2d->height = height;
|
||||||
@ -195,7 +194,7 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
|
|||||||
if (internal_format == COGL_PIXEL_FORMAT_ANY)
|
if (internal_format == COGL_PIXEL_FORMAT_ANY)
|
||||||
internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
|
internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
|
||||||
|
|
||||||
if (!_cogl_texture_2d_can_create (width, height, internal_format))
|
if (!_cogl_texture_2d_can_create (ctx, width, height, internal_format))
|
||||||
{
|
{
|
||||||
g_set_error (error, COGL_TEXTURE_ERROR,
|
g_set_error (error, COGL_TEXTURE_ERROR,
|
||||||
COGL_TEXTURE_ERROR_SIZE,
|
COGL_TEXTURE_ERROR_SIZE,
|
||||||
@ -210,7 +209,8 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
|
|||||||
&gl_format,
|
&gl_format,
|
||||||
&gl_type);
|
&gl_type);
|
||||||
|
|
||||||
tex_2d = _cogl_texture_2d_create_base (width, height,
|
tex_2d = _cogl_texture_2d_create_base (ctx,
|
||||||
|
width, height,
|
||||||
internal_format);
|
internal_format);
|
||||||
|
|
||||||
ctx->texture_driver->gen (ctx, GL_TEXTURE_2D, 1, &tex_2d->gl_texture);
|
ctx->texture_driver->gen (ctx, GL_TEXTURE_2D, 1, &tex_2d->gl_texture);
|
||||||
@ -244,7 +244,8 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
|
|||||||
_cogl_texture_determine_internal_format (cogl_bitmap_get_format (bmp),
|
_cogl_texture_determine_internal_format (cogl_bitmap_get_format (bmp),
|
||||||
internal_format);
|
internal_format);
|
||||||
|
|
||||||
if (!_cogl_texture_2d_can_create (cogl_bitmap_get_width (bmp),
|
if (!_cogl_texture_2d_can_create (ctx,
|
||||||
|
cogl_bitmap_get_width (bmp),
|
||||||
cogl_bitmap_get_height (bmp),
|
cogl_bitmap_get_height (bmp),
|
||||||
internal_format))
|
internal_format))
|
||||||
{
|
{
|
||||||
@ -269,7 +270,8 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tex_2d = _cogl_texture_2d_create_base (cogl_bitmap_get_width (bmp),
|
tex_2d = _cogl_texture_2d_create_base (ctx,
|
||||||
|
cogl_bitmap_get_width (bmp),
|
||||||
cogl_bitmap_get_height (bmp),
|
cogl_bitmap_get_height (bmp),
|
||||||
internal_format);
|
internal_format);
|
||||||
|
|
||||||
@ -463,7 +465,8 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx,
|
|||||||
the dirtiness tracking that Cogl would do. */
|
the dirtiness tracking that Cogl would do. */
|
||||||
|
|
||||||
/* Create new texture */
|
/* Create new texture */
|
||||||
tex_2d = _cogl_texture_2d_create_base (width, height,
|
tex_2d = _cogl_texture_2d_create_base (ctx,
|
||||||
|
width, height,
|
||||||
format);
|
format);
|
||||||
_cogl_texture_2d_set_auto_mipmap (COGL_TEXTURE (tex_2d), FALSE);
|
_cogl_texture_2d_set_auto_mipmap (COGL_TEXTURE (tex_2d), FALSE);
|
||||||
|
|
||||||
@ -506,7 +509,8 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
|
|||||||
COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE,
|
COGL_PRIVATE_FEATURE_TEXTURE_2D_FROM_EGL_IMAGE,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
tex_2d = _cogl_texture_2d_create_base (width, height,
|
tex_2d = _cogl_texture_2d_create_base (ctx,
|
||||||
|
width, height,
|
||||||
format);
|
format);
|
||||||
|
|
||||||
ctx->texture_driver->gen (ctx, GL_TEXTURE_2D, 1, &tex_2d->gl_texture);
|
ctx->texture_driver->gen (ctx, GL_TEXTURE_2D, 1, &tex_2d->gl_texture);
|
||||||
@ -617,10 +621,12 @@ _cogl_texture_2d_copy_from_framebuffer (CoglTexture2D *tex_2d,
|
|||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
CoglContext *ctx;
|
||||||
|
|
||||||
_COGL_RETURN_IF_FAIL (cogl_is_texture_2d (tex_2d));
|
_COGL_RETURN_IF_FAIL (cogl_is_texture_2d (tex_2d));
|
||||||
|
|
||||||
|
ctx = COGL_TEXTURE (tex_2d)->context;
|
||||||
|
|
||||||
/* Make sure the current framebuffers are bound, though we don't need to
|
/* Make sure the current framebuffers are bound, though we don't need to
|
||||||
* flush the clip state here since we aren't going to draw to the
|
* flush the clip state here since we aren't going to draw to the
|
||||||
* framebuffer. */
|
* framebuffer. */
|
||||||
@ -658,8 +664,7 @@ static CoglBool
|
|||||||
_cogl_texture_2d_can_hardware_repeat (CoglTexture *tex)
|
_cogl_texture_2d_can_hardware_repeat (CoglTexture *tex)
|
||||||
{
|
{
|
||||||
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
||||||
|
CoglContext *ctx = tex->context;
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT) ||
|
if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT) ||
|
||||||
(_cogl_util_is_pot (tex_2d->width) &&
|
(_cogl_util_is_pot (tex_2d->width) &&
|
||||||
@ -722,8 +727,7 @@ _cogl_texture_2d_set_filters (CoglTexture *tex,
|
|||||||
GLenum mag_filter)
|
GLenum mag_filter)
|
||||||
{
|
{
|
||||||
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
||||||
|
CoglContext *ctx = tex->context;
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
if (min_filter == tex_2d->min_filter
|
if (min_filter == tex_2d->min_filter
|
||||||
&& mag_filter == tex_2d->mag_filter)
|
&& mag_filter == tex_2d->mag_filter)
|
||||||
@ -745,8 +749,7 @@ static void
|
|||||||
_cogl_texture_2d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
|
_cogl_texture_2d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
|
||||||
{
|
{
|
||||||
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
||||||
|
CoglContext *ctx = tex->context;
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
/* Only update if the mipmaps are dirty */
|
/* Only update if the mipmaps are dirty */
|
||||||
if ((flags & COGL_TEXTURE_NEEDS_MIPMAP) &&
|
if ((flags & COGL_TEXTURE_NEEDS_MIPMAP) &&
|
||||||
@ -798,12 +801,11 @@ _cogl_texture_2d_set_region (CoglTexture *tex,
|
|||||||
CoglBitmap *bmp)
|
CoglBitmap *bmp)
|
||||||
{
|
{
|
||||||
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
||||||
|
CoglContext *ctx = tex->context;
|
||||||
GLenum gl_format;
|
GLenum gl_format;
|
||||||
GLenum gl_type;
|
GLenum gl_type;
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
bmp = _cogl_texture_prepare_for_upload (bmp,
|
bmp = _cogl_texture_prepare_for_upload (bmp,
|
||||||
cogl_texture_get_format (tex),
|
cogl_texture_get_format (tex),
|
||||||
NULL,
|
NULL,
|
||||||
@ -852,12 +854,11 @@ _cogl_texture_2d_get_data (CoglTexture *tex,
|
|||||||
unsigned int rowstride,
|
unsigned int rowstride,
|
||||||
uint8_t *data)
|
uint8_t *data)
|
||||||
{
|
{
|
||||||
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
CoglTexture2D *tex_2d = COGL_TEXTURE_2D (tex);
|
||||||
int bpp;
|
CoglContext *ctx = tex->context;
|
||||||
GLenum gl_format;
|
int bpp;
|
||||||
GLenum gl_type;
|
GLenum gl_format;
|
||||||
|
GLenum gl_type;
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
|
bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
|
||||||
|
|
||||||
|
@ -62,8 +62,7 @@ _cogl_texture_3d_set_wrap_mode_parameters (CoglTexture *tex,
|
|||||||
GLenum wrap_mode_p)
|
GLenum wrap_mode_p)
|
||||||
{
|
{
|
||||||
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
|
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
|
||||||
|
CoglContext *ctx = tex->context;
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
/* Only set the wrap mode if it's different from the current value
|
/* Only set the wrap mode if it's different from the current value
|
||||||
to avoid too many GL calls. */
|
to avoid too many GL calls. */
|
||||||
@ -118,7 +117,7 @@ _cogl_texture_3d_create_base (CoglContext *ctx,
|
|||||||
CoglTexture3D *tex_3d = g_new (CoglTexture3D, 1);
|
CoglTexture3D *tex_3d = g_new (CoglTexture3D, 1);
|
||||||
CoglTexture *tex = COGL_TEXTURE (tex_3d);
|
CoglTexture *tex = COGL_TEXTURE (tex_3d);
|
||||||
|
|
||||||
_cogl_texture_init (tex, &cogl_texture_3d_vtable);
|
_cogl_texture_init (tex, ctx, &cogl_texture_3d_vtable);
|
||||||
|
|
||||||
tex_3d->width = width;
|
tex_3d->width = width;
|
||||||
tex_3d->height = height;
|
tex_3d->height = height;
|
||||||
@ -485,8 +484,7 @@ _cogl_texture_3d_set_filters (CoglTexture *tex,
|
|||||||
GLenum mag_filter)
|
GLenum mag_filter)
|
||||||
{
|
{
|
||||||
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
|
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
|
||||||
|
CoglContext *ctx = tex->context;
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
if (min_filter == tex_3d->min_filter
|
if (min_filter == tex_3d->min_filter
|
||||||
&& mag_filter == tex_3d->mag_filter)
|
&& mag_filter == tex_3d->mag_filter)
|
||||||
@ -508,8 +506,7 @@ static void
|
|||||||
_cogl_texture_3d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
|
_cogl_texture_3d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
|
||||||
{
|
{
|
||||||
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
|
CoglTexture3D *tex_3d = COGL_TEXTURE_3D (tex);
|
||||||
|
CoglContext *ctx = tex->context;
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
/* Only update if the mipmaps are dirty */
|
/* Only update if the mipmaps are dirty */
|
||||||
if ((flags & COGL_TEXTURE_NEEDS_MIPMAP) &&
|
if ((flags & COGL_TEXTURE_NEEDS_MIPMAP) &&
|
||||||
|
@ -136,8 +136,9 @@ struct _CoglTextureVtable
|
|||||||
|
|
||||||
struct _CoglTexture
|
struct _CoglTexture
|
||||||
{
|
{
|
||||||
CoglObject _parent;
|
CoglObject _parent;
|
||||||
GList *framebuffers;
|
CoglContext *context;
|
||||||
|
GList *framebuffers;
|
||||||
const CoglTextureVtable *vtable;
|
const CoglTextureVtable *vtable;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -170,6 +171,7 @@ struct _CoglTexturePixel
|
|||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_init (CoglTexture *texture,
|
_cogl_texture_init (CoglTexture *texture,
|
||||||
|
CoglContext *ctx,
|
||||||
const CoglTextureVtable *vtable);
|
const CoglTextureVtable *vtable);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -73,8 +73,7 @@ _cogl_texture_rectangle_set_wrap_mode_parameters (CoglTexture *tex,
|
|||||||
GLenum wrap_mode_p)
|
GLenum wrap_mode_p)
|
||||||
{
|
{
|
||||||
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
|
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
|
||||||
|
CoglContext *ctx = tex->context;
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
/* Only set the wrap mode if it's different from the current value
|
/* Only set the wrap mode if it's different from the current value
|
||||||
to avoid too many GL calls. Texture rectangle doesn't make use of
|
to avoid too many GL calls. Texture rectangle doesn't make use of
|
||||||
@ -109,7 +108,8 @@ _cogl_texture_rectangle_free (CoglTextureRectangle *tex_rect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CoglBool
|
static CoglBool
|
||||||
_cogl_texture_rectangle_can_create (unsigned int width,
|
_cogl_texture_rectangle_can_create (CoglContext *ctx,
|
||||||
|
unsigned int width,
|
||||||
unsigned int height,
|
unsigned int height,
|
||||||
CoglPixelFormat internal_format,
|
CoglPixelFormat internal_format,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -118,8 +118,6 @@ _cogl_texture_rectangle_can_create (unsigned int width,
|
|||||||
GLenum gl_format;
|
GLenum gl_format;
|
||||||
GLenum gl_type;
|
GLenum gl_type;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE))
|
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE))
|
||||||
{
|
{
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
@ -163,14 +161,15 @@ _cogl_texture_rectangle_set_auto_mipmap (CoglTexture *tex,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static CoglTextureRectangle *
|
static CoglTextureRectangle *
|
||||||
_cogl_texture_rectangle_create_base (unsigned int width,
|
_cogl_texture_rectangle_create_base (CoglContext *ctx,
|
||||||
unsigned int height,
|
int width,
|
||||||
CoglPixelFormat internal_format)
|
int height,
|
||||||
|
CoglPixelFormat internal_format)
|
||||||
{
|
{
|
||||||
CoglTextureRectangle *tex_rect = g_new (CoglTextureRectangle, 1);
|
CoglTextureRectangle *tex_rect = g_new (CoglTextureRectangle, 1);
|
||||||
CoglTexture *tex = COGL_TEXTURE (tex_rect);
|
CoglTexture *tex = COGL_TEXTURE (tex_rect);
|
||||||
|
|
||||||
_cogl_texture_init (tex, &cogl_texture_rectangle_vtable);
|
_cogl_texture_init (tex, ctx, &cogl_texture_rectangle_vtable);
|
||||||
|
|
||||||
tex_rect->width = width;
|
tex_rect->width = width;
|
||||||
tex_rect->height = height;
|
tex_rect->height = height;
|
||||||
@ -204,7 +203,8 @@ cogl_texture_rectangle_new_with_size (CoglContext *ctx,
|
|||||||
if (internal_format == COGL_PIXEL_FORMAT_ANY)
|
if (internal_format == COGL_PIXEL_FORMAT_ANY)
|
||||||
internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
|
internal_format = COGL_PIXEL_FORMAT_RGBA_8888_PRE;
|
||||||
|
|
||||||
if (!_cogl_texture_rectangle_can_create (width, height,
|
if (!_cogl_texture_rectangle_can_create (ctx,
|
||||||
|
width, height,
|
||||||
internal_format, error))
|
internal_format, error))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -214,7 +214,8 @@ cogl_texture_rectangle_new_with_size (CoglContext *ctx,
|
|||||||
&gl_format,
|
&gl_format,
|
||||||
&gl_type);
|
&gl_type);
|
||||||
|
|
||||||
tex_rect = _cogl_texture_rectangle_create_base (width, height,
|
tex_rect = _cogl_texture_rectangle_create_base (ctx,
|
||||||
|
width, height,
|
||||||
internal_format);
|
internal_format);
|
||||||
|
|
||||||
ctx->texture_driver->gen (ctx,
|
ctx->texture_driver->gen (ctx,
|
||||||
@ -250,7 +251,8 @@ cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp,
|
|||||||
_cogl_texture_determine_internal_format (cogl_bitmap_get_format (bmp),
|
_cogl_texture_determine_internal_format (cogl_bitmap_get_format (bmp),
|
||||||
internal_format);
|
internal_format);
|
||||||
|
|
||||||
if (!_cogl_texture_rectangle_can_create (cogl_bitmap_get_width (bmp),
|
if (!_cogl_texture_rectangle_can_create (ctx,
|
||||||
|
cogl_bitmap_get_width (bmp),
|
||||||
cogl_bitmap_get_height (bmp),
|
cogl_bitmap_get_height (bmp),
|
||||||
internal_format,
|
internal_format,
|
||||||
error))
|
error))
|
||||||
@ -266,7 +268,8 @@ cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp,
|
|||||||
if (dst_bmp == NULL)
|
if (dst_bmp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
tex_rect = _cogl_texture_rectangle_create_base (cogl_bitmap_get_width (bmp),
|
tex_rect = _cogl_texture_rectangle_create_base (ctx,
|
||||||
|
cogl_bitmap_get_width (bmp),
|
||||||
cogl_bitmap_get_height (bmp),
|
cogl_bitmap_get_height (bmp),
|
||||||
internal_format);
|
internal_format);
|
||||||
|
|
||||||
@ -375,7 +378,7 @@ _cogl_texture_rectangle_new_from_foreign (GLuint gl_handle,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Create new texture */
|
/* Create new texture */
|
||||||
tex_rect = _cogl_texture_rectangle_create_base (width, height, format);
|
tex_rect = _cogl_texture_rectangle_create_base (ctx, width, height, format);
|
||||||
|
|
||||||
/* Setup bitmap info */
|
/* Setup bitmap info */
|
||||||
tex_rect->is_foreign = TRUE;
|
tex_rect->is_foreign = TRUE;
|
||||||
@ -462,8 +465,7 @@ _cogl_texture_rectangle_set_filters (CoglTexture *tex,
|
|||||||
GLenum mag_filter)
|
GLenum mag_filter)
|
||||||
{
|
{
|
||||||
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
|
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
|
||||||
|
CoglContext *ctx = tex->context;
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
if (min_filter == tex_rect->min_filter
|
if (min_filter == tex_rect->min_filter
|
||||||
&& mag_filter == tex_rect->mag_filter)
|
&& mag_filter == tex_rect->mag_filter)
|
||||||
@ -490,8 +492,6 @@ static void
|
|||||||
_cogl_texture_rectangle_pre_paint (CoglTexture *tex,
|
_cogl_texture_rectangle_pre_paint (CoglTexture *tex,
|
||||||
CoglTexturePrePaintFlags flags)
|
CoglTexturePrePaintFlags flags)
|
||||||
{
|
{
|
||||||
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
|
|
||||||
|
|
||||||
/* Rectangle textures don't support mipmaps */
|
/* Rectangle textures don't support mipmaps */
|
||||||
g_assert ((flags & COGL_TEXTURE_NEEDS_MIPMAP) == 0);
|
g_assert ((flags & COGL_TEXTURE_NEEDS_MIPMAP) == 0);
|
||||||
}
|
}
|
||||||
@ -513,10 +513,9 @@ _cogl_texture_rectangle_set_region (CoglTexture *tex,
|
|||||||
CoglBitmap *bmp)
|
CoglBitmap *bmp)
|
||||||
{
|
{
|
||||||
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
|
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
|
||||||
GLenum gl_format;
|
GLenum gl_format;
|
||||||
GLenum gl_type;
|
GLenum gl_type;
|
||||||
|
CoglContext *ctx = tex->context;
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
bmp = _cogl_texture_prepare_for_upload (bmp,
|
bmp = _cogl_texture_prepare_for_upload (bmp,
|
||||||
cogl_texture_get_format (tex),
|
cogl_texture_get_format (tex),
|
||||||
@ -549,11 +548,10 @@ _cogl_texture_rectangle_get_data (CoglTexture *tex,
|
|||||||
uint8_t *data)
|
uint8_t *data)
|
||||||
{
|
{
|
||||||
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
|
CoglTextureRectangle *tex_rect = COGL_TEXTURE_RECTANGLE (tex);
|
||||||
int bpp;
|
CoglContext *ctx = tex->context;
|
||||||
GLenum gl_format;
|
int bpp;
|
||||||
GLenum gl_type;
|
GLenum gl_format;
|
||||||
|
GLenum gl_type;
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
|
bpp = _cogl_pixel_format_get_bytes_per_pixel (format);
|
||||||
|
|
||||||
|
@ -128,8 +128,10 @@ cogl_texture_unref (void *object)
|
|||||||
|
|
||||||
void
|
void
|
||||||
_cogl_texture_init (CoglTexture *texture,
|
_cogl_texture_init (CoglTexture *texture,
|
||||||
|
CoglContext *context,
|
||||||
const CoglTextureVtable *vtable)
|
const CoglTextureVtable *vtable)
|
||||||
{
|
{
|
||||||
|
texture->context = context;
|
||||||
texture->vtable = vtable;
|
texture->vtable = vtable;
|
||||||
texture->framebuffers = NULL;
|
texture->framebuffers = NULL;
|
||||||
}
|
}
|
||||||
@ -721,10 +723,9 @@ cogl_texture_set_region (CoglTexture *texture,
|
|||||||
unsigned int rowstride,
|
unsigned int rowstride,
|
||||||
const uint8_t *data)
|
const uint8_t *data)
|
||||||
{
|
{
|
||||||
|
CoglContext *ctx = texture->context;
|
||||||
CoglBitmap *source_bmp;
|
CoglBitmap *source_bmp;
|
||||||
CoglBool ret;
|
CoglBool ret;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
_COGL_RETURN_VAL_IF_FAIL ((width - src_x) >= dst_width, FALSE);
|
_COGL_RETURN_VAL_IF_FAIL ((width - src_x) >= dst_width, FALSE);
|
||||||
_COGL_RETURN_VAL_IF_FAIL ((height - src_y) >= dst_height, FALSE);
|
_COGL_RETURN_VAL_IF_FAIL ((height - src_y) >= dst_height, FALSE);
|
||||||
@ -1010,13 +1011,12 @@ get_texture_bits_via_offscreen (CoglTexture *texture,
|
|||||||
unsigned int dst_rowstride,
|
unsigned int dst_rowstride,
|
||||||
CoglPixelFormat dst_format)
|
CoglPixelFormat dst_format)
|
||||||
{
|
{
|
||||||
|
CoglContext *ctx = texture->context;
|
||||||
CoglOffscreen *offscreen;
|
CoglOffscreen *offscreen;
|
||||||
CoglFramebuffer *framebuffer;
|
CoglFramebuffer *framebuffer;
|
||||||
CoglBitmap *bitmap;
|
CoglBitmap *bitmap;
|
||||||
CoglBool ret;
|
CoglBool ret;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, FALSE);
|
|
||||||
|
|
||||||
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
|
if (!cogl_has_feature (ctx, COGL_FEATURE_ID_OFFSCREEN))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -1175,20 +1175,19 @@ cogl_texture_get_data (CoglTexture *texture,
|
|||||||
unsigned int rowstride,
|
unsigned int rowstride,
|
||||||
uint8_t *data)
|
uint8_t *data)
|
||||||
{
|
{
|
||||||
int bpp;
|
CoglContext *ctx = texture->context;
|
||||||
int byte_size;
|
int bpp;
|
||||||
CoglPixelFormat closest_format;
|
int byte_size;
|
||||||
GLenum closest_gl_format;
|
CoglPixelFormat closest_format;
|
||||||
GLenum closest_gl_type;
|
GLenum closest_gl_format;
|
||||||
CoglBitmap *target_bmp;
|
GLenum closest_gl_type;
|
||||||
int tex_width;
|
CoglBitmap *target_bmp;
|
||||||
int tex_height;
|
int tex_width;
|
||||||
CoglPixelFormat texture_format;
|
int tex_height;
|
||||||
|
CoglPixelFormat texture_format;
|
||||||
|
|
||||||
CoglTextureGetData tg_data;
|
CoglTextureGetData tg_data;
|
||||||
|
|
||||||
_COGL_GET_CONTEXT (ctx, 0);
|
|
||||||
|
|
||||||
texture_format = cogl_texture_get_format (texture);
|
texture_format = cogl_texture_get_format (texture);
|
||||||
|
|
||||||
/* Default to internal format if none specified */
|
/* Default to internal format if none specified */
|
||||||
|
@ -285,7 +285,7 @@ cogl_texture_pixmap_x11_new (CoglContext *ctxt,
|
|||||||
int damage_base;
|
int damage_base;
|
||||||
const CoglWinsysVtable *winsys;
|
const CoglWinsysVtable *winsys;
|
||||||
|
|
||||||
_cogl_texture_init (tex, &cogl_texture_pixmap_x11_vtable);
|
_cogl_texture_init (tex, ctxt, &cogl_texture_pixmap_x11_vtable);
|
||||||
|
|
||||||
tex_pixmap->pixmap = pixmap;
|
tex_pixmap->pixmap = pixmap;
|
||||||
tex_pixmap->image = NULL;
|
tex_pixmap->image = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user