Enlightenment CVS committal

Author  : turran
Project : e17
Module  : proto/enesim

Dir     : e17/proto/enesim/src/lib/raster/rasterizer


Modified Files:
        kiia.h kiia8.c kiia16.c 


Log Message:
+ De Casteljau flat's test works now a simple manhattan distance between the 
control point and the ends
+ Added fixed precision code on utils
+ Make Kiia's algorithm use this header instead of its own implementation of 
fixed points

===================================================================
RCS file: /cvs/e/e17/proto/enesim/src/lib/raster/rasterizer/kiia.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- kiia.h      10 Dec 2007 23:04:04 -0000      1.2
+++ kiia.h      11 Dec 2007 16:03:26 -0000      1.3
@@ -1,6 +1,8 @@
 #ifndef _KIIA_H
 #define _KIIA_H
 
+#include "fixed_16p16.h"
+
 /*
  * Kiia Kallio Scanline edge-flag algorithm, check it out at:
  * http://mlab.uiah.fi/~kkallio/antialiasing/
@@ -11,16 +13,7 @@
  * - Support the clipping?
  */
 
-/* TODO Move the fixed point thing to a common place */
-#define FIXED_POINT int
-#define FIXED_POINT_SHIFT 16
-#define INT_TO_FIXED(a) ((a) << FIXED_POINT_SHIFT)
-#define FLOAT_TO_FIXED(a) (int)((a)*((float)(1 << FIXED_POINT_SHIFT)))
-
-#define FIXED_TO_INT(a) ((a) >> FIXED_POINT_SHIFT) 
-#define FIXED_TO_FLOAT(a) ((float)(a)/((float)(1 << FIXED_POINT_SHIFT)))
-#define RATIONAL_TO_FIXED(a) FLOAT_TO_FIXED(a)
-#define FIXED_TO_RATIONAL(a) FIXED_TO_FLOAT(a)
+//#define FLOAT_TO_FIXED(a) enesim_16p16_float_from(a)
 
 #define SLOPE_FIX_SHIFT 8
 #define SLOPE_FIX_STEP (1 << SLOPE_FIX_SHIFT)
@@ -39,9 +32,11 @@
 {
        int yfirst;
        int ylast;
-       FIXED_POINT x;
-       FIXED_POINT slope;
-       FIXED_POINT slope_fix;
+       
+       enesim_16p16_t x;
+       enesim_16p16_t slope;
+       enesim_16p16_t slope_fix;
+       
        int direction;
        Kiia_Edge *next; /* the next in the line */
        Kiia_Edge *gnext; /* the next while generating the AET */
@@ -68,8 +63,8 @@
        Enesim_Scanline_Mask sl; /* FIXME is it needed ??? */
 } Kiia;
 
-
-static const FIXED_POINT _offsets[KIIA_SUBPIXEL_COUNT] = KIIA_SUBPIXEL_OFFSETS;
+static float _float_offsets[KIIA_SUBPIXEL_COUNT] = KIIA_SUBPIXEL_OFFSETS;
+static enesim_16p16_t _offsets[KIIA_SUBPIXEL_COUNT];
 
 /*============================================================================*
  *                                  Local                                     
* 
@@ -151,16 +146,16 @@
        /* create the new edge */
        e = calloc(1, sizeof(Kiia_Edge));
        slope = (xend - xstart) / (yend - ystart);
-       e->slope = RATIONAL_TO_FIXED(slope);
+       e->slope = enesim_16p16_float_from(slope);
        if (last_line - first_line >= SLOPE_FIX_STEP)
        {
-               e->slope_fix = RATIONAL_TO_FIXED(slope * SLOPE_FIX_STEP) - 
(e->slope << SLOPE_FIX_SHIFT);
+               e->slope_fix = enesim_16p16_float_from(slope * SLOPE_FIX_STEP) 
- (e->slope << SLOPE_FIX_SHIFT);
        }
        else
        {
                e->slope_fix = 0;
        }
-       e->x = RATIONAL_TO_FIXED(xstart + (((float)first_line - ystart) * 
slope));
+       e->x = enesim_16p16_float_from(xstart + (((float)first_line - ystart) * 
slope));
        e->direction = direction;
        e->yfirst = first_line;
        e->ylast = last_line;
@@ -188,16 +183,16 @@
        k->vertex_last = v;
 }
 
-static inline FIXED_POINT _dda(Kiia *k, FIXED_POINT xs, int ys, int ye, 
FIXED_POINT slope, KIIA_SUBPIXEL_DATA mask)
+static inline enesim_16p16_t _dda(Kiia *k, enesim_16p16_t xs, int ys, int ye, 
enesim_16p16_t slope, KIIA_SUBPIXEL_DATA mask)
 {
-       FIXED_POINT x;
+       enesim_16p16_t x;
        int y;
 
        x = xs;
 
        for (y = ys; y <= ye; y++)
        {
-               int xp =  FIXED_TO_INT((x + _offsets[y]));
+               int xp =  enesim_16p16_int_to((x + _offsets[y]));
                
                k->mask[xp] ^= mask;
                mask <<= 1;
@@ -219,13 +214,13 @@
                {
                        int ye;
                        int xe;
-                       FIXED_POINT x;
+                       enesim_16p16_t x;
 
                        ye = curr_edge->ylast & (KIIA_SUBPIXEL_COUNT - 1);
                        x = _dda(k, curr_edge->x, 0, ye, curr_edge->slope, 1);
-                       xe = FIXED_TO_INT(x - curr_edge->slope);
+                       xe = enesim_16p16_int_to(x - curr_edge->slope);
                
-                       enesim_extender_int_unsorted_add(length, 
FIXED_TO_INT(curr_edge->x), xe);
+                       enesim_extender_int_unsorted_add(length, 
enesim_16p16_int_to(curr_edge->x), xe);
                        /* remove the edge from the AET */
                        curr_edge = curr_edge->gnext;
                        if (prev_edge)
@@ -236,11 +231,11 @@
                else
                {
                        int xe;
-                       FIXED_POINT x;
+                       enesim_16p16_t x;
 
                        x = _dda(k, curr_edge->x, 0, KIIA_SUBPIXEL_COUNT - 1, 
curr_edge->slope, 1);
-                       xe = FIXED_TO_INT(x - curr_edge->slope);
-                       enesim_extender_int_unsorted_add(length, 
FIXED_TO_INT(curr_edge->x), xe);
+                       xe = enesim_16p16_int_to(x - curr_edge->slope);
+                       enesim_extender_int_unsorted_add(length, 
enesim_16p16_int_to(curr_edge->x), xe);
                        /* update the edge */
                        if ((curr_line & SLOPE_FIX_SCANLINE_MASK) == 0)
                                curr_edge->x = x + curr_edge->slope_fix;
@@ -265,23 +260,23 @@
                                int ye;
                                int ys;
                                int xe;
-                               FIXED_POINT x;
+                               enesim_16p16_t x;
                                ye = curr_edge->ylast & (KIIA_SUBPIXEL_COUNT - 
1);
                                ys = curr_edge->yfirst & (KIIA_SUBPIXEL_COUNT - 
1);
                                x = _dda(k, curr_edge->x, ys, ye, 
curr_edge->slope, 1 << ys);
-                               xe = FIXED_TO_INT(x - curr_edge->slope);
-                               enesim_extender_int_unsorted_add(length, 
FIXED_TO_INT(curr_edge->x), xe);
+                               xe = enesim_16p16_int_to(x - curr_edge->slope);
+                               enesim_extender_int_unsorted_add(length, 
enesim_16p16_int_to(curr_edge->x), xe);
                                /* ignore this edge */
                        }
                        else
                        {
                                int ys;
                                int xe;
-                               FIXED_POINT x;
+                               enesim_16p16_t x;
                                ys = curr_edge->yfirst & (KIIA_SUBPIXEL_COUNT - 
1);
                                x = _dda(k, curr_edge->x, ys, 
KIIA_SUBPIXEL_COUNT - 1, curr_edge->slope, 1 << ys);
-                               xe = FIXED_TO_INT(x - curr_edge->slope);
-                               enesim_extender_int_unsorted_add(length, 
FIXED_TO_INT(curr_edge->x), xe);
+                               xe = enesim_16p16_int_to(x - curr_edge->slope);
+                               enesim_extender_int_unsorted_add(length, 
enesim_16p16_int_to(curr_edge->x), xe);
                                curr_edge->x = x;
                                /* add the edge to the AET */
                                if (prev_edge)
@@ -454,6 +449,7 @@
 {
        Kiia *k;
        Enesim_Rasterizer *r;
+       int i;
                
        k = calloc(1, sizeof(Kiia)); 
        r = enesim_rasterizer_new(k, func, boundaries, ENESIM_SCANLINE_MASK);
@@ -462,6 +458,11 @@
        /* TODO explain the 3 */
        k->mask = calloc(boundaries.w + 3, sizeof(KIIA_SUBPIXEL_DATA));
        k->coverages = calloc(boundaries.w + 3, sizeof(DATA8));
+       /* convert the offsets to fixed point */
+       for (i = 0; i < KIIA_SUBPIXEL_COUNT; i++)
+       {
+               _offsets[i] = enesim_16p16_float_from(_float_offsets[i]);       
+       }
        
        return r;
 }
===================================================================
RCS file: /cvs/e/e17/proto/enesim/src/lib/raster/rasterizer/kiia8.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- kiia8.c     10 Dec 2007 23:04:04 -0000      1.2
+++ kiia8.c     11 Dec 2007 16:03:26 -0000      1.3
@@ -29,13 +29,13 @@
  * [][]##[][][][][] 2
  */
 #define KIIA_SUBPIXEL_OFFSETS { \
-       FLOAT_TO_FIXED((5.0f/8.0f)),\
-       FLOAT_TO_FIXED((0.0f/8.0f)),\
-       FLOAT_TO_FIXED((3.0f/8.0f)),\
-       FLOAT_TO_FIXED((6.0f/8.0f)),\
-       FLOAT_TO_FIXED((1.0f/8.0f)),\
-       FLOAT_TO_FIXED((4.0f/8.0f)),\
-       FLOAT_TO_FIXED((7.0f/8.0f)) \
+       (5.0f/8.0f),\
+       (0.0f/8.0f),\
+       (3.0f/8.0f),\
+       (6.0f/8.0f),\
+       (1.0f/8.0f),\
+       (4.0f/8.0f),\
+       (7.0f/8.0f) \
 }
 
 #include "kiia.h"
===================================================================
RCS file: /cvs/e/e17/proto/enesim/src/lib/raster/rasterizer/kiia16.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- kiia16.c    10 Dec 2007 23:04:04 -0000      1.2
+++ kiia16.c    11 Dec 2007 16:03:26 -0000      1.3
@@ -39,22 +39,22 @@
 
 
 #define KIIA_SUBPIXEL_OFFSETS { \
-       FLOAT_TO_FIXED((1.0f/16.0f)),\
-       FLOAT_TO_FIXED((8.0f/16.0f)),\
-       FLOAT_TO_FIXED((4.0f/16.0f)),\
-       FLOAT_TO_FIXED((15.0f/16.0f)),\
-       FLOAT_TO_FIXED((11.0f/16.0f)),\
-       FLOAT_TO_FIXED((2.0f/16.0f)),\
-       FLOAT_TO_FIXED((6.0f/16.0f)),\
-       FLOAT_TO_FIXED((14.0f/16.0f)),\
-       FLOAT_TO_FIXED((10.0f/16.0f)),\
-       FLOAT_TO_FIXED((3.0f/16.0f)),\
-       FLOAT_TO_FIXED((7.0f/16.0f)),\
-       FLOAT_TO_FIXED((12.0f/16.0f)),\
-       FLOAT_TO_FIXED((0.0f/16.0f)),\
-       FLOAT_TO_FIXED((9.0f/16.0f)),\
-       FLOAT_TO_FIXED((5.0f/16.0f)),\
-       FLOAT_TO_FIXED((13.0f/16.0f))\
+       (1.0f/16.0f),\
+       (8.0f/16.0f),\
+       (4.0f/16.0f),\
+       (15.0f/16.0f),\
+       (11.0f/16.0f),\
+       (2.0f/16.0f),\
+       (6.0f/16.0f),\
+       (14.0f/16.0f),\
+       (10.0f/16.0f),\
+       (3.0f/16.0f),\
+       (7.0f/16.0f),\
+       (12.0f/16.0f),\
+       (0.0f/16.0f),\
+       (9.0f/16.0f),\
+       (5.0f/16.0f),\
+       (13.0f/16.0f)\
 }
 
 #include "kiia.h"



-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to