source: svn/newcon3bcm2_21bu/nexus/app/bgfx.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 32.5 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/** include files **/
20#include "bgfx.h"
21
22#define ZORDER_TUNNEL   3
23#define ZORDER_FX       2
24#define ZORDER_TOP      1
25#define ZORDER_BOTTOM   0
26
27
28#define SURF_WIDTH 720
29
30#define BGFX_MIN(x,y)   ((x < y) ? x : y)
31#define bgfx_clut8_to_rgb(clut,c) (uint32_t)(clut[c])   
32
33
34
35/* blit row a1 to clut 8 destination */
36static inline void bgfx_render_a1_to_clut4( uint8_t *src, uint8_t *dst, 
37                                                                                        int width, uint8_t c, int odd_pixel )
38{
39        int i;
40
41        BGFX_TRACE(("%p,%p,%d,0x%02x\n",src,dst,width,c));
42        for (i = 0; i < width; i++)
43        {
44                if (src[i>>3] & (1<<(7-(i%8))))
45                {
46                        if (odd_pixel & 1)
47                        {
48                                *dst &= 0xF0;
49                                *dst |= (c & 0xF);
50                        }
51                        else
52                        {
53                                *dst &= 0xF;
54                                *dst |= (c & 0xF) << 4;
55                        }
56                        BGFX_TRACE(("%d,",i));
57                }
58                if (odd_pixel)
59                {
60                        odd_pixel = 0;
61                        dst++;
62                }
63                else
64                        odd_pixel = 1;
65
66        }
67        BGFX_TRACE(("\n"));
68}
69
70/* blit row a8 to clut 8 destination */
71static inline void bgfx_render_a8_to_clut4( uint8_t *src, uint8_t *dst, int width, uint8_t c )
72{
73        int i;
74        for (i = 0; i < width; i++)
75        {
76                if (*src > 0x80)
77                {
78                        if (i & 1)
79                        {
80                                *dst &= 0xF0;
81                                *dst |= (c & 0xF);
82                        }
83                        else
84                        {
85                                *dst &= 0xF;
86                                *dst |= (c & 0xF) << 4;
87                        }
88                }
89                BGFX_TRACE(("0x%02x(0x%02x)",*src,*dst));
90                if (i & 1)
91                        dst++;
92                src++;
93        }
94        BGFX_TRACE(("\n"));
95}
96
97
98/* blit row a1 to clut 8 destination */
99static inline void bgfx_render_a1_to_clut8( uint8_t *src, uint8_t *dst, int width, uint8_t c )
100{
101        int i;
102
103        BGFX_TRACE(("%p,%p,%d,0x%02x\n",src,dst,width,c));
104        for (i = 0; i < width; i++)
105        {
106                if (src[i>>3] & (1<<(7-(i%8))))
107                {
108                        *dst = c;
109                        BGFX_TRACE(("%d,",i));
110                }
111                dst++;
112        }
113        BGFX_TRACE(("\n"));
114}
115/* blit row a8 to clut 8 destination */
116static inline void bgfx_render_a8_to_clut8( uint8_t *src, uint8_t *dst, int width, uint8_t c )
117{
118        int i;
119        for (i = 0; i < width; i++)
120        {
121                if (*src > 0x80)
122                {
123                        *dst = c;
124                }
125                BGFX_TRACE(("0x%02x(0x%02x)",*src,*dst));
126                dst++;
127                src++;
128        }
129        BGFX_TRACE(("\n"));
130}
131
132/* blit row a1 to 8888 ARGB destination */
133static inline void bgfx_render_a1_to_rgb( uint8_t *src, uint8_t *dst, int width, uint32_t c )
134{
135        int i;
136
137        BGFX_TRACE(("%p,%p,%d,0x%02lx\n",src,dst,width,c));
138        for (i = 0; i < width; i++)
139        {
140                if (src[i>>3] & (1<<(7-(i%8))))
141                {
142                        *((uint32_t*)dst) = c;
143                        BGFX_TRACE(("%d,",i));
144                }
145                dst += 4;
146        }
147        BGFX_TRACE(("\n"));
148}
149/* blit row a8 to 8888 ARGB destination */
150/*
151        #define BGFX_BLEND(a,rs,rd)     (((rs * a)/0xFF) + (rd - ((a * rd)/0xFF)) & 0xFF)
152*/
153#define BGFX_BLEND(a,rs,rd)     ((a * (rs-rd) >> 8) + rd)
154static inline void bgfx_render_a8_to_rgb( uint8_t *src, uint8_t *dst, int width, uint32_t c)
155{
156        register int i;
157        register uint32_t a,r,g,b;
158        register uint32_t a_src;
159        register uint32_t r_src =  (c >> 16) & 0xFF;
160        register uint32_t g_src =  (c >> 8) & 0xFF;
161        register uint32_t b_src =  (c >> 0) & 0xFF;
162        for (i = 0; i < width; i++)
163        {
164                a_src = *src;
165                a = dst[3]; r =  dst[2]; g =  dst[1]; b =  dst[0];
166                *((uint32_t*)dst) = (a << 24) |
167                                                        (BGFX_BLEND(a_src,r_src,r) << 16) |
168                                                        (BGFX_BLEND(a_src,g_src,g) << 8) |
169                                                        BGFX_BLEND(a_src,b_src,b);
170                BGFX_TRACE(("0x%02x(0x%08x)",*src,*((uint32_t*)dst)));
171                dst += 4;
172                src++;
173        }
174        BGFX_TRACE(("\n"));
175}
176
177/****************************************************************}
178* INPUTS:       io and protection function structures
179* OUTPUTS:      none
180* RETURNS:      non-zero on failure
181* FUNCTION: initialize sgl, primarily for handling freetype
182*
183****************************************************************/
184int bgfx_init(bgfx_io_t *io_p,bgfx_prot_t *prot_p)
185{
186        bgfx_config(io_p,prot_p);
187        return bgfx_font_init();
188}
189/****************************************************************}
190* INPUTS:       none
191* OUTPUTS:      none
192* RETURNS:      non-zero on failure
193* FUNCTION: release sgl global resources, primarily for handling freetype
194*
195****************************************************************/
196void bgfx_done(void)
197{
198        bgfx_font_done();
199}
200
201/****************************************************************}
202* bgfx_create
203*
204* INPUTS:       node_name - name of the node to create surface in
205*           p - surface structure to initialize
206* OUTPUTS:      none
207* RETURNS:      non-zero on failure
208* FUNCTION: initialize and create the surface.
209*
210****************************************************************/
211int bgfx_create(bgfx_surf_p p,uint16_t width,uint16_t height,
212                           uint8_t      *ptr, uint16_t pitch,
213                           bgfx_palette_t *palette,
214                           uint32_t flags)
215{
216        BGFX_DEBUG(("bgfx_create flags = 0x%08x\n",flags));
217        BGFX_MEMSET(p,0,sizeof(bgfx_surf_t));
218
219        if (!ptr && (flags & BGFX_SURF_PRIMARY))
220        {
221                BGFX_DEBUG(("bgfx_create BGFX_SURF_FULLSCREEN requires valid memory ptr.\n"));
222        }
223
224        p->bpp = BGFX_SURF_GET_BPP(flags);
225
226        BGFX_DEBUG(("bgfx_create bpp = %d.\n",p->bpp));
227
228        if ((p->bpp == 0) || ((flags & BGFX_SURF_RGB) && (p->bpp != 32)))
229        {
230                BGFX_DEBUG(("bgfx_create invalid bpp = %d.\n",p->bpp));
231                return -1;
232        }
233
234        p->flags = flags;
235        if (ptr)
236        {
237                p->surface.pitch = pitch;
238                p->surface.buf = ptr;
239                p->surface.width = width;
240                p->surface.height = height;
241        }
242        else
243        {
244
245                p->surface.pitch = width * p->bpp / 8;
246                if (p->surface.pitch & 0x1)
247                        p->surface.pitch += 1;
248
249                p->surface.width = width;
250                p->surface.height = height;
251                p->surface.buf = BGFX_MALLOC(p->surface.pitch * p->surface.height);
252                p->flags |= BGFX_SURF_ALLOC;
253        }
254
255        if (palette)
256        {
257                BGFX_MEMCPY(&p->palette,palette,sizeof(bgfx_palette_t));
258        }
259        return 0;
260}
261/****************************************************************
262* bgfx_destroy
263*
264* INPUTS:       p - surface structure
265* OUTPUTS:      none
266* RETURNS:      none
267* FUNCTION:     free up surface resources
268*
269****************************************************************/
270void bgfx_destroy(bgfx_surf_p p)
271{
272        if (p->flags & BGFX_SURF_ALLOC)
273        {
274                BGFX_FREE(p->surface.buf);
275                return;
276        }
277}
278/****************************************************************
279* bgfx_fill_rect
280*
281* INPUTS:       p - surface structure
282* OUTPUTS:      w,h,flags - surface width,height and flags
283* RETURNS:      none
284* FUNCTION:     Return surface information (width,height, and flags)
285*
286****************************************************************/
287void bgfx_get_info(bgfx_surf_p p,uint16_t *w,uint16_t *h,uint16_t *pitch, uint32_t *flags)
288{
289        *w = p->surface.width;
290        *h = p->surface.height;
291        *pitch = p->surface.pitch;
292        *flags = p->flags;
293}
294/****************************************************************
295* bgfx_get_palette
296*
297* INPUTS:       p - surface structure
298* OUTPUTS:      palette_p - return current palette
299* RETURNS:      none
300* FUNCTION:     get the current palett
301*
302****************************************************************/
303void bgfx_get_palette(bgfx_surf_p p,bgfx_palette_t *palette_p)
304{
305        BGFX_MEMCPY(palette_p,&p->palette,sizeof(bgfx_palette_t));
306}
307/****************************************************************
308* bgfx_set_palette
309*
310* INPUTS:       p - surface structure
311*                       palette_p - the palette
312* OUTPUTS:      none
313* RETURNS:      none
314* FUNCTION:     set the global system palette
315*
316****************************************************************/
317void bgfx_set_palette(bgfx_surf_p p, bgfx_palette_t *palette_p)
318{
319        BGFX_MEMCPY(&p->palette,palette_p,sizeof(bgfx_palette_t));
320}
321
322/****************************************************************
323* bgfx_set_pixel
324*
325* INPUTS:       p - surface structure
326*                       x,y - coordinates
327*                       c - pixel value
328* OUTPUTS:      none
329* RETURNS:      none
330* FUNCTION:     set the pixel at x,y
331*
332****************************************************************/
333void bgfx_set_pixel(bgfx_surf_p p,uint16_t x,uint16_t y,bgfx_pixel c)
334{
335        uint8_t *dst;
336
337        if ((x >= p->surface.width) || (y >= p->surface.height))
338        {
339                BGFX_DEBUG(("bgfx_set_pixel param error (%p,%d,%d)\n",p,x,y));
340                return;
341        }
342
343        dst = (uint8_t*)p->surface.buf;
344        dst += y * p->surface.pitch + (x * p->bpp)/8;
345        if (p->flags & BGFX_SURF_RGB)
346        {
347                *((uint32_t*)dst) = c;
348                bgfx_cacheflush(dst,4);
349        }
350        else if (p->bpp == 8)
351        {
352                *dst = (uint8_t)c;
353                bgfx_cacheflush(dst,1);
354        }
355        else
356        {
357                if (x & 1)
358                {
359                        *dst &= 0xF0;
360                        *dst |= (uint8_t)(c & 0xF);
361                }
362                else
363                {
364                        *dst &= 0xF;
365                        *dst |= (uint8_t)((c & 0xF) << 4);
366                }
367                bgfx_cacheflush(dst,1);
368        }
369}
370/****************************************************************
371* bgfx_get_pixel
372*
373* INPUTS:       p - surface structure
374*                       x,y - coordinates
375*                       c - pixel value
376* OUTPUTS:      none
377* RETURNS:      none
378* FUNCTION:     get the pixel value at x,y.  The bgfx_color will be the
379*                       actual pixel value.
380*
381* NOTE:  Not supported for RGB surfaces.  To get a pixel for RGB access buf
382* directly.
383*
384****************************************************************/
385bgfx_pixel bgfx_get_pixel(bgfx_surf_p p,uint16_t x,uint16_t y)
386{
387        uint8_t *dst;
388        if ((x >= p->surface.width) || (y >= p->surface.height))
389        {
390                BGFX_DEBUG(("bgfx_get_pixel param error (%p,%d,%d)\n",p,x,y));
391                return 0;
392        }
393        dst = (uint8_t*)p->surface.buf;
394        dst += y * p->surface.pitch + (x * p->bpp)/8;
395        if (p->flags & BGFX_SURF_RGB)
396        {
397                return *((uint32_t*)dst);
398        }
399        else if (p->bpp == 8)
400        {
401                return *dst;
402        }
403       
404        /* p->bpp == 4 */
405        if (x & 1)
406        {
407                return (*dst  & 0xF0);
408        }
409
410        return (*dst >> 4);
411}
412/****************************************************************
413* bgfx_h_draw_line
414*
415* INPUTS:       p - surface structure
416*                       x1,x2,y - coordinates
417*                       c - pixel value
418* OUTPUTS:      none
419* RETURNS:      none
420* FUNCTION:     Draw a horizontal line make of pixels defined by the value c.
421*
422*  JPF - these need to be optimized
423*
424****************************************************************/
425void bgfx_h_draw_line(bgfx_surf_p p,uint16_t x1,uint16_t x2,uint16_t y,
426                                         bgfx_pixel c)
427{
428        int w = x2 - x1;
429
430        if (w < 0)
431        {
432                w = -w;
433                bgfx_fill_rect(p,x2,y,(uint16_t)w,1, c);
434        }
435        else
436        {
437                bgfx_fill_rect(p,x1,y,(uint16_t)w,1, c);
438        }
439}
440/****************************************************************
441* bgfx_v_draw_line
442*
443* INPUTS:       p - surface structure
444*                       x,y1,y2 - coordinates
445*                       c - pixel value
446* OUTPUTS:      none
447* RETURNS:      none
448* FUNCTION:     Draw a vertical line make of pixels defined by the value c.
449*
450*   JPF - these need to be optimized
451*
452****************************************************************/
453void bgfx_v_draw_line(bgfx_surf_p p,uint16_t x,uint16_t y1,uint16_t y2,
454                                         bgfx_pixel c)
455{
456        uint8_t *dst;
457        uint16_t h = y2 - y1;
458        if ((y2 <= y1) || (x >= p->surface.width))
459        {
460                BGFX_DEBUG(("bgfx_v_draw_line param error (%p,%d,%d,%d,0x%02lx)\n",p,x,y1,y2,c));
461                return;
462        }
463
464        if (h > p->surface.height - y1)
465                h = p->surface.height - y1;
466        dst = (uint8_t*)p->surface.buf;
467        dst += y1 * p->surface.pitch + x * p->bpp/8;
468
469        if (p->flags & BGFX_SURF_RGB)
470        {
471                while (h--)
472                {
473                        *((uint32_t*)dst) = c;
474                        dst += p->surface.pitch;
475                }
476        }
477        else if (p->bpp == 8)
478        {
479                while (h--)
480                {
481                        *dst = (uint8_t)c;
482                        dst += p->surface.pitch;
483                }
484        }
485        else
486        {
487                while (h--)
488                {
489                        if (x & 1)
490                        {
491                                *dst &= 0xF0;
492                                *dst |= (uint8_t)(c & 0xF);
493                        }
494                        else
495                        {
496                                *dst &= 0xF;
497                                *dst |= (uint8_t)((c & 0xF) << 4);
498                        }
499                        dst += p->surface.pitch;
500                }
501        }
502        bgfx_cacheflush(p->surface.buf,p->surface.pitch * p->surface.height);
503}
504/****************************************************************
505* bgfx_fill_rect
506*
507* INPUTS:       p - surface structure
508*                       x1,x2,y1,y2 - coordinates
509*                       c - pixel value
510* OUTPUTS:      none
511* RETURNS:      none
512* FUNCTION:     Fill the rectangle with pixels defined by the value c.
513*
514*   JPF - these need to be optimized
515*
516****************************************************************/
517/* TODO create optimized version of memset */
518#if 0
519static inline void *bgfx_memset(void *dest,int c,size_t count)
520{
521        uint8_t *d = dest;
522        for(;count>0;count--) {
523                *d++ = c;
524        }
525        return dest;
526}
527#else
528#define bgfx_memset BGFX_MEMSET
529#endif
530
531void bgfx_fill_rect(bgfx_surf_p p,uint16_t x,uint16_t y,uint16_t w,uint16_t h,
532                                   bgfx_pixel c)
533{
534        uint8_t *tdst;
535        uint16_t i;
536        uint8_t *dst;
537        uint16_t j;     
538               
539        if (y + h > p->surface.height)
540                h = p->surface.height - y;
541
542        if (w + x > p->surface.width)
543                w = p->surface.width - x;
544
545        dst = (uint8_t*)p->surface.buf;
546        dst += y * p->surface.pitch + x * p->bpp/8;
547
548        if (p->flags & BGFX_SURF_RGB)
549        {
550                for (j = 0; j < h; ++j)
551                {
552                        tdst = dst;
553                        for (i = 0; i < w; ++i)
554                        {
555                                *((uint32_t*)tdst) = c;
556                                tdst += p->bpp/8;
557                        }
558                        dst += p->surface.pitch;
559                }
560        }
561        else if (p->bpp == 8)
562        {
563                for (j = 0; j < h; ++j)
564                {
565                        bgfx_memset(dst,(uint8_t)c,w);
566                        dst += p->surface.pitch;
567                }
568        }
569        else
570        {
571                unsigned char two_pixel = (uint8_t)((c << 4) | c);
572                for (j = 0; j < h; ++j)
573                {
574                        unsigned int num_bytes = (w * p->bpp)/8;
575                        if (x & 1)
576                        {
577                                *dst &= 0xF0;
578                                *dst |= (uint8_t)(c & 0xF);
579                                if (w & 1)
580                                {
581                                        bgfx_memset(&dst[1],two_pixel,num_bytes);
582                                }
583                                else
584                                {
585                                        bgfx_memset(&dst[1],two_pixel,num_bytes - 1);
586                                        dst[num_bytes] &= 0x0F;
587                                        dst[num_bytes] |= (uint8_t)((c & 0xF) << 4);
588                                }
589                        }
590                        else
591                        {
592                                if (w & 1)
593                                {
594                                        bgfx_memset(dst,two_pixel,num_bytes);
595                                        dst[num_bytes] &= 0x0F;
596                                        dst[num_bytes] |= (uint8_t)((c & 0xF) << 4);
597                                }
598                                else
599                                        bgfx_memset(dst,two_pixel,num_bytes);
600                        }
601                        dst += p->surface.pitch;
602                }
603        }
604        bgfx_cacheflush(p->surface.buf,p->surface.pitch * p->surface.height);
605}
606/****************************************************************
607* bgfx_render_glyph
608*
609* INPUTS:       p - surface structure
610*                       x,y - coordinates
611*                       a_char - character to render
612*                       font_p - font definition
613*                       c - color
614* OUTPUTS:      none
615* RETURNS:      character advance
616* FUNCTION:     Fill the rectangle with pixels defined by the value c.
617*
618****************************************************************/
619#define IT_OFFSET       3
620static inline int bgfx_render_glyph(bgfx_surf_p p,uint16_t x,uint16_t y,
621                                         const unsigned long a_char, bgfx_font_t *font_p,bgfx_pixel c,
622                                          bgfx_glyph_t * p_bgfx_glyph,bgfx_text_style style)
623{
624        int max_width,ybase;
625        uint16_t row;
626        uint8_t *src,*dst;
627        bgfx_glyph_t * bgfx_glyph = p_bgfx_glyph;
628        unsigned char   glyph_width;            /* width of the rendered character bitmap in pixels */
629        unsigned char   glyph_height;           /* height of the rendered character bitmap in pixels */
630
631        ybase = y;
632        if (x > p->surface.width)
633        {
634                BGFX_TRACE(("bgfx_render_glyph x > width (%d,%d)\n",x,p->surface.width));
635                return 0;
636        }
637
638        /* if using glyph cache use the get glyph rather than render directly to surface buffer */
639        if (!bgfx_glyph && (font_p->cache_size > 0))
640        {
641                bgfx_glyph = bgfx_get_glyph(font_p,a_char);
642        }
643
644        if (!bgfx_glyph)
645        {
646                BGFX_DEBUG(("bgfx_render_glyph could not load glyph 0x%08lx\n",a_char));
647                return 0;
648        }
649        BGFX_TRACE(("bgfx_render_glyph glyph (%p,%d,%d)\n",bgfx_glyph->buf,bgfx_glyph->height,bgfx_glyph->width));
650
651        glyph_width = bgfx_glyph->width;
652        glyph_height = bgfx_glyph->height;
653
654        if (bgfx_glyph->left + x > 0)
655                x += bgfx_glyph->left;
656        if (y-bgfx_glyph->top > 0)
657                y -= bgfx_glyph->top;
658        else
659                y = 0;
660
661        if (glyph_height + y > p->surface.height)
662                glyph_height = p->surface.height - y;
663        if (glyph_width + x > p->surface.width)
664                glyph_width = p->surface.width - x;
665
666        src = (uint8_t*)bgfx_glyph->buf;
667        dst = (uint8_t*)p->surface.buf;
668
669        BGFX_TRACE(("bgfx_render_glyph suface (%p(y = %d,x = %d,pitch = %d,bpp = %d)\n",dst,y,x,p->surface.pitch, p->bpp));
670       
671        dst += y * p->surface.pitch + x * p->bpp/8;
672        if (style & eBGFX_ITALIC)
673                max_width = BGFX_MIN(glyph_width + IT_OFFSET, p->surface.width - x);
674        else
675                max_width = BGFX_MIN(glyph_width, p->surface.width - x);
676       
677        if (max_width <= 0)
678        {
679                if (glyph_width != 0)
680                {
681                        BGFX_TRACE(("bgfx_render_glyph glyph_width = %d\n", glyph_width));
682                }
683                return bgfx_glyph->advance;
684        }
685
686        /* Render mono glyph */
687        if (font_p->format & BGFX_MONO)
688        {
689                BGFX_TRACE(("bgfx_render_glyph Alpha 1 font\n"));
690
691                if (p->flags & BGFX_SURF_RGB)
692                {
693                        for (row = 0; row < glyph_height; row++)
694                        {
695                                bgfx_render_a1_to_rgb( src, dst, max_width,c );
696
697                                src += bgfx_glyph->pitch;
698                                dst += p->surface.pitch;
699                        }
700                }
701                else if (p->bpp == 8)
702                {
703                        for (row = 0; row < glyph_height; row++)
704                        {
705                                bgfx_render_a1_to_clut8( src, dst, max_width,c );
706
707                                src += bgfx_glyph->pitch;
708                                dst += p->surface.pitch;
709                        }
710                }
711                else
712                {
713                        uint16_t adjx = x;
714                        for (row = 0; row < glyph_height; row++)
715                        {
716                                if (style & eBGFX_ITALIC)
717                                {
718                                        adjx = x + IT_OFFSET - ((row * IT_OFFSET)/glyph_height);
719                                        dst = (uint8_t*)p->surface.buf;
720                                        dst += (y + row) * p->surface.pitch + adjx * p->bpp/8;
721                                }
722                                bgfx_render_a1_to_clut4( src, dst, max_width,c, adjx & 0x1 );
723
724                                src += bgfx_glyph->pitch;
725                                dst += p->surface.pitch;
726                        }
727                }
728        }
729        else /* Render 8 bit grayscale glyph */
730        {
731                BGFX_TRACE(("bgfx_render_glyph Alpha 8 font\n"));
732                if (p->flags & BGFX_SURF_RGB)
733                {
734                        for (row = 0; row < glyph_height; row++)
735                        {
736                                bgfx_render_a8_to_rgb( src, dst, glyph_width,c);
737
738                                src += bgfx_glyph->pitch;
739                                dst += p->surface.pitch;
740                        }
741                }
742                else if (p->bpp == 8)
743                {
744                        for (row = 0; row < glyph_height; row++)
745                        {
746                                bgfx_render_a8_to_clut8( src, dst, glyph_width,c );
747
748                                src += bgfx_glyph->pitch;
749                                dst += p->surface.pitch;
750                        }
751                }
752                else
753                {
754                        for (row = 0; row < glyph_height; row++)
755                        {
756                                bgfx_render_a8_to_clut4( src, dst, glyph_width,c );
757
758                                src += bgfx_glyph->pitch;
759                                dst += p->surface.pitch;
760                        }
761                }
762        }
763        if (style & eBGFX_UNDERLINE)
764                bgfx_h_draw_line(p,x,x + bgfx_glyph->advance,ybase,c);
765        return bgfx_glyph->advance;
766}
767
768/****************************************************************
769* bgfx_draw_text
770*
771* INPUTS:       p - surface structure
772*                       x,y - coordinates
773*                       str_p - array of 32-bit unicode characters
774                        str_len - number of 32-bit characters in array
775*                       font_p - font definition
776*                       c - color
777* OUTPUTS:      none
778* RETURNS:      none
779* FUNCTION:     Fill the rectangle with pixels defined by the value c.
780*
781****************************************************************/
782void bgfx_draw_text(bgfx_surf_p p,uint16_t x,uint16_t y,
783                                   const unsigned long *str_p, int str_len, 
784                                   bgfx_font_t *font_p,bgfx_pixel c, bgfx_text_style style)
785{
786        int offset;
787
788        BGFX_TRACE(("bgfx_draw_text %ld characters.\n",str_len));
789       
790        for (offset = 0; offset < str_len; offset++)
791        {
792                x += bgfx_render_glyph(p,x,y, str_p[offset], font_p,c,NULL,style);
793        }
794        bgfx_cacheflush(p->surface.buf,p->surface.pitch * p->surface.height);
795}
796/****************************************************************
797* bgfx_draw_text_box
798*
799* INPUTS:       p - surface structure
800*                       x,y - coordinates
801*                       width,height - width and hegith of the text box to draw
802*                       str_p - array of 32-bit unicode characters
803                        str_len - number of 32-bit characters in array
804*                       font_p - font definition
805*                       c - color
806                        line_spacing - line space
807* OUTPUTS:      none
808* RETURNS:      none
809* FUNCTION:     Fill the rectangle with pixels defined by the value c.
810*
811****************************************************************/
812#define MAX_TEXT_BOX_CHARS      512
813#define MAX_LINES                       16
814static unsigned long s_test_char = 0x00000057UL;
815/* TODO:  Might want to improve macro to check for chars other than spaces */
816#define BGFX_IS_BREAK(x)        ((x == 0x00000020) ? 1 : 0)
817
818void bgfx_draw_text_box(bgfx_surf_p p,uint16_t x,uint16_t y,
819                                                uint16_t width, uint16_t height,
820                                                const unsigned long *str_p, int str_len, 
821                                                bgfx_font_t *font_p,bgfx_pixel c, 
822                                                uint16_t line_spacing)
823{
824        int offset,bw_off,line_idx;
825        static bgfx_glyph_t * p_bgfx_glyph[MAX_TEXT_BOX_CHARS]; /* Not thread safe */
826        static uint8_t brk_loc[MAX_TEXT_BOX_CHARS];
827        uint16_t max_h[MAX_LINES],ch_w,test_max_h,bot;
828        bgfx_glyph_t *p_test_glyph;
829
830        BGFX_TRACE(("bgfx_draw_text_box(%d,%d,%d,%d,%d) %ld characters.\n",x,y,width,height,line_spacing,str_len));
831        if (str_len > MAX_TEXT_BOX_CHARS) 
832        {
833                BGFX_DEBUG(("bgfx_draw_text %d > %d maximum characters.\n",str_len,MAX_TEXT_BOX_CHARS));
834                str_len = MAX_TEXT_BOX_CHARS;
835        }
836        bot = y + height;
837        p_test_glyph = bgfx_get_glyph(font_p,s_test_char);
838        if (p_test_glyph)
839                test_max_h = p_test_glyph->height;
840        else
841                test_max_h = 0;
842
843        for (line_idx = 0; line_idx < MAX_LINES; ++line_idx)
844                max_h[line_idx] = test_max_h;
845       
846        ch_w = 0;
847        line_idx = 0;
848        for (offset = 0; offset < str_len; offset++)
849        {
850                brk_loc[offset] = 0;
851                p_bgfx_glyph[offset] = bgfx_get_glyph(font_p,str_p[offset]);
852                if (p_bgfx_glyph[offset] == NULL)
853                {
854                        BGFX_DEBUG(("%s:%d str[%d] = 0x%08x\n",__FUNCTION__,__LINE__,offset,str_p[offset]));
855                        /* if not a printable charactor, then use space instead */
856                        p_bgfx_glyph[offset] = bgfx_get_glyph(font_p,0x00000020);
857                        continue;
858                }
859                ch_w += p_bgfx_glyph[offset]->advance;
860
861                if (p_bgfx_glyph[offset]->height > max_h[line_idx]) 
862                        max_h[line_idx] = p_bgfx_glyph[offset]->height;
863
864                if (ch_w >= width) 
865                {
866                        line_idx++;
867                        for (bw_off = offset - 1; bw_off >= 0; --bw_off)
868                        {
869                                if (brk_loc[bw_off]) {
870                                        bw_off = -1;
871                                        break;
872                                }
873                                if (BGFX_IS_BREAK(str_p[bw_off])) 
874                                {
875                                        brk_loc[bw_off] = 1;
876                                        break;
877                                }
878                        }
879
880                        /* last resort, break on preceding character */
881                        if (bw_off < 0) 
882                        {
883                                brk_loc[offset - 1] = 1;
884                                ch_w = p_bgfx_glyph[offset]->advance;
885                        }
886                        else
887                        {
888                                offset = bw_off;
889                                ch_w = 0;
890                        }
891                }
892        }
893
894        /* offset y so text is inside box */
895        line_idx = 0;
896#ifdef BGFX_VARIABL_LINE_HEIGHT
897        y += max_h[line_idx];
898#else
899        y += test_max_h;
900#endif
901        ch_w = 0;
902
903        for (offset = 0; (offset < str_len) && (line_idx < MAX_LINES); offset++)
904        {
905                if (brk_loc[offset]) 
906                {
907                        line_idx++;
908                        ch_w = 0;
909#ifdef BGFX_VARIABL_LINE_HEIGHT
910                        y += line_spacing + max_h[line_idx];
911                        if ((y - max_h[line_idx]) > bot) 
912                                break;
913#else
914                        y += line_spacing + test_max_h;
915                        if ((y - test_max_h) > bot) 
916                                break;
917#endif
918                        continue;
919                }
920                ch_w += bgfx_render_glyph(p,x + ch_w,y, str_p[offset], font_p,c,p_bgfx_glyph[offset],eBGFX_NORMAL);
921        }
922        bgfx_cacheflush(p->surface.buf,p->surface.pitch * p->surface.height);
923}
924
925/****************************************************************
926* bgfx_render_file
927*
928* INPUTS:       p - surface structure
929*                       x,y - coordinates
930*                       file_p - file to get image from
931*                       set_palette - use the palette in the file to set the
932*                                               global palette.
933* OUTPUTS:      none
934* RETURNS:      non-zero on error
935* FUNCTION:     Render the image in the file to the x,y location
936*
937****************************************************************/
938
939int bgfx_render_file(bgfx_surf_p p,uint16_t x,uint16_t y,
940                                        void *file_p,int set_palette)
941{
942        bcm_raw_8_t header;
943        int result = -1;
944        static uint8_t tbuf[SURF_WIDTH];
945        uint16_t row,rows,rowbytes;
946        uint8_t *dst_ptr;
947        int palette_bytes;
948        uint16_t i;
949        uint8_t *r_ptr,*tdst;
950
951        if (bgfx_read(&header,1,sizeof(header),file_p) == sizeof(header))
952        {
953                if (header.type != RAW_TYPE || header.version != RAW_VERSION)
954                {
955                        BGFX_DEBUG(("bgfx_render_file failed version,type invalid(0x%08lx,0x%08lx)\n",header.type,header.version));
956                        return -1;
957                }
958                BGFX_TRACE(("header.version = 0x%08lx\n",header.version));
959                BGFX_TRACE(("header.type = 0x%08lx\n",header.type));
960                BGFX_TRACE(("header.clut_size = %d\n",header.clut_size));
961                BGFX_TRACE(("header.color_key = 0x%02x\n",header.color_key));
962                BGFX_TRACE(("header.pitch = %ld\n",header.pitch));
963                BGFX_TRACE(("header.width = 0x%08x\n",header.width));
964                BGFX_TRACE(("header.height = 0x%08x\n",header.height));
965
966                palette_bytes = (sizeof(unsigned long) * header.clut_size);
967                if (bgfx_read(&p->palette,1,palette_bytes,file_p) == palette_bytes)
968                {
969                        if (set_palette && (header.clut_size == PALETTE_SIZE))
970                                bgfx_set_palette(p,&p->palette);
971                }
972
973                if ((header.width == p->surface.width) && (header.height == p->surface.height) &&
974                        (p->surface.pitch == header.pitch) && (x == 0) && (y == 0)
975                                 && !(p->flags & BGFX_SURF_RGB))
976                {
977                        BGFX_TRACE(("Fast Render\n"));
978                        bgfx_read(p->surface.buf,1,header.pitch*header.height,file_p);
979                }
980                else if ((p->palette.clut[header.color_key] & 0xFF000000) != 0)
981                {
982                        BGFX_TRACE(("Render - no color key\n"));
983                        rowbytes = BGFX_MIN(header.width,p->surface.width - x) * p->bpp/8;
984                        rows = BGFX_MIN(header.height, p->surface.height - y);
985
986                        dst_ptr = (uint8_t*)p->surface.buf;
987                        dst_ptr += y * p->surface.pitch + x * p->bpp/8;
988
989                        if (p->flags & BGFX_SURF_RGB)
990                        {
991                                for (row = 0; row < rows; row++)
992                                {
993                                        bgfx_read(tbuf ,1,rowbytes,file_p);
994                                        r_ptr = dst_ptr;
995                                        for (i = 0; i < rowbytes; ++i)
996                                        {
997                                                uint32_t sr,sg,sb,sa,dr,dg,db,da,src_c;
998                                                src_c = bgfx_clut8_to_rgb(p->palette.clut,tbuf[i]);
999                                                sa = (src_c >> 24) & 0xFF;
1000                                                if (sa == 0xFF)
1001                                                {
1002                                                        *((uint32_t*)r_ptr) = src_c;
1003                                                }
1004                                                else
1005                                                {
1006                                                        sr = (src_c >> 16) & 0xFF;
1007                                                        sg = (src_c >> 8) & 0xFF;
1008                                                        sb = (src_c >> 0) & 0xFF;
1009                                                        da = (*((uint32_t*)r_ptr) >> 24) & 0xFF;
1010                                                        dr = (*((uint32_t*)r_ptr) >> 16) & 0xFF;
1011                                                        dg = (*((uint32_t*)r_ptr) >> 8) & 0xFF;
1012                                                        db = (*((uint32_t*)r_ptr) >> 0) & 0xFF;
1013                                               
1014                                                        dr = (((sr * sa)/0xFF) & 0xFF) + ((((0xFF - sa) * dr)/0xFF) & 0xFF);
1015                                                        dg = (((sg * sa)/0xFF) & 0xFF) + ((((0xFF - sa) * dg)/0xFF) & 0xFF);
1016                                                        db = (((sb * sa)/0xFF) & 0xFF) + ((((0xFF - sa) * db)/0xFF) & 0xFF);
1017
1018                                                        *((uint32_t*)r_ptr) = (da << 24) | (dr << 16) | (dg << 8) | db;
1019                                                }
1020                                                r_ptr += p->bpp/8;
1021                                        }
1022
1023                                        if (header.pitch > rowbytes)
1024                                        {
1025                                                bgfx_read(tbuf ,1,header.pitch - rowbytes,file_p);
1026                                        }
1027                                        dst_ptr += p->surface.pitch;
1028                                }
1029                        }
1030                        else
1031                        {
1032                                for (row = 0; row < rows; row++)
1033                                {
1034                                        bgfx_read(dst_ptr ,1,rowbytes,file_p);
1035                                        if (header.pitch > rowbytes)
1036                                        {
1037                                                bgfx_read(tbuf ,1,header.pitch - rowbytes,file_p);
1038                                        }
1039                                        dst_ptr += p->surface.pitch;
1040                                }
1041                        }
1042                }
1043                else
1044                {
1045                        BGFX_TRACE(("Render - color key\n"));
1046                        rowbytes = BGFX_MIN(header.width,(p->surface.width - x)) * p->bpp/8;
1047                        rows = BGFX_MIN(header.height, (p->surface.height - y));
1048                        dst_ptr = (uint8_t*)p->surface.buf;
1049                        dst_ptr += y * p->surface.pitch + x * p->bpp/8;
1050
1051                        if (p->flags & BGFX_SURF_RGB)
1052                        {
1053                                for (row = 0; row < rows; row++)
1054                                {
1055                                        bgfx_read(tbuf ,1,rowbytes,file_p);
1056                                        r_ptr = dst_ptr;
1057                                        for (i = 0; i < rowbytes; ++i)
1058                                        {
1059                                                if (tbuf[i] != header.color_key)
1060                                                {
1061                                                        uint32_t sr,sg,sb,sa,dr,dg,db,da,src_c;
1062                                                        src_c = bgfx_clut8_to_rgb(p->palette.clut,tbuf[i]);
1063                                                        sa = (src_c >> 24) & 0xFF;
1064                                                        if (sa == 0xFF)
1065                                                        {
1066                                                                *((uint32_t*)r_ptr) = src_c;
1067                                                        }
1068                                                        else
1069                                                        {
1070                                                                sr = (src_c >> 16) & 0xFF;
1071                                                                sg = (src_c >> 8) & 0xFF;
1072                                                                sb = (src_c >> 0) & 0xFF;
1073                                                                da = (*((uint32_t*)r_ptr) >> 24) & 0xFF;
1074                                                                dr = (*((uint32_t*)r_ptr) >> 16) & 0xFF;
1075                                                                dg = (*((uint32_t*)r_ptr) >> 8) & 0xFF;
1076                                                                db = (*((uint32_t*)r_ptr) >> 0) & 0xFF;
1077
1078                                                                dr = (((sr * sa)/0xFF) & 0xFF) + ((((0xFF - sa) * dr)/0xFF) & 0xFF);
1079                                                                dg = (((sg * sa)/0xFF) & 0xFF) + ((((0xFF - sa) * dg)/0xFF) & 0xFF);
1080                                                                db = (((sb * sa)/0xFF) & 0xFF) + ((((0xFF - sa) * db)/0xFF) & 0xFF);
1081                                                                *((uint32_t*)r_ptr) = (da << 24) | (dr << 16) | (dg << 8) | db;
1082                                                        }
1083                                                }
1084                                                r_ptr += p->bpp/8;
1085                                        }
1086                                        if (header.pitch > rowbytes)
1087                                        {
1088                                                bgfx_read(tbuf ,1,header.pitch - rowbytes,file_p);
1089                                        }
1090                                        dst_ptr += p->surface.pitch;
1091                                }
1092                        }
1093                        else
1094                        {
1095                                for (row = 0; row < rows; row++)
1096                                {
1097                                        bgfx_read(dst_ptr ,1,rowbytes,file_p);
1098                                        if (header.pitch > rowbytes)
1099                                        {
1100                                                bgfx_read(tbuf ,1,header.pitch - rowbytes,file_p);
1101                                        }
1102                                        dst_ptr += p->surface.pitch;
1103                                }
1104                        }
1105                }
1106        }
1107        BGFX_TRACE(("Render - done\n"));
1108        bgfx_cacheflush(p->surface.buf,p->surface.pitch * p->surface.height);
1109        result = 0;
1110        return result;
1111}
1112
1113/****************************************************************
1114* bgfx_blit
1115*
1116* INPUTS:       p_src,p_dst - surface structure
1117*                       x,y - destination coordinates
1118* OUTPUTS:      none
1119* RETURNS:      non-zero on error
1120* FUNCTION:     Blit between the two surfaces, only the destination can be RGB
1121*
1122****************************************************************/
1123
1124int bgfx_blit(bgfx_surf_p p_src, bgfx_surf_p p_dst, uint16_t x,uint16_t y)
1125{
1126        uint8_t *dst,*src;
1127        uint16_t j,w,h,rowbytes;
1128        uint16_t i;
1129        uint8_t *tdst;
1130
1131        BGFX_TRACE(("bgfx_blit x,y (%d,%d)\n",x,y));           
1132
1133        if ((x > p_dst->surface.width) || (y > p_dst->surface.height))
1134        {
1135                BGFX_DEBUG(("bgfx_blit x,y (%d,%d) outside destination (%d,%d)\n",x,y,
1136                                   p_dst->surface.width,p_dst->surface.height));
1137                return -1;
1138        }
1139
1140        w = p_src->surface.width;
1141        if (w > p_dst->surface.width - x)
1142                w = p_dst->surface.width - x;
1143        h = p_src->surface.height;
1144        if (h > p_dst->surface.height - y)
1145                h = p_dst->surface.height - y;
1146
1147        src = (uint8_t*)p_src->surface.buf;
1148        dst = (uint8_t*)p_dst->surface.buf;
1149        dst += y * p_dst->surface.pitch + x * p_dst->bpp/8;
1150
1151        if (p_dst->flags & BGFX_SURF_RGB)
1152        {
1153                for (j = 0; j < h; ++j)
1154                {
1155                        tdst = dst;
1156                        for (i = 0; i < w; ++i)
1157                        {
1158                                if (src[i] != 0xFF)
1159                                        *((uint32_t*)tdst) = bgfx_clut8_to_rgb(p_src->palette.clut,src[i]);
1160                                tdst += p_dst->bpp/8;
1161                        }
1162                        dst += p_dst->surface.pitch;
1163                        src += p_src->surface.pitch;
1164                }
1165        }
1166        else
1167        {
1168                rowbytes = BGFX_MIN(p_src->surface.width,p_dst->surface.width - x) * p_dst->bpp/8;
1169                for (j = 0; j < h; ++j)
1170                {
1171                        BGFX_MEMCPY(dst,src,rowbytes);
1172                        dst += p_dst->surface.pitch;
1173                        src += p_src->surface.pitch;
1174                }
1175        }
1176        bgfx_cacheflush(p_dst->surface.buf,p_dst->surface.pitch * p_dst->surface.height);
1177        return 0;
1178}
1179/****************************************************************
1180* INPUTS:       p_src,p_dst - source and destination buffer pointers
1181*                       sx
1182*                       dx
1183*                       w - width
1184* OUTPUTS:      none
1185* RETURNS:      non-zero on error
1186* FUNCTION:     Blit a region of one surface to another (for 4 bpp )
1187*
1188****************************************************************/
1189
1190static inline void bgfx_row_copy(unsigned char *src, unsigned char *dst,
1191                                  uint16_t sx,uint16_t dx,uint16_t w, int bpp)
1192{
1193        if (bpp == 8)
1194        {
1195                BGFX_MEMCPY(dst,src,w); 
1196        }
1197        else
1198        {
1199                unsigned int num_bytes = (w * 4)/8;
1200                int pix;
1201       
1202                if (sx & 1)
1203                {
1204                        if (dx & 1)
1205                        {
1206                                *dst &= 0xF0;
1207                                *dst |= (*src & 0xF);
1208                                if (w & 1)
1209                                {
1210                                        BGFX_MEMCPY(&dst[1],&src[1],num_bytes);
1211                                }
1212                                else
1213                                {
1214                                        BGFX_MEMCPY(&dst[1],&src[1],num_bytes - 1);
1215                                        dst[num_bytes] &= 0x0F;
1216                                        dst[num_bytes] |= (src[num_bytes] & 0xF0);
1217                                }
1218                        }
1219                        else
1220                        {
1221                                for (pix = 0; pix < w; ++pix)
1222                                {
1223                                        if (pix & 1)
1224                                        {
1225                                                *dst &= 0xF0;
1226                                                *dst |= (*src & 0xF0) >> 4;
1227                                                dst++;
1228                                        }
1229                                        else
1230                                        {
1231                                                *dst &= 0x0F;
1232                                                *dst |= (*src & 0xF) << 4;
1233                                                src++;
1234                                        }
1235                                }
1236                        }
1237                }
1238                else
1239                {
1240                        if (dx & 1)
1241                        {
1242                                for (pix = 0; pix < w; ++pix)
1243                                {
1244                                        if (pix & 1)
1245                                        {
1246                                                *dst &= 0x0F;
1247                                                *dst |= (*src & 0xF) << 4;
1248                                                src++;
1249                                        }
1250                                        else
1251                                        {
1252                                                *dst &= 0xF0;
1253                                                *dst |= (*src & 0xF0) >> 4;
1254                                                dst++;
1255                                        }
1256                                }
1257                        }
1258                        else
1259                        {
1260                                if (w & 1)
1261                                {
1262                                        BGFX_MEMCPY(dst,src,num_bytes);
1263                                        dst[num_bytes] &= 0x0F;
1264                                        dst[num_bytes] |= (src[num_bytes] & 0xF0);
1265                                }
1266                                else
1267                                {
1268                                        BGFX_MEMCPY(dst,src,num_bytes);
1269                                }
1270                        }
1271                }
1272        }
1273}
1274/****************************************************************
1275* INPUTS:       p_src,p_dst - source and destination surface structures
1276*                       sx,sy - source coordinates
1277*                       dx,dy - destination coordinates
1278*                       sw,sh - width and height of region
1279* OUTPUTS:      none
1280* RETURNS:      non-zero on error
1281* FUNCTION:     Blit a region of one surface to another
1282*
1283****************************************************************/
1284
1285int bgfx_blit_rect(bgfx_surf_p p_src, bgfx_surf_p p_dst, 
1286                                  uint16_t sx,uint16_t sy, uint16_t dx,uint16_t dy, 
1287                                  uint16_t sw,uint16_t sh)
1288{
1289        uint8_t *dst,*src;
1290        uint16_t i,j,w,h;
1291        uint8_t *tdst;
1292
1293        if ((dx >= p_dst->surface.width) || (dy >= p_dst->surface.height))
1294        {
1295                BGFX_DEBUG(("bgfx_blit_rect dst_x,dst_y (%d,%d) outside destination (%d,%d)\n",dx,dy,
1296                                   p_dst->surface.width,p_dst->surface.height));
1297                return -1;
1298        }
1299
1300        if ((sx >= p_src->surface.width) || (sy >= p_src->surface.height))
1301        {
1302                BGFX_DEBUG(("bgfx_blit_rect src_x,src_y (%d,%d) outside source (%d,%d)\n",sx,sy,
1303                                   p_src->surface.width,p_src->surface.height));
1304                return -1;
1305        }
1306       
1307        src = (uint8_t*)p_src->surface.buf;
1308        src += (sy * p_src->surface.pitch) + ((sx * p_src->bpp)/8);
1309        dst = (uint8_t*)p_dst->surface.buf;
1310        dst += (dy * p_dst->surface.pitch) + ((dx * p_dst->bpp)/8);
1311
1312    w = sw;
1313       
1314        if (sw >= (p_src->surface.width - sx))
1315                w= p_src->surface.width - sx;
1316       
1317        if (w >= p_dst->surface.width - dx)
1318                w = p_dst->surface.width - dx;
1319
1320        h = sh;
1321
1322        if (sh >= (p_src->surface.height - sy))
1323                h= p_src->surface.height - sy;
1324
1325        if (h >= p_dst->surface.height - dy)
1326                h = p_dst->surface.height - dy;
1327       
1328
1329        if (p_dst->flags & BGFX_SURF_RGB)
1330        {
1331                for (j = 0; j < h; ++j)
1332                {
1333                        tdst = dst;
1334                        for (i = 0; i < w; ++i)
1335                        {
1336                                if (src[i] != 0xFF)
1337                                        *((uint32_t*)tdst) = bgfx_clut8_to_rgb(p_src->palette.clut,src[i]);
1338                                tdst += p_dst->bpp/8;
1339                        }
1340                        dst += p_dst->surface.pitch;
1341                        src += p_src->surface.pitch;
1342                }
1343        }
1344        else
1345        {
1346                for (j = 0; j < h; ++j)
1347                {
1348                        if (p_dst->bpp == 8)
1349                        {
1350                                for (i = 0; i < w; ++i)
1351                                {
1352                                        if (p_src->palette.clut[src[i]] & 0xFF000000)
1353                                        {
1354                                                dst[i] = src[i];
1355                                        }
1356                                }
1357                        }
1358                        else
1359                        {
1360                                bgfx_row_copy(src,dst,sx,dx,w,p_dst->bpp);
1361                        }
1362                        dst += p_dst->surface.pitch;
1363                        src += p_src->surface.pitch;
1364                }
1365        }
1366        bgfx_cacheflush(p_dst->surface.buf,p_dst->surface.pitch * p_dst->surface.height);
1367        return 0;
1368}
1369
1370
Note: See TracBrowser for help on using the repository browser.