Bug 699507. cairo-win32: remove dead fallbacks. r=ajuma

This code was never used.
This commit is contained in:
Jeff Muizelaar 2011-11-04 12:07:12 -04:00
parent 70dbdabd1d
commit e1dbca5f44

View File

@ -3681,419 +3681,6 @@ _cairo_win32_surface_fallback_fill (cairo_surface_t *surface,
return status;
}
typedef struct {
cairo_scaled_font_t *font;
cairo_glyph_t *glyphs;
int num_glyphs;
} cairo_show_glyphs_info_t;
static cairo_status_t
_cairo_surface_old_show_glyphs_draw_func (void *closure,
cairo_operator_t op,
const cairo_pattern_t *src,
cairo_surface_t *dst,
int dst_x,
int dst_y,
const cairo_rectangle_int_t *extents,
cairo_region_t *clip_region)
{
cairo_show_glyphs_info_t *glyph_info = closure;
cairo_status_t status;
cairo_region_t *extents_region = NULL;
if (clip_region == NULL &&
!_cairo_operator_bounded_by_source (op)) {
extents_region = cairo_region_create_rectangle (extents);
if (unlikely (extents_region->status))
return extents_region->status;
cairo_region_translate (extents_region, -dst_x, -dst_y);
clip_region = extents_region;
}
/* Modifying the glyph array is fine because we know that this function
* will be called only once, and we've already made a copy of the
* glyphs in the wrapper.
*/
if (dst_x != 0 || dst_y != 0) {
int i;
for (i = 0; i < glyph_info->num_glyphs; ++i) {
((cairo_glyph_t *) glyph_info->glyphs)[i].x -= dst_x;
((cairo_glyph_t *) glyph_info->glyphs)[i].y -= dst_y;
}
}
status = _cairo_surface_old_show_glyphs (glyph_info->font, op, src,
dst,
extents->x, extents->y,
extents->x - dst_x,
extents->y - dst_y,
extents->width,
extents->height,
glyph_info->glyphs,
glyph_info->num_glyphs,
clip_region);
if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
status = _cairo_scaled_font_show_glyphs (glyph_info->font,
op,
src, dst,
extents->x, extents->y,
extents->x - dst_x,
extents->y - dst_y,
extents->width, extents->height,
glyph_info->glyphs,
glyph_info->num_glyphs,
clip_region);
}
if (extents_region)
cairo_region_destroy (extents_region);
return status;
}
cairo_status_t
_cairo_win32_surface_fallback_show_glyphs (cairo_surface_t *surface,
cairo_operator_t op,
const cairo_pattern_t *source,
cairo_glyph_t *glyphs,
int num_glyphs,
cairo_scaled_font_t *scaled_font,
cairo_clip_t *clip)
{
cairo_show_glyphs_info_t glyph_info;
cairo_composite_rectangles_t extents;
cairo_rectangle_int_t rect;
cairo_status_t status;
if (!_cairo_surface_get_extents (surface, &rect))
ASSERT_NOT_REACHED;
status = _cairo_composite_rectangles_init_for_glyphs (&extents,
&rect,
op, source,
scaled_font,
glyphs, num_glyphs,
clip,
NULL);
if (unlikely (status))
return status;
if (_cairo_clip_contains_rectangle (clip, &extents.mask))
clip = NULL;
if (clip != NULL && extents.is_bounded) {
status = _cairo_clip_rectangle (clip, &extents.bounded);
if (unlikely (status))
return status;
}
glyph_info.font = scaled_font;
glyph_info.glyphs = glyphs;
glyph_info.num_glyphs = num_glyphs;
return _clip_and_composite (clip, op, source,
_cairo_surface_old_show_glyphs_draw_func,
&glyph_info,
surface,
extents.is_bounded ? &extents.bounded : &extents.unbounded);
}
cairo_surface_t *
_cairo_win32_surface_fallback_snapshot (cairo_surface_t *surface)
{
cairo_surface_t *snapshot;
cairo_status_t status;
cairo_format_t format;
cairo_surface_pattern_t pattern;
cairo_image_surface_t *image;
void *image_extra;
status = _cairo_surface_acquire_source_image (surface,
&image, &image_extra);
if (unlikely (status))
return _cairo_surface_create_in_error (status);
format = image->format;
if (format == CAIRO_FORMAT_INVALID) {
/* Non-standard images formats can be generated when retrieving
* images from unusual xservers, for example.
*/
format = _cairo_format_from_content (image->base.content);
}
snapshot = cairo_image_surface_create (format,
image->width,
image->height);
if (cairo_surface_status (snapshot)) {
_cairo_surface_release_source_image (surface, image, image_extra);
return snapshot;
}
_cairo_pattern_init_for_surface (&pattern, &image->base);
status = _cairo_surface_paint (snapshot,
CAIRO_OPERATOR_SOURCE,
&pattern.base,
NULL);
_cairo_pattern_fini (&pattern.base);
_cairo_surface_release_source_image (surface, image, image_extra);
if (unlikely (status)) {
cairo_surface_destroy (snapshot);
return _cairo_surface_create_in_error (status);
}
return snapshot;
}
cairo_status_t
_cairo_win32_surface_fallback_composite (cairo_operator_t op,
const cairo_pattern_t *src,
const cairo_pattern_t *mask,
cairo_surface_t *dst,
int src_x,
int src_y,
int mask_x,
int mask_y,
int dst_x,
int dst_y,
unsigned int width,
unsigned int height,
cairo_region_t *clip_region)
{
fallback_state_t state;
cairo_region_t *fallback_region = NULL;
cairo_status_t status;
status = _fallback_init (&state, dst, dst_x, dst_y, width, height);
if (unlikely (status))
return status;
/* We know this will never fail with the image backend; but
* instead of calling into it directly, we call
* _cairo_surface_composite so that we get the correct device
* offset handling.
*/
if (clip_region != NULL && (state.image_rect.x || state.image_rect.y)) {
fallback_region = cairo_region_copy (clip_region);
status = fallback_region->status;
if (unlikely (status))
goto FAIL;
cairo_region_translate (fallback_region,
-state.image_rect.x,
-state.image_rect.y);
clip_region = fallback_region;
}
status = _cairo_surface_composite (op, src, mask,
&state.image->base,
src_x, src_y, mask_x, mask_y,
dst_x - state.image_rect.x,
dst_y - state.image_rect.y,
width, height,
clip_region);
FAIL:
if (fallback_region != NULL)
cairo_region_destroy (fallback_region);
_fallback_fini (&state);
return status;
}
cairo_status_t
_cairo_win32_surface_fallback_fill_rectangles (cairo_surface_t *surface,
cairo_operator_t op,
const cairo_color_t *color,
cairo_rectangle_int_t *rects,
int num_rects)
{
fallback_state_t state;
cairo_rectangle_int_t *offset_rects = NULL;
cairo_status_t status;
int x1, y1, x2, y2;
int i;
assert (surface->snapshot_of == NULL);
if (num_rects <= 0)
return CAIRO_STATUS_SUCCESS;
/* Compute the bounds of the rectangles, so that we know what area of the
* destination surface to fetch
*/
x1 = rects[0].x;
y1 = rects[0].y;
x2 = rects[0].x + rects[0].width;
y2 = rects[0].y + rects[0].height;
for (i = 1; i < num_rects; i++) {
if (rects[i].x < x1)
x1 = rects[i].x;
if (rects[i].y < y1)
y1 = rects[i].y;
if ((int) (rects[i].x + rects[i].width) > x2)
x2 = rects[i].x + rects[i].width;
if ((int) (rects[i].y + rects[i].height) > y2)
y2 = rects[i].y + rects[i].height;
}
status = _fallback_init (&state, surface, x1, y1, x2 - x1, y2 - y1);
if (unlikely (status))
return status;
/* If the fetched image isn't at 0,0, we need to offset the rectangles */
if (state.image_rect.x != 0 || state.image_rect.y != 0) {
offset_rects = _cairo_malloc_ab (num_rects, sizeof (cairo_rectangle_int_t));
if (unlikely (offset_rects == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto DONE;
}
for (i = 0; i < num_rects; i++) {
offset_rects[i].x = rects[i].x - state.image_rect.x;
offset_rects[i].y = rects[i].y - state.image_rect.y;
offset_rects[i].width = rects[i].width;
offset_rects[i].height = rects[i].height;
}
rects = offset_rects;
}
status = _cairo_surface_fill_rectangles (&state.image->base,
op, color,
rects, num_rects);
free (offset_rects);
DONE:
_fallback_fini (&state);
return status;
}
cairo_status_t
_cairo_win32_surface_fallback_composite_trapezoids (cairo_operator_t op,
const cairo_pattern_t *pattern,
cairo_surface_t *dst,
cairo_antialias_t antialias,
int src_x,
int src_y,
int dst_x,
int dst_y,
unsigned int width,
unsigned int height,
cairo_trapezoid_t *traps,
int num_traps,
cairo_region_t *clip_region)
{
fallback_state_t state;
cairo_region_t *fallback_region = NULL;
cairo_trapezoid_t *offset_traps = NULL;
cairo_status_t status;
status = _fallback_init (&state, dst, dst_x, dst_y, width, height);
if (unlikely (status))
return status;
/* If the destination image isn't at 0,0, we need to offset the trapezoids */
if (state.image_rect.x != 0 || state.image_rect.y != 0) {
offset_traps = _cairo_malloc_ab (num_traps, sizeof (cairo_trapezoid_t));
if (offset_traps == NULL) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FAIL;
}
_cairo_trapezoid_array_translate_and_scale (offset_traps, traps, num_traps,
- state.image_rect.x, - state.image_rect.y,
1.0, 1.0);
traps = offset_traps;
/* similarly we need to adjust the region */
if (clip_region != NULL) {
fallback_region = cairo_region_copy (clip_region);
status = fallback_region->status;
if (unlikely (status))
goto FAIL;
cairo_region_translate (fallback_region,
-state.image_rect.x,
-state.image_rect.y);
clip_region = fallback_region;
}
}
status = _cairo_surface_composite_trapezoids (op, pattern,
&state.image->base,
antialias,
src_x, src_y,
dst_x - state.image_rect.x,
dst_y - state.image_rect.y,
width, height,
traps, num_traps,
clip_region);
FAIL:
if (offset_traps != NULL)
free (offset_traps);
if (fallback_region != NULL)
cairo_region_destroy (fallback_region);
_fallback_fini (&state);
return status;
}
cairo_status_t
_cairo_win32_surface_fallback_clone_similar (cairo_surface_t *surface,
cairo_surface_t *src,
int src_x,
int src_y,
int width,
int height,
int *clone_offset_x,
int *clone_offset_y,
cairo_surface_t **clone_out)
{
cairo_surface_t *new_surface;
cairo_surface_pattern_t pattern;
cairo_status_t status;
new_surface = _cairo_surface_create_similar_scratch (surface,
src->content,
width, height);
if (new_surface == NULL)
return CAIRO_INT_STATUS_UNSUPPORTED;
if (unlikely (new_surface->status))
return new_surface->status;
/* We have to copy these here, so that the coordinate spaces are correct */
new_surface->device_transform = src->device_transform;
new_surface->device_transform_inverse = src->device_transform_inverse;
_cairo_pattern_init_for_surface (&pattern, src);
cairo_matrix_init_translate (&pattern.base.matrix, src_x, src_y);
pattern.base.filter = CAIRO_FILTER_NEAREST;
status = _cairo_surface_paint (new_surface,
CAIRO_OPERATOR_SOURCE,
&pattern.base,
NULL);
_cairo_pattern_fini (&pattern.base);
if (unlikely (status)) {
cairo_surface_destroy (new_surface);
return status;
}
*clone_offset_x = src_x;
*clone_offset_y = src_y;
*clone_out = new_surface;
return CAIRO_STATUS_SUCCESS;
}
static const cairo_surface_backend_t cairo_win32_surface_backend = {
CAIRO_SURFACE_TYPE_WIN32,
_cairo_win32_surface_create_similar,