| 1 | /*************************************************************** |
|---|
| 2 | ** (c)2009-2010 Broadcom Corporation |
|---|
| 3 | ** |
|---|
| 4 | ** This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | ** and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | ** conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | ** (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | ** no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | ** Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | ** intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | ** HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | ** NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | ** |
|---|
| 14 | ** Except as expressly set forth in the Authorized License, |
|---|
| 15 | ** |
|---|
| 16 | ** 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | ** secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | ** and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | ** |
|---|
| 20 | ** 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | ** AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | ** WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | ** THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | ** OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | ** LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | ** OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | ** USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | ** |
|---|
| 29 | ** 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | ** LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | ** EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | ** USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | ** THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | ** ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | ** LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | ** ANY LIMITED REMEDY. |
|---|
| 37 | ** |
|---|
| 38 | ** Created: 8/22/2002 by Jeffrey P. Fisher |
|---|
| 39 | ** |
|---|
| 40 | ** $brcm_Workfile: bgfx.h $ |
|---|
| 41 | ** $brcm_Revision: Refsw_7550/4 $ |
|---|
| 42 | ** $brcm_Date: 4/8/10 6:38p $ |
|---|
| 43 | ** |
|---|
| 44 | ** Revision History: |
|---|
| 45 | ** |
|---|
| 46 | ** $brcm_Log: /nexus/lib/softgfx/src/bgfx.h $ |
|---|
| 47 | ** |
|---|
| 48 | ** Refsw_7550/4 4/8/10 6:38p gautamk |
|---|
| 49 | ** SW7550-369:[7550] Merging Scaling feature of softgfx to mainline. |
|---|
| 50 | ** |
|---|
| 51 | ** Refsw_7550/SWARTEMIS-10/1 3/26/10 6:58p gezhang |
|---|
| 52 | ** SW7550-208: Require stretch-BLIT function on soft-gfx lib |
|---|
| 53 | ** |
|---|
| 54 | ** Refsw_7550/3 2/18/10 11:12a kagrawal |
|---|
| 55 | ** SW7550-265: Added CSC from ARGB8888 to AYCbCr8888 |
|---|
| 56 | ** |
|---|
| 57 | ** Refsw_7550/2 9/25/09 12:54p kagrawal |
|---|
| 58 | ** SW7550-50: Performance optimized gfx from 7003 latest |
|---|
| 59 | ** |
|---|
| 60 | ** Refsw_7550/1 9/7/09 5:04p kagrawal |
|---|
| 61 | ** SW7550-3: Initial check-in for Soft Graphics |
|---|
| 62 | ******************************************************************/ |
|---|
| 63 | |
|---|
| 64 | #ifndef __bgfx_h__ |
|---|
| 65 | #define __bgfx_h__ |
|---|
| 66 | |
|---|
| 67 | /* Broadcom driver includes */ |
|---|
| 68 | #ifdef LINUX |
|---|
| 69 | #include <stdio.h> |
|---|
| 70 | #include <string.h> |
|---|
| 71 | #include <malloc.h> |
|---|
| 72 | #endif |
|---|
| 73 | #include "bgfx_types.h" |
|---|
| 74 | #include "bgfx_defs.h" |
|---|
| 75 | #include "bgfx_font.h" |
|---|
| 76 | |
|---|
| 77 | #if SOFT_GFX_AS_IN_7003 |
|---|
| 78 | typedef enum bgfx_blit_operation_blend{ |
|---|
| 79 | SURFBLIT_BLEND_WITH_SPEC_ALPHA1 = 0x00, /* Use alpha1 value for calculating R,G,B bleding */ |
|---|
| 80 | SURFBLIT_BLEND_WITH_SRC1_ALPHA = 0x01, /* Use source1 alpha value for calculating R,G,B bleding */ |
|---|
| 81 | SURFBLIT_BLEND_WITH_SRC2_ALPHA = 0x02, /* Use source2 alpha value for calculating R,G,B bleding */ |
|---|
| 82 | SURFBLIT_BLEND_WITH_AVG_ALPHA = 0x03 /* Use below formula for calculating R,G,B bleding */ |
|---|
| 83 | /* |
|---|
| 84 | * R = R1 * Alpha1 + R2 * Alpha2 * (1-Alpha1) |
|---|
| 85 | * G = G1 * Alpha1 + G2 * Alpha2 * (1-Alpha1) |
|---|
| 86 | * B = B1 * Alpha1 + B2 * Alpha2 * (1-Alpha1) |
|---|
| 87 | * Alpha = 1 - (1 - Alpha1) * ( 1 - Alpha2) |
|---|
| 88 | * R = R / Alpha |
|---|
| 89 | * G = G / Alpha |
|---|
| 90 | * B = B / Alpha |
|---|
| 91 | */ |
|---|
| 92 | }bgfx_blit_operation_blend; |
|---|
| 93 | |
|---|
| 94 | typedef enum bgfx_blit_operation_alpha{ |
|---|
| 95 | SURFBLIT_SET_DEST_ALPHA_WITH_SPEC_ALPHA2 = 0x00, /* Use alpha2 value for calculating A bleding */ |
|---|
| 96 | SURFBLIT_SET_DEST_ALPHA_WITH_SRC1_ALPHA = 0x10, /* Use source1 alpha value for calculating A bleding */ |
|---|
| 97 | SURFBLIT_SET_DEST_ALPHA_WITH_SRC2_ALPHA = 0x20, /* Use source2 alpha value for calculating A bleding */ |
|---|
| 98 | SURFBLIT_SET_DEST_ALPHA_WITH_AVG_ALPHA =0x30 /* Use below formula for calculating A bleding */ |
|---|
| 99 | /* Alpha = 1 - (1 - Alpha1) * ( 1 - Alpha2) */ |
|---|
| 100 | }bgfx_blit_operation_alpha; |
|---|
| 101 | #endif |
|---|
| 102 | /**************************************************************** |
|---|
| 103 | * raw bitmap structure |
|---|
| 104 | * bcm_raw_8_t describes the raw CLUT8 image format supported by SGIL |
|---|
| 105 | * The structure if followed by a 256 entry CLUT, each entry ARGB8888 |
|---|
| 106 | ****************************************************************/ |
|---|
| 107 | typedef struct bcm_raw_8_t |
|---|
| 108 | { |
|---|
| 109 | uint32_t version; /* version number of raw file - for future use */ |
|---|
| 110 | uint32_t type; /* type of raw file - for future use */ |
|---|
| 111 | uint32_t pitch; /* number of bytes per row */ |
|---|
| 112 | uint16_t width; /* number of pixel per row */ |
|---|
| 113 | uint16_t height; /* number of rows */ |
|---|
| 114 | uint8_t color_key; /* color key/transparency color value */ |
|---|
| 115 | uint16_t clut_size; /* number of entries in the ARGB8888 CLUT */ |
|---|
| 116 | }bcm_raw_8_t; |
|---|
| 117 | #define RAW_TYPE 0x52415720 |
|---|
| 118 | #define RAW_VERSION 0x00000001 |
|---|
| 119 | |
|---|
| 120 | #ifdef __cplusplus |
|---|
| 121 | extern "C" { |
|---|
| 122 | #endif |
|---|
| 123 | /**************************************************************** |
|---|
| 124 | * global sgil initialization |
|---|
| 125 | * Initialize SGIL global resources. Should be called prior to using |
|---|
| 126 | * any other SGIL function. prot_p must be an allocated and initialized. |
|---|
| 127 | * It is important that prot_p exists for the entire time |
|---|
| 128 | * SGIL is running and initialized because sgil just copies the reference. |
|---|
| 129 | ****************************************************************/ |
|---|
| 130 | int bgfx_init(bgfx_io_t *io_p, /* io callback functions */ |
|---|
| 131 | bgfx_prot_t *prot_p /* allocated, initialized sgil_prot_t reference */ |
|---|
| 132 | ); |
|---|
| 133 | |
|---|
| 134 | /**************************************************************** |
|---|
| 135 | * global sgil cleanup |
|---|
| 136 | * Free SGIL global resources. Should be called to cleanup all global resources |
|---|
| 137 | * allocated by SGIL. |
|---|
| 138 | ****************************************************************/ |
|---|
| 139 | void bgfx_done(void); |
|---|
| 140 | |
|---|
| 141 | /**************************************************************** |
|---|
| 142 | * Initialize an SGIL surface |
|---|
| 143 | * Create an SGIL surface using the node_name passed. width and height can be 0 when |
|---|
| 144 | * creating surfaces with the SGL_SURF_FULLSCREEN flag. All flags other than |
|---|
| 145 | * SGL_SURF_NONE can only be used when creating on-screen surfaces. Surfaces are |
|---|
| 146 | * CLUT8 (8-bpp) surfaces by default but can also be 8888 ARGB (32-bpp) |
|---|
| 147 | * when SGL_SURF_RGB is ored with the flags. |
|---|
| 148 | ****************************************************************/ |
|---|
| 149 | int bgfx_create(bgfx_surf_p p, /* pointer to allocated, uninitialized surface structure */ |
|---|
| 150 | uint16_t width, /* width in pixels of the surface */ |
|---|
| 151 | uint16_t height, /* height in pixels of the surface */ |
|---|
| 152 | #if SOFT_GFX_AS_IN_7003 |
|---|
| 153 | uint16_t x_pos, /* coordinate to the frame buffer */ |
|---|
| 154 | uint16_t y_pos, /* coordinate to the frame buffer */ |
|---|
| 155 | #endif |
|---|
| 156 | uint8_t *ptr, /* ptr to surface memory or NULL if memory needs to be allocated */ |
|---|
| 157 | uint16_t pitch, /* number of bytes per row in the surface */ |
|---|
| 158 | bgfx_palette_t *palette, /* a palette to copy or NULL to use default */ |
|---|
| 159 | uint32_t flags /* flags that define the type of surface to create */ |
|---|
| 160 | ); |
|---|
| 161 | |
|---|
| 162 | /**************************************************************** |
|---|
| 163 | * Free an SGIL surface |
|---|
| 164 | * Should be called to free up resources associated with the surface. |
|---|
| 165 | ****************************************************************/ |
|---|
| 166 | void bgfx_destroy(bgfx_surf_p p /* pointer to initialized surface structure */ |
|---|
| 167 | ); |
|---|
| 168 | |
|---|
| 169 | /**************************************************************** |
|---|
| 170 | * Get surface width,height and flags. |
|---|
| 171 | * Get surface information including width height and flags. |
|---|
| 172 | ****************************************************************/ |
|---|
| 173 | void bgfx_get_info(bgfx_surf_p p, /* pointer to initialized surface structure */ |
|---|
| 174 | uint16_t *w, /* surface width in pixels */ |
|---|
| 175 | uint16_t *h, /* surface height in pixels */ |
|---|
| 176 | uint16_t *pitch, /* surface width in bytes */ |
|---|
| 177 | uint32_t *flags /* surface flags (see bgfx_create) */ |
|---|
| 178 | ); |
|---|
| 179 | |
|---|
| 180 | /**************************************************************** |
|---|
| 181 | * Get the surface palette (CLUT). |
|---|
| 182 | * Get a copy of the current surface palette. |
|---|
| 183 | ****************************************************************/ |
|---|
| 184 | void bgfx_get_palette(bgfx_surf_p p, /* pointer to initialized surface structure */ |
|---|
| 185 | bgfx_palette_t *palette_p /* palette to copy surface palette to (CLUT8 ARGB8888)*/ |
|---|
| 186 | ); |
|---|
| 187 | |
|---|
| 188 | /**************************************************************** |
|---|
| 189 | * Set the surface palette (CLUT). |
|---|
| 190 | * Set the surface palette and update the hardware palette. |
|---|
| 191 | ****************************************************************/ |
|---|
| 192 | void bgfx_set_palette(bgfx_surf_p p, /* pointer to initialized surface structure */ |
|---|
| 193 | bgfx_palette_t *palette_p /* palette to copy to surface palette (CLUT8 ARGB8888)*/ |
|---|
| 194 | ); |
|---|
| 195 | /**************************************************************** |
|---|
| 196 | * Set the pixel value. |
|---|
| 197 | * Set the pixel value at x,y location to the value c. |
|---|
| 198 | * When the surface is a CLUT8 surface c should be an 8-bit |
|---|
| 199 | * value. When the surface is an 8888 ARGB surface c should be |
|---|
| 200 | * a 32-bit value. This avoids logic for performing |
|---|
| 201 | * color reduction or format translations. |
|---|
| 202 | ****************************************************************/ |
|---|
| 203 | void bgfx_set_pixel(bgfx_surf_p p, /* pointer to initialized surface structure */ |
|---|
| 204 | uint16_t x, /* horizontal location in pixels (top/left 0,0) */ |
|---|
| 205 | uint16_t y, /* vertical location in pixels */ |
|---|
| 206 | bgfx_pixel c /* pixel value to set */ |
|---|
| 207 | ); |
|---|
| 208 | |
|---|
| 209 | #if SOFT_GFX_AS_IN_7003 |
|---|
| 210 | void bgfx_set_pixel_direct(bgfx_surf_p p, |
|---|
| 211 | uint16_t x, |
|---|
| 212 | uint16_t y, |
|---|
| 213 | bgfx_pixel c); |
|---|
| 214 | #endif |
|---|
| 215 | |
|---|
| 216 | /**************************************************************** |
|---|
| 217 | * Get the pixel value. |
|---|
| 218 | * Get the pixel value at x,y location. |
|---|
| 219 | * When the surface is a CLUT8 surface c will be an 8-bit |
|---|
| 220 | * value. When the surface is an 8888 ARGB surface c will be |
|---|
| 221 | * a 32-bit value. This avoids logic for performing |
|---|
| 222 | * color reduction or format translations. |
|---|
| 223 | ****************************************************************/ |
|---|
| 224 | bgfx_pixel bgfx_get_pixel(bgfx_surf_p p, /* pointer to initialized surface structure */ |
|---|
| 225 | uint16_t x, /* horizontal location in pixels (top/left 0,0) */ |
|---|
| 226 | uint16_t y /* vertical location in pixels */ |
|---|
| 227 | ); |
|---|
| 228 | |
|---|
| 229 | #if SOFT_GFX_AS_IN_7003 |
|---|
| 230 | bgfx_pixel bgfx_get_pixel_from_buffer(uint8_t format, |
|---|
| 231 | uint16_t src_w, |
|---|
| 232 | uint16_t src_h, |
|---|
| 233 | uint32_t des_x, |
|---|
| 234 | uint32_t des_y, |
|---|
| 235 | void *pbuffer); |
|---|
| 236 | #endif |
|---|
| 237 | |
|---|
| 238 | /**************************************************************** |
|---|
| 239 | * Draw a horizontal line. |
|---|
| 240 | * Draw a single pixel wide horizontal line with the pixel value. |
|---|
| 241 | ****************************************************************/ |
|---|
| 242 | void bgfx_h_draw_line(bgfx_surf_p p, /* pointer to initialized surface structure */ |
|---|
| 243 | uint16_t x1, /* horizontal line starting point */ |
|---|
| 244 | uint16_t x2, /* horizontal line ending point */ |
|---|
| 245 | uint16_t y, /* vertical line location */ |
|---|
| 246 | bgfx_pixel c /* pixel value to set */ |
|---|
| 247 | ); |
|---|
| 248 | |
|---|
| 249 | /**************************************************************** |
|---|
| 250 | * Draw a vertical line. |
|---|
| 251 | * Draw a single pixel wide vertical line with the pixel value. |
|---|
| 252 | ****************************************************************/ |
|---|
| 253 | void bgfx_v_draw_line(bgfx_surf_p p, /* pointer to initialized surface structure */ |
|---|
| 254 | uint16_t x, /* horizontal location in pixels (top/left 0,0) */ |
|---|
| 255 | uint16_t y1, /* vertical line starting point */ |
|---|
| 256 | uint16_t y2, /* vertical line end point */ |
|---|
| 257 | bgfx_pixel c /* pixel value to set */ |
|---|
| 258 | ); |
|---|
| 259 | |
|---|
| 260 | /**************************************************************** |
|---|
| 261 | * Fill a rectanglular region of the surface. |
|---|
| 262 | * Fill the region with with the pixel value. |
|---|
| 263 | ****************************************************************/ |
|---|
| 264 | void bgfx_fill_rect(bgfx_surf_p p, /* pointer to initialized surface structure */ |
|---|
| 265 | uint16_t x, /* rectangle left location in pixels */ |
|---|
| 266 | uint16_t y, /* rectangle top location in pixels */ |
|---|
| 267 | uint16_t w, /* rectangle width in pixels */ |
|---|
| 268 | uint16_t h, /* rectangle height in pixels */ |
|---|
| 269 | bgfx_pixel c /* pixel value to set */ |
|---|
| 270 | ); |
|---|
| 271 | |
|---|
| 272 | /**************************************************************** |
|---|
| 273 | * Draw the UNI string. |
|---|
| 274 | * Draw the UNI string at the x,y location with |
|---|
| 275 | * the pixel value. Use the functions in sgl_font.h to initialize |
|---|
| 276 | * the font structure. Using preloaded cached fonts will result in best |
|---|
| 277 | * drawing performance. When using 8 -bit grayscale fonts rather than mono fonts |
|---|
| 278 | * the pixel value will be used when the grayscale value is >=75%, c-1 for >= 50% |
|---|
| 279 | * and c-2 for >= 25%. |
|---|
| 280 | ****************************************************************/ |
|---|
| 281 | void bgfx_draw_text(bgfx_surf_p p, /* pointer to initialized surface structure */ |
|---|
| 282 | uint16_t x, /* horizontal location in pixels (top/left 0,0) */ |
|---|
| 283 | uint16_t y, /* vertical location in pixels */ |
|---|
| 284 | const unsigned long *str_p, /* array of 32-bit unicode characters */ |
|---|
| 285 | int str_len, /* Length of character array */ |
|---|
| 286 | bgfx_font_t *font_p, /* initialized font structure (see sgl_font.h) */ |
|---|
| 287 | bgfx_pixel c, /* pixel value to set */ |
|---|
| 288 | bgfx_text_style style /* Text style */ |
|---|
| 289 | ); |
|---|
| 290 | /**************************************************************** |
|---|
| 291 | * Draw the UNI string. |
|---|
| 292 | * Draw the UNI string at the x,y location with |
|---|
| 293 | * the pixel value. Use the functions in sgl_font.h to initialize |
|---|
| 294 | * the font structure. Using preloaded cached fonts will result in best |
|---|
| 295 | * drawing performance. When using 8 -bit grayscale fonts rather than mono fonts |
|---|
| 296 | * the pixel value will be used when the grayscale value is >=75%, c-1 for >= 50% |
|---|
| 297 | * and c-2 for >= 25%. |
|---|
| 298 | ****************************************************************/ |
|---|
| 299 | void bgfx_draw_text_box(bgfx_surf_p p, /* pointer to initialized surface structure */ |
|---|
| 300 | uint16_t x, /* horizontal location in pixels (top/left 0,0) */ |
|---|
| 301 | uint16_t y, /* vertical location in pixels */ |
|---|
| 302 | uint16_t width, /* horizontal size in pixels (top/left 0,0) */ |
|---|
| 303 | uint16_t height, /* vertical size in pixels */ |
|---|
| 304 | const unsigned long *str_p, /* array of 32-bit unicode characters */ |
|---|
| 305 | int str_len, /* Length of character array */ |
|---|
| 306 | bgfx_font_t *font_p,/* initialized font structure (see sgl_font.h) */ |
|---|
| 307 | bgfx_pixel c, /* pixel value to set */ |
|---|
| 308 | uint16_t line_spacing /* Space between lines */ |
|---|
| 309 | ); |
|---|
| 310 | |
|---|
| 311 | |
|---|
| 312 | /**************************************************************** |
|---|
| 313 | * Draw bitmap from a file. |
|---|
| 314 | ****************************************************************/ |
|---|
| 315 | #if SOFT_GFX_AS_IN_7003 |
|---|
| 316 | int bgfx_render_file(bgfx_surf_p p, /* surface pointer */ |
|---|
| 317 | uint16_t src_w, /* source image width */ |
|---|
| 318 | uint16_t src_h, /* source image height */ |
|---|
| 319 | int16_t des_x, /* destination x position */ |
|---|
| 320 | int16_t des_y, /* destination y position */ |
|---|
| 321 | void *file_p); /* image file pointer */ |
|---|
| 322 | |
|---|
| 323 | /**************************************************************** |
|---|
| 324 | * Draw bitmap from a buffer. |
|---|
| 325 | ****************************************************************/ |
|---|
| 326 | int bgfx_render_buffer(bgfx_surf_p p, |
|---|
| 327 | uint8_t format, |
|---|
| 328 | uint16_t src_w, |
|---|
| 329 | uint16_t src_h, |
|---|
| 330 | uint16_t des_x, |
|---|
| 331 | uint16_t des_y, |
|---|
| 332 | void *pbuffer); |
|---|
| 333 | |
|---|
| 334 | #else |
|---|
| 335 | int bgfx_render_file(bgfx_surf_p p, /* pointer to initialized surface structure */ |
|---|
| 336 | uint16_t x, /* horizontal location in pixels (top/left 0,0) */ |
|---|
| 337 | uint16_t y, /* vertical location in pixels */ |
|---|
| 338 | void *file_p, /* open CLUT8 binary file point to render directly to the surface */ |
|---|
| 339 | int set_palette /* use this CLUT as the global palette */ |
|---|
| 340 | ); |
|---|
| 341 | #endif |
|---|
| 342 | /**************************************************************** |
|---|
| 343 | * Copy from one surface to the other. |
|---|
| 344 | * Copy the source surface to the destination at x,y location (top/left) |
|---|
| 345 | * The source colorkey value will be used. The source must be a CLUT8 surface |
|---|
| 346 | * but the destination can be CLUT8 or RGB. |
|---|
| 347 | ****************************************************************/ |
|---|
| 348 | int bgfx_blit(bgfx_surf_p p_src, /* pointer to initialized source surface structure */ |
|---|
| 349 | bgfx_surf_p p_dst, /* pointer to initialized destination surface structure */ |
|---|
| 350 | uint16_t x, /* horizontal location in pixels (top/left 0,0) */ |
|---|
| 351 | uint16_t y /* vertical location in pixels */ |
|---|
| 352 | ); |
|---|
| 353 | |
|---|
| 354 | /**************************************************************** |
|---|
| 355 | * Copy a rectangle area from one surface to the other. |
|---|
| 356 | * Copy the source surface at (sx,sy) to the destination at (dx,dy) |
|---|
| 357 | * The source colorkey value will be used. The source must be a CLUT8 surface |
|---|
| 358 | * but the destination can be CLUT8 or RGB. |
|---|
| 359 | ****************************************************************/ |
|---|
| 360 | int bgfx_blit_rect(bgfx_surf_p p_src, /* pointer to initialized source surface structure */ |
|---|
| 361 | bgfx_surf_p p_dst, /* pointer to initialized destination surface structure */ |
|---|
| 362 | uint16_t sx, /* source horizontal location in pixels */ |
|---|
| 363 | uint16_t sy, /* source vertical location in pixels */ |
|---|
| 364 | uint16_t dx, /* destination horizontal location in pixels */ |
|---|
| 365 | uint16_t dy, /* destination vertical location in pixels */ |
|---|
| 366 | uint16_t sw, /* source width in pixel */ |
|---|
| 367 | uint16_t sh, /* source height in pixel */ |
|---|
| 368 | bool b_csc, /* true = do RGB to YCbCr color space conversion as per matrix coeffs in p_csc */ |
|---|
| 369 | bgfx_color_matrix_p p_csc); |
|---|
| 370 | |
|---|
| 371 | #if SOFT_GFX_AS_IN_7003 |
|---|
| 372 | /**************************************************************** |
|---|
| 373 | * Alpha blend a rectangle area from 2 source surface to the destinate surface. |
|---|
| 374 | * Source and destinate surface must be RGB. |
|---|
| 375 | ****************************************************************/ |
|---|
| 376 | int bgfx_blit_rect_multisuf_blending(bgfx_surf_p p_src1, /* pointer to initialized source surface structure */ |
|---|
| 377 | bgfx_surf_p p_src2, /* pointer to initialized source surface structure */ |
|---|
| 378 | bgfx_surf_p p_dst, /* pointer to initialized destination surface structure */ |
|---|
| 379 | uint16_t s1x, /* source horizontal location in pixels */ |
|---|
| 380 | uint16_t s1y, /* source vertical location in pixels */ |
|---|
| 381 | uint16_t s2x, /* source horizontal location in pixels */ |
|---|
| 382 | uint16_t s2y, /* source vertical location in pixels */ |
|---|
| 383 | uint16_t dx, /* destination horizontal location in pixels */ |
|---|
| 384 | uint16_t dy, /* destination vertical location in pixels */ |
|---|
| 385 | uint16_t sw, /* source width in pixel */ |
|---|
| 386 | uint16_t sh, /* source height in pixel */ |
|---|
| 387 | unsigned int operation, /* alpha blending mode */ |
|---|
| 388 | uint32_t alpha1, /* specified alpha value for RGB blending calculation, see bgfx_blit_operation_blend*/ |
|---|
| 389 | uint32_t alpha2); /* specified alpha value for A blending calculation, see bgfx_blit_operation_alpha */ |
|---|
| 390 | #endif |
|---|
| 391 | |
|---|
| 392 | #if SOFT_GFX_AS_IN_7003 |
|---|
| 393 | /**************************************************************** |
|---|
| 394 | * |
|---|
| 395 | * INPUTS: p_src - source palette pointer |
|---|
| 396 | * OUTPUTS: none |
|---|
| 397 | * RETURNS: none |
|---|
| 398 | * FUNCTION: Map palette from RGB to YUV |
|---|
| 399 | * Raymond, 20090211 |
|---|
| 400 | ****************************************************************/ |
|---|
| 401 | void bgfx_mapping_palette(unsigned int *p_src, unsigned int size); |
|---|
| 402 | #endif |
|---|
| 403 | |
|---|
| 404 | /**************************************************************** |
|---|
| 405 | * do anti-flutter filter on one surface. |
|---|
| 406 | * source and destination surface can be same. |
|---|
| 407 | * |
|---|
| 408 | * |
|---|
| 409 | ****************************************************************/ |
|---|
| 410 | |
|---|
| 411 | int bgfx_anti_flutter_filter(bgfx_surf_p p_src, /* pointer to initialized source surface structure */ |
|---|
| 412 | bgfx_surf_p p_dst, /* pointer to initialized destination surface structure */ |
|---|
| 413 | uint16_t sx, /* source horizontal location in pixels */ |
|---|
| 414 | uint16_t sy, /* source vertical location in pixels */ |
|---|
| 415 | uint16_t dx, /* destination horizontal location in pixels */ |
|---|
| 416 | uint16_t dy, /* destination vertical location in pixels */ |
|---|
| 417 | uint16_t sw, /* source width in pixel */ |
|---|
| 418 | uint16_t sh); /* source height in pixel */ |
|---|
| 419 | |
|---|
| 420 | /**************************************************************** |
|---|
| 421 | * Blend fill a rectanglular region of the surface. |
|---|
| 422 | * Fill the region with constant color corresponding to colorOp=eBlend |
|---|
| 423 | * and alphaOp=eIgnore. |
|---|
| 424 | * |
|---|
| 425 | * Fills the region as per following rule: |
|---|
| 426 | * const color c -> AcRcGcBc (src1) |
|---|
| 427 | * surface p -> AiRiGiBi (src2) |
|---|
| 428 | * blended outpout -> AiRoGoBo |
|---|
| 429 | * where Ro = Ac * Rc + (1 - Ac) * Ri |
|---|
| 430 | * Go = Ac * Gc + (1 - Ac) * Gi |
|---|
| 431 | * Bo = Ac * Bc + (1 - Ac) * Bi |
|---|
| 432 | * Note: Constant color c is always in ARGB8888 format. |
|---|
| 433 | ****************************************************************/ |
|---|
| 434 | int bgfx_blend_fill_rect(bgfx_surf_p p, /* pointer to initialized surface structure */ |
|---|
| 435 | uint16_t x, /* rectangle left location in pixels */ |
|---|
| 436 | uint16_t y, /* rectangle top location in pixels */ |
|---|
| 437 | uint16_t w, /* rectangle width in pixels */ |
|---|
| 438 | uint16_t h, /* rectangle height in pixels */ |
|---|
| 439 | bgfx_pixel c); /* pixel value to blend fill */ |
|---|
| 440 | |
|---|
| 441 | /**************************************************************** |
|---|
| 442 | * Copy a rectangle area from one surface to the other with scaling. |
|---|
| 443 | * Copy the source surface at (sx,sy) to the destination at (dx,dy) |
|---|
| 444 | ****************************************************************/ |
|---|
| 445 | int bgfx_blit_rect_scale(bgfx_surf_p p_src, /* pointer to initialized source surface structure */ |
|---|
| 446 | bgfx_surf_p p_dst, /* pointer to initialized destination surface structure */ |
|---|
| 447 | uint16_t sx, /* source horizontal location in pixels */ |
|---|
| 448 | uint16_t sy, /* source vertical location in pixels */ |
|---|
| 449 | uint16_t dx, /* destination horizontal location in pixels */ |
|---|
| 450 | uint16_t dy, /* destination vertical location in pixels */ |
|---|
| 451 | uint16_t sw, /* source width in pixel */ |
|---|
| 452 | uint16_t sh,/* source height in pixel */ |
|---|
| 453 | uint16_t dw,/* destination width in pixel*/ |
|---|
| 454 | uint16_t dh); /* destination width in pixel*/ |
|---|
| 455 | /**************************************************************** |
|---|
| 456 | * Copy a rectangle area from one surface to the other with scaling. |
|---|
| 457 | * Copy the source surface at (sx,sy) to the destination at (dx,dy) |
|---|
| 458 | ****************************************************************/ |
|---|
| 459 | int bgfx_blit_rect_scale_v_up_h_up(bgfx_surf_p p_src, /* pointer to initialized source surface structure */ |
|---|
| 460 | bgfx_surf_p p_dst, /* pointer to initialized destination surface structure */ |
|---|
| 461 | uint16_t sx, /* source horizontal location in pixels */ |
|---|
| 462 | uint16_t sy, /* source vertical location in pixels */ |
|---|
| 463 | uint16_t dx, /* destination horizontal location in pixels */ |
|---|
| 464 | uint16_t dy, /* destination vertical location in pixels */ |
|---|
| 465 | uint16_t sw, /* source width in pixel */ |
|---|
| 466 | uint16_t sh,/* source height in pixel */ |
|---|
| 467 | uint16_t dw,/* destination width in pixel*/ |
|---|
| 468 | uint16_t dh); /* destination width in pixel*/ |
|---|
| 469 | /**************************************************************** |
|---|
| 470 | * Copy a rectangle area from one surface to the other with scaling. |
|---|
| 471 | * Copy the source surface at (sx,sy) to the destination at (dx,dy) |
|---|
| 472 | ****************************************************************/ |
|---|
| 473 | int bgfx_blit_rect_scale_v_down_h_down(bgfx_surf_p p_src, /* pointer to initialized source surface structure */ |
|---|
| 474 | bgfx_surf_p p_dst, /* pointer to initialized destination surface structure */ |
|---|
| 475 | uint16_t sx, /* source horizontal location in pixels */ |
|---|
| 476 | uint16_t sy, /* source vertical location in pixels */ |
|---|
| 477 | uint16_t dx, /* destination horizontal location in pixels */ |
|---|
| 478 | uint16_t dy, /* destination vertical location in pixels */ |
|---|
| 479 | uint16_t sw, /* source width in pixel */ |
|---|
| 480 | uint16_t sh,/* source height in pixel */ |
|---|
| 481 | uint16_t dw,/* destination width in pixel*/ |
|---|
| 482 | uint16_t dh); /* destination width in pixel*/ |
|---|
| 483 | |
|---|
| 484 | #ifdef __cplusplus |
|---|
| 485 | } |
|---|
| 486 | #endif |
|---|
| 487 | |
|---|
| 488 | #endif /* __bgfx_h__ */ |
|---|
| 489 | |
|---|