navit  0.5.3-trunk
raster.c File Reference
#include <math.h>
#include <glib.h>
#include "raster.h"

Macros

#define raster_rect_inline   raster_rect
 
#define MODIFIED_ALPHA_PIXEL_ROUTINE
 
#define clip_xmin(surface)   surface->clip_rect.x
 
#define clip_xmax(surface)   surface->clip_rect.x+surface->clip_rect.w-1
 
#define clip_ymin(surface)   surface->clip_rect.y
 
#define clip_ymax(surface)   surface->clip_rect.y+surface->clip_rect.h-1
 
#define CLIP_LEFT_EDGE   0x1
 
#define CLIP_RIGHT_EDGE   0x2
 
#define CLIP_BOTTOM_EDGE   0x4
 
#define CLIP_TOP_EDGE   0x8
 
#define CLIP_INSIDE(a)   (!a)
 
#define CLIP_REJECT(a, b)   (a&b)
 
#define CLIP_ACCEPT(a, b)   (!(a|b))
 
#define AAlevels   256
 
#define AAbits   8
 

Functions

static void raster_rect_inline (SDL_Surface *dst, int16_t x1, int16_t y1, int16_t w, int16_t h, uint32_t color)
 
void raster_rect (SDL_Surface *s, int16_t x, int16_t y, int16_t w, int16_t h, uint32_t col)
 
static void raster_PutPixel (SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color)
 
static void raster_PutPixelAlpha (SDL_Surface *surface, Sint16 x, Sint16 y, Uint32 color, Uint8 alpha)
 
static int raster_pixelColorNolock (SDL_Surface *dst, Sint16 x, Sint16 y, Uint32 color)
 
static int raster_pixelColorWeightNolock (SDL_Surface *dst, Sint16 x, Sint16 y, Uint32 color, Uint32 weight)
 
static void raster_hline (SDL_Surface *dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color)
 
static void raster_vline (SDL_Surface *dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color)
 
static int clipEncode (Sint16 x, Sint16 y, Sint16 left, Sint16 top, Sint16 right, Sint16 bottom)
 
static int clipLine (SDL_Surface *dst, Sint16 *x1, Sint16 *y1, Sint16 *x2, Sint16 *y2)
 
void raster_line (SDL_Surface *dst, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t color)
 
static void raster_aalineColorInt (SDL_Surface *dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color, int draw_endpoint)
 
void raster_aaline (SDL_Surface *s, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t col)
 
void raster_circle (SDL_Surface *dst, int16_t x, int16_t y, int16_t r, uint32_t color)
 
static void raster_AAFilledEllipse (SDL_Surface *surface, Sint16 xc, Sint16 yc, Sint16 rx, Sint16 ry, Uint32 color)
 
void raster_aacircle (SDL_Surface *s, int16_t x, int16_t y, int16_t r, uint32_t col)
 
static int gfxPrimitivesCompareInt (const void *a, const void *b)
 
static int raster_filledPolygonColorMT (SDL_Surface *dst, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color, int **polyInts, int *polyAllocated)
 
void raster_polygon (SDL_Surface *s, int16_t n, int16_t *vx, int16_t *vy, uint32_t col)
 
void raster_aapolygon (SDL_Surface *dst, int16_t n, int16_t *vx, int16_t *vy, uint32_t color)
 
void raster_aapolygon_with_holes (SDL_Surface *s, struct point *p, int count, int hole_count, int *ccount, struct point **holes, uint32_t col)
 render filled polygon with holes by raycasting along the y axis More...
 
void raster_polygon_with_holes (SDL_Surface *s, struct point *p, int count, int hole_count, int *ccount, struct point **holes, uint32_t col)
 render filled polygon with holes by raycasting along the y axis More...
 

Variables

static int * gfxPrimitivesPolyIntsGlobal = NULL
 
static int gfxPrimitivesPolyAllocatedGlobal = 0
 

Macro Definition Documentation

◆ AAbits

#define AAbits   8

◆ AAlevels

#define AAlevels   256

◆ CLIP_ACCEPT

#define CLIP_ACCEPT (   a,
 
)    (!(a|b))

◆ CLIP_BOTTOM_EDGE

#define CLIP_BOTTOM_EDGE   0x4

◆ CLIP_INSIDE

#define CLIP_INSIDE (   a)    (!a)

◆ CLIP_LEFT_EDGE

#define CLIP_LEFT_EDGE   0x1

◆ CLIP_REJECT

#define CLIP_REJECT (   a,
 
)    (a&b)

◆ CLIP_RIGHT_EDGE

#define CLIP_RIGHT_EDGE   0x2

◆ CLIP_TOP_EDGE

#define CLIP_TOP_EDGE   0x8

◆ clip_xmax

#define clip_xmax (   surface)    surface->clip_rect.x+surface->clip_rect.w-1

◆ clip_xmin

#define clip_xmin (   surface)    surface->clip_rect.x

◆ clip_ymax

#define clip_ymax (   surface)    surface->clip_rect.y+surface->clip_rect.h-1

◆ clip_ymin

#define clip_ymin (   surface)    surface->clip_rect.y

◆ MODIFIED_ALPHA_PIXEL_ROUTINE

#define MODIFIED_ALPHA_PIXEL_ROUTINE

◆ raster_rect_inline

#define raster_rect_inline   raster_rect

Function Documentation

◆ clipEncode()

static int clipEncode ( Sint16  x,
Sint16  y,
Sint16  left,
Sint16  top,
Sint16  right,
Sint16  bottom 
)
static

◆ clipLine()

static int clipLine ( SDL_Surface *  dst,
Sint16 *  x1,
Sint16 *  y1,
Sint16 *  x2,
Sint16 *  y2 
)
static

◆ gfxPrimitivesCompareInt()

static int gfxPrimitivesCompareInt ( const void *  a,
const void *  b 
)
static

◆ raster_aacircle()

void raster_aacircle ( SDL_Surface *  s,
int16_t  x,
int16_t  y,
int16_t  r,
uint32_t  col 
)

References raster_AAFilledEllipse().

Referenced by draw_circle().

◆ raster_AAFilledEllipse()

static void raster_AAFilledEllipse ( SDL_Surface *  surface,
Sint16  xc,
Sint16  yc,
Sint16  rx,
Sint16  ry,
Uint32  color 
)
static

◆ raster_aaline()

void raster_aaline ( SDL_Surface *  s,
int16_t  x1,
int16_t  y1,
int16_t  x2,
int16_t  y2,
uint32_t  col 
)

References raster_aalineColorInt().

Referenced by draw_lines().

◆ raster_aalineColorInt()

static void raster_aalineColorInt ( SDL_Surface *  dst,
Sint16  x1,
Sint16  y1,
Sint16  x2,
Sint16  y2,
Uint32  color,
int  draw_endpoint 
)
static

◆ raster_aapolygon()

void raster_aapolygon ( SDL_Surface *  dst,
int16_t  n,
int16_t *  vx,
int16_t *  vy,
uint32_t  color 
)

◆ raster_aapolygon_with_holes()

void raster_aapolygon_with_holes ( SDL_Surface *  s,
struct point p,
int  count,
int  hole_count,
int *  ccount,
struct point **  holes,
uint32_t  col 
)

render filled polygon with holes by raycasting along the y axis

This function renders a filled polygon that can have holes by SDL primitive graphic functions by raycasting along the y axis. This works basically the same as for complex polygons. Only difference is the "holes" are individual polygon loops not connected to the outer loop. FIXME: This draws well as long as the "hole" does not intersect with the outer polygon. However such multipolygons are seen a mapping error in OSM and therefore the rendering err may even help in detecting them. But this could be fixed by never starting a line on a vertex that came from a hole intersection.

Parameters
sSDL surface to draw on
pArray of points containing the outer polygon
countNumber of points in outer polygon
hole_countNumber of hole polygons
ccountnumber of points per hole polygon @oaram holes array of point arrays. One for each "hole"
colColor to draw this.

References p, raster_aalineColorInt(), raster_polygon_with_holes(), point::x, and point::y.

Referenced by draw_polygon_with_holes().

◆ raster_circle()

void raster_circle ( SDL_Surface *  dst,
int16_t  x,
int16_t  y,
int16_t  r,
uint32_t  color 
)

References raster_hline(), and raster_PutPixel().

Referenced by draw_circle().

◆ raster_filledPolygonColorMT()

static int raster_filledPolygonColorMT ( SDL_Surface *  dst,
const Sint16 *  vx,
const Sint16 *  vy,
int  n,
Uint32  color,
int **  polyInts,
int *  polyAllocated 
)
inlinestatic

◆ raster_hline()

static void raster_hline ( SDL_Surface *  dst,
Sint16  x1,
Sint16  x2,
Sint16  y,
Uint32  color 
)
inlinestatic

◆ raster_line()

void raster_line ( SDL_Surface *  dst,
int16_t  x1,
int16_t  y1,
int16_t  x2,
int16_t  y2,
uint32_t  color 
)

◆ raster_pixelColorNolock()

static int raster_pixelColorNolock ( SDL_Surface *  dst,
Sint16  x,
Sint16  y,
Uint32  color 
)
static

References raster_PutPixel().

Referenced by raster_aalineColorInt().

◆ raster_pixelColorWeightNolock()

static int raster_pixelColorWeightNolock ( SDL_Surface *  dst,
Sint16  x,
Sint16  y,
Uint32  color,
Uint32  weight 
)
static

References raster_PutPixelAlpha().

Referenced by raster_aalineColorInt().

◆ raster_polygon()

void raster_polygon ( SDL_Surface *  s,
int16_t  n,
int16_t *  vx,
int16_t *  vy,
uint32_t  col 
)

◆ raster_polygon_with_holes()

void raster_polygon_with_holes ( SDL_Surface *  s,
struct point p,
int  count,
int  hole_count,
int *  ccount,
struct point **  holes,
uint32_t  col 
)

render filled polygon with holes by raycasting along the y axis

This function renders a filled polygon that can have holes by SDL primitive graphic functions by raycasting along the y axis. This works basically the same as for complex polygons. Only difference is the "holes" are individual polygon loops not connected to the outer loop. FIXME: This draws well as long as the "hole" does not intersect with the outer polygon. However such multipolygons are seen a mapping error in OSM and therefore the rendering err may even help in detecting them. But this could be fixed by never starting a line on a vertex that came from a hole intersection.

Parameters
sSDL surface to draw on
pArray of points containing the outer polygon
countNumber of points in outer polygon
hole_countNumber of hole polygons
ccountnumber of points per hole polygon @oaram holes array of point arrays. One for each "hole"
colColor to draw this.

References gfxPrimitivesCompareInt(), p, raster_hline(), point::x, and point::y.

Referenced by draw_polygon_with_holes(), and raster_aapolygon_with_holes().

◆ raster_PutPixel()

static void raster_PutPixel ( SDL_Surface *  surface,
Sint16  x,
Sint16  y,
Uint32  color 
)
static

◆ raster_PutPixelAlpha()

static void raster_PutPixelAlpha ( SDL_Surface *  surface,
Sint16  x,
Sint16  y,
Uint32  color,
Uint8  alpha 
)
static

◆ raster_rect()

void raster_rect ( SDL_Surface *  s,
int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
uint32_t  col 
)

References raster_rect_inline.

Referenced by draw_rectangle().

◆ raster_rect_inline()

static void raster_rect_inline ( SDL_Surface *  dst,
int16_t  x1,
int16_t  y1,
int16_t  w,
int16_t  h,
uint32_t  color 
)
inlinestatic

References rect::h.

◆ raster_vline()

static void raster_vline ( SDL_Surface *  dst,
Sint16  x,
Sint16  y1,
Sint16  y2,
Uint32  color 
)
static

Variable Documentation

◆ gfxPrimitivesPolyAllocatedGlobal

int gfxPrimitivesPolyAllocatedGlobal = 0
static

◆ gfxPrimitivesPolyIntsGlobal

int* gfxPrimitivesPolyIntsGlobal = NULL
static