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:
authorCampbell Barton <ideasman42@gmail.com>2009-09-22 13:12:39 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-09-22 13:12:39 +0400
commit92145d5950b3c069418a097055cc8ae0e5710423 (patch)
treef64de73f354a7d76edcb608e6b26476dc929d280
parent3c8d34b94e8c615c0349a01e3ea5e6381feaeefa (diff)
Changes to allow python to do redraws through the timer operator, a reliable way to test the overhead of the python api (printed to the consoel on exit).
- rename WM_OT_ten_timer to WM_OT_redraw_timer - added iterations argument to run more then 10 times (10 is default still) - use report api rather then always calling a popup directly. - added a new test that draws every region without swapping. - dont show the info popup when operators are called from python. - operators called from python now print reports, useful with the interactive console. eg. >>> bpy.ops.wm.redraw_timer(type='DRAW_WIN', iterations=300) Info: 300 x Draw Window: 4168.56 ms, average: 13.8952
-rw-r--r--source/blender/blenkernel/intern/report.c2
-rw-r--r--source/blender/makesrna/intern/rna_sequence.c1
-rw-r--r--source/blender/python/intern/bpy_operator.c10
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c4
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c75
5 files changed, 66 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c
index 391adfb762a..e524359d2bc 100644
--- a/source/blender/blenkernel/intern/report.c
+++ b/source/blender/blenkernel/intern/report.c
@@ -230,7 +230,7 @@ char *BKE_reports_string(ReportList *reports, ReportType level)
DynStr *ds;
char *cstring;
- if(!reports)
+ if(!reports || !reports->list.first)
return NULL;
ds= BLI_dynstr_new();
diff --git a/source/blender/makesrna/intern/rna_sequence.c b/source/blender/makesrna/intern/rna_sequence.c
index b1ac02ae17f..51e81d6dd3a 100644
--- a/source/blender/makesrna/intern/rna_sequence.c
+++ b/source/blender/makesrna/intern/rna_sequence.c
@@ -520,6 +520,7 @@ static void rna_def_sequence(BlenderRNA *brna)
prop= RNA_def_property(srna, "channel", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "machine");
+ RNA_def_property_range(prop, 0, MAXSEQ-1);
RNA_def_property_ui_text(prop, "Channel", "Y position of the sequence strip.");
RNA_def_property_int_funcs(prop, NULL, "rna_SequenceEditor_channel_set",NULL); // overlap test
RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL);
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index f2e2dd77e6d..301204d3e2b 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -89,6 +89,16 @@ static PyObject *pyop_call( PyObject * self, PyObject * args)
if(BPy_reports_to_error(reports))
error_val = -1;
+ /* operator output is nice to have in the terminal/console too */
+ if(reports->list.first) {
+ char *report_str= BKE_reports_string(reports, 0); /* all reports */
+
+ if(report_str) {
+ PySys_WriteStdout(report_str);
+ MEM_freeN(report_str);
+ }
+ }
+
BKE_reports_clear(reports);
if ((reports->flag & RPT_FREE) == 0)
{
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 503eb5a1b9a..03e13329bbd 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -415,7 +415,9 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, P
else
printf("invalid operator call %s\n", ot->idname); /* debug, important to leave a while, should never happen */
- if(!(retval & OPERATOR_RUNNING_MODAL)) {
+ /* Note, if the report is given as an argument then assume the caller will deal with displaying them
+ * currently python only uses this */
+ if(!(retval & OPERATOR_RUNNING_MODAL) && reports==NULL) {
if(op->reports->list.first) /* only show the report if the report list was not given in the function */
uiPupMenuReports(C, op->reports);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 76c15043b89..0b5c2944624 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1979,17 +1979,19 @@ void WM_OT_radial_control_partial(wmOperatorType *ot)
/* uses no type defines, fully local testing function anyway... ;) */
-static int ten_timer_exec(bContext *C, wmOperator *op)
+static int redraw_timer_exec(bContext *C, wmOperator *op)
{
ARegion *ar= CTX_wm_region(C);
double stime= PIL_check_seconds_timer();
int type = RNA_int_get(op->ptr, "type");
- int a, time;
- char tmpstr[128];
+ int iter = RNA_int_get(op->ptr, "iterations");
+ int a;
+ float time;
+ char *infostr= "";
WM_cursor_wait(1);
-
- for(a=0; a<10; a++) {
+
+ for(a=0; a<iter; a++) {
if (type==0) {
ED_region_do_draw(C, ar);
}
@@ -2005,13 +2007,35 @@ static int ten_timer_exec(bContext *C, wmOperator *op)
wmWindow *win= CTX_wm_window(C);
ScrArea *sa;
+ ScrArea *sa_back= CTX_wm_area(C);
+ ARegion *ar_back= CTX_wm_region(C);
+
+ for(sa= CTX_wm_screen(C)->areabase.first; sa; sa= sa->next) {
+ ARegion *ar_iter;
+ CTX_wm_area_set(C, sa);
+
+ for(ar_iter= sa->regionbase.first; ar_iter; ar_iter= ar_iter->next) {
+ CTX_wm_region_set(C, ar_iter);
+ ED_region_do_draw(C, ar_iter);
+ }
+ }
+
+ CTX_wm_window_set(C, win); /* XXX context manipulation warning! */
+
+ CTX_wm_area_set(C, sa_back);
+ CTX_wm_region_set(C, ar_back);
+ }
+ else if (type==3) {
+ wmWindow *win= CTX_wm_window(C);
+ ScrArea *sa;
+
for(sa= CTX_wm_screen(C)->areabase.first; sa; sa= sa->next)
ED_area_tag_redraw(sa);
wm_draw_update(C);
CTX_wm_window_set(C, win); /* XXX context manipulation warning! */
}
- else if (type==3) {
+ else if (type==4) {
Scene *scene= CTX_data_scene(C);
if(a & 1) scene->r.cfra--;
@@ -2024,40 +2048,43 @@ static int ten_timer_exec(bContext *C, wmOperator *op)
}
}
- time= (int) ((PIL_check_seconds_timer()-stime)*1000);
+ time= ((PIL_check_seconds_timer()-stime)*1000);
- if(type==0) sprintf(tmpstr, "10 x Draw Region: %d ms", time);
- if(type==1) sprintf(tmpstr, "10 x Draw Region and Swap: %d ms", time);
- if(type==2) sprintf(tmpstr, "10 x Draw Window and Swap: %d ms", time);
- if(type==3) sprintf(tmpstr, "Anim Step: %d ms", time);
- if(type==4) sprintf(tmpstr, "10 x Undo/Redo: %d ms", time);
+ if(type==0) infostr= "Draw Region";
+ if(type==1) infostr= "Draw Region and Swap";
+ if(type==2) infostr= "Draw Window";
+ if(type==3) infostr= "Draw Window and Swap";
+ if(type==4) infostr= "Animation Steps";
+ if(type==5) infostr= "Undo/Redo";
WM_cursor_wait(0);
- uiPupMenuNotice(C, tmpstr);
+ BKE_reportf(op->reports, RPT_INFO, "%d x %s: %.2f ms, average: %.4f", iter, infostr, time, time/iter);
return OPERATOR_FINISHED;
}
-static void WM_OT_ten_timer(wmOperatorType *ot)
+static void WM_OT_redraw_timer(wmOperatorType *ot)
{
static EnumPropertyItem prop_type_items[] = {
{0, "DRAW", 0, "Draw Region", ""},
- {1, "DRAWSWAP", 0, "Draw Region + Swap", ""},
- {2, "DRAWWINSWAP", 0, "Draw Window + Swap", ""},
- {3, "ANIMSTEP", 0, "Anim Step", ""},
- {4, "UNDO", 0, "Undo/Redo", ""},
+ {1, "DRAW_SWAP", 0, "Draw Region + Swap", ""},
+ {2, "DRAW_WIN", 0, "Draw Window", ""},
+ {3, "DRAW_WIN_SWAP", 0, "Draw Window + Swap", ""},
+ {4, "ANIM_STEP", 0, "Anim Step", ""},
+ {5, "UNDO", 0, "Undo/Redo", ""},
{0, NULL, 0, NULL, NULL}};
- ot->name= "Ten Timer";
- ot->idname= "WM_OT_ten_timer";
- ot->description="Ten Timer operator.";
+ ot->name= "Redraw Timer";
+ ot->idname= "WM_OT_redraw_timer";
+ ot->description="Simple redraw timer to test the speed of updating the interface.";
ot->invoke= WM_menu_invoke;
- ot->exec= ten_timer_exec;
+ ot->exec= redraw_timer_exec;
ot->poll= WM_operator_winactive;
RNA_def_enum(ot->srna, "type", prop_type_items, 0, "Type", "");
+ RNA_def_int(ot->srna, "iterations", 10, 1,INT_MAX, "Iterations", "Number of times to redraw", 1,1000);
}
@@ -2092,7 +2119,7 @@ void wm_operatortype_init(void)
WM_operatortype_append(WM_OT_jobs_timer);
WM_operatortype_append(WM_OT_save_as_mainfile);
WM_operatortype_append(WM_OT_save_mainfile);
- WM_operatortype_append(WM_OT_ten_timer);
+ WM_operatortype_append(WM_OT_redraw_timer);
WM_operatortype_append(WM_OT_debug_menu);
WM_operatortype_append(WM_OT_search_menu);
}
@@ -2127,7 +2154,7 @@ void wm_window_keymap(wmWindowManager *wm)
WM_keymap_add_item(keymap, "WM_OT_exit_blender", QKEY, KM_PRESS, KM_CTRL, 0);
/* debug/testing */
- WM_keymap_verify_item(keymap, "WM_OT_ten_timer", TKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
+ WM_keymap_verify_item(keymap, "WM_OT_redraw_timer", TKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
WM_keymap_verify_item(keymap, "WM_OT_debug_menu", DKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
WM_keymap_verify_item(keymap, "WM_OT_search_menu", SPACEKEY, KM_PRESS, 0, 0);