/****
 *
 * Copyright (c) 1988 by Sun Microsystems, Inc.
 * @(#)sh_glyph.h 22.1 89/08/10 Copyright 1988 Sun Micro
 *
 * GLYPH.H - Glyp information for user level code (needed by shapes.h).
 *
 * The user does not know what the GLYPH object actually looks like.
 * It should only be accessed via the Xxx_GLYPH functions.
 *
 ****/
#ifndef _SH_GLYPH

/*
 * Glyph types (GLYPH_TYPE attribute)
 * There are several different types of GLYPH objects, differing
 * in how their pixel data is represented. The glyph alignment,
 * depth and other flag are stored in a single field (gl_DATA_TYPE)
 *
 * The gl_TYPE field of the glyph structure is broken up as follows:
 *
 *	8 7 6 5 4 3 2 1
 *      --- ----- -----
 *	 |    |     |______ depth (1,8,24,32)
 *       |    |____________ alignment (8, 16, 32)
 *       |_________________ space/speed
 *
 */

/*
 * Glyph attributes
 */
typedef enum
  {
   GLYPH_TYPE,		/* type of glyph data (depth, alignment) */
   GLYPH_DEPTH,		/* depth of glyph object */
   GLYPH_WIDTH,		/* width of glyph */
   GLYPH_HEIGHT,	/* height of glyph */
   GLYPH_SIZE,		/* glyph byte size */
   GLYPH_DATA,		/* load glyph from user data */
   GLYPH_RASTER,	/* load glyph from raster */
  } GLYPH_attr;

/*
 * GLYPH rendering optimization flags
 */
typedef char GLYPH_opt;
#define	GLYPH_OPT_MONOTONIC	0x01
#define	GLYPH_OPT_FIXED		0x02
#define	GLYPH_OPT_LEFT_TO_RIGHT	0x04
#define	GLYPH_OPT_CLEAR		0x08
/* flag used internally during glyph stippling and opaque stippling */
#define	GLYPH_OPT_ABSOLUTE	0x8000
/*
 * GLYPH internal data representation
 */
typedef struct sh_glyph
  {
   Unsgn8	gl_TYPE;	/* glyph depth and alignment */
   Unsgn8	gl_empty;	/* empty for now */
   Unsgn16	gl_WIDTH;	/* glyph width */
   Unsgn16	gl_HEIGHT;	/* glyph height */
   Unsgn16	gl_LINEBYTES;	/* struct size must be multiple of 4 bytes */
  } *GLYPH;

typedef	struct
  {
   GLYPH	gr_glyph;	/* glyph to display */
   Sgn16	gr_x, gr_y;	/* position of glyph upper left corner */
  } GLYPH_REF;

/*
 * GLYPH operators - not table dispatched.
 *
 * Create_Glyph(type, width, height)
 * Destroy_Glyph(g)		destroy glyph object
 * Get_Glyph(g, attr)		get glyph attribute
 * Set_Glyph(g, attr, val)	set glyph attribute
 * Poly_Glyph(ctx, gr, n, o, d, opt)	display glyph list in context
 */
#define	Poly_Glyph(ctx, gr, n, o, d, opt) \
        Glyph_Raster((ctx)->CTX_RASTER, ctx, gr, n, o, d, opt)
#define	Create_Glyph	sh_Create_Glyph
#define	Set_Glyph	sh_Set_Glyph
#define	Destroy_Glyph	sh_Destroy_Glyph

extern	GLYPH	Create_Glyph();
extern	void	Set_Glyph();
extern	void	Destroy_Glyph();
extern	int	sh_Get_Glyph_SIZE();

/*
 * Glyph "Get" macros
 * Fetching the glyph attributes are implemented with macros
 */
#define Get_Glyph(g,a) CAT(a,get)((GLYPH) g)

#define GLYPH_TYPEget(g)	((g)->gl_TYPE)
#define GLYPH_HEIGHTget(g)	((g)->gl_HEIGHT)
#define GLYPH_WIDTHget(g)	((g)->gl_WIDTH)
#define GLYPH_DATAget(g)	((unsigned char *) ((g) + 1))
#define GLYPH_SIZEget(g)	sh_Get_Glyph_SIZE(g)

#define	_SH_GLYPH
#endif	/* _SH_GLYPH */
