Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_image/image_draw.c
| Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "RE_pipeline.h" | #include "RE_pipeline.h" | ||||
| #include "RE_engine.h" | #include "RE_engine.h" | ||||
| #include "DRW_engine.h" | |||||
| #include "image_intern.h" | #include "image_intern.h" | ||||
| static void draw_render_info( | static void draw_render_info( | ||||
| const bContext *C, Scene *scene, Image *ima, ARegion *ar, float zoomx, float zoomy) | const bContext *C, Scene *scene, Image *ima, ARegion *ar, float zoomx, float zoomy) | ||||
| { | { | ||||
| Render *re = RE_GetSceneRender(scene); | Render *re = RE_GetSceneRender(scene); | ||||
| RenderData *rd = RE_engine_get_render_data(re); | RenderData *rd = RE_engine_get_render_data(re); | ||||
| Scene *stats_scene = ED_render_job_get_scene(C); | Scene *stats_scene = ED_render_job_get_scene(C); | ||||
| ▲ Show 20 Lines • Show All 674 Lines • ▼ Show 20 Lines | if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE) && brush->clone.image) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* draw main image region */ | /* draw main image region */ | ||||
| void draw_image_main(const bContext *C, ARegion *ar) | void draw_image_main(const bContext *C, ARegion *ar) | ||||
| { | { | ||||
| SpaceImage *sima = CTX_wm_space_image(C); | DRW_draw_view(C); | ||||
| Scene *scene = CTX_data_scene(C); | |||||
| Image *ima; | |||||
| ImBuf *ibuf; | |||||
| float zoomx, zoomy; | |||||
| bool show_viewer, show_render, show_paint, show_stereo3d, show_multilayer; | |||||
| void *lock; | |||||
| /* XXX can we do this in refresh? */ | |||||
| #if 0 | |||||
| what_image(sima); | |||||
| if (sima->image) { | |||||
| ED_image_get_aspect(sima->image, &xuser_asp, &yuser_asp); | |||||
| /* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */ | |||||
| if (sima->image->type == IMA_TYPE_COMPOSITE) { | |||||
| ImageUser *iuser = ntree_get_active_iuser(scene->nodetree); | |||||
| if (iuser) { | |||||
| BKE_image_user_calc_imanr(iuser, scene->r.cfra, 0); | |||||
| sima->iuser = *iuser; | |||||
| } | |||||
| } | |||||
| /* and we check for spare */ | |||||
| ibuf = ED_space_image_buffer(sima); | |||||
| } | |||||
| #endif | |||||
| /* retrieve the image and information about it */ | |||||
| ima = ED_space_image(sima); | |||||
| ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy); | |||||
| /* Tag image as in active use for garbage collector. */ | |||||
| if (ima) { | |||||
| BKE_image_tag_time(ima); | |||||
| } | |||||
| show_viewer = (ima && ima->source == IMA_SRC_VIEWER) != 0; | |||||
| show_render = (show_viewer && ima->type == IMA_TYPE_R_RESULT) != 0; | |||||
| show_paint = (ima && (sima->mode == SI_MODE_PAINT) && (show_viewer == false) && | |||||
| (show_render == false)); | |||||
| show_stereo3d = (ima && BKE_image_is_stereo(ima) && (sima->iuser.flag & IMA_SHOW_STEREO)); | |||||
| show_multilayer = ima && BKE_image_is_multilayer(ima); | |||||
| if (show_viewer) { | |||||
| /* use locked draw for drawing viewer image buffer since the compositor | |||||
| * is running in separated thread and compositor could free this buffers. | |||||
| * other images are not modifying in such a way so they does not require | |||||
| * lock (sergey) | |||||
| */ | |||||
| BLI_thread_lock(LOCK_DRAW_IMAGE); | |||||
| } | |||||
| if (show_stereo3d) { | |||||
| if (show_multilayer) { | |||||
| /* update multiindex and pass for the current eye */ | |||||
| BKE_image_multilayer_index(ima->rr, &sima->iuser); | |||||
| } | |||||
| else { | |||||
| BKE_image_multiview_index(ima, &sima->iuser); | |||||
| } | |||||
| } | |||||
| ibuf = ED_space_image_acquire_buffer(sima, &lock); | |||||
| /* draw the image or grid */ | |||||
| if (ibuf == NULL) { | |||||
| ED_region_grid_draw(ar, zoomx, zoomy); | |||||
| } | |||||
| else { | |||||
| if (sima->flag & SI_DRAW_TILE) { | |||||
| draw_image_buffer_repeated(C, sima, ar, scene, ibuf, zoomx, zoomy); | |||||
| } | |||||
| else { | |||||
| draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy); | |||||
| } | |||||
| if (sima->flag & SI_DRAW_METADATA) { | |||||
| int x, y; | |||||
| rctf frame; | |||||
| BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y); | |||||
| UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); | |||||
| ED_region_image_metadata_draw(x, y, ibuf, &frame, zoomx, zoomy); | |||||
| } | |||||
| } | |||||
| ED_space_image_release_buffer(sima, ibuf, lock); | |||||
| /* paint helpers */ | |||||
| if (show_paint) { | |||||
| draw_image_paint_helpers(C, ar, scene, zoomx, zoomy); | |||||
| } | |||||
| if (show_viewer) { | |||||
| BLI_thread_unlock(LOCK_DRAW_IMAGE); | |||||
| } | } | ||||
| /* render info */ | // SpaceImage *sima = CTX_wm_space_image(C); | ||||
| if (ima && show_render) { | // Scene *scene = CTX_data_scene(C); | ||||
| draw_render_info(C, sima->iuser.scene, ima, ar, zoomx, zoomy); | // Image *ima; | ||||
| } | // ImBuf *ibuf; | ||||
| } | // float zoomx, zoomy; | ||||
| // bool show_viewer, show_render, show_paint, show_stereo3d, show_multilayer; | |||||
| // void *lock; | |||||
| // /* XXX can we do this in refresh? */ | |||||
| // #if 0 | |||||
| // what_image(sima); | |||||
| // if (sima->image) { | |||||
| // ED_image_get_aspect(sima->image, &xuser_asp, &yuser_asp); | |||||
| // /* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */ | |||||
| // if (sima->image->type == IMA_TYPE_COMPOSITE) { | |||||
| // ImageUser *iuser = ntree_get_active_iuser(scene->nodetree); | |||||
| // if (iuser) { | |||||
| // BKE_image_user_calc_imanr(iuser, scene->r.cfra, 0); | |||||
| // sima->iuser = *iuser; | |||||
| // } | |||||
| // } | |||||
| // /* and we check for spare */ | |||||
| // ibuf = ED_space_image_buffer(sima); | |||||
| // } | |||||
| // #endif | |||||
| // /* retrieve the image and information about it */ | |||||
| // ima = ED_space_image(sima); | |||||
| // ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy); | |||||
| // /* Tag image as in active use for garbage collector. */ | |||||
| // if (ima) { | |||||
| // BKE_image_tag_time(ima); | |||||
| // } | |||||
| // show_viewer = (ima && ima->source == IMA_SRC_VIEWER) != 0; | |||||
| // show_render = (show_viewer && ima->type == IMA_TYPE_R_RESULT) != 0; | |||||
| // show_paint = (ima && (sima->mode == SI_MODE_PAINT) && (show_viewer == false) && | |||||
| // (show_render == false)); | |||||
| // show_stereo3d = (ima && BKE_image_is_stereo(ima) && (sima->iuser.flag & IMA_SHOW_STEREO)); | |||||
| // show_multilayer = ima && BKE_image_is_multilayer(ima); | |||||
| // if (show_viewer) { | |||||
| // /* use locked draw for drawing viewer image buffer since the compositor | |||||
| // * is running in separated thread and compositor could free this buffers. | |||||
| // * other images are not modifying in such a way so they does not require | |||||
| // * lock (sergey) | |||||
| // */ | |||||
| // BLI_thread_lock(LOCK_DRAW_IMAGE); | |||||
| // } | |||||
| // if (show_stereo3d) { | |||||
| // if (show_multilayer) { | |||||
| // /* update multiindex and pass for the current eye */ | |||||
| // BKE_image_multilayer_index(ima->rr, &sima->iuser); | |||||
| // } | |||||
| // else { | |||||
| // BKE_image_multiview_index(ima, &sima->iuser); | |||||
| // } | |||||
| // } | |||||
| // ibuf = ED_space_image_acquire_buffer(sima, &lock); | |||||
| // /* draw the image or grid */ | |||||
| // if (ibuf == NULL) { | |||||
| // ED_region_grid_draw(ar, zoomx, zoomy); | |||||
| // } | |||||
| // else { | |||||
| // if (sima->flag & SI_DRAW_TILE) { | |||||
| // draw_image_buffer_repeated(C, sima, ar, scene, ibuf, zoomx, zoomy); | |||||
| // } | |||||
| // else { | |||||
| // draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy); | |||||
| // } | |||||
| // if (sima->flag & SI_DRAW_METADATA) { | |||||
| // int x, y; | |||||
| // rctf frame; | |||||
| // BLI_rctf_init(&frame, 0.0f, ibuf->x, 0.0f, ibuf->y); | |||||
| // UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); | |||||
| // ED_region_image_metadata_draw(x, y, ibuf, &frame, zoomx, zoomy); | |||||
| // } | |||||
| // } | |||||
| // ED_space_image_release_buffer(sima, ibuf, lock); | |||||
| // /* paint helpers */ | |||||
| // if (show_paint) { | |||||
| // draw_image_paint_helpers(C, ar, scene, zoomx, zoomy); | |||||
| // } | |||||
| // if (show_viewer) { | |||||
| // BLI_thread_unlock(LOCK_DRAW_IMAGE); | |||||
| // } | |||||
| // /* render info */ | |||||
| // if (ima && show_render) { | |||||
| // draw_render_info(C, sima->iuser.scene, ima, ar, zoomx, zoomy); | |||||
| // } | |||||
| // } | |||||
| bool ED_space_image_show_cache(SpaceImage *sima) | bool ED_space_image_show_cache(SpaceImage *sima) | ||||
| { | { | ||||
| Image *image = ED_space_image(sima); | Image *image = ED_space_image(sima); | ||||
| Mask *mask = NULL; | Mask *mask = NULL; | ||||
| if (sima->mode == SI_MODE_MASK) { | if (sima->mode == SI_MODE_MASK) { | ||||
| mask = ED_space_image_get_mask(sima); | mask = ED_space_image_get_mask(sima); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines | |||||