diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2010-11-22 14:16:22 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2010-11-22 14:16:22 +0000 |
| commit | 61f6305edfde67e49372ee7cd2839539a62397a5 (patch) | |
| tree | 00f82450014030924e6b944afe088ead26821000 /src | |
| parent | Fix Cairo export of masked objects. (diff) | |
| download | inkscape-61f6305edfde67e49372ee7cd2839539a62397a5.tar.gz inkscape-61f6305edfde67e49372ee7cd2839539a62397a5.zip | |
Fix luminance to alpha calculation in masks.
(bzr r9914)
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/nr-arena-item.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/display/nr-arena-item.cpp b/src/display/nr-arena-item.cpp index 9b3a6214c..5598efa32 100644 --- a/src/display/nr-arena-item.cpp +++ b/src/display/nr-arena-item.cpp @@ -514,11 +514,12 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area d = NR_PIXBLOCK_PX (&mpb) + (y - carea.y0) * mpb.rs; for (x = carea.x0; x < carea.x1; x++) { + // See below for calculation unsigned int m; - m = NR_PREMUL_112 (s[0] + s[1] + s[2], s[3]); - d[0] = - FAST_DIV_ROUND < 3 * 255 * 255 > - (NR_PREMUL_123 (d[0], m)); + m = NR_PREMUL_112 ( (NR_PREMUL_112 (s[0], 54) + + NR_PREMUL_112 (s[1], 183) + + NR_PREMUL_112 (s[2], 19) ) >> 8, s[3]); + d[0] = FAST_DIV_ROUND < 255 * 255 > ( NR_PREMUL_123 (d[0], m)); s += 4; d += 1; } @@ -533,8 +534,17 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area carea.y0) * mpb.rs; for (x = carea.x0; x < carea.x1; x++) { unsigned int m; - m = NR_PREMUL_112 (s[0] + s[1] + s[2], s[3]); - d[0] = FAST_DIV_ROUND < 3 * 255 > (m); + // m = NR_PREMUL_112 (s[0] + s[1] + s[2], s[3]); + // d[0] = FAST_DIV_ROUND < 3 * 255 > (m); + // Must use luminance to alpha from feColorMatrix. + // This is an approximation, optimized(?) for speed. + // 0.2125 * 256 = 54.4000 + // 0.7154 * 256 = 183.1424 + // 0.0721 * 256 = 18.4576 + m = NR_PREMUL_112 ( (NR_PREMUL_112 (s[0], 54) + + NR_PREMUL_112 (s[1], 183) + + NR_PREMUL_112 (s[2], 19) ) >> 8, s[3]); + d[0] = FAST_DIV_ROUND < 255 > (m); s += 4; d += 1; } |
