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 a=lsblakk
authorRobert Longson <longsonr@gmail.com>
Mon, 13 Feb 2012 14:04:19 -0800
changeset 35272 57f74ecff4839969caf5d1488f71c015a29eef15
parent 35267 bb46b673486c01b10753ccdf1900088fa1f5b370
child 35273 9b893007fa4ef23fb90301193122a9ed6ea55877
push id2027
push userdholbert@mozilla.com
push dateWed, 22 Feb 2012 22:03:42 +0000
reviewersdholbert, lsblakk
bugs711653
milestone1.9.2.28pre
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 a=lsblakk
content/svg/content/src/nsSVGFilters.cpp
--- a/content/svg/content/src/nsSVGFilters.cpp
+++ b/content/svg/content/src/nsSVGFilters.cpp
@@ -4692,16 +4692,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;
   }