Merge branch 'org.openembedded.dev' of git://git.openembedded.net/openembedded into...
[vuplus_openembedded] / packages / tuxbox / files / libtuxtxt_32bpp.diff
1 diff -ru libs.org/libtuxtxt/libtuxtxt.c libs/libtuxtxt/libtuxtxt.c
2 --- libs.org/libtuxtxt/libtuxtxt.c      2008-05-21 09:25:30.000000000 +0200
3 +++ libs/libtuxtxt/libtuxtxt.c  2008-05-22 09:42:18.000000000 +0200
4 @@ -7,6 +7,12 @@
5   *    Info entnommen aus videotext-0.6.19991029,                              *
6   *    Copyright (c) 1994-96 Martin Buck  <martin-2.buck@student.uni-ulm.de>   *
7   *                                                                            *
8 + *              ported 2006 to Dreambox 7025 / 32Bit framebuffer              *
9 + *                   by Seddi <seddi@i-have-a-dreambox.com>                   *
10 + *                                                                            *
11 + *              ported 32Bit framebuffer to Tuxtxt v1.99 (2008)               *
12 + *                      by the PLi team (Sat-Turner)                          *
13 + *                                                                            *
14   ******************************************************************************/
15  
16  #ifdef DEBUG
17 diff -ru libs.org/libtuxtxt/tuxtxt_common.h libs/libtuxtxt/tuxtxt_common.h
18 --- libs.org/libtuxtxt/tuxtxt_common.h  2008-08-13 19:53:47.000000000 +0200
19 +++ libs/libtuxtxt/tuxtxt_common.h      2008-05-31 13:44:57.000000000 +0200
20 @@ -152,6 +152,19 @@
21         aG3_70, aG3_71, aG3_72, aG3_73, aG3_74, aG3_75, aG3_76, aG3_77, aG3_78, aG3_79, aG3_7a, aG3_7b, aG3_7c, aG3_7d, aG3_7e
22  };
23  
24 +/* 32bit colortable */
25 +unsigned char bgra[][4] = { 
26 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
27 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
28 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
29 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
30 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
31 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
32 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
33 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xFF",
34 +"\0\0\0\xFF", "\0\0\0\xFF", "\0\0\0\xC0", "\0\0\0\x00",
35 +"\0\0\0\x33" };
36 +
37  tuxtxt_cache_struct tuxtxt_cache;
38  static pthread_mutex_t tuxtxt_cache_lock = PTHREAD_MUTEX_INITIALIZER;
39  int tuxtxt_get_zipsize(int p,int sp)
40 @@ -2782,12 +2795,16 @@
41  void tuxtxt_FillRect(unsigned char *lfb, int xres, int x, int y, int w, int h, int color)
42  {
43         if (!lfb) return;
44 -       unsigned char *p = lfb + x + y * xres;
45 +       unsigned char *p = lfb + x*4 + y * xres;
46 +       int xtmp;
47  
48         if (w > 0)
49                 for ( ; h > 0 ; h--)
50                 {
51 -                       memset(p, color, w);
52 +                       for (xtmp=0; xtmp<w; xtmp++)
53 +                       {
54 +                               memcpy(p+xtmp*4,bgra[color],4);
55 +                       }
56                         p += xres;
57                 }
58  }
59 @@ -2799,7 +2816,7 @@
60         unsigned char fgcolor, unsigned char bgcolor)
61  {
62         if (d == NULL) return;
63 -       int bit, x, y;
64 +       int bit, x, y, ltmp;
65         unsigned char *ay = ax + 13; /* array[0..10] of y-offsets for each pixel */
66  
67         for (y = 0; y < 10; y++) /* 10*2 bytes a 6 pixels per char definition */
68 @@ -2823,9 +2840,21 @@
69                         for (i = 0; i < h; i++)
70                         {
71                                 if (ax[x+1] > ax[x])
72 -                                       memset(d + ax[x], f1, ax[x+1] - ax[x]);
73 +                               {
74 +//                                     memset(d + ax[x], f1, ax[x+1] - ax[x]);
75 +                                       for (ltmp=0 ; ltmp < (ax[x+1]-ax[x]); ltmp++)
76 +                                       {
77 +                                               memcpy(d + ax[x]*4 +ltmp*4,bgra[f1],4);
78 +                                       }
79 +                               }
80                                 if (ax[x+7] > ax[x+6])
81 -                                       memset(d + ax[x+6], f2, ax[x+7] - ax[x+6]); /* 2nd byte 6 pixels to the right */
82 +                               {
83 +//                                     memset(d + ax[x+6], f2, ax[x+7] - ax[x+6]); /* 2nd byte 6 pixels to the right */
84 +                                       for (ltmp=0 ; ltmp < (ax[x+7]-ax[x+6]); ltmp++)
85 +                                       {
86 +                                               memcpy(d + ax[x+6]*4 +ltmp*4,bgra[f2],4);
87 +                                       }
88 +                               }
89                                 d += xres;
90                         }
91                         d -= h * xres;
92 @@ -2838,20 +2867,26 @@
93  void tuxtxt_DrawVLine(unsigned char *lfb, int xres, int x, int y, int l, int color)
94  {
95         if (!lfb) return;
96 -       unsigned char *p = lfb + x + y * xres;
97 +       unsigned char *p = lfb + 4*x + y * xres;
98  
99         for ( ; l > 0 ; l--)
100         {
101 -               *p = color;
102 +               memcpy(p,bgra[color],4);
103                 p += xres;
104         }
105  }
106  
107  void tuxtxt_DrawHLine(unsigned char* lfb,int xres,int x, int y, int l, int color)
108  {
109 +       int ltmp;
110         if (!lfb) return;
111         if (l > 0)
112 -               memset(lfb + x + y * xres, color, l);
113 +       {
114 +               for (ltmp=0; ltmp < l; ltmp++)
115 +               {
116 +                       memcpy(lfb + x*4 + ltmp*4 + y * xres, bgra[color], 4);
117 +               }
118 +       }
119  }
120  
121  void tuxtxt_FillRectMosaicSeparated(unsigned char *lfb, int xres,int x, int y, int w, int h, int fgcolor, int bgcolor, int set)
122 @@ -2866,48 +2901,54 @@
123  
124  void tuxtxt_FillTrapez(unsigned char *lfb, int xres,int x0, int y0, int l0, int xoffset1, int h, int l1, int color)
125  {
126 -       unsigned char *p = lfb + x0 + y0 * xres;
127 +       unsigned char *p = lfb + x0*4 + y0 * xres;
128         int xoffset, l;
129         int yoffset;
130 +       int ltmp;
131  
132         for (yoffset = 0; yoffset < h; yoffset++)
133         {
134                 l = l0 + ((l1-l0) * yoffset + h/2) / h;
135                 xoffset = (xoffset1 * yoffset + h/2) / h;
136                 if (l > 0)
137 -                       memset(p + xoffset, color, l);
138 +               {
139 +                       for (ltmp=0; ltmp < l; ltmp++)
140 +                       {
141 +                               memcpy(p + xoffset*4 +ltmp*4, bgra[color], 4);
142 +                       }
143 +               }
144                 p += xres;
145         }
146  }
147  void tuxtxt_FlipHorz(unsigned char *lfb, int xres,int x, int y, int w, int h)
148  {
149 -       unsigned char buf[w];
150 -       unsigned char *p = lfb + x + y * xres;
151 +       unsigned char buf[w*4];
152 +       unsigned char *p = lfb + x*4 + y * xres;
153         int w1,h1;
154  
155         for (h1 = 0 ; h1 < h ; h1++)
156         {
157 -               memcpy(buf,p,w);
158 +               memcpy(buf,p,w*4);
159                 for (w1 = 0 ; w1 < w ; w1++)
160                 {
161 -                       *(p+w1) = buf[w-(w1+1)];
162 +                       memcpy(p+w1*4,buf+((w-w1)*4)-4,4);
163                 }
164                 p += xres;
165         }
166  }
167  void tuxtxt_FlipVert(unsigned char *lfb, int xres,int x, int y, int w, int h)
168  {
169 -       unsigned char buf[w];
170 -       unsigned char *p = lfb + x + y * xres, *p1, *p2;
171 +       unsigned char buf[w*4];
172 +       unsigned char *p = lfb + x*4 + y * xres, *p1, *p2;
173         int h1;
174  
175         for (h1 = 0 ; h1 < h/2 ; h1++)
176         {
177                 p1 = (p+(h1*xres));
178                 p2 = (p+(h-(h1+1))*xres);
179 -               memcpy(buf,p1,w);
180 -               memcpy(p1,p2,w);
181 -               memcpy(p2,buf,w);
182 +               memcpy(buf,p1,w*4);
183 +               memcpy(p1,p2,w*4);
184 +               memcpy(p2,buf,w*4);
185         }
186  }
187  
188 @@ -3163,7 +3204,7 @@
189                                 if (lfb) 
190                                 {
191                                         int x,y,f,c;
192 -                                       unsigned char* p = lfb + *pPosX + PosY* xres;
193 +                                       unsigned char* p = lfb + (*pPosX)*4 + PosY* xres;
194                                         for (y=0; y<fontheight;y++)
195                                         {
196                                                 for (f=0; f<factor; f++)
197 @@ -3171,7 +3212,7 @@
198                                                         for (x=0; x<curfontwidth*xfactor;x++)
199                                                         {
200                                                                 c = (y&4 ? (x/3)&1 :((x+3)/3)&1);
201 -                                                               *(p+x) = (c ? fgcolor : bgcolor);
202 +                                                               memcpy((p+x*4),bgra[(c ? fgcolor : bgcolor)],4);
203                                                         }
204                                                         p += xres;
205                                                 }
206 @@ -3209,7 +3250,7 @@
207                         }
208                         axdrcs[12] = curfontwidth; /* adjust last x-offset according to position, FIXME: double width */
209                         tuxtxt_RenderDRCS(xres,p,
210 -                                                 lfb + *pPosX + PosY * xres,
211 +                                                 lfb + (*pPosX)*4 + PosY * xres,
212                                                   axdrcs, fgcolor, bgcolor);
213                 }
214                 else