summaryrefslogtreecommitdiff
path: root/cogl
diff options
context:
space:
mode:
Diffstat (limited to 'cogl')
-rw-r--r--cogl/Makefile.am5
-rw-r--r--cogl/cogl-clutter.c3
-rw-r--r--cogl/cogl-context-private.h1
-rw-r--r--cogl/cogl-context.c19
-rw-r--r--cogl/cogl-display.c4
-rw-r--r--cogl/cogl-framebuffer.c2
-rw-r--r--cogl/cogl-renderer.c18
-rw-r--r--cogl/cogl.c4
-rw-r--r--cogl/winsys/cogl-winsys-stub-private.h30
-rw-r--r--cogl/winsys/cogl-winsys-stub.c137
10 files changed, 130 insertions, 93 deletions
diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index 91451bb4..be2759d9 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -303,6 +303,7 @@ cogl_sources_c = \
$(srcdir)/cogl-point-in-poly-private.h \
$(srcdir)/cogl-point-in-poly.c \
$(srcdir)/cogl-clutter.c \
+ $(srcdir)/winsys/cogl-winsys-stub.c \
$(NULL)
if SUPPORT_XLIB
@@ -352,10 +353,6 @@ if SUPPORT_EGL_PLATFORM_ANDROID
cogl_sources_c += \
$(srcdir)/winsys/cogl-winsys-egl.c
endif
-if SUPPORT_STUB
-cogl_sources_c += \
- $(srcdir)/winsys/cogl-winsys-stub.c
-endif
EXTRA_DIST += stb_image.c
diff --git a/cogl/cogl-clutter.c b/cogl/cogl-clutter.c
index f85f32ec..aaf02817 100644
--- a/cogl/cogl-clutter.c
+++ b/cogl/cogl-clutter.c
@@ -35,6 +35,7 @@
#include "cogl-private.h"
#include "cogl-context-private.h"
#include "cogl-winsys-private.h"
+#include "cogl-winsys-stub-private.h"
#include "cogl-framebuffer-private.h"
gboolean
@@ -56,7 +57,7 @@ cogl_onscreen_clutter_backend_set_size (int width, int height)
_COGL_GET_CONTEXT (ctx, NO_RETVAL);
- if (!ctx->stub_winsys)
+ if (_cogl_context_get_winsys (ctx) != _cogl_winsys_stub_get_vtable ())
return;
framebuffer = COGL_FRAMEBUFFER (ctx->window_buffer);
diff --git a/cogl/cogl-context-private.h b/cogl/cogl-context-private.h
index c9b7c640..2cf1be5d 100644
--- a/cogl/cogl-context-private.h
+++ b/cogl/cogl-context-private.h
@@ -263,7 +263,6 @@ struct _CoglContext
unsigned int winsys_features
[COGL_FLAGS_N_INTS_FOR_SIZE (COGL_WINSYS_FEATURE_N_FEATURES)];
void *winsys;
- gboolean stub_winsys;
};
CoglContext *
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index 90f8af46..7a0063d9 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -30,6 +30,7 @@
#include "cogl-internal.h"
#include "cogl-private.h"
#include "cogl-winsys-private.h"
+#include "cogl-winsys-stub-private.h"
#include "cogl-profile.h"
#include "cogl-util.h"
#include "cogl-context-private.h"
@@ -162,8 +163,6 @@ cogl_context_new (CoglDisplay *display,
context->display = display;
-#ifdef COGL_HAS_FULL_WINSYS
- context->stub_winsys = FALSE;
winsys = _cogl_context_get_winsys (context);
if (!winsys->context_init (context, error))
{
@@ -171,20 +170,6 @@ cogl_context_new (CoglDisplay *display,
g_free (context);
return NULL;
}
-#else
- /* In this case Clutter is still responsible for creating a GL
- * context. */
- context->stub_winsys = TRUE;
- if (!_cogl_gl_check_version (error))
- {
- g_free (context);
- return NULL;
- }
- _cogl_gl_update_features (context);
-#ifdef COGL_HAS_XLIB_SUPPORT
- _cogl_xlib_query_damage_extension ();
-#endif
-#endif
/* Initialise the driver specific state */
_cogl_init_feature_overrides (context);
@@ -284,7 +269,7 @@ cogl_context_new (CoglDisplay *display,
* the OpenGL binding API and for creating onscreen framebuffers and
* so we have to add a dummy framebuffer to represent the backend
* owned window... */
- if (context->stub_winsys)
+ if (_cogl_context_get_winsys (context) == _cogl_winsys_stub_get_vtable ())
{
CoglOnscreen *window = _cogl_onscreen_new ();
cogl_set_framebuffer (COGL_FRAMEBUFFER (window));
diff --git a/cogl/cogl-display.c b/cogl/cogl-display.c
index 0953f1f0..967c0706 100644
--- a/cogl/cogl-display.c
+++ b/cogl/cogl-display.c
@@ -104,18 +104,14 @@ gboolean
cogl_display_setup (CoglDisplay *display,
GError **error)
{
-#ifdef COGL_HAS_FULL_WINSYS
const CoglWinsysVtable *winsys;
-#endif
if (display->setup)
return TRUE;
-#ifdef COGL_HAS_FULL_WINSYS
winsys = _cogl_display_get_winsys (display);
if (!winsys->display_setup (display, error))
return FALSE;
-#endif
display->setup = TRUE;
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index ac2244d1..82d3f76d 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -1372,11 +1372,9 @@ bind_gl_framebuffer (CoglContext *ctx,
COGL_OFFSCREEN (framebuffer)->fbo_handle));
else
{
-#ifdef COGL_HAS_FULL_WINSYS
const CoglWinsysVtable *winsys =
_cogl_framebuffer_get_winsys (framebuffer);
winsys->onscreen_bind (COGL_ONSCREEN (framebuffer));
-#endif
/* glBindFramebuffer is an an extension with OpenGL ES 1.1 */
if (cogl_features_available (COGL_FEATURE_OFFSCREEN))
GE (glBindFramebuffer (target, 0));
diff --git a/cogl/cogl-renderer.c b/cogl/cogl-renderer.c
index df05247a..d2badc8d 100644
--- a/cogl/cogl-renderer.c
+++ b/cogl/cogl-renderer.c
@@ -39,8 +39,7 @@
#include "cogl-renderer-private.h"
#include "cogl-display-private.h"
#include "cogl-winsys-private.h"
-
-#ifdef COGL_HAS_FULL_WINSYS
+#include "cogl-winsys-stub-private.h"
#ifdef COGL_HAS_GLX_SUPPORT
extern const CoglWinsysVtable *_cogl_winsys_glx_get_vtable (void);
@@ -65,10 +64,9 @@ static CoglWinsysVtableGetter _cogl_winsys_vtable_getters[] =
#ifdef COGL_HAS_WGL_SUPPORT
_cogl_winsys_wgl_get_vtable,
#endif
+ _cogl_winsys_stub_get_vtable,
};
-#endif /* COGL_HAS_FULL_WINSYS */
-
static void _cogl_renderer_free (CoglRenderer *renderer);
COGL_OBJECT_DEFINE (Renderer, renderer);
@@ -100,10 +98,8 @@ native_filter_closure_free (CoglNativeFilterClosure *closure)
static void
_cogl_renderer_free (CoglRenderer *renderer)
{
-#ifdef COGL_HAS_FULL_WINSYS
const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer);
winsys->renderer_disconnect (renderer);
-#endif
g_slist_foreach (renderer->event_filters,
(GFunc) native_filter_closure_free,
@@ -151,7 +147,6 @@ cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
CoglOnscreenTemplate *onscreen_template,
GError **error)
{
-#ifdef COGL_HAS_FULL_WINSYS
CoglDisplay *display;
const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer);
@@ -166,7 +161,7 @@ cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
}
cogl_object_unref (display);
-#endif
+
return TRUE;
}
@@ -175,16 +170,13 @@ cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
gboolean
cogl_renderer_connect (CoglRenderer *renderer, GError **error)
{
-#ifdef COGL_HAS_FULL_WINSYS
int i;
char *renderer_name = getenv ("COGL_RENDERER");
-#endif
GString *error_message;
if (renderer->connected)
return TRUE;
-#ifdef COGL_HAS_FULL_WINSYS
error_message = g_string_new ("");
for (i = 0; i < G_N_ELEMENTS (_cogl_winsys_vtable_getters); i++)
{
@@ -221,10 +213,6 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error)
}
return TRUE;
-#else
- renderer->connected = TRUE;
- return TRUE;
-#endif
}
CoglFilterReturn
diff --git a/cogl/cogl.c b/cogl/cogl.c
index 65922217..896b2e66 100644
--- a/cogl/cogl.c
+++ b/cogl/cogl.c
@@ -95,7 +95,6 @@ cogl_get_proc_address (const char* name)
{
void *address;
static GModule *module = NULL;
-#ifdef COGL_HAS_FULL_WINSYS
const CoglWinsysVtable *winsys;
_COGL_GET_CONTEXT (ctx, NULL);
@@ -103,9 +102,6 @@ cogl_get_proc_address (const char* name)
winsys = _cogl_context_get_winsys (ctx);
address = winsys->get_proc_address (name);
-#else
- address = _cogl_winsys_get_proc_address (name);
-#endif
if (address)
return address;
diff --git a/cogl/winsys/cogl-winsys-stub-private.h b/cogl/winsys/cogl-winsys-stub-private.h
new file mode 100644
index 00000000..3e837b26
--- /dev/null
+++ b/cogl/winsys/cogl-winsys-stub-private.h
@@ -0,0 +1,30 @@
+/*
+ * Cogl
+ *
+ * An object oriented GL/GLES Abstraction/Utility Layer
+ *
+ * Copyright (C) 2011 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_WINSYS_STUB_PRIVATE_H
+#define __COGL_WINSYS_STUB_PRIVATE_H
+
+const CoglWinsysVtable *
+_cogl_winsys_stub_get_vtable (void);
+
+#endif /* __COGL_WINSYS_STUB_PRIVATE_H */
diff --git a/cogl/winsys/cogl-winsys-stub.c b/cogl/winsys/cogl-winsys-stub.c
index a45cbdf5..ef22e13b 100644
--- a/cogl/winsys/cogl-winsys-stub.c
+++ b/cogl/winsys/cogl-winsys-stub.c
@@ -3,7 +3,7 @@
*
* An object oriented GL/GLES Abstraction/Utility Layer
*
- * Copyright (C) 2010 Intel Corporation.
+ * Copyright (C) 2011 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -16,97 +16,144 @@
* 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/>.
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
*
*
+ * Authors:
+ * Robert Bragg <robert@linux.intel.com>
+ *
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include "cogl-renderer-private.h"
+#include "cogl-display-private.h"
+#include "cogl-context-private.h"
#include "cogl-framebuffer-private.h"
+#include "cogl-private.h"
+
+#include <string.h>
+
+static int _cogl_winsys_stub_dummy_ptr;
-/* This provides a stub winsys implementation for when Clutter still handles
- * creating an OpenGL context. This is useful so we don't have to guard all
- * calls into the winsys layer with #ifdef COGL_HAS_FULL_WINSYS
+/* This provides a NOP winsys. This can be useful for debugging or for
+ * integrating with toolkits that already have window system
+ * integration code.
*/
-CoglFuncPtr
+static CoglFuncPtr
_cogl_winsys_get_proc_address (const char *name)
{
return NULL;
}
-void
-_cogl_winsys_onscreen_swap_buffers (CoglOnscreen *onscreen)
+static void
+_cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
{
-
+ renderer->winsys = NULL;
}
-void
-_cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
- int *rectangles,
- int n_rectangles)
+static gboolean
+_cogl_winsys_renderer_connect (CoglRenderer *renderer,
+ GError **error)
{
-
+ renderer->winsys = &_cogl_winsys_stub_dummy_ptr;
+ return TRUE;
}
-void
-_cogl_winsys_onscreen_update_swap_throttled (CoglOnscreen *onscreen)
+static void
+_cogl_winsys_display_destroy (CoglDisplay *display)
{
-
+ display->winsys = NULL;
}
-unsigned int
-_cogl_winsys_onscreen_add_swap_buffers_callback (CoglOnscreen *onscreen,
- CoglSwapBuffersNotify callback,
- void *user_data)
+static gboolean
+_cogl_winsys_display_setup (CoglDisplay *display,
+ GError **error)
{
- g_assert (0);
- return 0;
+ display->winsys = &_cogl_winsys_stub_dummy_ptr;
+ return TRUE;
}
-void
-_cogl_winsys_onscreen_remove_swap_buffers_callback (CoglOnscreen *onscreen,
- unsigned int id)
+static gboolean
+_cogl_winsys_context_init (CoglContext *context, GError **error)
{
- g_assert (0);
-}
+ context->winsys = &_cogl_winsys_stub_dummy_ptr;
-#ifdef COGL_HAS_XLIB_SUPPORT
-XVisualInfo *
-_cogl_winsys_xlib_get_visual_info (void)
-{
- g_assert (0);
- return NULL;
+ if (!_cogl_gl_check_version (error))
+ return FALSE;
+
+ _cogl_gl_update_features (context);
+
+ memset (context->winsys_features, 0, sizeof (context->winsys_features));
+
+ return TRUE;
}
-#endif
-#ifdef COGL_HAS_X11_SUPPORT
-guint32
-_cogl_winsys_onscreen_x11_get_window_xid (CoglOnscreen *onscreen)
+static void
+_cogl_winsys_context_deinit (CoglContext *context)
{
- g_assert (0);
- return 0;
+ context->winsys = NULL;
}
-#endif
-gboolean
+static gboolean
_cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
GError **error)
{
return TRUE;
}
-void
+static void
_cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
{
+}
+static void
+_cogl_winsys_onscreen_bind (CoglOnscreen *onscreen)
+{
}
-void
-_cogl_winsys_context_deinit (CoglContext *context)
+static void
+_cogl_winsys_onscreen_swap_buffers (CoglOnscreen *onscreen)
{
+}
+static void
+_cogl_winsys_onscreen_update_swap_throttled (CoglOnscreen *onscreen)
+{
+}
+
+static void
+_cogl_winsys_onscreen_set_visibility (CoglOnscreen *onscreen,
+ gboolean visibility)
+{
+}
+
+static CoglWinsysVtable _cogl_winsys_vtable =
+ {
+ .name = "STUB",
+ .get_proc_address = _cogl_winsys_get_proc_address,
+ .renderer_connect = _cogl_winsys_renderer_connect,
+ .renderer_disconnect = _cogl_winsys_renderer_disconnect,
+ .display_setup = _cogl_winsys_display_setup,
+ .display_destroy = _cogl_winsys_display_destroy,
+ .context_init = _cogl_winsys_context_init,
+ .context_deinit = _cogl_winsys_context_deinit,
+
+ .onscreen_init = _cogl_winsys_onscreen_init,
+ .onscreen_deinit = _cogl_winsys_onscreen_deinit,
+ .onscreen_bind = _cogl_winsys_onscreen_bind,
+ .onscreen_swap_buffers = _cogl_winsys_onscreen_swap_buffers,
+ .onscreen_update_swap_throttled =
+ _cogl_winsys_onscreen_update_swap_throttled,
+ .onscreen_set_visibility = _cogl_winsys_onscreen_set_visibility,
+ };
+
+const CoglWinsysVtable *
+_cogl_winsys_stub_get_vtable (void)
+{
+ return &_cogl_winsys_vtable;
}