make inline version of premultiply, to speed up gradient creation.
We could speed-up again if we...
- respected kDither and only built 1/2 of the table for non-dither requests
- output simple params to the gpu rather than always a texture
- detected that we have no alpha, and then can skip premul per-entry
git-svn-id: http://skia.googlecode.com/svn/trunk@1772 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkColor.cpp b/src/core/SkColor.cpp
index 4256179..023f195 100644
--- a/src/core/SkColor.cpp
+++ b/src/core/SkColor.cpp
@@ -19,31 +19,15 @@
#include "SkColorPriv.h"
SkPMColor SkPreMultiplyARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
- if (a != 255) {
-#if 0
- unsigned scale = SkAlpha255To256(a);
- r = SkAlphaMul(r, scale);
- g = SkAlphaMul(g, scale);
- b = SkAlphaMul(b, scale);
-#else
- r = SkMulDiv255Round(r, a);
- g = SkMulDiv255Round(g, a);
- b = SkMulDiv255Round(b, a);
-#endif
- }
- return SkPackARGB32(a, r, g, b);
+ return SkPremultiplyARGBInline(a, r, g, b);
}
SkPMColor SkPreMultiplyColor(SkColor c) {
- unsigned a = SkColorGetA(c);
- unsigned r = SkColorGetR(c);
- unsigned g = SkColorGetG(c);
- unsigned b = SkColorGetB(c);
-
- return SkPreMultiplyARGB(a, r, g, b);
+ return SkPremultiplyARGBInline(SkColorGetA(c), SkColorGetR(c),
+ SkColorGetG(c), SkColorGetB(c));
}
-//////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
static inline SkScalar ByteToScalar(U8CPU x) {
SkASSERT(x <= 255);