summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2012-11-08 23:00:49 +0000
committerRobert Bragg <robert@linux.intel.com>2012-11-26 23:33:07 +0000
commit2c9e81de70cc02d72b1ce9013c49e39300a05b6a (patch)
tree7a7be472cd3dbd545aa65387d0589818053903f1
parent6d6a277b8e9a63a8268046e5258877ba94a1da5b (diff)
downloadcogl-2c9e81de70cc02d72b1ce9013c49e39300a05b6a.tar.gz
moves some gl texture code too cogl-texture-gl.c
This adds a driver/gl/cogl-texture-gl.c file and moves some gl specific bits from cogl-texture.c into it. The moved symbols were also given a _gl_ infix and the calling code was updated accordingly. Reviewed-by: Neil Roberts <neil@linux.intel.com>
-rw-r--r--cogl/Makefile.am2
-rw-r--r--cogl/cogl-atlas-texture.c1
-rw-r--r--cogl/cogl-sub-texture.c1
-rw-r--r--cogl/cogl-texture-2d-sliced.c1
-rw-r--r--cogl/cogl-texture-private.h19
-rw-r--r--cogl/cogl-texture.c64
-rw-r--r--cogl/cogl.symbols2
-rw-r--r--cogl/driver/gl/cogl-framebuffer-gl.c1
-rw-r--r--cogl/driver/gl/cogl-pipeline-opengl.c1
-rw-r--r--cogl/driver/gl/cogl-texture-gl-private.h49
-rw-r--r--cogl/driver/gl/cogl-texture-gl.c94
-rw-r--r--cogl/driver/gl/gl/cogl-texture-driver-gl.c6
-rw-r--r--cogl/driver/gl/gles/cogl-texture-driver-gles.c6
-rw-r--r--cogl/winsys/cogl-texture-pixmap-x11.c1
14 files changed, 160 insertions, 88 deletions
diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index 937a64b7..a026e91d 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -144,6 +144,8 @@ cogl_driver_sources += \
$(srcdir)/driver/gl/cogl-util-gl.c \
$(srcdir)/driver/gl/cogl-framebuffer-gl-private.h \
$(srcdir)/driver/gl/cogl-framebuffer-gl.c \
+ $(srcdir)/driver/gl/cogl-texture-gl-private.h \
+ $(srcdir)/driver/gl/cogl-texture-gl.c \
$(srcdir)/driver/gl/cogl-texture-2d-gl-private.h \
$(srcdir)/driver/gl/cogl-texture-2d-gl.c \
$(srcdir)/driver/gl/cogl-attribute-gl-private.h \
diff --git a/cogl/cogl-atlas-texture.c b/cogl/cogl-atlas-texture.c
index 1ea22601..77e52f90 100644
--- a/cogl/cogl-atlas-texture.c
+++ b/cogl/cogl-atlas-texture.c
@@ -45,6 +45,7 @@
#include "cogl1-context.h"
#include "cogl-sub-texture.h"
#include "cogl-error-private.h"
+#include "cogl-texture-gl-private.h"
#include <stdlib.h>
diff --git a/cogl/cogl-sub-texture.c b/cogl/cogl-sub-texture.c
index eb8f0979..fb2cf8ee 100644
--- a/cogl/cogl-sub-texture.c
+++ b/cogl/cogl-sub-texture.c
@@ -38,6 +38,7 @@
#include "cogl-texture-driver.h"
#include "cogl-texture-rectangle-private.h"
#include "cogl-texture-2d.h"
+#include "cogl-texture-gl-private.h"
#include <string.h>
#include <math.h>
diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c
index ce498d3a..29784544 100644
--- a/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl-texture-2d-sliced.c
@@ -39,6 +39,7 @@
#include "cogl-texture-2d-gl.h"
#include "cogl-texture-2d-private.h"
#include "cogl-texture-2d-sliced-private.h"
+#include "cogl-texture-gl-private.h"
#include "cogl-texture-driver.h"
#include "cogl-context-private.h"
#include "cogl-object-private.h"
diff --git a/cogl/cogl-texture-private.h b/cogl/cogl-texture-private.h
index e907242c..1619277a 100644
--- a/cogl/cogl-texture-private.h
+++ b/cogl/cogl-texture-private.h
@@ -210,17 +210,6 @@ GLenum
_cogl_texture_get_gl_format (CoglTexture *texture);
void
-_cogl_texture_gl_flush_legacy_texobj_wrap_modes (CoglTexture *texture,
- GLenum wrap_mode_s,
- GLenum wrap_mode_t,
- GLenum wrap_mode_p);
-
-void
-_cogl_texture_gl_flush_legacy_texobj_filters (CoglTexture *texture,
- GLenum min_filter,
- GLenum mag_filter);
-
-void
_cogl_texture_pre_paint (CoglTexture *texture, CoglTexturePrePaintFlags flags);
void
@@ -248,14 +237,6 @@ _cogl_texture_prepare_for_upload (CoglBitmap *src_bmp,
GLenum *out_gltype,
CoglError **error);
-void
-_cogl_texture_prep_gl_alignment_for_pixels_upload (int pixels_rowstride);
-
-void
-_cogl_texture_prep_gl_alignment_for_pixels_download (int bpp,
- int width,
- int rowstride);
-
CoglBool
_cogl_texture_is_foreign (CoglTexture *texture);
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index caa8f87f..69581601 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -239,49 +239,6 @@ _cogl_texture_prepare_for_upload (CoglBitmap *src_bmp,
return dst_bmp;
}
-static inline int
-calculate_alignment (int rowstride)
-{
- int alignment = 1 << (_cogl_util_ffs (rowstride) - 1);
-
- return MIN (alignment, 8);
-}
-
-void
-_cogl_texture_prep_gl_alignment_for_pixels_upload (int pixels_rowstride)
-{
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
- GE( ctx, glPixelStorei (GL_UNPACK_ALIGNMENT,
- calculate_alignment (pixels_rowstride)) );
-}
-
-void
-_cogl_texture_prep_gl_alignment_for_pixels_download (int bpp,
- int width,
- int rowstride)
-{
- int alignment;
-
- _COGL_GET_CONTEXT (ctx, NO_RETVAL);
-
- /* If no padding is needed then we can always use an alignment of 1.
- * We want to do this even though it is equivalent to the alignment
- * of the rowstride because the Intel driver in Mesa currently has
- * an optimisation when reading data into a PBO that only works if
- * the alignment is exactly 1.
- *
- * https://bugs.freedesktop.org/show_bug.cgi?id=46632
- */
-
- if (rowstride == bpp * width)
- alignment = 1;
- else
- alignment = calculate_alignment (rowstride);
-
- GE( ctx, glPixelStorei (GL_PACK_ALIGNMENT, alignment) );
-}
-
CoglBool
_cogl_texture_is_foreign (CoglTexture *texture)
{
@@ -1247,24 +1204,3 @@ _cogl_texture_spans_foreach_in_region (CoglSpan *x_spans,
}
}
}
-
-void
-_cogl_texture_gl_flush_legacy_texobj_wrap_modes (CoglTexture *texture,
- GLenum wrap_mode_s,
- GLenum wrap_mode_t,
- GLenum wrap_mode_p)
-{
- texture->vtable->gl_flush_legacy_texobj_wrap_modes (texture,
- wrap_mode_s,
- wrap_mode_t,
- wrap_mode_p);
-}
-
-void
-_cogl_texture_gl_flush_legacy_texobj_filters (CoglTexture *texture,
- GLenum min_filter,
- GLenum mag_filter)
-{
- texture->vtable->gl_flush_legacy_texobj_filters (texture,
- min_filter, mag_filter);
-}
diff --git a/cogl/cogl.symbols b/cogl/cogl.symbols
index 9c773dc3..99d8a055 100644
--- a/cogl/cogl.symbols
+++ b/cogl/cogl.symbols
@@ -673,7 +673,7 @@ _cogl_texture_get_gl_format
_cogl_texture_init
_cogl_texture_is_foreign
_cogl_texture_prepare_for_upload
-_cogl_texture_prep_gl_alignment_for_pixels_upload
+_cogl_texture_gl_prep_alignment_for_pixels_upload
_cogl_texture_pre_paint
_cogl_texture_register_texture_type
_cogl_texture_gl_flush_legacy_texobj_filters
diff --git a/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/driver/gl/cogl-framebuffer-gl.c
index 43874f69..23cf1a74 100644
--- a/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -31,6 +31,7 @@
#include "cogl-framebuffer-gl-private.h"
#include "cogl-buffer-gl-private.h"
#include "cogl-error-private.h"
+#include "cogl-texture-gl-private.h"
#include <glib.h>
diff --git a/cogl/driver/gl/cogl-pipeline-opengl.c b/cogl/driver/gl/cogl-pipeline-opengl.c
index a65caf9a..1ece0a7c 100644
--- a/cogl/driver/gl/cogl-pipeline-opengl.c
+++ b/cogl/driver/gl/cogl-pipeline-opengl.c
@@ -36,6 +36,7 @@
#include "cogl-texture-private.h"
#include "cogl-framebuffer-private.h"
#include "cogl-offscreen.h"
+#include "cogl-texture-gl-private.h"
#include "cogl-pipeline-progend-glsl-private.h"
diff --git a/cogl/driver/gl/cogl-texture-gl-private.h b/cogl/driver/gl/cogl-texture-gl-private.h
new file mode 100644
index 00000000..b44861c9
--- /dev/null
+++ b/cogl/driver/gl/cogl-texture-gl-private.h
@@ -0,0 +1,49 @@
+/*
+ * Cogl
+ *
+ * An object oriented GL/GLES Abstraction/Utility Layer
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * 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 2 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 this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef _COGL_TEXTURE_GL_PRIVATE_H_
+#define _COGL_TEXTURE_GL_PRIVATE_H_
+
+#include "cogl-context.h"
+
+void
+_cogl_texture_gl_prep_alignment_for_pixels_upload (CoglContext *ctx,
+ int pixels_rowstride);
+
+void
+_cogl_texture_gl_prep_alignment_for_pixels_download (CoglContext *ctx,
+ int bpp,
+ int width,
+ int rowstride);
+
+void
+_cogl_texture_gl_flush_legacy_texobj_wrap_modes (CoglTexture *texture,
+ unsigned int wrap_mode_s,
+ unsigned int wrap_mode_t,
+ unsigned int wrap_mode_p);
+
+void
+_cogl_texture_gl_flush_legacy_texobj_filters (CoglTexture *texture,
+ unsigned int min_filter,
+ unsigned int mag_filter);
+
+#endif /* _COGL_TEXTURE_GL_PRIVATE_H_ */
diff --git a/cogl/driver/gl/cogl-texture-gl.c b/cogl/driver/gl/cogl-texture-gl.c
new file mode 100644
index 00000000..a9f0d32b
--- /dev/null
+++ b/cogl/driver/gl/cogl-texture-gl.c
@@ -0,0 +1,94 @@
+/*
+ * Cogl
+ *
+ * An object oriented GL/GLES Abstraction/Utility Layer
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * 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 2 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 this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <strings.h>
+
+#include "cogl-internal.h"
+#include "cogl-context-private.h"
+#include "cogl-texture-gl-private.h"
+#include "cogl-util.h"
+
+static inline int
+calculate_alignment (int rowstride)
+{
+ int alignment = 1 << (_cogl_util_ffs (rowstride) - 1);
+
+ return MIN (alignment, 8);
+}
+
+void
+_cogl_texture_gl_prep_alignment_for_pixels_upload (CoglContext *ctx,
+ int pixels_rowstride)
+{
+ GE( ctx, glPixelStorei (GL_UNPACK_ALIGNMENT,
+ calculate_alignment (pixels_rowstride)) );
+}
+
+void
+_cogl_texture_gl_prep_alignment_for_pixels_download (CoglContext *ctx,
+ int bpp,
+ int width,
+ int rowstride)
+{
+ int alignment;
+
+ /* If no padding is needed then we can always use an alignment of 1.
+ * We want to do this even though it is equivalent to the alignment
+ * of the rowstride because the Intel driver in Mesa currently has
+ * an optimisation when reading data into a PBO that only works if
+ * the alignment is exactly 1.
+ *
+ * https://bugs.freedesktop.org/show_bug.cgi?id=46632
+ */
+
+ if (rowstride == bpp * width)
+ alignment = 1;
+ else
+ alignment = calculate_alignment (rowstride);
+
+ GE( ctx, glPixelStorei (GL_PACK_ALIGNMENT, alignment) );
+}
+
+void
+_cogl_texture_gl_flush_legacy_texobj_wrap_modes (CoglTexture *texture,
+ unsigned int wrap_mode_s,
+ unsigned int wrap_mode_t,
+ unsigned int wrap_mode_p)
+{
+ texture->vtable->gl_flush_legacy_texobj_wrap_modes (texture,
+ wrap_mode_s,
+ wrap_mode_t,
+ wrap_mode_p);
+}
+
+void
+_cogl_texture_gl_flush_legacy_texobj_filters (CoglTexture *texture,
+ unsigned int min_filter,
+ unsigned int mag_filter)
+{
+ texture->vtable->gl_flush_legacy_texobj_filters (texture,
+ min_filter, mag_filter);
+}
diff --git a/cogl/driver/gl/gl/cogl-texture-driver-gl.c b/cogl/driver/gl/gl/cogl-texture-driver-gl.c
index 2443b16b..0e72ac99 100644
--- a/cogl/driver/gl/gl/cogl-texture-driver-gl.c
+++ b/cogl/driver/gl/gl/cogl-texture-driver-gl.c
@@ -41,6 +41,7 @@
#include "cogl-pipeline-opengl-private.h"
#include "cogl-util-gl-private.h"
#include "cogl-error-private.h"
+#include "cogl-texture-gl-private.h"
#include <string.h>
#include <stdlib.h>
@@ -116,7 +117,7 @@ prep_gl_for_pixels_upload_full (CoglContext *ctx,
if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
GE( ctx, glPixelStorei (GL_UNPACK_IMAGE_HEIGHT, image_height) );
- _cogl_texture_prep_gl_alignment_for_pixels_upload (pixels_rowstride);
+ _cogl_texture_gl_prep_alignment_for_pixels_upload (ctx, pixels_rowstride);
}
static void
@@ -146,7 +147,8 @@ prep_gl_for_pixels_download_full (CoglContext *ctx,
if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
GE( ctx, glPixelStorei (GL_PACK_IMAGE_HEIGHT, image_height) );
- _cogl_texture_prep_gl_alignment_for_pixels_download (pixels_bpp,
+ _cogl_texture_gl_prep_alignment_for_pixels_download (ctx,
+ pixels_bpp,
image_width,
pixels_rowstride);
}
diff --git a/cogl/driver/gl/gles/cogl-texture-driver-gles.c b/cogl/driver/gl/gles/cogl-texture-driver-gles.c
index 7b17ef8a..f13f2782 100644
--- a/cogl/driver/gl/gles/cogl-texture-driver-gles.c
+++ b/cogl/driver/gl/gles/cogl-texture-driver-gles.c
@@ -41,6 +41,7 @@
#include "cogl-object-private.h"
#include "cogl-util-gl-private.h"
#include "cogl-error-private.h"
+#include "cogl-texture-gl-private.h"
#include <string.h>
#include <stdlib.h>
@@ -114,7 +115,7 @@ prep_gl_for_pixels_upload_full (CoglContext *ctx,
g_assert (pixels_src_y == 0);
}
- _cogl_texture_prep_gl_alignment_for_pixels_upload (pixels_rowstride);
+ _cogl_texture_gl_prep_alignment_for_pixels_upload (ctx, pixels_rowstride);
}
static void
@@ -134,7 +135,8 @@ _cogl_texture_driver_prep_gl_for_pixels_download (CoglContext *ctx,
int image_width,
int pixels_bpp)
{
- _cogl_texture_prep_gl_alignment_for_pixels_download (pixels_bpp,
+ _cogl_texture_gl_prep_alignment_for_pixels_download (ctx,
+ pixels_bpp,
image_width,
pixels_rowstride);
}
diff --git a/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/winsys/cogl-texture-pixmap-x11.c
index 31492f9b..4f642375 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.c
+++ b/cogl/winsys/cogl-texture-pixmap-x11.c
@@ -48,6 +48,7 @@
#include "cogl-pipeline-opengl-private.h"
#include "cogl-xlib.h"
#include "cogl-error-private.h"
+#include "cogl-texture-gl-private.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>