Bug 697057 - Patterns are blurred when the element is scaled. r=dholbert

--HG--
rename : layout/reftests/svg/pattern-scale-01.svg => layout/reftests/svg/pattern-scale-01a.svg
This commit is contained in:
Robert Longson 2011-10-27 09:51:46 +01:00
Родитель 903c1e295e
Коммит 1849aca068
5 изменённых файлов: 38 добавлений и 16 удалений

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

До

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

После

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

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

@ -0,0 +1,15 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<svg xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="pattern" width="1" height="1" patternUnits="userSpaceOnUse">
<circle cx="0.5" cy="0.5" r="0.5" fill="lime" />
</pattern>
</defs>
<g transform="scale(200)">
<rect width="1" height="1" fill="url(#pattern)" />
</g>
<circle cx="100" cy="100" r="100" fill="none" stroke="lime" stroke-width="2" shape-rendering="crispEdges" />
</svg>

После

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

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

@ -180,7 +180,8 @@ random-if(gtk2Widget) == objectBoundingBox-and-fePointLight-02.svg objectBoundin
== pattern-live-01a.svg pattern-live-01-ref.svg == pattern-live-01a.svg pattern-live-01-ref.svg
== pattern-live-01b.svg pattern-live-01-ref.svg == pattern-live-01b.svg pattern-live-01-ref.svg
== pattern-live-01c.svg pattern-live-01-ref.svg == pattern-live-01c.svg pattern-live-01-ref.svg
== pattern-scale-01.svg pattern-scale-01-ref.svg == pattern-scale-01a.svg pattern-scale-01-ref.svg
== pattern-scale-01b.svg pattern-scale-01-ref.svg
== pattern-transform-presence-01.svg pattern-transform-presence-01-ref.svg == pattern-transform-presence-01.svg pattern-transform-presence-01-ref.svg
== polygon-marker-01.svg pass.svg == polygon-marker-01.svg pass.svg
== polygon-points-negative-01.svg pass.svg == polygon-points-negative-01.svg pass.svg

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

@ -250,20 +250,24 @@ nsSVGPatternFrame::PaintPattern(gfxASurface** surface,
// box for the pattern tile. // box for the pattern tile.
gfxRect bbox = GetPatternRect(callerBBox, callerCTM, aSource); gfxRect bbox = GetPatternRect(callerBBox, callerCTM, aSource);
// Get the pattern transform
gfxMatrix patternTransform = GetPatternTransform();
// Get the transformation matrix that we will hand to the renderer's pattern // Get the transformation matrix that we will hand to the renderer's pattern
// routine. // routine.
*patternMatrix = GetPatternMatrix(bbox, callerBBox, callerCTM); *patternMatrix = GetPatternMatrix(patternTransform,
bbox, callerBBox, callerCTM);
// Now that we have all of the necessary geometries, we can // Now that we have all of the necessary geometries, we can
// create our surface. // create our surface.
float patternWidth = bbox.Width(); gfxFloat patternWidth = bbox.Width();
float patternHeight = bbox.Height(); gfxFloat patternHeight = bbox.Height();
bool resultOverflows; bool resultOverflows;
gfxIntSize surfaceSize = gfxIntSize surfaceSize =
nsSVGUtils::ConvertToSurfaceSize( nsSVGUtils::ConvertToSurfaceSize(
gfxSize(patternWidth * fabs(patternMatrix->xx), gfxSize(patternWidth * fabs(patternTransform.xx),
patternHeight * fabs(patternMatrix->yy)), patternHeight * fabs(patternTransform.yy)),
&resultOverflows); &resultOverflows);
// 0 disables rendering, < 0 is an error // 0 disables rendering, < 0 is an error
@ -607,17 +611,17 @@ nsSVGPatternFrame::ConstructCTM(const gfxRect &callerBBox,
return tm * tCTM; return tm * tCTM;
} }
// Given the matrix for the pattern element's own transform, this returns a
// combined matrix including the transforms applicable to its target.
gfxMatrix gfxMatrix
nsSVGPatternFrame::GetPatternMatrix(const gfxRect &bbox, nsSVGPatternFrame::GetPatternMatrix(const gfxMatrix &patternTransform,
const gfxRect &bbox,
const gfxRect &callerBBox, const gfxRect &callerBBox,
const gfxMatrix &callerCTM) const gfxMatrix &callerCTM)
{ {
// Get the pattern transform
gfxMatrix patternTransform = GetPatternTransform();
// We really want the pattern matrix to handle translations // We really want the pattern matrix to handle translations
float minx = bbox.X(); gfxFloat minx = bbox.X();
float miny = bbox.Y(); gfxFloat miny = bbox.Y();
PRUint16 type = GetEnumValue(nsSVGPatternElement::PATTERNCONTENTUNITS); PRUint16 type = GetEnumValue(nsSVGPatternElement::PATTERNCONTENTUNITS);
if (type == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { if (type == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
@ -626,10 +630,11 @@ nsSVGPatternFrame::GetPatternMatrix(const gfxRect &bbox,
} }
float scale = 1.0f / nsSVGUtils::MaxExpansion(callerCTM); float scale = 1.0f / nsSVGUtils::MaxExpansion(callerCTM);
patternTransform.Scale(scale, scale); gfxMatrix patternMatrix = patternTransform;
patternTransform.Translate(gfxPoint(minx, miny)); patternMatrix.Scale(scale, scale);
patternMatrix.Translate(gfxPoint(minx, miny));
return patternTransform; return patternMatrix;
} }
nsresult nsresult

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

@ -147,7 +147,8 @@ protected:
gfxRect GetPatternRect(const gfxRect &bbox, gfxRect GetPatternRect(const gfxRect &bbox,
const gfxMatrix &callerCTM, const gfxMatrix &callerCTM,
nsIFrame *aTarget); nsIFrame *aTarget);
gfxMatrix GetPatternMatrix(const gfxRect &bbox, gfxMatrix GetPatternMatrix(const gfxMatrix &patternTransform,
const gfxRect &bbox,
const gfxRect &callerBBox, const gfxRect &callerBBox,
const gfxMatrix &callerCTM); const gfxMatrix &callerCTM);
gfxMatrix ConstructCTM(const gfxRect &callerBBox, gfxMatrix ConstructCTM(const gfxRect &callerBBox,