diff options
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 24 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_draw.c | 562 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_edit.c | 28 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_intern.h | 5 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 149 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 154 |
7 files changed, 432 insertions, 491 deletions
diff --git a/source/blender/editors/space_image/CMakeLists.txt b/source/blender/editors/space_image/CMakeLists.txt index c60d194b620..0bc09981ba5 100644 --- a/source/blender/editors/space_image/CMakeLists.txt +++ b/source/blender/editors/space_image/CMakeLists.txt @@ -25,6 +25,7 @@ set(INC ../../blenlib ../../blentranslation ../../bmesh + ../../depsgraph ../../imbuf ../../gpu ../../makesdna diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 8b8aabb2ce0..7236a99ad80 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -291,23 +291,24 @@ static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void * { uiBlock *block = uiLayoutGetBlock(layout); Image *image = image_p; - int slot; + int slot_id; uiDefBut(block, UI_BTYPE_LABEL, 0, IFACE_("Slot"), 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); uiItemS(layout); - slot = IMA_MAX_RENDER_SLOT; - while (slot--) { + slot_id = BLI_listbase_count(&image->renderslots) - 1; + for (RenderSlot *slot = image->renderslots.last; slot; slot = slot->prev) { char str[64]; - if (image->render_slots[slot].name[0] != '\0') { - BLI_strncpy(str, image->render_slots[slot].name, sizeof(str)); + if (slot->name[0] != '\0') { + BLI_strncpy(str, slot->name, sizeof(str)); } else { - BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot + 1); + BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot_id + 1); } uiDefButS(block, UI_BTYPE_BUT_MENU, B_NOP, str, 0, 0, - UI_UNIT_X * 5, UI_UNIT_X, &image->render_slot, (float) slot, 0.0, 0, -1, ""); + UI_UNIT_X * 5, UI_UNIT_X, &image->render_slot, (float) slot_id, 0.0, 0, -1, ""); + slot_id--; } } @@ -708,8 +709,9 @@ static void uiblock_layer_pass_buttons( /* menu buts */ if (render_slot) { char str[64]; - if (image->render_slots[*render_slot].name[0] != '\0') { - BLI_strncpy(str, image->render_slots[*render_slot].name, sizeof(str)); + RenderSlot *slot = BKE_image_get_renderslot(image, *render_slot); + if (slot->name[0] != '\0') { + BLI_strncpy(str, slot->name, sizeof(str)); } else { BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), *render_slot + 1); @@ -1313,7 +1315,7 @@ static int image_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) void IMAGE_OT_properties(wmOperatorType *ot) { - ot->name = "Properties"; + ot->name = "Toggle Sidebar"; ot->idname = "IMAGE_OT_properties"; ot->description = "Toggle the properties region visibility"; @@ -1337,7 +1339,7 @@ static int image_scopes_toggle_exec(bContext *C, wmOperator *UNUSED(op)) void IMAGE_OT_toolshelf(wmOperatorType *ot) { - ot->name = "Tool Shelf"; + ot->name = "Toggle Toolbar"; ot->idname = "IMAGE_OT_toolshelf"; ot->description = "Toggles tool shelf display"; diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index c358b38520a..1e2d668018f 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -60,9 +60,12 @@ #include "BKE_image.h" #include "BKE_paint.h" -#include "BIF_gl.h" #include "BIF_glutil.h" +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" +#include "GPU_matrix.h" + #include "BLF_api.h" #include "ED_gpencil.h" @@ -87,7 +90,6 @@ static void draw_render_info(const bContext *C, float zoomx, float zoomy) { - RenderResult *rr; Render *re = RE_GetSceneRender(scene); RenderData *rd = RE_engine_get_render_data(re); Scene *stats_scene = ED_render_job_get_scene(C); @@ -95,7 +97,7 @@ static void draw_render_info(const bContext *C, stats_scene = CTX_data_scene(C); } - rr = BKE_image_acquire_renderresult(stats_scene, ima); + RenderResult *rr = BKE_image_acquire_renderresult(stats_scene, ima); if (rr && rr->text) { float fill_color[4] = {0.0f, 0.0f, 0.0f, 0.25f}; @@ -107,39 +109,41 @@ static void draw_render_info(const bContext *C, if (re) { int total_tiles; bool need_free_tiles; - rcti *tiles; - - tiles = RE_engine_get_current_tiles(re, &total_tiles, &need_free_tiles); + rcti *tiles = RE_engine_get_current_tiles(re, &total_tiles, &need_free_tiles); if (total_tiles) { - int i, x, y; - rcti *tile; - /* find window pixel coordinates of origin */ + int x, y; UI_view2d_view_to_region(&ar->v2d, 0.0f, 0.0f, &x, &y); - glPushMatrix(); - glTranslatef(x, y, 0.0f); - glScalef(zoomx, zoomy, 1.0f); + gpuPushMatrix(); + gpuTranslate2f(x, y); + gpuScale2f(zoomx, zoomy); if (rd->mode & R_BORDER) { - glTranslatef((int)(-rd->border.xmin * rd->xsch * rd->size / 100.0f), - (int)(-rd->border.ymin * rd->ysch * rd->size / 100.0f), - 0.0f); + /* TODO: round or floor instead of casting to int */ + gpuTranslate2f((int)(-rd->border.xmin * rd->xsch * rd->size * 0.01f), + (int)(-rd->border.ymin * rd->ysch * rd->size * 0.01f)); } - UI_ThemeColor(TH_FACE_SELECT); + unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformThemeColor(TH_FACE_SELECT); glLineWidth(1.0f); - for (i = 0, tile = tiles; i < total_tiles; i++, tile++) { - glaDrawBorderCorners(tile, zoomx, zoomy); + + rcti *tile = tiles; + for (int i = 0; i < total_tiles; i++, tile++) { + immDrawBorderCorners(pos, tile, zoomx, zoomy); } + immUnbindProgram(); + if (need_free_tiles) { MEM_freeN(tiles); } - glPopMatrix(); + gpuPopMatrix(); } } } @@ -166,31 +170,37 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d float hue = 0, sat = 0, val = 0, lum = 0, u = 0, v = 0; float col[4], finalcol[4]; - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); + unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + /* noisy, high contrast make impossible to read if lower alpha is used. */ - glColor4ub(0, 0, 0, 190); - glRecti(0.0, 0.0, BLI_rcti_size_x(&ar->winrct) + 1, UI_UNIT_Y); + immUniformColor4ub(0, 0, 0, 190); + immRecti(pos, 0, 0, BLI_rcti_size_x(&ar->winrct) + 1, UI_UNIT_Y); + + immUnbindProgram(); + glDisable(GL_BLEND); BLF_size(blf_mono_font, 11 * U.pixelsize, U.dpi); - glColor3ub(255, 255, 255); + BLF_color3ub(blf_mono_font, 255, 255, 255); BLI_snprintf(str, sizeof(str), "X:%-4d Y:%-4d |", x, y); BLF_position(blf_mono_font, dx, dy, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str, sizeof(str)); if (zp) { - glColor3ub(255, 255, 255); + BLF_color3ub(blf_mono_font, 255, 255, 255); BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f + 0.5f * (((float)*zp) / (float)0x7fffffff)); BLF_position(blf_mono_font, dx, dy, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str, sizeof(str)); } if (zpf) { - glColor3ub(255, 255, 255); + BLF_color3ub(blf_mono_font, 255, 255, 255); BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf); BLF_position(blf_mono_font, dx, dy, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); @@ -204,14 +214,14 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d else if (cp != NULL) { BLI_snprintf(str, sizeof(str), " Val:%-.3f |", cp[0] / 255.0f); } - glColor3ub(255, 255, 255); + BLF_color3ub(blf_mono_font, 255, 255, 255); BLF_position(blf_mono_font, dx, dy, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str, sizeof(str)); } if (channels >= 3) { - glColor3ubv(red); + BLF_color3ubv(blf_mono_font, red); if (fp) BLI_snprintf(str, sizeof(str), " R:%-.5f", fp[0]); else if (cp) @@ -222,7 +232,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str, sizeof(str)); - glColor3ubv(green); + BLF_color3ubv(blf_mono_font, green); if (fp) BLI_snprintf(str, sizeof(str), " G:%-.5f", fp[1]); else if (cp) @@ -233,7 +243,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str, sizeof(str)); - glColor3ubv(blue); + BLF_color3ubv(blf_mono_font, blue); if (fp) BLI_snprintf(str, sizeof(str), " B:%-.5f", fp[2]); else if (cp) @@ -245,7 +255,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d dx += BLF_width(blf_mono_font, str, sizeof(str)); if (channels == 4) { - glColor3ub(255, 255, 255); + BLF_color3ub(blf_mono_font, 255, 255, 255); if (fp) BLI_snprintf(str, sizeof(str), " A:%-.4f", fp[3]); else if (cp) @@ -267,9 +277,9 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d rgba[3] = linearcol[3]; if (use_default_view) - IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, NULL, &scene->display_settings); + IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, NULL, &scene->display_settings); else - IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, &scene->view_settings, &scene->display_settings); + IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, &scene->view_settings, &scene->display_settings); BLI_snprintf(str, sizeof(str), " | CM R:%-.4f G:%-.4f B:%-.4f", rgba[0], rgba[1], rgba[2]); BLF_position(blf_mono_font, dx, dy, 0); @@ -305,9 +315,9 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d if (color_manage) { if (use_default_view) - IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, NULL, &scene->display_settings); + IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, NULL, &scene->display_settings); else - IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, &scene->view_settings, &scene->display_settings); + IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, &scene->view_settings, &scene->display_settings); } else { copy_v4_v4(finalcol, col); @@ -318,13 +328,18 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d BLI_rcti_init(&color_rect, dx, dx + (1.5f * UI_UNIT_X), 0.15f * UI_UNIT_Y, 0.85f * UI_UNIT_Y); + /* BLF uses immediate mode too, so we must reset our vertex format */ + pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + if (channels == 4) { rcti color_rect_half; int color_quater_x, color_quater_y; color_rect_half = color_rect; color_rect_half.xmax = BLI_rcti_cent_x(&color_rect); - glRecti(color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax); + /* what color ??? */ + immRecti(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax); color_rect_half = color_rect; color_rect_half.xmin = BLI_rcti_cent_x(&color_rect); @@ -332,31 +347,34 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d color_quater_x = BLI_rcti_cent_x(&color_rect_half); color_quater_y = BLI_rcti_cent_y(&color_rect_half); - glColor4ub(UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, 255); - glRecti(color_rect_half.xmin, color_rect_half.ymin, color_rect_half.xmax, color_rect_half.ymax); + immUniformColor3ub(UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK); + immRecti(pos, color_rect_half.xmin, color_rect_half.ymin, color_rect_half.xmax, color_rect_half.ymax); - glColor4ub(UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, 255); - glRecti(color_quater_x, color_quater_y, color_rect_half.xmax, color_rect_half.ymax); - glRecti(color_rect_half.xmin, color_rect_half.ymin, color_quater_x, color_quater_y); + immUniformColor3ub(UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT); + immRecti(pos, color_quater_x, color_quater_y, color_rect_half.xmax, color_rect_half.ymax); + immRecti(pos, color_rect_half.xmin, color_rect_half.ymin, color_quater_x, color_quater_y); glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glColor4f(UNPACK3(finalcol), fp ? fp[3] : (cp[3] / 255.0f)); - glRecti(color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax); + immUniformColor3fvAlpha(finalcol, fp ? fp[3] : (cp[3] / 255.0f)); + immRecti(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax); glDisable(GL_BLEND); } else { - glColor3fv(finalcol); - glRecti(color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax); + immUniformColor3fv(finalcol); + immRecti(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax); } + immUnbindProgram(); /* draw outline */ - glColor3ub(128, 128, 128); - sdrawbox(color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax); + pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor3ub(128, 128, 128); + imm_draw_box_wire_2d(pos, color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax); + immUnbindProgram(); dx += 1.75f * UI_UNIT_X; - glColor3ub(255, 255, 255); + BLF_color3ub(blf_mono_font, 255, 255, 255); if (channels == 1) { if (fp) { rgb_to_hsv(fp[0], fp[0], fp[0], &hue, &sat, &val); @@ -375,7 +393,6 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d BLI_snprintf(str, sizeof(str), " L:%-.4f", lum); BLF_position(blf_mono_font, dx, dy, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str, sizeof(str)); } else if (channels >= 3) { rgb_to_hsv(finalcol[0], finalcol[1], finalcol[2], &hue, &sat, &val); @@ -399,69 +416,36 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d BLI_snprintf(str, sizeof(str), " L:%-.4f", lum); BLF_position(blf_mono_font, dx, dy, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); - dx += BLF_width(blf_mono_font, str, sizeof(str)); } - - (void)dx; } /* image drawing */ - -static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, unsigned int *recti) +static void sima_draw_zbuf_pixels(float x1, float y1, int rectx, int recty, int *rect, + float zoomx, float zoomy) { + float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; - /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ - if (ENDIAN_ORDER == B_ENDIAN) - glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); + /* Slowwww */ + int *recti = MEM_mallocN(rectx * recty * sizeof(int), "temp"); + for (int a = rectx * recty - 1; a >= 0; a--) { + /* zbuffer values are signed, so we need to shift color range */ + recti[a] = rect[a] * 0.5f + 0.5f; + } - glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_UNSIGNED_INT, recti); - glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); -} + IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); + GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red); -static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, float *rectf) -{ - float *trectf = MEM_mallocN(rectx * recty * 4, "temp"); - int a, b; - - for (a = rectx * recty - 1, b = 4 * a + 3; a >= 0; a--, b -= 4) - trectf[a] = rectf[b]; - - glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_FLOAT, trectf); - MEM_freeN(trectf); - /* ogl trick below is slower... (on ATI 9600) */ -// glColorMask(1, 0, 0, 0); -// glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf + 3); -// glColorMask(0, 1, 0, 0); -// glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf + 2); -// glColorMask(0, 0, 1, 0); -// glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_RGBA, GL_FLOAT, rectf + 1); -// glColorMask(1, 1, 1, 1); -} + immDrawPixelsTex(&state, x1, y1, rectx, recty, GL_RED, GL_INT, GL_NEAREST, recti, zoomx, zoomy, NULL); -static void sima_draw_zbuf_pixels(float x1, float y1, int rectx, int recty, int *recti) -{ - /* zbuffer values are signed, so we need to shift color range */ - glPixelTransferf(GL_RED_SCALE, 0.5f); - glPixelTransferf(GL_GREEN_SCALE, 0.5f); - glPixelTransferf(GL_BLUE_SCALE, 0.5f); - glPixelTransferf(GL_RED_BIAS, 0.5f); - glPixelTransferf(GL_GREEN_BIAS, 0.5f); - glPixelTransferf(GL_BLUE_BIAS, 0.5f); - - glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_INT, recti); - - glPixelTransferf(GL_RED_SCALE, 1.0f); - glPixelTransferf(GL_GREEN_SCALE, 1.0f); - glPixelTransferf(GL_BLUE_SCALE, 1.0f); - glPixelTransferf(GL_RED_BIAS, 0.0f); - glPixelTransferf(GL_GREEN_BIAS, 0.0f); - glPixelTransferf(GL_BLUE_BIAS, 0.0f); + MEM_freeN(recti); } -static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rectx, int recty, float *rect_float) +static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rectx, int recty, + float *rect_float, float zoomx, float zoomy) { float bias, scale, *rectf, clipend; int a; + float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; if (scene->camera && scene->camera->type == OB_CAMERA) { bias = ((Camera *)scene->camera->data)->clipsta; @@ -474,7 +458,7 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec clipend = 100.0f; } - rectf = MEM_mallocN(rectx * recty * 4, "temp"); + rectf = MEM_mallocN(rectx * recty * sizeof(float), "temp"); for (a = rectx * recty - 1; a >= 0; a--) { if (rect_float[a] > clipend) rectf[a] = 0.0f; @@ -485,196 +469,83 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec rectf[a] *= rectf[a]; } } - glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_FLOAT, rectf); - MEM_freeN(rectf); -} + IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); + GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, red); -static int draw_image_channel_offset(SpaceImage *sima) -{ -#ifdef __BIG_ENDIAN__ - if (sima->flag & SI_SHOW_R) return 0; - else if (sima->flag & SI_SHOW_G) return 1; - else return 2; -#else - if (sima->flag & SI_SHOW_R) return 1; - else if (sima->flag & SI_SHOW_G) return 2; - else return 3; -#endif + immDrawPixelsTex(&state, x1, y1, rectx, recty, GL_RED, GL_FLOAT, GL_NEAREST, rectf, zoomx, zoomy, NULL); + + MEM_freeN(rectf); } static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, Scene *scene, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy) { int x, y; - /* set zoom */ - glPixelZoom(zoomx, zoomy); - - glaDefine2DArea(&ar->winrct); - /* find window pixel coordinates of origin */ UI_view2d_view_to_region(&ar->v2d, fx, fy, &x, &y); /* this part is generic image display */ - if (sima->flag & SI_SHOW_ALPHA) { - if (ibuf->rect) - sima_draw_alpha_pixels(x, y, ibuf->x, ibuf->y, ibuf->rect); - else if (ibuf->rect_float && ibuf->channels == 4) - sima_draw_alpha_pixelsf(x, y, ibuf->x, ibuf->y, ibuf->rect_float); - } - else if (sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1))) { + if (sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1))) { if (ibuf->zbuf) - sima_draw_zbuf_pixels(x, y, ibuf->x, ibuf->y, ibuf->zbuf); + sima_draw_zbuf_pixels(x, y, ibuf->x, ibuf->y, ibuf->zbuf, zoomx, zoomy); else if (ibuf->zbuf_float) - sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->zbuf_float); + sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->zbuf_float, zoomx, zoomy); else if (ibuf->channels == 1) - sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float); + sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float, zoomx, zoomy); } 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); + if (sima->flag & SI_USE_ALPHA) { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + imm_draw_box_checker_2d(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy); - fdrawcheckerboard(x, y, x + ibuf->x * zoomx, y + ibuf->y * zoomy); + glEnable(GL_BLEND); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); } - if ((sima->flag & (SI_SHOW_R | SI_SHOW_G | SI_SHOW_B)) == 0) { - 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); + /* If RGBA display with color management */ + if ((sima->flag & (SI_SHOW_R | SI_SHOW_G | SI_SHOW_B | SI_SHOW_ALPHA)) == 0) { + glaDrawImBuf_glsl_ctx_clipping(C, ibuf, x, y, GL_NEAREST, - 0, 0, clip_max_x, clip_max_y); + 0, 0, clip_max_x, clip_max_y, zoomx, zoomy); } else { + float shuffle[4] = {0.0f, 0.0f, 0.0f, 0.0f}; unsigned char *display_buffer; void *cache_handle; - - /* TODO(sergey): Ideally GLSL shading should be capable of either - * disabling some channels or displaying buffer with custom offset. - */ - display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); - - if (display_buffer != NULL) { - int channel_offset = draw_image_channel_offset(sima); - glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, - display_buffer - (4 - channel_offset)); - } - if (cache_handle != NULL) { - IMB_display_buffer_release(cache_handle); + ColorManagedViewSettings *view_settings; + ColorManagedDisplaySettings *display_settings; + + if (sima->flag & SI_SHOW_R) + shuffle[0] = 1.0f; + else if (sima->flag & SI_SHOW_G) + shuffle[1] = 1.0f; + else if (sima->flag & SI_SHOW_B) + shuffle[2] = 1.0f; + else if (sima->flag & SI_SHOW_ALPHA) + shuffle[3] = 1.0f; + + IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); + GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, shuffle); + + IMB_colormanagement_display_settings_from_ctx(C, &view_settings, &display_settings); + display_buffer = IMB_display_buffer_acquire(ibuf, view_settings, display_settings, &cache_handle); + + if (display_buffer) { + immDrawPixelsTex_clipping(&state, x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer, + 0, 0, clip_max_x, clip_max_y, zoomx, zoomy, NULL); } + + IMB_display_buffer_release(cache_handle); } if (sima->flag & SI_USE_ALPHA) glDisable(GL_BLEND); } - - /* reset zoom */ - glPixelZoom(1.0f, 1.0f); -} - -static unsigned int *get_part_from_buffer(unsigned int *buffer, int width, short startx, short starty, short endx, short endy) -{ - unsigned int *rt, *rp, *rectmain; - short y, heigth, len; - - /* the right offset in rectot */ - - rt = buffer + (starty * width + startx); - - len = (endx - startx); - heigth = (endy - starty); - - rp = rectmain = MEM_mallocN(heigth * len * sizeof(int), "rect"); - - for (y = 0; y < heigth; y++) { - memcpy(rp, rt, len * 4); - rt += width; - rp += len; - } - return rectmain; -} - -static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy) -{ - unsigned char *display_buffer; - unsigned int *rect; - int dx, dy, sx, sy, x, y; - void *cache_handle; - int channel_offset = -1; - - /* verify valid values, just leave this a while */ - if (ima->xrep < 1) return; - if (ima->yrep < 1) return; - - if (ima->flag & IMA_VIEW_AS_RENDER) - display_buffer = IMB_display_buffer_acquire(ibuf, &scene->view_settings, &scene->display_settings, &cache_handle); - else - display_buffer = IMB_display_buffer_acquire(ibuf, NULL, &scene->display_settings, &cache_handle); - - if (!display_buffer) - return; - - glPixelZoom(zoomx, zoomy); - - if (sima->curtile >= ima->xrep * ima->yrep) - sima->curtile = ima->xrep * ima->yrep - 1; - - /* retrieve part of image buffer */ - dx = max_ii(ibuf->x / ima->xrep, 1); - dy = max_ii(ibuf->y / ima->yrep, 1); - sx = (sima->curtile % ima->xrep) * dx; - sy = (sima->curtile / ima->xrep) * dy; - rect = get_part_from_buffer((unsigned int *)display_buffer, ibuf->x, sx, sy, sx + dx, sy + dy); - - /* draw repeated */ - if ((sima->flag & (SI_SHOW_R | SI_SHOW_G | SI_SHOW_B)) != 0) { - channel_offset = draw_image_channel_offset(sima); - } - for (sy = 0; sy + dy <= ibuf->y; sy += dy) { - for (sx = 0; sx + dx <= ibuf->x; sx += dx) { - UI_view2d_view_to_region(&ar->v2d, fx + (float)sx / (float)ibuf->x, fy + (float)sy / (float)ibuf->y, &x, &y); - if (channel_offset == -1) { - glaDrawPixelsSafe(x, y, dx, dy, dx, GL_RGBA, GL_UNSIGNED_BYTE, rect); - } - else { - glaDrawPixelsSafe(x, y, dx, dy, dx, GL_LUMINANCE, GL_UNSIGNED_INT, - (unsigned char *)rect - (4 - channel_offset)); - } - } - } - - glPixelZoom(1.0f, 1.0f); - - IMB_display_buffer_release(cache_handle); - - MEM_freeN(rect); -} - -static void draw_image_buffer_repeated(const bContext *C, SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float zoomx, float zoomy) -{ - 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); - - int x; - - for (x = xmin; x < xmax; x++) { - int y; - for (y = ymin; y < ymax; y++) { - if (ima && (ima->tpageflag & IMA_TILES)) - draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy); - else - draw_image_buffer(C, sima, ar, scene, ibuf, x, y, zoomx, zoomy); - - /* only draw until running out of time */ - if ((PIL_check_seconds_timer() - time_current) > 0.25) - return; - } - } } /* draw uv edit */ @@ -701,134 +572,62 @@ void draw_image_sample_line(SpaceImage *sima) if (sima->sample_line_hist.flag & HISTO_FLAG_SAMPLELINE) { Histogram *hist = &sima->sample_line_hist; - glBegin(GL_LINES); - glColor3ub(0, 0, 0); - glVertex2fv(hist->co[0]); - glVertex2fv(hist->co[1]); - glEnd(); + Gwn_VertFormat *format = immVertexFormat(); + unsigned int shdr_dashed_pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - setlinestyle(1); - glBegin(GL_LINES); - glColor3ub(255, 255, 255); - glVertex2fv(hist->co[0]); - glVertex2fv(hist->co[1]); - glEnd(); - setlinestyle(0); + immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR); - } -} + float viewport_size[4]; + glGetFloatv(GL_VIEWPORT, viewport_size); + immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC); -/* XXX becomes WM paint cursor */ -#if 0 -static void draw_image_view_tool(Scene *scene) -{ - ToolSettings *settings = scene->toolsettings; - Brush *brush = settings->imapaint.brush; - int mval[2]; - float radius; - int draw = 0; - - if (brush) { - if (settings->imapaint.flag & IMAGEPAINT_DRAWING) { - if (settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL_DRAWING) - draw = 1; - } - else if (settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL) - draw = 1; - - if (draw) { - getmouseco_areawin(mval); + immUniform1i("num_colors", 2); /* Advanced dashes. */ + immUniformArray4fv("colors", (float *)(float[][4]){{1.0f, 1.0f, 1.0f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2); + immUniform1f("dash_width", 2.0f); - radius = BKE_brush_size_get(brush) * G.sima->zoom; - fdrawXORcirc(mval[0], mval[1], radius); + immBegin(GWN_PRIM_LINES, 2); + immVertex2fv(shdr_dashed_pos, hist->co[0]); + immVertex2fv(shdr_dashed_pos, hist->co[1]); + immEnd(); - if (brush->innerradius != 1.0) { - radius *= brush->innerradius; - fdrawXORcirc(mval[0], mval[1], radius); - } - } + immUnbindProgram(); } } -#endif - -static unsigned char *get_alpha_clone_image(const bContext *C, Scene *scene, int *width, int *height) -{ - Brush *brush = BKE_paint_brush(&scene->toolsettings->imapaint.paint); - ImBuf *ibuf; - unsigned int size, alpha; - unsigned char *display_buffer; - unsigned char *rect, *cp; - void *cache_handle; - - if (!brush || !brush->clone.image) - return NULL; - - ibuf = BKE_image_acquire_ibuf(brush->clone.image, NULL, NULL); - - if (!ibuf) - return NULL; - - 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 NULL; - } - - rect = MEM_dupallocN(display_buffer); - - IMB_display_buffer_release(cache_handle); - - if (!rect) { - BKE_image_release_ibuf(brush->clone.image, ibuf, NULL); - return NULL; - } - - *width = ibuf->x; - *height = ibuf->y; - - size = (*width) * (*height); - alpha = (unsigned char)255 * brush->clone.alpha; - cp = rect; - - while (size-- > 0) { - cp[3] = alpha; - cp += 4; - } - - BKE_image_release_ibuf(brush->clone.image, ibuf, NULL); - - return rect; -} static void draw_image_paint_helpers(const bContext *C, ARegion *ar, Scene *scene, float zoomx, float zoomy) { Brush *brush; - int x, y, w, h; - unsigned char *clonerect; + int x, y; + ImBuf *ibuf; brush = BKE_paint_brush(&scene->toolsettings->imapaint.paint); - if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) { - /* this is not very efficient, but glDrawPixels doesn't allow - * drawing with alpha */ - clonerect = get_alpha_clone_image(C, scene, &w, &h); + if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE) && brush->clone.image) { + ibuf = BKE_image_acquire_ibuf(brush->clone.image, NULL, NULL); - if (clonerect) { + 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); - glPixelZoom(zoomx, zoomy); + unsigned char *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; + } glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glaDrawPixelsSafe(x, y, w, h, w, GL_RGBA, GL_UNSIGNED_BYTE, clonerect); - glDisable(GL_BLEND); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + + IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); + immDrawPixelsTex(&state, x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer, zoomx, zoomy, col); - glPixelZoom(1.0, 1.0); + glDisable(GL_BLEND); - MEM_freeN(clonerect); + BKE_image_release_ibuf(brush->clone.image, ibuf, NULL); + IMB_display_buffer_release(cache_handle); } } } @@ -899,13 +698,7 @@ void draw_image_main(const bContext *C, ARegion *ar) ED_region_grid_draw(ar, zoomx, zoomy); } else { - - if (sima->flag & SI_DRAW_TILE) - draw_image_buffer_repeated(C, sima, ar, scene, ima, ibuf, zoomx, zoomy); - else if (ima && (ima->tpageflag & IMA_TILES)) - draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, 0.0f, 0.0, zoomx, zoomy); - else - draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy); + draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy); if (sima->flag & SI_DRAW_METADATA) { int x, y; @@ -924,23 +717,6 @@ void draw_image_main(const bContext *C, ARegion *ar) if (show_paint) draw_image_paint_helpers(C, ar, scene, zoomx, zoomy); - /* XXX integrate this code */ -#if 0 - if (ibuf) { - float xoffs = 0.0f, yoffs = 0.0f; - - if (image_preview_active(sa, &xim, &yim)) { - xoffs = scene->r.disprect.xmin; - yoffs = scene->r.disprect.ymin; - glColor3ub(0, 0, 0); - calc_image_view(sima, 'f'); - myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax); - glRectf(0.0f, 0.0f, 1.0f, 1.0f); - glLoadIdentity(); - } - } -#endif - if (show_viewer) { BLI_thread_unlock(LOCK_DRAW_IMAGE); } @@ -983,7 +759,7 @@ void draw_image_cache(const bContext *C, ARegion *ar) } glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); /* Draw cache background. */ ED_region_cache_draw_background(ar); @@ -1002,8 +778,12 @@ void draw_image_cache(const bContext *C, ARegion *ar) /* Draw current frame. */ x = (cfra - sfra) / (efra - sfra + 1) * ar->winx; - UI_ThemeColor(TH_CFRAME); - glRecti(x, 0, x + ceilf(framelen), 8 * UI_DPI_FAC); + unsigned int pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformThemeColor(TH_CFRAME); + immRecti(pos, x, 0, x + ceilf(framelen), 8 * UI_DPI_FAC); + immUnbindProgram(); + ED_region_cache_draw_curfra_label(cfra, x, 8.0f * UI_DPI_FAC); if (mask != NULL) { diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 087f3cdc7fe..f4ecd2e7d34 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -34,6 +34,7 @@ #include "DNA_scene_types.h" #include "BLI_rect.h" +#include "BLI_listbase.h" #include "BKE_colortools.h" #include "BKE_context.h" @@ -45,6 +46,8 @@ #include "IMB_imbuf_types.h" +#include "DEG_depsgraph.h" + #include "ED_image.h" /* own include */ #include "ED_mesh.h" #include "ED_screen.h" @@ -62,11 +65,8 @@ Image *ED_space_image(SpaceImage *sima) } /* called to assign images to UV faces */ -void ED_space_image_set(Main *bmain, SpaceImage *sima, Scene *scene, Object *obedit, Image *ima) +void ED_space_image_set(Main *bmain, SpaceImage *sima, Scene *UNUSED(scene), Object *obedit, Image *ima) { - /* context may be NULL, so use global */ - ED_uvedit_assign_image(bmain, scene, obedit, ima, sima->image); - /* change the space ima after because uvedit_face_visible_test uses the space ima * to check if the face is displayed in UV-localview */ sima->image = ima; @@ -303,17 +303,19 @@ bool ED_image_slot_cycle(struct Image *image, int direction) BLI_assert(ELEM(direction, -1, 1)); - for (i = 1; i < IMA_MAX_RENDER_SLOT; i++) { - slot = (cur + ((direction == -1) ? -i : i)) % IMA_MAX_RENDER_SLOT; - if (slot < 0) slot += IMA_MAX_RENDER_SLOT; + int num_slots = BLI_listbase_count(&image->renderslots); + for (i = 1; i < num_slots; i++) { + slot = (cur + ((direction == -1) ? -i : i)) % num_slots; + if (slot < 0) slot += num_slots; - if (image->renders[slot] || slot == image->last_render_slot) { + RenderSlot *render_slot = BKE_image_get_renderslot(image, slot); + if ((render_slot && render_slot->render) || slot == image->last_render_slot) { image->render_slot = slot; break; } } - if (i == IMA_MAX_RENDER_SLOT) { + if (i == num_slots) { image->render_slot = ((cur == 1) ? 0 : 1); } @@ -375,10 +377,10 @@ bool ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit) } /* matches clip function */ -bool ED_space_image_check_show_maskedit(Scene *scene, SpaceImage *sima) +bool ED_space_image_check_show_maskedit(SpaceImage *sima, ViewLayer *view_layer) { /* check editmode - this is reserved for UV editing */ - Object *ob = OBACT; + Object *ob = OBACT(view_layer); if (ob && ob->mode & OB_MODE_EDIT && ED_space_image_show_uvedit(sima, ob)) { return false; } @@ -391,8 +393,8 @@ int ED_space_image_maskedit_poll(bContext *C) SpaceImage *sima = CTX_wm_space_image(C); if (sima) { - Scene *scene = CTX_data_scene(C); - return ED_space_image_check_show_maskedit(scene, sima); + ViewLayer *view_layer = CTX_data_view_layer(C); + return ED_space_image_check_show_maskedit(sima, view_layer); } return false; diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index 0847a04a993..49c2690daaf 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -83,6 +83,9 @@ void IMAGE_OT_unpack(struct wmOperatorType *ot); void IMAGE_OT_invert(struct wmOperatorType *ot); void IMAGE_OT_cycle_render_slot(struct wmOperatorType *ot); +void IMAGE_OT_clear_render_slot(struct wmOperatorType *ot); +void IMAGE_OT_add_render_slot(struct wmOperatorType *ot); +void IMAGE_OT_remove_render_slot(struct wmOperatorType *ot); void IMAGE_OT_sample(struct wmOperatorType *ot); void IMAGE_OT_sample_line(struct wmOperatorType *ot); @@ -90,7 +93,7 @@ void IMAGE_OT_curves_point_set(struct wmOperatorType *ot); void IMAGE_OT_change_frame(struct wmOperatorType *ot); -void IMAGE_OT_read_renderlayers(struct wmOperatorType *ot); +void IMAGE_OT_read_viewlayers(struct wmOperatorType *ot); void IMAGE_OT_render_border(struct wmOperatorType *ot); void IMAGE_OT_clear_render_border(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index a441dedc57a..b2116b1a770 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -48,6 +48,7 @@ #include "BLT_translation.h" +#include "DNA_camera_types.h" #include "DNA_object_types.h" #include "DNA_node_types.h" #include "DNA_packedFile_types.h" @@ -56,7 +57,6 @@ #include "BKE_colortools.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_DerivedMesh.h" #include "BKE_icons.h" #include "BKE_image.h" @@ -70,8 +70,9 @@ #include "BKE_sound.h" #include "BKE_scene.h" +#include "DEG_depsgraph.h" + #include "GPU_draw.h" -#include "GPU_buffers.h" #include "IMB_colormanagement.h" #include "IMB_imbuf.h" @@ -277,8 +278,9 @@ static int space_image_main_area_not_uv_brush_poll(bContext *C) Scene *scene = CTX_data_scene(C); ToolSettings *toolsettings = scene->toolsettings; - if (sima && !toolsettings->uvsculpt && !scene->obedit) + if (sima && !toolsettings->uvsculpt && (CTX_data_edit_object(C) == NULL)) { return 1; + } return 0; } @@ -792,6 +794,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) SpaceImage *sima; ARegion *ar; Scene *scene; + ViewLayer *view_layer; Object *obedit; Image *ima; @@ -799,6 +802,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) sima = CTX_wm_space_image(C); ar = CTX_wm_region(C); scene = CTX_data_scene(C); + view_layer = CTX_data_view_layer(C); obedit = CTX_data_edit_object(C); ima = ED_space_image(sima); @@ -810,7 +814,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } } - else if (ED_space_image_check_show_maskedit(scene, sima)) { + else if (ED_space_image_check_show_maskedit(sima, view_layer)) { if (!ED_mask_selected_minmax(C, min, max)) { return OPERATOR_CANCELLED; } @@ -1307,21 +1311,23 @@ static int image_open_exec(bContext *C, wmOperator *op) ED_space_image_set(bmain, sima, scene, obedit, ima); iuser = &sima->iuser; } - else if (sa && sa->spacetype == SPACE_VIEW3D) { - View3D *v3d = sa->spacedata.first; - - for (BGpic *bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) { - if (bgpic->ima == ima) { - iuser = &bgpic->iuser; - break; - } - } - } else { Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; if (tex && tex->type == TEX_IMAGE) { iuser = &tex->iuser; } + + if (iuser == NULL) { + Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data; + if (cam) { + for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) { + if (bgpic->ima == ima) { + iuser = &bgpic->iuser; + break; + } + } + } + } } /* initialize because of new image */ @@ -1425,7 +1431,7 @@ static void image_open_draw(bContext *UNUSED(C), wmOperator *op) /* main draw call */ RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); - uiDefAutoButsRNA(layout, &ptr, image_open_draw_check_prop, '\0'); + uiDefAutoButsRNA(layout, &ptr, image_open_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false); /* image template */ RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr); @@ -2145,7 +2151,7 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op) /* main draw call */ RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr); - uiDefAutoButsRNA(layout, &ptr, image_save_as_draw_check_prop, '\0'); + uiDefAutoButsRNA(layout, &ptr, image_save_as_draw_check_prop, UI_BUT_LABEL_ALIGN_NONE, false); /* multiview template */ if (is_multiview) @@ -2347,7 +2353,7 @@ static int image_reload_exec(bContext *C, wmOperator *UNUSED(op)) // XXX other users? BKE_image_signal(bmain, ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_RELOAD); - DAG_id_tag_update(&ima->id, 0); + DEG_id_tag_update(&ima->id, 0); WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima); @@ -2444,7 +2450,6 @@ static int image_new_exec(bContext *C, wmOperator *op) bScreen *sc; Object *ob = CTX_data_active_object(C); - GPU_drawobject_free(ob->derivedFinal); if (scene->toolsettings->imapaint.canvas) id_us_min(&scene->toolsettings->imapaint.canvas->id); scene->toolsettings->imapaint.canvas = ima; @@ -2458,7 +2463,7 @@ static int image_new_exec(bContext *C, wmOperator *op) SpaceImage *sima_other = (SpaceImage *)sl; if (!sima_other->pin) { - ED_space_image_set(bmain, sima_other, scene, scene->obedit, ima); + ED_space_image_set(bmain, sima_other, scene, obedit, ima); } } } @@ -3459,7 +3464,8 @@ static int image_cycle_render_slot_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL); /* no undo push for browsing existing */ - if (ima->renders[ima->render_slot] || ima->render_slot == ima->last_render_slot) + RenderSlot *slot = BKE_image_get_renderslot(ima, ima->render_slot); + if ((slot && slot->render) || ima->render_slot == ima->last_render_slot) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -3482,6 +3488,97 @@ void IMAGE_OT_cycle_render_slot(wmOperatorType *ot) RNA_def_boolean(ot->srna, "reverse", 0, "Cycle in Reverse", ""); } +/********************* clear render slot operator *********************/ + +static int image_clear_render_slot_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceImage *sima = CTX_wm_space_image(C); + Image *ima = CTX_data_edit_image(C); + + if (!BKE_image_clear_renderslot(ima, &sima->iuser, ima->render_slot)) { + return OPERATOR_CANCELLED; + } + + WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL); + + return OPERATOR_FINISHED; +} + +void IMAGE_OT_clear_render_slot(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Clear Render Slot"; + ot->idname = "IMAGE_OT_clear_render_slot"; + ot->description = "Clear the currently selected render slot"; + + /* api callbacks */ + ot->exec = image_clear_render_slot_exec; + ot->poll = image_cycle_render_slot_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER; +} + +/********************* add render slot operator *********************/ + +static int image_add_render_slot_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Image *ima = CTX_data_edit_image(C); + + RenderSlot *slot = BKE_image_add_renderslot(ima, NULL); + ima->render_slot = BLI_findindex(&ima->renderslots, slot); + + WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL); + + return OPERATOR_FINISHED; +} + +void IMAGE_OT_add_render_slot(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Add Render Slot"; + ot->idname = "IMAGE_OT_add_render_slot"; + ot->description = "Add a new render slot"; + + /* api callbacks */ + ot->exec = image_add_render_slot_exec; + ot->poll = image_cycle_render_slot_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER; +} + +/********************* remove render slot operator *********************/ + +static int image_remove_render_slot_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceImage *sima = CTX_wm_space_image(C); + Image *ima = CTX_data_edit_image(C); + + if (!BKE_image_remove_renderslot(ima, &sima->iuser, ima->render_slot)) { + return OPERATOR_CANCELLED; + } + + WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL); + + return OPERATOR_FINISHED; +} + +void IMAGE_OT_remove_render_slot(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Remove Render Slot"; + ot->idname = "IMAGE_OT_remove_render_slot"; + ot->description = "Remove the current render slot"; + + /* api callbacks */ + ot->exec = image_remove_render_slot_exec; + ot->poll = image_cycle_render_slot_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER; +} + /********************** change frame operator *********************/ static int change_frame_poll(bContext *C) @@ -3600,7 +3697,7 @@ void IMAGE_OT_change_frame(wmOperatorType *ot) /* Reload cached render results... */ /* goes over all scenes, reads render layers */ -static int image_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op)) +static int image_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); @@ -3618,14 +3715,14 @@ static int image_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void IMAGE_OT_read_renderlayers(wmOperatorType *ot) +void IMAGE_OT_read_viewlayers(wmOperatorType *ot) { - ot->name = "Read Render Layers"; - ot->idname = "IMAGE_OT_read_renderlayers"; - ot->description = "Read all the current scene's render layers from cache, as needed"; + ot->name = "Read View Layers"; + ot->idname = "IMAGE_OT_read_viewlayers"; + ot->description = "Read all the current scene's view layers from cache, as needed"; ot->poll = space_image_main_region_poll; - ot->exec = image_read_renderlayers_exec; + ot->exec = image_read_viewlayers_exec; /* flags */ ot->flag = 0; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index dbe7ae578c7..827c39b8033 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -44,10 +44,15 @@ #include "BKE_colortools.h" #include "BKE_context.h" +#include "BKE_editmesh.h" #include "BKE_image.h" +#include "BKE_layer.h" #include "BKE_library.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_material.h" + +#include "DEG_depsgraph.h" #include "IMB_imbuf_types.h" @@ -59,6 +64,7 @@ #include "ED_space_api.h" #include "ED_screen.h" #include "ED_uvedit.h" +#include "ED_transform.h" #include "BIF_gl.h" @@ -66,6 +72,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "WM_message.h" #include "UI_resources.h" #include "UI_interface.h" @@ -156,7 +163,7 @@ ARegion *image_has_tools_region(ScrArea *sa) /* ******************** default callbacks for image space ***************** */ -static SpaceLink *image_new(const bContext *UNUSED(C)) +static SpaceLink *image_new(const ScrArea *UNUSED(area), const Scene *UNUSED(scene)) { ARegion *ar; SpaceImage *simage; @@ -165,12 +172,12 @@ static SpaceLink *image_new(const bContext *UNUSED(C)) simage->spacetype = SPACE_IMAGE; simage->zoom = 1.0f; simage->lock = true; - simage->flag = SI_SHOW_GPENCIL | SI_USE_ALPHA; + simage->flag = SI_SHOW_GPENCIL | SI_USE_ALPHA | SI_COORDFLOATS; simage->iuser.ok = true; simage->iuser.fie_ima = 2; simage->iuser.frames = 100; - simage->iuser.flag = IMA_SHOW_STEREO; + simage->iuser.flag = IMA_SHOW_STEREO | IMA_ANIM_ALWAYS; scopes_new(&simage->scopes); simage->sample_line_hist.height = 100; @@ -180,7 +187,7 @@ static SpaceLink *image_new(const bContext *UNUSED(C)) BLI_addtail(&simage->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; - ar->alignment = RGN_ALIGN_BOTTOM; + ar->alignment = RGN_ALIGN_TOP; /* buttons/list view */ ar = MEM_callocN(sizeof(ARegion), "buttons for image"); @@ -265,6 +272,9 @@ static void image_operatortypes(void) WM_operatortype_append(IMAGE_OT_invert); WM_operatortype_append(IMAGE_OT_cycle_render_slot); + WM_operatortype_append(IMAGE_OT_clear_render_slot); + WM_operatortype_append(IMAGE_OT_add_render_slot); + WM_operatortype_append(IMAGE_OT_remove_render_slot); WM_operatortype_append(IMAGE_OT_sample); WM_operatortype_append(IMAGE_OT_sample_line); @@ -275,7 +285,7 @@ static void image_operatortypes(void) WM_operatortype_append(IMAGE_OT_change_frame); - WM_operatortype_append(IMAGE_OT_read_renderlayers); + WM_operatortype_append(IMAGE_OT_read_viewlayers); WM_operatortype_append(IMAGE_OT_render_border); WM_operatortype_append(IMAGE_OT_clear_render_border); } @@ -289,12 +299,14 @@ static void image_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "IMAGE_OT_new", NKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "IMAGE_OT_open", OKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "IMAGE_OT_reload", RKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "IMAGE_OT_read_renderlayers", RKEY, KM_PRESS, KM_CTRL, 0); + WM_keymap_add_item(keymap, "IMAGE_OT_read_viewlayers", RKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "IMAGE_OT_save", SKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "IMAGE_OT_save_as", F3KEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "IMAGE_OT_save_as", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "IMAGE_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "IMAGE_OT_toolshelf", TKEY, KM_PRESS, 0, 0); + WM_keymap_add_menu(keymap, "IMAGE_MT_specials", WKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, KM_ALT, 0)->ptr, "reverse", true); @@ -349,7 +361,7 @@ static void image_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "toggle", true); /* fast switch to render slots */ - for (i = 0; i < MIN2(IMA_MAX_RENDER_SLOT, 9); i++) { + for (i = 0; i < 9; i++) { kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", ONEKEY + i, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.image.render_slots.active_index"); RNA_int_set(kmi->ptr, "value", i); @@ -404,7 +416,6 @@ static void image_refresh(const bContext *C, ScrArea *sa) { Scene *scene = CTX_data_scene(C); SpaceImage *sima = sa->spacedata.first; - Object *obedit = CTX_data_edit_object(C); Image *ima; ima = ED_space_image(sima); @@ -420,38 +431,11 @@ static void image_refresh(const bContext *C, ScrArea *sa) } } } - else if (ima && (ima->source == IMA_SRC_VIEWER || sima->pin)) { - /* pass */ - } - else if (obedit && obedit->type == OB_MESH) { - Mesh *me = (Mesh *)obedit->data; - struct BMEditMesh *em = me->edit_btmesh; - bool sloppy = true; /* partially selected face is ok */ - bool selected = !(scene->toolsettings->uv_flag & UV_SYNC_SELECTION); /* only selected active face? */ - - if (BKE_scene_use_new_shading_nodes(scene)) { - /* new shading system does not alter image */ - } - else { - /* old shading system, we set texface */ - if (em && EDBM_uv_check(em)) { - MTexPoly *tf; - if (EDBM_uv_active_face_get(em, sloppy, selected, &tf)) { - /* don't need to check for pin here, see above */ - sima->image = tf->tpage; - - if ((sima->flag & SI_EDITTILE) == 0) { - sima->curtile = tf->tile; - } - } - } - } - } } -static void image_listener(bScreen *sc, ScrArea *sa, wmNotifier *wmn) +static void image_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn, Scene *scene, + WorkSpace *workspace) { - Scene *scene = sc->scene; SpaceImage *sima = (SpaceImage *)sa->spacedata.first; /* context changes */ @@ -544,7 +528,8 @@ static void image_listener(bScreen *sc, ScrArea *sa, wmNotifier *wmn) case ND_TRANSFORM: case ND_MODIFIER: { - Object *ob = OBACT; + ViewLayer *view_layer = BKE_view_layer_from_workspace_get(scene, workspace); + Object *ob = OBACT(view_layer); if (ob && (ob == wmn->reference) && (ob->mode & OB_MODE_EDIT)) { if (sima->lock && (sima->flag & SI_DRAWSHADOW)) { ED_area_tag_refresh(sa); @@ -596,6 +581,27 @@ static int image_context(const bContext *C, const char *member, bContextDataResu return 0; } +static void IMAGE_WGT_manipulator2d(wmManipulatorGroupType *wgt) +{ + wgt->name = "UV Transform Manipulator"; + wgt->idname = "IMAGE_WGT_manipulator2d"; + + wgt->flag |= WM_MANIPULATORGROUPTYPE_PERSISTENT; + + wgt->poll = ED_widgetgroup_manipulator2d_poll; + wgt->setup = ED_widgetgroup_manipulator2d_setup; + wgt->refresh = ED_widgetgroup_manipulator2d_refresh; + wgt->draw_prepare = ED_widgetgroup_manipulator2d_draw_prepare; +} + +static void image_widgets(void) +{ + wmManipulatorMapType *mmap_type = WM_manipulatormaptype_ensure( + &(const struct wmManipulatorMapType_Params){SPACE_IMAGE, RGN_TYPE_WINDOW}); + + WM_manipulatorgrouptype_append_and_link(mmap_type, IMAGE_WGT_manipulator2d); +} + /************************** main region ***************************/ /* sets up the fields of the View2D from zoom and offset */ @@ -659,6 +665,16 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *ar) // image space manages own v2d // UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); + /* manipulators */ + if (ar->manipulator_map == NULL) { + const struct wmManipulatorMapType_Params wmap_params = { + .spaceid = SPACE_IMAGE, + .regionid = RGN_TYPE_WINDOW, + }; + ar->manipulator_map = WM_manipulatormap_new_from_type(&wmap_params); + } + WM_manipulatormap_add_handlers(ar, ar->manipulator_map); + /* mask polls mode */ keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -684,7 +700,6 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *ar) WM_event_add_keymap_handler(&ar->handlers, keymap); keymap = WM_keymap_find(wm->defaultconf, "Image", SPACE_IMAGE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - } static void image_main_region_draw(const bContext *C, ARegion *ar) @@ -693,9 +708,11 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) SpaceImage *sima = CTX_wm_space_image(C); Object *obact = CTX_data_active_object(C); Object *obedit = CTX_data_edit_object(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); Mask *mask = NULL; bool curve = false; Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); View2D *v2d = &ar->v2d; //View2DScrollers *scrollers; float col[3]; @@ -721,7 +738,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); - ED_uvedit_draw_main(sima, ar, scene, obedit, obact); + ED_uvedit_draw_main(sima, ar, scene, view_layer, obedit, obact, depsgraph); /* check for mask (delay draw) */ if (ED_space_image_show_uvedit(sima, obedit)) { @@ -790,6 +807,8 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); } + WM_manipulatormap_draw(ar->manipulator_map, C, WM_MANIPULATORMAP_DRAWSTEP_2D); + draw_image_cache(C, ar); /* scrollers? */ @@ -800,10 +819,16 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) #endif } -static void image_main_region_listener(bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar, wmNotifier *wmn) +static void image_main_region_listener( + bScreen *UNUSED(sc), ScrArea *sa, ARegion *ar, + wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ switch (wmn->category) { + case NC_GEOM: + if (ELEM(wmn->data, ND_DATA, ND_SELECT)) + WM_manipulatormap_tag_refresh(ar->manipulator_map); + break; case NC_GPENCIL: if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) ED_region_tag_redraw(ar); @@ -813,6 +838,7 @@ static void image_main_region_listener(bScreen *UNUSED(sc), ScrArea *sa, ARegion case NC_IMAGE: if (wmn->action == NA_PAINTING) ED_region_tag_redraw(ar); + WM_manipulatormap_tag_refresh(ar->manipulator_map); break; case NC_MATERIAL: if (wmn->data == ND_SHADING_LINKS) { @@ -822,6 +848,11 @@ static void image_main_region_listener(bScreen *UNUSED(sc), ScrArea *sa, ARegion ED_region_tag_redraw(ar); } break; + case NC_SCREEN: + if (ELEM(wmn->data, ND_LAYER)) { + ED_region_tag_redraw(ar); + } + break; } } @@ -841,10 +872,12 @@ static void image_buttons_region_init(wmWindowManager *wm, ARegion *ar) static void image_buttons_region_draw(const bContext *C, ARegion *ar) { - ED_region_panels(C, ar, NULL, -1, true); + ED_region_panels(C, ar); } -static void image_buttons_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) +static void image_buttons_region_listener( + bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ switch (wmn->category) { @@ -914,10 +947,12 @@ static void image_tools_region_draw(const bContext *C, ARegion *ar) } ED_space_image_release_buffer(sima, ibuf, lock); - ED_region_panels(C, ar, NULL, -1, true); + ED_region_panels(C, ar); } -static void image_tools_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) +static void image_tools_region_listener( + bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ switch (wmn->category) { @@ -950,6 +985,21 @@ static void image_tools_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa) } } +static void image_tools_region_message_subscribe( + const struct bContext *UNUSED(C), + struct WorkSpace *UNUSED(workspace), struct Scene *UNUSED(scene), + struct bScreen *UNUSED(screen), struct ScrArea *UNUSED(sa), struct ARegion *ar, + struct wmMsgBus *mbus) +{ + wmMsgSubscribeValue msg_sub_value_region_tag_redraw = { + .owner = ar, + .user_data = ar, + .notify = ED_region_do_msg_notify_tag_redraw, + }; + WM_msg_subscribe_rna_anon_prop(mbus, WorkSpace, tools, &msg_sub_value_region_tag_redraw); +} + + /************************* header region **************************/ /* add handlers, stuff you only do once or on area/region changes */ @@ -968,7 +1018,9 @@ static void image_header_region_draw(const bContext *C, ARegion *ar) ED_region_header(C, ar); } -static void image_header_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) +static void image_header_region_listener( + bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, + wmNotifier *wmn, const Scene *UNUSED(scene)) { /* context changes */ switch (wmn->category) { @@ -1037,6 +1089,7 @@ void ED_spacetype_image(void) st->refresh = image_refresh; st->listener = image_listener; st->context = image_context; + st->manipulators = image_widgets; st->id_remap = image_id_remap; /* regions: main window */ @@ -1046,7 +1099,6 @@ void ED_spacetype_image(void) art->init = image_main_region_init; art->draw = image_main_region_draw; art->listener = image_main_region_listener; - BLI_addhead(&st->regiontypes, art); /* regions: listview/buttons */ @@ -1068,6 +1120,7 @@ void ED_spacetype_image(void) art->prefsizex = 220; // XXX art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->listener = image_tools_region_listener; + art->message_subscribe = image_tools_region_message_subscribe; art->init = image_tools_region_init; art->draw = image_tools_region_draw; BLI_addhead(&st->regiontypes, art); @@ -1083,6 +1136,9 @@ void ED_spacetype_image(void) BLI_addhead(&st->regiontypes, art); + /* regions: hud */ + art = ED_area_type_hud(st->spaceid); + BLI_addhead(&st->regiontypes, art); + BKE_spacetype_register(st); } - |