Bring the kovidgoyal/kitty codebase in as the base of FWS-Kitty, vendored at upstream commit 91fb38a without its git history.
29 lines
820 B
Plaintext
29 lines
820 B
Plaintext
#language slang 2026
|
|
// Copyright (C) 2026 Kovid Goyal <kovid at kovidgoyal.net>
|
|
// Distributed under terms of the GPLv3 license.
|
|
|
|
// Maps a vertex id to src and destination co-ordinates
|
|
module blit_common;
|
|
|
|
public struct BlitOutput {
|
|
public float2 texcoord;
|
|
public float2 position;
|
|
};
|
|
|
|
#define left 0
|
|
#define top 1
|
|
#define right 2
|
|
#define bottom 3
|
|
|
|
// Static constant array mapping vertex IDs
|
|
static const int2 vertex_pos_map[4] = { { right, top }, { right, bottom }, { left, bottom }, { left, top } };
|
|
|
|
public BlitOutput
|
|
get_coords_for_blit(uint vertex_id, float4 src_rect, float4 dest_rect) {
|
|
int2 pos = vertex_pos_map[vertex_id];
|
|
BlitOutput output;
|
|
output.texcoord = float2(src_rect[pos.x], src_rect[pos.y]);
|
|
output.position = float2(dest_rect[pos.x], dest_rect[pos.y]);
|
|
return output;
|
|
}
|