[gtk+/wip/ebassi/gsk-renderer: 461/545] gsk: Rework surface -> texture API
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/ebassi/gsk-renderer: 461/545] gsk: Rework surface -> texture API
- Date: Mon, 17 Oct 2016 13:49:56 +0000 (UTC)
commit b4fdd3f422eb894812d119aa9a4202eca5675dfe
Author: Emmanuele Bassi <ebassi gnome org>
Date: Tue Jul 19 14:32:17 2016 +0100
gsk: Rework surface -> texture API
Drop the texture parameters handling from the texture creation, and
associate them with the contents upload. Also, rename the function to
something more in line with what it does.
gsk/gskgldriver.c | 27 ++++++++++++++++++---------
gsk/gskgldriverprivate.h | 10 +++++-----
gsk/gskglrenderer.c | 10 +++++-----
3 files changed, 28 insertions(+), 19 deletions(-)
---
diff --git a/gsk/gskgldriver.c b/gsk/gskgldriver.c
index 01caa00..634cb54 100644
--- a/gsk/gskgldriver.c
+++ b/gsk/gskgldriver.c
@@ -243,9 +243,7 @@ gsk_gl_driver_get_vao (GskGLDriver *driver,
int
gsk_gl_driver_create_texture (GskGLDriver *driver,
int width,
- int height,
- int min_filter,
- int mag_filter)
+ int height)
{
guint texture_id;
Texture *t;
@@ -257,15 +255,15 @@ gsk_gl_driver_create_texture (GskGLDriver *driver,
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
t = texture_new ();
t->texture_id = texture_id;
t->width = width;
t->height = height;
- t->min_filter = min_filter;
- t->mag_filter = mag_filter;
+ t->min_filter = GL_NEAREST;
+ t->mag_filter = GL_NEAREST;
g_hash_table_insert (driver->textures, GUINT_TO_POINTER (texture_id), t);
return texture_id;
@@ -441,9 +439,11 @@ gsk_gl_driver_bind_render_target (GskGLDriver *driver,
}
void
-gsk_gl_driver_render_surface_to_texture (GskGLDriver *driver,
+gsk_gl_driver_init_texture_with_surface (GskGLDriver *driver,
+ int texture_id,
cairo_surface_t *surface,
- int texture_id)
+ int min_filter,
+ int mag_filter)
{
Texture *t;
@@ -455,8 +455,17 @@ gsk_gl_driver_render_surface_to_texture (GskGLDriver *driver,
glBindTexture (GL_TEXTURE_2D, t->texture_id);
+ if (min_filter != t->min_filter)
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
+
+ if (mag_filter != t->mag_filter)
+ glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
+
gdk_cairo_surface_upload_to_gl (surface, GL_TEXTURE_2D, t->width, t->height, NULL);
+ t->min_filter = min_filter;
+ t->mag_filter = mag_filter;
+
if (t->min_filter != GL_NEAREST)
glGenerateMipmap (GL_TEXTURE_2D);
}
diff --git a/gsk/gskgldriverprivate.h b/gsk/gskgldriverprivate.h
index d5ddf46..27d7966 100644
--- a/gsk/gskgldriverprivate.h
+++ b/gsk/gskgldriverprivate.h
@@ -23,9 +23,7 @@ void gsk_gl_driver_end_frame (GskGLDriver *driver
int gsk_gl_driver_create_texture (GskGLDriver *driver,
int width,
- int height,
- int min_filter,
- int mag_filter);
+ int height);
int gsk_gl_driver_create_vao_for_quad (GskGLDriver *driver,
int position_id,
int uv_id,
@@ -41,9 +39,11 @@ void gsk_gl_driver_bind_mask_texture (GskGLDriver *driver
void gsk_gl_driver_bind_vao (GskGLDriver *driver,
int vao_id);
-void gsk_gl_driver_render_surface_to_texture (GskGLDriver *driver,
+void gsk_gl_driver_init_texture_with_surface (GskGLDriver *driver,
+ int texture_id,
cairo_surface_t *surface,
- int texture_id);
+ int min_filter,
+ int mag_filter);
G_END_DECLS
diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c
index 2ada400..8e0bc2c 100644
--- a/gsk/gskglrenderer.c
+++ b/gsk/gskglrenderer.c
@@ -720,12 +720,12 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self,
/* Upload the Cairo surface to a GL texture */
item.render_data.texture_id = gsk_gl_driver_create_texture (self->gl_driver,
bounds.size.width,
- bounds.size.height,
- self->gl_min_filter,
- self->gl_mag_filter);
- gsk_gl_driver_render_surface_to_texture (self->gl_driver,
+ bounds.size.height);
+ gsk_gl_driver_init_texture_with_surface (self->gl_driver,
+ item.render_data.texture_id,
surface,
- item.render_data.texture_id);
+ self->gl_min_filter,
+ self->gl_mag_filter);
GSK_NOTE (OPENGL, g_print ("Adding node <%s>[%p] to render items\n",
node->name != NULL ? node->name : "unnamed",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]