[gegl/gsoc2009-gpu: 4/15] Add a few new files for GPU support
- From: Martin Nordholts <martinn src gnome org>
- To: svn-commits-list gnome org
- Subject: [gegl/gsoc2009-gpu: 4/15] Add a few new files for GPU support
- Date: Wed, 24 Jun 2009 05:38:19 +0000 (UTC)
commit 1d2c3b0b2cf352caca35f50a31d90d9daa643be8
Author: Jerson Michael Perpetua <jersonperpetua gmail com>
Date: Wed Jun 17 00:11:57 2009 +0800
Add a few new files for GPU support
* gegl-gpu-init.[c|h] - OpenGL initialization
* gegl-gpu-texture.[c|h] - GeglGpuTexture access methods
* gegl-gpu-types.h - Wrappers to existing OpenGL types and the
GeglGpuTexture structure definition
* Add a new Makefile.am to gegl/gegl/gpu
* Adjust gegl/configure.ac and gegl/gegl/Makefile.am to make GEGL
buildable again
configure.ac | 40 +++++++
gegl/Makefile.am | 7 +-
gegl/gpu/Makefile.am | 28 +++++
gegl/gpu/gegl-gpu-init.c | 93 +++++++++++++++
gegl/gpu/gegl-gpu-init.h | 36 ++++++
gegl/gpu/gegl-gpu-texture.c | 271 +++++++++++++++++++++++++++++++++++++++++++
gegl/gpu/gegl-gpu-texture.h | 61 ++++++++++
gegl/gpu/gegl-gpu-types.h | 47 ++++++++
8 files changed, 582 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ee30b02..60a233f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -950,6 +950,44 @@ AM_CONDITIONAL(HAVE_SPIRO, test "$spiro_ok" = "yes")
AC_SUBST(LIBSPIRO)
+#######################
+# Check for GPU support
+#######################
+
+AC_ARG_WITH(gpu, [ --without-gpu build without GPU support])
+
+have_gpu="no"
+if test "x$with_gpu" != "xno"; then
+ PKG_CHECK_MODULES(GPU, gl,
+ have_gpu="yes",
+ have_gpu="no (OpenGL library not found)")
+ # verify the presence of the glut.h header
+ if test "x$have_gpu" = "xyes"; then
+ AC_MSG_CHECKING([for GL/glut.h])
+ AC_TRY_CPP([#include <GL/glut.h>],
+ have_gpu="yes",
+ have_gpu="no (Can't include GL/glut.h)")
+ AC_MSG_RESULT($gpu_ok)
+ fi
+ # verify the presence of the glew.h header
+ if test "x$have_gpu" = "xyes"; then
+ AC_MSG_CHECKING([for GL/glew.h])
+ AC_TRY_CPP([#include <GL/glew.h>],
+ have_gpu="yes"
+ AC_DEFINE(HAVE_GPU, 1,
+ [Define to 1 if all OpenGL dependencies are available])
+ GPU_LIBS="$GPU_LIBS -lglut -lGLEW",
+ have_gpu="no (Can't include GL/glew.h)")
+ AC_MSG_RESULT($have_gpu)
+ fi
+fi
+
+AM_CONDITIONAL(HAVE_GPU, test "x$have_gpu" = "xyes")
+
+AC_SUBST(GPU_CFLAGS)
+AC_SUBST(GPU_LIBS)
+
+
#######################
@@ -977,6 +1015,7 @@ gegl/Makefile
gegl/gegl-version.h
gegl/buffer/Makefile
gegl/graph/Makefile
+gegl/gpu/Makefile
gegl/module/Makefile
gegl/operation/Makefile
gegl/process/Makefile
@@ -1013,6 +1052,7 @@ Optional features:
Build workshop: $enable_workshop
Build website: $have_asciidoc
SIMD: sse:$enable_sse mmx:$enable_mmx
+ GPU: $have_gpu
Optional dependencies:
asciidoc: $have_asciidoc
diff --git a/gegl/Makefile.am b/gegl/Makefile.am
index eab0113..56c8722 100644
--- a/gegl/Makefile.am
+++ b/gegl/Makefile.am
@@ -2,12 +2,14 @@ if OS_WIN32
no_undefined = -no-undefined
endif
-SUBDIRS = buffer graph module operation process property-types
+SUBDIRS = buffer gpu graph module operation process property-types
AM_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_builddir)/gegl/buffer \
-I$(top_srcdir)/gegl/buffer \
+ -I$(top_builddir)/gegl/gpu \
+ -I$(top_srcdir)/gegl/gpu \
-I$(top_builddir)/gegl/property-types \
-I$(top_srcdir)/gegl/property-types \
-I$(top_builddir)/gegl/operation \
@@ -35,6 +37,8 @@ GEGL_public_HEADERS = \
gegl-plugin.h \
gegl-version.h \
buffer/gegl-buffer.h \
+ gpu/gegl-gpu-types.h \
+ gpu/gegl-gpu-texture.h \
property-types/gegl-paramspecs.h \
property-types/gegl-color.h \
property-types/gegl-path.h \
@@ -70,6 +74,7 @@ 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 \
diff --git a/gegl/gpu/Makefile.am b/gegl/gpu/Makefile.am
new file mode 100644
index 0000000..d6d66f9
--- /dev/null
+++ b/gegl/gpu/Makefile.am
@@ -0,0 +1,28 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_builddir)/gegl \
+ -I$(top_srcdir)/gegl \
+ -I$(top_builddir)/gegl/property-types \
+ -I$(top_srcdir)/gegl/property-types \
+ -I$(top_builddir)/gegl/buffer \
+ -I$(top_srcdir)/gegl/buffer
+
+AM_CFLAGS = $(DEP_CFLAGS) $(BABL_CFLAGS) $(GPU_CFLAGS)
+
+LIBS = $(GPU_LIBS)
+
+noinst_LTLIBRARIES = libgpu.la
+
+#libgpu_publicdir = $(includedir)/gegl-$(GEGL_API_VERSION)/gegl/gpu
+#libgpu_public_HEADERS = #
+
+libgpu_la_SOURCES = \
+ gegl-gpu-init.c \
+ gegl-gpu-texture.c \
+ \
+ gegl-gpu-init.h \
+ gegl-gpu-texture.h \
+ gegl-gpu-types.h
+
+#libgpu_la_SOURCES = $(libgpu_sources) $(libgpu_public_HEADERS)
+
diff --git a/gegl/gpu/gegl-gpu-init.c b/gegl/gpu/gegl-gpu-init.c
new file mode 100644
index 0000000..a191b0e
--- /dev/null
+++ b/gegl/gpu/gegl-gpu-init.c
@@ -0,0 +1,93 @@
+/* This file is part of GEGL.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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 2009 Jerson Michael Perpetua <jersonperpetua gmail com>
+ */
+
+#include <GL/glew.h>
+#include <GL/glut.h>
+
+#include "gegl-gpu-types.h"
+#include "gegl-gpu-init.h"
+
+static gint gpu_glut_window = -1;
+static gboolean gpu_is_accelerated = FALSE;
+static GeglGpuFramebufferHandle gpu_framebuffer = 0;
+static GSList *gpu_shader_programs = NULL;
+
+void
+gegl_gpu_init (gint *argc,
+ gchar ***argv)
+{
+ glutInit (argc, *argv);
+ gpu_glut_window = glutCreateWindow (NULL);
+ glewInit ();
+
+ if (glewIsSupported ("GL_VERSION_1_2")
+ && GLEW_ARB_fragment_shader
+ && GLEW_EXT_framebuffer_object
+ && GLEW_ARB_texture_rectangle
+ && GLEW_ARB_texture_float)
+ {
+ glGenFramebuffersEXT (1, &gpu_framebuffer);
+ glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, gpu_framebuffer);
+
+ glutSetWindow (gpu_glut_window);
+ glutHideWindow ();
+
+ gpu_is_accelerated = TRUE;
+ }
+}
+
+GeglGpuFramebufferHandle
+gegl_gpu_get_framebuffer (void)
+{
+ return gpu_framebuffer;
+}
+
+gboolean
+gegl_gpu_is_accelerated (void)
+{
+ return gpu_is_accelerated;
+}
+
+void
+gegl_gpu_register_shader_program (GeglGpuShaderProgramHandle gpu_shader_program)
+{
+ gpu_shader_programs = g_slist_prepend (gpu_shader_programs,
+ GUINT_TO_POINTER (gpu_shader_program));
+}
+
+void
+gegl_gpu_exit (void)
+{
+ GSList *iter;
+ iter = gpu_shader_programs;
+
+ while (iter)
+ {
+ glDeleteProgram (GPOINTER_TO_UINT (iter->data));
+ iter = iter->next;
+ }
+
+ g_slist_free (gpu_shader_programs);
+ gpu_shader_programs = NULL;
+
+ glDeleteFramebuffersEXT (1, &gpu_framebuffer);
+ gpu_framebuffer = 0;
+
+ glutDestroyWindow (gpu_glut_window);
+ gpu_glut_window = -1;
+}
diff --git a/gegl/gpu/gegl-gpu-init.h b/gegl/gpu/gegl-gpu-init.h
new file mode 100644
index 0000000..7035cc7
--- /dev/null
+++ b/gegl/gpu/gegl-gpu-init.h
@@ -0,0 +1,36 @@
+/* This file is part of GEGL.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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 2009 Jerson Michael Perpetua <jersonperpetua gmail com>
+ */
+
+#ifndef __GEGL_GPU_INIT_H__
+#define __GEGL_GPU_INIT_H__
+
+#include "gegl-gpu-types.h"
+
+G_BEGIN_DECLS
+
+void gegl_gpu_init (gint *argc,
+ gchar ***argv);
+void gegl_gpu_exit (void);
+GeglGpuFramebufferHandle gegl_gpu_get_framebuffer (void);
+gboolean gegl_gpu_is_accelerated (void);
+void gegl_gpu_register_shader_program
+ (GeglGpuShaderProgramHandle shaderProgram);
+
+G_END_DECLS
+
+#endif /* __GEGL_GPU_INIT_H__ */
diff --git a/gegl/gpu/gegl-gpu-texture.c b/gegl/gpu/gegl-gpu-texture.c
new file mode 100644
index 0000000..7302ef0
--- /dev/null
+++ b/gegl/gpu/gegl-gpu-texture.c
@@ -0,0 +1,271 @@
+/* This file is part of GEGL.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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 2009 Jerson Michael Perpetua <jersonperpetua gmail com>
+ */
+
+#include <GL/glew.h>
+#include <GL/glut.h>
+#include <babl/babl.h>
+
+#include "gegl.h"
+#include "gegl-types.h"
+#include "gegl-gpu-types.h"
+#include "gegl-gpu-texture.h"
+
+static void
+allocate_texture_data (GeglGpuTexture *texture)
+{
+ glGenTextures (1, &texture->handle);
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture->handle);
+
+ glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,
+ GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_RECTANGLE_ARB,
+ GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
+
+ glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA32F_ARB,
+ texture->width, texture->height, 0, GL_RGBA, GL_FLOAT, 0);
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
+
+ gegl_gpu_texture_clear (texture, NULL);
+}
+
+GeglGpuTexture *
+gegl_gpu_texture_new (gint width,
+ gint height,
+ const Babl *format)
+{
+ GeglGpuTexture *texture = g_new (GeglGpuTexture, 1);
+
+ texture->handle = 0;
+ texture->width = width;
+ texture->height = height;
+
+ /* implement storing of more compact formats later, up-sampling to
+ * RGBA floats will have to make do, for now
+ */
+ texture->format = babl_format ("RGBA float");
+ return texture;
+}
+
+void
+gegl_gpu_texture_free (GeglGpuTexture *texture)
+{
+ if (texture->handle > 0)
+ {
+ glDeleteTextures (1, &texture->handle);
+ }
+ g_free (texture);
+}
+
+void
+gegl_gpu_texture_get (GeglGpuTexture *texture,
+ const GeglRectangle *roi,
+ gpointer dest,
+ const Babl *format)
+{
+ gpointer buf;
+ gint pixel_count = (roi != NULL)
+ ? roi->width * roi->height
+ : gegl_gpu_texture_get_pixel_count (texture);
+
+ if (texture->handle == 0)
+ allocate_texture_data (texture);
+
+ if (format != NULL && format != texture->format)
+ {
+ gint bpp = babl_format_get_bytes_per_pixel (texture->format);
+ buf = g_malloc (pixel_count * bpp);
+ }
+ else
+ buf = dest;
+
+ if (roi == NULL || (roi->x == 0 && roi->y == 0
+ && roi->width == texture->width
+ && roi->height == texture->height))
+ {
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture->handle);
+ glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GL_FLOAT, buf);
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
+ }
+ else
+ {
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture->handle);
+ glReadPixels (roi->x, roi->y, roi->width, roi->height,
+ GL_RGBA, GL_FLOAT, buf);
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
+ }
+
+ if (buf != dest)
+ {
+ Babl *fish = babl_fish ((gpointer) texture->format,
+ (gpointer) format);
+
+ babl_process (fish, buf, dest, pixel_count);
+ g_free (buf);
+ }
+}
+
+void
+gegl_gpu_texture_set (GeglGpuTexture *texture,
+ const GeglRectangle *roi,
+ gpointer src,
+ const Babl *format)
+{
+ gpointer buf;
+
+ if (texture->handle == 0)
+ allocate_texture_data (texture);
+
+ if (format != NULL && format != texture->format)
+ {
+ Babl *fish = babl_fish ((gpointer) format,
+ (gpointer) texture->format);
+
+ gint pixel_count = roi->width * roi->height;
+ gint bpp = babl_format_get_bytes_per_pixel (texture->format);
+
+ buf = g_malloc (pixel_count * bpp);
+ babl_process (fish, src, buf, pixel_count);
+ }
+ else
+ buf = src;
+
+ if (roi == NULL || (roi->x == 0 && roi->y == 0
+ && 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, 0, GL_RGBA, GL_FLOAT, buf);
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
+ }
+ else
+ {
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture->handle);
+ glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, roi->x, roi->y,
+ roi->width, roi->height, GL_RGBA, GL_FLOAT, buf);
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
+ }
+
+ if (buf != src)
+ g_free (buf);
+}
+
+void
+gegl_gpu_texture_clear (GeglGpuTexture *texture,
+ const GeglRectangle *roi)
+{
+ gint bpp = babl_format_get_bytes_per_pixel (texture->format);
+
+ if (texture->handle == 0)
+ allocate_texture_data (texture);
+
+ if (roi == NULL || (roi->x == 0 && roi->y == 0
+ && roi->width == texture->width
+ && roi->height == texture->height))
+ {
+ gint width = texture->width;
+ gint height = texture->height;
+
+ gpointer buf = g_malloc0 (texture->width * texture->height * bpp);
+
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture->handle);
+ glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA32F_ARB,
+ width, height, 0, GL_RGBA, GL_FLOAT, buf);
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
+ }
+ else
+ {
+ gpointer buf = g_malloc0 (roi->width * roi->height * bpp);
+
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture->handle);
+ glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, roi->x, roi->y,
+ roi->width, roi->height, GL_RGBA, GL_FLOAT, buf);
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
+ }
+}
+
+void
+gegl_gpu_texture_copy (GeglGpuTexture *src,
+ const GeglRectangle *src_rect,
+ GeglGpuTexture *dest,
+ gint dest_x,
+ gint dest_y)
+{
+ if (src->handle == 0)
+ allocate_texture_data (src);
+
+ if (dest->handle == 0)
+ allocate_texture_data (dest);
+
+ if (src->format == dest->format)
+ {
+ glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT,
+ GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_RECTANGLE_ARB, src->handle, 0);
+
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, dest->handle);
+ glCopyTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, dest_x, dest_y,
+ src_rect->x, src_rect->y,
+ src_rect->width, src_rect->height);
+ glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 0);
+
+ glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT,
+ GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_RECTANGLE_ARB, 0, 0);
+ }
+ else
+ g_assert (0);
+}
+
+GeglGpuTexture *
+gegl_gpu_texture_dup (GeglGpuTexture *texture)
+{
+ GeglGpuTexture *result = gegl_gpu_texture_new (texture->width,
+ texture->height,
+ texture->format);
+
+ gegl_gpu_texture_copy (texture, NULL, result, 0, 0);
+ return result;
+}
+
+static GeglGpuTexture *
+gegl_gpu_texture_shallow_dup (const GeglGpuTexture *texture)
+{
+ GeglGpuTexture *result = g_new (GeglGpuTexture, 1);
+ *result = *texture;
+ return result;
+}
+
+GType
+gegl_gpu_texture_get_type (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static (
+ g_intern_static_string ("GeglGpuTexture"),
+ (GBoxedCopyFunc) gegl_gpu_texture_shallow_dup,
+ (GBoxedFreeFunc) g_free);
+
+ return our_type;
+}
diff --git a/gegl/gpu/gegl-gpu-texture.h b/gegl/gpu/gegl-gpu-texture.h
new file mode 100644
index 0000000..4833a20
--- /dev/null
+++ b/gegl/gpu/gegl-gpu-texture.h
@@ -0,0 +1,61 @@
+/* This file is part of GEGL.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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 2009 Jerson Michael Perpetua <jersonperpetua gmail com>
+ */
+
+#ifndef __GEGL_GPU_TEXTURE_H__
+#define __GEGL_GPU_TEXTURE_H__
+
+#include <babl/babl.h>
+
+#include "gegl.h"
+#include "gegl-types.h"
+#include "gegl-gpu-types.h"
+
+G_BEGIN_DECLS
+
+GType gegl_gpu_texture_get_type (void) G_GNUC_CONST;
+GeglGpuTexture *gegl_gpu_texture_new (gint width,
+ gint height,
+ const Babl *format);
+void gegl_gpu_texture_free (GeglGpuTexture *texture);
+void gegl_gpu_texture_get (GeglGpuTexture *texture,
+ const GeglRectangle *roi,
+ gpointer dest,
+ const Babl *format);
+void gegl_gpu_texture_set (GeglGpuTexture *texture,
+ const GeglRectangle *roi,
+ gpointer src,
+ const Babl *format);
+void gegl_gpu_texture_clear (GeglGpuTexture *texture,
+ const GeglRectangle *roi);
+void gegl_gpu_texture_copy (GeglGpuTexture *src,
+ const GeglRectangle *src_roi,
+ GeglGpuTexture *dest,
+ gint dest_x,
+ gint dest_y);
+GeglGpuTexture *gegl_gpu_texture_dup (GeglGpuTexture *texture);
+
+#define gegl_gpu_texture_get_width(texture) (texture->width)
+#define gegl_gpu_texture_get_height(texture) (texture->height)
+
+#define gegl_gpu_texture_get_pixel_count(texture) \
+ (gegl_gpu_texture_get_width(texture) \
+ * gegl_gpu_texture_get_height(texture))
+
+G_END_DECLS
+
+#endif /* __GEGL_GPU_TEXTURE_H__ */
diff --git a/gegl/gpu/gegl-gpu-types.h b/gegl/gpu/gegl-gpu-types.h
new file mode 100644
index 0000000..7c74a25
--- /dev/null
+++ b/gegl/gpu/gegl-gpu-types.h
@@ -0,0 +1,47 @@
+/* This file is part of GEGL.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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 2009 Jerson Michael Perpetua <jersonperpetua gmail com>
+ */
+
+#ifndef __GEGL_GPU_TYPES_H__
+#define __GEGL_GPU_TYPES_H__
+
+#include <GL/gl.h>
+#include <babl/babl.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef GLuint GeglGpuTextureHandle;
+typedef GLuint GeglGpuFramebufferHandle;
+typedef GLuint GeglGpuShaderProgramHandle;
+
+struct _GeglGpuTexture
+{
+ GeglGpuTextureHandle handle;
+
+ gint width;
+ gint height;
+ Babl *format;
+};
+GType gegl_gpu_texture_get_type (void) G_GNUC_CONST;
+#define GEGL_TYPE_GPU_TEXTURE (gegl_gpu_texture_get_type())
+
+typedef struct _GeglGpuTexture GeglGpuTexture;
+
+G_END_DECLS
+
+#endif /* __GEGL_GPU_TYPES_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]