diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-01-17 01:37:45 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-01-17 01:39:17 +0400 |
commit | 5b1330e99d5a281efa448b64880dfa24be67d8f2 (patch) | |
tree | a56e13396d3f14f00b08ba63622a48f41c2276b9 /source | |
parent | e9227c76d480c5e7973b6bce03cce3ad414b0348 (diff) |
Outliner: minor speedup for drawing, avoid 3 rna lookups per object
also for movie-clip dope-sheet
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_clip/clip_dopesheet_draw.c | 11 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/outliner_draw.c | 37 |
2 files changed, 31 insertions, 17 deletions
diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index e85b055bc59..d15a61d6430 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -293,6 +293,7 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) int fontid = style->widget.uifont_id; int height; float y; + PropertyRNA *chan_prop_lock; if (!clip) return; @@ -355,6 +356,10 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); y = (float) CHANNEL_FIRST; + /* get RNA properties (once) */ + chan_prop_lock = RNA_struct_type_find_property(&RNA_MovieTrackingTrack, "lock"); + BLI_assert(chan_prop_lock); + glEnable(GL_BLEND); for (channel = dopesheet->channels.first; channel; channel = channel->next) { float yminc = (float)(y - CHANNEL_HEIGHT_HALF); @@ -371,9 +376,9 @@ void clip_draw_dopesheet_channels(const bContext *C, ARegion *ar) RNA_pointer_create(&clip->id, &RNA_MovieTrackingTrack, track, &ptr); uiBlockSetEmboss(block, UI_EMBOSSN); - uiDefIconButR(block, ICONTOG, 1, icon, - v2d->cur.xmax - UI_UNIT_X - CHANNEL_PAD, y - UI_UNIT_Y / 2.0f, - UI_UNIT_X, UI_UNIT_Y, &ptr, "lock", 0, 0, 0, 0, 0, NULL); + uiDefIconButR_prop(block, ICONTOG, 1, icon, + v2d->cur.xmax - UI_UNIT_X - CHANNEL_PAD, y - UI_UNIT_Y / 2.0f, + UI_UNIT_X, UI_UNIT_Y, &ptr, chan_prop_lock, 0, 0, 0, 0, 0, NULL); uiBlockSetEmboss(block, UI_EMBOSS); } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index b5d4734ecf7..b4fdb1a5828 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -534,35 +534,44 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar Object *ob = NULL; Group *gr = NULL; + PropertyRNA *object_prop_hide, *object_prop_hide_select, *object_prop_hide_render; + + /* get RNA properties (once) */ + object_prop_hide = RNA_struct_type_find_property(&RNA_Object, "hide"); + object_prop_hide_select = RNA_struct_type_find_property(&RNA_Object, "hide_select"); + object_prop_hide_render = RNA_struct_type_find_property(&RNA_Object, "hide_render"); + BLI_assert(object_prop_hide && object_prop_hide_select && object_prop_hide_render); + + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { /* objects have toggle-able restriction flags */ if (tselem->type == 0 && te->idcode == ID_OB) { PointerRNA ptr; - + ob = (Object *)tselem->id; RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ptr); - + uiBlockSetEmboss(block, UI_EMBOSSN); - bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, - (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y, - &ptr, "hide", -1, 0, 0, -1, -1, - TIP_("Restrict viewport visibility (Ctrl - Recursive)")); + bt = uiDefIconButR_prop(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y, + &ptr, object_prop_hide, -1, 0, 0, -1, -1, + TIP_("Restrict viewport visibility (Ctrl - Recursive)")); uiButSetFunc(bt, restrictbutton_view_cb, scene, ob); uiButSetFlag(bt, UI_BUT_DRAG_LOCK); - bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, - (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, - &ptr, "hide_select", -1, 0, 0, -1, -1, - TIP_("Restrict viewport selection (Ctrl - Recursive)")); + bt = uiDefIconButR_prop(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, + &ptr, object_prop_hide_select, -1, 0, 0, -1, -1, + TIP_("Restrict viewport selection (Ctrl - Recursive)")); uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob); uiButSetFlag(bt, UI_BUT_DRAG_LOCK); - bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, - (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y, - &ptr, "hide_render", -1, 0, 0, -1, -1, - TIP_("Restrict rendering (Ctrl - Recursive)")); + bt = uiDefIconButR_prop(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y, + &ptr, object_prop_hide_render, -1, 0, 0, -1, -1, + TIP_("Restrict rendering (Ctrl - Recursive)")); uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob); uiButSetFlag(bt, UI_BUT_DRAG_LOCK); |