[clutter/wip/cogl-winsys-egl: 5/37] cogl: consolidate _create_context_driver + _features_init



commit 5f20cf6c129d27b78a65dcdbca2722787496f61a
Author: Robert Bragg <robert linux intel com>
Date:   Fri Nov 5 00:34:37 2010 +0000

    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.

 clutter/cogl/cogl/Makefile.am                      |    4 --
 clutter/cogl/cogl/cogl-context.c                   |    6 +--
 .../cogl/cogl/driver/gl/cogl-context-driver-gl.c   |   39 --------------
 .../cogl/cogl/driver/gl/cogl-context-driver-gl.h   |   53 --------------------
 clutter/cogl/cogl/driver/gl/cogl-gl.c              |   36 +++++++++----
 .../cogl/driver/gles/cogl-context-driver-gles.c    |   40 ---------------
 .../cogl/driver/gles/cogl-context-driver-gles.h    |   52 -------------------
 clutter/cogl/cogl/driver/gles/cogl-gles.c          |   28 ++++++++---
 8 files changed, 48 insertions(+), 210 deletions(-)
---
diff --git a/clutter/cogl/cogl/Makefile.am b/clutter/cogl/cogl/Makefile.am
index e697d6e..9f6a837 100644
--- a/clutter/cogl/cogl/Makefile.am
+++ b/clutter/cogl/cogl/Makefile.am
@@ -92,8 +92,6 @@ cogl_driver_sources =
 
 if COGL_DRIVER_GL
 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-gl.c			\
 	$(srcdir)/driver/gl/cogl-texture-driver-gl.c	\
@@ -102,8 +100,6 @@ endif
 
 if COGL_DRIVER_GLES
 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-gles.c			\
 	$(srcdir)/driver/gles/cogl-texture-driver-gles.c	\
diff --git a/clutter/cogl/cogl/cogl-context.c b/clutter/cogl/cogl/cogl-context.c
index aaefd6e..00f4eaf 100644
--- a/clutter/cogl/cogl/cogl-context.c
+++ b/clutter/cogl/cogl/cogl-context.c
@@ -146,10 +146,8 @@ cogl_context_new (CoglDisplay *display)
   context->buffer_types = NULL;
 
   /* Initialise the driver specific state */
-  /* TODO: combine these two into one function */
-  _cogl_create_context_driver (context);
-  _cogl_features_init ();
-  _cogl_init_feature_overrides (_context);
+  _cogl_gl_context_init (context);
+  _cogl_init_feature_overrides (context);
 
   _cogl_create_context_winsys (context);
 
diff --git a/clutter/cogl/cogl/driver/gl/cogl-gl.c b/clutter/cogl/cogl/driver/gl/cogl-gl.c
index 48088b3..b26f230 100644
--- a/clutter/cogl/cogl/driver/gl/cogl-gl.c
+++ b/clutter/cogl/cogl/driver/gl/cogl-gl.c
@@ -173,25 +173,39 @@ static const CoglFeatureData cogl_feature_data[] =
 #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
-_cogl_features_init (void)
+_cogl_gl_context_init (CoglContext *context)
 {
-  CoglFeatureFlags         flags = 0;
+  CoglFeatureFlags flags = 0;
   CoglFeatureFlagsPrivate  flags_private = 0;
-  const char              *gl_extensions;
-  GLint                    max_clip_planes = 0;
-  GLint                    num_stencil_bits = 0;
-  int                      gl_major = 0, gl_minor = 0;
-  int                      i;
+  const char *gl_extensions;
+  int max_clip_planes = 0;
+  int num_stencil_bits = 0;
+  int gl_major = 0, gl_minor = 0;
+  int i;
 
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  initialize_context_driver (context);
 
   _cogl_get_gl_version (&gl_major, &gl_minor);
 
   flags = (COGL_FEATURE_TEXTURE_READ_PIXELS
            | COGL_FEATURE_UNSIGNED_INT_INDICES);
 
-  gl_extensions = (const char*) glGetString (GL_EXTENSIONS);
+  gl_extensions = (const char *)glGetString (GL_EXTENSIONS);
 
   if (COGL_CHECK_GL_VERSION (gl_major, gl_minor, 2, 0) ||
       _cogl_check_extension ("GL_ARB_texture_non_power_of_two", gl_extensions))
@@ -231,6 +245,6 @@ _cogl_features_init (void)
       }
 
   /* Cache features */
-  ctx->feature_flags = flags;
-  ctx->feature_flags_private = flags_private;
+  context->feature_flags = flags;
+  context->feature_flags_private = flags_private;
 }
diff --git a/clutter/cogl/cogl/driver/gles/cogl-gles.c b/clutter/cogl/cogl/driver/gles/cogl-gles.c
index b2eaa80..304e537 100644
--- a/clutter/cogl/cogl/driver/gles/cogl-gles.c
+++ b/clutter/cogl/cogl/driver/gles/cogl-gles.c
@@ -70,18 +70,32 @@ static const CoglFeatureData cogl_feature_data[] =
 #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
-_cogl_features_init (void)
+_cogl_gl_context_init (CoglContext *context)
 {
   CoglFeatureFlags flags = 0;
 #ifndef HAVE_COGL_GLES2
-  int              max_clip_planes = 0;
+  int max_clip_planes = 0;
 #endif
-  GLint            num_stencil_bits = 0;
-  const char      *gl_extensions;
-  int              i;
+  int num_stencil_bits = 0;
+  const char *gl_extensions;
+  int i;
 
-  _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+  initialize_context_driver (context);
 
   gl_extensions = (const char*) glGetString (GL_EXTENSIONS);
 
@@ -115,6 +129,6 @@ _cogl_features_init (void)
   flags |= COGL_FEATURE_POINT_SPRITE;
 
   /* Cache features */
-  ctx->feature_flags = flags;
+  context->feature_flags = flags;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]