Bug 647687 - Fix filter SourceImage bounds. r=longsonr

This commit is contained in:
Robert O'Callahan ext:(.) 2011-09-17 09:29:51 +01:00
Родитель 3b3622d5ae
Коммит 9c015b9b38
6 изменённых файлов: 65 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,24 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Testcase for checking that filter bounds include stroke width</title>
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=647687 -->
<defs>
<filter id="f1" filterUnits="userSpaceOnUse" x="150" y="150" width="200" height="200">
<feOffset in="SourceGraphic"/>
</filter>
</defs>
<rect height="100%" width="100%" fill="lime"/>
<rect x="150" y="150" height="200" width="200" fill="red"/>
<rect x="200" y="200" height="100" width="100" stroke-width="100"
fill="none" stroke="lime" filter="url(#f1)"/>
</svg>

После

Ширина:  |  Высота:  |  Размер: 779 B

Просмотреть файл

@ -0,0 +1,25 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Testcase for checking that filter bounds include stroke width</title>
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=647687 -->
<defs>
<filter id="f1" filterUnits="objectBoundingBox">
<feFlood flood-color="red"/>
</filter>
</defs>
<rect height="100%" width="100%" fill="lime"/>
<polygon points="200,200 300,200 300,300 200,300" stroke-width="100"
fill="none" stroke="lime" filter="url(#f1)"/>
<rect x="150" y="150" height="200" width="200" fill="lime"/>
</svg>

После

Ширина:  |  Высота:  |  Размер: 744 B

Просмотреть файл

@ -111,6 +111,8 @@ random == dynamic-use-nested-01.svg dynamic-use-nested-01-ref.svg # bug 467498
== filter-basic-01.svg pass.svg
== filter-basic-02.svg pass.svg
== filter-basic-03.svg pass.svg
== filter-bounds-01.svg pass.svg
== filter-bounds-02.svg pass.svg
== filter-foreignObject-01.svg pass.svg
== filter-invalidation-01.svg pass.svg
== filter-scaled-01.svg pass.svg

Просмотреть файл

@ -206,11 +206,19 @@ nsAutoFilterInstance::nsAutoFilterInstance(nsIFrame *aTarget,
MapDeviceRectToFilterSpace(deviceToFilterSpace, filterRes, aDirtyOutputRect);
nsIntRect dirtyInputRect =
MapDeviceRectToFilterSpace(deviceToFilterSpace, filterRes, aDirtyInputRect);
nsIntRect targetBoundsDeviceSpace;
nsISVGChildFrame* svgTarget = do_QueryFrame(aTarget);
if (svgTarget) {
targetBoundsDeviceSpace.UnionRect(targetBoundsDeviceSpace,
svgTarget->GetCoveredRegion().ToOutsidePixels(aTarget->PresContext()->AppUnitsPerDevPixel()));
}
nsIntRect targetBoundsFilterSpace =
MapDeviceRectToFilterSpace(deviceToFilterSpace, filterRes, &targetBoundsDeviceSpace);
// Setup instance data
mInstance = new nsSVGFilterInstance(aTarget, aPaint, filter, bbox, filterRegion,
nsIntSize(filterRes.width, filterRes.height),
filterToDeviceSpace,
filterToDeviceSpace, targetBoundsFilterSpace,
dirtyOutputRect, dirtyInputRect,
primitiveUnits);
}

Просмотреть файл

@ -189,6 +189,7 @@ nsSVGFilterInstance::BuildSources()
// Detect possible float->int overflow
if (!gfxUtils::GfxRectToIntRect(sourceBounds, &sourceBoundsInt))
return NS_ERROR_FAILURE;
sourceBoundsInt.UnionRect(sourceBoundsInt, mTargetBounds);
mSourceColorAlpha.mResultBoundingBox = sourceBoundsInt;
mSourceAlpha.mResultBoundingBox = sourceBoundsInt;

Просмотреть файл

@ -70,6 +70,7 @@ public:
const gfxRect& aFilterRect,
const nsIntSize& aFilterSpaceSize,
const gfxMatrix &aFilterSpaceToDeviceSpaceTransform,
const nsIntRect& aTargetBounds,
const nsIntRect& aDirtyOutputRect,
const nsIntRect& aDirtyInputRect,
PRUint16 aPrimitiveUnits) :
@ -80,6 +81,7 @@ public:
mFilterSpaceToDeviceSpaceTransform(aFilterSpaceToDeviceSpaceTransform),
mFilterRect(aFilterRect),
mFilterSpaceSize(aFilterSpaceSize),
mTargetBounds(aTargetBounds),
mDirtyOutputRect(aDirtyOutputRect),
mDirtyInputRect(aDirtyInputRect),
mSurfaceRect(nsIntPoint(0, 0), aFilterSpaceSize),
@ -209,6 +211,8 @@ private:
gfxMatrix mFilterSpaceToDeviceSpaceTransform;
gfxRect mFilterRect;
nsIntSize mFilterSpaceSize;
// Filter-space bounds of the target image (SourceAlpha/SourceGraphic)
nsIntRect mTargetBounds;
nsIntRect mDirtyOutputRect;
nsIntRect mDirtyInputRect;
nsIntRect mSurfaceRect;