diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-01-25 15:15:04 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-01-25 15:49:38 +0000 |
commit | 197cb08a2d54cabbfe97454d7db85cfe1f5f27ba (patch) | |
tree | 765cab9076ca0cb9fcfcab7f5a2c0b76b21c8129 | |
parent | 5f93d019dc6311dd16b6792ffb60dbfc45ef3d08 (diff) |
Extract pixel value for all formats to avoid hitting fallbacks.
On failing to extract the pixel value for an alpha-only solid we
actually triggered a fallback. Since this path is commonly hitting
whilst fading in images, for example cairo_paint_with_alpha(), the
fallback was detected during the Moblin boot sequence where it was
adding a second to the overall boot time.
See
fallback intel: Moblin startup is hitting a composite fallback, costing
a ton of performance
https://bugs.freedesktop.org/show_bug.cgi?id=26189
Based on the initial patch by Arjan van de Van.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | uxa/uxa-render.c | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/uxa/uxa-render.c b/uxa/uxa-render.c index 826602bc..512ac02d 100644 --- a/uxa/uxa-render.c +++ b/uxa/uxa-render.c @@ -146,11 +146,6 @@ uxa_get_pixel_from_rgba(CARD32 * pixel, int rbits, bbits, gbits, abits; int rshift, bshift, gshift, ashift; - *pixel = 0; - - if (!PICT_FORMAT_COLOR(format)) - return FALSE; - rbits = PICT_FORMAT_R(format); gbits = PICT_FORMAT_G(format); bbits = PICT_FORMAT_B(format); @@ -158,6 +153,14 @@ uxa_get_pixel_from_rgba(CARD32 * pixel, if (abits == 0) abits = PICT_FORMAT_BPP(format) - (rbits+gbits+bbits); + if (PICT_FORMAT_TYPE(format) == PICT_TYPE_A) { + *pixel = alpha >> (16 - abits); + return TRUE; + } + + if (!PICT_FORMAT_COLOR(format)) + return FALSE; + if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) { bshift = 0; gshift = bbits; @@ -170,6 +173,7 @@ uxa_get_pixel_from_rgba(CARD32 * pixel, ashift = bshift + bbits; } + *pixel = 0; *pixel |= (blue >> (16 - bbits)) << bshift; *pixel |= (red >> (16 - rbits)) << rshift; *pixel |= (green >> (16 - gbits)) << gshift; @@ -187,43 +191,53 @@ uxa_get_rgba_from_pixel(CARD32 pixel, int rbits, bbits, gbits, abits; int rshift, bshift, gshift, ashift; - if (!PICT_FORMAT_COLOR(format)) - return FALSE; - rbits = PICT_FORMAT_R(format); gbits = PICT_FORMAT_G(format); bbits = PICT_FORMAT_B(format); abits = PICT_FORMAT_A(format); - if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) { + if (PICT_FORMAT_TYPE(format) == PICT_TYPE_A) { + rshift = gshift = bshift = ashift = 0; + } else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) { bshift = 0; gshift = bbits; rshift = gshift + gbits; ashift = rshift + rbits; - } else { /* PICT_TYPE_ABGR */ + } else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) { rshift = 0; gshift = rbits; bshift = gshift + gbits; ashift = bshift + bbits; + } else { + return FALSE; } - *red = ((pixel >> rshift) & ((1 << rbits) - 1)) << (16 - rbits); - while (rbits < 16) { - *red |= *red >> rbits; - rbits <<= 1; - } + if (rbits) { + *red = ((pixel >> rshift) & ((1 << rbits) - 1)) << (16 - rbits); + while (rbits < 16) { + *red |= *red >> rbits; + rbits <<= 1; + } + } else + *red = 0; - *green = ((pixel >> gshift) & ((1 << gbits) - 1)) << (16 - gbits); - while (gbits < 16) { - *green |= *green >> gbits; - gbits <<= 1; - } + if (gbits) { + *green = ((pixel >> gshift) & ((1 << gbits) - 1)) << (16 - gbits); + while (gbits < 16) { + *green |= *green >> gbits; + gbits <<= 1; + } + } else + *green = 0; - *blue = ((pixel >> bshift) & ((1 << bbits) - 1)) << (16 - bbits); - while (bbits < 16) { - *blue |= *blue >> bbits; - bbits <<= 1; - } + if (bbits) { + *blue = ((pixel >> bshift) & ((1 << bbits) - 1)) << (16 - bbits); + while (bbits < 16) { + *blue |= *blue >> bbits; + bbits <<= 1; + } + } else + *blue = 0; if (abits) { *alpha = |