[gegl/gsoc2009-gpu: 82/82] Add compilaiton guards for HAVE_GPU



commit fc419f6478329fbda7db39d533b08e11b27fbf68
Author: �yvind Kolås <pippin gimp org>
Date:   Sun Nov 15 01:47:15 2009 +0000

    Add compilaiton guards for HAVE_GPU
    
    This makes GEGL work when there is now gl/glew at all in the system.

 gegl/Makefile.am                             |   11 +++-
 gegl/buffer/gegl-buffer-access.c             |   12 +++
 gegl/buffer/gegl-buffer-iterator.c           |   40 ++++++++++-
 gegl/buffer/gegl-buffer-iterator.h           |    3 +-
 gegl/buffer/gegl-tile-handler-empty.c        |    4 +
 gegl/buffer/gegl-tile.c                      |   73 +++++++++++++++++---
 gegl/buffer/gegl-tile.h                      |    8 ++
 gegl/gegl-config.c                           |    7 ++-
 gegl/gegl-config.h                           |    2 +
 gegl/gegl-init.c                             |   12 +++
 gegl/operation/gegl-operation-point-filter.c |   20 +++++-
 operations/common/brightness-contrast.c      |   22 +++++-
 operations/common/invert.c                   |   64 ++++++++++-------
 operations/common/levels.c                   |   98 ++++++++++++++------------
 tests/Makefile.am                            |   15 +++--
 15 files changed, 292 insertions(+), 99 deletions(-)
---
diff --git a/gegl/Makefile.am b/gegl/Makefile.am
index 4b5a03d..226eb8c 100644
--- a/gegl/Makefile.am
+++ b/gegl/Makefile.am
@@ -2,7 +2,11 @@ if PLATFORM_WIN32
 no_undefined = -no-undefined
 endif
 
-SUBDIRS = buffer gpu graph module operation process property-types
+SUBDIRS = buffer graph module operation process property-types
+
+if HAVE_GPU
+ SUBDIRS+= gpu
+endif
 
 AM_CPPFLAGS = \
 	-I$(top_srcdir) \
@@ -74,10 +78,13 @@ lib_LTLIBRARIES = libgegl- GEGL_API_VERSION@.la
 libgegl_ GEGL_API_VERSION@_la_SOURCES = $(GEGL_sources) $(GEGL_public_HEADERS)
 libgegl_ GEGL_API_VERSION@_la_LIBADD = \
 	$(top_builddir)/gegl/buffer/libbuffer.la		\
-	$(top_builddir)/gegl/gpu/libgpu.la		\
 	$(top_builddir)/gegl/module/libmodule.la		\
 	$(top_builddir)/gegl/operation/liboperation.la		\
 	$(top_builddir)/gegl/graph/libgraph.la			\
 	$(top_builddir)/gegl/process/libprocess.la		\
 	$(top_builddir)/gegl/property-types/libpropertytypes.la
 
+if HAVE_GPU
+	libgegl_ GEGL_API_VERSION@_la_LIBADD += $(top_builddir)/gegl/gpu/libgpu.la
+endif
+
diff --git a/gegl/buffer/gegl-buffer-access.c b/gegl/buffer/gegl-buffer-access.c
index 2ed9535..bcb4a92 100644
--- a/gegl/buffer/gegl-buffer-access.c
+++ b/gegl/buffer/gegl-buffer-access.c
@@ -44,8 +44,10 @@
 #include "gegl-buffer-iterator.h"
 
 #include "gegl-region.h"
+#if HAVE_GPU
 #include "gegl-gpu-types.h"
 #include "gegl-gpu-texture.h"
+#endif
 
 #if ENABLE_MP
 GStaticRecMutex mutex = G_STATIC_REC_MUTEX_INIT;
@@ -218,6 +220,7 @@ gegl_buffer_set_pixel (GeglBuffer *buffer,
   }
 }
 
+#if HAVE_GPU
 static inline void
 gegl_buffer_gpu_set_pixel (GeglBuffer           *buffer,
                            gint                  x,
@@ -279,6 +282,7 @@ gegl_buffer_gpu_set_pixel (GeglBuffer           *buffer,
         }
     }
 }
+#endif
 
 static inline void
 gegl_buffer_get_pixel (GeglBuffer *buffer,
@@ -361,6 +365,7 @@ gegl_buffer_get_pixel (GeglBuffer *buffer,
   }
 }
 
+#if HAVE_GPU
 static inline void
 gegl_buffer_gpu_get_pixel (GeglBuffer     *buffer,
                            gint            x,
@@ -426,6 +431,7 @@ gegl_buffer_gpu_get_pixel (GeglBuffer     *buffer,
         }
     }
 }
+#endif
 
 /* flush any unwritten data (flushes the hot-cache of a single
  * tile used by gegl_buffer_set for 1x1 pixel sized rectangles
@@ -723,6 +729,7 @@ gegl_buffer_iterate (GeglBuffer          *buffer,
     }
 }
 
+#if HAVE_GPU
 static void inline
 gegl_buffer_gpu_iterate (GeglBuffer          *buffer,
                          const GeglRectangle *roi, /* or NULL for extent */
@@ -937,6 +944,7 @@ gegl_buffer_gpu_iterate (GeglBuffer          *buffer,
         }
     }
 }
+#endif
 
 void
 gegl_buffer_set (GeglBuffer          *buffer,
@@ -974,6 +982,7 @@ gegl_buffer_set (GeglBuffer          *buffer,
 #endif
 }
 
+#if HAVE_GPU
 void
 gegl_buffer_gpu_set (GeglBuffer           *buffer,
                      const GeglRectangle  *rect,
@@ -999,6 +1008,7 @@ gegl_buffer_gpu_set (GeglBuffer           *buffer,
   g_static_rec_mutex_unlock (&mutex);
 #endif
 }
+#endif
 
 
 
@@ -1452,6 +1462,7 @@ gegl_buffer_get (GeglBuffer          *buffer,
 #endif
 }
 
+#if HAVE_GPU
 void
 gegl_buffer_gpu_get (GeglBuffer          *buffer,
                      gdouble              scale,
@@ -1605,6 +1616,7 @@ gegl_buffer_gpu_get (GeglBuffer          *buffer,
   g_static_rec_mutex_unlock (&mutex);
 #endif
 }
+#endif
 
 const GeglRectangle *
 gegl_buffer_get_abyss (GeglBuffer *buffer)
diff --git a/gegl/buffer/gegl-buffer-iterator.c b/gegl/buffer/gegl-buffer-iterator.c
index f496787..e4d6968 100644
--- a/gegl/buffer/gegl-buffer-iterator.c
+++ b/gegl/buffer/gegl-buffer-iterator.c
@@ -32,9 +32,11 @@
 #include "gegl-tile-storage.h"
 #include "gegl-utils.h"
 
+#if HAVE_GPU
 #include "gegl-gpu-types.h"
 #include "gegl-gpu-texture.h"
 #include "gegl-gpu-init.h"
+#endif
 
 typedef struct _GeglBufferTileIterator
 {
@@ -48,7 +50,9 @@ typedef struct _GeglBufferTileIterator
                               * buffer represented by this scan
                               */
   gpointer         sub_data; /* pointer to the data as indicated by subrect */
+#if HAVE_GPU
   GeglGpuTexture  *gpu_data; /* pointer to the tile's full GPU data */
+#endif
 
   /* used internally */
   gint             next_col;
@@ -66,8 +70,10 @@ typedef struct _GeglBufferIterator
   /* current region of interest */
   gint                    length; /* length of current data in pixels */
   gpointer                data    [GEGL_BUFFER_MAX_ITERABLES];
-  GeglGpuTexture         *gpu_data[GEGL_BUFFER_MAX_ITERABLES];
   GeglRectangle           roi     [GEGL_BUFFER_MAX_ITERABLES];
+#if HAVE_GPU
+  GeglGpuTexture         *gpu_data[GEGL_BUFFER_MAX_ITERABLES];
+#endif
 
   /* the following is private */
   gint                    iterable_count;
@@ -143,7 +149,9 @@ gegl_buffer_tile_iterator_init (_GeglBufferTileIterator *i,
 
   memset (&i->subrect, 0, sizeof (GeglRectangle));
   i->sub_data = NULL;
+#if HAVE_GPU
   i->gpu_data = NULL;
+#endif
 
   i->next_row = 0;
   i->next_col = 0;
@@ -174,7 +182,9 @@ gulp:
       i->tile = NULL;
 
       i->sub_data = NULL;
+#if HAVE_GPU
       i->gpu_data = NULL;
+#endif
     }
 
   memset (&i->subrect, 0, sizeof (GeglRectangle));
@@ -191,7 +201,9 @@ gulp:
       GeglRectangle rect = {offset_x, offset_y, 0, 0};
 
       gboolean direct_access;
+#if HAVE_GPU
       gboolean gpu_direct_access;
+#endif
 
       if (i->roi.width + offset_x - i->next_col < tile_width)
         rect.width = (i->roi.width + offset_x - i->next_col) - offset_x;
@@ -207,12 +219,18 @@ gulp:
                                  || i->lock_mode & GEGL_TILE_LOCK_WRITE)
                                 && tile_width == rect.width);
 
+#if HAVE_GPU
       gpu_direct_access = ((i->lock_mode & GEGL_TILE_LOCK_GPU_READ
                             || i->lock_mode & GEGL_TILE_LOCK_GPU_WRITE)
                            && tile_width == rect.width
                            && tile_height == rect.height);
+#endif
 
-      if (direct_access || gpu_direct_access)
+      if (direct_access 
+#if HAVE_GPU
+       || gpu_direct_access
+#endif
+       )
         {
           i->tile = gegl_tile_source_get_tile ((GeglTileSource *) buffer,
                                                gegl_tile_index (x, tile_width),
@@ -227,9 +245,10 @@ gulp:
               gint bpp = babl_format_get_bytes_per_pixel (buffer->format);
               i->sub_data = (guchar *) data + (bpp * rect.y * tile_width);
             }
-
+#if HAVE_GPU
           if (gpu_direct_access)
             i->gpu_data = gegl_tile_get_gpu_data (i->tile);
+#endif
         }
 
       i->subrect.x      = i->roi.x + i->next_col;
@@ -294,6 +313,7 @@ gegl_buffer_iterator_add (GeglBufferIterator  *iterator,
   if (flags & GEGL_BUFFER_WRITE)
     lock_mode |= GEGL_TILE_LOCK_WRITE;
 
+#if HAVE_GPU
   if (gegl_gpu_is_accelerated ())
     {
       if (flags & GEGL_BUFFER_GPU_READ)
@@ -306,6 +326,7 @@ gegl_buffer_iterator_add (GeglBufferIterator  *iterator,
      * is disabled
      */
     i->flags[self] &= ~GEGL_BUFFER_GPU_READ & ~GEGL_BUFFER_GPU_WRITE;
+#endif
 
   if (self == 0)
     {
@@ -406,6 +427,8 @@ iterator_buf_pool_release (gpointer buf)
     }
 }
 
+#if HAVE_GPU
+
 typedef struct GpuTextureInfo {
   gint            used; /* if this texture is currently allocated */
   GeglGpuTexture *texture;
@@ -462,6 +485,7 @@ iterator_gpu_texture_pool_release (GeglGpuTexture *texture)
         info->used--;
     }
 }
+#endif
 
 void
 gegl_buffer_iterator_cleanup (void)
@@ -481,6 +505,7 @@ gegl_buffer_iterator_cleanup (void)
       buf_pool = NULL;
     }
 
+#if HAVE_GPU
   if (gpu_texture_pool != NULL)
     {
       for (cnt = 0; cnt < gpu_texture_pool->len; cnt++)
@@ -496,6 +521,7 @@ gegl_buffer_iterator_cleanup (void)
       g_array_free (gpu_texture_pool, TRUE);
       gpu_texture_pool = NULL;
     }
+#endif
 }
 
 #if DEBUG_DIRECT
@@ -527,9 +553,11 @@ gegl_buffer_iterator_next (GeglBufferIterator *iterator)
                && i->roi[no].width
                     == i->i[no].buffer->tile_storage->tile_width);
 
+#if HAVE_GPU
           gboolean gpu_direct_access
             = (direct_access && i->roi[no].height
                  == i->i[no].buffer->tile_storage->tile_height);
+#endif
 
           if (i->flags[no] & GEGL_BUFFER_READ
               || i->flags[no] & GEGL_BUFFER_WRITE)
@@ -565,6 +593,7 @@ gegl_buffer_iterator_next (GeglBufferIterator *iterator)
               i->data[no] = NULL;
             }
 
+#if HAVE_GPU
           if (i->flags[no] & GEGL_BUFFER_GPU_READ
               || i->flags[no] & GEGL_BUFFER_GPU_WRITE)
             {
@@ -596,6 +625,7 @@ gegl_buffer_iterator_next (GeglBufferIterator *iterator)
 
               i->gpu_data[no] = NULL;
             }
+#endif
 
           memset (&i->roi[no], 0, sizeof (GeglRectangle));
         }
@@ -669,6 +699,7 @@ gegl_buffer_iterator_next (GeglBufferIterator *iterator)
                 }
             }
 
+#if HAVE_GPU
           if (i->flags[no] & GEGL_BUFFER_GPU_READ
               || i->flags[no] & GEGL_BUFFER_GPU_WRITE)
             {
@@ -707,6 +738,7 @@ gegl_buffer_iterator_next (GeglBufferIterator *iterator)
 #endif
                 }
             }
+#endif
         }
       else
         {
@@ -734,6 +766,7 @@ gegl_buffer_iterator_next (GeglBufferIterator *iterator)
 #endif
             }
 
+#if HAVE_GPU
           if (i->flags[no] & GEGL_BUFFER_GPU_READ
               || i->flags[no] & GEGL_BUFFER_GPU_WRITE)
             {
@@ -751,6 +784,7 @@ gegl_buffer_iterator_next (GeglBufferIterator *iterator)
               in_direct_read += i->roi[no].width * i->roi[no].height;
 #endif
             }
+#endif
         }
 
       i->length = i->roi[no].width * i->roi[no].height;
diff --git a/gegl/buffer/gegl-buffer-iterator.h b/gegl/buffer/gegl-buffer-iterator.h
index 0020832..9bbc0fb 100644
--- a/gegl/buffer/gegl-buffer-iterator.h
+++ b/gegl/buffer/gegl-buffer-iterator.h
@@ -40,9 +40,8 @@ typedef struct GeglBufferIterator
   gint            length;
 
   gpointer        data    [GEGL_BUFFER_MAX_ITERABLES];
-  GeglGpuTexture *gpu_data[GEGL_BUFFER_MAX_ITERABLES];
-
   GeglRectangle   roi     [GEGL_BUFFER_MAX_ITERABLES];
+  GeglGpuTexture *gpu_data[GEGL_BUFFER_MAX_ITERABLES];
 
 } GeglBufferIterator;
 
diff --git a/gegl/buffer/gegl-tile-handler-empty.c b/gegl/buffer/gegl-tile-handler-empty.c
index 01a1789..f24a0d8 100644
--- a/gegl/buffer/gegl-tile-handler-empty.c
+++ b/gegl/buffer/gegl-tile-handler-empty.c
@@ -24,8 +24,10 @@
 #include "gegl-tile-handler-empty.h"
 #include "gegl-tile-handler-cache.h"
 
+#if HAVE_GPU
 #include "gegl-gpu-init.h"
 #include "gegl-gpu-texture.h"
+#endif
 
 G_DEFINE_TYPE (GeglTileHandlerEmpty, gegl_tile_handler_empty, GEGL_TYPE_TILE_HANDLER)
 
@@ -149,8 +151,10 @@ constructor (GType                  type,
   /* FIXME: need babl format here */
   memset (gegl_tile_get_data (empty->tile), 0x00, tile_size);
 
+#if HAVE_GPU
   if (gegl_gpu_is_accelerated ())
     gegl_gpu_texture_clear (empty->tile->gpu_data, NULL);
+#endif
 
   return object;
 }
diff --git a/gegl/buffer/gegl-tile.c b/gegl/buffer/gegl-tile.c
index 0d8536e..1b3f430 100644
--- a/gegl/buffer/gegl-tile.c
+++ b/gegl/buffer/gegl-tile.c
@@ -35,9 +35,11 @@
 #include "gegl-tile-source.h"
 #include "gegl-tile-storage.h"
 
+#if HAVE_GPU
 #include "gegl-gpu-types.h"
 #include "gegl-gpu-texture.h"
 #include "gegl-gpu-init.h"
+#endif
 
 
 G_DEFINE_TYPE (GeglTile, gegl_tile, G_TYPE_OBJECT)
@@ -116,14 +118,18 @@ set_property (GObject      *gobject,
 
 static void
 default_free (gpointer        data,
+#if HAVE_GPU
               GeglGpuTexture *gpu_data,
+#endif
               gpointer        userdata)
 {
   if (data != NULL)
     gegl_free (data);
 
+#if HAVE_GPU
   if (gpu_data != NULL)
     gegl_gpu_texture_free (gpu_data);
+#endif
 }
 
 static void
@@ -134,18 +140,26 @@ dispose (GObject *object)
   if (!gegl_tile_is_stored (tile))
     gegl_tile_store (tile);
 
-  if (tile->data != NULL || tile->gpu_data != NULL)
+  if (tile->data != NULL 
+#if HAVE_GPU 
+   || tile->gpu_data != NULL
+#endif
+   )
     {
       if (tile->next_shared == tile)
         {
           /* no clones */
           if (tile->destroy_notify)
             tile->destroy_notify (tile->data,
+#if HAVE_GPU 
                                   tile->gpu_data,
+#endif
                                   tile->destroy_notify_data);
 
           tile->data     = NULL;
+#if HAVE_GPU 
           tile->gpu_data = NULL;
+#endif
         }
       else
         {
@@ -204,12 +218,14 @@ static void
 gegl_tile_init (GeglTile *tile)
 {
   tile->data     = NULL;
-  tile->gpu_data = NULL;
 
+#if HAVE_GPU 
+  tile->gpu_data = NULL;
+  tile->gpu_rev    = 0;
+#endif
   tile->tile_storage = NULL;
 
   tile->rev        = 0;
-  tile->gpu_rev    = 0;
   tile->stored_rev = 0;
 
   tile->read_locks  = 0;
@@ -231,6 +247,7 @@ gegl_tile_dup (GeglTile *src)
 {
   GeglTile *tile = g_object_new (GEGL_TYPE_TILE, NULL);
 
+#if HAVE_GPU
   if (gegl_gpu_is_accelerated ())
     {
       if (src->rev > src->gpu_rev)
@@ -248,15 +265,16 @@ gegl_tile_dup (GeglTile *src)
           src->rev = src->gpu_rev;
         }
     }
+  tile->gpu_data = src->gpu_data;
+  tile->gpu_rev    = 1;
+#endif
 
   tile->data     = src->data;
   tile->size     = src->size;
-  tile->gpu_data = src->gpu_data;
 
   tile->tile_storage = src->tile_storage;
 
   tile->rev        = 1;
-  tile->gpu_rev    = 1;
   tile->stored_rev = 1;
 
   tile->next_shared              = src->next_shared;
@@ -277,8 +295,10 @@ gegl_tile_new (gint        width,
   tile->size = width * height * babl_format_get_bytes_per_pixel (format);
   tile->data = gegl_malloc (tile->size);
 
+#if HAVE_GPU
   if (gegl_gpu_is_accelerated ())
     tile->gpu_data = gegl_gpu_texture_new (width, height, format);
+#endif
 
   tile->stored_rev = 1;
 
@@ -315,11 +335,13 @@ gegl_tile_get_data (GeglTile *tile)
   return tile->data;
 }
 
+#if HAVE_GPU
 GeglGpuTexture *
 gegl_tile_get_gpu_data (GeglTile *tile)
 {
   return tile->gpu_data;
 }
+#endif
 
 static gpointer
 gegl_memdup (gpointer src,
@@ -345,8 +367,10 @@ gegl_tile_unclone (GeglTile *tile)
       tile->prev_shared              = tile;
       tile->next_shared              = tile;
 
+#if HAVE_GPU
       if (gegl_gpu_is_accelerated ())
         tile->gpu_data = gegl_gpu_texture_dup (tile->gpu_data);
+#endif
     }
 }
 
@@ -360,8 +384,10 @@ void
 gegl_tile_lock (GeglTile        *tile,
                 GeglTileLockMode lock_mode)
 {
+#if HAVE_GPU
   if (!gegl_gpu_is_accelerated ())
     lock_mode &= ~GEGL_TILE_LOCK_GPU_READ & ~GEGL_TILE_LOCK_GPU_WRITE;
+#endif
 
   if (tile->write_locks > 0)
     {
@@ -420,6 +446,7 @@ gegl_tile_lock (GeglTile        *tile,
       /*gegl_buffer_add_dirty (tile->buffer, tile->x, tile->y);*/
     }
 
+#if HAVE_GPU
   if (gegl_gpu_is_accelerated ())
     {
       if (lock_mode & GEGL_TILE_LOCK_GPU_READ && tile->rev > tile->gpu_rev)
@@ -438,6 +465,7 @@ gegl_tile_lock (GeglTile        *tile,
           tile->rev = tile->gpu_rev;
         }
     }
+#endif
 
   tile->lock_mode = lock_mode;
 }
@@ -486,13 +514,20 @@ gegl_tile_unlock (GeglTile *tile)
       if (tile->write_locks == 0)
         {
           guint rev     = tile->rev;
+#if HAVE_GPU
           guint gpu_rev = tile->gpu_rev;
 
           if (tile->lock_mode & GEGL_TILE_LOCK_GPU_WRITE)
             tile->gpu_rev = MAX (gpu_rev, rev) + 1;
+#endif
 
           if (tile->lock_mode & GEGL_TILE_LOCK_WRITE)
-            tile->rev = MAX (rev, gpu_rev) + 1;
+            tile->rev = 
+#if HAVE_GPU 
+              MAX (rev, gpu_rev) + 1;
+#else
+          rev + 1;
+#endif
 
           /* TODO: examine how this can be improved with h/w mipmaps */
           if (tile->z == 0)
@@ -520,13 +555,23 @@ gegl_tile_unlock (GeglTile *tile)
 gboolean
 gegl_tile_is_stored (GeglTile *tile)
 {
-  return tile->stored_rev == MAX (tile->rev, tile->gpu_rev);
+  return tile->stored_rev == 
+#if HAVE_GPU
+    MAX (tile->rev, tile->gpu_rev);
+#else
+    tile->rev;
+#endif
 }
 
 void
 gegl_tile_void (GeglTile *tile)
 {
-  tile->stored_rev   = MAX (tile->rev, tile->gpu_rev);
+  tile->stored_rev   = 
+#if HAVE_GPU
+    MAX (tile->rev, tile->gpu_rev);
+#else
+    tile->rev;
+#endif
   tile->tile_storage = NULL;
 
   if (tile->z == 0)
@@ -540,7 +585,11 @@ gegl_tile_cpy (GeglTile *src,
   gegl_tile_lock (src, GEGL_TILE_LOCK_ALL_READ);
   gegl_tile_lock (dst, GEGL_TILE_LOCK_ALL_WRITE);
 
-  default_free (dst->data, dst->gpu_data, NULL);
+  default_free (dst->data,
+#if HAVE_GPU
+   dst->gpu_data, 
+#endif
+   NULL);
 
   dst->next_shared              = src->next_shared;
   src->next_shared              = dst;
@@ -548,7 +597,9 @@ gegl_tile_cpy (GeglTile *src,
   dst->next_shared->prev_shared = dst;
 
   dst->data     = src->data;
+#if HAVE_GPU
   dst->gpu_data = src->gpu_data;
+#endif
 
   gegl_tile_unlock (dst);
   gegl_tile_unlock (src);
@@ -559,7 +610,9 @@ gegl_tile_swp (GeglTile *a,
                GeglTile *b)
 {
   guchar         *tmp_data;
+#if HAVE_GPU
   GeglGpuTexture *tmp_gpu_data;
+#endif
 
   gegl_tile_lock (a, GEGL_TILE_LOCK_ALL);
   gegl_tile_lock (b, GEGL_TILE_LOCK_ALL);
@@ -576,9 +629,11 @@ gegl_tile_swp (GeglTile *a,
   a->data  = b->data;
   b->data  = tmp_data;
 
+#if HAVE_GPU
   tmp_gpu_data = a->gpu_data;
   a->gpu_data  = b->gpu_data;
   b->gpu_data  = tmp_gpu_data;
+#endif
 
   gegl_tile_unlock (a);
   gegl_tile_unlock (b);
diff --git a/gegl/buffer/gegl-tile.h b/gegl/buffer/gegl-tile.h
index 66d189e..5c4b0bf 100644
--- a/gegl/buffer/gegl-tile.h
+++ b/gegl/buffer/gegl-tile.h
@@ -64,7 +64,9 @@ struct _GeglTile
                                   * a linear buffer
                                   */
   gint             size;         /* The size of the linear buffer */
+#if HAVE_GPU
   GeglGpuTexture  *gpu_data;     /* pixel data for tile, stored in the GPU */
+#endif
 
   GeglTileStorage *tile_storage; /* the buffer from which this tile was
                                   * retrieved, needed for the tile to be able
@@ -74,7 +76,9 @@ struct _GeglTile
   gint             x, y, z;
 
   guint            rev;          /* this tile's revision */
+#if HAVE_GPU
   guint            gpu_rev;      /* this tile's GPU data revision */ 
+#endif
   guint            stored_rev;   /* what revision was the tile when it was
                                   * committed to the tile_storage? (currently
                                   * set to 1 when loaded from disk)
@@ -99,7 +103,9 @@ struct _GeglTile
   GeglTile        *prev_shared;
 
   void (*destroy_notify) (gpointer        pixels,
+#if HAVE_GPU
                           GeglGpuTexture *gpu_data,
+#endif
                           gpointer        data);
 
   gpointer         destroy_notify_data;
@@ -129,8 +135,10 @@ void            gegl_tile_lock         (GeglTile *tile,
 /* get a pointer to the linear buffer of the tile */
 guchar         *gegl_tile_get_data     (GeglTile *tile);
 
+#if HAVE_GPU
 /* get a pointer to the GPU data of the tile */
 GeglGpuTexture *gegl_tile_get_gpu_data (GeglTile *tile);
+#endif
 
 /* unlock the tile notifying the tile that we're done accessing
  * the data
diff --git a/gegl/gegl-config.c b/gegl/gegl-config.c
index 3cad0b2..b0f45a3 100644
--- a/gegl/gegl-config.c
+++ b/gegl/gegl-config.c
@@ -80,8 +80,10 @@ get_property (GObject    *gobject,
         g_value_set_string (value, config->swap);
         break;
 
+#if HAVE_GPU
       case PROP_GPU_ENABLED:
         g_value_set_boolean (value, config->gpu_enabled);
+#endif
 
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
@@ -131,9 +133,11 @@ set_property (GObject      *gobject,
          g_free (config->swap);
         config->swap = g_value_dup_string (value);
         break;
+#if HAVE_GPU
       case PROP_GPU_ENABLED:
         config->gpu_enabled = g_value_get_boolean (value);
         break;
+#endif
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, pspec);
         break;
@@ -214,6 +218,7 @@ gegl_config_init (GeglConfig *self)
   self->chunk_size  = 512 * 512;
   self->tile_width  = 64;
   self->tile_height = 128;
-
+#if HAVE_GPU
   self->gpu_enabled = FALSE;
+#endif
 }
diff --git a/gegl/gegl-config.h b/gegl/gegl-config.h
index bf07209..d2d39cc 100644
--- a/gegl/gegl-config.h
+++ b/gegl/gegl-config.h
@@ -45,7 +45,9 @@ struct _GeglConfig
   gint     tile_width;
   gint     tile_height;
 
+#if HAVE_GPU
   gboolean gpu_enabled;
+#endif
 };
 
 struct _GeglConfigClass
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index 3115bbe..bf65a41 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -94,8 +94,12 @@ guint gegl_debug_flags = 0;
 #include "buffer/gegl-buffer-private.h"
 #include "gegl-config.h"
 
+#ifdef HAVE_GPU
+
 #include "gpu/gegl-gpu-init.h"
 
+#endif
+
 
 /* if this function is made to return NULL swapping is disabled */
 const gchar *
@@ -200,8 +204,10 @@ gegl_init (gint    *argc,
   g_option_context_free (context);
 #endif
 
+#if HAVE_GPU
   if (config->gpu_enabled)
     gegl_gpu_init (argc, argv);
+#endif
 }
 
 static gchar *cmd_gegl_swap        = NULL;
@@ -297,8 +303,10 @@ GeglConfig *gegl_config (void)
         }
       if (gegl_swap_dir())
         config->swap = g_strdup(gegl_swap_dir ());
+#if HAVE_GPU
       if (g_getenv ("GEGL_ENABLE_GPU") != NULL)
         config->gpu_enabled = TRUE;
+#endif
     }
   return GEGL_CONFIG (config);
 }
@@ -364,8 +372,10 @@ gegl_exit (void)
       module_db = NULL;
     }
 
+#if HAVE_GPU
   if (gegl_gpu_is_accelerated ())
     gegl_gpu_exit ();
+#endif
 
   babl_exit ();
 
@@ -499,10 +509,12 @@ gegl_post_parse_hook (GOptionContext *context,
 
   if (cmd_gegl_enable_gpu != NULL)
     {
+#if HAVE_GPU
       if (g_str_equal (cmd_gegl_enable_gpu, "true"))
         config->gpu_enabled = TRUE;
       else if (g_str_equal (cmd_gegl_enable_gpu, "false"))
         config->gpu_enabled = FALSE;
+#endif
     }
 
 #ifdef GEGL_ENABLE_DEBUG
diff --git a/gegl/operation/gegl-operation-point-filter.c b/gegl/operation/gegl-operation-point-filter.c
index 07b70ca..d62c996 100644
--- a/gegl/operation/gegl-operation-point-filter.c
+++ b/gegl/operation/gegl-operation-point-filter.c
@@ -82,27 +82,40 @@ gegl_operation_point_filter_process (GeglOperation       *operation,
 
   if (result->width > 0 && result->height > 0)
     {
+#if HAVE_GPU
       GeglOperationPointFilterGpuProcessor gpu_process
         = (gpointer) gegl_operation_class_get_gpu_processor (operation_class);
 
       gboolean use_gpu = (gegl_gpu_is_accelerated () && gpu_process != NULL);
+#endif
 
       GeglBufferIterator *i = gegl_buffer_iterator_new (
                                 output,
                                 result,
                                 out_format,
+#if HAVE_GPU
                                 use_gpu
                                   ? GEGL_BUFFER_GPU_WRITE
-                                  : GEGL_BUFFER_WRITE);
+                                  : GEGL_BUFFER_WRITE
+#else
+                                  GEGL_BUFFER_WRITE
+#endif
+                                  );
 
       gint read  = gegl_buffer_iterator_add (i,
                                              input,
                                              result,
                                              in_format,
+#if HAVE_GPU
                                              use_gpu
                                                ? GEGL_BUFFER_GPU_READ
-                                               : GEGL_BUFFER_READ);
+                                               : GEGL_BUFFER_READ
+#else
+                                               GEGL_BUFFER_READ
+#endif
+                                               );
 
+#if HAVE_GPU
       if (use_gpu)
         {
           while (gegl_buffer_iterator_next (i))
@@ -114,13 +127,16 @@ gegl_operation_point_filter_process (GeglOperation       *operation,
         }
       else
         {
+#endif
           while (gegl_buffer_iterator_next (i))
             point_filter_class->process (operation,
                                          i->data[read],
                                          i->data[0],
                                          i->length,
                                          &i->roi[0]);
+#if HAVE_GPU
         }
+#endif
 
       gegl_buffer_iterator_free (i);
     }
diff --git a/operations/common/brightness-contrast.c b/operations/common/brightness-contrast.c
index 0b0fa98..f4ba671 100644
--- a/operations/common/brightness-contrast.c
+++ b/operations/common/brightness-contrast.c
@@ -13,10 +13,13 @@
  * You should have received a copy of the GNU Lesser General Public
  * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
  *
- * Copyright 2006 �yvind Kolås <pippin gimp org>
+ * Copyright 2006-2009 �yvind Kolås <pippin gimp org>
+ *           2009      daerd
  */
 
+#ifdef HAVE_GPU
 #include <GL/glew.h>
+#endif
 
 #include "config.h"
 #include <glib/gi18n-lib.h>
@@ -58,10 +61,15 @@ gegl_chant_double (brightness, _("Brightness"), -3.0, 3.0, 0.0,
  */
 #include "gegl-chant.h"
 
+/* XXX: the amount of boiler plate to be able to write a sahder
+ * for the op needs to be reduced.
+ */
+#if 0
+
 #include "gegl-gpu-types.h"
 #include "gegl-gpu-init.h"
 
-static const char* shader_program_str = "                         \
+static gchar* shader_program_str = "                              \
 uniform sampler2DRect pixels;                                     \
 uniform float brightness, contrast;                               \
                                                                   \
@@ -96,6 +104,7 @@ create_shader_program (void)
 
   return program;
 }
+#endif
 
 /* prepare() is called on each operation providing data to a node that
  * is requested to provide a rendered result. When prepare is called
@@ -148,6 +157,11 @@ process (GeglOperation       *op,
   return TRUE;
 }
 
+/* XXX: could this perhaps be done more generically in the baseclass,
+ * allowing the implementation to be much more minimal?
+ */
+#if 0
+
 static gboolean
 process_gpu (GeglOperation       *op,
              GeglGpuTexture      *in,
@@ -215,6 +229,8 @@ process_gpu (GeglOperation       *op,
   return TRUE;
 }
 
+#endif
+
 #ifdef HAS_G4FLOAT
 /* The compiler supports vector extensions allowing an version of
  * the process code that produces more optimal instructions on the
@@ -289,9 +305,11 @@ gegl_chant_class_init (GeglChantClass *klass)
   gegl_operation_class_add_processor (operation_class,
                                       G_CALLBACK (process_simd), "simd");
 #endif
+#if 0
   gegl_operation_class_add_processor (operation_class,
                                       G_CALLBACK (process_gpu),
                                       "gpu:reference");
+#endif
 }
 
 #endif /* closing #ifdef GEGL_CHANT_PROPERTIES ... else ... */
diff --git a/operations/common/invert.c b/operations/common/invert.c
index 04613a1..65c74e1 100644
--- a/operations/common/invert.c
+++ b/operations/common/invert.c
@@ -16,7 +16,9 @@
  * Copyright 2006 �yvind Kolås <pippin gimp org>
  */
 
+#if 0
 #include <GL/glew.h>
+#endif
 
 #include "config.h"
 #include <glib/gi18n-lib.h>
@@ -34,6 +36,8 @@
 
 #include "gegl-chant.h"
 
+#if 0
+
 #include "gegl-gpu-types.h"
 #include "gegl-gpu-init.h"
 
@@ -69,34 +73,6 @@ create_shader_program (void)
 }
 
 static gboolean
-process (GeglOperation       *op,
-         void                *in_buf,
-         void                *out_buf,
-         glong                samples,
-         const GeglRectangle *roi)
-{
-  glong   i;
-  gfloat *in  = in_buf;
-  gfloat *out = out_buf;
-
-  for (i=0; i<samples; i++)
-    {
-      int  j;
-      for (j=0; j<3; j++)
-        {
-          gfloat c;
-          c = in[j];
-          c = 1.0 - c;
-          out[j] = c;
-        }
-      out[3]=in[3];
-      in += 4;
-      out+= 4;
-    }
-  return TRUE;
-}
-
-static gboolean
 process_gpu (GeglOperation       *op,
              GeglGpuTexture      *in,
              GeglGpuTexture      *out,
@@ -153,6 +129,36 @@ process_gpu (GeglOperation       *op,
 
   return TRUE;
 }
+#endif
+
+static gboolean
+process (GeglOperation       *op,
+         void                *in_buf,
+         void                *out_buf,
+         glong                samples,
+         const GeglRectangle *roi)
+{
+  glong   i;
+  gfloat *in  = in_buf;
+  gfloat *out = out_buf;
+
+  for (i=0; i<samples; i++)
+    {
+      int  j;
+      for (j=0; j<3; j++)
+        {
+          gfloat c;
+          c = in[j];
+          c = 1.0 - c;
+          out[j] = c;
+        }
+      out[3]=in[3];
+      in += 4;
+      out+= 4;
+    }
+  return TRUE;
+}
+
 
 #ifdef HAS_G4FLOAT
 static gboolean
@@ -199,9 +205,11 @@ gegl_chant_class_init (GeglChantClass *klass)
   gegl_operation_class_add_processor (operation_class,
                                       G_CALLBACK (process_simd), "simd");
 #endif
+#if 0
   gegl_operation_class_add_processor (operation_class,
                                       G_CALLBACK (process_gpu),
                                       "gpu:reference");
+#endif
 }
 
 #endif
diff --git a/operations/common/levels.c b/operations/common/levels.c
index 330b85b..6dcf722 100644
--- a/operations/common/levels.c
+++ b/operations/common/levels.c
@@ -16,8 +16,9 @@
  * Copyright 2006 �yvind Kolås <pippin gimp org>
  */
 
-
+#if 0
 #include <GL/glew.h>
+#endif
 
 #include "config.h"
 #include <glib/gi18n-lib.h>
@@ -41,6 +42,8 @@ gegl_chant_double (out_high, _("High output"),
 
 #include "gegl-chant.h"
 
+#if 0
+
 #include "gegl-gpu-types.h"
 #include "gegl-gpu-init.h"
 
@@ -82,50 +85,6 @@ create_shader_program (void)
   return program;
 }
 
-/* GeglOperationPointFilter gives us a linear buffer to operate on
- * in our requested pixel format
- */
-static gboolean
-process (GeglOperation       *op,
-         void                *in_buf,
-         void                *out_buf,
-         glong                n_pixels,
-         const GeglRectangle *roi)
-{
-  GeglChantO *o = GEGL_CHANT_PROPERTIES (op);
-  gfloat     *in_pixel;
-  gfloat     *out_pixel;
-  gfloat      in_range;
-  gfloat      out_range;
-  gfloat      in_offset;
-  gfloat      out_offset;
-  gfloat      scale;
-  glong       i;
-
-  in_pixel = in_buf;
-  out_pixel = out_buf;
-
-  in_offset = o->in_low * 1.0;
-  out_offset = o->out_low * 1.0;
-  in_range = o->in_high-o->in_low;
-  out_range = o->out_high-o->out_low;
-
-  if (in_range == 0.0)
-    in_range = 0.00000001;
-
-  scale = out_range/in_range;
-
-  for (i=0; i<n_pixels; i++)
-    {
-      int c;
-      for (c=0;c<3;c++)
-        out_pixel[c] = (in_pixel[c]- in_offset) * scale + out_offset;
-      out_pixel[3] = in_pixel[3];
-      out_pixel += 4;
-      in_pixel += 4;
-    }
-  return TRUE;
-}
 
 static gboolean
 process_gpu (GeglOperation       *op,
@@ -203,6 +162,53 @@ process_gpu (GeglOperation       *op,
   return TRUE;
 }
 
+#endif
+
+
+/* GeglOperationPointFilter gives us a linear buffer to operate on
+ * in our requested pixel format
+ */
+static gboolean
+process (GeglOperation       *op,
+         void                *in_buf,
+         void                *out_buf,
+         glong                n_pixels,
+         const GeglRectangle *roi)
+{
+  GeglChantO *o = GEGL_CHANT_PROPERTIES (op);
+  gfloat     *in_pixel;
+  gfloat     *out_pixel;
+  gfloat      in_range;
+  gfloat      out_range;
+  gfloat      in_offset;
+  gfloat      out_offset;
+  gfloat      scale;
+  glong       i;
+
+  in_pixel = in_buf;
+  out_pixel = out_buf;
+
+  in_offset = o->in_low * 1.0;
+  out_offset = o->out_low * 1.0;
+  in_range = o->in_high-o->in_low;
+  out_range = o->out_high-o->out_low;
+
+  if (in_range == 0.0)
+    in_range = 0.00000001;
+
+  scale = out_range/in_range;
+
+  for (i=0; i<n_pixels; i++)
+    {
+      int c;
+      for (c=0;c<3;c++)
+        out_pixel[c] = (in_pixel[c]- in_offset) * scale + out_offset;
+      out_pixel[3] = in_pixel[3];
+      out_pixel += 4;
+      in_pixel += 4;
+    }
+  return TRUE;
+}
 
 static void
 gegl_chant_class_init (GeglChantClass *klass)
@@ -220,9 +226,11 @@ gegl_chant_class_init (GeglChantClass *klass)
   operation_class->description =
         _("Remaps the intensity range of the image");
 
+#if 0
   gegl_operation_class_add_processor (operation_class,
                                       G_CALLBACK (process_gpu),
                                       "gpu:reference");
+#endif
 }
 
 #endif
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3b350e7..06dcbcf 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,21 +9,26 @@ TESTS = \
 	test-change-processor-rect	\
 	test-proxynop-processing	\
 	test-color-op			\
-	test-gegl-rectangle \
+	test-gegl-rectangle 
+
+if HAVE_GPU
+TESTS += \
 	test-gegl-gpu-texture-clear \
 	test-gegl-gpu-texture-clear-subrect \
 	test-gegl-gpu-texture-set \
 	test-gegl-gpu-texture-set-subrect \
 	test-gegl-gpu-texture-copy \
 	test-gegl-gpu-texture-copy-subrect \
-	test-gegl-gpu-texture-dup \
+	test-gegl-gpu-texture-dup  \
 	test-gegl-tile-lock-mode-write-then-read \
-	test-gegl-tile-lock-mode-write-then-gpu-read \
 	test-gegl-tile-lock-mode-gpu-write-then-read \
+	test-gegl-tile-lock-mode-write-then-gpu-read \
 	test-gegl-tile-lock-mode-gpu-write-then-gpu-read \
+	test-gegl-buffer-gpu-scale-normal \
 	test-gegl-tile-cow \
-	test-gegl-tile-cow-consistency \
-	test-gegl-buffer-gpu-scale-normal
+	test-gegl-tile-cow-consistency 
+endif
+
 noinst_PROGRAMS = $(TESTS)
 
 # Common CPPFLAGS



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]