[cairo-commit] libglc/src glc_agl_context.c,NONE,1.1 glc_agl_extension.c,NONE,1.1 glc_agl_format.c,NONE,1.1 glc_agl_info.c,NONE,1.1 glc_agl_pbuffer.c,NONE,1.1 glc_agl_surface.c,NONE,1.1 Makefile.am,1.5,1.6 glc-features.h.in,1.1,1.2 glc.c,1.11,1.12 glc.h,1.6,1.7 glc_glx_context.c,1.5,1.6 glc_glx_extension.c,1.3,1.4 glc_glx_format.c,1.4,1.5 glc_glx_info.c,1.5,1.6 glc_glx_pbuffer.c,1.3,1.4 glc_glx_surface.c,1.7,1.8 glc_rect.c,1.5,1.6 glc_surface.c,1.8,1.9 glc_texture.c,1.4,1.5 glc_trap.c,1.6,1.7 glc_tri.c,1.6,1.7 glc_util.c,1.5,1.6 glcint.h,1.10,1.11
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-serv11261/src
Modified Files:
Makefile.am glc-features.h.in glc.c glc.h glc_glx_context.c
glc_glx_extension.c glc_glx_format.c glc_glx_info.c
glc_glx_pbuffer.c glc_glx_surface.c glc_rect.c glc_surface.c
glc_texture.c glc_trap.c glc_tri.c glc_util.c glcint.h
Added Files:
glc_agl_context.c glc_agl_extension.c glc_agl_format.c
glc_agl_info.c glc_agl_pbuffer.c glc_agl_surface.c
Log Message:
Restructuring of internal rendering model, AGL backend added
--- NEW FILE: glc_agl_context.c ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: glc_agl_extension.c ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: glc_agl_format.c ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: glc_agl_info.c ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: glc_agl_pbuffer.c ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: glc_agl_surface.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.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Makefile.am 13 Dec 2003 10:44:41 -0000 1.5
--- Makefile.am 3 Feb 2004 15:12:11 -0000 1.6
***************
*** 14,17 ****
--- 14,29 ----
endif
+ if LIBGLC_HAS_AGL_BACKEND
+ libglc_agl_sources = \
+ glc_agl_surface.c \
+ glc_agl_format.c \
+ glc_agl_info.c \
+ glc_agl_extension.c \
+ glc_agl_context.c \
+ glc_agl_pbuffer.c
+ else
+ libglc_agl_sources =
+ endif
+
libglc_la_SOURCES = \
glc.c \
***************
*** 27,35 ****
glc_util.c \
$(libglc_glx_sources) \
glcint.h
libglc_la_LDFLAGS = -version-info @VERSION_INFO@
! INCLUDES = $(LIBGLC_CFLAGS) $(GL_CFLAGS) $(GLX_CFLAGS)
! libglc_la_LIBADD = $(LIBGLC_LIBS) $(GL_LIBS) $(GLX_LIBS) -lm
--- 39,48 ----
glc_util.c \
$(libglc_glx_sources) \
+ $(libglc_agl_sources) \
glcint.h
libglc_la_LDFLAGS = -version-info @VERSION_INFO@
! INCLUDES = $(GLX_CFLAGS) $(AGL_CFLAGS)
! libglc_la_LIBADD = $(GLX_LIBS) $(AGL_LIBS) -lm
Index: glc-features.h.in
===================================================================
RCS file: /cvs/cairo/libglc/src/glc-features.h.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** glc-features.h.in 5 Dec 2003 21:57:19 -0000 1.1
--- glc-features.h.in 3 Feb 2004 15:12:11 -0000 1.2
***************
*** 31,33 ****
--- 31,35 ----
#define @GLX_BACKEND_FEATURE@
+ #define @AGL_BACKEND_FEATURE@
+
#endif
Index: glc.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** glc.c 9 Dec 2003 19:50:45 -0000 1.11
--- glc.c 3 Feb 2004 15:12:11 -0000 1.12
***************
*** 95,111 ****
int height)
{
! glc_surface_t *intermediate = NULL, *mask_intermediate = NULL;
! GLuint dst_texture = 0, texture = 0;
! int texture_width, texture_height, dst_height = 0;
! double width_factor, height_factor;
glc_point_t tl, bl, br, tr;
! glc_region_box_t ibounds, clip;
! int x_draw_offset = 0, y_draw_offset = 0;
if (mask) {
- glc_surface_t *mask_surface;
glc_region_box_t mask_bounds;
! if (mask->type != GLC_SURFACE_PBUFFER_TYPE) {
glc_region_box_t bounds;
--- 95,107 ----
int height)
{
! glc_surface_t *intermediate = NULL, *mask_surface;
! glc_texture_t *texture;
glc_point_t tl, bl, br, tr;
! glc_region_box_t clip;
if (mask) {
glc_region_box_t mask_bounds;
! if (!mask->implicit_mask) {
glc_region_box_t bounds;
***************
*** 122,136 ****
return;
! mask_surface = mask_intermediate =
! glc_surface_create_intermediate (src,
! mask_bounds.x2 -
! mask_bounds.x1,
! mask_bounds.y2 -
! mask_bounds.y1);
if (!mask_surface) {
! glc_surface_status_add (src, GLC_STATUS_NOT_SUPPORTED_MASK);
return;
}
!
glc_composite (GLC_OPERATOR_SRC,
mask, NULL, mask_surface,
--- 118,133 ----
return;
! mask_surface = intermediate =
! glc_surface_create_similar (dst,
! mask_bounds.x2 -
! mask_bounds.x1,
! mask_bounds.y2 -
! mask_bounds.y1);
if (!mask_surface) {
! glc_surface_status_add (dst, GLC_STATUS_NOT_SUPPORTED_MASK);
return;
}
!
! glc_surface_disable_transform (mask);
glc_composite (GLC_OPERATOR_SRC,
mask, NULL, mask_surface,
***************
*** 138,141 ****
--- 135,140 ----
mask_surface->width,
mask_surface->height);
+ glc_surface_enable_transform (mask);
+
} else
mask_surface = mask;
***************
*** 147,244 ****
src, NULL, mask_surface,
x_src, y_src, 0, 0, 0, 0,
! mask_surface->width, mask_surface->height);
src = mask_surface;
x_src = y_src = 0;
}
-
- if (dst->type == GLC_SURFACE_TEXTURE_TYPE) {
- glc_region_box_t bounds;
-
- bounds.x1 = x_dst;
- bounds.x2 = x_dst + width;
- bounds.y1 = y_dst;
- bounds.y2 = y_dst + height;
-
- glc_intermediate_bounds (dst, &bounds, &ibounds,
- &x_draw_offset, &y_draw_offset);
-
- if (ibounds.x2 - ibounds.x1 <= 0 || ibounds.y2 - ibounds.y1 <= 0)
- return;
-
- intermediate =
- glc_surface_create_intermediate (dst,
- ibounds.x2 - ibounds.x1,
- ibounds.y2 - ibounds.y1);
- if (!intermediate) {
- glc_surface_status_add (dst, GLC_STATUS_NOT_SUPPORTED_MASK);
- if (mask_intermediate)
- glc_surface_destroy (mask_intermediate);
- return;
- }
! glc_surface_disable_transform_and_repeat (dst);
! glc_composite (GLC_OPERATOR_SRC,
! dst,
! NULL,
! intermediate,
! ibounds.x1, ibounds.y1,
! 0, 0,
! 0, 0,
! intermediate->width, intermediate->height);
! glc_surface_enable_transform_and_repeat (dst);
! dst_texture = dst->texture;
! dst_height = dst->height;
!
! dst = intermediate;
}
! glc_surface_push_current (dst);
!
! if (src->type == GLC_SURFACE_TEXTURE_TYPE) {
! glBindTexture (GL_TEXTURE_2D, src->texture);
! texture_width = src->real_width;
! texture_height = src->real_height;
! } else {
! texture = glc_texture_create (src->width, src->height,
! glc_surface_get_texture_format (src),
! &texture_width,
! &texture_height);
!
! glc_surface_push_current (src);
!
! glBindTexture (GL_TEXTURE_2D, texture);
! glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 0, 0,
! src->width, src->height);
! glFlush ();
!
! glc_surface_pop_current (src);
!
! glBindTexture (GL_TEXTURE_2D, texture);
! }
!
! width_factor = (double) src->width / (double) texture_width;
! height_factor = (double) src->height / (double) texture_height;
- glEnable (GL_TEXTURE_2D);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
! glDisable (GL_POLYGON_SMOOTH);
- switch (src->filter) {
- case GLC_FILTER_FAST:
- case GLC_FILTER_NEAREST:
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- break;
- case GLC_FILTER_GOOD:
- case GLC_FILTER_BEST:
- case GLC_FILTER_BILINEAR:
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- break;
- }
-
clip.x1 = x_dst;
clip.y1 = y_dst;
--- 146,170 ----
src, NULL, mask_surface,
x_src, y_src, 0, 0, 0, 0,
! mask_surface->width,
! mask_surface->height);
src = mask_surface;
x_src = y_src = 0;
}
! texture = glc_surface_get_texture (src);
! if (!glc_surface_push_current
! (dst, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
! glc_surface_pop_current (dst);
! return;
}
! glc_texture_bind (texture);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
! glc_texture_ensure_filter (texture, src->filter);
clip.x1 = x_dst;
clip.y1 = y_dst;
***************
*** 247,269 ****
glScissor (clip.x1, dst->height - (clip.y1 + height),
! clip.x2 - clip.x1, clip.y2 - clip.y1);
! glColorMask (src->red? GL_TRUE: GL_FALSE,
! src->green? GL_TRUE: GL_FALSE,
! src->blue? GL_TRUE: GL_FALSE,
! src->alpha? GL_TRUE: GL_FALSE);
glc_set_operator (op);
! if ((!src->transform) &&
! (!src->disable_transform_and_repeat) && src->repeat &&
! texture_width == src->width && texture_height == src->height) {
/* CASE 1: Repeat, no transformation and power of two sized texture,
GL can do repeat for us. */
double repeat_factor_x, repeat_factor_y;
!
! glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
! glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
!
bl.x = tl.x = x_dst;
tr.y = tl.y = y_dst;
--- 173,193 ----
glScissor (clip.x1, dst->height - (clip.y1 + height),
! width, height);
! glColorMask (src->red? 1: 0,
! src->green? 1: 0,
! src->blue? 1: 0,
! src->alpha? 1: 0);
glc_set_operator (op);
! if ((!src->transform) && (!src->disable_transform) &&
! src->repeat && texture->repeatable) {
/* CASE 1: Repeat, no transformation and power of two sized texture,
GL can do repeat for us. */
double repeat_factor_x, repeat_factor_y;
!
! glc_texture_ensure_repeat (texture, 1);
!
bl.x = tl.x = x_dst;
tr.y = tl.y = y_dst;
***************
*** 273,280 ****
--- 197,206 ----
/* Shift coordinates with source offset */
if (x_src) {
+ x_src = (src->width % x_src);
tl.x -= x_src;
bl.x -= x_src;
}
if (y_src) {
+ y_src = (src->height % y_src);
tl.y -= y_src;
tr.y -= y_src;
***************
*** 282,300 ****
/* Align with top left edge */
! bl.y += texture_height - (((int) (br.y - tl.y)) % texture_height);
! br.y += texture_height - (((int) (br.y - tl.y)) % texture_height);
! repeat_factor_x = (br.x - tl.x) / (double) texture_width;
! repeat_factor_y = (br.y - tl.y) / (double) texture_height;
glBegin (GL_QUADS);
glTexCoord2d (0.0, repeat_factor_y);
! glVertex2d (x_draw_offset + tl.x, y_draw_offset + tl.y);
glTexCoord2d (repeat_factor_x, repeat_factor_y);
! glVertex2d (x_draw_offset + tr.x, y_draw_offset + tr.y);
glTexCoord2d (repeat_factor_x, 0.0);
! glVertex2d (x_draw_offset + br.x, y_draw_offset + br.y);
glTexCoord2d (0.0, 0.0);
! glVertex2d (x_draw_offset + bl.x, y_draw_offset + bl.y);
glEnd ();
--- 208,226 ----
/* Align with top left edge */
! bl.y += texture->height - (((int) (br.y - tl.y)) % texture->height);
! br.y += texture->height - (((int) (br.y - tl.y)) % texture->height);
! repeat_factor_x = (br.x - tl.x) / (double) texture->width;
! repeat_factor_y = (br.y - tl.y) / (double) texture->height;
glBegin (GL_QUADS);
glTexCoord2d (0.0, repeat_factor_y);
! glVertex2d (tl.x, tl.y);
glTexCoord2d (repeat_factor_x, repeat_factor_y);
! glVertex2d (tr.x, tr.y);
glTexCoord2d (repeat_factor_x, 0.0);
! glVertex2d (br.x, br.y);
glTexCoord2d (0.0, 0.0);
! glVertex2d (bl.x, bl.y);
glEnd ();
***************
*** 303,309 ****
transformation is set. */
double save_tlx, save_trx, save_blx, save_brx;
!
! glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
! glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
bl.x = tl.x = 0;
--- 229,234 ----
transformation is set. */
double save_tlx, save_trx, save_blx, save_brx;
!
! glc_texture_ensure_repeat (texture, 0);
bl.x = tl.x = 0;
***************
*** 312,316 ****
bl.y = br.y = src->height;
! if (src->transform && (!src->disable_transform_and_repeat)) {
glc_matrix_transform_point (src->transform, &tl);
glc_matrix_transform_point (src->transform, &bl);
--- 237,241 ----
bl.y = br.y = src->height;
! if (src->transform && (!src->disable_transform)) {
glc_matrix_transform_point (src->transform, &tl);
glc_matrix_transform_point (src->transform, &bl);
***************
*** 335,338 ****
--- 260,264 ----
/* Shift all coordinates with source offset */
if (x_src) {
+ x_src = (src->width % x_src);
tl.x -= x_src;
bl.x -= x_src;
***************
*** 341,344 ****
--- 267,271 ----
}
if (y_src) {
+ y_src = (src->height % y_src);
tl.y -= y_src;
bl.y -= y_src;
***************
*** 356,365 ****
/* Clip to original source area if repeat and transform are both
used. */
! if ((!src->disable_transform_and_repeat) &&
! src->transform && src->repeat) {
glc_region_box_t src_clip, intersect_clip;
! src_clip.x1 = x_draw_offset + tl.x;
! src_clip.y1 = y_draw_offset + tl.y;
src_clip.x2 = src_clip.x1 + src->width;
src_clip.y2 = src_clip.y1 + src->height;
--- 283,291 ----
/* Clip to original source area if repeat and transform are both
used. */
! if ((!src->disable_transform) && src->transform && src->repeat) {
glc_region_box_t src_clip, intersect_clip;
! src_clip.x1 = tl.x;
! src_clip.y1 = tl.y;
src_clip.x2 = src_clip.x1 + src->width;
src_clip.y2 = src_clip.y1 + src->height;
***************
*** 375,386 ****
glBegin (GL_QUADS);
! glTexCoord2d (0.0, height_factor);
! glVertex2d (x_draw_offset + tl.x, y_draw_offset + tl.y);
! glTexCoord2d (width_factor, height_factor);
! glVertex2d (x_draw_offset + tr.x, y_draw_offset + tr.y);
! glTexCoord2d (width_factor, 0.0);
! glVertex2d (x_draw_offset + br.x, y_draw_offset + br.y);
glTexCoord2d (0.0, 0.0);
! glVertex2d (x_draw_offset + bl.x, y_draw_offset + bl.y);
glEnd ();
--- 301,312 ----
glBegin (GL_QUADS);
! glTexCoord2d (0.0, texture->texcoord_height);
! glVertex2d (tl.x, tl.y);
! glTexCoord2d (texture->texcoord_width, texture->texcoord_height);
! glVertex2d (tr.x, tr.y);
! glTexCoord2d (texture->texcoord_width, 0.0);
! glVertex2d (br.x, br.y);
glTexCoord2d (0.0, 0.0);
! glVertex2d (bl.x, bl.y);
glEnd ();
***************
*** 390,394 ****
br.x += src->width;
! } while ((!src->disable_transform_and_repeat) && src->repeat &&
(tl.x < (x_dst + width)));
--- 316,320 ----
br.x += src->width;
! } while ((!src->disable_transform) && src->repeat &&
(tl.x < (x_dst + width)));
***************
*** 403,431 ****
br.x = save_brx;
! } while ((!src->disable_transform_and_repeat) && src->repeat &&
(tl.y < (y_dst + height)));
}
! glDisable (GL_TEXTURE_2D);
! glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
! if (texture)
! glc_texture_destroy (texture);
!
! if (intermediate) {
! glBindTexture (GL_TEXTURE_2D, dst_texture);
! glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
! ibounds.x1, dst_height - ibounds.y2,
! 0, 0,
! intermediate->width, intermediate->height);
! glFlush ();
! glc_surface_pop_current (dst);
! glc_surface_destroy (intermediate);
! } else
! glc_surface_pop_current (dst);
! if (mask_intermediate)
! glc_surface_destroy (mask_intermediate);
}
--- 329,345 ----
br.x = save_brx;
! } while ((!src->disable_transform) && src->repeat &&
(tl.y < (y_dst + height)));
}
! glColorMask (1, 1, 1, 1);
! glc_texture_unbind (texture);
! glc_surface_dirty (dst, &clip);
! glc_surface_pop_current (dst);
! if (intermediate)
! glc_surface_destroy (intermediate);
}
Index: glc.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glc.h 13 Dec 2003 02:28:44 -0000 1.6
--- glc.h 3 Feb 2004 15:12:11 -0000 1.7
***************
*** 41,47 ****
#endif
- #include <X11/extensions/render.h>
- #include <GL/gl.h>
-
/* NOTE: Must be manually synchronized with LIBGLC_VERSION in configure.in */
#define GLC_MAJOR 0
--- 41,44 ----
***************
*** 53,66 ****
#endif
- #if defined(WIN32) || defined(__CYGWIN__)
- # if defined(_GLCINT_H_)
- # define __external_linkage __declspec(dllexport)
- # else
- # define __external_linkage __declspec(dllimport)
- # endif
- #else
- # define __external_linkage
- #endif
-
typedef int glc_bool_t;
typedef int glc_fixed16_16_t;
--- 50,53 ----
***************
*** 127,144 ****
typedef enum {
! GLC_OPERATOR_CLEAR = PictOpClear,
! GLC_OPERATOR_SRC = PictOpSrc,
! GLC_OPERATOR_DST = PictOpDst,
! GLC_OPERATOR_OVER = PictOpOver,
! GLC_OPERATOR_OVER_REVERSE = PictOpOverReverse,
! GLC_OPERATOR_IN = PictOpIn,
! GLC_OPERATOR_IN_REVERSE = PictOpInReverse,
! GLC_OPERATOR_OUT = PictOpOut,
! GLC_OPERATOR_OUT_REVERSE = PictOpOutReverse,
! GLC_OPERATOR_ATOP = PictOpAtop,
! GLC_OPERATOR_ATOP_REVERSE = PictOpAtopReverse,
! GLC_OPERATOR_XOR = PictOpXor,
! GLC_OPERATOR_ADD = PictOpAdd,
! GLC_OPERATOR_SATURATE = PictOpSaturate
} glc_operator_t;
--- 114,131 ----
typedef enum {
! GLC_OPERATOR_CLEAR,
! GLC_OPERATOR_SRC,
! GLC_OPERATOR_DST,
! GLC_OPERATOR_OVER,
! GLC_OPERATOR_OVER_REVERSE,
! GLC_OPERATOR_IN,
! GLC_OPERATOR_IN_REVERSE,
! GLC_OPERATOR_OUT,
! GLC_OPERATOR_OUT_REVERSE,
! GLC_OPERATOR_ATOP,
! GLC_OPERATOR_ATOP_REVERSE,
! GLC_OPERATOR_XOR,
! GLC_OPERATOR_ADD,
! GLC_OPERATOR_SATURATE
} glc_operator_t;
***************
*** 149,154 ****
GLC_STANDARD_A1
} glc_format_name_t;
-
/* glc_status.c */
--- 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 */
***************
*** 162,166 ****
} glc_status_t;
! extern const char * __external_linkage
glc_status_string (glc_status_t status);
--- 153,157 ----
} glc_status_t;
! const char *
glc_status_string (glc_status_t status);
***************
*** 175,210 ****
} glc_polyedge_t;
! extern void __external_linkage
glc_surface_destroy (glc_surface_t *surface);
! extern void __external_linkage
glc_surface_set_transform (glc_surface_t *surface,
glc_transform_t *transform);
! extern void __external_linkage
glc_surface_set_repeat (glc_surface_t *surface,
glc_bool_t repeat);
! extern void __external_linkage
glc_surface_set_filter (glc_surface_t *surface,
glc_filter_t filter);
! extern void __external_linkage
glc_surface_set_polyedge (glc_surface_t *surface,
glc_polyedge_t polyedge);
! extern int __external_linkage
glc_surface_get_width (glc_surface_t *surface);
! extern int __external_linkage
glc_surface_get_height (glc_surface_t *surface);
! extern void __external_linkage
glc_surface_swap_buffers (glc_surface_t *surface);
! extern void __external_linkage
! glc_surface_realize (glc_surface_t *surface);
! extern void __external_linkage
glc_surface_read_pixels (glc_surface_t *surface,
int x,
--- 166,204 ----
} glc_polyedge_t;
! void
glc_surface_destroy (glc_surface_t *surface);
! void
glc_surface_set_transform (glc_surface_t *surface,
glc_transform_t *transform);
! void
glc_surface_set_repeat (glc_surface_t *surface,
glc_bool_t repeat);
! void
glc_surface_set_filter (glc_surface_t *surface,
glc_filter_t filter);
! void
glc_surface_set_polyedge (glc_surface_t *surface,
glc_polyedge_t polyedge);
! int
glc_surface_get_width (glc_surface_t *surface);
! int
glc_surface_get_height (glc_surface_t *surface);
! void
! glc_surface_realize (glc_surface_t *surface);
!
! void
glc_surface_swap_buffers (glc_surface_t *surface);
! int
! glc_surface_get_pixelsize (glc_surface_t *surface);
! void
glc_surface_read_pixels (glc_surface_t *surface,
int x,
***************
*** 214,218 ****
char *pixels);
! extern void __external_linkage
glc_surface_draw_pixels (glc_surface_t *surface,
int x,
--- 208,212 ----
char *pixels);
! void
glc_surface_draw_pixels (glc_surface_t *surface,
int x,
***************
*** 222,231 ****
char *pixels);
! extern glc_status_t __external_linkage
glc_surface_get_status (glc_surface_t *surface);
/* glc_rect.c */
! extern void __external_linkage
glc_fill_rectangle (glc_operator_t op,
glc_surface_t *dst,
--- 216,240 ----
char *pixels);
! void
! glc_surface_get_gl_texture (glc_surface_t *surface,
! unsigned int *name,
! unsigned int *target,
! double *texcoord_width,
! double *texcoord_height,
! glc_bool_t *repeatable);
!
! void
! glc_surface_gl_begin (glc_surface_t *surface);
!
! void
! glc_surface_gl_end (glc_surface_t *surface);
!
! glc_status_t
glc_surface_get_status (glc_surface_t *surface);
+
/* glc_rect.c */
! void
glc_fill_rectangle (glc_operator_t op,
glc_surface_t *dst,
***************
*** 236,240 ****
unsigned int height);
! extern void __external_linkage
glc_fill_rectangles (glc_operator_t op,
glc_surface_t *dst,
--- 245,249 ----
unsigned int height);
! void
glc_fill_rectangles (glc_operator_t op,
glc_surface_t *dst,
***************
*** 246,250 ****
/* glc_trap.c */
! extern void __external_linkage
glc_composite_trapezoids (glc_operator_t op,
glc_surface_t *src,
--- 255,259 ----
/* glc_trap.c */
! void
glc_composite_trapezoids (glc_operator_t op,
glc_surface_t *src,
***************
*** 255,259 ****
int n_traps);
! extern void __external_linkage
glc_color_trapezoids (glc_operator_t op,
glc_surface_t *dst,
--- 264,268 ----
int n_traps);
! void
glc_color_trapezoids (glc_operator_t op,
glc_surface_t *dst,
***************
*** 264,268 ****
/* glc_tri.c */
! extern void __external_linkage
glc_composite_triangles (glc_operator_t op,
glc_surface_t *src,
--- 273,277 ----
/* glc_tri.c */
! void
glc_composite_triangles (glc_operator_t op,
glc_surface_t *src,
***************
*** 273,277 ****
int n_tris);
! extern void __external_linkage
glc_composite_tri_strip (glc_operator_t op,
glc_surface_t *src,
--- 282,286 ----
int n_tris);
! void
glc_composite_tri_strip (glc_operator_t op,
glc_surface_t *src,
***************
*** 283,287 ****
! extern void __external_linkage
glc_composite_tri_fan (glc_operator_t op,
glc_surface_t *src,
--- 292,296 ----
! void
glc_composite_tri_fan (glc_operator_t op,
glc_surface_t *src,
***************
*** 292,296 ****
int n_points);
! extern void __external_linkage
glc_color_triangles (glc_operator_t op,
glc_surface_t *dst,
--- 301,305 ----
int n_points);
! void
glc_color_triangles (glc_operator_t op,
glc_surface_t *dst,
***************
*** 301,305 ****
/* glc.c */
! extern void __external_linkage
glc_composite (glc_operator_t op,
glc_surface_t *src,
--- 310,314 ----
/* glc.c */
! void
glc_composite (glc_operator_t op,
glc_surface_t *src,
***************
*** 319,336 ****
#include <X11/Xlib.h>
! #include <GL/glx.h>
!
/* glc_glx_info.c */
! extern void __external_linkage
glc_glx_initialize (Display *display,
! int screen);
!
! #define GLC_GLX_FEATURE_FBCONFIG_MASK (1L << 0)
! #define GLC_GLX_FEATURE_PBUFFER_MASK (1L << 1)
! #define GLC_GLX_FEATURE_RECTANGULAR_TEXTURE_MASK (1L << 2)
! extern long int __external_linkage
glc_glx_features (Display *display,
int screen);
--- 328,340 ----
#include <X11/Xlib.h>
! #include <X11/Xutil.h>
/* glc_glx_info.c */
! void
glc_glx_initialize (Display *display,
! int screen);
! long int
glc_glx_features (Display *display,
int screen);
***************
*** 340,378 ****
#define GLC_GLX_FORMAT_ID_MASK (1 << 0)
! #define GLC_GLX_FORMAT_TYPE_MASK (1 << 1)
! #define GLC_GLX_FORMAT_ALPHA_MASK (1 << 2)
! #define GLC_GLX_FORMAT_RED_MASK (1 << 3)
! #define GLC_GLX_FORMAT_GREEN_MASK (1 << 4)
! #define GLC_GLX_FORMAT_BLUE_MASK (1 << 5)
! #define GLC_GLX_FORMAT_DOUBLEBUFFER_MASK (1 << 6)
! #define GLC_GLX_FORMAT_STEREO_MASK (1 << 7)
! #define GLC_GLX_FORMAT_FBCONFIGID_MASK (1 << 8)
! #define GLC_GLX_FORMAT_VISUALID_MASK (1 << 9)
typedef unsigned int glc_glx_format_id_t;
!
! typedef struct {
unsigned short red;
unsigned short green;
unsigned short blue;
unsigned short alpha;
- } glc_glx_direct_format_t;
-
- typedef enum {
- GLC_GLX_FORMAT_TYPE_INDEXED = PictTypeIndexed,
- GLC_GLX_FORMAT_TYPE_DIRECT = PictTypeDirect
- } glc_glx_format_type_t;
-
- typedef struct _glc_glx_format_t {
- glc_glx_format_id_t id;
- glc_glx_format_type_t type;
- glc_glx_direct_format_t direct;
glc_bool_t doublebuffer;
- glc_bool_t stereo;
- XID fbconfigid;
VisualID visualid;
} glc_glx_format_t;
! extern glc_glx_format_t *__external_linkage
glc_glx_find_format (Display *display,
int screen,
--- 344,367 ----
#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,
***************
*** 382,388 ****
#define GLC_GLX_OPTION_DOUBLEBUFFER_MASK (1 << 0)
- #define GLC_GLX_OPTION_STEREO_MASK (1 << 1)
! extern glc_glx_format_t *__external_linkage
glc_glx_find_visual_format (Display *display,
int screen,
--- 371,376 ----
#define GLC_GLX_OPTION_DOUBLEBUFFER_MASK (1 << 0)
! glc_glx_format_t *
glc_glx_find_visual_format (Display *display,
int screen,
***************
*** 390,394 ****
Visual *visual);
! extern glc_glx_format_t *__external_linkage
glc_glx_find_standard_format (Display *display,
int screen,
--- 378,382 ----
Visual *visual);
! glc_glx_format_t *
glc_glx_find_standard_format (Display *display,
int screen,
***************
*** 396,410 ****
glc_format_name_t format_name);
! extern XVisualInfo *__external_linkage
glc_glx_format_get_visual_info (Display *display,
glc_glx_format_t *format);
!
! extern int __external_linkage
! glc_glx_format_get_pixelsize (glc_glx_format_t *format);
!
/* glc_glx_surface.c */
! extern glc_surface_t * __external_linkage
glc_glx_surface_create_offscreen (Display *display,
int screen,
--- 384,395 ----
glc_format_name_t format_name);
! XVisualInfo *
glc_glx_format_get_visual_info (Display *display,
glc_glx_format_t *format);
!
/* glc_glx_surface.c */
! glc_surface_t *
glc_glx_surface_create_offscreen (Display *display,
int screen,
***************
*** 413,417 ****
int height);
! extern glc_surface_t * __external_linkage
glc_glx_surface_create_for_window (Display *display,
int screen,
--- 398,402 ----
int height);
! glc_surface_t *
glc_glx_surface_create_for_window (Display *display,
int screen,
***************
*** 419,431 ****
glc_glx_format_t *format);
- extern void __external_linkage
- glc_glx_surface_swap_buffers (glc_surface_t *surface);
-
#endif /* LIBGLC_HAS_GLX_BACKEND */
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
! #undef __external_linkage
#endif /* GLC_H_INCLUDED */
--- 404,471 ----
glc_glx_format_t *format);
#endif /* LIBGLC_HAS_GLX_BACKEND */
+ #ifdef LIBGLC_HAS_AGL_BACKEND
+
+ #include <Carbon/Carbon.h>
+
+ /* glc_agl_info.c */
+
+ void
+ glc_agl_initialize (void);
+
+ long int
+ glc_agl_features (void);
+
+
+ /* 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 */
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
!
#endif /* GLC_H_INCLUDED */
Index: glc_glx_context.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_context.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** glc_glx_context.c 8 Dec 2003 21:03:33 -0000 1.5
--- glc_glx_context.c 3 Feb 2004 15:12:11 -0000 1.6
***************
*** 63,67 ****
context->context = glcontext;
context->screen_info = screen_info;
! context->id.visual = visualid;
context->ref_count = 1;
--- 63,67 ----
context->context = glcontext;
context->screen_info = screen_info;
! context->visualid = visualid;
context->ref_count = 1;
***************
*** 71,121 ****
}
- static glc_glx_context_t *
- _glc_glx_context_create_for_fbconfig_with_type
- (glc_glx_screen_info_t *screen_info,
- XID fbconfigid,
- glc_glx_format_type_t type,
- GLXContext share_list)
- {
- int fbconfig_count, i;
- GLXFBConfig *fbconfigs;
- glc_glx_context_t *context;
- GLXContext glcontext;
-
- fbconfigs = glXGetFBConfigs (screen_info->display_info->display,
- screen_info->screen, &fbconfig_count);
- for (i = 0; i < fbconfig_count; i++) {
- int value;
-
- glXGetFBConfigAttrib (screen_info->display_info->display,
- fbconfigs[i], GLX_FBCONFIG_ID, &value);
- if (value == (int) fbconfigid)
- break;
- }
-
- if (i == fbconfig_count) {
- if (fbconfigs)
- XFree (fbconfigs);
- return NULL;
- }
-
- glcontext = glXCreateNewContext (screen_info->display_info->display,
- fbconfigs[i],
- (type == GLC_GLX_FORMAT_TYPE_DIRECT) ?
- GLX_RGBA_TYPE : GLX_COLOR_INDEX_TYPE,
- share_list, 1);
-
- context = (glc_glx_context_t *) malloc (sizeof (glc_glx_context_t));
- context->context = glcontext;
- context->screen_info = screen_info;
- context->ref_count = 1;
- context->id.fb.fbid = fbconfigid;
- context->id.fb.type = type;
-
- XFree (fbconfigs);
-
- return context;
- }
-
static void
_glc_glx_context_add (glc_glx_screen_info_t *screen_info,
--- 71,74 ----
***************
*** 131,135 ****
static glc_glx_context_t *
! glc_glx_context_reference (glc_glx_context_t * context)
{
context->ref_count++;
--- 84,88 ----
static glc_glx_context_t *
! glc_glx_context_reference (glc_glx_context_t *context)
{
context->ref_count++;
***************
*** 137,145 ****
}
! #define _C(data) ((glc_glx_context_t *) data)
! static glc_glx_context_t *
! glc_glx_context_get_with_visual (glc_glx_screen_info_t *screen_info,
! VisualID visualid)
{
glc_glx_context_node_t *node = screen_info->contexts;
--- 90,98 ----
}
! #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;
***************
*** 147,178 ****
for (; node; node = node->next)
! if (_C(node->data)->id.visual == visualid)
! return glc_glx_context_reference (_C(node->data));
!
! context = _glc_glx_context_create_for_visual (screen_info, visualid,
! screen_info->root_context);
! if (context)
! _glc_glx_context_add (screen_info, context);
!
! return context;
! }
!
! static glc_glx_context_t *
! glc_glx_context_get_with_fbconfig_and_type
! (glc_glx_screen_info_t *screen_info,
! XID fbconfigid,
! glc_glx_format_type_t type)
! {
! glc_glx_context_node_t *node = screen_info->contexts;
! glc_glx_context_t *context;
!
! for (; node; node = node->next)
! if (_C(node->data)->id.fb.fbid == fbconfigid &&
! _C(node->data)->id.fb.type == type)
! return glc_glx_context_reference (_C(node->data));
!
! context = _glc_glx_context_create_for_fbconfig_with_type
! (screen_info, fbconfigid, type, screen_info->root_context);
if (context)
--- 100,109 ----
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)
***************
*** 183,195 ****
glc_glx_context_t *
! glc_glx_context_get (glc_glx_screen_info_t *screen_info,
! glc_glx_format_t *format)
{
! if (format->fbconfigid)
! return glc_glx_context_get_with_fbconfig_and_type (screen_info,
! format->fbconfigid,
! format->type);
else
! return glc_glx_context_get_with_visual (screen_info, format->visualid);
}
--- 114,123 ----
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);
}
***************
*** 209,213 ****
for (; node; node = node->next) {
! if (_C(node->data) == context)
break;
previous_node = node;
--- 137,141 ----
for (; node; node = node->next) {
! if (GLC_GLX_CONTEXT (node->data) == context)
break;
previous_node = node;
***************
*** 220,285 ****
/* Make sure context is not current */
! if (context->context == glXGetCurrentContext ())
! glXMakeCurrent (context->screen_info->display_info->display, None, NULL);
!
glXDestroyContext (context->screen_info->display_info->display,
context->context);
free (context);
free (node);
}
void
! glc_glx_context_push_current (glc_glx_context_t *context,
! glc_glx_surface_t *surface,
! GLXDrawable drawable)
{
glc_glx_screen_info_t *screen_info;
glc_glx_context_info_t *new_context_info;
! screen_info = context->screen_info;
!
new_context_info = (glc_glx_context_info_t *)
calloc (1, sizeof (glc_glx_context_info_t));
- if (screen_info->context_stack->previous == NULL) {
- screen_info->context_stack->display = NULL;
- screen_info->context_stack->drawable = None;
- screen_info->context_stack->context = NULL;
- }
-
- if (drawable) {
- new_context_info->display = context->screen_info->display_info->display;
- new_context_info->drawable = drawable;
- new_context_info->context = context->context;
- } else {
- new_context_info->display = screen_info->display_info->display;
- new_context_info->drawable = screen_info->root_drawable;
- new_context_info->context = screen_info->root_context;
- }
-
new_context_info->surface = surface;
!
new_context_info->previous = screen_info->context_stack;
screen_info->context_stack = new_context_info;
! if (screen_info->context_stack->display) {
! if (screen_info->context_stack->context != glXGetCurrentContext () ||
! screen_info->context_stack->drawable != glXGetCurrentDrawable ()) {
! glXMakeCurrent (screen_info->context_stack->display,
! screen_info->context_stack->drawable,
! screen_info->context_stack->context);
! screen_info->current_drawable = screen_info->context_stack->drawable;
! screen_info->current_context = screen_info->context_stack->context;
! }
! }
}
glc_glx_surface_t *
! glc_glx_context_pop_current (glc_glx_context_t *context)
{
glc_glx_screen_info_t *screen_info;
glc_glx_context_info_t *old_context_info = NULL;
!
! screen_info = context->screen_info;
if (screen_info->context_stack->previous) {
--- 148,269 ----
/* 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);
}
+ static void
+ glc_glx_context_set_surface_anti_aliasing (glc_glx_surface_t *surface)
+ {
+ glc_bool_t multi_sample = 0;
+
+ surface->base.anti_aliasing = 0;
+
+ if (surface->pbuffer) {
+ if (surface->screen_info->feature_mask &
+ GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK)
+ multi_sample = 1;
+ } else if (surface->screen_info->feature_mask & GLC_FEATURE_MULTISAMPLE_MASK)
+ multi_sample = 1;
+
+ if (multi_sample) {
+ if (surface->base.polyedge == GLC_POLYEDGE_SMOOTH) {
+ glEnable (GL_MULTISAMPLE_ARB);
+ surface->base.anti_aliasing = 1;
+ if (surface->screen_info->glx_feature_mask &
+ GLC_GLX_FEATURE_MULTISAMPLE_FILTER_MASK)
+ glHint (GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST);
+ } else
+ glDisable (GL_MULTISAMPLE_ARB);
+ }
+ }
+
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);
! }
!
! static void
! 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);
! break;
! }
! }
!
! glc_glx_surface_t *
! glc_glx_context_push_current (glc_glx_surface_t *surface,
! glc_constraint_t constraint)
{
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;
}
glc_glx_surface_t *
! glc_glx_context_pop_current (glc_glx_surface_t *surface)
{
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) {
***************
*** 288,305 ****
}
! if (screen_info->context_stack->display) {
! if (screen_info->context_stack->context != glXGetCurrentContext () ||
! screen_info->context_stack->drawable != glXGetCurrentDrawable ()) {
! glXMakeCurrent (screen_info->context_stack->display,
! screen_info->context_stack->drawable,
! screen_info->context_stack->context);
! screen_info->current_drawable = screen_info->context_stack->drawable;
! screen_info->current_context = screen_info->context_stack->context;
! }
! }
if (old_context_info)
free (old_context_info);
! return screen_info->context_stack->surface;
}
--- 272,286 ----
}
! 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;
}
Index: glc_glx_extension.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_extension.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glc_glx_extension.c 9 Dec 2003 19:50:45 -0000 1.3
--- glc_glx_extension.c 3 Feb 2004 15:12:11 -0000 1.4
***************
*** 38,44 ****
}, client_glx_extensions[] = {
{ "GLX_ATI_render_texture",
! GLC_GLX_FEATURE_FBCONFIG_MASK | GLC_GLX_FEATURE_PBUFFER_MASK },
{ NULL, 0 }
}, gl_extensions[] = {
{ NULL, 0 }
};
--- 38,55 ----
}, 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 }
}, gl_extensions[] = {
+
+ #if GL_EXT_texture_rectangle
+ { "GL_EXT_texture_rectangle", GLC_GLX_FEATURE_TEXTURE_RECTANGLE_MASK },
+ #elif GL_NV_texture_rectangle
+ { "GL_NV_texture_rectangle", GLC_GLX_FEATURE_TEXTURE_RECTANGLE_MASK },
+ #endif
+
+ { "GL_ARB_multisample", GLC_GLX_FEATURE_MULTISAMPLE_MASK },
+ { "GL_NV_multisample_filter_hint", GLC_GLX_FEATURE_MULTISAMPLE_FILTER_MASK },
{ NULL, 0 }
};
***************
*** 79,133 ****
glc_glx_query_extensions (glc_glx_screen_info_t *screen_info)
{
! screen_info->feature_mask = 0;
! screen_info->feature_mask |=
_glc_glx_extension_query_glx (screen_info->display_info->display,
screen_info->screen);
! screen_info->feature_mask |=
_glc_glx_extension_query_client_glx (screen_info->display_info->display);
! screen_info->feature_mask |= _glc_glx_extension_query_gl ();
!
! /* Test to make sure that fbconfigs and pbuffers are really working. */
! if (screen_info->feature_mask & GLC_GLX_FEATURE_FBCONFIG_MASK) {
! GLXFBConfig *fbconfig;
! int nelements;
!
! fbconfig = glXGetFBConfigs (screen_info->display_info->display,
! screen_info->screen,
! &nelements);
! if (fbconfig) {
! if (screen_info->feature_mask & GLC_GLX_FEATURE_PBUFFER_MASK) {
! GLXPbuffer pbuffer = None;
! int i;
! for (i = 0; i < nelements; i++) {
! int value;
!
! glXGetFBConfigAttrib (screen_info->display_info->display,
! fbconfig[i], GLX_DRAWABLE_TYPE, &value);
!
! if (value & GLX_PBUFFER_BIT) {
! pbuffer =
! glc_glx_pbuffer_create (screen_info->display_info->display,
! fbconfig[i],
! 1, 1);
! break;
! }
! }
! if (pbuffer)
! glc_glx_pbuffer_destroy (screen_info->display_info->display,
! pbuffer);
! else
! screen_info->feature_mask &= ~GLC_GLX_FEATURE_PBUFFER_MASK;
! }
! } else
! screen_info->feature_mask &=
! ~(GLC_GLX_FEATURE_FBCONFIG_MASK | GLC_GLX_FEATURE_PBUFFER_MASK);
! if (fbconfig)
! free (fbconfig);
}
}
--- 90,125 ----
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);
! screen_info->glx_feature_mask |= _glc_glx_extension_query_gl ();
! screen_info->feature_mask = 0;
! if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_PBUFFER_MASK)
! screen_info->feature_mask |= GLC_FEATURE_OFFSCREEN_MASK;
!
! if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_MULTISAMPLE_MASK &&
! screen_info->glx_feature_mask &
! GLC_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK) {
! screen_info->feature_mask |= GLC_FEATURE_MULTISAMPLE_MASK;
!
! /*
! if (strcmp ("Card supporting pbuffer multisampling",
! glGetString (GL_RENDERER)))
! screen_info->feature_mask |= GLC_FEATURE_OFFSCREEN_MULTISAMPLE_MASK;
! */
! }
! if (screen_info->glx_feature_mask &
! GLC_GLX_FEATURE_TEXTURE_RECTANGLE_MASK) {
! screen_info->texture_mask |= GLC_TEXTURE_TARGET_RECTANGLE_MASK;
! screen_info->feature_mask |= GLC_FEATURE_TEXTURE_RECTANGLE_MASK;
}
}
Index: glc_glx_format.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_format.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glc_glx_format.c 8 Dec 2003 21:03:33 -0000 1.4
--- glc_glx_format.c 3 Feb 2004 15:12:11 -0000 1.5
***************
*** 51,82 ****
}
- static XID
- _glc_get_fbconfigid (glc_glx_screen_info_t *screen_info, XVisualInfo *vinfo)
- {
- XID best_fbconfigid = None;
- Display *display = screen_info->display_info->display;
- int screen = screen_info->screen;
-
- if (screen_info->feature_mask & GLC_GLX_FEATURE_FBCONFIG_MASK) {
- int config_count, i;
- GLXFBConfig *configs;
-
- configs = glXGetFBConfigs (display, screen, &config_count);
-
- for (i = 0; i < config_count; i++) {
- int value;
- int fbconfigid;
- glXGetFBConfigAttrib (display, configs[i], GLX_FBCONFIG_ID, &fbconfigid);
- glXGetFBConfigAttrib (display, configs[i], GLX_VISUAL_ID, &value);
- if ((XID) value == vinfo->visualid) {
- best_fbconfigid = fbconfigid;
- break;
- }
- }
- }
-
- return best_fbconfigid;
- }
-
void
glc_glx_query_formats (glc_glx_screen_info_t *screen_info)
--- 51,54 ----
***************
*** 84,117 ****
Display *display = screen_info->display_info->display;
int screen = screen_info->screen;
! XVisualInfo *vinfo;
! int i, attr[11];
glc_glx_format_id_t id = 0;
glc_glx_format_t format;
! attr[0] = GLX_RGBA;
! attr[1] = GLX_RED_SIZE;
! attr[3] = GLX_GREEN_SIZE;
! attr[5] = GLX_BLUE_SIZE;
! attr[7] = GLX_ALPHA_SIZE;
! attr[9] = None;
! attr[10] = None;
for (i = 0; i <= 1; i++) {
memset (&format, 0, sizeof (glc_glx_format_t));
- format.type = GLC_GLX_FORMAT_TYPE_DIRECT;
format.doublebuffer = i;
if (format.doublebuffer)
! attr[9] = GLX_DOUBLEBUFFER;
! attr[2] = attr[4] = attr[6] = 0;
! attr[8] = 1;
vinfo = glXChooseVisual (display, screen, attr);
if (vinfo) {
! format.fbconfigid = _glc_get_fbconfigid (screen_info, vinfo);
! format.direct.red = 0;
! format.direct.green = 0;
! format.direct.blue = 0;
! format.direct.alpha = 1;
format.id = id++;
format.visualid = vinfo->visualid;
--- 56,109 ----
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;
***************
*** 122,134 ****
}
! attr[2] = attr[4] = attr[6] = 8;
! attr[8] = 0;
vinfo = glXChooseVisual (display, screen, attr);
if (vinfo) {
! format.fbconfigid = _glc_get_fbconfigid (screen_info, vinfo);
! format.direct.red = 0;
! format.direct.green = 0;
! format.direct.blue = 0;
! format.direct.alpha = 8;
format.id = id++;
format.visualid = vinfo->visualid;
--- 114,125 ----
}
! 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;
***************
*** 136,151 ****
_glc_add_format (screen_info, &format);
! format.direct.red = 8;
! format.direct.green = 8;
! format.direct.blue = 8;
! format.direct.alpha = 0;
format.id = id++;
_glc_add_format (screen_info, &format);
! format.direct.red = 8;
! format.direct.green = 8;
! format.direct.blue = 8;
! format.direct.alpha = 8;
format.id = id++;
--- 127,142 ----
_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++;
***************
*** 155,167 ****
}
! attr[8] = 8;
vinfo = glXChooseVisual (display, screen, attr);
if (vinfo) {
! format.fbconfigid = _glc_get_fbconfigid (screen_info, vinfo);
! format.direct.red = 0;
! format.direct.green = 0;
! format.direct.blue = 0;
! format.direct.alpha = 8;
format.id = id++;
format.visualid = vinfo->visualid;
--- 146,157 ----
}
! 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;
***************
*** 169,184 ****
_glc_add_format (screen_info, &format);
! format.direct.red = 8;
! format.direct.green = 8;
! format.direct.blue = 8;
! format.direct.alpha = 0;
format.id = id++;
_glc_add_format (screen_info, &format);
! format.direct.red = 8;
! format.direct.green = 8;
! format.direct.blue = 8;
! format.direct.alpha = 8;
format.id = id++;
--- 159,174 ----
_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++;
***************
*** 190,194 ****
}
! #define _F(data) ((glc_glx_format_t *) data)
glc_glx_format_t *
--- 180,184 ----
}
! #define GLC_GLX_FORMAT(data) ((glc_glx_format_t *) data)
glc_glx_format_t *
***************
*** 205,263 ****
for (; node; node = node->next) {
if (mask & GLC_GLX_FORMAT_ID_MASK)
! if (templ->id != _F(node->data)->id)
! continue;
!
! if (mask & GLC_GLX_FORMAT_TYPE_MASK)
! if (templ->type != _F(node->data)->type)
continue;
! if (mask & GLC_GLX_FORMAT_ALPHA_MASK) {
! if (_F(node->data)->type != GLC_GLX_FORMAT_TYPE_DIRECT)
! continue;
! else if (templ->direct.alpha != _F(node->data)->direct.alpha)
continue;
- }
! if (mask & GLC_GLX_FORMAT_RED_MASK) {
! if (_F(node->data)->type != GLC_GLX_FORMAT_TYPE_DIRECT)
! continue;
! else if (templ->direct.red != _F(node->data)->direct.red)
continue;
- }
! if (mask & GLC_GLX_FORMAT_GREEN_MASK) {
! if (_F(node->data)->type != GLC_GLX_FORMAT_TYPE_DIRECT)
! continue;
! else if (templ->direct.green != _F(node->data)->direct.green)
continue;
- }
! if (mask & GLC_GLX_FORMAT_BLUE_MASK) {
! if (_F(node->data)->type != GLC_GLX_FORMAT_TYPE_DIRECT)
! continue;
! else if (templ->direct.blue != _F(node->data)->direct.blue)
continue;
- }
if (mask & GLC_GLX_FORMAT_DOUBLEBUFFER_MASK)
! if (templ->doublebuffer != _F(node->data)->doublebuffer)
! continue;
!
! if (mask & GLC_GLX_FORMAT_STEREO_MASK)
! if (templ->stereo != _F(node->data)->stereo)
! continue;
!
! if (mask & GLC_GLX_FORMAT_FBCONFIGID_MASK) {
! if (templ->fbconfigid != _F(node->data)->fbconfigid)
continue;
- }
if (mask & GLC_GLX_FORMAT_VISUALID_MASK) {
! if (templ->visualid != _F(node->data)->visualid)
continue;
}
if (count-- == 0)
! return _F(node->data);
}
--- 195,228 ----
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);
}
***************
*** 275,283 ****
*mask |= GLC_GLX_FORMAT_DOUBLEBUFFER_MASK;
}
-
- if (options & GLC_GLX_OPTION_STEREO_MASK) {
- format->stereo = 1;
- *mask |= GLC_GLX_FORMAT_STEREO_MASK;
- }
}
--- 240,243 ----
***************
*** 301,304 ****
--- 261,265 ----
return glc_glx_find_format (display, screen, mask, &templ, 0);
}
+ slim_hidden_def(glc_glx_find_visual_format);
glc_glx_format_t *
***************
*** 309,342 ****
{
glc_glx_format_t templ;
! unsigned long mask = GLC_GLX_FORMAT_TYPE_MASK | GLC_GLX_FORMAT_ALPHA_MASK |
! GLC_GLX_FORMAT_RED_MASK | GLC_GLX_FORMAT_GREEN_MASK |
! GLC_GLX_FORMAT_BLUE_MASK;
- templ.type = GLC_GLX_FORMAT_TYPE_DIRECT;
-
switch (format_name) {
case GLC_STANDARD_ARGB32:
! templ.direct.alpha = 8;
! templ.direct.red = 8;
! templ.direct.green = 8;
! templ.direct.blue = 8;
break;
case GLC_STANDARD_RGB24:
! templ.direct.alpha = 0;
! templ.direct.red = 8;
! templ.direct.green = 8;
! templ.direct.blue = 8;
break;
case GLC_STANDARD_A8:
! templ.direct.alpha = 8;
! templ.direct.red = 0;
! templ.direct.green = 0;
! templ.direct.blue = 0;
break;
case GLC_STANDARD_A1:
! templ.direct.alpha = 1;
! templ.direct.red = 0;
! templ.direct.green = 0;
! templ.direct.blue = 0;
break;
}
--- 270,300 ----
{
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;
}
***************
*** 346,361 ****
return glc_glx_find_format (display, screen, mask, &templ, 0);
}
!
! int
! glc_glx_format_get_pixelsize (glc_glx_format_t *format)
! {
! if (format->type != GLC_GLX_FORMAT_TYPE_DIRECT)
! return 4;
!
! return glc_get_pixelsize_from_components (format->direct.red,
! format->direct.green,
! format->direct.blue,
! format->direct.alpha);
! }
XVisualInfo *
--- 304,308 ----
return glc_glx_find_format (display, screen, mask, &templ, 0);
}
! slim_hidden_def(glc_glx_find_standard_format);
XVisualInfo *
***************
*** 369,370 ****
--- 316,318 ----
return XGetVisualInfo(display, VisualIDMask, &templ, &nitems);
}
+ slim_hidden_def(glc_glx_format_get_visual_info);
Index: glc_glx_info.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_info.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** glc_glx_info.c 8 Dec 2003 21:03:33 -0000 1.5
--- glc_glx_info.c 3 Feb 2004 15:12:11 -0000 1.6
***************
*** 35,43 ****
NULL,
NULL,
! None,
NULL,
! NULL
};
#ifdef XTHREADS
--- 35,73 ----
NULL,
NULL,
! GLC_CONSTRAINT_NONE
! };
!
! glc_glx_proc_address_list_t _glc_glx_proc_address = {
!
! #ifdef GLX_ATI_render_texture
NULL,
! NULL,
! #endif
!
! 0
};
+ static void
+ glc_proc_address_lookup (void)
+ {
+
+ #ifdef GLX_ARB_get_proc_address
+ _glc_glx_proc_address.supported = 1;
+
+ #ifdef GLX_ATI_render_texture
+ _glc_glx_proc_address.glx_bind_tex_image_ati =
+ (PFNGLXBINDTEXIMAGEATIPROC)
+ glXGetProcAddressARB ("glXBindTexImageATI");
+ _glc_glx_proc_address.glx_release_tex_image_ati =
+ (PFNGLXRELEASETEXIMAGEATIPROC)
+ glXGetProcAddressARB ("glXReleaseTexImageATI");
+ #endif
+
+ #elif
+ _glc_glx_proc_address.supported = 0;
+ #endif
+
+ }
+
#ifdef XTHREADS
***************
*** 57,60 ****
--- 87,91 ----
info->displays = NULL;
info->status_mask = GLC_STATUS_SUCCESS;
+ glc_proc_address_lookup ();
xthread_key_create (&info_tsd, NULL);
xthread_set_specific (info_tsd, info);
***************
*** 85,89 ****
#endif
! #define _D(data) ((glc_glx_display_info_t *) data)
glc_glx_display_info_t *
--- 116,120 ----
#endif
! #define GLC_GLX_DISPLAY_INFO(data) ((glc_glx_display_info_t *) data)
glc_glx_display_info_t *
***************
*** 95,100 ****
for (; node; node = node->next)
! if (_D(node->data)->display == display)
! return _D(node->data);
display_info = (glc_glx_display_info_t *)
--- 126,131 ----
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 *)
***************
*** 113,117 ****
}
! #define _S(data) ((glc_glx_screen_info_t *) data)
glc_glx_screen_info_t *
--- 144,200 ----
}
! 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;
!
! win_attrib.colormap =
! XCreateColormap (display,
! 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 *
***************
*** 119,134 ****
int screen)
{
- Window window;
- XVisualInfo *vinfo;
int attrib[] = {
GLX_RGBA,
! GLX_RED_SIZE, 1,
! GLX_GREEN_SIZE, 1,
! GLX_BLUE_SIZE, 1,
! GLX_DOUBLEBUFFER,
! None
! };
!
! XSetWindowAttributes win_attrib;
glc_glx_screen_info_t *screen_info;
glc_glx_display_info_t *display_info = glc_glx_display_info_get (display);
--- 202,209 ----
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);
***************
*** 136,141 ****
for (; node; node = node->next)
! if (_S(node->data)->screen == screen)
! return _S(node->data);
screen_info = (glc_glx_screen_info_t *)
--- 211,216 ----
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 *)
***************
*** 145,178 ****
screen_info->formats = NULL;
screen_info->contexts = NULL;
- screen_info->current_context = NULL;
- screen_info->current_drawable = None;
screen_info->contexts = NULL;
screen_info->context_stack = &context_info_dummy;
! vinfo = glXChooseVisual (display, screen, attrib);
! if (! vinfo) {
! attrib[7] = None;
! vinfo = glXChooseVisual (display, screen, attrib);
! /* XXX: Check if vinfo != NULL */
! }
!
! win_attrib.colormap =
! XCreateColormap (display_info->display,
! RootWindow (display_info->display, screen),
! vinfo->visual, AllocNone);
! window = XCreateWindow (display_info->display,
! RootWindow (display_info->display, screen),
! -1, -1, 1, 1, 0, vinfo->depth, CopyFromParent,
! vinfo->visual, CWColormap, &win_attrib);
!
! screen_info->root_drawable = window;
! screen_info->root_context = glXCreateContext (display_info->display,
! vinfo, NULL, 1);
- XFree (vinfo);
-
glXMakeCurrent (screen_info->display_info->display,
! screen_info->root_drawable,
! screen_info->root_context);
glPixelStorei (GL_PACK_ALIGNMENT, 4);
--- 220,241 ----
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);
***************
*** 180,184 ****
glc_glx_query_extensions (screen_info);
! glc_glx_query_formats (screen_info);
new_node = (glc_glx_screen_info_node_t *)
--- 243,339 ----
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 *)
***************
*** 197,200 ****
--- 352,356 ----
glc_glx_screen_info_get (display, screen);
}
+ slim_hidden_def(glc_glx_initialize);
long int
***************
*** 207,209 ****
return screen_info->feature_mask;
}
!
--- 363,365 ----
return screen_info->feature_mask;
}
! slim_hidden_def(glc_glx_features);
Index: glc_glx_pbuffer.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_pbuffer.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glc_glx_pbuffer.c 7 Dec 2003 02:42:29 -0000 1.3
--- glc_glx_pbuffer.c 3 Feb 2004 15:12:11 -0000 1.4
***************
*** 32,90 ****
#include "glcint.h"
! static int
! _glc_pbuffer_try_size (Display *display,
! GLXFBConfig fbconfig,
! int width,
! int height,
! GLXPbuffer *return_pbuffer)
{
! GLXPbuffer pbuffer;
! unsigned int w_ok, h_ok;
! int pbuffer_attr[7];
! pbuffer_attr[0] = GLX_PBUFFER_WIDTH;
! pbuffer_attr[1] = width;
! pbuffer_attr[2] = GLX_PBUFFER_HEIGHT;
! pbuffer_attr[3] = height;
! pbuffer_attr[4] = GLX_PRESERVED_CONTENTS;
! pbuffer_attr[5] = 1;
! pbuffer_attr[6] = 0;
!
! pbuffer = glXCreatePbuffer (display, fbconfig, pbuffer_attr);
! w_ok = h_ok = 0;
! if (pbuffer) {
! glXQueryDrawable (display, pbuffer, GLX_WIDTH, &w_ok);
! glXQueryDrawable (display, pbuffer, GLX_HEIGHT, &h_ok);
! }
! if ((int) w_ok != width || (int) h_ok != height) {
! if (pbuffer)
! glXDestroyPbuffer (display, pbuffer);
! return 0;
}
-
- *return_pbuffer = pbuffer;
-
- return 1;
- }
! GLXPbuffer
! glc_glx_pbuffer_create (Display *display,
! GLXFBConfig fbconfig,
! int width,
! int height)
! {
! GLXPbuffer pbuffer;
!
! if (_glc_pbuffer_try_size (display, fbconfig, width, height,
! &pbuffer))
! return pbuffer;
!
! return None;
}
void
! glc_glx_pbuffer_destroy (Display *display, GLXPbuffer pbuffer)
{
glXDestroyPbuffer (display, pbuffer);
}
--- 32,73 ----
#include "glcint.h"
! GLXPbuffer
! glc_glx_pbuffer_create (Display *display,
! GLXFBConfig fbconfig,
! glc_texture_t *texture,
! glc_bool_t render_texture)
{
! int pbuffer_attr[13], i = 0;
! pbuffer_attr[i++] = GLX_PBUFFER_WIDTH;
! pbuffer_attr[i++] = texture->width;
! pbuffer_attr[i++] = GLX_PBUFFER_HEIGHT;
! pbuffer_attr[i++] = texture->height;
! pbuffer_attr[i++] = GLX_PRESERVED_CONTENTS;
! pbuffer_attr[i++] = 1;
! pbuffer_attr[i++] = GLX_LARGEST_PBUFFER;
! pbuffer_attr[i++] = 0;
! if (render_texture) {
!
! #ifdef GLX_ATI_render_texture
! pbuffer_attr[i++] = GLX_TEXTURE_FORMAT_ATI;
! pbuffer_attr[i++] = GLX_TEXTURE_RGBA_ATI;
! pbuffer_attr[i++] = GLX_TEXTURE_TARGET_ATI;
! pbuffer_attr[i++] = GLX_TEXTURE_2D_ATI;
! #endif
!
}
! pbuffer_attr[i++] = 0;
!
! return glXCreatePbuffer (display, fbconfig, pbuffer_attr);
}
void
! glc_glx_pbuffer_destroy (Display *display,
! GLXPbuffer pbuffer)
{
glXDestroyPbuffer (display, pbuffer);
}
+
Index: glc_glx_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_surface.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** glc_glx_surface.c 9 Dec 2003 10:35:57 -0000 1.7
--- glc_glx_surface.c 3 Feb 2004 15:12:11 -0000 1.8
***************
*** 32,56 ****
#include "glcint.h"
static glc_surface_t *
! _glc_glx_surface_create_intermediate (void *abstract_templ,
! int width,
! int height);
static void
_glc_glx_surface_destroy (void *abstract_surface);
static void
! _glc_glx_surface_push_current (void *abstract_surface)
{
! glc_glx_surface_t *surface = abstract_surface;
!
! if (surface->base.type == GLC_SURFACE_TEXTURE_TYPE)
! glc_glx_context_push_current (surface->context, surface, None);
! else
! glc_glx_context_push_current (surface->context,
! surface,
! surface->drawable);
! glc_surface_setup_environment (&surface->base);
}
--- 32,82 ----
#include "glcint.h"
+ extern glc_glx_proc_address_list_t _glc_glx_proc_address;
+
static glc_surface_t *
! _glc_glx_surface_create_similar (void *abstract_templ,
! int width,
! int height);
static void
_glc_glx_surface_destroy (void *abstract_surface);
+ static glc_texture_t *
+ _glc_glx_surface_get_texture (void *abstract_surface);
+
static void
! _glc_glx_surface_realize (void *abstract_surface);
!
! static void
! _glc_glx_surface_swap_buffers (void *abstract_surface);
!
! static glc_bool_t
! _glc_glx_surface_push_current (void *abstract_surface,
! glc_constraint_t constraint)
{
! glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
!
! if (constraint == GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT) {
! if (surface->render_texture) {
!
! #ifdef GLX_ATI_render_texture
! _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;
! }
! surface = glc_glx_context_push_current (surface, constraint);
!
! if (surface) {
! glc_surface_setup_environment (&surface->base);
! return 1;
! }
!
! return 0;
}
***************
*** 58,81 ****
_glc_glx_surface_pop_current (void *abstract_surface)
{
! glc_glx_surface_t *surface = abstract_surface;
! glc_glx_surface_t *old_surface =
! glc_glx_context_pop_current (surface->context);
! if (old_surface)
! glc_surface_setup_environment (&old_surface->base);
}
static const struct glc_surface_backend glc_glx_surface_backend = {
! _glc_glx_surface_create_intermediate,
_glc_glx_surface_destroy,
_glc_glx_surface_push_current,
! _glc_glx_surface_pop_current
};
static glc_bool_t
! _glc_glx_surface_realize (Display *display,
! Window drawable,
! int *width,
! int *height)
{
unsigned int uwidth, uheight, bwidth_ignore, depth_ignore;
--- 84,110 ----
_glc_glx_surface_pop_current (void *abstract_surface)
{
! glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
!
! surface = glc_glx_context_pop_current (surface);
! if (surface)
! glc_surface_setup_environment (&surface->base);
}
static const struct glc_surface_backend glc_glx_surface_backend = {
! _glc_glx_surface_create_similar,
_glc_glx_surface_destroy,
_glc_glx_surface_push_current,
! _glc_glx_surface_pop_current,
! _glc_glx_surface_get_texture,
! _glc_glx_surface_realize,
! _glc_glx_surface_swap_buffers
};
static glc_bool_t
! _glc_glx_surface_realize_window (Display *display,
! Window drawable,
! int *width,
! int *height)
{
unsigned int uwidth, uheight, bwidth_ignore, depth_ignore;
***************
*** 93,173 ****
}
! glc_surface_t *
! glc_glx_surface_create_offscreen (Display *display,
! int screen,
! glc_glx_format_t *format,
! int width,
! int height)
{
! glc_glx_surface_t *surface;
! glc_glx_context_t *context;
! glc_glx_screen_info_t *screen_info =
! glc_glx_screen_info_get (display, screen);
!
! 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)
! return NULL;
! glc_surface_init (&surface->base, &glc_glx_surface_backend);
!
! surface->base.type = GLC_SURFACE_TEXTURE_TYPE;
! surface->screen_info = screen_info;
! surface->format = format;
!
! if (format->type == GLC_GLX_FORMAT_TYPE_DIRECT) {
! surface->base.red = format->direct.red;
! surface->base.green = format->direct.green;
! surface->base.blue = format->direct.blue;
! surface->base.alpha = format->direct.alpha;
! } else {
! surface->base.red = surface->base.green = surface->base.blue = 1;
! surface->base.alpha = 0;
! }
!
! surface->base.width = width;
! surface->base.height = height;
! surface->context = context;
! glc_surface_push_current (&surface->base);
! surface->base.texture =
! glc_texture_create (surface->base.width,
! surface->base.height,
! glc_surface_get_texture_format (&surface->base),
! &surface->base.real_width,
! &surface->base.real_height);
!
! glc_surface_pop_current (&surface->base);
! if (surface->base.texture)
! return &surface->base;
! else
! _glc_glx_surface_destroy (surface);
! return NULL;
}
! static glc_glx_surface_t *
! _glc_glx_surface_create_for_drawable (Display *display,
! int screen,
! Drawable drawable,
! glc_glx_format_t *format)
{
glc_glx_surface_t *surface;
! glc_glx_context_t *context;
! int width, height;
! glc_glx_screen_info_t *screen_info =
! glc_glx_screen_info_get (display, screen);
!
! context = glc_glx_context_get (screen_info, format);
! if (!context)
! return NULL;
!
! if (!_glc_glx_surface_realize (display, drawable, &width, &height))
! return NULL;
surface = (glc_glx_surface_t *) calloc (1, sizeof (glc_glx_surface_t));
--- 122,169 ----
}
! static void
! _glc_glx_surface_ensure_texture (glc_glx_surface_t *surface)
{
! if (!surface->base.dirty)
! return;
! if (surface->render_texture) {
! glc_texture_bind (surface->texture);
!
! #ifdef GLX_ATI_render_texture
! _glc_glx_proc_address.glx_bind_tex_image_ati
! (surface->screen_info->display_info->display, surface->pbuffer,
! GLX_FRONT_LEFT_ATI);
! #endif
!
! glc_texture_unbind (surface->texture);
! } else
! glc_texture_copy_surface (surface->texture, &surface->base,
! &surface->base.dirty_region);
! surface->base.dirty = 0;
! }
! static glc_texture_t *
! _glc_glx_surface_get_texture (void *abstract_surface) {
! glc_glx_surface_t *surface = (glc_glx_surface_t *) abstract_surface;
!
! if (!surface->texture->allocated)
! glc_texture_allocate (surface->texture);
! _glc_glx_surface_ensure_texture (surface);
! return surface->texture;
}
! 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));
***************
*** 178,267 ****
surface->screen_info = screen_info;
- surface->context = context;
surface->format = format;
-
- if (format->type == GLC_GLX_FORMAT_TYPE_DIRECT) {
- surface->base.red = format->direct.red;
- surface->base.green = format->direct.green;
- surface->base.blue = format->direct.blue;
- surface->base.alpha = format->direct.alpha;
- } else {
- surface->base.red = surface->base.green = surface->base.blue = 1;
- surface->base.alpha = 0;
- }
! surface->base.width = surface->base.real_width = width;
! surface->base.height = surface->base.real_height = height;
! surface->drawable = drawable;
! return surface;
! }
! 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;
!
! surface = _glc_glx_surface_create_for_drawable (display, screen, window,
! format);
! if (surface) {
! surface->base.type = GLC_SURFACE_WINDOW_TYPE;
!
! if (surface->drawable)
! return &surface->base;
glc_surface_destroy (&surface->base);
}
! return NULL;
}
! static int
! _glc_get_pbuffer_valid_fbconfig (Display *display,
! int screen,
! glc_glx_format_t *format,
! GLXFBConfig **fbconfig)
{
! int nelements, value;
! int fbconfig_attr[3];
!
! fbconfig_attr[0] = GLX_FBCONFIG_ID;
! fbconfig_attr[1] = format->fbconfigid;
! fbconfig_attr[2] = 0;
!
! *fbconfig = glXChooseFBConfig (display, screen, fbconfig_attr, &nelements);
!
! if (*fbconfig) {
! glXGetFBConfigAttrib (display, **fbconfig, GLX_DRAWABLE_TYPE, &value);
! if (value & GLX_PBUFFER_BIT) {
! return 1;
! } else {
! XFree (*fbconfig);
! *fbconfig = NULL;
! }
! }
!
! return 0;
}
! static glc_surface_t *
! _glc_glx_surface_create_pbuffer (glc_glx_surface_t *templ,
! GLXFBConfig fbconfig,
! glc_glx_format_t *format,
! int width,
! int height)
{
glc_glx_surface_t *surface;
glc_glx_context_t *context;
! glc_glx_screen_info_t *screen_info = templ->screen_info;
!
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)
--- 174,257 ----
surface->screen_info = screen_info;
surface->format = format;
! surface->base.red = format->red;
! surface->base.green = format->green;
! surface->base.blue = format->blue;
! surface->base.alpha = format->alpha;
! 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);
! if (screen_info->glx_feature_mask & GLC_GLX_FEATURE_RENDER_TEXTURE_MASK) {
! surface->render_texture = 1;
! if (format->red || format->green || format->blue)
! surface->base.requires_flipping = 0;
! }
!
! glc_surface_push_current (&surface->base,
! GLC_CONSTRAINT_ANY_CONTEXT_CURRENT);
!
! surface->texture =
! glc_texture_generate (width, height,
! texture_format,
! screen_info->texture_mask);
+ if (!surface->texture) {
glc_surface_destroy (&surface->base);
+ return NULL;
}
+
+ 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))
! glc_texture_allocate (surface->texture);
!
! glc_surface_pop_current (&surface->base);
!
! return &surface->base;
}
! 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;
glc_glx_context_t *context;
! int width, height;
! glc_glx_screen_info_t *screen_info =
! glc_glx_screen_info_get (display, screen);
!
context = glc_glx_context_get (screen_info, format);
if (!context)
return NULL;
+ if (!_glc_glx_surface_realize_window (display, window, &width, &height))
+ return NULL;
+
surface = (glc_glx_surface_t *) calloc (1, sizeof (glc_glx_surface_t));
if (surface == NULL)
***************
*** 269,356 ****
glc_surface_init (&surface->base, &glc_glx_surface_backend);
!
surface->screen_info = screen_info;
surface->context = context;
surface->format = format;
-
- if (format->type == GLC_GLX_FORMAT_TYPE_DIRECT) {
- surface->base.red = format->direct.red;
- surface->base.green = format->direct.green;
- surface->base.blue = format->direct.blue;
- surface->base.alpha = format->direct.alpha;
- } else {
- surface->base.red = surface->base.green = surface->base.blue = 1;
- surface->base.alpha = 0;
- }
-
- surface->base.width = surface->base.real_width = width;
- surface->base.height = surface->base.real_height = height;
- surface->base.type = GLC_SURFACE_PBUFFER_TYPE;
! surface->drawable =
! glc_glx_pbuffer_create (screen_info->display_info->display, fbconfig,
! surface->base.width, surface->base.height);
!
! if (surface->drawable)
! return &surface->base;
! glc_surface_destroy (&surface->base);
! return NULL;
}
static glc_surface_t *
! _glc_glx_surface_create_intermediate (void *abstract_templ,
! int width,
! int height)
{
! glc_glx_surface_t *templ = abstract_templ;
! glc_surface_t *surface;
! GLXFBConfig *fbconfig;
! glc_glx_screen_info_t *screen_info = templ->screen_info;
! Display *display = templ->screen_info->display_info->display;
! int screen = templ->screen_info->screen;
! if ((screen_info->feature_mask & GLC_GLX_FEATURE_PBUFFER_MASK) &&
! _glc_get_pbuffer_valid_fbconfig (display, screen, templ->format,
! &fbconfig)) {
! surface = _glc_glx_surface_create_pbuffer (templ, *fbconfig,
! templ->format, width, height);
!
! XFree (fbconfig);
! } else
! surface = NULL;
!
! return surface;
}
-
static void
_glc_glx_surface_destroy (void *abstract_surface)
{
! glc_glx_surface_t *surface = abstract_surface;
! /* Make sure drawable is not current */
! if (surface->base.type != GLC_SURFACE_TEXTURE_TYPE &&
! surface->drawable && surface->drawable == glXGetCurrentDrawable ())
! glXMakeCurrent (surface->screen_info->display_info->display, None, NULL);
! switch (surface->base.type) {
! case GLC_SURFACE_TEXTURE_TYPE:
! if (surface->base.texture)
! glc_texture_destroy (surface->base.texture);
! break;
! case GLC_SURFACE_PBUFFER_TYPE:
! if (surface->drawable)
! glc_glx_pbuffer_destroy (surface->screen_info->display_info->display,
! surface->drawable);
! break;
! case GLC_SURFACE_WINDOW_TYPE:
! break;
! }
if (surface->context)
glc_glx_context_release (surface->context);
!
glc_surface_deinit (&surface->base);
--- 259,329 ----
glc_surface_init (&surface->base, &glc_glx_surface_backend);
!
surface->screen_info = screen_info;
surface->context = context;
surface->format = format;
! surface->base.red = format->red;
! surface->base.green = format->green;
! surface->base.blue = format->blue;
! surface->base.alpha = format->alpha;
! surface->base.width = width;
! surface->base.height = height;
! surface->drawable = window;
! return &surface->base;
}
+ slim_hidden_def(glc_glx_surface_create_for_window);
static glc_surface_t *
! _glc_glx_surface_create_similar (void *abstract_templ,
! int width,
! int height)
{
! glc_glx_surface_t *templ = (glc_glx_surface_t *) abstract_templ;
! 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);
! }
!
! return NULL;
}
static void
_glc_glx_surface_destroy (void *abstract_surface)
{
! 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) {
!
! #ifdef GLX_ATI_render_texture
! _glc_glx_proc_address.glx_release_tex_image_ati
! (surface->screen_info->display_info->display, surface->pbuffer,
! GLX_FRONT_LEFT_ATI);
! #endif
!
! }
! if (surface->texture)
! glc_texture_destroy (surface->texture);
!
! if (surface->pbuffer)
! glc_glx_pbuffer_destroy (surface->screen_info->display_info->display,
! surface->pbuffer);
!
! 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);
***************
*** 358,386 ****
}
! void
! glc_glx_surface_realize (glc_surface_t *surface)
{
! glc_glx_surface_t *glx_surface = (glc_glx_surface_t *) surface;
! if (glx_surface->base.type == GLC_SURFACE_WINDOW_TYPE)
! _glc_glx_surface_realize (glx_surface->screen_info->display_info->display,
! glx_surface->drawable,
! &glx_surface->base.width,
! &glx_surface->base.height);
}
! void
! glc_glx_surface_swap_buffers (glc_surface_t *surface)
{
! glc_glx_surface_t *glx_surface = (glc_glx_surface_t *) surface;
!
! if (glx_surface->base.type != GLC_SURFACE_WINDOW_TYPE)
return;
! glc_glx_context_push_current (glx_surface->context, glx_surface,
! glx_surface->drawable);
! glFlush ();
! glXSwapBuffers (glx_surface->screen_info->display_info->display,
! glx_surface->drawable);
! glc_glx_context_pop_current (glx_surface->context);
}
--- 331,360 ----
}
!
! static void
! _glc_glx_surface_realize (void *abstract_surface)
{
! 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,
! &surface->base.width, &surface->base.height);
! }
}
! 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_ANY_CONTEXT_CURRENT);
+
+ glXSwapBuffers (surface->screen_info->display_info->display,
+ surface->drawable);
! glc_glx_context_pop_current (surface);
}
Index: glc_rect.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_rect.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** glc_rect.c 7 Dec 2003 02:42:29 -0000 1.5
--- glc_rect.c 3 Feb 2004 15:12:11 -0000 1.6
***************
*** 66,157 ****
unsigned int height)
{
! glc_surface_t *intermediate = NULL;
! glc_surface_t *surface;
! glc_region_box_t bounds, ibounds;
! int x_draw_offset = 0, y_draw_offset = 0;
! if (x > dst->width || y > dst->height ||
! (x + (int) width) < 0 || (y + (int) height) < 0)
return;
-
- if (dst->type == GLC_SURFACE_TEXTURE_TYPE) {
- bounds.x1 = x;
- bounds.x2 = x + width;
- bounds.y1 = y;
- bounds.y2 = y + height;
-
- glc_intermediate_bounds (dst, &bounds, &ibounds,
- &x_draw_offset, &y_draw_offset);
! if (ibounds.x2 - ibounds.x1 <= 0 || ibounds.y2 - ibounds.y1 <= 0)
! return;
!
! intermediate = surface =
! glc_surface_create_intermediate (dst,
! ibounds.x2 - ibounds.x1,
! ibounds.y2 - ibounds.y1);
!
! if (!surface) {
! glc_surface_status_add (dst, GLC_STATUS_NOT_SUPPORTED_MASK);
! return;
! }
!
! x += x_draw_offset;
! y += y_draw_offset;
!
! glc_surface_disable_transform_and_repeat (dst);
! glc_composite (GLC_OPERATOR_SRC,
! dst,
! NULL,
! surface,
! ibounds.x1, ibounds.y1,
! 0, 0,
! 0, 0,
! intermediate->width, intermediate->height);
! glc_surface_enable_transform_and_repeat (dst);
! } else
! surface = dst;
!
! glc_surface_push_current (surface);
! /* XXX: If operator == SRC and complete surface should be filled,
! then we do a clear instead (not sure that this is OK to do). */
! if (op == GLC_OPERATOR_SRC && x <= 0 && y <= 0 &&
! (x + (int) width) >= surface->width &&
! (y + (int) height) >= surface->height) {
! glClearColor ((double) color->red / (double) 0xffff,
! (double) color->green / (double) 0xffff,
! (double) color->blue / (double) 0xffff,
! (double) color->alpha / (double) 0xffff);
! glClear (GL_COLOR_BUFFER_BIT);
! } else {
! glDisable (GL_POLYGON_SMOOTH);
! glShadeModel (GL_FLAT);
! glColor4us (color->red, color->green, color->blue, color->alpha);
! glc_set_operator (op);
! glBegin (GL_QUADS);
! glVertex2i (x, y);
! glVertex2i (x + width, y);
! glVertex2i (x + width, y + height);
! glVertex2i (x, y + height);
! glEnd ();
! }
!
! if (intermediate) {
! glBindTexture (GL_TEXTURE_2D, dst->texture);
! glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
! ibounds.x1, dst->height - ibounds.y2,
! 0, 0,
! intermediate->width, intermediate->height);
! glFlush ();
! glc_surface_pop_current (surface);
! glc_surface_destroy (intermediate);
! } else
! glc_surface_pop_current (surface);
}
void
--- 66,104 ----
unsigned int height)
{
! glc_region_box_t bounds;
! bounds.x1 = x;
! bounds.x2 = x + width;
! bounds.y1 = y;
! bounds.y2 = y + height;
! if (bounds.x1 > dst->width || bounds.y1 > dst->height ||
! bounds.x2 < 0 || bounds.y2 < 0)
return;
! if (!glc_surface_push_current
! (dst, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
! glc_surface_pop_current (dst);
! return;
! }
! glShadeModel (GL_FLAT);
! glColor4us (color->red, color->green, color->blue, color->alpha);
! glc_set_operator (op);
! glBegin (GL_QUADS);
! glVertex2i (bounds.x1, bounds.y1);
! glVertex2i (bounds.x2, bounds.y1);
! glVertex2i (bounds.x2, bounds.y2);
! glVertex2i (bounds.x1, bounds.y2);
!
! glEnd ();
!
! glc_surface_dirty (dst, &bounds);
! glc_surface_pop_current (dst);
}
+ slim_hidden_def(glc_fill_rectangle);
void
***************
*** 162,170 ****
int n_rects)
{
! glc_surface_t *intermediate = NULL;
! glc_surface_t *surface;
! glc_region_box_t bounds, ibounds;
! int i, x_draw_offset = 0, y_draw_offset = 0;
!
glc_rectangle_bounds (n_rects, rects, &bounds);
if (bounds.x1 > dst->width || bounds.y1 > dst->height ||
--- 109,114 ----
int n_rects)
{
! glc_region_box_t bounds;
!
glc_rectangle_bounds (n_rects, rects, &bounds);
if (bounds.x1 > dst->width || bounds.y1 > dst->height ||
***************
*** 172,208 ****
return;
! if (dst->type == GLC_SURFACE_TEXTURE_TYPE) {
! glc_intermediate_bounds (dst, &bounds, &ibounds,
! &x_draw_offset, &y_draw_offset);
!
! if (ibounds.x2 - ibounds.x1 <= 0 || ibounds.y2 - ibounds.y1 <= 0)
! return;
!
! intermediate = surface =
! glc_surface_create_intermediate (dst,
! ibounds.x2 - ibounds.x1,
! ibounds.y2 - ibounds.y1);
!
! if (!surface) {
! glc_surface_status_add (dst, GLC_STATUS_NOT_SUPPORTED_MASK);
! return;
! }
!
! glc_surface_disable_transform_and_repeat (dst);
! glc_composite (GLC_OPERATOR_SRC,
! dst,
! NULL,
! surface,
! ibounds.x1, ibounds.y1,
! 0, 0,
! 0, 0,
! intermediate->width, intermediate->height);
! glc_surface_enable_transform_and_repeat (dst);
! } else
! surface = dst;
!
! glc_surface_push_current (surface);
- glDisable (GL_POLYGON_SMOOTH);
glShadeModel (GL_FLAT);
--- 116,125 ----
return;
! if (!glc_surface_push_current
! (dst, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
! glc_surface_pop_current (dst);
! return;
! }
glShadeModel (GL_FLAT);
***************
*** 212,238 ****
glBegin (GL_QUADS);
! for (i = 0; i < n_rects; i++) {
! glVertex2i (x_draw_offset + rects[i].x,
! y_draw_offset + rects[i].y);
! glVertex2i (x_draw_offset + rects[i].x + rects[i].width,
! y_draw_offset + rects[i].y);
! glVertex2i (x_draw_offset + rects[i].x + rects[i].width,
! y_draw_offset + rects[i].y + rects[i].height);
! glVertex2i (x_draw_offset + rects[i].x,
! y_draw_offset + rects[i].y + rects[i].height);
}
glEnd ();
! if (intermediate) {
! glBindTexture (GL_TEXTURE_2D, dst->texture);
! glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
! ibounds.x1, dst->height - ibounds.y2,
! 0, 0,
! intermediate->width, intermediate->height);
! glFlush ();
!
! glc_surface_pop_current (surface);
! glc_surface_destroy (intermediate);
! } else
! glc_surface_pop_current (surface);
}
--- 129,144 ----
glBegin (GL_QUADS);
!
! for (; n_rects; n_rects--, rects++) {
! glVertex2i (rects->x, rects->y);
! glVertex2i (rects->x + rects->width, rects->y);
! glVertex2i (rects->x + rects->width, rects->y + rects->height);
! glVertex2i (rects->x, rects->y + rects->height);
}
+
glEnd ();
! glc_surface_dirty (dst, &bounds);
! glc_surface_pop_current (dst);
}
+ slim_hidden_def(glc_fill_rectangles);
Index: glc_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_surface.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** glc_surface.c 9 Dec 2003 11:03:30 -0000 1.8
--- glc_surface.c 3 Feb 2004 15:12:11 -0000 1.9
***************
*** 43,50 ****
surface->repeat = 0;
surface->transform = NULL;
! surface->disable_transform_and_repeat = 0;
surface->filter = GLC_FILTER_NEAREST;
! surface->polyedge = GLC_POLYEDGE_SHARP;
surface->status_mask = 0;
}
--- 43,54 ----
surface->repeat = 0;
surface->transform = NULL;
! surface->disable_transform = 0;
! surface->anti_aliasing = 0;
surface->filter = GLC_FILTER_NEAREST;
! surface->polyedge = GLC_POLYEDGE_SMOOTH;
surface->status_mask = 0;
+ surface->implicit_mask = 0;
+ surface->dirty = 0;
+ surface->requires_flipping = 1;
}
***************
*** 57,65 ****
glc_surface_t *
! glc_surface_create_intermediate (glc_surface_t *templ,
! int width,
! int height)
{
! return templ->backend->create_intermediate (templ, width, height);
}
--- 61,74 ----
glc_surface_t *
! glc_surface_create_similar (glc_surface_t *templ,
! int width,
! int height)
{
! glc_surface_t *surface =
! templ->backend->create_similar (templ, width, height);
!
! surface->polyedge = templ->polyedge;
!
! return surface;
}
***************
*** 70,77 ****
}
! void
! glc_surface_push_current (glc_surface_t *surface)
{
! surface->backend->push_current (surface);
}
--- 79,92 ----
}
! glc_bool_t
! glc_surface_push_current (glc_surface_t *surface,
! glc_constraint_t constraint)
{
! if (!surface->backend->push_current (surface, constraint)) {
! glc_surface_status_add (surface, GLC_STATUS_NOT_SUPPORTED_MASK);
! return 0;
! }
!
! return 1;
}
***************
*** 83,92 ****
void
- glc_surface_status_add (glc_surface_t *surface, int flags)
- {
- surface->status_mask |= flags;
- }
-
- void
glc_surface_set_transform (glc_surface_t *surface,
glc_transform_t *transform)
--- 98,101 ----
***************
*** 94,100 ****
static const glc_transform_t identity = {
{
! { XFIXED1, 0x00000, 0x00000 },
! { 0x00000, XFIXED1, 0x00000 },
! { 0x00000, 0x00000, XFIXED1 },
}
};
--- 103,109 ----
static const glc_transform_t identity = {
{
! { FIXED1, 0x00000, 0x00000 },
! { 0x00000, FIXED1, 0x00000 },
! { 0x00000, 0x00000, FIXED1 },
}
};
***************
*** 111,121 ****
}
! surface->transform->m[0][0] = XFIXED_TO_DOUBLE (transform->matrix[0][0]);
! surface->transform->m[1][0] = XFIXED_TO_DOUBLE (transform->matrix[0][1]);
! surface->transform->m[2][0] = XFIXED_TO_DOUBLE (transform->matrix[0][2]);
! surface->transform->m[0][1] = XFIXED_TO_DOUBLE (transform->matrix[1][0]);
! surface->transform->m[1][1] = XFIXED_TO_DOUBLE (transform->matrix[1][1]);
! surface->transform->m[2][1] = XFIXED_TO_DOUBLE (transform->matrix[1][2]);
if (glc_matrix_invert (surface->transform)) {
--- 120,130 ----
}
! surface->transform->m[0][0] = FIXED_TO_DOUBLE (transform->matrix[0][0]);
! surface->transform->m[1][0] = FIXED_TO_DOUBLE (transform->matrix[0][1]);
! surface->transform->m[2][0] = FIXED_TO_DOUBLE (transform->matrix[0][2]);
! surface->transform->m[0][1] = FIXED_TO_DOUBLE (transform->matrix[1][0]);
! surface->transform->m[1][1] = FIXED_TO_DOUBLE (transform->matrix[1][1]);
! surface->transform->m[2][1] = FIXED_TO_DOUBLE (transform->matrix[1][2]);
if (glc_matrix_invert (surface->transform)) {
***************
*** 131,134 ****
--- 140,144 ----
}
}
+ slim_hidden_def(glc_surface_set_transform);
void
***************
*** 138,141 ****
--- 148,152 ----
surface->repeat = repeat;
}
+ slim_hidden_def(glc_surface_set_repeat);
void
***************
*** 145,148 ****
--- 156,160 ----
surface->filter = filter;
}
+ slim_hidden_def(glc_surface_set_filter);
void
***************
*** 152,155 ****
--- 164,168 ----
surface->polyedge = polyedge;
}
+ slim_hidden_def(glc_surface_set_polyedge);
int
***************
*** 158,161 ****
--- 171,175 ----
return surface->width;
}
+ slim_hidden_def(glc_surface_get_width);
int
***************
*** 164,167 ****
--- 178,240 ----
return surface->height;
}
+ slim_hidden_def(glc_surface_get_height);
+
+ glc_texture_t *
+ glc_surface_get_texture (glc_surface_t *surface)
+ {
+ return surface->backend->get_texture (surface);
+ }
+
+ void
+ glc_surface_realize (glc_surface_t *surface)
+ {
+ surface->backend->realize (surface);
+ }
+ slim_hidden_def(glc_surface_realize);
+
+ void
+ glc_surface_swap_buffers (glc_surface_t *surface)
+ {
+ surface->backend->swap_buffers (surface);
+ }
+ slim_hidden_def(glc_surface_swap_buffers);
+
+ int
+ glc_surface_get_pixelsize (glc_surface_t *surface)
+ {
+ return glc_get_pixelsize_from_components (surface->red,
+ surface->green,
+ surface->blue,
+ surface->alpha);
+ }
+ slim_hidden_def(glc_surface_get_pixelsize);
+
+ void
+ glc_surface_dirty (glc_surface_t *surface,
+ glc_region_box_t *region)
+ {
+ if (!region) {
+ surface->dirty_region.x1 = surface->dirty_region.y1 = 0;
+ surface->dirty_region.x2 = surface->width;
+ surface->dirty_region.y2 = surface->height;
+ } else {
+ if (!surface->dirty) {
+ memcpy (&surface->dirty_region, region, sizeof (glc_region_box_t));
+ } else
+ glc_union_region (region,
+ &surface->dirty_region,
+ &surface->dirty_region);
+ }
+
+ surface->dirty = 1;
+
+ glFlush ();
+ }
+
+ void
+ glc_surface_status_add (glc_surface_t *surface, int flags)
+ {
+ surface->status_mask |= flags;
+ }
glc_status_t
***************
*** 170,184 ****
return glc_status_pop_from_mask (&surface->status_mask);
}
void
! glc_surface_disable_transform_and_repeat (glc_surface_t *surface)
{
! surface->disable_transform_and_repeat = 1;
}
void
! glc_surface_enable_transform_and_repeat (glc_surface_t *surface)
{
! surface->disable_transform_and_repeat = 0;
}
--- 243,258 ----
return glc_status_pop_from_mask (&surface->status_mask);
}
+ slim_hidden_def(glc_surface_get_status);
void
! glc_surface_disable_transform (glc_surface_t *surface)
{
! surface->disable_transform = 1;
}
void
! glc_surface_enable_transform (glc_surface_t *surface)
{
! surface->disable_transform = 0;
}
***************
*** 188,195 ****
glPixelStorei (GL_PACK_ALIGNMENT, 4);
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
-
- if (surface->type == GLC_SURFACE_TEXTURE_TYPE)
- return;
-
glViewport (0, 0, surface->width, surface->height);
glMatrixMode (GL_PROJECTION);
--- 262,265 ----
***************
*** 207,213 ****
glScissor (0, 0, surface->width, surface->height);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
}
! GLenum
glc_surface_get_texture_format (glc_surface_t *surface)
{
--- 277,285 ----
glScissor (0, 0, surface->width, surface->height);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
+ glDisable (GL_POLYGON_SMOOTH);
+ glShadeModel (GL_FLAT);
}
! unsigned int
glc_surface_get_texture_format (glc_surface_t *surface)
{
***************
*** 251,267 ****
copy the part we want, not very efficient. We only want to read the
area requested. I think it can be fixed with glPixelStore parameters. */
- rowstride = surface->real_width * pixelsize;
- rowstride += (rowstride % 4)? (4 - (rowstride % 4)): 0;
-
- pixel_buf = (unsigned char *) malloc (surface->real_height * rowstride);
! glc_surface_push_current (surface);
! if (surface->type != GLC_SURFACE_TEXTURE_TYPE) {
! glReadPixels (0, 0, surface->real_width, surface->real_height,
format, type, pixel_buf);
} else {
! glEnable (GL_TEXTURE_2D);
! glBindTexture (GL_TEXTURE_2D, surface->texture);
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
--- 323,344 ----
copy the part we want, not very efficient. We only want to read the
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;
! pixel_buf = (unsigned char *) malloc (surface->height * rowstride);
! glReadPixels (0, 0, surface->width, surface->height,
format, type, pixel_buf);
} else {
! glc_texture_t *texture;
!
! texture = glc_surface_get_texture (surface);
! glc_texture_bind (texture);
!
! rowstride = texture->width * pixelsize;
! rowstride += (rowstride % 4)? (4 - (rowstride % 4)): 0;
! pixel_buf = (unsigned char *) malloc (texture->height * rowstride);
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
***************
*** 269,278 ****
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
! glGetTexImage (GL_TEXTURE_2D, 0,
format,
type,
pixel_buf);
}
!
glc_surface_pop_current (surface);
--- 346,357 ----
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
! glGetTexImage (texture->target, 0,
format,
type,
pixel_buf);
+
+ glc_texture_unbind (texture);
}
!
glc_surface_pop_current (surface);
***************
*** 280,290 ****
area_rowstride += (area_rowstride % 4)? (4 - (area_rowstride % 4)): 0;
! for (i = 0; i < height; i++)
memcpy (&pixels[(height - i - 1) * area_rowstride],
&pixel_buf[(surface->height - y - height + i) * rowstride + x],
area_rowstride);
free (pixel_buf);
}
void
--- 359,371 ----
area_rowstride += (area_rowstride % 4)? (4 - (area_rowstride % 4)): 0;
! for (i = 0; i < height; i++) {
memcpy (&pixels[(height - i - 1) * area_rowstride],
&pixel_buf[(surface->height - y - height + i) * rowstride + x],
area_rowstride);
+ }
free (pixel_buf);
}
+ slim_hidden_def(glc_surface_read_pixels);
void
***************
*** 299,303 ****
GLenum format, type;
int pixelsize;
!
if (x < 0 || x > (surface->width - (int) width) ||
y < 0 || y > (surface->height - (int) height)) {
--- 380,384 ----
GLenum format, type;
int pixelsize;
!
if (x < 0 || x > (surface->width - (int) width) ||
y < 0 || y > (surface->height - (int) height)) {
***************
*** 314,326 ****
type = glc_get_texture_data_type_from_pixelsize (pixelsize);
- glc_surface_push_current (surface);
! if (surface->type != GLC_SURFACE_TEXTURE_TYPE) {
! glPixelZoom (1.0, -1.0);
! glRasterPos2i (x, y);
glDrawPixels (width, height, format, type, pixels);
! glPixelZoom (1.0, 1.0);
} else {
int i, rowstride;
rowstride = width * pixelsize;
--- 395,440 ----
type = glc_get_texture_data_type_from_pixelsize (pixelsize);
! if (glc_surface_push_current
! (surface, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
! glc_region_box_t bounds;
!
! bounds.x1 = x;
! bounds.x2 = x + width;
! bounds.y1 = y;
! bounds.y2 = y + height;
!
! glDisable (GL_SCISSOR_TEST);
! glDisable (GL_DITHER);
!
! glc_set_operator (GLC_OPERATOR_SRC);
!
! glPushAttrib (GL_TRANSFORM_BIT | GL_VIEWPORT_BIT);
! glMatrixMode (GL_PROJECTION);
! glPushMatrix ();
! glLoadIdentity ();
! glMatrixMode (GL_MODELVIEW);
! glPushMatrix ();
! glLoadIdentity ();
! glDepthRange (0, 1);
! glViewport (-1, -1, 2, 2);
!
! if (surface->requires_flipping)
! glPixelZoom (1.0, -1.0);
!
! glRasterPos2d (0, 0);
! glBitmap (0, 0, 1, 1, x, surface->height - y, NULL);
!
! glPopMatrix ();
! glMatrixMode (GL_PROJECTION);
! glPopMatrix ();
! glPopAttrib ();
!
glDrawPixels (width, height, format, type, pixels);
!
! glc_surface_dirty (surface, &bounds);
} else {
int i, rowstride;
+ glc_texture_t *texture;
rowstride = width * pixelsize;
***************
*** 334,340 ****
memcpy (&pixel_buf[i * rowstride],
&pixels[(height - i - 1) * rowstride], rowstride);
!
! glEnable (GL_TEXTURE_2D);
! glBindTexture (GL_TEXTURE_2D, surface->texture);
glPixelStorei (GL_PACK_ROW_LENGTH, 0);
--- 448,454 ----
memcpy (&pixel_buf[i * rowstride],
&pixels[(height - i - 1) * rowstride], rowstride);
!
! texture = glc_surface_get_texture (surface);
! glc_texture_bind (texture);
glPixelStorei (GL_PACK_ROW_LENGTH, 0);
***************
*** 342,356 ****
glPixelStorei (GL_PACK_SKIP_PIXELS, 0);
! glTexSubImage2D (GL_TEXTURE_2D, 0,
x, surface->height - y - height,
width, height,
format, type,
pixel_buf);
-
glFlush ();
! glDisable (GL_TEXTURE_2D);
free (pixel_buf);
}
glc_surface_pop_current (surface);
}
--- 456,531 ----
glPixelStorei (GL_PACK_SKIP_PIXELS, 0);
! glTexSubImage2D (texture->target, 0,
x, surface->height - y - height,
width, height,
format, type,
pixel_buf);
glFlush ();
!
! glc_texture_unbind (texture);
!
free (pixel_buf);
}
+
+ glc_surface_pop_current (surface);
+ }
+ slim_hidden_def(glc_surface_draw_pixels);
+
+ void
+ glc_surface_get_gl_texture (glc_surface_t *surface,
+ unsigned int *name,
+ unsigned int *target,
+ double *texcoord_width,
+ double *texcoord_height,
+ glc_bool_t *repeatable)
+ {
+ glc_texture_t *texture = glc_surface_get_texture (surface);
+
+ if (!texture)
+ return;
+
+ glc_texture_bind (texture);
+ glc_texture_ensure_filter (texture, surface->filter);
+ glc_texture_ensure_repeat (texture, (surface->repeat && texture->repeatable));
+ glc_texture_unbind (texture);
+
+ if (name)
+ *name = texture->name;
+
+ if (target)
+ *target = texture->target;
+
+ if (texcoord_width)
+ *texcoord_width = texture->texcoord_width;
+
+ if (texcoord_height)
+ *texcoord_height = texture->texcoord_height;
+
+ if (repeatable)
+ *repeatable = texture->repeatable;
+ }
+ slim_hidden_def(glc_surface_get_gl_texture);
+
+ void
+ 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);
+ }
+ slim_hidden_def(glc_surface_gl_begin);
+
+ void
+ glc_surface_gl_end (glc_surface_t *surface)
+ {
+ glc_region_box_t region;
+
+ region.x1 = region.y1 = 0;
+ region.x2 = surface->width;
+ region.y2 = surface->height;
+
+ glc_surface_dirty (surface, ®ion);
glc_surface_pop_current (surface);
}
+ slim_hidden_def(glc_surface_gl_end);
Index: glc_texture.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_texture.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glc_texture.c 8 Dec 2003 21:03:33 -0000 1.4
--- glc_texture.c 3 Feb 2004 15:12:11 -0000 1.5
***************
*** 34,37 ****
--- 34,73 ----
#define TEXTURE_MAX_SIZE 4192
+ static glc_bool_t
+ _glc_texture_is_power_of_two (int value)
+ {
+ int x = 1;
+
+ while (x < value)
+ x <<= 1;
+
+ return (x == value);
+ }
+
+ static void
+ _glc_texture_find_best_target (int width, int height,
+ long int target_mask,
+ unsigned int *target,
+ unsigned int *proxy_target)
+ {
+ *target = GL_TEXTURE_2D;
+ *proxy_target = GL_PROXY_TEXTURE_2D;
+
+ if ((!_glc_texture_is_power_of_two (width)) ||
+ (!_glc_texture_is_power_of_two (height))) {
+ if (target_mask & GLC_TEXTURE_TARGET_RECTANGLE_MASK) {
+
+ #if GL_EXT_texture_rectangle
+ *target = GL_TEXTURE_RECTANGLE_EXT;
+ *proxy_target = GL_PROXY_TEXTURE_RECTANGLE_EXT;
+ #elif GL_NV_texture_rectangle
+ *target = GL_TEXTURE_RECTANGLE_NV;
+ *proxy_target = GL_PROXY_TEXTURE_RECTANGLE_NV;
+ #endif
+
+ }
+ }
+ }
+
static void
_glc_texture_power_of_two_size (int *value)
***************
*** 49,54 ****
int height,
GLenum texture_format,
! int *real_width,
! int *real_height)
{
int test_width = width;
--- 85,89 ----
int height,
GLenum texture_format,
! glc_texture_t *texture)
{
int test_width = width;
***************
*** 80,85 ****
}
} else {
! *real_width = test_width;
! *real_height = test_height;
return 1;
--- 115,120 ----
}
} else {
! texture->width = test_width;
! texture->height = test_height;
return 1;
***************
*** 90,121 ****
}
! GLuint
! glc_texture_create (int width,
! int height,
! GLenum texture_format,
! int *texture_width,
! int *texture_height)
{
! GLuint texture;
! if (_glc_texture_find_best_size (width, height, texture_format,
! texture_width, texture_height)) {
!
! glGenTextures (1, &texture);
! glBindTexture (GL_TEXTURE_2D, texture);
! glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
! *texture_width, *texture_height,
! 0, texture_format, GL_UNSIGNED_BYTE, NULL);
!
! return texture;
}
! return 0;
}
void
! glc_texture_destroy (GLuint texture)
{
! glDeleteTextures (1, &texture);
}
--- 125,291 ----
}
! glc_texture_t *
! glc_texture_generate (int width,
! int height,
! unsigned int texture_format,
! long int target_mask)
{
! glc_texture_t *texture;
! unsigned int proxy_target;
!
! texture = (glc_texture_t *) malloc (sizeof (glc_texture_t));
! if (texture == NULL)
! return NULL;
!
! texture->filter = -1;
! texture->repeat = -1;
! texture->width = width;
! texture->height = height;
! texture->format = texture_format;
! texture->allocated = 0;
! _glc_texture_find_best_target (width, height,
! target_mask,
! &texture->target, &proxy_target);
!
! if (texture->target == GL_TEXTURE_2D &&
! (!_glc_texture_find_best_size (width, height,
! texture_format, texture))) {
! free (texture);
! return NULL;
! }
! glGenTextures (1, (GLuint *) &texture->name);
!
! if (texture->target == GL_TEXTURE_2D &&
! texture->width == width && texture->height == height) {
! texture->repeatable = 1;
! texture->texcoord_width = texture->texcoord_height = 1.0;
! } else {
! texture->repeatable = 0;
! if (texture->target == GL_TEXTURE_2D) {
! texture->texcoord_width = (double) width / (double) texture->width;
! texture->texcoord_height = (double) height / (double) texture->height;
! } else {
! texture->texcoord_width = texture->width;
! texture->texcoord_height = texture->height;
! }
}
+
+ return texture;
+ }
! void
! glc_texture_allocate (glc_texture_t *texture)
! {
! if (texture->allocated)
! return;
!
! glc_texture_bind (texture);
!
! glTexImage2D (texture->target, 0, GL_RGBA,
! texture->width, texture->height,
! 0, texture->format, GL_UNSIGNED_BYTE, NULL);
!
! glc_texture_unbind (texture);
!
! texture->allocated = 1;
}
void
! glc_texture_destroy (glc_texture_t *texture)
! {
! glDeleteTextures (1, (GLuint *) &texture->name);
! free (texture);
! }
!
! void
! glc_texture_ensure_filter (glc_texture_t *texture,
! glc_filter_t filter)
{
! if (texture->filter != filter) {
! switch (filter) {
! case GLC_FILTER_FAST:
! case GLC_FILTER_NEAREST:
! glTexParameteri (texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
! glTexParameteri (texture->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
! break;
! case GLC_FILTER_GOOD:
! case GLC_FILTER_BEST:
! case GLC_FILTER_BILINEAR:
! glTexParameteri (texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
! glTexParameteri (texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
! break;
! }
! texture->filter = filter;
! }
! }
!
! void
! glc_texture_ensure_repeat (glc_texture_t *texture,
! glc_bool_t repeat)
! {
! if (texture->repeat != repeat) {
! if (repeat) {
! glTexParameteri (texture->target, GL_TEXTURE_WRAP_S, GL_REPEAT);
! glTexParameteri (texture->target, GL_TEXTURE_WRAP_T, GL_REPEAT);
! } else {
! glTexParameteri (texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP);
! glTexParameteri (texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP);
! }
! texture->repeat = repeat;
! }
! }
!
! void
! glc_texture_bind (glc_texture_t *texture)
! {
!
! #if GL_EXT_texture_rectangle
! glDisable (GL_TEXTURE_RECTANGLE_EXT);
! #elif GL_NV_texture_rectangle
! glDisable (GL_TEXTURE_RECTANGLE_NV);
! #endif
!
! glDisable (GL_TEXTURE_2D);
!
! glEnable (texture->target);
! glBindTexture (texture->target, texture->name);
! }
!
! void
! glc_texture_unbind (glc_texture_t *texture)
! {
! glBindTexture (texture->target, 0);
! glDisable (texture->target);
! }
!
! void
! glc_texture_copy_surface (glc_texture_t *texture,
! glc_surface_t *surface,
! glc_region_box_t *region)
! {
! if (!texture)
! return;
!
! glc_surface_push_current
! (surface, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT);
!
! glc_texture_bind (texture);
!
! if (region->x1 < 0) region->x1 = 0;
! if (region->y1 < 0) region->y1 = 0;
! if (region->x2 > surface->width) region->x2 = surface->width;
! if (region->y2 > surface->height) region->y2 = surface->height;
!
! glCopyTexSubImage2D (texture->target, 0,
! region->x1, region->y1,
! region->x1, region->y1,
! region->x2 - region->x1,
! region->y2 - region->y1);
!
! glFlush ();
!
! glc_texture_unbind (texture);
! glc_surface_pop_current (surface);
}
Index: glc_trap.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_trap.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glc_trap.c 9 Dec 2003 19:50:45 -0000 1.6
--- glc_trap.c 3 Feb 2004 15:12:11 -0000 1.7
***************
*** 47,52 ****
int ceil)
{
! glc_fixed16_16_t dx = l->p2.x - l->p1.x;
! x_fixed_32_32 ex = (x_fixed_32_32) (y - l->p1.y) * dx;
glc_fixed16_16_t dy = l->p2.y - l->p1.y;
--- 47,51 ----
int ceil)
{
! glc_fixed_32_32 ex = (glc_fixed_32_32) (y - l->p1.y) * (l->p2.x - l->p1.x);
glc_fixed16_16_t dy = l->p2.y - l->p1.y;
***************
*** 73,94 ****
continue;
! y1 = XFIXED_TO_INT (traps->top);
if (y1 < box->y1)
box->y1 = y1;
! y2 = XFIXED_TO_INT (XFIXED_CEIL (traps->bottom));
if (y2 > box->y2)
box->y2 = y2;
! x1 = XFIXED_TO_INT (MIN (glc_line_fixed_x (&traps->left, traps->top, 0),
! glc_line_fixed_x (&traps->left,
! traps->bottom, 0)));
if (x1 < box->x1)
box->x1 = x1;
! x2 = XFIXED_TO_INT (XFIXED_CEIL
! (MAX (glc_line_fixed_x (&traps->right, traps->top, 1),
! glc_line_fixed_x (&traps->right,
! traps->bottom, 1))));
if (x2 > box->x2)
box->x2 = x2;
--- 72,93 ----
continue;
! y1 = FIXED_TO_INT (traps->top);
if (y1 < box->y1)
box->y1 = y1;
! y2 = FIXED_TO_INT (FIXED_CEIL (traps->bottom));
if (y2 > box->y2)
box->y2 = y2;
! x1 = FIXED_TO_INT (MIN (glc_line_fixed_x (&traps->left, traps->top, 0),
! glc_line_fixed_x (&traps->left,
! traps->bottom, 0)));
if (x1 < box->x1)
box->x1 = x1;
! x2 = FIXED_TO_INT (FIXED_CEIL
! (MAX (glc_line_fixed_x (&traps->right, traps->top, 1),
! glc_line_fixed_x (&traps->right,
! traps->bottom, 1))));
if (x2 > box->x2)
box->x2 = x2;
***************
*** 96,99 ****
--- 95,133 ----
}
+ glc_bool_t
+ glc_composite_direct_check (glc_operator_t op,
+ glc_surface_t *src,
+ glc_surface_t *dst,
+ int x_src,
+ int y_src,
+ const glc_trapezoid_t *traps)
+ {
+ int16_t x1, y1, x2, y2;
+
+ if (!TRAPEZOID_VALID (traps))
+ return 1;
+
+ y1 = FIXED_TO_INT (traps->top);
+
+ y2 = FIXED_TO_INT (FIXED_CEIL (traps->bottom));
+
+ x1 = FIXED_TO_INT (MAX (glc_line_fixed_x (&traps->left, traps->top, 0),
+ glc_line_fixed_x (&traps->left,
+ traps->bottom, 0)));
+ x2 = FIXED_TO_INT (FIXED_CEIL
+ (MIN (glc_line_fixed_x (&traps->right, traps->top, 1),
+ glc_line_fixed_x (&traps->right,
+ traps->bottom, 1))));
+
+ if (x1 <= 0 && x2 >= dst->width &&
+ y1 <= 0 && y2 >= dst->height) {
+ glc_composite (op, src, NULL, dst, x_src, y_src, 0, 0, 0, 0,
+ dst->width, dst->height);
+ return 1;
+ }
+
+ return 0;
+ }
+
void
glc_composite_trapezoids (glc_operator_t op,
***************
*** 107,111 ****
glc_surface_t *mask;
glc_region_box_t bounds, mask_bounds;
! int x_draw_offset, y_draw_offset;
glc_trapezoid_bounds (n_traps, traps, &bounds);
--- 141,149 ----
glc_surface_t *mask;
glc_region_box_t bounds, mask_bounds;
! double x_draw_offset, y_draw_offset;
!
! if (n_traps == 1 &&
! glc_composite_direct_check (op, src, dst, x_src, y_src, traps))
! return;
glc_trapezoid_bounds (n_traps, traps, &bounds);
***************
*** 114,118 ****
bounds.x2 < 0 || bounds.y2 < 0)
return;
!
if ((!src->repeat) && (!src->transform)) {
if (bounds.x1 > (src->width - x_src))
--- 152,156 ----
bounds.x2 < 0 || bounds.y2 < 0)
return;
!
if ((!src->repeat) && (!src->transform)) {
if (bounds.x1 > (src->width - x_src))
***************
*** 131,136 ****
}
! glc_intermediate_bounds (dst, &bounds, &mask_bounds,
! &x_draw_offset, &y_draw_offset);
if (mask_bounds.x2 - mask_bounds.x1 <= 0 ||
--- 169,178 ----
}
! mask_bounds.x1 = mask_bounds.y1 = 0;
! mask_bounds.x2 = dst->width;
! mask_bounds.y2 = dst->height;
! glc_intersect_region (&bounds, &mask_bounds, &mask_bounds);
! x_draw_offset = (double) -mask_bounds.x1;
! y_draw_offset = (double) -mask_bounds.y1;
if (mask_bounds.x2 - mask_bounds.x1 <= 0 ||
***************
*** 138,145 ****
return;
! mask = glc_surface_create_intermediate (src,
! mask_bounds.x2 - mask_bounds.x1,
! mask_bounds.y2 - mask_bounds.y1);
!
if (!mask) {
glc_surface_status_add (dst, GLC_STATUS_NOT_SUPPORTED_MASK);
--- 180,187 ----
return;
! mask = glc_surface_create_similar (dst,
! mask_bounds.x2 - mask_bounds.x1,
! mask_bounds.y2 - mask_bounds.y1);
!
if (!mask) {
glc_surface_status_add (dst, GLC_STATUS_NOT_SUPPORTED_MASK);
***************
*** 147,152 ****
}
! glc_surface_push_current (mask);
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT);
--- 189,200 ----
}
! mask->implicit_mask = 1;
+ if (!glc_surface_push_current
+ (mask, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
+ glc_surface_pop_current (mask);
+ return;
+ }
+
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT);
***************
*** 154,165 ****
glColorMask (1, 1, 1, 1);
! if (dst->polyedge == GLC_POLYEDGE_SMOOTH) {
! glEnable (GL_POLYGON_SMOOTH);
! glEnable (GL_BLEND);
! glHint(GL_POLYGON_SMOOTH, GL_NICEST);
! glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
! } else {
! glDisable (GL_POLYGON_SMOOTH);
! glDisable (GL_BLEND);
}
--- 202,214 ----
glColorMask (1, 1, 1, 1);
! glc_set_operator (GLC_OPERATOR_SRC);
!
! if (mask->polyedge == GLC_POLYEDGE_SMOOTH) {
! if (!mask->anti_aliasing) {
! glEnable (GL_POLYGON_SMOOTH);
! glEnable (GL_BLEND);
! glHint (GL_POLYGON_SMOOTH, GL_NICEST);
! glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
! }
}
***************
*** 172,196 ****
continue;
! top = y_draw_offset + XFIXED_TO_DOUBLE (traps->top);
! bottom = y_draw_offset + XFIXED_TO_DOUBLE (XFIXED_CEIL (traps->bottom));
!
glVertex2d (x_draw_offset +
! XFIXED_TO_DOUBLE (glc_line_fixed_x
! (&traps->left, traps->top, 0)), top);
glVertex2d (x_draw_offset +
! XFIXED_TO_DOUBLE (glc_line_fixed_x
! (&traps->right, traps->top, 1)), top);
glVertex2d (x_draw_offset +
! XFIXED_TO_DOUBLE (glc_line_fixed_x
! (&traps->right, traps->bottom, 1)), bottom);
glVertex2d (x_draw_offset +
! XFIXED_TO_DOUBLE (glc_line_fixed_x
! (&traps->left, traps->bottom, 0)), bottom);
}
glEnd ();
! glDisable (GL_POLYGON_SMOOTH);
glc_surface_pop_current (mask);
--- 221,251 ----
continue;
! top = y_draw_offset + FIXED_TO_DOUBLE (traps->top);
! bottom = y_draw_offset + FIXED_TO_DOUBLE (traps->bottom);
!
glVertex2d (x_draw_offset +
! FIXED_TO_DOUBLE (glc_line_fixed_x
! (&traps->left, traps->top, 0)), top);
glVertex2d (x_draw_offset +
! FIXED_TO_DOUBLE (glc_line_fixed_x
! (&traps->right, traps->top, 1)), top);
glVertex2d (x_draw_offset +
! FIXED_TO_DOUBLE (glc_line_fixed_x
! (&traps->right, traps->bottom, 1)), bottom);
glVertex2d (x_draw_offset +
! FIXED_TO_DOUBLE (glc_line_fixed_x
! (&traps->left, traps->bottom, 0)), bottom);
}
glEnd ();
! if (mask->polyedge == GLC_POLYEDGE_SMOOTH) {
! if (!mask->anti_aliasing) {
! glDisable (GL_POLYGON_SMOOTH);
! glDisable (GL_BLEND);
! }
! }
+ glc_surface_dirty (mask, NULL);
glc_surface_pop_current (mask);
***************
*** 202,210 ****
0, 0,
mask_bounds.x1, mask_bounds.y1,
! mask->width, mask->height);
!
glc_surface_destroy (mask);
-
}
static void
--- 257,265 ----
0, 0,
mask_bounds.x1, mask_bounds.y1,
! mask->width, mask->height);
!
glc_surface_destroy (mask);
}
+ slim_hidden_def(glc_composite_trapezoids);
static void
***************
*** 224,242 ****
continue;
! x1 = MIN (XFIXED_TO_INT (color_traps->top.left),
! XFIXED_TO_INT (color_traps->bottom.left));
if (x1 < box->x1)
box->x1 = x1;
! x2 = MAX (XFIXED_TO_INT (XFIXED_CEIL (color_traps->top.right)),
! XFIXED_TO_INT (XFIXED_CEIL (color_traps->bottom.right)));
if (x2 > box->x2)
box->x2 = x2;
! y1 = XFIXED_TO_INT (color_traps->top.y);
if (y1 < box->y1)
box->y1 = y1;
! y2 = XFIXED_TO_INT (XFIXED_CEIL (color_traps->bottom.y));
if (y2 > box->y2)
box->y2 = y2;
--- 279,297 ----
continue;
! x1 = MIN (FIXED_TO_INT (color_traps->top.left),
! FIXED_TO_INT (color_traps->bottom.left));
if (x1 < box->x1)
box->x1 = x1;
! x2 = MAX (FIXED_TO_INT (FIXED_CEIL (color_traps->top.right)),
! FIXED_TO_INT (FIXED_CEIL (color_traps->bottom.right)));
if (x2 > box->x2)
box->x2 = x2;
! y1 = FIXED_TO_INT (color_traps->top.y);
if (y1 < box->y1)
box->y1 = y1;
! y2 = FIXED_TO_INT (FIXED_CEIL (color_traps->bottom.y));
if (y2 > box->y2)
box->y2 = y2;
***************
*** 250,258 ****
int n_color_traps)
{
! glc_surface_t *intermediate = NULL;
! glc_surface_t *surface;
! glc_region_box_t bounds, ibounds;
! int x_draw_offset = 0, y_draw_offset = 0;
! glc_bool_t shade;
glc_color_trapezoid_bounds (n_color_traps, color_traps, &bounds);
--- 305,311 ----
int n_color_traps)
{
! glc_region_box_t bounds;
! int index;
! glc_bool_t shade = 0;
glc_color_trapezoid_bounds (n_color_traps, color_traps, &bounds);
***************
*** 262,335 ****
return;
! if (dst->type == GLC_SURFACE_TEXTURE_TYPE) {
! glc_intermediate_bounds (dst, &bounds, &ibounds,
! &x_draw_offset, &y_draw_offset);
! if (ibounds.x2 - ibounds.x1 <= 0 || ibounds.y2 - ibounds.y1 <= 0)
! return;
!
! intermediate = surface =
! glc_surface_create_intermediate (dst,
! ibounds.x2 - ibounds.x1,
! ibounds.y2 - ibounds.y1);
! if (!surface) {
! glc_surface_status_add (dst, GLC_STATUS_NOT_SUPPORTED_MASK);
! return;
}
!
! glc_surface_disable_transform_and_repeat (dst);
! glc_composite (GLC_OPERATOR_SRC,
! dst,
! NULL,
! surface,
! ibounds.x1, ibounds.y1,
! 0, 0,
! 0, 0,
! intermediate->width, intermediate->height);
! glc_surface_enable_transform_and_repeat (dst);
! } else
! surface = dst;
!
! glc_surface_push_current (surface);
!
! if (dst->polyedge == GLC_POLYEDGE_SMOOTH)
! glEnable (GL_POLYGON_SMOOTH);
! else
! glDisable (GL_POLYGON_SMOOTH);
! glc_set_operator (op);
for (; n_color_traps; n_color_traps--, color_traps++) {
if (!COLORTRAPEZOID_VALID (color_traps))
continue;
! if (memcmp (&color_traps->top.left_color,
! &color_traps->top.right_color, sizeof (glc_color_t)) ||
! memcmp (&color_traps->bottom.left_color,
! &color_traps->bottom.right_color, sizeof (glc_color_t)) ||
! memcmp (&color_traps->top.left_color,
! &color_traps->bottom.left_color, sizeof (glc_color_t))) {
! shade = 1;
! glShadeModel (GL_SMOOTH);
! } else {
! shade = 0;
! glShadeModel (GL_FLAT);
! glColor4us (color_traps->bottom.left_color.red,
! color_traps->bottom.left_color.green,
! color_traps->bottom.left_color.blue,
! color_traps->bottom.left_color.alpha);
!
! }
!
! glBegin (GL_QUADS);
!
! if (shade)
! glColor4us (color_traps->bottom.left_color.red,
! color_traps->bottom.left_color.green,
! color_traps->bottom.left_color.blue,
! color_traps->bottom.left_color.alpha);
! glVertex2d (x_draw_offset + XFIXED_TO_DOUBLE (color_traps->bottom.left),
! y_draw_offset + XFIXED_TO_DOUBLE (color_traps->bottom.y));
if (shade)
--- 315,358 ----
return;
! if (!glc_surface_push_current
! (dst, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
! glc_surface_pop_current (dst);
! return;
! }
!
! glc_set_operator (op);
! glShadeModel (GL_FLAT);
! for (index = 0; index < n_color_traps; index++) {
!
! if (!COLORTRAPEZOID_VALID (&color_traps[index]))
! continue;
!
! if (memcmp (&color_traps[index].top.right_color,
! &color_traps[index].top.left_color, sizeof (glc_color_t)) ||
! memcmp (&color_traps[index].bottom.right_color,
! &color_traps[index].bottom.left_color, sizeof (glc_color_t)) ||
! memcmp (&color_traps[index].top.left_color,
! &color_traps[index].bottom.left_color, sizeof (glc_color_t))) {
! glShadeModel (GL_SMOOTH);
! shade = 1;
! break;
}
! }
! glBegin (GL_QUADS);
for (; n_color_traps; n_color_traps--, color_traps++) {
+
if (!COLORTRAPEZOID_VALID (color_traps))
continue;
! glColor4us (color_traps->bottom.left_color.red,
! color_traps->bottom.left_color.green,
! color_traps->bottom.left_color.blue,
! color_traps->bottom.left_color.alpha);
! glVertex2d (FIXED_TO_DOUBLE (color_traps->bottom.left),
! FIXED_TO_DOUBLE (color_traps->bottom.y));
if (shade)
***************
*** 338,343 ****
color_traps->top.left_color.blue,
color_traps->top.left_color.alpha);
! glVertex2d (x_draw_offset + XFIXED_TO_DOUBLE (color_traps->top.left),
! y_draw_offset + XFIXED_TO_DOUBLE (color_traps->top.y));
if (shade)
--- 361,366 ----
color_traps->top.left_color.blue,
color_traps->top.left_color.alpha);
! glVertex2d (FIXED_TO_DOUBLE (color_traps->top.left),
! FIXED_TO_DOUBLE (color_traps->top.y));
if (shade)
***************
*** 346,351 ****
color_traps->top.right_color.blue,
color_traps->top.right_color.alpha);
! glVertex2d (x_draw_offset + XFIXED_TO_DOUBLE (color_traps->top.right),
! y_draw_offset + XFIXED_TO_DOUBLE (color_traps->top.y));
if (shade)
--- 369,374 ----
color_traps->top.right_color.blue,
color_traps->top.right_color.alpha);
! glVertex2d (FIXED_TO_DOUBLE (color_traps->top.right),
! FIXED_TO_DOUBLE (color_traps->top.y));
if (shade)
***************
*** 354,377 ****
color_traps->bottom.right_color.blue,
color_traps->bottom.right_color.alpha);
! glVertex2d (x_draw_offset + XFIXED_TO_DOUBLE (color_traps->bottom.right),
! y_draw_offset + XFIXED_TO_DOUBLE (color_traps->bottom.y));
!
! glEnd ();
}
- glDisable (GL_POLYGON_SMOOTH);
glShadeModel (GL_FLAT);
!
! if (intermediate) {
! glBindTexture (GL_TEXTURE_2D, dst->texture);
! glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
! ibounds.x1, dst->height - ibounds.y2,
! 0, 0,
! intermediate->width, intermediate->height);
! glFlush ();
!
! glc_surface_pop_current (surface);
! glc_surface_destroy (intermediate);
! } else
! glc_surface_pop_current (surface);
}
--- 377,390 ----
color_traps->bottom.right_color.blue,
color_traps->bottom.right_color.alpha);
! glVertex2d (FIXED_TO_DOUBLE (color_traps->bottom.right),
! FIXED_TO_DOUBLE (color_traps->bottom.y));
}
+
+ glEnd ();
glShadeModel (GL_FLAT);
!
! glc_surface_dirty (dst, &bounds);
! glc_surface_pop_current (dst);
}
+ slim_hidden_def(glc_color_trapezoids);
Index: glc_tri.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_tri.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** glc_tri.c 9 Dec 2003 19:50:45 -0000 1.6
--- glc_tri.c 3 Feb 2004 15:12:11 -0000 1.7
***************
*** 37,52 ****
glc_region_box_t *box)
{
! box->x1 = XFIXED_TO_INT (points->x);
! box->x2 = XFIXED_TO_INT (XFIXED_CEIL (points->x));
! box->y1 = XFIXED_TO_INT (points->y);
! box->y2 = XFIXED_TO_INT (XFIXED_CEIL (points->y));
points++;
n_point--;
while (n_point-- > 0) {
! int x1 = XFIXED_TO_INT (points->x);
! int x2 = XFIXED_TO_INT (XFIXED_CEIL (points->x));
! int y1 = XFIXED_TO_INT (points->y);
! int y2 = XFIXED_TO_INT (XFIXED_CEIL (points->y));
if (x1 < box->x1)
--- 37,52 ----
glc_region_box_t *box)
{
! box->x1 = FIXED_TO_INT (points->x);
! box->x2 = FIXED_TO_INT (FIXED_CEIL (points->x));
! box->y1 = FIXED_TO_INT (points->y);
! box->y2 = FIXED_TO_INT (FIXED_CEIL (points->y));
points++;
n_point--;
while (n_point-- > 0) {
! int x1 = FIXED_TO_INT (points->x);
! int x2 = FIXED_TO_INT (FIXED_CEIL (points->x));
! int y1 = FIXED_TO_INT (points->y);
! int y2 = FIXED_TO_INT (FIXED_CEIL (points->y));
if (x1 < box->x1)
***************
*** 73,77 ****
glc_surface_t *mask;
glc_region_box_t bounds, mask_bounds;
! int x_draw_offset, y_draw_offset;
glc_point_fixed_bounds (n_tris * 3, (glc_point_fixed_t *) tris, &bounds);
--- 73,77 ----
glc_surface_t *mask;
glc_region_box_t bounds, mask_bounds;
! double x_draw_offset, y_draw_offset;
glc_point_fixed_bounds (n_tris * 3, (glc_point_fixed_t *) tris, &bounds);
***************
*** 97,110 ****
}
! glc_intermediate_bounds (dst, &bounds, &mask_bounds,
! &x_draw_offset, &y_draw_offset);
!
if (mask_bounds.x2 - mask_bounds.x1 <= 0 ||
mask_bounds.y2 - mask_bounds.y1 <= 0)
return;
! mask = glc_surface_create_intermediate (src,
! mask_bounds.x2 - mask_bounds.x1,
! mask_bounds.y2 - mask_bounds.y1);
if (!mask) {
--- 97,114 ----
}
! mask_bounds.x1 = mask_bounds.y1 = 0;
! mask_bounds.x2 = dst->width;
! mask_bounds.y2 = dst->height;
! glc_intersect_region (&bounds, &mask_bounds, &mask_bounds);
! x_draw_offset = (double) -mask_bounds.x1;
! y_draw_offset = (double) -mask_bounds.y1;
!
if (mask_bounds.x2 - mask_bounds.x1 <= 0 ||
mask_bounds.y2 - mask_bounds.y1 <= 0)
return;
! mask = glc_surface_create_similar (dst,
! mask_bounds.x2 - mask_bounds.x1,
! mask_bounds.y2 - mask_bounds.y1);
if (!mask) {
***************
*** 113,117 ****
}
! glc_surface_push_current (mask);
glClearColor (0.0, 0.0, 0.0, 0.0);
--- 117,127 ----
}
! mask->implicit_mask = 1;
!
! if (!glc_surface_push_current
! (mask, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
! glc_surface_pop_current (mask);
! return;
! }
glClearColor (0.0, 0.0, 0.0, 0.0);
***************
*** 120,131 ****
glColorMask (1, 1, 1, 1);
! if (dst->polyedge == GLC_POLYEDGE_SMOOTH) {
! glEnable (GL_POLYGON_SMOOTH);
! glEnable (GL_BLEND);
! glHint(GL_POLYGON_SMOOTH, GL_NICEST);
! glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
! } else {
! glDisable (GL_POLYGON_SMOOTH);
! glDisable (GL_BLEND);
}
--- 130,142 ----
glColorMask (1, 1, 1, 1);
! glc_set_operator (GLC_OPERATOR_SRC);
!
! if (mask->polyedge == GLC_POLYEDGE_SMOOTH) {
! if (!mask->anti_aliasing) {
! glEnable (GL_POLYGON_SMOOTH);
! glEnable (GL_BLEND);
! glHint(GL_POLYGON_SMOOTH, GL_NICEST);
! glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
! }
}
***************
*** 133,150 ****
for (; n_tris; n_tris--, tris++) {
! glVertex2d (x_draw_offset + XFIXED_TO_DOUBLE (tris->p1.x),
! y_draw_offset + XFIXED_TO_DOUBLE (tris->p1.y));
! glVertex2d (x_draw_offset + XFIXED_TO_DOUBLE (tris->p2.x),
! y_draw_offset + XFIXED_TO_DOUBLE (tris->p2.y));
! glVertex2d (x_draw_offset + XFIXED_TO_DOUBLE (tris->p3.x),
! y_draw_offset + XFIXED_TO_DOUBLE (tris->p3.y));
}
glEnd ();
! glDisable (GL_POLYGON_SMOOTH);
!
glc_surface_pop_current (mask);
!
glc_composite (op,
src,
--- 144,167 ----
for (; n_tris; n_tris--, tris++) {
! glVertex2d (x_draw_offset + FIXED_TO_DOUBLE (tris->p1.x),
! y_draw_offset + FIXED_TO_DOUBLE (tris->p1.y));
! glVertex2d (x_draw_offset + FIXED_TO_DOUBLE (tris->p2.x),
! y_draw_offset + FIXED_TO_DOUBLE (tris->p2.y));
! glVertex2d (x_draw_offset + FIXED_TO_DOUBLE (tris->p3.x),
! y_draw_offset + FIXED_TO_DOUBLE (tris->p3.y));
}
glEnd ();
! if (mask->polyedge == GLC_POLYEDGE_SMOOTH) {
! if (!mask->anti_aliasing) {
! glDisable (GL_POLYGON_SMOOTH);
! glDisable (GL_BLEND);
! }
! }
!
! glc_surface_dirty (mask, NULL);
glc_surface_pop_current (mask);
!
glc_composite (op,
src,
***************
*** 155,162 ****
mask_bounds.x1, mask_bounds.y1,
mask->width, mask->height);
!
glc_surface_destroy (mask);
}
!
void
glc_composite_tri_strip (glc_operator_t op,
--- 172,180 ----
mask_bounds.x1, mask_bounds.y1,
mask->width, mask->height);
!
glc_surface_destroy (mask);
}
! slim_hidden_def(glc_composite_triangles);
!
void
glc_composite_tri_strip (glc_operator_t op,
***************
*** 170,174 ****
glc_surface_t *mask;
glc_region_box_t bounds, mask_bounds;
! int x_draw_offset, y_draw_offset;
if (n_points < 3)
--- 188,192 ----
glc_surface_t *mask;
glc_region_box_t bounds, mask_bounds;
! double x_draw_offset, y_draw_offset;
if (n_points < 3)
***************
*** 197,210 ****
}
! glc_intermediate_bounds (dst, &bounds, &mask_bounds,
! &x_draw_offset, &y_draw_offset);
!
if (mask_bounds.x2 - mask_bounds.x1 <= 0 ||
mask_bounds.y2 - mask_bounds.y1 <= 0)
return;
! mask = glc_surface_create_intermediate (src,
! mask_bounds.x2 - mask_bounds.x1,
! mask_bounds.y2 - mask_bounds.y1);
if (!mask) {
--- 215,232 ----
}
! mask_bounds.x1 = mask_bounds.y1 = 0;
! mask_bounds.x2 = dst->width;
! mask_bounds.y2 = dst->height;
! glc_intersect_region (&bounds, &mask_bounds, &mask_bounds);
! x_draw_offset = (double) -mask_bounds.x1;
! y_draw_offset = (double) -mask_bounds.y1;
!
if (mask_bounds.x2 - mask_bounds.x1 <= 0 ||
mask_bounds.y2 - mask_bounds.y1 <= 0)
return;
! mask = glc_surface_create_similar (dst,
! mask_bounds.x2 - mask_bounds.x1,
! mask_bounds.y2 - mask_bounds.y1);
if (!mask) {
***************
*** 213,217 ****
}
! glc_surface_push_current (mask);
glClearColor (0.0, 0.0, 0.0, 0.0);
--- 235,245 ----
}
! mask->implicit_mask = 1;
!
! if (!glc_surface_push_current
! (mask, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
! glc_surface_pop_current (mask);
! return;
! }
glClearColor (0.0, 0.0, 0.0, 0.0);
***************
*** 220,231 ****
glColorMask (1, 1, 1, 1);
! if (dst->polyedge == GLC_POLYEDGE_SMOOTH) {
! glEnable (GL_POLYGON_SMOOTH);
! glEnable (GL_BLEND);
! glHint(GL_POLYGON_SMOOTH, GL_NICEST);
! glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
! } else {
! glDisable (GL_POLYGON_SMOOTH);
! glDisable (GL_BLEND);
}
--- 248,260 ----
glColorMask (1, 1, 1, 1);
! glc_set_operator (GLC_OPERATOR_SRC);
!
! if (mask->polyedge == GLC_POLYEDGE_SMOOTH) {
! if (!mask->anti_aliasing) {
! glEnable (GL_POLYGON_SMOOTH);
! glEnable (GL_BLEND);
! glHint(GL_POLYGON_SMOOTH, GL_NICEST);
! glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
! }
}
***************
*** 233,243 ****
for (; n_points; n_points--, points++)
! glVertex2d (x_draw_offset + XFIXED_TO_DOUBLE (points->x),
! y_draw_offset + XFIXED_TO_DOUBLE (points->y));
glEnd ();
! glDisable (GL_POLYGON_SMOOTH);
!
glc_surface_pop_current (mask);
--- 262,278 ----
for (; n_points; n_points--, points++)
! glVertex2d (x_draw_offset + FIXED_TO_DOUBLE (points->x),
! y_draw_offset + FIXED_TO_DOUBLE (points->y));
glEnd ();
! if (mask->polyedge == GLC_POLYEDGE_SMOOTH) {
! if (!mask->anti_aliasing) {
! glDisable (GL_POLYGON_SMOOTH);
! glDisable (GL_BLEND);
! }
! }
!
! glc_surface_dirty (mask, NULL);
glc_surface_pop_current (mask);
***************
*** 250,256 ****
mask_bounds.x1, mask_bounds.y1,
mask->width, mask->height);
!
glc_surface_destroy (mask);
}
void
--- 285,292 ----
mask_bounds.x1, mask_bounds.y1,
mask->width, mask->height);
!
glc_surface_destroy (mask);
}
+ slim_hidden_def(glc_composite_tri_strip);
void
***************
*** 265,269 ****
glc_surface_t *mask;
glc_region_box_t bounds, mask_bounds;
! int x_draw_offset, y_draw_offset;
if (n_points < 3)
--- 301,305 ----
glc_surface_t *mask;
glc_region_box_t bounds, mask_bounds;
! double x_draw_offset, y_draw_offset;
if (n_points < 3)
***************
*** 291,305 ****
return;
}
-
- glc_intermediate_bounds (dst, &bounds, &mask_bounds,
- &x_draw_offset, &y_draw_offset);
if (mask_bounds.x2 - mask_bounds.x1 <= 0 ||
mask_bounds.y2 - mask_bounds.y1 <= 0)
return;
! mask = glc_surface_create_intermediate (src,
! mask_bounds.x2 - mask_bounds.x1,
! mask_bounds.y2 - mask_bounds.y1);
if (!mask) {
--- 327,345 ----
return;
}
+ mask_bounds.x1 = mask_bounds.y1 = 0;
+ mask_bounds.x2 = dst->width;
+ mask_bounds.y2 = dst->height;
+ glc_intersect_region (&bounds, &mask_bounds, &mask_bounds);
+ x_draw_offset = (double) -mask_bounds.x1;
+ y_draw_offset = (double) -mask_bounds.y1;
+
if (mask_bounds.x2 - mask_bounds.x1 <= 0 ||
mask_bounds.y2 - mask_bounds.y1 <= 0)
return;
! mask = glc_surface_create_similar (dst,
! mask_bounds.x2 - mask_bounds.x1,
! mask_bounds.y2 - mask_bounds.y1);
if (!mask) {
***************
*** 307,312 ****
return;
}
! glc_surface_push_current (mask);
glClearColor (0.0, 0.0, 0.0, 0.0);
--- 347,358 ----
return;
}
+
+ mask->implicit_mask = 1;
! if (!glc_surface_push_current
! (mask, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
! glc_surface_pop_current (mask);
! return;
! }
glClearColor (0.0, 0.0, 0.0, 0.0);
***************
*** 315,326 ****
glColorMask (1, 1, 1, 1);
! if (dst->polyedge == GLC_POLYEDGE_SMOOTH) {
! glEnable (GL_POLYGON_SMOOTH);
! glEnable (GL_BLEND);
! glHint(GL_POLYGON_SMOOTH, GL_NICEST);
! glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
! } else {
! glDisable (GL_POLYGON_SMOOTH);
! glDisable (GL_BLEND);
}
--- 361,373 ----
glColorMask (1, 1, 1, 1);
! glc_set_operator (GLC_OPERATOR_SRC);
!
! if (mask->polyedge == GLC_POLYEDGE_SMOOTH) {
! if (!mask->anti_aliasing) {
! glEnable (GL_POLYGON_SMOOTH);
! glEnable (GL_BLEND);
! glHint(GL_POLYGON_SMOOTH, GL_NICEST);
! glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);
! }
}
***************
*** 328,340 ****
for (; n_points; n_points--, points++)
! glVertex2d (x_draw_offset + XFIXED_TO_DOUBLE (points->x),
! y_draw_offset + XFIXED_TO_DOUBLE (points->y));
glEnd ();
! glDisable (GL_POLYGON_SMOOTH);
!
glc_surface_pop_current (mask);
!
glc_composite (op,
src,
--- 375,393 ----
for (; n_points; n_points--, points++)
! glVertex2d (x_draw_offset + FIXED_TO_DOUBLE (points->x),
! y_draw_offset + FIXED_TO_DOUBLE (points->y));
glEnd ();
! if (mask->polyedge == GLC_POLYEDGE_SMOOTH) {
! if (!mask->anti_aliasing) {
! glDisable (GL_POLYGON_SMOOTH);
! glDisable (GL_BLEND);
! }
! }
!
! glc_surface_dirty (mask, NULL);
glc_surface_pop_current (mask);
!
glc_composite (op,
src,
***************
*** 345,351 ****
mask_bounds.x1, mask_bounds.y1,
mask->width, mask->height);
!
glc_surface_destroy (mask);
}
static void
--- 398,405 ----
mask_bounds.x1, mask_bounds.y1,
mask->width, mask->height);
!
glc_surface_destroy (mask);
}
+ slim_hidden_def(glc_composite_tri_fan);
static void
***************
*** 354,372 ****
glc_region_box_t *box)
{
! box->x1 = MIN (MIN (XFIXED_TO_INT (color_tris->p1.point.x),
! XFIXED_TO_INT (color_tris->p2.point.x)),
! XFIXED_TO_INT (color_tris->p3.point.x));
! box->x2 = MAX (MAX (XFIXED_TO_INT (XFIXED_CEIL (color_tris->p1.point.x)),
! XFIXED_TO_INT (XFIXED_CEIL (color_tris->p2.point.x))),
! XFIXED_TO_INT (XFIXED_CEIL (color_tris->p3.point.x)));
! box->y1 = MIN (MIN (XFIXED_TO_INT (color_tris->p1.point.y),
! XFIXED_TO_INT (color_tris->p2.point.y)),
! XFIXED_TO_INT (color_tris->p3.point.y));
! box->y2 = MAX (MAX (XFIXED_TO_INT (XFIXED_CEIL (color_tris->p1.point.y)),
! XFIXED_TO_INT (XFIXED_CEIL (color_tris->p2.point.y))),
! XFIXED_TO_INT (XFIXED_CEIL (color_tris->p3.point.y)));
color_tris++;
--- 408,426 ----
glc_region_box_t *box)
{
! box->x1 = MIN (MIN (FIXED_TO_INT (color_tris->p1.point.x),
! FIXED_TO_INT (color_tris->p2.point.x)),
! FIXED_TO_INT (color_tris->p3.point.x));
! box->x2 = MAX (MAX (FIXED_TO_INT (FIXED_CEIL (color_tris->p1.point.x)),
! FIXED_TO_INT (FIXED_CEIL (color_tris->p2.point.x))),
! FIXED_TO_INT (FIXED_CEIL (color_tris->p3.point.x)));
! box->y1 = MIN (MIN (FIXED_TO_INT (color_tris->p1.point.y),
! FIXED_TO_INT (color_tris->p2.point.y)),
! FIXED_TO_INT (color_tris->p3.point.y));
! box->y2 = MAX (MAX (FIXED_TO_INT (FIXED_CEIL (color_tris->p1.point.y)),
! FIXED_TO_INT (FIXED_CEIL (color_tris->p2.point.y))),
! FIXED_TO_INT (FIXED_CEIL (color_tris->p3.point.y)));
color_tris++;
***************
*** 376,400 ****
int16_t x1, y1, x2, y2;
! x1 = MIN (MIN (XFIXED_TO_INT (color_tris->p1.point.x),
! XFIXED_TO_INT (color_tris->p2.point.x)),
! XFIXED_TO_INT (color_tris->p3.point.x));
if (x1 < box->x1)
box->x1 = x1;
! x2 = MAX (MAX (XFIXED_TO_INT (XFIXED_CEIL (color_tris->p1.point.x)),
! XFIXED_TO_INT (XFIXED_CEIL (color_tris->p2.point.x))),
! XFIXED_TO_INT (XFIXED_CEIL (color_tris->p3.point.x)));
if (x2 > box->x2)
box->x2 = x2;
! y1 = MIN (MIN (XFIXED_TO_INT (color_tris->p1.point.y),
! XFIXED_TO_INT (color_tris->p2.point.y)),
! XFIXED_TO_INT (color_tris->p3.point.y));
if (y1 < box->y1)
box->y1 = y1;
! y2 = MAX (MAX (XFIXED_TO_INT (XFIXED_CEIL (color_tris->p1.point.y)),
! XFIXED_TO_INT (XFIXED_CEIL (color_tris->p2.point.y))),
! XFIXED_TO_INT (XFIXED_CEIL (color_tris->p3.point.y)));
if (y2 > box->y2)
box->y2 = y2;
--- 430,454 ----
int16_t x1, y1, x2, y2;
! x1 = MIN (MIN (FIXED_TO_INT (color_tris->p1.point.x),
! FIXED_TO_INT (color_tris->p2.point.x)),
! FIXED_TO_INT (color_tris->p3.point.x));
if (x1 < box->x1)
box->x1 = x1;
! x2 = MAX (MAX (FIXED_TO_INT (FIXED_CEIL (color_tris->p1.point.x)),
! FIXED_TO_INT (FIXED_CEIL (color_tris->p2.point.x))),
! FIXED_TO_INT (FIXED_CEIL (color_tris->p3.point.x)));
if (x2 > box->x2)
box->x2 = x2;
! y1 = MIN (MIN (FIXED_TO_INT (color_tris->p1.point.y),
! FIXED_TO_INT (color_tris->p2.point.y)),
! FIXED_TO_INT (color_tris->p3.point.y));
if (y1 < box->y1)
box->y1 = y1;
! y2 = MAX (MAX (FIXED_TO_INT (FIXED_CEIL (color_tris->p1.point.y)),
! FIXED_TO_INT (FIXED_CEIL (color_tris->p2.point.y))),
! FIXED_TO_INT (FIXED_CEIL (color_tris->p3.point.y)));
if (y2 > box->y2)
box->y2 = y2;
***************
*** 411,419 ****
int n_color_tris)
{
! glc_surface_t *intermediate = NULL;
! glc_surface_t *surface;
! glc_region_box_t bounds, ibounds;
! int x_draw_offset = 0, y_draw_offset = 0;
! glc_bool_t shade;
glc_color_triangle_bounds (n_color_tris, color_tris, &bounds);
--- 465,471 ----
int n_color_tris)
{
! glc_region_box_t bounds;
! int index;
! glc_bool_t shade = 0;
glc_color_triangle_bounds (n_color_tris, color_tris, &bounds);
***************
*** 423,499 ****
return;
! if (dst->type == GLC_SURFACE_TEXTURE_TYPE) {
! glc_intermediate_bounds (dst, &bounds, &ibounds,
! &x_draw_offset, &y_draw_offset);
!
! if (ibounds.x2 - ibounds.x1 <= 0 || ibounds.y2 - ibounds.y1 <= 0)
! return;
!
! intermediate = surface =
! glc_surface_create_intermediate (dst,
! ibounds.x2 - ibounds.x1,
! ibounds.y2 - ibounds.y1);
!
! if (!surface) {
! glc_surface_status_add (dst, GLC_STATUS_NOT_SUPPORTED_MASK);
! return;
! }
!
! glc_surface_disable_transform_and_repeat (dst);
! glc_composite (GLC_OPERATOR_SRC,
! dst,
! NULL,
! surface,
! ibounds.x1, ibounds.y1,
! 0, 0,
! 0, 0,
! intermediate->width, intermediate->height);
! glc_surface_enable_transform_and_repeat (dst);
! } else
! surface = dst;
!
! glc_surface_push_current (surface);
!
! if (dst->polyedge == GLC_POLYEDGE_SMOOTH)
! glEnable (GL_POLYGON_SMOOTH);
! else
! glDisable (GL_POLYGON_SMOOTH);
glc_set_operator (op);
! for (; n_color_tris; n_color_tris--, color_tris++) {
! if (memcmp (&color_tris->p1.color,
! &color_tris->p2.color, sizeof (glc_color_t)) ||
! memcmp (&color_tris->p2.color,
! &color_tris->p3.color, sizeof (glc_color_t))) {
! shade = 1;
glShadeModel (GL_SMOOTH);
! } else {
! shade = 0;
! glShadeModel (GL_FLAT);
! glColor4us (color_tris->p1.color.red,
! color_tris->p1.color.green,
! color_tris->p1.color.blue,
! color_tris->p1.color.alpha);
!
}
!
! glBegin (GL_TRIANGLES);
! if (shade)
! glColor4us (color_tris->p1.color.red,
! color_tris->p1.color.green,
! color_tris->p1.color.blue,
! color_tris->p1.color.alpha);
! glVertex2d (x_draw_offset + XFIXED_TO_DOUBLE (color_tris->p1.point.x),
! y_draw_offset + XFIXED_TO_DOUBLE (color_tris->p1.point.y));
if (shade)
glColor4us (color_tris->p2.color.red,
color_tris->p2.color.green,
color_tris->p2.color.blue,
! color_tris->p2.color.alpha);
! glVertex2d (x_draw_offset + XFIXED_TO_DOUBLE (color_tris->p2.point.x),
! y_draw_offset + XFIXED_TO_DOUBLE (color_tris->p2.point.y));
if (shade)
--- 475,515 ----
return;
! if (!glc_surface_push_current
! (dst, GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT)) {
! glc_surface_pop_current (dst);
! return;
! }
glc_set_operator (op);
! glShadeModel (GL_FLAT);
! for (index = 0; index < n_color_tris; index++) {
! if (memcmp (&color_tris[index].p1.color,
! &color_tris[index].p2.color, sizeof (glc_color_t)) ||
! memcmp (&color_tris[index].p2.color,
! &color_tris[index].p3.color, sizeof (glc_color_t))) {
glShadeModel (GL_SMOOTH);
! shade = 1;
! break;
}
! }
! glBegin (GL_TRIANGLES);
+ for (; n_color_tris; n_color_tris--, color_tris++) {
+ glColor4us (color_tris->p1.color.red,
+ color_tris->p1.color.green,
+ color_tris->p1.color.blue,
+ color_tris->p1.color.alpha);
+ glVertex2d (FIXED_TO_DOUBLE (color_tris->p1.point.x),
+ FIXED_TO_DOUBLE (color_tris->p1.point.y));
+
if (shade)
glColor4us (color_tris->p2.color.red,
color_tris->p2.color.green,
color_tris->p2.color.blue,
! color_tris->p2.color.alpha);
! glVertex2d (FIXED_TO_DOUBLE (color_tris->p2.point.x),
! FIXED_TO_DOUBLE (color_tris->p2.point.y));
if (shade)
***************
*** 501,525 ****
color_tris->p3.color.green,
color_tris->p3.color.blue,
! color_tris->p3.color.alpha);
! glVertex2d (x_draw_offset + XFIXED_TO_DOUBLE (color_tris->p3.point.x),
! y_draw_offset + XFIXED_TO_DOUBLE (color_tris->p3.point.y));
!
! glEnd ();
}
! glDisable (GL_POLYGON_SMOOTH);
glShadeModel (GL_FLAT);
! if (intermediate) {
! glBindTexture (GL_TEXTURE_2D, dst->texture);
! glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
! ibounds.x1, dst->height - ibounds.y2,
! 0, 0,
! intermediate->width, intermediate->height);
! glFlush ();
!
! glc_surface_pop_current (surface);
! glc_surface_destroy (intermediate);
! } else
! glc_surface_pop_current (surface);
}
--- 517,531 ----
color_tris->p3.color.green,
color_tris->p3.color.blue,
! color_tris->p3.color.alpha);
! glVertex2d (FIXED_TO_DOUBLE (color_tris->p3.point.x),
! FIXED_TO_DOUBLE (color_tris->p3.point.y));
}
! glEnd ();
!
glShadeModel (GL_FLAT);
! glc_surface_dirty (dst, &bounds);
! glc_surface_pop_current (dst);
}
+ slim_hidden_def(glc_color_triangles);
Index: glc_util.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_util.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** glc_util.c 9 Dec 2003 19:50:45 -0000 1.5
--- glc_util.c 3 Feb 2004 15:12:11 -0000 1.6
***************
*** 36,70 ****
void
- glc_intermediate_bounds (glc_surface_t *surface,
- glc_region_box_t *bounds,
- glc_region_box_t *ibounds,
- int *x_draw_offset,
- int *y_draw_offset)
- {
- if (bounds->x1 <= 0)
- ibounds->x1 = 0;
- else
- ibounds->x1 = bounds->x1;
-
- if (bounds->x2 >= surface->width)
- ibounds->x2 = surface->width;
- else
- ibounds->x2 = bounds->x2;
-
- if (bounds->y1 <= 0)
- ibounds->y1 = 0;
- else
- ibounds->y1 = bounds->y1;
-
- if (bounds->y2 >= surface->height)
- ibounds->y2 = surface->height;
- else
- ibounds->y2 = bounds->y2;
-
- *x_draw_offset = (ibounds->x1 > 0)? -ibounds->x1: 0;
- *y_draw_offset = (ibounds->y1 > 0)? -ibounds->y1: 0;
- }
-
- void
glc_intersect_region (glc_region_box_t *box1,
glc_region_box_t *box2,
--- 36,39 ----
***************
*** 83,86 ****
--- 52,66 ----
}
+ void
+ glc_union_region (glc_region_box_t *box1,
+ glc_region_box_t *box2,
+ glc_region_box_t *return_box)
+ {
+ return_box->x1 = (box1->x1 <= box2->x1)? box1->x1: box2->x1;
+ return_box->x2 = (box1->x2 >= box2->x2)? box1->x2: box2->x2;
+ return_box->y1 = (box1->y1 <= box2->y1)? box1->y1: box2->y1;
+ return_box->y2 = (box1->y2 >= box2->y2)? box1->y2: box2->y2;
+ }
+
int
glc_get_pixelsize_from_components (int red,
***************
*** 113,117 ****
}
! GLenum
glc_get_texture_format_from_pixelsize (int pixelsize)
{
--- 93,97 ----
}
! unsigned int
glc_get_texture_format_from_pixelsize (int pixelsize)
{
***************
*** 132,136 ****
}
! GLenum
glc_get_texture_data_type_from_pixelsize (int pixelsize)
{
--- 112,116 ----
}
! unsigned int
glc_get_texture_data_type_from_pixelsize (int pixelsize)
{
***************
*** 171,175 ****
long int mask = 0;
int i;
!
for (i = 0; extensions_map[i].name; i++)
if (_glc_extension_check (extensions_string, extensions_map[i].name))
--- 151,155 ----
long int mask = 0;
int i;
!
for (i = 0; extensions_map[i].name; i++)
if (_glc_extension_check (extensions_string, extensions_map[i].name))
Index: glcint.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glcint.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** glcint.h 13 Dec 2003 02:28:44 -0000 1.10
--- glcint.h 3 Feb 2004 15:12:11 -0000 1.11
***************
*** 73,76 ****
--- 73,85 ----
#define GLC_STATUS_INVALID_MATRIX_MASK (1L << 6)
+ #define GLC_TEXTURE_TARGET_RECTANGLE_MASK (1L << 0)
+
+ typedef enum {
+ GLC_CONSTRAINT_NONE,
+ GLC_CONSTRAINT_ANY_CONTEXT_CURRENT,
+ GLC_CONSTRAINT_SURFACE_CONTEXT_CURRENT,
+ GLC_CONSTRAINT_SURFACE_DRAWABLE_CURRENT
+ } glc_constraint_t;
+
typedef struct _glc_region_box_t {
int x1, x2, y1, y2;
***************
*** 85,109 ****
} glc_matrix_t;
typedef struct glc_surface_backend {
glc_surface_t *
! (*create_intermediate) (void *surface,
! int width,
! int height);
void
(*destroy) (void *surface);
! void
! (*push_current) (void *surface);
void
(*pop_current) (void *surface);
- } glc_surface_backend_t;
! typedef enum {
! GLC_SURFACE_WINDOW_TYPE,
! GLC_SURFACE_TEXTURE_TYPE,
! GLC_SURFACE_PBUFFER_TYPE
! } glc_surface_type_t;
struct _glc_surface {
--- 94,140 ----
} glc_matrix_t;
+ typedef struct _glc_texture {
+ unsigned int name;
+ unsigned int target;
+ unsigned int format;
+ glc_bool_t allocated;
+
+ glc_filter_t filter;
+ glc_bool_t repeat;
+
+ int width;
+ int height;
+
+ double texcoord_width;
+ double texcoord_height;
+
+ glc_bool_t repeatable;
+ } glc_texture_t;
+
typedef struct glc_surface_backend {
glc_surface_t *
! (*create_similar) (void *surface,
! int width,
! int height);
void
(*destroy) (void *surface);
! glc_bool_t
! (*push_current) (void *surface,
! glc_constraint_t constraint);
void
(*pop_current) (void *surface);
! glc_texture_t *
! (*get_texture) (void *surface);
!
! void
! (*realize) (void *surface);
!
! void
! (*swap_buffers) (void *surface);
! } glc_surface_backend_t;
struct _glc_surface {
***************
*** 111,126 ****
long int status_mask;
- glc_surface_type_t type;
glc_filter_t filter;
glc_bool_t repeat;
glc_polyedge_t polyedge;
glc_matrix_t *transform;
! glc_bool_t disable_transform_and_repeat;
int width, height;
- int real_width, real_height;
- GLuint texture;
glc_bool_t red, green, blue, alpha;
};
-
typedef struct _glc_extension_map {
char *name;
--- 142,158 ----
long int status_mask;
glc_filter_t filter;
glc_bool_t repeat;
glc_polyedge_t polyedge;
glc_matrix_t *transform;
! glc_bool_t disable_transform;
! glc_bool_t anti_aliasing;
int width, height;
glc_bool_t red, green, blue, alpha;
+ glc_bool_t implicit_mask;
+ glc_bool_t dirty;
+ glc_region_box_t dirty_region;
+ glc_bool_t requires_flipping;
};
typedef struct _glc_extension_map {
char *name;
***************
*** 139,153 ****
extern void __internal_linkage
- glc_intermediate_bounds (glc_surface_t *surface,
- glc_region_box_t *bounds,
- glc_region_box_t *ibounds,
- int *x_draw_offset,
- int *y_draw_offset);
-
- extern void __internal_linkage
glc_intersect_region (glc_region_box_t *box1,
glc_region_box_t *box2,
glc_region_box_t *return_box);
extern int __internal_linkage
glc_get_pixelsize_from_components (int red,
--- 171,183 ----
extern void __internal_linkage
glc_intersect_region (glc_region_box_t *box1,
glc_region_box_t *box2,
glc_region_box_t *return_box);
+ extern void __internal_linkage
+ glc_union_region (glc_region_box_t *box1,
+ glc_region_box_t *box2,
+ glc_region_box_t *return_box);
+
extern int __internal_linkage
glc_get_pixelsize_from_components (int red,
***************
*** 155,162 ****
int blue,
int alpha);
! extern GLenum __internal_linkage
glc_get_texture_format_from_pixelsize (int pixelsize);
! extern GLenum __internal_linkage
glc_get_texture_data_type_from_pixelsize (int pixelsize);
--- 185,193 ----
int blue,
int alpha);
!
! extern unsigned int __internal_linkage
glc_get_texture_format_from_pixelsize (int pixelsize);
! extern unsigned int __internal_linkage
glc_get_texture_data_type_from_pixelsize (int pixelsize);
***************
*** 165,178 ****
glc_extension_map *extensions_map);
! extern GLuint __internal_linkage
! glc_texture_create (int width,
! int height,
! GLenum texture_format,
! int *texture_width,
! int *texture_height);
extern void __internal_linkage
! glc_texture_destroy (GLuint texture);
extern void __internal_linkage
--- 196,230 ----
glc_extension_map *extensions_map);
+ extern glc_texture_t *__internal_linkage
+ glc_texture_generate (int width,
+ int height,
+ unsigned int texture_format,
+ long int target_mask);
! extern void __internal_linkage
! glc_texture_allocate (glc_texture_t *texture);
extern void __internal_linkage
! glc_texture_destroy (glc_texture_t *texture);
!
! extern void __internal_linkage
! glc_texture_ensure_filter (glc_texture_t *texture,
! glc_filter_t filter);
!
! extern void __internal_linkage
! glc_texture_ensure_repeat (glc_texture_t *texture,
! glc_bool_t repeat);
!
! extern void __internal_linkage
! glc_texture_bind (glc_texture_t *texture);
!
! extern void __internal_linkage
! glc_texture_unbind (glc_texture_t *texture);
!
!
! extern void __internal_linkage
! glc_texture_copy_surface (glc_texture_t *texture,
! glc_surface_t *surface,
! glc_region_box_t *region);
extern void __internal_linkage
***************
*** 184,196 ****
extern glc_surface_t * __internal_linkage
! glc_surface_create_intermediate (glc_surface_t *templ,
! int width,
! int height);
extern void __internal_linkage
glc_surface_destory (glc_surface_t *surface);
! extern void __internal_linkage
! glc_surface_push_current (glc_surface_t *surface);
extern void __internal_linkage
--- 236,252 ----
extern glc_surface_t * __internal_linkage
! glc_surface_create_similar (glc_surface_t *templ,
! int width,
! int height);
!
! extern glc_texture_t *__internal_linkage
! glc_surface_get_texture (glc_surface_t *surface);
extern void __internal_linkage
glc_surface_destory (glc_surface_t *surface);
! extern glc_bool_t __internal_linkage
! glc_surface_push_current (glc_surface_t *surface,
! glc_constraint_t constraint);
extern void __internal_linkage
***************
*** 198,213 ****
extern void __internal_linkage
glc_surface_status_add (glc_surface_t *surface, int flags);
extern void __internal_linkage
! glc_surface_disable_transform_and_repeat (glc_surface_t *surface);
extern void __internal_linkage
! glc_surface_enable_transform_and_repeat (glc_surface_t *surface);
extern void __internal_linkage
glc_surface_setup_environment (glc_surface_t *surface);
! extern GLenum __internal_linkage
glc_surface_get_texture_format (glc_surface_t *surface);
--- 254,273 ----
extern void __internal_linkage
+ glc_surface_dirty (glc_surface_t *surface,
+ glc_region_box_t *region);
+
+ extern void __internal_linkage
glc_surface_status_add (glc_surface_t *surface, int flags);
extern void __internal_linkage
! glc_surface_disable_transform (glc_surface_t *surface);
extern void __internal_linkage
! glc_surface_enable_transform (glc_surface_t *surface);
extern void __internal_linkage
glc_surface_setup_environment (glc_surface_t *surface);
! extern unsigned int __internal_linkage
glc_surface_get_texture_format (glc_surface_t *surface);
***************
*** 225,229 ****
#ifdef WIN32
! typedef __int64 x_fixed_32_32;
#else
# if defined(__alpha__) || defined(__alpha) || \
--- 285,289 ----
#ifdef WIN32
! typedef __int64 glc_fixed_32_32;
#else
# if defined(__alpha__) || defined(__alpha) || \
***************
*** 232,236 ****
defined(__s390x__) || \
defined(x86_64) || defined (__x86_64__)
! typedef long x_fixed_32_32;
# else
# if defined(__GNUC__) && \
--- 292,296 ----
defined(__s390x__) || \
defined(x86_64) || defined (__x86_64__)
! typedef long glc_fixed_32_32;
# else
# if defined(__GNUC__) && \
***************
*** 239,277 ****
__extension__
# endif
! typedef long long int x_fixed_32_32;
# endif
#endif
! typedef uint32_t x_fixed_1_31;
! typedef uint32_t x_fixed_1_16;
! typedef int32_t x_fixed_16_16;
/*
! * An unadorned "x_fixed" is the same as x_fixed_16_16,
* (since it's quite common in the code)
*/
! typedef x_fixed_16_16 x_fixed;
! #define XFIXED_BITS 16
! #define XFIXED_TO_INT(f) (int) ((f) >> XFIXED_BITS)
! #define INT_TO_XFIXED(i) ((x_fixed) (i) << XFIXED_BITS)
! #define XFIXED_E ((x_fixed) 1)
! #define XFIXED1 (INT_TO_XFIXED(1))
! #define XFIXED1_MINUS_E (XFIXED1 - XFIXED_E)
! #define XFIXED_FRAC(f) ((f) & XFIXED1_MINUS_E)
! #define XFIXED_FLOOR(f) ((f) & ~XFIXED1_MINUS_E)
! #define XFIXED_CEIL(f) XFIXED_FLOOR((f) + XFIXED1_MINUS_E)
! #define XFIXED_FRACTION(f) ((f) & XFIXED1_MINUS_E)
! #define XFIXED_MOD2(f) ((f) & (XFIXED1 | XFIXED1_MINUS_E))
- #define XFIXED_TO_DOUBLE(f) (((double) (f)) / 65536)
- #define DOUBLE_TO_XFIXED(f) ((int) ((f) * 65536))
#ifdef LIBGLC_HAS_GLX_BACKEND
typedef struct _glc_glx_surface glc_glx_surface_t;
typedef struct _glc_glx_list_node_t {
--- 299,393 ----
__extension__
# endif
! typedef long long int glc_fixed_32_32;
# endif
#endif
! typedef uint32_t glc_fixed_1_31;
! typedef uint32_t glc_fixed_1_16;
! typedef int32_t glc_fixed_16_16;
/*
! * An unadorned "glc_fixed" is the same as glc_fixed_16_16,
* (since it's quite common in the code)
*/
! typedef glc_fixed_16_16 glc_fixed;
! #define FIXED_BITS 16
! #define FIXED_TO_INT(f) (int) ((f) >> FIXED_BITS)
! #define INT_TO_FIXED(i) ((glc_fixed) (i) << FIXED_BITS)
! #define FIXED_E ((glc_fixed) 1)
! #define FIXED1 (INT_TO_FIXED(1))
! #define FIXED1_MINUS_E (FIXED1 - FIXED_E)
! #define FIXED_FRAC(f) ((f) & FIXED1_MINUS_E)
! #define FIXED_FLOOR(f) ((f) & ~FIXED1_MINUS_E)
! #define FIXED_CEIL(f) FIXED_FLOOR((f) + FIXED1_MINUS_E)
! #define FIXED_FRACTION(f) ((f) & FIXED1_MINUS_E)
! #define FIXED_MOD2(f) ((f) & (FIXED1 | FIXED1_MINUS_E))
!
! #define FIXED_TO_DOUBLE(f) (((double) (f)) / 65536)
! #define DOUBLE_TO_FIXED(f) ((int) ((f) * 65536))
+ /* Avoid unnecessary PLT entries. */
+ slim_hidden_proto(glc_surface_set_transform)
+ slim_hidden_proto(glc_surface_set_repeat)
+ slim_hidden_proto(glc_surface_set_filter)
+ slim_hidden_proto(glc_surface_set_polyedge)
+ slim_hidden_proto(glc_surface_get_width)
+ 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)
+ slim_hidden_proto(glc_surface_draw_pixels)
+ slim_hidden_proto(glc_surface_get_status)
+ slim_hidden_proto(glc_surface_get_gl_texture)
+ slim_hidden_proto(glc_surface_gl_begin)
+ slim_hidden_proto(glc_surface_gl_end)
+ slim_hidden_proto(glc_fill_rectangle)
+ slim_hidden_proto(glc_fill_rectangles)
+ slim_hidden_proto(glc_composite_trapezoids)
+ slim_hidden_proto(glc_color_trapezoids)
+ slim_hidden_proto(glc_composite_triangles)
+ slim_hidden_proto(glc_composite_tri_strip)
+ slim_hidden_proto(glc_composite_tri_fan)
+ slim_hidden_proto(glc_color_triangles)
+
+
#ifdef LIBGLC_HAS_GLX_BACKEND
+ #define GLX_GLXEXT_PROTOTYPES 1
+
+ #include <GL/glx.h>
+
+ #ifdef HAVE_GL_GLXATI_H
+ # include <GL/glxATI.h>
+ #endif
+
+ #define GLC_GLX_MULTISAMPLE_MAX_SAMPLES 8
+
+ #define GLC_GLX_FEATURE_FBCONFIG_MASK (1L << 0)
+ #define GLC_GLX_FEATURE_PBUFFER_MASK (1L << 1)
+ #define GLC_GLX_FEATURE_RENDER_TEXTURE_MASK (1L << 2)
+ #define GLC_GLX_FEATURE_TEXTURE_RECTANGLE_MASK (1L << 3)
+ #define GLC_GLX_FEATURE_MULTISAMPLE_MASK (1L << 4)
+ #define GLC_GLX_FEATURE_CLIENT_MULTISAMPLE_MASK (1L << 5)
+ #define GLC_GLX_FEATURE_MULTISAMPLE_FILTER_MASK (1L << 6)
+
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 {
+
+ #ifdef GLX_ATI_render_texture
+ PFNGLXBINDTEXIMAGEATIPROC glx_bind_tex_image_ati;
+ PFNGLXRELEASETEXIMAGEATIPROC glx_release_tex_image_ati;
+ #endif
+
+ glc_bool_t supported;
+ } glc_glx_proc_address_list_t;
typedef struct _glc_glx_list_node_t {
***************
*** 296,306 ****
typedef struct _glc_glx_context_info_t {
struct _glc_glx_context_info_t *previous;
- Display *display;
- GLXDrawable drawable;
- GLXContext context;
glc_glx_surface_t *surface;
} glc_glx_context_info_t;
! typedef struct _glc_glx_screen_info_t {
glc_glx_display_info_t *display_info;
int screen;
--- 412,427 ----
typedef struct _glc_glx_context_info_t {
struct _glc_glx_context_info_t *previous;
glc_glx_surface_t *surface;
+ glc_constraint_t constraint;
} glc_glx_context_info_t;
! 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;
***************
*** 308,332 ****
glc_glx_context_node_t *contexts;
glc_glx_context_info_t *context_stack;
! GLXPixmap root_drawable;
! GLXContext root_context;
! GLXPixmap current_drawable;
! GLXContext current_context;
long int feature_mask;
! } glc_glx_screen_info_t;
!
! typedef struct _glc_glx_fbid_t {
! XID fbid;
! glc_glx_format_type_t type;
! } glc_glx_fbid_t;
!
! typedef struct _glc_glx_context_t {
! GLXContext context;
! unsigned int ref_count;
! glc_glx_screen_info_t *screen_info;
! union {
! glc_glx_fbid_t fb;
! VisualID visual;
! } id;
! } glc_glx_context_t;
struct _glc_glx_surface {
--- 429,441 ----
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;
! long int texture_mask;
! };
struct _glc_glx_surface {
***************
*** 336,340 ****
--- 445,452 ----
glc_glx_context_t *context;
glc_glx_format_t *format;
+ glc_texture_t *texture;
GLXDrawable drawable;
+ GLXPbuffer pbuffer;
+ glc_bool_t render_texture;
};
***************
*** 356,369 ****
glc_glx_format_t *format);
extern void __internal_linkage
glc_glx_context_release (glc_glx_context_t *context);
! extern void __internal_linkage
! glc_glx_context_push_current (glc_glx_context_t *context,
! glc_glx_surface_t *surface,
! GLXDrawable drawable);
extern glc_glx_surface_t * __internal_linkage
! glc_glx_context_pop_current (glc_glx_context_t *context);
extern void __internal_linkage
--- 468,486 ----
glc_glx_format_t *format);
+ extern glc_glx_context_t *__internal_linkage
+ glc_glx_context_get_default (glc_glx_screen_info_t *screen_info);
+
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
***************
*** 373,378 ****
glc_glx_pbuffer_create (Display *display,
GLXFBConfig fbconfig,
! int width,
! int height);
extern void __internal_linkage
--- 490,495 ----
glc_glx_pbuffer_create (Display *display,
GLXFBConfig fbconfig,
! glc_texture_t *texture,
! glc_bool_t render_texture);
extern void __internal_linkage
***************
*** 380,385 ****
--- 497,624 ----
GLXPbuffer pbuffer);
+ /* Avoid unnecessary PLT entries. */
+
+ 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)
+
#endif /* LIBGLC_HAS_GLX_BACKEND */
+ #ifdef LIBGLC_HAS_AGL_BACKEND
+
+ #include <Carbon/Carbon.h>
+ #include <OpenGL/gl.h>
+ #include <OpenGL/glext.h>
+ #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)
+ #define GLC_AGL_FEATURE_MULTISAMPLE_MASK (1L << 2)
+ #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;
+ } glc_agl_context_info_t;
+
+ 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;
+ AGLPbuffer pbuffer;
+ WindowRef window;
+ };
+
+ extern void __internal_linkage
+ glc_agl_query_extensions (glc_agl_thread_info_t *thread_info);
+
+ extern glc_agl_thread_info_t *__internal_linkage
+ 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
+ glc_agl_context_push_current (glc_agl_surface_t *surface,
+ glc_constraint_t constraint);
+
+ extern glc_agl_surface_t *__internal_linkage
+ glc_agl_context_pop_current (glc_agl_surface_t *surface);
+
+ 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
+ glc_agl_pbuffer_destroy (AGLPbuffer pbuffer);
+
+
+ /* Avoid unnecessary PLT entries. */
+
+ 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)
+
+ #endif /* LIBGLC_HAS_AGL_BACKEND */
+
+
#endif /* GLCINT_H_INCLUDED */
More information about the cairo-commit
mailing list