[poppler] splash/SplashScreen.cc splash/SplashScreen.h

Albert Astals Cid aacid at kemper.freedesktop.org
Sun Nov 15 11:41:38 PST 2009


 splash/SplashScreen.cc |   35 +++++++++++++++++++++++++++++++++--
 splash/SplashScreen.h  |   16 ++++++++++++++++
 2 files changed, 49 insertions(+), 2 deletions(-)

New commits:
commit 572d79f4b8a7bf1717b88dbd2609d8fa9b036dee
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun Nov 15 20:40:56 2009 +0100

    Only calculate the matrix when it is really needed
    
    That only happens when outputting to 1 bit images
    Speeds out rendering on some pdf up to 40%

diff --git a/splash/SplashScreen.cc b/splash/SplashScreen.cc
index 4fa8488..6b75c0c 100644
--- a/splash/SplashScreen.cc
+++ b/splash/SplashScreen.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) 2009 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
@@ -46,12 +60,24 @@ static int cmpDistances(const void *p0, const void *p1) {
 // threshold matrix using recursive tesselation.  Gamma correction
 // (gamma = 1 / 1.33) is also computed here.
 SplashScreen::SplashScreen(SplashScreenParams *params) {
-  Guchar u, black, white;
-  int i;
 
   if (!params) {
     params = &defaultParams;
   }
+  
+  screenParams = params;
+  mat = NULL;
+  size = 0;
+  maxVal = 0;
+  minVal = 0;
+}
+
+void SplashScreen::createMatrix()
+{
+  Guchar u, black, white;
+  int i;
+  
+  SplashScreenParams *params = screenParams;
 
   switch (params->type) {
 
@@ -349,6 +375,7 @@ void SplashScreen::buildSCDMatrix(int r) {
 }
 
 SplashScreen::SplashScreen(SplashScreen *screen) {
+  screenParams = screen->screenParams;
   size = screen->size;
   mat = (Guchar *)gmallocn(size * size, sizeof(Guchar));
   memcpy(mat, screen->mat, size * size * sizeof(Guchar));
@@ -362,6 +389,8 @@ SplashScreen::~SplashScreen() {
 
 int SplashScreen::test(int x, int y, Guchar value) {
   int xx, yy;
+  
+  if (mat == NULL) createMatrix();
 
   if (value < minVal) {
     return 0;
@@ -379,5 +408,7 @@ int SplashScreen::test(int x, int y, Guchar value) {
 }
 
 GBool SplashScreen::isStatic(Guchar value) {
+  if (mat == NULL) createMatrix();
+  
   return value < minVal || value >= maxVal;
 }
diff --git a/splash/SplashScreen.h b/splash/SplashScreen.h
index 4174c80..fe3b5c8 100644
--- a/splash/SplashScreen.h
+++ b/splash/SplashScreen.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) 2009 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 SPLASHSCREEN_H
 #define SPLASHSCREEN_H
 
@@ -36,6 +50,7 @@ public:
   GBool isStatic(Guchar value);
 
 private:
+  void createMatrix();
 
   void buildDispersedMatrix(int i, int j, int val,
 			    int delta, int offset);
@@ -43,6 +58,7 @@ private:
   int distance(int x0, int y0, int x1, int y1);
   void buildSCDMatrix(int r);
 
+  SplashScreenParams *screenParams;	// params to create the other members
   Guchar *mat;			// threshold matrix
   int size;			// size of the threshold matrix
   Guchar minVal;		// any pixel value below minVal generates


More information about the poppler mailing list