Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-11-24 13:43:16 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-11-27 14:11:56 +0300
commit37fc23dd9e7738de7187e889f058cda845544ffb (patch)
treeb1423676fcc8f2cc07fdeb8125152e4d7d105b6a /source/blender/editors
parentff9cf0664529db88bd2ea6e13dde6f002054c745 (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/editors')
-rw-r--r--source/blender/editors/include/ED_view3d.h19
-rw-r--r--source/blender/editors/render/render_opengl.c13
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c25
4 files changed, 38 insertions, 21 deletions
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 85fb0ee4447..0a87360e58d 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -367,15 +367,26 @@ void ED_view3d_draw_setup_view(
struct wmWindow *win, struct Scene *scene, struct ARegion *ar, struct View3D *v3d,
float viewmat[4][4], float winmat[4][4], const struct rcti *rect);
+enum {
+ V3D_OFSDRAW_NONE = (0),
+
+ V3D_OFSDRAW_USE_BACKGROUND = (1 << 0),
+ V3D_OFSDRAW_USE_FULL_SAMPLE = (1 << 1),
+
+ /* Only works with ED_view3d_draw_offscreen_imbuf_simple(). */
+ V3D_OFSDRAW_USE_GPENCIL = (1 << 2),
+ V3D_OFSDRAW_USE_SOLID_TEX = (1 << 2),
+};
+
struct ImBuf *ED_view3d_draw_offscreen_imbuf(
struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey,
- unsigned int flag, bool draw_background,
- int alpha_mode, int samples, bool full_samples, const char *viewname,
+ unsigned int flag, unsigned int draw_flags,
+ int alpha_mode, int samples, const char *viewname,
struct GPUFX *fx, struct GPUOffScreen *ofs, char err_out[256]);
struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
struct Scene *scene, struct Object *camera, int width, int height,
- unsigned int flag, int drawtype, bool use_solid_tex, bool use_gpencil, bool draw_background,
- int alpha_mode, int samples, bool full_samples, const char *viewname,
+ 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]);
struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]);
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index a27026878e1..a2d34ffefa8 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -353,11 +353,15 @@ static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr)
ImBuf *ibuf_view;
const int alpha_mode = (draw_sky) ? R_ADDSKY : R_ALPHAPREMUL;
+ unsigned int draw_flags = V3D_OFSDRAW_NONE;
+ draw_flags |= (oglrender->ofs_full_samples) ? V3D_OFSDRAW_USE_FULL_SAMPLE : 0;
+
if (view_context) {
+ draw_flags |= (draw_bgpic) ? V3D_OFSDRAW_USE_BACKGROUND : 0;
+
ibuf_view = ED_view3d_draw_offscreen_imbuf(
scene, v3d, ar, sizex, sizey,
- IB_rect, draw_bgpic,
- alpha_mode, oglrender->ofs_samples, oglrender->ofs_full_samples, viewname,
+ IB_rect, draw_flags, alpha_mode, oglrender->ofs_samples, viewname,
oglrender->fx, oglrender->ofs, err_out);
/* for stamp only */
@@ -366,10 +370,11 @@ static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr)
}
}
else {
+ draw_flags |= (V3D_OFSDRAW_USE_GPENCIL | V3D_OFSDRAW_USE_BACKGROUND);
ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(
scene, scene->camera, oglrender->sizex, oglrender->sizey,
- IB_rect, OB_SOLID, false, true, true,
- alpha_mode, oglrender->ofs_samples, oglrender->ofs_full_samples, viewname,
+ IB_rect, draw_flags, OB_SOLID,
+ alpha_mode, oglrender->ofs_samples, viewname,
oglrender->fx, oglrender->ofs, err_out);
camera = scene->camera;
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index ae6dbbf440c..6fa45f1932a 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -5460,7 +5460,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op)
ibuf = ED_view3d_draw_offscreen_imbuf(
scene, CTX_wm_view3d(C), CTX_wm_region(C),
- w, h, IB_rect, false, R_ALPHAPREMUL, 0, false, NULL,
+ w, h, IB_rect, V3D_OFSDRAW_NONE, R_ALPHAPREMUL, 0, NULL,
NULL, NULL, err_out);
if (!ibuf) {
/* Mostly happens when OpenGL offscreen buffer was failed to create, */
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 56508ea989a..8fd38d6a8de 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -3286,14 +3286,16 @@ void ED_view3d_draw_setup_view(
*/
ImBuf *ED_view3d_draw_offscreen_imbuf(
Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey,
- unsigned int flag, bool draw_background,
- int alpha_mode, int samples, bool full_samples, const char *viewname,
+ unsigned int flag, unsigned int draw_flags,
+ int alpha_mode, int samples, const char *viewname,
/* output vars */
GPUFX *fx, GPUOffScreen *ofs, char err_out[256])
{
RegionView3D *rv3d = ar->regiondata;
ImBuf *ibuf;
const bool draw_sky = (alpha_mode == R_ADDSKY);
+ const bool draw_background = (draw_flags & V3D_OFSDRAW_USE_BACKGROUND);
+ const bool use_full_sample = (draw_flags & V3D_OFSDRAW_USE_FULL_SAMPLE);
/* view state */
GPUFXSettings fx_settings = v3d->fx_settings;
@@ -3309,7 +3311,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
if (own_ofs) {
/* bind */
- ofs = GPU_offscreen_create(sizex, sizey, full_samples ? 0 : samples, err_out);
+ ofs = GPU_offscreen_create(sizex, sizey, use_full_sample ? 0 : samples, err_out);
if (ofs == NULL) {
return NULL;
}
@@ -3354,7 +3356,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
}
}
- if ((samples && full_samples) == 0) {
+ if ((samples && use_full_sample) == 0) {
/* Single-pass render, common case */
ED_view3d_draw_offscreen(
scene, v3d, ar, sizex, sizey, NULL, winmat,
@@ -3454,8 +3456,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(
*/
ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
Scene *scene, Object *camera, int width, int height,
- unsigned int flag, int drawtype, bool use_solid_tex, bool use_gpencil, bool draw_background,
- int alpha_mode, int samples, bool full_samples, const char *viewname,
+ unsigned int flag, unsigned int draw_flags, int drawtype,
+ int alpha_mode, int samples, const char *viewname,
GPUFX *fx, GPUOffScreen *ofs, char err_out[256])
{
View3D v3d = {NULL};
@@ -3472,13 +3474,13 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
v3d.drawtype = drawtype;
v3d.flag2 = V3D_RENDER_OVERRIDE;
- if (use_gpencil)
+ if (draw_flags & V3D_OFSDRAW_USE_GPENCIL)
v3d.flag2 |= V3D_SHOW_GPENCIL;
- if (use_solid_tex)
+ if (draw_flags & V3D_OFSDRAW_USE_SOLID_TEX)
v3d.flag2 |= V3D_SOLID_TEX;
- if (draw_background)
+ if (draw_flags & V3D_OFSDRAW_USE_BACKGROUND)
v3d.flag3 |= V3D_SHOW_WORLD;
rv3d.persp = RV3D_CAMOB;
@@ -3507,9 +3509,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
invert_m4_m4(rv3d.persinv, rv3d.viewinv);
return ED_view3d_draw_offscreen_imbuf(
- scene, &v3d, &ar, width, height, flag,
- draw_background, alpha_mode, samples, full_samples, viewname,
- fx, ofs, err_out);
+ scene, &v3d, &ar, width, height, flag, draw_flags,
+ alpha_mode, samples, viewname, fx, ofs, err_out);
}