[cairo-commit] libglc/src glc.c,1.5,1.6 glc_glx_info.c,1.2,1.3 glc_glx_surface.c,1.2,1.3 glc_rect.c,1.3,1.4 glc_surface.c,1.3,1.4 glc_texture.c,1.2,1.3 glc_trap.c,1.3,1.4 glc_tri.c,1.3,1.4 glcint.h,1.3,1.4
David Reveman
commit at pdx.freedesktop.org
Thu Dec 4 04:55:31 PST 2003
Committed by: davidr
Update of /cvs/cairo/libglc/src
In directory pdx:/tmp/cvs-serv29658/src
Modified Files:
glc.c glc_glx_info.c glc_glx_surface.c glc_rect.c
glc_surface.c glc_texture.c glc_trap.c glc_tri.c glcint.h
Log Message:
Repeat for none power of two textures implemented
Index: glc.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** glc.c 3 Dec 2003 22:19:43 -0000 1.5
--- glc.c 4 Dec 2003 12:55:29 -0000 1.6
***************
*** 97,100 ****
--- 97,101 ----
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;
***************
*** 178,182 ****
}
! glc_surface_disable_transform (dst);
glc_composite (GLC_OPERATOR_SRC,
dst,
--- 179,183 ----
}
! glc_surface_disable_transform_and_repeat (dst);
glc_composite (GLC_OPERATOR_SRC,
dst,
***************
*** 187,191 ****
0, 0,
intermediate->width, intermediate->height);
! glc_surface_enable_transform (dst);
src_texture = dst->texture;
dst = intermediate;
--- 188,192 ----
0, 0,
intermediate->width, intermediate->height);
! glc_surface_enable_transform_and_repeat (dst);
src_texture = dst->texture;
dst = intermediate;
***************
*** 196,226 ****
if (src->type == GLC_SURFACE_TEXTURE_TYPE) {
glBindTexture (GL_TEXTURE_2D, src->texture);
! width_factor = (double) src->width / (double) src->real_width;
! height_factor = (double) src->height / (double) src->real_height;
} else {
- int texture_width, texture_height;
-
texture = glc_texture_create (src->width, src->height,
&texture_width,
&texture_height);
- width_factor = (double) width / (double) texture_width;
- height_factor = (double) height / (double) 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);
glc_surface_pop_current (src);
glBindTexture (GL_TEXTURE_2D, texture);
! }
glEnable (GL_TEXTURE_2D);
!
switch (src->filter) {
case GLC_FILTER_FAST:
--- 197,226 ----
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,
&texture_width,
&texture_height);
glc_surface_push_current (src);
glBindTexture (GL_TEXTURE_2D, texture);
glCopyTexSubImage2D (GL_TEXTURE_2D, 0,
! 0, texture_height - src->height,
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);
switch (src->filter) {
case GLC_FILTER_FAST:
***************
*** 236,271 ****
break;
}
! if (src->repeat) {
! double repeat_factor_x, repeat_factor_y;
! int tx1i, ty1i;
! /* NYI: REPEAT ONLY WORKS FOR POWER OF TWO SIZED TEXTURES.
! Fix for this is to do manual repeat for textures which are not
! power of two sized.
! */
! 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;
! tr.x = br.x = x_dst + width;
! bl.y = br.y = y_dst + height;
! tx1i = x_src % src->width;
! ty1i = src->real_height - (height % src->real_height) -
! (y_src % src->height);
! repeat_factor_x = (double) width / src->real_width;
! repeat_factor_y = (double) height / src->real_height;
!
! /* Normalizing texture coordinates */
! tx1 = (double) tx1i / (double) src->real_width;
! ty1 = (double) ty1i / (double) src->real_height;
! tx2 = tx1 + repeat_factor_x;
! ty2 = ty1 + repeat_factor_y;
} else {
int tx1i, tx2i, ty1i, ty2i;
!
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
--- 236,353 ----
break;
}
+ glScissor (x_dst, dst->height - (y_dst + height), width, height);
+ glColorMask (src->red, src->green, src->blue, src->alpha);
! glc_set_operator (op);
! if (src->repeat && (!src->disable_transform_and_repeat)) {
! /* Source should be repeated. */
! if (texture_width == src->width && texture_height == src->height) {
! /* CASE 1: Repeat 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;
! tr.x = br.x = x_dst + width;
! bl.y = br.y = y_dst + height;
! /* Shift coordinates with source offset */
! if (x_src) {
! tl.x -= x_src;
! bl.x -= x_src;
! }
! if (y_src) {
! tl.y -= y_src;
! tr.y -= y_src;
! }
! /* 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;
!
! 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: Repeat and not power of two sized texture, manual repeat
! must be done. */
! int tx1i, tx2i, ty1i, ty2i;
!
! glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
! glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
!
! tx1i = 0;
! ty2i = texture_height;
!
! tx2i = src->width;
! ty1i = texture_height - src->height;
!
! /* 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;
!
! tr.y = tl.y = y_dst - y_src;
! bl.y = br.y = y_dst + src->height - y_src;
!
! while (tl.y < (y_dst + height)) {
! bl.x = tl.x = x_dst - x_src;
! tr.x = br.x = x_dst + src->width - x_src;
!
! while (tl.x < (x_dst + width)) {
! 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;
! tr.x += src->width;
! br.x += src->width;
! }
!
! bl.y += src->height;
! tl.y += src->height;
! tr.y += src->height;
! br.y += src->height;
! }
! }
} else {
+ /* CASE 3: No repeat. Transformation should be used if set. */
int tx1i, tx2i, ty1i, ty2i;
!
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
***************
*** 277,289 ****
tx1i = 0;
! ty2i = src->real_height;
tx2i = src->width;
! ty1i = src->real_height - src->height;
tr.x = br.x = tx2i - tx1i;
bl.y = br.y = ty2i - ty1i;
! if (src->transform && (!src->disable_transform)) {
glc_matrix_transform_point (src->transform, &tl);
glc_matrix_transform_point (src->transform, &bl);
--- 359,371 ----
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)) {
glc_matrix_transform_point (src->transform, &tl);
glc_matrix_transform_point (src->transform, &bl);
***************
*** 331,355 ****
ty1 *= height_factor;
ty2 *= height_factor;
}
- glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- glc_set_operator (op);
-
- glScissor (x_dst, dst->height - (y_dst + height), width, height);
-
- glColorMask (src->red, src->green, src->blue, src->alpha);
-
- 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 ();
-
glDisable (GL_TEXTURE_2D);
--- 413,429 ----
ty1 *= height_factor;
ty2 *= height_factor;
+
+ 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 ();
}
glDisable (GL_TEXTURE_2D);
***************
*** 365,368 ****
--- 439,443 ----
0, 0,
intermediate->width, intermediate->height);
+ glFlush ();
glc_surface_pop_current (dst);
***************
*** 372,375 ****
if (mask_intermediate)
! glc_surface_destroy (mask_intermediate);
}
--- 447,450 ----
if (mask_intermediate)
! glc_surface_destroy (mask_intermediate);
}
Index: glc_glx_info.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_info.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_glx_info.c 27 Nov 2003 18:56:44 -0000 1.2
--- glc_glx_info.c 4 Dec 2003 12:55:29 -0000 1.3
***************
*** 168,171 ****
--- 168,174 ----
screen_info->root_context);
+ glPixelStorei (GL_PACK_ALIGNMENT, 4);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
+
glc_glx_query_extensions (screen_info);
glc_glx_query_formats (screen_info);
Index: glc_glx_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_glx_surface.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_glx_surface.c 3 Dec 2003 16:55:50 -0000 1.2
--- glc_glx_surface.c 4 Dec 2003 12:55:29 -0000 1.3
***************
*** 377,380 ****
--- 377,381 ----
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);
***************
*** 552,555 ****
--- 553,557 ----
GL_UNSIGNED_BYTE,
pixel_buf);
+ glFlush ();
glDisable (GL_TEXTURE_2D);
Index: glc_rect.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_rect.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glc_rect.c 3 Dec 2003 16:55:50 -0000 1.3
--- glc_rect.c 4 Dec 2003 12:55:29 -0000 1.4
***************
*** 100,104 ****
y += y_draw_offset;
! glc_surface_disable_transform (dst);
glc_composite (GLC_OPERATOR_SRC,
dst,
--- 100,104 ----
y += y_draw_offset;
! glc_surface_disable_transform_and_repeat (dst);
glc_composite (GLC_OPERATOR_SRC,
dst,
***************
*** 109,113 ****
0, 0,
intermediate->width, intermediate->height);
! glc_surface_enable_transform (dst);
} else
surface = dst;
--- 109,113 ----
0, 0,
intermediate->width, intermediate->height);
! glc_surface_enable_transform_and_repeat (dst);
} else
surface = dst;
***************
*** 140,144 ****
glEnd ();
}
!
if (intermediate) {
glBindTexture (GL_TEXTURE_2D, dst->texture);
--- 140,144 ----
glEnd ();
}
!
if (intermediate) {
glBindTexture (GL_TEXTURE_2D, dst->texture);
***************
*** 149,152 ****
--- 149,153 ----
0, 0,
intermediate->width, intermediate->height);
+ glFlush ();
glc_surface_pop_current (surface);
***************
*** 190,194 ****
}
! glc_surface_disable_transform (dst);
glc_composite (GLC_OPERATOR_SRC,
dst,
--- 191,195 ----
}
! glc_surface_disable_transform_and_repeat (dst);
glc_composite (GLC_OPERATOR_SRC,
dst,
***************
*** 199,203 ****
0, 0,
intermediate->width, intermediate->height);
! glc_surface_enable_transform (dst);
} else
surface = dst;
--- 200,204 ----
0, 0,
intermediate->width, intermediate->height);
! glc_surface_enable_transform_and_repeat (dst);
} else
surface = dst;
***************
*** 233,240 ****
0, 0,
intermediate->width, intermediate->height);
glc_surface_pop_current (surface);
glc_surface_destroy (intermediate);
} else
! glc_surface_pop_current (surface);
}
--- 234,242 ----
0, 0,
intermediate->width, intermediate->height);
+ glFlush ();
glc_surface_pop_current (surface);
glc_surface_destroy (intermediate);
} else
! glc_surface_pop_current (surface);
}
Index: glc_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_surface.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glc_surface.c 3 Dec 2003 16:55:50 -0000 1.3
--- glc_surface.c 4 Dec 2003 12:55:29 -0000 1.4
***************
*** 43,47 ****
surface->repeat = 0;
surface->transform = NULL;
! surface->disable_transform = 0;
surface->filter = GLC_FILTER_NEAREST;
surface->polyedge = GLC_POLYEDGE_SHARP;
--- 43,47 ----
surface->repeat = 0;
surface->transform = NULL;
! surface->disable_transform_and_repeat = 0;
surface->filter = GLC_FILTER_NEAREST;
surface->polyedge = GLC_POLYEDGE_SHARP;
***************
*** 172,184 ****
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;
}
--- 172,184 ----
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;
}
***************
*** 186,189 ****
--- 186,192 ----
glc_surface_setup_environment (glc_surface_t *surface)
{
+ glPixelStorei (GL_PACK_ALIGNMENT, 4);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
+
if (surface->type == GLC_SURFACE_TEXTURE_TYPE)
return;
***************
*** 202,206 ****
glDisable (GL_CULL_FACE);
glDepthMask (GL_FALSE);
- glPixelStorei (GL_PACK_ALIGNMENT, 1);
glEnable (GL_SCISSOR_TEST);
glScissor (0, 0, surface->width, surface->height);
--- 205,208 ----
Index: glc_texture.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_texture.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** glc_texture.c 3 Dec 2003 22:19:43 -0000 1.2
--- glc_texture.c 4 Dec 2003 12:55:29 -0000 1.3
***************
*** 60,64 ****
GLint w_ok, h_ok;
! glTexImage2D (GL_PROXY_TEXTURE_2D, 0, GL_RGBA8,
test_width, test_height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
--- 60,64 ----
GLint w_ok, h_ok;
! glTexImage2D (GL_PROXY_TEXTURE_2D, 0, GL_RGBA,
test_width, test_height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
***************
*** 103,107 ****
glBindTexture (GL_TEXTURE_2D, texture);
! glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8,
*texture_width, *texture_height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
--- 103,107 ----
glBindTexture (GL_TEXTURE_2D, texture);
! glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
*texture_width, *texture_height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
Index: glc_trap.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_trap.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glc_trap.c 3 Dec 2003 16:55:50 -0000 1.3
--- glc_trap.c 4 Dec 2003 12:55:29 -0000 1.4
***************
*** 277,281 ****
}
! glc_surface_disable_transform (dst);
glc_composite (GLC_OPERATOR_SRC,
dst,
--- 277,281 ----
}
! glc_surface_disable_transform_and_repeat (dst);
glc_composite (GLC_OPERATOR_SRC,
dst,
***************
*** 286,290 ****
0, 0,
intermediate->width, intermediate->height);
! glc_surface_enable_transform (dst);
} else
surface = dst;
--- 286,290 ----
0, 0,
intermediate->width, intermediate->height);
! glc_surface_enable_transform_and_repeat (dst);
} else
surface = dst;
***************
*** 368,371 ****
--- 368,372 ----
0, 0,
intermediate->width, intermediate->height);
+ glFlush ();
glc_surface_pop_current (surface);
Index: glc_tri.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_tri.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glc_tri.c 3 Dec 2003 16:55:50 -0000 1.3
--- glc_tri.c 4 Dec 2003 12:55:29 -0000 1.4
***************
*** 434,438 ****
}
! glc_surface_disable_transform (dst);
glc_composite (GLC_OPERATOR_SRC,
dst,
--- 434,438 ----
}
! glc_surface_disable_transform_and_repeat (dst);
glc_composite (GLC_OPERATOR_SRC,
dst,
***************
*** 443,447 ****
0, 0,
intermediate->width, intermediate->height);
! glc_surface_enable_transform (dst);
} else
surface = dst;
--- 443,447 ----
0, 0,
intermediate->width, intermediate->height);
! glc_surface_enable_transform_and_repeat (dst);
} else
surface = dst;
***************
*** 512,515 ****
--- 512,516 ----
0, 0,
intermediate->width, intermediate->height);
+ glFlush ();
glc_surface_pop_current (surface);
Index: glcint.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glcint.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** glcint.h 3 Dec 2003 16:55:50 -0000 1.3
--- glcint.h 4 Dec 2003 12:55:29 -0000 1.4
***************
*** 90,94 ****
glc_polyedge_t polyedge;
glc_matrix_t *transform;
! glc_bool_t disable_transform;
int width, height;
int real_width, real_height;
--- 90,94 ----
glc_polyedge_t polyedge;
glc_matrix_t *transform;
! glc_bool_t disable_transform_and_repeat;
int width, height;
int real_width, real_height;
***************
*** 148,155 ****
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
--- 148,155 ----
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
More information about the cairo-commit
mailing list