Upstream mulDiv255Ceil() from WebKit to the skia repository.

(Patch by Noel Gordon (noel.gordon@gmail.com))

Review URL:  http://codereview.appspot.com/3466042



git-svn-id: http://skia.googlecode.com/svn/trunk@632 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkMath.h b/include/core/SkMath.h
index e0f2361..22ebd60 100644
--- a/include/core/SkMath.h
+++ b/include/core/SkMath.h
@@ -213,6 +213,16 @@
     return (prod + (prod >> 8)) >> 8;
 }
 
+/** Return (a*b)/255, taking the ceiling of any fractional bits. Only valid if
+    both a and b are 0..255. The expected result equals (a * b + 254) / 255.
+ */
+static inline U8CPU SkMulDiv255Ceiling(U8CPU a, U8CPU b) {
+    SkASSERT((uint8_t)a == a);
+    SkASSERT((uint8_t)b == b);
+    unsigned prod = SkMulS16(a, b) + 255;
+    return (prod + (prod >> 8)) >> 8;
+}
+
 /** Return a*b/((1 << shift) - 1), rounding any fractional bits.
     Only valid if a and b are unsigned and <= 32767 and shift is > 0 and <= 8
 */