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>

(cherry picked from commit 2c9e81de70cc02d72b1ce9013c49e39300a05b6a)
This commit is contained in:
Robert Bragg 2012-11-08 23:00:49 +00:00
parent 6941ff2c71
commit e8eb9793e6
14 changed files with 160 additions and 88 deletions

View File

@ -163,6 +163,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 \

View File

@ -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>

View File

@ -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>

View File

@ -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"

View File

@ -209,17 +209,6 @@ _cogl_texture_transform_quad_coords_to_gl (CoglTexture *texture,
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);
@ -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);

View File

@ -269,49 +269,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)
{
@ -1376,24 +1333,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);
}

View File

@ -920,7 +920,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

View File

@ -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>

View File

@ -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"

View File

@ -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_ */

View File

@ -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);
}

View File

@ -42,6 +42,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>
@ -117,7 +118,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
@ -147,7 +148,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);
}

View File

@ -42,6 +42,7 @@
#include "cogl-primitives.h"
#include "cogl-util-gl-private.h"
#include "cogl-error-private.h"
#include "cogl-texture-gl-private.h"
#include <string.h>
#include <stdlib.h>
@ -115,7 +116,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
@ -135,7 +136,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);
}

View File

@ -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>