Bug 743444 - Lighting Filter clipped when kernelUnitLength specified. r=roc

This commit is contained in:
Robert Longson 2012-04-13 08:01:55 +01:00
parent 827586c908
commit 611dcd8782
4 changed files with 45 additions and 0 deletions

View File

@ -100,6 +100,16 @@ CopyRect(const nsSVGFE::Image* aDest, const nsSVGFE::Image* aSrc, const nsIntRec
aSrc->mImage->Stride(), aDataRect); aSrc->mImage->Stride(), aDataRect);
} }
static void
CopyAndScaleDeviceOffset(const gfxImageSurface *aImage, gfxImageSurface *aResult,
gfxFloat kernelX, gfxFloat kernelY)
{
gfxPoint deviceOffset = aImage->GetDeviceOffset();
deviceOffset.x /= kernelX;
deviceOffset.y /= kernelY;
aResult->SetDeviceOffset(deviceOffset);
}
//--------------------Filter Element Base Class----------------------- //--------------------Filter Element Base Class-----------------------
nsSVGElement::LengthInfo nsSVGFE::sLengthInfo[4] = nsSVGElement::LengthInfo nsSVGFE::sLengthInfo[4] =
@ -181,6 +191,10 @@ nsSVGFE::SetupScalingFilter(nsSVGFilterInstance *aInstance,
result.mTarget = nsnull; result.mTarget = nsnull;
return result; return result;
} }
CopyAndScaleDeviceOffset(aSource->mImage, result.mSource, kernelX, kernelY);
CopyAndScaleDeviceOffset(aTarget->mImage, result.mTarget, kernelX, kernelY);
result.mRealTarget = aTarget->mImage; result.mRealTarget = aTarget->mImage;
gfxContext ctx(result.mSource); gfxContext ctx(result.mSource);

View File

@ -0,0 +1,15 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<filter id="emboss">
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blur"/>
<!-- without kernelUnitLength attribute -->
<feSpecularLighting in="blur" result="spec" surfaceScale="-3"
specularConstant="2" specularExponent="16"
lighting-color="#ffb155">
<feDistantLight azimuth="45" elevation="45"/>
</feSpecularLighting>
<feComposite in="spec" in2="SourceGraphic" operator="in" result="specOut"/>
</filter>
</defs>
<path filter="url(#emboss)" d="M 44.408917,5.7095287 C 535.13945,101.91182 534.01725,101.52506 532.53904,101.52499 C 531.36871,101.52506 530.17420,101.85117 528.96683,102.49024 z "/>
</svg>

After

Width:  |  Height:  |  Size: 809 B

View File

@ -0,0 +1,15 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<filter id="emboss">
<feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blur"/>
<!-- with kernelUnitLength attribute -->
<feSpecularLighting in="blur" result="spec" surfaceScale="-3"
specularConstant="2" specularExponent="16"
lighting-color="#ffb155" kernelUnitLength="1">
<feDistantLight azimuth="45" elevation="45"/>
</feSpecularLighting>
<feComposite in="spec" in2="SourceGraphic" operator="in" result="specOut"/>
</filter>
</defs>
<path filter="url(#emboss)" d="M 44.408917,5.7095287 C 535.13945,101.91182 534.01725,101.52506 532.53904,101.52499 C 531.36871,101.52506 530.17420,101.85117 528.96683,102.49024 z "/>
</svg>

After

Width:  |  Height:  |  Size: 827 B

View File

@ -54,6 +54,7 @@ random-if(d2d) == filter-filterRes-low-01.svg pass.svg
== filter-inner-svg-02.svg pass.svg == filter-inner-svg-02.svg pass.svg
== filter-inner-svg-03.svg pass.svg == filter-inner-svg-03.svg pass.svg
fails == filter-marked-line-01.svg pass.svg # bug 477704 fails == filter-marked-line-01.svg pass.svg # bug 477704
== filter-kernelUnitLength-01.svg filter-kernelUnitLength-01-ref.svg
== filter-marked-line-02.svg pass.svg == filter-marked-line-02.svg pass.svg
== filter-marked-line-03.svg pass.svg == filter-marked-line-03.svg pass.svg
== filter-marked-line-04.svg pass.svg == filter-marked-line-04.svg pass.svg