[gegl/gsoc2009-gpu] gegl_gpu_texture_set(): fix segmentation fault when the texture roi is NULL



commit 0de20c3efb389bbc45b3bf6b610c899d8ce8cf73
Author: Jerson Michael Perpetua <jersonperpetua gmail com>
Date:   Sun Aug 23 22:21:38 2009 +0800

    gegl_gpu_texture_set(): fix segmentation fault when the texture roi is NULL

 gegl/gpu/gegl-gpu-texture.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/gegl/gpu/gegl-gpu-texture.c b/gegl/gpu/gegl-gpu-texture.c
index 2d124db..27248cf 100644
--- a/gegl/gpu/gegl-gpu-texture.c
+++ b/gegl/gpu/gegl-gpu-texture.c
@@ -143,7 +143,10 @@ gegl_gpu_texture_set (GeglGpuTexture      *texture,
       Babl *fish = babl_fish ((gpointer) format,
                               (gpointer) texture->format);
 
-      gint pixel_count = roi->width * roi->height;
+      gint pixel_count = (roi != NULL)
+                           ? roi->width * roi->height
+                           : gegl_gpu_texture_get_pixel_count (texture);
+
       gint bpp         = babl_format_get_bytes_per_pixel (texture->format);
 
       buf = g_malloc (pixel_count * bpp);
@@ -156,15 +159,12 @@ gegl_gpu_texture_set (GeglGpuTexture      *texture,
                       && roi->width == texture->width
                       && roi->height == texture->height))
     {
-      gint width  = texture->width;
-      gint height = texture->height;
-
       glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture->handle);
       glTexImage2D  (GL_TEXTURE_RECTANGLE_ARB,
                      0,
                      GL_RGBA32F_ARB,
-                     width,
-                     height,
+                     texture->width,
+                     texture->height,
                      0,
                      GL_RGBA,
                      GL_FLOAT,
@@ -220,6 +220,7 @@ gegl_gpu_texture_copy (const GeglGpuTexture *src,
   else
     roi = src_rect;
 
+
   if (src->format == dest->format)
     {
       glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT,



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