From e920c0f97739a936d6e02f4cc6a4feb8486f683e Mon Sep 17 00:00:00 2001 From: Jasper van de Gronde Date: Sat, 27 Oct 2012 14:42:19 +0200 Subject: Clamp colour channels in feComposite result to alpha channel, instead of 1, as the channels are premultiplied. (bzr r11835) --- src/display/nr-filter-composite.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/display/nr-filter-composite.cpp b/src/display/nr-filter-composite.cpp index b25ecdf2c..040424cb3 100644 --- a/src/display/nr-filter-composite.cpp +++ b/src/display/nr-filter-composite.cpp @@ -48,10 +48,11 @@ struct ComposeArithmetic { gint32 go = _k1*ga*gb + _k2*ga + _k3*gb + _k4; gint32 bo = _k1*ba*bb + _k2*ba + _k3*bb + _k4; - ao = (pxclamp(ao, 0, 255*255*255) + (255*255/2)) / (255*255); - ro = (pxclamp(ro, 0, 255*255*255) + (255*255/2)) / (255*255); - go = (pxclamp(go, 0, 255*255*255) + (255*255/2)) / (255*255); - bo = (pxclamp(bo, 0, 255*255*255) + (255*255/2)) / (255*255); + ao = pxclamp(ao, 0, 255*255*255); // r, g and b are premultiplied, so should be clamped to the alpha channel + ro = (pxclamp(ro, 0, ao) + (255*255/2)) / (255*255); + go = (pxclamp(go, 0, ao) + (255*255/2)) / (255*255); + bo = (pxclamp(bo, 0, ao) + (255*255/2)) / (255*255); + ao = (ao + (255*255/2)) / (255*255); ASSEMBLE_ARGB32(pxout, ao, ro, go, bo) return pxout; -- cgit v1.2.3