Пример #1
0
/* uses ROUNDBOX button in block to get the rect */
static int ed_preview_draw_rect(ScrArea *sa, wmWindow *win, ID *id, int split, int first, rcti *rect, rcti *newrect)
{
	Render *re;
	RenderResult rres;
	char name[32];
	const char * gamma_correct_profile=0;
	int offx=0, newx= rect->xmax-rect->xmin, newy= rect->ymax-rect->ymin;

	if (id && GS(id->name) != ID_TE) {
		/* exception: don't color manage texture previews - show the raw values */
		if (win){
			ColorSpace* cs = BCM_get_ui_colorspace(win);
			gamma_correct_profile = cs->name;
		}
	}

	if(!split || first) sprintf(name, "Preview %p", (void *)sa);
	else sprintf(name, "SecondPreview %p", (void *)sa);

	if(split) {
		if(first) {
			offx= 0;
			newx= newx/2;
		}
		else {
			offx= newx/2;
			newx= newx - newx/2;
		}
	}

	re= RE_GetRender(name);
	RE_AcquireResultImage(re, &rres);

	if(rres.rectf) {
		
		if(ABS(rres.rectx-newx)<2 && ABS(rres.recty-newy)<2) {
			newrect->xmax= MAX2(newrect->xmax, rect->xmin + rres.rectx + offx);
			newrect->ymax= MAX2(newrect->ymax, rect->ymin + rres.recty);

			glaDrawPixelsSafe_to32(rect->xmin+offx, rect->ymin, rres.rectx, rres.recty, rres.rectx, rres.rectf, gamma_correct_profile);

			RE_ReleaseResultImage(re);
			return 1;
		}
	}

	RE_ReleaseResultImage(re);
	return 0;
}
Пример #2
0
/* uses ROUNDBOX button in block to get the rect */
static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int first, rcti *rect, rcti *newrect)
{
	Render *re;
	RenderResult rres;
	char name[32];
	int do_gamma_correct=0;
	int offx=0, newx= rect->xmax-rect->xmin, newy= rect->ymax-rect->ymin;

	if (id && GS(id->name) != ID_TE) {
		/* exception: don't color manage texture previews - show the raw values */
		if (sce) do_gamma_correct = sce->r.color_mgt_flag & R_COLOR_MANAGEMENT;
	}

	if(!split || first) sprintf(name, "Preview %p", (void *)sa);
	else sprintf(name, "SecondPreview %p", (void *)sa);

	if(split) {
		if(first) {
			offx= 0;
			newx= newx/2;
		}
		else {
			offx= newx/2;
			newx= newx - newx/2;
		}
	}

	re= RE_GetRender(name);
	RE_AcquireResultImage(re, &rres);

	if(rres.rectf) {
		
		if(ABS(rres.rectx-newx)<2 && ABS(rres.recty-newy)<2) {
			newrect->xmax= MAX2(newrect->xmax, rect->xmin + rres.rectx + offx);
			newrect->ymax= MAX2(newrect->ymax, rect->ymin + rres.recty);

			glaDrawPixelsSafe_to32(rect->xmin+offx, rect->ymin, rres.rectx, rres.recty, rres.rectx, rres.rectf, do_gamma_correct);

			RE_ReleaseResultImage(re);
			return 1;
		}
	}

	RE_ReleaseResultImage(re);
	return 0;
}