source: svn/trunk/newcon3bcm2_21bu/dta/src/app/bgfx.h @ 2

Last change on this file since 2 was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 14.6 KB
Line 
1/***************************************************************
2**
3** Broadcom Corp. Confidential
4** Copyright 2002 Broadcom Corp. All Rights Reserved.
5**
6** THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED
7** SOFTWARE LICENSE AGREEMENT BETWEEN THE USER AND BROADCOM.
8** YOU HAVE NO RIGHT TO USE OR EXPLOIT THIS MATERIAL EXCEPT
9** SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
10**
11** Description: bgfx core implementation
12**
13** Created: 8/22/2002 by Jeffrey P. Fisher
14**
15**
16**
17****************************************************************/
18
19#ifndef __bgfx_h__
20#define __bgfx_h__
21
22/* Broadcom driver includes */
23#include "bgfx_types.h"
24#include "bgfx_defs.h"
25#include "bgfx_font.h"
26
27typedef enum bgfx_textbox_ex_t
28{
29    eBANNER_STATUS_JUSTIFY_LEFT                = 0,
30    eBANNER_STATUS_JUSTIFY_CENTER              = 1,
31    eBANNER_STATUS_JUSTIFY_RIGHT               = 2,
32    eBANNER_STATUS_JUSTIFY_TOP                 = 0
33}bgfx_textbox_ex_t;
34
35/****************************************************************
36* raw bitmap structure
37*               bcm_raw_8_t describes the raw CLUT8 image format supported by SGIL
38*               The structure if followed by a 256 entry CLUT, each entry ARGB8888
39****************************************************************/
40typedef struct bcm_raw_8_t
41{
42        uint32_t version;               /* version number of raw file - for future use */
43        uint32_t type;                  /* type of raw file - for future use */
44        uint32_t pitch;                 /* number of bytes per row */
45        uint16_t width;                 /* number of pixel per row */
46        uint16_t height;                /* number of rows */
47        uint8_t color_key;              /* color key/transparency color value */
48        uint16_t clut_size;             /* number of entries in the ARGB8888 CLUT */
49}bcm_raw_8_t;
50#define RAW_TYPE                0x52415720
51#define RAW_VERSION             0x00000001
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56/****************************************************************
57* global sgil initialization
58 *              Initialize SGIL global resources. Should be called prior to using
59 *              any other SGIL function.  prot_p must be an allocated and initialized.
60 *              It is important that prot_p exists for the entire time
61 *              SGIL is running and initialized because sgil just copies the reference.
62****************************************************************/
63    int bgfx_init(bgfx_io_t *io_p,              /* io callback functions */
64                                 bgfx_prot_t *prot_p,   /* allocated, initialized sgil_prot_t */
65                                 bgfx_hw_t      *hw_p           /* hw acceleration callbacks */
66                                 );
67
68/****************************************************************
69* global sgil cleanup
70*               Free SGIL global resources.  Should be called to cleanup all global resources
71*               allocated by SGIL.
72****************************************************************/
73    void bgfx_done(void);
74
75/****************************************************************
76* Initialize an SGIL surface
77*               Create an SGIL surface using the node_name passed.  width and height can be 0 when
78*               creating surfaces with the SGL_SURF_FULLSCREEN flag.  All flags other than
79*               SGL_SURF_NONE can only be used when creating on-screen surfaces.   Surfaces are
80*               CLUT8 (8-bpp) surfaces by default but can also be 8888 ARGB (32-bpp)
81*               when SGL_SURF_RGB is ored with the flags.
82****************************************************************/
83        int bgfx_create(bgfx_surf_p p,                  /* pointer to allocated, uninitialized surface structure */
84                                   uint16_t width,                      /* width in pixels of the surface */
85                                   uint16_t height,                     /* height in pixels of the surface */
86                                   uint8_t      *ptr,                   /* ptr to surface memory or NULL if memory needs to be allocated */
87                                   uint16_t pitch,                      /* number of bytes per row in the surface */
88                                   bgfx_palette_t *palette,     /* a palette to copy or NULL to use default */
89                                   uint32_t flags                       /* flags that define the type of surface to create */
90                                   );
91
92/****************************************************************
93* Free an SGIL surface
94*               Should be called to free up resources associated with the surface.
95****************************************************************/
96        void bgfx_destroy(bgfx_surf_p p                 /* pointer to initialized surface structure */
97                                         );
98
99        /****************************************************************
100* Get surface width,height and flags.
101*               Get surface information including width height and flags.
102****************************************************************/
103        void bgfx_get_info(bgfx_surf_p p,                               /* pointer to initialized surface structure */
104                                                        uint16_t *w,            /* surface width in pixels */
105                                                        uint16_t *h,            /* surface height in pixels */
106                                                        uint16_t *pitch,                /* surface width in bytes */
107                                                        uint32_t *flags         /* surface flags (see bgfx_create) */
108                                                 );
109
110/****************************************************************
111* Get the surface palette (CLUT).
112*               Get a copy of the current surface palette.
113****************************************************************/
114        void bgfx_get_palette(bgfx_surf_p p,                    /* pointer to initialized surface structure */
115                                                 bgfx_palette_t *palette_p /* palette to copy surface palette to (CLUT8 ARGB8888)*/
116                                                 );
117
118/****************************************************************
119* Set the surface palette (CLUT).
120*               Set the surface palette and update the hardware palette.
121****************************************************************/
122        void bgfx_set_palette(bgfx_surf_p p,                    /* pointer to initialized surface structure */
123                                                 bgfx_palette_t *palette_p /* palette to copy to surface palette (CLUT8 ARGB8888)*/
124                                                 );
125
126/****************************************************************
127* Set the pixel value.
128*               Set the pixel value at x,y location to the value c. 
129*               When the surface is a CLUT8 surface c should be an 8-bit
130*               value.  When the surface is an 8888 ARGB surface c should be
131*               a 32-bit value.  This avoids logic for performing
132*               color reduction or format translations.
133****************************************************************/
134        void bgfx_set_pixel(bgfx_surf_p p,                      /* pointer to initialized surface structure */
135                                                        uint16_t x,                     /* horizontal location in pixels (top/left 0,0) */
136                                                        uint16_t y,                     /* vertical location in pixels */
137                                           bgfx_pixel c                         /* pixel value to set */
138                                           );
139
140/****************************************************************
141* Get the pixel value.
142*               Get the pixel value at x,y location. 
143*               When the surface is a CLUT8 surface c will be an 8-bit
144*               value.  When the surface is an 8888 ARGB surface c will be
145*               a 32-bit value.  This avoids logic for performing
146*               color reduction or format translations.
147****************************************************************/
148        bgfx_pixel bgfx_get_pixel(bgfx_surf_p p,                /* pointer to initialized surface structure */
149                                                        uint16_t x,                     /* horizontal location in pixels (top/left 0,0) */
150                                                        uint16_t y                      /* vertical location in pixels */
151                                                        );
152
153/****************************************************************
154* Draw a horizontal line.
155*               Draw a single pixel wide horizontal line with the pixel value.
156****************************************************************/
157        void bgfx_h_draw_line(bgfx_surf_p p,                    /* pointer to initialized surface structure */
158                                                        uint16_t x1,            /* horizontal line starting point */
159                                                        uint16_t x2,            /* horizontal line ending point */
160                                                        uint16_t y,                     /* vertical line location */
161                                                        bgfx_pixel c                    /* pixel value to set */
162                                                        );
163
164/****************************************************************
165* Draw a vertical line.
166*               Draw a single pixel wide vertical line with the pixel value.
167****************************************************************/
168        void bgfx_v_draw_line(bgfx_surf_p p,                    /* pointer to initialized surface structure */
169                                                        uint16_t x,                     /* horizontal location in pixels (top/left 0,0) */
170                                                        uint16_t y1,            /* vertical line starting point */
171                                                        uint16_t y2,            /* vertical line end point */
172                                                        bgfx_pixel c                    /* pixel value to set */
173                                                        );
174
175/****************************************************************
176* Fill a rectanglular region of the surface.
177*               Fill the region with with the pixel value.
178****************************************************************/
179        void bgfx_fill_rect(bgfx_surf_p p,                      /* pointer to initialized surface structure */
180                                                        uint16_t x,                     /* rectangle left location in pixels */
181                                                        uint16_t y,                     /* rectangle top location in pixels */
182                                                        uint16_t w,                     /* rectangle width in pixels */
183                                                        uint16_t h,                     /* rectangle height in pixels */
184                                                        bgfx_pixel c                    /* pixel value to set */
185                                                        );
186       
187/****************************************************************
188* Draw the UNI string.
189*               Draw the UNI string at the x,y location with
190*               the pixel value.  Use the functions in sgl_font.h to initialize
191*               the font structure.  Using preloaded cached fonts will result in best
192*               drawing performance.  When using 8 -bit grayscale fonts rather than mono fonts
193*               the pixel value will be used when the grayscale value is >=75%, c-1 for >= 50%
194*               and c-2 for >= 25%.
195****************************************************************/
196        void bgfx_draw_text(bgfx_surf_p p,                      /* pointer to initialized surface structure */
197                                                        uint16_t x,                     /* horizontal location in pixels (top/left 0,0) */
198                                                        uint16_t y,                     /* vertical location in pixels */
199                                                        const unsigned long *str_p,     /* array of 32-bit unicode characters */
200                                                        int str_len,            /* Length of character array */
201                                                        bgfx_font_t *font_p,    /* initialized font structure (see sgl_font.h) */
202                                                        bgfx_pixel c,                   /* pixel value to set */
203                                                        bgfx_text_style style   /* Text style */
204                                                        );
205/****************************************************************
206* Draw the UNI string.
207*               Draw the UNI string at the x,y location with
208*               the pixel value.  Use the functions in sgl_font.h to initialize
209*               the font structure.  Using preloaded cached fonts will result in best
210*               drawing performance.  When using 8 -bit grayscale fonts rather than mono fonts
211*               the pixel value will be used when the grayscale value is >=75%, c-1 for >= 50%
212*               and c-2 for >= 25%.
213****************************************************************/
214        void bgfx_draw_text_box(bgfx_surf_p p,          /* pointer to initialized surface structure */
215                                                        uint16_t x,                     /* horizontal location in pixels (top/left 0,0) */
216                                                        uint16_t y,                     /* vertical location in pixels */
217                                                        uint16_t width,         /* horizontal size in pixels (top/left 0,0) */
218                                                        uint16_t height,        /* vertical size in pixels */
219                                                        const unsigned long *str_p,     /* array of 32-bit unicode characters */
220                                                        int str_len,            /* Length of character array */
221                                                        bgfx_font_t *font_p,/* initialized font structure (see sgl_font.h) */
222                                                        bgfx_pixel c,           /* pixel value to set */
223                                                        uint16_t line_spacing   /* Space between lines */
224                                                        );
225   
226       
227/****************************************************************
228* Draw bitmap from a file.
229****************************************************************/
230        int bgfx_render_file(bgfx_surf_p p,                     /* pointer to initialized surface structure */
231                                                        uint16_t x,                     /* horizontal location in pixels (top/left 0,0) */
232                                                        uint16_t y,                     /* vertical location in pixels */
233                                                        void *file_p,           /* open CLUT8 binary file point to render directly to the surface */
234                                                        int set_palette         /* use this CLUT as the global palette */
235                                                        );
236       
237/****************************************************************
238* Copy from one surface to the other.
239*               Copy the source surface to the destination at x,y location (top/left)
240*               The source colorkey value will be used.  The source must be a CLUT8 surface
241*               but the destination can be CLUT8 or RGB.
242****************************************************************/
243    int bgfx_blit(bgfx_surf_p p_src,                            /* pointer to initialized source surface structure */ 
244                                                        bgfx_surf_p p_dst,      /* pointer to initialized destination surface structure */ 
245                                                        uint16_t x,                     /* horizontal location in pixels (top/left 0,0) */
246                                                        uint16_t y                      /* vertical location in pixels */
247                                                        );
248   
249/****************************************************************
250* Copy a rectangle area from one surface to the other.
251*               Copy the source surface at (sx,sy) to the destination at (dx,dy)
252*               The source colorkey value will be used.  The source must be a CLUT8 surface
253*               but the destination can be CLUT8 or RGB.
254****************************************************************/
255        int bgfx_blit_rect(bgfx_surf_p p_src,           /* pointer to initialized source surface structure */ 
256                                          bgfx_surf_p p_dst,                    /* pointer to initialized destination surface structure */ 
257                                          uint16_t sx,                          /* source horizontal location in pixels */
258                                          uint16_t sy,              /* source vertical location in pixels */
259                                          uint16_t dx,              /* destination horizontal location in pixels */
260                                          uint16_t dy,              /* destination vertical location in pixels */
261                                          uint16_t sw,                          /* source width in pixel */
262                                          uint16_t sh);                         /* source height in pixel */
263
264#ifdef  HAS_SUBTITLE
265void bgfx_fill_box_subtitle(
266    bgfx_surf_p p,              /* surface buffer to draw */
267    uint16_t x,uint16_t y,      /* x and y */
268    uint16_t w,uint16_t h,      /* w and h */
269    uint8_t *pbuf,              /* pointer to a buffer with bitmap for subtitle to draw */
270    uint16_t buf_len,           /* buf length, should match the w * h * format bytes */
271    bgfx_pixel bg,              /* background color, for palettle, it is color index */
272    bgfx_pixel fg,              /* forground color, for palettle, it is color index */
273    bool update_bg              /* update background with given color */
274);
275
276#endif
277
278bool bgfx_draw_text_box_ex(
279        bgfx_surf_p p,              /* pointer to initialized surface structure */
280    uint16_t *x,                /* horizontal location in pixels (top/left 0,0)*/
281    uint16_t *y,                /* vertical location in pixels */
282    uint16_t *w,                /* horizontal size in pixels (top/left 0,0) */
283    uint16_t *h,                /* vertical size in pixels */
284    const unsigned int *str_p,  /* array of 32-bit unicode characters */
285    uint16_t str_len,           /* length of character array */
286    bgfx_font_t *f,             /* initialized font structure (see sgl_font.h) */
287    bgfx_pixel fg,              /* foreground color */
288    bgfx_pixel bg,              /* background color */
289    bgfx_pixel bc,              /* border color */
290    uint16_t line_spacing,              /* leading (extra space between lines) */
291    uint16_t m,             /* margin between text and borders */
292    uint16_t b,             /* width of border (on the outside of the box) */
293    uint16_t h_justify,         /* Horizontal justification type: 0=left, 1=center, 2=right */
294    uint16_t v_justify                      /* Vertical justification type:0=top, 1=center */
295    );
296
297int bgfx_stretch_blit(bgfx_surf_p p_src, bgfx_surf_p p_dst,
298        uint16_t sx,uint16_t sy,uint16_t dx,uint16_t dy,
299        uint16_t sw,uint16_t sh,uint16_t dw,uint16_t dh);
300#ifdef __cplusplus
301}
302#endif
303
304#endif /* __bgfx_h__ */
305
306
Note: See TracBrowser for help on using the repository browser.