diff --git a/source/blender/editors/space_sequencer/sequencer_preview_draw.cc b/source/blender/editors/space_sequencer/sequencer_preview_draw.cc index 704300326fd..be5eaf698c1 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview_draw.cc +++ b/source/blender/editors/space_sequencer/sequencer_preview_draw.cc @@ -485,8 +485,6 @@ static void sequencer_draw_display_buffer(const bContext *C, immUniformColor3f(1.0f, 1.0f, 1.0f); } - immBegin(GPU_PRIM_TRI_FAN, 4); - rctf preview; rctf canvas; sequencer_preview_get_rect(&preview, scene, region, sseq, draw_overlay, draw_backdrop); @@ -498,19 +496,7 @@ static void sequencer_draw_display_buffer(const bContext *C, BLI_rctf_init(&canvas, 0.0f, 1.0f, 0.0f, 1.0f); } - immAttr2f(texCoord, canvas.xmin, canvas.ymin); - immVertex2f(pos, preview.xmin, preview.ymin); - - immAttr2f(texCoord, canvas.xmin, canvas.ymax); - immVertex2f(pos, preview.xmin, preview.ymax); - - immAttr2f(texCoord, canvas.xmax, canvas.ymax); - immVertex2f(pos, preview.xmax, preview.ymax); - - immAttr2f(texCoord, canvas.xmax, canvas.ymin); - immVertex2f(pos, preview.xmax, preview.ymin); - - immEnd(); + immRectf_with_texco(pos, texCoord, preview, canvas); GPU_texture_unbind(texture); GPU_texture_free(texture); diff --git a/source/blender/gpu/GPU_immediate_util.hh b/source/blender/gpu/GPU_immediate_util.hh index 2e1ec709f40..bb77912f296 100644 --- a/source/blender/gpu/GPU_immediate_util.hh +++ b/source/blender/gpu/GPU_immediate_util.hh @@ -12,10 +12,13 @@ #include "BLI_sys_types.h" +struct rctf; + /* Draw 2D rectangles (replaces glRect functions) */ /* caller is responsible for vertex format & shader */ void immRectf(uint pos, float x1, float y1, float x2, float y2); void immRecti(uint pos, int x1, int y1, int x2, int y2); +void immRectf_with_texco(uint pos, uint tex_coord, const rctf &p, const rctf &uv); /** * Same as #immRectf / #immRecti but does not call #immBegin / #immEnd. diff --git a/source/blender/gpu/intern/gpu_immediate_util.cc b/source/blender/gpu/intern/gpu_immediate_util.cc index 4aa650f1276..5978038bc5d 100644 --- a/source/blender/gpu/intern/gpu_immediate_util.cc +++ b/source/blender/gpu/intern/gpu_immediate_util.cc @@ -12,6 +12,7 @@ #include "BLI_math_rotation.h" #include "BLI_math_vector.h" +#include "BLI_rect.h" #include "BLI_utildefines.h" #include "GPU_immediate.hh" @@ -118,6 +119,23 @@ void immRecti_fast_with_color( immVertex2i(pos, x1, y2); } +void immRectf_with_texco(const uint pos, const uint tex_coord, const rctf &p, const rctf &uv) +{ + immBegin(GPU_PRIM_TRI_FAN, 4); + immAttr2f(tex_coord, uv.xmin, uv.ymin); + immVertex2f(pos, p.xmin, p.ymin); + + immAttr2f(tex_coord, uv.xmin, uv.ymax); + immVertex2f(pos, p.xmin, p.ymax); + + immAttr2f(tex_coord, uv.xmax, uv.ymax); + immVertex2f(pos, p.xmax, p.ymax); + + immAttr2f(tex_coord, uv.xmax, uv.ymin); + immVertex2f(pos, p.xmax, p.ymin); + immEnd(); +} + #if 0 /* more complete version in case we want that */ void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4]) {