diff options
author | Eric Anholt <eric@anholt.net> | 2010-02-18 14:02:48 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-02-18 14:04:03 -0800 |
commit | 85e49c07e37b02f8c8a363707cf0f47b6deab7ab (patch) | |
tree | 30381bb8562fa663e688519c5df9f39d9115d85d /glamor/glamor_render.c | |
parent | 1bc64af07ab1ca53084491ab7d9c131bbb1e3846 (diff) |
glamor: Add support for component alpha rendering.
Brings x11perf -rgb24text from 230/sec to 18400/sec
Diffstat (limited to 'glamor/glamor_render.c')
-rw-r--r-- | glamor/glamor_render.c | 64 |
1 files changed, 47 insertions, 17 deletions
diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c index f4840dc0c..55d533856 100644 --- a/glamor/glamor_render.c +++ b/glamor/glamor_render.c @@ -118,6 +118,16 @@ glamor_create_composite_fs(struct shader_key *key) "{\n" " gl_FragColor = get_source() * get_mask().a;\n" "}\n"; + const char *in_ca_source = + "void main()\n" + "{\n" + " gl_FragColor = get_source() * get_mask();\n" + "}\n"; + const char *in_ca_alpha = + "void main()\n" + "{\n" + " gl_FragColor = get_source().a * get_mask();\n" + "}\n"; char *source; const char *source_fetch; const char *mask_fetch = ""; @@ -161,6 +171,12 @@ glamor_create_composite_fs(struct shader_key *key) case SHADER_IN_NORMAL: in = in_normal; break; + case SHADER_IN_CA_SOURCE: + in = in_ca_source; + break; + case SHADER_IN_CA_ALPHA: + in = in_ca_alpha; + break; default: FatalError("Bad composite IN type"); } @@ -615,11 +631,22 @@ glamor_composite_with_shader(CARD8 op, } } - key.in = SHADER_IN_NORMAL; + if (!mask->componentAlpha) { + key.in = SHADER_IN_NORMAL; + } else { + /* We only handle two CA modes. */ + if (op == PictOpAdd) + key.in = SHADER_IN_CA_SOURCE; + else { + assert(op == PictOpOutReverse); + key.in = SHADER_IN_CA_ALPHA; + } + } } else { key.mask = SHADER_MASK_NONE; key.in = SHADER_IN_SOURCE_ONLY; } + if (source->alphaMap) { glamor_fallback("source alphaMap\n"); goto fail; @@ -838,22 +865,25 @@ glamor_composite(CARD8 op, /* Do two-pass PictOpOver componentAlpha, until we enable * dual source color blending. */ - if (mask && mask->componentAlpha) - goto fail; - if (mask && mask->componentAlpha && op == PictOpOver) { - glamor_composite(PictOpOutReverse, - source, mask, dest, - x_source, y_source, - x_mask, y_mask, - x_dest, y_dest, - width, height); - glamor_composite(PictOpAdd, - source, mask, dest, - x_source, y_source, - x_mask, y_mask, - x_dest, y_dest, - width, height); - return; + if (mask && mask->componentAlpha) { + if (op == PictOpOver) { + glamor_composite(PictOpOutReverse, + source, mask, dest, + x_source, y_source, + x_mask, y_mask, + x_dest, y_dest, + width, height); + glamor_composite(PictOpAdd, + source, mask, dest, + x_source, y_source, + x_mask, y_mask, + x_dest, y_dest, + width, height); + return; + } else if (op != PictOpAdd && op != PictOpOutReverse) { + glamor_fallback("glamor_composite(): component alpha\n"); + goto fail; + } } if (!mask) { |