diff options
author | Tomas Frydrych <tf@openedhand.com> | 2007-05-04 14:56:43 +0000 |
---|---|---|
committer | Tomas Frydrych <tf@openedhand.com> | 2007-05-04 14:56:43 +0000 |
commit | 0efc0dfc20f452ea25630b45aa5e13cf3e074e46 (patch) | |
tree | 59d15ae271a4f4c82f53f8065ce12defee2da4a2 /meta/packages/libmatchbox | |
parent | 85d984ea18b03b4fed679f2e2e818c61a7ddc8bd (diff) | |
download | poky-0efc0dfc20f452ea25630b45aa5e13cf3e074e46.tar.gz |
added updated 16bpp patch that handles 555 BRG and does bit of inlining
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@1595 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/packages/libmatchbox')
-rw-r--r-- | meta/packages/libmatchbox/files/16bppfixes-2.patch | 258 |
1 files changed, 258 insertions, 0 deletions
diff --git a/meta/packages/libmatchbox/files/16bppfixes-2.patch b/meta/packages/libmatchbox/files/16bppfixes-2.patch new file mode 100644 index 0000000000..ab9cdc74a5 --- /dev/null +++ b/meta/packages/libmatchbox/files/16bppfixes-2.patch | |||
@@ -0,0 +1,258 @@ | |||
1 | --- libmatchbox/libmb/mbpixbuf.c.orig 2007-05-04 14:41:55.000000000 +0100 | ||
2 | +++ libmatchbox/libmb/mbpixbuf.c 2007-05-04 14:41:55.000000000 +0100 | ||
3 | @@ -710,46 +710,19 @@ | ||
4 | return colnum; | ||
5 | } | ||
6 | |||
7 | - | ||
8 | -static unsigned long | ||
9 | -mb_pixbuf_get_pixel(MBPixbuf *pb, int r, int g, int b, int a) | ||
10 | +/* | ||
11 | + * Split the mb_pixbuf_get_pixel() function into several specialized | ||
12 | + * functions which we will inline; this allows us to optimize | ||
13 | + * mb_pixbuf_img_render_to_drawable_with_gc () by taking some of the | ||
14 | + * decision taking outside of the double loop | ||
15 | + */ | ||
16 | + | ||
17 | +/* | ||
18 | + * Get pixel value for rgb values and pixel depth <= 8 | ||
19 | + */ | ||
20 | +static inline unsigned long | ||
21 | +mb_pixbuf_get_pixel_le8_rgb (MBPixbuf *pb, int r, int g, int b) | ||
22 | { | ||
23 | - if (pb->depth > 8) | ||
24 | - { | ||
25 | - switch (pb->depth) | ||
26 | - { | ||
27 | - case 15: | ||
28 | - return ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3); | ||
29 | - case 16: | ||
30 | - return ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3); | ||
31 | - case 24: | ||
32 | - case 32: | ||
33 | - switch (pb->byte_order) | ||
34 | - { | ||
35 | - case BYTE_ORD_24_RGB: | ||
36 | - return ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); | ||
37 | - case BYTE_ORD_24_RBG: | ||
38 | - return ((r & 0xff) << 16) | ((b & 0xff) << 8) | (g & 0xff); | ||
39 | - case BYTE_ORD_24_BRG: | ||
40 | - return ((b & 0xff) << 16) | ((r & 0xff) << 8) | (g & 0xff); | ||
41 | - case BYTE_ORD_24_BGR: | ||
42 | - return ((b & 0xff) << 16) | ((g & 0xff) << 8) | (r & 0xff); | ||
43 | - case BYTE_ORD_24_GRB: | ||
44 | - return ((g & 0xff) << 16) | ((r & 0xff) << 8) | (b & 0xff); | ||
45 | - case BYTE_ORD_24_GBR: | ||
46 | - return ((g & 0xff) << 16) | ((b & 0xff) << 8) | (r & 0xff); | ||
47 | - case BYTE_ORD_32_ARGB: | ||
48 | - return (a << 24) | (r << 16) | (g << 8) | b; | ||
49 | - default: | ||
50 | - return 0; | ||
51 | - } | ||
52 | - default: | ||
53 | - return 0; | ||
54 | - } | ||
55 | - return 0; | ||
56 | - } | ||
57 | - | ||
58 | - /* pb->depth <= 8 */ | ||
59 | switch(pb->vis->class) | ||
60 | { | ||
61 | case PseudoColor: | ||
62 | @@ -794,6 +767,111 @@ | ||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | +/* | ||
67 | + * Get pixel value from a pointer to 16bbp value for pixel depth <= 8 | ||
68 | + * and advance the pointer | ||
69 | + */ | ||
70 | +static inline unsigned long | ||
71 | +mb_pixbuf_get_pixel_le8_16bpp_advance (MBPixbuf *pb, unsigned char ** p) | ||
72 | +{ | ||
73 | + unsigned short s = SHORT_FROM_2BYTES(*p); | ||
74 | + int r, b, g; | ||
75 | + | ||
76 | + r = (s & 0xf800) >> 8; | ||
77 | + g = (s & 0x07e0) >> 3; | ||
78 | + b = (s & 0x001f) << 3; | ||
79 | + | ||
80 | + *p += 2; | ||
81 | + | ||
82 | + return mb_pixbuf_get_pixel_le8_rgb (pb, r, g, b); | ||
83 | +} | ||
84 | + | ||
85 | +/* | ||
86 | + * Get pixel value for rgba values and pixel depth > 8 | ||
87 | + * | ||
88 | + */ | ||
89 | +static inline unsigned long | ||
90 | +mb_pixbuf_get_pixel_gt8_rgba (MBPixbuf *pb, int r, int g, int b, int a) | ||
91 | +{ | ||
92 | + switch (pb->depth) | ||
93 | + { | ||
94 | + case 15: | ||
95 | + switch (pb->byte_order) | ||
96 | + { | ||
97 | + case BYTE_ORD_24_RGB: | ||
98 | + return ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3); | ||
99 | + case BYTE_ORD_24_BGR: | ||
100 | + return ((b & 0xf8) << 7) | ((g & 0xf8) << 2) | ((r & 0xf8) >> 3); | ||
101 | + } | ||
102 | + case 16: | ||
103 | + switch (pb->byte_order) | ||
104 | + { | ||
105 | + case BYTE_ORD_24_RGB: | ||
106 | + return ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3); | ||
107 | + case BYTE_ORD_24_BGR: | ||
108 | + return ((b & 0xf8) << 8) | ((g & 0xfc) << 3) | ((r & 0xf8) >> 3); | ||
109 | + } | ||
110 | + case 24: | ||
111 | + case 32: | ||
112 | + switch (pb->byte_order) | ||
113 | + { | ||
114 | + case BYTE_ORD_24_RGB: | ||
115 | + return ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); | ||
116 | + case BYTE_ORD_24_RBG: | ||
117 | + return ((r & 0xff) << 16) | ((b & 0xff) << 8) | (g & 0xff); | ||
118 | + case BYTE_ORD_24_BRG: | ||
119 | + return ((b & 0xff) << 16) | ((r & 0xff) << 8) | (g & 0xff); | ||
120 | + case BYTE_ORD_24_BGR: | ||
121 | + return ((b & 0xff) << 16) | ((g & 0xff) << 8) | (r & 0xff); | ||
122 | + case BYTE_ORD_24_GRB: | ||
123 | + return ((g & 0xff) << 16) | ((r & 0xff) << 8) | (b & 0xff); | ||
124 | + case BYTE_ORD_24_GBR: | ||
125 | + return ((g & 0xff) << 16) | ((b & 0xff) << 8) | (r & 0xff); | ||
126 | + case BYTE_ORD_32_ARGB: | ||
127 | + return (a << 24) | (r << 16) | (g << 8) | b; | ||
128 | + default: | ||
129 | + return 0; | ||
130 | + } | ||
131 | + default: | ||
132 | + return 0; | ||
133 | + } | ||
134 | +} | ||
135 | + | ||
136 | +/* | ||
137 | + * Get pixel value from pointer to 16bpp data for pixel depth > 8 | ||
138 | + * and advance the pointer | ||
139 | + * | ||
140 | + * TODO ? We could take the 32bit case out of here, which would allow | ||
141 | + * to ignore the alpha value for <15, 24>, but we might not gain that | ||
142 | + * much by this on arm due to the conditional execution. | ||
143 | + */ | ||
144 | +static inline unsigned long | ||
145 | +mb_pixbuf_get_pixel_gt8_16bpp_advance (MBPixbuf *pb, unsigned char ** p, | ||
146 | + int has_alpha) | ||
147 | +{ | ||
148 | + unsigned short s = SHORT_FROM_2BYTES(*p); | ||
149 | + int r, b, g, a; | ||
150 | + | ||
151 | + r = (s & 0xf800) >> 8; | ||
152 | + g = (s & 0x07e0) >> 3; | ||
153 | + b = (s & 0x001f) << 3; | ||
154 | + | ||
155 | + *p += 2; | ||
156 | + | ||
157 | + a = has_alpha ? *(*p)++ : 0xff; | ||
158 | + | ||
159 | + return mb_pixbuf_get_pixel_gt8_rgba (pb, r, g, b, a); | ||
160 | +} | ||
161 | + | ||
162 | +static inline unsigned long | ||
163 | +mb_pixbuf_get_pixel(MBPixbuf *pb, int r, int g, int b, int a) | ||
164 | +{ | ||
165 | + if (pb->depth > 8) | ||
166 | + return mb_pixbuf_get_pixel_gt8_rgba (pb, r, g, b, a); | ||
167 | + | ||
168 | + return mb_pixbuf_get_pixel_le8_rgb (pb, r, g, b); | ||
169 | +} | ||
170 | + | ||
171 | unsigned long | ||
172 | mb_pixbuf_lookup_x_pixel(MBPixbuf *pb, int r, int g, int b, int a) | ||
173 | { | ||
174 | @@ -1825,7 +1903,6 @@ | ||
175 | mb_pixbuf_img_render_to_drawable_with_gc(pb, img, drw, drw_x, drw_y, pb->gc); | ||
176 | } | ||
177 | |||
178 | - | ||
179 | void | ||
180 | mb_pixbuf_img_render_to_drawable_with_gc(MBPixbuf *pb, | ||
181 | MBPixbufImage *img, | ||
182 | @@ -1883,31 +1960,57 @@ | ||
183 | |||
184 | if (pb->internal_bytespp == 2) | ||
185 | { | ||
186 | - for(y=0; y<img->height; y++) | ||
187 | - for(x=0; x<img->width; x++) | ||
188 | - { | ||
189 | - /* Below is potentially dangerous. | ||
190 | - */ | ||
191 | - pixel = ( *p | (*(p+1) << 8)); | ||
192 | - | ||
193 | - p += ((img->has_alpha) ? 3 : 2); | ||
194 | - | ||
195 | - XPutPixel(img->ximg, x, y, pixel); | ||
196 | - } | ||
197 | + if (pb->depth > 8) | ||
198 | + { | ||
199 | + for(y=0; y<img->height; y++) | ||
200 | + for(x=0; x<img->width; x++) | ||
201 | + { | ||
202 | + pixel = mb_pixbuf_get_pixel_gt8_16bpp_advance(pb, &p, | ||
203 | + img->has_alpha); | ||
204 | + XPutPixel(img->ximg, x, y, pixel); | ||
205 | + } | ||
206 | + } | ||
207 | + else | ||
208 | + { | ||
209 | + for(y=0; y<img->height; y++) | ||
210 | + for(x=0; x<img->width; x++) | ||
211 | + { | ||
212 | + pixel = mb_pixbuf_get_pixel_le8_16bpp_advance(pb, &p); | ||
213 | + XPutPixel(img->ximg, x, y, pixel); | ||
214 | + } | ||
215 | + } | ||
216 | } | ||
217 | else | ||
218 | { | ||
219 | - for(y=0; y<img->height; y++) | ||
220 | + if (pb->depth > 8) | ||
221 | { | ||
222 | - for(x=0; x<img->width; x++) | ||
223 | + for(y=0; y<img->height; y++) | ||
224 | { | ||
225 | - r = ( *p++ ); | ||
226 | - g = ( *p++ ); | ||
227 | - b = ( *p++ ); | ||
228 | - a = ((img->has_alpha) ? *p++ : 0xff); | ||
229 | + for(x=0; x<img->width; x++) | ||
230 | + { | ||
231 | + r = ( *p++ ); | ||
232 | + g = ( *p++ ); | ||
233 | + b = ( *p++ ); | ||
234 | + a = ((img->has_alpha) ? *p++ : 0xff); | ||
235 | |||
236 | - pixel = mb_pixbuf_get_pixel(pb, r, g, b, a); | ||
237 | - XPutPixel(img->ximg, x, y, pixel); | ||
238 | + pixel = mb_pixbuf_get_pixel_gt8_rgba(pb, r, g, b, a); | ||
239 | + XPutPixel(img->ximg, x, y, pixel); | ||
240 | + } | ||
241 | + } | ||
242 | + } | ||
243 | + else | ||
244 | + { | ||
245 | + for(y=0; y<img->height; y++) | ||
246 | + { | ||
247 | + for(x=0; x<img->width; x++) | ||
248 | + { | ||
249 | + r = ( *p++ ); | ||
250 | + g = ( *p++ ); | ||
251 | + b = ( *p++ ); | ||
252 | + | ||
253 | + pixel = mb_pixbuf_get_pixel_le8_rgb(pb, r, g, b); | ||
254 | + XPutPixel(img->ximg, x, y, pixel); | ||
255 | + } | ||
256 | } | ||
257 | } | ||
258 | } | ||