summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2011-08-21 21:21:34 +0100
committerRobert Bragg <robert@linux.intel.com>2011-09-05 19:02:05 +0100
commit476ff37fa682d127228ad90c11aaa614744acab8 (patch)
tree428c127671673ab0284e7fef80a9fd6462ba6d4b
parent21e87a9bf095044873ac187d5ece154411defc78 (diff)
downloadcogl-476ff37fa682d127228ad90c11aaa614744acab8.tar.gz
display: always ensure we have an onscreen_template
If the user doesn't explicitly pass an onscreen template then instead of leaving display->onscreen_template as NULL we now instantiate a template ourselves. This simplifies winsys code that might want to refer to the template since it needn't first check for a NULL pointer. Reviewed-by: Neil Roberts <neil@linux.intel.com>
-rw-r--r--cogl/cogl-display.c2
-rw-r--r--cogl/winsys/cogl-winsys-egl.c9
-rw-r--r--cogl/winsys/cogl-winsys-glx.c3
3 files changed, 8 insertions, 6 deletions
diff --git a/cogl/cogl-display.c b/cogl/cogl-display.c
index b45560e0..0eefee82 100644
--- a/cogl/cogl-display.c
+++ b/cogl/cogl-display.c
@@ -109,6 +109,8 @@ cogl_display_new (CoglRenderer *renderer,
display->onscreen_template = onscreen_template;
if (onscreen_template)
cogl_object_ref (onscreen_template);
+ else
+ display->onscreen_template = cogl_onscreen_template_new (NULL);
display->setup = FALSE;
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index 35230fc8..86eaa4dd 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -1005,8 +1005,7 @@ create_context (CoglDisplay *display, GError **error)
g_return_val_if_fail (egl_display->egl_context == NULL, TRUE);
- if (display->onscreen_template &&
- display->onscreen_template->swap_chain &&
+ if (display->onscreen_template->swap_chain &&
display->onscreen_template->swap_chain->has_alpha)
support_transparent_windows = TRUE;
else
@@ -1098,10 +1097,12 @@ gdl_plane_init (CoglDisplay *display, GError **error)
if (rc == GDL_SUCCESS)
rc = gdl_plane_set_attr (GDL_PLANE_DST_RECT, &dstRect);
- /* Default to triple buffering if we don't have an onscreen template */
+ /* Default to triple buffering if the swap_chain doesn't have an explicit
+ * length */
if (rc == GDL_SUCCESS)
{
- if (display->onscreen_template)
+ if (display->onscreen_template->swap_chain &&
+ display->onscreen_template->swap_chain->length != -1)
rc = gdl_plane_set_uint (GDL_PLANE_NUM_GFX_SURFACES,
display->onscreen_template->swap_chain->length);
else
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index b50af556..80e262c3 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -550,8 +550,7 @@ create_context (CoglDisplay *display, GError **error)
g_return_val_if_fail (glx_display->glx_context == NULL, TRUE);
- if (display->onscreen_template &&
- display->onscreen_template->swap_chain &&
+ if (display->onscreen_template->swap_chain &&
display->onscreen_template->swap_chain->has_alpha)
support_transparent_windows = TRUE;
else