Commit 6f5a89a0 authored by Albert Astals Cid's avatar Albert Astals Cid

* poppler/SplashOutputDev.cc:

        * qt4/src/poppler-private.h:
        * splash/Splash.cc:
        * splash/SplashBitmap.cc:
        * splash/SplashTypes.h: bring splashModeRGB8 back to the old code
        (before Frank's patch), create splashModeRGB8Qt that has Frank's
        codepath and is used by Qt frontends. Fixes corruption on
        other programs expecting the old behaviour.

Remember dude we are now a lib! you can not change behaviour from one day to another!

/me hits himself
parent 495d592c
2006-05-21 Albert Astals Cid <aacid@kde.org>
* poppler/SplashOutputDev.cc:
* qt4/src/poppler-private.h:
* splash/Splash.cc:
* splash/SplashBitmap.cc:
* splash/SplashTypes.h: bring splashModeRGB8 back to the old code
(before Frank's patch), create splashModeRGB8Qt that has Frank's
codepath and is used by Qt frontends. Fixes corruption on
other programs expecting the old behaviour.
2006-05-23 Kristian Høgsberg <krh@redhat.com>
* qt4/src/Makefile.am (libpoppler_qt4_la_SOURCES): Add missing
......
......@@ -626,6 +626,7 @@ void SplashOutputDev::startPage(int pageNum, GfxState *state) {
break;
case splashModeRGB8:
case splashModeBGR8:
case splashModeRGB8Qt:
color[0] = color[1] = color[2] = 0;
break;
case splashModeAMono8:
......@@ -877,6 +878,7 @@ SplashPattern *SplashOutputDev::getColor(GfxGray gray, GfxRGB *rgb) {
pattern = new SplashSolidColor(color1);
break;
case splashModeRGB8:
case splashModeRGB8Qt:
color1[0] = colToByte(r);
color1[1] = colToByte(g);
color1[2] = colToByte(b);
......@@ -1670,6 +1672,7 @@ GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr line) {
break;
case splashModeRGB8:
case splashModeBGR8:
case splashModeRGB8Qt:
for (x = 0, p = imgData->imgStr->getLine(), q = line;
x < imgData->width;
++x, ++p) {
......@@ -1713,6 +1716,7 @@ GBool SplashOutputDev::imageSrc(void *data, SplashColorPtr line) {
}
break;
case splashModeRGB8:
case splashModeRGB8Qt:
for (x = 0, p = imgData->imgStr->getLine(), q = line;
x < imgData->width;
++x, p += nComps) {
......@@ -1797,6 +1801,7 @@ GBool SplashOutputDev::alphaImageSrc(void *data, SplashColorPtr line) {
*q++ = imgData->lookup[*p];
break;
case splashModeRGB8:
case splashModeRGB8Qt:
*q++ = alpha;
col = &imgData->lookup[3 * *p];
*q++ = col[0];
......@@ -1838,6 +1843,7 @@ GBool SplashOutputDev::alphaImageSrc(void *data, SplashColorPtr line) {
*q++ = colToByte(gray);
break;
case splashModeRGB8:
case splashModeRGB8Qt:
imgData->colorMap->getRGB(p, &rgb);
*q++ = alpha;
*q++ = colToByte(rgb.r);
......@@ -2043,6 +2049,7 @@ GBool SplashOutputDev::maskedImageSrc(void *data, SplashColorPtr line) {
*q++ = imgData->lookup[*p];
break;
case splashModeRGB8:
case splashModeRGB8Qt:
*q++ = alpha;
col = &imgData->lookup[3 * *p];
*q++ = col[0];
......@@ -2084,6 +2091,7 @@ GBool SplashOutputDev::maskedImageSrc(void *data, SplashColorPtr line) {
*q++ = colToByte(gray);
break;
case splashModeRGB8:
case splashModeRGB8Qt:
imgData->colorMap->getRGB(p, &rgb);
*q++ = alpha;
*q++ = colToByte(rgb.r);
......
......@@ -41,7 +41,7 @@ class DocumentData {
white[0] = 255;
white[1] = 255;
white[2] = 255;
m_outputDev = new SplashOutputDev(splashModeRGB8, 4, gFalse, white);
m_outputDev = new SplashOutputDev(splashModeRGB8Qt, 4, gFalse, white);
m_outputDev->startDoc(doc.getXRef());
}
return m_outputDev;
......
......@@ -95,7 +95,7 @@ namespace Poppler {
bgColor[0] = paperColor.red();
bgColor[1] = paperColor.green();
bgColor[2] = paperColor.blue();
m_splashOutputDev = new SplashOutputDev(splashModeRGB8, 4, gFalse, bgColor);
m_splashOutputDev = new SplashOutputDev(splashModeRGB8Qt, 4, gFalse, bgColor);
m_splashOutputDev->startDoc(doc.getXRef());
}
return m_splashOutputDev;
......
......@@ -307,6 +307,27 @@ void Splash::clear(SplashColorPtr color) {
break;
case splashModeRGB8:
case splashModeBGR8:
if (color[0] == color[1] && color[1] == color[2]) {
if (bitmap->rowSize < 0) {
memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1),
color[0], -bitmap->rowSize * bitmap->height);
} else {
memset(bitmap->data, color[0], bitmap->rowSize * bitmap->height);
}
} else {
row = bitmap->data;
for (y = 0; y < bitmap->height; ++y) {
p = row;
for (x = 0; x < bitmap->width; ++x) {
*p++ = color[0];
*p++ = color[1];
*p++ = color[2];
}
row += bitmap->rowSize;
}
}
break;
case splashModeRGB8Qt:
if (color[0] == color[1] && color[1] == color[2]) {
if (bitmap->rowSize < 0) {
memset(bitmap->data + bitmap->rowSize * (bitmap->height - 1),
......@@ -964,6 +985,13 @@ void Splash::drawPixel(int x, int y, SplashColorPtr color,
break;
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x];
(*blendFunc)(color, p, blend, bitmap->mode);
p[0] = (alpha2 * blend[0] + ialpha2 * p[0]) >> 8;
p[1] = (alpha2 * blend[1] + ialpha2 * p[1]) >> 8;
p[2] = (alpha2 * blend[2] + ialpha2 * p[2]) >> 8;
break;
case splashModeRGB8Qt:
p = &bitmap->data[y * bitmap->rowSize + 4 * x];
(*blendFunc)(color, p, blend, bitmap->mode);
p[0] = (alpha2 * blend[2] + ialpha2 * p[0]) >> 8;
......@@ -1015,6 +1043,12 @@ void Splash::drawPixel(int x, int y, SplashColorPtr color,
break;
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x];
p[0] = color[0];
p[1] = color[1];
p[2] = color[2];
break;
case splashModeRGB8Qt:
p = &bitmap->data[y * bitmap->rowSize + 4 * x];
p[0] = color[2];
p[1] = color[1];
......@@ -1093,6 +1127,13 @@ void Splash::drawPixel(int x, int y, SplashPattern *pattern,
break;
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x];
(*blendFunc)(color, p, blend, bitmap->mode);
p[0] = (alpha2 * blend[0] + ialpha2 * p[0]) >> 8;
p[1] = (alpha2 * blend[1] + ialpha2 * p[1]) >> 8;
p[2] = (alpha2 * blend[2] + ialpha2 * p[2]) >> 8;
break;
case splashModeRGB8Qt:
p = &bitmap->data[y * bitmap->rowSize + 4 * x];
(*blendFunc)(color, p, blend, bitmap->mode);
p[0] = (alpha2 * blend[2] + ialpha2 * p[0]) >> 8;
......@@ -1145,6 +1186,12 @@ void Splash::drawPixel(int x, int y, SplashPattern *pattern,
break;
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x];
p[0] = color[0];
p[1] = color[1];
p[2] = color[2];
break;
case splashModeRGB8Qt:
p = &bitmap->data[y * bitmap->rowSize + 4 * x];
p[0] = color[2];
p[1] = color[1];
......@@ -1406,6 +1453,51 @@ void Splash::drawSpan(int x0, int x1, int y, SplashPattern *pattern,
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x0];
if (pattern->isStatic()) {
pattern->getColor(0, 0, color);
for (i = 0; i < n; ++i) {
if (noClip || state->clip->test(x0 + i, y)) {
if (softMask) {
alpha2 = (int)(alpha *
softMask->data[y * softMask->rowSize + x0 + i]);
ialpha2 = 255 - alpha2;
}
(*blendFunc)(color, p, blend, bitmap->mode);
p[0] = (alpha2 * blend[0] + ialpha2 * p[0]) >> 8;
p[1] = (alpha2 * blend[1] + ialpha2 * p[1]) >> 8;
p[2] = (alpha2 * blend[2] + ialpha2 * p[2]) >> 8;
if (!noClip) {
updateModX(x0 + i);
updateModY(y);
}
}
p += 3;
}
} else {
for (i = 0; i < n; ++i) {
if (noClip || state->clip->test(x0 + i, y)) {
pattern->getColor(x0 + i, y, color);
if (softMask) {
alpha2 = (int)(alpha *
softMask->data[y * softMask->rowSize + x0 + i]);
ialpha2 = 255 - alpha2;
}
(*blendFunc)(color, p, blend, bitmap->mode);
p[0] = (alpha2 * blend[0] + ialpha2 * p[0]) >> 8;
p[1] = (alpha2 * blend[1] + ialpha2 * p[1]) >> 8;
p[2] = (alpha2 * blend[2] + ialpha2 * p[2]) >> 8;
if (!noClip) {
updateModX(x0 + i);
updateModY(y);
}
}
p += 3;
}
}
break;
case splashModeRGB8Qt:
p = &bitmap->data[y * bitmap->rowSize + 4 * x0];
if (pattern->isStatic()) {
pattern->getColor(0, 0, color);
......@@ -1699,6 +1791,39 @@ void Splash::drawSpan(int x0, int x1, int y, SplashPattern *pattern,
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x0];
if (pattern->isStatic()) {
pattern->getColor(0, 0, color);
for (i = 0; i < n; ++i) {
if (noClip || state->clip->test(x0 + i, y)) {
p[0] = color[0];
p[1] = color[1];
p[2] = color[2];
if (!noClip) {
updateModX(x0 + i);
updateModY(y);
}
}
p += 3;
}
} else {
for (i = 0; i < n; ++i) {
if (noClip || state->clip->test(x0 + i, y)) {
pattern->getColor(x0 + i, y, color);
p[0] = color[0];
p[1] = color[1];
p[2] = color[2];
if (!noClip) {
updateModX(x0 + i);
updateModY(y);
}
}
p += 3;
}
}
break;
case splashModeRGB8Qt:
p = &bitmap->data[y * bitmap->rowSize + 4 * x0];
if (pattern->isStatic()) {
pattern->getColor(0, 0, color);
......@@ -1899,6 +2024,23 @@ void Splash::xorSpan(int x0, int x1, int y, SplashPattern *pattern,
case splashModeRGB8:
case splashModeBGR8:
p = &bitmap->data[y * bitmap->rowSize + 3 * x0];
for (i = 0; i < n; ++i) {
if (noClip || state->clip->test(x0 + i, y)) {
pattern->getColor(x0 + i, y, color);
p[0] ^= color[0];
p[1] ^= color[1];
p[2] ^= color[2];
if (!noClip) {
updateModX(x0 + i);
updateModY(y);
}
}
p += 3;
}
break;
case splashModeRGB8Qt:
p = &bitmap->data[y * bitmap->rowSize + 4 * x0];
for (i = 0; i < n; ++i) {
if (noClip || state->clip->test(x0 + i, y)) {
......@@ -2056,6 +2198,13 @@ SplashError Splash::fillGlyph(SplashCoord x, SplashCoord y,
break;
case splashModeRGB8:
case splashModeBGR8:
pix = &bitmap->data[y1 * bitmap->rowSize + 3 * x1];
(*blendFunc)(fg, pix, blend, bitmap->mode);
pix[0] = (alpha * blend[0] + ialpha * pix[0]) >> 8;
pix[1] = (alpha * blend[1] + ialpha * pix[1]) >> 8;
pix[2] = (alpha * blend[2] + ialpha * pix[2]) >> 8;
break;
case splashModeRGB8Qt:
pix = &bitmap->data[y1 * bitmap->rowSize + 4 * x1];
(*blendFunc)(fg, pix, blend, bitmap->mode);
pix[0] = (alpha * blend[2] + ialpha * pix[0]) >> 8;
......@@ -2137,6 +2286,13 @@ SplashError Splash::fillGlyph(SplashCoord x, SplashCoord y,
break;
case splashModeRGB8:
case splashModeBGR8:
pix = &bitmap->data[y1 * bitmap->rowSize + 3 * x1];
(*blendFunc)(fg, pix, blend, bitmap->mode);
pix[0] = (alpha * blend[0] + ialpha * pix[0]) >> 8;
pix[1] = (alpha * blend[1] + ialpha * pix[1]) >> 8;
pix[2] = (alpha * blend[2] + ialpha * pix[2]) >> 8;
break;
case splashModeRGB8Qt:
pix = &bitmap->data[y1 * bitmap->rowSize + 4 * x1];
(*blendFunc)(fg, pix, blend, bitmap->mode);
pix[0] = (alpha * blend[2] + ialpha * pix[0]) >> 8;
......@@ -2212,6 +2368,12 @@ SplashError Splash::fillGlyph(SplashCoord x, SplashCoord y,
break;
case splashModeRGB8:
case splashModeBGR8:
pix = &bitmap->data[y1 * bitmap->rowSize + 3 * x1];
pix[0] = (alpha * fg[0] + ialpha * pix[0]) >> 8;
pix[1] = (alpha * fg[1] + ialpha * pix[1]) >> 8;
pix[2] = (alpha * fg[2] + ialpha * pix[2]) >> 8;
break;
case splashModeRGB8Qt:
pix = &bitmap->data[y1 * bitmap->rowSize + 4 * x1];
pix[0] = (alpha * fg[2] + ialpha * pix[0]) >> 8;
pix[1] = (alpha * fg[1] + ialpha * pix[1]) >> 8;
......@@ -2277,6 +2439,12 @@ SplashError Splash::fillGlyph(SplashCoord x, SplashCoord y,
break;
case splashModeRGB8:
case splashModeBGR8:
pix = &bitmap->data[y1 * bitmap->rowSize + 3 * x1];
pix[0] = fg[0];
pix[1] = fg[1];
pix[2] = fg[2];
break;
case splashModeRGB8Qt:
pix = &bitmap->data[y1 * bitmap->rowSize + 4 * x1];
pix[0] = fg[2];
pix[1] = fg[1];
......@@ -2634,6 +2802,7 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData,
ok = gFalse;
nComps = 2;
break;
case splashModeRGB8Qt:
case splashModeRGB8:
ok = srcMode == splashModeRGB8 || srcMode == splashModeARGB8;
srcAlpha = srcMode == splashModeARGB8;
......
......@@ -36,8 +36,9 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad,
break;
case splashModeRGB8:
case splashModeBGR8:
rowSize = width * 4;
rowSize = width * 3;
break;
case splashModeRGB8Qt:
case splashModeARGB8:
case splashModeBGRA8:
#if SPLASH_CMYK
......@@ -128,7 +129,7 @@ SplashError SplashBitmap::writePNMFile(char *fileName) {
fputc(splashRGB8R(p), f);
fputc(splashRGB8G(p), f);
fputc(splashRGB8B(p), f);
p += 4;
p += 3;
}
row += rowSize;
}
......@@ -149,6 +150,21 @@ SplashError SplashBitmap::writePNMFile(char *fileName) {
}
break;
case splashModeRGB8Qt:
fprintf(f, "P6\n%d %d\n255\n", width, height);
row = data;
for (y = 0; y < height; ++y) {
p = row;
for (x = 0; x < width; ++x) {
fputc(splashRGB8R(p), f);
fputc(splashRGB8G(p), f);
fputc(splashRGB8B(p), f);
p += 4;
}
row += rowSize;
}
break;
case splashModeARGB8:
fprintf(f, "P6\n%d %d\n255\n", width, height);
row = data;
......@@ -213,6 +229,12 @@ void SplashBitmap::getPixel(int x, int y, SplashColorPtr pixel) {
break;
case splashModeRGB8:
case splashModeBGR8:
p = &data[y * rowSize + 3 * x];
pixel[0] = p[0];
pixel[1] = p[1];
pixel[2] = p[2];
break;
case splashModeRGB8Qt:
p = &data[y * rowSize + 4 * x];
pixel[0] = p[2];
pixel[1] = p[1];
......
......@@ -36,6 +36,8 @@ enum SplashColorMode {
// BGRBGR...
splashModeARGB8, // 1 byte per component, 4 bytes per pixel:
// ARGBARGB...
splashModeRGB8Qt, // 1 byte per component, 4 bytes per pixel:
// Specially hacked to use in Qt frontends
splashModeBGRA8 // 1 byte per component, 4 bytes per pixel:
// BGRABGRA...
#if SPLASH_CMYK
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment