[poppler] poppler/qt4/src: poppler-document.cc, 1.12, 1.13 poppler-page.cc, 1.11, 1.12 poppler-private.h, 1.2, 1.3

Albert Astals Cid aacid at freedesktop.org
Sun Jan 1 14:35:50 PST 2006


Update of /cvs/poppler/poppler/qt4/src
In directory gabe:/tmp/cvs-serv25460/qt4/src

Modified Files:
	poppler-document.cc poppler-page.cc poppler-private.h 
Log Message:
        * qt4/src/poppler-private.h:
        * qt4/src/poppler-page.cc:
        * qt4/src/poppler-document.cc: Don't create a SplashOutputDev for
        every splashRenderToPixmap


Index: poppler-document.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-document.cc,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- poppler-document.cc	28 Dec 2005 09:23:43 -0000	1.12
+++ poppler-document.cc	1 Jan 2006 22:35:48 -0000	1.13
@@ -65,7 +65,6 @@
 
     Document::~Document()
     {
-	delete m_doc->m_fontInfoScanner;
 	delete m_doc;
     }
 

Index: poppler-page.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-page.cc,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- poppler-page.cc	30 Dec 2005 22:54:46 -0000	1.11
+++ poppler-page.cc	1 Jan 2006 22:35:48 -0000	1.12
@@ -27,12 +27,12 @@
 #include <ErrorCodes.h>
 #include <ArthurOutputDev.h>
 #include <Private.h>
-#include <TextOutputDev.h>
-#include "poppler-private.h"
-
 #include <SplashOutputDev.h>
+#include <TextOutputDev.h>
 #include <splash/SplashBitmap.h>
 
+#include "poppler-private.h"
+
 namespace Poppler {
 
 class PageData {
@@ -57,12 +57,7 @@
 
 QPixmap *Page::splashRenderToPixmap(double xres, double yres, int x, int y, int w, int h) const
 {
-  SplashColor white;
-  white[0] = 255;
-  white[1] = 255;
-  white[2] = 255;
-  SplashOutputDev *output_dev = new SplashOutputDev(splashModeRGB8, 4, gFalse, white);
-  output_dev->startDoc(m_page->parentDoc->m_doc->doc.getXRef ());
+  SplashOutputDev *output_dev = m_page->parentDoc->m_doc->getSplashOutputDev();
   
   m_page->parentDoc->m_doc->doc.displayPageSlice(output_dev, m_page->index + 1, xres, yres,
 						 0, false, true, false, x, y, w, h);
@@ -90,13 +85,10 @@
     }
   }
   delete[] pixel;
- 
+
   // Turn the QImage into a QPixmap
   QPixmap* out = new QPixmap(QPixmap::fromImage(img));
 
-  // Delete temporary buffers
-  delete output_dev;
-
   return out;
 }
 

Index: poppler-private.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-private.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- poppler-private.h	28 Dec 2005 09:23:43 -0000	1.2
+++ poppler-private.h	1 Jan 2006 22:35:48 -0000	1.3
@@ -25,15 +25,37 @@
     class DocumentData {
     public:
 	DocumentData(GooString *filePath, GooString *ownerPassword, GooString *userPassword) :
-	    doc(filePath, ownerPassword, userPassword)
+	    doc(filePath, ownerPassword, userPassword), m_splashOutputDev(0)
 	    {
 		// It might be more appropriate to delete these in PDFDoc
 		delete ownerPassword;
 		delete userPassword;
 	    }
+	
+	~DocumentData()
+	{
+		delete m_splashOutputDev;
+		delete m_fontInfoScanner;
+	}
+	
+	SplashOutputDev *getSplashOutputDev()
+	{
+		if (!m_splashOutputDev)
+		{
+			SplashColor white;
+			white[0] = 255;
+			white[1] = 255;
+			white[2] = 255;
+			m_splashOutputDev = new SplashOutputDev(splashModeRGB8, 4, gFalse, white);
+			m_splashOutputDev->startDoc(doc.getXRef());
+		}
+		return m_splashOutputDev;
+	}
+	
 	class PDFDoc doc;
 	bool locked;
 	FontInfoScanner *m_fontInfoScanner;
+	SplashOutputDev *m_splashOutputDev;
     };
 
 }



More information about the poppler mailing list