Commit: da9e08847c535173fa5ca31487ff9d41981ebd4f
Author: Campbell Barton
Date:   Wed Feb 7 13:29:26 2018 +1100
Branches: temp-workspace-object-mode-removal
https://developer.blender.org/rBda9e08847c535173fa5ca31487ff9d41981ebd4f

Pass object mode instead of eval_ctx for brush update function

===================================================================

M       source/blender/blenkernel/BKE_paint.h
M       source/blender/blenkernel/intern/paint.c
M       source/blender/editors/interface/interface_handlers.c
M       source/blender/editors/render/render_update.c
M       source/blender/editors/sculpt_paint/paint_utils.c
M       source/blender/makesrna/intern/rna_brush.c
M       source/blender/makesrna/intern/rna_texture.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index c1f4a909b54..17f6438870c 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -94,10 +94,9 @@ typedef enum eOverlayControlFlags {
                                                     
PAINT_OVERLAY_OVERRIDE_CURSOR)
 
 void BKE_paint_invalidate_overlay_tex(
-        const struct EvaluationContext *eval_ctx, struct Scene *scene, struct 
ViewLayer *view_layer, const struct Tex *tex);
+        struct Scene *scene, struct ViewLayer *view_layer, const struct Tex 
*tex, eObjectMode object_mode);
 void BKE_paint_invalidate_cursor_overlay(
-        const struct EvaluationContext *eval_ctx,
-        struct Scene *scene, struct ViewLayer *view_layer, struct CurveMapping 
*curve);
+        struct Scene *scene, struct ViewLayer *view_layer, struct CurveMapping 
*curve, eObjectMode object_mode);
 void BKE_paint_invalidate_overlay_all(void);
 eOverlayControlFlags BKE_paint_get_overlay_flags(void);
 void BKE_paint_reset_overlay_invalid(eOverlayControlFlags flag);
diff --git a/source/blender/blenkernel/intern/paint.c 
b/source/blender/blenkernel/intern/paint.c
index 8e29457bf3c..507c43bf251 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -76,9 +76,10 @@ const char PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255};
 static eOverlayControlFlags overlay_flags = 0;
 
 void BKE_paint_invalidate_overlay_tex(
-        const EvaluationContext *eval_ctx, Scene *scene, ViewLayer 
*view_layer, const Tex *tex)
+        Scene *scene, ViewLayer *view_layer, const Tex *tex, eObjectMode 
object_mode)
 {
-       Paint *p = BKE_paint_get_active(scene, view_layer, 
eval_ctx->object_mode);
+       /* TODO/OBMODE: enumerate multiple modes */
+       Paint *p = BKE_paint_get_active(scene, view_layer, object_mode);
        Brush *br = p->brush;
 
        if (!br)
@@ -91,9 +92,10 @@ void BKE_paint_invalidate_overlay_tex(
 }
 
 void BKE_paint_invalidate_cursor_overlay(
-        const EvaluationContext *eval_ctx, Scene *scene, ViewLayer 
*view_layer, CurveMapping *curve)
+        Scene *scene, ViewLayer *view_layer, CurveMapping *curve, eObjectMode 
object_mode)
 {
-       Paint *p = BKE_paint_get_active(scene, view_layer, 
eval_ctx->object_mode);
+       /* TODO/OBMODE: enumerate multiple modes */
+       Paint *p = BKE_paint_get_active(scene, view_layer, object_mode);
        Brush *br = p->brush;
 
        if (br && br->curve == curve)
diff --git a/source/blender/editors/interface/interface_handlers.c 
b/source/blender/editors/interface/interface_handlers.c
index 23dd48ed257..3a01ff16297 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -46,6 +46,7 @@
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
+#include "DNA_workspace_types.h"
 
 #include "BLI_math.h"
 #include "BLI_listbase.h"
@@ -5232,12 +5233,11 @@ static int ui_do_but_COLOR(
                if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
                        if ((int)(but->a1) == UI_PALETTE_COLOR) {
                                if (!event->ctrl) {
-                                       EvaluationContext eval_ctx;
-                                       CTX_data_eval_ctx(C, &eval_ctx);
                                        float color[3];
+                                       const WorkSpace *workspace = 
CTX_wm_workspace(C);
                                        Scene *scene = CTX_data_scene(C);
                                        ViewLayer *view_layer = 
CTX_data_view_layer(C);
-                                       Paint *paint = 
BKE_paint_get_active(scene, view_layer, eval_ctx.object_mode);
+                                       Paint *paint = 
BKE_paint_get_active(scene, view_layer, workspace->object_mode);
                                        Brush *brush = BKE_paint_brush(paint);
 
                                        if (brush->flag & BRUSH_USE_GRADIENT) {
@@ -6154,9 +6154,6 @@ static int ui_do_but_CURVE(
        int mx, my, a;
        bool changed = false;
 
-       EvaluationContext eval_ctx;
-       CTX_data_eval_ctx(C, &eval_ctx);
-
        Scene *scene = CTX_data_scene(C);
        ViewLayer *view_layer = CTX_data_view_layer(C);
 
@@ -6273,6 +6270,7 @@ static int ui_do_but_CURVE(
                }
                else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
                        if (data->dragsel != -1) {
+                               const WorkSpace *workspace = 
CTX_wm_workspace(C);
                                CurveMapping *cumap = (CurveMapping *)but->poin;
                                CurveMap *cuma = cumap->cm + cumap->cur;
                                CurveMapPoint *cmp = cuma->curve;
@@ -6287,7 +6285,7 @@ static int ui_do_but_CURVE(
                                }
                                else {
                                        curvemapping_changed(cumap, true);  /* 
remove doubles */
-                                       
BKE_paint_invalidate_cursor_overlay(&eval_ctx, scene, view_layer, cumap);
+                                       
BKE_paint_invalidate_cursor_overlay(scene, view_layer, cumap, 
workspace->object_mode);
                                }
                        }
 
diff --git a/source/blender/editors/render/render_update.c 
b/source/blender/editors/render/render_update.c
index 66366e9f200..92f9dd9ee26 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -387,7 +387,7 @@ static int material_uses_texture(Material *ma, Tex *tex)
        return false;
 }
 
-static void texture_changed(const EvaluationContext *eval_ctx, Main *bmain, 
Tex *tex)
+static void texture_changed(Main *bmain, Tex *tex)
 {
        Material *ma;
        Lamp *la;
@@ -401,10 +401,12 @@ static void texture_changed(const EvaluationContext 
*eval_ctx, Main *bmain, Tex
        /* icons */
        BKE_icon_changed(BKE_icon_id_ensure(&tex->id));
 
+       const eObjectMode object_mode = 
WM_windows_object_mode_get(bmain->wm.first);
+
        /* paint overlays */
        for (scene = bmain->scene.first; scene; scene = scene->id.next) {
                for (view_layer = scene->view_layers.first; view_layer; 
view_layer = view_layer->next) {
-                       BKE_paint_invalidate_overlay_tex(eval_ctx, scene, 
view_layer, tex);
+                       BKE_paint_invalidate_overlay_tex(scene, view_layer, 
tex, object_mode);
                }
        }
 
@@ -506,7 +508,7 @@ static void world_changed(Main *UNUSED(bmain), World *wo)
        }
 }
 
-static void image_changed(const EvaluationContext *eval_ctx, Main *bmain, 
Image *ima)
+static void image_changed(Main *bmain, Image *ima)
 {
        Tex *tex;
 
@@ -516,7 +518,7 @@ static void image_changed(const EvaluationContext 
*eval_ctx, Main *bmain, Image
        /* textures */
        for (tex = bmain->tex.first; tex; tex = tex->id.next)
                if (tex->ima == ima)
-                       texture_changed(eval_ctx, bmain, tex);
+                       texture_changed(bmain, tex);
 }
 
 static void scene_changed(Main *bmain, Scene *scene)
@@ -552,7 +554,6 @@ void ED_render_id_flush_update(const DEGEditorUpdateContext 
*update_ctx, ID *id)
                return;
        }
        Main *bmain = update_ctx->bmain;
-       const EvaluationContext *eval_ctx = bmain->eval_ctx;  /* OBMODE/TODO 
(all visible workspace modes) */
        /* Internal ID update handlers. */
        switch (GS(id->name)) {
                case ID_MA:
@@ -560,7 +561,7 @@ void ED_render_id_flush_update(const DEGEditorUpdateContext 
*update_ctx, ID *id)
                        render_engine_flag_changed(bmain, RE_ENGINE_UPDATE_MA);
                        break;
                case ID_TE:
-                       texture_changed(eval_ctx, bmain, (Tex *)id);
+                       texture_changed(bmain, (Tex *)id);
                        break;
                case ID_WO:
                        world_changed(bmain, (World *)id);
@@ -570,7 +571,7 @@ void ED_render_id_flush_update(const DEGEditorUpdateContext 
*update_ctx, ID *id)
                        break;
                case ID_IM:
                {
-                       image_changed(eval_ctx, bmain, (Image *)id);
+                       image_changed(bmain, (Image *)id);
                        break;
                }
                case ID_SCE:
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c 
b/source/blender/editors/sculpt_paint/paint_utils.c
index 480733be994..8535bc863cf 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -565,13 +565,11 @@ static int brush_curve_preset_exec(bContext *C, 
wmOperator *op)
 {
        Brush *br = BKE_paint_brush(BKE_paint_get_active_from_context(C));
 
-       if (br) {
-               EvaluationContext eval_ctx;
-               CTX_data_eval_ctx(C, &eval_ctx);
+       if (br) {const WorkSpace *workspace = CTX_wm_workspace(C);
                Scene *scene = CTX_data_scene(C);
                ViewLayer *view_layer = CTX_data_view_layer(C);
                BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape"));
-               BKE_paint_invalidate_cursor_overlay(&eval_ctx, scene, 
view_layer, br->curve);
+               BKE_paint_invalidate_cursor_overlay(scene, view_layer, 
br->curve, workspace->object_mode);
        }
 
        return OPERATOR_FINISHED;
diff --git a/source/blender/makesrna/intern/rna_brush.c 
b/source/blender/makesrna/intern/rna_brush.c
index 1dbf25c7007..aa37c9ffa88 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -31,6 +31,7 @@
 #include "DNA_texture_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_object_types.h"
+#include "DNA_workspace_types.h"
 
 #include "BLI_math.h"
 
@@ -375,25 +376,23 @@ static void rna_Brush_update(Main *UNUSED(bmain), Scene 
*UNUSED(scene), PointerR
 
 static void rna_Brush_main_tex_update(bContext *C, PointerRNA *ptr)
 {
-       EvaluationContext eval_ctx;
-       CTX_data_eval_ctx(C, &eval_ctx);
+       const WorkSpace *workspace = CTX_wm_workspace(C);
        Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
        ViewLayer *view_layer = CTX_data_view_layer(C);
        Brush *br = (Brush *)ptr->data;
-       BKE_paint_invalidate_overlay_tex(&eval_ctx, scene, view_layer, 
br->mtex.tex);
+       BKE_paint_invalidate_overlay_tex(scene, view_layer, br->mtex.tex, 
workspace->object_mode);
        rna_Brush_update(bmain, scene, ptr);
 }
 
 static void rna_Brush_secondary_tex_update(bContext *C, PointerRNA *ptr)
 {
-       EvaluationContext eval_ctx;
-       CTX_data_eval_ctx(C, &eval_ctx);
        Main *bmain = CTX_data_main(C);
+       const WorkSpace *workspace = CTX_wm_workspace(C);
        Scene *scene = CTX_data_scene(C);
        ViewLayer *view_layer = CTX_data_view_layer(C);
        Brush *br = (Brush *)ptr->data;
-       BKE_paint_invalidate_overlay_tex(&eval_ctx, scene, view_layer, 
br->mask_mtex.tex);
+       BKE_paint_invalidate_overlay_tex(scene, view_layer, br->mask_mtex.tex, 
workspace->object_mode);
        rna_Brush_update(bmain, scene, ptr);
 }
 
@@ -455,10 +454,9 @@ static void rna_TextureSlot_brush_angle_update(bContext 
*C, PointerRNA *ptr)
        MTex *mtex = ptr->data;
        /* skip invalidation of overlay for stencil mode */
        if (mtex->mapping != MTEX_MAP_MODE_STENCIL) {
-               EvaluationContext eval_ctx;
-               CTX_data_eval_ctx(C, &eval_ctx);
+               const WorkSpace *workspace = CTX_wm_workspace(C);
                ViewLayer *view_layer = CTX_data_view_layer(C);
-               BKE_paint_invalidate_overlay_tex(&eval_ctx, scene, view_layer, 
mtex->tex);
+               BKE_paint_invalidate_overlay_tex(scene, view_layer, mtex->tex, 
workspace->o

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to