[cairo-commit] xpdf-cairo/xpdf CairoOutputDev.cc,1.4,1.5

Alexander Larsson commit at pdx.freedesktop.org
Sat Feb 5 11:47:27 PST 2005


Committed by: alexl

Update of /cvs/cairo/xpdf-cairo/xpdf
In directory gabe:/tmp/cvs-serv4232/xpdf

Modified Files:
	CairoOutputDev.cc 
Log Message:
2005-02-06  Jeff Muizelaar  <jrmuizel at nit.ca>

        * xpdf/CairoOutputDev.cc: (drawImage):
        Avoid doing pointless color space transformations from RGB to
        RGB



Index: CairoOutputDev.cc
===================================================================
RCS file: /cvs/cairo/xpdf-cairo/xpdf/CairoOutputDev.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CairoOutputDev.cc	27 Jan 2005 10:36:05 -0000	1.4
+++ CairoOutputDev.cc	5 Feb 2005 19:47:24 -0000	1.5
@@ -490,6 +490,7 @@
   int alpha, i;
   double *ctm;
   cairo_matrix_t *mat;
+  int is_identity_transform;
   
   buffer = (char *)malloc (width * height * 4);
 
@@ -503,13 +504,17 @@
 			   colorMap->getNumPixelComps(),
 			   colorMap->getBits());
   imgStr->reset();
-
+  
+  /* ICCBased color space doesn't do any color correction
+   * so check its underlying color space as well */
+  is_identity_transform = colorMap->getColorSpace()->getMode() == csDeviceRGB ||
+		  colorMap->getColorSpace()->getMode() == csICCBased && 
+		  ((GfxICCBasedColorSpace*)colorMap->getColorSpace())->getAlt()->getMode() == csDeviceRGB;
+  
   for (y = 0; y < height; y++) {
     dest = buffer + y * 4 * width;
     pix = imgStr->getLine();
     for (x = 0; x < width; x++, pix += colorMap->getNumPixelComps()) {
-      colorMap->getRGB(pix, &rgb);
-
       if (maskColors) {
 	alpha = 0;
 	for (i = 0; i < colorMap->getNumPixelComps(); ++i) {
@@ -522,10 +527,16 @@
       } else {
 	alpha = 255;
       }
-      
-      *dest++ = soutRound(255 * rgb.b);
-      *dest++ = soutRound(255 * rgb.g);
-      *dest++ = soutRound(255 * rgb.r);
+      if (is_identity_transform) {
+	*dest++ = pix[2];
+	*dest++ = pix[1];
+	*dest++ = pix[0];
+      } else {      
+	colorMap->getRGB(pix, &rgb);
+	*dest++ = soutRound(255 * rgb.b);
+	*dest++ = soutRound(255 * rgb.g);
+	*dest++ = soutRound(255 * rgb.r);
+      }
       *dest++ = alpha;
     }
   }




More information about the cairo-commit mailing list