diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2013-02-06 06:49:54 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2013-02-06 06:49:54 (GMT) |
commit | 6514398bead7926b85b6e5eb7d6276f47a97cd2f (patch) | |
tree | 17fd36433e427551c3fd56248593c66c5ae60235 /src/FbTk | |
parent | 779618e45d4571bb6a4866aa2e398780f4b4da5d (diff) | |
download | fluxbox_pavel-6514398bead7926b85b6e5eb7d6276f47a97cd2f.zip fluxbox_pavel-6514398bead7926b85b6e5eb7d6276f47a97cd2f.tar.bz2 |
Branchless code for interlacing a texture
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/TextureRender.cc | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc index 4623417..93c91f1 100644 --- a/src/FbTk/TextureRender.cc +++ b/src/FbTk/TextureRender.cc | |||
@@ -85,12 +85,14 @@ struct RGBA { | |||
85 | color.b = PRE_MULTIPLY_0_75[color.b]; | 85 | color.b = PRE_MULTIPLY_0_75[color.b]; |
86 | } | 86 | } |
87 | 87 | ||
88 | static void noop(RGBA& color) { } | ||
88 | 89 | ||
89 | typedef void (*colorFunc)(RGBA&); | 90 | typedef void (*colorFunc)(RGBA&); |
90 | static const colorFunc pseudoInterlaceFuncs[2]; | 91 | static const colorFunc pseudoInterlaceFuncs[3]; |
91 | }; | 92 | }; |
92 | 93 | ||
93 | const RGBA::colorFunc RGBA::pseudoInterlaceFuncs[2] = { | 94 | const RGBA::colorFunc RGBA::pseudoInterlaceFuncs[3] = { |
95 | RGBA::noop, | ||
94 | RGBA::brighten_4, | 96 | RGBA::brighten_4, |
95 | RGBA::darken | 97 | RGBA::darken |
96 | }; | 98 | }; |
@@ -233,12 +235,11 @@ void prepareMirrorTable(prepareFunc prepare, size_t size, FbTk::RGBA* rgba, | |||
233 | size_t half_size = (size >> 1) + (size & 1); | 235 | size_t half_size = (size >> 1) + (size & 1); |
234 | 236 | ||
235 | prepare(half_size, &rgba[0], from, to, scale); | 237 | prepare(half_size, &rgba[0], from, to, scale); |
236 | mirrorRGB(size, 1, rgba); // TODO!! | 238 | mirrorRGB(size, 1, rgba); |
237 | } | 239 | } |
238 | 240 | ||
239 | 241 | inline void pseudoInterlace(FbTk::RGBA& rgba, const bool& do_interlace, const size_t& y) { | |
240 | inline void pseudoInterlace(FbTk::RGBA& rgba, const size_t& y) { | 242 | FbTk::RGBA::pseudoInterlaceFuncs[do_interlace + (do_interlace * (y & 1))](rgba); |
241 | FbTk::RGBA::pseudoInterlaceFuncs[y & 1](rgba); | ||
242 | } | 243 | } |
243 | 244 | ||
244 | 245 | ||
@@ -367,11 +368,8 @@ void renderHorizontalGradient(bool interlaced, | |||
367 | 368 | ||
368 | for (i = 0, y = 0; y < height; ++y) { | 369 | for (i = 0, y = 0; y < height; ++y) { |
369 | for (x = 0; x < width; ++x, ++i) { | 370 | for (x = 0; x < width; ++x, ++i) { |
370 | |||
371 | rgba[i] = gradient[x]; | 371 | rgba[i] = gradient[x]; |
372 | 372 | pseudoInterlace(rgba[i], interlaced, y); | |
373 | if (interlaced) | ||
374 | pseudoInterlace(rgba[i], y); | ||
375 | } | 373 | } |
376 | } | 374 | } |
377 | } | 375 | } |
@@ -392,9 +390,7 @@ void renderVerticalGradient(bool interlaced, | |||
392 | for (i = 0, y = 0; y < height; ++y) { | 390 | for (i = 0, y = 0; y < height; ++y) { |
393 | for (x = 0; x < width; ++x, ++i) { | 391 | for (x = 0; x < width; ++x, ++i) { |
394 | rgba[i] = gradient[y]; | 392 | rgba[i] = gradient[y]; |
395 | 393 | pseudoInterlace(rgba[i], interlaced, y); | |
396 | if (interlaced) | ||
397 | pseudoInterlace(rgba[i], y); | ||
398 | } | 394 | } |
399 | } | 395 | } |
400 | } | 396 | } |
@@ -427,8 +423,7 @@ void renderPyramidGradient(bool interlaced, | |||
427 | rgba[i].g = x_gradient[x].g + y_gradient[y].g; | 423 | rgba[i].g = x_gradient[x].g + y_gradient[y].g; |
428 | rgba[i].b = x_gradient[x].b + y_gradient[y].b; | 424 | rgba[i].b = x_gradient[x].b + y_gradient[y].b; |
429 | 425 | ||
430 | if (interlaced) | 426 | pseudoInterlace(rgba[i], interlaced, y); |
431 | pseudoInterlace(rgba[i], y); | ||
432 | } | 427 | } |
433 | } | 428 | } |
434 | } | 429 | } |
@@ -482,8 +477,7 @@ void renderRectangleGradient(bool interlaced, | |||
482 | rgba[i] = y_gradient[y]; | 477 | rgba[i] = y_gradient[y]; |
483 | } | 478 | } |
484 | 479 | ||
485 | if (interlaced) | 480 | pseudoInterlace(rgba[i], interlaced, y); |
486 | pseudoInterlace(rgba[i], y); | ||
487 | } | 481 | } |
488 | } | 482 | } |
489 | } | 483 | } |
@@ -525,8 +519,7 @@ void renderPipeCrossGradient(bool interlaced, | |||
525 | rgba[i] = y_gradient[y]; | 519 | rgba[i] = y_gradient[y]; |
526 | } | 520 | } |
527 | 521 | ||
528 | if (interlaced) | 522 | pseudoInterlace(rgba[i], interlaced, y); |
529 | pseudoInterlace(rgba[i], y); | ||
530 | } | 523 | } |
531 | } | 524 | } |
532 | } | 525 | } |
@@ -562,8 +555,7 @@ void renderDiagonalGradient(bool interlaced, | |||
562 | rgba[i].g = x_gradient[x].g + y_gradient[y].g; | 555 | rgba[i].g = x_gradient[x].g + y_gradient[y].g; |
563 | rgba[i].b = x_gradient[x].b + y_gradient[y].b; | 556 | rgba[i].b = x_gradient[x].b + y_gradient[y].b; |
564 | 557 | ||
565 | if (interlaced) | 558 | pseudoInterlace(rgba[i], interlaced, y); |
566 | pseudoInterlace(rgba[i], y); | ||
567 | } | 559 | } |
568 | } | 560 | } |
569 | } | 561 | } |
@@ -608,8 +600,7 @@ void renderEllipticGradient(bool interlaced, | |||
608 | rgba[i].g = (unsigned char)(g - (d * dg)); | 600 | rgba[i].g = (unsigned char)(g - (d * dg)); |
609 | rgba[i].b = (unsigned char)(b - (d * db)); | 601 | rgba[i].b = (unsigned char)(b - (d * db)); |
610 | 602 | ||
611 | if (interlaced) | 603 | pseudoInterlace(rgba[i], interlaced, y); |
612 | pseudoInterlace(rgba[i], y); | ||
613 | } | 604 | } |
614 | } | 605 | } |
615 | } | 606 | } |
@@ -643,8 +634,7 @@ void renderCrossDiagonalGradient(bool interlaced, | |||
643 | rgba[i].g = x_gradient[x].g + y_gradient[y].g; | 634 | rgba[i].g = x_gradient[x].g + y_gradient[y].g; |
644 | rgba[i].b = x_gradient[x].b + y_gradient[y].b; | 635 | rgba[i].b = x_gradient[x].b + y_gradient[y].b; |
645 | 636 | ||
646 | if (interlaced) | 637 | pseudoInterlace(rgba[i], interlaced, y); |
647 | pseudoInterlace(rgba[i], y); | ||
648 | } | 638 | } |
649 | } | 639 | } |
650 | } | 640 | } |