[gtk+/wip/ebassi/gsk-renderer: 61/126] gsk: Split surface upload from texture creation
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/ebassi/gsk-renderer: 61/126] gsk: Split surface upload from texture creation
- Date: Tue, 9 Aug 2016 16:35:52 +0000 (UTC)
commit c940cc80022b80479b8d66f4ab3d81fa65d6489e
Author: Emmanuele Bassi <ebassi gnome org>
Date: Tue Jul 12 11:15:45 2016 +0100
gsk: Split surface upload from texture creation
We're going to need a method to create textures without a surface.
gsk/gskgldriver.c | 35 ++++++++++++++++++++++++++++-------
gsk/gskgldriverprivate.h | 7 +++++--
gsk/gskglrenderer.c | 6 ++++--
3 files changed, 37 insertions(+), 11 deletions(-)
---
diff --git a/gsk/gskgldriver.c b/gsk/gskgldriver.c
index 0ed1493..57e8bfe 100644
--- a/gsk/gskgldriver.c
+++ b/gsk/gskgldriver.c
@@ -11,6 +11,8 @@ typedef struct {
GLuint texture_id;
int width;
int height;
+ GLuint min_filter;
+ GLuint mag_filter;
} Texture;
typedef struct {
@@ -197,12 +199,13 @@ gsk_gl_driver_create_texture (GskGLDriver *driver,
int width,
int height,
int min_filter,
- int mag_filter,
- cairo_surface_t *surface)
+ int mag_filter)
{
guint texture_id;
Texture t;
+ g_return_val_if_fail (GSK_IS_GL_DRIVER (driver), -1);
+
glGenTextures (1, &texture_id);
glBindTexture (GL_TEXTURE_2D, texture_id);
@@ -211,14 +214,11 @@ gsk_gl_driver_create_texture (GskGLDriver *driver,
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
- gdk_cairo_surface_upload_to_gl (surface, GL_TEXTURE_2D, width, height, NULL);
-
- if (min_filter != GL_NEAREST)
- glGenerateMipmap (GL_TEXTURE_2D);
-
t.texture_id = texture_id;
t.width = width;
t.height = height;
+ t.min_filter = min_filter;
+ t.mag_filter = mag_filter;
g_array_append_val (driver->textures, t);
return texture_id;
@@ -367,3 +367,24 @@ gsk_gl_driver_bind_vao (GskGLDriver *driver,
driver->bound_vao = v;
}
}
+
+void
+gsk_gl_driver_render_surface_to_texture (GskGLDriver *driver,
+ cairo_surface_t *surface,
+ int texture_id)
+{
+ Texture *t;
+
+ g_return_if_fail (GSK_IS_GL_DRIVER (driver));
+
+ t = gsk_gl_driver_get_texture (driver, texture_id);
+ if (t == NULL)
+ return;
+
+ glBindTexture (GL_TEXTURE_2D, t->texture_id);
+
+ gdk_cairo_surface_upload_to_gl (surface, GL_TEXTURE_2D, t->width, t->height, NULL);
+
+ if (t->min_filter != GL_NEAREST)
+ glGenerateMipmap (GL_TEXTURE_2D);
+}
diff --git a/gsk/gskgldriverprivate.h b/gsk/gskgldriverprivate.h
index 53f97cd..9fc1d8a 100644
--- a/gsk/gskgldriverprivate.h
+++ b/gsk/gskgldriverprivate.h
@@ -25,8 +25,7 @@ int gsk_gl_driver_create_texture (GskGLDriver *driver
int width,
int height,
int min_filter,
- int mag_filter,
- cairo_surface_t *surface);
+ int mag_filter);
int gsk_gl_driver_create_vao_for_quad (GskGLDriver *driver,
int position_id,
int uv_id,
@@ -40,6 +39,10 @@ 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,
+ cairo_surface_t *surface,
+ int texture_id);
+
G_END_DECLS
#endif /* __GSK_GL_DRIVER_PRIVATE_H__ */
diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c
index 6a787d1..9e070e6 100644
--- a/gsk/gskglrenderer.c
+++ b/gsk/gskglrenderer.c
@@ -719,8 +719,10 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self,
bounds.size.width,
bounds.size.height,
self->gl_min_filter,
- self->gl_mag_filter,
- surface);
+ self->gl_mag_filter);
+ gsk_gl_driver_render_surface_to_texture (self->gl_driver,
+ surface,
+ item.render_data.texture_id);
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]