Upload Tizen2.0 source
[framework/graphics/cairo.git] / src / cairo-win32-private.h
1 /* cairo - a vector graphics library with display and print output
2  *
3  * Copyright © 2005 Red Hat, Inc
4  *
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.
12  *
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
18  *
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/
23  *
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.
27  *
28  * The Original Code is the cairo graphics library.
29  *
30  * The Initial Developer of the Original Code is Red Hat, Inc.
31  *
32  * Contributor(s):
33  *      Owen Taylor <otaylor@redhat.com>
34  */
35
36 #ifndef CAIRO_WIN32_PRIVATE_H
37 #define CAIRO_WIN32_PRIVATE_H
38
39 #include "cairo-win32.h"
40 #include "cairoint.h"
41 #include "cairo-surface-clipper-private.h"
42
43 #ifndef SHADEBLENDCAPS
44 #define SHADEBLENDCAPS 120
45 #endif
46 #ifndef SB_NONE
47 #define SB_NONE 0
48 #endif
49
50 #define WIN32_FONT_LOGICAL_SCALE 32
51
52 typedef struct _cairo_win32_surface {
53     cairo_surface_t base;
54
55     cairo_format_t format;
56
57     HDC dc;
58
59     /* We create off-screen surfaces as DIBs or DDBs, based on what we created
60      * originally*/
61     HBITMAP bitmap;
62     cairo_bool_t is_dib;
63
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.
70      */
71     HBITMAP saved_dc_bitmap;
72
73     cairo_surface_t *image;
74
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.
81      *
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;
85
86     /* Initial clip bits
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.
90      */
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;
95
96     /* For path clipping to the printing-surface */
97     cairo_surface_clipper_t clipper;
98
99     /* Surface DC flags */
100     uint32_t flags;
101
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;
107     cairo_matrix_t 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;
113
114 /* Surface DC flag values */
115 enum {
116     /* If this is a surface created for printing or not */
117     CAIRO_WIN32_SURFACE_FOR_PRINTING = (1<<0),
118
119     /* Whether the DC is a display DC or not */
120     CAIRO_WIN32_SURFACE_IS_DISPLAY = (1<<1),
121
122     /* Whether we can use BitBlt with this surface */
123     CAIRO_WIN32_SURFACE_CAN_BITBLT = (1<<2),
124
125     /* Whether we can use AlphaBlend with this surface */
126     CAIRO_WIN32_SURFACE_CAN_ALPHABLEND = (1<<3),
127
128     /* Whether we can use StretchBlt with this surface */
129     CAIRO_WIN32_SURFACE_CAN_STRETCHBLT = (1<<4),
130
131     /* Whether we can use StretchDIBits with this surface */
132     CAIRO_WIN32_SURFACE_CAN_STRETCHDIB = (1<<5),
133
134     /* Whether we can use GradientFill rectangles with this surface */
135     CAIRO_WIN32_SURFACE_CAN_RECT_GRADIENT = (1<<6),
136
137     /* Whether we can use the CHECKJPEGFORMAT escape function */
138     CAIRO_WIN32_SURFACE_CAN_CHECK_JPEG = (1<<7),
139
140     /* Whether we can use the CHECKJPEGFORMAT escape function */
141     CAIRO_WIN32_SURFACE_CAN_CHECK_PNG = (1<<8),
142 };
143
144 cairo_status_t
145 _cairo_win32_print_gdi_error (const char *context);
146
147 cairo_bool_t
148 _cairo_surface_is_win32 (cairo_surface_t *surface);
149
150 cairo_bool_t
151 _cairo_surface_is_win32_printing (cairo_surface_t *surface);
152
153 cairo_status_t
154 _cairo_win32_surface_finish (void *abstract_surface);
155
156 cairo_bool_t
157 _cairo_win32_surface_get_extents (void                    *abstract_surface,
158                                   cairo_rectangle_int_t   *rectangle);
159
160 uint32_t
161 _cairo_win32_flags_for_dc (HDC dc);
162
163 cairo_status_t
164 _cairo_win32_surface_set_clip_region (void           *abstract_surface,
165                                       cairo_region_t *region);
166
167 cairo_int_status_t
168 _cairo_win32_surface_show_glyphs_internal (void                  *surface,
169                                            cairo_operator_t       op,
170                                            const cairo_pattern_t *source,
171                                            cairo_glyph_t         *glyphs,
172                                            int                    num_glyphs,
173                                            cairo_scaled_font_t   *scaled_font,
174                                            const cairo_clip_t    *clip,
175                                            cairo_bool_t           glyph_indices);
176
177 cairo_int_status_t
178 _cairo_win32_surface_show_glyphs (void                  *surface,
179                                   cairo_operator_t       op,
180                                   const cairo_pattern_t *source,
181                                   cairo_glyph_t         *glyphs,
182                                   int                    num_glyphs,
183                                   cairo_scaled_font_t   *scaled_font,
184                                   const cairo_clip_t    *clip);
185
186 cairo_surface_t *
187 _cairo_win32_surface_create_similar (void           *abstract_src,
188                                      cairo_content_t content,
189                                      int             width,
190                                      int             height);
191
192 static inline void
193 _cairo_matrix_to_win32_xform (const cairo_matrix_t *m,
194                               XFORM *xform)
195 {
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;
202 }
203
204 cairo_int_status_t
205 _cairo_win32_save_initial_clip (HDC dc, cairo_win32_surface_t *surface);
206
207 cairo_int_status_t
208 _cairo_win32_restore_initial_clip (cairo_win32_surface_t *surface);
209
210 void
211 _cairo_win32_debug_dump_hrgn (HRGN rgn, char *header);
212
213 cairo_bool_t
214 _cairo_win32_scaled_font_is_type1 (cairo_scaled_font_t *scaled_font);
215
216 cairo_bool_t
217 _cairo_win32_scaled_font_is_bitmap (cairo_scaled_font_t *scaled_font);
218
219 #endif /* CAIRO_WIN32_PRIVATE_H */