コード例 #1
0
static void PointSet2D_Draw(DrawableContext *ctx)
{
	LPM4PATH path;
	Float alpha, w, h;
	u32 i;
	SFColor col;
	M_PointSet2D *ps2D = (M_PointSet2D *)ctx->node->owner;
	M_Coordinate2D *coord = (M_Coordinate2D*) ps2D->coord;
	M_Color *color = (M_Color *) ps2D->color;

	/*never outline PS2D*/
	ctx->path_stroke = 1;
	if (!color || color->color.count<coord->point.count) {
		/*no texturing*/
		VS2D_DrawPath(ctx->surface, ctx->node->path, ctx, NULL, NULL);
		return;
	}

	get_point_size(&ctx->transform, &w, &h);

	path = m4_new_path();
	alpha = (Float) M4C_A(ctx->aspect.line_color) / 255;
	for (i = 0; i < coord->point.count; i++) {
		col = color->color.vals[i];
		ctx->aspect.line_color = MAKE_ARGB_FLOAT(alpha, col.red, col.green, col.blue);
		m4_path_add_rectangle(path, coord->point.vals[i].x, coord->point.vals[i].y, w, h);
		VS2D_DrawPath(ctx->surface, path, ctx, NULL, NULL);
		m4_path_reset(path);
		ctx->path_filled = 0;
	}
	m4_path_delete(path);
}
コード例 #2
0
void VS2D_TexturePath(VisualSurface2D *surf, GF_Path *path, struct _drawable_context *ctx)
{
#ifdef SKIP_DRAW
	return;
#endif
	if (!surf->the_surface || (ctx->flags & CTX_PATH_FILLED) || !ctx->h_texture || surf->render->compositor->is_hidden) return;

	/*this is ambiguous in the spec, what if the material is filled and the texture is transparent ?
	let's draw, it's nicer */
#if 0
	if (GF_COL_A(ctx->aspect.fill_color) && ctx->h_texture->transparent) {
		VS2D_DrawPath(surf, path, ctx, NULL, NULL);
		ctx->flags &= ~CTX_PATH_FILLED;
	}
#endif

	VS2D_TexturePathIntern(surf, path, NULL, ctx);
}
コード例 #3
0
static void FS_Draw(DrawableContext *ctx)
{
	u32 i;
	FSStack *st = (FSStack *) Node_GetPrivate((SFNode *) ctx->node->owner);

	for (i=0; i<ChainGetCount(st->items); i++) {
		FSItem *item = ChainGetEntry(st->items, i);
		memset(&ctx->aspect, 0, sizeof(DrawAspect2D));
		if (item->fill_col) {
			ctx->aspect.fill_color = item->fill_col;
			ctx->aspect.filled = 1;
		}
		if (item->width) {
			ctx->aspect.has_line = 1;
			ctx->aspect.line_color = item->line_col;
			ctx->aspect.pen_props.width = item->width;
		}
		VS2D_DrawPath(ctx->surface, item->path, ctx, NULL, NULL);
		ctx->path_filled = ctx->path_stroke = 0;
	}
}
コード例 #4
0
ファイル: ils2d.c プロジェクト: DmitrySigaev/DSMedia
static void ILS2D_Draw(DrawableContext *ctx)
{
	LPM4PATH path;
	LPM4STENCIL grad;
	SFVec2f start, end, *pts;
	SFColor col;
	Graphics2DDriver *g_hw;
	Float alpha;
	u32 i, j, count, num_col, col_ind, ind, end_at;
	u32 linear[2], *colors;
	M_IndexedLineSet2D *ils2D = (M_IndexedLineSet2D *)ctx->node->owner;
	M_Coordinate2D *coord = (M_Coordinate2D*) ils2D->coord;
	M_Color *color = (M_Color *) ils2D->color;


	if (!coord->point.count) return;

	if (! ils2D->color) {
		/*no texturing*/
		VS2D_DrawPath(ctx->surface, ctx->node->path, ctx, NULL, NULL);
		return;
	}
	
	alpha = (Float) M4C_A(ctx->aspect.line_color) / 255;
	pts = coord->point.vals;

	if (!ils2D->colorPerVertex || (color->color.count<2) ) {
		count = 0;
		end_at = ils2D->coordIndex.count;
		if (!end_at) end_at = coord->point.count;
		ind = ils2D->coordIndex.count ? ils2D->coordIndex.vals[0] : 0;
		i=1;
		path = m4_new_path();
		m4_path_add_move_to(path, pts[ind].x, pts[ind].y);

		for (; i<=end_at; i++) {
			if ((i==end_at) || (ils2D->coordIndex.count && ils2D->coordIndex.vals[i] == -1)) {

				/*draw current*/
				col_ind = (ils2D->colorIndex.count) ? ils2D->colorIndex.vals[count] : count;
				if (col_ind>=color->color.count) col_ind=color->color.count-1;
				col = color->color.vals[col_ind];
				ctx->aspect.line_color = MAKE_ARGB_FLOAT(alpha, col.red, col.green, col.blue);

				VS2D_DrawPath(ctx->surface, path, ctx, NULL, NULL);

				i++;
				if (i>=end_at) break;
				m4_path_reset(path);

				ind = ils2D->coordIndex.count ? ils2D->coordIndex.vals[i] : i;
				m4_path_add_move_to(path, pts[ind].x, pts[ind].y);

				if (ils2D->coordIndex.count) count++;
				continue;
			} else {
				ind = ils2D->coordIndex.count ? ils2D->coordIndex.vals[i] : i;
				m4_path_add_line_to(path, pts[ind].x, pts[ind].y);
			}
		}
		m4_path_delete(path);
		return;
	}

	g_hw = NULL;
	end_at = ils2D->coordIndex.count;
	if (!end_at) end_at = coord->point.count;
	count = 0;
	col_ind = 0;
	ind = 0;
	i=0;
	path = m4_new_path();
	while (1) {
		m4_path_reset(path);
		ind = ils2D->coordIndex.count ? ils2D->coordIndex.vals[i] : i;
		start = pts[ind];
		num_col = 1;
		i++;
		m4_path_add_move_to(path, start.x, start.y);

		if (ils2D->coordIndex.count) {
			while (ils2D->coordIndex.vals[i] != -1) {
				end = pts[ils2D->coordIndex.vals[i]];
				m4_path_add_line_to(path, end.x, end.y);
				i++;
				num_col++;
				if (i >= ils2D->coordIndex.count) break;
			}
		} else {
			while (i<end_at) {
				end = pts[i];
				m4_path_add_line_to(path, end.x, end.y);
				i++;
				num_col++;
			}
		}

		g_hw = ctx->surface->render->compositor->g_hw;
		/*use linear gradient*/
		if (num_col==2) {
			grad = g_hw->new_stencil(g_hw, M4StencilLinearGradient);
			if (ils2D->colorIndex.count) {
				col = color->color.vals[ils2D->colorIndex.vals[col_ind]];
				linear[0] = MAKE_ARGB_FLOAT(alpha, col.red, col.green, col.blue);
				col = color->color.vals[ils2D->colorIndex.vals[col_ind+1]];
				linear[1] = MAKE_ARGB_FLOAT(alpha, col.red, col.green, col.blue);
			} else if (ils2D->coordIndex.count) {
				col = color->color.vals[ils2D->coordIndex.vals[col_ind]];
				linear[0] = MAKE_ARGB_FLOAT(alpha, col.red, col.green, col.blue);
				col = color->color.vals[ils2D->coordIndex.vals[col_ind+1]];
				linear[1] = MAKE_ARGB_FLOAT(alpha, col.red, col.green, col.blue);
			} else {
				col = color->color.vals[col_ind];
				linear[0] = MAKE_ARGB_FLOAT(alpha, col.red, col.green, col.blue);
				col = color->color.vals[col_ind+1];
				linear[1] = MAKE_ARGB_FLOAT(alpha, col.red, col.green, col.blue);
			}
			g_hw->set_linear_gradient(grad, start.x, start.y, end.x, end.y, linear[0], linear[1]);
		} else {
			grad = g_hw->new_stencil(g_hw, M4StencilVertexGradient);
			if (grad) {
				g_hw->set_vertex_path(grad, path);

				colors = malloc(sizeof(u32) * num_col);
				for (j=0; j<num_col; j++) {
					if (ils2D->colorIndex.count>0) {
						col = color->color.vals[ils2D->colorIndex.vals[col_ind+j]];
					} else if (ils2D->coordIndex.count) {
						col = color->color.vals[ils2D->coordIndex.vals[col_ind+j]];
					} else {
						col = color->color.vals[col_ind+j];
					}
					colors[j] = MAKE_ARGB_FLOAT(alpha, col.red, col.green, col.blue);
				}
				g_hw->set_vertex_colors(grad, colors, num_col);
				free(colors);
			}
		}
		g_hw->stencil_set_matrix(grad, &ctx->transform);
		VS2D_DrawPath(ctx->surface, path, ctx, NULL, grad);
		if (grad) g_hw->delete_stencil(grad);

		i ++;
		col_ind += num_col + 1;
		if (i >= ils2D->coordIndex.count) break;
		ctx->path_stroke = 0;
	}
	m4_path_delete(path);

}
コード例 #5
0
ファイル: drawable.c プロジェクト: DmitrySigaev/DSMedia
/*default rendering routine*/
static void drawable_draw(DrawableContext *ctx) 
{
	VS2D_TexturePath(ctx->surface, ctx->node->path, ctx);
	VS2D_DrawPath(ctx->surface, ctx->node->path, ctx, NULL, NULL);
}