Revert "gldriver: Don't create surfaces to upload textures"
This reverts commit 6466e53bfc.
This breaks GtkGLArea.
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
#include "gskprofilerprivate.h"
|
||||
#include "gdk/gdktextureprivate.h"
|
||||
#include "gdk/gdkgltextureprivate.h"
|
||||
#include "gdk/gdkglcontextprivate.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <epoxy/gl.h>
|
||||
@@ -112,34 +111,6 @@ gsk_gl_driver_set_texture_parameters (GskGLDriver *self,
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_driver_upload_texture (GskGLDriver *self,
|
||||
Texture *texture,
|
||||
int min_filter,
|
||||
int mag_filter,
|
||||
guchar *data)
|
||||
{
|
||||
if (self->bound_source_texture != texture)
|
||||
{
|
||||
g_critical ("You must bind the texture before initializing it.");
|
||||
return;
|
||||
}
|
||||
|
||||
gsk_gl_driver_set_texture_parameters (self, min_filter, mag_filter);
|
||||
gdk_gl_context_upload_texture (self->gl_context,
|
||||
data,
|
||||
texture->width,
|
||||
texture->height,
|
||||
texture->width * 4,
|
||||
GL_TEXTURE_2D);
|
||||
|
||||
texture->min_filter = min_filter;
|
||||
texture->mag_filter = mag_filter;
|
||||
|
||||
if (texture->min_filter != GL_NEAREST)
|
||||
glGenerateMipmap (GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gl_driver_finalize (GObject *gobject)
|
||||
{
|
||||
@@ -526,9 +497,8 @@ gsk_gl_driver_get_texture_for_texture (GskGLDriver *self,
|
||||
int min_filter,
|
||||
int mag_filter)
|
||||
{
|
||||
const int stride = gdk_texture_get_width (texture) * 4;
|
||||
Texture *t;
|
||||
guchar *texture_data = NULL;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
if (GDK_IS_GL_TEXTURE (texture))
|
||||
{
|
||||
@@ -539,8 +509,7 @@ gsk_gl_driver_get_texture_for_texture (GskGLDriver *self,
|
||||
/* In this case, we have to temporarily make the texture's context the current one,
|
||||
* download its data into our context and then create a texture from it. */
|
||||
gdk_gl_context_make_current (texture_context);
|
||||
texture_data = g_malloc (stride * gdk_texture_get_height (texture));
|
||||
gdk_texture_download (texture, texture_data, stride);
|
||||
surface = gdk_texture_download_surface (texture);
|
||||
gdk_gl_context_make_current (self->gl_context);
|
||||
}
|
||||
else
|
||||
@@ -559,10 +528,8 @@ gsk_gl_driver_get_texture_for_texture (GskGLDriver *self,
|
||||
return t->texture_id;
|
||||
}
|
||||
|
||||
texture_data = g_malloc (stride * gdk_texture_get_height (texture));
|
||||
gdk_texture_download (texture, texture_data, stride);
|
||||
surface = gdk_texture_download_surface (texture);
|
||||
}
|
||||
g_assert (texture_data != NULL);
|
||||
|
||||
t = create_texture (self, gdk_texture_get_width (texture), gdk_texture_get_height (texture));
|
||||
|
||||
@@ -570,9 +537,12 @@ gsk_gl_driver_get_texture_for_texture (GskGLDriver *self,
|
||||
t->user = texture;
|
||||
|
||||
gsk_gl_driver_bind_source_texture (self, t->texture_id);
|
||||
gsk_gl_driver_upload_texture (self, t, min_filter, mag_filter, texture_data);
|
||||
|
||||
g_free (texture_data);
|
||||
gsk_gl_driver_init_texture_with_surface (self,
|
||||
t->texture_id,
|
||||
surface,
|
||||
min_filter,
|
||||
mag_filter);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
return t->texture_id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user