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

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


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

New commits:
commit 7cbe3d1521aea8b484efb8663e75684e05b6fb61
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 562c7cc..4f2419f 100644
--- a/splash/Splash.cc
+++ b/splash/Splash.cc
@@ -3113,10 +3113,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;
       }
     }
@@ -3130,10 +3139,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 f323e5e4cdcc20075ee7c722f7adc088c0772249
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