[cairo-commit] glitz/src glitz.c, 1.8, 1.9 glitz.h, 1.8,
1.9 glitz_agl_context.c, 1.2, 1.3 glitz_agl_pbuffer.c, 1.3,
1.4 glitz_agl_surface.c, 1.7, 1.8 glitz_aglint.h, 1.4,
1.5 glitz_glx_context.c, 1.5, 1.6 glitz_glx_info.c, 1.5,
1.6 glitz_glx_surface.c, 1.9, 1.10 glitz_glxext.h, 1.4,
1.5 glitz_glxint.h, 1.7, 1.8 glitz_matrix.c, 1.3,
1.4 glitz_programmatic.c, 1.5, 1.6 glitz_surface.c, 1.9,
1.10 glitz_texture.c, 1.5, 1.6 glitzint.h, 1.12, 1.13
David Reveman
commit at pdx.freedesktop.org
Tue May 18 08:01:52 PDT 2004
Committed by: davidr
Update of /cvs/cairo/glitz/src
In directory pdx:/tmp/cvs-serv9621/src
Modified Files:
glitz.c glitz.h glitz_agl_context.c glitz_agl_pbuffer.c
glitz_agl_surface.c glitz_aglint.h glitz_glx_context.c
glitz_glx_info.c glitz_glx_surface.c glitz_glxext.h
glitz_glxint.h glitz_matrix.c glitz_programmatic.c
glitz_surface.c glitz_texture.c glitzint.h
Log Message:
Added new read/draw buffer interface
Index: glitz.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** a/glitz.c 13 May 2004 21:19:56 -0000 1.8
--- b/glitz.c 18 May 2004 15:01:50 -0000 1.9
***************
*** 157,162 ****
src_box.y2 = src->height;
! if (src->transform)
! glitz_matrix_transform_bounding_box_double (src->transform, &src_box);
src_width = src_box.x2 - src_box.x1;
--- 157,164 ----
src_box.y2 = src->height;
! if (src->transform) {
! glitz_matrix_transform_point (src->transform, &src_box.x1, &src_box.y1);
! glitz_matrix_transform_point (src->transform, &src_box.x2, &src_box.y2);
! }
src_width = src_box.x2 - src_box.x1;
***************
*** 177,182 ****
mask_box.y2 = mask->height;
! if (mask->transform)
! glitz_matrix_transform_bounding_box_double (mask->transform, &mask_box);
mask_width = mask_box.x2 - mask_box.x1;
--- 179,186 ----
mask_box.y2 = mask->height;
! if (mask->transform) {
! glitz_matrix_transform_point (src->transform, &mask_box.x1, &mask_box.y1);
! glitz_matrix_transform_point (src->transform, &mask_box.x2, &mask_box.y2);
! }
mask_width = mask_box.x2 - mask_box.x1;
***************
*** 319,340 ****
glitz_bounding_box_t *mbounds)
{
! glitz_bounding_box_t box;
! if (bounds->x1 <= 0)
mbounds->x1 = 0;
else
mbounds->x1 = bounds->x1;
! if (bounds->y1 <= 0)
mbounds->y1 = 0;
else
mbounds->y1 = bounds->y1;
! if (bounds->x2 >= dst->width)
mbounds->x2 = dst->width;
else
mbounds->x2 = bounds->x2;
! if (bounds->y2 >= dst->height)
mbounds->y2 = dst->height;
else
--- 323,345 ----
glitz_bounding_box_t *mbounds)
{
! double x1, y1, x2, y2;
! int ix1, iy1, ix2, iy2;
! if (bounds->x1 < 0)
mbounds->x1 = 0;
else
mbounds->x1 = bounds->x1;
! if (bounds->y1 < 0)
mbounds->y1 = 0;
else
mbounds->y1 = bounds->y1;
! if (bounds->x2 > dst->width)
mbounds->x2 = dst->width;
else
mbounds->x2 = bounds->x2;
! if (bounds->y2 > dst->height)
mbounds->y2 = dst->height;
else
***************
*** 342,394 ****
if (!SURFACE_REPEAT (src)) {
! box.x1 = x_dst;
! box.y1 = y_dst;
! if (x_src < 0) box.x1 -= x_src;
! if (y_src < 0) box.y1 -= y_src;
! box.x2 = box.x1 + src->width;
! box.y2 = box.y1 + src->height;
! if (x_src > 0) box.x2 -= x_src;
! if (y_src > 0) box.y2 -= y_src;
if (src->transform)
! glitz_matrix_transform_bounding_box (src->transform, &box);
! if (mbounds->x1 < box.x1)
! mbounds->x1 = box.x1;
! if (mbounds->y1 < box.y1)
! mbounds->y1 = box.y1;
! if (mbounds->x2 > box.x2)
! mbounds->x2 = box.x2;
! if (mbounds->y2 > box.y2)
! mbounds->y2 = box.y2;
}
if (!SURFACE_REPEAT (mask)) {
! box.x1 = x_dst;
! box.y1 = y_dst;
! if (x_mask < 0) box.x1 -= x_mask;
! if (y_mask < 0) box.y1 -= y_mask;
! box.x2 = box.x1 + mask->width;
! box.y2 = box.y1 + mask->height;
! if (x_mask > 0) box.x2 -= x_mask;
! if (y_mask > 0) box.y2 -= y_mask;
!
if (mask->transform)
! glitz_matrix_transform_bounding_box (mask->transform, &box);
! if (mbounds->x1 < box.x1)
! mbounds->x1 = box.x1;
! if (mbounds->y1 < box.y1)
! mbounds->y1 = box.y1;
! if (mbounds->x2 > box.x2)
! mbounds->x2 = box.x2;
! if (mbounds->y2 > box.y2)
! mbounds->y2 = box.y2;
}
}
--- 347,401 ----
if (!SURFACE_REPEAT (src)) {
! x1 = y1 = 0;
! x2 = src->width;
! y2 = src->height;
if (src->transform)
! glitz_matrix_transform_bounding_box (src->transform,
! &x1, &y1, &x2, &y2);
! ix1 = (int) x1 + x_dst - x_src;
! iy1 = (int) y1 + y_dst - y_src;
! ix2 = (int) x2 + x_dst - x_src;
! iy2 = (int) y2 + y_dst - y_src;
! if (mbounds->x1 < ix1)
! mbounds->x1 = ix1;
! if (mbounds->y1 < iy1)
! mbounds->y1 = iy1;
! if (mbounds->x2 > ix2)
! mbounds->x2 = ix2;
!
! if (mbounds->y2 > iy2)
! mbounds->y2 = iy2;
}
if (!SURFACE_REPEAT (mask)) {
! x1 = y1 = 0;
! x2 = mask->width;
! y2 = mask->height;
!
if (mask->transform)
! glitz_matrix_transform_bounding_box (mask->transform,
! &x1, &y1, &x2, &y2);
! ix1 = (int) x1 + x_dst - x_mask;
! iy1 = (int) y1 + y_dst - y_mask;
! ix2 = (int) x2 + x_dst - x_mask;
! iy2 = (int) y2 + y_dst - y_mask;
! if (mbounds->x1 < ix1)
! mbounds->x1 = ix1;
! if (mbounds->y1 < iy1)
! mbounds->y1 = iy1;
! if (mbounds->x2 > ix2)
! mbounds->x2 = ix2;
!
! if (mbounds->y2 > iy2)
! mbounds->y2 = iy2;
}
}
***************
*** 681,688 ****
if (src->transform) {
! glitz_matrix_transform_point (src->transform, &tl);
! glitz_matrix_transform_point (src->transform, &bl);
! glitz_matrix_transform_point (src->transform, &tr);
! glitz_matrix_transform_point (src->transform, &br);
}
--- 688,695 ----
if (src->transform) {
! glitz_matrix_transform_point (src->transform, &tl.x, &tl.y);
! glitz_matrix_transform_point (src->transform, &bl.x, &bl.y);
! glitz_matrix_transform_point (src->transform, &tr.x, &tr.y);
! glitz_matrix_transform_point (src->transform, &br.x, &br.y);
}
***************
*** 939,946 ****
if (status) {
if (src->format->doublebuffer)
! gl->read_buffer (GLITZ_GL_BACK);
! if (dst->format->doublebuffer)
! gl->draw_buffer (GLITZ_GL_BACK);
!
gl->disable (GLITZ_GL_SCISSOR_TEST);
gl->disable (GLITZ_GL_DITHER);
--- 946,951 ----
if (status) {
if (src->format->doublebuffer)
! gl->read_buffer (src->read_buffer);
!
gl->disable (GLITZ_GL_SCISSOR_TEST);
gl->disable (GLITZ_GL_DITHER);
***************
*** 994,1000 ****
glitz_texture_unbind (gl, texture);
}
- gl->flush ();
}
status = 1;
glitz_surface_pop_current (dst);
}
--- 999,1005 ----
glitz_texture_unbind (gl, texture);
}
}
status = 1;
+ glitz_surface_dirty (dst, &dst_box);
glitz_surface_pop_current (dst);
}
***************
*** 1027,1031 ****
free (pixel_buf);
}
-
- glitz_surface_dirty (dst, &dst_box);
}
--- 1032,1034 ----
Index: glitz.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** a/glitz.h 13 May 2004 00:47:32 -0000 1.8
--- b/glitz.h 18 May 2004 15:01:50 -0000 1.9
***************
*** 337,346 ****
glitz_surface_update_size (glitz_surface_t *surface);
void
! glitz_surface_flush (glitz_surface_t *surface,
! int x,
! int y,
! unsigned int width,
! unsigned int height);
void
--- 337,358 ----
glitz_surface_update_size (glitz_surface_t *surface);
+ typedef enum {
+ GLITZ_BUFFER_FRONT,
+ GLITZ_BUFFER_BACK
+ } glitz_buffer_t;
+
void
! glitz_surface_set_read_buffer (glitz_surface_t *surface,
! glitz_buffer_t buffer);
!
! void
! glitz_surface_set_draw_buffer (glitz_surface_t *surface,
! glitz_buffer_t buffer);
!
! void
! glitz_surface_flush (glitz_surface_t *surface);
!
! void
! glitz_surface_swap_buffers (glitz_surface_t *surface);
void
Index: glitz_agl_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_context.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** a/glitz_agl_context.c 9 May 2004 20:54:51 -0000 1.2
--- b/glitz_agl_context.c 18 May 2004 15:01:50 -0000 1.3
***************
*** 99,107 ****
void
! glitz_agl_context_make_current (glitz_agl_surface_t *surface)
{
AGLContext context;
AGLDrawable drawable = (AGLDrawable) 0;
AGLPbuffer pbuffer = (AGLPbuffer) 0;
if ((!surface->drawable) && (!surface->pbuffer)) {
--- 99,111 ----
void
! glitz_agl_context_make_current (glitz_agl_surface_t *surface,
! glitz_bool_t flush)
{
AGLContext context;
AGLDrawable drawable = (AGLDrawable) 0;
AGLPbuffer pbuffer = (AGLPbuffer) 0;
+
+ if (flush)
+ glFlush ();
if ((!surface->drawable) && (!surface->pbuffer)) {
***************
*** 125,142 ****
glitz_constraint_t constraint)
{
switch (constraint) {
case GLITZ_CN_NONE:
break;
case GLITZ_CN_ANY_CONTEXT_CURRENT:
! if (aglGetCurrentContext () == NULL)
! glitz_agl_context_make_current (surface);
break;
case GLITZ_CN_SURFACE_CONTEXT_CURRENT:
! if (aglGetCurrentContext () != surface->context->context)
! glitz_agl_context_make_current (surface);
break;
case GLITZ_CN_SURFACE_DRAWABLE_CURRENT:
! if (aglGetCurrentContext () != surface->context->context) {
! glitz_agl_context_make_current (surface);
} else {
if (surface->pbuffer) {
--- 129,148 ----
glitz_constraint_t constraint)
{
+ AGLContext context = aglGetCurrentContext ();
+
switch (constraint) {
case GLITZ_CN_NONE:
break;
case GLITZ_CN_ANY_CONTEXT_CURRENT:
! if (context == NULL)
! glitz_agl_context_make_current (surface, 0);
break;
case GLITZ_CN_SURFACE_CONTEXT_CURRENT:
! if (context != surface->context->context)
! glitz_agl_context_make_current (surface, (context)? 1: 0);
break;
case GLITZ_CN_SURFACE_DRAWABLE_CURRENT:
! if (context != surface->context->context) {
! glitz_agl_context_make_current (surface, (context)? 1: 0);
} else {
if (surface->pbuffer) {
***************
*** 148,156 ****
if (pbuffer != surface->pbuffer)
! glitz_agl_context_make_current (surface);
} else if (surface->drawable) {
if (aglGetDrawable (surface->context->context) != surface->drawable)
! glitz_agl_context_make_current (surface);
}
}
--- 154,162 ----
if (pbuffer != surface->pbuffer)
! glitz_agl_context_make_current (surface, (context)? 1: 0);
} else if (surface->drawable) {
if (aglGetDrawable (surface->context->context) != surface->drawable)
! glitz_agl_context_make_current (surface, (context)? 1: 0);
}
}
Index: glitz_agl_pbuffer.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_pbuffer.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** a/glitz_agl_pbuffer.c 6 May 2004 14:55:03 -0000 1.3
--- b/glitz_agl_pbuffer.c 18 May 2004 15:01:50 -0000 1.4
***************
*** 49,63 ****
AGLContext context,
glitz_texture_t *texture,
! glitz_format_t *format)
{
! _glitz_agl_gl_proc_address.gen_textures (1, &texture->name);
! texture->allocated = 1;
glitz_texture_bind (&_glitz_agl_gl_proc_address, texture);
! if (format->doublebuffer)
! aglTexImagePBuffer (context, pbuffer, GL_BACK);
! else
! aglTexImagePBuffer (context, pbuffer, GL_FRONT);
glitz_texture_unbind (&_glitz_agl_gl_proc_address, texture);
--- 49,62 ----
AGLContext context,
glitz_texture_t *texture,
! glitz_gl_enum_t buffer)
{
! if (!texture->allocated) {
! _glitz_agl_gl_proc_address.gen_textures (1, &texture->name);
! texture->allocated = 1;
! }
glitz_texture_bind (&_glitz_agl_gl_proc_address, texture);
! aglTexImagePBuffer (context, pbuffer, buffer);
glitz_texture_unbind (&_glitz_agl_gl_proc_address, texture);
Index: glitz_agl_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_agl_surface.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** a/glitz_agl_surface.c 13 May 2004 00:47:32 -0000 1.7
--- b/glitz_agl_surface.c 18 May 2004 15:01:50 -0000 1.8
***************
*** 51,55 ****
static void
! _glitz_agl_surface_flush (void *abstract_surface);
static glitz_bool_t
--- 51,55 ----
static void
! _glitz_agl_surface_swap_buffers (void *abstract_surface);
static glitz_bool_t
***************
*** 100,104 ****
_glitz_agl_surface_get_texture,
_glitz_agl_surface_update_size,
! _glitz_agl_surface_flush,
_glitz_agl_surface_make_current_read
};
--- 100,104 ----
_glitz_agl_surface_get_texture,
_glitz_agl_surface_update_size,
! _glitz_agl_surface_swap_buffers,
_glitz_agl_surface_make_current_read
};
***************
*** 111,114 ****
--- 111,122 ----
if (surface->pbuffer) {
surface->base.hint_mask &= ~GLITZ_INT_HINT_DIRTY_MASK;
+
+ if (surface->base.read_buffer != surface->bound_buffer) {
+ glitz_agl_pbuffer_bind (surface->pbuffer,
+ surface->context->context,
+ &surface->base.texture,
+ surface->base.read_buffer);
+ surface->bound_buffer = surface->base.read_buffer;
+ }
return &surface->base.texture;
***************
*** 214,218 ****
surface->context->context,
&surface->base.texture,
! surface->base.format);
glitz_surface_pop_current (&surface->base);
}
--- 222,227 ----
surface->context->context,
&surface->base.texture,
! surface->base.read_buffer);
! surface->bound_buffer = surface->base.read_buffer;
glitz_surface_pop_current (&surface->base);
}
***************
*** 333,351 ****
if (surface->window) {
_glitz_agl_surface_update_size_for_window (surface->window,
! &surface->base.width,
! &surface->base.height);
! glitz_agl_context_push_current (surface,
! GLITZ_CN_SURFACE_DRAWABLE_CURRENT);
! aglUpdateContext (surface->context->context);
! glitz_agl_context_pop_current (surface);
}
}
static void
! _glitz_agl_surface_flush (void *abstract_surface)
{
glitz_agl_surface_t *surface = (glitz_agl_surface_t *) abstract_surface;
--- 342,381 ----
if (surface->window) {
+ int width, height;
+
_glitz_agl_surface_update_size_for_window (surface->window,
! &width, &height);
!
! if (width != surface->base.width || height != surface->base.height) {
! glitz_texture_t texture;
!
! glitz_texture_init (&texture,
! width, height,
! glitz_get_gl_format_from_bpp
! (surface->base.format->bpp),
! surface->thread_info->texture_mask);
!
! if (texture.width != surface->base.texture.width ||
! texture.height != surface->base.texture.height ||
! texture.target != surface->base.texture.target) {
! texture.name = surface->base.texture.name;
! surface->base.texture = texture;
! }
!
! surface->base.width = width;
! surface->base.height = height;
! glitz_agl_context_push_current (surface,
! GLITZ_CN_SURFACE_DRAWABLE_CURRENT);
! aglUpdateContext (surface->context->context);
! glitz_agl_context_pop_current (surface);
! }
}
}
static void
! _glitz_agl_surface_swap_buffers (void *abstract_surface)
{
glitz_agl_surface_t *surface = (glitz_agl_surface_t *) abstract_surface;
Index: glitz_aglint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_aglint.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** a/glitz_aglint.h 9 May 2004 20:54:51 -0000 1.4
--- b/glitz_aglint.h 18 May 2004 15:01:50 -0000 1.5
***************
*** 89,92 ****
--- 89,93 ----
AGLPbuffer pbuffer;
WindowRef window;
+ glitz_gl_enum_t bound_buffer;
};
***************
*** 126,130 ****
AGLContext context,
glitz_texture_t *texture,
! glitz_format_t *format);
extern void __internal_linkage
--- 127,131 ----
AGLContext context,
glitz_texture_t *texture,
! glitz_gl_enum_t buffer);
extern void __internal_linkage
Index: glitz_glx_context.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_context.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** a/glitz_glx_context.c 9 May 2004 20:54:51 -0000 1.5
--- b/glitz_glx_context.c 18 May 2004 15:01:50 -0000 1.6
***************
*** 259,266 ****
void
! glitz_glx_context_make_current (glitz_glx_surface_t *surface)
{
GLXContext context;
Drawable drawable;
if (!surface->drawable) {
--- 259,270 ----
void
! glitz_glx_context_make_current (glitz_glx_surface_t *surface,
! glitz_bool_t flush)
{
GLXContext context;
Drawable drawable;
+
+ if (flush)
+ glFlush ();
if (!surface->drawable) {
***************
*** 271,275 ****
drawable = surface->drawable;
}
!
glXMakeCurrent (surface->screen_info->display_info->display,
drawable, context);
--- 275,279 ----
drawable = surface->drawable;
}
!
glXMakeCurrent (surface->screen_info->display_info->display,
drawable, context);
***************
*** 283,302 ****
glitz_glx_context_update (glitz_glx_surface_t *surface,
glitz_constraint_t constraint)
! {
switch (constraint) {
case GLITZ_CN_NONE:
break;
case GLITZ_CN_ANY_CONTEXT_CURRENT:
! if (glXGetCurrentContext () == NULL)
! glitz_glx_context_make_current (surface);
break;
case GLITZ_CN_SURFACE_CONTEXT_CURRENT:
! if (glXGetCurrentContext () != surface->context->context)
! glitz_glx_context_make_current (surface);
break;
case GLITZ_CN_SURFACE_DRAWABLE_CURRENT:
! if ((glXGetCurrentContext () != surface->context->context) ||
(glXGetCurrentDrawable () != surface->drawable))
! glitz_glx_context_make_current (surface);
glitz_glx_context_set_surface_anti_aliasing (surface);
--- 287,308 ----
glitz_glx_context_update (glitz_glx_surface_t *surface,
glitz_constraint_t constraint)
! {
! GLXContext context = glXGetCurrentContext ();
!
switch (constraint) {
case GLITZ_CN_NONE:
break;
case GLITZ_CN_ANY_CONTEXT_CURRENT:
! if (context == NULL)
! glitz_glx_context_make_current (surface, 0);
break;
case GLITZ_CN_SURFACE_CONTEXT_CURRENT:
! if (context != surface->context->context)
! glitz_glx_context_make_current (surface, (context)? 1: 0);
break;
case GLITZ_CN_SURFACE_DRAWABLE_CURRENT:
! if ((context != surface->context->context) ||
(glXGetCurrentDrawable () != surface->drawable))
! glitz_glx_context_make_current (surface, (context)? 1: 0);
glitz_glx_context_set_surface_anti_aliasing (surface);
Index: glitz_glx_info.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_info.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** a/glitz_glx_info.c 13 May 2004 00:47:32 -0000 1.5
--- b/glitz_glx_info.c 18 May 2004 15:01:50 -0000 1.6
***************
*** 100,107 ****
};
! void *
glitz_glx_get_proc_address (glitz_glx_thread_info_t *info, const char *name)
{
! void *address = NULL;
if (info->glx.get_proc_address_arb)
--- 100,107 ----
};
! glitz_function_pointer_t
glitz_glx_get_proc_address (glitz_glx_thread_info_t *info, const char *name)
{
! glitz_function_pointer_t address = NULL;
if (info->glx.get_proc_address_arb)
***************
*** 111,116 ****
if (!info->dlhand)
info->dlhand = dlopen (info->gl_library, RTLD_LAZY);
!
! address = dlsym (info->dlhand, name);
}
--- 111,121 ----
if (!info->dlhand)
info->dlhand = dlopen (info->gl_library, RTLD_LAZY);
!
! if (info->dlhand) {
! dlerror ();
! address = (glitz_function_pointer_t) dlsym (info->dlhand, name);
! if (dlerror () != NULL)
! address = NULL;
! }
}
Index: glitz_glx_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glx_surface.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** a/glitz_glx_surface.c 13 May 2004 21:19:56 -0000 1.9
--- b/glitz_glx_surface.c 18 May 2004 15:01:50 -0000 1.10
***************
*** 49,53 ****
static void
! _glitz_glx_surface_flush (void *abstract_surface);
static glitz_bool_t
--- 49,53 ----
static void
! _glitz_glx_surface_swap_buffers (void *abstract_surface);
static glitz_bool_t
***************
*** 115,119 ****
_glitz_glx_surface_get_texture,
_glitz_glx_surface_update_size,
! _glitz_glx_surface_flush,
_glitz_glx_surface_make_current_read
};
--- 115,119 ----
_glitz_glx_surface_get_texture,
_glitz_glx_surface_update_size,
! _glitz_glx_surface_swap_buffers,
_glitz_glx_surface_make_current_read
};
***************
*** 359,363 ****
if (glXGetCurrentDrawable () == surface->drawable) {
surface->drawable = None;
! glitz_glx_context_make_current (surface);
}
--- 359,363 ----
if (glXGetCurrentDrawable () == surface->drawable) {
surface->drawable = None;
! glitz_glx_context_make_current (surface, 0);
}
***************
*** 367,371 ****
}
-
static void
_glitz_glx_surface_update_size (void *abstract_surface)
--- 367,370 ----
***************
*** 373,385 ****
glitz_glx_surface_t *surface = (glitz_glx_surface_t *) abstract_surface;
! if ((! surface->pbuffer) && surface->drawable) {
_glitz_glx_surface_update_size_for_window
(surface->screen_info->display_info->display, surface->drawable,
! &surface->base.width, &surface->base.height);
}
}
static void
! _glitz_glx_surface_flush (void *abstract_surface)
{
glitz_glx_surface_t *surface = (glitz_glx_surface_t *) abstract_surface;
--- 372,406 ----
glitz_glx_surface_t *surface = (glitz_glx_surface_t *) abstract_surface;
! if ((!surface->pbuffer) && surface->drawable) {
! int width, height;
!
_glitz_glx_surface_update_size_for_window
(surface->screen_info->display_info->display, surface->drawable,
! &width, &height);
!
! if (width != surface->base.width || height != surface->base.height) {
! glitz_texture_t texture;
!
! glitz_texture_init (&texture,
! width, height,
! glitz_get_gl_format_from_bpp
! (surface->base.format->bpp),
! surface->screen_info->texture_mask);
!
! if (texture.width != surface->base.texture.width ||
! texture.height != surface->base.texture.height ||
! texture.target != surface->base.texture.target) {
! texture.name = surface->base.texture.name;
! surface->base.texture = texture;
! }
!
! surface->base.width = width;
! surface->base.height = height;
! }
}
}
static void
! _glitz_glx_surface_swap_buffers (void *abstract_surface)
{
glitz_glx_surface_t *surface = (glitz_glx_surface_t *) abstract_surface;
Index: glitz_glxext.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glxext.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** a/glitz_glxext.h 13 May 2004 00:47:32 -0000 1.4
--- b/glitz_glxext.h 18 May 2004 15:01:50 -0000 1.5
***************
*** 95,99 ****
#endif
! typedef void *(* glitz_glx_get_proc_address_arb_t)(glitz_gl_ubyte_t *);
typedef GLXFBConfig *(* glitz_glx_get_fbconfigs_t)
(Display *display, int screen, int *n_elements);
--- 95,100 ----
#endif
! typedef glitz_function_pointer_t (* glitz_glx_get_proc_address_arb_t)
! (const glitz_gl_ubyte_t *);
typedef GLXFBConfig *(* glitz_glx_get_fbconfigs_t)
(Display *display, int screen, int *n_elements);
Index: glitz_glxint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_glxint.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** a/glitz_glxint.h 13 May 2004 00:47:32 -0000 1.7
--- b/glitz_glxint.h 18 May 2004 15:01:50 -0000 1.8
***************
*** 141,145 ****
int screen);
! extern void *__internal_linkage
glitz_glx_get_proc_address (glitz_glx_thread_info_t *info, const char *name);
--- 141,145 ----
int screen);
! extern glitz_function_pointer_t __internal_linkage
glitz_glx_get_proc_address (glitz_glx_thread_info_t *info, const char *name);
***************
*** 160,164 ****
extern void __internal_linkage
! glitz_glx_context_make_current (glitz_glx_surface_t *surface);
extern glitz_glx_surface_t *__internal_linkage
--- 160,165 ----
extern void __internal_linkage
! glitz_glx_context_make_current (glitz_glx_surface_t *surface,
! glitz_bool_t flush);
extern glitz_glx_surface_t *__internal_linkage
Index: glitz_matrix.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_matrix.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** a/glitz_matrix.c 10 May 2004 15:14:39 -0000 1.3
--- b/glitz_matrix.c 18 May 2004 15:01:50 -0000 1.4
***************
*** 34,96 ****
#include <math.h>
- static void
- _glitz_matrix_transform_distance (glitz_matrix_t *matrix,
- double *dx,
- double *dy)
- {
- double new_x, new_y;
-
- new_x = (matrix->m[0][0] * *dx + matrix->m[1][0] * *dy);
- new_y = (matrix->m[0][1] * *dx + matrix->m[1][1] * *dy);
-
- *dx = new_x;
- *dy = new_y;
- }
-
void
glitz_matrix_transform_point (glitz_matrix_t *matrix,
! glitz_point_t *point)
{
! _glitz_matrix_transform_distance (matrix, &point->x, &point->y);
!
! point->x += matrix->m[2][0];
! point->y += matrix->m[2][1];
}
void
glitz_matrix_transform_bounding_box (glitz_matrix_t *matrix,
! glitz_bounding_box_t *box)
{
! glitz_point_t point;
! point.x = box->x1;
! point.y = box->y1;
! _glitz_matrix_transform_distance (matrix, &point.x, &point.y);
! box->x1 = floor (point.x);
! box->y1 = floor (point.y);
! point.x = box->x2;
! point.y = box->y2;
! _glitz_matrix_transform_distance (matrix, &point.x, &point.y);
! box->x2 = ceil (point.x);
! box->y2 = ceil (point.y);
!
! box->x1 += (int) floor (matrix->m[2][0]);
! box->y1 += (int) floor (matrix->m[2][1]);
! box->x2 += (int) ceil (matrix->m[2][0]);
! box->y2 += (int) ceil (matrix->m[2][1]);
! }
! void
! glitz_matrix_transform_bounding_box_double (glitz_matrix_t *matrix,
! glitz_bounding_box_double_t *box)
! {
! _glitz_matrix_transform_distance (matrix, &box->x1, &box->y1);
! _glitz_matrix_transform_distance (matrix, &box->x2, &box->y2);
! box->x1 += matrix->m[2][0];
! box->y1 += matrix->m[2][1];
! box->x2 += matrix->m[2][0];
! box->y2 += matrix->m[2][1];
}
--- 34,95 ----
#include <math.h>
void
glitz_matrix_transform_point (glitz_matrix_t *matrix,
! double *x, double *y)
{
! double _x, _y;
!
! _x = matrix->m[0][0] * *x + matrix->m[1][0] * *y + matrix->m[2][0];
! _y = matrix->m[0][1] * *x + matrix->m[1][1] * *y + matrix->m[2][1];
!
! *x = _x;
! *y = _y;
}
void
glitz_matrix_transform_bounding_box (glitz_matrix_t *matrix,
! double *x1, double *y1,
! double *x2, double *y2)
{
! int i;
! double quad_x[4], quad_y[4];
! double min_x, max_x;
! double min_y, max_y;
! quad_x[0] = *x1;
! quad_y[0] = *y1;
! glitz_matrix_transform_point (matrix, &quad_x[0], &quad_y[0]);
! quad_x[1] = *x2;
! quad_y[1] = *y1;
! glitz_matrix_transform_point (matrix, &quad_x[1], &quad_y[1]);
! quad_x[2] = *x2;
! quad_y[2] = *y2;
! glitz_matrix_transform_point (matrix, &quad_x[2], &quad_y[2]);
!
! quad_x[3] = *x1;
! quad_y[3] = *y2;
! glitz_matrix_transform_point (matrix, &quad_x[3], &quad_y[3]);
!
! min_x = max_x = quad_x[0];
! min_y = max_y = quad_y[0];
!
! for (i = 1; i < 4; i++) {
! if (quad_x[i] < min_x)
! min_x = quad_x[i];
! if (quad_x[i] > max_x)
! max_x = quad_x[i];
!
! if (quad_y[i] < min_y)
! min_y = quad_y[i];
! if (quad_y[i] > max_y)
! max_y = quad_y[i];
! }
! *x1 = min_x;
! *y2 = min_y;
! *x2 = max_x;
! *y2 = max_y;
}
***************
*** 156,160 ****
_glitz_matrix_compute_determinant (matrix, &det);
!
if (det == 0)
return GLITZ_STATUS_INVALID_MATRIX;
--- 155,159 ----
_glitz_matrix_compute_determinant (matrix, &det);
!
if (det == 0)
return GLITZ_STATUS_INVALID_MATRIX;
Index: glitz_programmatic.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_programmatic.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** a/glitz_programmatic.c 13 May 2004 00:47:32 -0000 1.5
--- b/glitz_programmatic.c 18 May 2004 15:01:50 -0000 1.6
***************
*** 93,97 ****
static void
! _glitz_programmatic_surface_flush (void *abstract_surface) {}
static glitz_bool_t
--- 93,97 ----
static void
! _glitz_programmatic_surface_swap_buffers (void *abstract_surface) {}
static glitz_bool_t
***************
*** 109,113 ****
_glitz_programmatic_surface_get_texture,
_glitz_programmatic_surface_update_size,
! _glitz_programmatic_surface_flush,
_glitz_programmatic_surface_make_current_read
};
--- 109,113 ----
_glitz_programmatic_surface_get_texture,
_glitz_programmatic_surface_update_size,
! _glitz_programmatic_surface_swap_buffers,
_glitz_programmatic_surface_make_current_read
};
Index: glitz_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_surface.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** a/glitz_surface.c 13 May 2004 00:47:32 -0000 1.9
--- b/glitz_surface.c 18 May 2004 15:01:50 -0000 1.10
***************
*** 56,65 ****
surface->height = height;
surface->gl = gl;
! if (surface->gl)
glitz_texture_init (&surface->texture,
width, height,
glitz_get_gl_format_from_bpp (format->bpp),
texture_mask);
}
--- 56,70 ----
surface->height = height;
surface->gl = gl;
+ surface->draw_buffer = surface->read_buffer = GLITZ_GL_FRONT;
! if (surface->gl) {
! if (format->doublebuffer)
! surface->draw_buffer = surface->read_buffer = GLITZ_GL_BACK;
!
glitz_texture_init (&surface->texture,
width, height,
glitz_get_gl_format_from_bpp (format->bpp),
texture_mask);
+ }
}
***************
*** 326,331 ****
surface->convolution = malloc (sizeof (glitz_matrix_t));
if (!surface->convolution)
! return;
! }
for (row = 0; row < 3; row++)
--- 331,336 ----
surface->convolution = malloc (sizeof (glitz_matrix_t));
if (!surface->convolution)
! return;
! }
for (row = 0; row < 3; row++)
***************
*** 423,466 ****
slim_hidden_def(glitz_surface_update_size);
void
! glitz_surface_flush (glitz_surface_t *surface,
! int x,
! int y,
! unsigned int width,
! unsigned int height)
{
! if (SURFACE_PROGRAMMATIC (surface))
! return;
! if (surface->format->doublebuffer &&
! x <= 0 && y <= 0 &&
! (x + (int) width) >= surface->width &&
! (y + (int) height) >= surface->height) {
! surface->backend->flush (surface);
! } else if (width > 0 && height > 0) {
! if (x < 0) x = 0;
! if (y < 0) y = 0;
! if (glitz_surface_push_current (surface,
! GLITZ_CN_SURFACE_DRAWABLE_CURRENT)) {
! if (surface->format->doublebuffer) {
! surface->gl->read_buffer (GLITZ_GL_BACK);
! surface->gl->draw_buffer (GLITZ_GL_FRONT);
! surface->gl->disable (GLITZ_GL_SCISSOR_TEST);
! surface->gl->disable (GLITZ_GL_DITHER);
! glitz_set_operator (surface->gl, GLITZ_OPERATOR_SRC);
!
! glitz_set_raster_pos (surface->gl, x, surface->height - (y + height));
! surface->gl->copy_pixels (x, surface->height - (y + height),
! width, height, GLITZ_GL_COLOR);
!
! surface->gl->draw_buffer (GLITZ_GL_BACK);
! }
! surface->gl->flush ();
! }
! glitz_surface_pop_current (surface);
}
}
slim_hidden_def(glitz_surface_flush);
glitz_bool_t
glitz_surface_make_current_read (glitz_surface_t *surface)
--- 428,493 ----
slim_hidden_def(glitz_surface_update_size);
+ static glitz_gl_enum_t
+ _gl_buffer (glitz_buffer_t buffer)
+ {
+ switch (buffer) {
+ case GLITZ_BUFFER_FRONT:
+ return GLITZ_GL_FRONT;
+ case GLITZ_BUFFER_BACK:
+ return GLITZ_GL_BACK;
+ default:
+ return GLITZ_GL_BACK;
+ }
+ }
+
void
! glitz_surface_set_read_buffer (glitz_surface_t *surface,
! glitz_buffer_t buffer)
{
! glitz_gl_enum_t mode;
! if (SURFACE_PROGRAMMATIC (surface) || (!surface->format->doublebuffer))
! return;
!
! mode = _gl_buffer (buffer);
! if (mode != surface->read_buffer) {
! surface->read_buffer = mode;
! glitz_surface_dirty (surface, NULL);
}
}
+ slim_hidden_def(glitz_surface_set_read_buffer);
+
+ void
+ glitz_surface_set_draw_buffer (glitz_surface_t *surface,
+ glitz_buffer_t buffer)
+ {
+ if (SURFACE_PROGRAMMATIC (surface) || (!surface->format->doublebuffer))
+ return;
+
+ surface->draw_buffer = _gl_buffer (buffer);
+ }
+ slim_hidden_def(glitz_surface_set_draw_buffer);
+
+ void
+ glitz_surface_flush (glitz_surface_t *surface)
+ {
+ if (glitz_surface_try_push_current (surface,
+ GLITZ_CN_SURFACE_DRAWABLE_CURRENT))
+ surface->gl->flush ();
+
+ glitz_surface_pop_current (surface);
+ }
slim_hidden_def(glitz_surface_flush);
+ void
+ glitz_surface_swap_buffers (glitz_surface_t *surface)
+ {
+ if (SURFACE_PROGRAMMATIC (surface) || (!surface->format->doublebuffer))
+ return;
+
+ surface->backend->swap_buffers (surface);
+ }
+ slim_hidden_def(glitz_surface_swap_buffers);
+
glitz_bool_t
glitz_surface_make_current_read (glitz_surface_t *surface)
***************
*** 472,476 ****
glitz_surface_dirty (glitz_surface_t *surface,
glitz_bounding_box_t *box)
! {
if (!box) {
surface->dirty_box.x1 = surface->dirty_box.y1 = 0;
--- 499,506 ----
glitz_surface_dirty (glitz_surface_t *surface,
glitz_bounding_box_t *box)
! {
! if (surface->draw_buffer != surface->read_buffer)
! return;
!
if (!box) {
surface->dirty_box.x1 = surface->dirty_box.y1 = 0;
***************
*** 487,492 ****
surface->hint_mask |= GLITZ_INT_HINT_DIRTY_MASK;
-
- surface->gl->flush ();
}
--- 517,520 ----
***************
*** 529,532 ****
--- 557,563 ----
gl->shade_model (GLITZ_GL_FLAT);
gl->color_mask (GLITZ_GL_TRUE, GLITZ_GL_TRUE, GLITZ_GL_TRUE, GLITZ_GL_TRUE);
+
+ if (surface->format->doublebuffer)
+ gl->draw_buffer (surface->draw_buffer);
if (surface->clip_mask)
***************
*** 575,578 ****
--- 606,617 ----
rowstride = (rowstride + 3) & -4;
pixel_buf = malloc (surface->height * rowstride);
+ if (!pixel_buf) {
+ glitz_surface_status_add (surface, GLITZ_STATUS_NO_MEMORY_MASK);
+ glitz_surface_pop_current (surface);
+ return;
+ }
+ if (surface->format->doublebuffer)
+ surface->gl->read_buffer (surface->read_buffer);
+
surface->gl->read_pixels (0, 0, surface->width, surface->height,
format, type, pixel_buf);
***************
*** 596,599 ****
--- 635,643 ----
rowstride = (rowstride + 3) & -4;
pixel_buf = malloc (texture->height * rowstride);
+ if (!pixel_buf) {
+ glitz_surface_status_add (surface, GLITZ_STATUS_NO_MEMORY_MASK);
+ glitz_surface_pop_current (surface);
+ return;
+ }
surface->gl->pixel_store_i (GLITZ_GL_UNPACK_ROW_LENGTH, 0);
***************
*** 674,677 ****
--- 718,726 ----
dst_rowstride = (width * 2 + 3) & -4;
pixel_buf = malloc (dst_rowstride * height);
+ if (!pixel_buf) {
+ glitz_surface_status_add (surface, GLITZ_STATUS_NO_MEMORY_MASK);
+ glitz_surface_pop_current (surface);
+ return;
+ }
/* Pad and flip A8 image data. */
***************
*** 689,692 ****
--- 738,746 ----
rowstride = (width * bytes_per_pixel + 3) & -4;
pixel_buf = malloc (rowstride * height);
+ if (!pixel_buf) {
+ glitz_surface_status_add (surface, GLITZ_STATUS_NO_MEMORY_MASK);
+ glitz_surface_pop_current (surface);
+ return;
+ }
/* Flip image data. */
***************
*** 733,737 ****
format, type,
pixel_buf);
- surface->gl->flush ();
glitz_texture_unbind (surface->gl, &surface->texture);
--- 787,790 ----
Index: glitz_texture.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_texture.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** a/glitz_texture.c 13 May 2004 00:47:32 -0000 1.5
--- b/glitz_texture.c 18 May 2004 15:01:50 -0000 1.6
***************
*** 236,239 ****
--- 236,242 ----
height = (box->x2 < (int) texture->height)?
box->y2 - y_dst: (int) texture->height - y_dst;
+
+ if (surface->format->doublebuffer)
+ surface->gl->read_buffer (surface->read_buffer);
surface->gl->copy_tex_sub_image_2d (texture->target, 0,
***************
*** 241,246 ****
x_src, y_src,
width, height);
-
- surface->gl->flush ();
glitz_texture_unbind (surface->gl, texture);
--- 244,247 ----
Index: glitzint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitzint.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** a/glitzint.h 13 May 2004 00:47:32 -0000 1.12
--- b/glitzint.h 18 May 2004 15:01:50 -0000 1.13
***************
*** 271,275 ****
void
! (*flush) (void *surface);
glitz_bool_t
--- 271,275 ----
void
! (*swap_buffers) (void *surface);
glitz_bool_t
***************
*** 322,325 ****
--- 322,327 ----
unsigned long hint_mask;
unsigned short polyopacity;
+ glitz_gl_enum_t draw_buffer;
+ glitz_gl_enum_t read_buffer;
};
***************
*** 371,379 ****
extern void __internal_linkage
glitz_matrix_transform_point (glitz_matrix_t *matrix,
! glitz_point_t *point);
extern void __internal_linkage
glitz_matrix_transform_bounding_box (glitz_matrix_t *matrix,
! glitz_bounding_box_t *box);
extern void __internal_linkage
--- 373,382 ----
extern void __internal_linkage
glitz_matrix_transform_point (glitz_matrix_t *matrix,
! double *x, double *y);
extern void __internal_linkage
glitz_matrix_transform_bounding_box (glitz_matrix_t *matrix,
! double *x1, double *y1,
! double *x2, double *y2);
extern void __internal_linkage
***************
*** 741,744 ****
--- 744,749 ----
#define DOUBLE_TO_FIXED(f) ((int) ((f) * 65536))
+ typedef void (*glitz_function_pointer_t) (void);
+
/* Avoid unnecessary PLT entries. */
***************
*** 757,761 ****
--- 762,769 ----
slim_hidden_proto(glitz_surface_get_height)
slim_hidden_proto(glitz_surface_update_size)
+ slim_hidden_proto(glitz_surface_set_read_buffer)
+ slim_hidden_proto(glitz_surface_set_draw_buffer)
slim_hidden_proto(glitz_surface_flush)
+ slim_hidden_proto(glitz_surface_swap_buffers)
slim_hidden_proto(glitz_surface_get_status)
slim_hidden_proto(glitz_surface_get_gl_texture)
More information about the cairo-commit
mailing list