[poppler] 3 commits - poppler/Function.cc poppler/Gfx.cc poppler/PopplerCache.cc poppler/PopplerCache.h

Albert Astals Cid aacid at kemper.freedesktop.org
Wed Jun 10 14:00:03 PDT 2009


 poppler/Function.cc     |   28 ++++++++++++++++++++++++++++
 poppler/Gfx.cc          |   19 +++++++++++++------
 poppler/PopplerCache.cc |   20 ++++++++++++++++++++
 poppler/PopplerCache.h  |   14 ++++++++++++++
 4 files changed, 75 insertions(+), 6 deletions(-)

New commits:
commit 572779f8037763c1e0ee64c47a3dad6df0d3b693
Author: Koji Otani <sho at bbr.jp>
Date:   Wed Jun 10 22:55:26 2009 +0200

    Fix dashed line in page 1 of bug 20011

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index a5c2678..1b6c3e6 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -1906,10 +1906,6 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
   out->updateFillColor(state);
   state->setStrokePattern(NULL);
   out->updateStrokeColor(state);
-  if (!stroke) {
-    state->setLineWidth(0);
-    out->updateLineWidth(state);
-  }
 
   // clip to current path
   if (stroke) {
@@ -1924,6 +1920,8 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
     }
   }
   state->clearPath();
+  state->setLineWidth(0);
+  out->updateLineWidth(state);
 
   // get the clip region, check for empty
   state->getClipBBox(&cxMin, &cyMin, &cxMax, &cyMax);
commit b97591672e0d9c31a3d044fe52e34cc80a491221
Author: Koji Otani <sho at bbr.jp>
Date:   Wed Jun 10 22:54:57 2009 +0200

    Fix "Conditional jump or move depends on uninitialised value"
    
    When stroking with a pattern, set strokeColor with a copy of fillColor.
    This is wrong and the fillColor may be uninitialized.
    See bug 20011

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index afd1d15..a5c2678 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -1824,6 +1824,7 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
 			      GBool stroke, GBool eoFill) {
   GfxPatternColorSpace *patCS;
   GfxColorSpace *cs;
+  GfxColor color;
   GfxPath *savedPath;
   double xMin, yMin, xMax, yMax, x, y, x1, y1;
   double cxMin, cyMin, cxMax, cyMax;
@@ -1886,11 +1887,19 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
     out->updateFillColorSpace(state);
     state->setStrokeColorSpace(cs->copy());
     out->updateStrokeColorSpace(state);
-    state->setStrokeColor(state->getFillColor());
+    if (stroke) {
+	state->setFillColor(state->getStrokeColor());
+    } else {
+	state->setStrokeColor(state->getFillColor());
+    }
   } else {
-    state->setFillColorSpace(new GfxDeviceGrayColorSpace());
+    cs = new GfxDeviceGrayColorSpace();
+    state->setFillColorSpace(cs);
+    cs->getDefaultColor(&color);
+    state->setFillColor(&color);
     out->updateFillColorSpace(state);
     state->setStrokeColorSpace(new GfxDeviceGrayColorSpace());
+    state->setStrokeColor(&color);
     out->updateStrokeColorSpace(state);
   }
   state->setFillPattern(NULL);
commit a92b38836b1e4475d5a7a1b9cb8f3e9429cef275
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Jun 9 22:39:19 2009 +0200

    Correctly duplicate the cache on PostScriptFunction(PostScriptFunction *func)

diff --git a/poppler/Function.cc b/poppler/Function.cc
index 9c53cec..431dc5d 100644
--- a/poppler/Function.cc
+++ b/poppler/Function.cc
@@ -1024,6 +1024,16 @@ class PostScriptFunctionKey : public PopplerCacheKey
   public:
     PostScriptFunctionKey(int sizeA, double *inA, bool copyA)
     {
+      init(sizeA, inA, copyA);
+    }
+    
+    PostScriptFunctionKey(const PostScriptFunctionKey &key)
+    {
+      init(key.size, key.in, key.copied);
+    }
+    
+    void init(int sizeA, double *inA, bool copyA)
+    {
       copied = copyA;
       size = sizeA;
       if (copied) {
@@ -1063,6 +1073,16 @@ class PostScriptFunctionItem : public PopplerCacheItem
   public:
     PostScriptFunctionItem(int sizeA, double *outA)
     {
+      init(sizeA, outA);
+    }
+    
+    PostScriptFunctionItem(const PostScriptFunctionItem &item)
+    {
+      init(item.size, item.out);
+    }
+    
+    void init(int sizeA, double *outA)
+    {
       size = sizeA;
       out = new double[size];
       for (int i = 0; i < size; ++i) out[i] = outA[i];
@@ -1138,6 +1158,14 @@ PostScriptFunction::PostScriptFunction(PostScriptFunction *func) {
   codeString = func->codeString->copy();
   stack = new PSStack();
   memcpy(stack, func->stack, sizeof(PSStack));
+  
+  cache = new PopplerCache(func->cache->size());
+  for (int i = 0; i < func->cache->numberOfItems(); ++i)
+  {
+    PostScriptFunctionKey *key = new PostScriptFunctionKey(*(PostScriptFunctionKey*)func->cache->key(i));
+    PostScriptFunctionItem *item = new PostScriptFunctionItem(*(PostScriptFunctionItem*)func->cache->item(i));
+    cache->put(key, item);
+  }
 }
 
 PostScriptFunction::~PostScriptFunction() {
diff --git a/poppler/PopplerCache.cc b/poppler/PopplerCache.cc
index 10c5f99..b0859aa 100644
--- a/poppler/PopplerCache.cc
+++ b/poppler/PopplerCache.cc
@@ -80,3 +80,23 @@ void PopplerCache::put(PopplerCacheKey *key, PopplerCacheItem *item)
   keys[0] = key;
   items[0] = item;
 }
+
+int PopplerCache::size()
+{
+  return cacheSize;
+}
+
+int PopplerCache::numberOfItems()
+{
+  return lastValidCacheIndex + 1;
+}
+    
+PopplerCacheItem *PopplerCache::item(int index)
+{
+  return items[index];
+}
+    
+PopplerCacheKey *PopplerCache::key(int index)
+{
+  return keys[index];
+}
diff --git a/poppler/PopplerCache.h b/poppler/PopplerCache.h
index 7d72d76..5f22409 100644
--- a/poppler/PopplerCache.h
+++ b/poppler/PopplerCache.h
@@ -36,8 +36,22 @@ class PopplerCache
     
     /* The key and item pointers ownership is taken by the cache */
     void put(PopplerCacheKey *key, PopplerCacheItem *item);
+    
+    /* The max size of the cache */
+    int size();
+    
+    /* The number of items in the cache */
+    int numberOfItems();
+    
+    /* The n-th item in the cache */
+    PopplerCacheItem *item(int index);
+    
+    /* The n-th key in the cache */
+    PopplerCacheKey *key(int index);
   
   private:
+    PopplerCache(const PopplerCache &cache); // not allowed
+  
     PopplerCacheKey **keys;
     PopplerCacheItem **items;
     int lastValidCacheIndex;


More information about the poppler mailing list