Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2020-09-11 08:59:48 +0300
committerJeroen Bakker <jeroen@blender.org>2020-09-11 09:08:46 +0300
commitd6525e8d133b787655bdb2c2fcef218591a457c3 (patch)
treeb4dbb06b75005deee918d7816c074a5735be930c /source/blender/editors/space_image
parentd023c4104cb642c839d5868411a3b719f3528421 (diff)
Use DrawManager for Image/UV Editor
This project moves the current UV/Image editor drawing to the draw manager. Why would we do this: **Performance**: Current implementation would draw each texel per time. Multiple texels could be drawn per pixel what would overwrite the previous result. You can notice this when working with large textures. Repeat image drawing made this visible by drawing for a small period of time and stop drawing the rest. Now the rendering is fast and all repeated images are drawn. **Alpha drawing**: Current implementation would draw directly in display space. Giving incorrect results when displaying alpha transparent images. This addresses {T52680}, {T74709}, {T79518} The image editor now can show emission only colors. See {D8234} for examples. **Current Limitations** Using images that are larger than supported by your GPU are resized (eg larger than 16000x16000 are resized to 8k). This leaves some blurring artifacts. It is a low priority to add support back of displaying individual pixels of huge images. There is a design task {T80113} with more detail. **Implementation overview** Introduced an Image Engine in the draw module. this engine is responsible for drawing the texture in the main area of the UV/Image editor. The overlay engine has a edit_uv overlay which is responsible to draw the UV's, shadows and overlays specifically for the UV Image editor. The background + checker pattern is drawn by the overlay_background. The patch will allow us to share overlays between the 3d viewport and UV/Image editor more easily. In most cases we just need to switch the `pos` with the `u` attribute in the vertex shader. The project can be activated in the user preferences as experimental features. In a later commit this will be reversed. Reviewed By: Clément Foucault Differential Revision: https://developer.blender.org/D8234
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r--source/blender/editors/space_image/image_draw.c31
-rw-r--r--source/blender/editors/space_image/image_intern.h1
-rw-r--r--source/blender/editors/space_image/space_image.c77
3 files changed, 66 insertions, 43 deletions
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 058436a46bf..85d153feb4c 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -865,7 +865,7 @@ void draw_image_main(const bContext *C, ARegion *region)
Image *ima;
ImBuf *ibuf;
float zoomx, zoomy;
- bool show_viewer, show_render, show_paint, show_stereo3d, show_multilayer;
+ bool show_viewer, show_stereo3d, show_multilayer;
void *lock;
/* XXX can we do this in refresh? */
@@ -898,9 +898,6 @@ void draw_image_main(const bContext *C, ARegion *region)
}
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);
@@ -998,16 +995,32 @@ void draw_image_main(const bContext *C, ARegion *region)
}
draw_udim_tile_grids(region, sima, ima);
-
- /* paint helpers */
- if (show_paint) {
- draw_image_paint_helpers(C, region, scene, zoomx, zoomy);
- }
+ draw_image_main_helpers(C, region);
if (show_viewer) {
BLI_thread_unlock(LOCK_DRAW_IMAGE);
}
+}
+
+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;
+ 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 */
if (ima && show_render) {
draw_render_info(C, sima->iuser.scene, ima, region, zoomx, zoomy);
diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h
index e6f5988aed8..100556ad29a 100644
--- a/source/blender/editors/space_image/image_intern.h
+++ b/source/blender/editors/space_image/image_intern.h
@@ -37,6 +37,7 @@ extern const char *image_context_dir[]; /* doc access */
/* image_draw.c */
void draw_image_main(const struct bContext *C, struct ARegion *region);
+void draw_image_main_helpers(const struct bContext *C, struct ARegion *region);
void draw_image_cache(const struct bContext *C, struct ARegion *region);
void draw_image_grease_pencil(struct bContext *C, bool onlyv2d);
void draw_image_sample_line(struct SpaceImage *sima);
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index aa3f6446d51..032196b33bd 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -76,6 +76,7 @@
#include "GPU_framebuffer.h"
#include "GPU_viewport.h"
+#include "DRW_engine.h"
#include "DRW_engine_types.h"
#include "image_intern.h"
@@ -638,8 +639,6 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
View2D *v2d = &region->v2d;
- // View2DScrollers *scrollers;
- float col[3];
GPUViewport *viewport = WM_draw_region_get_viewport(region);
GPUFrameBuffer *framebuffer_default, *framebuffer_overlay;
@@ -647,35 +646,14 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
framebuffer_default = GPU_viewport_framebuffer_default_get(viewport);
framebuffer_overlay = GPU_viewport_framebuffer_overlay_get(viewport);
- GPU_framebuffer_bind(framebuffer_default);
- GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f);
-
- GPU_framebuffer_bind(framebuffer_overlay);
-
/* XXX not supported yet, disabling for now */
scene->r.scemode &= ~R_COMP_CROP;
- /* clear and setup matrix */
- UI_GetThemeColor3fv(TH_BACK, col);
- srgb_to_linearrgb_v3_v3(col, col);
- GPU_clear_color(col[0], col[1], col[2], 1.0f);
- GPU_depth_test(GPU_DEPTH_NONE);
-
image_user_refresh_scene(C, sima);
/* we set view2d from own zoom and offset each time */
image_main_region_set_view2d(sima, region);
- /* we draw image in pixelspace */
- draw_image_main(C, region);
-
- /* and uvs in 0.0-1.0 space */
- UI_view2d_view_ortho(v2d);
-
- ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW);
-
- ED_uvedit_draw_main(sima, scene, view_layer, obedit, obact, depsgraph);
-
/* check for mask (delay draw) */
if (ED_space_image_show_uvedit(sima, obedit)) {
show_uvedit = true;
@@ -687,21 +665,52 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
show_curve = true;
}
- ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW);
+ /* we draw image in pixelspace */
+ if (U.experimental.use_drw_image_editor) {
+ DRW_draw_view(C);
+ draw_image_main_helpers(C, region);
- if (sima->flag & SI_SHOW_GPENCIL) {
- /* Grease Pencil too (in addition to UV's) */
- draw_image_grease_pencil((bContext *)C, true);
+ /* sample line */
+ UI_view2d_view_ortho(v2d);
+ draw_image_sample_line(sima);
+ UI_view2d_view_restore(C);
}
+ else {
+ GPU_framebuffer_bind(framebuffer_default);
+ GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f);
+
+ GPU_framebuffer_bind(framebuffer_overlay);
+
+ float col[3];
+ /* clear and setup matrix */
+ UI_GetThemeColor3fv(TH_BACK, col);
+ srgb_to_linearrgb_v3_v3(col, col);
+ GPU_clear_color(col[0], col[1], col[2], 1.0f);
+ GPU_depth_test(GPU_DEPTH_NONE);
+ draw_image_main(C, region);
+
+ /* and uvs in 0.0-1.0 space */
+ UI_view2d_view_ortho(v2d);
+
+ ED_region_draw_cb_draw(C, region, REGION_DRAW_PRE_VIEW);
- /* sample line */
- draw_image_sample_line(sima);
+ ED_uvedit_draw_main(sima, scene, view_layer, obedit, obact, depsgraph);
- UI_view2d_view_restore(C);
+ ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW);
- if (sima->flag & SI_SHOW_GPENCIL) {
- /* draw Grease Pencil - screen space only */
- draw_image_grease_pencil((bContext *)C, false);
+ if (sima->flag & SI_SHOW_GPENCIL) {
+ /* Grease Pencil too (in addition to UV's) */
+ draw_image_grease_pencil((bContext *)C, true);
+ }
+ /* sample line */
+ draw_image_sample_line(sima);
+
+ UI_view2d_view_restore(C);
+
+ if (sima->flag & SI_SHOW_GPENCIL) {
+ /* draw Grease Pencil - screen space only */
+ draw_image_grease_pencil((bContext *)C, false);
+ }
}
if (mask) {
@@ -741,7 +750,7 @@ static void image_main_region_draw(const bContext *C, ARegion *region)
C);
}
- if (show_uvedit || mask || show_curve) {
+ if ((show_uvedit || mask || show_curve) && !U.experimental.use_drw_image_editor) {
UI_view2d_view_ortho(v2d);
ED_image_draw_cursor(region, sima->cursor);
UI_view2d_view_restore(C);