[poppler] 4 commits - splash/SplashBitmap.cc splash/Splash.cc splash/SplashClip.cc splash/SplashClip.h
Albert Astals Cid
aacid at kemper.freedesktop.org
Sat Feb 20 02:09:12 PST 2010
splash/Splash.cc | 25 +++++++++++++------------
splash/SplashBitmap.cc | 25 +++++++++++++++++++++++--
splash/SplashClip.cc | 40 ++++++++++++++--------------------------
splash/SplashClip.h | 43 +++++++++++++++++++++++++++++++++++++++++--
4 files changed, 91 insertions(+), 42 deletions(-)
New commits:
commit d074485aa9d9fac6b715382002f53e3303bbc519
Author: Albert Astals Cid <aacid at kde.org>
Date: Sat Feb 20 10:08:33 2010 +0000
Do not call getPixel if we know how to access the data
Gives a 20% speed increase in some pdf
diff --git a/splash/Splash.cc b/splash/Splash.cc
index 202fe45..8b11583 100644
--- a/splash/Splash.cc
+++ b/splash/Splash.cc
@@ -3163,7 +3163,7 @@ void Splash::compositeBackground(SplashColorPtr color) {
SplashError Splash::blitTransparent(SplashBitmap *src, int xSrc, int ySrc,
int xDest, int yDest, int w, int h) {
SplashColor pixel;
- SplashColorPtr p;
+ SplashColorPtr p, sp;
Guchar *q;
int x, y, mask;
@@ -3203,23 +3203,24 @@ SplashError Splash::blitTransparent(SplashBitmap *src, int xSrc, int ySrc,
case splashModeBGR8:
for (y = 0; y < h; ++y) {
p = &bitmap->data[(yDest + y) * bitmap->rowSize + 3 * xDest];
+ sp = &src->data[(ySrc + y) * src->rowSize + 3 * xSrc];
for (x = 0; x < w; ++x) {
- src->getPixel(xSrc + x, ySrc + y, pixel);
- *p++ = pixel[0];
- *p++ = pixel[1];
- *p++ = pixel[2];
+ *p++ = *sp++;
+ *p++ = *sp++;
+ *p++ = *sp++;
}
}
break;
case splashModeXBGR8:
for (y = 0; y < h; ++y) {
p = &bitmap->data[(yDest + y) * bitmap->rowSize + 4 * xDest];
+ sp = &src->data[(ySrc + y) * src->rowSize + 4 * xSrc];
for (x = 0; x < w; ++x) {
- src->getPixel(xSrc + x, ySrc + y, pixel);
- *p++ = pixel[0];
- *p++ = pixel[1];
- *p++ = pixel[2];
+ *p++ = *sp++;
+ *p++ = *sp++;
+ *p++ = *sp++;
*p++ = 255;
+ *sp++;
}
}
break;
commit d4cafe357bd86feb4b56e5dfbf5b7822e237a2ee
Author: Albert Astals Cid <aacid at kde.org>
Date: Sat Feb 20 10:07:20 2010 +0000
Only call getPixel when really needed
Gives a 8% speed increase in some pdf
diff --git a/splash/Splash.cc b/splash/Splash.cc
index 834cb10..202fe45 100644
--- a/splash/Splash.cc
+++ b/splash/Splash.cc
@@ -11,7 +11,7 @@
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
-// Copyright (C) 2005-2009 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2005-2010 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2005 Marco Pesenti Gritti <mpg at redhat.com>
//
// To see a description of the changes please see the Changelog file that
@@ -3018,11 +3018,11 @@ SplashError Splash::composite(SplashBitmap *src, int xSrc, int ySrc,
pipeSetXY(&pipe, xDest, yDest + y);
ap = src->getAlphaPtr() + (ySrc + y) * src->getWidth() + xSrc;
for (x = 0; x < w; ++x) {
- src->getPixel(xSrc + x, ySrc + y, pixel);
alpha = *ap++;
if (noClip || state->clip->test(xDest + x, yDest + y)) {
// this uses shape instead of alpha, which isn't technically
// correct, but works out the same
+ src->getPixel(xSrc + x, ySrc + y, pixel);
pipe.shape = (SplashCoord)(alpha / 255.0);
pipeRun(&pipe);
updateModX(xDest + x);
@@ -3038,8 +3038,8 @@ SplashError Splash::composite(SplashBitmap *src, int xSrc, int ySrc,
for (y = 0; y < h; ++y) {
pipeSetXY(&pipe, xDest, yDest + y);
for (x = 0; x < w; ++x) {
- src->getPixel(xSrc + x, ySrc + y, pixel);
if (noClip || state->clip->test(xDest + x, yDest + y)) {
+ src->getPixel(xSrc + x, ySrc + y, pixel);
pipeRun(&pipe);
updateModX(xDest + x);
updateModY(yDest + y);
commit c3122cfbe090f3a4045269222f941cd5ce77c171
Author: Albert Astals Cid <aacid at kde.org>
Date: Sat Feb 20 10:04:37 2010 +0000
Move test code to the header to it can be inlined
Gives a 10% speed increase in some documents
diff --git a/splash/SplashClip.cc b/splash/SplashClip.cc
index 87b0d7e..5add152 100644
--- a/splash/SplashClip.cc
+++ b/splash/SplashClip.cc
@@ -4,6 +4,20 @@
//
//========================================================================
+//========================================================================
+//
+// Modified under the Poppler project - http://poppler.freedesktop.org
+//
+// All changes made under the Poppler project to this file are licensed
+// under GPL version 2 or later
+//
+// Copyright (C) 2010 Albert Astals Cid <aacid at kde.org>
+//
+// To see a description of the changes please see the Changelog file that
+// came with your tarball or type make ChangeLog if you are building from git
+//
+//========================================================================
+
#include <config.h>
#ifdef USE_GCC_PRAGMAS
@@ -248,32 +262,6 @@ SplashError SplashClip::clipToPath(SplashPath *path, SplashCoord *matrix,
return splashOk;
}
-GBool SplashClip::test(int x, int y) {
- int i;
-
- // check the rectangle
- if (x < xMinI || x > xMaxI || y < yMinI || y > yMaxI) {
- return gFalse;
- }
-
- // check the paths
- if (antialias) {
- for (i = 0; i < length; ++i) {
- if (!scanners[i]->test(x * splashAASize, y * splashAASize)) {
- return gFalse;
- }
- }
- } else {
- for (i = 0; i < length; ++i) {
- if (!scanners[i]->test(x, y)) {
- return gFalse;
- }
- }
- }
-
- return gTrue;
-}
-
SplashClipResult SplashClip::testRect(int rectXMin, int rectYMin,
int rectXMax, int rectYMax) {
// This tests the rectangle:
diff --git a/splash/SplashClip.h b/splash/SplashClip.h
index 1864149..7933017 100644
--- a/splash/SplashClip.h
+++ b/splash/SplashClip.h
@@ -4,6 +4,20 @@
//
//========================================================================
+//========================================================================
+//
+// Modified under the Poppler project - http://poppler.freedesktop.org
+//
+// All changes made under the Poppler project to this file are licensed
+// under GPL version 2 or later
+//
+// Copyright (C) 2010 Albert Astals Cid <aacid at kde.org>
+//
+// To see a description of the changes please see the Changelog file that
+// came with your tarball or type make ChangeLog if you are building from git
+//
+//========================================================================
+
#ifndef SPLASHCLIP_H
#define SPLASHCLIP_H
@@ -13,10 +27,10 @@
#include "SplashTypes.h"
#include "SplashMath.h"
+#include "SplashXPathScanner.h"
class SplashPath;
class SplashXPath;
-class SplashXPathScanner;
class SplashBitmap;
//------------------------------------------------------------------------
@@ -57,7 +71,32 @@ public:
SplashCoord flatness, GBool eo);
// Returns true if (<x>,<y>) is inside the clip.
- GBool test(int x, int y);
+ GBool test(int x, int y)
+ {
+ int i;
+
+ // check the rectangle
+ if (x < xMinI || x > xMaxI || y < yMinI || y > yMaxI) {
+ return gFalse;
+ }
+
+ // check the paths
+ if (antialias) {
+ for (i = 0; i < length; ++i) {
+ if (!scanners[i]->test(x * splashAASize, y * splashAASize)) {
+ return gFalse;
+ }
+ }
+ } else {
+ for (i = 0; i < length; ++i) {
+ if (!scanners[i]->test(x, y)) {
+ return gFalse;
+ }
+ }
+ }
+
+ return gTrue;
+ }
// Tests a rectangle against the clipping region. Returns one of:
// - splashClipAllInside if the entire rectangle is inside the
commit d987fb9b77e6da454eb898cc6c8baaf747b7ac4f
Author: Albert Astals Cid <aacid at kde.org>
Date: Fri Feb 19 23:59:03 2010 +0000
implement writeImgFile for splashModeXBGR8
diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc
index 4844d0b..6832293 100644
--- a/splash/SplashBitmap.cc
+++ b/splash/SplashBitmap.cc
@@ -11,7 +11,7 @@
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
-// Copyright (C) 2006, 2009 Albert Astals Cid <aacid at kde.org>
+// Copyright (C) 2006, 2009, 2010 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2007 Ilmari Heikkinen <ilmari.heikkinen at gmail.com>
// Copyright (C) 2009 Shen Liang <shenzhuxi at gmail.com>
// Copyright (C) 2009 Stefan Thomas <thomas at eload24.com>
@@ -307,7 +307,7 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, in
return splashErrGeneric;
}
- if (mode != splashModeRGB8 && mode != splashModeMono8 && mode != splashModeMono1) {
+ if (mode != splashModeRGB8 && mode != splashModeMono8 && mode != splashModeMono1 && mode != splashModeXBGR8) {
error(-1, "unsupported SplashBitmap mode");
return splashErrGeneric;
}
@@ -337,6 +337,27 @@ SplashError SplashBitmap::writeImgFile(SplashImageFileFormat format, FILE *f, in
}
break;
+ case splashModeXBGR8:
+ {
+ unsigned char *row = new unsigned char[3 * width];
+ for (int y = 0; y < height; y++) {
+ // Convert into a PNG row
+ for (int x = 0; x < width; x++) {
+ row[3*x] = data[y * rowSize + x * 4 + 2];
+ row[3*x+1] = data[y * rowSize + x * 4 + 1];
+ row[3*x+2] = data[y * rowSize + x * 4];
+ }
+
+ if (!writer->writeRow(&row)) {
+ delete[] row;
+ delete writer;
+ return splashErrGeneric;
+ }
+ }
+ delete[] row;
+ }
+ break;
+
case splashModeMono8:
{
unsigned char *row = new unsigned char[3 * width];
More information about the poppler
mailing list