mirror of
https://github.com/brl/mutter.git
synced 2025-03-03 19:58:10 +00:00
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:
parent
6941ff2c71
commit
e8eb9793e6
@ -163,6 +163,8 @@ cogl_driver_sources += \
|
|||||||
$(srcdir)/driver/gl/cogl-util-gl.c \
|
$(srcdir)/driver/gl/cogl-util-gl.c \
|
||||||
$(srcdir)/driver/gl/cogl-framebuffer-gl-private.h \
|
$(srcdir)/driver/gl/cogl-framebuffer-gl-private.h \
|
||||||
$(srcdir)/driver/gl/cogl-framebuffer-gl.c \
|
$(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-private.h \
|
||||||
$(srcdir)/driver/gl/cogl-texture-2d-gl.c \
|
$(srcdir)/driver/gl/cogl-texture-2d-gl.c \
|
||||||
$(srcdir)/driver/gl/cogl-attribute-gl-private.h \
|
$(srcdir)/driver/gl/cogl-attribute-gl-private.h \
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include "cogl1-context.h"
|
#include "cogl1-context.h"
|
||||||
#include "cogl-sub-texture.h"
|
#include "cogl-sub-texture.h"
|
||||||
#include "cogl-error-private.h"
|
#include "cogl-error-private.h"
|
||||||
|
#include "cogl-texture-gl-private.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "cogl-texture-driver.h"
|
#include "cogl-texture-driver.h"
|
||||||
#include "cogl-texture-rectangle-private.h"
|
#include "cogl-texture-rectangle-private.h"
|
||||||
#include "cogl-texture-2d.h"
|
#include "cogl-texture-2d.h"
|
||||||
|
#include "cogl-texture-gl-private.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "cogl-texture-2d-gl.h"
|
#include "cogl-texture-2d-gl.h"
|
||||||
#include "cogl-texture-2d-private.h"
|
#include "cogl-texture-2d-private.h"
|
||||||
#include "cogl-texture-2d-sliced-private.h"
|
#include "cogl-texture-2d-sliced-private.h"
|
||||||
|
#include "cogl-texture-gl-private.h"
|
||||||
#include "cogl-texture-driver.h"
|
#include "cogl-texture-driver.h"
|
||||||
#include "cogl-context-private.h"
|
#include "cogl-context-private.h"
|
||||||
#include "cogl-object-private.h"
|
#include "cogl-object-private.h"
|
||||||
|
@ -209,17 +209,6 @@ _cogl_texture_transform_quad_coords_to_gl (CoglTexture *texture,
|
|||||||
GLenum
|
GLenum
|
||||||
_cogl_texture_get_gl_format (CoglTexture *texture);
|
_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
|
void
|
||||||
_cogl_texture_pre_paint (CoglTexture *texture, CoglTexturePrePaintFlags flags);
|
_cogl_texture_pre_paint (CoglTexture *texture, CoglTexturePrePaintFlags flags);
|
||||||
|
|
||||||
@ -248,14 +237,6 @@ _cogl_texture_prepare_for_upload (CoglBitmap *src_bmp,
|
|||||||
GLenum *out_gltype,
|
GLenum *out_gltype,
|
||||||
CoglError **error);
|
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
|
CoglBool
|
||||||
_cogl_texture_is_foreign (CoglTexture *texture);
|
_cogl_texture_is_foreign (CoglTexture *texture);
|
||||||
|
|
||||||
|
@ -269,49 +269,6 @@ _cogl_texture_prepare_for_upload (CoglBitmap *src_bmp,
|
|||||||
return dst_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
|
CoglBool
|
||||||
_cogl_texture_is_foreign (CoglTexture *texture)
|
_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);
|
|
||||||
}
|
|
||||||
|
@ -920,7 +920,7 @@ _cogl_texture_get_gl_format
|
|||||||
_cogl_texture_init
|
_cogl_texture_init
|
||||||
_cogl_texture_is_foreign
|
_cogl_texture_is_foreign
|
||||||
_cogl_texture_prepare_for_upload
|
_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_pre_paint
|
||||||
_cogl_texture_register_texture_type
|
_cogl_texture_register_texture_type
|
||||||
_cogl_texture_gl_flush_legacy_texobj_filters
|
_cogl_texture_gl_flush_legacy_texobj_filters
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "cogl-framebuffer-gl-private.h"
|
#include "cogl-framebuffer-gl-private.h"
|
||||||
#include "cogl-buffer-gl-private.h"
|
#include "cogl-buffer-gl-private.h"
|
||||||
#include "cogl-error-private.h"
|
#include "cogl-error-private.h"
|
||||||
|
#include "cogl-texture-gl-private.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "cogl-texture-private.h"
|
#include "cogl-texture-private.h"
|
||||||
#include "cogl-framebuffer-private.h"
|
#include "cogl-framebuffer-private.h"
|
||||||
#include "cogl-offscreen.h"
|
#include "cogl-offscreen.h"
|
||||||
|
#include "cogl-texture-gl-private.h"
|
||||||
|
|
||||||
#include "cogl-pipeline-progend-glsl-private.h"
|
#include "cogl-pipeline-progend-glsl-private.h"
|
||||||
|
|
||||||
|
49
cogl/driver/gl/cogl-texture-gl-private.h
Normal file
49
cogl/driver/gl/cogl-texture-gl-private.h
Normal 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_ */
|
94
cogl/driver/gl/cogl-texture-gl.c
Normal file
94
cogl/driver/gl/cogl-texture-gl.c
Normal 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);
|
||||||
|
}
|
@ -42,6 +42,7 @@
|
|||||||
#include "cogl-pipeline-opengl-private.h"
|
#include "cogl-pipeline-opengl-private.h"
|
||||||
#include "cogl-util-gl-private.h"
|
#include "cogl-util-gl-private.h"
|
||||||
#include "cogl-error-private.h"
|
#include "cogl-error-private.h"
|
||||||
|
#include "cogl-texture-gl-private.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.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))
|
if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
|
||||||
GE( ctx, glPixelStorei (GL_UNPACK_IMAGE_HEIGHT, image_height) );
|
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
|
static void
|
||||||
@ -147,7 +148,8 @@ prep_gl_for_pixels_download_full (CoglContext *ctx,
|
|||||||
if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
|
if (cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
|
||||||
GE( ctx, glPixelStorei (GL_PACK_IMAGE_HEIGHT, image_height) );
|
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,
|
image_width,
|
||||||
pixels_rowstride);
|
pixels_rowstride);
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include "cogl-primitives.h"
|
#include "cogl-primitives.h"
|
||||||
#include "cogl-util-gl-private.h"
|
#include "cogl-util-gl-private.h"
|
||||||
#include "cogl-error-private.h"
|
#include "cogl-error-private.h"
|
||||||
|
#include "cogl-texture-gl-private.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -115,7 +116,7 @@ prep_gl_for_pixels_upload_full (CoglContext *ctx,
|
|||||||
g_assert (pixels_src_y == 0);
|
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
|
static void
|
||||||
@ -135,7 +136,8 @@ _cogl_texture_driver_prep_gl_for_pixels_download (CoglContext *ctx,
|
|||||||
int image_width,
|
int image_width,
|
||||||
int pixels_bpp)
|
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,
|
image_width,
|
||||||
pixels_rowstride);
|
pixels_rowstride);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include "cogl-pipeline-opengl-private.h"
|
#include "cogl-pipeline-opengl-private.h"
|
||||||
#include "cogl-xlib.h"
|
#include "cogl-xlib.h"
|
||||||
#include "cogl-error-private.h"
|
#include "cogl-error-private.h"
|
||||||
|
#include "cogl-texture-gl-private.h"
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user