Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_image/space_image.c
| Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
| #include "BIF_gl.h" | #include "BIF_gl.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "UI_interface.h" | |||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "image_intern.h" | #include "image_intern.h" | ||||
| /**************************** common state *****************************/ | /**************************** common state *****************************/ | ||||
| static void image_scopes_tag_refresh(ScrArea *sa) | static void image_scopes_tag_refresh(ScrArea *sa) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 740 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void image_scope_area_draw(const bContext *C, ARegion *ar) | static void image_scope_area_draw(const bContext *C, ARegion *ar) | ||||
| { | { | ||||
| SpaceImage *sima = CTX_wm_space_image(C); | SpaceImage *sima = CTX_wm_space_image(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| void *lock; | void *lock; | ||||
| ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock); | ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock); | ||||
| /* XXX performance regression if name of scopes category changes! */ | |||||
| PanelCategoryStack *category = UI_panel_category_active_find(ar, "Scopes"); | |||||
brecht: I guess we'll have to live with that loose coupling, I don't think it's so bad.
The other… | |||||
| /* only update scopes if scope category is active */ | |||||
| if (category) { | |||||
| if (ibuf) { | if (ibuf) { | ||||
| if (!sima->scopes.ok) { | if (!sima->scopes.ok) { | ||||
| BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings); | BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings); | ||||
| } | } | ||||
| if (sima->image->flag & IMA_VIEW_AS_RENDER) | if (sima->image->flag & IMA_VIEW_AS_RENDER) | ||||
| scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings); | scopes_update(&sima->scopes, ibuf, &scene->view_settings, &scene->display_settings); | ||||
| else | else | ||||
| scopes_update(&sima->scopes, ibuf, NULL, &scene->display_settings); | scopes_update(&sima->scopes, ibuf, NULL, &scene->display_settings); | ||||
| } | } | ||||
| } | |||||
| ED_space_image_release_buffer(sima, ibuf, lock); | ED_space_image_release_buffer(sima, ibuf, lock); | ||||
| ED_region_panels(C, ar, 1, NULL, -1); | ED_region_panels(C, ar, 1, NULL, -1); | ||||
| } | } | ||||
| static void image_scope_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) | static void image_scope_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) | ||||
| { | { | ||||
| /* context changes */ | /* context changes */ | ||||
| ▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | void ED_spacetype_image(void) | ||||
| art->regionid = RGN_TYPE_UI; | art->regionid = RGN_TYPE_UI; | ||||
| art->prefsizex = 220; // XXX | art->prefsizex = 220; // XXX | ||||
| art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; | art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; | ||||
| art->listener = image_buttons_area_listener; | art->listener = image_buttons_area_listener; | ||||
| art->init = image_buttons_area_init; | art->init = image_buttons_area_init; | ||||
| art->draw = image_buttons_area_draw; | art->draw = image_buttons_area_draw; | ||||
| BLI_addhead(&st->regiontypes, art); | BLI_addhead(&st->regiontypes, art); | ||||
| image_buttons_register(art); | |||||
| ED_uvedit_buttons_register(art); | ED_uvedit_buttons_register(art); | ||||
| /* regions: statistics/scope buttons */ | /* regions: statistics/scope buttons */ | ||||
| art = MEM_callocN(sizeof(ARegionType), "spacetype image region"); | art = MEM_callocN(sizeof(ARegionType), "spacetype image region"); | ||||
| art->regionid = RGN_TYPE_PREVIEW; | art->regionid = RGN_TYPE_PREVIEW; | ||||
| art->prefsizex = 220; // XXX | art->prefsizex = 220; // XXX | ||||
| art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; | art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; | ||||
| art->listener = image_scope_area_listener; | art->listener = image_scope_area_listener; | ||||
| art->init = image_scope_area_init; | art->init = image_scope_area_init; | ||||
| art->draw = image_scope_area_draw; | art->draw = image_scope_area_draw; | ||||
| BLI_addhead(&st->regiontypes, art); | BLI_addhead(&st->regiontypes, art); | ||||
| image_buttons_register(art); | |||||
| /* regions: header */ | /* regions: header */ | ||||
| art = MEM_callocN(sizeof(ARegionType), "spacetype image region"); | art = MEM_callocN(sizeof(ARegionType), "spacetype image region"); | ||||
| art->regionid = RGN_TYPE_HEADER; | art->regionid = RGN_TYPE_HEADER; | ||||
| art->prefsizey = HEADERY; | art->prefsizey = HEADERY; | ||||
| art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; | art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; | ||||
| art->listener = image_header_area_listener; | art->listener = image_header_area_listener; | ||||
| art->init = image_header_area_init; | art->init = image_header_area_init; | ||||
| art->draw = image_header_area_draw; | art->draw = image_header_area_draw; | ||||
| BLI_addhead(&st->regiontypes, art); | BLI_addhead(&st->regiontypes, art); | ||||
| BKE_spacetype_register(st); | BKE_spacetype_register(st); | ||||
| } | } | ||||
I guess we'll have to live with that loose coupling, I don't think it's so bad.
The other solution would be to compute the scopes just in time before drawing, but I don't like that much either, since ideally the scopes should be computed as part of the dependency graph somehow for better threading.