diff options
Diffstat (limited to 'source/blender/editors/space_image/image_draw.c')
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 97 |
1 files changed, 49 insertions, 48 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index c455b7d7c54..d1b2c2330ac 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -78,7 +78,7 @@ #include "image_intern.h" 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 *region, float zoomx, float zoomy) { Render *re = RE_GetSceneRender(scene); RenderData *rd = RE_engine_get_render_data(re); @@ -91,7 +91,7 @@ static void draw_render_info( if (rr && rr->text) { float fill_color[4] = {0.0f, 0.0f, 0.0f, 0.25f}; - ED_region_info_draw(ar, rr->text, fill_color, true); + ED_region_info_draw(region, rr->text, fill_color, true); } BKE_image_release_renderresult(stats_scene, ima); @@ -104,7 +104,7 @@ static void draw_render_info( if (total_tiles) { /* find window pixel coordinates of origin */ int x, y; - UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); + UI_view2d_view_to_region(®ion->v2d, 0.0f, 0.0f, &x, &y); GPU_matrix_push(); GPU_matrix_translate_2f(x, y); @@ -141,7 +141,7 @@ static void draw_render_info( /* used by node view too */ void ED_image_draw_info(Scene *scene, - ARegion *ar, + ARegion *region, bool color_manage, bool use_default_view, int channels, @@ -157,7 +157,7 @@ void ED_image_draw_info(Scene *scene, char str[256]; int dx = 6; /* local coordinate visible rect inside region, to accommodate overlapping ui */ - const rcti *rect = ED_region_visible_rect(ar); + const rcti *rect = ED_region_visible_rect(region); const int ymin = rect->ymin; const int dy = ymin + 0.3f * UI_UNIT_Y; @@ -185,7 +185,7 @@ void ED_image_draw_info(Scene *scene, /* noisy, high contrast make impossible to read if lower alpha is used. */ immUniformColor4ub(0, 0, 0, 190); - immRecti(pos, 0, ymin, BLI_rcti_size_x(&ar->winrct) + 1, ymin + UI_UNIT_Y); + immRecti(pos, 0, ymin, BLI_rcti_size_x(®ion->winrct) + 1, ymin + UI_UNIT_Y); immUnbindProgram(); @@ -532,7 +532,7 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, MEM_freeN(rectf); } -static void draw_udim_label(ARegion *ar, float fx, float fy, const char *label) +static void draw_udim_label(ARegion *region, float fx, float fy, const char *label) { if (label == NULL || !label[0]) { return; @@ -540,14 +540,14 @@ static void draw_udim_label(ARegion *ar, float fx, float fy, const char *label) /* find window pixel coordinates of origin */ int x, y; - UI_view2d_view_to_region(&ar->v2d, fx, fy, &x, &y); + UI_view2d_view_to_region(®ion->v2d, fx, fy, &x, &y); GPU_blend_set_func_separate( GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); GPU_blend(true); int textwidth = BLF_width(blf_mono_font, label, strlen(label)) + 10; - float stepx = BLI_rcti_size_x(&ar->v2d.mask) / BLI_rctf_size_x(&ar->v2d.cur); + float stepx = BLI_rcti_size_x(®ion->v2d.mask) / BLI_rctf_size_x(®ion->v2d.cur); float opacity; if (textwidth < 0.5f * (stepx - 10)) { opacity = 1.0f; @@ -567,7 +567,7 @@ static void draw_udim_label(ARegion *ar, float fx, float fy, const char *label) static void draw_image_buffer(const bContext *C, SpaceImage *sima, - ARegion *ar, + ARegion *region, Scene *scene, ImBuf *ibuf, float fx, @@ -578,7 +578,7 @@ static void draw_image_buffer(const bContext *C, int x, y; /* find window pixel coordinates of origin */ - UI_view2d_view_to_region(&ar->v2d, fx, fy, &x, &y); + UI_view2d_view_to_region(®ion->v2d, fx, fy, &x, &y); /* this part is generic image display */ if (sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1))) { @@ -595,7 +595,7 @@ static void draw_image_buffer(const bContext *C, else { int clip_max_x, clip_max_y; UI_view2d_view_to_region( - &ar->v2d, ar->v2d.cur.xmax, ar->v2d.cur.ymax, &clip_max_x, &clip_max_y); + ®ion->v2d, region->v2d.cur.xmax, region->v2d.cur.ymax, &clip_max_x, &clip_max_y); if (sima->flag & SI_USE_ALPHA) { imm_draw_box_checker_2d(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy); @@ -669,7 +669,7 @@ static void draw_image_buffer(const bContext *C, static void draw_image_buffer_repeated(const bContext *C, SpaceImage *sima, - ARegion *ar, + ARegion *region, Scene *scene, ImBuf *ibuf, float zoomx, @@ -677,14 +677,14 @@ static void draw_image_buffer_repeated(const bContext *C, { const double time_current = PIL_check_seconds_timer(); - const int xmax = ceil(ar->v2d.cur.xmax); - const int ymax = ceil(ar->v2d.cur.ymax); - const int xmin = floor(ar->v2d.cur.xmin); - const int ymin = floor(ar->v2d.cur.ymin); + const int xmax = ceil(region->v2d.cur.xmax); + const int ymax = ceil(region->v2d.cur.ymax); + const int xmin = floor(region->v2d.cur.xmin); + const int ymin = floor(region->v2d.cur.ymin); for (int x = xmin; x < xmax; x++) { for (int y = ymin; y < ymax; y++) { - draw_image_buffer(C, sima, ar, scene, ibuf, x, y, zoomx, zoomy); + draw_image_buffer(C, sima, region, scene, ibuf, x, y, zoomx, zoomy); /* only draw until running out of time */ if ((PIL_check_seconds_timer() - time_current) > 0.25) { @@ -744,7 +744,7 @@ void draw_image_sample_line(SpaceImage *sima) } static void draw_image_paint_helpers( - const bContext *C, ARegion *ar, Scene *scene, float zoomx, float zoomy) + const bContext *C, ARegion *region, Scene *scene, float zoomx, float zoomy) { Brush *brush; int x, y; @@ -758,7 +758,8 @@ static void draw_image_paint_helpers( if (ibuf) { void *cache_handle = NULL; float col[4] = {1.0f, 1.0f, 1.0f, brush->clone.alpha}; - UI_view2d_view_to_region(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y); + UI_view2d_view_to_region( + ®ion->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y); uchar *display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); @@ -796,7 +797,7 @@ static void draw_image_paint_helpers( static void draw_udim_tile_grid(uint pos_attr, uint color_attr, - ARegion *ar, + ARegion *region, int x, int y, float stepx, @@ -804,7 +805,7 @@ static void draw_udim_tile_grid(uint pos_attr, const float color[3]) { float x1, y1; - UI_view2d_view_to_region_fl(&ar->v2d, x, y, &x1, &y1); + UI_view2d_view_to_region_fl(®ion->v2d, x, y, &x1, &y1); int gridpos[5][2] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}}; for (int i = 0; i < 4; i++) { immAttr3fv(color_attr, color); @@ -814,7 +815,7 @@ static void draw_udim_tile_grid(uint pos_attr, } } -static void draw_udim_tile_grids(ARegion *ar, SpaceImage *sima, Image *ima) +static void draw_udim_tile_grids(ARegion *region, SpaceImage *sima, Image *ima) { int num_tiles; if (ima != NULL) { @@ -828,8 +829,8 @@ static void draw_udim_tile_grids(ARegion *ar, SpaceImage *sima, Image *ima) num_tiles = sima->tile_grid_shape[0] * sima->tile_grid_shape[1]; } - float stepx = BLI_rcti_size_x(&ar->v2d.mask) / BLI_rctf_size_x(&ar->v2d.cur); - float stepy = BLI_rcti_size_y(&ar->v2d.mask) / BLI_rctf_size_y(&ar->v2d.cur); + float stepx = BLI_rcti_size_x(®ion->v2d.mask) / BLI_rctf_size_x(®ion->v2d.cur); + float stepy = BLI_rcti_size_y(®ion->v2d.mask) / BLI_rctf_size_y(®ion->v2d.cur); GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); @@ -849,20 +850,20 @@ static void draw_udim_tile_grids(ARegion *ar, SpaceImage *sima, Image *ima) if (tile != cur_tile) { int x = (tile->tile_number - 1001) % 10; int y = (tile->tile_number - 1001) / 10; - draw_udim_tile_grid(pos, color, ar, x, y, stepx, stepy, theme_color); + draw_udim_tile_grid(pos, color, region, x, y, stepx, stepy, theme_color); } } if (cur_tile != NULL) { int cur_x = (cur_tile->tile_number - 1001) % 10; int cur_y = (cur_tile->tile_number - 1001) / 10; - draw_udim_tile_grid(pos, color, ar, cur_x, cur_y, stepx, stepy, selected_color); + draw_udim_tile_grid(pos, color, region, cur_x, cur_y, stepx, stepy, selected_color); } } else { for (int y = 0; y < sima->tile_grid_shape[1]; y++) { for (int x = 0; x < sima->tile_grid_shape[0]; x++) { - draw_udim_tile_grid(pos, color, ar, x, y, stepx, stepy, theme_color); + draw_udim_tile_grid(pos, color, region, x, y, stepx, stepy, theme_color); } } } @@ -873,7 +874,7 @@ static void draw_udim_tile_grids(ARegion *ar, SpaceImage *sima, Image *ima) /* draw main image region */ -void draw_image_main(const bContext *C, ARegion *ar) +void draw_image_main(const bContext *C, ARegion *region) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); @@ -905,7 +906,7 @@ void draw_image_main(const bContext *C, ARegion *ar) /* retrieve the image and information about it */ ima = ED_space_image(sima); - ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy); + ED_space_image_get_zoom(sima, region, &zoomx, &zoomy); /* Tag image as in active use for garbage collector. */ if (ima) { @@ -949,31 +950,31 @@ void draw_image_main(const bContext *C, ARegion *ar) LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) { int x = (tile->tile_number - 1001) % 10; int y = (tile->tile_number - 1001) / 10; - ED_region_grid_draw(ar, zoomx, zoomy, x, y); + ED_region_grid_draw(region, zoomx, zoomy, x, y); } } else { for (int y = 0; y < sima->tile_grid_shape[1]; y++) { for (int x = 0; x < sima->tile_grid_shape[0]; x++) { - ED_region_grid_draw(ar, zoomx, zoomy, x, y); + ED_region_grid_draw(region, zoomx, zoomy, x, y); } } } } else { if (sima->flag & SI_DRAW_TILE) { - draw_image_buffer_repeated(C, sima, ar, scene, ibuf, zoomx, zoomy); + draw_image_buffer_repeated(C, sima, region, scene, ibuf, zoomx, zoomy); } else { main_w = ibuf->x; main_h = ibuf->y; - draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy); + draw_image_buffer(C, sima, region, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy); if (ima->source == IMA_SRC_TILED) { ImageTile *tile = BKE_image_get_tile(ima, 0); char label[sizeof(tile->label)]; BKE_image_get_tile_label(ima, tile, label, sizeof(label)); - draw_udim_label(ar, 0.0f, 0.0f, label); + draw_udim_label(region, 0.0f, 0.0f, label); } } @@ -982,7 +983,7 @@ void draw_image_main(const bContext *C, ARegion *ar) 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); + UI_view2d_view_to_region(®ion->v2d, 0.0f, 0.0f, &x, &y); ED_region_image_metadata_draw(x, y, ibuf, &frame, zoomx, zoomy); } @@ -1005,18 +1006,18 @@ void draw_image_main(const bContext *C, ARegion *ar) float tile_zoomx = (zoomx * main_w) / ibuf->x; float tile_zoomy = (zoomy * main_h) / ibuf->y; - draw_image_buffer(C, sima, ar, scene, ibuf, x_pos, y_pos, tile_zoomx, tile_zoomy); - draw_udim_label(ar, x_pos, y_pos, label); + draw_image_buffer(C, sima, region, scene, ibuf, x_pos, y_pos, tile_zoomx, tile_zoomy); + draw_udim_label(region, x_pos, y_pos, label); } ED_space_image_release_buffer(sima, ibuf, lock); } } - draw_udim_tile_grids(ar, sima, ima); + draw_udim_tile_grids(region, sima, ima); /* paint helpers */ if (show_paint) { - draw_image_paint_helpers(C, ar, scene, zoomx, zoomy); + draw_image_paint_helpers(C, region, scene, zoomx, zoomy); } if (show_viewer) { @@ -1025,7 +1026,7 @@ void draw_image_main(const bContext *C, ARegion *ar) /* render info */ if (ima && show_render) { - draw_render_info(C, sima->iuser.scene, ima, ar, zoomx, zoomy); + draw_render_info(C, sima->iuser.scene, ima, region, zoomx, zoomy); } } @@ -1045,12 +1046,12 @@ bool ED_space_image_show_cache(SpaceImage *sima) return true; } -void draw_image_cache(const bContext *C, ARegion *ar) +void draw_image_cache(const bContext *C, ARegion *region) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); Image *image = ED_space_image(sima); - float x, cfra = CFRA, sfra = SFRA, efra = EFRA, framelen = ar->winx / (efra - sfra + 1); + float x, cfra = CFRA, sfra = SFRA, efra = EFRA, framelen = region->winx / (efra - sfra + 1); Mask *mask = NULL; if (!ED_space_image_show_cache(sima)) { @@ -1062,7 +1063,7 @@ void draw_image_cache(const bContext *C, ARegion *ar) } /* Local coordinate visible rect inside region, to accommodate overlapping ui. */ - const rcti *rect_visible = ED_region_visible_rect(ar); + const rcti *rect_visible = ED_region_visible_rect(region); const int region_bottom = rect_visible->ymin; GPU_blend(true); @@ -1070,7 +1071,7 @@ void draw_image_cache(const bContext *C, ARegion *ar) GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); /* Draw cache background. */ - ED_region_cache_draw_background(ar); + ED_region_cache_draw_background(region); /* Draw cached segments. */ if (image != NULL && image->cache != NULL && @@ -1080,13 +1081,13 @@ void draw_image_cache(const bContext *C, ARegion *ar) IMB_moviecache_get_cache_segments(image->cache, IMB_PROXY_NONE, 0, &num_segments, &points); ED_region_cache_draw_cached_segments( - ar, num_segments, points, sfra + sima->iuser.offset, efra + sima->iuser.offset); + region, num_segments, points, sfra + sima->iuser.offset, efra + sima->iuser.offset); } GPU_blend(false); /* Draw current frame. */ - x = (cfra - sfra) / (efra - sfra + 1) * ar->winx; + x = (cfra - sfra) / (efra - sfra + 1) * region->winx; uint pos = GPU_vertformat_attr_add( immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); @@ -1098,6 +1099,6 @@ void draw_image_cache(const bContext *C, ARegion *ar) ED_region_cache_draw_curfra_label(cfra, x, region_bottom + 8.0f * UI_DPI_FAC); if (mask != NULL) { - ED_mask_draw_frames(mask, ar, cfra, sfra, efra); + ED_mask_draw_frames(mask, region, cfra, sfra, efra); } } |