Add only-just-better-than-ASCII-art diagram showing all macros used in locating sub-pixel sample rows/columns.

Add missing protective parentheses around macro parameter usage.
This commit is contained in:
Carl Worth 2005-02-21 13:29:22 +00:00
parent 6d70b286f5
commit 272df99aab
2 changed files with 58 additions and 11 deletions

View file

@ -1,3 +1,11 @@
2005-02-21 Carl Worth <cworth@cworth.org>
* src/renderedge.h: Add only-just-better-than-ASCII-art diagram
showing all macros used in locating sub-pixel sample rows/columns.
* src/renderedge.h (RenderEdgeStepSmall, RenderEdgeStepBig): Add
missing protective parentheses around macro parameter usage.
2005-02-21 Carl Worth <cworth@cworth.org>
* src/ic.c:

View file

@ -1,5 +1,5 @@
/*
* $Id: renderedge.h,v 1.2 2005-01-21 18:26:28 cworth Exp $
* $Id: renderedge.h,v 1.3 2005-02-21 21:29:22 cworth Exp $
*
* Copyright © 2004 Keith Packard
*
@ -27,6 +27,45 @@
#include "pixman-xserver-compat.h"
/* Here is a drawing of the sample grid for the 4-bit alpha case,
along with indications of the various defined terms:
STEP_Y_SMALL
Y_FRAC_FIRST
Y_FRAC_LAST
STEP_Y_BIG
STEP_X_BIG
STEP_X_SMALL
X_FRAC_LAST
X_FRAC_FIRST
N = 4 (# of bits of alpha)
MAX_ALPHA = 15 (# of samples per pixel)
N_X_FRAC = 5 (# of sample columns per pixel)
N_Y_FRAC = 3 (# of sample rows per column)
STEP_X_SMALL (distance between sample columns within a pixel)
STEP_X_BIG (distance between sample columns across pixel boundaries)
STEP_Y_SMALL (distance between sample rows within a pixel)
STEP_Y_BIG (distance between sample rows across pixel boundaries)
X_FRAC_FIRST (sub-pixel position of first sample column in pixel)
X_FRAC_LAST (sub-pixel position of last sample column in pixel)
Y_FRAC_FIRST (sub-pixel position of first sample row in pixel)
Y_FRAC_LAST (sub-pixel position of last sample row pixel)
*/
#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)
@ -69,12 +108,12 @@ typedef struct {
* 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)->x += (edge)->stepx_small; \
(edge)->e += (edge)->dx_small; \
if ((edge)->e > 0) \
{ \
edge->e -= edge->dy; \
edge->x += edge->signdx; \
(edge)->e -= (edge)->dy; \
(edge)->x += (edge)->signdx; \
} \
}
@ -82,12 +121,12 @@ typedef struct {
* 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)->x += (edge)->stepx_big; \
(edge)->e += (edge)->dx_big; \
if ((edge)->e > 0) \
{ \
edge->e -= edge->dy; \
edge->x += edge->signdx; \
(edge)->e -= (edge)->dy; \
(edge)->x += (edge)->signdx; \
} \
}