@@ -90,20 +90,38 @@ void twin_composite(twin_pixmap_t *_dst,
90
90
pixman_image_t * dst = create_pixman_image_from_twin_pixmap (_dst );
91
91
92
92
/* Set origin */
93
- twin_coord_t ox , oy ;
93
+ twin_coord_t ox , oy , offset_x = 0 , offset_y = 0 ;
94
94
twin_pixmap_get_origin (_dst , & ox , & oy );
95
95
ox += dst_x ;
96
96
oy += dst_y ;
97
97
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
+
98
114
if (!_msk ) {
99
115
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 );
101
118
} else {
102
119
pixman_image_t * msk =
103
120
create_pixman_image_from_twin_pixmap (_msk -> u .pixmap );
104
121
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 );
107
125
pixman_image_unref (msk );
108
126
}
109
127
@@ -134,6 +152,8 @@ void twin_fill(twin_pixmap_t *_dst,
134
152
top = _dst -> clip .top ;
135
153
if (bottom > _dst -> clip .bottom )
136
154
bottom = _dst -> clip .bottom ;
155
+ if (left >= right || top >= bottom )
156
+ return ;
137
157
138
158
pixman_image_t * dst = create_pixman_image_from_twin_pixmap (_dst );
139
159
pixman_color_t color ;
0 commit comments