Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kretzschmar <martink@src.gnome.org>2005-01-08 21:59:23 (GMT)
committer Martin Kretzschmar <martink@src.gnome.org>2005-01-08 21:59:23 (GMT)
commit0607a5da99d7206625d8537fb28096d755721de3 (patch)
tree978330e3a78189ac0586d88026733112820051cb
parentfed5ac607fbe74668f1b74c2022ef56b5ee25d61 (diff)
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.
-rw-r--r--ChangeLog10
-rw-r--r--pdf/splash/Splash.cc84
-rw-r--r--pdf/splash/SplashBitmap.cc25
-rw-r--r--pdf/splash/SplashTypes.h4
-rw-r--r--pdf/xpdf/GDKSplashOutputDev.cc41
-rw-r--r--pdf/xpdf/SplashOutputDev.cc5
6 files changed, 129 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index 995300f..19cbedc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2005-01-08 Martin Kretzschmar <martink@gnome.org>
+ * 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.
+
* shell/ev-print-job.c (ev_print_job_finalize)
(ev_print_job_set_property, ev_print_job_get_property)
(ev_print_job_set_gnome_print_job, ev_print_job_set_document)
diff --git a/pdf/splash/Splash.cc b/pdf/splash/Splash.cc
index f86156d..4094f4a 100644
--- a/pdf/splash/Splash.cc
+++ b/pdf/splash/Splash.cc
@@ -188,6 +188,7 @@ void Splash::clear(SplashColor color) {
SplashMono1P *mono1;
SplashMono8 *mono8;
SplashRGB8 *rgb8;
+ SplashRGB8P *rgb8pline, *rgb8p;
SplashBGR8P *bgr8line, *bgr8;
SplashMono1 data;
int n, i, x, y;
@@ -212,6 +213,19 @@ void Splash::clear(SplashColor color) {
*rgb8 = color.rgb8;
}
break;
+ case splashModeRGB8Packed:
+ rgb8pline = bitmap->data.rgb8p;
+ for (y = 0; y < bitmap->height; ++y) {
+ rgb8p = rgb8pline;
+ for (x = 0; x < bitmap->width; ++x) {
+ rgb8p[0] = splashRGB8R(color.rgb8);
+ rgb8p[1] = splashRGB8G(color.rgb8);
+ rgb8p[2] = splashRGB8B(color.rgb8);
+ rgb8p += 3;
+ }
+ rgb8pline += bitmap->rowSize;
+ }
+ break;
case splashModeBGR8Packed:
bgr8line = bitmap->data.bgr8;
for (y = 0; y < bitmap->height; ++y) {
@@ -701,6 +715,7 @@ SplashError Splash::xorFill(SplashPath *path, GBool eo) {
void Splash::drawPixel(int x, int y, SplashColor *color, GBool noClip) {
SplashMono1P *mono1;
+ SplashRGB8P *rgb8p;
SplashBGR8P *bgr8;
if (noClip || state->clip->test(x, y)) {
@@ -719,6 +734,12 @@ void Splash::drawPixel(int x, int y, SplashColor *color, GBool noClip) {
case splashModeRGB8:
bitmap->data.rgb8[y * bitmap->width + x] = color->rgb8;
break;
+ case splashModeRGB8Packed:
+ rgb8p = &bitmap->data.rgb8p[y * bitmap->rowSize + 3 * x];
+ rgb8p[0] = splashRGB8R(color->rgb8);
+ rgb8p[1] = splashRGB8G(color->rgb8);
+ rgb8p[2] = splashRGB8B(color->rgb8);
+ break;
case splashModeBGR8Packed:
bgr8 = &bitmap->data.bgr8[y * bitmap->rowSize + 3 * x];
bgr8[2] = splashBGR8R(color->bgr8);
@@ -732,6 +753,7 @@ void Splash::drawPixel(int x, int y, SplashColor *color, GBool noClip) {
void Splash::drawPixel(int x, int y, SplashPattern *pattern, GBool noClip) {
SplashColor color;
SplashMono1P *mono1;
+ SplashRGB8P *rgb8p;
SplashBGR8P *bgr8;
if (noClip || state->clip->test(x, y)) {
@@ -751,6 +773,12 @@ void Splash::drawPixel(int x, int y, SplashPattern *pattern, GBool noClip) {
case splashModeRGB8:
bitmap->data.rgb8[y * bitmap->width + x] = color.rgb8;
break;
+ case splashModeRGB8Packed:
+ rgb8p = &bitmap->data.rgb8p[y * bitmap->rowSize + 3 * x];
+ rgb8p[0] = splashRGB8R(color.rgb8);
+ rgb8p[1] = splashRGB8G(color.rgb8);
+ rgb8p[2] = splashRGB8B(color.rgb8);
+ break;
case splashModeBGR8Packed:
bgr8 = &bitmap->data.bgr8[y * bitmap->rowSize + 3 * x];
bgr8[2] = splashBGR8R(color.bgr8);
@@ -767,6 +795,7 @@ void Splash::drawSpan(int x0, int x1, int y, SplashPattern *pattern,
SplashMono1P *mono1;
SplashMono8 *mono8;
SplashRGB8 *rgb8;
+ SplashRGB8P *rgb8p;
SplashBGR8P *bgr8;
SplashMono1 mask1;
int i, j, n;
@@ -831,6 +860,19 @@ void Splash::drawSpan(int x0, int x1, int y, SplashPattern *pattern,
}
break;
+ case splashModeRGB8Packed:
+ rgb8p = &bitmap->data.rgb8p[y * bitmap->rowSize + 3 * x0];
+ for (i = 0; i < n; ++i) {
+ if (noClip || state->clip->test(x0 + i, y)) {
+ color = pattern->getColor(x0 + i, y);
+ rgb8p[0] = splashRGB8R(color.rgb8);
+ rgb8p[1] = splashRGB8G(color.rgb8);
+ rgb8p[2] = splashRGB8B(color.rgb8);
+ }
+ rgb8p += 3;
+ }
+ break;
+
case splashModeBGR8Packed:
bgr8 = &bitmap->data.bgr8[y * bitmap->rowSize + 3 * x0];
for (i = 0; i < n; ++i) {
@@ -852,6 +894,7 @@ void Splash::xorSpan(int x0, int x1, int y, SplashPattern *pattern,
SplashMono1P *mono1;
SplashMono8 *mono8;
SplashRGB8 *rgb8;
+ SplashRGB8P *rgb8p;
SplashBGR8P *bgr8;
SplashMono1 mask1;
int i, j, n;
@@ -912,6 +955,19 @@ void Splash::xorSpan(int x0, int x1, int y, SplashPattern *pattern,
}
break;
+ case splashModeRGB8Packed:
+ rgb8p = &bitmap->data.rgb8p[y * bitmap->rowSize + 3 * x0];
+ for (i = 0; i < n; ++i) {
+ if (noClip || state->clip->test(x0 + i, y)) {
+ color = pattern->getColor(x0 + i, y);
+ rgb8p[0] ^= splashRGB8R(color.rgb8);
+ rgb8p[1] ^= splashRGB8G(color.rgb8);
+ rgb8p[2] ^= splashRGB8B(color.rgb8);
+ }
+ rgb8p += 3;
+ }
+ break;
+
case splashModeBGR8Packed:
bgr8 = &bitmap->data.bgr8[y * bitmap->rowSize + 3 * x0];
for (i = 0; i < n; ++i) {
@@ -928,6 +984,7 @@ void Splash::xorSpan(int x0, int x1, int y, SplashPattern *pattern,
}
void Splash::getPixel(int x, int y, SplashColor *pixel) {
+ SplashRGB8P *rgb8p;
SplashBGR8P *bgr8;
if (y < 0 || y >= bitmap->height || x < 0 || x >= bitmap->width) {
@@ -944,6 +1001,10 @@ void Splash::getPixel(int x, int y, SplashColor *pixel) {
case splashModeRGB8:
pixel->rgb8 = bitmap->data.rgb8[y * bitmap->width + x];
break;
+ case splashModeRGB8Packed:
+ rgb8p = &bitmap->data.rgb8p[y * bitmap->rowSize + 3 * x];
+ pixel->rgb8 = splashMakeRGB8(rgb8p[0], rgb8p[1], rgb8p[2]);
+ break;
case splashModeBGR8Packed:
bgr8 = &bitmap->data.bgr8[y * bitmap->rowSize + 3 * x];
pixel->bgr8 = splashMakeBGR8(bgr8[2], bgr8[1], bgr8[0]);
@@ -983,6 +1044,7 @@ SplashError Splash::fillGlyph(SplashCoord x, SplashCoord y,
SplashMono1P *mono1Ptr;
SplashMono8 *mono8Ptr;
SplashRGB8 *rgb8Ptr;
+ SplashRGB8P *rgb8pPtr;
SplashBGR8P *bgr8Ptr;
SplashMono8 bgMono8;
int bgR, bgG, bgB;
@@ -1040,6 +1102,15 @@ SplashError Splash::fillGlyph(SplashCoord x, SplashCoord y,
(alpha * splashRGB8B(fg.rgb8) +
ialpha * bgB) >> 8);
break;
+ case splashModeRGB8Packed:
+ rgb8pPtr = &bitmap->data.rgb8p[y1 * bitmap->rowSize + 3 * x1];
+ rgb8pPtr[0] =
+ (alpha * splashRGB8R(fg.rgb8) + ialpha * rgb8pPtr[0]) >> 8;
+ rgb8pPtr[1] =
+ (alpha * splashRGB8G(fg.rgb8) + ialpha * rgb8pPtr[1]) >> 8;
+ rgb8pPtr[2] =
+ (alpha * splashRGB8B(fg.rgb8) + ialpha * rgb8pPtr[2]) >> 8;
+ break;
case splashModeBGR8Packed:
bgr8Ptr = &bitmap->data.bgr8[y1 * bitmap->rowSize + 3 * x1];
bgr8Ptr[2] =
@@ -1080,6 +1151,12 @@ SplashError Splash::fillGlyph(SplashCoord x, SplashCoord y,
case splashModeRGB8:
bitmap->data.rgb8[y1 * bitmap->width + x1] = fg.rgb8;
break;
+ case splashModeRGB8Packed:
+ rgb8pPtr = &bitmap->data.rgb8p[y1 * bitmap->rowSize + 3 * x1];
+ rgb8pPtr[0] = splashRGB8R(fg.rgb8);
+ rgb8pPtr[1] = splashRGB8G(fg.rgb8);
+ rgb8pPtr[2] = splashRGB8B(fg.rgb8);
+ break;
case splashModeBGR8Packed:
bgr8Ptr = &bitmap->data.bgr8[y1 * bitmap->rowSize + 3 * x1];
bgr8Ptr[2] = splashBGR8R(fg.bgr8);
@@ -1307,6 +1384,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData,
(1 - alpha) * bg.mono8);
break;
case splashModeRGB8:
+ case splashModeRGB8Packed:
pix.rgb8 = splashMakeRGB8(
splashRound(alpha * splashRGB8R(fg.rgb8) +
(1 - alpha) * splashRGB8R(bg.rgb8)),
@@ -1314,6 +1392,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData,
(1 - alpha) * splashRGB8G(bg.rgb8)),
splashRound(alpha * splashRGB8B(fg.rgb8) +
(1 - alpha) * splashRGB8B(bg.rgb8)));
+ break;
case splashModeBGR8Packed:
pix.bgr8 = splashMakeBGR8(
splashRound(alpha * splashBGR8R(fg.bgr8) +
@@ -1378,6 +1457,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData,
case splashModeRGB8:
ok = srcMode == splashModeRGB8;
break;
+ case splashModeRGB8Packed:
+ ok = srcMode == splashModeRGB8Packed;
+ break;
case splashModeBGR8Packed:
ok = srcMode == splashModeBGR8Packed;
break;
@@ -1564,6 +1646,7 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData,
pixAcc[0] += p->mono8;
break;
case splashModeRGB8:
+ case splashModeRGB8Packed:
pixAcc[0] += splashRGB8R(p->rgb8);
pixAcc[1] += splashRGB8G(p->rgb8);
pixAcc[2] += splashRGB8B(p->rgb8);
@@ -1606,6 +1689,7 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData,
pix.mono8 = splashRound(pixAcc[0] * pixMul);
break;
case splashModeRGB8:
+ case splashModeRGB8Packed:
pix.rgb8 = splashMakeRGB8(splashRound(pixAcc[0] * pixMul),
splashRound(pixAcc[1] * pixMul),
splashRound(pixAcc[2] * pixMul));
diff --git a/pdf/splash/SplashBitmap.cc b/pdf/splash/SplashBitmap.cc
index 5ea304f..0bec16e 100644
--- a/pdf/splash/SplashBitmap.cc
+++ b/pdf/splash/SplashBitmap.cc
@@ -39,6 +39,11 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, SplashColorMode modeA) {
data.rgb8 = (SplashRGB8 *)
gmalloc(width * height * sizeof(SplashRGB8));
break;
+ case splashModeRGB8Packed:
+ rowSize = (width * 3 + 3) & ~3;
+ data.rgb8p = (SplashRGB8P *)
+ gmalloc(rowSize * height * sizeof(SplashRGB8P));
+ break;
case splashModeBGR8Packed:
rowSize = (width * 3 + 3) & ~3;
data.bgr8 = (SplashBGR8P *)
@@ -58,9 +63,11 @@ SplashBitmap::~SplashBitmap() {
case splashModeRGB8:
gfree(data.rgb8);
break;
+ case splashModeRGB8Packed:
+ gfree(data.rgb8p);
+ break;
case splashModeBGR8Packed:
gfree(data.bgr8);
- break;
}
}
@@ -69,6 +76,7 @@ SplashError SplashBitmap::writePNMFile(char *fileName) {
SplashMono1P *mono1;
SplashMono8 *mono8;
SplashRGB8 *rgb8;
+ SplashRGB8P *rgb8pline, *rgb8p;
SplashBGR8P *bgr8line, *bgr8;
int x, y;
@@ -113,6 +121,21 @@ SplashError SplashBitmap::writePNMFile(char *fileName) {
}
break;
+ case splashModeRGB8Packed:
+ fprintf(f, "P6\n%d %d\n255\n", width, height);
+ rgb8pline = data.rgb8p;
+ for (y = 0; y < height; ++y) {
+ rgb8p = rgb8pline;
+ for (x = 0; x < width; ++x) {
+ fputc(rgb8p[0], f);
+ fputc(rgb8p[1], f);
+ fputc(rgb8p[2], f);
+ rgb8p += 3;
+ }
+ rgb8pline += rowSize;
+ }
+ break;
+
case splashModeBGR8Packed:
fprintf(f, "P6\n%d %d\n255\n", width, height);
bgr8line = data.bgr8;
diff --git a/pdf/splash/SplashTypes.h b/pdf/splash/SplashTypes.h
index 91b120f..38c6775 100644
--- a/pdf/splash/SplashTypes.h
+++ b/pdf/splash/SplashTypes.h
@@ -24,6 +24,7 @@ enum SplashColorMode {
splashModeMono1,
splashModeMono8,
splashModeRGB8,
+ splashModeRGB8Packed,
splashModeBGR8Packed
};
@@ -45,6 +46,8 @@ typedef Guint SplashRGB8;
#define splashMakeRGB8(r, g, b) \
((((r) & 0xff) << 16) | (((g) & 0xff) << 8) | ((b) & 0xff))
+typedef Guchar SplashRGB8P; // packed
+
// 3x8-bit RGB: (MSB) 00BBGGRR (LSB)
typedef Guint SplashBGR8;
typedef Guchar SplashBGR8P; // packed
@@ -65,6 +68,7 @@ union SplashColorPtr {
SplashMono1P *mono1;
SplashMono8 *mono8;
SplashRGB8 *rgb8;
+ SplashRGB8P *rgb8p;
SplashBGR8P *bgr8;
};
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),