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/draw/engines/overlay/overlay_engine.c
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/draw/engines/overlay/overlay_engine.c')
-rw-r--r--source/blender/draw/engines/overlay/overlay_engine.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c
index 1312408498a..9cdd371ec4e 100644
--- a/source/blender/draw/engines/overlay/overlay_engine.c
+++ b/source/blender/draw/engines/overlay/overlay_engine.c
@@ -29,9 +29,13 @@
#include "ED_view3d.h"
+#include "UI_interface.h"
+
#include "BKE_object.h"
#include "BKE_paint.h"
+#include "DNA_space_types.h"
+
#include "overlay_engine.h"
#include "overlay_private.h"
@@ -48,6 +52,10 @@ static void OVERLAY_engine_init(void *vedata)
const View3D *v3d = draw_ctx->v3d;
const Scene *scene = draw_ctx->scene;
const ToolSettings *ts = scene->toolsettings;
+ const SpaceImage *sima = (SpaceImage *)draw_ctx->space_data;
+ BLI_assert(v3d || sima);
+
+ OVERLAY_shader_library_ensure();
if (!stl->pd) {
/* Alloc transient pointers */
@@ -55,6 +63,14 @@ static void OVERLAY_engine_init(void *vedata)
}
OVERLAY_PrivateData *pd = stl->pd;
+ pd->is_image_editor = sima != NULL;
+
+ if (pd->is_image_editor) {
+ pd->clipping_state = 0;
+ OVERLAY_grid_init(data);
+ OVERLAY_edit_uv_init(data);
+ return;
+ }
pd->hide_overlays = (v3d->flag2 & V3D_HIDE_OVERLAYS) != 0;
pd->ctx_mode = CTX_data_mode_enum_ex(
@@ -122,6 +138,13 @@ static void OVERLAY_cache_init(void *vedata)
OVERLAY_StorageList *stl = data->stl;
OVERLAY_PrivateData *pd = stl->pd;
+ if (pd->is_image_editor) {
+ OVERLAY_background_cache_init(vedata);
+ OVERLAY_grid_cache_init(vedata);
+ OVERLAY_edit_uv_cache_init(vedata);
+ return;
+ }
+
switch (pd->ctx_mode) {
case CTX_MODE_EDIT_MESH:
OVERLAY_edit_mesh_cache_init(vedata);
@@ -240,6 +263,14 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
{
OVERLAY_Data *data = vedata;
OVERLAY_PrivateData *pd = data->stl->pd;
+
+ if (pd->is_image_editor) {
+ if (ob->type == OB_MESH) {
+ OVERLAY_edit_uv_cache_populate(vedata, ob);
+ }
+ return;
+ }
+
const DRWContextState *draw_ctx = DRW_context_state_get();
const bool is_select = DRW_state_is_select();
const bool renderable = DRW_object_is_renderable(ob);
@@ -414,6 +445,12 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob)
static void OVERLAY_cache_finish(void *vedata)
{
+ OVERLAY_Data *data = vedata;
+ OVERLAY_PrivateData *pd = data->stl->pd;
+ if (pd->is_image_editor) {
+ return;
+ }
+
/* TODO(fclem) Only do this when really needed. */
{
/* HACK we allocate the in front depth here to avoid the overhead when if is not needed. */
@@ -445,6 +482,16 @@ static void OVERLAY_draw_scene(void *vedata)
GPU_framebuffer_clear_color(dfbl->overlay_only_fb, clear_col);
}
+ if (pd->is_image_editor) {
+ OVERLAY_background_draw(data);
+ OVERLAY_grid_draw(data);
+ if (DRW_state_is_fbo()) {
+ GPU_framebuffer_bind(dfbl->overlay_fb);
+ }
+ OVERLAY_edit_uv_draw(data);
+ return;
+ }
+
OVERLAY_image_background_draw(vedata);
OVERLAY_background_draw(vedata);