summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2005-05-26 13:02:31 +0000
committerKeith Packard <keithp@keithp.com>2005-05-26 13:02:31 +0000
commitae96f5db6cb357ae9432d66a9590e11e6c7d9cca (patch)
tree2e67c23b229780a130dfa3c004db07631be33a94
parent45a966f69528c86dd6e3d4736805803b80de9f9b (diff)
Split clipping into separate source and destination operand clips. By default, source operands are not affected by any client clipping. This matches the desired semantics for cairo. When this code is ported back to the X server, that will have to select the clipping option which clip source operands to the client clip.
-rw-r--r--pixman/ChangeLog15
-rw-r--r--pixman/src/iccompose.c20
-rw-r--r--pixman/src/icimage.c37
-rw-r--r--pixman/src/icimage.h9
4 files changed, 66 insertions, 15 deletions
diff --git a/pixman/ChangeLog b/pixman/ChangeLog
index 4490a763f..e619314c4 100644
--- a/pixman/ChangeLog
+++ b/pixman/ChangeLog
@@ -1,3 +1,18 @@
+2005-05-26 Keith Packard <keithp@keithp.com>
+
+ * src/iccompose.c: (IcFetch_transform), (IcFetcha_transform),
+ (IcBuildCompositeOperand):
+ * src/icimage.c: (pixman_image_init), (pixman_image_destroy),
+ (pixman_image_set_clip_region), (IcClipImageSrc):
+ * src/icimage.h:
+
+ Split clipping into separate source and destination operand
+ clips. By default, source operands are not affected by
+ any client clipping. This matches the desired semantics
+ for cairo. When this code is ported back to the X server,
+ that will have to select the clipping option which clip
+ source operands to the client clip.
+
2005-05-18 Carl Worth <cworth@cworth.org>
* configure.in: Add -head to CAIRO_VERSION after tagging with
diff --git a/pixman/src/iccompose.c b/pixman/src/iccompose.c
index 96d23b76b..84c48017d 100644
--- a/pixman/src/iccompose.c
+++ b/pixman/src/iccompose.c
@@ -2265,7 +2265,7 @@ IcFetch_transform (pixman_compositeOperand *op)
y = MOD (y, op->u.transform.height);
x = MOD (x, op->u.transform.width);
}
- if (pixman_region_contains_point (op->clip, x, y, &box))
+ if (pixman_region_contains_point (op->src_clip, x, y, &box))
{
(*op[1].set) (&op[1], x, y);
bits = (*op[1].fetch) (&op[1]);
@@ -2302,7 +2302,7 @@ IcFetch_transform (pixman_compositeOperand *op)
else
tx = x;
- if (pixman_region_contains_point (op->clip, tx, ty, &box))
+ if (pixman_region_contains_point (op->src_clip, tx, ty, &box))
{
(*op[1].set) (&op[1], tx, ty);
bits = (*op[1].fetch) (&op[1]);
@@ -2364,7 +2364,7 @@ IcFetcha_transform (pixman_compositeOperand *op)
y = MOD (y, op->u.transform.height);
x = MOD (x, op->u.transform.width);
}
- if (pixman_region_contains_point (op->clip, x, y, &box))
+ if (pixman_region_contains_point (op->src_clip, x, y, &box))
{
(*op[1].set) (&op[1], x, y);
bits = (*op[1].fetcha) (&op[1]);
@@ -2402,7 +2402,7 @@ IcFetcha_transform (pixman_compositeOperand *op)
else
tx = x;
- if (pixman_region_contains_point (op->clip, tx, ty, &box))
+ if (pixman_region_contains_point (op->src_clip, tx, ty, &box))
{
(*op[1].set) (&op[1], tx, ty);
bits = (*op[1].fetcha) (&op[1]);
@@ -2579,7 +2579,8 @@ IcBuildCompositeOperand (pixman_image_t *image,
op->down = IcStepDown_transform;
op->set = IcSet_transform;
- op->clip = op[1].clip;
+ op->src_clip = op[1].src_clip;
+ op->dst_clip = op[1].dst_clip;
return 1;
}
@@ -2603,7 +2604,8 @@ IcBuildCompositeOperand (pixman_image_t *image,
op->down = IcStepDown_external;
op->set = IcSet_external;
- op->clip = op[1].clip;
+ op->src_clip = op[1].dst_clip;
+ op->dst_clip = op[1].dst_clip;
return 1;
}
@@ -2627,7 +2629,11 @@ IcBuildCompositeOperand (pixman_image_t *image,
op->down = IcStepDown;
op->set = IcSet;
- op->clip = image->pCompositeClip;
+ op->dst_clip = image->pCompositeClip;
+ if (image->compositeClipSource)
+ op->src_clip = image->pCompositeClip;
+ else
+ op->src_clip = image->pSourceClip;
IcGetPixels (image->pixels, bits, stride, bpp,
xoff, yoff);
diff --git a/pixman/src/icimage.c b/pixman/src/icimage.c
index aefd5ba4b..7f5b9ef89 100644
--- a/pixman/src/icimage.c
+++ b/pixman/src/icimage.c
@@ -110,10 +110,15 @@ pixman_image_init (pixman_image_t *image)
image->subWindowMode = ClipByChildren;
image->polyEdge = PolyEdgeSharp;
image->polyMode = PolyModePrecise;
- /* XXX: In the server this was 0. Why? */
- image->freeCompClip = 1;
+ /*
+ * In the server this was 0 because the composite clip list
+ * can be referenced from a window (and often is)
+ */
+ image->freeCompClip = 0;
+ image->freeSourceClip = 0;
image->clientClipType = CT_NONE;
image->componentAlpha = 0;
+ image->compositeClipSource = 0;
image->alphaMap = 0;
image->alphaOrigin.x = 0;
@@ -133,7 +138,13 @@ pixman_image_init (pixman_image_t *image)
image->pCompositeClip = pixman_region_create();
pixman_region_union_rect (image->pCompositeClip, image->pCompositeClip,
0, 0, image->pixels->width, image->pixels->height);
+ image->freeCompClip = 1;
+ image->pSourceClip = pixman_region_create ();
+ pixman_region_union_rect (image->pSourceClip, image->pSourceClip,
+ 0, 0, image->pixels->width, image->pixels->height);
+ image->freeSourceClip = 1;
+
image->transform = NULL;
image->filter = PIXMAN_FILTER_NEAREST;
@@ -247,6 +258,11 @@ pixman_image_destroy (pixman_image_t *image)
pixman_region_destroy (image->pCompositeClip);
image->pCompositeClip = NULL;
}
+
+ if (image->freeSourceClip) {
+ pixman_region_destroy (image->pSourceClip);
+ image->pSourceClip = NULL;
+ }
if (image->owns_pixels) {
IcPixelsDestroy (image->pixels);
@@ -281,7 +297,7 @@ pixman_image_destroyClip (pixman_image_t *image)
int
pixman_image_set_clip_region (pixman_image_t *image,
- pixman_region16_t *region)
+ pixman_region16_t *region)
{
pixman_image_destroyClip (image);
if (region) {
@@ -290,9 +306,12 @@ pixman_image_set_clip_region (pixman_image_t *image,
image->clientClipType = CT_REGION;
}
+ if (image->freeCompClip)
+ pixman_region_destroy (image->pCompositeClip);
image->pCompositeClip = pixman_region_create();
pixman_region_union_rect (image->pCompositeClip, image->pCompositeClip,
0, 0, image->pixels->width, image->pixels->height);
+ image->freeCompClip = 1;
if (region) {
pixman_region_translate (image->pCompositeClip,
- image->clipOrigin.x,
@@ -358,7 +377,9 @@ IcClipImageSrc (pixman_region16_t *region,
return 1;
if (image->repeat)
{
- if (image->clientClipType != CT_NONE)
+ /* XXX no source clipping */
+ if (image->compositeClipSource &&
+ image->clientClipType != CT_NONE)
{
pixman_region_translate (region,
dx - image->clipOrigin.x,
@@ -372,8 +393,14 @@ IcClipImageSrc (pixman_region16_t *region,
}
else
{
+ pixman_region16_t *clip;
+
+ if (image->compositeClipSource)
+ clip = image->pCompositeClip;
+ else
+ clip = image->pSourceClip;
return IcClipImageReg (region,
- image->pCompositeClip,
+ clip,
dx,
dy);
}
diff --git a/pixman/src/icimage.h b/pixman/src/icimage.h
index becc7b09a..afbff2ca0 100644
--- a/pixman/src/icimage.h
+++ b/pixman/src/icimage.h
@@ -97,11 +97,12 @@ struct pixman_image {
unsigned int subWindowMode : 1;
unsigned int polyEdge : 1;
unsigned int polyMode : 1;
- /* XXX: Do we need this field */
unsigned int freeCompClip : 1;
+ unsigned int freeSourceClip : 1;
unsigned int clientClipType : 2;
unsigned int componentAlpha : 1;
- unsigned int unused : 23;
+ unsigned int compositeClipSource : 1;
+ unsigned int unused : 21;
struct pixman_image *alphaMap;
IcPoint alphaOrigin;
@@ -115,6 +116,7 @@ struct pixman_image {
unsigned long serialNumber;
pixman_region16_t *pCompositeClip;
+ pixman_region16_t *pSourceClip;
pixman_transform_t *transform;
@@ -289,7 +291,8 @@ struct _pixman_compositeOperand {
/* XXX: We're not supporting indexed operations, right?
IcIndexedPtr indexed;
*/
- pixman_region16_t *clip;
+ pixman_region16_t *dst_clip;
+ pixman_region16_t *src_clip;
};
typedef void (*IcCombineFunc) (pixman_compositeOperand *src,