cogl: Remove cogl_texture_2d_gl_new_from_foreign

As noted in <cogl-texture-2d-gl.h> (now also removed), this is for
allowing external GL callers to promote one of their textures to a
CoglTexture. We aren't doing that and don't want to start.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/883
This commit is contained in:
Adam Jackson 2019-10-23 11:24:37 -04:00 committed by Georges Basile Stavracas Neto
parent 54ac1f6b59
commit 806ebc464a
22 changed files with 20 additions and 507 deletions

View File

@ -1022,6 +1022,5 @@ cogl_atlas_texture_vtable =
_cogl_atlas_texture_gl_flush_legacy_texobj_wrap_modes,
_cogl_atlas_texture_get_format,
_cogl_atlas_texture_get_gl_format,
NULL, /* is_foreign */
NULL /* set_auto_mipmap */
};

View File

@ -436,6 +436,5 @@ cogl_sub_texture_vtable =
_cogl_sub_texture_gl_flush_legacy_texobj_wrap_modes,
_cogl_sub_texture_get_format,
_cogl_sub_texture_get_gl_format,
NULL, /* is_foreign */
NULL /* set_auto_mipmap */
};

View File

@ -1,78 +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 <robert@linux.intel.com>
*/
#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
#error "Only <cogl/cogl.h> can be included directly."
#endif
#ifndef _COGL_TEXTURE_2D_GL_H_
#define _COGL_TEXTURE_2D_GL_H_
#include "cogl-context.h"
#include "cogl-texture-2d.h"
G_BEGIN_DECLS
/**
* cogl_texture_2d_gl_new_from_foreign:
* @ctx: A #CoglContext
* @gl_handle: A GL handle for a GL_TEXTURE_2D texture object
* @width: Width of the foreign GL texture
* @height: Height of the foreign GL texture
* @format: The format of the texture
*
* Wraps an existing GL_TEXTURE_2D texture object as a #CoglTexture2D.
* This can be used for integrating Cogl with software using OpenGL
* directly.
*
* The texture is still configurable until it has been allocated so
* for example you can declare whether the texture is premultiplied
* with cogl_texture_set_premultiplied().
*
* <note>The results are undefined for passing an invalid @gl_handle
* or if @width or @height don't have the correct texture
* geometry.</note>
*
* Returns: (transfer full): A newly allocated #CoglTexture2D
*
* Since: 2.0
*/
CoglTexture2D *
cogl_texture_2d_gl_new_from_foreign (CoglContext *ctx,
unsigned int gl_handle,
int width,
int height,
CoglPixelFormat format);
G_END_DECLS
#endif /* _COGL_TEXTURE_2D_GL_H_ */

View File

@ -46,7 +46,6 @@ struct _CoglTexture2D
gboolean auto_mipmap;
gboolean mipmaps_dirty;
gboolean is_foreign;
gboolean is_get_data_supported;
/* TODO: factor out these OpenGL specific members into some form

View File

@ -49,16 +49,6 @@ struct _CoglTexture2DSliced
CoglPixelFormat internal_format;
};
CoglTexture2DSliced *
_cogl_texture_2d_sliced_new_from_foreign (CoglContext *context,
unsigned int gl_handle,
unsigned int gl_target,
int width,
int height,
int x_pot_waste,
int y_pot_waste,
CoglPixelFormat format);
CoglTexture2DSliced *
_cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap *bmp,
int max_waste,

View File

@ -41,7 +41,6 @@
#include "cogl-bitmap.h"
#include "cogl-bitmap-private.h"
#include "cogl-texture-private.h"
#include "cogl-texture-2d-gl.h"
#include "cogl-texture-2d-private.h"
#include "cogl-texture-2d-sliced-private.h"
#include "cogl-texture-driver.h"
@ -917,50 +916,6 @@ cogl_texture_2d_sliced_new_from_bitmap (CoglBitmap *bmp,
FALSE);
}
CoglTexture2DSliced *
_cogl_texture_2d_sliced_new_from_foreign (CoglContext *ctx,
unsigned int gl_handle,
unsigned int gl_target,
int width,
int height,
int x_pot_waste,
int y_pot_waste,
CoglPixelFormat format)
{
CoglTextureLoader *loader;
/* NOTE: width, height and internal format are not queriable
* in GLES, hence such a function prototype.
*/
/* This should only be called when the texture target is 2D. */
g_return_val_if_fail (gl_target == GL_TEXTURE_2D, NULL);
/* Assert it is a valid GL texture object */
g_return_val_if_fail (ctx->glIsTexture (gl_handle), FALSE);
/* Validate width and height */
g_return_val_if_fail (width > 0 && height > 0, NULL);
/* Validate pot waste */
g_return_val_if_fail (x_pot_waste >= 0 && x_pot_waste < width &&
y_pot_waste >= 0 && y_pot_waste < height,
NULL);
loader = _cogl_texture_create_loader ();
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_GL_FOREIGN;
loader->src.gl_foreign.gl_handle = gl_handle;
loader->src.gl_foreign.width = width + x_pot_waste;
loader->src.gl_foreign.height = height + y_pot_waste;
loader->src.gl_foreign.format = format;
return _cogl_texture_2d_sliced_create_base (ctx,
width,
height,
0, /* max waste */
format, loader);
}
CoglTexture2DSliced *
cogl_texture_2d_sliced_new_from_data (CoglContext *ctx,
int width,
@ -1106,71 +1061,6 @@ allocate_from_bitmap (CoglTexture2DSliced *tex_2ds,
return TRUE;
}
static gboolean
allocate_from_gl_foreign (CoglTexture2DSliced *tex_2ds,
CoglTextureLoader *loader,
GError **error)
{
CoglTexture *tex = COGL_TEXTURE (tex_2ds);
CoglContext *ctx = tex->context;
CoglPixelFormat format = loader->src.gl_foreign.format;
int gl_width = loader->src.gl_foreign.width;
int gl_height = loader->src.gl_foreign.height;
int x_pot_waste = gl_width - tex->width;
int y_pot_waste = gl_height - tex->height;
CoglSpan x_span;
CoglSpan y_span;
CoglTexture2D *tex_2d =
cogl_texture_2d_gl_new_from_foreign (ctx,
loader->src.gl_foreign.gl_handle,
gl_width,
gl_height,
format);
if (!cogl_texture_allocate (COGL_TEXTURE (tex_2d), error))
{
cogl_object_unref (tex_2d);
return FALSE;
}
/* The texture 2d backend may use a different pixel format if it
queries the actual texture so we'll refetch the format it
actually used */
format = _cogl_texture_get_format (tex);
tex_2ds->internal_format = format;
/* Create slice arrays */
tex_2ds->slice_x_spans =
g_array_sized_new (FALSE, FALSE, sizeof (CoglSpan), 1);
tex_2ds->slice_y_spans =
g_array_sized_new (FALSE, FALSE, sizeof (CoglSpan), 1);
tex_2ds->slice_textures =
g_array_sized_new (FALSE, FALSE, sizeof (CoglTexture2D *), 1);
/* Store info for a single slice */
x_span.start = 0;
x_span.size = gl_width;
x_span.waste = x_pot_waste;
g_array_append_val (tex_2ds->slice_x_spans, x_span);
y_span.start = 0;
y_span.size = gl_height;
y_span.waste = y_pot_waste;
g_array_append_val (tex_2ds->slice_y_spans, y_span);
g_array_append_val (tex_2ds->slice_textures, tex_2d);
_cogl_texture_set_allocated (tex,
format,
tex->width,
tex->height);
return TRUE;
}
static gboolean
_cogl_texture_2d_sliced_allocate (CoglTexture *tex,
GError **error)
@ -1186,8 +1076,6 @@ _cogl_texture_2d_sliced_allocate (CoglTexture *tex,
return allocate_with_size (tex_2ds, loader, error);
case COGL_TEXTURE_SOURCE_TYPE_BITMAP:
return allocate_from_bitmap (tex_2ds, loader, error);
case COGL_TEXTURE_SOURCE_TYPE_GL_FOREIGN:
return allocate_from_gl_foreign (tex_2ds, loader, error);
default:
break;
}
@ -1195,21 +1083,6 @@ _cogl_texture_2d_sliced_allocate (CoglTexture *tex,
g_return_val_if_reached (FALSE);
}
static gboolean
_cogl_texture_2d_sliced_is_foreign (CoglTexture *tex)
{
CoglTexture2DSliced *tex_2ds = COGL_TEXTURE_2D_SLICED (tex);
CoglTexture2D *slice_tex;
/* Make sure slices were created */
if (tex_2ds->slice_textures == NULL)
return FALSE;
/* Pass the call on to the first slice */
slice_tex = g_array_index (tex_2ds->slice_textures, CoglTexture2D *, 0);
return _cogl_texture_is_foreign (COGL_TEXTURE (slice_tex));
}
static int
_cogl_texture_2d_sliced_get_max_waste (CoglTexture *tex)
{
@ -1466,6 +1339,5 @@ cogl_texture_2d_sliced_vtable =
_cogl_texture_2d_sliced_gl_flush_legacy_texobj_wrap_modes,
_cogl_texture_2d_sliced_get_format,
_cogl_texture_2d_sliced_get_gl_format,
_cogl_texture_2d_sliced_is_foreign,
NULL /* set_auto_mipmap */
};

View File

@ -109,8 +109,6 @@ _cogl_texture_2d_create_base (CoglContext *ctx,
tex_2d->gl_target = GL_TEXTURE_2D;
tex_2d->is_foreign = FALSE;
ctx->driver_vtable->texture_2d_init (tex_2d);
return _cogl_texture_2d_object_new (tex_2d);
@ -486,12 +484,6 @@ _cogl_texture_2d_get_gl_format (CoglTexture *tex)
return COGL_TEXTURE_2D (tex)->gl_internal_format;
}
static gboolean
_cogl_texture_2d_is_foreign (CoglTexture *tex)
{
return COGL_TEXTURE_2D (tex)->is_foreign;
}
static const CoglTextureVtable
cogl_texture_2d_vtable =
{
@ -513,6 +505,5 @@ cogl_texture_2d_vtable =
_cogl_texture_2d_gl_flush_legacy_texobj_wrap_modes,
_cogl_texture_2d_get_format,
_cogl_texture_2d_get_gl_format,
_cogl_texture_2d_is_foreign,
_cogl_texture_2d_set_auto_mipmap
};

View File

@ -61,7 +61,6 @@ struct _CoglTextureDriver
gboolean
(* upload_subregion_to_gl) (CoglContext *ctx,
CoglTexture *texture,
gboolean is_foreign,
int src_x,
int src_y,
int dst_x,
@ -84,7 +83,6 @@ struct _CoglTextureDriver
(* upload_to_gl) (CoglContext *ctx,
GLenum gl_target,
GLuint gl_handle,
gboolean is_foreign,
CoglBitmap *source_bmp,
GLint internal_gl_format,
GLuint source_gl_format,
@ -130,15 +128,6 @@ struct _CoglTextureDriver
int width,
int height);
/*
* It may depend on the driver as to what texture targets may be used when
* creating a foreign texture. E.g. OpenGL supports ARB_texture_rectangle
* but GLES doesn't
*/
gboolean
(* allows_foreign_gl_target) (CoglContext *ctx,
GLenum gl_target);
/*
* The driver may impose constraints on what formats can be used to store
* texture data read from textures. For example GLES currently only supports

View File

@ -146,8 +146,6 @@ struct _CoglTextureVtable
CoglPixelFormat (* get_format) (CoglTexture *tex);
GLenum (* get_gl_format) (CoglTexture *tex);
gboolean (* is_foreign) (CoglTexture *tex);
/* Only needs to be implemented if is_primitive == TRUE */
void (* set_auto_mipmap) (CoglTexture *texture,
gboolean value);
@ -157,7 +155,6 @@ typedef enum _CoglTextureSoureType {
COGL_TEXTURE_SOURCE_TYPE_SIZED = 1,
COGL_TEXTURE_SOURCE_TYPE_BITMAP,
COGL_TEXTURE_SOURCE_TYPE_EGL_IMAGE,
COGL_TEXTURE_SOURCE_TYPE_GL_FOREIGN,
COGL_TEXTURE_SOURCE_TYPE_EGL_IMAGE_EXTERNAL
} CoglTextureSourceType;
@ -326,9 +323,6 @@ void
_cogl_texture_set_internal_format (CoglTexture *texture,
CoglPixelFormat internal_format);
gboolean
_cogl_texture_is_foreign (CoglTexture *texture);
void
_cogl_texture_associate_framebuffer (CoglTexture *texture,
CoglFramebuffer *framebuffer);

View File

@ -46,7 +46,6 @@
#include "cogl-texture-driver.h"
#include "cogl-texture-2d-sliced-private.h"
#include "cogl-texture-2d-private.h"
#include "cogl-texture-2d-gl.h"
#include "cogl-sub-texture-private.h"
#include "cogl-atlas-texture-private.h"
#include "cogl-pipeline.h"
@ -154,7 +153,6 @@ _cogl_texture_free_loader (CoglTexture *texture)
{
case COGL_TEXTURE_SOURCE_TYPE_SIZED:
case COGL_TEXTURE_SOURCE_TYPE_EGL_IMAGE:
case COGL_TEXTURE_SOURCE_TYPE_GL_FOREIGN:
case COGL_TEXTURE_SOURCE_TYPE_EGL_IMAGE_EXTERNAL:
break;
case COGL_TEXTURE_SOURCE_TYPE_BITMAP:
@ -191,15 +189,6 @@ _cogl_texture_needs_premult_conversion (CoglPixelFormat src_format,
(dst_format & COGL_PREMULT_BIT));
}
gboolean
_cogl_texture_is_foreign (CoglTexture *texture)
{
if (texture->vtable->is_foreign)
return texture->vtable->is_foreign (texture);
else
return FALSE;
}
gboolean
cogl_texture_is_get_data_supported (CoglTexture *texture)
{

View File

@ -102,7 +102,6 @@
#include <cogl/cogl-buffer.h>
#include <cogl/cogl-pixel-buffer.h>
#include <cogl/cogl-texture-2d.h>
#include <cogl/cogl-texture-2d-gl.h>
#include <cogl/cogl-texture-2d-sliced.h>
#include <cogl/cogl-sub-texture.h>
#include <cogl/cogl-atlas-texture.h>

View File

@ -822,7 +822,6 @@ cogl_texture_pixmap_x11_update_area
cogl_texture_rectangle_get_gtype
#endif
cogl_texture_rectangle_new_from_bitmap
cogl_texture_rectangle_new_from_foreign
cogl_texture_rectangle_new_with_size
#ifndef COGL_DISABLE_DEPRECATED
cogl_texture_ref

View File

@ -48,7 +48,6 @@
#include "cogl-bitmap-private.h"
#include "cogl-atlas-texture-private.h"
#include "cogl-sub-texture.h"
#include "cogl-texture-2d-gl.h"
#include "deprecated/cogl-auto-texture.h"

View File

@ -71,13 +71,6 @@ typedef struct _CoglTextureUnit
* dirty_gl_texture == TRUE */
GLenum gl_target;
/* Foreign textures are those not created or deleted by Cogl. If we ever
* call glBindTexture for a foreign texture then the next time we are
* asked to glBindTexture we can't try and optimize a redundant state
* change because we don't know if the original texture name was deleted
* and now we are being asked to bind a recycled name. */
gboolean is_foreign;
/* We have many components in Cogl that need to temporarily bind arbitrary
* textures e.g. to query texture object parameters and since we don't
* want that to result in too much redundant reflushing of layer state
@ -141,8 +134,7 @@ _cogl_set_active_texture_unit (int unit_index);
void
_cogl_bind_gl_texture_transient (GLenum gl_target,
GLuint gl_texture,
gboolean is_foreign);
GLuint gl_texture);
void
_cogl_delete_gl_texture (GLuint gl_texture);

View File

@ -77,7 +77,6 @@ texture_unit_init (CoglContext *ctx,
unit->enabled_gl_target = 0;
unit->gl_texture = 0;
unit->gl_target = 0;
unit->is_foreign = FALSE;
unit->dirty_gl_texture = FALSE;
unit->matrix_stack = cogl_matrix_stack_new (ctx);
@ -166,8 +165,7 @@ _cogl_set_active_texture_unit (int unit_index)
*/
void
_cogl_bind_gl_texture_transient (GLenum gl_target,
GLuint gl_texture,
gboolean is_foreign)
GLuint gl_texture)
{
CoglTextureUnit *unit;
@ -183,18 +181,12 @@ _cogl_bind_gl_texture_transient (GLenum gl_target,
_cogl_set_active_texture_unit (1);
unit = _cogl_get_texture_unit (1);
/* NB: If we have previously bound a foreign texture to this texture
* unit we don't know if that texture has since been deleted and we
* are seeing the texture name recycled */
if (unit->gl_texture == gl_texture &&
!unit->dirty_gl_texture &&
!unit->is_foreign)
if (unit->gl_texture == gl_texture && !unit->dirty_gl_texture)
return;
GE (ctx, glBindTexture (gl_target, gl_texture));
unit->dirty_gl_texture = TRUE;
unit->is_foreign = is_foreign;
}
void
@ -775,7 +767,7 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
* associated with the texture unit then we can't assume that we
* aren't seeing a recycled texture name so we have to bind.
*/
if (unit->gl_texture != gl_texture || unit->is_foreign)
if (unit->gl_texture != gl_texture)
{
if (unit_index == 1)
unit->dirty_gl_texture = TRUE;
@ -785,8 +777,6 @@ flush_layers_common_gl_state_cb (CoglPipelineLayer *layer, void *user_data)
unit->gl_target = gl_target;
}
unit->is_foreign = _cogl_texture_is_foreign (texture);
/* The texture_storage_changed boolean indicates if the
* CoglTexture's underlying GL texture storage has changed since
* it was flushed to the texture unit. We've just flushed the

View File

@ -38,7 +38,6 @@
#include "cogl-private.h"
#include "cogl-texture-private.h"
#include "cogl-texture-2d-gl.h"
#include "cogl-texture-2d-private.h"
#include "driver/gl/cogl-texture-2d-gl-private.h"
#include "driver/gl/cogl-texture-gl-private.h"
@ -63,7 +62,7 @@
void
_cogl_texture_2d_gl_free (CoglTexture2D *tex_2d)
{
if (!tex_2d->is_foreign && tex_2d->gl_texture)
if (tex_2d->gl_texture)
_cogl_delete_gl_texture (tex_2d->gl_texture);
#if defined (COGL_HAS_EGL_SUPPORT)
@ -163,8 +162,7 @@ allocate_with_size (CoglTexture2D *tex_2d,
tex_2d->gl_internal_format = gl_intformat;
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
gl_texture,
tex_2d->is_foreign);
gl_texture);
/* Clear any GL errors */
_cogl_gl_util_clear_gl_errors (ctx);
@ -243,7 +241,6 @@ allocate_from_bitmap (CoglTexture2D *tex_2d,
if (!ctx->texture_driver->upload_to_gl (ctx,
GL_TEXTURE_2D,
tex_2d->gl_texture,
FALSE,
upload_bmp,
gl_intformat,
gl_format,
@ -278,8 +275,7 @@ allocate_from_egl_image (CoglTexture2D *tex_2d,
tex_2d->gl_texture =
ctx->texture_driver->gen (ctx, GL_TEXTURE_2D, internal_format);
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
tex_2d->gl_texture,
FALSE);
tex_2d->gl_texture);
_cogl_gl_util_clear_gl_errors (ctx);
ctx->glEGLImageTargetTexture2D (GL_TEXTURE_2D, loader->src.egl_image.image);
@ -307,132 +303,6 @@ allocate_from_egl_image (CoglTexture2D *tex_2d,
}
#endif
static gboolean
allocate_from_gl_foreign (CoglTexture2D *tex_2d,
CoglTextureLoader *loader,
GError **error)
{
CoglTexture *tex = COGL_TEXTURE (tex_2d);
CoglContext *ctx = tex->context;
CoglPixelFormat format = loader->src.gl_foreign.format;
GLint gl_compressed = GL_FALSE;
GLenum gl_int_format = 0;
if (!ctx->texture_driver->allows_foreign_gl_target (ctx, GL_TEXTURE_2D))
{
g_set_error_literal (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Foreign GL_TEXTURE_2D textures are not "
"supported by your system");
return FALSE;
}
/* Make sure binding succeeds */
_cogl_gl_util_clear_gl_errors (ctx);
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
loader->src.gl_foreign.gl_handle, TRUE);
if (_cogl_gl_util_get_error (ctx) != GL_NO_ERROR)
{
g_set_error_literal (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Failed to bind foreign GL_TEXTURE_2D texture");
return FALSE;
}
/* Obtain texture parameters
(only level 0 we are interested in) */
#ifdef HAVE_COGL_GL
if (_cogl_has_private_feature
(ctx, COGL_PRIVATE_FEATURE_QUERY_TEXTURE_PARAMETERS))
{
GE( ctx, glGetTexLevelParameteriv (GL_TEXTURE_2D, 0,
GL_TEXTURE_COMPRESSED,
&gl_compressed) );
{
GLint val;
GE( ctx, glGetTexLevelParameteriv (GL_TEXTURE_2D, 0,
GL_TEXTURE_INTERNAL_FORMAT,
&val) );
gl_int_format = val;
}
/* If we can query GL for the actual pixel format then we'll ignore
the passed in format and use that. */
if (!ctx->driver_vtable->pixel_format_from_gl_internal (ctx,
gl_int_format,
&format))
{
g_set_error_literal (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Unsupported internal format for foreign "
"texture");
return FALSE;
}
}
else
#endif
{
/* Otherwise we'll assume we can derive the GL format from the
passed in format */
ctx->driver_vtable->pixel_format_to_gl (ctx,
format,
&gl_int_format,
NULL,
NULL);
}
/* Compressed texture images not supported */
if (gl_compressed == GL_TRUE)
{
g_set_error_literal (error,
COGL_SYSTEM_ERROR,
COGL_SYSTEM_ERROR_UNSUPPORTED,
"Compressed foreign textures aren't currently"
" supported");
return FALSE;
}
/* Note: previously this code would query the texture object for
whether it has GL_GENERATE_MIPMAP enabled to determine whether to
auto-generate the mipmap. This doesn't make much sense any more
since Cogl switch to using glGenerateMipmap. Ideally I think
cogl_texture_2d_gl_new_from_foreign should take a flags parameter so
that the application can decide whether it wants
auto-mipmapping. To be compatible with existing code, Cogl now
disables its own auto-mipmapping but leaves the value of
GL_GENERATE_MIPMAP alone so that it would still work but without
the dirtiness tracking that Cogl would do. */
_cogl_texture_2d_set_auto_mipmap (COGL_TEXTURE (tex_2d), FALSE);
/* Setup bitmap info */
tex_2d->is_foreign = TRUE;
tex_2d->mipmaps_dirty = TRUE;
tex_2d->gl_texture = loader->src.gl_foreign.gl_handle;
tex_2d->gl_internal_format = gl_int_format;
/* Unknown filter */
tex_2d->gl_legacy_texobj_min_filter = GL_FALSE;
tex_2d->gl_legacy_texobj_mag_filter = GL_FALSE;
tex_2d->internal_format = format;
_cogl_texture_set_allocated (tex,
format,
loader->src.gl_foreign.width,
loader->src.gl_foreign.height);
return TRUE;
}
#if defined (COGL_HAS_EGL_SUPPORT)
static gboolean
allocate_custom_egl_image_external (CoglTexture2D *tex_2d,
@ -550,8 +420,6 @@ _cogl_texture_2d_gl_allocate (CoglTexture *tex,
#else
g_return_val_if_reached (FALSE);
#endif
case COGL_TEXTURE_SOURCE_TYPE_GL_FOREIGN:
return allocate_from_gl_foreign (tex_2d, loader, error);
case COGL_TEXTURE_SOURCE_TYPE_EGL_IMAGE_EXTERNAL:
#if defined (COGL_HAS_EGL_SUPPORT)
return allocate_custom_egl_image_external (tex_2d, loader, error);
@ -581,8 +449,7 @@ _cogl_texture_2d_gl_flush_legacy_texobj_filters (CoglTexture *tex,
/* Apply new filters to the texture */
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
tex_2d->gl_texture,
tex_2d->is_foreign);
tex_2d->gl_texture);
GE( ctx, glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter) );
GE( ctx, glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter) );
}
@ -603,8 +470,7 @@ _cogl_texture_2d_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex,
tex_2d->gl_legacy_texobj_wrap_mode_t != wrap_mode_t)
{
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
tex_2d->gl_texture,
tex_2d->is_foreign);
tex_2d->gl_texture);
GE( ctx, glTexParameteri (GL_TEXTURE_2D,
GL_TEXTURE_WRAP_S,
wrap_mode_s) );
@ -617,42 +483,6 @@ _cogl_texture_2d_gl_flush_legacy_texobj_wrap_modes (CoglTexture *tex,
}
}
CoglTexture2D *
cogl_texture_2d_gl_new_from_foreign (CoglContext *ctx,
unsigned int gl_handle,
int width,
int height,
CoglPixelFormat format)
{
CoglTextureLoader *loader;
/* NOTE: width, height and internal format are not queriable
* in GLES, hence such a function prototype.
*/
/* Note: We always trust the given width and height without querying
* the texture object because the user may be creating a Cogl
* texture for a texture_from_pixmap object where glTexImage2D may
* not have been called and the texture_from_pixmap spec doesn't
* clarify that it is reliable to query back the size from OpenGL.
*/
/* Assert it is a valid GL texture object */
g_return_val_if_fail (ctx->glIsTexture (gl_handle), FALSE);
/* Validate width and height */
g_return_val_if_fail (width > 0 && height > 0, NULL);
loader = _cogl_texture_create_loader ();
loader->src_type = COGL_TEXTURE_SOURCE_TYPE_GL_FOREIGN;
loader->src.gl_foreign.gl_handle = gl_handle;
loader->src.gl_foreign.width = width;
loader->src.gl_foreign.height = height;
loader->src.gl_foreign.format = format;
return _cogl_texture_2d_create_base (ctx, width, height, format, loader);
}
void
_cogl_texture_2d_gl_copy_from_framebuffer (CoglTexture2D *tex_2d,
int src_x,
@ -676,8 +506,7 @@ _cogl_texture_2d_gl_copy_from_framebuffer (CoglTexture2D *tex_2d,
~COGL_FRAMEBUFFER_STATE_CLIP);
_cogl_bind_gl_texture_transient (GL_TEXTURE_2D,
tex_2d->gl_texture,
tex_2d->is_foreign);
tex_2d->gl_texture);
ctx->glCopyTexSubImage2D (GL_TEXTURE_2D,
0, /* level */
@ -741,7 +570,6 @@ _cogl_texture_2d_gl_copy_from_bitmap (CoglTexture2D *tex_2d,
status = ctx->texture_driver->upload_subregion_to_gl (ctx,
tex,
FALSE,
src_x, src_y,
dst_x, dst_y,
width, height,
@ -793,8 +621,7 @@ _cogl_texture_2d_gl_get_data (CoglTexture2D *tex_2d,
bpp);
_cogl_bind_gl_texture_transient (tex_2d->gl_target,
tex_2d->gl_texture,
tex_2d->is_foreign);
tex_2d->gl_texture);
ctx->texture_driver->gl_get_tex_image (ctx,
tex_2d->gl_target,

View File

@ -119,8 +119,7 @@ _cogl_texture_gl_maybe_update_max_level (CoglTexture *texture,
texture->max_level = max_level;
_cogl_bind_gl_texture_transient (gl_target,
gl_handle,
_cogl_texture_is_foreign (texture));
gl_handle);
GE( ctx, glTexParameteri (gl_target,
GL_TEXTURE_MAX_LEVEL, texture->max_level));
@ -141,8 +140,7 @@ _cogl_texture_gl_generate_mipmaps (CoglTexture *texture)
cogl_texture_get_gl_texture (texture, &gl_handle, &gl_target);
_cogl_bind_gl_texture_transient (gl_target,
gl_handle,
_cogl_texture_is_foreign (texture));
gl_handle);
GE( ctx, glGenerateMipmap (gl_target) );
}

View File

@ -66,7 +66,7 @@ _cogl_texture_driver_gen (CoglContext *ctx,
GE (ctx, glGenTextures (1, &tex));
_cogl_bind_gl_texture_transient (gl_target, tex, FALSE);
_cogl_bind_gl_texture_transient (gl_target, tex);
switch (gl_target)
{
@ -172,7 +172,6 @@ _cogl_texture_driver_prep_gl_for_pixels_download (CoglContext *ctx,
static gboolean
_cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
CoglTexture *texture,
gboolean is_foreign,
int src_x,
int src_y,
int dst_x,
@ -221,7 +220,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
src_y,
bpp);
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
_cogl_bind_gl_texture_transient (gl_target, gl_handle);
/* Clear any GL errors */
_cogl_gl_util_clear_gl_errors (ctx);
@ -291,7 +290,6 @@ static gboolean
_cogl_texture_driver_upload_to_gl (CoglContext *ctx,
GLenum gl_target,
GLuint gl_handle,
gboolean is_foreign,
CoglBitmap *source_bmp,
GLint internal_gl_format,
GLuint source_gl_format,
@ -329,7 +327,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
cogl_bitmap_get_rowstride (source_bmp),
0, 0, 0, bpp);
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
_cogl_bind_gl_texture_transient (gl_target, gl_handle);
/* Clear any GL errors */
_cogl_gl_util_clear_gl_errors (ctx);
@ -399,23 +397,6 @@ _cogl_texture_driver_size_supported (CoglContext *ctx,
return new_width != 0;
}
static gboolean
_cogl_texture_driver_allows_foreign_gl_target (CoglContext *ctx,
GLenum gl_target)
{
/* GL_ARB_texture_rectangle textures are supported if they are
created from foreign because some chipsets have trouble with
GL_ARB_texture_non_power_of_two. There is no Cogl call to create
them directly to emphasize the fact that they don't work fully
(for example, no mipmapping and complicated shader support) */
/* Allow 2-dimensional or rectangle textures only */
if (gl_target != GL_TEXTURE_2D && gl_target != GL_TEXTURE_RECTANGLE_ARB)
return FALSE;
return TRUE;
}
static CoglPixelFormat
_cogl_texture_driver_find_best_gl_get_data_format
(CoglContext *context,
@ -439,6 +420,5 @@ _cogl_texture_driver_gl =
_cogl_texture_driver_prep_gl_for_pixels_download,
_cogl_texture_driver_gl_get_tex_image,
_cogl_texture_driver_size_supported,
_cogl_texture_driver_allows_foreign_gl_target,
_cogl_texture_driver_find_best_gl_get_data_format
};

View File

@ -81,7 +81,7 @@ _cogl_texture_driver_gen (CoglContext *ctx,
GE (ctx, glGenTextures (1, &tex));
_cogl_bind_gl_texture_transient (gl_target, tex, FALSE);
_cogl_bind_gl_texture_transient (gl_target, tex);
switch (gl_target)
{
@ -184,7 +184,6 @@ prepare_bitmap_alignment_for_upload (CoglContext *ctx,
static gboolean
_cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
CoglTexture *texture,
gboolean is_foreign,
int src_x,
int src_y,
int dst_x,
@ -270,7 +269,7 @@ _cogl_texture_driver_upload_subregion_to_gl (CoglContext *ctx,
return FALSE;
}
_cogl_bind_gl_texture_transient (gl_target, gl_handle, is_foreign);
_cogl_bind_gl_texture_transient (gl_target, gl_handle);
/* Clear any GL errors */
_cogl_gl_util_clear_gl_errors (ctx);
@ -341,7 +340,6 @@ static gboolean
_cogl_texture_driver_upload_to_gl (CoglContext *ctx,
GLenum gl_target,
GLuint gl_handle,
gboolean is_foreign,
CoglBitmap *source_bmp,
GLint internal_gl_format,
GLuint source_gl_format,
@ -373,7 +371,7 @@ _cogl_texture_driver_upload_to_gl (CoglContext *ctx,
/* Setup gl alignment to match rowstride and top-left corner */
_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);
data = _cogl_bitmap_gl_bind (bmp,
COGL_BUFFER_ACCESS_READ,
@ -442,16 +440,6 @@ _cogl_texture_driver_size_supported (CoglContext *ctx,
return width <= max_size && height <= max_size;
}
static gboolean
_cogl_texture_driver_allows_foreign_gl_target (CoglContext *ctx,
GLenum gl_target)
{
/* Allow 2-dimensional textures only */
if (gl_target != GL_TEXTURE_2D)
return FALSE;
return TRUE;
}
static CoglPixelFormat
_cogl_texture_driver_find_best_gl_get_data_format
(CoglContext *context,
@ -476,6 +464,5 @@ _cogl_texture_driver_gles =
_cogl_texture_driver_prep_gl_for_pixels_download,
_cogl_texture_driver_gl_get_tex_image,
_cogl_texture_driver_size_supported,
_cogl_texture_driver_allows_foreign_gl_target,
_cogl_texture_driver_find_best_gl_get_data_format
};

View File

@ -113,7 +113,6 @@ cogl_nonintrospected_headers = [
'cogl-output.h',
'cogl-matrix-stack.h',
'cogl-poll.h',
'cogl-texture-2d-gl.h',
'cogl-sub-texture.h',
'cogl-atlas-texture.h',
'cogl-meta-texture.h',

View File

@ -1094,6 +1094,5 @@ cogl_texture_pixmap_x11_vtable =
_cogl_texture_pixmap_x11_gl_flush_legacy_texobj_wrap_modes,
_cogl_texture_pixmap_x11_get_format,
_cogl_texture_pixmap_x11_get_gl_format,
NULL, /* is_foreign */
NULL /* set_auto_mipmap */
};

View File

@ -2471,7 +2471,7 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
COGL_NOTE (TEXTURE_PIXMAP, "Rebinding GLXPixmap for %p", tex_pixmap);
_cogl_bind_gl_texture_transient (gl_target, gl_handle, FALSE);
_cogl_bind_gl_texture_transient (gl_target, gl_handle);
if (texture_info->pixmap_bound)
glx_renderer->glXReleaseTexImage (xlib_renderer->xdpy,