[poppler] Branch 'poppler-0.14' - 2 commits - poppler/GfxState.cc splash/Splash.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Thu Jun 17 15:05:39 PDT 2010


 poppler/GfxState.cc |   11 +++++++----
 splash/Splash.cc    |   34 ++++++++++++++++++++++++++--------
 2 files changed, 33 insertions(+), 12 deletions(-)

New commits:
commit fb08e3d0ff34c4d5757b95ae500a882bb1a35b07
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Jun 17 23:01:21 2010 +0100

    Optimize Splash::compositeBackground
    
    Optimization takes into account the two most common cases, the pixel not
    being painted at all (alpha == 0) meaning we just copy the paperColor
    and the pixel being opage meaning we have to do nothing

diff --git a/splash/Splash.cc b/splash/Splash.cc
index bea4706..8af2859 100644
--- a/splash/Splash.cc
+++ b/splash/Splash.cc
@@ -3115,10 +3115,19 @@ void Splash::compositeBackground(SplashColorPtr color) {
       q = &bitmap->alpha[y * bitmap->width];
       for (x = 0; x < bitmap->width; ++x) {
 	alpha = *q++;
-	alpha1 = 255 - alpha;
-	p[0] = div255(alpha1 * color0 + alpha * p[0]);
-	p[1] = div255(alpha1 * color1 + alpha * p[1]);
-	p[2] = div255(alpha1 * color2 + alpha * p[2]);
+	if (alpha == 0)
+	{
+	  p[0] = color0;
+	  p[1] = color1;
+	  p[2] = color2;
+	}
+	else if (alpha != 255)
+	{
+	  alpha1 = 255 - alpha;
+	  p[0] = div255(alpha1 * color0 + alpha * p[0]);
+	  p[1] = div255(alpha1 * color1 + alpha * p[1]);
+	  p[2] = div255(alpha1 * color2 + alpha * p[2]);
+	}
 	p += 3;
       }
     }
@@ -3132,10 +3141,19 @@ void Splash::compositeBackground(SplashColorPtr color) {
       q = &bitmap->alpha[y * bitmap->width];
       for (x = 0; x < bitmap->width; ++x) {
 	alpha = *q++;
-	alpha1 = 255 - alpha;
-	p[0] = div255(alpha1 * color0 + alpha * p[0]);
-	p[1] = div255(alpha1 * color1 + alpha * p[1]);
-	p[2] = div255(alpha1 * color2 + alpha * p[2]);
+	if (alpha == 0)
+	{
+	  p[0] = color0;
+	  p[1] = color1;
+	  p[2] = color2;
+	}
+	else if (alpha != 255)
+	{
+	  alpha1 = 255 - alpha;
+	  p[0] = div255(alpha1 * color0 + alpha * p[0]);
+	  p[1] = div255(alpha1 * color1 + alpha * p[1]);
+	  p[2] = div255(alpha1 * color2 + alpha * p[2]);
+	}
 	p[3] = 255;
 	p += 4;
       }
commit b45d60e9c750b7ee892e2008da48b5893ab0f0d3
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Jun 17 22:59:37 2010 +0100

    Check the objects are num before reading them
    
    Might have caused the kde bug #241995

diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 12e14d6..76cb010 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -1465,13 +1465,16 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, Gfx *gfx) {
   cs = new GfxICCBasedColorSpace(nCompsA, altA, &iccProfileStreamA);
   if (dict->lookup("Range", &obj2)->isArray() &&
       obj2.arrayGetLength() == 2 * nCompsA) {
+    Object obj4;
     for (i = 0; i < nCompsA; ++i) {
       obj2.arrayGet(2*i, &obj3);
-      cs->rangeMin[i] = obj3.getNum();
-      obj3.free();
-      obj2.arrayGet(2*i+1, &obj3);
-      cs->rangeMax[i] = obj3.getNum();
+      obj2.arrayGet(2*i+1, &obj4);
+      if (obj3.isNum() && obj4.isNum()) {
+        cs->rangeMin[i] = obj3.getNum();
+        cs->rangeMax[i] = obj4.getNum();
+      }
       obj3.free();
+      obj4.free();
     }
   }
   obj2.free();


More information about the poppler mailing list