diff options
author | Jeroen Bakker <jeroen@blender.org> | 2020-10-26 17:54:00 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2020-11-17 15:10:39 +0300 |
commit | 1e1c39fc89395c5e5a68a7a21500195cd8dc6fd5 (patch) | |
tree | a9b6d8e5cceb6a5bffb7d000499449be51fabed2 /source/blender/editors/space_image | |
parent | 8b6ce77f163cf0822af8a107a213e984ba4b3e97 (diff) |
Fix T82064: Add Image Clone tool to overlay engine
The clone tool in the image editor can show a second texture on top
of the image. This wasn't ported and now results into alpha and depth
issues. This fix adds the clone tool drawing to the overlay engine.
Reviewed By: Clément Foucault
Differential Revision: https://developer.blender.org/D9352
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 61 |
1 files changed, 5 insertions, 56 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 7934d600cf1..63e5ae64a8c 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -741,46 +741,6 @@ void draw_image_sample_line(SpaceImage *sima) } } -static void draw_image_paint_helpers( - const bContext *C, ARegion *region, Scene *scene, float zoomx, float zoomy) -{ - Brush *brush; - int x, y; - ImBuf *ibuf; - - brush = BKE_paint_brush(&scene->toolsettings->imapaint.paint); - - if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE) && brush->clone.image) { - ibuf = BKE_image_acquire_ibuf(brush->clone.image, NULL, NULL); - - if (ibuf) { - void *cache_handle = NULL; - float col[4] = {1.0f, 1.0f, 1.0f, brush->clone.alpha}; - 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); - - if (!display_buffer) { - BKE_image_release_ibuf(brush->clone.image, ibuf, NULL); - IMB_display_buffer_release(cache_handle); - return; - } - - GPU_blend(GPU_BLEND_ALPHA); - - IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); - immDrawPixelsTex( - &state, x, y, ibuf->x, ibuf->y, GPU_RGBA8, false, display_buffer, zoomx, zoomy, col); - - GPU_blend(GPU_BLEND_NONE); - - BKE_image_release_ibuf(brush->clone.image, ibuf, NULL); - IMB_display_buffer_release(cache_handle); - } - } -} - static void draw_udim_tile_grid(uint pos_attr, uint color_attr, ARegion *region, @@ -1007,24 +967,13 @@ void draw_image_main(const bContext *C, ARegion *region) void draw_image_main_helpers(const bContext *C, ARegion *region) { SpaceImage *sima = CTX_wm_space_image(C); - Scene *scene = CTX_data_scene(C); - Image *ima; - float zoomx, zoomy; - bool show_viewer, show_render, show_paint; + Image *ima = ED_space_image(sima); - ima = ED_space_image(sima); - ED_space_image_get_zoom(sima, region, &zoomx, &zoomy); - - 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)); - /* paint helpers */ - if (show_paint) { - draw_image_paint_helpers(C, region, scene, zoomx, zoomy); - } - /* render info */ + const bool show_viewer = (ima && ima->source == IMA_SRC_VIEWER) != 0; + const bool show_render = (show_viewer && ima->type == IMA_TYPE_R_RESULT) != 0; if (ima && show_render) { + float zoomx, zoomy; + ED_space_image_get_zoom(sima, region, &zoomx, &zoomy); draw_render_info(C, sima->iuser.scene, ima, region, zoomx, zoomy); } } |