Move some utility functions from pixman-edge.c to pixman-utils.c
authorSøren Sandmann <sandmann@redhat.com>
Sun, 17 Jun 2007 01:40:43 +0000 (21:40 -0400)
committerSøren Sandmann <sandmann@redhat.com>
Sun, 17 Jun 2007 01:40:43 +0000 (21:40 -0400)
Set up so pixman-edge.c is compiled twice.

pixman/Makefile.am
pixman/pixman-edge.c
pixman/pixman-private.h
pixman/pixman-utils.c

index 6e9c75f..a444fe7 100644 (file)
@@ -19,7 +19,8 @@ libpixmaninclude_HEADERS = pixman.h
 # wrapper library
 noinst_LTLIBRARIES = libpixmanwrapper.la
 libpixmanwrapper_la_SOURCES =  \
-       pixman-compose.c
+       pixman-compose.c        \
+       pixman-edge.c
 libpixmanwrapper_la_CFLAGS = $(DEP_CFLAGS) -DPIXMAN_FB_ACCESSORS
 
 
index cec1902..bfa34e3 100644 (file)
 #include "pixman.h"
 #include "pixman-private.h"
 
+#ifdef PIXMAN_FB_ACCESSORS
+#define PIXMAN_RASTERIZE_EDGES pixman_rasterize_edges_accessors
+#else
+#define PIXMAN_RASTERIZE_EDGES pixman_rasterize_edges_no_accessors
+#endif
+
 /*
  * 4 bit alpha
  */
@@ -284,8 +290,11 @@ fbRasterizeEdges8 (pixman_image_t       *image,
     }
 }
 
+#ifndef PIXMAN_FB_ACCESSORS
+static
+#endif
 void
-pixman_rasterize_edges (pixman_image_t *image,
+PIXMAN_RASTERIZE_EDGES (pixman_image_t *image,
                        pixman_edge_t   *l,
                        pixman_edge_t   *r,
                        pixman_fixed_t  t,
@@ -305,175 +314,23 @@ pixman_rasterize_edges (pixman_image_t *image,
     }
 }
 
-/*
- * Compute the smallest value no less than y which is on a
- * grid row
- */
-
-pixman_fixed_t
-pixman_sample_ceil_y (pixman_fixed_t y, int n)
-{
-    pixman_fixed_t   f = pixman_fixed_frac(y);
-    pixman_fixed_t   i = pixman_fixed_floor(y);
-    
-    f = ((f + Y_FRAC_FIRST(n)) / STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
-    if (f > Y_FRAC_LAST(n))
-    {
-       f = Y_FRAC_FIRST(n);
-       i += pixman_fixed_1;
-    }
-    return (i | f);
-}
-
-#define _div(a,b)    ((a) >= 0 ? (a) / (b) : -((-(a) + (b) - 1) / (b)))
-
-/*
- * Compute the largest value no greater than y which is on a
- * grid row
- */
-pixman_fixed_t
-pixman_sample_floor_y (pixman_fixed_t y, int n)
-{
-    pixman_fixed_t   f = pixman_fixed_frac(y);
-    pixman_fixed_t   i = pixman_fixed_floor (y);
-    
-    f = _div(f - Y_FRAC_FIRST(n), STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
-    if (f < Y_FRAC_FIRST(n))
-    {
-       f = Y_FRAC_LAST(n);
-       i -= pixman_fixed_1;
-    }
-    return (i | f);
-}
+#ifndef PIXMAN_FB_ACCESSORS
 
-/*
- * Step an edge by any amount (including negative values)
- */
 void
-pixman_edge_step (pixman_edge_t *e, int n)
-{
-    pixman_fixed_48_16_t       ne;
-
-    e->x += n * e->stepx;
-    
-    ne = e->e + n * (pixman_fixed_48_16_t) e->dx;
-    
-    if (n >= 0)
-    {
-       if (ne > 0)
-       {
-           int nx = (ne + e->dy - 1) / e->dy;
-           e->e = ne - nx * (pixman_fixed_48_16_t) e->dy;
-           e->x += nx * e->signdx;
-       }
-    }
-    else
-    {
-       if (ne <= -e->dy)
-       {
-           int nx = (-ne) / e->dy;
-           e->e = ne + nx * (pixman_fixed_48_16_t) e->dy;
-           e->x -= nx * e->signdx;
-       }
-    }
-}
-
-/*
- * A private routine to initialize the multi-step
- * elements of an edge structure
- */
-static void
-_pixman_edge_tMultiInit (pixman_edge_t *e, int n, pixman_fixed_t *stepx_p, pixman_fixed_t *dx_p)
-{
-    pixman_fixed_t     stepx;
-    pixman_fixed_48_16_t       ne;
-    
-    ne = n * (pixman_fixed_48_16_t) e->dx;
-    stepx = n * e->stepx;
-    if (ne > 0)
-    {
-       int nx = ne / e->dy;
-       ne -= nx * e->dy;
-       stepx += nx * e->signdx;
-    }
-    *dx_p = ne;
-    *stepx_p = stepx;
-}
-
-/*
- * Initialize one edge structure given the line endpoints and a
- * starting y value
- */
-void
-pixman_edge_init (pixman_edge_t        *e,
-                 int           n,
-                 pixman_fixed_t                y_start,
-                 pixman_fixed_t                x_top,
-                 pixman_fixed_t                y_top,
-                 pixman_fixed_t                x_bot,
-                 pixman_fixed_t                y_bot)
-{
-    pixman_fixed_t     dx, dy;
-
-    e->x = x_top;
-    e->e = 0;
-    dx = x_bot - x_top;
-    dy = y_bot - y_top;
-    e->dy = dy;
-    e->dx = 0;
-    if (dy)
-    {
-       if (dx >= 0)
-       {
-           e->signdx = 1;
-           e->stepx = dx / dy;
-           e->dx = dx % dy;
-           e->e = -dy;
-       }
-       else
-       {
-           e->signdx = -1;
-           e->stepx = -(-dx / dy);
-           e->dx = -dx % dy;
-           e->e = 0;
-       }
-    
-       _pixman_edge_tMultiInit (e, STEP_Y_SMALL(n), &e->stepx_small, &e->dx_small);
-       _pixman_edge_tMultiInit (e, STEP_Y_BIG(n), &e->stepx_big, &e->dx_big);
-    }
-    pixman_edge_step (e, y_start - y_top);
-}
-
-/*
- * Initialize one edge structure given a line, starting y value
- * and a pixel offset for the line
- */
-void
-pixman_line_fixed_edge_init (pixman_edge_t *e,
-                            int            n,
-                            pixman_fixed_t         y,
-                            const pixman_line_fixed_t *line,
-                            int            x_off,
-                            int            y_off)
+pixman_rasterize_edges (pixman_image_t *image,
+                       pixman_edge_t   *l,
+                       pixman_edge_t   *r,
+                       pixman_fixed_t  t,
+                       pixman_fixed_t  b)
 {
-    pixman_fixed_t     x_off_fixed = pixman_int_to_fixed(x_off);
-    pixman_fixed_t     y_off_fixed = pixman_int_to_fixed(y_off);
-    const pixman_point_fixed_t *top, *bot;
-
-    if (line->p1.y <= line->p2.y)
+    if (image->common.read_func        || image->common.write_func)
     {
-       top = &line->p1;
-       bot = &line->p2;
+       return pixman_rasterize_edges_accessors (image, l, r, t, b);
     }
     else
     {
-       top = &line->p2;
-       bot = &line->p1;
+       return pixman_rasterize_edges_no_accessors (image, l, r, t, b);
     }
-    pixman_edge_init (e, n, y,
-                   top->x + x_off_fixed,
-                   top->y + y_off_fixed,
-                   bot->x + x_off_fixed,
-                   bot->y + y_off_fixed);
 }
 
+#endif
index 9ac871d..222e4cc 100644 (file)
@@ -134,8 +134,6 @@ extern FbComposeFunctions pixman_composeFunctions;
 
 void pixman_composite_rect_general_accessors (const FbComposeData *data,
                                              uint32_t *scanline_buffer);
-void pixman_composite_rect_general_no_acessors (const FbComposeData *data,
-                                               uint32_t *scanline_buffer);
 void pixman_composite_rect_general (const FbComposeData *data,
                                    uint32_t *scanline_buffer);
 
@@ -762,4 +760,11 @@ union pixman_image
     }                              \
 }
 
+void
+pixman_rasterize_edges_accessors (pixman_image_t *image,
+                                 pixman_edge_t *l,
+                                 pixman_edge_t *r,
+                                 pixman_fixed_t        t,
+                                 pixman_fixed_t        b);
+
 #endif /* PIXMAN_PRIVATE_H */
index 9d611e9..f831ebe 100644 (file)
@@ -100,3 +100,175 @@ pixman_fill (uint32_t *bits,
        return FALSE;
 }
            
+
+/*
+ * Compute the smallest value no less than y which is on a
+ * grid row
+ */
+
+pixman_fixed_t
+pixman_sample_ceil_y (pixman_fixed_t y, int n)
+{
+    pixman_fixed_t   f = pixman_fixed_frac(y);
+    pixman_fixed_t   i = pixman_fixed_floor(y);
+    
+    f = ((f + Y_FRAC_FIRST(n)) / STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
+    if (f > Y_FRAC_LAST(n))
+    {
+       f = Y_FRAC_FIRST(n);
+       i += pixman_fixed_1;
+    }
+    return (i | f);
+}
+
+#define _div(a,b)    ((a) >= 0 ? (a) / (b) : -((-(a) + (b) - 1) / (b)))
+
+/*
+ * Compute the largest value no greater than y which is on a
+ * grid row
+ */
+pixman_fixed_t
+pixman_sample_floor_y (pixman_fixed_t y, int n)
+{
+    pixman_fixed_t   f = pixman_fixed_frac(y);
+    pixman_fixed_t   i = pixman_fixed_floor (y);
+    
+    f = _div(f - Y_FRAC_FIRST(n), STEP_Y_SMALL(n)) * STEP_Y_SMALL(n) + Y_FRAC_FIRST(n);
+    if (f < Y_FRAC_FIRST(n))
+    {
+       f = Y_FRAC_LAST(n);
+       i -= pixman_fixed_1;
+    }
+    return (i | f);
+}
+
+/*
+ * Step an edge by any amount (including negative values)
+ */
+void
+pixman_edge_step (pixman_edge_t *e, int n)
+{
+    pixman_fixed_48_16_t       ne;
+
+    e->x += n * e->stepx;
+    
+    ne = e->e + n * (pixman_fixed_48_16_t) e->dx;
+    
+    if (n >= 0)
+    {
+       if (ne > 0)
+       {
+           int nx = (ne + e->dy - 1) / e->dy;
+           e->e = ne - nx * (pixman_fixed_48_16_t) e->dy;
+           e->x += nx * e->signdx;
+       }
+    }
+    else
+    {
+       if (ne <= -e->dy)
+       {
+           int nx = (-ne) / e->dy;
+           e->e = ne + nx * (pixman_fixed_48_16_t) e->dy;
+           e->x -= nx * e->signdx;
+       }
+    }
+}
+
+/*
+ * A private routine to initialize the multi-step
+ * elements of an edge structure
+ */
+static void
+_pixman_edge_tMultiInit (pixman_edge_t *e, int n, pixman_fixed_t *stepx_p, pixman_fixed_t *dx_p)
+{
+    pixman_fixed_t     stepx;
+    pixman_fixed_48_16_t       ne;
+    
+    ne = n * (pixman_fixed_48_16_t) e->dx;
+    stepx = n * e->stepx;
+    if (ne > 0)
+    {
+       int nx = ne / e->dy;
+       ne -= nx * e->dy;
+       stepx += nx * e->signdx;
+    }
+    *dx_p = ne;
+    *stepx_p = stepx;
+}
+
+/*
+ * Initialize one edge structure given the line endpoints and a
+ * starting y value
+ */
+void
+pixman_edge_init (pixman_edge_t        *e,
+                 int           n,
+                 pixman_fixed_t                y_start,
+                 pixman_fixed_t                x_top,
+                 pixman_fixed_t                y_top,
+                 pixman_fixed_t                x_bot,
+                 pixman_fixed_t                y_bot)
+{
+    pixman_fixed_t     dx, dy;
+
+    e->x = x_top;
+    e->e = 0;
+    dx = x_bot - x_top;
+    dy = y_bot - y_top;
+    e->dy = dy;
+    e->dx = 0;
+    if (dy)
+    {
+       if (dx >= 0)
+       {
+           e->signdx = 1;
+           e->stepx = dx / dy;
+           e->dx = dx % dy;
+           e->e = -dy;
+       }
+       else
+       {
+           e->signdx = -1;
+           e->stepx = -(-dx / dy);
+           e->dx = -dx % dy;
+           e->e = 0;
+       }
+    
+       _pixman_edge_tMultiInit (e, STEP_Y_SMALL(n), &e->stepx_small, &e->dx_small);
+       _pixman_edge_tMultiInit (e, STEP_Y_BIG(n), &e->stepx_big, &e->dx_big);
+    }
+    pixman_edge_step (e, y_start - y_top);
+}
+
+/*
+ * Initialize one edge structure given a line, starting y value
+ * and a pixel offset for the line
+ */
+void
+pixman_line_fixed_edge_init (pixman_edge_t *e,
+                            int            n,
+                            pixman_fixed_t         y,
+                            const pixman_line_fixed_t *line,
+                            int            x_off,
+                            int            y_off)
+{
+    pixman_fixed_t     x_off_fixed = pixman_int_to_fixed(x_off);
+    pixman_fixed_t     y_off_fixed = pixman_int_to_fixed(y_off);
+    const pixman_point_fixed_t *top, *bot;
+
+    if (line->p1.y <= line->p2.y)
+    {
+       top = &line->p1;
+       bot = &line->p2;
+    }
+    else
+    {
+       top = &line->p2;
+       bot = &line->p1;
+    }
+    pixman_edge_init (e, n, y,
+                   top->x + x_off_fixed,
+                   top->y + y_off_fixed,
+                   bot->x + x_off_fixed,
+                   bot->y + y_off_fixed);
+}