diff options
| author | bulia byak <buliabyak@gmail.com> | 2006-06-27 00:31:47 +0000 |
|---|---|---|
| committer | buliabyak <buliabyak@users.sourceforge.net> | 2006-06-27 00:31:47 +0000 |
| commit | 393a9af0a70717faa2a4987be9c2179e68b27e78 (patch) | |
| tree | 65ad69b196f280097676fc7765a5bfdcf13a15b1 /src/libnr | |
| parent | * packaging/macosx/ScriptExec/main.c: (diff) | |
| download | inkscape-393a9af0a70717faa2a4987be9c2179e68b27e78.tar.gz inkscape-393a9af0a70717faa2a4987be9c2179e68b27e78.zip | |
a little optimization by making some macros into inlined functions
(bzr r1302)
Diffstat (limited to 'src/libnr')
| -rw-r--r-- | src/libnr/nr-pixops.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/libnr/nr-pixops.h b/src/libnr/nr-pixops.h index 32fc1e1cd..ba7fbc41a 100644 --- a/src/libnr/nr-pixops.h +++ b/src/libnr/nr-pixops.h @@ -17,20 +17,33 @@ #define NR_RGBA32_A(v) (unsigned char) ((v) & 0xff) #define FAST_DIVIDE_BY_255(v) ((((v) << 8) + (v) + 257) >> 16) -#define NR_PREMUL(c,a) (FAST_DIVIDE_BY_255(((c) * (a) + 127))) -#define NR_PREMUL_SINGLE(c) (FAST_DIVIDE_BY_255((c) + 127)) + #define NR_A7(fa,ba) (65025 - (255 - fa) * (255 - ba)) -#define NR_A7_NORMALIZED(fa,ba) (FAST_DIVIDE_BY_255((65025 - (255 - (fa)) * (255 - (ba))) + 127)) #define NR_COMPOSENNN_A7(fc,fa,bc,ba,a) (((255 - (fa)) * (bc) * (ba) + (fa) * (fc) * 255 + 127) / a) #define NR_COMPOSEPNN_A7(fc,fa,bc,ba,a) (((255 - (fa)) * (bc) * (ba) + (fc) * 65025 + 127) / a) #define NR_COMPOSENNP(fc,fa,bc,ba) (((255 - (fa)) * (bc) * (ba) + (fa) * (fc) * 255 + 32512) / 65025) #define NR_COMPOSEPNP(fc,fa,bc,ba) (((255 - (fa)) * (bc) * (ba) + (fc) * 65025 + 32512) / 65025) +#define INK_COMPOSE(f,a,b) ( ( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) ((b ^ ~f) + b/4 - (b>127? 63 : 0))) * ((guchar) a) ) >>8) +#define NR_PREMUL(c,a) (FAST_DIVIDE_BY_255(((c) * (a) + 127))) +#define NR_PREMUL_SINGLE(c) (FAST_DIVIDE_BY_255((c) + 127)) + +#if 0 + +#define NR_A7_NORMALIZED(fa,ba) (FAST_DIVIDE_BY_255((65025 - (255 - (fa)) * (255 - (ba))) + 127)) #define NR_COMPOSENPP(fc,fa,bc,ba) (FAST_DIVIDE_BY_255((255 - (fa)) * (bc) + (fa) * (fc) + 127)) #define NR_COMPOSEPPP(fc,fa,bc,ba) (FAST_DIVIDE_BY_255((255 - (fa)) * (bc) + (fc) * 255 + 127)) #define NR_COMPOSEP11(fc,fa,bc) (FAST_DIVIDE_BY_255((255 - (fa)) * (bc) + (fc) * 255 + 127)) #define NR_COMPOSEN11(fc,fa,bc) (FAST_DIVIDE_BY_255((255 - (fa)) * (bc) + (fc) * (fa) + 127)) -#define INK_COMPOSE(f,a,b) ( ( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) ((b ^ ~f) + b/4 - (b>127? 63 : 0))) * ((guchar) a) ) >>8) +#else + +inline int NR_A7_NORMALIZED(int fa,int ba) {int temp=(65025 - (255 - (fa)) * (255 - (ba))) + 127; return FAST_DIVIDE_BY_255(temp);} +inline int NR_COMPOSENPP(int fc,int fa,int bc,int ba) {int temp=(255 - (fa)) * (bc) + (fa) * (fc) + 127; return FAST_DIVIDE_BY_255(temp);} +inline int NR_COMPOSEPPP(int fc,int fa,int bc,int ba) {int temp=(255 - (fa)) * (bc) + (fc) * 255 + 127; return FAST_DIVIDE_BY_255(temp);} +inline int NR_COMPOSEP11(int fc,int fa,int bc) {int temp=(255 - (fa)) * (bc) + (fc) * 255 + 127; return FAST_DIVIDE_BY_255(temp);} +inline int NR_COMPOSEN11(int fc,int fa,int bc) {int temp=(255 - (fa)) * (bc) + (fc) * (fa) + 127; return FAST_DIVIDE_BY_255(temp);} + +#endif #endif |
