Bug 711653: In SVG lighting calculations, when input surface is 1px wide, use a normal vector that points straight out of the page. r=dholbert
authorRobert Longson <longsonr@gmail.com>
Mon, 13 Feb 2012 14:04:19 -0800
changeset 89629 f28f16d674c95fdbe2ecb1f8dcff61ded1dbe404
parent 89628 7d542384106f630dfbe78c57ed1f3bca7fd3eb10
child 89630 01b07f54ec5085368ee00b892eabbcf05a9b8f29
push id783
push userlsblakk@mozilla.com
push dateTue, 24 Apr 2012 17:33:42 +0000
treeherdermozilla-beta@11faed19f136 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs711653
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 711653: In SVG lighting calculations, when input surface is 1px wide, use a normal vector that points straight out of the page. r=dholbert
content/svg/content/src/nsSVGFilters.cpp
--- a/content/svg/content/src/nsSVGFilters.cpp
+++ b/content/svg/content/src/nsSVGFilters.cpp
@@ -4952,16 +4952,25 @@ GenerateNormal(float *N, const PRUint8 *
     { { 2.0 / 3.0, 1.0 / 3.0, 2.0 / 3.0 },
       { 1.0 / 2.0, 1.0 / 4.0, 1.0 / 2.0 },
       { 2.0 / 3.0, 1.0 / 3.0, 2.0 / 3.0 } };
   static const float FACTORy[3][3] =
     { { 2.0 / 3.0, 1.0 / 2.0, 2.0 / 3.0 },
       { 1.0 / 3.0, 1.0 / 4.0, 1.0 / 3.0 },
       { 2.0 / 3.0, 1.0 / 2.0, 2.0 / 3.0 } };
 
+  // degenerate cases
+  if (surfaceWidth == 1 || surfaceHeight == 1) {
+    // just return a unit vector pointing towards the viewer
+    N[0] = 0;
+    N[1] = 0;
+    N[2] = 255;
+    return;
+  }
+
   PRInt8 xflag, yflag;
   if (x == 0) {
     xflag = 0;
   } else if (x == surfaceWidth - 1) {
     xflag = 2;
   } else {
     xflag = 1;
   }