summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Reveman <davidr@novell.com>2005-12-21 16:19:50 +0000
committerDavid Reveman <davidr@novell.com>2005-12-21 16:19:50 +0000
commit9ee05ac602c3d93058644f94e9ff93d80112e221 (patch)
treea83e9b4699b9ef57f2b4f9805e7892425dc1e378 /src
parent0055b28ad6bc3a565fba38a424ca37ac6e2a143d (diff)
DrawBuffer/ReadBuffer support, flips when swapping buffers of FBOs and fix texture filter and wrap typo
Diffstat (limited to 'src')
-rw-r--r--src/agl/glitz_agl_context.c3
-rw-r--r--src/egl/glitz_egl_context.c3
-rw-r--r--src/glitz.c12
-rw-r--r--src/glitz.h11
-rw-r--r--src/glitz_context.c60
-rw-r--r--src/glitz_drawable.c26
-rw-r--r--src/glitz_framebuffer.c59
-rw-r--r--src/glitz_pixel.c2
-rw-r--r--src/glitz_surface.c9
-rw-r--r--src/glitzint.h19
-rw-r--r--src/glx/glitz_glx_context.c3
-rw-r--r--src/wgl/glitz_wgl_context.c3
12 files changed, 196 insertions, 14 deletions
diff --git a/src/agl/glitz_agl_context.c b/src/agl/glitz_agl_context.c
index 130654c..7105fd3 100644
--- a/src/agl/glitz_agl_context.c
+++ b/src/agl/glitz_agl_context.c
@@ -309,6 +309,9 @@ glitz_agl_context_get (glitz_agl_thread_info_t *thread_info,
context->backend.make_current = _glitz_agl_make_current;
context->backend.get_proc_address = _glitz_agl_context_get_proc_address;
+ context->backend.draw_buffer = _glitz_drawable_draw_buffer;
+ context->backend.read_buffer = _glitz_drawable_read_buffer;
+
context->backend.drawable_formats = NULL;
context->backend.n_drawable_formats = 0;
diff --git a/src/egl/glitz_egl_context.c b/src/egl/glitz_egl_context.c
index f64e8f7..41486c5 100644
--- a/src/egl/glitz_egl_context.c
+++ b/src/egl/glitz_egl_context.c
@@ -206,6 +206,9 @@ glitz_egl_context_get (glitz_egl_screen_info_t *screen_info,
context->backend.make_current = _glitz_egl_make_current;
context->backend.get_proc_address = _glitz_egl_context_get_proc_address;
+ context->backend.draw_buffer = _glitz_drawable_draw_buffer;
+ context->backend.read_buffer = _glitz_drawable_read_buffer;
+
context->backend.drawable_formats = NULL;
context->backend.n_drawable_formats = 0;
diff --git a/src/glitz.c b/src/glitz.c
index dbe2ba2..4e4c952 100644
--- a/src/glitz.c
+++ b/src/glitz.c
@@ -422,8 +422,10 @@ glitz_copy_area (glitz_surface_t *src,
glitz_surface_pop_current (src);
}
- gl->read_buffer (src->buffer);
- gl->draw_buffer (dst->buffer);
+ src->drawable->backend->read_buffer (src->drawable,
+ src->buffer);
+ dst->drawable->backend->draw_buffer (dst->drawable,
+ dst->buffer);
glitz_set_operator (gl, GLITZ_OPERATOR_SRC);
@@ -496,8 +498,8 @@ glitz_copy_area (glitz_surface_t *src,
gl->color_4us (0x0, 0x0, 0x0, 0xffff);
- param.filter[0] = param.filter[1] = GLITZ_GL_CLAMP_TO_EDGE;
- param.wrap[0] = param.wrap[1] = GLITZ_GL_NEAREST;
+ param.filter[0] = param.filter[1] = GLITZ_GL_NEAREST;
+ param.wrap[0] = param.wrap[1] = GLITZ_GL_CLAMP_TO_EDGE;
glitz_texture_ensure_parameters (gl, texture, &param);
@@ -596,7 +598,7 @@ glitz_copy_area (glitz_surface_t *src,
{
glitz_texture_t *texture;
- gl->read_buffer (src->buffer);
+ src->drawable->backend->read_buffer (src->drawable, src->buffer);
texture = glitz_surface_get_texture (dst, 1);
if (texture)
diff --git a/src/glitz.h b/src/glitz.h
index 71b9091..be4f735 100644
--- a/src/glitz.h
+++ b/src/glitz.h
@@ -28,7 +28,7 @@
#define GLITZ_MAJOR 0
#define GLITZ_MINOR 5
-#define GLITZ_REVISION 1
+#define GLITZ_REVISION 2
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
@@ -477,6 +477,15 @@ void
glitz_context_bind_texture (glitz_context_t *context,
glitz_texture_object_t *texture);
+void
+glitz_context_draw_buffers (glitz_context_t *context,
+ const glitz_drawable_buffer_t *buffers,
+ int n);
+
+void
+glitz_context_read_buffer (glitz_context_t *context,
+ const glitz_drawable_buffer_t buffer);
+
/* glitz_rect.c */
diff --git a/src/glitz_context.c b/src/glitz_context.c
index 249d933..fe0e637 100644
--- a/src/glitz_context.c
+++ b/src/glitz_context.c
@@ -186,3 +186,63 @@ glitz_context_bind_texture (glitz_context_t *context,
&texture->param);
}
slim_hidden_def(glitz_context_bind_texture);
+
+void
+glitz_context_draw_buffers (glitz_context_t *context,
+ const glitz_drawable_buffer_t *buffers,
+ int n)
+{
+ unsigned int mask = 0;
+
+#define FRONT_BIT (1 << 0)
+#define BACK_BIT (1 << 1)
+
+ while (n--)
+ {
+ switch (*buffers++) {
+ case GLITZ_DRAWABLE_BUFFER_FRONT_COLOR:
+ mask |= FRONT_BIT;
+ break;
+ case GLITZ_DRAWABLE_BUFFER_BACK_COLOR:
+ mask |= BACK_BIT;
+ default:
+ break;
+ }
+ }
+
+ if (mask)
+ {
+ if (mask == (FRONT_BIT | BACK_BIT))
+ context->drawable->backend->draw_buffer (context->drawable,
+ GLITZ_GL_FRONT_AND_BACK);
+ else if (mask == FRONT_BIT)
+ context->drawable->backend->draw_buffer (context->drawable,
+ GLITZ_GL_FRONT);
+ else
+ context->drawable->backend->draw_buffer (context->drawable,
+ GLITZ_GL_BACK);
+ }
+
+#undef FRONT_BIT
+#undef BACK_BIT
+
+}
+slim_hidden_def(glitz_context_draw_buffers);
+
+void
+glitz_context_read_buffer (glitz_context_t *context,
+ const glitz_drawable_buffer_t buffer)
+{
+ switch (buffer) {
+ case GLITZ_DRAWABLE_BUFFER_FRONT_COLOR:
+ context->drawable->backend->read_buffer (context->drawable,
+ GLITZ_GL_FRONT);
+ break;
+ case GLITZ_DRAWABLE_BUFFER_BACK_COLOR:
+ context->drawable->backend->read_buffer (context->drawable,
+ GLITZ_GL_BACK);
+ default:
+ break;
+ }
+}
+slim_hidden_def(glitz_context_read_buffer);
diff --git a/src/glitz_drawable.c b/src/glitz_drawable.c
index 9b0e77f..77fd833 100644
--- a/src/glitz_drawable.c
+++ b/src/glitz_drawable.c
@@ -55,6 +55,28 @@ _glitz_drawable_init (glitz_drawable_t *drawable,
drawable->update_all = 1;
}
+void
+_glitz_drawable_draw_buffer (void *abstract_drawable,
+ const glitz_gl_enum_t buffer)
+{
+ glitz_drawable_t *drawable = abstract_drawable;
+
+ GLITZ_GL_DRAWABLE (drawable);
+
+ gl->draw_buffer (buffer);
+}
+
+void
+_glitz_drawable_read_buffer (void *abstract_drawable,
+ const glitz_gl_enum_t buffer)
+{
+ glitz_drawable_t *drawable = abstract_drawable;
+
+ GLITZ_GL_DRAWABLE (drawable);
+
+ gl->read_buffer (buffer);
+}
+
static glitz_bool_t
_glitz_drawable_size_check (glitz_drawable_t *other,
unsigned int width,
@@ -241,8 +263,8 @@ glitz_drawable_swap_buffer_region (glitz_drawable_t *drawable,
gl->disable (GLITZ_GL_DITHER);
- gl->read_buffer (GLITZ_GL_BACK);
- gl->draw_buffer (GLITZ_GL_FRONT);
+ drawable->backend->read_buffer (drawable, GLITZ_GL_BACK);
+ drawable->backend->draw_buffer (drawable, GLITZ_GL_FRONT);
glitz_set_operator (gl, GLITZ_OPERATOR_SRC);
diff --git a/src/glitz_framebuffer.c b/src/glitz_framebuffer.c
index 69e7381..d39119b 100644
--- a/src/glitz_framebuffer.c
+++ b/src/glitz_framebuffer.c
@@ -313,6 +313,19 @@ _glitz_fbo_swap_buffers (void *abstract_drawable)
if (!drawable->fb)
return 1;
+ /* flip */
+ if (drawable->base.back && drawable->base.front)
+ {
+ glitz_texture_t tmp;
+
+ tmp = drawable->base.front->texture;
+
+ drawable->base.front->texture = drawable->base.back->texture;
+ drawable->base.back->texture = tmp;
+
+ return 1;
+ }
+
return 0;
}
@@ -351,6 +364,50 @@ _glitz_fbo_destroy (void *abstract_drawable)
free (drawable);
}
+static void
+_glitz_fbo_draw_buffer (void *abstract_drawable,
+ const glitz_gl_enum_t buffer)
+{
+ glitz_fbo_drawable_t *drawable = (glitz_fbo_drawable_t *)
+ abstract_drawable;
+
+ GLITZ_GL_DRAWABLE (drawable->other);
+
+ switch (buffer) {
+ case GLITZ_GL_FRONT:
+ gl->draw_buffer (GLITZ_GL_COLOR_ATTACHMENT0);
+ break;
+ case GLITZ_GL_BACK:
+ gl->draw_buffer (GLITZ_GL_COLOR_ATTACHMENT1);
+ break;
+ /* TODO: use GL_ARB_draw_buffers
+ case GLITZ_GL_FRONT_AND_BACK:
+ */
+ default:
+ break;
+ }
+}
+
+static void
+_glitz_fbo_read_buffer (void *abstract_drawable,
+ const glitz_gl_enum_t buffer)
+{
+ glitz_fbo_drawable_t *drawable = (glitz_fbo_drawable_t *)
+ abstract_drawable;
+
+ GLITZ_GL_DRAWABLE (drawable->other);
+
+ switch (buffer) {
+ case GLITZ_GL_FRONT:
+ gl->read_buffer (GLITZ_GL_COLOR_ATTACHMENT0);
+ break;
+ case GLITZ_GL_BACK:
+ gl->read_buffer (GLITZ_GL_COLOR_ATTACHMENT1);
+ default:
+ break;
+ }
+}
+
glitz_drawable_t *
_glitz_fbo_drawable_create (glitz_drawable_t *other,
glitz_int_drawable_format_t *format,
@@ -377,6 +434,8 @@ _glitz_fbo_drawable_create (glitz_drawable_t *other,
backend->detach_notify = _glitz_fbo_detach_notify;
backend->swap_buffers = _glitz_fbo_swap_buffers;
backend->make_current = _glitz_fbo_make_current;
+ backend->draw_buffer = _glitz_fbo_draw_buffer;
+ backend->read_buffer = _glitz_fbo_read_buffer;
drawable->fb = 0;
diff --git a/src/glitz_pixel.c b/src/glitz_pixel.c
index b0010e6..4384970 100644
--- a/src/glitz_pixel.c
+++ b/src/glitz_pixel.c
@@ -1509,7 +1509,7 @@ glitz_get_pixels (glitz_surface_t *src,
if (from_drawable)
{
- gl->read_buffer (src->buffer);
+ src->drawable->backend->read_buffer (src->drawable, src->buffer);
gl->disable (GLITZ_GL_SCISSOR_TEST);
diff --git a/src/glitz_surface.c b/src/glitz_surface.c
index 7e1cb03..b32f44e 100644
--- a/src/glitz_surface.c
+++ b/src/glitz_surface.c
@@ -208,7 +208,8 @@ _glitz_surface_sync_texture (glitz_surface_t *surface)
glitz_surface_push_current (surface, GLITZ_DRAWABLE_CURRENT);
- gl->read_buffer (surface->buffer);
+ surface->drawable->backend->read_buffer (surface->drawable,
+ surface->buffer);
gl->disable (GLITZ_GL_SCISSOR_TEST);
@@ -273,8 +274,8 @@ glitz_surface_sync_drawable (glitz_surface_t *surface)
GLITZ_GL_REPLACE);
gl->color_4us (0x0, 0x0, 0x0, 0xffff);
- param.filter[0] = param.filter[1] = GLITZ_GL_CLAMP_TO_EDGE;
- param.wrap[0] = param.wrap[1] = GLITZ_GL_NEAREST;
+ param.filter[0] = param.filter[1] = GLITZ_GL_NEAREST;
+ param.wrap[0] = param.wrap[1] = GLITZ_GL_CLAMP_TO_EDGE;
glitz_texture_ensure_parameters (gl, texture, &param);
@@ -473,7 +474,7 @@ _glitz_surface_update_state (glitz_surface_t *surface)
drawable->update_all = 0;
}
- gl->draw_buffer (surface->buffer);
+ drawable->backend->draw_buffer (drawable, surface->buffer);
if (SURFACE_DITHER (surface))
gl->enable (GLITZ_GL_DITHER);
diff --git a/src/glitzint.h b/src/glitzint.h
index 8f92d09..e8a9763 100644
--- a/src/glitzint.h
+++ b/src/glitzint.h
@@ -407,6 +407,14 @@ typedef struct glitz_backend {
(*make_current) (void *drawable,
void *context);
+ void
+ (*draw_buffer) (void *drawable,
+ const glitz_gl_enum_t buffer);
+
+ void
+ (*read_buffer) (void *drawable,
+ const glitz_gl_enum_t buffer);
+
glitz_function_pointer_t
(*get_proc_address) (void *context,
const char *name);
@@ -494,7 +502,6 @@ typedef struct _glitz_texture {
int height;
glitz_box_t box;
- glitz_box_t box_internal;
glitz_float_t texcoord_width_unit;
glitz_float_t texcoord_height_unit;
@@ -940,6 +947,14 @@ _glitz_drawable_init (glitz_drawable_t *drawable,
int width,
int height);
+void
+_glitz_drawable_draw_buffer (void *abstract_drawable,
+ const glitz_gl_enum_t buffer);
+
+void
+_glitz_drawable_read_buffer (void *abstract_drawable,
+ const glitz_gl_enum_t buffer);
+
extern glitz_drawable_t __internal_linkage *
_glitz_fbo_drawable_create (glitz_drawable_t *other,
glitz_int_drawable_format_t *format,
@@ -1085,5 +1100,7 @@ slim_hidden_proto(glitz_context_set_user_data)
slim_hidden_proto(glitz_context_get_proc_address)
slim_hidden_proto(glitz_context_make_current)
slim_hidden_proto(glitz_context_bind_texture)
+slim_hidden_proto(glitz_context_draw_buffers)
+slim_hidden_proto(glitz_context_read_buffer)
#endif /* GLITZINT_H_INCLUDED */
diff --git a/src/glx/glitz_glx_context.c b/src/glx/glitz_glx_context.c
index e0f87a9..5614428 100644
--- a/src/glx/glitz_glx_context.c
+++ b/src/glx/glitz_glx_context.c
@@ -286,6 +286,9 @@ glitz_glx_context_get (glitz_glx_screen_info_t *screen_info,
context->backend.make_current = _glitz_glx_make_current;
context->backend.get_proc_address = _glitz_glx_context_get_proc_address;
+ context->backend.draw_buffer = _glitz_drawable_draw_buffer;
+ context->backend.read_buffer = _glitz_drawable_read_buffer;
+
context->backend.drawable_formats = NULL;
context->backend.n_drawable_formats = 0;
diff --git a/src/wgl/glitz_wgl_context.c b/src/wgl/glitz_wgl_context.c
index 1b6d871..ec83a4f 100644
--- a/src/wgl/glitz_wgl_context.c
+++ b/src/wgl/glitz_wgl_context.c
@@ -193,6 +193,9 @@ glitz_wgl_context_get (glitz_wgl_screen_info_t *screen_info,
context->backend.make_current = _glitz_wgl_make_current;
context->backend.get_proc_address = _glitz_wgl_context_get_proc_address;
+ context->backend.draw_buffer = _glitz_drawable_draw_buffer;
+ context->backend.read_buffer = _glitz_drawable_read_buffer;
+
context->backend.drawable_formats = screen_info->formats;
context->backend.n_drawable_formats = screen_info->n_formats;