Commit b8fdd5b2 authored by Robert Longson's avatar Robert Longson
Browse files

Bug 1824025 - transformed patterns may be blurry r=jfkthame

parent 3c966c23
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
<svg width="800" height="500" xmlns="http://www.w3.org/2000/svg">

  <text x="25" y="25">Both patterns should render without blurriness</text>

  <pattern id="pattern1" viewBox="0 0 100 20" width="100" height="20"
           patternUnits="userSpaceOnUse">
    <circle r="2" cx="10" cy="10" fill="green"/>
    <circle r="4" cx="30" cy="10" fill="green"/>
    <circle r="6" cx="50" cy="10" fill="green"/>
    <circle r="8" cx="70" cy="10" fill="green"/>
    <circle r="10" cx="90" cy="10" fill="green"/>
  </pattern>

  <circle r="150" cx="200" cy="200" stroke="gray" fill="none"/>
  <circle r="150" cx="200" cy="200" fill="url(#pattern1)"/>

  <circle r="150" cx="600" cy="200" stroke="gray" fill="none"/>
  <circle r="150" cx="600" cy="200" fill="url(#pattern1)"/>

</svg>
+29 −0
Original line number Diff line number Diff line
<svg width="800" height="500" xmlns="http://www.w3.org/2000/svg">

  <text x="25" y="25">Both patterns should render without blurriness</text>

  <pattern id="pattern1" viewBox="0 0 100 20" width="100" height="20"
           patternUnits="userSpaceOnUse">
    <circle r="2" cx="10" cy="10" fill="green"/>
    <circle r="4" cx="30" cy="10" fill="green"/>
    <circle r="6" cx="50" cy="10" fill="green"/>
    <circle r="8" cx="70" cy="10" fill="green"/>
    <circle r="10" cx="90" cy="10" fill="green"/>
  </pattern>

  <circle r="150" cx="200" cy="200" stroke="gray" fill="none"/>
  <circle r="150" cx="200" cy="200" fill="url(#pattern1)"/>

  <pattern id="pattern2" viewBox="0 0 20 100" width="20" height="100"
           patternUnits="userSpaceOnUse" patternTransform="rotate(270)">
    <circle r="2" cx="10" cy="10" fill="green"/>
    <circle r="4" cx="10" cy="30" fill="green"/>
    <circle r="6" cx="10" cy="50" fill="green"/>
    <circle r="8" cx="10" cy="70" fill="green"/>
    <circle r="10" cx="10" cy="90" fill="green"/>
  </pattern>

  <circle r="150" cx="600" cy="200" stroke="gray" fill="none"/>
  <circle r="150" cx="600" cy="200" fill="url(#pattern2)"/>

</svg>
+5 −4
Original line number Diff line number Diff line
@@ -394,11 +394,12 @@ fuzzy(0-128,0-100) == pattern-big-image.html pattern-big-image-ref.html
fuzzy(0-1,0-5) == pattern-live-01a.svg pattern-live-01-ref.svg
fuzzy(0-1,0-5) == pattern-live-01b.svg pattern-live-01-ref.svg
fuzzy(0-1,0-5) == pattern-live-01c.svg pattern-live-01-ref.svg
fuzzy(0-1,0-5) == pattern-scale-01a.svg pattern-scale-01-ref.svg
== pattern-scale-01a.svg pattern-scale-01-ref.svg
== pattern-scale-01b.svg pattern-scale-01-ref.svg
fuzzy(0-3,0-5) == pattern-scale-01c.svg pattern-scale-01-ref.svg
fuzzy(0-2,0-227) == pattern-transform-presence-01.svg pattern-transform-presence-01-ref.svg
fuzzy(0-72,0-1255) == pattern-transformed-01.svg pattern-transformed-01-ref.svg
== pattern-scale-01c.svg pattern-scale-01-ref.svg
== pattern-transform-presence-01.svg pattern-transform-presence-01-ref.svg
fuzzy(0-72,0-865) == pattern-transformed-01.svg pattern-transformed-01-ref.svg
fuzzy(0-17,0-2511) fuzzy-if(Android,0-18,0-6414) == pattern-transformed-02.svg pattern-transformed-02-ref.svg

== polygon-01.svg polygon-01-ref.svg
== polygon-marker-01.svg pass.svg
+4 −6
Original line number Diff line number Diff line
@@ -304,12 +304,11 @@ already_AddRefed<SourceSurface> SVGPatternFrame::PaintPattern(

  // Now that we have all of the necessary geometries, we can
  // create our surface.
  gfxRect transformedBBox =
      ThebesRect(patternTransform.TransformBounds(ToRect(bbox)));
  gfxSize scaledSize = bbox.Size() * MaxExpansion(patternTransform);

  bool resultOverflows;
  IntSize surfaceSize =
      SVGUtils::ConvertToSurfaceSize(transformedBBox.Size(), &resultOverflows);
      SVGUtils::ConvertToSurfaceSize(scaledSize, &resultOverflows);

  // 0 disables rendering, < 0 is an error
  if (surfaceSize.width <= 0 || surfaceSize.height <= 0) {
@@ -322,9 +321,8 @@ already_AddRefed<SourceSurface> SVGPatternFrame::PaintPattern(
  if (resultOverflows || patternWidth != surfaceSize.width ||
      patternHeight != surfaceSize.height) {
    // scale drawing to pattern surface size
    gfxMatrix tempTM = gfxMatrix(surfaceSize.width / patternWidth, 0.0, 0.0,
                                 surfaceSize.height / patternHeight, 0.0, 0.0);
    patternWithChildren->mCTM->PreMultiply(tempTM);
    patternWithChildren->mCTM->PreScale(surfaceSize.width / patternWidth,
                                        surfaceSize.height / patternHeight);

    // and rescale pattern to compensate
    patternMatrix->PreScale(patternWidth / surfaceSize.width,