diff options
Diffstat (limited to 'src/win32')
-rw-r--r--[-rwxr-xr-x] | src/win32/cairo-win32-debug.c | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/win32/cairo-win32-device.c | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/win32/cairo-win32-display-surface.c | 14 | ||||
-rw-r--r--[-rwxr-xr-x] | src/win32/cairo-win32-font.c | 97 | ||||
-rw-r--r--[-rwxr-xr-x] | src/win32/cairo-win32-gdi-compositor.c | 3 | ||||
-rw-r--r--[-rwxr-xr-x] | src/win32/cairo-win32-printing-surface.c | 9 | ||||
-rw-r--r--[-rwxr-xr-x] | src/win32/cairo-win32-private.h | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | src/win32/cairo-win32-surface.c | 21 | ||||
-rw-r--r--[-rwxr-xr-x] | src/win32/cairo-win32-system.c | 0 |
9 files changed, 85 insertions, 59 deletions
diff --git a/src/win32/cairo-win32-debug.c b/src/win32/cairo-win32-debug.c index ff7aeaf1f..ff7aeaf1f 100755..100644 --- a/src/win32/cairo-win32-debug.c +++ b/src/win32/cairo-win32-debug.c diff --git a/src/win32/cairo-win32-device.c b/src/win32/cairo-win32-device.c index 741e49e33..741e49e33 100755..100644 --- a/src/win32/cairo-win32-device.c +++ b/src/win32/cairo-win32-device.c diff --git a/src/win32/cairo-win32-display-surface.c b/src/win32/cairo-win32-display-surface.c index ccd285d7d..965f2c45d 100755..100644 --- a/src/win32/cairo-win32-display-surface.c +++ b/src/win32/cairo-win32-display-surface.c @@ -415,7 +415,8 @@ _cairo_win32_display_surface_finish (void *abstract_surface) { cairo_win32_display_surface_t *surface = abstract_surface; - if (surface->image) { + if (surface->image && to_image_surface(surface->image)->parent) { + assert (to_image_surface(surface->image)->parent == &surface->win32.base); /* Unhook ourselves first to avoid the double-unref from the image */ to_image_surface(surface->image)->parent = NULL; cairo_surface_finish (surface->image); @@ -429,6 +430,8 @@ _cairo_win32_display_surface_finish (void *abstract_surface) DeleteDC (surface->win32.dc); } + _cairo_win32_display_surface_discard_fallback (surface); + if (surface->initial_clip_rgn) DeleteObject (surface->initial_clip_rgn); @@ -452,17 +455,17 @@ _cairo_win32_display_surface_map_to_image (void *abstract_sur surface->fallback = _cairo_win32_display_surface_create_for_dc (surface->win32.dc, surface->win32.format, - surface->win32.extents.width, - surface->win32.extents.height); + surface->win32.extents.x + surface->win32.extents.width, + surface->win32.extents.y + surface->win32.extents.height); if (unlikely (status = surface->fallback->status)) goto err; if (!BitBlt (to_win32_surface(surface->fallback)->dc, - 0, 0, + surface->win32.extents.x, surface->win32.extents.y, surface->win32.extents.width, surface->win32.extents.height, surface->win32.dc, - 0, 0, + surface->win32.extents.x, surface->win32.extents.y, SRCCOPY)) { status = _cairo_error (CAIRO_STATUS_DEVICE_ERROR); goto err; @@ -758,6 +761,7 @@ _cairo_win32_display_surface_discard_fallback (cairo_win32_display_surface_t *su TRACE ((stderr, "%s (surface=%d)\n", __FUNCTION__, surface->win32.base.unique_id)); + cairo_surface_finish (surface->fallback); cairo_surface_destroy (surface->fallback); surface->fallback = NULL; } diff --git a/src/win32/cairo-win32-font.c b/src/win32/cairo-win32-font.c index a65d81b1a..1599b0751 100755..100644 --- a/src/win32/cairo-win32-font.c +++ b/src/win32/cairo-win32-font.c @@ -157,10 +157,6 @@ static cairo_status_t _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font, cairo_scaled_glyph_t *scaled_glyph); -static void -_cairo_win32_font_face_destroy (void *abstract_face); - - #define NEARLY_ZERO(d) (fabs(d) < (1. / 65536.)) static HDC @@ -1847,49 +1843,6 @@ struct _cairo_win32_font_face { HFONT hfont; }; -/* implement the platform-specific interface */ - -static cairo_bool_t -_is_scale (const cairo_matrix_t *matrix, double scale) -{ - return matrix->xx == scale && matrix->yy == scale && - matrix->xy == 0. && matrix->yx == 0. && - matrix->x0 == 0. && matrix->y0 == 0.; -} - -static cairo_status_t -_cairo_win32_font_face_scaled_font_create (void *abstract_face, - const cairo_matrix_t *font_matrix, - const cairo_matrix_t *ctm, - const cairo_font_options_t *options, - cairo_scaled_font_t **font) -{ - HFONT hfont = NULL; - - cairo_win32_font_face_t *font_face = abstract_face; - - if (font_face->hfont) { - /* Check whether it's OK to go ahead and use the font-face's HFONT. */ - if (_is_scale (ctm, 1.) && - _is_scale (font_matrix, -font_face->logfont.lfHeight)) { - hfont = font_face->hfont; - } - } - - return _win32_scaled_font_create (&font_face->logfont, - hfont, - &font_face->base, - font_matrix, ctm, options, - font); -} - -const cairo_font_face_backend_t _cairo_win32_font_face_backend = { - CAIRO_FONT_TYPE_WIN32, - _cairo_win32_font_face_create_for_toy, - _cairo_win32_font_face_destroy, - _cairo_win32_font_face_scaled_font_create -}; - /* We maintain a hash table from LOGFONT,HFONT => #cairo_font_face_t. * The primary purpose of this mapping is to provide unique * #cairo_font_face_t values so that our cache and mapping from @@ -1950,7 +1903,7 @@ _cairo_win32_font_face_hash_table_unlock (void) CAIRO_MUTEX_UNLOCK (_cairo_win32_font_face_mutex); } -static void +static cairo_bool_t _cairo_win32_font_face_destroy (void *abstract_face) { cairo_win32_font_face_t *font_face = abstract_face; @@ -1960,10 +1913,10 @@ _cairo_win32_font_face_destroy (void *abstract_face) /* All created objects must have been mapped in the hash table. */ assert (hash_table != NULL); - if (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&font_face->base.ref_count)) { + if (! _cairo_reference_count_dec_and_test (&font_face->base.ref_count)) { /* somebody recreated the font whilst we waited for the lock */ _cairo_win32_font_face_hash_table_unlock (); - return; + return FALSE; } /* Font faces in SUCCESS status are guaranteed to be in the @@ -1975,6 +1928,7 @@ _cairo_win32_font_face_destroy (void *abstract_face) _cairo_hash_table_remove (hash_table, &font_face->base.hash_entry); _cairo_win32_font_face_hash_table_unlock (); + return TRUE; } static void @@ -2015,6 +1969,49 @@ _cairo_win32_font_face_keys_equal (const void *key_a, return FALSE; } +/* implement the platform-specific interface */ + +static cairo_bool_t +_is_scale (const cairo_matrix_t *matrix, double scale) +{ + return matrix->xx == scale && matrix->yy == scale && + matrix->xy == 0. && matrix->yx == 0. && + matrix->x0 == 0. && matrix->y0 == 0.; +} + +static cairo_status_t +_cairo_win32_font_face_scaled_font_create (void *abstract_face, + const cairo_matrix_t *font_matrix, + const cairo_matrix_t *ctm, + const cairo_font_options_t *options, + cairo_scaled_font_t **font) +{ + HFONT hfont = NULL; + + cairo_win32_font_face_t *font_face = abstract_face; + + if (font_face->hfont) { + /* Check whether it's OK to go ahead and use the font-face's HFONT. */ + if (_is_scale (ctm, 1.) && + _is_scale (font_matrix, -font_face->logfont.lfHeight)) { + hfont = font_face->hfont; + } + } + + return _win32_scaled_font_create (&font_face->logfont, + hfont, + &font_face->base, + font_matrix, ctm, options, + font); +} + +const cairo_font_face_backend_t _cairo_win32_font_face_backend = { + CAIRO_FONT_TYPE_WIN32, + _cairo_win32_font_face_create_for_toy, + _cairo_win32_font_face_destroy, + _cairo_win32_font_face_scaled_font_create +}; + /** * cairo_win32_font_face_create_for_logfontw_hfont: * @logfont: A #LOGFONTW structure specifying the font to use. diff --git a/src/win32/cairo-win32-gdi-compositor.c b/src/win32/cairo-win32-gdi-compositor.c index c70b0f90a..073e889ab 100755..100644 --- a/src/win32/cairo-win32-gdi-compositor.c +++ b/src/win32/cairo-win32-gdi-compositor.c @@ -151,10 +151,11 @@ static cairo_bool_t upload_box (cairo_box_t *box, void *closure) int y = _cairo_fixed_integer_part (box->p1.y); int width = _cairo_fixed_integer_part (box->p2.x - box->p1.x); int height = _cairo_fixed_integer_part (box->p2.y - box->p1.y); + int src_height = -cb->bi.bmiHeader.biHeight; TRACE ((stderr, "%s\n", __FUNCTION__)); return StretchDIBits (cb->dst, x, y + height - 1, width, -height, - x + cb->tx, height - (y + cb->ty - 1), + x + cb->tx, src_height - (y + cb->ty - 1), width, -height, cb->data, &cb->bi, DIB_RGB_COLORS, SRCCOPY); diff --git a/src/win32/cairo-win32-printing-surface.c b/src/win32/cairo-win32-printing-surface.c index be91445cf..6005cb53d 100755..100644 --- a/src/win32/cairo-win32-printing-surface.c +++ b/src/win32/cairo-win32-printing-surface.c @@ -726,6 +726,7 @@ _cairo_win32_printing_surface_paint_image_pattern (cairo_win32_printing_surface_ /* _cairo_pattern_set_matrix guarantees invertibility */ assert (status == CAIRO_STATUS_SUCCESS); + cairo_matrix_multiply (&m, &m, &surface->ctm); cairo_matrix_multiply (&m, &m, &surface->gdi_ctm); SaveDC (surface->win32.dc); _cairo_matrix_to_win32_xform (&m, &xform); @@ -1578,14 +1579,18 @@ _cairo_win32_printing_surface_show_glyphs (void *abstract_surfac * CAIRO_INT_STATUS_UNSUPPORTED and a fallback image will be * used. */ + _cairo_scaled_font_freeze_cache (scaled_font); for (i = 0; i < num_glyphs; i++) { status = _cairo_scaled_glyph_lookup (scaled_font, glyphs[i].index, CAIRO_SCALED_GLYPH_INFO_PATH, &scaled_glyph); if (status) - return status; + break; } + _cairo_scaled_font_thaw_cache (scaled_font); + if (status) + return status; return _cairo_win32_printing_surface_analyze_operation (surface, op, source); } @@ -1623,6 +1628,7 @@ _cairo_win32_printing_surface_show_glyphs (void *abstract_surfac old_has_ctm = surface->has_ctm; surface->has_ctm = TRUE; surface->path_empty = TRUE; + _cairo_scaled_font_freeze_cache (scaled_font); BeginPath (surface->win32.dc); for (i = 0; i < num_glyphs; i++) { status = _cairo_scaled_glyph_lookup (scaled_font, @@ -1636,6 +1642,7 @@ _cairo_win32_printing_surface_show_glyphs (void *abstract_surfac status = _cairo_win32_printing_surface_emit_path (surface, scaled_glyph->path); } EndPath (surface->win32.dc); + _cairo_scaled_font_thaw_cache (scaled_font); surface->ctm = old_ctm; surface->has_ctm = old_has_ctm; if (status == CAIRO_STATUS_SUCCESS && surface->path_empty == FALSE) { diff --git a/src/win32/cairo-win32-private.h b/src/win32/cairo-win32-private.h index b6c24311a..b6c24311a 100755..100644 --- a/src/win32/cairo-win32-private.h +++ b/src/win32/cairo-win32-private.h diff --git a/src/win32/cairo-win32-surface.c b/src/win32/cairo-win32-surface.c index 7cd46fc60..e6862bd10 100755..100644 --- a/src/win32/cairo-win32-surface.c +++ b/src/win32/cairo-win32-surface.c @@ -172,6 +172,21 @@ cairo_win32_surface_get_dc (cairo_surface_t *surface) } /** + * _cairo_surface_is_win32: + * @surface: a #cairo_surface_t + * + * Checks if a surface is an #cairo_win32_surface_t + * + * Return value: %TRUE if the surface is an win32 surface + **/ +static inline cairo_bool_t +_cairo_surface_is_win32 (const cairo_surface_t *surface) +{ + /* _cairo_surface_nil sets a NULL backend so be safe */ + return surface->backend && surface->backend->type == CAIRO_SURFACE_TYPE_WIN32; +} + +/** * cairo_win32_surface_get_image: * @surface: a #cairo_surface_t * @@ -187,8 +202,10 @@ cairo_win32_surface_get_dc (cairo_surface_t *surface) cairo_surface_t * cairo_win32_surface_get_image (cairo_surface_t *surface) { - if (surface->backend->type != CAIRO_SURFACE_TYPE_WIN32) - return NULL; + + if (! _cairo_surface_is_win32 (surface)) { + return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH)); + } GdiFlush(); return to_win32_display_surface(surface)->image; diff --git a/src/win32/cairo-win32-system.c b/src/win32/cairo-win32-system.c index 878553009..878553009 100755..100644 --- a/src/win32/cairo-win32-system.c +++ b/src/win32/cairo-win32-system.c |