[Bf-blender-cvs] [7f21913] master: Disable scope updates in texture and image paint modes.

Lukas Tönne noreply at git.blender.org
Tue Jan 20 09:53:27 CET 2015


Commit: 7f219137cf13003143f5d671b6c59bc500b53f75
Author: Lukas Tönne
Date:   Mon Jan 12 14:21:23 2015 +0100
Branches: master
https://developer.blender.org/rB7f219137cf13003143f5d671b6c59bc500b53f75

Disable scope updates in texture and image paint modes.

Scope update is very slow for high resolutions, and currently blocks
the UI thread(!). This is especially terrible in paint modes, where
each stroke causes a scope update and unacceptable freezing.

The scopes update method tries to avoid this somewhat by skipping if the
toolbar is disabled, but this doesn't help when painting where brush
tools etc. are frequently needed. It's also a bad-level poll, with the
core system accessing a UI element.

Eventually scope updates should become a low-priority background job,
as well as becoming threaded. Until then this polling provides a usable
workaround to the most outrageous cases.

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

M	release/scripts/startup/bl_ui/space_image.py
M	source/blender/editors/include/ED_image.h
M	source/blender/editors/space_image/image_edit.c
M	source/blender/editors/space_image/space_image.c
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index a1da262..a302dab 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -1041,18 +1041,26 @@ class IMAGE_PT_tools_mask(MASK_PT_tools, Panel):
 
 # --- end mask ---
 
-
-class IMAGE_PT_view_histogram(Panel):
+class ImageScopesPanel():
+    @classmethod
+    def poll(cls, context):
+        sima = context.space_data
+        if not (sima and sima.image):
+            return False
+        # scopes are not updated in paint modes, hide
+        if sima.mode in {'PAINT'}:
+            return False
+        ob = context.active_object
+        if ob and ob.mode in {'TEXTURE_PAINT'}:
+            return False
+        return True
+
+class IMAGE_PT_view_histogram(ImageScopesPanel, Panel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'TOOLS'
     bl_label = "Histogram"
     bl_category = "Scopes"
 
-    @classmethod
-    def poll(cls, context):
-        sima = context.space_data
-        return (sima and sima.image)
-
     def draw(self, context):
         layout = self.layout
 
@@ -1065,17 +1073,12 @@ class IMAGE_PT_view_histogram(Panel):
         row.prop(hist, "show_line", text="")
 
 
-class IMAGE_PT_view_waveform(Panel):
+class IMAGE_PT_view_waveform(ImageScopesPanel, Panel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'TOOLS'
     bl_label = "Waveform"
     bl_category = "Scopes"
 
-    @classmethod
-    def poll(cls, context):
-        sima = context.space_data
-        return (sima and sima.image)
-
     def draw(self, context):
         layout = self.layout
 
@@ -1087,17 +1090,12 @@ class IMAGE_PT_view_waveform(Panel):
         row.prop(sima.scopes, "waveform_mode", text="")
 
 
-class IMAGE_PT_view_vectorscope(Panel):
+class IMAGE_PT_view_vectorscope(ImageScopesPanel, Panel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'TOOLS'
     bl_label = "Vectorscope"
     bl_category = "Scopes"
 
-    @classmethod
-    def poll(cls, context):
-        sima = context.space_data
-        return (sima and sima.image)
-
     def draw(self, context):
         layout = self.layout
 
@@ -1106,17 +1104,12 @@ class IMAGE_PT_view_vectorscope(Panel):
         layout.prop(sima.scopes, "vectorscope_alpha")
 
 
-class IMAGE_PT_sample_line(Panel):
+class IMAGE_PT_sample_line(ImageScopesPanel, Panel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'TOOLS'
     bl_label = "Sample Line"
     bl_category = "Scopes"
 
-    @classmethod
-    def poll(cls, context):
-        sima = context.space_data
-        return (sima and sima.image)
-
     def draw(self, context):
         layout = self.layout
 
@@ -1130,17 +1123,12 @@ class IMAGE_PT_sample_line(Panel):
         row.prop(hist, "show_line", text="")
 
 
-class IMAGE_PT_scope_sample(Panel):
+class IMAGE_PT_scope_sample(ImageScopesPanel, Panel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'TOOLS'
     bl_label = "Scope Samples"
     bl_category = "Scopes"
 
-    @classmethod
-    def poll(cls, context):
-        sima = context.space_data
-        return sima
-
     def draw(self, context):
         layout = self.layout
 
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index 1188ecd..704876e 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -35,6 +35,7 @@ struct Main;
 struct bContext;
 struct Image;
 struct ImageUser;
+struct ImBuf;
 struct ToolSettings;
 struct uiBlock;
 struct wmWindowManager;
@@ -58,6 +59,8 @@ void ED_space_image_get_aspect(struct SpaceImage *sima, float *aspx, float *aspy
 void ED_space_image_get_zoom(struct SpaceImage *sima, struct ARegion *ar, float *zoomx, float *zoomy);
 void ED_space_image_get_uv_aspect(struct SpaceImage *sima, float *aspx, float *aspy);
 
+void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *sima, struct ImBuf *ibuf, bool use_view_settings);
+
 void ED_space_image_paint_update(struct wmWindowManager *wm, struct ToolSettings *settings);
 void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct ToolSettings *settings);
 
diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c
index 757059e..8e2c6b9 100644
--- a/source/blender/editors/space_image/image_edit.c
+++ b/source/blender/editors/space_image/image_edit.c
@@ -35,6 +35,7 @@
 
 #include "BLI_rect.h"
 
+#include "BKE_colortools.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_image.h"
@@ -290,6 +291,20 @@ void ED_image_point_pos__reverse(SpaceImage *sima, ARegion *ar, const float co[2
 	r_co[1] = (co[1] * height * zoomy) + (float)sy;
 }
 
+void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *sima, struct ImBuf *ibuf, bool use_view_settings)
+{
+	Scene *scene = CTX_data_scene(C);
+	Object *ob = CTX_data_active_object(C);
+	
+	/* scope update can be expensive, don't update during paint modes */
+	if (sima->mode == SI_MODE_PAINT)
+		return;
+	if (ob && ((ob->mode & OB_MODE_TEXTURE_PAINT) != 0))
+		return;
+	
+	scopes_update(&sima->scopes, ibuf, use_view_settings ? &scene->view_settings : NULL, &scene->display_settings);
+}
+
 bool ED_space_image_show_render(SpaceImage *sima)
 {
 	return (sima->image && ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE));
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 6cf5353..af15025 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -899,9 +899,9 @@ static void image_tools_area_draw(const bContext *C, ARegion *ar)
 				BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings);
 			}
 			if (sima->image->flag & IMA_VIEW_AS_RENDER)
-				scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings);
+				ED_space_image_scopes_update(C, sima, ibuf, true);
 			else
-				scopes_update(&sima->scopes, ibuf, NULL, &scene->display_settings);
+				ED_space_image_scopes_update(C, sima, ibuf, false);
 		}
 	}
 	ED_space_image_release_buffer(sima, ibuf, lock);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 58476c4..8572d2f 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -791,15 +791,16 @@ static void rna_SpaceImageEditor_cursor_location_set(PointerRNA *ptr, const floa
 	}
 }
 
-static void rna_SpaceImageEditor_scopes_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
+static void rna_SpaceImageEditor_scopes_update(struct bContext *C, struct PointerRNA *ptr)
 {
+	Scene *scene = CTX_data_scene(C);
 	SpaceImage *sima = (SpaceImage *)ptr->data;
 	ImBuf *ibuf;
 	void *lock;
 	
 	ibuf = ED_space_image_acquire_buffer(sima, &lock);
 	if (ibuf) {
-		scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings);
+		ED_space_image_scopes_update(C, sima, ibuf, true);
 		WM_main_add_notifier(NC_IMAGE, sima->image);
 	}
 	ED_space_image_release_buffer(sima, ibuf, lock);
@@ -2366,6 +2367,7 @@ static void rna_def_space_image(BlenderRNA *brna)
 	RNA_def_property_pointer_sdna(prop, NULL, "scopes");
 	RNA_def_property_struct_type(prop, "Scopes");
 	RNA_def_property_ui_text(prop, "Scopes", "Scopes to visualize image statistics");
+	RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_scopes_update");
 
 	prop = RNA_def_property(srna, "use_image_pin", PROP_BOOLEAN, PROP_NONE);




More information about the Bf-blender-cvs mailing list