Bug 672646. D2D: Fix trasparent radial gradients. r=roc

The output merger stage was expecting premultiplied alpha
and we were giving non-premultiplied. Fix by premultiplying
in the shader.

Also adds a reftest for this situation.
This commit is contained in:
Jeff Muizelaar 2011-07-21 18:40:41 -04:00
parent 51c63a3844
commit 49346550bd
5 changed files with 2550 additions and 2477 deletions

View File

@ -178,8 +178,12 @@ float4 SampleRadialGradientPS( VS_RADIAL_OUTPUT In) : SV_Target
float upper_t = lerp(t.y, t.x, isValid.x);
float4 output = tex.Sample(sSampler, float2(upper_t, 0.5));
// Premultiply
output *= output.a;
// Multiply the output color by the input mask for the operation.
return tex.Sample(sSampler, float2(upper_t, 0.5)) * mask.Sample(sMaskSampler, In.MaskTexCoord).a;
output *= mask.Sample(sMaskSampler, In.MaskTexCoord).a;
return output;
};
float4 SampleRadialGradientA0PS( VS_RADIAL_OUTPUT In) : SV_Target
@ -201,7 +205,12 @@ float4 SampleRadialGradientA0PS( VS_RADIAL_OUTPUT In) : SV_Target
return float4(0, 0, 0, 0);
}
return tex.Sample(sSampler, float2(t, 0.5)) * mask.Sample(sMaskSampler, In.MaskTexCoord).a;
float4 output = tex.Sample(sSampler, float2(t, 0.5));
// Premultiply
output *= output.a;
// Multiply the output color by the input mask for the operation.
output *= mask.Sample(sMaskSampler, In.MaskTexCoord).a;
return output;
};
float4 SampleShadowHPS( VS_OUTPUT In) : SV_Target

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
<!doctype html>
<head>
<style>
body {
background-color: blue;
}
</style>
<body>
<canvas id="mycanvas" width="200" height="200"></canvas>
<script type="text/javascript">
var cx = document.getElementById('mycanvas').getContext('2d');
cx.beginPath();
cx.arc(100, 100, 80, 0, Math.PI*2, true);
cx.closePath();
cx.fillStyle = "white";
cx.fill();
</script>

View File

@ -0,0 +1,24 @@
<!doctype html>
<head>
<style>
body {
background-color: blue;
}
</style>
<body>
<canvas id="mycanvas" width="200" height="200"></canvas>
<script type="text/javascript">
var cx = document.getElementById('mycanvas').getContext('2d');
var g = cx.createRadialGradient(100, 100, 50, 100, 100, 75);
g.addColorStop(0, 'rgba(100%, 100%, 0%, 0.5)');
g.addColorStop(1, 'rgba(100%, 100%, 0%, 0)');
cx.fillStyle = g;
cx.fillRect(0, 0, 200, 200);
cx.beginPath();
cx.arc(100, 100, 80, 0, Math.PI*2, true);
cx.closePath();
cx.fillStyle = "white";
cx.fill();
</script>

View File

@ -64,3 +64,5 @@ random-if(Android) == dash-1.html dash-1-ref.svg # Bug 668412 (really is androi
== ctm-sanity.html data:text/html,<body>Pass
fails == ctm-singular-sanity.html data:text/html,<body>Pass # Bug 612033
== ctm-1.html ctm-1-ref.html
== 672646-alpha-radial-gradient.html 672646-alpha-radial-gradient-ref.html