[cairo-commit] libglc/src glc.c,1.23,1.24 glc_program.c,1.7,1.8 glc_surface.c,1.21,1.22 glcint.h,1.24,1.25
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-serv16488/src
Modified Files:
glc.c glc_program.c glc_surface.c glcint.h
Log Message:
Fragment program updates
Index: glc.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** a/glc.c 6 Mar 2004 13:58:17 -0000 1.23
--- b/glc.c 8 Mar 2004 00:20:28 -0000 1.24
***************
*** 83,90 ****
translate_mask;
double src_width, src_height, mask_width, mask_height;
! /* Only one of src or mask can be processed using fragment program */
! if ((src->programmatic || src->convolution) &&
! (mask->programmatic || mask->convolution))
return 0;
--- 83,91 ----
translate_mask;
double src_width, src_height, mask_width, mask_height;
+ glc_program_type_t type;
! type = glc_program_type (dst, src, mask);
!
! if (type == GLC_PROGRAM_TYPE_NOT_SUPPORTED)
return 0;
***************
*** 114,122 ****
glDisable (GL_SCISSOR_TEST);
! if (!glc_surface_enable_program (dst, src, mask,
! src_texture, mask_texture)) {
! glc_surface_pop_current (dst);
! return 0;
! }
glc_set_operator (op);
--- 115,119 ----
glDisable (GL_SCISSOR_TEST);
! glc_surface_enable_program (type, dst, src, mask, src_texture, mask_texture);
glc_set_operator (op);
***************
*** 548,552 ****
if (src->convolution || src->programmatic)
! glc_surface_enable_program (dst, src, mask, texture, NULL);
if ((!TRANSFORM (src)) && GLREPEAT (src, texture)) {
--- 545,550 ----
if (src->convolution || src->programmatic)
! glc_surface_enable_program (glc_program_type (dst, src, NULL),
! dst, src, NULL, texture, NULL);
if ((!TRANSFORM (src)) && GLREPEAT (src, texture)) {
Index: glc_program.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_program.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** a/glc_program.c 6 Mar 2004 13:58:17 -0000 1.7
--- b/glc_program.c 8 Mar 2004 00:20:28 -0000 1.8
***************
*** 159,169 ****
"TEMP color;\n"
! /* mask temporary expand */
"%s"
! /* src texture expand */
"TEX color, fragment.texcoord[0], texture[0], %s;\n"
! /* mask operation expand */
"%s"
--- 159,169 ----
"TEMP color;\n"
! /* temporary */
"%s"
! /* src texture */
"TEX color, fragment.texcoord[0], texture[0], %s;\n"
! /* pd operation */
"%s"
***************
*** 191,195 ****
"TEMP color, in, coord;\n"
! /* mask temporary expand */
"%s"
--- 191,195 ----
"TEMP color, in, coord;\n"
! /* temporary */
"%s"
***************
*** 235,239 ****
"MAD color, in, k1.x, color;\n"
! /* mask operation expand */
"%s"
--- 235,239 ----
"MAD color, in, k1.x, color;\n"
! /* pd operation */
"%s"
***************
*** 251,258 ****
"ATTRIB color = fragment.color;\n"
! /* expanded with mask/src temporary */
"%s"
! /* expanded with mask/src operation */
"%s"
--- 251,258 ----
"ATTRIB color = fragment.color;\n"
! /* temporary */
"%s"
! /* pd operation */
"%s"
***************
*** 280,284 ****
"TEMP color, distance, position;\n"
! /* expanded with mask temporary */
"%s"
--- 280,284 ----
"TEMP color, distance, position;\n"
! /* temporary */
"%s"
***************
*** 296,300 ****
"MAD color, distance, start_color, color;\n"
! /* expanded with mask operation */
"%s"
--- 296,300 ----
"MAD color, distance, start_color, color;\n"
! /* pd operation */
"%s"
***************
*** 320,324 ****
"TEMP color, distance;\n"
! /* expanded with mask temporary */
"%s"
--- 320,324 ----
"TEMP color, distance;\n"
! /* temporary */
"%s"
***************
*** 334,338 ****
"MAD color, distance, start_color, color;\n"
! /* expanded with mask operation */
"%s"
--- 334,338 ----
"MAD color, distance, start_color, color;\n"
! /* pd operation */
"%s"
***************
*** 453,464 ****
static unsigned long
glc_program_compile_convolution (glc_gl_proc_address_list_t *proc_address,
! int offset)
{
char program_buffer[1280];
const glc_program_expand_t *expand = &_program_expand_map[offset];
sprintf (program_buffer,
_glc_fragment_program_convolution,
! expand->temporary,
expand->index, expand->index, expand->tex,
expand->index, expand->tex,
--- 453,478 ----
static unsigned long
glc_program_compile_convolution (glc_gl_proc_address_list_t *proc_address,
! int offset,
! int solid_offset)
{
+ char *solid_op_table[] = {
+ "MUL result.color, color, solid.a;\n",
+ "MUL result.color, solid, color.a;\n",
+ };
char program_buffer[1280];
const glc_program_expand_t *expand = &_program_expand_map[offset];
+ char *temporary, *operation;
+
+ if (solid_offset) {
+ temporary = "PARAM solid = program.local[3];\n";
+ operation = solid_op_table[solid_offset - 1];
+ } else {
+ temporary = expand->temporary;
+ operation = expand->operation;
+ }
sprintf (program_buffer,
_glc_fragment_program_convolution,
! temporary,
expand->index, expand->index, expand->tex,
expand->index, expand->tex,
***************
*** 470,474 ****
expand->index, expand->tex,
expand->index, expand->tex,
! expand->operation);
return glc_program_compile_fragment_arb (proc_address, program_buffer);
--- 484,488 ----
expand->index, expand->tex,
expand->index, expand->tex,
! operation);
return glc_program_compile_fragment_arb (proc_address, program_buffer);
***************
*** 503,507 ****
}
! static glc_bool_t
glc_program_enable_simple (glc_gl_proc_address_list_t *proc_address,
glc_programs_t *programs,
--- 517,521 ----
}
! static void
glc_program_enable_simple (glc_gl_proc_address_list_t *proc_address,
glc_programs_t *programs,
***************
*** 519,530 ****
proc_address->gl_bind_program_arb (GL_FRAGMENT_PROGRAM_ARB,
programs->fragment_simple[offset]);
-
- return 1;
}
-
- return 0;
}
! static glc_bool_t
glc_program_enable_convolution (glc_gl_proc_address_list_t *proc_address,
glc_programs_t *programs,
--- 533,540 ----
proc_address->gl_bind_program_arb (GL_FRAGMENT_PROGRAM_ARB,
programs->fragment_simple[offset]);
}
}
! static void
glc_program_enable_convolution (glc_gl_proc_address_list_t *proc_address,
glc_programs_t *programs,
***************
*** 533,541 ****
glc_texture_t *src_texture,
glc_texture_t *mask_texture,
! int offset)
{
glc_texture_t *texture;
glc_surface_t *surface;
! int vertex_offset = (offset)? 1: 0;
if (offset) {
--- 543,552 ----
glc_texture_t *src_texture,
glc_texture_t *mask_texture,
! int offset,
! int solid_offset)
{
glc_texture_t *texture;
glc_surface_t *surface;
! int fragment_offset, vertex_offset = (offset)? 1: 0;
if (offset) {
***************
*** 547,569 ****
}
- if (!(surface->feature_mask & GLC_FEATURE_CONVOLUTION_FILTER_MASK))
- return 1;
-
offset += _glc_program_offset (src_texture, mask_texture);
if (!programs->vertex_convolution[vertex_offset])
programs->vertex_convolution[vertex_offset] =
glc_program_compile_vertex_convolution (proc_address, vertex_offset);
! if (!programs->fragment_convolution[offset])
! programs->fragment_convolution[offset] =
! glc_program_compile_convolution (proc_address, offset);
! if (programs->fragment_convolution[offset] &&
! programs->vertex_convolution[0]) {
glEnable (GL_VERTEX_PROGRAM_ARB);
! proc_address->gl_bind_program_arb (GL_VERTEX_PROGRAM_ARB,
! programs->vertex_convolution[0]);
proc_address->gl_program_local_param_4d_arb (GL_VERTEX_PROGRAM_ARB, 0,
texture->texcoord_width /
--- 558,579 ----
}
offset += _glc_program_offset (src_texture, mask_texture);
+ fragment_offset = offset + GLC_FRAGMENT_PROGRAM_TYPES * solid_offset;
+
if (!programs->vertex_convolution[vertex_offset])
programs->vertex_convolution[vertex_offset] =
glc_program_compile_vertex_convolution (proc_address, vertex_offset);
! if (!programs->fragment_convolution[fragment_offset])
! programs->fragment_convolution[fragment_offset] =
! glc_program_compile_convolution (proc_address, offset, solid_offset);
! if (programs->fragment_convolution[fragment_offset] &&
! programs->vertex_convolution[vertex_offset]) {
glEnable (GL_VERTEX_PROGRAM_ARB);
! proc_address->gl_bind_program_arb
! (GL_VERTEX_PROGRAM_ARB, programs->vertex_convolution[vertex_offset]);
proc_address->gl_program_local_param_4d_arb (GL_VERTEX_PROGRAM_ARB, 0,
texture->texcoord_width /
***************
*** 577,582 ****
glEnable (GL_FRAGMENT_PROGRAM_ARB);
! proc_address->gl_bind_program_arb (GL_FRAGMENT_PROGRAM_ARB,
! programs->fragment_convolution[offset]);
proc_address->gl_program_local_param_4d_arb (GL_FRAGMENT_PROGRAM_ARB, 0,
surface->convolution->m[0][0],
--- 587,593 ----
glEnable (GL_FRAGMENT_PROGRAM_ARB);
! proc_address->gl_bind_program_arb
! (GL_FRAGMENT_PROGRAM_ARB,
! programs->fragment_convolution[fragment_offset]);
proc_address->gl_program_local_param_4d_arb (GL_FRAGMENT_PROGRAM_ARB, 0,
surface->convolution->m[0][0],
***************
*** 594,604 ****
surface->convolution->m[2][2],
0.0);
! return 1;
}
-
- return 0;
}
! static glc_bool_t
glc_program_enable_programmatic (glc_surface_t *dst,
glc_programmatic_surface_t *surface,
--- 605,628 ----
surface->convolution->m[2][2],
0.0);
!
! if (solid_offset) {
! glc_solid_t *solid;
!
! if (solid_offset == 1)
! solid = &((glc_programmatic_surface_t *) mask)->attributes.solid;
! else
! solid = &((glc_programmatic_surface_t *) src)->attributes.solid;
!
! proc_address->gl_program_local_param_4d_arb
! (GL_FRAGMENT_PROGRAM_ARB, 3,
! (double) solid->color.red / 65536.0,
! (double) solid->color.green / 65536.0,
! (double) solid->color.blue / 65536.0,
! (double) solid->color.alpha / 65536.0);
! }
}
}
! static void
glc_program_enable_programmatic (glc_surface_t *dst,
glc_programmatic_surface_t *surface,
***************
*** 625,629 ****
glc_programmatic_surface_set_parameters (proc_address, surface);
! return 1;
}
--- 649,653 ----
glc_programmatic_surface_set_parameters (proc_address, surface);
! return;
}
***************
*** 640,653 ****
glc_programmatic_surface_set_parameters (proc_address, surface);
! return 1;
}
}
! return 0;
}
! glc_bool_t
! glc_program_enable (glc_surface_t *dst,
glc_surface_t *src,
glc_surface_t *mask,
--- 664,754 ----
glc_programmatic_surface_set_parameters (proc_address, surface);
+ }
+ }
+ }
+
+ glc_program_type_t
+ glc_program_type (glc_surface_t *dst,
+ glc_surface_t *src,
+ glc_surface_t *mask)
+ {
+ glc_program_type_t type = GLC_PROGRAM_TYPE_NONE;
+
+ if (dst->feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) {
+
+ if (dst->feature_mask & GLC_FEATURE_CONVOLUTION_FILTER_MASK)
! if (src->convolution) {
! if (mask && mask->programmatic &&
! ((glc_programmatic_surface_t *) mask)->type ==
! GLC_PROGRAMMATIC_SURFACE_SOLID_TYPE) {
! if (dst->feature_mask & GLC_FEATURE_CONVOLUTION_FILTER_MASK) {
! type = GLC_PROGRAM_TYPE_SRC_CONVOLUTION_AND_SOLID_MASK;
! goto OK2;
! } else {
! type = GLC_PROGRAM_TYPE_MASK_PROGRAMMATIC;
! goto OK1;
! }
! }
! type = GLC_PROGRAM_TYPE_SRC_CONVOLUTION;
! goto OK1;
}
+
+ if (mask && mask->convolution) {
+ if (src->programmatic &&
+ ((glc_programmatic_surface_t *) src)->type ==
+ GLC_PROGRAMMATIC_SURFACE_SOLID_TYPE) {
+ if (dst->feature_mask & GLC_FEATURE_CONVOLUTION_FILTER_MASK) {
+ type = GLC_PROGRAM_TYPE_MASK_CONVOLUTION_AND_SOLID_SRC;
+ goto OK2;
+ } else {
+ type = GLC_PROGRAM_TYPE_SRC_PROGRAMMATIC;
+ goto OK1;
+ }
+ }
+ type = GLC_PROGRAM_TYPE_MASK_CONVOLUTION;
+ goto OK1;
+ }
+
+ if (src->programmatic) {
+ type = GLC_PROGRAM_TYPE_SRC_PROGRAMMATIC;
+ goto OK1;
+ }
+
+ if (mask && mask->programmatic) {
+ type = GLC_PROGRAM_TYPE_MASK_PROGRAMMATIC;
+ goto OK1;
+ }
}
! if (src->programmatic &&
! ((glc_programmatic_surface_t *) src)->type ==
! GLC_PROGRAMMATIC_SURFACE_SOLID_TYPE) {
! type = GLC_PROGRAM_TYPE_SRC_PROGRAMMATIC;
! goto OK1;
! }
!
! if (mask && mask->programmatic &&
! ((glc_programmatic_surface_t *) mask)->type ==
! GLC_PROGRAMMATIC_SURFACE_SOLID_TYPE) {
! type = GLC_PROGRAM_TYPE_MASK_PROGRAMMATIC;
! goto OK1;
! }
!
! if (mask && (!mask->programmatic))
! type = GLC_PROGRAM_TYPE_SIMPLE;
!
! OK1:
! if ((src->programmatic || src->convolution) &&
! (mask && (mask->programmatic || mask->convolution)))
! return GLC_PROGRAM_TYPE_NOT_SUPPORTED;
!
! OK2:
! return type;
}
! void
! glc_program_enable (glc_program_type_t type,
! glc_surface_t *dst,
glc_surface_t *src,
glc_surface_t *mask,
***************
*** 655,711 ****
glc_texture_t *mask_texture)
{
! /* fragment operation on both src and mask is not supported yet */
! if ((src->programmatic || src->convolution) &&
! (mask && (mask->programmatic || mask->convolution)))
! return 0;
!
! if ((!mask) && (!src->programmatic) && (!src->convolution))
! return 1;
!
! if (src->programmatic)
! return
! glc_program_enable_programmatic (dst,
! (glc_programmatic_surface_t *) src,
! src_texture,
! mask_texture,
! GLC_PROGRAM_SRC_OPERATION_OFFSET);
!
! if (dst->feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) {
! if (mask && mask->programmatic)
! return
! glc_program_enable_programmatic (dst,
! (glc_programmatic_surface_t *) mask,
! src_texture,
! mask_texture,
! GLC_PROGRAM_MASK_OPERATION_OFFSET);
!
! if (src->convolution)
! return
! glc_program_enable_convolution (dst->proc_address,
! dst->programs,
! src,
! mask,
! src_texture,
! mask_texture,
! GLC_PROGRAM_SRC_OPERATION_OFFSET);
!
! if (mask && mask->convolution)
! return
! glc_program_enable_convolution (dst->proc_address,
! dst->programs,
! src,
! mask,
! src_texture,
! mask_texture,
! GLC_PROGRAM_MASK_OPERATION_OFFSET);
!
! return
! glc_program_enable_simple (dst->proc_address,
! dst->programs,
! src_texture,
! mask_texture);
}
-
- return 0;
}
--- 756,798 ----
glc_texture_t *mask_texture)
{
! switch (type) {
! case GLC_PROGRAM_TYPE_SRC_CONVOLUTION:
! glc_program_enable_convolution (dst->proc_address, dst->programs,
! src, mask, src_texture, mask_texture,
! GLC_PROGRAM_SRC_OPERATION_OFFSET, 0);
! break;
! case GLC_PROGRAM_TYPE_SRC_CONVOLUTION_AND_SOLID_MASK:
! glc_program_enable_convolution (dst->proc_address, dst->programs,
! src, mask, src_texture, mask_texture,
! GLC_PROGRAM_SRC_OPERATION_OFFSET, 1);
! break;
! case GLC_PROGRAM_TYPE_MASK_CONVOLUTION:
! glc_program_enable_convolution (dst->proc_address, dst->programs,
! src, mask, src_texture, mask_texture,
! GLC_PROGRAM_MASK_OPERATION_OFFSET, 0);
! break;
! case GLC_PROGRAM_TYPE_MASK_CONVOLUTION_AND_SOLID_SRC:
! glc_program_enable_convolution (dst->proc_address, dst->programs,
! src, mask, src_texture, mask_texture,
! GLC_PROGRAM_MASK_OPERATION_OFFSET, 2);
! break;
! case GLC_PROGRAM_TYPE_SRC_PROGRAMMATIC:
! glc_program_enable_programmatic (dst, (glc_programmatic_surface_t *) src,
! src_texture, mask_texture,
! GLC_PROGRAM_SRC_OPERATION_OFFSET);
! break;
! case GLC_PROGRAM_TYPE_MASK_PROGRAMMATIC:
! glc_program_enable_programmatic (dst, (glc_programmatic_surface_t *) mask,
! src_texture, mask_texture,
! GLC_PROGRAM_MASK_OPERATION_OFFSET);
! break;
! case GLC_PROGRAM_TYPE_SIMPLE:
! glc_program_enable_simple (dst->proc_address, dst->programs,
! src_texture, mask_texture);
! break;
! case GLC_PROGRAM_TYPE_NONE:
! case GLC_PROGRAM_TYPE_NOT_SUPPORTED:
! break;
}
}
Index: glc_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_surface.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** a/glc_surface.c 6 Mar 2004 13:58:17 -0000 1.21
--- b/glc_surface.c 8 Mar 2004 00:20:28 -0000 1.22
***************
*** 109,114 ****
}
! glc_bool_t
! glc_surface_enable_program (glc_surface_t *surface,
glc_surface_t *src,
glc_surface_t *mask,
--- 109,115 ----
}
! void
! glc_surface_enable_program (glc_program_type_t type,
! glc_surface_t *surface,
glc_surface_t *src,
glc_surface_t *mask,
***************
*** 116,120 ****
glc_texture_t *mask_texture)
{
! return glc_program_enable (surface, src, mask, src_texture, mask_texture);
}
--- 117,122 ----
glc_texture_t *mask_texture)
{
! return
! glc_program_enable (type, surface, src, mask, src_texture, mask_texture);
}
Index: glcint.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glcint.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** a/glcint.h 6 Mar 2004 13:58:17 -0000 1.24
--- b/glcint.h 8 Mar 2004 00:20:28 -0000 1.25
***************
*** 105,108 ****
--- 105,120 ----
} glc_programmatic_surface_type_t;
+ typedef enum {
+ GLC_PROGRAM_TYPE_NONE,
+ GLC_PROGRAM_TYPE_NOT_SUPPORTED,
+ GLC_PROGRAM_TYPE_SRC_CONVOLUTION,
+ GLC_PROGRAM_TYPE_SRC_CONVOLUTION_AND_SOLID_MASK,
+ GLC_PROGRAM_TYPE_MASK_CONVOLUTION,
+ GLC_PROGRAM_TYPE_MASK_CONVOLUTION_AND_SOLID_SRC,
+ GLC_PROGRAM_TYPE_SRC_PROGRAMMATIC,
+ GLC_PROGRAM_TYPE_MASK_PROGRAMMATIC,
+ GLC_PROGRAM_TYPE_SIMPLE
+ } glc_program_type_t;
+
#define GLC_PROGRAMMATIC_SURFACE_NUM \
(GLC_PROGRAMMATIC_SURFACE_RADIAL_GRADIENT_TYPE + 1)
***************
*** 129,133 ****
unsigned long vertex_convolution[GLC_VERTEX_PROGRAM_TYPES];
unsigned long fragment_simple[GLC_FRAGMENT_PROGRAM_TYPES];
! unsigned long fragment_convolution[GLC_FRAGMENT_PROGRAM_TYPES];
unsigned long fragment_programmatic[GLC_FRAGMENT_PROGRAMMATIC_PROGRAM_TYPES];
} glc_programs_t;
--- 141,145 ----
unsigned long vertex_convolution[GLC_VERTEX_PROGRAM_TYPES];
unsigned long fragment_simple[GLC_FRAGMENT_PROGRAM_TYPES];
! unsigned long fragment_convolution[GLC_FRAGMENT_PROGRAM_TYPES * 3];
unsigned long fragment_programmatic[GLC_FRAGMENT_PROGRAMMATIC_PROGRAM_TYPES];
} glc_programs_t;
***************
*** 380,385 ****
glc_surface_pop_current (glc_surface_t *surface);
! extern glc_bool_t __internal_linkage
! glc_surface_enable_program (glc_surface_t *surface,
glc_surface_t *src,
glc_surface_t *mask,
--- 392,398 ----
glc_surface_pop_current (glc_surface_t *surface);
! extern void __internal_linkage
! glc_surface_enable_program (glc_program_type_t type,
! glc_surface_t *surface,
glc_surface_t *src,
glc_surface_t *mask,
***************
*** 425,430 ****
glc_format_calculate_pixel_transfer_info (glc_format_t *format);
! extern glc_bool_t __internal_linkage
! glc_program_enable (glc_surface_t *dst,
glc_surface_t *src,
glc_surface_t *mask,
--- 438,449 ----
glc_format_calculate_pixel_transfer_info (glc_format_t *format);
! extern glc_program_type_t __internal_linkage
! glc_program_type (glc_surface_t *dst,
! glc_surface_t *src,
! glc_surface_t *mask);
!
! extern void __internal_linkage
! glc_program_enable (glc_program_type_t type,
! glc_surface_t *dst,
glc_surface_t *src,
glc_surface_t *mask,
More information about the cairo-commit
mailing list