splash/Splash.cc | 57 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 18 deletions(-)
New commits: commit ffb0daefda688564c1456f4b8b3f5a715d228cdc Author: Albert Astals Cid <[email protected]> Date: Wed May 23 19:06:51 2018 +0200 Apply previous optimization also to Splash::pipeRunAARGB8 diff --git a/splash/Splash.cc b/splash/Splash.cc index 643e8190..7a772144 100644 --- a/splash/Splash.cc +++ b/splash/Splash.cc @@ -1078,25 +1078,35 @@ void Splash::pipeRunAARGB8(SplashPipe *pipe) { SplashColor cDest; Guchar cResult0, cResult1, cResult2; - //----- read destination pixel - cDest[0] = pipe->destColorPtr[0]; - cDest[1] = pipe->destColorPtr[1]; - cDest[2] = pipe->destColorPtr[2]; + //----- read destination alpha aDest = *pipe->destAlphaPtr; //----- source alpha aSrc = div255(pipe->aInput * pipe->shape); - //----- result alpha and non-isolated group element correction - aResult = aSrc + aDest - div255(aSrc * aDest); - alpha2 = aResult; - //----- result color - if (alpha2 == 0) { + if (aSrc == 255) { + cResult0 = state->rgbTransferR[pipe->cSrc[0]]; + cResult1 = state->rgbTransferG[pipe->cSrc[1]]; + cResult2 = state->rgbTransferB[pipe->cSrc[2]]; + aResult = 255; + + } else if (aSrc == 0 && aDest == 0) { cResult0 = 0; cResult1 = 0; cResult2 = 0; + aResult = 0; + } else { + //----- read destination pixel + cDest[0] = pipe->destColorPtr[0]; + cDest[1] = pipe->destColorPtr[1]; + cDest[2] = pipe->destColorPtr[2]; + + //----- result alpha and non-isolated group element correction + aResult = aSrc + aDest - div255(aSrc * aDest); + alpha2 = aResult; + cResult0 = state->rgbTransferR[(Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * pipe->cSrc[0]) / alpha2)]; cResult1 = state->rgbTransferG[(Guchar)(((alpha2 - aSrc) * cDest[1] + commit f47936af75088c55a19fe6b1a67128fcc3f57b08 Author: Stefan Brüns <[email protected]> Date: Wed May 23 19:05:50 2018 +0200 Small optimization for AAXRGB8 pipes Skip some computations if both src and dest alpha are zero, or if src is fully opaque. For common cases (majority of pixels fully opaque) like in fdo#81211, this reduces execution time of pipeRunAAXBGR8 by 50% (-20% total execution time). diff --git a/splash/Splash.cc b/splash/Splash.cc index 0ee71077..643e8190 100644 --- a/splash/Splash.cc +++ b/splash/Splash.cc @@ -19,6 +19,7 @@ // Copyright (C) 2012 Markus Trippelsdorf <[email protected]> // Copyright (C) 2012, 2017 Adrian Johnson <[email protected]> // Copyright (C) 2012 Matthias Kramm <[email protected]> +// Copyright (C) 2018 Stefan Brüns <[email protected]> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -1123,25 +1124,35 @@ void Splash::pipeRunAAXBGR8(SplashPipe *pipe) { SplashColor cDest; Guchar cResult0, cResult1, cResult2; - //----- read destination pixel - cDest[0] = pipe->destColorPtr[2]; - cDest[1] = pipe->destColorPtr[1]; - cDest[2] = pipe->destColorPtr[0]; + //----- read destination alpha aDest = *pipe->destAlphaPtr; //----- source alpha aSrc = div255(pipe->aInput * pipe->shape); - //----- result alpha and non-isolated group element correction - aResult = aSrc + aDest - div255(aSrc * aDest); - alpha2 = aResult; - //----- result color - if (alpha2 == 0) { + if (aSrc == 255) { + cResult0 = state->rgbTransferR[pipe->cSrc[0]]; + cResult1 = state->rgbTransferG[pipe->cSrc[1]]; + cResult2 = state->rgbTransferB[pipe->cSrc[2]]; + aResult = 255; + + } else if (aSrc == 0 && aDest == 0) { cResult0 = 0; cResult1 = 0; cResult2 = 0; + aResult = 0; + } else { + //----- read destination color + cDest[0] = pipe->destColorPtr[2]; + cDest[1] = pipe->destColorPtr[1]; + cDest[2] = pipe->destColorPtr[0]; + + //----- result alpha and non-isolated group element correction + aResult = aSrc + aDest - div255(aSrc * aDest); + alpha2 = aResult; + cResult0 = state->rgbTransferR[(Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * pipe->cSrc[0]) / alpha2)]; cResult1 = state->rgbTransferG[(Guchar)(((alpha2 - aSrc) * cDest[1] + _______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
