WM: Use draw manager to draw UV image editor spaces
authorClément Foucault <foucault.clem@gmail.com>
Wed, 9 Jan 2019 21:26:52 +0000 (22:26 +0100)
committerClément Foucault <foucault.clem@gmail.com>
Fri, 11 Jan 2019 15:00:23 +0000 (16:00 +0100)
This is in order to use batch cache directly without using tricks like
batch presets reseting the VAOs.

Note: For now it also create a depth buffer for this area which is not
needed. We could get rid of this to lower VRAM usage.

source/blender/editors/space_image/space_image.c
source/blender/windowmanager/intern/wm_draw.c

index 3c850ae1689200fdee92a8bb3ef1e8eab6062dca..4f2b0f0db2b588e136e82f6f819405e74c3712f5 100644 (file)
 
 #include "image_intern.h"
 #include "GPU_framebuffer.h"
+#include "GPU_batch_presets.h"
+#include "GPU_viewport.h"
+
+/* TODO(fclem) remove bad level calls */
+#include "../draw/DRW_engine.h"
+#include "wm_draw.h"
 
 /**************************** common state *****************************/
 
@@ -620,6 +626,14 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
        //View2DScrollers *scrollers;
        float col[3];
 
+       /* XXX This is in order to draw UI batches with the DRW
+        * olg context since we now use it for drawing the entire area */
+       gpu_batch_presets_reset();
+
+       /* TODO(fclem) port to draw manager and remove the depth buffer allocation. */
+       DefaultFramebufferList *fbl = GPU_viewport_framebuffer_list_get(ar->draw_buffer->viewport[0]);
+       GPU_framebuffer_bind(fbl->color_only_fb);
+
        /* XXX not supported yet, disabling for now */
        scene->r.scemode &= ~R_COMP_CROP;
 
index d6058ac0d282af32e0b4d54918c4c0035cedd335..c811a52c0e9503a83112c6a1518650b428db9faa 100644 (file)
@@ -213,7 +213,7 @@ static void wm_region_test_render_do_draw(const Scene *scene, struct Depsgraph *
 
 static bool wm_region_use_viewport(ScrArea *sa, ARegion *ar)
 {
-       return (sa->spacetype == SPACE_VIEW3D && ar->regiontype == RGN_TYPE_WINDOW);
+       return (ELEM(sa->spacetype, SPACE_VIEW3D, SPACE_IMAGE) && ar->regiontype == RGN_TYPE_WINDOW);
 }
 
 /********************** draw all **************************/