[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56822] trunk/blender/source/blender: Fix another cases where painting long brush strokes with small radius was slowed
Brecht Van Lommel
brechtvanlommel at pandora.be
Wed May 15 16:37:01 CEST 2013
Revision: 56822
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56822
Author: blendix
Date: 2013-05-15 14:37:01 +0000 (Wed, 15 May 2013)
Log Message:
-----------
Fix another cases where painting long brush strokes with small radius was slowed
down, this time by the operator properties getting converted to a string for
display in the info window.
With 1000+ stroke points this can get slow, and takes up too much space anyway,
so now it's (somewhat arbitrarily) limited to printing only 10 points.
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/RNA_access.h
trunk/blender/source/blender/makesrna/intern/rna_access.c
trunk/blender/source/blender/python/intern/bpy_rna.c
trunk/blender/source/blender/windowmanager/intern/wm_operators.c
Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h 2013-05-15 14:36:58 UTC (rev 56821)
+++ trunk/blender/source/blender/makesrna/RNA_access.h 2013-05-15 14:37:01 UTC (rev 56822)
@@ -1031,15 +1031,18 @@
void RNA_struct_property_unset(PointerRNA *ptr, const char *identifier);
/* python compatible string representation of this property, (must be freed!) */
-char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index);
+char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index, int max_prop_length);
char *RNA_pointer_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop_ptr, PointerRNA *ptr_prop);
char *RNA_pointer_as_string_keywords_ex(struct bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
const short skip_optional_value, const short all_args,
+ const int max_prop_length,
PropertyRNA *iterprop);
char *RNA_pointer_as_string_keywords(struct bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
- const short skip_optional_value, const short all_args);
+ const short skip_optional_value, const short all_args,
+ const int max_prop_length);
char *RNA_function_as_string_keywords(struct bContext *C, FunctionRNA *func, PointerRNA *ptr_default,
- const short as_function, const short all_args);
+ const short as_function, const short all_args,
+ const int max_prop_length);
/* Function */
Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c 2013-05-15 14:36:58 UTC (rev 56821)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c 2013-05-15 14:37:01 UTC (rev 56822)
@@ -4983,7 +4983,7 @@
BLI_dynstr_append(dynstr, ", ");
first_time = 0;
- cstring = RNA_property_as_string(C, ptr, prop, -1);
+ cstring = RNA_property_as_string(C, ptr, prop, -1, INT_MAX);
BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring);
MEM_freeN(cstring);
}
@@ -5023,6 +5023,7 @@
/* context and ptr_default can be NULL */
char *RNA_pointer_as_string_keywords_ex(bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
const short as_function, const short all_args,
+ const int max_prop_length,
PropertyRNA *iterprop)
{
const char *arg_name = NULL;
@@ -5071,7 +5072,7 @@
}
}
else {
- buf = RNA_property_as_string(C, ptr, prop, -1);
+ buf = RNA_property_as_string(C, ptr, prop, -1, max_prop_length);
}
ok = TRUE;
@@ -5082,7 +5083,7 @@
prop_default = RNA_struct_find_property(ptr_default, arg_name);
if (prop_default) {
- buf_default = RNA_property_as_string(C, ptr_default, prop_default, -1);
+ buf_default = RNA_property_as_string(C, ptr_default, prop_default, -1, max_prop_length);
if (strcmp(buf, buf_default) == 0)
ok = FALSE; /* values match, don't bother printing */
@@ -5106,18 +5107,20 @@
}
char *RNA_pointer_as_string_keywords(bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
- const short as_function, const short all_args)
+ const short as_function, const short all_args,
+ const int max_prop_length)
{
PropertyRNA *iterprop;
iterprop = RNA_struct_iterator_property(ptr->type);
return RNA_pointer_as_string_keywords_ex(C, ptr, ptr_default, as_function, all_args,
- iterprop);
+ max_prop_length, iterprop);
}
char *RNA_function_as_string_keywords(bContext *C, FunctionRNA *func, PointerRNA *ptr_default,
- const short as_function, const short all_args)
+ const short as_function, const short all_args,
+ const int max_prop_length)
{
PointerRNA funcptr;
PropertyRNA *iterprop;
@@ -5129,7 +5132,7 @@
RNA_struct_iterator_property(funcptr.type);
return RNA_pointer_as_string_keywords_ex(C, &funcptr, ptr_default, as_function, all_args,
- iterprop);
+ max_prop_length, iterprop);
}
static const char *bool_as_py_string(const int var)
@@ -5137,7 +5140,7 @@
return var ? "True" : "False";
}
-char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index)
+char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index, int max_prop_length)
{
int type = RNA_property_type(prop);
int len = RNA_property_array_length(ptr, prop);
@@ -5277,18 +5280,18 @@
}
case PROP_COLLECTION:
{
- int first_time = 1;
+ int i = 0;
CollectionPropertyIterator collect_iter;
BLI_dynstr_append(dynstr, "[");
- for (RNA_property_collection_begin(ptr, prop, &collect_iter); collect_iter.valid;
- RNA_property_collection_next(&collect_iter))
+ for (RNA_property_collection_begin(ptr, prop, &collect_iter);
+ (i < max_prop_length) && collect_iter.valid;
+ RNA_property_collection_next(&collect_iter), i++)
{
PointerRNA itemptr = collect_iter.ptr;
- if (first_time == 0)
+ if (i != 0)
BLI_dynstr_append(dynstr, ", ");
- first_time = 0;
/* now get every prop of the collection */
cstring = RNA_pointer_as_string(C, ptr, prop, &itemptr);
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2013-05-15 14:36:58 UTC (rev 56821)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2013-05-15 14:37:01 UTC (rev 56822)
@@ -5318,7 +5318,7 @@
PyObject *ret;
char *args;
- args = RNA_function_as_string_keywords(NULL, self->func, NULL, true, true);
+ args = RNA_function_as_string_keywords(NULL, self->func, NULL, true, true, INT_MAX);
ret = PyUnicode_FromFormat("%.200s.%.200s(%.200s)\n%s",
RNA_struct_identifier(self->ptr.type),
Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2013-05-15 14:36:58 UTC (rev 56821)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c 2013-05-15 14:37:01 UTC (rev 56822)
@@ -541,6 +541,9 @@
char *cstring;
char *cstring_args;
+ /* arbitrary, but can get huge string with stroke painting otherwise */
+ int max_prop_length = 10;
+
/* only to get the orginal props for comparisons */
PointerRNA opptr_default;
@@ -554,7 +557,8 @@
WM_operator_py_idname(idname_py, ot->idname);
BLI_dynstr_appendf(dynstr, "bpy.ops.%s(", idname_py);
- cstring_args = RNA_pointer_as_string_keywords(C, opptr, &opptr_default, FALSE, all_args);
+ cstring_args = RNA_pointer_as_string_keywords(C, opptr, &opptr_default, FALSE,
+ all_args, max_prop_length);
BLI_dynstr_append(dynstr, cstring_args);
MEM_freeN(cstring_args);
@@ -737,7 +741,7 @@
return NULL;
}
- rhs = RNA_property_as_string(C, ptr, prop, index);
+ rhs = RNA_property_as_string(C, ptr, prop, index, INT_MAX);
if (!rhs) {
MEM_freeN(lhs);
return NULL;
More information about the Bf-blender-cvs
mailing list