[gtk+/wip/baedert/gl: 21/95] GskGLDriver: Use float for texture size in create_texture



commit 78be5f84c44d42eb7bb1f35522b4b0d55e631235
Author: Timm Bäder <mail baedert org>
Date:   Wed Nov 15 18:40:57 2017 +0100

    GskGLDriver: Use float for texture size in create_texture
    
    Render nodes can end up with bounds < 1 since they are floats, and the
    implicit cast to int ends up creating a texture with 0 width or height.
    Use ceil() instead in create_texture so we don't have to do that on the
    caller side everywhere.

 gsk/gskgldriver.c        |   15 ++++++++-------
 gsk/gskgldriverprivate.h |    4 ++--
 gsk/gskglrenderer.c      |    4 ++--
 3 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/gsk/gskgldriver.c b/gsk/gskgldriver.c
index 68c9148..a758c2d 100644
--- a/gsk/gskgldriver.c
+++ b/gsk/gskgldriver.c
@@ -389,11 +389,13 @@ find_texture_by_size (GHashTable *textures,
 
 static Texture *
 create_texture (GskGLDriver *driver,
-                int          width,
-                int          height)
+                float        fwidth,
+                float        fheight)
 {
   guint texture_id;
   Texture *t;
+  int width = ceilf (fwidth);
+  int height = ceilf (fheight);
 
   if (width >= driver->max_texture_size ||
       height >= driver->max_texture_size)
@@ -456,7 +458,7 @@ gsk_gl_driver_get_texture_for_texture (GskGLDriver *driver,
       if (t->min_filter == min_filter && t->mag_filter == mag_filter)
         return t->texture_id;
     }
-  
+
   t = create_texture (driver, gdk_texture_get_width (texture), gdk_texture_get_height (texture));
 
   if (gdk_texture_set_render_data (texture, driver, t, gsk_gl_driver_release_texture))
@@ -476,8 +478,8 @@ gsk_gl_driver_get_texture_for_texture (GskGLDriver *driver,
 
 int
 gsk_gl_driver_create_texture (GskGLDriver *driver,
-                              int          width,
-                              int          height)
+                              float        width,
+                              float        height)
 {
   Texture *t;
 
@@ -644,8 +646,7 @@ gsk_gl_driver_create_render_target (GskGLDriver *driver,
 
   g_array_append_val (t->fbos, f);
 
-  g_assert (glCheckFramebufferStatus (GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
-
+  g_assert_cmpint (glCheckFramebufferStatus (GL_FRAMEBUFFER), ==, GL_FRAMEBUFFER_COMPLETE);
   glBindFramebuffer (GL_FRAMEBUFFER, driver->default_fbo.fbo_id);
 
   return fbo_id;
diff --git a/gsk/gskgldriverprivate.h b/gsk/gskgldriverprivate.h
index 955a2a8..5a138b1 100644
--- a/gsk/gskgldriverprivate.h
+++ b/gsk/gskgldriverprivate.h
@@ -28,8 +28,8 @@ int             gsk_gl_driver_get_texture_for_texture   (GskGLDriver     *driver
                                                          int              min_filter,
                                                          int              mag_filter);
 int             gsk_gl_driver_create_texture            (GskGLDriver     *driver,
-                                                         int              width,
-                                                         int              height);
+                                                         float            width,
+                                                         float            height);
 int             gsk_gl_driver_create_vao_for_quad       (GskGLDriver     *driver,
                                                          int              position_id,
                                                          int              uv_id,
diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c
index 88ee17b..7634359 100644
--- a/gsk/gskglrenderer.c
+++ b/gsk/gskglrenderer.c
@@ -979,8 +979,8 @@ gsk_gl_renderer_add_render_item (GskGLRenderer           *self,
         cairo_t *cr;
 
         surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
-                                              item.size.width * self->scale_factor,
-                                              item.size.height * self->scale_factor);
+                                              ceilf (item.size.width) * self->scale_factor,
+                                              ceilf (item.size.height) * self->scale_factor);
         cairo_surface_set_device_scale (surface, self->scale_factor, self->scale_factor);
         cr = cairo_create (surface);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]