/*************************************************************** ** (c)2009-2010 Broadcom Corporation ** ** This program is the proprietary software of Broadcom Corporation and/or its licensors, ** and may only be used, duplicated, modified or distributed pursuant to the terms and ** conditions of a separate, written license agreement executed between you and Broadcom ** (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants ** no license (express or implied), right to use, or waiver of any kind with respect to the ** Software, and Broadcom expressly reserves all rights in and to the Software and all ** intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU ** HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY ** NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. ** ** Except as expressly set forth in the Authorized License, ** ** 1. This program, including its structure, sequence and organization, constitutes the valuable trade ** secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, ** and to use this information only in connection with your use of Broadcom integrated circuit products. ** ** 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" ** AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR ** WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO ** THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES ** OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, ** LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION ** OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF ** USE OR PERFORMANCE OF THE SOFTWARE. ** ** 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS ** LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR ** EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR ** USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF ** THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ** ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE ** LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ** ANY LIMITED REMEDY. ** ** Created: 8/22/2002 by Jeffrey P. Fisher ** ** $brcm_Workfile: bgfx.h $ ** $brcm_Revision: Refsw_7550/4 $ ** $brcm_Date: 4/8/10 6:38p $ ** ** Revision History: ** ** $brcm_Log: /nexus/lib/softgfx/src/bgfx.h $ ** ** Refsw_7550/4 4/8/10 6:38p gautamk ** SW7550-369:[7550] Merging Scaling feature of softgfx to mainline. ** ** Refsw_7550/SWARTEMIS-10/1 3/26/10 6:58p gezhang ** SW7550-208: Require stretch-BLIT function on soft-gfx lib ** ** Refsw_7550/3 2/18/10 11:12a kagrawal ** SW7550-265: Added CSC from ARGB8888 to AYCbCr8888 ** ** Refsw_7550/2 9/25/09 12:54p kagrawal ** SW7550-50: Performance optimized gfx from 7003 latest ** ** Refsw_7550/1 9/7/09 5:04p kagrawal ** SW7550-3: Initial check-in for Soft Graphics ******************************************************************/ #ifndef __bgfx_h__ #define __bgfx_h__ /* Broadcom driver includes */ #ifdef LINUX #include #include #include #endif #include "bgfx_types.h" #include "bgfx_defs.h" #include "bgfx_font.h" #if SOFT_GFX_AS_IN_7003 typedef enum bgfx_blit_operation_blend{ SURFBLIT_BLEND_WITH_SPEC_ALPHA1 = 0x00, /* Use alpha1 value for calculating R,G,B bleding */ SURFBLIT_BLEND_WITH_SRC1_ALPHA = 0x01, /* Use source1 alpha value for calculating R,G,B bleding */ SURFBLIT_BLEND_WITH_SRC2_ALPHA = 0x02, /* Use source2 alpha value for calculating R,G,B bleding */ SURFBLIT_BLEND_WITH_AVG_ALPHA = 0x03 /* Use below formula for calculating R,G,B bleding */ /* * R = R1 * Alpha1 + R2 * Alpha2 * (1-Alpha1) * G = G1 * Alpha1 + G2 * Alpha2 * (1-Alpha1) * B = B1 * Alpha1 + B2 * Alpha2 * (1-Alpha1) * Alpha = 1 - (1 - Alpha1) * ( 1 - Alpha2) * R = R / Alpha * G = G / Alpha * B = B / Alpha */ }bgfx_blit_operation_blend; typedef enum bgfx_blit_operation_alpha{ SURFBLIT_SET_DEST_ALPHA_WITH_SPEC_ALPHA2 = 0x00, /* Use alpha2 value for calculating A bleding */ SURFBLIT_SET_DEST_ALPHA_WITH_SRC1_ALPHA = 0x10, /* Use source1 alpha value for calculating A bleding */ SURFBLIT_SET_DEST_ALPHA_WITH_SRC2_ALPHA = 0x20, /* Use source2 alpha value for calculating A bleding */ SURFBLIT_SET_DEST_ALPHA_WITH_AVG_ALPHA =0x30 /* Use below formula for calculating A bleding */ /* Alpha = 1 - (1 - Alpha1) * ( 1 - Alpha2) */ }bgfx_blit_operation_alpha; #endif /**************************************************************** * 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 */ #if SOFT_GFX_AS_IN_7003 uint16_t x_pos, /* coordinate to the frame buffer */ uint16_t y_pos, /* coordinate to the frame buffer */ #endif 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 */ ); #if SOFT_GFX_AS_IN_7003 void bgfx_set_pixel_direct(bgfx_surf_p p, uint16_t x, uint16_t y, bgfx_pixel c); #endif /**************************************************************** * 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 */ ); #if SOFT_GFX_AS_IN_7003 bgfx_pixel bgfx_get_pixel_from_buffer(uint8_t format, uint16_t src_w, uint16_t src_h, uint32_t des_x, uint32_t des_y, void *pbuffer); #endif /**************************************************************** * 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. ****************************************************************/ #if SOFT_GFX_AS_IN_7003 int bgfx_render_file(bgfx_surf_p p, /* surface pointer */ uint16_t src_w, /* source image width */ uint16_t src_h, /* source image height */ int16_t des_x, /* destination x position */ int16_t des_y, /* destination y position */ void *file_p); /* image file pointer */ /**************************************************************** * Draw bitmap from a buffer. ****************************************************************/ int bgfx_render_buffer(bgfx_surf_p p, uint8_t format, uint16_t src_w, uint16_t src_h, uint16_t des_x, uint16_t des_y, void *pbuffer); #else 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 */ ); #endif /**************************************************************** * 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 */ bool b_csc, /* true = do RGB to YCbCr color space conversion as per matrix coeffs in p_csc */ bgfx_color_matrix_p p_csc); #if SOFT_GFX_AS_IN_7003 /**************************************************************** * Alpha blend a rectangle area from 2 source surface to the destinate surface. * Source and destinate surface must be RGB. ****************************************************************/ int bgfx_blit_rect_multisuf_blending(bgfx_surf_p p_src1, /* pointer to initialized source surface structure */ bgfx_surf_p p_src2, /* pointer to initialized source surface structure */ bgfx_surf_p p_dst, /* pointer to initialized destination surface structure */ uint16_t s1x, /* source horizontal location in pixels */ uint16_t s1y, /* source vertical location in pixels */ uint16_t s2x, /* source horizontal location in pixels */ uint16_t s2y, /* 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 */ unsigned int operation, /* alpha blending mode */ uint32_t alpha1, /* specified alpha value for RGB blending calculation, see bgfx_blit_operation_blend*/ uint32_t alpha2); /* specified alpha value for A blending calculation, see bgfx_blit_operation_alpha */ #endif #if SOFT_GFX_AS_IN_7003 /**************************************************************** * * INPUTS: p_src - source palette pointer * OUTPUTS: none * RETURNS: none * FUNCTION: Map palette from RGB to YUV * Raymond, 20090211 ****************************************************************/ void bgfx_mapping_palette(unsigned int *p_src, unsigned int size); #endif /**************************************************************** * do anti-flutter filter on one surface. * source and destination surface can be same. * * ****************************************************************/ int bgfx_anti_flutter_filter(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 */ /**************************************************************** * Blend fill a rectanglular region of the surface. * Fill the region with constant color corresponding to colorOp=eBlend * and alphaOp=eIgnore. * * Fills the region as per following rule: * const color c -> AcRcGcBc (src1) * surface p -> AiRiGiBi (src2) * blended outpout -> AiRoGoBo * where Ro = Ac * Rc + (1 - Ac) * Ri * Go = Ac * Gc + (1 - Ac) * Gi * Bo = Ac * Bc + (1 - Ac) * Bi * Note: Constant color c is always in ARGB8888 format. ****************************************************************/ int bgfx_blend_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 blend fill */ /**************************************************************** * Copy a rectangle area from one surface to the other with scaling. * Copy the source surface at (sx,sy) to the destination at (dx,dy) ****************************************************************/ int bgfx_blit_rect_scale(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 */ uint16_t dw,/* destination width in pixel*/ uint16_t dh); /* destination width in pixel*/ /**************************************************************** * Copy a rectangle area from one surface to the other with scaling. * Copy the source surface at (sx,sy) to the destination at (dx,dy) ****************************************************************/ int bgfx_blit_rect_scale_v_up_h_up(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 */ uint16_t dw,/* destination width in pixel*/ uint16_t dh); /* destination width in pixel*/ /**************************************************************** * Copy a rectangle area from one surface to the other with scaling. * Copy the source surface at (sx,sy) to the destination at (dx,dy) ****************************************************************/ int bgfx_blit_rect_scale_v_down_h_down(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 */ uint16_t dw,/* destination width in pixel*/ uint16_t dh); /* destination width in pixel*/ #ifdef __cplusplus } #endif #endif /* __bgfx_h__ */