[clutter/wip/cogl-winsys-glx: 13/20] Adds renderer, display, onscreen-template and swap-chain stubs



commit 2b7fcbd1bcc6421ebf546cd2a08135a502c6d6b8
Author: Robert Bragg <robert linux intel com>
Date:   Fri Feb 25 17:06:50 2011 +0000

    Adds renderer,display,onscreen-template and swap-chain stubs
    
    As part of the process of splitting Cogl out as a standalone graphics
    API we need to introduce some API concepts that will allow us to
    initialize a new CoglContext when Clutter isn't there to handle that for
    us...
    
    The new objects roughly in the order that they are (optionally) involved
    in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
    CoglSwapChain and CoglDisplay.
    
    Conceptually a CoglRenderer represents a means for rendering.  Cogl
    supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
    accessed through a number of different windowing APIs such as GLX, EGL,
    SDL or WGL and more. Potentially in the future Cogl could render using
    D3D or even by using libdrm and directly banging the hardware. All these
    choices are wrapped up in the configuration of a CoglRenderer.
    
    Conceptually a CoglDisplay represents a display pipeline for a renderer.
    Although Cogl doesn't aim to provide a detailed abstraction of display
    hardware, on some platforms we can give control over multiple display
    planes (On TV platforms for instance video content may be on one plane
    and 3D would be on another so a CoglDisplay lets you select the plane
    up-front.)
    
    Another aspect of CoglDisplay is that it lets us negotiate a display
    pipeline that best supports the type of CoglOnscreen framebuffers we are
    planning to create. For instance if you want transparent CoglOnscreen
    framebuffers then we have to be sure the display pipeline wont discard
    the alpha component of your framebuffers. Or if you want to use
    double/tripple buffering that requires support from the display
    pipeline.
    
    CoglOnscreenTemplate and CoglSwapChain are how we describe our default
    CoglOnscreen framebuffer configuration which can affect the
    configuration of the display pipeline.
    
    The default/simple way we expect most CoglContexts to be constructed
    will be via something like:
    
     if (!cogl_context_new (NULL, &error))
       g_error ("Failed to construct a CoglContext: %s", error->message);
    
    Where that NULL is for an optional "display" parameter and NULL says to
    Cogl "please just try to do something sensible".
    
    If you want some more control though you can manually construct a
    CoglDisplay something like:
    
     display = cogl_display_new (NULL, NULL);
     cogl_display_cex100_set_plane (display, plane);
     if (!cogl_display_setup (display, &error))
       g_error ("Failed to setup a CoglDisplay: %s", error->message);
    
    And in a similar fashion to cogl_context_new() you can optionally pass
    a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
    just do something sensible.
    
    If you need to change the CoglOnscreen defaults you can provide a
    template something like:
      chain = cogl_swap_chain_new ();
      cogl_swap_chain_set_has_alpha (chain, TRUE);
      cogl_swap_chain_set_length (chain, 3);
    
      onscreen_template = cogl_onscreen_template_new (chain);
      cogl_onscreen_template_set_pixel_format (onscreen_template,
                                               COGL_PIXEL_FORMAT_RGB565);
    
      display = cogl_display_new (NULL, onscreen_template);
      if (!cogl_display_setup (display, &error))
        g_error ("Failed to setup a CoglDisplay: %s", error->message);

 clutter/cogl/cogl/Makefile.am                      |   16 ++
 clutter/cogl/cogl/cogl-context.c                   |   44 ++++--
 clutter/cogl/cogl/cogl-display-private.h           |   43 ++++++
 clutter/cogl/cogl/cogl-display.c                   |  106 +++++++++++++
 clutter/cogl/cogl/cogl-onscreen-template-private.h |   37 +++++
 clutter/cogl/cogl/cogl-onscreen-template.c         |   62 ++++++++
 clutter/cogl/cogl/cogl-onscreen-template.h         |   48 ++++++
 clutter/cogl/cogl/cogl-renderer-private.h          |   43 ++++++
 clutter/cogl/cogl/cogl-renderer.c                  |  106 +++++++++++++
 clutter/cogl/cogl/cogl-renderer.h                  |  158 ++++++++++++++++++++
 clutter/cogl/cogl/cogl-swap-chain-private.h        |   37 +++++
 clutter/cogl/cogl/cogl-swap-chain.c                |   66 ++++++++
 clutter/cogl/cogl/cogl-swap-chain.h                |   46 ++++++
 13 files changed, 802 insertions(+), 10 deletions(-)
---
diff --git a/clutter/cogl/cogl/Makefile.am b/clutter/cogl/cogl/Makefile.am
index cdb342f..80b5ae5 100644
--- a/clutter/cogl/cogl/Makefile.am
+++ b/clutter/cogl/cogl/Makefile.am
@@ -83,6 +83,10 @@ cogl_public_h = \
 	$(NULL)
 
 cogl_experimental_h = \
+	$(srcdir)/cogl-renderer.h 		\
+	$(srcdir)/cogl-swap-chain.h 		\
+	$(srcdir)/cogl-onscreen-template.h 	\
+	$(srcdir)/cogl-display.h 		\
 	$(srcdir)/cogl-context.h 		\
 	$(srcdir)/cogl2-path.h 			\
 	$(srcdir)/cogl2-clip-state.h		\
@@ -161,6 +165,18 @@ cogl_sources_c = \
 	$(srcdir)/cogl-handle.h 			\
 	$(srcdir)/cogl-context-private.h		\
 	$(srcdir)/cogl-context.c			\
+	$(srcdir)/cogl-renderer-private.h		\
+	$(srcdir)/cogl-renderer.h			\
+	$(srcdir)/cogl-renderer.c			\
+	$(srcdir)/cogl-swap-chain-private.h		\
+	$(srcdir)/cogl-swap-chain.h			\
+	$(srcdir)/cogl-swap-chain.c			\
+	$(srcdir)/cogl-onscreen-template-private.h 	\
+	$(srcdir)/cogl-onscreen-template.h 		\
+	$(srcdir)/cogl-onscreen-template.c 		\
+	$(srcdir)/cogl-display-private.h		\
+	$(srcdir)/cogl-display.h			\
+	$(srcdir)/cogl-display.c			\
 	$(srcdir)/cogl-internal.h			\
 	$(srcdir)/cogl.c				\
 	$(srcdir)/cogl-object-private.h			\
diff --git a/clutter/cogl/cogl/cogl-context.c b/clutter/cogl/cogl/cogl-context.c
index 00f4eaf..ed950c3 100644
--- a/clutter/cogl/cogl/cogl-context.c
+++ b/clutter/cogl/cogl/cogl-context.c
@@ -86,17 +86,18 @@ _cogl_init_feature_overrides (CoglContext *ctx)
                             COGL_FEATURE_TEXTURE_NPOT_REPEAT);
 }
 
-/* FIXME: We don't report a GError here should we? With non NULL
- * displays then there should basically be no risk of error I think,
- * but NULL just says "please do the right thing" and we could hit any
- * number of problems that should be reported back to the caller!
- *
- * Also is it acceptable for construction to report an error
- * or should there be a separate cogl_context_check_status()
- * API of some kind?
+/* For reference: There was some deliberation over whether to have a
+ * constructor that could throw an exception but looking at standard
+ * practices with several high level OO languages including python, C++,
+ * C# Java and Ruby they all support exceptions in constructors and the
+ * general consensus appears to be that throwing an exception is neater
+ * than successfully constructing with an internal error status that
+ * would then have to be explicitly checked via some form of ::is_ok()
+ * method.
  */
 CoglContext *
-cogl_context_new (CoglDisplay *display)
+cogl_context_new (CoglDisplay *display,
+                  GError **error)
 {
   CoglContext *context;
   GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 };
@@ -145,6 +146,18 @@ cogl_context_new (CoglDisplay *display)
   context->texture_types = NULL;
   context->buffer_types = NULL;
 
+    if (!display)
+    display = cogl_display_new (NULL, NULL);
+  else
+    cogl_object_ref (display);
+
+  if (!cogl_display_setup (display, error))
+    {
+      cogl_object_unref (display);
+      g_free (context);
+      return NULL;
+    }
+
   /* Initialise the driver specific state */
   _cogl_gl_context_init (context);
   _cogl_init_feature_overrides (context);
@@ -411,15 +424,26 @@ _cogl_context_free (CoglContext *context)
 
   g_byte_array_free (context->buffer_map_fallback_array, TRUE);
 
+  cogl_object_unref (context->display);
+
   g_free (context);
 }
 
 CoglContext *
 _cogl_context_get_default (void)
 {
+  GError *error = NULL;
   /* Create if doesn't exist yet */
   if (_context == NULL)
-    _context = cogl_context_new (NULL);
+    {
+      _context = cogl_context_new (NULL, &error);
+      if (!_context)
+        {
+          g_warning ("Failed to create default context: %s",
+                     error->message);
+          g_error_free (error);
+        }
+    }
 
   return _context;
 }
diff --git a/clutter/cogl/cogl/cogl-display-private.h b/clutter/cogl/cogl/cogl-display-private.h
new file mode 100644
index 0000000..1bda21d
--- /dev/null
+++ b/clutter/cogl/cogl/cogl-display-private.h
@@ -0,0 +1,43 @@
+/*
+ * 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_DISPLAY_PRIVATE_H
+#define __COGL_DISPLAY_PRIVATE_H
+
+#include "cogl-object-private.h"
+#include "cogl-renderer.h"
+#include "cogl-onscreen-template.h"
+
+struct _CoglDisplay
+{
+  CoglObject _parent;
+
+  gboolean setup;
+  CoglRenderer *renderer;
+  CoglOnscreenTemplate *onscreen_template;
+
+  void *winsys;
+};
+
+#endif /* __COGL_DISPLAY_PRIVATE_H */
diff --git a/clutter/cogl/cogl/cogl-display.c b/clutter/cogl/cogl/cogl-display.c
new file mode 100644
index 0000000..ebaaafa
--- /dev/null
+++ b/clutter/cogl/cogl/cogl-display.c
@@ -0,0 +1,106 @@
+/*
+ * 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ *   Robert Bragg <robert linux intel com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "cogl.h"
+#include "cogl-object.h"
+
+#include "cogl-display-private.h"
+#include "cogl-winsys-private.h"
+
+static void _cogl_display_free (CoglDisplay *display);
+
+COGL_OBJECT_DEFINE (Display, display);
+
+GQuark
+cogl_display_error_quark (void)
+{
+  return g_quark_from_static_string ("cogl-display-error-quark");
+}
+
+static void
+_cogl_display_free (CoglDisplay *display)
+{
+  if (display->renderer)
+    {
+      cogl_object_unref (display->renderer);
+      display->renderer = NULL;
+    }
+
+  if (display->onscreen_template)
+    {
+      cogl_object_unref (display->onscreen_template);
+      display->onscreen_template = NULL;
+    }
+
+  g_slice_free (CoglDisplay, display);
+}
+
+CoglDisplay *
+cogl_display_new (CoglRenderer *renderer,
+                  CoglOnscreenTemplate *onscreen_template)
+{
+  CoglDisplay *display = g_slice_new0 (CoglDisplay);
+  GError *error = NULL;
+
+  display->renderer = renderer;
+  if (renderer)
+    cogl_object_ref (renderer);
+  else
+    display->renderer = cogl_renderer_new ();
+
+  if (!cogl_renderer_connect (display->renderer, &error))
+    {
+      g_warning ("Failed to connect renderer: %s\n", error->message);
+      g_error_free (error);
+      g_object_unref (display->renderer);
+      g_slice_free (CoglDisplay, display);
+      return NULL;
+    }
+
+  display->onscreen_template = onscreen_template;
+  if (onscreen_template)
+    cogl_object_ref (onscreen_template);
+
+  display->setup = FALSE;
+
+  return _cogl_display_object_new (display);
+}
+
+gboolean
+cogl_display_setup (CoglDisplay *display,
+                    GError **error)
+{
+  if (display->setup)
+    return TRUE;
+
+  display->setup = TRUE;
+
+  return TRUE;
+}
diff --git a/clutter/cogl/cogl/cogl-onscreen-template-private.h b/clutter/cogl/cogl/cogl-onscreen-template-private.h
new file mode 100644
index 0000000..0f8d253
--- /dev/null
+++ b/clutter/cogl/cogl/cogl-onscreen-template-private.h
@@ -0,0 +1,37 @@
+/*
+ * 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_ONSCREEN_TEMPLATE_PRIVATE_H
+#define __COGL_ONSCREEN_TEMPLATE_PRIVATE_H
+
+#include "cogl-object-private.h"
+#include "cogl-swap-chain.h"
+
+struct _CoglOnscreenTemplate
+{
+  CoglObject _parent;
+
+  CoglSwapChain *swap_chain;
+};
+
+#endif /* __COGL_ONSCREEN_TEMPLATE_PRIVATE_H */
diff --git a/clutter/cogl/cogl/cogl-onscreen-template.c b/clutter/cogl/cogl/cogl-onscreen-template.c
new file mode 100644
index 0000000..ff400e4
--- /dev/null
+++ b/clutter/cogl/cogl/cogl-onscreen-template.c
@@ -0,0 +1,62 @@
+/*
+ * 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ *   Robert Bragg <robert linux intel com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "cogl.h"
+#include "cogl-object.h"
+
+#include "cogl-onscreen-template-private.h"
+
+static void _cogl_onscreen_template_free (CoglOnscreenTemplate *onscreen_template);
+
+COGL_OBJECT_DEFINE (OnscreenTemplate, onscreen_template);
+
+GQuark
+cogl_onscreen_template_error_quark (void)
+{
+  return g_quark_from_static_string ("cogl-onscreen-template-error-quark");
+}
+
+static void
+_cogl_onscreen_template_free (CoglOnscreenTemplate *onscreen_template)
+{
+  g_slice_free (CoglOnscreenTemplate, onscreen_template);
+}
+
+CoglOnscreenTemplate *
+cogl_onscreen_template_new (CoglSwapChain *swap_chain)
+{
+  CoglOnscreenTemplate *onscreen_template = g_slice_new0 (CoglOnscreenTemplate);
+
+  onscreen_template->swap_chain = swap_chain;
+  if (swap_chain)
+    cogl_object_ref (swap_chain);
+
+  return _cogl_onscreen_template_object_new (onscreen_template);
+}
diff --git a/clutter/cogl/cogl/cogl-onscreen-template.h b/clutter/cogl/cogl/cogl-onscreen-template.h
new file mode 100644
index 0000000..4769f9f
--- /dev/null
+++ b/clutter/cogl/cogl/cogl-onscreen-template.h
@@ -0,0 +1,48 @@
+/*
+ * 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/>.
+ *
+ * Authors:
+ *  Robert Bragg <robert linux intel com>
+ *
+ */
+
+#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
+#error "Only <cogl/cogl.h> can be included directly."
+#endif
+
+#ifndef __COGL_ONSCREEN_TEMPLATE_H__
+#define __COGL_ONSCREEN_TEMPLATE_H__
+
+#include <cogl/cogl-swap-chain.h>
+
+G_BEGIN_DECLS
+
+typedef struct _CoglOnscreenTemplate	      CoglOnscreenTemplate;
+
+#define COGL_ONSCREEN_TEMPLATE(OBJECT) ((CoglOnscreenTemplate *)OBJECT)
+
+#define cogl_onscreen_template_new cogl_onscreen_template_new_EXP
+CoglOnscreenTemplate *
+cogl_onscreen_template_new (CoglSwapChain *swap_chain);
+
+G_END_DECLS
+
+#endif /* __COGL_ONSCREEN_TEMPLATE_H__ */
diff --git a/clutter/cogl/cogl/cogl-renderer-private.h b/clutter/cogl/cogl/cogl-renderer-private.h
new file mode 100644
index 0000000..8668270
--- /dev/null
+++ b/clutter/cogl/cogl/cogl-renderer-private.h
@@ -0,0 +1,43 @@
+/*
+ * 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_RENDERER_PRIVATE_H
+#define __COGL_RENDERER_PRIVATE_H
+
+#include "cogl-object-private.h"
+
+#ifdef COGL_HAS_XLIB_SUPPORT
+#include <X11/Xlib.h>
+#endif
+
+struct _CoglRenderer
+{
+  CoglObject _parent;
+  gboolean connected;
+#ifdef COGL_HAS_XLIB_SUPPORT
+  Display *foreign_xdpy;
+#endif
+  void *winsys;
+};
+
+#endif /* __COGL_RENDERER_PRIVATE_H */
diff --git a/clutter/cogl/cogl/cogl-renderer.c b/clutter/cogl/cogl/cogl-renderer.c
new file mode 100644
index 0000000..9eddc9b
--- /dev/null
+++ b/clutter/cogl/cogl/cogl-renderer.c
@@ -0,0 +1,106 @@
+/*
+ * 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ *   Robert Bragg <robert linux intel com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "cogl.h"
+#include "cogl-internal.h"
+#include "cogl-object.h"
+
+#include "cogl-renderer.h"
+#include "cogl-renderer-private.h"
+#include "cogl-display-private.h"
+#include "cogl-winsys-private.h"
+
+static void _cogl_renderer_free (CoglRenderer *renderer);
+
+COGL_OBJECT_DEFINE (Renderer, renderer);
+
+GQuark
+cogl_renderer_error_quark (void)
+{
+  return g_quark_from_static_string ("cogl-renderer-error-quark");
+}
+
+static void
+_cogl_renderer_free (CoglRenderer *renderer)
+{
+  g_free (renderer);
+}
+
+CoglRenderer *
+cogl_renderer_new (void)
+{
+  CoglRenderer *renderer = g_new0 (CoglRenderer, 1);
+
+  renderer->connected = FALSE;
+
+  return _cogl_renderer_object_new (renderer);
+}
+
+#if COGL_HAS_XLIB_SUPPORT
+void
+cogl_renderer_xlib_set_foreign_display (CoglRenderer *renderer,
+                                        Display *xdisplay)
+{
+  g_return_if_fail (cogl_is_renderer (renderer));
+
+  /* NB: Renderers are considered immutable once connected */
+  g_return_if_fail (!renderer->connected);
+
+  renderer->foreign_xdpy = xdisplay;
+}
+
+Display *
+cogl_renderer_xlib_get_foreign_display (CoglRenderer *renderer)
+{
+  g_return_val_if_fail (cogl_is_renderer (renderer), NULL);
+
+  return renderer->foreign_xdpy;
+}
+#endif /* COGL_HAS_XLIB_SUPPORT */
+
+gboolean
+cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
+                                       CoglOnscreenTemplate *onscreen_template,
+                                       GError **error)
+{
+  return TRUE;
+}
+
+/* Final connection API */
+
+gboolean
+cogl_renderer_connect (CoglRenderer *renderer, GError **error)
+{
+  if (renderer->connected)
+    return TRUE;
+
+  renderer->connected = TRUE;
+  return TRUE;
+}
diff --git a/clutter/cogl/cogl/cogl-renderer.h b/clutter/cogl/cogl/cogl-renderer.h
new file mode 100644
index 0000000..6844299
--- /dev/null
+++ b/clutter/cogl/cogl/cogl-renderer.h
@@ -0,0 +1,158 @@
+/*
+ * 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
+#error "Only <cogl/cogl.h> can be included directly."
+#endif
+
+#ifndef __COGL_RENDERER_H__
+#define __COGL_RENDERER_H__
+
+#include <glib.h>
+
+#include <cogl/cogl-types.h>
+#include <cogl/cogl-onscreen-template.h>
+
+#ifdef COGL_HAS_XLIB
+#include <X11/Xlib.h>
+#endif
+
+G_BEGIN_DECLS
+
+/**
+ * SECTION:cogl-renderer
+ * @short_description:
+ *
+ */
+
+#define cogl_renderer_error_quark cogl_renderer_error_quark_EXP
+
+#define COGL_RENDERER_ERROR cogl_renderer_error_quark ()
+GQuark
+cogl_renderer_error_quark (void);
+
+typedef struct _CoglRenderer CoglRenderer;
+
+#define cogl_is_renderer cogl_is_renderer_EXP
+gboolean
+cogl_is_renderer (void *object);
+
+#define cogl_renderer_new cogl_renderer_new_EXP
+CoglRenderer *
+cogl_renderer_new (void);
+
+/* optional configuration APIs */
+
+#ifdef COGL_HAS_XLIB
+
+#define cogl_renderer_xlib_handle_event cogl_renderer_xlib_handle_event_EXP
+/*
+ * cogl_renderer_xlib_handle_event:
+ * @xevent: pointer to XEvent structure
+ *
+ * This function processes a single X event; it can be used to hook
+ * into external X event retrieval (for example that done by Clutter
+ * or GDK).
+ *
+ * Return value: #CoglXlibFilterReturn. %COGL_XLIB_FILTER_REMOVE
+ * indicates that Cogl has internally handled the event and the
+ * caller should do no further processing. %COGL_XLIB_FILTER_CONTINUE
+ * indicates that Cogl is either not interested in the event,
+ * or has used the event to update internal state without taking
+ * any exclusive action.
+ */
+CoglXlibFilterReturn
+cogl_renderer_xlib_handle_event (CoglRenderer *renderer,
+                                 XEvent *xevent);
+
+#define cogl_renderer_xlib_get_foreign_display \
+  cogl_renderer_xlib_get_foreign_display_EXP
+/*
+ * cogl_renderer_xlib_get_foreign_display:
+ *
+ * Return value: the foreign Xlib display that will be used by any Xlib based
+ * winsys backend. The display needs to be set with
+ * cogl_renderer_xlib_set_foreign_display() before this function is called.
+ */
+Display *
+cogl_renderer_xlib_get_foreign_display (CoglRenderer *renderer);
+
+#define cogl_renderer_xlib_set_foreign_display \
+  cogl_renderer_xlib_set_foreign_display_EXP
+/*
+ * cogl_renderer_xlib_set_foreign_display:
+ *
+ * Sets a foreign Xlib display that Cogl will use for and Xlib based winsys
+ * backend.
+ */
+void
+cogl_renderer_xlib_set_foreign_display (CoglRenderer *renderer,
+                                        Display *display);
+
+#define cogl_renderer_xlib_get_display cogl_renderer_xlib_get_display_EXP
+Display *
+cogl_renderer_xlib_get_display (CoglRenderer *renderer);
+
+#define cogl_renderer_xlib_add_filter cogl_renderer_xlib_add_filter_EXP
+/*
+ * _cogl_xlib_add_filter:
+ *
+ * Adds a callback function that will receive all X11 events. The
+ * function can stop further processing of the event by return
+ * %COGL_XLIB_FILTER_REMOVE.
+ */
+void
+cogl_renderer_xlib_add_filter (CoglRenderer *renderer,
+                               CoglXlibFilterFunc func,
+                               void *data);
+
+#define cogl_renderer_xlib_remove_filter cogl_renderer_xlib_remove_filter_EXP
+/*
+ * _cogl_xlib_remove_filter:
+ *
+ * Removes a callback that was previously added with
+ * _cogl_xlib_add_filter().
+ */
+void
+cogl_renderer_xlib_remove_filter (CoglRenderer *renderer,
+                                  CoglXlibFilterFunc func,
+                                  void *data);
+#endif /* COGL_HAS_XLIB */
+
+#define cogl_renderer_check_onscreen_template \
+  cogl_renderer_check_onscreen_template_EXP
+gboolean
+cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
+                                       CoglOnscreenTemplate *onscreen_template,
+                                       GError **error);
+
+/* Final connection API */
+
+#define cogl_renderer_connect cogl_renderer_connect_EXP
+gboolean
+cogl_renderer_connect (CoglRenderer *renderer, GError **error);
+
+G_END_DECLS
+
+#endif /* __COGL_RENDERER_H__ */
+
diff --git a/clutter/cogl/cogl/cogl-swap-chain-private.h b/clutter/cogl/cogl/cogl-swap-chain-private.h
new file mode 100644
index 0000000..5edadeb
--- /dev/null
+++ b/clutter/cogl/cogl/cogl-swap-chain-private.h
@@ -0,0 +1,37 @@
+/*
+ * 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_SWAP_CHAIN_PRIVATE_H
+#define __COGL_SWAP_CHAIN_PRIVATE_H
+
+#include "cogl-object-private.h"
+
+struct _CoglSwapChain
+{
+  CoglObject _parent;
+
+  gboolean has_alpha;
+
+};
+
+#endif /* __COGL_SWAP_CHAIN_PRIVATE_H */
diff --git a/clutter/cogl/cogl/cogl-swap-chain.c b/clutter/cogl/cogl/cogl-swap-chain.c
new file mode 100644
index 0000000..9622e9e
--- /dev/null
+++ b/clutter/cogl/cogl/cogl-swap-chain.c
@@ -0,0 +1,66 @@
+/*
+ * 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ *   Robert Bragg <robert linux intel com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "cogl.h"
+#include "cogl-object.h"
+
+#include "cogl-swap-chain-private.h"
+
+static void _cogl_swap_chain_free (CoglSwapChain *swap_chain);
+
+COGL_OBJECT_DEFINE (SwapChain, swap_chain);
+
+GQuark
+cogl_swap_chain_error_quark (void)
+{
+  return g_quark_from_static_string ("cogl-swap-chain-error-quark");
+}
+
+static void
+_cogl_swap_chain_free (CoglSwapChain *swap_chain)
+{
+  g_slice_free (CoglSwapChain, swap_chain);
+}
+
+CoglSwapChain *
+cogl_swap_chain_new (void)
+{
+  CoglSwapChain *swap_chain = g_slice_new0 (CoglSwapChain);
+
+  return _cogl_swap_chain_object_new (swap_chain);
+}
+
+void
+cogl_swap_chain_set_has_alpha (CoglSwapChain *swap_chain,
+                               gboolean has_alpha)
+{
+  swap_chain->has_alpha = has_alpha;
+}
+
diff --git a/clutter/cogl/cogl/cogl-swap-chain.h b/clutter/cogl/cogl/cogl-swap-chain.h
new file mode 100644
index 0000000..7791e23
--- /dev/null
+++ b/clutter/cogl/cogl/cogl-swap-chain.h
@@ -0,0 +1,46 @@
+/*
+ * 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
+#error "Only <cogl/cogl.h> can be included directly."
+#endif
+
+#ifndef __COGL_SWAP_CHAIN_H__
+#define __COGL_SWAP_CHAIN_H__
+
+G_BEGIN_DECLS
+
+typedef struct _CoglSwapChain CoglSwapChain;
+
+#define cogl_swap_chain_new cogl_swap_chain_new_EXP
+CoglSwapChain *
+cogl_swap_chain_new (void);
+
+#define cogl_swap_chain_set_has_alpha cogl_swap_chain_set_has_alpha_EXP
+void
+cogl_swap_chain_set_has_alpha (CoglSwapChain *swap_chain,
+                               gboolean has_alpha);
+
+G_END_DECLS
+
+#endif /* __COGL_SWAP_CHAIN_H__ */



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