[cairo-commit] libglc/src glc.c,1.8,1.9 glc.h,1.3,1.4 glc_glx_context.c,1.3,1.4 glc_glx_pbuffer.c,1.2,1.3 glc_glx_surface.c,1.4,1.5 glc_rect.c,1.4,1.5 glc_surface.c,1.4,1.5 glc_trap.c,1.4,1.5 glc_tri.c,1.4,1.5
David Reveman
commit at pdx.freedesktop.org
Sat Dec 6 18:42:31 PST 2003
Committed by: davidr
Update of /cvs/cairo/libglc/src
In directory pdx:/tmp/cvs-serv13278/src
Modified Files:
glc.c glc.h glc_glx_context.c glc_glx_pbuffer.c
glc_glx_surface.c glc_rect.c glc_surface.c glc_trap.c
glc_tri.c
Log Message:
New system for handling texture coordinates
Index: glc.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** glc.c 5 Dec 2003 15:22:16 -0000 1.8
--- glc.c 7 Dec 2003 02:42:29 -0000 1.9
***************
*** 96,103 ****
{
glc_surface_t *intermediate = NULL, *mask_intermediate = NULL;
! GLuint src_texture = 0, texture = 0;
! int texture_width, texture_height;
double width_factor, height_factor;
- double tx1, tx2, ty1, ty2;
glc_point_t tl, bl, br, tr;
glc_region_box_t ibounds, clip;
--- 96,102 ----
{
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;
***************
*** 189,193 ****
intermediate->width, intermediate->height);
glc_surface_enable_transform_and_repeat (dst);
! src_texture = dst->texture;
dst = intermediate;
}
--- 188,195 ----
intermediate->width, intermediate->height);
glc_surface_enable_transform_and_repeat (dst);
!
! dst_texture = dst->texture;
! dst_height = dst->height;
!
dst = intermediate;
}
***************
*** 207,213 ****
glBindTexture (GL_TEXTURE_2D, texture);
! glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
! 0, texture_height - src->height,
! 0, 0,
src->width, src->height);
glFlush ();
--- 209,213 ----
glBindTexture (GL_TEXTURE_2D, texture);
! glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 0, 0,
src->width, src->height);
glFlush ();
***************
*** 280,301 ****
repeat_factor_y = (br.y - tl.y) / (double) texture_height;
- tx1 = ty1 = 0.0;
- tx2 = repeat_factor_x;
- ty2 = repeat_factor_y;
-
glBegin (GL_QUADS);
! glTexCoord2d (tx1, ty2);
glVertex2d (x_draw_offset + tl.x, y_draw_offset + tl.y);
! glTexCoord2d (tx2, ty2);
glVertex2d (x_draw_offset + tr.x, y_draw_offset + tr.y);
! glTexCoord2d (tx2, ty1);
glVertex2d (x_draw_offset + br.x, y_draw_offset + br.y);
! glTexCoord2d (tx1, ty1);
glVertex2d (x_draw_offset + bl.x, y_draw_offset + bl.y);
glEnd ();
} else {
! /* CASE 2: Either none power of two sized texture or transformation is set. */
! int tx1i, tx2i, ty1i, ty2i;
double save_tlx, save_trx, save_blx, save_brx;
--- 280,297 ----
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 ();
} else {
! /* CASE 2: Either none power of two sized texture or
! transformation is set. */
double save_tlx, save_trx, save_blx, save_brx;
***************
*** 303,319 ****
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- /* Calculate texture and vertex coordinates. Y is flipped in
- texture coordinates. */
bl.x = tl.x = 0;
tr.y = tl.y = 0;
!
! tx1i = 0;
! ty2i = texture_height;
!
! tx2i = src->width;
! ty1i = texture_height - src->height;
!
! tr.x = br.x = tx2i - tx1i;
! bl.y = br.y = ty2i - ty1i;
if (src->transform && (!src->disable_transform_and_repeat)) {
--- 299,306 ----
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
bl.x = tl.x = 0;
tr.y = tl.y = 0;
! tr.x = br.x = src->width;
! bl.y = br.y = src->height;
if (src->transform && (!src->disable_transform_and_repeat)) {
***************
*** 352,376 ****
}
- /* Normalizing texture coordinates */
- tx1 = (double) tx1i / (double) src->width;
- ty1 = (double) ty1i / (double) src->height;
- tx2 = (double) tx2i / (double) src->width;
- ty2 = (double) ty2i / (double) src->height;
-
- /* Scale texture coordinates to real texture size */
- tx1 *= width_factor;
- tx2 *= width_factor;
- ty1 *= height_factor;
- ty2 *= height_factor;
-
save_tlx = tl.x;
save_blx = bl.x;
save_trx = tr.x;
save_brx = br.x;
!
do {
do {
! /* 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;
--- 339,353 ----
}
save_tlx = tl.x;
save_blx = bl.x;
save_trx = tr.x;
save_brx = br.x;
!
do {
do {
! /* 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;
***************
*** 383,403 ****
glScissor (intersect_clip.x1,
! dst->height -
! (intersect_clip.y1 + (intersect_clip.y2 - intersect_clip.y1)),
intersect_clip.x2 - intersect_clip.x1,
intersect_clip.y2 - intersect_clip.y1);
}
!
glBegin (GL_QUADS);
! glTexCoord2d (tx1, ty2);
glVertex2d (x_draw_offset + tl.x, y_draw_offset + tl.y);
! glTexCoord2d (tx2, ty2);
glVertex2d (x_draw_offset + tr.x, y_draw_offset + tr.y);
! glTexCoord2d (tx2, ty1);
glVertex2d (x_draw_offset + br.x, y_draw_offset + br.y);
! glTexCoord2d (tx1, ty1);
glVertex2d (x_draw_offset + bl.x, y_draw_offset + bl.y);
glEnd ();
!
bl.x += src->width;
tl.x += src->width;
--- 360,380 ----
glScissor (intersect_clip.x1,
! dst->height - (intersect_clip.y1 +
! (intersect_clip.y2 - intersect_clip.y1)),
intersect_clip.x2 - intersect_clip.x1,
intersect_clip.y2 - intersect_clip.y1);
}
!
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 ();
!
bl.x += src->width;
tl.x += src->width;
***************
*** 427,436 ****
glc_texture_destroy (texture);
! if (intermediate) {
! glBindTexture (GL_TEXTURE_2D, src_texture);
glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
! ibounds.x1,
! dst->real_height -
! (ibounds.y1 + intermediate->height),
0, 0,
intermediate->width, intermediate->height);
--- 404,411 ----
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);
Index: glc.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glc.h 5 Dec 2003 21:57:19 -0000 1.3
--- glc.h 7 Dec 2003 02:42:29 -0000 1.4
***************
*** 29,32 ****
--- 29,34 ----
#define GLC_H_INCLUDED
+ #include <glc-features.h>
+
#if defined(__SVR4) && defined(__sun)
# include <sys/int_types.h>
***************
*** 48,53 ****
#endif
- #include <glc-features.h>
-
/* NOTE: Must be manually synchronized with LIBGLC_VERSION in configure.in */
#define GLC_MAJOR 0
--- 50,53 ----
Index: glc_glx_context.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_context.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glc_glx_context.c 5 Dec 2003 01:55:31 -0000 1.3
--- glc_glx_context.c 7 Dec 2003 02:42:29 -0000 1.4
***************
*** 219,222 ****
--- 219,226 ----
screen_info->contexts = node->next;
+ /* 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);
Index: glc_glx_pbuffer.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_pbuffer.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_glx_pbuffer.c 5 Dec 2003 01:55:31 -0000 1.2
--- glc_glx_pbuffer.c 7 Dec 2003 02:42:29 -0000 1.3
***************
*** 52,56 ****
pbuffer = glXCreatePbuffer (display, fbconfig, pbuffer_attr);
!
w_ok = h_ok = 0;
if (pbuffer) {
--- 52,56 ----
pbuffer = glXCreatePbuffer (display, fbconfig, pbuffer_attr);
!
w_ok = h_ok = 0;
if (pbuffer) {
***************
*** 76,79 ****
--- 76,80 ----
{
GLXPbuffer pbuffer;
+
if (_glc_pbuffer_try_size (display, fbconfig, width, height,
&pbuffer))
Index: glc_glx_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_surface.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glc_glx_surface.c 5 Dec 2003 01:55:31 -0000 1.4
--- glc_glx_surface.c 7 Dec 2003 02:42:29 -0000 1.5
***************
*** 134,138 ****
glc_surface_push_current (&surface->base);
!
surface->base.texture =
glc_texture_create (surface->base.width,
--- 134,138 ----
glc_surface_push_current (&surface->base);
!
surface->base.texture =
glc_texture_create (surface->base.width,
***************
*** 145,150 ****
if (surface->base.texture)
return &surface->base;
!
! _glc_glx_surface_destroy (surface);
return NULL;
--- 145,150 ----
if (surface->base.texture)
return &surface->base;
! else
! _glc_glx_surface_destroy (surface);
return NULL;
***************
*** 307,316 ****
glc_surface_t *surface;
GLXFBConfig *fbconfig;
- Display *display;
- int screen;
-
glc_glx_screen_info_t *screen_info = templ->screen_info;
! display = templ->screen_info->display_info->display;
! screen = templ->screen_info->screen;
if ((screen_info->feature_mask & GLC_GLX_FEATURE_PBUFFER_MASK) &&
--- 307,313 ----
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) &&
***************
*** 323,327 ****
} else
surface = NULL;
!
return surface;
}
--- 320,324 ----
} else
surface = NULL;
!
return surface;
}
***************
*** 332,335 ****
--- 329,337 ----
{
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) {
***************
*** 430,436 ****
char *pixels)
{
! unsigned char *row_buf;
! int i, rowstride, pixelsize;
! glc_surface_t *intermediate = NULL;
GLenum format;
glc_glx_surface_t *glx_surface = (glc_glx_surface_t *) surface;
--- 432,437 ----
char *pixels)
{
! unsigned char *pixel_buf;
! int i, rowstride, area_rowstride, pixelsize;
GLenum format;
glc_glx_surface_t *glx_surface = (glc_glx_surface_t *) surface;
***************
*** 441,495 ****
return;
}
-
- if (surface->type == GLC_SURFACE_TEXTURE_TYPE) {
- intermediate = _glc_glx_surface_create_intermediate (surface,
- width, height);
- if (!intermediate) {
- glc_surface_status_add (surface, GLC_STATUS_NOT_SUPPORTED_MASK);
- return;
- }
-
- glc_composite (GLC_OPERATOR_SRC,
- surface,
- NULL,
- intermediate,
- x, y,
- 0, 0,
- 0, 0,
- width,
- height);
-
- surface = intermediate;
- x = y = 0;
- }
- glc_surface_push_current (surface);
pixelsize = glc_glx_format_get_pixelsize (glx_surface->format);
format = _glc_glx_surface_get_inverted_glformat_from_pixelsize (pixelsize);
! rowstride = width * pixelsize;
rowstride += (rowstride % 4)? (4 - (rowstride % 4)): 0;
! row_buf = (unsigned char *) malloc (rowstride);
!
! glReadPixels (x, glx_surface->base.real_height - (y + height),
! width, height, format, GL_UNSIGNED_BYTE, pixels);
! /* TODO: This is very ugly and I like to remove it as soon as possible.
! Needs some changes to texture handling, as images will become upside
! down without it.
! */
! for (i = 0; i < ((int) height - i); i++) {
! memcpy (row_buf, &pixels[(height - i - 1) * rowstride], rowstride);
! memcpy (&pixels[(height - i - 1) * rowstride], &pixels[i * rowstride],
! rowstride);
! memcpy (&pixels[i * rowstride], row_buf, rowstride);
}
glc_surface_pop_current (surface);
! free (row_buf);
! if (intermediate)
! glc_surface_destroy (intermediate);
}
--- 442,484 ----
return;
}
pixelsize = glc_glx_format_get_pixelsize (glx_surface->format);
format = _glc_glx_surface_get_inverted_glformat_from_pixelsize (pixelsize);
! /* We currently read the whole image to a temporary buffer and then
! 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, GL_UNSIGNED_BYTE, pixel_buf);
! } else {
! glEnable (GL_TEXTURE_2D);
! glBindTexture (GL_TEXTURE_2D, surface->texture);
! glGetTexImage (GL_TEXTURE_2D, 0,
! format,
! GL_UNSIGNED_BYTE,
! pixel_buf);
}
glc_surface_pop_current (surface);
!
! area_rowstride = width * pixelsize;
! 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);
! glc_surface_pop_current (surface);
! free (pixel_buf);
}
***************
*** 548,552 ****
glTexSubImage2D (GL_TEXTURE_2D, 0,
! x, (dst->real_height - y) - height,
width, height,
format,
--- 537,541 ----
glTexSubImage2D (GL_TEXTURE_2D, 0,
! x, dst->height - y - height,
width, height,
format,
Index: glc_rect.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_rect.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glc_rect.c 4 Dec 2003 12:55:29 -0000 1.4
--- glc_rect.c 7 Dec 2003 02:42:29 -0000 1.5
***************
*** 144,150 ****
glBindTexture (GL_TEXTURE_2D, dst->texture);
glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
! ibounds.x1,
! dst->real_height -
! (ibounds.y1 + intermediate->height),
0, 0,
intermediate->width, intermediate->height);
--- 144,148 ----
glBindTexture (GL_TEXTURE_2D, dst->texture);
glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
! ibounds.x1, dst->height - ibounds.y2,
0, 0,
intermediate->width, intermediate->height);
***************
*** 226,235 ****
glEnd ();
! if (intermediate) {
glBindTexture (GL_TEXTURE_2D, dst->texture);
glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
! ibounds.x1,
! dst->real_height -
! (ibounds.y1 + intermediate->height),
0, 0,
intermediate->width, intermediate->height);
--- 224,231 ----
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);
Index: glc_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_surface.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glc_surface.c 4 Dec 2003 12:55:29 -0000 1.4
--- glc_surface.c 7 Dec 2003 02:42:29 -0000 1.5
***************
*** 198,202 ****
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
! glScalef(1, -1, 1);
glTranslatef (0, -surface->height, 0);
glDisable (GL_DEPTH_TEST);
--- 198,202 ----
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
! glScalef (1, -1, 1);
glTranslatef (0, -surface->height, 0);
glDisable (GL_DEPTH_TEST);
Index: glc_trap.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_trap.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glc_trap.c 4 Dec 2003 12:55:29 -0000 1.4
--- glc_trap.c 7 Dec 2003 02:42:29 -0000 1.5
***************
*** 360,369 ****
glShadeModel (GL_FLAT);
! if (intermediate) {
glBindTexture (GL_TEXTURE_2D, dst->texture);
glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
! ibounds.x1,
! dst->real_height -
! (ibounds.y1 + intermediate->height),
0, 0,
intermediate->width, intermediate->height);
--- 360,367 ----
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);
Index: glc_tri.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_tri.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** glc_tri.c 4 Dec 2003 12:55:29 -0000 1.4
--- glc_tri.c 7 Dec 2003 02:42:29 -0000 1.5
***************
*** 504,513 ****
glShadeModel (GL_FLAT);
! if (intermediate) {
glBindTexture (GL_TEXTURE_2D, dst->texture);
glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
! ibounds.x1,
! dst->real_height -
! (ibounds.y1 + intermediate->height),
0, 0,
intermediate->width, intermediate->height);
--- 504,511 ----
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);
More information about the cairo-commit
mailing list