WebRadioApp  0.1
ewgfxres.h
Go to the documentation of this file.
1 /*******************************************************************************
2  *
3  * E M B E D D E D W I Z A R D P R O J E C T
4  *
5  * Copyright (c) TARA Systems
6  *GmbH written by Paul Banach and Manfred Schweyer
7  *
8  ********************************************************************************
9  *
10  * This software and related documentation ("Software") are intellectual
11  * property owned by TARA Systems and are copyright of TARA Systems.
12  * Any modification, copying, reproduction or redistribution of the Software in
13  * whole or in part by any means not in accordance with the End-User License
14  * Agreement for Embedded Wizard is expressly prohibited. The removal of this
15  * preamble is expressly prohibited.
16  *
17  ********************************************************************************
18  *
19  * DESCRIPTION:
20  * This is an internal header of the Embedded Wizard Graphics Engine EWGFX. It
21  * declares the platform independent interface to an external bitmap and font
22  * resource provider. In Embedded Wizard the access to resources is handled
23  * separately by platform specific provider functionality. Depending on the
24  * manner to store bitmap and font resources, the provider has the job to
25  *find, open, decompress, load, etc. the desired bitmap or font.
26  *
27  * The provider consists of two interfaces:
28  *
29  * 1. Bitmap loader. Its intention is to access and load bitmaps, images, etc.
30  * Depending on the provider implementation, the bitmaps can be loaded from
31  * the code memory or from an external storage medium.
32  *
33  * 2. Font loader. Its intention is to access and load fonts and glyphs.
34  * Depending on the provider implementation, true type fonts can be opened
35  * or pre-rasterized glyphs can be decompressed from the code memory.
36  *
37  * Usually, a loader interface will consist of a header and an implementation
38  * files, whose names are predetermined in order to allow the Graphics Engine
39  * to access them independent of the particular target system:
40  *
41  * > ewextbmp.h + ewextbmp.c -> for bitmap resource loader.
42  *
43  * > ewextfnt.h + ewextfnt.c -> for font resource loader.
44  *
45  *******************************************************************************/
46 
47 #ifndef EWGFXRES_H
48 #define EWGFXRES_H
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 /* Predeklaration of platform dependent resource structures */
55 struct XBmpRes;
56 struct XFntRes;
57 
58 /*******************************************************************************
59  * FUNCTION:
60  * EwBmpInit
61  *
62  * DESCRIPTION:
63  * The function EwBmpInit() is called during the initialization of the
64  *Graphics Engine. Its intention is to give the external loader a chance to
65  *initialize its private variables and to start the bitmap decoder functionality
66  *(if any)
67  *
68  * ARGUMENTS:
69  * aArgs - User argument passed in the EwInitGraphicsEngine().
70  *
71  * RETURN VALUE:
72  * If successful, returns != 0.
73  *
74  *******************************************************************************/
75 int EwBmpInit(void *aArgs);
76 
77 /*******************************************************************************
78  * FUNCTION:
79  * EwBmpDone
80  *
81  * DESCRIPTION:
82  * The function EwBmpDone() will be called during the shutdown of the Graphics
83  * Engine. It gives the loader a chance to deinitialize itself just before the
84  * Graphics Engine terminates.
85  *
86  * ARGUMENTS:
87  * None
88  *
89  * RETURN VALUE:
90  * None
91  *
92  *******************************************************************************/
93 void EwBmpDone(void);
94 
95 /*******************************************************************************
96  * FUNCTION:
97  * EwBmpOpen
98  *
99  * DESCRIPTION:
100  * The function EwBmpOpen() will be called by the Graphics Engine in order to
101  * initiate the access to the given bitmap resource. Depending on the manner,
102  * the resources are handled in the particular platform system, the function
103  * can open an image file or it can access bitmap information available in the
104  * code memory.
105  *
106  * The function should return a handle to the opened resource. By using this
107  * handle, the bitmap content and its metrics can be requested by the Graphics
108  * Engine without taking in account any platform specific aspects.
109  *
110  * ARGUMENTS:
111  * aResource - Descriptor of the bitmap resource to open. The content of this
112  * descriptor depends on the particular platform system.
113  *
114  * RETURN VALUE:
115  * If sucessful, the function returns the handle to the opened bitmap
116  *resource. If failed, the function returns null.
117  *
118  *******************************************************************************/
119 unsigned long EwBmpOpen(const struct XBmpRes *aResource);
120 
121 /*******************************************************************************
122  * FUNCTION:
123  * EwBmpClose
124  *
125  * DESCRIPTION:
126  * The function EwBmpClose() will be called by the Graphics Engine to finish
127  * the processing of a bitmap resource. Depending on the manner, the resources
128  * are handled in the particular platform system, the function can close the
129  * previously opened file and free any temporarily reserved resources.
130  *
131  * ARGUMENTS:
132  * aHandle - Handle to the bitmap resource to terminate the access.
133  *
134  * RETURN VALUE:
135  * None
136  *
137  *******************************************************************************/
138 void EwBmpClose(unsigned long aHandle);
139 
140 /*******************************************************************************
141  * FUNCTION:
142  * EwBmpGetMetrics
143  *
144  * DESCRIPTION:
145  * The function EwBmpGetMetrics() will be called by the Graphics Engine to get
146  * the general attributes of the bitmap resource. By using of these
147  *attributes, Graphics Engine can create and initialize video surfaces.
148  *
149  * ARGUMENTS:
150  * aHandle - Handle to the bitmap resource to determine its
151  *attributes. aFormat - Pointer to a variable, where the pixel format of
152  *the bitmap resource will returned (See EW_PIXEL_FORMAT_XXX). aNoOfFrames -
153  *Pointer to a variable, where the number of frames included within this bitmap
154  *resource will returned. aNoOfVirtFrames - Pointer to a variable, where the
155  *number of all frames incl. duplicates will be returned. This value can be
156  *greater than aNoOfFrames if some of the frames do repeat in the bitmap.
157  * aFrameWidth,
158  * aFrameHeight - Pointers to variables, where the size in pixel of a
159  *single frame will be returned. aFrameDelay - Pointer to a variable, where
160  *the delay in milliseconds for animated bitmap resources will be returned.
161  *
162  * RETURN VALUE:
163  * If sucessful, the function returns != 0.
164  *
165  *******************************************************************************/
166 int EwBmpGetMetrics(unsigned long aHandle, int *aFormat, int *aNoOfFrames,
167  int *aNoOfVirtFrames, int *aFrameWidth, int *aFrameHeight,
168  int *aFrameDelay);
169 
170 /*******************************************************************************
171  * FUNCTION:
172  * EwBmpGetFrameMetrics
173  *
174  * DESCRIPTION:
175  * The function EwBmpGetFrameMetrics() will be called by the Graphics Engine
176  *in order to obtain attributes for a single bitmap resource frame.
177  *
178  * ARGUMENTS:
179  * aHandle - Handle to the bitmap resource to determine its attributes.
180  * aFrameNo - Number of the desired frame to get its attributes.
181  * aOpqX, aOpqY,
182  * aOpqWidth,
183  * aOpqHeight - Pointers to variables, where an optional full-opaque area of
184  * the frame will be returned. By using this area, drawing operation can be
185  * optimized. The returned origin lies relative to the top-left corner of
186  *the frame.
187  *
188  * RETURN VALUE:
189  * If sucessful, the function returns != 0.
190  *
191  *******************************************************************************/
192 int EwBmpGetFrameMetrics(unsigned long aHandle, int aFrameNo, int *aOpqX,
193  int *aOpqY, int *aOpqWidth, int *aOpqHeight);
194 
195 /*******************************************************************************
196  * FUNCTION:
197  * EwBmpGetFrameMemory
198  *
199  * DESCRIPTION:
200  * The function EwBmpGetFrameMemory() will be called by the Graphics Engine in
201  * order to verify whether it is possible to directly access the frame pixel
202  * data of the bitmap resource represented by aHandle and in the positive case
203  * to obtain the affected memory address pointers.
204  *
205  * This function belongs to the interface separating the Graphics Engine from
206  * the platform specific bitmap resource loader functionality. In the case the
207  * target system stores the bitmap resources already in a usable format, the
208  * function allows the Graphics Engine to use it directly without to need any
209  * additional surface memory to be allocated and pixel contents to be copied.
210  *
211  * This approach will not work when the bitmap resources are stored compressed
212  * or loaded dynamically from e.g. file system. To work it is essential, that
213  * the delivered pixel memory address is persistently valid (e.g. resides in
214  * ROM code) and the pixel in the memory are stored in the format used by the
215  * surfaces in the target system.
216  *
217  * The function should return 0 if the direct access is not supported.
218  *
219  * ARGUMENTS:
220  * aHandle - Handle to the bitmap resource to obtain direct pixel memory
221  * access.
222  * aFrameNo - Number of the desired frame to get its pixel data.
223  * aMemory - Structure to receive the desired address information.
224  *
225  * RETURN VALUE:
226  * If successful, the function fills the given aMemory structure with the
227  * address information and returns != 0. Otherwise 0 is returned.
228  *
229  *******************************************************************************/
230 int EwBmpGetFrameMemory(unsigned long aHandle, int aFrameNo,
231  XSurfaceMemory *aMemory);
232 
233 /*******************************************************************************
234  * FUNCTION:
235  * EwBmpLoadFrame
236  *
237  * DESCRIPTION:
238  * The function EwBmpLoadFrame() will be called by the Graphics Engine in
239  *order to load the frame pixel data from the openend bitmap resource aHandle
240  *into the given memory area aMemory. Depending on the manner, the resources are
241  * handled in the particular platform, the pixel data may be loaded from a
242  *file or they can be decompressed from the code memory.
243  *
244  * ARGUMENTS:
245  * aHandle - Handle to the bitmap resource to load the pixel data.
246  * aFrameNo - Number of the desired frame to get its pixel data.
247  * aMemory - Memory descriptor containing pointers and pitch information of
248  * the destination to write the pixel data.
249  *
250  * RETURN VALUE:
251  * If sucessful, the function returns != 0.
252  *
253  *******************************************************************************/
254 int EwBmpLoadFrame(unsigned long aHandle, int aFrameNo,
255  XSurfaceMemory *aMemory);
256 
257 /*******************************************************************************
258  * FUNCTION:
259  * EwBmpLoadClut
260  *
261  * DESCRIPTION:
262  * The function EwBmpLoadClut() will be called by the Graphics Engine in order
263  * to load the Clut data from the openend bitmap resource aHandle into the
264  * given memory area aMemory.
265  *
266  * ARGUMENTS:
267  * aHandle - Handle to the bitmap resource to load the CLUT data.
268  * aMemory - Memory descriptor containing pointers to the CLUT where to copy
269  * the CLUT data.
270  *
271  * RETURN VALUE:
272  * If sucessful, the function returns != 0.
273  *
274  *******************************************************************************/
275 int EwBmpLoadClut(unsigned long aHandle, XSurfaceMemory *aMemory);
276 
277 /*******************************************************************************
278  * FUNCTION:
279  * EwBmpLoadMappingTable
280  *
281  * DESCRIPTION:
282  * The function EwBmpLoadMappingTable() will be called by the Graphics Engine
283  * in order to load a table used to map between virtual and real frame
284  *numbers. If a bitmap contains repetitions of a frame, the corresponding frames
285  *are stored only once (as real frame). The numbers of original frames need to
286  *be mapped to the numbers of the real (existing) frames.
287  *
288  * ARGUMENTS:
289  * aHandle - Handle to the bitmap resource to load the table.
290  * aMapping - Pointer to memory where to copy the table. The memory area has
291  * to be large enough.
292  *
293  * RETURN VALUE:
294  * If sucessful, the function returns the number of virtual frames (the number
295  * of copied entries).
296  *
297  *******************************************************************************/
298 int EwBmpLoadMappingTable(unsigned long aHandle, unsigned short *aMapping);
299 
300 /*******************************************************************************
301  * FUNCTION:
302  * EwFntInit
303  *
304  * DESCRIPTION:
305  * The function EwFntInit() is called during the initialization of the
306  *Graphics Engine. Its intention is to give the external loader a chance to
307  *initialize its private variables and to start the TrueType font engine
308  *functionality (if any).
309  *
310  * ARGUMENTS:
311  * aArgs - User argument passed in the EwInitGraphicsEngine().
312  *
313  * RETURN VALUE:
314  * If successful, returns != 0.
315  *
316  *******************************************************************************/
317 int EwFntInit(void *aArgs);
318 
319 /*******************************************************************************
320  * FUNCTION:
321  * EwFntDone
322  *
323  * DESCRIPTION:
324  * The function EwFntDone() will be called during the shutdown of the Graphics
325  * Engine. It gives the loader a chance to deinitialize itself just before the
326  * Graphics Engine terminates.
327  *
328  * ARGUMENTS:
329  * None
330  *
331  * RETURN VALUE:
332  * None
333  *
334  *******************************************************************************/
335 void EwFntDone(void);
336 
337 /*******************************************************************************
338  * FUNCTION:
339  * EwFntOpen
340  *
341  * DESCRIPTION:
342  * The function EwFntOpen() will be called by the Graphics Engine in order to
343  * initiate the access to the given font resource. Depending on the manner,
344  * the resources are handled in the particular platform system, the function
345  * can open a TrueType file or it can access font information available in the
346  * code memory.
347  *
348  * The function should return a handle to the opened resource. By using this
349  * handle, the font content and its metrics can be requested by the Graphics
350  * Engine without taking in account any platform specific aspects.
351  *
352  * ARGUMENTS:
353  * aResource - Descriptor of the font resource to open. The content of this
354  * descriptor depends on the particular platform system.
355  *
356  * RETURN VALUE:
357  * If sucessful, the function returns the handle to the opened font resource.
358  * If failed, the function returns null.
359  *
360  *******************************************************************************/
361 unsigned long EwFntOpen(const struct XFntRes *aResource);
362 
363 /*******************************************************************************
364  * FUNCTION:
365  * EwFntClose
366  *
367  * DESCRIPTION:
368  * The function EwFntClose() will be called by the Graphics Engine to finish
369  * the processing of a font resource. Depending on the manner, the resources
370  * are handled in the particular platform system, the function can close the
371  * previously opened file and free any temporarily reserved resources.
372  *
373  * ARGUMENTS:
374  * aHandle - Handle to the font resource to terminate the access.
375  *
376  * RETURN VALUE:
377  * None
378  *
379  *******************************************************************************/
380 void EwFntClose(unsigned long aHandle);
381 
382 /*******************************************************************************
383  * FUNCTION:
384  * EwFntGetResourceName
385  *
386  * DESCRIPTION:
387  * The function EwFntGetResourceName() will be called by the Graphics Engine
388  *in order to query the name of the corresponding font resource member. This
389  *name is used to display error messages and warnings.
390  *
391  * The function should return a pointer to a zero terminated char string.
392  *
393  * ARGUMENTS:
394  * aResource - Descriptor of the font resource to query its name.
395  *
396  * RETURN VALUE:
397  * If sucessful, the function returns the pointer to the char string.
398  *
399  *******************************************************************************/
400 const char *EwFntGetResourceName(const struct XFntRes *aResource);
401 
402 /*******************************************************************************
403  * FUNCTION:
404  * EwFntGetMetrics
405  *
406  * DESCRIPTION:
407  * The function EwFntGetMetrics() will be called by the Graphics Engine to get
408  * the general attributes of the font resource. By using of these attributes,
409  * Graphics Engine can create and initialize new font instances.
410  *
411  * ARGUMENTS:
412  * aHandle - Handle to the font resource to determine its attributes.
413  * aAscent,
414  * aDescent,
415  * aLeading - Pointers to variables, where the font metrics will be returned.
416  * aDefChar - Pointers to variable, where the default character code will be
417  * returned.
418  *
419  * RETURN VALUE:
420  * If sucessful, the function returns != 0.
421  *
422  *******************************************************************************/
423 int EwFntGetMetrics(unsigned long aHandle, int *aAscent, int *aDescent,
424  int *aLeading, XChar *aDefChar);
425 
426 /*******************************************************************************
427  * FUNCTION:
428  * EwFntGetGlyphMetrics
429  *
430  * DESCRIPTION:
431  * The function EwFntGetGlyphMetrics() will be called by the Graphics Engine
432  *in order to obtain the metrics of a single glyph from the given font.
433  *
434  * ARGUMENTS:
435  * aHandle - Handle to the font resource to determine its attributes.
436  * aCharCode - Character code of the glyph to be inspected.
437  * aOriginX,
438  * aOriginY - Pointers to variables, where the origin offset in pixel of the
439  * desired glyph will be returned.
440  * aWidth,
441  * aHeight - Pointers to variables, where the size in pixel of the glyph
442  *will be returned. aAdvance - Pointer to a variable, where the horizontal
443  *advance in pixel for the glyph will be returned.
444  *
445  * RETURN VALUE:
446  * If sucessful, the function returns != 0.
447  *
448  *******************************************************************************/
449 int EwFntGetGlyphMetrics(unsigned long aHandle, unsigned short aCharCode,
450  int *aOriginX, int *aOriginY, int *aWidth,
451  int *aHeight, int *aAdvance);
452 
453 /*******************************************************************************
454  * FUNCTION:
455  * EwFntGetKerning
456  *
457  * DESCRIPTION:
458  * The function EwFntGetKerning() will be called by the Graphics Engine in
459  * order to obtain the kerning value for the pair of two glyphs from the given
460  * font.
461  *
462  * ARGUMENTS:
463  * aHandle - Handle to the font resource to determine the kerning.
464  * aCharCode1 - Character code of the first glyph.
465  * aCharCode2 - Character code of the second glyph.
466  *
467  * RETURN VALUE:
468  * The function returns the kerning value for the given pair of glyphs or 0
469  * if the glyphs are not affected by kerning or at least one of the glyphs is
470  * not existing in the font.
471  *
472  *******************************************************************************/
473 int EwFntGetKerning(unsigned long aHandle, unsigned short aCharCode1,
474  unsigned short aCharCode2);
475 
476 /*******************************************************************************
477  * FUNCTION:
478  * EwFntIsGlyphAvailable
479  *
480  * DESCRIPTION:
481  * The function EwFntIsGlyphAvailable() will be called by the Graphics Engine
482  * in order to verify whether the given font contains a glyph for the
483  *character aCharCode.
484  *
485  * ARGUMENTS:
486  * aHandle - Handle to the font resource to determine the glyph existence.
487  * aCharCode - Character code of the glyph.
488  *
489  * RETURN VALUE:
490  * The function returns != 0 if the glyph exists. Otherwise 0 is returned.
491  *
492  *******************************************************************************/
493 int EwFntIsGlyphAvailable(unsigned long aHandle, unsigned short aCharCode);
494 
495 /*******************************************************************************
496  * FUNCTION:
497  * EwFntLoadGlyph
498  *
499  * DESCRIPTION:
500  * The function EwFntLoadGlyph() will be called by the Graphics Engine in
501  *order to load the glyph pixel data from the openend font resource aHandle into
502  *the given memory area aMemory. Depending on the manner, a resource is handled
503  *in the particular platform, the pixel data may be loaded from a TrueType file
504  * or they can be decompressed from the code memory.
505  *
506  * ARGUMENTS:
507  * aHandle - Handle to the font resource to load its glyph pixel data.
508  * aCharCode - Character code of the glyph to be loaded.
509  * aMemory - Memory descriptor containing pointers and pitch information of
510  * the destination to write the glyph pixel data.
511  *
512  * RETURN VALUE:
513  * If sucessful, the function returns != 0.
514  *
515  *******************************************************************************/
516 int EwFntLoadGlyph(unsigned long aHandle, unsigned short aCharCode,
517  XSurfaceMemory *aMemory);
518 
519 #ifdef __cplusplus
520 }
521 #endif
522 
523 #endif /* EWGFXRES_H */
524 
525 /* msy, pba */
XSurfaceMemory
Definition: ewgfxdriver.h:186
EwFntClose
void EwFntClose(unsigned long aHandle)
EwBmpGetFrameMemory
int EwBmpGetFrameMemory(unsigned long aHandle, int aFrameNo, XSurfaceMemory *aMemory)
EwFntDone
void EwFntDone(void)
EwBmpGetMetrics
int EwBmpGetMetrics(unsigned long aHandle, int *aFormat, int *aNoOfFrames, int *aNoOfVirtFrames, int *aFrameWidth, int *aFrameHeight, int *aFrameDelay)
EwFntGetResourceName
const char * EwFntGetResourceName(const struct XFntRes *aResource)
EwBmpOpen
unsigned long EwBmpOpen(const struct XBmpRes *aResource)
EwBmpLoadFrame
int EwBmpLoadFrame(unsigned long aHandle, int aFrameNo, XSurfaceMemory *aMemory)
XBmpRes
Definition: ewextbmp.h:133
XChar
unsigned short XChar
Definition: ewrte.h:1596
EwFntLoadGlyph
int EwFntLoadGlyph(unsigned long aHandle, unsigned short aCharCode, XSurfaceMemory *aMemory)
EwFntGetMetrics
int EwFntGetMetrics(unsigned long aHandle, int *aAscent, int *aDescent, int *aLeading, XChar *aDefChar)
EwBmpGetFrameMetrics
int EwBmpGetFrameMetrics(unsigned long aHandle, int aFrameNo, int *aOpqX, int *aOpqY, int *aOpqWidth, int *aOpqHeight)
EwFntInit
int EwFntInit(void *aArgs)
EwBmpClose
void EwBmpClose(unsigned long aHandle)
EwFntIsGlyphAvailable
int EwFntIsGlyphAvailable(unsigned long aHandle, unsigned short aCharCode)
EwFntOpen
unsigned long EwFntOpen(const struct XFntRes *aResource)
XFntRes
Definition: ewextfnt.h:126
EwBmpDone
void EwBmpDone(void)
EwFntGetKerning
int EwFntGetKerning(unsigned long aHandle, unsigned short aCharCode1, unsigned short aCharCode2)
EwBmpInit
int EwBmpInit(void *aArgs)
EwFntGetGlyphMetrics
int EwFntGetGlyphMetrics(unsigned long aHandle, unsigned short aCharCode, int *aOriginX, int *aOriginY, int *aWidth, int *aHeight, int *aAdvance)
EwBmpLoadMappingTable
int EwBmpLoadMappingTable(unsigned long aHandle, unsigned short *aMapping)
EwBmpLoadClut
int EwBmpLoadClut(unsigned long aHandle, XSurfaceMemory *aMemory)