tried switching 1bit compare code to 64 bit registers
[swftools.git] / lib / pdf / BitmapOutputDev.cc
index ccf1da9..d0129d2 100644 (file)
@@ -440,6 +440,16 @@ static void clearBooleanBitmap(SplashBitmap*btm)
     }
 }
 
+long long unsigned int compare64(long long unsigned int*data1, long long unsigned int*data2, int len)
+{
+    long long unsigned int c;
+    int t;
+    for(t=0;t<len;t++) {
+        c |= data1[t]&data2[t];
+    }
+    return c;
+}
+
 GBool BitmapOutputDev::intersection()
 {
     SplashBitmap*boolpoly = boolpolybitmap;
@@ -457,17 +467,18 @@ GBool BitmapOutputDev::intersection()
        
        int t;
        int len = height*width8;
-       unsigned int c=0;
-       if(len & (sizeof(unsigned int)-1)) {
-           Guchar c2=0;
-           for(t=0;t<len;t++) {
-               c2 |= polypixels[t]&textpixels[t];
-           }
-           c = c2;
-       } else {
-           len /= sizeof(unsigned int);
-           for(t=0;t<len;t++) {
-               c |= (((unsigned int*)polypixels)[t]) & (((unsigned int*)textpixels)[t]);
+       unsigned long long int c=0;
+        assert(sizeof(unsigned long long int)==8);
+       {
+            if((polypixels&7) || (textpixels&7)) {
+                msg("<warning> Non-optimal alignment");
+            }
+            int l2 = len;
+           len /= sizeof(unsigned long long int);
+            c = compare64((unsigned long long int*)polypixels, (unsigned long long int*)textpixels, len);
+            int l1 = len*sizeof(unsigned long long int);
+           for(t=l1;t<l2;t++) {
+               c |= (unsigned long long int)(polypixels[t]&textpixels[t]);
            }
        }
        if(c)
@@ -552,6 +563,14 @@ void BitmapOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, do
 void BitmapOutputDev::endPage()
 {
     msg("<verbose> endPage (BitmapOutputDev)");
+
+    /* notice: we're not fully done yet with this page- there might still be 
+       a few calls to drawLink() yet to come */
+}
+void BitmapOutputDev::finishPage()
+{
+    msg("<verbose> finishPage (BitmapOutputDev)");
+    gfxdev->endPage();
    
     if(layerstate == STATE_BITMAP_IS_ABOVE) {
        this->flushText();
@@ -568,7 +587,6 @@ void BitmapOutputDev::endPage()
     rgbdev->endPage();
     clip0dev->endPage();
     clip1dev->endPage();
-    gfxdev->endPage();
 }
 
 GBool BitmapOutputDev::upsideDown()
@@ -1017,7 +1035,6 @@ void BitmapOutputDev::clip(GfxState *state)
 }
 void BitmapOutputDev::eoClip(GfxState *state)
 {
-    return;
     msg("<debug> eoClip");
     boolpolydev->eoClip(state);
     booltextdev->eoClip(state);
@@ -1269,8 +1286,17 @@ void BitmapOutputDev::beginTransparencyGroup(GfxState *state, double *bbox,
                                    GBool forSoftMask)
 {
     msg("<debug> beginTransparencyGroup");
+#if (xpdfMajorVersion*10000 + xpdfMinorVersion*100 + xpdfUpdateVersion) < 30207
+    GfxState*state1 = state->copy();
+    GfxState*state2 = state->copy();
+    state1->setPath(0);
+    state1->setPath(state->getPath()->copy());
+    state2->setPath(0);
+    state2->setPath(state->getPath()->copy());
+#else
     GfxState*state1 = state->copy(gTrue);
     GfxState*state2 = state->copy(gTrue);
+#endif
     boolpolydev->beginTransparencyGroup(state1, bbox, blendingColorSpace, isolated, knockout, forSoftMask);
     rgbdev->beginTransparencyGroup(state2, bbox, blendingColorSpace, isolated, knockout, forSoftMask);
     clip1dev->beginTransparencyGroup(state, bbox, blendingColorSpace, isolated, knockout, forSoftMask);
@@ -1280,8 +1306,17 @@ void BitmapOutputDev::beginTransparencyGroup(GfxState *state, double *bbox,
 void BitmapOutputDev::endTransparencyGroup(GfxState *state)
 {
     msg("<debug> endTransparencyGroup");
+#if (xpdfMajorVersion*10000 + xpdfMinorVersion*100 + xpdfUpdateVersion) < 30207
+    GfxState*state1 = state->copy();
+    GfxState*state2 = state->copy();
+    state1->setPath(0);
+    state1->setPath(state->getPath()->copy());
+    state2->setPath(0);
+    state2->setPath(state->getPath()->copy());
+#else
     GfxState*state1 = state->copy(gTrue);
     GfxState*state2 = state->copy(gTrue);
+#endif
     boolpolydev->endTransparencyGroup(state1);
     checkNewBitmap();
     rgbdev->endTransparencyGroup(state2);