[gtk/wip/otte/float-textures: 3/12] gltexture: Implement download() via glGetTexImage()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/float-textures: 3/12] gltexture: Implement download() via glGetTexImage()
- Date: Sun, 12 Sep 2021 03:19:44 +0000 (UTC)
commit 376c765ef923dda64a8feb39239bc7678cba7a30
Author: Benjamin Otte <otte redhat com>
Date: Sun Sep 12 00:14:19 2021 +0200
gltexture: Implement download() via glGetTexImage()
1. The download via gdk_cairo_draw_from_gl() was broken sometimes
2. We get easy conversion on fallback by chaining up and using
download_texture().
3. One more place where Cairo is no longer necessary.
gdk/gdkgltexture.c | 42 +++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)
---
diff --git a/gdk/gdkgltexture.c b/gdk/gdkgltexture.c
index ef95c4604b..bd69809061 100644
--- a/gdk/gdkgltexture.c
+++ b/gdk/gdkgltexture.c
@@ -20,7 +20,6 @@
#include "gdkgltextureprivate.h"
-#include "gdkcairo.h"
#include "gdkmemorytextureprivate.h"
#include "gdktextureprivate.h"
@@ -145,10 +144,7 @@ gdk_gl_texture_download (GdkTexture *texture,
gsize stride)
{
GdkGLTexture *self = GDK_GL_TEXTURE (texture);
- GdkSurface *gl_surface;
- cairo_surface_t *surface;
- cairo_t *cr;
- int width, height;
+ GLint active_texture;
if (self->saved)
{
@@ -156,23 +152,31 @@ gdk_gl_texture_download (GdkTexture *texture,
return;
}
- width = gdk_texture_get_width (texture);
- height = gdk_texture_get_width (texture);
- surface = cairo_image_surface_create_for_data (data,
- CAIRO_FORMAT_ARGB32,
- width, height,
- stride);
+ if (gdk_gl_context_get_use_es (self->context) ||
+ stride != texture->width * 4)
+ {
+ GDK_TEXTURE_CLASS (gdk_gl_texture_parent_class)->download (texture, data, stride);
+ return;
+ }
- cr = cairo_create (surface);
+ gdk_gl_context_make_current (self->context);
- gl_surface = gdk_gl_context_get_surface (self->context);
- gdk_cairo_draw_from_gl (cr, gl_surface, self->id, GL_TEXTURE, 1,
- 0, 0,
- width, height);
+ glGetIntegerv (GL_TEXTURE_BINDING_2D, &active_texture);
+ glBindTexture (GL_TEXTURE_2D, self->id);
- cairo_destroy (cr);
- cairo_surface_finish (surface);
- cairo_surface_destroy (surface);
+ glGetTexImage (GL_TEXTURE_2D,
+ 0,
+ GL_BGRA,
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+ GL_UNSIGNED_INT_8_8_8_8_REV,
+#elif G_BYTE_ORDER == G_BIG_ENDIAN
+ GL_UNSIGNED_BYTE,
+#else
+#error "Unknown byte order for gdk_gl_texture_download()"
+#endif
+ data);
+
+ glBindTexture (GL_TEXTURE_2D, active_texture);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]