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"
41 #include "cairo-surface-clipper-private.h"
43 #ifndef SHADEBLENDCAPS
44 #define SHADEBLENDCAPS 120
50 #define WIN32_FONT_LOGICAL_SCALE 32
52 typedef struct _cairo_win32_surface {
55 cairo_format_t format;
59 /* We create off-screen surfaces as DIBs or DDBs, based on what we created
64 /* Used to save the initial 1x1 monochrome bitmap for the DC to
65 * select back into the DC before deleting the DC and our
66 * bitmap. For Windows XP, this doesn't seem to be necessary
67 * ... we can just delete the DC and that automatically unselects
68 * out bitmap. But it's standard practice so apparently is needed
69 * on some versions of Windows.
71 HBITMAP saved_dc_bitmap;
73 cairo_surface_t *image;
75 /* We use the x and y parts of extents for situations where
76 * we're not supposed to draw to the entire surface.
77 * For example, during a paint event a program will get
78 * a DC that has been clipped to the dirty region.
79 * A cairo surface constructed for that DC will have extents
80 * that match bounds of the clipped region.
82 * jrmuizel: I'm not sure if storing these extents instead
83 * of just using the size is better... */
84 cairo_rectangle_int_t extents;
87 * We need these kept around so that we maintain
88 * whatever clip was set on the original DC at creation
89 * time when cairo is asked to reset the surface clip.
91 cairo_rectangle_int_t clip_rect;
92 HRGN initial_clip_rgn;
93 cairo_bool_t had_simple_clip;
94 cairo_region_t *clip_region;
96 /* For path clipping to the printing-surface */
97 cairo_surface_clipper_t clipper;
99 /* Surface DC flags */
102 /* printing surface bits */
103 cairo_paginated_mode_t paginated_mode;
104 cairo_content_t content;
105 cairo_bool_t path_empty;
106 cairo_bool_t has_ctm;
108 cairo_bool_t has_gdi_ctm;
109 cairo_matrix_t gdi_ctm;
110 HBRUSH brush, old_brush;
111 cairo_scaled_font_subsets_t *font_subsets;
112 } cairo_win32_surface_t;
114 /* Surface DC flag values */
116 /* If this is a surface created for printing or not */
117 CAIRO_WIN32_SURFACE_FOR_PRINTING = (1<<0),
119 /* Whether the DC is a display DC or not */
120 CAIRO_WIN32_SURFACE_IS_DISPLAY = (1<<1),
122 /* Whether we can use BitBlt with this surface */
123 CAIRO_WIN32_SURFACE_CAN_BITBLT = (1<<2),
125 /* Whether we can use AlphaBlend with this surface */
126 CAIRO_WIN32_SURFACE_CAN_ALPHABLEND = (1<<3),
128 /* Whether we can use StretchBlt with this surface */
129 CAIRO_WIN32_SURFACE_CAN_STRETCHBLT = (1<<4),
131 /* Whether we can use StretchDIBits with this surface */
132 CAIRO_WIN32_SURFACE_CAN_STRETCHDIB = (1<<5),
134 /* Whether we can use GradientFill rectangles with this surface */
135 CAIRO_WIN32_SURFACE_CAN_RECT_GRADIENT = (1<<6),
137 /* Whether we can use the CHECKJPEGFORMAT escape function */
138 CAIRO_WIN32_SURFACE_CAN_CHECK_JPEG = (1<<7),
140 /* Whether we can use the CHECKJPEGFORMAT escape function */
141 CAIRO_WIN32_SURFACE_CAN_CHECK_PNG = (1<<8),
145 _cairo_win32_print_gdi_error (const char *context);
148 _cairo_surface_is_win32 (cairo_surface_t *surface);
151 _cairo_surface_is_win32_printing (cairo_surface_t *surface);
154 _cairo_win32_surface_finish (void *abstract_surface);
157 _cairo_win32_surface_get_extents (void *abstract_surface,
158 cairo_rectangle_int_t *rectangle);
161 _cairo_win32_flags_for_dc (HDC dc);
164 _cairo_win32_surface_set_clip_region (void *abstract_surface,
165 cairo_region_t *region);
168 _cairo_win32_surface_show_glyphs_internal (void *surface,
170 const cairo_pattern_t *source,
171 cairo_glyph_t *glyphs,
173 cairo_scaled_font_t *scaled_font,
174 const cairo_clip_t *clip,
175 cairo_bool_t glyph_indices);
178 _cairo_win32_surface_show_glyphs (void *surface,
180 const cairo_pattern_t *source,
181 cairo_glyph_t *glyphs,
183 cairo_scaled_font_t *scaled_font,
184 const cairo_clip_t *clip);
187 _cairo_win32_surface_create_similar (void *abstract_src,
188 cairo_content_t content,
193 _cairo_matrix_to_win32_xform (const cairo_matrix_t *m,
196 xform->eM11 = (FLOAT) m->xx;
197 xform->eM21 = (FLOAT) m->xy;
198 xform->eM12 = (FLOAT) m->yx;
199 xform->eM22 = (FLOAT) m->yy;
200 xform->eDx = (FLOAT) m->x0;
201 xform->eDy = (FLOAT) m->y0;
205 _cairo_win32_save_initial_clip (HDC dc, cairo_win32_surface_t *surface);
208 _cairo_win32_restore_initial_clip (cairo_win32_surface_t *surface);
211 _cairo_win32_debug_dump_hrgn (HRGN rgn, char *header);
214 _cairo_win32_scaled_font_is_type1 (cairo_scaled_font_t *scaled_font);
217 _cairo_win32_scaled_font_is_bitmap (cairo_scaled_font_t *scaled_font);
219 #endif /* CAIRO_WIN32_PRIVATE_H */