Bug 448906 - linked patterns are not scaled correctly. r=roc

This commit is contained in:
Robert Longson 2009-10-26 19:37:31 +00:00
Родитель 622eb5ba06
Коммит 3dbc9675ed
3 изменённых файлов: 34 добавлений и 10 удалений

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

@ -0,0 +1,19 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Test for linked pattern scaling</title>
<!-- From https://bugzilla.mozilla.org/show_bug.cgi?id=448906 -->
<defs>
<pattern id="pattern01" height="20" width="20"
patternTransform="scale(0.5)"
patternUnits="userSpaceOnUse">
<rect height="20" width="20" fill="lime" />
</pattern>
<pattern id="pattern02" xlink:href="#pattern01"/>
</defs>
<rect width="100%" height="100%" style="fill:url(#pattern02)" transform="scale(2)"/>
</svg>

После

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

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

@ -52,6 +52,7 @@ include moz-only/reftest.list
== dynamic-textPath-01.svg dynamic-textPath-01-ref.svg
== dynamic-use-01.svg pass.svg
== dynamic-use-02.svg pass.svg
== linked-pattern-01.svg pass.svg
== use-01-extref.svg pass.svg
== use-02-extref.svg use-02-extref-ref.svg
== use-children.svg pass.svg

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

@ -172,7 +172,7 @@ nsSVGPatternFrame::PaintPattern(gfxASurface** surface,
*/
*surface = nsnull;
// Get our child
// Get the first child of the pattern data we will render
nsIFrame *firstKid;
if (NS_FAILED(GetPatternFirstChild(&firstKid)))
return NS_ERROR_FAILURE; // Either no kids or a bad reference
@ -212,7 +212,11 @@ nsSVGPatternFrame::PaintPattern(gfxASurface** surface,
if (ctm.IsSingular()) {
return NS_ERROR_FAILURE;
}
mCTM = NS_NewSVGMatrix(ctm);
// Get the pattern we are going to render
nsSVGPatternFrame *patternFrame =
static_cast<nsSVGPatternFrame*>(firstKid->GetParent());
patternFrame->mCTM = NS_NewSVGMatrix(ctm);
// Get the bounding box of the pattern. This will be used to determine
// the size of the surface, and will also be used to define the bounding
@ -244,8 +248,8 @@ nsSVGPatternFrame::PaintPattern(gfxASurface** surface,
surfaceSize.width / patternWidth, 0.0f,
0.0f, surfaceSize.height / patternHeight,
0.0f, 0.0f);
mCTM->Multiply(tempTM, getter_AddRefs(aCTM));
aCTM.swap(mCTM);
patternFrame->mCTM->Multiply(tempTM, getter_AddRefs(aCTM));
aCTM.swap(patternFrame->mCTM);
// and magnify pattern to compensate
patternMatrix->Scale(patternWidth / surfaceSize.width,
@ -275,21 +279,21 @@ nsSVGPatternFrame::PaintPattern(gfxASurface** surface,
// we got at the beginning because it takes care of the
// referenced pattern situation for us
// Set our geometrical parent
mSource = aSource;
// Set the geometrical parent of the pattern we are rendering
patternFrame->mSource = aSource;
// Delay checking mPaintLoopFlag until here so we can give back a clear
// surface if there's a loop
if (!mPaintLoopFlag) {
mPaintLoopFlag = PR_TRUE;
if (!patternFrame->mPaintLoopFlag) {
patternFrame->mPaintLoopFlag = PR_TRUE;
for (nsIFrame* kid = firstKid; kid;
kid = kid->GetNextSibling()) {
nsSVGUtils::PaintFrameWithEffects(&tmpState, nsnull, kid);
}
mPaintLoopFlag = PR_FALSE;
patternFrame->mPaintLoopFlag = PR_FALSE;
}
mSource = nsnull;
patternFrame->mSource = nsnull;
if (aGraphicOpacity != 1.0f) {
tmpContext->PopGroupToSource();