summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/bmp_smooth_scale.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2014-06-18 07:15:00 +0200
committerThomas Martitz <kugel@rockbox.org>2014-06-21 00:15:53 +0200
commita1842c04f9cb73210d4cacde61a9e4b115050765 (patch)
treea37af61ef9285b763a42cd33797e2f3d634fbf9f /apps/plugins/lib/bmp_smooth_scale.c
parent0250be1d6799db7b5ddc99cb33f31bf9cff01ed2 (diff)
downloadrockbox-a1842c04f9cb73210d4cacde61a9e4b115050765.tar.gz
rockbox-a1842c04f9cb73210d4cacde61a9e4b115050765.zip
lcd-24bit: Introduce a 24-bit mid-level LCD driver
With LCD driver all calculation will be performed on RGB888 and the hardware/OS can display from our 24bit framebuffer. It is not yet as performance optimized as the existing drivers but should be good enough.The vast number of small changes is due to the fact that fb_data can be a struct type now, while most of the code expected a scalar type. lcd-as-memframe ASM code does not work with 24bit currently so the with 24bit it enforces the generic C code. All plugins are ported over. Except for rockpaint. It uses so much memory that it wouldnt fit into the 512k plugin buffer anymore (patches welcome). Change-Id: Ibb1964545028ce0d8ff9833ccc3ab66be3ee0754
Diffstat (limited to 'apps/plugins/lib/bmp_smooth_scale.c')
-rw-r--r--apps/plugins/lib/bmp_smooth_scale.c186
1 files changed, 93 insertions, 93 deletions
diff --git a/apps/plugins/lib/bmp_smooth_scale.c b/apps/plugins/lib/bmp_smooth_scale.c
index e99ff33d71..c5f258cdbf 100644
--- a/apps/plugins/lib/bmp_smooth_scale.c
+++ b/apps/plugins/lib/bmp_smooth_scale.c
@@ -130,38 +130,38 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
130 130
131 if (XAP > 0) { 131 if (XAP > 0) {
132 pix = ypoint + xpoint; 132 pix = ypoint + xpoint;
133 r = RGB_UNPACK_RED(*pix) * INV_XAP; 133 r = FB_UNPACK_RED(*pix) * INV_XAP;
134 g = RGB_UNPACK_GREEN(*pix) * INV_XAP; 134 g = FB_UNPACK_GREEN(*pix) * INV_XAP;
135 b = RGB_UNPACK_BLUE(*pix) * INV_XAP; 135 b = FB_UNPACK_BLUE(*pix) * INV_XAP;
136 pix++; 136 pix++;
137 r += RGB_UNPACK_RED(*pix) * XAP; 137 r += FB_UNPACK_RED(*pix) * XAP;
138 g += RGB_UNPACK_GREEN(*pix) * XAP; 138 g += FB_UNPACK_GREEN(*pix) * XAP;
139 b += RGB_UNPACK_BLUE(*pix) * XAP; 139 b += FB_UNPACK_BLUE(*pix) * XAP;
140 pix += sow; 140 pix += sow;
141 rr = RGB_UNPACK_RED(*pix) * XAP; 141 rr = FB_UNPACK_RED(*pix) * XAP;
142 gg = RGB_UNPACK_GREEN(*pix) * XAP; 142 gg = FB_UNPACK_GREEN(*pix) * XAP;
143 bb = RGB_UNPACK_BLUE(*pix) * XAP; 143 bb = FB_UNPACK_BLUE(*pix) * XAP;
144 pix--; 144 pix--;
145 rr += RGB_UNPACK_RED(*pix) * INV_XAP; 145 rr += FB_UNPACK_RED(*pix) * INV_XAP;
146 gg += RGB_UNPACK_GREEN(*pix) * INV_XAP; 146 gg += FB_UNPACK_GREEN(*pix) * INV_XAP;
147 bb += RGB_UNPACK_BLUE(*pix) * INV_XAP; 147 bb += FB_UNPACK_BLUE(*pix) * INV_XAP;
148 r = ((rr * YAP) + (r * INV_YAP)) >> 16; 148 r = ((rr * YAP) + (r * INV_YAP)) >> 16;
149 g = ((gg * YAP) + (g * INV_YAP)) >> 16; 149 g = ((gg * YAP) + (g * INV_YAP)) >> 16;
150 b = ((bb * YAP) + (b * INV_YAP)) >> 16; 150 b = ((bb * YAP) + (b * INV_YAP)) >> 16;
151 *dptr++ = LCD_RGBPACK(r, g, b); 151 *dptr++ = FB_RGBPACK(r, g, b);
152 } else { 152 } else {
153 pix = ypoint + xpoint; 153 pix = ypoint + xpoint;
154 r = RGB_UNPACK_RED(*pix) * INV_YAP; 154 r = FB_UNPACK_RED(*pix) * INV_YAP;
155 g = RGB_UNPACK_GREEN(*pix) * INV_YAP; 155 g = FB_UNPACK_GREEN(*pix) * INV_YAP;
156 b = RGB_UNPACK_BLUE(*pix) * INV_YAP; 156 b = FB_UNPACK_BLUE(*pix) * INV_YAP;
157 pix += sow; 157 pix += sow;
158 r += RGB_UNPACK_RED(*pix) * YAP; 158 r += FB_UNPACK_RED(*pix) * YAP;
159 g += RGB_UNPACK_GREEN(*pix) * YAP; 159 g += FB_UNPACK_GREEN(*pix) * YAP;
160 b += RGB_UNPACK_BLUE(*pix) * YAP; 160 b += FB_UNPACK_BLUE(*pix) * YAP;
161 r >>= 8; 161 r >>= 8;
162 g >>= 8; 162 g >>= 8;
163 b >>= 8; 163 b >>= 8;
164 *dptr++ = LCD_RGBPACK(r, g, b); 164 *dptr++ = FB_RGBPACK(r, g, b);
165 } 165 }
166 } 166 }
167 } else { 167 } else {
@@ -176,17 +176,17 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
176 176
177 if (XAP > 0) { 177 if (XAP > 0) {
178 pix = ypoint + xpoint; 178 pix = ypoint + xpoint;
179 r = RGB_UNPACK_RED(*pix) * INV_XAP; 179 r = FB_UNPACK_RED(*pix) * INV_XAP;
180 g = RGB_UNPACK_GREEN(*pix) * INV_XAP; 180 g = FB_UNPACK_GREEN(*pix) * INV_XAP;
181 b = RGB_UNPACK_BLUE(*pix) * INV_XAP; 181 b = FB_UNPACK_BLUE(*pix) * INV_XAP;
182 pix++; 182 pix++;
183 r += RGB_UNPACK_RED(*pix) * XAP; 183 r += FB_UNPACK_RED(*pix) * XAP;
184 g += RGB_UNPACK_GREEN(*pix) * XAP; 184 g += FB_UNPACK_GREEN(*pix) * XAP;
185 b += RGB_UNPACK_BLUE(*pix) * XAP; 185 b += FB_UNPACK_BLUE(*pix) * XAP;
186 r >>= 8; 186 r >>= 8;
187 g >>= 8; 187 g >>= 8;
188 b >>= 8; 188 b >>= 8;
189 *dptr++ = LCD_RGBPACK(r, g, b); 189 *dptr++ = FB_RGBPACK(r, g, b);
190 } else 190 } else
191 *dptr++ = sptr[xpoint]; 191 *dptr++ = sptr[xpoint];
192 } 192 }
@@ -221,37 +221,37 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
221 val_x += inc_x; 221 val_x += inc_x;
222 222
223 pix = ypoint + xpoint; 223 pix = ypoint + xpoint;
224 r = (RGB_UNPACK_RED(*pix) * yap) >> 10; 224 r = (FB_UNPACK_RED(*pix) * yap) >> 10;
225 g = (RGB_UNPACK_GREEN(*pix) * yap) >> 10; 225 g = (FB_UNPACK_GREEN(*pix) * yap) >> 10;
226 b = (RGB_UNPACK_BLUE(*pix) * yap) >> 10; 226 b = (FB_UNPACK_BLUE(*pix) * yap) >> 10;
227 pix += sow; 227 pix += sow;
228 for (j = (1 << 14) - yap; j > Cy; j -= Cy) { 228 for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
229 r += (RGB_UNPACK_RED(*pix) * Cy) >> 10; 229 r += (FB_UNPACK_RED(*pix) * Cy) >> 10;
230 g += (RGB_UNPACK_GREEN(*pix) * Cy) >> 10; 230 g += (FB_UNPACK_GREEN(*pix) * Cy) >> 10;
231 b += (RGB_UNPACK_BLUE(*pix) * Cy) >> 10; 231 b += (FB_UNPACK_BLUE(*pix) * Cy) >> 10;
232 pix += sow; 232 pix += sow;
233 } 233 }
234 if (j > 0) { 234 if (j > 0) {
235 r += (RGB_UNPACK_RED(*pix) * j) >> 10; 235 r += (FB_UNPACK_RED(*pix) * j) >> 10;
236 g += (RGB_UNPACK_GREEN(*pix) * j) >> 10; 236 g += (FB_UNPACK_GREEN(*pix) * j) >> 10;
237 b += (RGB_UNPACK_BLUE(*pix) * j) >> 10; 237 b += (FB_UNPACK_BLUE(*pix) * j) >> 10;
238 } 238 }
239 if (XAP > 0) { 239 if (XAP > 0) {
240 pix = ypoint + xpoint + 1; 240 pix = ypoint + xpoint + 1;
241 rr = (RGB_UNPACK_RED(*pix) * yap) >> 10; 241 rr = (FB_UNPACK_RED(*pix) * yap) >> 10;
242 gg = (RGB_UNPACK_GREEN(*pix) * yap) >> 10; 242 gg = (FB_UNPACK_GREEN(*pix) * yap) >> 10;
243 bb = (RGB_UNPACK_BLUE(*pix) * yap) >> 10; 243 bb = (FB_UNPACK_BLUE(*pix) * yap) >> 10;
244 pix += sow; 244 pix += sow;
245 for (j = (1 << 14) - yap; j > Cy; j -= Cy) { 245 for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
246 rr += (RGB_UNPACK_RED(*pix) * Cy) >> 10; 246 rr += (FB_UNPACK_RED(*pix) * Cy) >> 10;
247 gg += (RGB_UNPACK_GREEN(*pix) * Cy) >> 10; 247 gg += (FB_UNPACK_GREEN(*pix) * Cy) >> 10;
248 bb += (RGB_UNPACK_BLUE(*pix) * Cy) >> 10; 248 bb += (FB_UNPACK_BLUE(*pix) * Cy) >> 10;
249 pix += sow; 249 pix += sow;
250 } 250 }
251 if (j > 0) { 251 if (j > 0) {
252 rr += (RGB_UNPACK_RED(*pix) * j) >> 10; 252 rr += (FB_UNPACK_RED(*pix) * j) >> 10;
253 gg += (RGB_UNPACK_GREEN(*pix) * j) >> 10; 253 gg += (FB_UNPACK_GREEN(*pix) * j) >> 10;
254 bb += (RGB_UNPACK_BLUE(*pix) * j) >> 10; 254 bb += (FB_UNPACK_BLUE(*pix) * j) >> 10;
255 } 255 }
256 r = r * INV_XAP; 256 r = r * INV_XAP;
257 g = g * INV_XAP; 257 g = g * INV_XAP;
@@ -264,7 +264,7 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
264 g >>= 4; 264 g >>= 4;
265 b >>= 4; 265 b >>= 4;
266 } 266 }
267 *dptr = LCD_RGBPACK(r, g, b); 267 *dptr = FB_RGBPACK(r, g, b);
268 dptr++; 268 dptr++;
269 } 269 }
270 } 270 }
@@ -297,37 +297,37 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
297 xap = XAP & 0xffff; 297 xap = XAP & 0xffff;
298 298
299 pix = ypoint + xpoint; 299 pix = ypoint + xpoint;
300 r = (RGB_UNPACK_RED(*pix) * xap) >> 10; 300 r = (FB_UNPACK_RED(*pix) * xap) >> 10;
301 g = (RGB_UNPACK_GREEN(*pix) * xap) >> 10; 301 g = (FB_UNPACK_GREEN(*pix) * xap) >> 10;
302 b = (RGB_UNPACK_BLUE(*pix) * xap) >> 10; 302 b = (FB_UNPACK_BLUE(*pix) * xap) >> 10;
303 pix++; 303 pix++;
304 for (j = (1 << 14) - xap; j > Cx; j -= Cx) { 304 for (j = (1 << 14) - xap; j > Cx; j -= Cx) {
305 r += (RGB_UNPACK_RED(*pix) * Cx) >> 10; 305 r += (FB_UNPACK_RED(*pix) * Cx) >> 10;
306 g += (RGB_UNPACK_GREEN(*pix) * Cx) >> 10; 306 g += (FB_UNPACK_GREEN(*pix) * Cx) >> 10;
307 b += (RGB_UNPACK_BLUE(*pix) * Cx) >> 10; 307 b += (FB_UNPACK_BLUE(*pix) * Cx) >> 10;
308 pix++; 308 pix++;
309 } 309 }
310 if (j > 0) { 310 if (j > 0) {
311 r += (RGB_UNPACK_RED(*pix) * j) >> 10; 311 r += (FB_UNPACK_RED(*pix) * j) >> 10;
312 g += (RGB_UNPACK_GREEN(*pix) * j) >> 10; 312 g += (FB_UNPACK_GREEN(*pix) * j) >> 10;
313 b += (RGB_UNPACK_BLUE(*pix) * j) >> 10; 313 b += (FB_UNPACK_BLUE(*pix) * j) >> 10;
314 } 314 }
315 if (YAP > 0) { 315 if (YAP > 0) {
316 pix = ypoint + xpoint + sow; 316 pix = ypoint + xpoint + sow;
317 rr = (RGB_UNPACK_RED(*pix) * xap) >> 10; 317 rr = (FB_UNPACK_RED(*pix) * xap) >> 10;
318 gg = (RGB_UNPACK_GREEN(*pix) * xap) >> 10; 318 gg = (FB_UNPACK_GREEN(*pix) * xap) >> 10;
319 bb = (RGB_UNPACK_BLUE(*pix) * xap) >> 10; 319 bb = (FB_UNPACK_BLUE(*pix) * xap) >> 10;
320 pix++; 320 pix++;
321 for (j = (1 << 14) - xap; j > Cx; j -= Cx) { 321 for (j = (1 << 14) - xap; j > Cx; j -= Cx) {
322 rr += (RGB_UNPACK_RED(*pix) * Cx) >> 10; 322 rr += (FB_UNPACK_RED(*pix) * Cx) >> 10;
323 gg += (RGB_UNPACK_GREEN(*pix) * Cx) >> 10; 323 gg += (FB_UNPACK_GREEN(*pix) * Cx) >> 10;
324 bb += (RGB_UNPACK_BLUE(*pix) * Cx) >> 10; 324 bb += (FB_UNPACK_BLUE(*pix) * Cx) >> 10;
325 pix++; 325 pix++;
326 } 326 }
327 if (j > 0) { 327 if (j > 0) {
328 rr += (RGB_UNPACK_RED(*pix) * j) >> 10; 328 rr += (FB_UNPACK_RED(*pix) * j) >> 10;
329 gg += (RGB_UNPACK_GREEN(*pix) * j) >> 10; 329 gg += (FB_UNPACK_GREEN(*pix) * j) >> 10;
330 bb += (RGB_UNPACK_BLUE(*pix) * j) >> 10; 330 bb += (FB_UNPACK_BLUE(*pix) * j) >> 10;
331 } 331 }
332 r = r * INV_YAP; 332 r = r * INV_YAP;
333 g = g * INV_YAP; 333 g = g * INV_YAP;
@@ -340,7 +340,7 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
340 g >>= 4; 340 g >>= 4;
341 b >>= 4; 341 b >>= 4;
342 } 342 }
343 *dptr = LCD_RGBPACK(r, g, b); 343 *dptr = FB_RGBPACK(r, g, b);
344 dptr++; 344 dptr++;
345 } 345 }
346 } 346 }
@@ -378,20 +378,20 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
378 378
379 pix = sptr; 379 pix = sptr;
380 sptr += sow; 380 sptr += sow;
381 rx = (RGB_UNPACK_RED(*pix) * xap) >> 9; 381 rx = (FB_UNPACK_RED(*pix) * xap) >> 9;
382 gx = (RGB_UNPACK_GREEN(*pix) * xap) >> 9; 382 gx = (FB_UNPACK_GREEN(*pix) * xap) >> 9;
383 bx = (RGB_UNPACK_BLUE(*pix) * xap) >> 9; 383 bx = (FB_UNPACK_BLUE(*pix) * xap) >> 9;
384 pix++; 384 pix++;
385 for (i = (1 << 14) - xap; i > Cx; i -= Cx) { 385 for (i = (1 << 14) - xap; i > Cx; i -= Cx) {
386 rx += (RGB_UNPACK_RED(*pix) * Cx) >> 9; 386 rx += (FB_UNPACK_RED(*pix) * Cx) >> 9;
387 gx += (RGB_UNPACK_GREEN(*pix) * Cx) >> 9; 387 gx += (FB_UNPACK_GREEN(*pix) * Cx) >> 9;
388 bx += (RGB_UNPACK_BLUE(*pix) * Cx) >> 9; 388 bx += (FB_UNPACK_BLUE(*pix) * Cx) >> 9;
389 pix++; 389 pix++;
390 } 390 }
391 if (i > 0) { 391 if (i > 0) {
392 rx += (RGB_UNPACK_RED(*pix) * i) >> 9; 392 rx += (FB_UNPACK_RED(*pix) * i) >> 9;
393 gx += (RGB_UNPACK_GREEN(*pix) * i) >> 9; 393 gx += (FB_UNPACK_GREEN(*pix) * i) >> 9;
394 bx += (RGB_UNPACK_BLUE(*pix) * i) >> 9; 394 bx += (FB_UNPACK_BLUE(*pix) * i) >> 9;
395 } 395 }
396 396
397 r = (rx * yap) >> 14; 397 r = (rx * yap) >> 14;
@@ -401,20 +401,20 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
401 for (j = (1 << 14) - yap; j > Cy; j -= Cy) { 401 for (j = (1 << 14) - yap; j > Cy; j -= Cy) {
402 pix = sptr; 402 pix = sptr;
403 sptr += sow; 403 sptr += sow;
404 rx = (RGB_UNPACK_RED(*pix) * xap) >> 9; 404 rx = (FB_UNPACK_RED(*pix) * xap) >> 9;
405 gx = (RGB_UNPACK_GREEN(*pix) * xap) >> 9; 405 gx = (FB_UNPACK_GREEN(*pix) * xap) >> 9;
406 bx = (RGB_UNPACK_BLUE(*pix) * xap) >> 9; 406 bx = (FB_UNPACK_BLUE(*pix) * xap) >> 9;
407 pix++; 407 pix++;
408 for (i = (1 << 14) - xap; i > Cx; i -= Cx) { 408 for (i = (1 << 14) - xap; i > Cx; i -= Cx) {
409 rx += (RGB_UNPACK_RED(*pix) * Cx) >> 9; 409 rx += (FB_UNPACK_RED(*pix) * Cx) >> 9;
410 gx += (RGB_UNPACK_GREEN(*pix) * Cx) >> 9; 410 gx += (FB_UNPACK_GREEN(*pix) * Cx) >> 9;
411 bx += (RGB_UNPACK_BLUE(*pix) * Cx) >> 9; 411 bx += (FB_UNPACK_BLUE(*pix) * Cx) >> 9;
412 pix++; 412 pix++;
413 } 413 }
414 if (i > 0) { 414 if (i > 0) {
415 rx += (RGB_UNPACK_RED(*pix) * i) >> 9; 415 rx += (FB_UNPACK_RED(*pix) * i) >> 9;
416 gx += (RGB_UNPACK_GREEN(*pix) * i) >> 9; 416 gx += (FB_UNPACK_GREEN(*pix) * i) >> 9;
417 bx += (RGB_UNPACK_BLUE(*pix) * i) >> 9; 417 bx += (FB_UNPACK_BLUE(*pix) * i) >> 9;
418 } 418 }
419 419
420 r += (rx * Cy) >> 14; 420 r += (rx * Cy) >> 14;
@@ -424,20 +424,20 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
424 if (j > 0) { 424 if (j > 0) {
425 pix = sptr; 425 pix = sptr;
426 sptr += sow; 426 sptr += sow;
427 rx = (RGB_UNPACK_RED(*pix) * xap) >> 9; 427 rx = (FB_UNPACK_RED(*pix) * xap) >> 9;
428 gx = (RGB_UNPACK_GREEN(*pix) * xap) >> 9; 428 gx = (FB_UNPACK_GREEN(*pix) * xap) >> 9;
429 bx = (RGB_UNPACK_BLUE(*pix) * xap) >> 9; 429 bx = (FB_UNPACK_BLUE(*pix) * xap) >> 9;
430 pix++; 430 pix++;
431 for (i = (1 << 14) - xap; i > Cx; i -= Cx) { 431 for (i = (1 << 14) - xap; i > Cx; i -= Cx) {
432 rx += (RGB_UNPACK_RED(*pix) * Cx) >> 9; 432 rx += (FB_UNPACK_RED(*pix) * Cx) >> 9;
433 gx += (RGB_UNPACK_GREEN(*pix) * Cx) >> 9; 433 gx += (FB_UNPACK_GREEN(*pix) * Cx) >> 9;
434 bx += (RGB_UNPACK_BLUE(*pix) * Cx) >> 9; 434 bx += (FB_UNPACK_BLUE(*pix) * Cx) >> 9;
435 pix++; 435 pix++;
436 } 436 }
437 if (i > 0) { 437 if (i > 0) {
438 rx += (RGB_UNPACK_RED(*pix) * i) >> 9; 438 rx += (FB_UNPACK_RED(*pix) * i) >> 9;
439 gx += (RGB_UNPACK_GREEN(*pix) * i) >> 9; 439 gx += (FB_UNPACK_GREEN(*pix) * i) >> 9;
440 bx += (RGB_UNPACK_BLUE(*pix) * i) >> 9; 440 bx += (FB_UNPACK_BLUE(*pix) * i) >> 9;
441 } 441 }
442 442
443 r += (rx * j) >> 14; 443 r += (rx * j) >> 14;
@@ -445,7 +445,7 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp)
445 b += (bx * j) >> 14; 445 b += (bx * j) >> 14;
446 } 446 }
447 447
448 *dptr = LCD_RGBPACK(r >> 5, g >> 5, b >> 5); 448 *dptr = FB_RGBPACK(r >> 5, g >> 5, b >> 5);
449 dptr++; 449 dptr++;
450 } 450 }
451 } 451 }