Hey,

I have written a small patch for setting external data to the SplashBitmap class. It's not finished yet as i have some questions (and doc is not added):

 * is the coding style good ?
 * i don't think I break ABI.
 * what about alpha ? Afaics, it's just allocated memory with
   a getter, that's all.
 * I don't know what to do if topDown is true. Btw is there something
   to do ?

Vincent Torri
diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc
index f983439..6df1fae 100644
--- a/splash/SplashBitmap.cc
+++ b/splash/SplashBitmap.cc
@@ -46,7 +46,7 @@
 
 SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad,
 			   SplashColorMode modeA, GBool alphaA,
-			   GBool topDown) {
+			   GBool topDown, SplashColorPtr dataExternal) {
   width = widthA;
   height = heightA;
   mode = modeA;
@@ -94,10 +94,17 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad,
     rowSize += rowPad - 1;
     rowSize -= rowSize % rowPad;
   }
-  data = (SplashColorPtr)gmallocn(rowSize, height);
-  if (!topDown) {
-    data += (height - 1) * rowSize;
-    rowSize = -rowSize;
+  if (dataExternal) {
+    data = dataExternal;
+    isDataExternal = true;
+    // FIXME: what about topDown and alpha ?
+  } else {
+    data = (SplashColorPtr)gmallocn(rowSize, height);
+    isDataExternal = false;
+    if (!topDown) {
+      data += (height - 1) * rowSize;
+      rowSize = -rowSize;
+    }
   }
   if (alphaA) {
     alpha = (Guchar *)gmallocn(width, height);
@@ -108,10 +115,12 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad,
 
 
 SplashBitmap::~SplashBitmap() {
-  if (rowSize < 0) {
-    gfree(data + (height - 1) * rowSize);
-  } else {
-    gfree(data);
+  if (!isDataExternal) {
+    if (rowSize < 0) {
+      gfree(data + (height - 1) * rowSize);
+    } else {
+      gfree(data);
+    }
   }
   gfree(alpha);
 }
diff --git a/splash/SplashBitmap.h b/splash/SplashBitmap.h
index e741a91..28bcd42 100644
--- a/splash/SplashBitmap.h
+++ b/splash/SplashBitmap.h
@@ -48,7 +48,7 @@ public:
   // upside-down, i.e., with the last row first in memory.
   SplashBitmap(int widthA, int heightA, int rowPad,
 	       SplashColorMode modeA, GBool alphaA,
-	       GBool topDown = gTrue);
+	       GBool topDown = gTrue, SplashColorPtr dataExternal = NULL);
 
   ~SplashBitmap();
 
@@ -81,6 +81,7 @@ private:
 				//   (always top-down)
 
   friend class Splash;
+  GBool isDataExternal;
 };
 
 #endif
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to