Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | commit 4a412c0b144ed1fdde668e0e91241bac8bedd579 |
michael@0 | 2 | Author: Jeff Muizelaar <jmuizelaar@mozilla.com> |
michael@0 | 3 | Date: Sun Jan 24 14:04:33 2010 -0500 |
michael@0 | 4 | |
michael@0 | 5 | d2d |
michael@0 | 6 | |
michael@0 | 7 | diff --git a/src/cairo-fixed-private.h b/src/cairo-fixed-private.h |
michael@0 | 8 | index c299def..a37ca6a 100644 |
michael@0 | 9 | --- a/src/cairo-fixed-private.h |
michael@0 | 10 | +++ b/src/cairo-fixed-private.h |
michael@0 | 11 | @@ -50,6 +50,7 @@ |
michael@0 | 12 | |
michael@0 | 13 | #define CAIRO_FIXED_ONE ((cairo_fixed_t)(1 << CAIRO_FIXED_FRAC_BITS)) |
michael@0 | 14 | #define CAIRO_FIXED_ONE_DOUBLE ((double)(1 << CAIRO_FIXED_FRAC_BITS)) |
michael@0 | 15 | +#define CAIRO_FIXED_ONE_FLOAT ((float)(1 << CAIRO_FIXED_FRAC_BITS)) |
michael@0 | 16 | #define CAIRO_FIXED_EPSILON ((cairo_fixed_t)(1)) |
michael@0 | 17 | |
michael@0 | 18 | #define CAIRO_FIXED_FRAC_MASK (((cairo_fixed_unsigned_t)(-1)) >> (CAIRO_FIXED_BITS - CAIRO_FIXED_FRAC_BITS)) |
michael@0 | 19 | @@ -141,6 +142,12 @@ _cairo_fixed_to_double (cairo_fixed_t f) |
michael@0 | 20 | return ((double) f) / CAIRO_FIXED_ONE_DOUBLE; |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | +static inline float |
michael@0 | 24 | +_cairo_fixed_to_float (cairo_fixed_t f) |
michael@0 | 25 | +{ |
michael@0 | 26 | + return ((float) f) / CAIRO_FIXED_ONE_FLOAT; |
michael@0 | 27 | +} |
michael@0 | 28 | + |
michael@0 | 29 | static inline int |
michael@0 | 30 | _cairo_fixed_is_integer (cairo_fixed_t f) |
michael@0 | 31 | { |
michael@0 | 32 | diff --git a/src/cairo-win32-private.h b/src/cairo-win32-private.h |
michael@0 | 33 | index b9926bb..ba57595 100644 |
michael@0 | 34 | --- a/src/cairo-win32-private.h |
michael@0 | 35 | +++ b/src/cairo-win32-private.h |
michael@0 | 36 | @@ -231,4 +231,19 @@ inline BOOL ModifyWorldTransform(HDC hdc, CONST XFORM * lpxf, DWORD mode) { retu |
michael@0 | 37 | |
michael@0 | 38 | #endif |
michael@0 | 39 | |
michael@0 | 40 | +#ifdef CAIRO_HAS_DWRITE_FONT |
michael@0 | 41 | +CAIRO_BEGIN_DECLS |
michael@0 | 42 | + |
michael@0 | 43 | +cairo_public cairo_int_status_t |
michael@0 | 44 | +cairo_dwrite_show_glyphs_on_surface(void *surface, |
michael@0 | 45 | + cairo_operator_t op, |
michael@0 | 46 | + const cairo_pattern_t *source, |
michael@0 | 47 | + cairo_glyph_t *glyphs, |
michael@0 | 48 | + int num_glyphs, |
michael@0 | 49 | + cairo_scaled_font_t *scaled_font, |
michael@0 | 50 | + cairo_rectangle_int_t *extents); |
michael@0 | 51 | + |
michael@0 | 52 | + |
michael@0 | 53 | +CAIRO_END_DECLS |
michael@0 | 54 | +#endif /* CAIRO_HAS_DWRITE_FONT */ |
michael@0 | 55 | #endif /* CAIRO_WIN32_PRIVATE_H */ |
michael@0 | 56 | diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c |
michael@0 | 57 | index 0dc5e76..bee00b1 100644 |
michael@0 | 58 | --- a/src/cairo-win32-surface.c |
michael@0 | 59 | +++ b/src/cairo-win32-surface.c |
michael@0 | 60 | @@ -1547,152 +1547,158 @@ _cairo_win32_surface_show_glyphs (void *surface, |
michael@0 | 61 | int *remaining_glyphs) |
michael@0 | 62 | { |
michael@0 | 63 | #if defined(CAIRO_HAS_WIN32_FONT) && !defined(WINCE) |
michael@0 | 64 | - cairo_win32_surface_t *dst = surface; |
michael@0 | 65 | - |
michael@0 | 66 | - WORD glyph_buf_stack[STACK_GLYPH_SIZE]; |
michael@0 | 67 | - WORD *glyph_buf = glyph_buf_stack; |
michael@0 | 68 | - int dxy_buf_stack[2 * STACK_GLYPH_SIZE]; |
michael@0 | 69 | - int *dxy_buf = dxy_buf_stack; |
michael@0 | 70 | - |
michael@0 | 71 | - BOOL win_result = 0; |
michael@0 | 72 | - int i, j; |
michael@0 | 73 | + if (scaled_font->backend->type == CAIRO_FONT_TYPE_DWRITE) { |
michael@0 | 74 | +#ifdef CAIRO_HAS_DWRITE_FONT |
michael@0 | 75 | + return cairo_dwrite_show_glyphs_on_surface(surface, op, source, glyphs, num_glyphs, scaled_font, clip); |
michael@0 | 76 | +#endif |
michael@0 | 77 | + } else { |
michael@0 | 78 | + cairo_win32_surface_t *dst = surface; |
michael@0 | 79 | + |
michael@0 | 80 | + WORD glyph_buf_stack[STACK_GLYPH_SIZE]; |
michael@0 | 81 | + WORD *glyph_buf = glyph_buf_stack; |
michael@0 | 82 | + int dxy_buf_stack[2 * STACK_GLYPH_SIZE]; |
michael@0 | 83 | + int *dxy_buf = dxy_buf_stack; |
michael@0 | 84 | |
michael@0 | 85 | - cairo_solid_pattern_t *solid_pattern; |
michael@0 | 86 | - COLORREF color; |
michael@0 | 87 | + BOOL win_result = 0; |
michael@0 | 88 | + int i, j; |
michael@0 | 89 | |
michael@0 | 90 | - cairo_matrix_t device_to_logical; |
michael@0 | 91 | + cairo_solid_pattern_t *solid_pattern; |
michael@0 | 92 | + COLORREF color; |
michael@0 | 93 | |
michael@0 | 94 | - int start_x, start_y; |
michael@0 | 95 | - double user_x, user_y; |
michael@0 | 96 | - int logical_x, logical_y; |
michael@0 | 97 | - unsigned int glyph_index_option; |
michael@0 | 98 | + cairo_matrix_t device_to_logical; |
michael@0 | 99 | |
michael@0 | 100 | - /* We can only handle win32 fonts */ |
michael@0 | 101 | - if (cairo_scaled_font_get_type (scaled_font) != CAIRO_FONT_TYPE_WIN32) |
michael@0 | 102 | - return CAIRO_INT_STATUS_UNSUPPORTED; |
michael@0 | 103 | + int start_x, start_y; |
michael@0 | 104 | + double user_x, user_y; |
michael@0 | 105 | + int logical_x, logical_y; |
michael@0 | 106 | + unsigned int glyph_index_option; |
michael@0 | 107 | |
michael@0 | 108 | - /* We can only handle opaque solid color sources */ |
michael@0 | 109 | - if (!_cairo_pattern_is_opaque_solid(source)) |
michael@0 | 110 | - return CAIRO_INT_STATUS_UNSUPPORTED; |
michael@0 | 111 | + /* We can only handle win32 fonts */ |
michael@0 | 112 | + if (cairo_scaled_font_get_type (scaled_font) != CAIRO_FONT_TYPE_WIN32) |
michael@0 | 113 | + return CAIRO_INT_STATUS_UNSUPPORTED; |
michael@0 | 114 | |
michael@0 | 115 | - /* We can only handle operator SOURCE or OVER with the destination |
michael@0 | 116 | - * having no alpha */ |
michael@0 | 117 | - if ((op != CAIRO_OPERATOR_SOURCE && op != CAIRO_OPERATOR_OVER) || |
michael@0 | 118 | - (dst->format != CAIRO_FORMAT_RGB24)) |
michael@0 | 119 | - return CAIRO_INT_STATUS_UNSUPPORTED; |
michael@0 | 120 | + /* We can only handle opaque solid color sources */ |
michael@0 | 121 | + if (!_cairo_pattern_is_opaque_solid(source)) |
michael@0 | 122 | + return CAIRO_INT_STATUS_UNSUPPORTED; |
michael@0 | 123 | |
michael@0 | 124 | - /* If we have a fallback mask clip set on the dst, we have |
michael@0 | 125 | - * to go through the fallback path, but only if we're not |
michael@0 | 126 | - * doing this for printing */ |
michael@0 | 127 | - if (clip != NULL) { |
michael@0 | 128 | - if ((dst->flags & CAIRO_WIN32_SURFACE_FOR_PRINTING) == 0) { |
michael@0 | 129 | - cairo_region_t *clip_region; |
michael@0 | 130 | - cairo_status_t status; |
michael@0 | 131 | + /* We can only handle operator SOURCE or OVER with the destination |
michael@0 | 132 | + * having no alpha */ |
michael@0 | 133 | + if ((op != CAIRO_OPERATOR_SOURCE && op != CAIRO_OPERATOR_OVER) || |
michael@0 | 134 | + (dst->format != CAIRO_FORMAT_RGB24)) |
michael@0 | 135 | + return CAIRO_INT_STATUS_UNSUPPORTED; |
michael@0 | 136 | |
michael@0 | 137 | - status = _cairo_clip_get_region (clip, &clip_region); |
michael@0 | 138 | - assert (status != CAIRO_INT_STATUS_NOTHING_TO_DO); |
michael@0 | 139 | - if (status) |
michael@0 | 140 | - return status; |
michael@0 | 141 | + /* If we have a fallback mask clip set on the dst, we have |
michael@0 | 142 | + * to go through the fallback path, but only if we're not |
michael@0 | 143 | + * doing this for printing */ |
michael@0 | 144 | + if (clip != NULL) { |
michael@0 | 145 | + if ((dst->flags & CAIRO_WIN32_SURFACE_FOR_PRINTING) == 0) { |
michael@0 | 146 | + cairo_region_t *clip_region; |
michael@0 | 147 | + cairo_status_t status; |
michael@0 | 148 | + |
michael@0 | 149 | + status = _cairo_clip_get_region (clip, &clip_region); |
michael@0 | 150 | + assert (status != CAIRO_INT_STATUS_NOTHING_TO_DO); |
michael@0 | 151 | + if (status) |
michael@0 | 152 | + return status; |
michael@0 | 153 | |
michael@0 | 154 | - _cairo_win32_surface_set_clip_region (surface, clip_region); |
michael@0 | 155 | + _cairo_win32_surface_set_clip_region (surface, clip_region); |
michael@0 | 156 | + } |
michael@0 | 157 | } |
michael@0 | 158 | - } |
michael@0 | 159 | |
michael@0 | 160 | - solid_pattern = (cairo_solid_pattern_t *)source; |
michael@0 | 161 | - color = RGB(((int)solid_pattern->color.red_short) >> 8, |
michael@0 | 162 | - ((int)solid_pattern->color.green_short) >> 8, |
michael@0 | 163 | - ((int)solid_pattern->color.blue_short) >> 8); |
michael@0 | 164 | + solid_pattern = (cairo_solid_pattern_t *)source; |
michael@0 | 165 | + color = RGB(((int)solid_pattern->color.red_short) >> 8, |
michael@0 | 166 | + ((int)solid_pattern->color.green_short) >> 8, |
michael@0 | 167 | + ((int)solid_pattern->color.blue_short) >> 8); |
michael@0 | 168 | |
michael@0 | 169 | - cairo_win32_scaled_font_get_device_to_logical(scaled_font, &device_to_logical); |
michael@0 | 170 | + cairo_win32_scaled_font_get_device_to_logical(scaled_font, &device_to_logical); |
michael@0 | 171 | |
michael@0 | 172 | - SaveDC(dst->dc); |
michael@0 | 173 | + SaveDC(dst->dc); |
michael@0 | 174 | |
michael@0 | 175 | - cairo_win32_scaled_font_select_font(scaled_font, dst->dc); |
michael@0 | 176 | - SetTextColor(dst->dc, color); |
michael@0 | 177 | - SetTextAlign(dst->dc, TA_BASELINE | TA_LEFT); |
michael@0 | 178 | - SetBkMode(dst->dc, TRANSPARENT); |
michael@0 | 179 | + cairo_win32_scaled_font_select_font(scaled_font, dst->dc); |
michael@0 | 180 | + SetTextColor(dst->dc, color); |
michael@0 | 181 | + SetTextAlign(dst->dc, TA_BASELINE | TA_LEFT); |
michael@0 | 182 | + SetBkMode(dst->dc, TRANSPARENT); |
michael@0 | 183 | |
michael@0 | 184 | - if (num_glyphs > STACK_GLYPH_SIZE) { |
michael@0 | 185 | - glyph_buf = (WORD *) _cairo_malloc_ab (num_glyphs, sizeof(WORD)); |
michael@0 | 186 | - dxy_buf = (int *) _cairo_malloc_abc (num_glyphs, sizeof(int), 2); |
michael@0 | 187 | - } |
michael@0 | 188 | + if (num_glyphs > STACK_GLYPH_SIZE) { |
michael@0 | 189 | + glyph_buf = (WORD *) _cairo_malloc_ab (num_glyphs, sizeof(WORD)); |
michael@0 | 190 | + dxy_buf = (int *) _cairo_malloc_abc (num_glyphs, sizeof(int), 2); |
michael@0 | 191 | + } |
michael@0 | 192 | |
michael@0 | 193 | - /* It is vital that dx values for dxy_buf are calculated from the delta of |
michael@0 | 194 | - * _logical_ x coordinates (not user x coordinates) or else the sum of all |
michael@0 | 195 | - * previous dx values may start to diverge from the current glyph's x |
michael@0 | 196 | - * coordinate due to accumulated rounding error. As a result strings could |
michael@0 | 197 | - * be painted shorter or longer than expected. */ |
michael@0 | 198 | + /* It is vital that dx values for dxy_buf are calculated from the delta of |
michael@0 | 199 | + * _logical_ x coordinates (not user x coordinates) or else the sum of all |
michael@0 | 200 | + * previous dx values may start to diverge from the current glyph's x |
michael@0 | 201 | + * coordinate due to accumulated rounding error. As a result strings could |
michael@0 | 202 | + * be painted shorter or longer than expected. */ |
michael@0 | 203 | |
michael@0 | 204 | - user_x = glyphs[0].x; |
michael@0 | 205 | - user_y = glyphs[0].y; |
michael@0 | 206 | + user_x = glyphs[0].x; |
michael@0 | 207 | + user_y = glyphs[0].y; |
michael@0 | 208 | |
michael@0 | 209 | - cairo_matrix_transform_point(&device_to_logical, |
michael@0 | 210 | - &user_x, &user_y); |
michael@0 | 211 | + cairo_matrix_transform_point(&device_to_logical, |
michael@0 | 212 | + &user_x, &user_y); |
michael@0 | 213 | |
michael@0 | 214 | - logical_x = _cairo_lround (user_x); |
michael@0 | 215 | - logical_y = _cairo_lround (user_y); |
michael@0 | 216 | + logical_x = _cairo_lround (user_x); |
michael@0 | 217 | + logical_y = _cairo_lround (user_y); |
michael@0 | 218 | |
michael@0 | 219 | - start_x = logical_x; |
michael@0 | 220 | - start_y = logical_y; |
michael@0 | 221 | + start_x = logical_x; |
michael@0 | 222 | + start_y = logical_y; |
michael@0 | 223 | |
michael@0 | 224 | - for (i = 0, j = 0; i < num_glyphs; ++i, j = 2 * i) { |
michael@0 | 225 | - glyph_buf[i] = (WORD) glyphs[i].index; |
michael@0 | 226 | - if (i == num_glyphs - 1) { |
michael@0 | 227 | - dxy_buf[j] = 0; |
michael@0 | 228 | - dxy_buf[j+1] = 0; |
michael@0 | 229 | - } else { |
michael@0 | 230 | - double next_user_x = glyphs[i+1].x; |
michael@0 | 231 | - double next_user_y = glyphs[i+1].y; |
michael@0 | 232 | - int next_logical_x, next_logical_y; |
michael@0 | 233 | + for (i = 0, j = 0; i < num_glyphs; ++i, j = 2 * i) { |
michael@0 | 234 | + glyph_buf[i] = (WORD) glyphs[i].index; |
michael@0 | 235 | + if (i == num_glyphs - 1) { |
michael@0 | 236 | + dxy_buf[j] = 0; |
michael@0 | 237 | + dxy_buf[j+1] = 0; |
michael@0 | 238 | + } else { |
michael@0 | 239 | + double next_user_x = glyphs[i+1].x; |
michael@0 | 240 | + double next_user_y = glyphs[i+1].y; |
michael@0 | 241 | + int next_logical_x, next_logical_y; |
michael@0 | 242 | |
michael@0 | 243 | - cairo_matrix_transform_point(&device_to_logical, |
michael@0 | 244 | - &next_user_x, &next_user_y); |
michael@0 | 245 | + cairo_matrix_transform_point(&device_to_logical, |
michael@0 | 246 | + &next_user_x, &next_user_y); |
michael@0 | 247 | |
michael@0 | 248 | - next_logical_x = _cairo_lround (next_user_x); |
michael@0 | 249 | - next_logical_y = _cairo_lround (next_user_y); |
michael@0 | 250 | + next_logical_x = _cairo_lround (next_user_x); |
michael@0 | 251 | + next_logical_y = _cairo_lround (next_user_y); |
michael@0 | 252 | |
michael@0 | 253 | - dxy_buf[j] = _cairo_lround (next_logical_x - logical_x); |
michael@0 | 254 | - dxy_buf[j+1] = _cairo_lround (logical_y - next_logical_y); |
michael@0 | 255 | - /* note that GDI coordinate system is inverted */ |
michael@0 | 256 | + dxy_buf[j] = _cairo_lround (next_logical_x - logical_x); |
michael@0 | 257 | + dxy_buf[j+1] = _cairo_lround (logical_y - next_logical_y); |
michael@0 | 258 | + /* note that GDI coordinate system is inverted */ |
michael@0 | 259 | |
michael@0 | 260 | - logical_x = next_logical_x; |
michael@0 | 261 | - logical_y = next_logical_y; |
michael@0 | 262 | - } |
michael@0 | 263 | - } |
michael@0 | 264 | + logical_x = next_logical_x; |
michael@0 | 265 | + logical_y = next_logical_y; |
michael@0 | 266 | + } |
michael@0 | 267 | + } |
michael@0 | 268 | |
michael@0 | 269 | - /* Using glyph indices for a Type 1 font does not work on a |
michael@0 | 270 | - * printer DC. The win32 printing surface will convert the the |
michael@0 | 271 | - * glyph indices of Type 1 fonts to the unicode values. |
michael@0 | 272 | - */ |
michael@0 | 273 | - if ((dst->flags & CAIRO_WIN32_SURFACE_FOR_PRINTING) && |
michael@0 | 274 | - _cairo_win32_scaled_font_is_type1 (scaled_font)) |
michael@0 | 275 | - { |
michael@0 | 276 | - glyph_index_option = 0; |
michael@0 | 277 | - } |
michael@0 | 278 | - else |
michael@0 | 279 | - { |
michael@0 | 280 | - glyph_index_option = ETO_GLYPH_INDEX; |
michael@0 | 281 | - } |
michael@0 | 282 | + /* Using glyph indices for a Type 1 font does not work on a |
michael@0 | 283 | + * printer DC. The win32 printing surface will convert the the |
michael@0 | 284 | + * glyph indices of Type 1 fonts to the unicode values. |
michael@0 | 285 | + */ |
michael@0 | 286 | + if ((dst->flags & CAIRO_WIN32_SURFACE_FOR_PRINTING) && |
michael@0 | 287 | + _cairo_win32_scaled_font_is_type1 (scaled_font)) |
michael@0 | 288 | + { |
michael@0 | 289 | + glyph_index_option = 0; |
michael@0 | 290 | + } |
michael@0 | 291 | + else |
michael@0 | 292 | + { |
michael@0 | 293 | + glyph_index_option = ETO_GLYPH_INDEX; |
michael@0 | 294 | + } |
michael@0 | 295 | |
michael@0 | 296 | - win_result = ExtTextOutW(dst->dc, |
michael@0 | 297 | - start_x, |
michael@0 | 298 | - start_y, |
michael@0 | 299 | - glyph_index_option | ETO_PDY, |
michael@0 | 300 | - NULL, |
michael@0 | 301 | - glyph_buf, |
michael@0 | 302 | - num_glyphs, |
michael@0 | 303 | - dxy_buf); |
michael@0 | 304 | - if (!win_result) { |
michael@0 | 305 | - _cairo_win32_print_gdi_error("_cairo_win32_surface_show_glyphs(ExtTextOutW failed)"); |
michael@0 | 306 | - } |
michael@0 | 307 | + win_result = ExtTextOutW(dst->dc, |
michael@0 | 308 | + start_x, |
michael@0 | 309 | + start_y, |
michael@0 | 310 | + glyph_index_option | ETO_PDY, |
michael@0 | 311 | + NULL, |
michael@0 | 312 | + glyph_buf, |
michael@0 | 313 | + num_glyphs, |
michael@0 | 314 | + dxy_buf); |
michael@0 | 315 | + if (!win_result) { |
michael@0 | 316 | + _cairo_win32_print_gdi_error("_cairo_win32_surface_show_glyphs(ExtTextOutW failed)"); |
michael@0 | 317 | + } |
michael@0 | 318 | |
michael@0 | 319 | - RestoreDC(dst->dc, -1); |
michael@0 | 320 | + RestoreDC(dst->dc, -1); |
michael@0 | 321 | |
michael@0 | 322 | - if (glyph_buf != glyph_buf_stack) { |
michael@0 | 323 | - free(glyph_buf); |
michael@0 | 324 | - free(dxy_buf); |
michael@0 | 325 | + if (glyph_buf != glyph_buf_stack) { |
michael@0 | 326 | + free(glyph_buf); |
michael@0 | 327 | + free(dxy_buf); |
michael@0 | 328 | + } |
michael@0 | 329 | + return (win_result) ? CAIRO_STATUS_SUCCESS : CAIRO_INT_STATUS_UNSUPPORTED; |
michael@0 | 330 | } |
michael@0 | 331 | - return (win_result) ? CAIRO_STATUS_SUCCESS : CAIRO_INT_STATUS_UNSUPPORTED; |
michael@0 | 332 | #else |
michael@0 | 333 | return CAIRO_INT_STATUS_UNSUPPORTED; |
michael@0 | 334 | #endif |
michael@0 | 335 | diff --git a/src/cairo-win32.h b/src/cairo-win32.h |
michael@0 | 336 | index 6b86d4e..fcf20b8 100644 |
michael@0 | 337 | --- a/src/cairo-win32.h |
michael@0 | 338 | +++ b/src/cairo-win32.h |
michael@0 | 339 | @@ -109,6 +109,63 @@ cairo_win32_scaled_font_get_device_to_logical (cairo_scaled_font_t *scaled_font, |
michael@0 | 340 | |
michael@0 | 341 | #endif /* CAIRO_HAS_WIN32_FONT */ |
michael@0 | 342 | |
michael@0 | 343 | +#if CAIRO_HAS_DWRITE_FONT |
michael@0 | 344 | + |
michael@0 | 345 | +/* |
michael@0 | 346 | + * Win32 DirectWrite font support |
michael@0 | 347 | + */ |
michael@0 | 348 | +cairo_public cairo_font_face_t * |
michael@0 | 349 | +cairo_dwrite_font_face_create_for_dwrite_fontface(void *dwrite_font, void *dwrite_font_face); |
michael@0 | 350 | + |
michael@0 | 351 | +#endif /* CAIRO_HAS_DWRITE_FONT */ |
michael@0 | 352 | + |
michael@0 | 353 | +#if CAIRO_HAS_D2D_SURFACE |
michael@0 | 354 | + |
michael@0 | 355 | +/** |
michael@0 | 356 | + * Create a D2D surface for an HWND |
michael@0 | 357 | + * |
michael@0 | 358 | + * \param wnd Handle for the window |
michael@0 | 359 | + * \return New cairo surface |
michael@0 | 360 | + */ |
michael@0 | 361 | +cairo_public cairo_surface_t * |
michael@0 | 362 | +cairo_d2d_surface_create_for_hwnd(HWND wnd); |
michael@0 | 363 | + |
michael@0 | 364 | +/** |
michael@0 | 365 | + * Create a D2D surface of a certain size. |
michael@0 | 366 | + * |
michael@0 | 367 | + * \param format Cairo format of the surface |
michael@0 | 368 | + * \param width Width of the surface |
michael@0 | 369 | + * \param height Height of the surface |
michael@0 | 370 | + * \return New cairo surface |
michael@0 | 371 | + */ |
michael@0 | 372 | +cairo_public cairo_surface_t * |
michael@0 | 373 | +cairo_d2d_surface_create(cairo_format_t format, |
michael@0 | 374 | + int width, |
michael@0 | 375 | + int height); |
michael@0 | 376 | + |
michael@0 | 377 | +/** |
michael@0 | 378 | + * Present the backbuffer for a surface create for an HWND. This needs |
michael@0 | 379 | + * to be called when the owner of the original window surface wants to |
michael@0 | 380 | + * actually present the executed drawing operations to the screen. |
michael@0 | 381 | + * |
michael@0 | 382 | + * \param surface D2D surface. |
michael@0 | 383 | + */ |
michael@0 | 384 | +void cairo_d2d_present_backbuffer(cairo_surface_t *surface); |
michael@0 | 385 | + |
michael@0 | 386 | +/** |
michael@0 | 387 | + * Scroll the surface, this only moves the surface graphics, it does not |
michael@0 | 388 | + * actually scroll child windows or anything like that. Nor does it invalidate |
michael@0 | 389 | + * that area of the window. |
michael@0 | 390 | + * |
michael@0 | 391 | + * \param surface The d2d surface this operation should apply to. |
michael@0 | 392 | + * \param x The x delta for the movement |
michael@0 | 393 | + * \param y The y delta for the movement |
michael@0 | 394 | + * \param clip The clip rectangle, the is the 'part' of the surface that needs |
michael@0 | 395 | + * scrolling. |
michael@0 | 396 | + */ |
michael@0 | 397 | +void cairo_d2d_scroll(cairo_surface_t *surface, int x, int y, cairo_rectangle_t *clip); |
michael@0 | 398 | +#endif |
michael@0 | 399 | + |
michael@0 | 400 | CAIRO_END_DECLS |
michael@0 | 401 | |
michael@0 | 402 | #else /* CAIRO_HAS_WIN32_SURFACE */ |
michael@0 | 403 | diff --git a/src/cairo.h b/src/cairo.h |
michael@0 | 404 | index 3a8b8a6..21827aa 100644 |
michael@0 | 405 | --- a/src/cairo.h |
michael@0 | 406 | +++ b/src/cairo.h |
michael@0 | 407 | @@ -1370,7 +1370,8 @@ typedef enum _cairo_font_type { |
michael@0 | 408 | CAIRO_FONT_TYPE_FT, |
michael@0 | 409 | CAIRO_FONT_TYPE_WIN32, |
michael@0 | 410 | CAIRO_FONT_TYPE_QUARTZ, |
michael@0 | 411 | - CAIRO_FONT_TYPE_USER |
michael@0 | 412 | + CAIRO_FONT_TYPE_USER, |
michael@0 | 413 | + CAIRO_FONT_TYPE_DWRITE |
michael@0 | 414 | } cairo_font_type_t; |
michael@0 | 415 | |
michael@0 | 416 | cairo_public cairo_font_type_t |
michael@0 | 417 | @@ -2009,7 +2010,7 @@ typedef enum _cairo_surface_type { |
michael@0 | 418 | CAIRO_SURFACE_TYPE_TEE, |
michael@0 | 419 | CAIRO_SURFACE_TYPE_XML, |
michael@0 | 420 | CAIRO_SURFACE_TYPE_SKIA, |
michael@0 | 421 | - CAIRO_SURFACE_TYPE_DDRAW |
michael@0 | 422 | + CAIRO_SURFACE_TYPE_D2D |
michael@0 | 423 | } cairo_surface_type_t; |
michael@0 | 424 | |
michael@0 | 425 | cairo_public cairo_surface_type_t |
michael@0 | 426 | diff --git a/src/cairoint.h b/src/cairoint.h |
michael@0 | 427 | index b942b4b..58850ab 100644 |
michael@0 | 428 | --- a/src/cairoint.h |
michael@0 | 429 | +++ b/src/cairoint.h |
michael@0 | 430 | @@ -587,6 +587,12 @@ extern const cairo_private struct _cairo_font_face_backend _cairo_win32_font_fac |
michael@0 | 431 | |
michael@0 | 432 | #endif |
michael@0 | 433 | |
michael@0 | 434 | +#if CAIRO_HAS_DWRITE_FONT |
michael@0 | 435 | + |
michael@0 | 436 | +extern const cairo_private struct _cairo_font_face_backend _cairo_dwrite_font_face_backend; |
michael@0 | 437 | + |
michael@0 | 438 | +#endif |
michael@0 | 439 | + |
michael@0 | 440 | #if CAIRO_HAS_QUARTZ_FONT |
michael@0 | 441 | |
michael@0 | 442 | extern const cairo_private struct _cairo_font_face_backend _cairo_quartz_font_face_backend; |
michael@0 | 443 | @@ -932,7 +938,12 @@ typedef struct _cairo_traps { |
michael@0 | 444 | #define CAIRO_FT_FONT_FAMILY_DEFAULT "" |
michael@0 | 445 | #define CAIRO_USER_FONT_FAMILY_DEFAULT "@cairo:" |
michael@0 | 446 | |
michael@0 | 447 | -#if CAIRO_HAS_WIN32_FONT |
michael@0 | 448 | +#if CAIRO_HAS_DWRITE_FONT |
michael@0 | 449 | + |
michael@0 | 450 | +#define CAIRO_FONT_FAMILY_DEFAULT CAIRO_WIN32_FONT_FAMILY_DEFAULT |
michael@0 | 451 | +#define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_dwrite_font_face_backend |
michael@0 | 452 | + |
michael@0 | 453 | +#elif CAIRO_HAS_WIN32_FONT |
michael@0 | 454 | |
michael@0 | 455 | #define CAIRO_FONT_FAMILY_DEFAULT CAIRO_WIN32_FONT_FAMILY_DEFAULT |
michael@0 | 456 | #define CAIRO_FONT_FACE_BACKEND_DEFAULT &_cairo_win32_font_face_backend |
michael@0 | 457 | @@ -2617,7 +2628,7 @@ cairo_private int |
michael@0 | 458 | _cairo_ucs4_to_utf8 (uint32_t unicode, |
michael@0 | 459 | char *utf8); |
michael@0 | 460 | |
michael@0 | 461 | -#if CAIRO_HAS_WIN32_FONT || CAIRO_HAS_QUARTZ_FONT || CAIRO_HAS_PDF_OPERATORS |
michael@0 | 462 | +#if CAIRO_HAS_WIN32_FONT || CAIRO_HAS_QUARTZ_FONT || CAIRO_HAS_PDF_OPERATORS || CAIRO_HAS_DW_FONT |
michael@0 | 463 | # define CAIRO_HAS_UTF8_TO_UTF16 1 |
michael@0 | 464 | #endif |
michael@0 | 465 | #if CAIRO_HAS_UTF8_TO_UTF16 |