[cairo-commit] glitz/src glitz.c, 1.35, 1.36 glitz.h, 1.36,
1.37 glitz_context.c, 1.4, 1.5 glitz_drawable.c, 1.3,
1.4 glitz_framebuffer.c, 1.3, 1.4 glitz_pixel.c, 1.22,
1.23 glitz_surface.c, 1.32, 1.33 glitzint.h, 1.38, 1.39
David Reveman
commit at pdx.freedesktop.org
Wed Dec 21 08:19:53 PST 2005
Committed by: davidr
Update of /cvs/cairo/glitz/src
In directory gabe:/tmp/cvs-serv16879/src
Modified Files:
glitz.c glitz.h glitz_context.c glitz_drawable.c
glitz_framebuffer.c glitz_pixel.c glitz_surface.c glitzint.h
Log Message:
DrawBuffer/ReadBuffer support, flips when swapping buffers of FBOs and fix texture filter and wrap typo
Index: glitz.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- glitz.c 14 Sep 2005 15:57:16 -0000 1.35
+++ glitz.c 21 Dec 2005 16:19:51 -0000 1.36
@@ -422,8 +422,10 @@
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 @@
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, ¶m);
@@ -596,7 +598,7 @@
{
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)
Index: glitz.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- glitz.h 29 Nov 2005 22:41:26 -0000 1.36
+++ glitz.h 21 Dec 2005 16:19:51 -0000 1.37
@@ -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 @@
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 */
Index: glitz_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_context.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- glitz_context.c 29 Nov 2005 22:41:26 -0000 1.4
+++ glitz_context.c 21 Dec 2005 16:19:51 -0000 1.5
@@ -186,3 +186,63 @@
&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);
Index: glitz_drawable.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_drawable.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- glitz_drawable.c 14 Sep 2005 15:57:16 -0000 1.3
+++ glitz_drawable.c 21 Dec 2005 16:19:51 -0000 1.4
@@ -55,6 +55,28 @@
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 @@
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);
Index: glitz_framebuffer.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_framebuffer.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- glitz_framebuffer.c 14 Sep 2005 15:57:16 -0000 1.3
+++ glitz_framebuffer.c 21 Dec 2005 16:19:51 -0000 1.4
@@ -313,6 +313,19 @@
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 @@
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 @@
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;
Index: glitz_pixel.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_pixel.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- glitz_pixel.c 29 Nov 2005 22:41:27 -0000 1.22
+++ glitz_pixel.c 21 Dec 2005 16:19:51 -0000 1.23
@@ -1509,7 +1509,7 @@
if (from_drawable)
{
- gl->read_buffer (src->buffer);
+ src->drawable->backend->read_buffer (src->drawable, src->buffer);
gl->disable (GLITZ_GL_SCISSOR_TEST);
Index: glitz_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_surface.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- glitz_surface.c 29 Nov 2005 22:41:27 -0000 1.32
+++ glitz_surface.c 21 Dec 2005 16:19:51 -0000 1.33
@@ -208,7 +208,8 @@
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_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, ¶m);
@@ -473,7 +474,7 @@
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);
Index: glitzint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitzint.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- glitzint.h 29 Nov 2005 22:41:27 -0000 1.38
+++ glitzint.h 21 Dec 2005 16:19:51 -0000 1.39
@@ -407,6 +407,14 @@
(*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 @@
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 @@
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_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 */
More information about the cairo-commit
mailing list