⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cairo-meta-surface.c

📁 按照官方的说法:Cairo is a vector graphics library with cross-device output support. 翻译过来
💻 C
📖 第 1 页 / 共 2 页
字号:
    return status;}static cairo_int_status_t_cairo_meta_surface_fill (void			*abstract_surface,			  cairo_operator_t	 op,			  cairo_pattern_t	*source,			  cairo_path_fixed_t	*path,			  cairo_fill_rule_t	 fill_rule,			  double		 tolerance,			  cairo_antialias_t	 antialias){    cairo_status_t status;    cairo_meta_surface_t *meta = abstract_surface;    cairo_command_fill_t *command;    command = malloc (sizeof (cairo_command_fill_t));    if (command == NULL)	return CAIRO_STATUS_NO_MEMORY;    command->type = CAIRO_COMMAND_FILL;    command->op = op;    status = _init_pattern_with_snapshot (&command->source.base, source);    if (status)	goto CLEANUP_COMMAND;    status = _cairo_path_fixed_init_copy (&command->path, path);    if (status)	goto CLEANUP_SOURCE;    command->fill_rule = fill_rule;    command->tolerance = tolerance;    command->antialias = antialias;    status = _cairo_array_append (&meta->commands, &command);    if (status)	goto CLEANUP_PATH;    return CAIRO_STATUS_SUCCESS;  CLEANUP_PATH:    _cairo_path_fixed_fini (&command->path);  CLEANUP_SOURCE:    _cairo_pattern_fini (&command->source.base);  CLEANUP_COMMAND:    free (command);    return status;}static cairo_int_status_t_cairo_meta_surface_show_glyphs (void			*abstract_surface,				 cairo_operator_t	 op,				 cairo_pattern_t	*source,				 const cairo_glyph_t	*glyphs,				 int			 num_glyphs,				 cairo_scaled_font_t	*scaled_font){    cairo_status_t status;    cairo_meta_surface_t *meta = abstract_surface;    cairo_command_show_glyphs_t *command;    command = malloc (sizeof (cairo_command_show_glyphs_t));    if (command == NULL)	return CAIRO_STATUS_NO_MEMORY;    command->type = CAIRO_COMMAND_SHOW_GLYPHS;    command->op = op;    status = _init_pattern_with_snapshot (&command->source.base, source);    if (status)	goto CLEANUP_COMMAND;    command->glyphs = malloc (sizeof (cairo_glyph_t) * num_glyphs);    if (command->glyphs == NULL) {	status = CAIRO_STATUS_NO_MEMORY;	goto CLEANUP_SOURCE;    }    memcpy (command->glyphs, glyphs, sizeof (cairo_glyph_t) * num_glyphs);    command->num_glyphs = num_glyphs;    command->scaled_font = cairo_scaled_font_reference (scaled_font);    status = _cairo_array_append (&meta->commands, &command);    if (status)	goto CLEANUP_SCALED_FONT;    return CAIRO_STATUS_SUCCESS;  CLEANUP_SCALED_FONT:    cairo_scaled_font_destroy (command->scaled_font);    free (command->glyphs);  CLEANUP_SOURCE:    _cairo_pattern_fini (&command->source.base);  CLEANUP_COMMAND:    free (command);    return status;}/** * _cairo_meta_surface_snapshot * @surface: a #cairo_surface_t which must be a meta surface * * Make an immutable copy of @surface. It is an error to call a * surface-modifying function on the result of this function. * * The caller owns the return value and should call * cairo_surface_destroy when finished with it. This function will not * return NULL, but will return a nil surface instead. * * Return value: The snapshot surface. **/static cairo_surface_t *_cairo_meta_surface_snapshot (void *abstract_other){    cairo_meta_surface_t *other = abstract_other;    cairo_meta_surface_t *meta;    meta = malloc (sizeof (cairo_meta_surface_t));    if (meta == NULL) {	_cairo_error (CAIRO_STATUS_NO_MEMORY);	return (cairo_surface_t*) &_cairo_surface_nil;    }    _cairo_surface_init (&meta->base, &cairo_meta_surface_backend,			 other->base.content);    meta->base.is_snapshot = TRUE;    meta->width_pixels = other->width_pixels;    meta->height_pixels = other->height_pixels;    meta->replay_start_idx = other->replay_start_idx;    meta->content = other->content;    _cairo_array_init_snapshot (&meta->commands, &other->commands);    meta->commands_owner = cairo_surface_reference (&other->base);    return &meta->base;}static cairo_int_status_t_cairo_meta_surface_intersect_clip_path (void		    *dst,					 cairo_path_fixed_t *path,					 cairo_fill_rule_t   fill_rule,					 double		     tolerance,					 cairo_antialias_t   antialias){    cairo_meta_surface_t *meta = dst;    cairo_command_intersect_clip_path_t *command;    cairo_status_t status;    command = malloc (sizeof (cairo_command_intersect_clip_path_t));    if (command == NULL)	return CAIRO_STATUS_NO_MEMORY;    command->type = CAIRO_COMMAND_INTERSECT_CLIP_PATH;    if (path) {	status = _cairo_path_fixed_init_copy (&command->path, path);	if (status) {	    free (command);	    return status;	}	command->path_pointer = &command->path;	meta->is_clipped = TRUE;    } else {	command->path_pointer = NULL;	meta->is_clipped = FALSE;    }    command->fill_rule = fill_rule;    command->tolerance = tolerance;    command->antialias = antialias;    status = _cairo_array_append (&meta->commands, &command);    if (status) {	if (path)	    _cairo_path_fixed_fini (&command->path);	free (command);	return status;    }    return CAIRO_STATUS_SUCCESS;}/* Currently, we're using as the "size" of a meta surface the largest * surface size against which the meta-surface is expected to be * replayed, (as passed in to _cairo_meta_surface_create). */static cairo_int_status_t_cairo_meta_surface_get_extents (void			 *abstract_surface,				 cairo_rectangle_int16_t *rectangle){    cairo_meta_surface_t *surface = abstract_surface;    rectangle->x = 0;    rectangle->y = 0;    rectangle->width = surface->width_pixels;    rectangle->height = surface->height_pixels;    return CAIRO_STATUS_SUCCESS;}/** * _cairo_surface_is_meta: * @surface: a #cairo_surface_t * * Checks if a surface is a #cairo_meta_surface_t * * Return value: TRUE if the surface is a meta surface **/cairo_bool_t_cairo_surface_is_meta (const cairo_surface_t *surface){    return surface->backend == &cairo_meta_surface_backend;}static const cairo_surface_backend_t cairo_meta_surface_backend = {    CAIRO_INTERNAL_SURFACE_TYPE_META,    _cairo_meta_surface_create_similar,    _cairo_meta_surface_finish,    _cairo_meta_surface_acquire_source_image,    _cairo_meta_surface_release_source_image,    NULL, /* acquire_dest_image */    NULL, /* release_dest_image */    NULL, /* clone_similar */    NULL, /* composite */    NULL, /* fill_rectangles */    NULL, /* composite_trapezoids */    NULL, /* copy_page */    NULL, /* show_page */    NULL, /* set_clip_region */    _cairo_meta_surface_intersect_clip_path,    _cairo_meta_surface_get_extents,    NULL, /* old_show_glyphs */    NULL, /* get_font_options */    NULL, /* flush */    NULL, /* mark_dirty_rectangle */    NULL, /* scaled_font_fini */    NULL, /* scaled_glyph_fini */    /* Here are the 5 basic drawing operations, (which are in some     * sense the only things that cairo_meta_surface should need to     * implement). */    _cairo_meta_surface_paint,    _cairo_meta_surface_mask,    _cairo_meta_surface_stroke,    _cairo_meta_surface_fill,    _cairo_meta_surface_show_glyphs,    _cairo_meta_surface_snapshot};cairo_status_t_cairo_meta_surface_replay (cairo_surface_t *surface,			    cairo_surface_t *target){    cairo_meta_surface_t *meta;    cairo_command_t *command, **elements;    int i, num_elements;    cairo_int_status_t status;    cairo_clip_t clip;    meta = (cairo_meta_surface_t *) surface;    status = CAIRO_STATUS_SUCCESS;    _cairo_clip_init (&clip, target);    num_elements = meta->commands.num_elements;    elements = _cairo_array_index (&meta->commands, 0);    for (i = meta->replay_start_idx; i < num_elements; i++) {	command = elements[i];	switch (command->type) {	case CAIRO_COMMAND_PAINT:	    status = _cairo_surface_set_clip (target, &clip);	    if (status)		break;	    status = _cairo_surface_paint (target,					   command->paint.op,					   &command->paint.source.base);	    break;	case CAIRO_COMMAND_MASK:	    status = _cairo_surface_set_clip (target, &clip);	    if (status)		break;	    status = _cairo_surface_mask (target,					  command->mask.op,					  &command->mask.source.base,					  &command->mask.mask.base);	    break;	case CAIRO_COMMAND_STROKE:	    status = _cairo_surface_set_clip (target, &clip);	    if (status)		break;	    status = _cairo_surface_stroke (target,					    command->stroke.op,					    &command->stroke.source.base,					    &command->stroke.path,					    &command->stroke.style,					    &command->stroke.ctm,					    &command->stroke.ctm_inverse,					    command->stroke.tolerance,					    command->stroke.antialias);	    break;	case CAIRO_COMMAND_FILL:	    status = _cairo_surface_set_clip (target, &clip);	    if (status)		break;	    status = _cairo_surface_fill (target,					  command->fill.op,					  &command->fill.source.base,					  &command->fill.path,					  command->fill.fill_rule,					  command->fill.tolerance,					  command->fill.antialias);	    break;	case CAIRO_COMMAND_SHOW_GLYPHS:	    status = _cairo_surface_set_clip (target, &clip);	    if (status)		break;	    status = _cairo_surface_show_glyphs	(target,						 command->show_glyphs.op,						 &command->show_glyphs.source.base,						 command->show_glyphs.glyphs,						 command->show_glyphs.num_glyphs,						 command->show_glyphs.scaled_font);	    break;	case CAIRO_COMMAND_INTERSECT_CLIP_PATH:	    /* XXX Meta surface clipping is broken and requires some	     * cairo-gstate.c rewriting.  Work around it for now. */	    if (command->intersect_clip_path.path_pointer == NULL)		status = _cairo_clip_reset (&clip);	    else		status = _cairo_clip_clip (&clip,					   command->intersect_clip_path.path_pointer,					   command->intersect_clip_path.fill_rule,					   command->intersect_clip_path.tolerance,					   command->intersect_clip_path.antialias,					   target);	    break;	default:	    ASSERT_NOT_REACHED;	}	if (status)	    break;    }    _cairo_clip_fini (&clip);    return status;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -