cogl: consolidate _create_context_driver + _features_init

This moves the functionality of _cogl_create_context_driver from
driver/{gl,gles}/cogl-context-driver-{gl,gles}.c into
driver/{gl,gles}/cogl-{gl,gles}.c as a static function called
initialize_context_driver.

cogl-context-driver-{gl,gles}.[ch] have now been removed.
This commit is contained in:
Robert Bragg 2010-11-05 00:34:37 +00:00
parent e9b1ca0165
commit c415818537
8 changed files with 51 additions and 213 deletions

View File

@ -92,8 +92,6 @@ cogl_driver_sources =
if COGL_DRIVER_GL if COGL_DRIVER_GL
cogl_driver_sources += \ cogl_driver_sources += \
$(srcdir)/driver/gl/cogl-context-driver-gl.c \
$(srcdir)/driver/gl/cogl-context-driver-gl.h \
$(srcdir)/driver/gl/cogl-feature-functions-gl.h \ $(srcdir)/driver/gl/cogl-feature-functions-gl.h \
$(srcdir)/driver/gl/cogl-gl.c \ $(srcdir)/driver/gl/cogl-gl.c \
$(srcdir)/driver/gl/cogl-texture-driver-gl.c \ $(srcdir)/driver/gl/cogl-texture-driver-gl.c \
@ -102,8 +100,6 @@ endif
if COGL_DRIVER_GLES if COGL_DRIVER_GLES
cogl_driver_sources += \ cogl_driver_sources += \
$(srcdir)/driver/gles/cogl-context-driver-gles.c \
$(srcdir)/driver/gles/cogl-context-driver-gles.h \
$(srcdir)/driver/gles/cogl-feature-functions-gles.h \ $(srcdir)/driver/gles/cogl-feature-functions-gles.h \
$(srcdir)/driver/gles/cogl-gles.c \ $(srcdir)/driver/gles/cogl-gles.c \
$(srcdir)/driver/gles/cogl-texture-driver-gles.c \ $(srcdir)/driver/gles/cogl-texture-driver-gles.c \

View File

@ -146,10 +146,8 @@ cogl_context_new (CoglDisplay *display)
context->buffer_types = NULL; context->buffer_types = NULL;
/* Initialise the driver specific state */ /* Initialise the driver specific state */
/* TODO: combine these two into one function */ _cogl_gl_context_init (context);
_cogl_create_context_driver (context); _cogl_init_feature_overrides (context);
_cogl_features_init ();
_cogl_init_feature_overrides (_context);
_cogl_create_context_winsys (context); _cogl_create_context_winsys (context);

View File

@ -1,39 +0,0 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009 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 "cogl-context-private.h"
#define COGL_FEATURE_BEGIN(a, b, c, d, e, f, g)
#define COGL_FEATURE_FUNCTION(ret, name, args) \
_context->drv.pf_ ## name = NULL;
#define COGL_FEATURE_END()
void
_cogl_create_context_driver (CoglContext *_context)
{
#include "cogl-feature-functions-gl.h"
}

View File

@ -1,53 +0,0 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009 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_CONTEXT_DRIVER_H
#define __COGL_CONTEXT_DRIVER_H
#include "cogl.h"
#ifndef APIENTRY
#define APIENTRY
#endif
#define COGL_FEATURE_BEGIN(a, b, c, d, e, f, g)
#define COGL_FEATURE_FUNCTION(ret, name, args) \
ret (APIENTRY * pf_ ## name) args;
#define COGL_FEATURE_END()
typedef struct _CoglContextDriver
{
/* This defines a list of function pointers */
#include "cogl-feature-functions-gl.h"
GLint gl_max_program_temoraries_arb;
} CoglContextDriver;
#undef COGL_FEATURE_BEGIN
#undef COGL_FEATURE_FUNCTION
#undef COGL_FEATURE_END
#endif /* __COGL_CONTEXT_DRIVER_H */

View File

@ -173,18 +173,32 @@ static const CoglFeatureData cogl_feature_data[] =
#include "cogl-feature-functions-gl.h" #include "cogl-feature-functions-gl.h"
}; };
#undef COGL_FEATURE_BEGIN
#define COGL_FEATURE_BEGIN(a, b, c, d, e, f, g)
#undef COGL_FEATURE_FUNCTION
#define COGL_FEATURE_FUNCTION(ret, name, args) \
context->drv.pf_ ## name = NULL;
#undef COGL_FEATURE_END
#define COGL_FEATURE_END()
static void
initialize_context_driver (CoglContext *context)
{
#include "cogl-feature-functions-gl.h"
}
void void
_cogl_features_init (void) _cogl_gl_context_init (CoglContext *context)
{ {
CoglFeatureFlags flags = 0; CoglFeatureFlags flags = 0;
CoglFeatureFlagsPrivate flags_private = 0; CoglFeatureFlagsPrivate flags_private = 0;
const char *gl_extensions; const char *gl_extensions;
GLint max_clip_planes = 0; int max_clip_planes = 0;
GLint num_stencil_bits = 0; int num_stencil_bits = 0;
int gl_major = 0, gl_minor = 0; int gl_major = 0, gl_minor = 0;
int i; int i;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); initialize_context_driver (context);
_cogl_get_gl_version (&gl_major, &gl_minor); _cogl_get_gl_version (&gl_major, &gl_minor);
@ -231,6 +245,6 @@ _cogl_features_init (void)
} }
/* Cache features */ /* Cache features */
ctx->feature_flags = flags; context->feature_flags = flags;
ctx->feature_flags_private = flags_private; context->feature_flags_private = flags_private;
} }

View File

@ -1,40 +0,0 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009 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 "cogl-context-private.h"
#define COGL_FEATURE_BEGIN(a, b, c, d, e, f, g)
#define COGL_FEATURE_FUNCTION(ret, name, args) \
_context->drv.pf_ ## name = NULL;
#define COGL_FEATURE_END()
void
_cogl_create_context_driver (CoglContext *_context)
{
#include "cogl-feature-functions-gles.h"
}

View File

@ -1,52 +0,0 @@
/*
* Cogl
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
* Copyright (C) 2007,2008,2009 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_CONTEXT_DRIVER_H
#define __COGL_CONTEXT_DRIVER_H
#include "cogl.h"
#ifndef APIENTRY
#define APIENTRY
#endif
#define COGL_FEATURE_BEGIN(a, b, c, d, e, f, g)
#define COGL_FEATURE_FUNCTION(ret, name, args) \
ret (APIENTRY * pf_ ## name) args;
#define COGL_FEATURE_END()
typedef struct _CoglContextDriver
{
/* This defines a list of function pointers */
#include "cogl-feature-functions-gles.h"
} CoglContextDriver;
#undef COGL_FEATURE_BEGIN
#undef COGL_FEATURE_FUNCTION
#undef COGL_FEATURE_END
#endif /* __COGL_CONTEXT_DRIVER_H */

View File

@ -70,18 +70,32 @@ static const CoglFeatureData cogl_feature_data[] =
#include "cogl-feature-functions-gles.h" #include "cogl-feature-functions-gles.h"
}; };
#undef COGL_FEATURE_BEGIN
#define COGL_FEATURE_BEGIN(a, b, c, d, e, f, g)
#undef COGL_FEATURE_FUNCTION
#define COGL_FEATURE_FUNCTION(ret, name, args) \
_context->drv.pf_ ## name = NULL;
#undef COGL_FEATURE_END
#define COGL_FEATURE_END()
static void
initialize_context_driver (CoglContext *context)
{
#include "cogl-feature-functions-gles.h"
}
void void
_cogl_features_init (void) _cogl_gl_context_init (CoglContext *context)
{ {
CoglFeatureFlags flags = 0; CoglFeatureFlags flags = 0;
#ifndef HAVE_COGL_GLES2 #ifndef HAVE_COGL_GLES2
int max_clip_planes = 0; int max_clip_planes = 0;
#endif #endif
GLint num_stencil_bits = 0; int num_stencil_bits = 0;
const char *gl_extensions; const char *gl_extensions;
int i; int i;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); initialize_context_driver (context);
gl_extensions = (const char*) glGetString (GL_EXTENSIONS); gl_extensions = (const char*) glGetString (GL_EXTENSIONS);
@ -115,6 +129,6 @@ _cogl_features_init (void)
flags |= COGL_FEATURE_POINT_SPRITE; flags |= COGL_FEATURE_POINT_SPRITE;
/* Cache features */ /* Cache features */
ctx->feature_flags = flags; context->feature_flags = flags;
} }