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:
authorClément Foucault <foucault.clem@gmail.com>2020-08-18 17:12:56 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-08-18 17:15:34 +0300
commit55087b84b8080063dac47e4ba7bcaea3a0d58aab (patch)
tree9d27eeb767912ce5d2af4f7525fc3c33b0fc18f8
parent3e5431fdf43906cd900f960f65ef8897e8a108a3 (diff)
Cleanup: Node: Use checker shader for preview background
Removes many drawcalls which might have slowdown the UI.
-rw-r--r--source/blender/editors/space_node/node_draw.c42
1 files changed, 7 insertions, 35 deletions
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 0a754b6ec2a..fd18583195d 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -867,46 +867,18 @@ void ED_node_socket_draw(bNodeSocket *sock, const rcti *rect, const float color[
static void node_draw_preview_background(float tile, rctf *rect)
{
- float x, y;
-
GPUVertFormat *format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+ immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
- /* draw checkerboard backdrop to show alpha */
- immUniformColor3ub(120, 120, 120);
+ /* Drawing the checkerboard. */
+ const float checker_dark = UI_ALPHA_CHECKER_DARK / 255.0f;
+ const float checker_light = UI_ALPHA_CHECKER_LIGHT / 255.0f;
+ immUniform4f("color1", checker_dark, checker_dark, checker_dark, 1.0f);
+ immUniform4f("color2", checker_light, checker_light, checker_light, 1.0f);
+ immUniform1i("size", 8);
immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax);
- immUniformColor3ub(160, 160, 160);
-
- for (y = rect->ymin; y < rect->ymax; y += tile * 2) {
- for (x = rect->xmin; x < rect->xmax; x += tile * 2) {
- float tilex = tile, tiley = tile;
-
- if (x + tile > rect->xmax) {
- tilex = rect->xmax - x;
- }
- if (y + tile > rect->ymax) {
- tiley = rect->ymax - y;
- }
-
- immRectf(pos, x, y, x + tilex, y + tiley);
- }
- }
- for (y = rect->ymin + tile; y < rect->ymax; y += tile * 2) {
- for (x = rect->xmin + tile; x < rect->xmax; x += tile * 2) {
- float tilex = tile, tiley = tile;
-
- if (x + tile > rect->xmax) {
- tilex = rect->xmax - x;
- }
- if (y + tile > rect->ymax) {
- tiley = rect->ymax - y;
- }
-
- immRectf(pos, x, y, x + tilex, y + tiley);
- }
- }
immUnbindProgram();
}