Skip to content

Commit 090bd9c

Browse files
authored
Merge pull request #93 from weihsinyeh/pixman
Fix the wrong range of pixel map for pixman
2 parents 57a8f78 + 3c2b66e commit 090bd9c

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/draw-pixman.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,38 @@ void twin_composite(twin_pixmap_t *_dst,
9090
pixman_image_t *dst = create_pixman_image_from_twin_pixmap(_dst);
9191

9292
/* Set origin */
93-
twin_coord_t ox, oy;
93+
twin_coord_t ox, oy, offset_x = 0, offset_y = 0;
9494
twin_pixmap_get_origin(_dst, &ox, &oy);
9595
ox += dst_x;
9696
oy += dst_y;
9797

98+
if (ox < _dst->clip.left) {
99+
offset_x = _dst->clip.left - ox;
100+
ox = _dst->clip.left;
101+
}
102+
if (oy < _dst->clip.top) {
103+
offset_y = _dst->clip.top - oy;
104+
oy = _dst->clip.top;
105+
}
106+
if (ox + width > _dst->clip.right)
107+
width = _dst->clip.right - ox;
108+
if (oy + height > _dst->clip.bottom)
109+
height = _dst->clip.bottom - oy;
110+
111+
if (width < 0 || height < 0)
112+
return;
113+
98114
if (!_msk) {
99115
pixman_image_composite(twin_to_pixman_op(operator), src, NULL, dst,
100-
src_x, src_y, 0, 0, ox, oy, width, height);
116+
src_x + offset_x, src_y + offset_y, offset_x,
117+
offset_y, ox, oy, width, height);
101118
} else {
102119
pixman_image_t *msk =
103120
create_pixman_image_from_twin_pixmap(_msk->u.pixmap);
104121
pixman_image_composite(twin_to_pixman_op(operator), src, msk, dst,
105-
src_x, src_y, msk_x, msk_y, ox, oy, width,
106-
height);
122+
src_x + offset_x, src_y + offset_y,
123+
msk_x + offset_x, msk_y + offset_y, ox, oy,
124+
width, height);
107125
pixman_image_unref(msk);
108126
}
109127

@@ -134,6 +152,8 @@ void twin_fill(twin_pixmap_t *_dst,
134152
top = _dst->clip.top;
135153
if (bottom > _dst->clip.bottom)
136154
bottom = _dst->clip.bottom;
155+
if (left >= right || top >= bottom)
156+
return;
137157

138158
pixman_image_t *dst = create_pixman_image_from_twin_pixmap(_dst);
139159
pixman_color_t color;

0 commit comments

Comments
 (0)