1 /* cairo - a vector graphics library with display and print output
3 * Copyright © 2005 Red Hat, Inc
5 * This library is free software; you can redistribute it and/or
6 * modify it either under the terms of the GNU Lesser General Public
7 * License version 2.1 as published by the Free Software Foundation
8 * (the "LGPL") or, at your option, under the terms of the Mozilla
9 * Public License Version 1.1 (the "MPL"). If you do not alter this
10 * notice, a recipient may use your version of this file under either
11 * the MPL or the LGPL.
13 * You should have received a copy of the LGPL along with this library
14 * in the file COPYING-LGPL-2.1; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
16 * You should have received a copy of the MPL along with this library
17 * in the file COPYING-MPL-1.1
19 * The contents of this file are subject to the Mozilla Public License
20 * Version 1.1 (the "License"); you may not use this file except in
21 * compliance with the License. You may obtain a copy of the License at
22 * http://www.mozilla.org/MPL/
24 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
25 * OF ANY KIND, either express or implied. See the LGPL or the MPL for
26 * the specific language governing rights and limitations.
28 * The Original Code is the cairo graphics library.
30 * The Initial Developer of the Original Code is Red Hat, Inc.
33 * Owen Taylor <otaylor@redhat.com>
36 #ifndef CAIRO_WIN32_PRIVATE_H
37 #define CAIRO_WIN32_PRIVATE_H
39 #include "cairo-win32.h"
43 #include "cairo-device-private.h"
44 #include "cairo-surface-clipper-private.h"
45 #include "cairo-surface-private.h"
47 #ifndef SHADEBLENDCAPS
48 #define SHADEBLENDCAPS 120
54 #define WIN32_FONT_LOGICAL_SCALE 32
56 /* Surface DC flag values */
58 /* If this is a surface created for printing or not */
59 CAIRO_WIN32_SURFACE_FOR_PRINTING = (1<<0),
61 /* Whether the DC is a display DC or not */
62 CAIRO_WIN32_SURFACE_IS_DISPLAY = (1<<1),
64 /* Whether we can use BitBlt with this surface */
65 CAIRO_WIN32_SURFACE_CAN_BITBLT = (1<<2),
67 /* Whether we can use AlphaBlend with this surface */
68 CAIRO_WIN32_SURFACE_CAN_ALPHABLEND = (1<<3),
70 /* Whether we can use StretchBlt with this surface */
71 CAIRO_WIN32_SURFACE_CAN_STRETCHBLT = (1<<4),
73 /* Whether we can use StretchDIBits with this surface */
74 CAIRO_WIN32_SURFACE_CAN_STRETCHDIB = (1<<5),
76 /* Whether we can use GradientFill rectangles with this surface */
77 CAIRO_WIN32_SURFACE_CAN_RECT_GRADIENT = (1<<6),
79 /* Whether we can use the CHECKJPEGFORMAT escape function */
80 CAIRO_WIN32_SURFACE_CAN_CHECK_JPEG = (1<<7),
82 /* Whether we can use the CHECKJPEGFORMAT escape function */
83 CAIRO_WIN32_SURFACE_CAN_CHECK_PNG = (1<<8),
86 typedef struct _cairo_win32_surface {
89 cairo_format_t format;
92 /* Surface DC flags */
95 /* We use the x and y parts of extents for situations where
96 * we're not supposed to draw to the entire surface.
97 * For example, during a paint event a program will get
98 * a DC that has been clipped to the dirty region.
99 * A cairo surface constructed for that DC will have extents
100 * that match bounds of the clipped region.
102 cairo_rectangle_int_t extents;
103 } cairo_win32_surface_t;
104 #define to_win32_surface(S) ((cairo_win32_surface_t *)(S))
106 typedef struct _cairo_win32_display_surface {
107 cairo_win32_surface_t win32;
109 /* We create off-screen surfaces as DIBs or DDBs, based on what we created
114 /* Used to save the initial 1x1 monochrome bitmap for the DC to
115 * select back into the DC before deleting the DC and our
116 * bitmap. For Windows XP, this doesn't seem to be necessary
117 * ... we can just delete the DC and that automatically unselects
118 * out bitmap. But it's standard practice so apparently is needed
119 * on some versions of Windows.
121 HBITMAP saved_dc_bitmap;
122 cairo_surface_t *image;
123 cairo_surface_t *fallback;
125 HRGN initial_clip_rgn;
126 cairo_bool_t had_simple_clip;
127 } cairo_win32_display_surface_t;
128 #define to_win32_display_surface(S) ((cairo_win32_display_surface_t *)(S))
130 typedef struct _cairo_win32_printing_surface {
131 cairo_win32_surface_t win32;
133 cairo_surface_clipper_t clipper;
135 cairo_paginated_mode_t paginated_mode;
136 cairo_content_t content;
137 cairo_bool_t path_empty;
138 cairo_bool_t has_ctm;
140 cairo_bool_t has_gdi_ctm;
141 cairo_matrix_t gdi_ctm;
142 HBRUSH brush, old_brush;
143 cairo_scaled_font_subsets_t *font_subsets;
144 } cairo_win32_printing_surface_t;
145 #define to_win32_printing_surface(S) ((cairo_win32_printing_surface_t *)(S))
147 typedef BOOL (WINAPI *cairo_win32_alpha_blend_func_t) (HDC hdcDest,
157 BLENDFUNCTION blendFunction);
159 typedef struct _cairo_win32_device {
164 const cairo_compositor_t *compositor;
166 cairo_win32_alpha_blend_func_t alpha_blend;
167 } cairo_win32_device_t;
168 #define to_win32_device(D) ((cairo_win32_device_t *)(D))
169 #define to_win32_device_from_surface(S) to_win32_device(((cairo_surface_t *)(S))->device)
171 cairo_private cairo_device_t *
172 _cairo_win32_device_get (void);
174 const cairo_compositor_t *
175 _cairo_win32_gdi_compositor_get (void);
178 _cairo_win32_print_gdi_error (const char *context);
181 _cairo_win32_display_surface_discard_fallback (cairo_win32_display_surface_t *surface);
184 _cairo_win32_surface_get_extents (void *abstract_surface,
185 cairo_rectangle_int_t *rectangle);
188 _cairo_win32_flags_for_dc (HDC dc);
191 _cairo_win32_surface_emit_glyphs (cairo_win32_surface_t *dst,
192 const cairo_pattern_t *source,
193 cairo_glyph_t *glyphs,
195 cairo_scaled_font_t *scaled_font,
196 cairo_bool_t glyph_indexing);
199 _cairo_matrix_to_win32_xform (const cairo_matrix_t *m,
202 xform->eM11 = (FLOAT) m->xx;
203 xform->eM21 = (FLOAT) m->xy;
204 xform->eM12 = (FLOAT) m->yx;
205 xform->eM22 = (FLOAT) m->yy;
206 xform->eDx = (FLOAT) m->x0;
207 xform->eDy = (FLOAT) m->y0;
211 _cairo_win32_display_surface_set_clip (cairo_win32_display_surface_t *surface,
215 _cairo_win32_display_surface_unset_clip (cairo_win32_display_surface_t *surface);
218 _cairo_win32_debug_dump_hrgn (HRGN rgn, char *header);
221 _cairo_win32_scaled_font_is_type1 (cairo_scaled_font_t *scaled_font);
224 _cairo_win32_scaled_font_is_bitmap (cairo_scaled_font_t *scaled_font);
226 #endif /* CAIRO_WIN32_PRIVATE_H */