From 1413bb7a5ddc2d49109a1e9669fab155352bc3c7 Mon Sep 17 00:00:00 2001 From: Soren Sandmann Pedersen Date: Tue, 22 May 2007 11:58:46 -0400 Subject: [PATCH] Add edge data types --- pixman/pixman-private.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ pixman/pixman.h | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 96 insertions(+), 1 deletion(-) diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h index 85a670f..0d5125e 100644 --- a/pixman/pixman-private.h +++ b/pixman/pixman-private.h @@ -648,4 +648,53 @@ void pixmanCompositeRect (const FbComposeData *data, (out_stride) * (y) + (mul) * (x); \ } while (0) + +/* + * Edges + */ + +#define MAX_ALPHA(n) ((1 << (n)) - 1) +#define N_Y_FRAC(n) ((n) == 1 ? 1 : (1 << ((n)/2)) - 1) +#define N_X_FRAC(n) ((1 << ((n)/2)) + 1) + +#define STEP_Y_SMALL(n) (xFixed1 / N_Y_FRAC(n)) +#define STEP_Y_BIG(n) (xFixed1 - (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n)) + +#define Y_FRAC_FIRST(n) (STEP_Y_SMALL(n) / 2) +#define Y_FRAC_LAST(n) (Y_FRAC_FIRST(n) + (N_Y_FRAC(n) - 1) * STEP_Y_SMALL(n)) + +#define STEP_X_SMALL(n) (xFixed1 / N_X_FRAC(n)) +#define STEP_X_BIG(n) (xFixed1 - (N_X_FRAC(n) - 1) * STEP_X_SMALL(n)) + +#define X_FRAC_FIRST(n) (STEP_X_SMALL(n) / 2) +#define X_FRAC_LAST(n) (X_FRAC_FIRST(n) + (N_X_FRAC(n) - 1) * STEP_X_SMALL(n)) + +#define RenderSamplesX(x,n) ((n) == 1 ? 0 : (xFixedFrac (x) + X_FRAC_FIRST(n)) / STEP_X_SMALL(n)) + +/* + * Step across a small sample grid gap + */ +#define RenderEdgeStepSmall(edge) { \ + edge->x += edge->stepx_small; \ + edge->e += edge->dx_small; \ + if (edge->e > 0) \ + { \ + edge->e -= edge->dy; \ + edge->x += edge->signdx; \ + } \ +} + +/* + * Step across a large sample grid gap + */ +#define RenderEdgeStepBig(edge) { \ + edge->x += edge->stepx_big; \ + edge->e += edge->dx_big; \ + if (edge->e > 0) \ + { \ + edge->e -= edge->dy; \ + edge->x += edge->signdx; \ + } \ +} + #endif /* PIXMAN_PRIVATE_H */ diff --git a/pixman/pixman.h b/pixman/pixman.h index 3110c36..3550f69 100644 --- a/pixman/pixman.h +++ b/pixman/pixman.h @@ -44,7 +44,7 @@ SOFTWARE. ******************************************************************/ /* - * Copyright © 1998 Keith Packard + * Copyright © 1998, 2004 Keith Packard * Copyright 2007 Red Hat, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -290,6 +290,52 @@ pixman_bool_t pixman_region_selfcheck (pixman_region16_t *region); void pixman_region_reset(pixman_region16_t *region, pixman_box16_t *box); /* + * Trapezoids + */ +typedef struct pixman_edge pixman_edge_t; + +/* + * An edge structure. This represents a single polygon edge + * and can be quickly stepped across small or large gaps in the + * sample grid + */ +struct pixman_render_edge +{ + pixman_fixed_t x; + pixman_fixed_t e; + pixman_fixed_t stepx; + pixman_fixed_t signdx; + pixman_fixed_t dy; + pixman_fixed_t dx; + + pixman_fixed_t stepx_small; + pixman_fixed_t stepx_big; + pixman_fixed_t dx_small; + pixman_fixed_t dx_big; +}; + +pixman_fixed_t pixman_sample_ceil_y (pixman_fixed_t y, + int bpp); +pixman_fixed_t pixman_sample_floor_y (pixman_fixed_t y, + int bpp); +void pixman_edge_step (pixman_edge_t *e, + int n); +void pixman_edge_init (pixman_edge_t *e, + int bpp, + 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); +void pixman_line_fixed_edge_init (pixman_edge_t *e, + int bpp, + pixman_fixed_t y, + pixman_line_fixed_t *line, + int x_off, + int y_off); + + +/* * Images */ typedef union pixman_image pixman_image_t; -- 2.7.4