[Cogl] [PATCH] Removes the CoglSwapChain api

Robert Bragg robert at sixbynine.org
Fri Jun 7 09:05:00 PDT 2013


From: Robert Bragg <robert at linux.intel.com>

The CoglSwapChain api made initializing a context more awkward than it
ought to be in the relatively common case where you want onscreen
framebuffers to have an alpha channel.

The api let you specify an explicit swap-chain length and also request
that the swap chain buffers should have an alpha component and then the
a CoglSwapChain could be used to construct a CoglOnscreenTemplate

This removes the CoglSwapChain object and apis and adds a
cogl_onscreen_template_set_has_alpha() api instead. Since we can't
normally control exactly how long the swap chain is even if we have api
to request a length this patch doesn't replace that capability.

One thing to note here is that this removes the ability to request a
single buffered CoglOnscreen framebuffer but since we have never had a
use case for that and have not generally considered the implications of
supporting single buffered rendering in Cogl's design it is probably for
the best not to imply that it's supported.
---
 cogl/Makefile.am                       |  4 --
 cogl/cogl-display.c                    |  2 +-
 cogl/cogl-framebuffer-private.h        |  2 +-
 cogl/cogl-gles2-context.c              |  1 -
 cogl/cogl-onscreen-template-private.h  |  2 +-
 cogl/cogl-onscreen-template.c          | 15 ++++----
 cogl/cogl-onscreen-template.h          | 26 +++++++++++--
 cogl/cogl-onscreen.c                   |  1 -
 cogl/cogl-swap-chain-private.h         | 38 -------------------
 cogl/cogl-swap-chain.c                 | 68 ----------------------------------
 cogl/cogl-swap-chain.h                 | 51 -------------------------
 cogl/cogl.h                            |  1 -
 cogl/cogl.symbols                      |  5 +--
 cogl/winsys/cogl-winsys-egl-gdl.c      | 13 +------
 cogl/winsys/cogl-winsys-egl.c          |  3 +-
 cogl/winsys/cogl-winsys-glx.c          |  8 ++--
 cogl/winsys/cogl-winsys-sdl.c          |  7 +---
 cogl/winsys/cogl-winsys-sdl2.c         |  7 +---
 cogl/winsys/cogl-winsys-wgl.c          |  3 +-
 doc/reference/cogl2/cogl2-sections.txt | 16 ++------
 examples/cogl-msaa.c                   |  2 +-
 examples/cogl-x11-foreign.c            | 21 ++++-------
 examples/cogl-x11-tfp.c                | 20 +++-------
 23 files changed, 61 insertions(+), 255 deletions(-)
 delete mode 100644 cogl/cogl-swap-chain-private.h
 delete mode 100644 cogl/cogl-swap-chain.c
 delete mode 100644 cogl/cogl-swap-chain.h

diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index 323239d..a9cd039 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -98,7 +98,6 @@ cogl_public_h = \
 	$(srcdir)/cogl-renderer.h 		\
 	$(srcdir)/cogl-snippet.h		\
 	$(srcdir)/cogl-sub-texture.h            \
-	$(srcdir)/cogl-swap-chain.h 		\
 	$(srcdir)/cogl-texture-2d-gl.h 		\
 	$(srcdir)/cogl-texture-2d-sliced.h      \
 	$(srcdir)/cogl-texture-2d.h             \
@@ -247,9 +246,6 @@ cogl_sources_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 		\
diff --git a/cogl/cogl-display.c b/cogl/cogl-display.c
index 73d2cfb..1f3acd1 100644
--- a/cogl/cogl-display.c
+++ b/cogl/cogl-display.c
@@ -99,7 +99,7 @@ cogl_display_new (CoglRenderer *renderer,
   if (onscreen_template)
     cogl_object_ref (onscreen_template);
   else
-    display->onscreen_template = cogl_onscreen_template_new (NULL);
+    display->onscreen_template = cogl_onscreen_template_new ();
 
   display->setup = FALSE;
 
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index 2dfcb6e..ffe5e86 100644
--- a/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl-framebuffer-private.h
@@ -49,7 +49,7 @@ typedef enum _CoglFramebufferType {
 
 typedef struct
 {
-  CoglSwapChain *swap_chain;
+  CoglBool has_alpha;
   CoglBool need_stencil;
   int samples_per_pixel;
   CoglBool swap_throttled;
diff --git a/cogl/cogl-gles2-context.c b/cogl/cogl-gles2-context.c
index 2d0ab52..8062a6e 100644
--- a/cogl/cogl-gles2-context.c
+++ b/cogl/cogl-gles2-context.c
@@ -42,7 +42,6 @@
 #include "cogl-framebuffer-gl-private.h"
 #include "cogl-onscreen-template-private.h"
 #include "cogl-renderer-private.h"
-#include "cogl-swap-chain-private.h"
 #include "cogl-texture-2d-gl.h"
 #include "cogl-texture-2d-private.h"
 #include "cogl-pipeline-opengl-private.h"
diff --git a/cogl/cogl-onscreen-template-private.h b/cogl/cogl-onscreen-template-private.h
index b080b57..3dc937f 100644
--- a/cogl/cogl-onscreen-template-private.h
+++ b/cogl/cogl-onscreen-template-private.h
@@ -25,8 +25,8 @@
 #define __COGL_ONSCREEN_TEMPLATE_PRIVATE_H
 
 #include "cogl-object-private.h"
-#include "cogl-swap-chain.h"
 #include "cogl-framebuffer-private.h"
+#include "cogl-boxed-value.h"
 
 struct _CoglOnscreenTemplate
 {
diff --git a/cogl/cogl-onscreen-template.c b/cogl/cogl-onscreen-template.c
index 5fa5b99..6141444 100644
--- a/cogl/cogl-onscreen-template.c
+++ b/cogl/cogl-onscreen-template.c
@@ -46,17 +46,11 @@ _cogl_onscreen_template_free (CoglOnscreenTemplate *onscreen_template)
 }
 
 CoglOnscreenTemplate *
-cogl_onscreen_template_new (CoglSwapChain *swap_chain)
+cogl_onscreen_template_new (void)
 {
   CoglOnscreenTemplate *onscreen_template = g_slice_new0 (CoglOnscreenTemplate);
   char *user_config;
 
-  onscreen_template->config.swap_chain = swap_chain;
-  if (swap_chain)
-    cogl_object_ref (swap_chain);
-  else
-    onscreen_template->config.swap_chain = cogl_swap_chain_new ();
-
   onscreen_template->config.swap_throttled = TRUE;
   onscreen_template->config.need_stencil = TRUE;
   onscreen_template->config.samples_per_pixel = 0;
@@ -88,3 +82,10 @@ cogl_onscreen_template_set_swap_throttled (
 {
   onscreen_template->config.swap_throttled = throttled;
 }
+
+void
+cogl_onscreen_template_set_has_alpha (CoglOnscreenTemplate *onscreen_template,
+                                      CoglBool has_alpha)
+{
+  onscreen_template->config.has_alpha = has_alpha;
+}
diff --git a/cogl/cogl-onscreen-template.h b/cogl/cogl-onscreen-template.h
index 58d88d4..d69798a 100644
--- a/cogl/cogl-onscreen-template.h
+++ b/cogl/cogl-onscreen-template.h
@@ -31,8 +31,6 @@
 #ifndef __COGL_ONSCREEN_TEMPLATE_H__
 #define __COGL_ONSCREEN_TEMPLATE_H__
 
-#include <cogl/cogl-swap-chain.h>
-
 COGL_BEGIN_DECLS
 
 typedef struct _CoglOnscreenTemplate	      CoglOnscreenTemplate;
@@ -40,11 +38,11 @@ typedef struct _CoglOnscreenTemplate	      CoglOnscreenTemplate;
 #define COGL_ONSCREEN_TEMPLATE(OBJECT) ((CoglOnscreenTemplate *)OBJECT)
 
 CoglOnscreenTemplate *
-cogl_onscreen_template_new (CoglSwapChain *swap_chain);
+cogl_onscreen_template_new (void);
 
 /**
  * cogl_onscreen_template_set_samples_per_pixel:
- * @onscreen: A #CoglOnscreenTemplate template framebuffer
+ * @onscreen_template: A #CoglOnscreenTemplate template framebuffer
  * @n: The minimum number of samples per pixel
  *
  * Requires that any future CoglOnscreen framebuffers derived from
@@ -88,6 +86,26 @@ cogl_onscreen_template_set_swap_throttled (
                                           CoglBool throttled);
 
 /**
+ * cogl_onscreen_template_set_has_alpha:
+ * @onscreen_template: A #CoglOnscreenTemplate template framebuffer
+ * @has_alpha: Whether an alpha channel is required
+ *
+ * Requests that any future #CoglOnscreen framebuffers derived from
+ * this template should have an alpha channel if @has_alpha is %TRUE.
+ * If @has_alpha is FALSE then future framebuffers derived from this
+ * template aren't required to have an alpha channel, although Cogl
+ * may choose to ignore this and allocate a redundant alpha channel.
+ *
+ * By default a template does not request an alpha component.
+ *
+ * Since: 1.16
+ * Stability: unstable
+ */
+void
+cogl_onscreen_template_set_has_alpha (CoglOnscreenTemplate *onscreen_template,
+                                      CoglBool has_alpha);
+
+/**
  * cogl_is_onscreen_template:
  * @object: A #CoglObject pointer
  *
diff --git a/cogl/cogl-onscreen.c b/cogl/cogl-onscreen.c
index f686b14..6cdff55 100644
--- a/cogl/cogl-onscreen.c
+++ b/cogl/cogl-onscreen.c
@@ -52,7 +52,6 @@ _cogl_onscreen_init_from_template (CoglOnscreen *onscreen,
   COGL_LIST_INIT (&onscreen->dirty_closures);
 
   framebuffer->config = onscreen_template->config;
-  cogl_object_ref (framebuffer->config.swap_chain);
 }
 
 CoglOnscreen *
diff --git a/cogl/cogl-swap-chain-private.h b/cogl/cogl-swap-chain-private.h
deleted file mode 100644
index ac27358..0000000
--- a/cogl/cogl-swap-chain-private.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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;
-
-  CoglBool has_alpha;
-
-  int length;
-};
-
-#endif /* __COGL_SWAP_CHAIN_PRIVATE_H */
diff --git a/cogl/cogl-swap-chain.c b/cogl/cogl-swap-chain.c
deleted file mode 100644
index 7a5b342..0000000
--- a/cogl/cogl-swap-chain.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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 at linux.intel.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "cogl-object.h"
-
-#include "cogl-swap-chain-private.h"
-#include "cogl-swap-chain.h"
-
-static void _cogl_swap_chain_free (CoglSwapChain *swap_chain);
-
-COGL_OBJECT_DEFINE (SwapChain, swap_chain);
-
-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);
-
-  swap_chain->length = -1; /* no preference */
-
-  return _cogl_swap_chain_object_new (swap_chain);
-}
-
-void
-cogl_swap_chain_set_has_alpha (CoglSwapChain *swap_chain,
-                               CoglBool has_alpha)
-{
-  swap_chain->has_alpha = has_alpha;
-}
-
-void
-cogl_swap_chain_set_length (CoglSwapChain *swap_chain,
-                            int length)
-{
-  swap_chain->length = length;
-}
diff --git a/cogl/cogl-swap-chain.h b/cogl/cogl-swap-chain.h
deleted file mode 100644
index 05596a8..0000000
--- a/cogl/cogl-swap-chain.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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(COGL_COMPILATION)
-#error "Only <cogl/cogl.h> can be included directly."
-#endif
-
-#ifndef __COGL_SWAP_CHAIN_H__
-#define __COGL_SWAP_CHAIN_H__
-
-COGL_BEGIN_DECLS
-
-typedef struct _CoglSwapChain CoglSwapChain;
-
-CoglSwapChain *
-cogl_swap_chain_new (void);
-
-void
-cogl_swap_chain_set_has_alpha (CoglSwapChain *swap_chain,
-                               CoglBool has_alpha);
-
-void
-cogl_swap_chain_set_length (CoglSwapChain *swap_chain,
-                            int length);
-
-CoglBool
-cogl_is_swap_chain (void *object);
-
-COGL_END_DECLS
-
-#endif /* __COGL_SWAP_CHAIN_H__ */
diff --git a/cogl/cogl.h b/cogl/cogl.h
index 790dcd9..b7a373a 100644
--- a/cogl/cogl.h
+++ b/cogl/cogl.h
@@ -46,7 +46,6 @@
 #include <cogl/cogl-enum-types.h>
 #endif
 
-#include <cogl/cogl-swap-chain.h>
 #include <cogl/cogl-renderer.h>
 #include <cogl/cogl-output.h>
 #include <cogl/cogl-display.h>
diff --git a/cogl/cogl.symbols b/cogl/cogl.symbols
index 21a0c81..714ef15 100644
--- a/cogl/cogl.symbols
+++ b/cogl/cogl.symbols
@@ -357,6 +357,7 @@ cogl_onscreen_show
 cogl_onscreen_swap_buffers
 cogl_onscreen_swap_region
 cogl_onscreen_template_new
+cogl_onscreen_template_set_has_alpha
 cogl_onscreen_template_set_samples_per_pixel
 cogl_onscreen_template_set_swap_throttled
 
@@ -540,10 +541,6 @@ cogl_snippet_set_replace
 cogl_sub_texture_get_parent
 cogl_sub_texture_new
 
-cogl_swap_chain_new
-cogl_swap_chain_set_has_alpha
-cogl_swap_chain_set_length
-
 cogl_texture_error_domain
 cogl_texture_flags_get_type
 cogl_texture_get_data
diff --git a/cogl/winsys/cogl-winsys-egl-gdl.c b/cogl/winsys/cogl-winsys-egl-gdl.c
index f8b4a13..9bbce35 100644
--- a/cogl/winsys/cogl-winsys-egl-gdl.c
+++ b/cogl/winsys/cogl-winsys-egl-gdl.c
@@ -35,7 +35,6 @@
 #include "cogl-framebuffer-private.h"
 #include "cogl-onscreen-private.h"
 #include "cogl-onscreen-template-private.h"
-#include "cogl-swap-chain-private.h"
 
 static const CoglWinsysEGLVtable _cogl_winsys_egl_vtable;
 
@@ -223,18 +222,8 @@ gdl_plane_init (CoglDisplay *display, CoglError **error)
   if (rc == GDL_SUCCESS)
     rc = gdl_plane_set_attr (GDL_PLANE_DST_RECT, &dstRect);
 
-  /* Default to triple buffering if the swap_chain doesn't have an explicit
-   * length */
   if (rc == GDL_SUCCESS)
-    {
-      if (display->onscreen_template->config.swap_chain &&
-          display->onscreen_template->config.swap_chain->length != -1)
-        rc = gdl_plane_set_uint (GDL_PLANE_NUM_GFX_SURFACES,
-                                 display->onscreen_template->
-                                 config.swap_chain->length);
-      else
-        rc = gdl_plane_set_uint (GDL_PLANE_NUM_GFX_SURFACES, 3);
-    }
+    rc = gdl_plane_set_uint (GDL_PLANE_NUM_GFX_SURFACES, 3);
 
   if (rc == GDL_SUCCESS)
     rc = gdl_plane_config_end (GDL_FALSE);
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index 4ccebcd..e5aa7e8 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -36,7 +36,6 @@
 #include "cogl-context-private.h"
 #include "cogl-framebuffer.h"
 #include "cogl-onscreen-private.h"
-#include "cogl-swap-chain-private.h"
 #include "cogl-renderer-private.h"
 #include "cogl-onscreen-template-private.h"
 #include "cogl-gles2-context-private.h"
@@ -246,7 +245,7 @@ egl_attributes_from_framebuffer_config (CoglDisplay *display,
   attributes[i++] = 1;
 
   attributes[i++] = EGL_ALPHA_SIZE;
-  attributes[i++] = config->swap_chain->has_alpha ? 1 : EGL_DONT_CARE;
+  attributes[i++] = config->has_alpha ? 1 : EGL_DONT_CARE;
 
   attributes[i++] = EGL_DEPTH_SIZE;
   attributes[i++] = 1;
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index 3f9e017..9f90a8f 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -34,7 +34,6 @@
 #include "cogl-feature-private.h"
 #include "cogl-context-private.h"
 #include "cogl-framebuffer.h"
-#include "cogl-swap-chain-private.h"
 #include "cogl-renderer-private.h"
 #include "cogl-glx-renderer-private.h"
 #include "cogl-onscreen-template-private.h"
@@ -46,7 +45,6 @@
 #include "cogl-frame-info-private.h"
 #include "cogl-framebuffer-private.h"
 #include "cogl-onscreen-private.h"
-#include "cogl-swap-chain-private.h"
 #include "cogl-xlib-renderer.h"
 #include "cogl-util.h"
 #include "cogl-winsys-glx-private.h"
@@ -874,7 +872,7 @@ glx_attributes_from_framebuffer_config (CoglDisplay *display,
   attributes[i++] = GLX_BLUE_SIZE;
   attributes[i++] = 1;
   attributes[i++] = GLX_ALPHA_SIZE;
-  attributes[i++] = config->swap_chain->has_alpha ? 1 : GLX_DONT_CARE;
+  attributes[i++] = config->has_alpha ? 1 : GLX_DONT_CARE;
   attributes[i++] = GLX_DEPTH_SIZE;
   attributes[i++] = 1;
   attributes[i++] = GLX_STENCIL_SIZE;
@@ -927,7 +925,7 @@ find_fbconfig (CoglDisplay *display,
       goto done;
     }
 
-  if (config->swap_chain->has_alpha)
+  if (config->has_alpha)
     {
       int i;
 
@@ -1005,7 +1003,7 @@ create_context (CoglDisplay *display, CoglError **error)
     _cogl_xlib_renderer_get_data (display->renderer);
   CoglGLXRenderer *glx_renderer = display->renderer->winsys;
   CoglBool support_transparent_windows =
-    display->onscreen_template->config.swap_chain->has_alpha;
+    display->onscreen_template->config.has_alpha;
   GLXFBConfig config;
   CoglError *fbconfig_error = NULL;
   XSetWindowAttributes attrs;
diff --git a/cogl/winsys/cogl-winsys-sdl.c b/cogl/winsys/cogl-winsys-sdl.c
index 75b7edd..9d6d8ae 100644
--- a/cogl/winsys/cogl-winsys-sdl.c
+++ b/cogl/winsys/cogl-winsys-sdl.c
@@ -32,7 +32,6 @@
 #include "cogl-renderer-private.h"
 #include "cogl-display-private.h"
 #include "cogl-framebuffer-private.h"
-#include "cogl-swap-chain-private.h"
 #include "cogl-onscreen-template-private.h"
 #include "cogl-context-private.h"
 #include "cogl-onscreen-private.h"
@@ -146,12 +145,10 @@ set_gl_attribs_from_framebuffer_config (CoglFramebufferConfig *config)
   SDL_GL_SetAttribute (SDL_GL_STENCIL_SIZE,
                        config->need_stencil ? 1 : 0);
 
-  if (config->swap_chain->length >= 0)
-    SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER,
-                         config->swap_chain->length > 1 ? 1 : 0);
+  SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
 
   SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE,
-                       config->swap_chain->has_alpha ? 1 : 0);
+                       config->has_alpha ? 1 : 0);
 }
 
 static CoglBool
diff --git a/cogl/winsys/cogl-winsys-sdl2.c b/cogl/winsys/cogl-winsys-sdl2.c
index 58666cb..00445b8 100644
--- a/cogl/winsys/cogl-winsys-sdl2.c
+++ b/cogl/winsys/cogl-winsys-sdl2.c
@@ -32,7 +32,6 @@
 #include "cogl-renderer-private.h"
 #include "cogl-display-private.h"
 #include "cogl-framebuffer-private.h"
-#include "cogl-swap-chain-private.h"
 #include "cogl-onscreen-template-private.h"
 #include "cogl-context-private.h"
 #include "cogl-onscreen-private.h"
@@ -138,12 +137,10 @@ set_gl_attribs_from_framebuffer_config (CoglFramebufferConfig *config)
   SDL_GL_SetAttribute (SDL_GL_STENCIL_SIZE,
                        config->need_stencil ? 1 : 0);
 
-  if (config->swap_chain->length >= 0)
-    SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER,
-                         config->swap_chain->length > 1 ? 1 : 0);
+  SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
 
   SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE,
-                       config->swap_chain->has_alpha ? 1 : 0);
+                       config->has_alpha ? 1 : 0);
 }
 
 static CoglBool
diff --git a/cogl/winsys/cogl-winsys-wgl.c b/cogl/winsys/cogl-winsys-wgl.c
index 6a32e63..d83ff91 100644
--- a/cogl/winsys/cogl-winsys-wgl.c
+++ b/cogl/winsys/cogl-winsys-wgl.c
@@ -37,7 +37,6 @@
 #include "cogl-context-private.h"
 #include "cogl-framebuffer.h"
 #include "cogl-onscreen-private.h"
-#include "cogl-swap-chain-private.h"
 #include "cogl-renderer-private.h"
 #include "cogl-display-private.h"
 #include "cogl-onscreen-template-private.h"
@@ -423,7 +422,7 @@ choose_pixel_format (CoglFramebufferConfig *config,
              already found */
           (best_pf == 0 || pixel_format_is_better (&best_pfd, pfd)))
         {
-          if (config->swap_chain->has_alpha && pfd->cAlphaBits == 0)
+          if (config->has_alpha && pfd->cAlphaBits == 0)
             continue;
           if (config->need_stencil && pfd->cStencilBits == 0)
             continue;
diff --git a/doc/reference/cogl2/cogl2-sections.txt b/doc/reference/cogl2/cogl2-sections.txt
index ee79fd9..5f028ac 100644
--- a/doc/reference/cogl2/cogl2-sections.txt
+++ b/doc/reference/cogl2/cogl2-sections.txt
@@ -97,19 +97,6 @@ cogl_wayland_renderer_get_shell
 </SECTION>
 
 <SECTION>
-<FILE>cogl-swap-chain</FILE>
-<TITLE>CoglSwapChain: Describe a set of back buffers for flipping between</TITLE>
-<SUBSECTION>
-CoglSwapChain
-cogl_is_swap_chain
-
-<SUBSECTION>
-cogl_swap_chain_new
-cogl_swap_chain_set_has_alpha
-cogl_swap_chain_set_length
-</SECTION>
-
-<SECTION>
 <FILE>cogl-onscreen-template</FILE>
 <TITLE>CoglOnscreenTemplate: Describe a template for onscreen framebuffers</TITLE>
 <SUBSECTION>
@@ -118,6 +105,9 @@ cogl_is_onscreen_template
 
 <SUBSECTION>
 cogl_onscreen_template_new
+cogl_onscreen_template_set_has_alpha
+cogl_onscreen_template_set_swap_throttled
+cogl_onscreen_template_set_samples_per_pixel
 </SECTION>
 
 <SECTION>
diff --git a/examples/cogl-msaa.c b/examples/cogl-msaa.c
index 9fa7a3a..c0d9065 100644
--- a/examples/cogl-msaa.c
+++ b/examples/cogl-msaa.c
@@ -22,7 +22,7 @@ main (int argc, char **argv)
     CoglFramebuffer *offscreen_fb;
     CoglPipeline *pipeline;
 
-    onscreen_template = cogl_onscreen_template_new (NULL);
+    onscreen_template = cogl_onscreen_template_new ();
     cogl_onscreen_template_set_samples_per_pixel (onscreen_template, 4);
     display = cogl_display_new (NULL, onscreen_template);
 
diff --git a/examples/cogl-x11-foreign.c b/examples/cogl-x11-foreign.c
index 1622266..cdc2c88 100644
--- a/examples/cogl-x11-foreign.c
+++ b/examples/cogl-x11-foreign.c
@@ -46,7 +46,6 @@ main (int argc, char **argv)
 {
   Display *xdpy;
   CoglRenderer *renderer;
-  CoglSwapChain *chain;
   CoglOnscreenTemplate *onscreen_template;
   CoglDisplay *display;
   CoglContext *ctx;
@@ -77,10 +76,8 @@ main (int argc, char **argv)
       return 1;
     }
 
-  /* Conceptually choose a GPU... */
+  /* Choose a means to render... */
   renderer = cogl_renderer_new ();
-  /* FIXME: This should conceptually be part of the configuration of
-   * a renderer. */
   cogl_xlib_renderer_set_foreign_display (renderer, xdpy);
   if (!cogl_renderer_connect (renderer, &error))
     {
@@ -88,17 +85,13 @@ main (int argc, char **argv)
                error->message);
     }
 
-  chain = cogl_swap_chain_new ();
-  cogl_swap_chain_set_has_alpha (chain, TRUE);
+  /* Create a template for onscreen framebuffers that requests an
+   * alpha component */
+  onscreen_template = cogl_onscreen_template_new ();
+  cogl_onscreen_template_set_has_alpha (onscreen_template, TRUE);
 
-  /* Conceptually declare upfront the kinds of windows we anticipate
-   * creating so that when we configure the display pipeline we can avoid
-   * having an impedance miss-match between the format of windows and the
-   * format the display pipeline expects. */
-  onscreen_template = cogl_onscreen_template_new (chain);
-  cogl_object_unref (chain);
-
-  /* Conceptually setup a display pipeline */
+  /* Give Cogl our template for onscreen framebuffers which can
+   * influence how the context will be setup */
   display = cogl_display_new (renderer, onscreen_template);
   cogl_object_unref (renderer);
   if (!cogl_display_setup (display, &error))
diff --git a/examples/cogl-x11-tfp.c b/examples/cogl-x11-tfp.c
index e7d7b0e..7788da4 100644
--- a/examples/cogl-x11-tfp.c
+++ b/examples/cogl-x11-tfp.c
@@ -43,7 +43,6 @@ main (int argc, char **argv)
   Display *xdpy;
   int composite_error = 0, composite_event = 0;
   CoglRenderer *renderer;
-  CoglSwapChain *chain;
   CoglOnscreenTemplate *onscreen_template;
   CoglDisplay *display;
   CoglContext *ctx;
@@ -87,10 +86,8 @@ main (int argc, char **argv)
         }
     }
 
-  /* Conceptually choose a GPU... */
+  /* Choose a means to render... */
   renderer = cogl_renderer_new ();
-  /* FIXME: This should conceptually be part of the configuration of
-   * a renderer. */
   cogl_xlib_renderer_set_foreign_display (renderer, xdpy);
   if (!cogl_renderer_connect (renderer, &error))
     {
@@ -98,17 +95,12 @@ main (int argc, char **argv)
                error->message);
     }
 
-  chain = cogl_swap_chain_new ();
-  cogl_swap_chain_set_has_alpha (chain, TRUE);
+  /* Request that onscreen framebuffers should have an alpha component */
+  onscreen_template = cogl_onscreen_template_new ();
+  cogl_onscreen_template_set_has_alpha (onscreen_template, TRUE);
 
-  /* Conceptually declare upfront the kinds of windows we anticipate
-   * creating so that when we configure the display pipeline we can avoid
-   * having an impedance miss-match between the format of windows and the
-   * format the display pipeline expects. */
-  onscreen_template = cogl_onscreen_template_new (chain);
-  cogl_object_unref (chain);
-
-  /* Conceptually setup a display pipeline */
+  /* Give Cogl our template for onscreen windows which can influence
+   * how the context will be setup */
   display = cogl_display_new (renderer, onscreen_template);
   cogl_object_unref (renderer);
   if (!cogl_display_setup (display, &error))
-- 
1.8.2.1



More information about the Cogl mailing list