From c8475af85654a00cf17754517b54f089a4044ab1 Mon Sep 17 00:00:00 2001 From: Matthias Kramm Date: Fri, 19 Mar 2010 18:33:29 -0700 Subject: [PATCH] made poly2bitmap slightly faster --- lib/pdf/BitmapOutputDev.cc | 59 ++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/lib/pdf/BitmapOutputDev.cc b/lib/pdf/BitmapOutputDev.cc index adc3165..e1cb3d3 100644 --- a/lib/pdf/BitmapOutputDev.cc +++ b/lib/pdf/BitmapOutputDev.cc @@ -454,16 +454,27 @@ static void update_bitmap(SplashBitmap*bitmap, SplashBitmap*update, int x1, int if(!fixBBox(&x1, &y1, &x2, &y2, bitmap->getWidth(), bitmap->getHeight())) return; - Guchar*b = bitmap->getDataPtr() + y1*width8; - Guchar*u = update->getDataPtr() + y1*width8; + Guchar*b = bitmap->getDataPtr() + y1*width8 + x1/8; + Guchar*u = update->getDataPtr() + y1*width8 + x1/8; + int yspan = y2-y1; + int xspan = (x2+7)/8 - x1/8; int size = (y2-y1)*width8; if(overwrite) { - memcpy(b, u, size); + int y; + for(y=0;y drawImageMask streamkind=%d", str->getKind()); - CopyStream*cpystr = 0; - if(inlineImg) { - cpystr = new CopyStream(str, height * ((width + 7) / 8)); - str = cpystr->getStream(); - } + + CopyStream*cpystr = new CopyStream(str, height * ((width + 7) / 8)); + str = cpystr->getStream(); + boolpolydev->drawImageMask(state, ref, str, width, height, invert, inlineImg); gfxbbox_t bbox = getImageBBox(state); checkNewBitmap(bbox.xmin, bbox.ymin, ceil(bbox.xmax), ceil(bbox.ymax)); rgbdev->drawImageMask(state, ref, str, width, height, invert, inlineImg); - if(cpystr) - delete cpystr; + delete cpystr; dbg_newdata("imagemask"); } void BitmapOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, @@ -1629,17 +1638,15 @@ void BitmapOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, int *maskColors, GBool inlineImg) { msg(" drawImage streamkind=%d", str->getKind()); - CopyStream*cpystr = 0; - if(inlineImg) { - cpystr = new CopyStream(str, height * ((width * colorMap->getNumPixelComps() * colorMap->getBits() + 7) / 8)); - str = cpystr->getStream(); - } + + CopyStream*cpystr = new CopyStream(str, height * ((width * colorMap->getNumPixelComps() * colorMap->getBits() + 7) / 8)); + str = cpystr->getStream(); + boolpolydev->drawImage(state, ref, str, width, height, colorMap, maskColors, inlineImg); gfxbbox_t bbox=getImageBBox(state); checkNewBitmap(bbox.xmin, bbox.ymin, ceil(bbox.xmax), ceil(bbox.ymax)); rgbdev->drawImage(state, ref, str, width, height, colorMap, maskColors, inlineImg); - if(cpystr) - delete cpystr; + delete cpystr; dbg_newdata("image"); } void BitmapOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str, @@ -1649,10 +1656,15 @@ void BitmapOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str, GBool maskInvert) { msg(" drawMaskedImage streamkind=%d", str->getKind()); + + CopyStream*cpystr = new CopyStream(str, height * ((width * colorMap->getNumPixelComps() * colorMap->getBits() + 7) / 8)); + str = cpystr->getStream(); + boolpolydev->drawMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskInvert); gfxbbox_t bbox=getImageBBox(state); checkNewBitmap(bbox.xmin, bbox.ymin, ceil(bbox.xmax), ceil(bbox.ymax)); rgbdev->drawMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskInvert); + delete cpystr; dbg_newdata("maskedimage"); } void BitmapOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, @@ -1663,10 +1675,15 @@ void BitmapOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream * GfxImageColorMap *maskColorMap) { msg(" drawSoftMaskedImage %dx%d (%dx%d) streamkind=%d", width, height, maskWidth, maskHeight, str->getKind()); + + CopyStream*cpystr = new CopyStream(str, height * ((width * colorMap->getNumPixelComps() * colorMap->getBits() + 7) / 8)); + str = cpystr->getStream(); + boolpolydev->drawSoftMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskColorMap); gfxbbox_t bbox=getImageBBox(state); checkNewBitmap(bbox.xmin, bbox.ymin, ceil(bbox.xmax), ceil(bbox.ymax)); rgbdev->drawSoftMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskColorMap); + delete cpystr; dbg_newdata("softmaskimage"); } void BitmapOutputDev::drawForm(Ref id) -- 1.7.10.4