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

📄 svg_base_sani.c

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 C
📖 第 1 页 / 共 3 页
字号:
		return;	}		gf_svg_sani_apply_local_transformation(eff, node, &backup_matrix);	if (eff->traversing_mode == TRAVERSE_GET_BOUNDS) {		svg_get_nodes_bounds(node, s->children, eff);	} else {		GF_ChildNodeItem *l = s->children;		while (l) {			if (svg_sani_eval_conditional(eff->surface->render->compositor, (SVG_SANI_Element*)l->node)) {				svg_render_node((GF_Node*)l->node, eff);				break;			}			l = l->next;		}	}	gf_svg_sani_restore_parent_transformation(eff, &backup_matrix);}void svg_sani_init_switch(Render2D *sr, GF_Node *node){	gf_node_set_callback_function(node, svg_sani_render_switch);}static void svg_sani_DrawablePostRender(Drawable *cs, SVG_SANI_TransformableElement *elt, RenderEffect2D *eff, 									Bool rectangular, Fixed path_length){	GF_FieldInfo info;	GF_Matrix2D backup_matrix;	DrawableContext *ctx;	if (eff->traversing_mode == TRAVERSE_GET_BOUNDS) {		gf_node_get_field_by_name(cs->node, "display", &info);		if (*(SVG_Display *)info.far_ptr == SVG_DISPLAY_NONE) gf_path_get_bounds(cs->path, &eff->bounds);		return;	}	gf_node_get_field_by_name(cs->node, "display", &info);	if (*(SVG_Display *)info.far_ptr == SVG_DISPLAY_NONE) return;			gf_node_get_field_by_name(cs->node, "visibility", &info);	if (*(SVG_Visibility *)info.far_ptr == SVG_VISIBILITY_HIDDEN) return;	gf_svg_sani_apply_local_transformation(eff, (GF_Node *)elt, &backup_matrix);	gf_node_get_field_by_name(cs->node, "fill-rule", &info);	if (*(SVG_FillRule *)info.far_ptr == SVG_FILLRULE_NONZERO)		cs->path->flags |= GF_PATH_FILL_ZERO_NONZERO;	else 		cs->path->flags &= ~GF_PATH_FILL_ZERO_NONZERO;	ctx = svg_sani_drawable_init_context(cs, eff);	if (ctx) {		if (rectangular) {			if (ctx->h_texture && ctx->h_texture->transparent) {}			else if (GF_COL_A(ctx->aspect.fill_color) != 0xFF) {}			else if (ctx->transform.m[1] || ctx->transform.m[3]) {}			else {				ctx->flags &= ~CTX_IS_TRANSPARENT;			}		}		if (path_length) ctx->aspect.pen_props.path_length = path_length;		drawable_finalize_render(ctx, eff, NULL);	}	gf_svg_sani_restore_parent_transformation(eff, &backup_matrix);}static void svg_sani_render_rect(GF_Node *node, void *rs, Bool is_destroy){	Drawable *cs = (Drawable *)gf_node_get_private(node);	SVG_SANI_rectElement *rect = (SVG_SANI_rectElement *)node;	RenderEffect2D *eff = (RenderEffect2D *)rs;	if (is_destroy) {		DestroyDrawableNode(node);		return;	}	if (eff->traversing_mode==TRAVERSE_DRAW) {		drawable_draw(eff);		return;	}	else if (eff->traversing_mode==TRAVERSE_PICK) {		drawable_pick(eff);		return;	}	svg_sani_render_base(node, (RenderEffect2D *)rs);		/* 3) for a leaf node	   Recreates the path (i.e the shape) only if the node is dirty 	   (has changed compared to the previous rendering phase) */	if (gf_node_dirty_get(node) & GF_SG_SVG_GEOMETRY_DIRTY) {		Fixed rx = rect->rx.value;		Fixed ry = rect->ry.value;		Fixed x = rect->x.value;		Fixed y = rect->y.value;		Fixed width = rect->width.value;		Fixed height = rect->height.value;		//fprintf(stdout, "Rebuilding rect %8x\n",rect);		drawable_reset_path(cs);		if (rx || ry) {			if (rx >= width/2) rx = width/2;			if (ry >= height/2) ry = height/2;			if (rx == 0) rx = ry;			if (ry == 0) ry = rx;			gf_path_add_move_to(cs->path, x+rx, y);			gf_path_add_line_to(cs->path, x+width-rx, y);			gf_path_add_quadratic_to(cs->path, x+width, y, x+width, y+ry);			gf_path_add_line_to(cs->path, x+width, y+height-ry);			gf_path_add_quadratic_to(cs->path, x+width, y+height, x+width-rx, y+height);			gf_path_add_line_to(cs->path, x+rx, y+height);			gf_path_add_quadratic_to(cs->path, x, y+height, x, y+height-ry);			gf_path_add_line_to(cs->path, x, y+ry);			gf_path_add_quadratic_to(cs->path, x, y, x+rx, y);			gf_path_close(cs->path);		} else {			gf_path_add_move_to(cs->path, x, y);			gf_path_add_line_to(cs->path, x+width, y);					gf_path_add_line_to(cs->path, x+width, y+height);					gf_path_add_line_to(cs->path, x, y+height);					gf_path_close(cs->path);				}		gf_node_dirty_clear(node, GF_SG_SVG_GEOMETRY_DIRTY);		cs->flags |= DRAWABLE_HAS_CHANGED;	}	svg_sani_DrawablePostRender(cs, (SVG_SANI_TransformableElement *)rect, (RenderEffect2D *)rs, 1, 0);}void svg_sani_init_rect(Render2D *sr, GF_Node *node){	drawable_stack_new(sr, node);	gf_node_set_callback_function(node, svg_sani_render_rect);}static void svg_sani_render_circle(GF_Node *node, void *rs, Bool is_destroy){	SVG_SANI_circleElement *circle = (SVG_SANI_circleElement *)node;	Drawable *cs = (Drawable *)gf_node_get_private(node);	RenderEffect2D *eff = (RenderEffect2D *)rs;	if (is_destroy) {		DestroyDrawableNode(node);		return;	}	if (eff->traversing_mode==TRAVERSE_DRAW) {		drawable_draw(eff);		return;	}	else if (eff->traversing_mode==TRAVERSE_PICK) {		drawable_pick(eff);		return;	}	svg_sani_render_base(node, (RenderEffect2D *)rs);	if (gf_node_dirty_get(node) & GF_SG_SVG_GEOMETRY_DIRTY) {		Fixed r = 2*circle->r.value;		drawable_reset_path(cs);		gf_path_add_ellipse(cs->path, circle->cx.value, circle->cy.value, r, r);		gf_node_dirty_clear(node, GF_SG_SVG_GEOMETRY_DIRTY);		cs->flags |= DRAWABLE_HAS_CHANGED;	}	svg_sani_DrawablePostRender(cs, (SVG_SANI_TransformableElement *)circle, (RenderEffect2D *)rs, 0, 0);}void svg_sani_init_circle(Render2D *sr, GF_Node *node){	drawable_stack_new(sr, node);	gf_node_set_callback_function(node, svg_sani_render_circle);}static void svg_sani_render_ellipse(GF_Node *node, void *rs, Bool is_destroy){	SVG_SANI_ellipseElement *ellipse = (SVG_SANI_ellipseElement *)node;	Drawable *cs = (Drawable *)gf_node_get_private(node);	RenderEffect2D *eff = (RenderEffect2D *)rs;	if (is_destroy) {		DestroyDrawableNode(node);		return;	}	if (eff->traversing_mode==TRAVERSE_DRAW) {		drawable_draw(eff);		return;	}	else if (eff->traversing_mode==TRAVERSE_PICK) {		drawable_pick(eff);		return;	}	svg_sani_render_base(node, (RenderEffect2D *)rs);	if (gf_node_dirty_get(node) & GF_SG_SVG_GEOMETRY_DIRTY) {		drawable_reset_path(cs);		gf_path_add_ellipse(cs->path, ellipse->cx.value, ellipse->cy.value, 2*ellipse->rx.value, 2*ellipse->ry.value);		gf_node_dirty_clear(node, GF_SG_SVG_GEOMETRY_DIRTY);		cs->flags |= DRAWABLE_HAS_CHANGED;	}	svg_sani_DrawablePostRender(cs, (SVG_SANI_TransformableElement *)ellipse, (RenderEffect2D *)rs, 0, 0);}void svg_sani_init_ellipse(Render2D *sr, GF_Node *node){	drawable_stack_new(sr, node);	gf_node_set_callback_function(node, svg_sani_render_ellipse);}static void svg_sani_render_line(GF_Node *node, void *rs, Bool is_destroy){	SVG_SANI_lineElement *line = (SVG_SANI_lineElement *)node;	Drawable *cs = (Drawable *)gf_node_get_private(node);	RenderEffect2D *eff = (RenderEffect2D *)rs;	if (is_destroy) {		DestroyDrawableNode(node);		return;	}	if (eff->traversing_mode==TRAVERSE_DRAW) {		drawable_draw(eff);		return;	}	else if (eff->traversing_mode==TRAVERSE_PICK) {		drawable_pick(eff);		return;	}	svg_sani_render_base(node, (RenderEffect2D *)rs);	if (gf_node_dirty_get(node) & GF_SG_SVG_GEOMETRY_DIRTY) {		drawable_reset_path(cs);		gf_path_add_move_to(cs->path, line->x1.value, line->y1.value);		gf_path_add_line_to(cs->path, line->x2.value, line->y2.value);		gf_node_dirty_clear(node, GF_SG_SVG_GEOMETRY_DIRTY);		cs->flags |= DRAWABLE_HAS_CHANGED;	}	svg_sani_DrawablePostRender(cs, (SVG_SANI_TransformableElement *)line, (RenderEffect2D *)rs, 0, 0);}void svg_sani_init_line(Render2D *sr, GF_Node *node){	drawable_stack_new(sr, node);	gf_node_set_callback_function(node, svg_sani_render_line);}static void svg_sani_render_polyline(GF_Node *node, void *rs, Bool is_destroy){	SVG_SANI_polylineElement *polyline = (SVG_SANI_polylineElement *)node;	Drawable *cs = (Drawable *)gf_node_get_private(node);	RenderEffect2D *eff = (RenderEffect2D *)rs;	if (is_destroy) {		DestroyDrawableNode(node);		return;	}	if (eff->traversing_mode==TRAVERSE_DRAW) {		drawable_draw(eff);		return;	}	else if (eff->traversing_mode==TRAVERSE_PICK) {		drawable_pick(eff);		return;	}	svg_sani_render_base(node, (RenderEffect2D *)rs);	if (gf_node_dirty_get(node) & GF_SG_SVG_GEOMETRY_DIRTY) {		u32 i;		u32 nbPoints = gf_list_count(polyline->points);		drawable_reset_path(cs);		if (nbPoints) {			SVG_Point *p = (SVG_Point *)gf_list_get(polyline->points, 0);			gf_path_add_move_to(cs->path, p->x, p->y);			for (i = 1; i < nbPoints; i++) {				p = (SVG_Point *)gf_list_get(polyline->points, i);				gf_path_add_line_to(cs->path, p->x, p->y);			}		} else {			gf_path_add_move_to(cs->path, 0, 0);		}		gf_node_dirty_clear(node, GF_SG_SVG_GEOMETRY_DIRTY);		cs->flags |= DRAWABLE_HAS_CHANGED;	}	svg_sani_DrawablePostRender(cs, (SVG_SANI_TransformableElement *)polyline, (RenderEffect2D *)rs, 0, 0);}void svg_sani_init_polyline(Render2D *sr, GF_Node *node){	drawable_stack_new(sr, node);	gf_node_set_callback_function(node, svg_sani_render_polyline);}static void svg_sani_render_polygon(GF_Node *node, void *rs, Bool is_destroy){	SVG_SANI_polygonElement *polygon = (SVG_SANI_polygonElement *)node;	Drawable *cs = (Drawable *)gf_node_get_private(node);	RenderEffect2D *eff = (RenderEffect2D *)rs;	if (is_destroy) {		DestroyDrawableNode(node);		return;	}	if (eff->traversing_mode==TRAVERSE_DRAW) {		drawable_draw(eff);		return;	}	else if (eff->traversing_mode==TRAVERSE_PICK) {		drawable_pick(eff);		return;	}	svg_sani_render_base(node, (RenderEffect2D *)rs);	if (gf_node_dirty_get(node) & GF_SG_SVG_GEOMETRY_DIRTY) {		u32 i;		u32 nbPoints = gf_list_count(polygon->points);		drawable_reset_path(cs);		if (nbPoints) {			SVG_Point *p = (SVG_Point *)gf_list_get(polygon->points, 0);			gf_path_add_move_to(cs->path, p->x, p->y);			for (i = 1; i < nbPoints; i++) {				p = (SVG_Point *)gf_list_get(polygon->points, i);				gf_path_add_line_to(cs->path, p->x, p->y);			}			gf_path_close(cs->path);		} else {			gf_path_add_move_to(cs->path, 0, 0);		}		gf_node_dirty_clear(node, GF_SG_SVG_GEOMETRY_DIRTY);		cs->flags |= DRAWABLE_HAS_CHANGED;	}	svg_sani_DrawablePostRender(cs, (SVG_SANI_TransformableElement *)polygon, (RenderEffect2D *)rs, 0, 0);}void svg_sani_init_polygon(Render2D *sr, GF_Node *node){	drawable_stack_new(sr, node);	gf_node_set_callback_function(node, svg_sani_render_polygon);}static void svg_sani_destroy_path(GF_Node *node){	Drawable *dr = gf_node_get_private(node);#if USE_GF_PATH	/* The path is the same as the one in the SVG node, don't delete it here */	dr->path = NULL;#endif	drawable_del(dr);}static void svg_sani_render_path(GF_Node *node, void *rs, Bool is_destroy){	SVG_SANI_pathElement *path = (SVG_SANI_pathElement *)node;	Drawable *cs = (Drawable *)gf_node_get_private(node);	RenderEffect2D *eff = (RenderEffect2D *)rs;	if (is_destroy) {		svg_sani_destroy_path(node);		return;	}	if (eff->traversing_mode==TRAVERSE_DRAW) {		drawable_draw(eff);		return;	}	else if (eff->traversing_mode==TRAVERSE_PICK) {		drawable_pick(eff);		return;	}	svg_sani_render_base(node, eff);	if (gf_node_dirty_get(node) & GF_SG_SVG_GEOMETRY_DIRTY) {#if USE_GF_PATH		cs->path = &path->d;#else		drawable_reset_path(cs);		gf_svg_path_build(cs->path, path->d.commands, path->d.points);#endif		if (path->fill_rule==GF_PATH_FILL_ZERO_NONZERO) cs->path->flags |= GF_PATH_FILL_ZERO_NONZERO;		gf_node_dirty_clear(node, GF_SG_SVG_GEOMETRY_DIRTY);		cs->flags |= DRAWABLE_HAS_CHANGED;	}	svg_sani_DrawablePostRender(cs, (SVG_SANI_TransformableElement *)path, eff, 0, (path->pathLength.type==SVG_NUMBER_VALUE) ? path->pathLength.value : 0);

⌨️ 快捷键说明

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