[cogl/wip/for-cairo-cogl: 4/8] onscreen: Support point sample based onscreen rendering
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/wip/for-cairo-cogl: 4/8] onscreen: Support point sample based onscreen rendering
- Date: Wed, 21 Sep 2011 16:09:08 +0000 (UTC)
commit 2783bf7d5a7911a369c70cde5a7af788da67ab02
Author: Robert Bragg <robert linux intel com>
Date: Sun Aug 21 21:27:13 2011 +0100
onscreen: Support point sample based onscreen rendering
This adds support for point sample based rendering of onscreen windows
whereby multiple point samples per pixel can be requested and if the
hardware supports that it typically results in reduced aliasing
(especially considering the jagged edges of polygons)
cogl/cogl-framebuffer-private.h | 1 +
cogl/cogl-onscreen-template.c | 18 ++++++++++++++++++
cogl/cogl-onscreen-template.h | 19 +++++++++++++++++++
cogl/winsys/cogl-winsys-egl.c | 8 ++++++++
cogl/winsys/cogl-winsys-glx.c | 9 +++++++++
5 files changed, 55 insertions(+), 0 deletions(-)
---
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h
index c429be9..98a13ea 100644
--- a/cogl/cogl-framebuffer-private.h
+++ b/cogl/cogl-framebuffer-private.h
@@ -51,6 +51,7 @@ typedef struct
{
CoglSwapChain *swap_chain;
gboolean need_stencil;
+ int point_samples_per_pixel;
} CoglFramebufferConfig;
struct _CoglFramebuffer
diff --git a/cogl/cogl-onscreen-template.c b/cogl/cogl-onscreen-template.c
index b9fbd23..5cad939 100644
--- a/cogl/cogl-onscreen-template.c
+++ b/cogl/cogl-onscreen-template.c
@@ -65,6 +65,24 @@ cogl_onscreen_template_new (CoglSwapChain *swap_chain)
onscreen_template->config.swap_chain = cogl_swap_chain_new ();
onscreen_template->config.need_stencil = TRUE;
+ onscreen_template->config.point_samples_per_pixel = 0;
+
+ user_config = getenv ("COGL_POINT_SAMPLES_PER_PIXEL");
+ if (user_config)
+ {
+ unsigned long point_samples_per_pixel = strtoul (user_config, NULL, 10);
+ if (point_samples_per_pixel != ULONG_MAX)
+ onscreen_template->config.point_samples_per_pixel =
+ point_samples_per_pixel;
+ }
return _cogl_onscreen_template_object_new (onscreen_template);
}
+
+void
+cogl_onscreen_template_set_point_samples_per_pixel (
+ CoglOnscreenTemplate *onscreen_template,
+ int samples_per_pixel)
+{
+ onscreen_template->config.point_samples_per_pixel = samples_per_pixel;
+}
diff --git a/cogl/cogl-onscreen-template.h b/cogl/cogl-onscreen-template.h
index 4769f9f..d4a0ea5 100644
--- a/cogl/cogl-onscreen-template.h
+++ b/cogl/cogl-onscreen-template.h
@@ -43,6 +43,25 @@ typedef struct _CoglOnscreenTemplate CoglOnscreenTemplate;
CoglOnscreenTemplate *
cogl_onscreen_template_new (CoglSwapChain *swap_chain);
+/**
+ * cogl_onscreen_template_set_point_samples_per_pixel:
+ * @onscreen: A #CoglOnscreenTemplate template framebuffer
+ * @n: The minimum number of samples per pixel
+ *
+ * Requires that any future CoglOnscreen framebuffers derived from
+ * this template must support making @n point samples per pixel which
+ * will all contribute to the final resolved color for that pixel.
+ *
+ * By default sampling is not based on point samples but rather by
+ * considering the whole rectangular area of the current pixel, so an
+ * @n value of %1 is not equivalent to the default behaviour. A value
+ * of %0 can be used to explicitly request non point based sampling.
+ */
+void
+cogl_onscreen_template_set_point_samples_per_pixel (
+ CoglOnscreenTemplate *onscreen_template,
+ int n);
+
G_END_DECLS
#endif /* __COGL_ONSCREEN_TEMPLATE_H__ */
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index b8b0d30..e7c273a 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -644,6 +644,14 @@ egl_attributes_from_framebuffer_config (CoglDisplay *display,
attributes[i++] = EGL_SURFACE_TYPE;
attributes[i++] = EGL_WINDOW_BIT;
+ if (config->point_samples_per_pixel)
+ {
+ attributes[i++] = EGL_SAMPLE_BUFFERS;
+ attributes[i++] = 1;
+ attributes[i++] = EGL_SAMPLES;
+ attributes[i++] = config->point_samples_per_pixel;
+ }
+
attributes[i++] = EGL_NONE;
g_assert (i < MAX_EGL_CONFIG_ATTRIBS);
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index c41fe45..bde57a2 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -485,6 +485,15 @@ glx_attributes_from_framebuffer_config (CoglDisplay *display,
attributes[i++] = GLX_STENCIL_SIZE;
attributes[i++] = config->need_stencil ? 1: GLX_DONT_CARE;
+ if (glx_renderer->glx_major == 1 && glx_renderer->glx_minor >= 4 &&
+ config->point_samples_per_pixel)
+ {
+ attributes[i++] = GLX_SAMPLE_BUFFERS;
+ attributes[i++] = 1;
+ attributes[i++] = GLX_SAMPLES;
+ attributes[i++] = config->point_samples_per_pixel;
+ }
+
attributes[i++] = None;
g_assert (i < MAX_GLX_CONFIG_ATTRIBS);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]