G_OBJECT_CLASS (gdk_gl_texture_parent_class)->dispose (object);
}
+typedef void (* GLFunc) (GdkGLTexture *self,
+ gpointer data,
+ GdkGLContext *context);
+
typedef struct _InvokeData
{
GdkGLTexture *self;
volatile int spinlock;
- GFunc func;
+ GLFunc func;
gpointer data;
} InvokeData;
gdk_gl_context_make_current (context);
glBindTexture (GL_TEXTURE_2D, invoke->self->id);
- invoke->func (invoke->self, invoke->data);
+ invoke->func (invoke->self, invoke->data, context);
g_atomic_int_set (&invoke->spinlock, 1);
static void
gdk_gl_texture_run (GdkGLTexture *self,
- GFunc func,
+ GLFunc func,
gpointer data)
{
InvokeData invoke = { self, 0, func, data };
}
static inline void
-gdk_gl_texture_do_download (gpointer texture_,
- gpointer download_)
+gdk_gl_texture_do_download (GdkGLTexture *self,
+ gpointer download_,
+ GdkGLContext *context)
{
+ GdkTexture *texture = GDK_TEXTURE (self);
gsize expected_stride;
- GdkGLTexture *self = texture_;
- GdkTexture *texture = texture_;
Download *download = download_;
GLenum gl_internal_format, gl_format, gl_type;
expected_stride = texture->width * gdk_memory_format_bytes_per_pixel (download->format);
if (download->stride == expected_stride &&
- !gdk_gl_context_get_use_es (self->context) &&
+ !gdk_gl_context_get_use_es (context) &&
gdk_memory_format_gl_format (download->format, TRUE, &gl_internal_format, &gl_format, &gl_type))
{
glGetTexImage (GL_TEXTURE_2D,
glGenFramebuffers (1, &fbo);
glBindFramebuffer (GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, self->id, 0);
- if (gdk_gl_context_check_version (self->context, 4, 3, 3, 1))
+ if (gdk_gl_context_check_version (context, 4, 3, 3, 1))
{
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_FORMAT, &gl_read_format);
glGetFramebufferParameteriv (GL_FRAMEBUFFER, GL_IMPLEMENTATION_COLOR_READ_TYPE, &gl_read_type);
- if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (self->context), gl_read_format, gl_read_type, &actual_format))
+ if (!gdk_gl_texture_find_format (gdk_gl_context_get_use_es (context), gl_read_format, gl_read_type, &actual_format))
actual_format = GDK_MEMORY_R8G8B8A8_PREMULTIPLIED; /* pray */
}
else
(download->stride == expected_stride))
{
glReadPixels (0, 0,
- texture->width, texture->height,
+ texture->width, texture->height,
gl_read_format,
gl_read_type,
download->data);
guchar *pixels = g_malloc_n (texture->width * actual_bpp, texture->height);
glReadPixels (0, 0,
- texture->width, texture->height,
+ texture->width, texture->height,
gl_read_format,
gl_read_type,
pixels);