Exemplo n.º 1
0
Arquivo: t-gob.c Projeto: xqlab/r3
*/	static REBSER *Flags_To_Block(REBGOB *gob)
/*
***********************************************************************/
{
    REBSER *ser;
    REBVAL *val;
    REBINT i;

    ser = Make_Block(3);

    for (i = 0; Gob_Flag_Words[i]; i += 2) {
        if (GET_GOB_FLAG(gob, Gob_Flag_Words[i+1])) {
            val = Append_Value(ser);
            Init_Word(val, Gob_Flag_Words[i]);
        }
    }

    return ser;
}
Exemplo n.º 2
0
Arquivo: t-gob.c Projeto: Oldes/r3
*/	REBSER *Gob_To_Block(REBGOB *gob)
/*
**		Used by MOLD to create a block.
**
***********************************************************************/
{
	REBSER *ser = Make_Block(10);
	REBVAL *val;
	REBVAL *val1;
	REBCNT sym;

	val = Append_Value(ser);
	Init_Word(val, SYM_OFFSET);
	VAL_SET(val, REB_SET_WORD);
	val = Append_Value(ser);
	SET_PAIR(val, GOB_X(gob), GOB_Y(gob));

	val = Append_Value(ser);
	Init_Word(val, SYM_SIZE);
	VAL_SET(val, REB_SET_WORD);
	val = Append_Value(ser);
	SET_PAIR(val, GOB_W(gob), GOB_H(gob));

	if (!GET_GOB_FLAG(gob, GOBF_OPAQUE) && GOB_ALPHA(gob) < 255) {
		val = Append_Value(ser);
		Init_Word(val, SYM_ALPHA);
		VAL_SET(val, REB_SET_WORD);
		val = Append_Value(ser);
		SET_INTEGER(val, 255 - GOB_ALPHA(gob));
	}

	if (!GOB_TYPE(gob)) return ser;

	if (GOB_CONTENT(gob)) {
		val1 = Append_Value(ser);
		val = Append_Value(ser);
		switch (GOB_TYPE(gob)) {
		case GOBT_COLOR:
			sym = SYM_COLOR;
			break;
		case GOBT_IMAGE:
			sym = SYM_IMAGE;
			break;
#ifdef HAS_WIDGET_GOB
		case GOBT_WIDGET:
			sym = SYM_WIDGET;
			break;
#endif
		case GOBT_STRING:
		case GOBT_TEXT:
			sym = SYM_TEXT;
			break;
		case GOBT_DRAW:
			sym = SYM_DRAW;
			break;
		case GOBT_EFFECT:
			sym = SYM_EFFECT;
			break;
		}
		Init_Word(val1, sym);
		VAL_SET(val1, REB_SET_WORD);
		Get_GOB_Var(gob, val1, val);
	}

	return ser;
}
Exemplo n.º 3
0
*/ void rebcmp_compose(REBCMP_CTX* ctx, REBGOB* winGob, REBGOB* gob, REBOOL only)
/*
**	Compose content of the specified gob. Main compositing function.
**
**  If the ONLY arg is TRUE then the specified gob area will be
**  rendered to the buffer at 0x0 offset.(used by TO-IMAGE)
**
***********************************************************************/
{
	REBINT max_depth = 1000; // avoid infinite loops
	REBD32 abs_x = 0;
	REBD32 abs_y = 0;
	REBD32 abs_ox;
	REBD32 abs_oy;
	REBGOB* parent_gob = gob;
	REBINT x = GOB_LOG_X_INT(gob);
	REBINT y = GOB_LOG_Y_INT(gob);
	REBINT w = GOB_LOG_W_INT(gob);
	REBINT h = GOB_LOG_H_INT(gob);
	/*
	RL_Print("Composing gob: %x (%dx%d, %dx%d) in wingob %x\n", 
			 gob,
			 (int)GOB_LOG_X(gob),
			 (int)GOB_LOG_Y(gob),
			 GOB_W_INT(gob),
			 GOB_H_INT(gob),
			 winGob);
			 */

	//reset clip region to window area
	if (ctx->Win_Region != NULL){
		XDestroyRegion(ctx->Win_Region);
	}
	ctx->Win_Region = XCreateRegion();

	//calculate absolute offset of the gob
	while (GOB_PARENT(parent_gob) && (max_depth-- > 0) && !GET_GOB_FLAG(parent_gob, GOBF_WINDOW))
	{
		abs_x += GOB_LOG_X(parent_gob);
		abs_y += GOB_LOG_Y(parent_gob);
		parent_gob = GOB_PARENT(parent_gob);
	}

	assert(max_depth > 0);

	//the offset is shifted to render given gob at offset 0x0 (used by TO-IMAGE)
	if (only){
		ctx->absOffset.x = -abs_x;
		ctx->absOffset.y = -abs_y;
		abs_x = 0;
		abs_y = 0;
	} else {
		ctx->absOffset.x = 0;
		ctx->absOffset.y = 0;
	}

	ctx->New_Clip.x = abs_x;
	ctx->New_Clip.y = abs_y;
	ctx->New_Clip.width = GOB_LOG_W_INT(gob);
	ctx->New_Clip.height = GOB_LOG_H_INT(gob);

	//handle newly added gob case
	if (!GET_GOB_STATE(gob, GOBS_NEW)){
		//calculate absolute old offset of the gob
		abs_ox = abs_x + (GOB_XO(gob) - GOB_LOG_X(gob));
		abs_oy = abs_y + (GOB_YO(gob) - GOB_LOG_Y(gob));

		//set region with old gob location and dimensions
		ctx->Old_Clip.x = abs_ox;
		ctx->Old_Clip.y = abs_oy;
		ctx->Old_Clip.width = GOB_WO_INT(gob);
		ctx->Old_Clip.height = GOB_HO_INT(gob);
		XUnionRectWithRegion(&ctx->Old_Clip, ctx->Win_Region, ctx->Win_Region);
		//RL_Print("OLD: %dx%d %dx%d\n",(REBINT)abs_ox, (REBINT)abs_oy, (REBINT)abs_ox + GOB_WO_INT(gob), (REBINT)abs_oy + GOB_HO_INT(gob));
	}
	//RL_Print("NEW: %dx%d %dx%d\n",(REBINT)abs_x, (REBINT)abs_y, (REBINT)abs_x + GOB_LOG_W_INT(gob), (REBINT)abs_y + GOB_LOG_H_INT(gob));

	//Create union of "new" and "old" gob location
	XUnionRectWithRegion(&ctx->New_Clip, ctx->Win_Region, ctx->Win_Region);
	/*
	XClipBox(ctx->Win_Region, &win_rect);
	RL_Print("Old+New, %dx%d,%dx%d\n",
			 win_rect.x,
			 win_rect.y,
			 win_rect.x + win_rect.width,
			 win_rect.y + win_rect.height);
			 */

	if (!XEmptyRegion(ctx->Win_Region))
	{
		swap_buffer(ctx);
		ctx->Window_Buffer = rebcmp_get_buffer(ctx);
		if (gob == winGob) {
			memset(ctx->Window_Buffer, 0, ctx->pixbuf_len);
		}

		//redraw gobs
		process_gobs(ctx, winGob);

		rebcmp_release_buffer(ctx);

		ctx->Window_Buffer = NULL;
	}

	//update old GOB area
	GOB_XO(gob) = GOB_LOG_X(gob);
	GOB_YO(gob) = GOB_LOG_Y(gob);
	GOB_WO(gob) = GOB_LOG_W(gob);
	GOB_HO(gob) = GOB_LOG_H(gob);
}
Exemplo n.º 4
0
*/ void rebcmp_compose(REBCMP_CTX* ctx, REBGOB* winGob, REBGOB* gob, REBOOL only)
/*
**	Compose content of the specified gob. Main compositing function.
**
**  If the ONLY arg is TRUE then the specified gob area will be
**  rendered to the buffer at 0x0 offset.(used by TO-IMAGE)
**
***********************************************************************/
{
	REBINT max_depth = 1000; // avoid infinite loops
	REBD32 abs_x = 0;
	REBD32 abs_y = 0;
	REBD32 abs_ox;
	REBD32 abs_oy;
	REBGOB* parent_gob = gob;

	//reset clip region to window area
	//------------------------------
	//Put backend specific code here
	//------------------------------

	//calculate absolute offset of the gob
	while (GOB_PARENT(parent_gob) && (max_depth-- > 0) && !GET_GOB_FLAG(parent_gob, GOBF_WINDOW))
	{
		abs_x += GOB_LOG_X(parent_gob);
		abs_y += GOB_LOG_Y(parent_gob);
		parent_gob = GOB_PARENT(parent_gob);
	}

	//the offset is shifted to render given gob at offset 0x0 (used by TO-IMAGE)
	if (only){
		ctx->absOffset.x = -abs_x;
		ctx->absOffset.y = -abs_y;
		abs_x = 0;
		abs_y = 0;
	} else {
		ctx->absOffset.x = 0;
		ctx->absOffset.y = 0;
	}

	//handle newly added gob case
	if (!GET_GOB_STATE(gob, GOBS_NEW)){
		//calculate absolute old offset of the gob
		abs_ox = abs_x + (GOB_XO(gob) - GOB_LOG_X(gob));
		abs_oy = abs_y + (GOB_YO(gob) - GOB_LOG_Y(gob));

		//set region with old gob location and dimensions
		//------------------------------
		//Put backend specific code here
		//------------------------------
	}

	//Create union of "new" and "old" gob location
	REBOOL valid_intersection;
	//------------------------------
	//Put backend specific code here
	//------------------------------

	//intersect resulting region with window clip region
	//------------------------------
	//Put backend specific code here
	//------------------------------

	if (valid_intersection)
	{
		ctx->Window_Buffer = rebcmp_get_buffer(ctx);

		//redraw gobs
		process_gobs(ctx, winGob);

		rebcmp_release_buffer(ctx);

		ctx->Window_Buffer = NULL;
	}

	//update old GOB area
	GOB_XO(gob) = GOB_LOG_X(gob);
	GOB_YO(gob) = GOB_LOG_Y(gob);
	GOB_WO(gob) = GOB_LOG_W(gob);
	GOB_HO(gob) = GOB_LOG_H(gob);
}