[mapserver-commits] r12455 - in trunk/mapserver/mapcache: . src

svn at osgeo.org svn at osgeo.org
Fri Aug 26 07:27:56 EDT 2011


Author: tbonfort
Date: 2011-08-26 04:27:56 -0700 (Fri, 26 Aug 2011)
New Revision: 12455

Modified:
   trunk/mapserver/mapcache/Makefile.inc.in
   trunk/mapserver/mapcache/configure.in
   trunk/mapserver/mapcache/src/image.c
Log:


Modified: trunk/mapserver/mapcache/Makefile.inc.in
===================================================================
--- trunk/mapserver/mapcache/Makefile.inc.in	2011-08-26 11:27:51 UTC (rev 12454)
+++ trunk/mapserver/mapcache/Makefile.inc.in	2011-08-26 11:27:56 UTC (rev 12455)
@@ -48,10 +48,14 @@
 SQLITE_LIB=@SQLITE_LIB@
 SQLITE_ENABLED=@SQLITE_ENABLED@
 
+PIXMAN_INC=@PIXMAN_INC@
+PIXMAN_LIB=@PIXMAN_LIB@
+PIXMAN_ENABLED=@PIXMAN_ENABLED@
+
 MISC_ENABLED=@MISC_ENABLED@ -DTHREADED_MPM=$(shell $(HTTPD) -V | grep "Server MPM" | grep -q "Prefork"; echo $$?)
 
-INCLUDES=-I../include $(MISC_ENABLED) $(CURL_CFLAGS) $(PNG_INC) $(JPEG_INC) $(GDAL_INC) $(GEOS_INC) $(APR_INC) $(APU_INC) $(MEMCACHE_ENABLED) $(PCRE_CFLAGS) $(PCRE_ENABLED) $(OGR_ENABLED) $(GEOS_ENABLED) $(SQLITE_ENABLED)
-LIBS=$(CURL_LIBS) $(PNG_LIB) $(JPEG_LIB) $(APR_LIBS) $(APU_LIBS) $(PCRE_LIBS) $(SQLITE_LIB)
+INCLUDES=-I../include $(MISC_ENABLED) $(CURL_CFLAGS) $(PNG_INC) $(JPEG_INC) $(GDAL_INC) $(GEOS_INC) $(APR_INC) $(APU_INC) $(MEMCACHE_ENABLED) $(PCRE_CFLAGS) $(PCRE_ENABLED) $(OGR_ENABLED) $(GEOS_ENABLED) $(SQLITE_ENABLED) $(SQLITE_INC) $(PIXMAN_ENABLED) $(PIXMAN_ENABLED) $(PIXMAN_INC)
+LIBS=$(CURL_LIBS) $(PNG_LIB) $(JPEG_LIB) $(APR_LIBS) $(APU_LIBS) $(PCRE_LIBS) $(SQLITE_LIB) $(PIXMAN_LIB)
 SEEDER_EXTRALIBS=$(GDAL_LIB) $(GEOS_LIB)
 
 

Modified: trunk/mapserver/mapcache/configure.in
===================================================================
--- trunk/mapserver/mapcache/configure.in	2011-08-26 11:27:51 UTC (rev 12454)
+++ trunk/mapserver/mapcache/configure.in	2011-08-26 11:27:56 UTC (rev 12455)
@@ -187,7 +187,56 @@
     AC_SUBST(CAIRO_LIB,$CAIRO_LIB)
 ])
 
+AC_DEFUN([PIXMAN_CHECK],[
+    AC_ARG_WITH(pixman,
+        AC_HELP_STRING([--with-pixman[[=ARG]]],[Include Pixman Support (ARG=yes/no/path to pixman.pc)]),
+        ,
+        [with_pixman=yes])
+    
+    if test "$with_pixman" = "no" -o "$with_pixman" = "" ; then
+      AC_MSG_RESULT(no)
+      PIXMAN_CONFIG="no"
+    else
+        if test -z "$PKGCONFIG"; then
+            AC_MSG_ERROR([pixman support requested, but pkg-config not found/configured])
+        fi
+        if test "$with_pixman" = "yes" ; then
+            AC_MSG_CHECKING(for pixman pkg-config entry)
+            `$PKGCONFIG --silence-errors -- pixman >> /dev/null`
+            if test $? -eq 0 ; then
+                AC_MSG_RESULT(found)
+                PIXMAN_CONFIG="pixman"
+            else
+               `$PKGCONFIG --silence-errors -- pixman-1 >> /dev/null`
+               if test $? -eq 0 ; then
+                  AC_MSG_RESULT(found)
+                  PIXMAN_CONFIG="pixman-1"
+               else
+                  AC_MSG_ERROR([pixman support requested, but not found.Try installing the pixman development headers])
+               fi
+            fi
+        else
+          PIXMAN_CONFIG=$with_pixman
+        fi
+    fi
+    
+    if test "$PIXMAN_CONFIG" = "no" ; then
+      AC_MSG_WARN([pixman support has been disabled or could not be configured.
+                   full WMS will use the internal (usually slower) image merging functions])
+      PIXMAN_ENABLED=
+      PIXMAN_INC=
+      PIXMAN_LIB=
+    else
+      PIXMAN_ENABLED="-DUSE_PIXMAN"
+      PIXMAN_LIB=`$PKGCONFIG --libs $PIXMAN_CONFIG`
+      PIXMAN_INC=`$PKGCONFIG --cflags $PIXMAN_CONFIG`
+    fi
+    AC_SUBST(PIXMAN_ENABLED,$PIXMAN_ENABLED)
+    AC_SUBST(PIXMAN_INC,$PIXMAN_INC)
+    AC_SUBST(PIXMAN_LIB,$PIXMAN_LIB)
+])
 
+
 AC_DEFUN([APU_CHECK],[
   AC_SUBST(APUCONFIG)
   AC_SUBST(MEMCACHE_ENABLED)
@@ -712,6 +761,7 @@
 SQLITE_CHECK
 PKGCONFIG_CHECK
 # CAIRO_CHECK
+PIXMAN_CHECK
 PNG_CHECK
 
 JPEG_CHECK

Modified: trunk/mapserver/mapcache/src/image.c
===================================================================
--- trunk/mapserver/mapcache/src/image.c	2011-08-26 11:27:51 UTC (rev 12454)
+++ trunk/mapserver/mapcache/src/image.c	2011-08-26 11:27:56 UTC (rev 12455)
@@ -15,6 +15,11 @@
  */
 
 #include "geocache.h"
+#ifdef USE_PIXMAN
+#include <pixman.h>
+#else
+#include <math.h>
+#endif
 
 geocache_image* geocache_image_create(geocache_context *ctx) {
     geocache_image *img = (geocache_image*)apr_pcalloc(ctx->pool,sizeof(geocache_image));
@@ -47,6 +52,7 @@
    }
    starti = (base->h - overlay->h)/2;
    startj = (base->w - overlay->w)/2;
+
    browptr = base->data + starti * base->stride + startj*4;
    orowptr = overlay->data;
    for(i=0;i<overlay->h;i++) {
@@ -81,28 +87,7 @@
    }
 }
 
-#include <math.h>
-
-void geocache_image_copy_resampled_nearest(geocache_context *ctx, geocache_image *src, geocache_image *dst,
-      double off_x, double off_y, double scale_x, double scale_y) {
-   int dstx,dsty;
-   unsigned char *dstrowptr = dst->data;
-   for(dsty=0; dsty<dst->h; dsty++) {
-      int *dstptr = (int*)dstrowptr;
-      int srcy = round((dsty-off_y)/scale_y);
-      if(srcy >= 0 && srcy < src->h) {
-         for(dstx=0; dstx<dst->w;dstx++) {
-            int srcx = round((dstx-off_x)/scale_x);
-            if(srcx >= 0 && srcx < src->w) {
-               *dstptr = *((int*)&(src->data[srcy*src->stride+srcx*4]));
-            }
-            dstptr ++;
-         }
-      }
-      dstrowptr += dst->stride;
-   }
-} 
-
+#ifndef USE_PIXMAN
 static inline void bilinear_pixel(geocache_image *img, double x, double y, unsigned char *dst) {
    int px,py;
    px = (int)x;
@@ -133,9 +118,62 @@
    dst[2] = (p1[2] * w1 + p2[2] * w2 + p3[2] * w3 + p4[2] * w4) >> 8;
    dst[3] = (p1[3] * w1 + p2[3] * w2 + p3[3] * w3 + p4[3] * w4) >> 8;
 }
+#endif
 
+void geocache_image_copy_resampled_nearest(geocache_context *ctx, geocache_image *src, geocache_image *dst,
+      double off_x, double off_y, double scale_x, double scale_y) {
+#ifdef USE_PIXMAN
+   pixman_image_t *si = pixman_image_create_bits(PIXMAN_a8r8g8b8,src->w,src->h,
+         (uint32_t*)src->data,src->stride);
+   pixman_image_t *bi = pixman_image_create_bits(PIXMAN_a8r8g8b8,dst->w,dst->h,
+         (uint32_t*)dst->data,dst->stride);
+   pixman_transform_t transform;
+   pixman_transform_init_translate(&transform,pixman_double_to_fixed(-off_x),pixman_double_to_fixed(-off_y));
+   pixman_transform_scale(&transform,NULL,pixman_double_to_fixed(1.0/scale_x),pixman_double_to_fixed(1.0/scale_y));
+   pixman_image_set_transform (si, &transform);
+   pixman_image_set_filter(si,PIXMAN_FILTER_NEAREST, NULL, 0);
+   pixman_image_composite (PIXMAN_OP_SRC, si, NULL, bi,
+                            0, 0, 0, 0, 0, 0, dst->w,dst->h);
+   pixman_image_unref(si);
+   pixman_image_unref(bi);
+#else
+   int dstx,dsty;
+   unsigned char *dstrowptr = dst->data;
+   for(dsty=0; dsty<dst->h; dsty++) {
+      int *dstptr = (int*)dstrowptr;
+      int srcy = round((dsty-off_y)/scale_y);
+      if(srcy >= 0 && srcy < src->h) {
+         for(dstx=0; dstx<dst->w;dstx++) {
+            int srcx = round((dstx-off_x)/scale_x);
+            if(srcx >= 0 && srcx < src->w) {
+               *dstptr = *((int*)&(src->data[srcy*src->stride+srcx*4]));
+            }
+            dstptr ++;
+         }
+      }
+      dstrowptr += dst->stride;
+   }
+#endif
+} 
+
+
 void geocache_image_copy_resampled_bilinear(geocache_context *ctx, geocache_image *src, geocache_image *dst,
       double off_x, double off_y, double scale_x, double scale_y) {
+#ifdef USE_PIXMAN
+   pixman_image_t *si = pixman_image_create_bits(PIXMAN_a8r8g8b8,src->w,src->h,
+         (uint32_t*)src->data,src->stride);
+   pixman_image_t *bi = pixman_image_create_bits(PIXMAN_a8r8g8b8,dst->w,dst->h,
+         (uint32_t*)dst->data,dst->stride);
+   pixman_transform_t transform;
+   pixman_transform_init_translate(&transform,pixman_double_to_fixed(-off_x),pixman_double_to_fixed(-off_y));
+   pixman_transform_scale(&transform,NULL,pixman_double_to_fixed(1.0/scale_x),pixman_double_to_fixed(1.0/scale_y));
+   pixman_image_set_transform (si, &transform);
+   pixman_image_set_filter(si,PIXMAN_FILTER_BILINEAR, NULL, 0);
+   pixman_image_composite (PIXMAN_OP_SRC, si, NULL, bi,
+                            0, 0, 0, 0, 0, 0, dst->w,dst->h);
+   pixman_image_unref(si);
+   pixman_image_unref(bi);
+#else
    int dstx,dsty;
    unsigned char *dstrowptr = dst->data;
    for(dsty=0; dsty<dst->h; dsty++) {
@@ -152,6 +190,7 @@
       }
       dstrowptr += dst->stride;
    }
+#endif
 } 
 
 geocache_tile* geocache_image_merge_tiles(geocache_context *ctx, geocache_image_format *format, geocache_tile **tiles, int ntiles) {



More information about the mapserver-commits mailing list