[gtk/wip/chergert/glproto: 803/920] make closer to glutilsprivate.h implementation




commit 1502676ee2e91959fba5354d1b51fa7398a3e19f
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jan 28 21:32:27 2021 -0800

    make closer to glutilsprivate.h implementation

 gsk/next/gskglrenderjob.c   |  6 +++---
 gsk/next/ninesliceprivate.h | 14 +++++++-------
 2 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/gsk/next/gskglrenderjob.c b/gsk/next/gskglrenderjob.c
index a4f72de85f..8852ad8258 100644
--- a/gsk/next/gskglrenderjob.c
+++ b/gsk/next/gskglrenderjob.c
@@ -2143,7 +2143,7 @@ gsk_gl_render_job_visit_blurred_outset_shadow_node (GskGLRenderJob *job,
       /* Increase by the spread */
       gsk_rounded_rect_shrink (&scaled_outline, -spread, -spread, -spread, -spread);
       /* Grow bounds but don't grow corners */
-      graphene_rect_inset (&scaled_outline.bounds, -half_blur_extra, -half_blur_extra);
+      graphene_rect_inset (&scaled_outline.bounds, - blur_extra / 2.0, - blur_extra / 2.0);
       /* For the center part, we add a few pixels */
       scaled_outline.bounds.size.width += SHADOW_EXTRA_SIZE;
       scaled_outline.bounds.size.height += SHADOW_EXTRA_SIZE;
@@ -2151,8 +2151,8 @@ gsk_gl_render_job_visit_blurred_outset_shadow_node (GskGLRenderJob *job,
       do_slicing = TRUE;
     }
 
-  texture_width = ceil ((scaled_outline.bounds.size.width + blur_extra) * scale_x);
-  texture_height = ceil ((scaled_outline.bounds.size.height + blur_extra) * scale_y);
+  texture_width = (int)ceil ((scaled_outline.bounds.size.width + blur_extra) * scale_x);
+  texture_height = (int)ceil ((scaled_outline.bounds.size.height + blur_extra) * scale_y);
 
   scaled_outline.bounds.origin.x = extra_blur_pixels;
   scaled_outline.bounds.origin.y = extra_blur_pixels;
diff --git a/gsk/next/ninesliceprivate.h b/gsk/next/ninesliceprivate.h
index 86ac1ac91a..2bf1c006ff 100644
--- a/gsk/next/ninesliceprivate.h
+++ b/gsk/next/ninesliceprivate.h
@@ -79,7 +79,7 @@ nine_slice_rounded_rect (GskGLTextureNineSlice *slices,
 
   /* Left center */
   slices[3].rect.x = origin->x;
-  slices[3].rect.y = origin->y + size->height / 2.0;
+  slices[3].rect.y = origin->y + size->height / 2;
   slices[3].rect.width = left_width;
   slices[3].rect.height = 1;
 
@@ -124,8 +124,8 @@ nine_slice_to_texture_coords (GskGLTextureNineSlice *slices,
                               int                    texture_width,
                               int                    texture_height)
 {
-  float fw = (float)texture_width;
-  float fh = (float)texture_height;
+  float fw = texture_width;
+  float fh = texture_height;
 
   for (guint i = 0; i < 9; i++)
     {
@@ -133,16 +133,16 @@ nine_slice_to_texture_coords (GskGLTextureNineSlice *slices,
 
       slice->area.origin.x = slice->rect.x / fw;
       slice->area.origin.y = 1.0 - ((slice->rect.y + slice->rect.height) / fh);
-      slice->area.size.width = slice->rect.width / fw;
-      slice->area.size.height = slice->rect.height / fh;
+      slice->area.size.width = ((slice->rect.x + slice->rect.width) / fw) - slice->area.origin.x;
+      slice->area.size.height = (1.0 - (slice->rect.y / fh)) - slice->area.origin.y;
 
 #ifdef G_ENABLE_DEBUG
       g_assert_cmpfloat (slice->area.origin.x, >=, 0);
       g_assert_cmpfloat (slice->area.origin.x, <=, 1);
       g_assert_cmpfloat (slice->area.origin.y, >=, 0);
       g_assert_cmpfloat (slice->area.origin.y, <=, 1);
-      g_assert_cmpfloat (slice->area.origin.x + slice->area.size.width, <=, 1);
-      g_assert_cmpfloat (slice->area.origin.y + slice->area.size.height, <=, 1);
+      g_assert_cmpfloat (slice->area.size.width, >, 0);
+      g_assert_cmpfloat (slice->area.size.height, >, 0);
 #endif
     }
 }


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