@@ -175,57 +175,27 @@ draw (const cairo_test_context_t *ctx,
175
175
}
176
176
177
177
static cairo_test_status_t
178
- compare (const cairo_test_context_t * ctx , cairo_surface_t * surface )
179
- {
180
- cairo_t * cr ;
181
- cairo_surface_t * image , * reference , * diff ;
182
- cairo_status_t status ;
183
- buffer_diff_result_t result ;
184
-
185
- diff = cairo_image_surface_create (CAIRO_FORMAT_RGB24 , SIZE , SIZE );
186
-
187
- /* copy the pixmap to an image buffer */
188
- image = cairo_image_surface_create (CAIRO_FORMAT_RGB24 , SIZE , SIZE );
189
- cr = cairo_create (image );
190
- cairo_set_source_surface (cr , surface , 0 , 0 );
191
- cairo_paint (cr );
192
- cairo_destroy (cr );
193
- cairo_surface_write_to_png (image , "xlib-expose-event.out.png" );
194
-
195
- reference = cairo_test_create_surface_from_png (ctx , "xlib-expose-event.ref.png" );
196
- status = image_diff (ctx , reference , image , diff , & result );
197
-
198
- cairo_surface_destroy (reference );
199
- cairo_surface_destroy (image );
200
- cairo_surface_destroy (diff );
201
-
202
- return status == CAIRO_STATUS_SUCCESS && ! result .pixels_changed ?
203
- CAIRO_TEST_SUCCESS : CAIRO_TEST_FAILURE ;
204
- }
205
-
206
- static cairo_test_status_t
207
- preamble (cairo_test_context_t * ctx )
178
+ draw_func (cairo_t * cr , int width , int height )
208
179
{
209
180
Display * dpy ;
210
181
Drawable drawable ;
211
182
int screen ;
212
183
cairo_surface_t * surface ;
213
184
cairo_rectangle_t region [4 ];
214
185
int i , j ;
215
- cairo_test_status_t result = CAIRO_TEST_UNTESTED ;
186
+ const cairo_test_context_t * ctx ;
187
+
188
+ ctx = cairo_test_get_context (cr );
189
+ surface = cairo_get_target (cr );
216
190
217
- if (! cairo_test_is_target_enabled ( ctx , "xlib" ) )
218
- goto CLEANUP_TEST ;
191
+ if (cairo_surface_get_type ( surface ) != CAIRO_SURFACE_TYPE_XLIB )
192
+ return CAIRO_TEST_UNTESTED ;
219
193
220
- dpy = XOpenDisplay (NULL );
221
- if (dpy == NULL ) {
222
- cairo_test_log (ctx , "xlib-expose-event: Cannot open display, skipping\n" );
223
- goto CLEANUP_TEST ;
224
- }
194
+ dpy = cairo_xlib_surface_get_display (surface );
225
195
226
196
if (! check_visual (dpy )) {
227
197
cairo_test_log (ctx , "xlib-expose-event: default visual is not RGB24 or BGR24, skipping\n" );
228
- goto CLEANUP_DISPLAY ;
198
+ return CAIRO_TEST_UNTESTED ;
229
199
}
230
200
231
201
screen = DefaultScreen (dpy );
@@ -263,22 +233,19 @@ preamble (cairo_test_context_t *ctx)
263
233
}
264
234
}
265
235
266
- result = compare (ctx , surface );
267
-
236
+ cairo_set_source_surface (cr , surface , 0 , 0 );
268
237
cairo_surface_destroy (surface );
238
+ cairo_set_operator (cr , CAIRO_OPERATOR_SOURCE );
239
+ cairo_paint (cr );
269
240
270
241
XFreePixmap (dpy , drawable );
271
242
272
- CLEANUP_DISPLAY :
273
- XCloseDisplay (dpy );
274
-
275
- CLEANUP_TEST :
276
- return result ;
243
+ return CAIRO_TEST_SUCCESS ;
277
244
}
278
245
279
246
CAIRO_TEST (xlib_expose_event ,
280
247
"Emulate a typical expose event" ,
281
248
"xlib" , /* keywords */
282
249
NULL , /* requirements */
283
- 0 , 0 ,
284
- preamble , NULL )
250
+ SIZE , SIZE ,
251
+ NULL , draw_func )
0 commit comments