Commit: 3643f96460bb94b9db8aa2d3d08e625b07235d2b
Author: Jeroen Bakker
Date:   Mon Aug 17 15:35:44 2020 +0200
Branches: uvimage-editor-drawing
https://developer.blender.org/rB3643f96460bb94b9db8aa2d3d08e625b07235d2b

Renamed draw/engines/editors to draw/engines/image

===================================================================

M       source/blender/draw/CMakeLists.txt
D       source/blender/draw/engines/editors/editors_engine.c
R095    source/blender/draw/engines/editors/editors_batches.c   
source/blender/draw/engines/image/image_batches.c
R083    source/blender/draw/engines/editors/editors_image.c     
source/blender/draw/engines/image/image_engine.c
R100    source/blender/draw/engines/editors/editors_engine.h    
source/blender/draw/engines/image/image_engine.h
R067    source/blender/draw/engines/editors/editors_private.h   
source/blender/draw/engines/image/image_private.h
R073    source/blender/draw/engines/editors/editors_shaders.c   
source/blender/draw/engines/image/image_shaders.c
R100    source/blender/draw/engines/editors/shaders/editors_image_frag.glsl     
source/blender/draw/engines/image/shaders/engine_image_frag.glsl
R100    
source/blender/draw/engines/editors/shaders/editors_image_unavailable_frag.glsl 
source/blender/draw/engines/image/shaders/engine_image_unavailable_frag.glsl
R100    
source/blender/draw/engines/editors/shaders/editors_image_unavailable_vert.glsl 
source/blender/draw/engines/image/shaders/engine_image_unavailable_vert.glsl
R100    source/blender/draw/engines/editors/shaders/editors_image_vert.glsl     
source/blender/draw/engines/image/shaders/engine_image_vert.glsl
M       source/blender/draw/intern/draw_manager.c

===================================================================

diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 081d7a2ee25..434e5e6003c 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -77,10 +77,9 @@ set(SRC
   intern/draw_select_buffer.c
   intern/draw_view.c
   engines/basic/basic_engine.c
-  engines/editors/editors_batches.c
-  engines/editors/editors_engine.c
-  engines/editors/editors_image.c
-  engines/editors/editors_shaders.c
+  engines/image/image_batches.c
+  engines/image/image_engine.c
+  engines/image/image_shaders.c
   engines/eevee/eevee_bloom.c
   engines/eevee/eevee_data.c
   engines/eevee/eevee_depth_of_field.c
@@ -424,10 +423,10 @@ 
data_to_c_simple(engines/overlay2d/shaders/uv_face_dots_vert.glsl SRC)
 data_to_c_simple(engines/overlay2d/shaders/uv_verts_vert.glsl SRC)
 data_to_c_simple(engines/overlay2d/shaders/uv_verts_frag.glsl SRC)
 
-data_to_c_simple(engines/editors/shaders/editors_image_frag.glsl SRC)
-data_to_c_simple(engines/editors/shaders/editors_image_unavailable_frag.glsl 
SRC)
-data_to_c_simple(engines/editors/shaders/editors_image_unavailable_vert.glsl 
SRC)
-data_to_c_simple(engines/editors/shaders/editors_image_vert.glsl SRC)
+data_to_c_simple(engines/image/shaders/engine_image_frag.glsl SRC)
+data_to_c_simple(engines/image/shaders/engine_image_unavailable_frag.glsl SRC)
+data_to_c_simple(engines/image/shaders/engine_image_unavailable_vert.glsl SRC)
+data_to_c_simple(engines/image/shaders/engine_image_vert.glsl SRC)
 
 list(APPEND INC
 )
diff --git a/source/blender/draw/engines/editors/editors_engine.c 
b/source/blender/draw/engines/editors/editors_engine.c
deleted file mode 100644
index 1c4d2bebec9..00000000000
--- a/source/blender/draw/engines/editors/editors_engine.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Copyright 2020, Blender Foundation.
- */
-
-/** \file
- * \ingroup draw_editors
- *
- * Draw engine to draw the Image/UV editor
- */
-
-#include "DRW_render.h"
-
-#include "BKE_object.h"
-
-#include "editors_engine.h"
-#include "editors_private.h"
-
-/* Shaders */
-
-/* Default image width and height when image is not available */
-
-/* -------------------------------------------------------------------- */
-/** \name Engine Callbacks
- * \{ */
-static void EDITORS_engine_init(void *vedata)
-{
-  EDITORS_Data *ed = (EDITORS_Data *)vedata;
-
-  EDITORS_shader_library_ensure();
-  EDITORS_image_init(ed);
-}
-
-static void EDITORS_cache_init(void *vedata)
-{
-  EDITORS_Data *ed = (EDITORS_Data *)vedata;
-  EDITORS_image_cache_init(ed);
-}
-
-static void EDITORS_cache_populate(void *UNUSED(vedata), Object *UNUSED(ob))
-{
-}
-
-static void EDITORS_draw_scene(void *vedata)
-{
-  EDITORS_Data *ed = (EDITORS_Data *)vedata;
-  EDITORS_image_draw_scene(ed);
-}
-
-static void EDITORS_engine_free(void)
-{
-  EDITORS_shaders_free();
-}
-
-/* \} */
-static const DrawEngineDataSize EDITORS_data_size = 
DRW_VIEWPORT_DATA_SIZE(EDITORS_Data);
-
-DrawEngineType draw_engine_editors_type = {
-    NULL,                    /* next */
-    NULL,                    /* prev */
-    N_("Editor"),            /* idname */
-    &EDITORS_data_size,      /*vedata_size */
-    &EDITORS_engine_init,    /* engine_init */
-    &EDITORS_engine_free,    /* engine_free */
-    &EDITORS_cache_init,     /* cache_init */
-    &EDITORS_cache_populate, /* cache_populate */
-    NULL,                    /* cache_finish */
-    &EDITORS_draw_scene,     /* draw_scene */
-    NULL,                    /* view_update */
-    NULL,                    /* id_update */
-    NULL,                    /* render_to_image */
-};
diff --git a/source/blender/draw/engines/editors/editors_batches.c 
b/source/blender/draw/engines/image/image_batches.c
similarity index 95%
rename from source/blender/draw/engines/editors/editors_batches.c
rename to source/blender/draw/engines/image/image_batches.c
index 15256488160..9822f97ea30 100644
--- a/source/blender/draw/engines/editors/editors_batches.c
+++ b/source/blender/draw/engines/image/image_batches.c
@@ -25,7 +25,7 @@
 
 #include "GPU_batch.h"
 
-#include "editors_private.h"
+#include "image_private.h"
 
 static GPUVertFormat *editors_batches_image_instance_format(void)
 {
@@ -36,7 +36,7 @@ static GPUVertFormat 
*editors_batches_image_instance_format(void)
   return &format;
 }
 
-GPUBatch *EDITORS_batches_image_instance_create(rcti *rect)
+GPUBatch *IMAGE_batches_image_instance_create(rcti *rect)
 {
   GPUVertFormat *format = editors_batches_image_instance_format();
   GPUVertBuf *vbo = GPU_vertbuf_create_with_format(format);
diff --git a/source/blender/draw/engines/editors/editors_image.c 
b/source/blender/draw/engines/image/image_engine.c
similarity index 83%
rename from source/blender/draw/engines/editors/editors_image.c
rename to source/blender/draw/engines/image/image_engine.c
index b983f3c4623..73b451c838f 100644
--- a/source/blender/draw/engines/editors/editors_image.c
+++ b/source/blender/draw/engines/image/image_engine.c
@@ -17,19 +17,19 @@
  */
 
 /** \file
- * \ingroup draw_engine
+ * \ingroup draw_editors
+ *
+ * Draw engine to draw the Image/UV editor
  */
+
 #include "DRW_render.h"
 
 #include "BKE_image.h"
+#include "BKE_object.h"
 
-#include "BLI_dynstr.h"
 #include "BLI_rect.h"
 
 #include "DNA_camera_types.h"
-#include "DNA_space_types.h"
-
-#include "UI_resources.h"
 
 #include "IMB_imbuf_types.h"
 
@@ -37,10 +37,8 @@
 
 #include "GPU_batch.h"
 
-#include "editors_engine.h"
-#include "editors_private.h"
-
-#define DEFAULT_IMAGE_SIZE_PX 256
+#include "image_engine.h"
+#include "image_private.h"
 
 #define SIMA_DRAW_FLAG_SHOW_ALPHA (1 << 0)
 #define SIMA_DRAW_FLAG_APPLY_ALPHA (1 << 1)
@@ -62,11 +60,53 @@ static struct {
   GPUBatch *gpu_batch_instances;
 } e_data = {0}; /* Engine data */
 
-/* -------------------------------------------------------------------- */
-/** \name Image Pass
- * \{ */
+/* Shaders */
+
+/* Default image width and height when image is not available */
+
+static void editors_image_batch_instances_update(void)
+{
+  const DRWContextState *draw_ctx = DRW_context_state_get();
+  SpaceImage *sima = (SpaceImage *)draw_ctx->space_data;
+  Image *image = e_data.image;
+  const bool is_tiled_texture = image && image->source == IMA_SRC_TILED;
+  rcti instances;
+
+  if (is_tiled_texture) {
+    GPU_BATCH_DISCARD_SAFE(e_data.gpu_batch_instances);
+    e_data.gpu_batch_instances = 
BKE_image_tiled_gpu_instance_batch_create(image);
+    return;
+  }
+
+  /* repeat */
+  BLI_rcti_init(&instances, 0, 0, 0, 0);
+  if ((sima->flag & SI_DRAW_TILE) != 0) {
+    float view_inv_m4[4][4];
+    DRW_view_viewmat_get(NULL, view_inv_m4, true);
+    float v3min[3] = {0.0f, 0.0f, 0.0f};
+    float v3max[3] = {1.0f, 1.0f, 0.0f};
+    mul_m4_v3(view_inv_m4, v3min);
+    mul_m4_v3(view_inv_m4, v3max);
 
-static void editors_image_cache_image(EDITORS_PassList *psl,
+    instances.xmin = (int)floorf(v3min[0]);
+    instances.ymin = (int)floorf(v3min[1]);
+    instances.xmax = (int)floorf(v3max[0]);
+    instances.ymax = (int)floorf(v3max[1]);
+  }
+
+  if (e_data.gpu_batch_instances) {
+    if (!BLI_rcti_compare(&e_data.gpu_batch_instances_rect, &instances)) {
+      GPU_BATCH_DISCARD_SAFE(e_data.gpu_batch_instances);
+    }
+  }
+
+  if (!e_data.gpu_batch_instances) {
+    e_data.gpu_batch_instances = 
IMAGE_batches_image_instance_create(&instances);
+    e_data.gpu_batch_instances_rect = instances;
+  }
+}
+
+static void editors_image_cache_image(IMAGE_PassList *psl,
                                       Image *ima,
                                       ImageUser *iuser,
                                       ImBuf *ibuf)
@@ -106,7 +146,7 @@ static void editors_image_cache_image(EDITORS_PassList *psl,
 
   if (e_data.texture) {
     eGPUSamplerState state = 0;
-    GPUShader *shader = EDITORS_shaders_image_get();
+    GPUShader *shader = IMAGE_shaders_image_get();
     DRWShadingGroup *shgrp = DRW_shgroup_create(shader, psl->image_pass);
     static float color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
     static float shuffle[4] = {1.0f, 1.0f, 1.0f, 1.0f};
@@ -164,20 +204,20 @@ static void editors_image_cache_image(EDITORS_PassList 
*psl,
   }
   else {
     /* No image available. use the image unavailable shader. */
-    GPUShader *shader = EDITORS_shaders_image_unavailable_get();
+    GPUShader *shader = IMAGE_shaders_image_unavailable_get();
     DRWShadingGroup *grp = DRW_shgroup_create(shader, psl->image_pass);
     DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
     DRW_shgroup_call(grp, e_data.gpu_batch_image, NULL);
   }
 }
 
-/* \} */
-
 /* -------------------------------------------------------------------- */
-/** \name DrawEngine Interface
+/** \name Engine Callbacks
  * \{ */
-void EDITORS_image_init(EDITORS_Data *UNUSED(vedata))
+static void IMAGE_engine_init(void *UNUSED(vedata))
 {
+  IMAGE_shader_library_ensure();
+
   e_data.image = NULL;
   e_data.ibuf = NULL;
   e_data.lock = NULL;
@@ -189,51 +229,10 @@ void EDITORS_image_init(EDITORS_Data *UNUSED(vedata))
   }
 }
 
-static void editors_image_batch_instances_update(void)
+static void IMAGE_cache_init(void *vedata)
 {
-  const DRWContextState *draw_ctx = DRW_context_state_get();
-  SpaceImage *sima = (SpaceImage *)draw_ctx->space_data;
-  Image *image = e_data.image;
-  const bool is_tiled_texture = image && image->source == IMA_SRC_TILED;
-  rcti instances;
-
-  if (is_tiled_texture) {
-    GPU_BATCH_DISCARD_SAFE(e_data.gpu_batch_instances);
-    e_data.gpu_batch_instances = BKE_image_tiled_gpu_

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to