[cairo-commit] glitz/src glitz.c, 1.2, 1.3 glitz.h, 1.3,
1.4 glitz_matrix.c, 1.1.1.1, 1.2 glitz_program.c, 1.3,
1.4 glitz_programmatic.c, 1.2, 1.3 glitz_surface.c, 1.4,
1.5 glitzint.h, 1.5, 1.6
David Reveman
commit at pdx.freedesktop.org
Thu Apr 29 19:26:05 PDT 2004
Committed by: davidr
Update of /cvs/cairo/glitz/src
In directory pdx:/tmp/cvs-serv30260/src
Modified Files:
glitz.c glitz.h glitz_matrix.c glitz_program.c
glitz_programmatic.c glitz_surface.c glitzint.h
Log Message:
Updated linear and radial surfaces
Index: glitz.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** a/glitz.c 28 Apr 2004 08:59:38 -0000 1.2
--- b/glitz.c 30 Apr 2004 02:26:02 -0000 1.3
***************
*** 210,213 ****
--- 210,216 ----
glitz_intersect_sub_pixel_region (&src_region, &dst_region, &src_region);
+ if (x_src < 0) x_src = 0;
+ if (y_src < 0) y_src = 0;
+
src_region.x2 = x_src + (src_region.x2 - src_region.x1) - translate_src.x;
src_region.y2 = y_src + (src_region.y2 - src_region.y1) - translate_src.y;
***************
*** 226,229 ****
--- 229,235 ----
} else {
glitz_intersect_sub_pixel_region (&mask_region, &dst_region, &mask_region);
+
+ if (x_mask < 0) x_mask = 0;
+ if (y_mask < 0) y_mask = 0;
mask_region.x2 = x_mask + (mask_region.x2 - mask_region.x1) -
Index: glitz.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** a/glitz.h 28 Apr 2004 08:59:38 -0000 1.3
--- b/glitz.h 30 Apr 2004 02:26:02 -0000 1.4
***************
*** 56,63 ****
} glitz_point_fixed_t;
- typedef struct _glitz_distance_fixed_t {
- glitz_fixed16_16_t dx, dy;
- } glitz_distance_fixed_t;
-
typedef struct _glitz_line_fixed_t {
glitz_point_fixed_t p1, p2;
--- 56,59 ----
***************
*** 278,282 ****
glitz_surface_t *
glitz_surface_create_radial (glitz_point_fixed_t *center,
! glitz_distance_fixed_t *radius,
glitz_color_range_t *color_range);
--- 274,279 ----
glitz_surface_t *
glitz_surface_create_radial (glitz_point_fixed_t *center,
! glitz_fixed16_16_t radius0,
! glitz_fixed16_16_t radius1,
glitz_color_range_t *color_range);
Index: glitz_matrix.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_matrix.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** a/glitz_matrix.c 30 Mar 2004 17:07:18 -0000 1.1.1.1
--- b/glitz_matrix.c 30 Apr 2004 02:26:02 -0000 1.2
***************
*** 36,41 ****
static void
_glitz_matrix_transform_distance (glitz_matrix_t *matrix,
! double *dx,
! double *dy)
{
double new_x, new_y;
--- 36,41 ----
static void
_glitz_matrix_transform_distance (glitz_matrix_t *matrix,
! double *dx,
! double *dy)
{
double new_x, new_y;
***************
*** 50,54 ****
void
glitz_matrix_transform_point (glitz_matrix_t *matrix,
! glitz_point_t *point)
{
_glitz_matrix_transform_distance (matrix, &point->x, &point->y);
--- 50,54 ----
void
glitz_matrix_transform_point (glitz_matrix_t *matrix,
! glitz_point_t *point)
{
_glitz_matrix_transform_distance (matrix, &point->x, &point->y);
***************
*** 60,64 ****
void
glitz_matrix_transform_region (glitz_matrix_t *matrix,
! glitz_region_box_t *region)
{
glitz_point_t point;
--- 60,64 ----
void
glitz_matrix_transform_region (glitz_matrix_t *matrix,
! glitz_region_box_t *region)
{
glitz_point_t point;
***************
*** 84,88 ****
void
glitz_matrix_transform_sub_pixel_region (glitz_matrix_t *matrix,
! glitz_sub_pixel_region_box_t *region)
{
_glitz_matrix_transform_distance (matrix, ®ion->x1, ®ion->y1);
--- 84,88 ----
void
glitz_matrix_transform_sub_pixel_region (glitz_matrix_t *matrix,
! glitz_sub_pixel_region_box_t *region)
{
_glitz_matrix_transform_distance (matrix, ®ion->x1, ®ion->y1);
***************
*** 97,103 ****
static void
_glitz_matrix_set_affine (glitz_matrix_t *matrix,
! double a, double b,
! double c, double d,
! double tx, double ty)
{
matrix->m[0][0] = a; matrix->m[0][1] = b;
--- 97,103 ----
static void
_glitz_matrix_set_affine (glitz_matrix_t *matrix,
! double a, double b,
! double c, double d,
! double tx, double ty)
{
matrix->m[0][0] = a; matrix->m[0][1] = b;
***************
*** 108,112 ****
static void
_glitz_matrix_scalar_multiply (glitz_matrix_t *matrix,
! double scalar)
{
int row, col;
--- 108,112 ----
static void
_glitz_matrix_scalar_multiply (glitz_matrix_t *matrix,
! double scalar)
{
int row, col;
***************
*** 132,143 ****
_glitz_matrix_set_affine (matrix,
! d, -b,
! -c, a,
! c * ty - d * tx, b * tx - a * ty);
}
static void
_glitz_matrix_compute_determinant (glitz_matrix_t *matrix,
! double *det)
{
double a, b, c, d;
--- 132,143 ----
_glitz_matrix_set_affine (matrix,
! d, -b,
! -c, a,
! c * ty - d * tx, b * tx - a * ty);
}
static void
_glitz_matrix_compute_determinant (glitz_matrix_t *matrix,
! double *det)
{
double a, b, c, d;
***************
*** 168,173 ****
void
glitz_matrix_translate (glitz_matrix_t *matrix,
! double tx,
! double ty)
{
matrix->m[2][0] += tx;
--- 168,173 ----
void
glitz_matrix_translate (glitz_matrix_t *matrix,
! double tx,
! double ty)
{
matrix->m[2][0] += tx;
***************
*** 175,179 ****
}
-
/* This function is only used for convolution kernel normalization.
I'm not sure that it does the right thing when kernel contains negative
--- 175,178 ----
Index: glitz_program.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_program.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** a/glitz_program.c 28 Apr 2004 08:59:38 -0000 1.3
--- b/glitz_program.c 30 Apr 2004 02:26:02 -0000 1.4
***************
*** 261,265 ****
/*
* Linear gradient using 1D texture as color range.
! * Texture unit 2 is color range.
*
* program.local[0].x = start offset
--- 261,265 ----
/*
* Linear gradient using 1D texture as color range.
! * Color range in texture unit 2.
*
* program.local[0].x = start offset
***************
*** 268,271 ****
--- 268,284 ----
* program.local[0].w = cos (angle)
*
+ * transform:
+ * [ a | c | tx ]
+ * [ b | d | ty ]
+ * [ 0 | 0 | 1 ]
+ *
+ * program.local[1].x = a
+ * program.local[1].y = b
+ * program.local[1].z = c
+ * program.local[1].w = d
+ * program.local[2].x = tx
+ * program.local[2].y = ty
+ * program.local[2].z = height
+ *
* Author: David Reveman <c99drn at cs.umu.se>
*/
***************
*** 273,284 ****
"!!ARBfp1.0\n"
"PARAM gradient = program.local[0];\n"
"ATTRIB pos = fragment.texcoord[%d];\n"
"TEMP color, distance, position;\n"
!
/* temporary */
"%s"
!
! "MUL position.x, gradient.z, pos.x;\n"
! "MAD position.x, gradient.w, pos.y, position.x;\n"
"SUB distance.x, position.x, gradient.x;\n"
--- 286,313 ----
"!!ARBfp1.0\n"
"PARAM gradient = program.local[0];\n"
+ "PARAM transform = program.local[1];\n"
+ "PARAM translate = program.local[2];\n"
"ATTRIB pos = fragment.texcoord[%d];\n"
"TEMP color, distance, position;\n"
!
/* temporary */
"%s"
!
! /* flip Y position */
! "SUB position.y, translate.z, pos.y;\n"
!
! /* transform X position */
! "MUL position.x, transform.x, pos.x;\n"
! "MAD position.x, transform.z, position.y, position.x;\n"
! "ADD position.x, position.x, translate.x;\n"
!
! /* transform Y position */
! "MUL position.y, transform.w, position.y;\n"
! "MAD position.y, transform.y, pos.x, position.y;\n"
! "ADD position.y, position.y, translate.y;\n"
!
! /* calculate gradient offset */
! "MUL position.x, gradient.z, position.x;\n"
! "MAD position.x, gradient.w, position.y, position.x;\n"
"SUB distance.x, position.x, gradient.x;\n"
***************
*** 294,305 ****
/*
* Radial gradient using 1D texture as color range.
! * Texture unit 2 is color range.
*
! * param[0].x = center point X coordinate
! * param[0].y = center point Y coordinate
! * param[1].x = MIN (radius_x, radius_y) / radius_x
! * param[1].y = MIN (radius_x, radius_y) / radius_y
! * param[1].z = 0
! * param[1].x = 1 / MIN (radius_x, radius_y)
*
* Author: David Reveman <c99drn at cs.umu.se>
--- 323,345 ----
/*
* Radial gradient using 1D texture as color range.
! * Color range in texture unit 2.
*
! * param.local[0].x = center point X coordinate
! * param.local[0].y = center point Y coordinate
! * param.local[0].z = 1 / (radius1 - radius0)
! * param.local[0].w = radius0
! *
! * transform:
! * [ a | c | tx ]
! * [ b | d | ty ]
! * [ 0 | 0 | 1 ]
! *
! * program.local[1].x = a
! * program.local[1].y = b
! * program.local[1].z = c
! * program.local[1].w = d
! * program.local[2].x = tx
! * program.local[2].y = ty
! * program.local[2].z = height
*
* Author: David Reveman <c99drn at cs.umu.se>
***************
*** 308,320 ****
"!!ARBfp1.0\n"
"PARAM gradient = program.local[0];\n"
! "PARAM length = program.local[1];\n"
! "ATTRIB position = fragment.texcoord[%d];\n"
! "TEMP color, distance;\n"
/* temporary */
"%s"
!
"SUB distance, position, gradient;\n"
- "MUL distance, distance, length;\n"
"DP3 distance.x, distance, distance;\n"
--- 348,374 ----
"!!ARBfp1.0\n"
"PARAM gradient = program.local[0];\n"
! "PARAM transform = program.local[1];\n"
! "PARAM translate = program.local[2];\n"
! "ATTRIB pos = fragment.texcoord[%d];\n"
! "TEMP color, distance, position;\n"
/* temporary */
"%s"
!
! /* flip Y position */
! "SUB position.y, translate.z, pos.y;\n"
!
! /* transform X position */
! "MUL position.x, transform.x, pos.x;\n"
! "MAD position.x, transform.z, position.y, position.x;\n"
! "ADD position.x, position.x, translate.x;\n"
!
! /* transform Y position */
! "MUL position.y, transform.w, position.y;\n"
! "MAD position.y, transform.y, pos.x, position.y;\n"
! "ADD position.y, position.y, translate.y;\n"
!
! /* calculate gradient offset */
"SUB distance, position, gradient;\n"
"DP3 distance.x, distance, distance;\n"
***************
*** 324,329 ****
"MUL distance.x, distance.x, distance.x;\n"
"MUL distance.x, distance.x, distance.w;\n"
!
! "MUL distance.x, distance.x, length.w;\n"
"TEX color, distance, texture[2], 1D;\n"
--- 378,384 ----
"MUL distance.x, distance.x, distance.x;\n"
"MUL distance.x, distance.x, distance.w;\n"
!
! "SUB distance.x, distance.x, gradient.w;\n"
! "MUL distance.x, distance.x, gradient.z;\n"
"TEX color, distance, texture[2], 1D;\n"
Index: glitz_programmatic.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_programmatic.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** a/glitz_programmatic.c 24 Apr 2004 22:10:22 -0000 1.2
--- b/glitz_programmatic.c 30 Apr 2004 02:26:02 -0000 1.3
***************
*** 109,112 ****
--- 109,119 ----
_glitz_programmatic_surface_create (void)
{
+ static const glitz_matrix_t identity = {
+ {
+ { 1.0, 0.0, 0.0 },
+ { 0.0, 1.0, 0.0 },
+ { 0.0, 0.0, 1.0 }
+ }
+ };
glitz_programmatic_surface_t *surface;
***************
*** 127,130 ****
--- 134,138 ----
surface->texture.texcoord_height = 1.0;
surface->texture.repeatable = surface->texture.repeat = 1;
+ surface->transform = identity;
return surface;
***************
*** 182,186 ****
glitz_surface_t *
glitz_programmatic_surface_create_radial (glitz_point_fixed_t *start,
! glitz_distance_fixed_t *radius,
glitz_color_range_t *color_range)
{
--- 190,195 ----
glitz_surface_t *
glitz_programmatic_surface_create_radial (glitz_point_fixed_t *start,
! glitz_fixed16_16_t radius0,
! glitz_fixed16_16_t radius1,
glitz_color_range_t *color_range)
{
***************
*** 193,197 ****
surface->type = GLITZ_PROGRAMMATIC_SURFACE_RADIAL_TYPE;
surface->u.radial.center = *start;
! surface->u.radial.radius = *radius;
surface->u.radial.color_range = color_range;
glitz_color_range_reference (color_range);
--- 202,207 ----
surface->type = GLITZ_PROGRAMMATIC_SURFACE_RADIAL_TYPE;
surface->u.radial.center = *start;
! surface->u.radial.radius0 = radius0;
! surface->u.radial.radius1 = radius1;
surface->u.radial.color_range = color_range;
glitz_color_range_reference (color_range);
***************
*** 201,204 ****
--- 211,230 ----
void
+ glitz_programmatic_surface_set_transform (glitz_surface_t *abstract_surface,
+ glitz_transform_t *transform)
+ {
+ glitz_programmatic_surface_t *surface =
+ (glitz_programmatic_surface_t *) abstract_surface;
+
+ 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]);
+ }
+
+ void
glitz_programmatic_surface_bind (glitz_gl_proc_address_list_t *gl,
glitz_programmatic_surface_t *surface,
***************
*** 217,226 ****
p1.x = FIXED_TO_DOUBLE (surface->u.linear.start.x);
! p1.y = surface->base.height -
! FIXED_TO_DOUBLE (surface->u.linear.start.y);
!
p2.x = FIXED_TO_DOUBLE (surface->u.linear.stop.x);
! p2.y = surface->base.height -
! FIXED_TO_DOUBLE (surface->u.linear.stop.y);
length = sqrt ((p2.x - p1.x) * (p2.x - p1.x) +
--- 243,249 ----
p1.x = FIXED_TO_DOUBLE (surface->u.linear.start.x);
! p1.y = FIXED_TO_DOUBLE (surface->u.linear.start.y);
p2.x = FIXED_TO_DOUBLE (surface->u.linear.stop.x);
! p2.y = FIXED_TO_DOUBLE (surface->u.linear.stop.y);
length = sqrt ((p2.x - p1.x) * (p2.x - p1.x) +
***************
*** 237,240 ****
--- 260,272 ----
cos (angle),
-sin (angle));
+ gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 1,
+ surface->transform.m[0][0],
+ surface->transform.m[0][1],
+ surface->transform.m[1][0],
+ surface->transform.m[1][1]);
+ gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 2,
+ surface->transform.m[2][0],
+ surface->transform.m[2][1],
+ surface->base.height, 0.0);
gl->active_texture_arb (GLITZ_GL_TEXTURE2_ARB);
***************
*** 242,275 ****
gl->active_texture_arb (GLITZ_GL_TEXTURE0_ARB);
} break;
! case GLITZ_PROGRAMMATIC_SURFACE_RADIAL_TYPE: {
! double radius_x, radius_y;
! double length;
!
! radius_x = FIXED_TO_DOUBLE (surface->u.radial.radius.dx);
! radius_y = FIXED_TO_DOUBLE (surface->u.radial.radius.dy);
!
! length = fabs (MIN (radius_x, radius_y));
!
! /* ugly */
! if (length == 0.0)
! length = 0.000001;
!
! gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 0,
! FIXED_TO_DOUBLE
! (surface->u.radial.center.x),
! surface->base.height -
! FIXED_TO_DOUBLE
! (surface->u.radial.center.y),
! 0.0, 0.0);
gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 1,
! length / radius_x,
! length / radius_y,
! 0.0,
! 1.0 / length);
gl->active_texture_arb (GLITZ_GL_TEXTURE2_ARB);
glitz_color_range_bind (gl, surface->u.radial.color_range, feature_mask);
gl->active_texture_arb (GLITZ_GL_TEXTURE0_ARB);
- }
default:
break;
--- 274,298 ----
gl->active_texture_arb (GLITZ_GL_TEXTURE0_ARB);
} break;
! case GLITZ_PROGRAMMATIC_SURFACE_RADIAL_TYPE:
! gl->program_local_param_4d_arb
! (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 0,
! FIXED_TO_DOUBLE (surface->u.radial.center.x),
! FIXED_TO_DOUBLE (surface->u.radial.center.y),
! 1.0 / (FIXED_TO_DOUBLE (surface->u.radial.radius1) -
! FIXED_TO_DOUBLE (surface->u.radial.radius0)),
! FIXED_TO_DOUBLE (surface->u.radial.radius0));
gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 1,
! surface->transform.m[0][0],
! surface->transform.m[0][1],
! surface->transform.m[1][0],
! surface->transform.m[1][1]);
! gl->program_local_param_4d_arb (GLITZ_GL_FRAGMENT_PROGRAM_ARB, 2,
! surface->transform.m[2][0],
! surface->transform.m[2][1],
! surface->base.height, 0.0);
gl->active_texture_arb (GLITZ_GL_TEXTURE2_ARB);
glitz_color_range_bind (gl, surface->u.radial.color_range, feature_mask);
gl->active_texture_arb (GLITZ_GL_TEXTURE0_ARB);
default:
break;
Index: glitz_surface.c
===================================================================
RCS file: /cvs/cairo/glitz/src/glitz_surface.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** a/glitz_surface.c 28 Apr 2004 08:59:38 -0000 1.4
--- b/glitz_surface.c 30 Apr 2004 02:26:02 -0000 1.5
***************
*** 105,113 ****
glitz_surface_t *
glitz_surface_create_radial (glitz_point_fixed_t *center,
! glitz_distance_fixed_t *radius,
glitz_color_range_t *color_range)
{
return
! glitz_programmatic_surface_create_radial (center, radius, color_range);
}
slim_hidden_def(glitz_surface_create_radial);
--- 105,116 ----
glitz_surface_t *
glitz_surface_create_radial (glitz_point_fixed_t *center,
! glitz_fixed16_16_t radius0,
! glitz_fixed16_16_t radius1,
glitz_color_range_t *color_range)
{
return
! glitz_programmatic_surface_create_radial (center,
! radius0, radius1,
! color_range);
}
slim_hidden_def(glitz_surface_create_radial);
***************
*** 244,249 ****
};
! if (SURFACE_PROGRAMMATIC (surface))
return;
if (transform && memcmp (transform, &identity,
--- 247,254 ----
};
! if (SURFACE_PROGRAMMATIC (surface)) {
! glitz_programmatic_surface_set_transform (surface, transform);
return;
+ }
if (transform && memcmp (transform, &identity,
***************
*** 255,260 ****
glitz_surface_push_transform (surface);
if (!surface->transform)
! return;
! }
surface->transform->m[0][0] = FIXED_TO_DOUBLE (transform->matrix[0][0]);
--- 260,265 ----
glitz_surface_push_transform (surface);
if (!surface->transform)
! return;
! }
surface->transform->m[0][0] = FIXED_TO_DOUBLE (transform->matrix[0][0]);
Index: glitzint.h
===================================================================
RCS file: /cvs/cairo/glitz/src/glitzint.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** a/glitzint.h 28 Apr 2004 08:59:38 -0000 1.5
--- b/glitzint.h 30 Apr 2004 02:26:02 -0000 1.6
***************
*** 334,337 ****
--- 334,338 ----
glitz_texture_t texture;
+ glitz_matrix_t transform;
glitz_programmatic_surface_type_t type;
***************
*** 347,351 ****
struct {
glitz_point_fixed_t center;
! glitz_distance_fixed_t radius;
glitz_color_range_t *color_range;
} radial;
--- 348,353 ----
struct {
glitz_point_fixed_t center;
! glitz_fixed16_16_t radius0;
! glitz_fixed16_16_t radius1;
glitz_color_range_t *color_range;
} radial;
***************
*** 614,621 ****
extern glitz_surface_t *__internal_linkage
glitz_programmatic_surface_create_radial (glitz_point_fixed_t *start,
! glitz_distance_fixed_t *radius,
glitz_color_range_t *color_range);
extern void __internal_linkage
glitz_color_range_bind (glitz_gl_proc_address_list_t *gl,
glitz_color_range_t *color_range,
--- 616,628 ----
extern glitz_surface_t *__internal_linkage
glitz_programmatic_surface_create_radial (glitz_point_fixed_t *start,
! glitz_fixed16_16_t radius0,
! glitz_fixed16_16_t radius1,
glitz_color_range_t *color_range);
extern void __internal_linkage
+ glitz_programmatic_surface_set_transform (glitz_surface_t *surface,
+ glitz_transform_t *transform);
+
+ extern void __internal_linkage
glitz_color_range_bind (glitz_gl_proc_address_list_t *gl,
glitz_color_range_t *color_range,
More information about the cairo-commit
mailing list