Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_image/image_draw.c
| Show First 20 Lines • Show All 735 Lines • ▼ Show 20 Lines | if (sima->sample_line_hist.flag & HISTO_FLAG_SAMPLELINE) { | ||||
| immVertex2fv(shdr_dashed_pos, hist->co[0]); | immVertex2fv(shdr_dashed_pos, hist->co[0]); | ||||
| immVertex2fv(shdr_dashed_pos, hist->co[1]); | immVertex2fv(shdr_dashed_pos, hist->co[1]); | ||||
| immEnd(); | immEnd(); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| } | } | ||||
| 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, | static void draw_udim_tile_grid(uint pos_attr, | ||||
| uint color_attr, | uint color_attr, | ||||
| ARegion *region, | ARegion *region, | ||||
| int x, | int x, | ||||
| int y, | int y, | ||||
| float stepx, | float stepx, | ||||
| float stepy, | float stepy, | ||||
| const float color[3]) | const float color[3]) | ||||
| ▲ Show 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | #endif | ||||
| if (show_viewer) { | if (show_viewer) { | ||||
| BLI_thread_unlock(LOCK_DRAW_IMAGE); | BLI_thread_unlock(LOCK_DRAW_IMAGE); | ||||
| } | } | ||||
| } | } | ||||
| void draw_image_main_helpers(const bContext *C, ARegion *region) | void draw_image_main_helpers(const bContext *C, ARegion *region) | ||||
| { | { | ||||
| SpaceImage *sima = CTX_wm_space_image(C); | SpaceImage *sima = CTX_wm_space_image(C); | ||||
| Scene *scene = CTX_data_scene(C); | Image *ima = ED_space_image(sima); | ||||
| Image *ima; | |||||
| float zoomx, zoomy; | |||||
| bool show_viewer, show_render, show_paint; | |||||
| ima = ED_space_image(sima); | |||||
| ED_space_image_get_zoom(sima, region, &zoomx, &zoomy); | |||||
| show_viewer = (ima && ima->source == IMA_SRC_VIEWER) != 0; | const bool show_viewer = (ima && ima->source == IMA_SRC_VIEWER) != 0; | ||||
| show_render = (show_viewer && ima->type == IMA_TYPE_R_RESULT) != 0; | const bool 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 */ | |||||
| if (ima && show_render) { | 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); | draw_render_info(C, sima->iuser.scene, ima, region, 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; | ||||
| ▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines | |||||