mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
Don't include any GL header from the public GL headers
This splits the GL header inclusion from cogl-defines.h into a separate headear called cogl-gl-header.h which we will only include internally. That way we don't leak GL declarations out of our public headers. The texture functions that were using GLenum and GLuint in the public header have now changed to just use unsigned int. Note however that if an EGL winsys is enabled then it will still publicly include an EGL header. This is a bit more awkward to fix because we have public API which returns an EGLDisplay and we can't determine what type that is. There is also a conformance test which just verifies that no GL header has been included while compiling. The test isn't added to test-conform-main because it doesn't actually test anything at runtime. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit ef5680d3fda5df929dbd0b420c8f598ded58dfee)
This commit is contained in:
parent
e85a04f0ce
commit
6400b455b8
@ -34,9 +34,9 @@ AM_CPPFLAGS = \
|
|||||||
|
|
||||||
AM_CFLAGS = $(COGL_DEP_CFLAGS) $(COGL_EXTRA_CFLAGS) $(MAINTAINER_CFLAGS)
|
AM_CFLAGS = $(COGL_DEP_CFLAGS) $(COGL_EXTRA_CFLAGS) $(MAINTAINER_CFLAGS)
|
||||||
|
|
||||||
BUILT_SOURCES += cogl-defines.h
|
BUILT_SOURCES += cogl-defines.h cogl-gl-header.h
|
||||||
DISTCLEANFILES += cogl-defines.h
|
DISTCLEANFILES += cogl-defines.h cogl-gl-header.h
|
||||||
EXTRA_DIST += cogl-defines.h.in
|
EXTRA_DIST += cogl-defines.h.in cogl-gl-header.h.in
|
||||||
|
|
||||||
# Note: The cogl-1.0/cogl-gl-1.0 files are essentially for
|
# Note: The cogl-1.0/cogl-gl-1.0 files are essentially for
|
||||||
# compatability only. I'm not really sure who could possibly be using
|
# compatability only. I'm not really sure who could possibly be using
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "cogl-object-private.h"
|
#include "cogl-object-private.h"
|
||||||
#include "cogl-buffer.h"
|
#include "cogl-buffer.h"
|
||||||
#include "cogl-context.h"
|
#include "cogl-context.h"
|
||||||
|
#include "cogl-gl-header.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include "cogl-texture-rectangle.h"
|
#include "cogl-texture-rectangle.h"
|
||||||
#include "cogl-sampler-cache-private.h"
|
#include "cogl-sampler-cache-private.h"
|
||||||
#include "cogl-gpu-info-private.h"
|
#include "cogl-gpu-info-private.h"
|
||||||
|
#include "cogl-gl-header.h"
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#define __COGL_DEFINES_H__
|
#define __COGL_DEFINES_H__
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
@COGL_GL_HEADER_INCLUDES@
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -41,9 +40,6 @@ G_BEGIN_DECLS
|
|||||||
#define NativeWindowType EGLNativeWindowType
|
#define NativeWindowType EGLNativeWindowType
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GL_OES_EGL_image
|
|
||||||
#define GLeglImageOES void *
|
|
||||||
#endif
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
39
cogl/cogl-gl-header.h.in
Normal file
39
cogl/cogl-gl-header.h.in
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(CLUTTER_COMPILATION)
|
||||||
|
#error "cogl-gl-header.h should only be included when compiling Cogl"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __COGL_GL_HEADER_H__
|
||||||
|
#define __COGL_GL_HEADER_H__
|
||||||
|
|
||||||
|
#include "cogl-defines.h"
|
||||||
|
|
||||||
|
@COGL_GL_HEADER_INCLUDES@
|
||||||
|
|
||||||
|
#ifndef GL_OES_EGL_image
|
||||||
|
#define GLeglImageOES void *
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __COGL_GL_HEADER_H__ */
|
@ -25,6 +25,7 @@
|
|||||||
#define __COGL_INTERNAL_H
|
#define __COGL_INTERNAL_H
|
||||||
|
|
||||||
#include "cogl-bitmask.h"
|
#include "cogl-bitmask.h"
|
||||||
|
#include "cogl-gl-header.h"
|
||||||
|
|
||||||
#ifdef COGL_HAS_XLIB_SUPPORT
|
#ifdef COGL_HAS_XLIB_SUPPORT
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#define __COGL_SAMPLER_CACHE_PRIVATE_H
|
#define __COGL_SAMPLER_CACHE_PRIVATE_H
|
||||||
|
|
||||||
#include "cogl-context.h"
|
#include "cogl-context.h"
|
||||||
|
#include "cogl-gl-header.h"
|
||||||
|
|
||||||
/* GL_ALWAYS is just used here as a value that is known not to clash
|
/* GL_ALWAYS is just used here as a value that is known not to clash
|
||||||
* with any valid GL wrap modes.
|
* with any valid GL wrap modes.
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "cogl-handle.h"
|
#include "cogl-handle.h"
|
||||||
#include "cogl-shader.h"
|
#include "cogl-shader.h"
|
||||||
|
#include "cogl-gl-header.h"
|
||||||
|
|
||||||
typedef struct _CoglShader CoglShader;
|
typedef struct _CoglShader CoglShader;
|
||||||
|
|
||||||
|
@ -207,12 +207,12 @@ cogl_texture_new_from_data (unsigned int width,
|
|||||||
* Since: 0.8
|
* Since: 0.8
|
||||||
*/
|
*/
|
||||||
CoglTexture *
|
CoglTexture *
|
||||||
cogl_texture_new_from_foreign (GLuint gl_handle,
|
cogl_texture_new_from_foreign (unsigned int gl_handle,
|
||||||
GLenum gl_target,
|
unsigned int gl_target,
|
||||||
GLuint width,
|
unsigned int width,
|
||||||
GLuint height,
|
unsigned int height,
|
||||||
GLuint x_pot_waste,
|
unsigned int x_pot_waste,
|
||||||
GLuint y_pot_waste,
|
unsigned int y_pot_waste,
|
||||||
CoglPixelFormat format);
|
CoglPixelFormat format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -353,8 +353,8 @@ cogl_texture_is_sliced (CoglTexture *texture);
|
|||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
cogl_texture_get_gl_texture (CoglTexture *texture,
|
cogl_texture_get_gl_texture (CoglTexture *texture,
|
||||||
GLuint *out_gl_handle,
|
unsigned int *out_gl_handle,
|
||||||
GLenum *out_gl_target);
|
unsigned int *out_gl_target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cogl_texture_get_data:
|
* cogl_texture_get_data:
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
/* This just includes the defines needed by the tesselator code */
|
/* This just includes the defines needed by the tesselator code */
|
||||||
|
|
||||||
#include "cogl/cogl-defines.h"
|
#include "cogl/cogl-defines.h"
|
||||||
|
#include "cogl/cogl-gl-header.h"
|
||||||
|
|
||||||
typedef struct GLUtesselator GLUtesselator;
|
typedef struct GLUtesselator GLUtesselator;
|
||||||
|
|
||||||
|
@ -1120,6 +1120,7 @@ cogl/Makefile
|
|||||||
cogl/cogl-1.0.pc
|
cogl/cogl-1.0.pc
|
||||||
cogl/cogl-2.0-experimental.pc
|
cogl/cogl-2.0-experimental.pc
|
||||||
cogl/cogl-defines.h
|
cogl/cogl-defines.h
|
||||||
|
cogl/cogl-gl-header.h
|
||||||
cogl/cogl.rc
|
cogl/cogl.rc
|
||||||
cogl-pango/Makefile
|
cogl-pango/Makefile
|
||||||
cogl-pango/cogl-pango-1.0.pc
|
cogl-pango/cogl-pango-1.0.pc
|
||||||
|
@ -52,6 +52,7 @@ test_sources = \
|
|||||||
test-write-texture-formats.c \
|
test-write-texture-formats.c \
|
||||||
test-point-size.c \
|
test-point-size.c \
|
||||||
test-point-sprite.c \
|
test-point-sprite.c \
|
||||||
|
test-no-gl-header.c \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
test_conformance_SOURCES = $(common_sources) $(test_sources)
|
test_conformance_SOURCES = $(common_sources) $(test_sources)
|
||||||
|
17
tests/conform/test-no-gl-header.c
Normal file
17
tests/conform/test-no-gl-header.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include <cogl/cogl.h>
|
||||||
|
|
||||||
|
#include "test-utils.h"
|
||||||
|
|
||||||
|
/* If you just include cogl/cogl.h, you shouldn't end up including any
|
||||||
|
GL headers */
|
||||||
|
#ifdef GL_TRUE
|
||||||
|
#error "Including cogl.h shouldn't be including any GL headers"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
test_no_gl_header (void)
|
||||||
|
{
|
||||||
|
if (cogl_test_verbose ())
|
||||||
|
g_print ("OK\n");
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user