diff options
author | 2009-07-03 12:54:24 +0000 | |
---|---|---|
committer | 2009-07-03 12:54:24 +0000 | |
commit | da94699149a40a90731425766d3b994e34c5ba26 (patch) | |
tree | 833db92481cb7021ca83c86ebef0afec46e1d3e1 /src/core/SkXfermode.cpp | |
parent | 8433b5db1a0f94cd92d2606817d5374ab899b87a (diff) |
Optimize some alpha blending modes.
- Inline the component calculation helpers.
- Reorder the computation in plus_modeproc.
This doubles the performance of plus_modeproc.
Review URL: http://codereview.appspot.com/88084
git-svn-id: http://skia.googlecode.com/svn/trunk@250 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkXfermode.cpp')
-rw-r--r-- | src/core/SkXfermode.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp index ec42e43810..8d1531a0a0 100644 --- a/src/core/SkXfermode.cpp +++ b/src/core/SkXfermode.cpp @@ -45,7 +45,7 @@ static U8CPU mulmuldiv255round(U8CPU a, U8CPU b, U8CPU c, U8CPU d) { } #endif -static unsigned saturated_add(unsigned a, unsigned b) { +static inline unsigned saturated_add(unsigned a, unsigned b) { SkASSERT(a <= 255); SkASSERT(b <= 255); unsigned sum = a + b; @@ -55,7 +55,7 @@ static unsigned saturated_add(unsigned a, unsigned b) { return sum; } -static int clamp_signed_byte(int n) { +static inline int clamp_signed_byte(int n) { if (n < 0) { n = 0; } else if (n > 255) { @@ -64,7 +64,7 @@ static int clamp_signed_byte(int n) { return n; } -static int clamp_div255round(int prod) { +static inline int clamp_div255round(int prod) { if (prod <= 0) { return 0; } else if (prod >= 255*255) { @@ -74,7 +74,7 @@ static int clamp_div255round(int prod) { } } -static int clamp_max(int value, int max) { +static inline int clamp_max(int value, int max) { if (value > max) { value = max; } @@ -470,10 +470,10 @@ static SkPMColor xor_modeproc(SkPMColor src, SkPMColor dst) { // kPlus_Mode static SkPMColor plus_modeproc(SkPMColor src, SkPMColor dst) { - unsigned a = saturated_add(SkGetPackedA32(src), SkGetPackedA32(dst)); - unsigned r = saturated_add(SkGetPackedR32(src), SkGetPackedR32(dst)); - unsigned g = saturated_add(SkGetPackedG32(src), SkGetPackedG32(dst)); unsigned b = saturated_add(SkGetPackedB32(src), SkGetPackedB32(dst)); + unsigned g = saturated_add(SkGetPackedG32(src), SkGetPackedG32(dst)); + unsigned r = saturated_add(SkGetPackedR32(src), SkGetPackedR32(dst)); + unsigned a = saturated_add(SkGetPackedA32(src), SkGetPackedA32(dst)); return SkPackARGB32(a, r, g, b); } |