[cairo-commit] libglc/src glc_format.c,NONE,1.1 Makefile.am,1.6,1.7 glc.c,1.12,1.13 glc.h,1.7,1.8 glc_agl_context.c,1.1,1.2 glc_agl_format.c,1.2,1.3 glc_agl_info.c,1.1,1.2 glc_agl_pbuffer.c,1.1,1.2 glc_agl_surface.c,1.2,1.3 glc_glx_context.c,1.6,1.7 glc_glx_extension.c,1.4,1.5 glc_glx_format.c,1.8,1.9 glc_glx_info.c,1.6,1.7 glc_glx_surface.c,1.9,1.10 glc_rect.c,1.6,1.7 glc_surface.c,1.9,1.10 glc_texture.c,1.5,1.6 glc_trap.c,1.7,1.8 glc_tri.c,1.7,1.8 glcint.h,1.11,1.12
David Reveman
commit at pdx.freedesktop.org
Mon Aug 15 11:12:59 PDT 2005
Committed by: davidr
Update of /cvs/cairo/libglc/src
In directory pdx:/tmp/cvs-serv27430/src
Modified Files:
Makefile.am glc.c glc.h glc_agl_context.c glc_agl_format.c
glc_agl_info.c glc_agl_pbuffer.c glc_agl_surface.c
glc_glx_context.c glc_glx_extension.c glc_glx_format.c
glc_glx_info.c glc_glx_surface.c glc_rect.c glc_surface.c
glc_texture.c glc_trap.c glc_tri.c glcint.h
Added Files:
glc_format.c
Log Message:
Merged new format handling code
--- NEW FILE: glc_format.c ---
(This appears to be a binary file; contents omitted.)
Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/libglc/src/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** Makefile.am 3 Feb 2004 15:12:11 -0000 1.6
--- Makefile.am 5 Feb 2004 22:22:28 -0000 1.7
***************
*** 38,41 ****
--- 38,42 ----
glc_matrix.c \
glc_util.c \
+ glc_format.c \
$(libglc_glx_sources) \
$(libglc_agl_sources) \
Index: glc.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** glc.c 3 Feb 2004 15:12:11 -0000 1.12
--- glc.c 5 Feb 2004 22:22:28 -0000 1.13
***************
*** 155,160 ****
texture = glc_surface_get_texture (src);
! if (!glc_surface_push_current
! (dst, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (dst);
return;
--- 155,159 ----
texture = glc_surface_get_texture (src);
! if (!glc_surface_push_current (dst, GLC_CN_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (dst);
return;
***************
*** 175,182 ****
width, height);
! glColorMask (src->red? 1: 0,
! src->green? 1: 0,
! src->blue? 1: 0,
! src->alpha? 1: 0);
glc_set_operator (op);
--- 174,181 ----
width, height);
! glColorMask (dst->red? 1: 0,
! dst->green? 1: 0,
! dst->blue? 1: 0,
! dst->alpha? 1: 0);
glc_set_operator (op);
Index: glc.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** glc.h 3 Feb 2004 15:12:11 -0000 1.7
--- glc.h 5 Feb 2004 22:22:28 -0000 1.8
***************
*** 130,133 ****
--- 130,138 ----
} glc_operator_t;
+ #define GLC_FEATURE_OFFSCREEN_MASK (1L << 0)
+ #define GLC_FEATURE_TEXTURE_RECTANGLE_MASK (1L << 1)
+ #define GLC_FEATURE_MULTISAMPLE_MASK (1L << 2)
+ #define GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK (1L << 3)
+
typedef enum {
GLC_STANDARD_ARGB32,
***************
*** 136,145 ****
GLC_STANDARD_A1
} glc_format_name_t;
-
- #define GLC_FEATURE_OFFSCREEN_MASK (1L << 0)
- #define GLC_FEATURE_TEXTURE_RECTANGLE_MASK (1L << 1)
- #define GLC_FEATURE_MULTISAMPLE_MASK (1L << 2)
- #define GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK (1L << 3)
/* glc_status.c */
--- 141,188 ----
GLC_STANDARD_A1
} glc_format_name_t;
+ #define GLC_FORMAT_ID_MASK (1 << 0)
+ #define GLC_FORMAT_RED_MASK (1 << 1)
+ #define GLC_FORMAT_GREEN_MASK (1 << 2)
+ #define GLC_FORMAT_BLUE_MASK (1 << 3)
+ #define GLC_FORMAT_ALPHA_MASK (1 << 4)
+ #define GLC_FORMAT_DEPTH_MASK (1 << 5)
+ #define GLC_FORMAT_DOUBLEBUFFER_MASK (1 << 6)
+ #define GLC_FORMAT_ONSCREEN_MASK (1 << 7)
+ #define GLC_FORMAT_OFFSCREEN_MASK (1 << 8)
+ #define GLC_FORMAT_MULTISAMPLE_MASK (1 << 9)
+ #define GLC_FORMAT_MULTISAMPLE_SAMPLES_MASK (1 << 10)
+
+ typedef unsigned long int glc_format_id_t;
+
+ typedef struct _glc_drawable_type_t {
+ glc_bool_t onscreen;
+ glc_bool_t offscreen;
+ } glc_drawable_type_t;
+
+ typedef struct _glc_multisample_format_t {
+ glc_bool_t supported;
+ unsigned short samples;
+ } glc_multisample_format_t;
+
+ typedef struct _glc_format_t {
+ glc_format_id_t id;
+ unsigned short red;
+ unsigned short green;
+ unsigned short blue;
+ unsigned short alpha;
+ unsigned short depth;
+ glc_bool_t doublebuffer;
+ glc_drawable_type_t drawable;
+ glc_multisample_format_t multisample;
+ } glc_format_t;
+
+ #define GLC_FORMAT_OPTION_DOUBLEBUFFER_MASK (1 << 0)
+ #define GLC_FORMAT_OPTION_SINGLEBUFFER_MASK (1 << 1)
+ #define GLC_FORMAT_OPTION_ONSCREEN_MASK (1 << 2)
+ #define GLC_FORMAT_OPTION_OFFSCREEN_MASK (1 << 3)
+ #define GLC_FORMAT_OPTION_MULTISAMPLE_MASK (1 << 4)
+ #define GLC_FORMAT_OPTION_NO_MULTISAMPLE_MASK (1 << 5)
+
/* glc_status.c */
***************
*** 195,199 ****
void
! glc_surface_swap_buffers (glc_surface_t *surface);
int
--- 238,242 ----
void
! glc_surface_show (glc_surface_t *surface);
int
***************
*** 343,382 ****
/* glc_glx_format.c */
! #define GLC_GLX_FORMAT_ID_MASK (1 << 0)
! #define GLC_GLX_FORMAT_ALPHA_MASK (1 << 1)
! #define GLC_GLX_FORMAT_RED_MASK (1 << 2)
! #define GLC_GLX_FORMAT_GREEN_MASK (1 << 3)
! #define GLC_GLX_FORMAT_BLUE_MASK (1 << 4)
! #define GLC_GLX_FORMAT_DOUBLEBUFFER_MASK (1 << 5)
! #define GLC_GLX_FORMAT_VISUALID_MASK (1 << 6)
!
! typedef unsigned int glc_glx_format_id_t;
!
! typedef struct _glc_glx_format_t {
! glc_glx_format_id_t id;
! unsigned short red;
! unsigned short green;
! unsigned short blue;
! unsigned short alpha;
! glc_bool_t doublebuffer;
! VisualID visualid;
! } glc_glx_format_t;
!
! glc_glx_format_t *
glc_glx_find_format (Display *display,
int screen,
unsigned long mask,
! const glc_glx_format_t *templ,
int count);
!
! #define GLC_GLX_OPTION_DOUBLEBUFFER_MASK (1 << 0)
!
! glc_glx_format_t *
! glc_glx_find_visual_format (Display *display,
! int screen,
! unsigned long options,
! Visual *visual);
!
! glc_glx_format_t *
glc_glx_find_standard_format (Display *display,
int screen,
--- 386,397 ----
/* glc_glx_format.c */
! glc_format_t *
glc_glx_find_format (Display *display,
int screen,
unsigned long mask,
! const glc_format_t *templ,
int count);
!
! glc_format_t *
glc_glx_find_standard_format (Display *display,
int screen,
***************
*** 385,390 ****
XVisualInfo *
! glc_glx_format_get_visual_info (Display *display,
! glc_glx_format_t *format);
--- 400,406 ----
XVisualInfo *
! glc_glx_get_visual_info_from_format (Display *display,
! int screen,
! glc_format_t *format);
***************
*** 392,406 ****
glc_surface_t *
! glc_glx_surface_create_offscreen (Display *display,
! int screen,
! glc_glx_format_t *format,
! int width,
! int height);
glc_surface_t *
glc_glx_surface_create_for_window (Display *display,
int screen,
! Window window,
! glc_glx_format_t *format);
#endif /* LIBGLC_HAS_GLX_BACKEND */
--- 408,422 ----
glc_surface_t *
! glc_glx_surface_create (Display *display,
! int screen,
! glc_format_t *format,
! int width,
! int height);
glc_surface_t *
glc_glx_surface_create_for_window (Display *display,
int screen,
! glc_format_t *format,
! Window window);
#endif /* LIBGLC_HAS_GLX_BACKEND */
***************
*** 422,465 ****
/* glc_agl_format.c */
! #define GLC_AGL_FORMAT_ID_MASK (1 << 0)
! #define GLC_AGL_FORMAT_ALPHA_MASK (1 << 2)
! #define GLC_AGL_FORMAT_RED_MASK (1 << 3)
! #define GLC_AGL_FORMAT_GREEN_MASK (1 << 4)
! #define GLC_AGL_FORMAT_BLUE_MASK (1 << 5)
! #define GLC_AGL_FORMAT_DOUBLEBUFFER_MASK (1 << 6)
!
! typedef unsigned int glc_agl_format_id_t;
!
! typedef struct _glc_agl_format_t {
! glc_agl_format_id_t id;
! unsigned short red;
! unsigned short green;
! unsigned short blue;
! unsigned short alpha;
! glc_bool_t doublebuffer;
! } glc_agl_format_t;
!
! glc_agl_format_t *
glc_agl_find_format (unsigned long mask,
! const glc_agl_format_t *templ,
int count);
!
! #define GLC_AGL_OPTION_DOUBLEBUFFER_MASK (1 << 0)
!
! glc_agl_format_t *
glc_agl_find_standard_format (unsigned long options,
glc_format_name_t format_name);
!
/* glc_agl_surface.c */
glc_surface_t *
! glc_agl_surface_create_offscreen (glc_agl_format_t *format,
! int width,
! int height);
glc_surface_t *
! glc_agl_surface_create_for_window (WindowRef window,
! glc_agl_format_t *format);
#endif /* LIBGLC_HAS_AGL_BACKEND */
--- 438,461 ----
/* glc_agl_format.c */
! glc_format_t *
glc_agl_find_format (unsigned long mask,
! const glc_format_t *templ,
int count);
!
! glc_format_t *
glc_agl_find_standard_format (unsigned long options,
glc_format_name_t format_name);
!
/* glc_agl_surface.c */
glc_surface_t *
! glc_agl_surface_create (glc_format_t *format,
! int width,
! int height);
glc_surface_t *
! glc_agl_surface_create_for_window (glc_format_t *format,
! WindowRef window);
#endif /* LIBGLC_HAS_AGL_BACKEND */
Index: glc_agl_context.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_context.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** glc_agl_context.c 3 Feb 2004 15:12:11 -0000 1.1
--- glc_agl_context.c 5 Feb 2004 22:22:28 -0000 1.2
***************
*** 32,196 ****
#include "glcint.h"
- void
- glc_agl_context_create (glc_agl_thread_info_t *thread_info,
- AGLContext *context,
- GLint *attrib)
- {
- AGLPixelFormat pixel_format =
- aglChoosePixelFormat (NULL, 0, attrib);
-
- if (!pixel_format)
- return;
-
- *context =
- aglCreateContext (pixel_format, thread_info->texture_context.context);
-
- aglDestroyPixelFormat (pixel_format);
- }
-
static void
! _glc_agl_context_add (glc_agl_thread_info_t *thread_info,
! glc_agl_context_t *context)
! {
! glc_agl_context_node_t *node;
!
! node = (glc_agl_context_node_t *) malloc (sizeof (glc_agl_context_node_t));
! node->next = thread_info->contexts;
! node->data = context;
! thread_info->contexts = node;
! }
!
! static glc_agl_context_t *
! glc_agl_context_reference (glc_agl_context_t *context)
{
! context->ref_count++;
! return context;
}
- #define GLC_AGL_CONTEXT(data) ((glc_agl_context_t *) data)
-
glc_agl_context_t *
glc_agl_context_get (glc_agl_thread_info_t *thread_info,
! glc_agl_format_t *format)
{
- glc_agl_context_node_t *node = thread_info->contexts;
glc_agl_context_t *context;
! int i = 0, without_multisample;
! GLint attr[18];
!
! for (; node; node = node->next)
! if (GLC_AGL_CONTEXT (node->data)->formatid == format->id)
! return glc_agl_context_reference (GLC_AGL_CONTEXT (node->data));
! context = (glc_agl_context_t *) malloc (sizeof (glc_agl_context_t));
! context->thread_info = thread_info;
! context->formatid = format->id;
! context->ref_count = 1;
! context->context = NULL;
! attr[i++] = AGL_RGBA;
! if (format->red) {
! attr[i++] = AGL_RED_SIZE;
! attr[i++] = format->red;
! }
! if (format->green) {
! attr[i++] = AGL_GREEN_SIZE;
! attr[i++] = format->green;
! }
! if (format->blue) {
! attr[i++] = AGL_BLUE_SIZE;
! attr[i++] = format->blue;
! }
! if (format->alpha) {
! attr[i++] = AGL_ALPHA_SIZE;
! attr[i++] = format->alpha;
! }
! if (format->doublebuffer)
! attr[i++] = AGL_DOUBLEBUFFER;
! attr[i++] = AGL_NO_RECOVERY;
! attr[i] = AGL_NONE;
! without_multisample = i;
! if (thread_info->feature_mask & GLC_FEATURE_MULTISAMPLE_MASK) {
! attr[i++] = AGL_SAMPLE_BUFFERS_ARB;
! attr[i++] = 1;
! attr[i++] = AGL_SAMPLES_ARB;
! attr[i] = GLC_AGL_MULTISAMPLE_MAX_SAMPLES;
! attr[i + 1] = AGL_NONE;
! for (; (!context->context) && attr[i] >= 2; attr[i] -= 2)
! glc_agl_context_create (thread_info, &context->context, attr);
! }
! if (!context->context) {
! attr[without_multisample] = AGL_NONE;
! glc_agl_context_create (thread_info, &context->context, attr);
! }
- _glc_agl_context_add (thread_info, context);
-
return context;
}
- glc_agl_context_t *
- glc_agl_context_get_default (glc_agl_thread_info_t *thread_info)
- {
- if (thread_info->pbuffer_context.context)
- return glc_agl_context_reference (&thread_info->pbuffer_context);
- else
- return glc_agl_context_reference (&thread_info->texture_context);
- }
-
- void
- glc_agl_context_release (glc_agl_context_t *context)
- {
- glc_agl_thread_info_t *thread_info;
- glc_agl_context_node_t *node, *previous_node;
-
- context->ref_count--;
- if (context->ref_count)
- return;
-
- thread_info = context->thread_info;
- node = thread_info->contexts;
- previous_node = NULL;
-
- for (; node; node = node->next) {
- if (GLC_AGL_CONTEXT (node->data) == context)
- break;
- previous_node = node;
- }
-
- if (previous_node)
- previous_node->next = node->next;
- else
- thread_info->contexts = node->next;
-
- /* Make sure context is not current */
- if (context->context == aglGetCurrentContext ())
- glc_agl_context_set_default (thread_info);
-
- aglDestroyContext (context->context);
-
- free (context);
- free (node);
- }
-
static void
glc_agl_context_set_surface_anti_aliasing (glc_agl_surface_t *surface)
{
- glc_bool_t multi_sample = 0;
-
surface->base.anti_aliasing = 0;
! if (surface->pbuffer) {
! if (surface->thread_info->feature_mask &
! GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK)
! multi_sample = 1;
! } else if (surface->thread_info->feature_mask & GLC_FEATURE_MULTISAMPLE_MASK)
! multi_sample = 1;
!
! if (multi_sample) {
if (surface->base.polyedge == GLC_POLYEDGE_SMOOTH) {
glEnable (GL_MULTISAMPLE_ARB);
--- 32,85 ----
#include "glcint.h"
static void
! _glc_agl_context_create (glc_agl_thread_info_t *thread_info,
! AGLPixelFormat pixel_format,
! glc_agl_context_t *context)
{
! context->context =
! aglCreateContext (pixel_format, thread_info->root_context.context);
! context->pixel_format = pixel_format;
}
glc_agl_context_t *
glc_agl_context_get (glc_agl_thread_info_t *thread_info,
! glc_format_t *format,
! glc_bool_t offscreen)
{
glc_agl_context_t *context;
! glc_agl_context_t **contexts = thread_info->contexts;
! int index, n_contexts = thread_info->n_contexts;
! if (thread_info->format_ids[format->id] == (AGLPixelFormat) 0)
! return &thread_info->root_context;
! for (; n_contexts; n_contexts--, contexts++)
! if ((*contexts)->pixel_format == thread_info->format_ids[format->id] &&
! (*contexts)->offscreen == offscreen)
! return *contexts;
! index = thread_info->n_contexts++;
! thread_info->contexts =
! realloc (thread_info->contexts,
! sizeof (glc_agl_context_t *) * thread_info->n_contexts);
! context = malloc (sizeof (glc_agl_context_t));
! thread_info->contexts[index] = context;
! _glc_agl_context_create (thread_info,
! thread_info->format_ids[format->id],
! context);
! context->offscreen = offscreen;
return context;
}
static void
glc_agl_context_set_surface_anti_aliasing (glc_agl_surface_t *surface)
{
surface->base.anti_aliasing = 0;
! if (surface->format->multisample.supported) {
if (surface->base.polyedge == GLC_POLYEDGE_SMOOTH) {
glEnable (GL_MULTISAMPLE_ARB);
***************
*** 205,214 ****
void
! glc_agl_context_set_default (glc_agl_thread_info_t *thread_info)
{
! if (thread_info->pbuffer_context.context)
! aglSetCurrentContext (thread_info->pbuffer_context.context);
else
! aglSetCurrentContext (thread_info->texture_context.context);
}
--- 94,117 ----
void
! glc_agl_context_make_current (glc_agl_surface_t *surface)
{
! AGLContext context;
! AGLDrawable drawable = (AGLDrawable) 0;
! AGLPbuffer pbuffer = (AGLPbuffer) 0;
!
! if ((!surface->drawable) && (!surface->pbuffer)) {
! context = surface->thread_info->root_context.context;
! } else {
! context = surface->context->context;
! pbuffer = surface->pbuffer;
! drawable = surface->drawable;
! }
!
! if (pbuffer)
! aglSetPBuffer (context, pbuffer, 0, 0, 0);
else
! aglSetDrawable (context, drawable);
!
! aglSetCurrentContext (context);
}
***************
*** 217,249 ****
glc_constraint_t constraint)
{
- AGLContext context = aglGetCurrentContext ();
-
switch (constraint) {
! case GLC_CONSTRAINT_NONE:
break;
! case GLC_CONSTRAINT_ANY_CONTEXT_CURRENT:
! if (context == NULL)
! glc_agl_context_set_default (surface->thread_info);
break;
! case GLC_CONSTRAINT_SURFACE_CONTEXT_CURRENT:
! if (context != surface->context->context)
! aglSetCurrentContext (surface->context->context);
break;
! case GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT:
! if (context != surface->context->context)
! aglSetCurrentContext (surface->context->context);
!
! if (surface->pbuffer) {
! AGLPbuffer pbuffer;
! GLuint unused;
!
! aglGetPBuffer (context, &pbuffer, &unused, &unused, &unused);
! if (pbuffer != surface->pbuffer)
! aglSetPBuffer (surface->context->context, surface->pbuffer, 0, 0, 0);
!
! } else if (surface->drawable) {
! if (aglGetDrawable (surface->context->context) != surface->drawable)
! aglSetDrawable (surface->context->context, surface->drawable);
}
--- 120,152 ----
glc_constraint_t constraint)
{
switch (constraint) {
! case GLC_CN_NONE:
break;
! case GLC_CN_ANY_CONTEXT_CURRENT:
! if (aglGetCurrentContext () == NULL)
! glc_agl_context_make_current (surface);
break;
! case GLC_CN_SURFACE_CONTEXT_CURRENT:
! if (aglGetCurrentContext () != surface->context->context)
! glc_agl_context_make_current (surface);
break;
! case GLC_CN_SURFACE_DRAWABLE_CURRENT:
! if (aglGetCurrentContext () != surface->context->context) {
! glc_agl_context_make_current (surface);
! } else {
! if (surface->pbuffer) {
! AGLPbuffer pbuffer;
! GLuint unused;
!
! aglGetPBuffer (surface->context->context, &pbuffer,
! &unused, &unused, &unused);
! if (pbuffer != surface->pbuffer)
! glc_agl_context_make_current (surface);
!
! } else if (surface->drawable) {
! if (aglGetDrawable (surface->context->context) != surface->drawable)
! glc_agl_context_make_current (surface);
! }
}
***************
*** 258,280 ****
{
glc_agl_thread_info_t *thread_info;
! glc_agl_context_info_t *new_context_info;
! thread_info = surface->context->thread_info;
! new_context_info = (glc_agl_context_info_t *)
! calloc (1, sizeof (glc_agl_context_info_t));
! new_context_info->surface = surface;
! new_context_info->constraint = constraint;
! new_context_info->previous = thread_info->context_stack;
! thread_info->context_stack = new_context_info;
!
! glc_agl_context_update (thread_info->context_stack->surface,
! constraint);
! if (thread_info->context_stack->constraint ==
! GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)
! return thread_info->context_stack->surface;
return NULL;
}
--- 161,185 ----
{
glc_agl_thread_info_t *thread_info;
! glc_agl_context_info_t *context_info;
! int index;
! thread_info = surface->thread_info;
! index = thread_info->context_stack_size++;
! thread_info->context_stack =
! realloc (thread_info->context_stack,
! sizeof (glc_agl_context_info_t) *
! thread_info->context_stack_size);
! context_info = &thread_info->context_stack[index];
! context_info->surface = surface;
! context_info->constraint = constraint;
!
! glc_agl_context_update (context_info->surface, constraint);
+ if (context_info->constraint == GLC_CN_SURFACE_DRAWABLE_CURRENT)
+ return context_info->surface;
+
return NULL;
}
***************
*** 284,306 ****
{
glc_agl_thread_info_t *thread_info;
! glc_agl_context_info_t *old_context_info = NULL;
! thread_info = surface->context->thread_info;
!
! if (thread_info->context_stack->previous) {
! old_context_info = thread_info->context_stack;
! thread_info->context_stack = thread_info->context_stack->previous;
! }
! if (thread_info->context_stack->surface)
! glc_agl_context_update (thread_info->context_stack->surface,
! thread_info->context_stack->constraint);
! if (old_context_info)
! free (old_context_info);
! if (thread_info->context_stack->constraint ==
! GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)
! return thread_info->context_stack->surface;
return NULL;
--- 189,212 ----
{
glc_agl_thread_info_t *thread_info;
! glc_agl_context_info_t *context_info = NULL;
! int index;
! thread_info = surface->thread_info;
! thread_info->context_stack_size--;
! index = thread_info->context_stack_size - 1;
!
! thread_info->context_stack =
! realloc (thread_info->context_stack,
! sizeof (glc_agl_context_info_t) *
! thread_info->context_stack_size);
! context_info = &thread_info->context_stack[index];
! if (context_info->surface)
! glc_agl_context_update (context_info->surface, context_info->constraint);
!
! if (context_info->constraint == GLC_CN_SURFACE_DRAWABLE_CURRENT)
! return context_info->surface;
return NULL;
Index: glc_agl_format.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_format.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_agl_format.c 3 Feb 2004 16:34:51 -0000 1.2
--- glc_agl_format.c 5 Feb 2004 22:22:28 -0000 1.3
***************
*** 32,49 ****
#include "glcint.h"
static void
_glc_add_format (glc_agl_thread_info_t *thread_info,
! glc_agl_format_t *format)
{
! glc_agl_format_node_t *node;
! glc_agl_format_t *new_format = (glc_agl_format_t *)
! malloc (sizeof (glc_agl_format_t));
! memcpy (new_format, format, sizeof (glc_agl_format_t));
! node = (glc_agl_format_node_t *) malloc (sizeof (glc_agl_format_node_t));
! node->next = thread_info->formats;
! node->data = new_format;
! thread_info->formats = node;
}
--- 32,195 ----
#include "glcint.h"
+ #include <stdlib.h>
+ #include <string.h>
+
+ static const struct _glx_pixel_format_attrib {
+ GLint attrib[18];
+ } pixel_format_attrib_map[] = {
+ {
+ {
+ AGL_RGBA,
+ AGL_DOUBLEBUFFER,
+ AGL_RED_SIZE, 8,
+ AGL_GREEN_SIZE, 8,
+ AGL_BLUE_SIZE, 8,
+ AGL_ALPHA_SIZE, 0,
+ AGL_NO_RECOVERY,
+ AGL_NONE, 0, 0, 0, 0, 0, 0
+ }
+ }, {
+ {
+ AGL_RGBA,
+ AGL_DOUBLEBUFFER,
+ AGL_RED_SIZE, 8,
+ AGL_GREEN_SIZE, 8,
+ AGL_BLUE_SIZE, 8,
+ AGL_ALPHA_SIZE, 8,
+ AGL_NO_RECOVERY,
+ AGL_NONE, 0, 0, 0, 0, 0, 0
+ }
+ }, {
+ {
+ AGL_RGBA,
+ AGL_DOUBLEBUFFER,
+ AGL_RED_SIZE, 8,
+ AGL_GREEN_SIZE, 8,
+ AGL_BLUE_SIZE, 8,
+ AGL_NO_RECOVERY,
+ AGL_SAMPLE_BUFFERS_ARB, 1,
+ AGL_SAMPLES_ARB, 2,
+ AGL_NONE, 0, 0
+ }
+ }, {
+ {
+ AGL_RGBA,
+ AGL_DOUBLEBUFFER,
+ AGL_RED_SIZE, 8,
+ AGL_GREEN_SIZE, 8,
+ AGL_BLUE_SIZE, 8,
+ AGL_NO_RECOVERY,
+ AGL_SAMPLE_BUFFERS_ARB, 1,
+ AGL_SAMPLES_ARB, 4,
+ AGL_NONE, 0, 0
+ }
+ }, {
+ {
+ AGL_RGBA,
+ AGL_DOUBLEBUFFER,
+ AGL_RED_SIZE, 8,
+ AGL_GREEN_SIZE, 8,
+ AGL_BLUE_SIZE, 8,
+ AGL_ALPHA_SIZE, 0,
+ AGL_DEPTH_SIZE, 1,
+ AGL_NO_RECOVERY,
+ AGL_NONE, 0, 0, 0, 0
+ }
+ }, {
+ {
+ AGL_RGBA,
+ AGL_DOUBLEBUFFER,
+ AGL_RED_SIZE, 8,
+ AGL_GREEN_SIZE, 8,
+ AGL_BLUE_SIZE, 8,
+ AGL_ALPHA_SIZE, 8,
+ AGL_DEPTH_SIZE, 1,
+ AGL_NO_RECOVERY,
+ AGL_NONE, 0, 0, 0, 0
+ }
+ }, {
+ {
+ AGL_RGBA,
+ AGL_DOUBLEBUFFER,
+ AGL_RED_SIZE, 8,
+ AGL_GREEN_SIZE, 8,
+ AGL_BLUE_SIZE, 8,
+ AGL_DEPTH_SIZE, 1,
+ AGL_NO_RECOVERY,
+ AGL_SAMPLE_BUFFERS_ARB, 1,
+ AGL_SAMPLES_ARB, 2,
+ AGL_NONE,
+ }
+ }, {
+ {
+ AGL_RGBA,
+ AGL_DOUBLEBUFFER,
+ AGL_RED_SIZE, 8,
+ AGL_GREEN_SIZE, 8,
+ AGL_BLUE_SIZE, 8,
+ AGL_DEPTH_SIZE, 1,
+ AGL_NO_RECOVERY,
+ AGL_SAMPLE_BUFFERS_ARB, 1,
+ AGL_SAMPLES_ARB, 4,
+ AGL_NONE,
+ }
+ }, {
+ {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ }
+ }
+ };
+
+ static int
+ _glc_agl_format_compare (const void *elem1,
+ const void *elem2)
+ {
+ int i, score[2];
+ glc_format_t *format[2];
+
+ format[0] = (glc_format_t *) elem1;
+ format[1] = (glc_format_t *) elem2;
+ i = score[0] = score[1] = 0;
+
+ for (; i < 2; i++) {
+ if (format[i]->alpha)
+ score[i] += 10;
+ if (format[i]->red)
+ score[i] += 10;
+ if (format[i]->depth)
+ score[i] += 10;
+ if (format[i]->multisample.supported)
+ score[i] += (10 + format[i]->multisample.samples);
+ }
+
+ return score[1] - score[0];
+ }
+
static void
_glc_add_format (glc_agl_thread_info_t *thread_info,
! glc_format_t *format)
{
! int index = thread_info->n_formats++;
!
! thread_info->formats =
! realloc (thread_info->formats,
! sizeof (glc_format_t) * thread_info->n_formats);
!
! memcpy (&thread_info->formats[index], format, sizeof (glc_format_t));
! }
! static void
! _glc_move_out_ids (glc_agl_thread_info_t *thread_info)
! {
! int i;
! glc_format_t *formats = thread_info->formats;
! int n_formats = thread_info->n_formats;
! thread_info->format_ids = malloc (sizeof (AGLPixelFormat) * n_formats);
!
! for (i = 0; n_formats; n_formats--, formats++) {
! thread_info->format_ids[i] = (AGLPixelFormat) formats->id;
! formats->id = i++;
! }
}
***************
*** 51,250 ****
glc_agl_query_formats (glc_agl_thread_info_t *thread_info)
{
! int i;
! GLint attr[11];
! glc_agl_format_id_t id = 0;
! glc_agl_format_t format;
AGLPixelFormat pixel_format;
!
! attr[0] = AGL_RGBA;
! attr[1] = AGL_RED_SIZE;
! attr[3] = AGL_GREEN_SIZE;
! attr[5] = AGL_BLUE_SIZE;
! attr[7] = AGL_ALPHA_SIZE;
! attr[9] = AGL_NONE;
! attr[10] = AGL_NONE;
!
! for (i = 0; i <= 1; i++) {
! memset (&format, 0, sizeof (glc_agl_format_t));
! format.doublebuffer = i;
! if (format.doublebuffer)
! attr[9] = AGL_DOUBLEBUFFER;
! attr[2] = attr[4] = attr[6] = 0;
! attr[8] = 1;
! pixel_format = aglChoosePixelFormat (NULL, 0, attr);
! if (pixel_format) {
! format.red = 0;
! format.green = 0;
! format.blue = 0;
! format.alpha = 1;
! format.id = id++;
!
! _glc_add_format (thread_info, &format);
aglDestroyPixelFormat (pixel_format);
}
! attr[2] = attr[4] = attr[6] = 8;
! attr[8] = 0;
! pixel_format = aglChoosePixelFormat (NULL, 0, attr);
! if (pixel_format) {
! format.red = 0;
! format.green = 0;
! format.blue = 0;
! format.alpha = 8;
! format.id = id++;
!
! _glc_add_format (thread_info, &format);
!
! format.red = 8;
! format.green = 8;
! format.blue = 8;
! format.alpha = 0;
! format.id = id++;
! _glc_add_format (thread_info, &format);
!
! format.red = 8;
! format.green = 8;
! format.blue = 8;
! format.alpha = 8;
! format.id = id++;
!
! _glc_add_format (thread_info, &format);
!
aglDestroyPixelFormat (pixel_format);
}
! attr[8] = 8;
!
! pixel_format = aglChoosePixelFormat (NULL, 0, attr);
! if (pixel_format) {
! format.red = 0;
! format.green = 0;
! format.blue = 0;
! format.alpha = 8;
! format.id = id++;
! _glc_add_format (thread_info, &format);
! format.red = 8;
! format.green = 8;
! format.blue = 8;
! format.alpha = 0;
! format.id = id++;
! _glc_add_format (thread_info, &format);
!
! format.red = 8;
! format.green = 8;
! format.blue = 8;
! format.alpha = 8;
! format.id = id++;
_glc_add_format (thread_info, &format);
-
- aglDestroyPixelFormat (pixel_format);
}
}
- }
-
- #define GLC_AGL_FORMAT(data) ((glc_agl_format_t *) data)
-
- glc_agl_format_t *
- glc_agl_find_format (unsigned long mask,
- const glc_agl_format_t *templ,
- int count)
- {
- glc_agl_thread_info_t *thread_info =
- glc_agl_thread_info_get ();
- glc_agl_format_node_t *node = thread_info->formats;
-
- for (; node; node = node->next) {
- if (mask & GLC_AGL_FORMAT_ID_MASK)
- if (templ->id != GLC_AGL_FORMAT (node->data)->id)
- continue;
-
- if (mask & GLC_AGL_FORMAT_ALPHA_MASK)
- if (templ->alpha != GLC_AGL_FORMAT (node->data)->alpha)
- continue;
-
- if (mask & GLC_AGL_FORMAT_RED_MASK)
- if (templ->red != GLC_AGL_FORMAT (node->data)->red)
- continue;
-
- if (mask & GLC_AGL_FORMAT_GREEN_MASK)
- if (templ->green != GLC_AGL_FORMAT (node->data)->green)
- continue;
-
- if (mask & GLC_AGL_FORMAT_BLUE_MASK)
- if (templ->blue != GLC_AGL_FORMAT (node->data)->blue)
- continue;
-
- if (mask & GLC_AGL_FORMAT_DOUBLEBUFFER_MASK)
- if (templ->doublebuffer != GLC_AGL_FORMAT (node->data)->doublebuffer)
- continue;
! if (count-- == 0)
! return GLC_AGL_FORMAT (node->data);
!
}
! return NULL;
}
! static void
! _glc_add_options (unsigned long options,
! glc_agl_format_t *format,
! unsigned long *mask)
{
! if (options & GLC_AGL_OPTION_DOUBLEBUFFER_MASK) {
! format->doublebuffer = 1;
! *mask |= GLC_AGL_FORMAT_DOUBLEBUFFER_MASK;
! } else {
! format->doublebuffer = 0;
! *mask |= GLC_AGL_FORMAT_DOUBLEBUFFER_MASK;
! }
}
! glc_agl_format_t *
glc_agl_find_standard_format (unsigned long options,
glc_format_name_t format_name)
{
! glc_agl_format_t templ;
! unsigned long mask = GLC_AGL_FORMAT_ALPHA_MASK | GLC_AGL_FORMAT_RED_MASK |
! GLC_AGL_FORMAT_GREEN_MASK | GLC_AGL_FORMAT_BLUE_MASK;
! switch (format_name) {
! case GLC_STANDARD_ARGB32:
! templ.alpha = 8;
! templ.red = 8;
! templ.green = 8;
! templ.blue = 8;
! break;
! case GLC_STANDARD_RGB24:
! templ.alpha = 0;
! templ.red = 8;
! templ.green = 8;
! templ.blue = 8;
! break;
! case GLC_STANDARD_A8:
! templ.alpha = 8;
! templ.red = 0;
! templ.green = 0;
! templ.blue = 0;
! break;
! case GLC_STANDARD_A1:
! templ.alpha = 1;
! templ.red = 0;
! templ.green = 0;
! templ.blue = 0;
! break;
! }
!
! _glc_add_options (options, &templ, &mask);
!
! return glc_agl_find_format (mask, &templ, 0);
}
slim_hidden_def(glc_agl_find_standard_format);
--- 197,313 ----
glc_agl_query_formats (glc_agl_thread_info_t *thread_info)
{
! glc_format_t format;
AGLPixelFormat pixel_format;
! int i = 0;
! for (i = 0; *(pixel_format_attrib_map[i].attrib); i++) {
! GLint value;
! pixel_format = aglChoosePixelFormat (NULL, 0,
! pixel_format_attrib_map[i].attrib);
+ /* Stereo is not supported yet */
+ if (!(aglDescribePixelFormat (pixel_format, AGL_STEREO, &value)) ||
+ value) {
aglDestroyPixelFormat (pixel_format);
+ continue;
}
! aglDescribePixelFormat (pixel_format, AGL_DOUBLEBUFFER, &value);
! format.doublebuffer = (value) ? 1: 0;
! /* We don't support single buffering in MacOS X */
! if (!format.doublebuffer) {
aglDestroyPixelFormat (pixel_format);
+ continue;
}
! format.id = (unsigned long int) pixel_format;
!
! format.drawable.onscreen = 1;
! if (thread_info->feature_mask & GLC_FEATURE_OFFSCREEN_MASK)
! format.drawable.offscreen = 1;
! else
! format.drawable.offscreen = 0;
! aglDescribePixelFormat (pixel_format, AGL_RED_SIZE, &value);
! format.red = (unsigned short) value;
! aglDescribePixelFormat (pixel_format, AGL_GREEN_SIZE, &value);
! format.green = (unsigned short) value;
! aglDescribePixelFormat (pixel_format, AGL_BLUE_SIZE, &value);
! format.blue = (unsigned short) value;
! aglDescribePixelFormat (pixel_format, AGL_ALPHA_SIZE, &value);
! format.alpha = (unsigned short) value;
! aglDescribePixelFormat (pixel_format, AGL_DEPTH_SIZE, &value);
! format.depth = (unsigned short) value;
!
! if (thread_info->feature_mask & GLC_FEATURE_MULTISAMPLE_MASK) {
! aglDescribePixelFormat (pixel_format, AGL_SAMPLE_BUFFERS_ARB, &value);
! format.multisample.supported = (value) ? 1: 0;
! aglDescribePixelFormat (pixel_format, AGL_SAMPLES_ARB, &value);
! format.multisample.samples = (unsigned short) value;
! if (format.multisample.supported) {
! if (!(thread_info->feature_mask &
! GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK))
! format.drawable.offscreen = 0;
! }
! } else {
! format.multisample.supported = 0;
! format.multisample.samples = 0;
! }
!
! _glc_add_format (thread_info, &format);
! if (format.alpha && (format.red || format.green || format.blue)) {
! unsigned short tmp;
+ tmp = format.alpha;
+ format.alpha = 0;
+ _glc_add_format (thread_info, &format);
+ format.alpha = tmp;
+ format.red = format.green = format.blue = 0;
_glc_add_format (thread_info, &format);
}
}
! qsort (thread_info->formats, thread_info->n_formats,
! sizeof (glc_format_t), _glc_agl_format_compare);
!
! /* Adding fake offscreen format if no real offscreen formats exists.
! Surfaces created with this format can only be used with draw/read
! pixel functions and as source in composite functions. */
! if (!(thread_info->feature_mask & GLC_FEATURE_OFFSCREEN_MASK)) {
! memset (&format, 0, sizeof (glc_format_t));
! format.drawable.offscreen = 1;
! format.alpha = format.red = format.green = format.blue = 8;
! format.id = 0;
! _glc_add_format (thread_info, &format);
}
! _glc_move_out_ids (thread_info);
}
! glc_format_t *
! glc_agl_find_format (unsigned long mask,
! const glc_format_t *templ,
! int count)
{
! glc_agl_thread_info_t *thread_info = glc_agl_thread_info_get ();
!
! return glc_format_find (thread_info->formats, thread_info->n_formats,
! mask, templ, count);
}
+ slim_hidden_def(glc_agl_find_format);
! glc_format_t *
glc_agl_find_standard_format (unsigned long options,
glc_format_name_t format_name)
{
! glc_agl_thread_info_t *thread_info = glc_agl_thread_info_get ();
! return
! glc_format_find_standard (thread_info->formats, thread_info->n_formats,
! options, format_name);
}
slim_hidden_def(glc_agl_find_standard_format);
Index: glc_agl_info.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_info.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** glc_agl_info.c 3 Feb 2004 15:12:11 -0000 1.1
--- glc_agl_info.c 5 Feb 2004 22:22:28 -0000 1.2
***************
*** 66,73 ****
NULL,
NULL,
NULL,
! { (AGLContext) 0, 1, &_thread_info, 0 },
! { (AGLContext) 0, 1, &_thread_info, 0 },
! GLC_STATUS_SUCCESS,
0,
0
--- 66,76 ----
NULL,
NULL,
+ 0,
+ NULL,
+ 0,
NULL,
! 0,
! { (AGLContext) 0, (AGLPixelFormat) 0, 0 },
! 0,
0,
0
***************
*** 85,93 ****
#endif
- static glc_agl_context_info_t context_info_dummy = {
- NULL,
- NULL
- };
-
static void
_glc_agl_thread_info_init (glc_agl_thread_info_t *thread_info)
--- 88,91 ----
***************
*** 99,176 ****
};
- thread_info->context_stack = &context_info_dummy;
thread_info->formats = NULL;
thread_info->contexts = NULL;
! thread_info->texture_context.context = (AGLContext) 0;
! thread_info->texture_context.ref_count = 1;
! thread_info->texture_context.thread_info = thread_info;
! thread_info->texture_context.formatid = 0;
! thread_info->pbuffer_context.context = (AGLContext) 0;
! thread_info->pbuffer_context.ref_count = 1;
! thread_info->pbuffer_context.thread_info = thread_info;
! thread_info->pbuffer_context.formatid = 0;
! thread_info->status_mask = GLC_STATUS_SUCCESS;
! glc_agl_context_create (thread_info,
! &thread_info->texture_context.context,
! attrib);
!
! aglSetCurrentContext (thread_info->texture_context.context);
!
glPixelStorei (GL_PACK_ALIGNMENT, 4);
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
glc_agl_query_extensions (thread_info);
-
- aglSetCurrentContext (NULL);
-
glc_agl_query_formats (thread_info);
! if (thread_info->feature_mask & GLC_FEATURE_OFFSCREEN_MASK) {
! GLint attr[18];
! int i = 0, without_multisample;
!
! attr[i++] = AGL_RGBA;
! attr[i++] = AGL_RED_SIZE;
! attr[i++] = 8;
! attr[i++] = AGL_BLUE_SIZE;
! attr[i++] = 8;
! attr[i++] = AGL_GREEN_SIZE;
! attr[i++] = 8;
! attr[i++] = AGL_ALPHA_SIZE;
! attr[i++] = 8;
! attr[i++] = AGL_NO_RECOVERY;
! attr[i] = AGL_NONE;
! without_multisample = i;
!
! if (thread_info->feature_mask & GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK) {
! attr[i++] = AGL_SAMPLE_BUFFERS_ARB;
! attr[i++] = 1;
! attr[i++] = AGL_SAMPLES_ARB;
! attr[i] = GLC_AGL_MULTISAMPLE_MAX_SAMPLES;
! attr[i + 1] = AGL_NONE;
!
! for (; (!thread_info->pbuffer_context.context) && attr[i] >= 2;
! attr[i] -= 2)
! glc_agl_context_create (thread_info,
! &thread_info->pbuffer_context.context,
! attr);
!
! if (!thread_info->pbuffer_context.context)
! thread_info->feature_mask &= ~GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK;
! }
!
! if (!thread_info->pbuffer_context.context) {
! attr[without_multisample] = AGL_NONE;
! glc_agl_context_create (thread_info,
! &thread_info->pbuffer_context.context,
! attr);
! }
!
! if (!thread_info->pbuffer_context.context) {
! /* Couldn't create a pbuffer context, offscreen drawing not supported */
! thread_info->feature_mask &= ~GLC_FEATURE_OFFSCREEN_MASK;
! }
! }
}
--- 97,121 ----
};
thread_info->formats = NULL;
+ thread_info->format_ids = NULL;
+ thread_info->n_formats = 0;
thread_info->contexts = NULL;
! thread_info->n_contexts = 0;
! thread_info->root_context.pixel_format =
! aglChoosePixelFormat (NULL, 0, attrib);
! thread_info->root_context.context =
! aglCreateContext (thread_info->root_context.pixel_format, NULL);
! aglSetCurrentContext (thread_info->root_context.context);
glPixelStorei (GL_PACK_ALIGNMENT, 4);
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
glc_agl_query_extensions (thread_info);
glc_agl_query_formats (thread_info);
! thread_info->context_stack = malloc (sizeof (glc_agl_context_info_t));
! thread_info->context_stack_size = 1;
! thread_info->context_stack->surface = NULL;
! thread_info->context_stack->constraint = GLC_CN_NONE;
}
Index: glc_agl_pbuffer.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_pbuffer.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** glc_agl_pbuffer.c 3 Feb 2004 15:12:11 -0000 1.1
--- glc_agl_pbuffer.c 5 Feb 2004 22:22:28 -0000 1.2
***************
*** 33,37 ****
AGLPbuffer
! glc_agl_pbuffer_create (glc_texture_t *texture)
{
AGLPbuffer pbuffer;
--- 33,38 ----
AGLPbuffer
! glc_agl_pbuffer_create (glc_texture_t *texture,
! glc_format_t *format)
{
AGLPbuffer pbuffer;
***************
*** 40,50 ****
texture->target, GL_RGBA, 0, &pbuffer);
glc_texture_bind (texture);
!
! aglTexImagePBuffer (aglGetCurrentContext (), pbuffer, GL_FRONT);
glc_texture_unbind (texture);
-
- return pbuffer;
}
--- 41,61 ----
texture->target, GL_RGBA, 0, &pbuffer);
+ return pbuffer;
+ }
+
+ void
+ glc_agl_pbuffer_bind (AGLPbuffer pbuffer,
+ AGLContext context,
+ glc_texture_t *texture,
+ glc_format_t *format)
+ {
glc_texture_bind (texture);
!
! if (format->doublebuffer)
! aglTexImagePBuffer (context, pbuffer, GL_BACK);
! else
! aglTexImagePBuffer (context, pbuffer, GL_FRONT);
glc_texture_unbind (texture);
}
Index: glc_agl_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_agl_surface.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_agl_surface.c 3 Feb 2004 16:34:51 -0000 1.2
--- glc_agl_surface.c 5 Feb 2004 22:22:28 -0000 1.3
***************
*** 47,51 ****
static void
! _glc_agl_surface_swap_buffers (void *abstract_surface);
static glc_bool_t
--- 47,51 ----
static void
! _glc_agl_surface_show (void *abstract_surface);
static glc_bool_t
***************
*** 55,61 ****
glc_agl_surface_t *surface = (glc_agl_surface_t *) abstract_surface;
! if (constraint == GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT &&
((!surface->pbuffer) && (!surface->drawable)))
! constraint = GLC_CONSTRAINT_ANY_CONTEXT_CURRENT;
surface = glc_agl_context_push_current (surface, constraint);
--- 55,61 ----
glc_agl_surface_t *surface = (glc_agl_surface_t *) abstract_surface;
! if (constraint == GLC_CN_SURFACE_DRAWABLE_CURRENT &&
((!surface->pbuffer) && (!surface->drawable)))
! constraint = GLC_CN_ANY_CONTEXT_CURRENT;
surface = glc_agl_context_push_current (surface, constraint);
***************
*** 87,91 ****
_glc_agl_surface_get_texture,
_glc_agl_surface_realize,
! _glc_agl_surface_swap_buffers
};
--- 87,91 ----
_glc_agl_surface_get_texture,
_glc_agl_surface_realize,
! _glc_agl_surface_show
};
***************
*** 129,140 ****
static glc_surface_t *
! _glc_agl_surface_create_offscreen (glc_agl_thread_info_t *thread_info,
! glc_agl_format_t *format,
! int width,
! int height)
{
glc_agl_surface_t *surface;
unsigned int texture_format;
surface = (glc_agl_surface_t *) calloc (1, sizeof (glc_agl_surface_t));
if (surface == NULL)
--- 129,145 ----
static glc_surface_t *
! _glc_agl_surface_create (glc_agl_thread_info_t *thread_info,
! glc_format_t *format,
! int width,
! int height)
{
glc_agl_surface_t *surface;
+ glc_agl_context_t *context;
unsigned int texture_format;
+ context = glc_agl_context_get (thread_info, format, 1);
+ if (!context)
+ return NULL;
+
surface = (glc_agl_surface_t *) calloc (1, sizeof (glc_agl_surface_t));
if (surface == NULL)
***************
*** 144,147 ****
--- 149,153 ----
surface->thread_info = thread_info;
+ surface->context = context;
surface->format = format;
***************
*** 153,162 ****
surface->base.width = width;
surface->base.height = height;
- surface->context = glc_agl_context_get_default (thread_info);
texture_format = glc_surface_get_texture_format (&surface->base);
! glc_surface_push_current (&surface->base,
! GLC_CONSTRAINT_ANY_CONTEXT_CURRENT);
surface->texture =
--- 159,166 ----
surface->base.width = width;
surface->base.height = height;
texture_format = glc_surface_get_texture_format (&surface->base);
! glc_surface_push_current (&surface->base, GLC_CN_ANY_CONTEXT_CURRENT);
surface->texture =
***************
*** 166,169 ****
--- 170,174 ----
if (!surface->texture) {
+ glc_surface_pop_current (&surface->base);
glc_surface_destroy (&surface->base);
return NULL;
***************
*** 171,178 ****
if (thread_info->feature_mask & GLC_FEATURE_OFFSCREEN_MASK)
! surface->pbuffer = glc_agl_pbuffer_create (surface->texture);
! if (!surface->pbuffer)
glc_texture_allocate (surface->texture);
return &surface->base;
--- 176,194 ----
if (thread_info->feature_mask & GLC_FEATURE_OFFSCREEN_MASK)
! surface->pbuffer =
! glc_agl_pbuffer_create (surface->texture, surface->format);
! if (!surface->pbuffer) {
glc_texture_allocate (surface->texture);
+ } else {
+ glc_surface_push_current (&surface->base, GLC_CN_SURFACE_CONTEXT_CURRENT);
+ glc_agl_pbuffer_bind (surface->pbuffer,
+ surface->context->context,
+ surface->texture,
+ surface->format);
+ glc_surface_pop_current (&surface->base);
+ }
+
+ glc_surface_pop_current (&surface->base);
return &surface->base;
***************
*** 180,195 ****
glc_surface_t *
! glc_agl_surface_create_offscreen (glc_agl_format_t *format,
! int width,
! int height)
{
! return _glc_agl_surface_create_offscreen (glc_agl_thread_info_get (),
! format, width, height);
}
slim_hidden_def(glc_agl_surface_create_offscreen);
glc_surface_t *
! glc_agl_surface_create_for_window (WindowRef window,
! glc_agl_format_t *format)
{
glc_agl_surface_t *surface;
--- 196,211 ----
glc_surface_t *
! glc_agl_surface_create (glc_format_t *format,
! int width,
! int height)
{
! return _glc_agl_surface_create (glc_agl_thread_info_get (),
! format, width, height);
}
slim_hidden_def(glc_agl_surface_create_offscreen);
glc_surface_t *
! glc_agl_surface_create_for_window (glc_format_t *format,
! WindowRef window)
{
glc_agl_surface_t *surface;
***************
*** 198,202 ****
glc_agl_thread_info_t *thread_info = glc_agl_thread_info_get ();
! context = glc_agl_context_get (thread_info, format);
if (!context)
return NULL;
--- 214,218 ----
glc_agl_thread_info_t *thread_info = glc_agl_thread_info_get ();
! context = glc_agl_context_get (thread_info, format, 0);
if (!context)
return NULL;
***************
*** 237,242 ****
if (templ->thread_info->agl_feature_mask & GLC_AGL_FEATURE_PBUFFER_MASK) {
! return _glc_agl_surface_create_offscreen (templ->thread_info,
! templ->format, width, height);
}
--- 253,267 ----
if (templ->thread_info->agl_feature_mask & GLC_AGL_FEATURE_PBUFFER_MASK) {
! glc_format_t *format;
!
! if (templ->format->drawable.offscreen && templ->format->alpha)
! format = templ->format;
! else
! format = glc_format_find_standard (templ->thread_info->formats,
! templ->thread_info->n_formats,
! GLC_FORMAT_OPTION_OFFSCREEN_MASK,
! GLC_STANDARD_A8);
!
! return _glc_agl_surface_create (templ->thread_info, format, width, height);
}
***************
*** 258,265 ****
if (pbuffer == surface->pbuffer)
! glc_agl_context_set_default (surface->thread_info);
} else if (surface->drawable) {
if (aglGetDrawable (context) == surface->drawable)
! glc_agl_context_set_default (surface->thread_info);
}
}
--- 283,290 ----
if (pbuffer == surface->pbuffer)
! glc_agl_context_make_current (surface);
} else if (surface->drawable) {
if (aglGetDrawable (context) == surface->drawable)
! glc_agl_context_make_current (surface);
}
}
***************
*** 271,277 ****
glc_agl_pbuffer_destroy (surface->pbuffer);
- if (surface->context)
- glc_agl_context_release (surface->context);
-
glc_surface_deinit (&surface->base);
--- 296,299 ----
***************
*** 289,294 ****
&surface->base.height);
! glc_agl_context_push_current (surface,
! GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT);
aglUpdateContext (surface->context->context);
--- 311,315 ----
&surface->base.height);
! glc_agl_context_push_current (surface, GLC_CN_SURFACE_DRAWABLE_CURRENT);
aglUpdateContext (surface->context->context);
***************
*** 299,303 ****
static void
! _glc_agl_surface_swap_buffers (void *abstract_surface)
{
glc_agl_surface_t *surface = (glc_agl_surface_t *) abstract_surface;
--- 320,324 ----
static void
! _glc_agl_surface_show (void *abstract_surface)
{
glc_agl_surface_t *surface = (glc_agl_surface_t *) abstract_surface;
***************
*** 306,311 ****
return;
! glc_agl_context_push_current (surface,
! GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT);
if (surface->format->doublebuffer)
--- 327,331 ----
return;
! glc_agl_context_push_current (surface, GLC_CN_SURFACE_DRAWABLE_CURRENT);
if (surface->format->doublebuffer)
Index: glc_glx_context.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_context.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glc_glx_context.c 3 Feb 2004 15:12:11 -0000 1.6
--- glc_glx_context.c 5 Feb 2004 22:22:28 -0000 1.7
***************
*** 34,46 ****
#include <stdlib.h>
! static glc_glx_context_t *
! _glc_glx_context_create_for_visual (glc_glx_screen_info_t *screen_info,
! VisualID visualid,
! GLXContext share_list)
{
int vis_info_count, i;
XVisualInfo *vis_infos;
- glc_glx_context_t *context;
- GLXContext glcontext;
vis_infos = XGetVisualInfo (screen_info->display_info->display,
--- 34,45 ----
#include <stdlib.h>
! static void
! _glc_glx_context_create_glx12 (glc_glx_screen_info_t *screen_info,
! XID visualid,
! GLXContext share_list,
! glc_glx_context_t *context)
{
int vis_info_count, i;
XVisualInfo *vis_infos;
vis_infos = XGetVisualInfo (screen_info->display_info->display,
***************
*** 51,160 ****
}
! if (i == vis_info_count) {
! if (vis_infos)
! XFree (vis_infos);
! return NULL;
! }
!
! glcontext = glXCreateContext (screen_info->display_info->display,
! &vis_infos[i], share_list, 1);
!
! context = (glc_glx_context_t *) malloc (sizeof (glc_glx_context_t));
! context->context = glcontext;
! context->screen_info = screen_info;
! context->visualid = visualid;
! context->ref_count = 1;
XFree (vis_infos);
-
- return context;
}
static void
! _glc_glx_context_add (glc_glx_screen_info_t *screen_info,
! glc_glx_context_t *context)
{
! glc_glx_context_node_t *node;
!
! node = (glc_glx_context_node_t *) malloc (sizeof (glc_glx_context_node_t));
! node->next = screen_info->contexts;
! node->data = context;
! screen_info->contexts = node;
! }
! static glc_glx_context_t *
! glc_glx_context_reference (glc_glx_context_t *context)
! {
! context->ref_count++;
! return context;
! }
! #define GLC_GLX_CONTEXT(data) ((glc_glx_context_t *) data)
glc_glx_context_t *
glc_glx_context_get (glc_glx_screen_info_t *screen_info,
! glc_glx_format_t *format)
{
- glc_glx_context_node_t *node = screen_info->contexts;
glc_glx_context_t *context;
!
! for (; node; node = node->next)
! if (GLC_GLX_CONTEXT (node->data)->visualid == format->visualid)
! return glc_glx_context_reference (GLC_GLX_CONTEXT (node->data));
!
! context =
! _glc_glx_context_create_for_visual (screen_info, format->visualid,
! screen_info->texture_context.context);
!
! if (context)
! _glc_glx_context_add (screen_info, context);
! return context;
! }
! glc_glx_context_t *
! glc_glx_context_get_default (glc_glx_screen_info_t *screen_info)
! {
! if (screen_info->pbuffer_context.context)
! return glc_glx_context_reference (&screen_info->pbuffer_context);
! else
! return glc_glx_context_reference (&screen_info->texture_context);
! }
! void
! glc_glx_context_release (glc_glx_context_t *context)
! {
! glc_glx_screen_info_t *screen_info;
! glc_glx_context_node_t *node, *previous_node;
!
! context->ref_count--;
! if (context->ref_count)
! return;
! screen_info = context->screen_info;
! node = screen_info->contexts;
! previous_node = NULL;
!
! for (; node; node = node->next) {
! if (GLC_GLX_CONTEXT (node->data) == context)
! break;
! previous_node = node;
! }
! if (previous_node)
! previous_node->next = node->next;
! else
! screen_info->contexts = node->next;
! /* Make sure context is not current */
! if (context->context == glXGetCurrentContext ()) {
! glc_glx_context_set_default (screen_info);
! }
!
! glXDestroyContext (context->screen_info->display_info->display,
! context->context);
! free (context);
! free (node);
}
--- 50,123 ----
}
! context->context = glXCreateContext (screen_info->display_info->display,
! &vis_infos[i], share_list, 1);
! context->id = visualid;
! context->fbconfig = (XID) 0;
XFree (vis_infos);
}
static void
! _glc_glx_context_create_glx13 (glc_glx_screen_info_t *screen_info,
! XID fbconfigid,
! GLXContext share_list,
! glc_glx_context_t *context)
{
! GLXFBConfig *fbconfigs;
! int attrib[3];
! int n_fbconfigs;
! attrib[0] = GLX_FBCONFIG_ID;
! attrib[1] = fbconfigid;
! attrib[2] = 0;
! fbconfigs = glXChooseFBConfig (screen_info->display_info->display,
! screen_info->screen, attrib, &n_fbconfigs);
!
! context->context =
! glXCreateNewContext (screen_info->display_info->display,
! *fbconfigs, GLX_RGBA_TYPE, share_list, 1);
! context->id = fbconfigid;
! context->fbconfig = *fbconfigs;
!
! XFree (fbconfigs);
! }
glc_glx_context_t *
glc_glx_context_get (glc_glx_screen_info_t *screen_info,
! glc_format_t *format)
{
glc_glx_context_t *context;
! glc_glx_context_t **contexts = screen_info->contexts;
! int index, n_contexts = screen_info->n_contexts;
! if (screen_info->format_ids[format->id] == (XID) 0)
! return &screen_info->root_context;
! for (; n_contexts; n_contexts--, contexts++)
! if ((*contexts)->id == screen_info->format_ids[format->id])
! return *contexts;
! index = screen_info->n_contexts++;
! screen_info->contexts =
! realloc (screen_info->contexts,
! sizeof (glc_glx_context_t *) * screen_info->n_contexts);
! context = malloc (sizeof (glc_glx_context_t));
! screen_info->contexts[index] = context;
! if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_FBCONFIG_MASK)
! _glc_glx_context_create_glx13 (screen_info,
! screen_info->format_ids[format->id],
! screen_info->root_context.context,
! context);
! else
! _glc_glx_context_create_glx12 (screen_info,
! screen_info->format_ids[format->id],
! screen_info->root_context.context,
! context);
! return context;
}
***************
*** 186,199 ****
void
! glc_glx_context_set_default (glc_glx_screen_info_t *screen_info)
{
! if (screen_info->pbuffer_drawable)
! glXMakeCurrent (screen_info->display_info->display,
! screen_info->pbuffer_drawable,
! screen_info->pbuffer_context.context);
! else
! glXMakeCurrent (screen_info->display_info->display,
! screen_info->texture_drawable,
! screen_info->texture_context.context);
}
--- 149,167 ----
void
! glc_glx_context_make_current (glc_glx_surface_t *surface)
{
! GLXContext context;
! Drawable drawable;
!
! if (!surface->drawable) {
! drawable = surface->screen_info->root_drawable;
! context = surface->screen_info->root_context.context;
! } else {
! context = surface->context->context;
! drawable = surface->drawable;
! }
!
! glXMakeCurrent (surface->screen_info->display_info->display,
! drawable, context);
}
***************
*** 201,229 ****
glc_glx_context_update (glc_glx_surface_t *surface,
glc_constraint_t constraint)
! {
switch (constraint) {
! case GLC_CONSTRAINT_NONE:
break;
! case GLC_CONSTRAINT_ANY_CONTEXT_CURRENT:
if (glXGetCurrentContext () == NULL)
! glc_glx_context_set_default (surface->screen_info);
break;
! case GLC_CONSTRAINT_SURFACE_CONTEXT_CURRENT:
! if (glXGetCurrentContext () != surface->context->context) {
! if (surface->pbuffer && surface->drawable)
! glXMakeCurrent (surface->screen_info->display_info->display,
! (surface->pbuffer) ? surface->pbuffer:
! surface->drawable,
! surface->context->context);
! else
! glc_glx_context_set_default (surface->screen_info);
! }
break;
! case GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT:
! if ((glXGetCurrentDrawable () !=
! ((surface->pbuffer) ? surface->pbuffer: surface->drawable)))
! glXMakeCurrent (surface->screen_info->display_info->display,
! (surface->pbuffer) ? surface->pbuffer: surface->drawable,
! surface->context->context);
glc_glx_context_set_surface_anti_aliasing (surface);
--- 169,188 ----
glc_glx_context_update (glc_glx_surface_t *surface,
glc_constraint_t constraint)
! {
switch (constraint) {
! case GLC_CN_NONE:
break;
! case GLC_CN_ANY_CONTEXT_CURRENT:
if (glXGetCurrentContext () == NULL)
! glc_glx_context_make_current (surface);
break;
! case GLC_CN_SURFACE_CONTEXT_CURRENT:
! if (glXGetCurrentContext () != surface->context->context)
! glc_glx_context_make_current (surface);
break;
! case GLC_CN_SURFACE_DRAWABLE_CURRENT:
! if ((glXGetCurrentContext () != surface->context->context) ||
! (glXGetCurrentDrawable () != surface->drawable))
! glc_glx_context_make_current (surface);
glc_glx_context_set_surface_anti_aliasing (surface);
***************
*** 237,259 ****
{
glc_glx_screen_info_t *screen_info;
! glc_glx_context_info_t *new_context_info;
! screen_info = surface->context->screen_info;
! new_context_info = (glc_glx_context_info_t *)
! calloc (1, sizeof (glc_glx_context_info_t));
! new_context_info->surface = surface;
! new_context_info->constraint = constraint;
! new_context_info->previous = screen_info->context_stack;
! screen_info->context_stack = new_context_info;
!
! glc_glx_context_update (screen_info->context_stack->surface,
! constraint);
! if (screen_info->context_stack->constraint ==
! GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)
! return screen_info->context_stack->surface;
return NULL;
}
--- 196,220 ----
{
glc_glx_screen_info_t *screen_info;
! glc_glx_context_info_t *context_info;
! int index;
! screen_info = surface->screen_info;
! index = screen_info->context_stack_size++;
! screen_info->context_stack =
! realloc (screen_info->context_stack,
! sizeof (glc_glx_context_info_t) *
! screen_info->context_stack_size);
! context_info = &screen_info->context_stack[index];
! context_info->surface = surface;
! context_info->constraint = constraint;
!
! glc_glx_context_update (context_info->surface, constraint);
+ if (context_info->constraint == GLC_CN_SURFACE_DRAWABLE_CURRENT)
+ return context_info->surface;
+
return NULL;
}
***************
*** 263,285 ****
{
glc_glx_screen_info_t *screen_info;
! glc_glx_context_info_t *old_context_info = NULL;
! screen_info = surface->context->screen_info;
!
! if (screen_info->context_stack->previous) {
! old_context_info = screen_info->context_stack;
! screen_info->context_stack = screen_info->context_stack->previous;
! }
! if (screen_info->context_stack->surface)
! glc_glx_context_update (screen_info->context_stack->surface,
! screen_info->context_stack->constraint);
! if (old_context_info)
! free (old_context_info);
! if (screen_info->context_stack->constraint ==
! GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)
! return screen_info->context_stack->surface;
return NULL;
--- 224,247 ----
{
glc_glx_screen_info_t *screen_info;
! glc_glx_context_info_t *context_info = NULL;
! int index;
! screen_info = surface->screen_info;
! screen_info->context_stack_size--;
! index = screen_info->context_stack_size - 1;
!
! screen_info->context_stack =
! realloc (screen_info->context_stack,
! sizeof (glc_glx_context_info_t) *
! screen_info->context_stack_size);
! context_info = &screen_info->context_stack[index];
! if (context_info->surface)
! glc_glx_context_update (context_info->surface, context_info->constraint);
!
! if (context_info->constraint == GLC_CN_SURFACE_DRAWABLE_CURRENT)
! return context_info->surface;
return NULL;
Index: glc_glx_extension.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_extension.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glc_glx_extension.c 3 Feb 2004 15:12:11 -0000 1.4
--- glc_glx_extension.c 5 Feb 2004 22:22:28 -0000 1.5
***************
*** 32,43 ****
#include "glcint.h"
! static glc_extension_map glx_extensions[] = {
! { "GLX_SGIX_fbconfig", GLC_GLX_FEATURE_FBCONFIG_MASK },
! { "GLX_SGIX_pbuffer", GLC_GLX_FEATURE_PBUFFER_MASK },
! { NULL, 0 }
! }, client_glx_extensions[] = {
! { "GLX_ATI_render_texture",
! GLC_GLX_FEATURE_FBCONFIG_MASK | GLC_GLX_FEATURE_PBUFFER_MASK |
! GLC_GLX_FEATURE_RENDER_TEXTURE_MASK },
{ "GLX_ARB_multisample", GLC_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK },
{ NULL, 0 }
--- 32,39 ----
#include "glcint.h"
! extern glc_glx_proc_address_list_t _glc_glx_proc_address;
!
! static glc_extension_map client_glx_extensions[] = {
! { "GLX_ATI_render_texture", GLC_GLX_FEATURE_RENDER_TEXTURE_MASK },
{ "GLX_ARB_multisample", GLC_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK },
{ NULL, 0 }
***************
*** 56,70 ****
static long int
- _glc_glx_extension_query_glx (Display *display,
- int screen)
- {
- const char *glx_extensions_strings;
-
- glx_extensions_strings = glXQueryExtensionsString (display, screen);
-
- return glc_extensions_query (glx_extensions_strings, glx_extensions);
- }
-
- static long int
_glc_glx_extension_query_client_glx (Display *display)
{
--- 52,55 ----
***************
*** 90,99 ****
glc_glx_query_extensions (glc_glx_screen_info_t *screen_info)
{
screen_info->glx_feature_mask = 0;
!
! screen_info->glx_feature_mask |=
! _glc_glx_extension_query_glx (screen_info->display_info->display,
! screen_info->screen);
!
screen_info->glx_feature_mask |=
_glc_glx_extension_query_client_glx (screen_info->display_info->display);
--- 75,82 ----
glc_glx_query_extensions (glc_glx_screen_info_t *screen_info)
{
+ const char *glx_server_version, *glx_client_version;
+
screen_info->glx_feature_mask = 0;
!
screen_info->glx_feature_mask |=
_glc_glx_extension_query_client_glx (screen_info->display_info->display);
***************
*** 101,104 ****
--- 84,107 ----
screen_info->glx_feature_mask |= _glc_glx_extension_query_gl ();
+ glx_server_version =
+ glXQueryServerString (screen_info->display_info->display,
+ screen_info->screen, GLX_VERSION);
+ glx_client_version =
+ glXGetClientString (screen_info->display_info->display, GLX_VERSION);
+
+ if (strcmp (glx_client_version, "1.3") >= 0) {
+ if (strcmp (glx_server_version, "1.3") >= 0) {
+ screen_info->glx_feature_mask |=
+ (GLC_GLX_FEATURE_FBCONFIG_MASK | GLC_GLX_FEATURE_PBUFFER_MASK);
+ } else if (screen_info->glx_feature_mask &
+ GLC_GLX_FEATURE_RENDER_TEXTURE_MASK) {
+ /* ATI emulates GLX 1.3 in there latest drivers. If the driver
+ supports GLX_ATI_render_texture extension, GLX 1.3 emulation is
+ probably also in there. */
+ screen_info->glx_feature_mask |=
+ (GLC_GLX_FEATURE_FBCONFIG_MASK | GLC_GLX_FEATURE_PBUFFER_MASK);
+ }
+ }
+
screen_info->feature_mask = 0;
***************
*** 123,125 ****
--- 126,142 ----
screen_info->feature_mask |= GLC_FEATURE_TEXTURE_RECTANGLE_MASK;
}
+
+ if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_RENDER_TEXTURE_MASK) {
+ screen_info->glx_feature_mask &= ~GLC_GLX_FEATURE_RENDER_TEXTURE_MASK;
+
+ #ifdef GLX_ATI_render_texture
+ if (_glc_glx_proc_address.glx_bind_tex_image_ati &&
+ _glc_glx_proc_address.glx_release_tex_image_ati) {
+ screen_info->glx_feature_mask |= GLC_GLX_FEATURE_RENDER_TEXTURE_MASK;
+ screen_info->texture_mask &= ~GLC_TEXTURE_TARGET_RECTANGLE_MASK;
+ screen_info->feature_mask &= ~GLC_FEATURE_TEXTURE_RECTANGLE_MASK;
+ }
+ #endif
+
+ }
}
Index: glc_glx_format.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_format.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** glc_glx_format.c 3 Feb 2004 17:54:01 -0000 1.8
--- glc_glx_format.c 5 Feb 2004 22:22:28 -0000 1.9
***************
*** 35,270 ****
#include <string.h>
! static void
! _glc_add_format (glc_glx_screen_info_t *screen_info,
! glc_glx_format_t *format)
{
! glc_glx_format_node_t *node;
! glc_glx_format_t *new_format = (glc_glx_format_t *)
! malloc (sizeof (glc_glx_format_t));
!
! memcpy (new_format, format, sizeof (glc_glx_format_t));
! node = (glc_glx_format_node_t *) malloc (sizeof (glc_glx_format_node_t));
! node->next = screen_info->formats;
! node->data = new_format;
! screen_info->formats = node;
}
! void
! glc_glx_query_formats (glc_glx_screen_info_t *screen_info)
{
! Display *display = screen_info->display_info->display;
! int screen = screen_info->screen;
! XVisualInfo *vinfo = NULL;
! int i, j = 0, attr[18], red, green, blue, alpha, doublebuffer;
! glc_glx_format_id_t id = 0;
! glc_glx_format_t format;
!
! attr[j++] = GLX_RGBA;
! attr[j++] = GLX_RED_SIZE;
! red = j++;
! attr[j++] = GLX_GREEN_SIZE;
! green = j++;
! attr[j++] = GLX_BLUE_SIZE;
! blue = j++;
! attr[j++] = GLX_ALPHA_SIZE;
! alpha = j++;
!
! if (screen_info->feature_mask & GLC_FEATURE_MULTISAMPLE_MASK) {
! attr[j++] = GLX_SAMPLE_BUFFERS_ARB;
! attr[j++] = 1;
! attr[j++] = GLX_SAMPLES_ARB;
! attr[j] = GLC_GLX_MULTISAMPLE_MAX_SAMPLES;
! attr[j + 1] = 0;
!
! for (; (!vinfo) && attr[j] >= 2; attr[j] -= 2)
! vinfo = glXChooseVisual (display, screen, attr);
!
! j++;
!
! if (vinfo)
! XFree (vinfo);
! }
! doublebuffer = j;
! attr[j++] = 0;
! attr[j] = 0;
! for (i = 0; i <= 1; i++) {
! memset (&format, 0, sizeof (glc_glx_format_t));
! format.doublebuffer = i;
! if (format.doublebuffer)
! attr[doublebuffer] = GLX_DOUBLEBUFFER;
! attr[red] = attr[green] = attr[blue] = 0;
! attr[alpha] = 1;
! vinfo = glXChooseVisual (display, screen, attr);
! if (vinfo) {
! format.red = 0;
! format.green = 0;
! format.blue = 0;
! format.alpha = 1;
! format.id = id++;
! format.visualid = vinfo->visualid;
!
! _glc_add_format (screen_info, &format);
! XFree (vinfo);
! }
! attr[red] = attr[green] = attr[blue] = 8;
! attr[alpha] = 0;
! vinfo = glXChooseVisual (display, screen, attr);
! if (vinfo) {
! format.red = 0;
! format.green = 0;
! format.blue = 0;
! format.alpha = 8;
! format.id = id++;
! format.visualid = vinfo->visualid;
!
! _glc_add_format (screen_info, &format);
! format.red = 8;
! format.green = 8;
! format.blue = 8;
! format.alpha = 0;
! format.id = id++;
! _glc_add_format (screen_info, &format);
!
! format.red = 8;
! format.green = 8;
! format.blue = 8;
! format.alpha = 8;
! format.id = id++;
!
! _glc_add_format (screen_info, &format);
!
! XFree (vinfo);
}
! attr[alpha] = 8;
!
! vinfo = glXChooseVisual (display, screen, attr);
! if (vinfo) {
! format.red = 0;
! format.green = 0;
! format.blue = 0;
! format.alpha = 8;
! format.id = id++;
! format.visualid = vinfo->visualid;
!
! _glc_add_format (screen_info, &format);
! format.red = 8;
! format.green = 8;
! format.blue = 8;
format.alpha = 0;
- format.id = id++;
-
_glc_add_format (screen_info, &format);
!
! format.red = 8;
! format.green = 8;
! format.blue = 8;
! format.alpha = 8;
! format.id = id++;
!
_glc_add_format (screen_info, &format);
-
- XFree (vinfo);
}
}
- }
-
- #define GLC_GLX_FORMAT(data) ((glc_glx_format_t *) data)
! glc_glx_format_t *
! glc_glx_find_format (Display *display,
! int screen,
! unsigned long mask,
! const glc_glx_format_t *templ,
! int count)
! {
! glc_glx_screen_info_t *screen_info =
! glc_glx_screen_info_get (display, screen);
! glc_glx_format_node_t *node = screen_info->formats;
! for (; node; node = node->next) {
! if (mask & GLC_GLX_FORMAT_ID_MASK)
! if (templ->id != GLC_GLX_FORMAT (node->data)->id)
! continue;
! if (mask & GLC_GLX_FORMAT_ALPHA_MASK)
! if (templ->alpha != GLC_GLX_FORMAT (node->data)->alpha)
! continue;
! if (mask & GLC_GLX_FORMAT_RED_MASK)
! if (templ->red != GLC_GLX_FORMAT (node->data)->red)
! continue;
! if (mask & GLC_GLX_FORMAT_GREEN_MASK)
! if (templ->green != GLC_GLX_FORMAT (node->data)->green)
! continue;
! if (mask & GLC_GLX_FORMAT_BLUE_MASK)
! if (templ->blue != GLC_GLX_FORMAT (node->data)->blue)
! continue;
! if (mask & GLC_GLX_FORMAT_DOUBLEBUFFER_MASK)
! if (templ->doublebuffer != GLC_GLX_FORMAT (node->data)->doublebuffer)
! continue;
! if (mask & GLC_GLX_FORMAT_VISUALID_MASK) {
! if (templ->visualid != GLC_GLX_FORMAT (node->data)->visualid)
! continue;
}
! if (count-- == 0)
! return GLC_GLX_FORMAT (node->data);
!
}
! return NULL;
}
! static void
! _glc_add_options (unsigned long options,
! glc_glx_format_t *format,
! unsigned long *mask)
{
! if (options & GLC_GLX_OPTION_DOUBLEBUFFER_MASK) {
! format->doublebuffer = 1;
! *mask |= GLC_GLX_FORMAT_DOUBLEBUFFER_MASK;
! } else {
! format->doublebuffer = 0;
! *mask |= GLC_GLX_FORMAT_DOUBLEBUFFER_MASK;
! }
}
! glc_glx_format_t *
! glc_glx_find_visual_format (Display *display,
! int screen,
! unsigned long options,
! Visual *visual)
{
! glc_glx_format_t templ;
! unsigned long mask;
! if (visual) {
! templ.visualid = XVisualIDFromVisual (visual);
! mask = GLC_GLX_FORMAT_VISUALID_MASK;
! } else {
! mask = 0;
! _glc_add_options (options, &templ, &mask);
! }
!
! return glc_glx_find_format (display, screen, mask, &templ, 0);
}
! slim_hidden_def(glc_glx_find_visual_format);
! glc_glx_format_t *
glc_glx_find_standard_format (Display *display,
int screen,
--- 35,323 ----
#include <string.h>
! static int
! _glc_glx_format_compare (const void *elem1,
! const void *elem2)
{
! int i, score[2];
! glc_format_t *format[2];
!
! format[0] = (glc_format_t *) elem1;
! format[1] = (glc_format_t *) elem2;
! i = score[0] = score[1] = 0;
! for (; i < 2; i++) {
! if (format[i]->depth)
! score[i] += 10;
! if (format[i]->alpha)
! score[i] += 10;
! if (format[i]->red)
! score[i] += 10;
! if (format[i]->doublebuffer)
! score[i] += 10;
! if (format[i]->drawable.onscreen)
! score[i] += 10;
! if (format[i]->drawable.offscreen)
! score[i] += 10;
! if (format[i]->drawable.offscreen &&
! format[i]->drawable.onscreen)
! score[i] += 10;
! if (format[i]->multisample.supported)
! score[i] += (5 + format[i]->multisample.samples);
! }
!
! return score[1] - score[0];
}
! static void
! _glc_add_format (glc_glx_screen_info_t *screen_info,
! glc_format_t *format)
{
! int index = screen_info->n_formats++;
! screen_info->formats =
! realloc (screen_info->formats,
! sizeof (glc_format_t) * screen_info->n_formats);
! memcpy (&screen_info->formats[index], format, sizeof (glc_format_t));
! }
! static void
! _glc_move_out_ids (glc_glx_screen_info_t *screen_info)
! {
! int i;
! glc_format_t *formats = screen_info->formats;
! int n_formats = screen_info->n_formats;
! screen_info->format_ids = malloc (sizeof (XID) * n_formats);
!
! for (i = 0; n_formats; n_formats--, formats++) {
! screen_info->format_ids[i] = formats->id;
! formats->id = i++;
! }
! }
! static void
! glc_glx_query_formats_glx12 (glc_glx_screen_info_t *screen_info)
! {
! Display *display;
! glc_format_t format;
! XVisualInfo visual_templ;
! XVisualInfo *visuals;
! long int mask;
! int i, num_visuals;
!
! display = screen_info->display_info->display;
! visual_templ.screen = screen_info->screen;
! mask = VisualScreenMask;
! visuals =
! XGetVisualInfo (display, VisualScreenMask, &visual_templ, &num_visuals);
! /* Offscreen drawing never supported if GLX is older than 1.3 */
! format.drawable.offscreen = 0;
! format.drawable.onscreen = 1;
! for (i = 0; i < num_visuals; i++) {
! int value;
!
! if ((glXGetConfig (display, &visuals[i], GLX_USE_GL, &value) != 0) ||
! (value == 0))
! continue;
!
! glXGetConfig (display, &visuals[i], GLX_RGBA, &value);
! if (value == 0)
! continue;
!
! /* Stereo is not supported yet */
! glXGetConfig (display, &visuals[i], GLX_STEREO, &value);
! if (value != 0)
! continue;
!
! format.id = visuals->visualid;
! glXGetConfig (display, &visuals[i], GLX_RED_SIZE, &value);
! format.red = (unsigned short) value;
! glXGetConfig (display, &visuals[i], GLX_GREEN_SIZE, &value);
! format.green = (unsigned short) value;
! glXGetConfig (display, &visuals[i], GLX_BLUE_SIZE, &value);
! format.blue = (unsigned short) value;
! glXGetConfig (display, &visuals[i], GLX_ALPHA_SIZE, &value);
! format.alpha = (unsigned short) value;
! glXGetConfig (display, &visuals[i], GLX_DEPTH_SIZE, &value);
! format.depth = (unsigned short) value;
! glXGetConfig (display, &visuals[i], GLX_DOUBLEBUFFER, &value);
! format.doublebuffer = (value) ? 1: 0;
!
! if (screen_info->feature_mask & GLC_FEATURE_MULTISAMPLE_MASK) {
! glXGetConfig (display, &visuals[i], GLX_SAMPLE_BUFFERS_ARB, &value);
! format.multisample.supported = (value) ? 1: 0;
! glXGetConfig (display, &visuals[i], GLX_SAMPLES_ARB, &value);
! format.multisample.samples = (unsigned short) value;
! } else {
! format.multisample.supported = 0;
! format.multisample.samples = 0;
}
! _glc_add_format (screen_info, &format);
! if (format.alpha && (format.red || format.green || format.blue)) {
! unsigned short tmp;
!
! tmp = format.alpha;
format.alpha = 0;
_glc_add_format (screen_info, &format);
! format.alpha = tmp;
! format.red = format.green = format.blue = 0;
_glc_add_format (screen_info, &format);
}
}
! qsort (screen_info->formats, screen_info->n_formats,
! sizeof (glc_format_t), _glc_glx_format_compare);
! /* Adding fake offscreen format as no real offscreen formats exists.
! Surfaces created with this format can only be used with draw/read
! pixel functions and as source in composite functions. */
! memset (&format, 0, sizeof (glc_format_t));
! format.drawable.offscreen = 1;
! format.alpha = format.red = format.green = format.blue = 8;
! format.id = 0;
! _glc_add_format (screen_info, &format);
!
! if (visuals)
! XFree (visuals);
! }
! static glc_bool_t
! glc_glx_query_formats_glx13 (glc_glx_screen_info_t *screen_info)
! {
! Display *display;
! glc_format_t format;
! GLXFBConfig *fbconfigs;
! int i, num_configs;
! glc_bool_t offscreen_formats = 0;
!
! display = screen_info->display_info->display;
! fbconfigs = glXGetFBConfigs (display, screen_info->screen, &num_configs);
! /* GLX 1.3 is not support, falling back to GLX 1.2 */
! if (!fbconfigs)
! return 1;
!
! for (i = 0; i < num_configs; i++) {
! int value;
!
! if ((glXGetFBConfigAttrib (display, fbconfigs[i], GLX_RENDER_TYPE,
! &value) != 0) ||
! (!(value & GLX_RGBA_BIT)))
! continue;
! /* Stereo is not supported yet */
! glXGetFBConfigAttrib (display, fbconfigs[i], GLX_STEREO, &value);
! if (value != 0)
! continue;
! glXGetFBConfigAttrib (display, fbconfigs[i], GLX_DRAWABLE_TYPE, &value);
! if (!((value & GLX_WINDOW_BIT) || (value & GLX_PBUFFER_BIT)))
! continue;
!
! format.drawable.onscreen = (value & GLX_WINDOW_BIT)? 1: 0;
! format.drawable.offscreen = (value & GLX_PBUFFER_BIT)? 1: 0;
! if (format.drawable.offscreen)
! offscreen_formats = 1;
!
! glXGetFBConfigAttrib (display, fbconfigs[i], GLX_FBCONFIG_ID, &value);
! format.id = (XID) value;
!
! glXGetFBConfigAttrib (display, fbconfigs[i], GLX_RED_SIZE, &value);
! format.red = (unsigned short) value;
! glXGetFBConfigAttrib (display, fbconfigs[i], GLX_GREEN_SIZE, &value);
! format.green = (unsigned short) value;
! glXGetFBConfigAttrib (display, fbconfigs[i], GLX_BLUE_SIZE, &value);
! format.blue = (unsigned short) value;
! glXGetFBConfigAttrib (display, fbconfigs[i], GLX_ALPHA_SIZE, &value);
! format.alpha = (unsigned short) value;
! glXGetFBConfigAttrib (display, fbconfigs[i], GLX_DEPTH_SIZE, &value);
! format.depth = (unsigned short) value;
! glXGetFBConfigAttrib (display, fbconfigs[i], GLX_DOUBLEBUFFER, &value);
! format.doublebuffer = (value) ? 1: 0;
!
! if (screen_info->feature_mask & GLC_FEATURE_MULTISAMPLE_MASK) {
! glXGetFBConfigAttrib (display, fbconfigs[i],
! GLX_SAMPLE_BUFFERS_ARB, &value);
! format.multisample.supported = (value) ? 1: 0;
! glXGetFBConfigAttrib (display, fbconfigs[i], GLX_SAMPLES_ARB, &value);
! format.multisample.samples = (unsigned short) value;
! } else {
! format.multisample.supported = 0;
! format.multisample.samples = 0;
! }
!
! _glc_add_format (screen_info, &format);
! if (format.alpha && (format.red || format.green || format.blue)) {
! unsigned short tmp;
!
! tmp = format.alpha;
! format.alpha = 0;
! _glc_add_format (screen_info, &format);
! format.alpha = tmp;
! format.red = format.green = format.blue = 0;
! _glc_add_format (screen_info, &format);
}
+ }
! qsort (screen_info->formats, screen_info->n_formats,
! sizeof (glc_format_t), _glc_glx_format_compare);
!
! /* Adding fake offscreen format if no real offscreen formats exists.
! Surfaces created with this format can only be used with draw/read
! pixel functions and as source in composite functions. */
! if (!offscreen_formats) {
! screen_info->glx_feature_mask &= ~GLC_GLX_FEATURE_PBUFFER_MASK;
! screen_info->feature_mask &= ~GLC_FEATURE_OFFSCREEN_MASK;
! memset (&format, 0, sizeof (glc_format_t));
! format.drawable.offscreen = 1;
! format.alpha = format.red = format.green = format.blue = 8;
! format.id = 0;
! _glc_add_format (screen_info, &format);
}
+
+ if (fbconfigs)
+ XFree (fbconfigs);
! return 0;
}
! void
! glc_glx_query_formats (glc_glx_screen_info_t *screen_info)
{
! glc_bool_t status = 1;
!
! if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_FBCONFIG_MASK)
! status = glc_glx_query_formats_glx13 (screen_info);
!
! if (status)
! glc_glx_query_formats_glx12 (screen_info);
!
! _glc_move_out_ids (screen_info);
}
! glc_format_t *
! glc_glx_find_format (Display *display,
! int screen,
! unsigned long mask,
! const glc_format_t *templ,
! int count)
{
! glc_glx_screen_info_t *screen_info =
! glc_glx_screen_info_get (display, screen);
! return glc_format_find (screen_info->formats, screen_info->n_formats,
! mask, templ, count);
}
! slim_hidden_def(glc_glx_find_format);
! glc_format_t *
glc_glx_find_standard_format (Display *display,
int screen,
***************
*** 272,322 ****
glc_format_name_t format_name)
{
! glc_glx_format_t templ;
! unsigned long mask = GLC_GLX_FORMAT_ALPHA_MASK | GLC_GLX_FORMAT_RED_MASK |
! GLC_GLX_FORMAT_GREEN_MASK | GLC_GLX_FORMAT_BLUE_MASK;
!
! switch (format_name) {
! case GLC_STANDARD_ARGB32:
! templ.alpha = 8;
! templ.red = 8;
! templ.green = 8;
! templ.blue = 8;
! break;
! case GLC_STANDARD_RGB24:
! templ.alpha = 0;
! templ.red = 8;
! templ.green = 8;
! templ.blue = 8;
! break;
! case GLC_STANDARD_A8:
! templ.alpha = 8;
! templ.red = 0;
! templ.green = 0;
! templ.blue = 0;
! break;
! case GLC_STANDARD_A1:
! templ.alpha = 1;
! templ.red = 0;
! templ.green = 0;
! templ.blue = 0;
! break;
! }
!
! _glc_add_options (options, &templ, &mask);
! mask &= ~GLC_GLX_FORMAT_DOUBLEBUFFER_MASK;
!
! return glc_glx_find_format (display, screen, mask, &templ, 0);
}
slim_hidden_def(glc_glx_find_standard_format);
XVisualInfo *
! glc_glx_format_get_visual_info (Display *display,
! glc_glx_format_t *format)
{
! XVisualInfo templ;
! int nitems;
! templ.visualid = format->visualid;
! return XGetVisualInfo(display, VisualIDMask, &templ, &nitems);
}
! slim_hidden_def(glc_glx_format_get_visual_info);
--- 325,370 ----
glc_format_name_t format_name)
{
! glc_glx_screen_info_t *screen_info =
! glc_glx_screen_info_get (display, screen);
!
! return
! glc_format_find_standard (screen_info->formats, screen_info->n_formats,
! options, format_name);
}
slim_hidden_def(glc_glx_find_standard_format);
XVisualInfo *
! glc_glx_get_visual_info_from_format (Display *display,
! int screen,
! glc_format_t *format)
{
! XVisualInfo *vinfo = NULL;
! glc_glx_screen_info_t *screen_info =
! glc_glx_screen_info_get (display, screen);
! if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_FBCONFIG_MASK) {
! GLXFBConfig *fbconfigs;
! int attrib[3];
! int n_fbconfigs;
!
! attrib[0] = GLX_FBCONFIG_ID;
! attrib[1] = screen_info->format_ids[format->id];
! attrib[2] = 0;
!
! fbconfigs = glXChooseFBConfig (display, screen, attrib, &n_fbconfigs);
!
! vinfo = glXGetVisualFromFBConfig (display, *fbconfigs);
!
! XFree (fbconfigs);
! } else {
! XVisualInfo templ;
! int n_items;
!
! templ.visualid = screen_info->format_ids[format->id];
!
! vinfo = XGetVisualInfo (display, VisualIDMask, &templ, &n_items);
! }
!
! return vinfo;
}
! slim_hidden_def(glc_glx_get_visual_info_from_format);
Index: glc_glx_info.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_info.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glc_glx_info.c 3 Feb 2004 15:12:11 -0000 1.6
--- glc_glx_info.c 5 Feb 2004 22:22:28 -0000 1.7
***************
*** 32,41 ****
#include "glcint.h"
- static glc_glx_context_info_t context_info_dummy = {
- NULL,
- NULL,
- GLC_CONSTRAINT_NONE
- };
-
glc_glx_proc_address_list_t _glc_glx_proc_address = {
--- 32,35 ----
***************
*** 86,90 ****
malloc (sizeof (glc_glx_thread_info_t));
info->displays = NULL;
! info->status_mask = GLC_STATUS_SUCCESS;
glc_proc_address_lookup ();
xthread_key_create (&info_tsd, NULL);
--- 80,84 ----
malloc (sizeof (glc_glx_thread_info_t));
info->displays = NULL;
! info->n_displays = 0;
glc_proc_address_lookup ();
xthread_key_create (&info_tsd, NULL);
***************
*** 105,109 ****
static glc_glx_thread_info_t thread_info = {
NULL,
! GLC_STATUS_SUCCESS
};
--- 99,103 ----
static glc_glx_thread_info_t thread_info = {
NULL,
! 0
};
***************
*** 116,121 ****
#endif
- #define GLC_GLX_DISPLAY_INFO(data) ((glc_glx_display_info_t *) data)
-
glc_glx_display_info_t *
glc_glx_display_info_get (Display *display)
--- 110,113 ----
***************
*** 123,143 ****
glc_glx_display_info_t *display_info;
glc_glx_thread_info_t *thread_info = glc_glx_thread_info_get ();
! glc_glx_display_info_node_t *new_node, *node = thread_info->displays;
! for (; node; node = node->next)
! if (GLC_GLX_DISPLAY_INFO (node->data)->display == display)
! return GLC_GLX_DISPLAY_INFO (node->data);
- display_info = (glc_glx_display_info_t *)
- malloc (sizeof (glc_glx_display_info_t));
display_info->thread_info = thread_info;
display_info->display = display;
display_info->screens = NULL;
!
! new_node = (glc_glx_display_info_node_t *)
! malloc (sizeof (glc_glx_display_info_node_t));
! new_node->next = thread_info->displays;
! new_node->data = display_info;
! thread_info->displays = new_node;
return display_info;
--- 115,138 ----
glc_glx_display_info_t *display_info;
glc_glx_thread_info_t *thread_info = glc_glx_thread_info_get ();
! glc_glx_display_info_t **displays = thread_info->displays;
! int index, n_displays = thread_info->n_displays;
! for (; n_displays; n_displays--, displays++)
! if ((*displays)->display == display)
! return *displays;
!
! index = thread_info->n_displays++;
!
! thread_info->displays =
! realloc (thread_info->displays,
! sizeof (glc_glx_display_info_t *) * thread_info->n_displays);
!
! display_info = malloc (sizeof (glc_glx_display_info_t));
! thread_info->displays[index] = display_info;
display_info->thread_info = thread_info;
display_info->display = display;
display_info->screens = NULL;
! display_info->n_screens = 0;
return display_info;
***************
*** 145,158 ****
static void
! glc_glx_create_texture_context (glc_glx_screen_info_t *screen_info,
! int *attrib)
{
XVisualInfo *vinfo;
XSetWindowAttributes win_attrib;
int screen = screen_info->screen;
Display *display = screen_info->display_info->display;
vinfo = glXChooseVisual (display, screen, attrib);
! if (! vinfo)
return;
--- 140,156 ----
static void
! glc_glx_create_root_context (glc_glx_screen_info_t *screen_info)
{
XVisualInfo *vinfo;
XSetWindowAttributes win_attrib;
+ int attrib[] = {
+ GLX_RGBA,
+ 0
+ };
int screen = screen_info->screen;
Display *display = screen_info->display_info->display;
vinfo = glXChooseVisual (display, screen, attrib);
! if (!vinfo)
return;
***************
*** 161,242 ****
RootWindow (display, screen),
vinfo->visual, AllocNone);
! screen_info->texture_drawable =
XCreateWindow (display,
RootWindow (display, screen),
! -1, -1, 1, 1, 0, vinfo->depth, CopyFromParent,
vinfo->visual, CWColormap, &win_attrib);
! screen_info->texture_context.context =
glXCreateContext (display, vinfo, NULL, 1);
XFree (vinfo);
}
- static void
- glc_glx_create_pbuffer_context (glc_glx_screen_info_t *screen_info,
- int *attrib,
- GLXContext *context)
- {
- int nfbconfigs;
- Display *display = screen_info->display_info->display;
-
- screen_info->fbconfig =
- glXChooseFBConfig (display, screen_info->screen, attrib, &nfbconfigs);
-
- if (!screen_info->fbconfig)
- return;
-
- *context =
- glXCreateNewContext (display, *screen_info->fbconfig,
- GLX_RGBA_TYPE,
- screen_info->texture_context.context, 1);
-
- if (!*context)
- XFree (screen_info->fbconfig);
- }
-
- #define GLC_GLX_SCREEN_INFO(data) ((glc_glx_screen_info_t *) data)
-
glc_glx_screen_info_t *
glc_glx_screen_info_get (Display *display,
int screen)
{
- int attrib[] = {
- GLX_RGBA,
- 0
- };
glc_glx_screen_info_t *screen_info;
glc_glx_display_info_t *display_info = glc_glx_display_info_get (display);
! glc_glx_screen_info_node_t *new_node, *node = display_info->screens;
- for (; node; node = node->next)
- if (GLC_GLX_SCREEN_INFO (node->data)->screen == screen)
- return GLC_GLX_SCREEN_INFO (node->data);
-
- screen_info = (glc_glx_screen_info_t *)
- malloc (sizeof (glc_glx_screen_info_t));
screen_info->display_info = display_info;
screen_info->screen = screen;
screen_info->formats = NULL;
screen_info->contexts = NULL;
! screen_info->contexts = NULL;
! screen_info->context_stack = &context_info_dummy;
! screen_info->texture_context.context = NULL;
! screen_info->texture_context.ref_count = 1;
! screen_info->texture_context.screen_info = screen_info;
! screen_info->texture_context.visualid = None;
! screen_info->texture_drawable = None;
! screen_info->pbuffer_context.context = NULL;
! screen_info->pbuffer_context.ref_count = 1;
! screen_info->pbuffer_context.screen_info = screen_info;
! screen_info->pbuffer_context.visualid = None;
! screen_info->pbuffer_drawable = None;
! glc_glx_create_texture_context (screen_info, attrib);
!
! glXMakeCurrent (screen_info->display_info->display,
! screen_info->texture_drawable,
! screen_info->texture_context.context);
glPixelStorei (GL_PACK_ALIGNMENT, 4);
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
--- 159,213 ----
RootWindow (display, screen),
vinfo->visual, AllocNone);
! screen_info->root_drawable =
XCreateWindow (display,
RootWindow (display, screen),
! -2, -2, 1, 1, 0, vinfo->depth, CopyFromParent,
vinfo->visual, CWColormap, &win_attrib);
! screen_info->root_context.context =
glXCreateContext (display, vinfo, NULL, 1);
+
+ screen_info->root_context.fbconfig = (XID) 0;
+ screen_info->root_context.id = vinfo->visualid;
XFree (vinfo);
}
glc_glx_screen_info_t *
glc_glx_screen_info_get (Display *display,
int screen)
{
glc_glx_screen_info_t *screen_info;
glc_glx_display_info_t *display_info = glc_glx_display_info_get (display);
! glc_glx_screen_info_t **screens = display_info->screens;
! int index, n_screens = display_info->n_screens;
!
! for (; n_screens; n_screens--, screens++)
! if ((*screens)->screen == screen)
! return *screens;
!
! index = display_info->n_screens++;
!
! display_info->screens =
! realloc (display_info->screens,
! sizeof (glc_glx_screen_info_t *) * display_info->n_screens);
!
! screen_info = malloc (sizeof (glc_glx_screen_info_t));
! display_info->screens[index] = screen_info;
screen_info->display_info = display_info;
screen_info->screen = screen;
screen_info->formats = NULL;
+ screen_info->format_ids = NULL;
+ screen_info->n_formats = 0;
+
screen_info->contexts = NULL;
! screen_info->n_contexts = 0;
! glc_glx_create_root_context (screen_info);
+ glXMakeCurrent (screen_info->display_info->display,
+ screen_info->root_drawable,
+ screen_info->root_context.context);
glPixelStorei (GL_PACK_ALIGNMENT, 4);
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
***************
*** 244,346 ****
glc_glx_query_extensions (screen_info);
glc_glx_query_formats (screen_info);
-
- if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_RENDER_TEXTURE_MASK) {
- screen_info->glx_feature_mask &= ~GLC_GLX_FEATURE_RENDER_TEXTURE_MASK;
-
- #ifdef GLX_ATI_render_texture
- if (_glc_glx_proc_address.glx_bind_tex_image_ati &&
- _glc_glx_proc_address.glx_release_tex_image_ati) {
- screen_info->glx_feature_mask |= GLC_GLX_FEATURE_RENDER_TEXTURE_MASK;
- screen_info->texture_mask &= ~GLC_TEXTURE_TARGET_RECTANGLE_MASK;
- screen_info->feature_mask &= ~GLC_FEATURE_TEXTURE_RECTANGLE_MASK;
- }
- #endif
-
- }
-
- if (screen_info->feature_mask & GLC_FEATURE_OFFSCREEN_MASK) {
- int attr[20];
- int i = 0, without_multisample, render_texture;
-
- attr[i++] = GLX_DOUBLEBUFFER;
- attr[i++] = 0;
- attr[i++] = GLX_RED_SIZE;
- attr[i++] = 8;
- attr[i++] = GLX_GREEN_SIZE;
- attr[i++] = 8;
- attr[i++] = GLX_BLUE_SIZE;
- attr[i++] = 8;
- attr[i++] = GLX_ALPHA_SIZE;
- attr[i++] = 8;
- attr[i++] = GLX_RENDER_TYPE;
- attr[i++] = GLX_RGBA_BIT;
- attr[i++] = GLX_DRAWABLE_TYPE;
- attr[i++] = GLX_PBUFFER_BIT;
-
- if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_RENDER_TEXTURE_MASK) {
- render_texture = 1;
-
- #ifdef GLX_ATI_render_texture
- attr[i++] = GLX_BIND_TO_TEXTURE_RGBA_ATI;
- attr[i++] = 1;
- #endif
-
- } else
- render_texture = 0;
-
- attr[i] = 0;
- without_multisample = i;
-
- if (screen_info->feature_mask & GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK) {
- attr[i++] = GLX_SAMPLE_BUFFERS_ARB;
- attr[i++] = 1;
- attr[i++] = GLX_SAMPLES_ARB;
- attr[i] = GLC_GLX_MULTISAMPLE_MAX_SAMPLES;
- attr[i + 1] = 0;
-
- for (; (!screen_info->pbuffer_context.context) && attr[i] >= 2;
- attr[i] -= 2)
- glc_glx_create_pbuffer_context (screen_info,
- attr,
- &screen_info->pbuffer_context.context);
-
- if (!screen_info->pbuffer_context.context)
- screen_info->feature_mask &= ~GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK;
- }
-
- if (!screen_info->pbuffer_context.context) {
- attr[without_multisample] = 0;
- glc_glx_create_pbuffer_context (screen_info,
- attr,
- &screen_info->pbuffer_context.context);
- }
-
- if (!screen_info->pbuffer_context.context) {
- /* Couldn't create a pbuffer context, offscreen drawing not supported */
- screen_info->glx_feature_mask &= ~GLC_GLX_FEATURE_PBUFFER_MASK;
- screen_info->feature_mask &= ~GLC_FEATURE_OFFSCREEN_MASK;
- } else {
- static glc_texture_t texture;
-
- texture.width = texture.height = 1;
- screen_info->pbuffer_drawable =
- glc_glx_pbuffer_create (screen_info->display_info->display,
- *screen_info->fbconfig, &texture,
- render_texture);
-
- if (!screen_info->pbuffer_drawable) {
- /* Couldn't create a pbuffer, offscreen drawing not supported */
- screen_info->glx_feature_mask &= ~GLC_GLX_FEATURE_PBUFFER_MASK;
- screen_info->feature_mask &= ~GLC_FEATURE_OFFSCREEN_MASK;
- }
- }
- }
-
- new_node = (glc_glx_screen_info_node_t *)
- malloc (sizeof (glc_glx_screen_info_node_t));
- new_node->next = display_info->screens;
- new_node->data = screen_info;
- display_info->screens = new_node;
return screen_info;
}
--- 215,224 ----
glc_glx_query_extensions (screen_info);
glc_glx_query_formats (screen_info);
+ screen_info->context_stack = malloc (sizeof (glc_glx_context_info_t));
+ screen_info->context_stack_size = 1;
+ screen_info->context_stack->surface = NULL;
+ screen_info->context_stack->constraint = GLC_CN_NONE;
+
return screen_info;
}
Index: glc_glx_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_surface.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** glc_glx_surface.c 3 Feb 2004 16:34:51 -0000 1.9
--- glc_glx_surface.c 5 Feb 2004 22:22:28 -0000 1.10
***************
*** 49,53 ****
static void
! _glc_glx_surface_swap_buffers (void *abstract_surface);
static glc_bool_t
--- 49,53 ----
static void
! _glc_glx_surface_show (void *abstract_surface);
static glc_bool_t
***************
*** 57,61 ****
glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
! if (constraint == GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT) {
if (surface->render_texture) {
--- 57,61 ----
glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
! if (constraint == GLC_CN_SURFACE_DRAWABLE_CURRENT) {
if (surface->render_texture) {
***************
*** 63,72 ****
_glc_glx_proc_address.glx_release_tex_image_ati
(surface->screen_info->display_info->display, surface->pbuffer,
! GLX_FRONT_LEFT_ATI);
#endif
}
! if ((!surface->pbuffer) && (!surface->drawable))
! constraint = GLC_CONSTRAINT_ANY_CONTEXT_CURRENT;
}
--- 63,72 ----
_glc_glx_proc_address.glx_release_tex_image_ati
(surface->screen_info->display_info->display, surface->pbuffer,
! (surface->format->doublebuffer)? GLX_BACK_LEFT_ATI: GLX_FRONT_LEFT_ATI);
#endif
}
! if (!surface->drawable)
! constraint = GLC_CN_ANY_CONTEXT_CURRENT;
}
***************
*** 99,103 ****
_glc_glx_surface_get_texture,
_glc_glx_surface_realize,
! _glc_glx_surface_swap_buffers
};
--- 99,103 ----
_glc_glx_surface_get_texture,
_glc_glx_surface_realize,
! _glc_glx_surface_show
};
***************
*** 134,138 ****
_glc_glx_proc_address.glx_bind_tex_image_ati
(surface->screen_info->display_info->display, surface->pbuffer,
! GLX_FRONT_LEFT_ATI);
#endif
--- 134,138 ----
_glc_glx_proc_address.glx_bind_tex_image_ati
(surface->screen_info->display_info->display, surface->pbuffer,
! (surface->format->doublebuffer)? GLX_BACK_LEFT_ATI: GLX_FRONT_LEFT_ATI);
#endif
***************
*** 159,170 ****
static glc_surface_t *
! _glc_glx_surface_create_offscreen (glc_glx_screen_info_t *screen_info,
! glc_glx_format_t *format,
! int width,
! int height)
{
glc_glx_surface_t *surface;
unsigned int texture_format;
surface = (glc_glx_surface_t *) calloc (1, sizeof (glc_glx_surface_t));
if (surface == NULL)
--- 159,175 ----
static glc_surface_t *
! _glc_glx_surface_create (glc_glx_screen_info_t *screen_info,
! glc_format_t *format,
! int width,
! int height)
{
glc_glx_surface_t *surface;
+ glc_glx_context_t *context;
unsigned int texture_format;
+ context = glc_glx_context_get (screen_info, format);
+ if (!context)
+ return NULL;
+
surface = (glc_glx_surface_t *) calloc (1, sizeof (glc_glx_surface_t));
if (surface == NULL)
***************
*** 172,177 ****
glc_surface_init (&surface->base, &glc_glx_surface_backend);
!
surface->screen_info = screen_info;
surface->format = format;
--- 177,183 ----
glc_surface_init (&surface->base, &glc_glx_surface_backend);
!
surface->screen_info = screen_info;
+ surface->context = context;
surface->format = format;
***************
*** 183,187 ****
surface->base.width = width;
surface->base.height = height;
- surface->context = glc_glx_context_get_default (screen_info);
texture_format = glc_surface_get_texture_format (&surface->base);
--- 189,192 ----
***************
*** 192,198 ****
surface->base.requires_flipping = 0;
}
!
! glc_surface_push_current (&surface->base,
! GLC_CONSTRAINT_ANY_CONTEXT_CURRENT);
surface->texture =
--- 197,202 ----
surface->base.requires_flipping = 0;
}
!
! glc_surface_push_current (&surface->base, GLC_CN_ANY_CONTEXT_CURRENT);
surface->texture =
***************
*** 207,214 ****
if (screen_info->feature_mask & GLC_FEATURE_OFFSCREEN_MASK)
! surface->pbuffer =
glc_glx_pbuffer_create (screen_info->display_info->display,
! *screen_info->fbconfig,
! surface->texture, surface->render_texture);
if ((!surface->render_texture) && (!surface->pbuffer))
--- 211,219 ----
if (screen_info->feature_mask & GLC_FEATURE_OFFSCREEN_MASK)
! surface->drawable = surface->pbuffer =
glc_glx_pbuffer_create (screen_info->display_info->display,
! surface->context->fbconfig,
! surface->texture,
! surface->render_texture);
if ((!surface->render_texture) && (!surface->pbuffer))
***************
*** 221,243 ****
glc_surface_t *
! glc_glx_surface_create_offscreen (Display *display,
! int screen,
! glc_glx_format_t *format,
! int width,
! int height)
{
return
! _glc_glx_surface_create_offscreen (glc_glx_screen_info_get
! (display, screen),
! format, width, height);
}
! slim_hidden_def(glc_glx_surface_create_offscreen);
glc_surface_t *
glc_glx_surface_create_for_window (Display *display,
int screen,
! Window window,
! glc_glx_format_t *format)
{
glc_glx_surface_t *surface;
--- 226,248 ----
glc_surface_t *
! glc_glx_surface_create (Display *display,
! int screen,
! glc_format_t *format,
! int width,
! int height)
{
return
! _glc_glx_surface_create (glc_glx_screen_info_get
! (display, screen),
! format, width, height);
}
! slim_hidden_def(glc_glx_surface_create);
glc_surface_t *
glc_glx_surface_create_for_window (Display *display,
int screen,
! glc_format_t *format,
! Window window)
{
glc_glx_surface_t *surface;
***************
*** 285,290 ****
if (templ->screen_info->glx_feature_mask & GLC_GLX_FEATURE_PBUFFER_MASK) {
! return _glc_glx_surface_create_offscreen (templ->screen_info,
! templ->format, width, height);
}
--- 290,304 ----
if (templ->screen_info->glx_feature_mask & GLC_GLX_FEATURE_PBUFFER_MASK) {
! glc_format_t *format;
!
! if (templ->format->drawable.offscreen && templ->format->alpha)
! format = templ->format;
! else
! format = glc_format_find_standard (templ->screen_info->formats,
! templ->screen_info->n_formats,
! GLC_FORMAT_OPTION_OFFSCREEN_MASK,
! GLC_STANDARD_A8);
!
! return _glc_glx_surface_create (templ->screen_info, format, width, height);
}
***************
*** 297,302 ****
glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
! glc_surface_push_current (&surface->base,
! GLC_CONSTRAINT_ANY_CONTEXT_CURRENT);
if (surface->render_texture) {
--- 311,315 ----
glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
! glc_surface_push_current (&surface->base, GLC_CN_ANY_CONTEXT_CURRENT);
if (surface->render_texture) {
***************
*** 319,328 ****
glc_surface_pop_current (&surface->base);
! if (glXGetCurrentDrawable () ==
! ((surface->pbuffer)? surface->pbuffer: surface->drawable))
! glc_glx_context_set_default (surface->screen_info);
!
! if (surface->context)
! glc_glx_context_release (surface->context);
glc_surface_deinit (&surface->base);
--- 332,339 ----
glc_surface_pop_current (&surface->base);
! if (glXGetCurrentDrawable () == surface->drawable) {
! surface->drawable = None;
! glc_glx_context_make_current (surface);
! }
glc_surface_deinit (&surface->base);
***************
*** 337,341 ****
glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
! if (surface->drawable) {
_glc_glx_surface_realize_window
(surface->screen_info->display_info->display, surface->drawable,
--- 348,352 ----
glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
! if ((! surface->pbuffer) && surface->drawable) {
_glc_glx_surface_realize_window
(surface->screen_info->display_info->display, surface->drawable,
***************
*** 345,358 ****
static void
! _glc_glx_surface_swap_buffers (void *abstract_surface)
{
glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
! if (!surface->drawable)
return;
! glc_glx_context_push_current (surface,
! GLC_CONSTRAINT_SURFACE_CONTEXT_CURRENT);
!
if (surface->format->doublebuffer)
glXSwapBuffers (surface->screen_info->display_info->display,
--- 356,368 ----
static void
! _glc_glx_surface_show (void *abstract_surface)
{
glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
! if (surface->pbuffer || (!surface->drawable))
return;
! glc_glx_context_push_current (surface, GLC_CN_SURFACE_CONTEXT_CURRENT);
!
if (surface->format->doublebuffer)
glXSwapBuffers (surface->screen_info->display_info->display,
Index: glc_rect.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_rect.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glc_rect.c 3 Feb 2004 15:12:11 -0000 1.6
--- glc_rect.c 5 Feb 2004 22:22:28 -0000 1.7
***************
*** 76,81 ****
return;
! if (!glc_surface_push_current
! (dst, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (dst);
return;
--- 76,80 ----
return;
! if (!glc_surface_push_current (dst, GLC_CN_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (dst);
return;
***************
*** 85,88 ****
--- 84,92 ----
glColor4us (color->red, color->green, color->blue, color->alpha);
+
+ glColorMask (dst->red? 1: 0,
+ dst->green? 1: 0,
+ dst->blue? 1: 0,
+ dst->alpha? 1: 0);
glc_set_operator (op);
***************
*** 97,100 ****
--- 101,106 ----
glEnd ();
+ glColorMask (1, 1, 1, 1);
+
glc_surface_dirty (dst, &bounds);
glc_surface_pop_current (dst);
***************
*** 116,121 ****
return;
! if (!glc_surface_push_current
! (dst, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (dst);
return;
--- 122,126 ----
return;
! if (!glc_surface_push_current (dst, GLC_CN_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (dst);
return;
***************
*** 125,128 ****
--- 130,138 ----
glColor4us (color->red, color->green, color->blue, color->alpha);
+
+ glColorMask (dst->red? 1: 0,
+ dst->green? 1: 0,
+ dst->blue? 1: 0,
+ dst->alpha? 1: 0);
glc_set_operator (op);
***************
*** 138,141 ****
--- 148,153 ----
glEnd ();
+
+ glColorMask (1, 1, 1, 1);
glc_surface_dirty (dst, &bounds);
Index: glc_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_surface.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** glc_surface.c 3 Feb 2004 15:12:11 -0000 1.9
--- glc_surface.c 5 Feb 2004 22:22:28 -0000 1.10
***************
*** 194,202 ****
void
! glc_surface_swap_buffers (glc_surface_t *surface)
{
! surface->backend->swap_buffers (surface);
}
! slim_hidden_def(glc_surface_swap_buffers);
int
--- 194,202 ----
void
! glc_surface_show (glc_surface_t *surface)
{
! surface->backend->show (surface);
}
! slim_hidden_def(glc_surface_show);
int
***************
*** 324,329 ****
area requested. I think it can be fixed with glPixelStore parameters. */
! if (glc_surface_push_current
! (surface, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
rowstride = surface->width * pixelsize;
rowstride += (rowstride % 4)? (4 - (rowstride % 4)): 0;
--- 324,328 ----
area requested. I think it can be fixed with glPixelStore parameters. */
! if (glc_surface_push_current (surface, GLC_CN_SURFACE_DRAWABLE_CURRENT)) {
rowstride = surface->width * pixelsize;
rowstride += (rowstride % 4)? (4 - (rowstride % 4)): 0;
***************
*** 396,401 ****
! if (glc_surface_push_current
! (surface, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
glc_region_box_t bounds;
--- 395,399 ----
! if (glc_surface_push_current (surface, GLC_CN_SURFACE_DRAWABLE_CURRENT)) {
glc_region_box_t bounds;
***************
*** 510,515 ****
glc_surface_gl_begin (glc_surface_t *surface)
{
! if (!glc_surface_push_current (surface,
! GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT))
glc_surface_status_add (surface, GLC_STATUS_NOT_SUPPORTED_MASK);
}
--- 508,512 ----
glc_surface_gl_begin (glc_surface_t *surface)
{
! if (!glc_surface_push_current (surface, GLC_CN_SURFACE_DRAWABLE_CURRENT))
glc_surface_status_add (surface, GLC_STATUS_NOT_SUPPORTED_MASK);
}
Index: glc_texture.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_texture.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** glc_texture.c 3 Feb 2004 15:12:11 -0000 1.5
--- glc_texture.c 5 Feb 2004 22:22:28 -0000 1.6
***************
*** 269,274 ****
return;
! glc_surface_push_current
! (surface, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT);
glc_texture_bind (texture);
--- 269,273 ----
return;
! glc_surface_push_current (surface, GLC_CN_SURFACE_DRAWABLE_CURRENT);
glc_texture_bind (texture);
Index: glc_trap.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_trap.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** glc_trap.c 3 Feb 2004 15:12:11 -0000 1.7
--- glc_trap.c 5 Feb 2004 22:22:28 -0000 1.8
***************
*** 191,196 ****
mask->implicit_mask = 1;
! if (!glc_surface_push_current
! (mask, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (mask);
return;
--- 191,195 ----
mask->implicit_mask = 1;
! if (!glc_surface_push_current (mask, GLC_CN_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (mask);
return;
***************
*** 315,323 ****
return;
! if (!glc_surface_push_current
! (dst, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (dst);
return;
}
glc_set_operator (op);
--- 314,326 ----
return;
! if (!glc_surface_push_current (dst, GLC_CN_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (dst);
return;
}
+
+ glColorMask (dst->red? 1: 0,
+ dst->green? 1: 0,
+ dst->blue? 1: 0,
+ dst->alpha? 1: 0);
glc_set_operator (op);
***************
*** 382,387 ****
glEnd ();
!
glShadeModel (GL_FLAT);
glc_surface_dirty (dst, &bounds);
--- 385,391 ----
glEnd ();
!
glShadeModel (GL_FLAT);
+ glColorMask (1, 1, 1, 1);
glc_surface_dirty (dst, &bounds);
Index: glc_tri.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_tri.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** glc_tri.c 3 Feb 2004 15:12:11 -0000 1.7
--- glc_tri.c 5 Feb 2004 22:22:28 -0000 1.8
***************
*** 119,124 ****
mask->implicit_mask = 1;
! if (!glc_surface_push_current
! (mask, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (mask);
return;
--- 119,123 ----
mask->implicit_mask = 1;
! if (!glc_surface_push_current (mask, GLC_CN_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (mask);
return;
***************
*** 237,242 ****
mask->implicit_mask = 1;
! if (!glc_surface_push_current
! (mask, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (mask);
return;
--- 236,240 ----
mask->implicit_mask = 1;
! if (!glc_surface_push_current (mask, GLC_CN_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (mask);
return;
***************
*** 350,355 ****
mask->implicit_mask = 1;
! if (!glc_surface_push_current
! (mask, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (mask);
return;
--- 348,352 ----
mask->implicit_mask = 1;
! if (!glc_surface_push_current (mask, GLC_CN_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (mask);
return;
***************
*** 475,484 ****
return;
! if (!glc_surface_push_current
! (dst, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (dst);
return;
}
glc_set_operator (op);
--- 472,485 ----
return;
! if (!glc_surface_push_current (dst, GLC_CN_SURFACE_DRAWABLE_CURRENT)) {
glc_surface_pop_current (dst);
return;
}
+ glColorMask (dst->red? 1: 0,
+ dst->green? 1: 0,
+ dst->blue? 1: 0,
+ dst->alpha? 1: 0);
+
glc_set_operator (op);
***************
*** 525,528 ****
--- 526,530 ----
glShadeModel (GL_FLAT);
+ glColorMask (1, 1, 1, 1);
glc_surface_dirty (dst, &bounds);
Index: glcint.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glcint.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** glcint.h 3 Feb 2004 15:12:11 -0000 1.11
--- glcint.h 5 Feb 2004 22:22:28 -0000 1.12
***************
*** 76,83 ****
typedef enum {
! GLC_CONSTRAINT_NONE,
! GLC_CONSTRAINT_ANY_CONTEXT_CURRENT,
! GLC_CONSTRAINT_SURFACE_CONTEXT_CURRENT,
! GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT
} glc_constraint_t;
--- 76,83 ----
typedef enum {
! GLC_CN_NONE,
! GLC_CN_ANY_CONTEXT_CURRENT,
! GLC_CN_SURFACE_CONTEXT_CURRENT,
! GLC_CN_SURFACE_DRAWABLE_CURRENT
} glc_constraint_t;
***************
*** 135,139 ****
void
! (*swap_buffers) (void *surface);
} glc_surface_backend_t;
--- 135,139 ----
void
! (*show) (void *surface);
} glc_surface_backend_t;
***************
*** 275,278 ****
--- 275,290 ----
glc_status_pop_from_mask (long int *mask);
+ extern glc_format_t *__internal_linkage
+ glc_format_find (glc_format_t *formats,
+ int n_formats,
+ unsigned long mask,
+ const glc_format_t *templ,
+ int count);
+
+ extern glc_format_t *__internal_linkage
+ glc_format_find_standard (glc_format_t *formats,
+ int n_formats,
+ unsigned long options,
+ glc_format_name_t format_name);
#define MAXSHORT SHRT_MAX
***************
*** 340,344 ****
slim_hidden_proto(glc_surface_get_height)
slim_hidden_proto(glc_surface_realize)
! slim_hidden_proto(glc_surface_swap_buffers)
slim_hidden_proto(glc_surface_get_pixelsize)
slim_hidden_proto(glc_surface_read_pixels)
--- 352,356 ----
slim_hidden_proto(glc_surface_get_height)
slim_hidden_proto(glc_surface_realize)
! slim_hidden_proto(glc_surface_show)
slim_hidden_proto(glc_surface_get_pixelsize)
slim_hidden_proto(glc_surface_read_pixels)
***************
*** 368,373 ****
#endif
- #define GLC_GLX_MULTISAMPLE_MAX_SAMPLES 8
-
#define GLC_GLX_FEATURE_FBCONFIG_MASK (1L << 0)
#define GLC_GLX_FEATURE_PBUFFER_MASK (1L << 1)
--- 380,383 ----
***************
*** 379,383 ****
typedef struct _glc_glx_surface glc_glx_surface_t;
! typedef struct _glc_glx_screen_info glc_glx_screen_info_t;
typedef struct _glc_glx_proc_address_list_t {
--- 389,394 ----
typedef struct _glc_glx_surface glc_glx_surface_t;
! typedef struct _glc_glx_screen_info_t glc_glx_screen_info_t;
! typedef struct _glc_glx_display_info_t glc_glx_display_info_t;
typedef struct _glc_glx_proc_address_list_t {
***************
*** 391,415 ****
} glc_glx_proc_address_list_t;
- typedef struct _glc_glx_list_node_t {
- struct _glc_glx_list_node_t *next;
- void *data;
- } glc_glx_screen_info_node_t,
- glc_glx_display_info_node_t,
- glc_glx_format_node_t,
- glc_glx_context_node_t;
-
typedef struct _glc_glx_thread_info_t {
! glc_glx_display_info_node_t *displays;
! long int status_mask;
} glc_glx_thread_info_t;
! typedef struct _glc_glx_display_info_t {
glc_glx_thread_info_t *thread_info;
Display *display;
! glc_glx_screen_info_node_t *screens;
! } glc_glx_display_info_t;
typedef struct _glc_glx_context_info_t {
- struct _glc_glx_context_info_t *previous;
glc_glx_surface_t *surface;
glc_constraint_t constraint;
--- 402,418 ----
} glc_glx_proc_address_list_t;
typedef struct _glc_glx_thread_info_t {
! glc_glx_display_info_t **displays;
! int n_displays;
} glc_glx_thread_info_t;
! struct _glc_glx_display_info_t {
glc_glx_thread_info_t *thread_info;
Display *display;
! glc_glx_screen_info_t **screens;
! int n_screens;
! };
typedef struct _glc_glx_context_info_t {
glc_glx_surface_t *surface;
glc_constraint_t constraint;
***************
*** 418,437 ****
typedef struct _glc_glx_context_t {
GLXContext context;
! unsigned int ref_count;
! glc_glx_screen_info_t *screen_info;
! VisualID visualid;
} glc_glx_context_t;
! struct _glc_glx_screen_info {
glc_glx_display_info_t *display_info;
int screen;
! glc_glx_format_node_t *formats;
! glc_glx_context_node_t *contexts;
glc_glx_context_info_t *context_stack;
! GLXFBConfig *fbconfig;
! glc_glx_context_t texture_context;
! glc_glx_context_t pbuffer_context;
! GLXDrawable texture_drawable;
! GLXDrawable pbuffer_drawable;
long int feature_mask;
long int glx_feature_mask;
--- 421,445 ----
typedef struct _glc_glx_context_t {
GLXContext context;
! XID id;
! GLXFBConfig fbconfig;
} glc_glx_context_t;
! struct _glc_glx_screen_info_t {
glc_glx_display_info_t *display_info;
int screen;
!
! glc_format_t *formats;
! XID *format_ids;
! int n_formats;
!
! glc_glx_context_t **contexts;
! int n_contexts;
!
glc_glx_context_info_t *context_stack;
! int context_stack_size;
!
! glc_glx_context_t root_context;
! GLXDrawable root_drawable;
!
long int feature_mask;
long int glx_feature_mask;
***************
*** 444,448 ****
glc_glx_screen_info_t *screen_info;
glc_glx_context_t *context;
! glc_glx_format_t *format;
glc_texture_t *texture;
GLXDrawable drawable;
--- 452,456 ----
glc_glx_screen_info_t *screen_info;
glc_glx_context_t *context;
! glc_format_t *format;
glc_texture_t *texture;
GLXDrawable drawable;
***************
*** 466,470 ****
extern glc_glx_context_t *__internal_linkage
glc_glx_context_get (glc_glx_screen_info_t *screen_info,
! glc_glx_format_t *format);
extern glc_glx_context_t *__internal_linkage
--- 474,478 ----
extern glc_glx_context_t *__internal_linkage
glc_glx_context_get (glc_glx_screen_info_t *screen_info,
! glc_format_t *format);
extern glc_glx_context_t *__internal_linkage
***************
*** 472,488 ****
extern void __internal_linkage
! glc_glx_context_release (glc_glx_context_t *context);
! extern glc_glx_surface_t * __internal_linkage
glc_glx_context_push_current (glc_glx_surface_t *surface,
glc_constraint_t constraint);
! extern glc_glx_surface_t * __internal_linkage
glc_glx_context_pop_current (glc_glx_surface_t *surface);
extern void __internal_linkage
- glc_glx_context_set_default (glc_glx_screen_info_t *screen_info);
-
- extern void __internal_linkage
glc_glx_query_formats (glc_glx_screen_info_t *screen_info);
--- 480,493 ----
extern void __internal_linkage
! glc_glx_context_make_current (glc_glx_surface_t *surface);
! extern glc_glx_surface_t *__internal_linkage
glc_glx_context_push_current (glc_glx_surface_t *surface,
glc_constraint_t constraint);
! extern glc_glx_surface_t *__internal_linkage
glc_glx_context_pop_current (glc_glx_surface_t *surface);
extern void __internal_linkage
glc_glx_query_formats (glc_glx_screen_info_t *screen_info);
***************
*** 501,508 ****
slim_hidden_proto(glc_glx_initialize)
slim_hidden_proto(glc_glx_features)
! slim_hidden_proto(glc_glx_find_visual_format)
slim_hidden_proto(glc_glx_find_standard_format)
! slim_hidden_proto(glc_glx_format_get_visual_info)
! slim_hidden_proto(glc_glx_surface_create_offscreen)
slim_hidden_proto(glc_glx_surface_create_for_window)
--- 506,513 ----
slim_hidden_proto(glc_glx_initialize)
slim_hidden_proto(glc_glx_features)
! slim_hidden_proto(glc_glx_find_format)
slim_hidden_proto(glc_glx_find_standard_format)
! slim_hidden_proto(glc_glx_get_visual_info_from_format)
! slim_hidden_proto(glc_glx_surface_create)
slim_hidden_proto(glc_glx_surface_create_for_window)
***************
*** 517,522 ****
#include <AGL/agl.h>
- #define GLC_AGL_MULTISAMPLE_MAX_SAMPLES 8
-
#define GLC_AGL_FEATURE_PBUFFER_MASK (1L << 0)
#define GLC_AGL_FEATURE_TEXTURE_RECTANGLE_MASK (1L << 1)
--- 522,525 ----
***************
*** 524,538 ****
#define GLC_AGL_FEATURE_MULTISAMPLE_FILTER_MASK (1L << 3)
! typedef struct _glc_agl_surface glc_agl_surface_t;
! typedef struct _glc_agl_thread_info glc_agl_thread_info_t;
!
! typedef struct _glc_agl_list_node_t {
! struct _glc_agl_list_node_t *next;
! void *data;
! } glc_agl_format_node_t,
! glc_agl_context_node_t;
typedef struct _glc_agl_context_info_t {
- struct _glc_agl_context_info_t *previous;
glc_agl_surface_t *surface;
glc_constraint_t constraint;
--- 527,533 ----
#define GLC_AGL_FEATURE_MULTISAMPLE_FILTER_MASK (1L << 3)
! typedef struct _glc_agl_surface_t glc_agl_surface_t;
typedef struct _glc_agl_context_info_t {
glc_agl_surface_t *surface;
glc_constraint_t constraint;
***************
*** 541,567 ****
typedef struct _glc_agl_context_t {
AGLContext context;
! unsigned int ref_count;
! glc_agl_thread_info_t *thread_info;
! glc_agl_format_id_t formatid;
} glc_agl_context_t;
! struct _glc_agl_thread_info {
! glc_agl_format_node_t *formats;
! glc_agl_context_node_t *contexts;
glc_agl_context_info_t *context_stack;
! glc_agl_context_t texture_context;
! glc_agl_context_t pbuffer_context;
! long int status_mask;
! long int agl_feature_mask;
long int feature_mask;
long int texture_mask;
! };
! struct _glc_agl_surface {
glc_surface_t base;
glc_agl_thread_info_t *thread_info;
glc_agl_context_t *context;
! glc_agl_format_t *format;
glc_texture_t *texture;
AGLDrawable drawable;
--- 536,567 ----
typedef struct _glc_agl_context_t {
AGLContext context;
! AGLPixelFormat pixel_format;
! glc_bool_t offscreen;
} glc_agl_context_t;
! typedef struct _glc_agl_thread_info_t {
! glc_format_t *formats;
! AGLPixelFormat *format_ids;
! int n_formats;
!
! glc_agl_context_t **contexts;
! int n_contexts;
!
glc_agl_context_info_t *context_stack;
! int context_stack_size;
!
! glc_agl_context_t root_context;
!
long int feature_mask;
+ long int agl_feature_mask;
long int texture_mask;
! } glc_agl_thread_info_t;
! struct _glc_agl_surface_t {
glc_surface_t base;
glc_agl_thread_info_t *thread_info;
glc_agl_context_t *context;
! glc_format_t *format;
glc_texture_t *texture;
AGLDrawable drawable;
***************
*** 576,593 ****
glc_agl_thread_info_get (void);
- extern void __internal_linkage
- glc_agl_context_create (glc_agl_thread_info_t *thread_info,
- AGLContext *context,
- GLint *attrib);
-
extern glc_agl_context_t *__internal_linkage
glc_agl_context_get (glc_agl_thread_info_t *thread_info,
! glc_agl_format_t *format);
!
! extern glc_agl_context_t *__internal_linkage
! glc_agl_context_get_default (glc_agl_thread_info_t *thread_info);
extern void __internal_linkage
! glc_agl_context_release (glc_agl_context_t *context);
extern glc_agl_surface_t *__internal_linkage
--- 576,586 ----
glc_agl_thread_info_get (void);
extern glc_agl_context_t *__internal_linkage
glc_agl_context_get (glc_agl_thread_info_t *thread_info,
! glc_format_t *format,
! glc_bool_t offscreen);
extern void __internal_linkage
! glc_agl_context_make_current (glc_agl_surface_t *surface);
extern glc_agl_surface_t *__internal_linkage
***************
*** 599,609 ****
extern void __internal_linkage
- glc_agl_context_set_default (glc_agl_thread_info_t *thread_info);
-
- extern void __internal_linkage
glc_agl_query_formats (glc_agl_thread_info_t *thread_info);
extern AGLPbuffer __internal_linkage
! glc_agl_pbuffer_create (glc_texture_t *texture);
extern void __internal_linkage
--- 592,606 ----
extern void __internal_linkage
glc_agl_query_formats (glc_agl_thread_info_t *thread_info);
extern AGLPbuffer __internal_linkage
! glc_agl_pbuffer_create (glc_texture_t *texture,
! glc_format_t *format);
!
! extern void __internal_linkage
! glc_agl_pbuffer_bind (AGLPbuffer pbuffer,
! AGLContext context,
! glc_texture_t *texture,
! glc_format_t *format);
extern void __internal_linkage
***************
*** 615,620 ****
slim_hidden_proto(glc_agl_initialize)
slim_hidden_proto(glc_agl_features)
slim_hidden_proto(glc_agl_find_standard_format)
! slim_hidden_proto(glc_agl_surface_create_offscreen)
slim_hidden_proto(glc_agl_surface_create_for_window)
--- 612,618 ----
slim_hidden_proto(glc_agl_initialize)
slim_hidden_proto(glc_agl_features)
+ slim_hidden_proto(glc_agl_find_format)
slim_hidden_proto(glc_agl_find_standard_format)
! slim_hidden_proto(glc_agl_surface_create)
slim_hidden_proto(glc_agl_surface_create_for_window)
More information about the cairo-commit
mailing list