From 0607a5da99d7206625d8537fb28096d755721de3 Mon Sep 17 00:00:00 2001 From: Martin Kretzschmar Date: Sat, 08 Jan 2005 21:59:23 +0000 Subject: pdf/splash/SplashBitmap.cc (SplashBitmap, ~SplashBitmap, writePNMFile): * pdf/splash/Splash.cc (clear, drawPixel, drawSpan, xorSpan, getPixel) (fillGlyph, fillImageMask, drawImage): pdf/splash/SplashBitmap.cc (SplashBitmap, ~SplashBitmap, writePNMFile): pdf/splash/SplashTypes.h: pdf/xpdf/SplashOutputDev (startPage, getColor, imageSrc): implement RGB8 packed mode for Splash. * pdf/xpdf/GDKSplashOutputDev.cc (GDKSplashOutputDev, redraw): use RGB8 packed mode, eliminates the pixbuf data creation loop. --- (limited to 'pdf/xpdf') diff --git a/pdf/xpdf/GDKSplashOutputDev.cc b/pdf/xpdf/GDKSplashOutputDev.cc index 90f8811..ad0040f 100644 --- a/pdf/xpdf/GDKSplashOutputDev.cc +++ b/pdf/xpdf/GDKSplashOutputDev.cc @@ -41,7 +41,7 @@ static SplashColor makeSplashColor(int r, int g, int b) GDKSplashOutputDev::GDKSplashOutputDev(GdkScreen *screen, void (*redrawCbkA)(void *data), void *redrawCbkDataA): - SplashOutputDev(splashModeRGB8, gFalse, makeSplashColor (255,255,255)), + SplashOutputDev(splashModeRGB8Packed, gFalse, makeSplashColor (255,255,255)), incrementalUpdate (1) { redrawCbk = redrawCbkA; @@ -104,55 +104,20 @@ void GDKSplashOutputDev::redraw(int srcX, int srcY, GdkDrawable *drawable, int destX, int destY, int width, int height) { - SplashColorPtr dataPtr; GdkGC *gc; - guchar *gdk_buf; int gdk_rowstride; - int bw, x, y, r, g, b; - gdk_rowstride = width * 3; - - /* better to draw nothing than crash on a huge image */ - gdk_buf = (guchar*) g_try_malloc (height * gdk_rowstride); - if (gdk_buf == NULL) - return; - - bw = getBitmap()->getWidth(); - dataPtr = getBitmap()->getDataPtr(); - - for (y = 0; y < height; ++y) - { - SplashRGB8 *p; - SplashRGB8 rgb; - guchar *gdk_p; - - p = dataPtr.rgb8 + (y + srcY) * bw + srcX; - gdk_p = gdk_buf + y * gdk_rowstride; - for (x = 0; x < width; ++x) - { - rgb = *p++; - r = splashRGB8R(rgb); - g = splashRGB8G(rgb); - b = splashRGB8B(rgb); - - *gdk_p++ = r; - *gdk_p++ = g; - *gdk_p++ = b; - } - } - + gdk_rowstride = getBitmap()->getRowSize(); gc = gdk_gc_new (drawable); gdk_draw_rgb_image (drawable, gc, destX, destY, width, height, GDK_RGB_DITHER_NORMAL, - gdk_buf, + getBitmap()->getDataPtr().rgb8p + srcY * gdk_rowstride + srcX, gdk_rowstride); g_object_unref (gc); - - g_free (gdk_buf); } void GDKSplashOutputDev::drawToPixbuf(GdkPixbuf *pixbuf, int pageNum) { diff --git a/pdf/xpdf/SplashOutputDev.cc b/pdf/xpdf/SplashOutputDev.cc index 0284d82..58da12c 100644 --- a/pdf/xpdf/SplashOutputDev.cc +++ b/pdf/xpdf/SplashOutputDev.cc @@ -276,7 +276,8 @@ void SplashOutputDev::startPage(int pageNum, GfxState *state) { switch (colorMode) { case splashModeMono1: color.mono1 = 0; break; case splashModeMono8: color.mono8 = 0; break; - case splashModeRGB8: color.rgb8 = splashMakeRGB8(0, 0, 0); break; + case splashModeRGB8: + case splashModeRGB8Packed: color.rgb8 = splashMakeRGB8(0, 0, 0); break; case splashModeBGR8Packed: color.bgr8 = splashMakeBGR8(0, 0, 0); break; } splash->setStrokePattern(new SplashSolidColor(color)); @@ -469,6 +470,7 @@ SplashPattern *SplashOutputDev::getColor(double gray, GfxRGB *rgb) { pattern = new SplashSolidColor(color1); break; case splashModeRGB8: + case splashModeRGB8Packed: color1.rgb8 = splashMakeRGB8(soutRound(255 * r), soutRound(255 * g), soutRound(255 * b)); @@ -1201,6 +1203,7 @@ GBool SplashOutputDev::imageSrc(void *data, SplashColor *pixel, pixel->mono8 = soutRound(255 * gray); break; case splashModeRGB8: + case splashModeRGB8Packed: imgData->colorMap->getRGB(pix, &rgb); pixel->rgb8 = splashMakeRGB8(soutRound(255 * rgb.r), soutRound(255 * rgb.g), -- cgit v0.9.1