/*************************************************************** ** ** Broadcom Corp. Confidential ** Copyright 2002 Broadcom Corp. All Rights Reserved. ** ** THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED ** SOFTWARE LICENSE AGREEMENT BETWEEN THE USER AND BROADCOM. ** YOU HAVE NO RIGHT TO USE OR EXPLOIT THIS MATERIAL EXCEPT ** SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. ** ** Description: bgfx core implementation ** ** Created: 8/22/2002 by Jeffrey P. Fisher ** ** ** ****************************************************************/ #ifndef __bgfx_h__ #define __bgfx_h__ /* Broadcom driver includes */ #include "bgfx_types.h" #include "bgfx_defs.h" #include "bgfx_font.h" /**************************************************************** * raw bitmap structure * bcm_raw_8_t describes the raw CLUT8 image format supported by SGIL * The structure if followed by a 256 entry CLUT, each entry ARGB8888 ****************************************************************/ typedef struct bcm_raw_8_t { uint32_t version; /* version number of raw file - for future use */ uint32_t type; /* type of raw file - for future use */ uint32_t pitch; /* number of bytes per row */ uint16_t width; /* number of pixel per row */ uint16_t height; /* number of rows */ uint8_t color_key; /* color key/transparency color value */ uint16_t clut_size; /* number of entries in the ARGB8888 CLUT */ }bcm_raw_8_t; #define RAW_TYPE 0x52415720 #define RAW_VERSION 0x00000001 #ifdef __cplusplus extern "C" { #endif /**************************************************************** * global sgil initialization * Initialize SGIL global resources. Should be called prior to using * any other SGIL function. prot_p must be an allocated and initialized. * It is important that prot_p exists for the entire time * SGIL is running and initialized because sgil just copies the reference. ****************************************************************/ int bgfx_init(bgfx_io_t *io_p, /* io callback functions */ bgfx_prot_t *prot_p /* allocated, initialized sgil_prot_t reference */ ); /**************************************************************** * global sgil cleanup * Free SGIL global resources. Should be called to cleanup all global resources * allocated by SGIL. ****************************************************************/ void bgfx_done(void); /**************************************************************** * Initialize an SGIL surface * Create an SGIL surface using the node_name passed. width and height can be 0 when * creating surfaces with the SGL_SURF_FULLSCREEN flag. All flags other than * SGL_SURF_NONE can only be used when creating on-screen surfaces. Surfaces are * CLUT8 (8-bpp) surfaces by default but can also be 8888 ARGB (32-bpp) * when SGL_SURF_RGB is ored with the flags. ****************************************************************/ int bgfx_create(bgfx_surf_p p, /* pointer to allocated, uninitialized surface structure */ uint16_t width, /* width in pixels of the surface */ uint16_t height, /* height in pixels of the surface */ uint8_t *ptr, /* ptr to surface memory or NULL if memory needs to be allocated */ uint16_t pitch, /* number of bytes per row in the surface */ bgfx_palette_t *palette, /* a palette to copy or NULL to use default */ uint32_t flags /* flags that define the type of surface to create */ ); /**************************************************************** * Free an SGIL surface * Should be called to free up resources associated with the surface. ****************************************************************/ void bgfx_destroy(bgfx_surf_p p /* pointer to initialized surface structure */ ); /**************************************************************** * Get surface width,height and flags. * Get surface information including width height and flags. ****************************************************************/ void bgfx_get_info(bgfx_surf_p p, /* pointer to initialized surface structure */ uint16_t *w, /* surface width in pixels */ uint16_t *h, /* surface height in pixels */ uint16_t *pitch, /* surface width in bytes */ uint32_t *flags /* surface flags (see bgfx_create) */ ); /**************************************************************** * Get the surface palette (CLUT). * Get a copy of the current surface palette. ****************************************************************/ void bgfx_get_palette(bgfx_surf_p p, /* pointer to initialized surface structure */ bgfx_palette_t *palette_p /* palette to copy surface palette to (CLUT8 ARGB8888)*/ ); /**************************************************************** * Set the surface palette (CLUT). * Set the surface palette and update the hardware palette. ****************************************************************/ void bgfx_set_palette(bgfx_surf_p p, /* pointer to initialized surface structure */ bgfx_palette_t *palette_p /* palette to copy to surface palette (CLUT8 ARGB8888)*/ ); /**************************************************************** * Set the pixel value. * Set the pixel value at x,y location to the value c. * When the surface is a CLUT8 surface c should be an 8-bit * value. When the surface is an 8888 ARGB surface c should be * a 32-bit value. This avoids logic for performing * color reduction or format translations. ****************************************************************/ void bgfx_set_pixel(bgfx_surf_p p, /* pointer to initialized surface structure */ uint16_t x, /* horizontal location in pixels (top/left 0,0) */ uint16_t y, /* vertical location in pixels */ bgfx_pixel c /* pixel value to set */ ); /**************************************************************** * Get the pixel value. * Get the pixel value at x,y location. * When the surface is a CLUT8 surface c will be an 8-bit * value. When the surface is an 8888 ARGB surface c will be * a 32-bit value. This avoids logic for performing * color reduction or format translations. ****************************************************************/ bgfx_pixel bgfx_get_pixel(bgfx_surf_p p, /* pointer to initialized surface structure */ uint16_t x, /* horizontal location in pixels (top/left 0,0) */ uint16_t y /* vertical location in pixels */ ); /**************************************************************** * Draw a horizontal line. * Draw a single pixel wide horizontal line with the pixel value. ****************************************************************/ void bgfx_h_draw_line(bgfx_surf_p p, /* pointer to initialized surface structure */ uint16_t x1, /* horizontal line starting point */ uint16_t x2, /* horizontal line ending point */ uint16_t y, /* vertical line location */ bgfx_pixel c /* pixel value to set */ ); /**************************************************************** * Draw a vertical line. * Draw a single pixel wide vertical line with the pixel value. ****************************************************************/ void bgfx_v_draw_line(bgfx_surf_p p, /* pointer to initialized surface structure */ uint16_t x, /* horizontal location in pixels (top/left 0,0) */ uint16_t y1, /* vertical line starting point */ uint16_t y2, /* vertical line end point */ bgfx_pixel c /* pixel value to set */ ); /**************************************************************** * Fill a rectanglular region of the surface. * Fill the region with with the pixel value. ****************************************************************/ void bgfx_fill_rect(bgfx_surf_p p, /* pointer to initialized surface structure */ uint16_t x, /* rectangle left location in pixels */ uint16_t y, /* rectangle top location in pixels */ uint16_t w, /* rectangle width in pixels */ uint16_t h, /* rectangle height in pixels */ bgfx_pixel c /* pixel value to set */ ); /**************************************************************** * Draw the UNI string. * Draw the UNI string at the x,y location with * the pixel value. Use the functions in sgl_font.h to initialize * the font structure. Using preloaded cached fonts will result in best * drawing performance. When using 8 -bit grayscale fonts rather than mono fonts * the pixel value will be used when the grayscale value is >=75%, c-1 for >= 50% * and c-2 for >= 25%. ****************************************************************/ void bgfx_draw_text(bgfx_surf_p p, /* pointer to initialized surface structure */ uint16_t x, /* horizontal location in pixels (top/left 0,0) */ uint16_t y, /* vertical location in pixels */ const unsigned long *str_p, /* array of 32-bit unicode characters */ int str_len, /* Length of character array */ bgfx_font_t *font_p, /* initialized font structure (see sgl_font.h) */ bgfx_pixel c, /* pixel value to set */ bgfx_text_style style /* Text style */ ); /**************************************************************** * Draw the UNI string. * Draw the UNI string at the x,y location with * the pixel value. Use the functions in sgl_font.h to initialize * the font structure. Using preloaded cached fonts will result in best * drawing performance. When using 8 -bit grayscale fonts rather than mono fonts * the pixel value will be used when the grayscale value is >=75%, c-1 for >= 50% * and c-2 for >= 25%. ****************************************************************/ void bgfx_draw_text_box(bgfx_surf_p p, /* pointer to initialized surface structure */ uint16_t x, /* horizontal location in pixels (top/left 0,0) */ uint16_t y, /* vertical location in pixels */ uint16_t width, /* horizontal size in pixels (top/left 0,0) */ uint16_t height, /* vertical size in pixels */ const unsigned long *str_p, /* array of 32-bit unicode characters */ int str_len, /* Length of character array */ bgfx_font_t *font_p,/* initialized font structure (see sgl_font.h) */ bgfx_pixel c, /* pixel value to set */ uint16_t line_spacing /* Space between lines */ ); /**************************************************************** * Draw bitmap from a file. ****************************************************************/ int bgfx_render_file(bgfx_surf_p p, /* pointer to initialized surface structure */ uint16_t x, /* horizontal location in pixels (top/left 0,0) */ uint16_t y, /* vertical location in pixels */ void *file_p, /* open CLUT8 binary file point to render directly to the surface */ int set_palette /* use this CLUT as the global palette */ ); /**************************************************************** * Copy from one surface to the other. * Copy the source surface to the destination at x,y location (top/left) * The source colorkey value will be used. The source must be a CLUT8 surface * but the destination can be CLUT8 or RGB. ****************************************************************/ int bgfx_blit(bgfx_surf_p p_src, /* pointer to initialized source surface structure */ bgfx_surf_p p_dst, /* pointer to initialized destination surface structure */ uint16_t x, /* horizontal location in pixels (top/left 0,0) */ uint16_t y /* vertical location in pixels */ ); /**************************************************************** * Copy a rectangle area from one surface to the other. * Copy the source surface at (sx,sy) to the destination at (dx,dy) * The source colorkey value will be used. The source must be a CLUT8 surface * but the destination can be CLUT8 or RGB. ****************************************************************/ int bgfx_blit_rect(bgfx_surf_p p_src, /* pointer to initialized source surface structure */ bgfx_surf_p p_dst, /* pointer to initialized destination surface structure */ uint16_t sx, /* source horizontal location in pixels */ uint16_t sy, /* source vertical location in pixels */ uint16_t dx, /* destination horizontal location in pixels */ uint16_t dy, /* destination vertical location in pixels */ uint16_t sw, /* source width in pixel */ uint16_t sh); /* source height in pixel */ #ifdef __cplusplus } #endif #endif /* __bgfx_h__ */