[cairo-commit] libglc/src glc.c,1.18,1.19 glc_matrix.c,1.3,1.4 glc_surface.c,1.17,1.18 glcint.h,1.18,1.19
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-serv4375/src
Modified Files:
glc.c glc_matrix.c glc_surface.c glcint.h
Log Message:
None direct compositing optimizations
Index: glc.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** a/glc.c 20 Feb 2004 17:40:57 -0000 1.18
--- b/glc.c 21 Feb 2004 03:19:11 -0000 1.19
***************
*** 306,309 ****
--- 306,311 ----
glc_region_box_t *mbounds)
{
+ glc_region_box_t region;
+
if (bounds->x1 <= 0)
mbounds->x1 = 0;
***************
*** 326,347 ****
mbounds->y2 = bounds->y2;
! /* TODO: This can be optimized by clipping to transformed
! surface coordinates. */
! if ((!TRANSFORM (src)) && (!TRANSFORM (mask))) {
! if (!src->repeat) {
! if ((mbounds->x2 - mbounds->x1) >= (src->width - x_src))
! mbounds->x2 = mbounds->x1 + (src->width - x_src);
!
! if ((mbounds->y2 - mbounds->y1) >= (src->height - y_src))
! mbounds->y2 = mbounds->y1 + (src->height - y_src);
! }
! if (!mask->repeat) {
! if ((mbounds->x2 - mbounds->x1) >= (mask->width - x_mask))
! mbounds->x2 = mbounds->x1 + (mask->width - x_mask);
!
! if ((mbounds->y2 - mbounds->y1) >= (mask->height - y_mask))
! mbounds->y2 = mbounds->y1 + (mask->height - y_mask);
! }
}
}
--- 328,373 ----
mbounds->y2 = bounds->y2;
! if (!REPEAT (src)) {
! region.x1 = 0;
! region.y1 = 0;
! region.x2 = src->width - x_src;
! region.y2 = src->height - y_src;
!
! if (TRANSFORM (src))
! glc_matrix_transform_region (src->transform, ®ion);
!
! if (mbounds->x1 < region.x1)
! mbounds->x1 = region.x1;
!
! if (mbounds->y1 < region.y1)
! mbounds->y1 = region.y1;
!
! if (mbounds->x2 > region.x2)
! mbounds->x2 = region.x2;
!
! if (mbounds->y2 > region.y2)
! mbounds->y2 = region.y2;
! }
! if (!REPEAT (mask)) {
! region.x1 = 0;
! region.y1 = 0;
! region.x2 = mask->width - x_mask;
! region.y2 = mask->height - y_mask;
!
! if (TRANSFORM (mask))
! glc_matrix_transform_region (mask->transform, ®ion);
!
! if (mbounds->x1 < region.x1)
! mbounds->x1 = region.x1;
!
! if (mbounds->y1 < region.y1)
! mbounds->y1 = region.y1;
!
! if (mbounds->x2 > region.x2)
! mbounds->x2 = region.x2;
!
! if (mbounds->y2 > region.y2)
! mbounds->y2 = region.y2;
}
}
***************
*** 361,365 ****
int height)
{
! glc_surface_t *intermediate = NULL, *src_intermediate = NULL, *mask_surface;
glc_texture_t *texture;
glc_point_t tl, bl, br, tr;
--- 387,391 ----
int height)
{
! glc_surface_t *intermediate = NULL, *mask_surface;
glc_texture_t *texture;
glc_point_t tl, bl, br, tr;
***************
*** 369,372 ****
--- 395,399 ----
glc_region_box_t mask_bounds;
static glc_color_t clear_color = { 0x0000, 0x0000, 0x0000, 0x0000 };
+ glc_bool_t intermediate_translate;
if ((dst->feature_mask & GLC_FEATURE_ARB_FRAGMENT_PROGRAM_MASK) &&
***************
*** 378,381 ****
--- 405,412 ----
width, height))
return;
+
+ mask_bounds.x1 = x_dst;
+ mask_bounds.y1 = y_dst;
+ intermediate_translate = 0;
if (!mask->implicit_mask) {
***************
*** 393,404 ****
mask_bounds.y2 - mask_bounds.y1 <= 0)
return;
mask_surface = intermediate =
glc_surface_create_similar (dst,
GLC_STANDARD_ARGB32,
! mask_bounds.x2 -
! mask_bounds.x1,
! mask_bounds.y2 -
! mask_bounds.y1);
if (!mask_surface) {
--- 424,436 ----
mask_bounds.y2 - mask_bounds.y1 <= 0)
return;
+
+ if ((x_dst != mask_bounds.x1) || (y_dst != mask_bounds.y1))
+ intermediate_translate = 1;
mask_surface = intermediate =
glc_surface_create_similar (dst,
GLC_STANDARD_ARGB32,
! mask_bounds.x2 - mask_bounds.x1,
! mask_bounds.y2 - mask_bounds.y1);
if (!mask_surface) {
***************
*** 414,450 ****
mask_surface->width,
mask_surface->height);
!
glc_composite (GLC_OPERATOR_SRC,
mask, NULL, mask_surface,
! x_mask, y_mask, 0, 0, 0, 0,
mask_surface->width,
mask_surface->height);
} else
mask_surface = mask;
! if (TRANSFORM (src)) {
! src_intermediate =
! glc_surface_create_similar (dst,
! GLC_STANDARD_ARGB32,
! mask_surface->width,
! mask_surface->height);
! glc_fill_rectangle (GLC_OPERATOR_SRC, src_intermediate,
! &clear_color, 0, 0,
! mask_surface->width,
! mask_surface->height);
! glc_composite (GLC_OPERATOR_SRC,
! src, NULL, src_intermediate,
! x_src, y_src, 0, 0, 0, 0,
! mask_surface->width,
! mask_surface->height);
! src = src_intermediate;
}
glc_composite (GLC_OPERATOR_IN,
src, NULL, mask_surface,
! x_src, y_src, 0, 0, 0, 0,
mask_surface->width,
mask_surface->height);
!
width = mask_surface->width;
height = mask_surface->height;
--- 446,494 ----
mask_surface->width,
mask_surface->height);
!
! if ((!REPEAT (mask)) && intermediate_translate) {
! glc_surface_push_transform (mask);
! glc_matrix_translate (mask->transform,
! x_dst - mask_bounds.x1,
! y_dst - mask_bounds.y1);
! }
!
glc_composite (GLC_OPERATOR_SRC,
mask, NULL, mask_surface,
! x_mask, y_mask,
! 0, 0,
! 0, 0,
mask_surface->width,
mask_surface->height);
+
+ if (intermediate_translate)
+ glc_surface_pop_transform (mask);
+
} else
mask_surface = mask;
! if ((!REPEAT (src)) && intermediate_translate) {
! glc_surface_push_transform (src);
! glc_matrix_translate (src->transform,
! x_dst - mask_bounds.x1,
! y_dst - mask_bounds.y1);
}
+
+ if (TRANSFORM (src))
+ mask_surface->clear_exterior = 1;
glc_composite (GLC_OPERATOR_IN,
src, NULL, mask_surface,
! x_src, y_src,
! 0, 0,
! 0, 0,
mask_surface->width,
mask_surface->height);
!
! if (intermediate_translate)
! glc_surface_pop_transform (src);
!
! x_dst = mask_bounds.x1;
! y_dst = mask_bounds.y1;
width = mask_surface->width;
height = mask_surface->height;
***************
*** 609,628 ****
glEnd ();
! bl.x += src->width;
! tl.x += src->width;
! tr.x += src->width;
! br.x += src->width;
} while (REPEAT (src) && (tl.x < (x_dst + width)));
-
- bl.y += src->height;
- tl.y += src->height;
- tr.y += src->height;
- br.y += src->height;
! tl.x = save_tlx;
! bl.x = save_blx;
! tr.x = save_trx;
! br.x = save_brx;
} while (REPEAT (src) && (tl.y < (y_dst + height)));
--- 653,676 ----
glEnd ();
! if (REPEAT (src)) {
! bl.x += src->width;
! tl.x += src->width;
! tr.x += src->width;
! br.x += src->width;
! }
} while (REPEAT (src) && (tl.x < (x_dst + width)));
! if (REPEAT (src)) {
! bl.y += src->height;
! tl.y += src->height;
! tr.y += src->height;
! br.y += src->height;
!
! tl.x = save_tlx;
! bl.x = save_blx;
! tr.x = save_trx;
! br.x = save_brx;
! }
} while (REPEAT (src) && (tl.y < (y_dst + height)));
***************
*** 634,644 ****
glc_texture_unbind (texture);
glc_surface_dirty (dst, &clip);
glc_surface_pop_current (dst);
- if (src_intermediate)
- glc_surface_destroy (src_intermediate);
-
if (intermediate)
glc_surface_destroy (intermediate);
--- 682,741 ----
glc_texture_unbind (texture);
+ /* Clear intermediate mask exterior. This is only done if
+ destination surfaces is an intermediate mask surface
+ and source surface is transformed and not repeating. */
+ if (dst->clear_exterior && (!REPEAT (src))) {
+ glc_set_operator (GLC_OPERATOR_SRC);
+ glColor4f (0.0, 0.0, 0.0, 0.0);
+
+ glBegin (GL_QUADS);
+
+ glVertex2d (tl.x, tl.y);
+ glVertex2d (0.0, tl.y);
+ glVertex2d (0.0, 0.0);
+ glVertex2d (tl.x, 0.0);
+
+ glVertex2d (tl.x, tl.y);
+ glVertex2d (tl.x, 0.0);
+ glVertex2d (tr.x, 0.0);
+ glVertex2d (tr.x, tr.y);
+
+ glVertex2d (tr.x, tr.y);
+ glVertex2d (tr.x, 0.0);
+ glVertex2d (dst->width, 0.0);
+ glVertex2d (dst->width, tr.y);
+
+ glVertex2d (tr.x, tr.y);
+ glVertex2d (dst->width, tr.y);
+ glVertex2d (dst->width, br.y);
+ glVertex2d (br.x, br.y);
+
+ glVertex2d (br.x, br.y);
+ glVertex2d (dst->width, br.y);
+ glVertex2d (dst->width, dst->height);
+ glVertex2d (br.x, dst->height);
+
+ glVertex2d (br.x, br.y);
+ glVertex2d (br.x, dst->height);
+ glVertex2d (bl.x, dst->height);
+ glVertex2d (bl.x, bl.y);
+
+ glVertex2d (bl.x, bl.y);
+ glVertex2d (bl.x, dst->height);
+ glVertex2d (0.0, dst->height);
+ glVertex2d (0.0, bl.y);
+
+ glVertex2d (bl.x, bl.y);
+ glVertex2d (0.0, bl.y);
+ glVertex2d (0.0, tl.y);
+ glVertex2d (tl.x, tl.y);
+
+ glEnd ();
+ }
+
glc_surface_dirty (dst, &clip);
glc_surface_pop_current (dst);
if (intermediate)
glc_surface_destroy (intermediate);
Index: glc_matrix.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_matrix.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** a/glc_matrix.c 20 Feb 2004 17:40:57 -0000 1.3
--- b/glc_matrix.c 21 Feb 2004 03:19:12 -0000 1.4
***************
*** 59,62 ****
--- 59,86 ----
void
+ glc_matrix_transform_region (glc_matrix_t *matrix,
+ glc_region_box_t *region)
+ {
+ glc_point_t point;
+
+ point.x = region->x1;
+ point.y = region->y1;
+ _glc_matrix_transform_distance (matrix, &point.x, &point.y);
+ region->x1 = floor (point.x);
+ region->y1 = floor (point.y);
+
+ point.x = region->x2;
+ point.y = region->y2;
+ _glc_matrix_transform_distance (matrix, &point.x, &point.y);
+ region->x2 = ceil (point.x);
+ region->y2 = ceil (point.y);
+
+ region->x1 += (int) floor (matrix->m[2][0]);
+ region->y1 += (int) floor (matrix->m[2][1]);
+ region->x2 += (int) ceil (matrix->m[2][0]);
+ region->y2 += (int) ceil (matrix->m[2][1]);
+ }
+
+ void
glc_matrix_transform_sub_pixel_region (glc_matrix_t *matrix,
glc_sub_pixel_region_box_t *region)
***************
*** 142,145 ****
--- 166,179 ----
}
+ void
+ glc_matrix_translate (glc_matrix_t *matrix,
+ double tx,
+ double ty)
+ {
+ matrix->m[2][0] += tx;
+ matrix->m[2][1] += ty;
+ }
+
+
/* This function is only used for convolution kernel normalization.
I'm not sure that it does the right thing when kernel contains negative
Index: glc_surface.c
===================================================================
RCS file: /cvs/cairo/libglc/src/glc_surface.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** a/glc_surface.c 20 Feb 2004 17:40:57 -0000 1.17
--- b/glc_surface.c 21 Feb 2004 03:19:12 -0000 1.18
***************
*** 46,49 ****
--- 46,51 ----
surface->repeat = 0;
surface->transform = NULL;
+ surface->transforms = NULL;
+ surface->n_transforms = 0;
surface->anti_aliasing = 0;
surface->filter = GLC_FILTER_NEAREST;
***************
*** 54,57 ****
--- 56,60 ----
surface->requires_flipping = 1;
surface->convolution = NULL;
+ surface->clear_exterior = 0;
}
***************
*** 59,64 ****
glc_surface_deinit (glc_surface_t *surface)
{
! if (surface->transform)
! free (surface->transform);
if (surface->convolution)
--- 62,67 ----
glc_surface_deinit (glc_surface_t *surface)
{
! if (surface->transforms)
! free (surface->transforms);
if (surface->convolution)
***************
*** 125,128 ****
--- 128,180 ----
void
+ glc_surface_push_transform (glc_surface_t *surface)
+ {
+ static const glc_matrix_t identity = {
+ {
+ { 1.0, 0.0, 0.0 },
+ { 0.0, 1.0, 0.0 },
+ { 0.0, 0.0, 1.0 }
+ }
+ };
+
+ surface->n_transforms++;
+
+ surface->transforms =
+ realloc (surface->transforms,
+ surface->n_transforms * sizeof (glc_matrix_t));
+
+ if (!surface->transforms)
+ return;
+
+ if (surface->n_transforms > 1) {
+ memcpy (&surface->transforms[surface->n_transforms - 1],
+ &surface->transforms[surface->n_transforms - 2],
+ sizeof (glc_matrix_t));
+ } else
+ memcpy (&surface->transforms[surface->n_transforms - 1],
+ &identity, sizeof (glc_matrix_t));
+
+ surface->transform = &surface->transforms[surface->n_transforms - 1];
+ }
+
+ void
+ glc_surface_pop_transform (glc_surface_t *surface)
+ {
+ if (surface->n_transforms < 1)
+ return;
+
+ surface->n_transforms--;
+
+ surface->transforms =
+ realloc (surface->transforms,
+ surface->n_transforms * sizeof (glc_matrix_t));
+
+ if (surface->n_transforms)
+ surface->transform = &surface->transforms[surface->n_transforms - 1];
+ else
+ surface->transform = NULL;
+ }
+
+ void
glc_surface_set_transform (glc_surface_t *surface,
glc_transform_t *transform)
***************
*** 142,146 ****
if (transform) {
if (!surface->transform) {
! surface->transform = malloc (sizeof (glc_matrix_t));
if (!surface->transform)
return;
--- 194,198 ----
if (transform) {
if (!surface->transform) {
! glc_surface_push_transform (surface);
if (!surface->transform)
return;
***************
*** 156,169 ****
if (glc_matrix_invert (surface->transform)) {
! free (surface->transform);
! surface->transform = NULL;
glc_surface_status_add (surface, GLC_STATUS_INVALID_MATRIX_MASK);
}
! } else {
! if (surface->transform) {
! free (surface->transform);
! surface->transform = NULL;
! }
! }
}
slim_hidden_def(glc_surface_set_transform);
--- 208,216 ----
if (glc_matrix_invert (surface->transform)) {
! glc_surface_pop_transform (surface);
glc_surface_status_add (surface, GLC_STATUS_INVALID_MATRIX_MASK);
}
! } else
! glc_surface_pop_transform (surface);
}
slim_hidden_def(glc_surface_set_transform);
Index: glcint.h
===================================================================
RCS file: /cvs/cairo/libglc/src/glcint.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** a/glcint.h 20 Feb 2004 17:40:57 -0000 1.18
--- b/glcint.h 21 Feb 2004 03:19:12 -0000 1.19
***************
*** 221,224 ****
--- 221,226 ----
glc_polyedge_t polyedge;
glc_matrix_t *transform;
+ glc_matrix_t *transforms;
+ unsigned int n_transforms;
glc_bool_t anti_aliasing;
int width, height;
***************
*** 230,233 ****
--- 232,236 ----
glc_programs_t *programs;
glc_matrix_t *convolution;
+ glc_bool_t clear_exterior;
};
***************
*** 242,245 ****
--- 245,252 ----
extern void __internal_linkage
+ glc_matrix_transform_region (glc_matrix_t *matrix,
+ glc_region_box_t *region);
+
+ extern void __internal_linkage
glc_matrix_transform_sub_pixel_region (glc_matrix_t *matrix,
glc_sub_pixel_region_box_t *region);
***************
*** 248,251 ****
--- 255,263 ----
glc_matrix_invert (glc_matrix_t *matrix);
+ extern void __internal_linkage
+ glc_matrix_translate (glc_matrix_t *matrix,
+ double tx,
+ double ty);
+
extern glc_status_t __internal_linkage
glc_matrix_normalize (glc_matrix_t *matrix);
***************
*** 321,324 ****
--- 333,342 ----
extern void __internal_linkage
+ glc_surface_push_transform (glc_surface_t *surface);
+
+ extern void __internal_linkage
+ glc_surface_pop_transform (glc_surface_t *surface);
+
+ extern void __internal_linkage
glc_surface_deinit (glc_surface_t *surface);
More information about the cairo-commit
mailing list