Example #1
0
void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, rcti *rect)
{
  if (idp) {
    wmWindowManager *wm = CTX_wm_manager(C);
    ScrArea *sa = CTX_wm_area(C);
    ID *id = (ID *)idp;
    ID *parent = (ID *)parentp;
    MTex *slot = (MTex *)slotp;
    SpaceProperties *sbuts = CTX_wm_space_properties(C);
    ShaderPreview *sp = WM_jobs_customdata(wm, sa);
    rcti newrect;
    int ok;
    int newx = BLI_rcti_size_x(rect);
    int newy = BLI_rcti_size_y(rect);

    newrect.xmin = rect->xmin;
    newrect.xmax = rect->xmin;
    newrect.ymin = rect->ymin;
    newrect.ymax = rect->ymin;

    if (parent) {
      ok = ed_preview_draw_rect(sa, 1, 1, rect, &newrect);
      ok &= ed_preview_draw_rect(sa, 1, 0, rect, &newrect);
    }
    else {
      ok = ed_preview_draw_rect(sa, 0, 0, rect, &newrect);
    }

    if (ok) {
      *rect = newrect;
    }

    /* start a new preview render job if signaled through sbuts->preview,
     * if no render result was found and no preview render job is running,
     * or if the job is running and the size of preview changed */
    if ((sbuts != NULL && sbuts->preview) ||
        (!ok && !WM_jobs_test(wm, sa, WM_JOB_TYPE_RENDER_PREVIEW)) ||
        (sp && (ABS(sp->sizex - newx) >= 2 || ABS(sp->sizey - newy) > 2))) {
      if (sbuts != NULL) {
        sbuts->preview = 0;
      }
      ED_preview_shader_job(C, sa, id, parent, slot, newx, newy, PR_BUTS_RENDER);
    }
  }
}
Example #2
0
void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, rcti *rect)
{
	if(idp) {
		ScrArea *sa= CTX_wm_area(C);
		Scene *sce = CTX_data_scene(C);
		ID *id = (ID *)idp;
		ID *parent= (ID *)parentp;
		MTex *slot= (MTex *)slotp;
		SpaceButs *sbuts= sa->spacedata.first;
		rcti newrect;
		int ok;
		int newx= rect->xmax-rect->xmin, newy= rect->ymax-rect->ymin;

		newrect.xmin= rect->xmin;
		newrect.xmax= rect->xmin;
		newrect.ymin= rect->ymin;
		newrect.ymax= rect->ymin;

		if(parent) {
			ok = ed_preview_draw_rect(sa, sce, id, 1, 1, rect, &newrect);
			ok &= ed_preview_draw_rect(sa, sce, parent, 1, 0, rect, &newrect);
		}
		else
			ok = ed_preview_draw_rect(sa, sce, id, 0, 0, rect, &newrect);

		if(ok)
			*rect= newrect;

		/* check for spacetype... */
		if(sbuts->spacetype==SPACE_BUTS && sbuts->preview) {
			sbuts->preview= 0;
			ok= 0;
		}
	
		if(ok==0) {
			ED_preview_shader_job(C, sa, id, parent, slot, newx, newy, PR_BUTS_RENDER);
		}
	}	
}
Example #3
0
void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, rcti *rect)
{
	if (idp) {
		wmWindowManager *wm = CTX_wm_manager(C);
		ScrArea *sa = CTX_wm_area(C);
		ID *id = (ID *)idp;
		ID *parent = (ID *)parentp;
		MTex *slot = (MTex *)slotp;
		SpaceButs *sbuts = sa->spacedata.first;
		rcti newrect;
		int ok;
		int newx = BLI_rcti_size_x(rect);
		int newy = BLI_rcti_size_y(rect);

		newrect.xmin = rect->xmin;
		newrect.xmax = rect->xmin;
		newrect.ymin = rect->ymin;
		newrect.ymax = rect->ymin;

		if (parent) {
			ok = ed_preview_draw_rect(sa, 1, 1, rect, &newrect);
			ok &= ed_preview_draw_rect(sa, 1, 0, rect, &newrect);
		}
		else
			ok = ed_preview_draw_rect(sa, 0, 0, rect, &newrect);

		if (ok)
			*rect = newrect;

		/* start a new preview render job if signalled through sbuts->preview,
		 * or if no render result was found and no preview render job is running */
		if ((sbuts->spacetype == SPACE_BUTS && sbuts->preview) ||
		    (!ok && !WM_jobs_test(wm, sa, WM_JOB_TYPE_RENDER_PREVIEW)))
		{
			sbuts->preview = 0;
			ED_preview_shader_job(C, sa, id, parent, slot, newx, newy, PR_BUTS_RENDER);
		}
	}
}