[cogl] spans: Represent spans with floating point precision



commit c11036cd13140eede00d2b7d79547ffe7b9676e1
Author: Robert Bragg <robert linux intel com>
Date:   Sun Oct 23 20:20:49 2011 +0100

    spans: Represent spans with floating point precision
    
    Instead of using integers to represent spans we now use floats instead.
    This means we are no longer forced to iterate using non-normalized
    coordinates so we should hopefully be able to avoid numerous redundant
    unnormalize/normalize steps when using the spans api.
    
    Reviewed-by: Neil Roberts <neil linux intel com>

 cogl/cogl-spans.c             |    3 +--
 cogl/cogl-spans.h             |    6 +++---
 cogl/cogl-texture-2d-sliced.c |   12 ++++++------
 3 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/cogl/cogl-spans.c b/cogl/cogl-spans.c
index bf72274..d627930 100644
--- a/cogl/cogl-spans.c
+++ b/cogl/cogl-spans.c
@@ -38,8 +38,7 @@ _cogl_span_iter_update (CoglSpanIter *iter)
   iter->span = &g_array_index (iter->array, CoglSpan, iter->index);
 
   /* Offset next position by span size */
-  iter->next_pos = iter->pos +
-    (float)(iter->span->size - iter->span->waste);
+  iter->next_pos = iter->pos + iter->span->size - iter->span->waste;
 
   /* Check if span intersects the area to cover */
   if (iter->next_pos <= iter->cover_start ||
diff --git a/cogl/cogl-spans.h b/cogl/cogl-spans.h
index 1717522..c3b77c0 100644
--- a/cogl/cogl-spans.h
+++ b/cogl/cogl-spans.h
@@ -28,9 +28,9 @@
 
 typedef struct _CoglSpan
 {
-  int start;
-  int size;
-  int waste;
+  float start;
+  float size;
+  float waste;
 } CoglSpan;
 
 typedef struct _CoglSpanIter
diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c
index 0f3d355..150f05d 100644
--- a/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl-texture-2d-sliced.c
@@ -246,8 +246,8 @@ _cogl_texture_2d_sliced_set_waste (CoglTexture2DSliced *tex_2ds,
         {
           src = (bmp_data + ((src_y + (int) y_iter->intersect_start - dst_y) *
                              bmp_rowstride) +
-                 (src_x + x_span->start + x_span->size -
-                  x_span->waste - dst_x - 1) * bpp);
+                 (src_x + (int)x_span->start + (int)x_span->size -
+                  (int)x_span->waste - dst_x - 1) * bpp);
 
           dst = waste_buf;
 
@@ -295,8 +295,8 @@ _cogl_texture_2d_sliced_set_waste (CoglTexture2DSliced *tex_2ds,
 
           src = (bmp_data + ((src_x + (int) x_iter->intersect_start - dst_x) *
                              bpp) +
-                 (src_y + y_span->start + y_span->size - y_span->waste
-                  - dst_y - 1) * bmp_rowstride);
+                 (src_y + (int)y_span->start + (int)y_span->size -
+                  (int)y_span->waste - dst_y - 1) * bmp_rowstride);
 
           dst = waste_buf;
 
@@ -790,8 +790,8 @@ _cogl_texture_2d_sliced_slices_create (CoglContext *ctx,
 
           COGL_NOTE (SLICING, "CREATE SLICE (%d,%d)\tsize (%d,%d)",
                      x, y,
-                     x_span->size - x_span->waste,
-                     y_span->size - y_span->waste);
+                     (int)(x_span->size - x_span->waste),
+                     (int)(y_span->size - y_span->waste));
 
           slice_textures[y * n_x_slices + x] =
             cogl_texture_2d_new_with_size (ctx, x_span->size, y_span->size,



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