X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2FBitmapOutputDev.cc;h=d0129d260c63e168d10dd7d0bfaa05955dd763c0;hb=6a4e4086d9fb91474f4d8c7ae20ec2ad205a34d9;hp=c27f87f4933f2dbb15c7a0978d8119e075fff25b;hpb=1f80a93dce1414db2d9b237b6af51527bd3d14bf;p=swftools.git diff --git a/lib/pdf/BitmapOutputDev.cc b/lib/pdf/BitmapOutputDev.cc index c27f87f..d0129d2 100644 --- a/lib/pdf/BitmapOutputDev.cc +++ b/lib/pdf/BitmapOutputDev.cc @@ -307,7 +307,7 @@ static int dbg_btm_counter=1; static const char*STATE_NAME[] = {"parallel", "textabovebitmap", "bitmapabovetext"}; -void BitmapOutputDev::checkNewText(int x1, int y1, int x2, int y2) +void BitmapOutputDev::checkNewText() { /* called once some new text was drawn on booltextdev, and before the same thing is drawn on gfxdev */ @@ -324,7 +324,7 @@ void BitmapOutputDev::checkNewText(int x1, int y1, int x2, int y2) } dbg_btm_counter++; - if(intersection(x1,y1,x2,y2)) { + if(intersection()) { if(layerstate==STATE_PARALLEL) { /* the new text is above the bitmap. So record that fact, and also clear the bitmap buffer, so we can check for @@ -373,7 +373,7 @@ void BitmapOutputDev::checkNewBitmap() } dbg_btm_counter++; - if(intersection(0,0,0,0)) { + if(intersection()) { if(layerstate==STATE_PARALLEL) { msg(" Bitmap is above current text data"); layerstate=STATE_BITMAP_IS_ABOVE; @@ -409,46 +409,14 @@ void BitmapOutputDev::checkNewBitmap() // break; //} -GBool BitmapOutputDev::clip0and1differ(int x1,int y1,int x2,int y2) +GBool BitmapOutputDev::clip0and1differ() { if(clip0bitmap->getMode()==splashModeMono1) { - if(x2<=x1) - return gFalse; - if(x2<0) - return gFalse; - if(x1<0) - x1 = 0; - if(x1>=clip0bitmap->getWidth()) - return gFalse; - if(x2>clip0bitmap->getWidth()) - x2=clip0bitmap->getWidth(); - - if(y2<=y1) - return gFalse; - if(y2<0) - return gFalse; - if(y1<0) - y1 = 0; - if(y1>=clip0bitmap->getHeight()) - return gFalse; - if(y2>clip0bitmap->getHeight()) - y2=clip0bitmap->getHeight(); - SplashBitmap*clip0 = clip0bitmap; SplashBitmap*clip1 = clip1bitmap; - int width8 = (clip0bitmap->getWidth()+7)/8; - int height = clip0bitmap->getHeight(); - int x18 = x1/8; - int x28 = (x2+7)/8; - int y; - - for(y=y1;ygetDataPtr()[width8*y+x18]; - unsigned char*row2 = &clip1bitmap->getDataPtr()[width8*y+x28]; - if(memcmp(row1, row2, x28-x18)) - return gTrue; - } - return gFalse; + int width8 = (clip0->getWidth()+7)/8; + int height = clip0->getHeight(); + return memcmp(clip0->getDataPtr(), clip1->getDataPtr(), width8*height); } else { SplashBitmap*clip0 = clip0bitmap; SplashBitmap*clip1 = clip1bitmap; @@ -482,7 +450,7 @@ long long unsigned int compare64(long long unsigned int*data1, long long unsigne return c; } -GBool BitmapOutputDev::intersection(int x1, int y1, int x2, int y2) +GBool BitmapOutputDev::intersection() { SplashBitmap*boolpoly = boolpolybitmap; SplashBitmap*booltext = booltextbitmap; @@ -493,25 +461,17 @@ GBool BitmapOutputDev::intersection(int x1, int y1, int x2, int y2) Guchar*polypixels = boolpoly->getDataPtr(); Guchar*textpixels = booltext->getDataPtr(); - + int width8 = (width+7)/8; int height = boolpoly->getHeight(); - if(x1|y1|x2|y2) { - if(y1>=0 && y1<=y2 && y2<=height) { - polypixels+=y1*width8; - textpixels+=y1*width8; - height=y2-y1; - } - } - int t; int len = height*width8; unsigned long long int c=0; assert(sizeof(unsigned long long int)==8); { - if(((int)polypixels&7) || ((int)textpixels&7)) { - //msg(" Non-optimal alignment"); + if((polypixels&7) || (textpixels&7)) { + msg(" Non-optimal alignment"); } int l2 = len; len /= sizeof(unsigned long long int); @@ -1104,7 +1064,7 @@ void BitmapOutputDev::endStringOp(GfxState *state) clip0dev->endStringOp(state); clip1dev->endStringOp(state); booltextdev->endStringOp(state); - checkNewText(0,0,0,0); + checkNewText(); gfxdev->endStringOp(state); } void BitmapOutputDev::beginString(GfxState *state, GString *s) @@ -1121,7 +1081,7 @@ void BitmapOutputDev::endString(GfxState *state) clip0dev->endString(state); clip1dev->endString(state); booltextdev->endString(state); - checkNewText(0,0,0,0); + checkNewText(); gfxdev->endString(state); } @@ -1150,27 +1110,11 @@ void BitmapOutputDev::drawChar(GfxState *state, double x, double y, clearClips(); clip0dev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen); clip1dev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen); - - /* calculate the bbox of this character */ - int x1 = (int)x, x2 = (int)x+1, y1 = (int)y, y2 = (int)y+1; - SplashPath*path = clip0dev->getCurrentFont()->getGlyphPath(code); - int t; - for(t=0;tgetLength();t++) { - double xx,yy; - Guchar f; - path->getPoint(t,&xx,&yy,&f); - xx+=x; - yy+=y; - if(xxx2) x2=(int)xx+1; - if(yy>y2) y2=(int)yy+1; - } /* if this character is affected somehow by the various clippings (i.e., it looks different on a device without clipping), then draw it on the bitmap, not as text */ - if(clip0and1differ(x1,y1,x2,y2)) { + if(clip0and1differ()) { msg(" Char %d is affected by clipping", code); boolpolydev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen); checkNewBitmap(); @@ -1185,7 +1129,7 @@ void BitmapOutputDev::drawChar(GfxState *state, double x, double y, /* this char is not at all affected by clipping. Now just dump out the bitmap we're currently working on, if necessary. */ booltextdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen); - checkNewText(x1,y1,x2,y2); + checkNewText(); /* use polygonal output device to do the actual text handling */ gfxdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen); } @@ -1207,8 +1151,7 @@ void BitmapOutputDev::endTextObject(GfxState *state) clip0dev->endTextObject(state); clip1dev->endTextObject(state); booltextdev->endTextObject(state); - /* TODO: do this only if rendermode!=0 */ - checkNewText(0,0,0,0); + checkNewText(); gfxdev->endTextObject(state); }