diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-24 13:43:16 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-27 14:11:56 +0300 |
commit | 37fc23dd9e7738de7187e889f058cda845544ffb (patch) | |
tree | b1423676fcc8f2cc07fdeb8125152e4d7d105b6a /source/blender/blenkernel | |
parent | ff9cf0664529db88bd2ea6e13dde6f002054c745 (diff) |
Refactor view3d offscreen drawing to avoid having multiple boolean arguments
This is fully unreadable to have lots of boolean arguments scattered across the
whole argument list. What does `false, true, true` mean in terms of behavior?
Replace those with bitfield which has advantage of having more human readable
meaning.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_sequencer.h | 17 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 17 |
2 files changed, 23 insertions, 11 deletions
diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 657e99f05d1..66325cee98e 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -421,11 +421,20 @@ struct Sequence *BKE_sequencer_add_sound_strip(struct bContext *C, ListBase *seq struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load); /* view3d draw callback, run when not in background view */ +/* NOTE: Keep in sync with V3D_OFS_* flags. */ +enum { + SEQ_OFSDRAW_NONE = (0), + SEQ_OFSDRAW_USE_BACKGROUND = (1 << 0), + SEQ_OFSDRAW_USE_FULL_SAMPLE = (1 << 1), + SEQ_OFSDRAW_USE_GPENCIL = (1 << 2), + SEQ_OFSDRAW_USE_SOLID_TEX = (1 << 2), +}; + typedef struct ImBuf *(*SequencerDrawView)( - struct Scene *, struct Object *, int, int, - unsigned int, int, bool, bool, bool, - int, int, bool, const char *, - struct GPUFX *, struct GPUOffScreen *, char[256]); + struct Scene *scene, struct Object *camera, int width, int height, + unsigned int flag, unsigned int draw_flags, int drawtype, int alpha_mode, + int samples, const char *viewname, + struct GPUFX *fx, struct GPUOffScreen *ofs, char err_out[256]); extern SequencerDrawView sequencer_view3d_cb; /* copy/paste */ diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 9b0db300e6d..592091b057f 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3295,11 +3295,17 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq if ((sequencer_view3d_cb && do_seq_gl && camera) && is_thread_main) { char err_out[256] = "unknown"; - int width = (scene->r.xsch * scene->r.size) / 100; - int height = (scene->r.ysch * scene->r.size) / 100; + const int width = (scene->r.xsch * scene->r.size) / 100; + const int height = (scene->r.ysch * scene->r.size) / 100; const bool use_background = (scene->r.alphamode == R_ADDSKY); const char *viewname = BKE_scene_multiview_render_view_name_get(&scene->r, context->view_id); + unsigned int draw_flags = SEQ_OFSDRAW_NONE; + draw_flags |= (use_gpencil) ? SEQ_OFSDRAW_USE_GPENCIL : 0; + draw_flags |= (use_background) ? SEQ_OFSDRAW_USE_BACKGROUND : 0; + draw_flags |= (context->gpu_full_samples) ? SEQ_OFSDRAW_USE_FULL_SAMPLE : 0; + draw_flags |= (context->scene->r.seq_flag & R_SEQ_SOLID_TEX) ? SEQ_OFSDRAW_USE_SOLID_TEX : 0; + /* for old scene this can be uninitialized, * should probably be added to do_versions at some point if the functionality stays */ if (context->scene->r.seq_prev_type == 0) @@ -3309,11 +3315,8 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq BKE_scene_update_for_newframe(context->eval_ctx, context->bmain, scene, scene->lay); ibuf = sequencer_view3d_cb( /* set for OpenGL render (NULL when scrubbing) */ - scene, camera, width, height, IB_rect, - context->scene->r.seq_prev_type, - (context->scene->r.seq_flag & R_SEQ_SOLID_TEX) != 0, - use_gpencil, use_background, scene->r.alphamode, - context->gpu_samples, context->gpu_full_samples, viewname, + scene, camera, width, height, IB_rect, draw_flags, context->scene->r.seq_prev_type, + scene->r.alphamode, context->gpu_samples, viewname, context->gpu_fx, context->gpu_offscreen, err_out); if (ibuf == NULL) { fprintf(stderr, "seq_render_scene_strip failed to get opengl buffer: %s\n", err_out); |