39db674db706e45ad812ae49fb14775bb0e559e9
[framework/graphics/cairo.git] / src / win32 / cairo-win32-gdi-compositor.c
1 /* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
2 /* cairo - a vector graphics library with display and print output
3  *
4  * Copyright © 2012 Intel Corporation
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it either under the terms of the GNU Lesser General Public
8  * License version 2.1 as published by the Free Software Foundation
9  * (the "LGPL") or, at your option, under the terms of the Mozilla
10  * Public License Version 1.1 (the "MPL"). If you do not alter this
11  * notice, a recipient may use your version of this file under either
12  * the MPL or the LGPL.
13  *
14  * You should have received a copy of the LGPL along with this library
15  * in the file COPYING-LGPL-2.1; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
17  * You should have received a copy of the MPL along with this library
18  * in the file COPYING-MPL-1.1
19  *
20  * The contents of this file are subject to the Mozilla Public License
21  * Version 1.1 (the "License"); you may not use this file except in
22  * compliance with the License. You may obtain a copy of the License at
23  * http://www.mozilla.org/MPL/
24  *
25  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
26  * OF ANY KIND, either express or implied. See the LGPL or the MPL for
27  * the specific language governing rights and limitations.
28  *
29  * The Original Code is the cairo graphics library.
30  *
31  * The Initial Developer of the Original Code is University of Southern
32  * California.
33  *
34  * Contributor(s):
35  *      Carl D. Worth <cworth@cworth.org>
36  *      Behdad Esfahbod <behdad@behdad.org>
37  *      Chris Wilson <chris@chris-wilson.co.uk>
38  *      Karl Tomlinson <karlt+@karlt.net>, Mozilla Corporation
39  */
40
41 /* The original X drawing API was very restrictive in what it could handle,
42  * pixel-aligned fill/blits are all that map into Cairo's drawing model.
43  */
44
45 #include "cairoint.h"
46
47 #include "cairo-win32-private.h"
48
49 #include "cairo-boxes-private.h"
50 #include "cairo-clip-inline.h"
51 #include "cairo-compositor-private.h"
52 #include "cairo-image-surface-private.h"
53 #include "cairo-pattern-private.h"
54 #include "cairo-region-private.h"
55 #include "cairo-surface-inline.h"
56 #include "cairo-surface-offset-private.h"
57
58 #if !defined(AC_SRC_OVER)
59 #define AC_SRC_OVER                 0x00
60 #pragma pack(1)
61 typedef struct {
62     BYTE   BlendOp;
63     BYTE   BlendFlags;
64     BYTE   SourceConstantAlpha;
65     BYTE   AlphaFormat;
66 }BLENDFUNCTION;
67 #pragma pack()
68 #endif
69
70 /* for compatibility with VC++ 6 */
71 #ifndef AC_SRC_ALPHA
72 #define AC_SRC_ALPHA                0x01
73 #endif
74
75 #define PELS_72DPI  ((LONG)(72. / 0.0254))
76
77 /* the low-level interface */
78
79 struct fill_box {
80     HDC dc;
81     HBRUSH brush;
82 };
83
84 static cairo_bool_t fill_box (cairo_box_t *box, void *closure)
85 {
86     struct fill_box *fb = closure;
87     RECT rect;
88
89     rect.left = _cairo_fixed_integer_part (box->p1.x);
90     rect.top = _cairo_fixed_integer_part (box->p1.y);
91     rect.right = _cairo_fixed_integer_part (box->p2.x);
92     rect.bottom = _cairo_fixed_integer_part (box->p2.y);
93
94     TRACE ((stderr, "%s\n", __FUNCTION__));
95     return FillRect (fb->dc, &rect, fb->brush);
96 }
97
98 struct check_box {
99     cairo_rectangle_int_t limit;
100     int tx, ty;
101 };
102
103 struct copy_box {
104     cairo_rectangle_int_t limit;
105     int tx, ty;
106     HDC dst, src;
107     BLENDFUNCTION bf;
108     cairo_win32_alpha_blend_func_t alpha_blend;
109 };
110
111 static cairo_bool_t copy_box (cairo_box_t *box, void *closure)
112 {
113     const struct copy_box *cb = closure;
114     int x = _cairo_fixed_integer_part (box->p1.x);
115     int y = _cairo_fixed_integer_part (box->p1.y);
116     int width  = _cairo_fixed_integer_part (box->p2.x - box->p1.x);
117     int height = _cairo_fixed_integer_part (box->p2.y - box->p1.y);
118
119     TRACE ((stderr, "%s\n", __FUNCTION__));
120     return BitBlt (cb->dst, x, y, width, height,
121                    cb->src, x + cb->tx, y + cb->ty,
122                    SRCCOPY);
123 }
124
125 static cairo_bool_t alpha_box (cairo_box_t *box, void *closure)
126 {
127     const struct copy_box *cb = closure;
128     int x = _cairo_fixed_integer_part (box->p1.x);
129     int y = _cairo_fixed_integer_part (box->p1.y);
130     int width  = _cairo_fixed_integer_part (box->p2.x - box->p1.x);
131     int height = _cairo_fixed_integer_part (box->p2.y - box->p1.y);
132
133     TRACE ((stderr, "%s\n", __FUNCTION__));
134     return cb->alpha_blend (cb->dst, x, y, width, height,
135                             cb->src, x + cb->tx, y + cb->ty, width, height,
136                             cb->bf);
137 }
138
139 struct upload_box {
140     cairo_rectangle_int_t limit;
141     int tx, ty;
142     HDC dst;
143     BITMAPINFO bi;
144     void *data;
145 };
146
147 static cairo_bool_t upload_box (cairo_box_t *box, void *closure)
148 {
149     const struct upload_box *cb = closure;
150     int x = _cairo_fixed_integer_part (box->p1.x);
151     int y = _cairo_fixed_integer_part (box->p1.y);
152     int width  = _cairo_fixed_integer_part (box->p2.x - box->p1.x);
153     int height = _cairo_fixed_integer_part (box->p2.y - box->p1.y);
154
155     TRACE ((stderr, "%s\n", __FUNCTION__));
156     return StretchDIBits (cb->dst, x, y + height - 1, width, -height,
157                           x + cb->tx,  height - (y + cb->ty - 1),
158                           width, -height,
159                           cb->data, &cb->bi,
160                           DIB_RGB_COLORS, SRCCOPY);
161 }
162
163 /* the mid-level: converts boxes into drawing operations */
164
165 static COLORREF color_to_rgb(const cairo_color_t *c)
166 {
167     return RGB (c->red_short >> 8, c->green_short >> 8, c->blue_short >> 8);
168 }
169
170 static cairo_int_status_t
171 fill_boxes (cairo_win32_display_surface_t       *dst,
172             const cairo_pattern_t               *src,
173             cairo_boxes_t                       *boxes)
174 {
175     const cairo_color_t *color = &((cairo_solid_pattern_t *) src)->color;
176     cairo_status_t status = CAIRO_STATUS_SUCCESS;
177     struct fill_box fb;
178
179     TRACE ((stderr, "%s\n", __FUNCTION__));
180
181     fb.dc = dst->win32.dc;
182     fb.brush = CreateSolidBrush (color_to_rgb(color));
183     if (!fb.brush)
184         return _cairo_win32_print_gdi_error (__FUNCTION__);
185
186     if (! _cairo_boxes_for_each_box (boxes, fill_box, &fb))
187         status = CAIRO_INT_STATUS_UNSUPPORTED;
188
189     DeleteObject (fb.brush);
190
191     return status;
192 }
193
194 static cairo_bool_t source_contains_box (cairo_box_t *box, void *closure)
195 {
196     struct check_box *data = closure;
197
198     /* The box is pixel-aligned so the truncation is safe. */
199     return
200         _cairo_fixed_integer_part (box->p1.x) + data->tx >= data->limit.x &&
201         _cairo_fixed_integer_part (box->p1.y) + data->ty >= data->limit.y &&
202         _cairo_fixed_integer_part (box->p2.x) + data->tx <= data->limit.x + data->limit.width &&
203         _cairo_fixed_integer_part (box->p2.y) + data->ty <= data->limit.y + data->limit.height;
204 }
205
206 static cairo_status_t
207 copy_boxes (cairo_win32_display_surface_t *dst,
208             const cairo_pattern_t *source,
209             cairo_boxes_t *boxes)
210 {
211     const cairo_surface_pattern_t *pattern;
212     struct copy_box cb;
213     cairo_surface_t *surface;
214     cairo_status_t status;
215
216     TRACE ((stderr, "%s\n", __FUNCTION__));
217
218     pattern = (const cairo_surface_pattern_t *) source;
219     surface = _cairo_surface_get_source (pattern->surface, &cb.limit);
220     if (surface->type == CAIRO_SURFACE_TYPE_IMAGE) {
221         surface = to_image_surface(surface)->parent;
222         if (surface == NULL)
223             return CAIRO_INT_STATUS_UNSUPPORTED;
224     }
225     if (surface->type != CAIRO_SURFACE_TYPE_WIN32)
226         return CAIRO_INT_STATUS_UNSUPPORTED;
227
228     if (! _cairo_matrix_is_integer_translation (&source->matrix,
229                                                 &cb.tx, &cb.ty))
230         return CAIRO_INT_STATUS_UNSUPPORTED;
231
232     cb.dst = dst->win32.dc;
233     cb.src = to_win32_surface(surface)->dc;
234
235     /* First check that the data is entirely within the image */
236     if (! _cairo_boxes_for_each_box (boxes, source_contains_box, &cb))
237         return CAIRO_INT_STATUS_UNSUPPORTED;
238
239     status = _cairo_surface_flush (surface);
240     if (status)
241         return status;
242
243     cb.tx += cb.limit.x;
244     cb.ty += cb.limit.y;
245     status = CAIRO_STATUS_SUCCESS;
246     if (! _cairo_boxes_for_each_box (boxes, copy_box, &cb))
247         status = CAIRO_INT_STATUS_UNSUPPORTED;
248
249     _cairo_win32_display_surface_discard_fallback (dst);
250     return status;
251 }
252
253 static cairo_status_t
254 upload_boxes (cairo_win32_display_surface_t *dst,
255               const cairo_pattern_t *source,
256               cairo_boxes_t *boxes)
257 {
258     const cairo_surface_pattern_t *pattern;
259     struct upload_box cb;
260     cairo_surface_t *surface;
261     cairo_image_surface_t *image;
262     void *image_extra;
263     cairo_status_t status;
264
265     TRACE ((stderr, "%s\n", __FUNCTION__));
266
267     if ((dst->win32.flags & CAIRO_WIN32_SURFACE_CAN_STRETCHDIB) == 0)
268         return CAIRO_INT_STATUS_UNSUPPORTED;
269
270     if (! _cairo_matrix_is_integer_translation (&source->matrix,
271                                                 &cb.tx, &cb.ty))
272         return CAIRO_INT_STATUS_UNSUPPORTED;
273
274     pattern = (const cairo_surface_pattern_t *) source;
275     surface = _cairo_surface_get_source (pattern->surface, &cb.limit);
276
277     /* First check that the data is entirely within the image */
278     if (! _cairo_boxes_for_each_box (boxes, source_contains_box, &cb))
279         return CAIRO_INT_STATUS_UNSUPPORTED;
280
281     if (surface->type != CAIRO_SURFACE_TYPE_IMAGE) {
282         status = _cairo_surface_acquire_source_image (surface,
283                                                       &image, &image_extra);
284         if (status)
285             return status;
286     } else
287         image = to_image_surface(surface);
288
289     status = CAIRO_INT_STATUS_UNSUPPORTED;
290     if (!(image->format == CAIRO_FORMAT_ARGB32 ||
291           image->format == CAIRO_FORMAT_RGB24))
292         goto err;
293     if (image->stride != 4*image->width)
294         goto err;
295
296     cb.dst = dst->win32.dc;
297     cb.data = image->data;
298
299     cb.bi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
300     cb.bi.bmiHeader.biWidth = image->width;
301     cb.bi.bmiHeader.biHeight = -image->height;
302     cb.bi.bmiHeader.biSizeImage = 0;
303     cb.bi.bmiHeader.biXPelsPerMeter = PELS_72DPI;
304     cb.bi.bmiHeader.biYPelsPerMeter = PELS_72DPI;
305     cb.bi.bmiHeader.biPlanes = 1;
306     cb.bi.bmiHeader.biBitCount = 32;
307     cb.bi.bmiHeader.biCompression = BI_RGB;
308     cb.bi.bmiHeader.biClrUsed = 0;
309     cb.bi.bmiHeader.biClrImportant = 0;
310
311     cb.tx += cb.limit.x;
312     cb.ty += cb.limit.y;
313     status = CAIRO_STATUS_SUCCESS;
314     if (! _cairo_boxes_for_each_box (boxes, upload_box, &cb))
315         status = CAIRO_INT_STATUS_UNSUPPORTED;
316
317     _cairo_win32_display_surface_discard_fallback (dst);
318 err:
319     if (&image->base != surface)
320         _cairo_surface_release_source_image (surface, image, image_extra);
321
322     return status;
323 }
324
325 static cairo_status_t
326 alpha_blend_boxes (cairo_win32_display_surface_t *dst,
327                    const cairo_pattern_t *source,
328                    cairo_boxes_t *boxes,
329                    uint8_t alpha)
330 {
331     const cairo_surface_pattern_t *pattern;
332     struct copy_box cb;
333     cairo_surface_t *surface;
334     cairo_win32_display_surface_t *src;
335     cairo_status_t status;
336
337     TRACE ((stderr, "%s\n", __FUNCTION__));
338     if (source->type != CAIRO_PATTERN_TYPE_SURFACE)
339         return CAIRO_INT_STATUS_UNSUPPORTED;
340
341     pattern = (const cairo_surface_pattern_t *) source;
342     surface = _cairo_surface_get_source (pattern->surface, &cb.limit);
343     if (surface->type == CAIRO_SURFACE_TYPE_IMAGE) {
344         surface = to_image_surface(surface)->parent;
345         if (surface == NULL)
346             return CAIRO_INT_STATUS_UNSUPPORTED;
347     }
348     if (surface->type != CAIRO_SURFACE_TYPE_WIN32)
349         return CAIRO_INT_STATUS_UNSUPPORTED;
350
351     if (! _cairo_matrix_is_integer_translation (&source->matrix,
352                                                 &cb.tx, &cb.ty))
353         return CAIRO_INT_STATUS_UNSUPPORTED;
354
355     src = to_win32_display_surface (surface);
356     cb.dst = dst->win32.dc;
357     cb.src = src->win32.dc;
358
359     /* First check that the data is entirely within the image */
360     if (! _cairo_boxes_for_each_box (boxes, source_contains_box, &cb))
361         return CAIRO_INT_STATUS_UNSUPPORTED;
362
363     status = _cairo_surface_flush (&src->win32.base);
364     if (status)
365         return status;
366
367     cb.bf.BlendOp = AC_SRC_OVER;
368     cb.bf.BlendFlags = 0;
369     cb.bf.SourceConstantAlpha = alpha;
370     cb.bf.AlphaFormat = (src->win32.format == CAIRO_FORMAT_ARGB32) ? AC_SRC_ALPHA : 0;
371     cb.alpha_blend = to_win32_device(dst->win32.base.device)->alpha_blend;
372
373     cb.tx += cb.limit.x;
374     cb.ty += cb.limit.y;
375     status = CAIRO_STATUS_SUCCESS;
376     if (! _cairo_boxes_for_each_box (boxes, alpha_box, &cb))
377         status = CAIRO_INT_STATUS_UNSUPPORTED;
378
379     _cairo_win32_display_surface_discard_fallback (dst);
380     return status;
381 }
382
383 static cairo_bool_t
384 can_alpha_blend (cairo_win32_display_surface_t *dst)
385 {
386     if ((dst->win32.flags & CAIRO_WIN32_SURFACE_CAN_ALPHABLEND) == 0)
387         return FALSE;
388
389     return to_win32_device(dst->win32.base.device)->alpha_blend != NULL;
390 }
391
392 static cairo_status_t
393 draw_boxes (cairo_composite_rectangles_t *composite,
394             cairo_boxes_t *boxes)
395 {
396     cairo_win32_display_surface_t *dst = to_win32_display_surface(composite->surface);
397     cairo_operator_t op = composite->op;
398     const cairo_pattern_t *src = &composite->source_pattern.base;
399     cairo_int_status_t status;
400
401     TRACE ((stderr, "%s\n", __FUNCTION__));
402     if (boxes->num_boxes == 0 && composite->is_bounded)
403         return CAIRO_STATUS_SUCCESS;
404
405     if (!boxes->is_pixel_aligned)
406         return CAIRO_INT_STATUS_UNSUPPORTED;
407
408     if (op == CAIRO_OPERATOR_CLEAR)
409         op = CAIRO_OPERATOR_SOURCE;
410
411     if (op == CAIRO_OPERATOR_OVER &&
412         _cairo_pattern_is_opaque (src, &composite->bounded))
413         op = CAIRO_OPERATOR_SOURCE;
414
415     if (dst->win32.base.is_clear &&
416         (op == CAIRO_OPERATOR_OVER || op == CAIRO_OPERATOR_ADD))
417         op = CAIRO_OPERATOR_SOURCE;
418
419     if (op == CAIRO_OPERATOR_SOURCE) {
420         status = CAIRO_INT_STATUS_UNSUPPORTED;
421         if (src->type == CAIRO_PATTERN_TYPE_SURFACE) {
422             status = copy_boxes (dst, src, boxes);
423             if (status == CAIRO_INT_STATUS_UNSUPPORTED)
424                 status = upload_boxes (dst, src, boxes);
425         } else if (src->type == CAIRO_PATTERN_TYPE_SOLID) {
426             status = fill_boxes (dst, src, boxes);
427         }
428         return status;
429     }
430
431     if (op == CAIRO_OPERATOR_OVER && can_alpha_blend (dst))
432         return alpha_blend_boxes (dst, src, boxes, 255);
433
434     return CAIRO_INT_STATUS_UNSUPPORTED;
435 }
436
437 static cairo_status_t
438 opacity_boxes (cairo_composite_rectangles_t *composite,
439                cairo_boxes_t *boxes)
440 {
441     cairo_win32_display_surface_t *dst = to_win32_display_surface(composite->surface);
442     cairo_operator_t op = composite->op;
443     const cairo_pattern_t *src = &composite->source_pattern.base;
444
445     TRACE ((stderr, "%s\n", __FUNCTION__));
446     if (composite->mask_pattern.base.type != CAIRO_PATTERN_TYPE_SOLID)
447         return CAIRO_INT_STATUS_UNSUPPORTED;
448
449     if (boxes->num_boxes == 0 && composite->is_bounded)
450         return CAIRO_STATUS_SUCCESS;
451
452     if (!boxes->is_pixel_aligned)
453         return CAIRO_INT_STATUS_UNSUPPORTED;
454
455     if (op != CAIRO_OPERATOR_OVER)
456         return CAIRO_INT_STATUS_UNSUPPORTED;
457
458     if (!can_alpha_blend (dst))
459         return CAIRO_INT_STATUS_UNSUPPORTED;
460
461     return alpha_blend_boxes (dst, src, boxes,
462                               composite->mask_pattern.solid.color.alpha_short >> 8);
463 }
464
465 /* high-level compositor interface */
466
467 static cairo_bool_t check_blit (cairo_composite_rectangles_t *composite)
468 {
469     cairo_win32_display_surface_t *dst;
470
471     if (composite->clip->path)
472         return FALSE;
473
474     dst = to_win32_display_surface (composite->surface);
475     if (dst->fallback)
476         return FALSE;
477
478     if (dst->win32.format != CAIRO_FORMAT_RGB24)
479         return FALSE;
480
481     if (dst->win32.flags & CAIRO_WIN32_SURFACE_CAN_BITBLT)
482         return TRUE;
483
484     return dst->image == NULL;
485 }
486
487 static cairo_int_status_t
488 _cairo_win32_gdi_compositor_paint (const cairo_compositor_t     *compositor,
489                                    cairo_composite_rectangles_t *composite)
490 {
491     cairo_int_status_t status = CAIRO_INT_STATUS_UNSUPPORTED;
492
493     if (check_blit (composite)) {
494         cairo_boxes_t boxes;
495
496         TRACE ((stderr, "%s\n", __FUNCTION__));
497         _cairo_clip_steal_boxes (composite->clip, &boxes);
498         status = draw_boxes (composite, &boxes);
499         _cairo_clip_unsteal_boxes (composite->clip, &boxes);
500     }
501
502     return status;
503 }
504
505 static cairo_int_status_t
506 _cairo_win32_gdi_compositor_mask (const cairo_compositor_t      *compositor,
507                                   cairo_composite_rectangles_t *composite)
508 {
509     cairo_int_status_t status = CAIRO_INT_STATUS_UNSUPPORTED;
510
511     if (check_blit (composite)) {
512         cairo_boxes_t boxes;
513
514         TRACE ((stderr, "%s\n", __FUNCTION__));
515         _cairo_clip_steal_boxes (composite->clip, &boxes);
516         status = opacity_boxes (composite, &boxes);
517         _cairo_clip_unsteal_boxes (composite->clip, &boxes);
518     }
519
520     return status;
521 }
522
523 static cairo_int_status_t
524 _cairo_win32_gdi_compositor_stroke (const cairo_compositor_t    *compositor,
525                                     cairo_composite_rectangles_t *composite,
526                                     const cairo_path_fixed_t    *path,
527                                     const cairo_stroke_style_t  *style,
528                                     const cairo_matrix_t        *ctm,
529                                     const cairo_matrix_t        *ctm_inverse,
530                                     double                       tolerance,
531                                     cairo_antialias_t            antialias)
532 {
533     cairo_int_status_t status;
534
535     status = CAIRO_INT_STATUS_UNSUPPORTED;
536     if (check_blit (composite) &&
537         _cairo_path_fixed_stroke_is_rectilinear (path)) {
538         cairo_boxes_t boxes;
539
540         TRACE ((stderr, "%s\n", __FUNCTION__));
541         _cairo_boxes_init_with_clip (&boxes, composite->clip);
542         status = _cairo_path_fixed_stroke_rectilinear_to_boxes (path,
543                                                                 style,
544                                                                 ctm,
545                                                                 antialias,
546                                                                 &boxes);
547         if (likely (status == CAIRO_INT_STATUS_SUCCESS))
548             status = draw_boxes (composite, &boxes);
549         _cairo_boxes_fini (&boxes);
550     }
551
552     return status;
553 }
554
555 static cairo_int_status_t
556 _cairo_win32_gdi_compositor_fill (const cairo_compositor_t      *compositor,
557                                   cairo_composite_rectangles_t  *composite,
558                                   const cairo_path_fixed_t      *path,
559                                   cairo_fill_rule_t              fill_rule,
560                                   double                         tolerance,
561                                   cairo_antialias_t              antialias)
562 {
563     cairo_int_status_t status;
564
565     status = CAIRO_INT_STATUS_UNSUPPORTED;
566     if (check_blit (composite) &&
567         _cairo_path_fixed_fill_is_rectilinear (path)) {
568         cairo_boxes_t boxes;
569
570         TRACE ((stderr, "%s\n", __FUNCTION__));
571         _cairo_boxes_init_with_clip (&boxes, composite->clip);
572         status = _cairo_path_fixed_fill_rectilinear_to_boxes (path,
573                                                               fill_rule,
574                                                               antialias,
575                                                               &boxes);
576         if (likely (status == CAIRO_INT_STATUS_SUCCESS))
577             status = draw_boxes (composite, &boxes);
578         _cairo_boxes_fini (&boxes);
579     }
580
581     return status;
582 }
583
584 static cairo_bool_t check_glyphs (cairo_composite_rectangles_t *composite,
585                                   cairo_scaled_font_t *scaled_font)
586 {
587     if (! _cairo_clip_is_region (composite->clip))
588         return FALSE;
589
590     if (cairo_scaled_font_get_type (scaled_font) != CAIRO_FONT_TYPE_WIN32)
591         return FALSE;
592
593     if (! _cairo_pattern_is_opaque_solid (&composite->source_pattern.base))
594         return FALSE;
595
596     return (composite->op == CAIRO_OPERATOR_CLEAR ||
597             composite->op == CAIRO_OPERATOR_SOURCE ||
598             composite->op == CAIRO_OPERATOR_OVER);
599 }
600
601 static cairo_int_status_t
602 _cairo_win32_gdi_compositor_glyphs (const cairo_compositor_t    *compositor,
603                                     cairo_composite_rectangles_t*composite,
604                                     cairo_scaled_font_t         *scaled_font,
605                                     cairo_glyph_t               *glyphs,
606                                     int                          num_glyphs,
607                                     cairo_bool_t                 overlap)
608 {
609     cairo_int_status_t status;
610
611     status = CAIRO_INT_STATUS_UNSUPPORTED;
612     if (check_blit (composite) && check_glyphs (composite, scaled_font)) {
613         cairo_win32_display_surface_t *dst = to_win32_display_surface (composite->surface);
614
615         TRACE ((stderr, "%s\n", __FUNCTION__));
616         status = _cairo_win32_display_surface_set_clip(dst, composite->clip);
617         if (status)
618             return status;
619
620         status = _cairo_win32_surface_emit_glyphs (&dst->win32,
621                                                    &composite->source_pattern.base,
622                                                    glyphs,
623                                                    num_glyphs,
624                                                    scaled_font,
625                                                    TRUE);
626
627         _cairo_win32_display_surface_unset_clip (dst);
628     }
629
630     return status;
631 }
632
633 const cairo_compositor_t *
634 _cairo_win32_gdi_compositor_get (void)
635 {
636     static cairo_compositor_t compositor;
637
638     if (compositor.delegate == NULL) {
639         compositor.delegate = &_cairo_fallback_compositor;
640
641         compositor.paint  = _cairo_win32_gdi_compositor_paint;
642         compositor.mask   = _cairo_win32_gdi_compositor_mask;
643         compositor.fill   = _cairo_win32_gdi_compositor_fill;
644         compositor.stroke = _cairo_win32_gdi_compositor_stroke;
645         compositor.glyphs = _cairo_win32_gdi_compositor_glyphs;
646     }
647
648     return &compositor;
649 }