[gegl/gsoc2011-opencl] Corrections in GeglClTexture



commit 4a3d06023c09010ad8a90011c49808bae49accf0
Author: Victor Oliveira <victormatheus gmail com>
Date:   Wed Jun 1 17:12:17 2011 -0300

    Corrections in GeglClTexture

 gegl/opencl/gegl-cl-texture.c |   60 +++++-----------------------------------
 gegl/opencl/gegl-cl-texture.h |   10 ++-----
 2 files changed, 11 insertions(+), 59 deletions(-)
---
diff --git a/gegl/opencl/gegl-cl-texture.c b/gegl/opencl/gegl-cl-texture.c
index 1d9674e..6b31077 100644
--- a/gegl/opencl/gegl-cl-texture.c
+++ b/gegl/opencl/gegl-cl-texture.c
@@ -1,5 +1,3 @@
-#include <babl/babl.h>
-
 #include "gegl.h"
 #include "gegl-cl-types.h"
 #include "gegl-cl-init.h"
@@ -7,18 +5,14 @@
 #include "gegl-cl-texture.h"
 
 GeglClTexture *
-gegl_cl_texture_new (gint size,
-                     const Babl *format)
+gegl_cl_texture_new (gint size)
 {
   cl_int errcode;
-  gint bpp = babl_format_get_bytes_per_pixel (format);
-  gint npixels = (size/bpp);
 
   GeglClTexture *texture = g_new (GeglClTexture, 1);
-  texture->format = babl_format ("RGBA float");
-  texture->size   = npixels * babl_format_get_bytes_per_pixel (texture->format);
-  texture->data   = gegl_clCreateBuffer (gegl_cl_get_context(), CL_MEM_READ_ONLY,
-                                         texture->size, NULL, &errcode);
+  texture->size = size;
+  texture->data  = gegl_clCreateBuffer (gegl_cl_get_context(), CL_MEM_READ_ONLY,
+                                        size, NULL, &errcode);
   if (errcode != CL_SUCCESS)
   {
     g_free(texture);
@@ -38,59 +32,21 @@ gegl_cl_texture_free (GeglClTexture *texture)
 void
 gegl_cl_texture_get (const GeglClTexture *texture,
                      gpointer             dst,
-                     const Babl          *format)
+                     const gint           size);
 {
-  gpointer buf;
-
-  if (format != NULL && format != texture->format)
-    buf = g_malloc (texture->size);
-  else
-    buf = dst;
-
   gegl_clEnqueueReadBuffer(gegl_cl_get_command_queue(), 
-                           texture->data, CL_TRUE, 0, texture->size, buf,
+                           texture->data, CL_TRUE, 0, size, dst,
                            0, NULL, NULL);
   gegl_clFinish(gegl_cl_get_command_queue());
-
-  if (format != NULL && format != texture->format)
-    {
-      Babl *fish = babl_fish ((gpointer) texture->format,
-                              (gpointer) format);
-      gint cl_bpp  = babl_format_get_bytes_per_pixel (texture->format);
-      gint npixels = texture->size/cl_bpp;
-      babl_process (fish, buf, dst, npixels);
-    }
-
-  if (buf != dst)
-    g_free (buf);
 }
 
 void
 gegl_cl_texture_set (GeglClTexture  *texture,
                      const gpointer  src,
-                     const Babl     *format)
+                     const gint      size)
 {
-  gpointer buf;
-
-  if (format != NULL && format != texture->format)
-    {
-      Babl *fish = babl_fish ((gpointer) format,
-                              (gpointer) texture->format);
-
-      gint cl_bpp  = babl_format_get_bytes_per_pixel (texture->format);
-      gint npixels = texture->size/cl_bpp;
-
-      buf = g_malloc (texture->size);
-      babl_process (fish, src, buf, npixels);
-    }
-  else
-    buf = src;
-
   gegl_clEnqueueWriteBuffer(gegl_cl_get_command_queue(), 
-                            texture->data, CL_TRUE, 0, texture->size, buf,
+                            texture->data, CL_TRUE, 0, size, src,
                             0, NULL, NULL);
   gegl_clFinish(gegl_cl_get_command_queue());
-
-  if (buf != src)
-    g_free (buf);
 }
diff --git a/gegl/opencl/gegl-cl-texture.h b/gegl/opencl/gegl-cl-texture.h
index b66b94a..ea05cbc 100644
--- a/gegl/opencl/gegl-cl-texture.h
+++ b/gegl/opencl/gegl-cl-texture.h
@@ -1,7 +1,6 @@
 #ifndef __GEGL_CL_TEXTURE_H__
 #define __GEGL_CL_TEXTURE_H__
 
-#include <babl/babl.h>
 #include <glib-object.h>
 
 #include "gegl-cl-init.h"
@@ -11,26 +10,23 @@ G_BEGIN_DECLS
 struct _GeglClTexture
 {
   cl_mem data;
-  gint size;
-  Babl *format;
 };
 
 typedef struct _GeglClTexture GeglClTexture;
 
 GType           gegl_cl_texture_get_type (void) G_GNUC_CONST;
 
-GeglClTexture  *gegl_cl_texture_new      (gint                 size,
-                                          const Babl          *format);
+GeglClTexture  *gegl_cl_texture_new      (gint                 size);
 
 void            gegl_cl_texture_free     (GeglClTexture       *texture);
 
 void            gegl_cl_texture_get      (const GeglClTexture *texture,
                                           gpointer             dest,
-                                          const Babl          *format);
+                                          gint                 size);
 
 void            gegl_cl_texture_set      (GeglClTexture       *texture,
                                           const gpointer       src,
-                                          const Babl          *format);
+                                          gint                 size);
 
 GeglClTexture  *gegl_cl_texture_dup      (const GeglClTexture *texture);
 



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