diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-07 02:17:41 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-07 02:17:41 +0400 |
commit | 297a21c39a9b33337b168b32adf0538b11d56510 (patch) | |
tree | cb15b1bf2221504a17dd65cbd059da1a2126750c | |
parent | 10985c38d6e3122f8fcd58443d4fb09edfb84315 (diff) |
Code Cleanup:
don't call CTX_data_scene(C) for every marker drawn
also remove unneeded call when scene was already defined as well as redundant scene cast.
-rw-r--r-- | source/blender/editors/animation/anim_markers.c | 23 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 3 |
6 files changed, 24 insertions, 14 deletions
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 216bb8d0e08..79d767be63c 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -439,22 +439,28 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) void draw_markers_time(const bContext *C, int flag) { ListBase *markers= ED_context_get_markers(C); - View2D *v2d= UI_view2d_fromcontext(C); + View2D *v2d; TimeMarker *marker; - + Scene *scene; + if (markers == NULL) return; - + + scene = CTX_data_scene(C); + v2d = UI_view2d_fromcontext(C); + /* unselected markers are drawn at the first time */ for (marker= markers->first; marker; marker= marker->next) { - if ((marker->flag & SELECT) == 0) - draw_marker(v2d, marker, CTX_data_scene(C)->r.cfra, flag); + if ((marker->flag & SELECT) == 0) { + draw_marker(v2d, marker, scene->r.cfra, flag); + } } /* selected markers are drawn later */ for (marker= markers->first; marker; marker= marker->next) { - if (marker->flag & SELECT) - draw_marker(v2d, marker, CTX_data_scene(C)->r.cfra, flag); + if (marker->flag & SELECT) { + draw_marker(v2d, marker, scene->r.cfra, flag); + } } } @@ -550,7 +556,8 @@ static int ed_marker_add(bContext *C, wmOperator *UNUSED(op)) if (markers == NULL) return OPERATOR_CANCELLED; - /* two markers can't be at the same place */ + /* prefer not having 2 markers at the same place, + * though the user can move them to overlap once added */ for (marker= markers->first; marker; marker= marker->next) { if (marker->frame == frame) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 40cf0213203..0521ecbf0d0 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -103,7 +103,8 @@ static int eyedropper_cancel(bContext *C, wmOperator *op) static void eyedropper_sample(bContext *C, Eyedropper *eye, int mx, int my) { if(RNA_property_type(eye->prop) == PROP_FLOAT) { - const int color_manage = CTX_data_scene(C)->r.color_mgt_flag & R_COLOR_MANAGEMENT; + Scene *scene = CTX_data_scene(C); + const int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; float col[4]; RNA_property_float_get_array(&eye->ptr, eye->prop, col); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 5abdafbfffc..97da05e3f76 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -593,6 +593,7 @@ static void clip_refresh(const bContext *C, ScrArea *sa) { wmWindowManager *wm= CTX_wm_manager(C); wmWindow *window= CTX_wm_window(C); + Scene *scene = CTX_data_scene(C); SpaceClip *sc= (SpaceClip *)sa->spacedata.first; ARegion *ar_main= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); ARegion *ar_preview= clip_has_preview_region(C, sa); @@ -634,7 +635,7 @@ static void clip_refresh(const bContext *C, ScrArea *sa) ED_area_tag_redraw(sa); } - BKE_movieclip_user_set_frame(&sc->user, CTX_data_scene(C)->r.cfra); + BKE_movieclip_user_set_frame(&sc->user, scene->r.cfra); } /********************* main region ********************/ diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index ea58b4aa737..e1fe3788d05 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -594,7 +594,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* retrieve state */ sima= CTX_wm_space_image(C); ar= CTX_wm_region(C); - scene= (Scene*)CTX_data_scene(C); + scene= CTX_data_scene(C); obedit= CTX_data_edit_object(C); ima= ED_space_image(sima); @@ -1445,7 +1445,7 @@ static int image_new_exec(bContext *C, wmOperator *op) /* retrieve state */ sima= CTX_wm_space_image(C); - scene= (Scene*)CTX_data_scene(C); + scene= CTX_data_scene(C); obedit= CTX_data_edit_object(C); RNA_string_get(op->ptr, "name", name); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index fd7895052f1..3a5793461ea 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -581,7 +581,7 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) ima= ED_space_image(sima); if(sima->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&sima->iuser, CTX_data_scene(C)->r.cfra, 0); + BKE_image_user_calc_frame(&sima->iuser, scene->r.cfra, 0); /* check if we have to set the image from the editmesh */ if(ima && (ima->source==IMA_SRC_VIEWER || sima->pin)); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index fe734e53651..906b5d01e32 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1341,9 +1341,10 @@ typedef struct ImageSampleInfo { static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) { + Scene *scene = CTX_data_scene(C); ImageSampleInfo *info= arg_info; - ED_image_draw_info(ar, (CTX_data_scene(C)->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels, + ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels, info->x, info->y, info->col, info->colf, NULL, NULL /* zbuf - unused for nodes */ ); |