ED_view3d_draw_offscreen_imbuf_simple and ED_view3d_draw_offscreen_imbuf now accept the imbuf flag so they can get the float buffer from opengl directly.
This commit is contained in:
@@ -276,7 +276,7 @@ struct Sequence *sequencer_add_sound_strip(struct bContext *C, ListBase *seqbase
|
||||
struct Sequence *sequencer_add_movie_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
|
||||
|
||||
/* view3d draw callback, run when not in background view */
|
||||
typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, int, int, int);
|
||||
typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, int, int, unsigned int, int);
|
||||
extern SequencerDrawView sequencer_view3d_cb;
|
||||
|
||||
/* copy/paste */
|
||||
|
||||
@@ -1852,7 +1852,7 @@ static ImBuf * seq_render_scene_strip_impl(
|
||||
if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (seq->scene == scene || have_seq==0) && seq->scene->camera) {
|
||||
/* opengl offscreen render */
|
||||
scene_update_for_newframe(bmain, seq->scene, seq->scene->lay);
|
||||
ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty,
|
||||
ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, IB_rect,
|
||||
scene->r.seq_prev_type);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -160,8 +160,8 @@ int ED_view3d_context_activate(struct bContext *C);
|
||||
void ED_view3d_draw_offscreen(struct Scene *scene, struct View3D *v3d, struct ARegion *ar,
|
||||
int winx, int winy, float viewmat[][4], float winmat[][4]);
|
||||
|
||||
struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey);
|
||||
struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height, int drawtype);
|
||||
struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag);
|
||||
struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height, unsigned int flag, int drawtype);
|
||||
|
||||
void view3d_clipping_local(struct RegionView3D *rv3d, float mat[][4]);
|
||||
|
||||
|
||||
@@ -144,12 +144,8 @@ static void screen_opengl_render_apply(OGLRender *oglrender)
|
||||
GPU_offscreen_unbind(oglrender->ofs); /* unbind */
|
||||
}
|
||||
else {
|
||||
ImBuf *ibuf_view= ED_view3d_draw_offscreen_imbuf_simple(scene, oglrender->sizex, oglrender->sizey, OB_SOLID);
|
||||
ibuf_view->profile = IB_PROFILE_NONE; /* ensures no conversion!, see note above */
|
||||
IMB_float_from_rect(ibuf_view);
|
||||
|
||||
ImBuf *ibuf_view= ED_view3d_draw_offscreen_imbuf_simple(scene, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID);
|
||||
memcpy(rr->rectf, ibuf_view->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey);
|
||||
|
||||
IMB_freeImBuf(ibuf_view);
|
||||
}
|
||||
|
||||
|
||||
@@ -5514,7 +5514,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
|
||||
if(w > maxsize) w= maxsize;
|
||||
if(h > maxsize) h= maxsize;
|
||||
|
||||
ibuf= ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h);
|
||||
ibuf= ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect);
|
||||
image= BKE_add_image_imbuf(ibuf);
|
||||
|
||||
if(image) {
|
||||
|
||||
@@ -2115,7 +2115,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx,
|
||||
}
|
||||
|
||||
/* utility func for ED_view3d_draw_offscreen */
|
||||
ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey)
|
||||
ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey, unsigned int flag)
|
||||
{
|
||||
RegionView3D *rv3d= ar->regiondata;
|
||||
ImBuf *ibuf;
|
||||
@@ -2143,9 +2143,13 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in
|
||||
}
|
||||
|
||||
/* read in pixels & stamp */
|
||||
ibuf= IMB_allocImBuf(sizex, sizey, 24, IB_rect, 0);
|
||||
glReadPixels(0, 0, sizex, sizey, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
|
||||
ibuf= IMB_allocImBuf(sizex, sizey, 32, flag, 0);
|
||||
|
||||
if(ibuf->rect_float)
|
||||
glReadPixels(0, 0, sizex, sizey, GL_RGBA, GL_FLOAT, ibuf->rect_float);
|
||||
else if(ibuf->rect)
|
||||
glReadPixels(0, 0, sizex, sizey, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
|
||||
|
||||
//if((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW))
|
||||
// BKE_stamp_buf(scene, NULL, rr->rectf, rr->rectx, rr->recty, 4);
|
||||
|
||||
@@ -2153,11 +2157,14 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in
|
||||
GPU_offscreen_unbind(ofs);
|
||||
GPU_offscreen_free(ofs);
|
||||
|
||||
if(ibuf->rect_float && ibuf->rect)
|
||||
IMB_rect_from_float(ibuf);
|
||||
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
/* creates own 3d views, used by the sequencer */
|
||||
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height, int drawtype)
|
||||
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height, unsigned int flag, int drawtype)
|
||||
{
|
||||
View3D v3d;
|
||||
ARegion ar;
|
||||
@@ -2192,7 +2199,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height
|
||||
mul_m4_m4m4(rv3d.persmat, rv3d.viewmat, rv3d.winmat);
|
||||
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
|
||||
|
||||
return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height);
|
||||
return ED_view3d_draw_offscreen_imbuf(scene, &v3d, &ar, width, height, flag);
|
||||
|
||||
// seq_view3d_cb(scene, cfra, render_size, seqrectx, seqrecty);
|
||||
}
|
||||
|
||||
@@ -4704,8 +4704,6 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("could not find function %s in %s to execute callback.\n", RNA_function_identifier(func), RNA_struct_identifier(ptr->type));
|
||||
|
||||
bpy_context_set(C, &gilstate);
|
||||
|
||||
if (!is_static) {
|
||||
|
||||
@@ -526,7 +526,7 @@ static ImBuf *blend_file_thumb(const char *path, Scene *scene, int **thumb_pt)
|
||||
return NULL;
|
||||
|
||||
/* gets scaled to BLEN_THUMB_SIZE */
|
||||
ibuf= ED_view3d_draw_offscreen_imbuf_simple(scene, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, OB_SOLID);
|
||||
ibuf= ED_view3d_draw_offscreen_imbuf_simple(scene, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, IB_rect, OB_SOLID);
|
||||
|
||||
if(ibuf) {
|
||||
float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp);
|
||||
|
||||
Reference in New Issue
Block a user