Read/Write bganchor directly from the options' state
Slight performance improvement, maybe? Also, `kitty/graphics.h` has been reverted to the original version; this version would be better in that aspect too.
This commit is contained in:
parent
2aa01c58a1
commit
cae31ab336
@ -66,7 +66,6 @@ typedef struct {
|
||||
unsigned int height, width;
|
||||
uint8_t* bitmap;
|
||||
uint32_t refcnt;
|
||||
BackgroundImageAnchor anchor;
|
||||
} BackgroundImage;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@ -417,15 +417,15 @@ draw_bg(OSWindow *w) {
|
||||
bgimage_constants_set = true;
|
||||
}
|
||||
float translate_left = 0.0f, translate_top = 0.0f;
|
||||
if (OPT(background_image_layout) != SCALED) {
|
||||
if (w->bgimage->anchor == NORTH || w->bgimage->anchor == CENTER || w->bgimage->anchor == SOUTH) {
|
||||
if (OPT(background_image_layout) == TILING || OPT(background_image_layout) == MIRRORED) {
|
||||
if (OPT(background_image_anchor) == NORTH || OPT(background_image_anchor) == CENTER || OPT(background_image_anchor) == SOUTH) {
|
||||
translate_left = ((float)w->window_width / 2.0f - (float)w->bgimage->width / 2.0f) / (float)w->bgimage->width;
|
||||
} else if (w->bgimage->anchor == NORTHEAST || w->bgimage->anchor == EAST || w->bgimage->anchor == SOUTHEAST) {
|
||||
} else if (OPT(background_image_anchor) == NORTHEAST || OPT(background_image_anchor) == EAST || OPT(background_image_anchor) == SOUTHEAST) {
|
||||
translate_left = ((float)w->window_width - (float)w->bgimage->width) / (float)w->bgimage->width;
|
||||
}
|
||||
if (w->bgimage->anchor == WEST || w->bgimage->anchor == CENTER || w->bgimage->anchor == EAST) {
|
||||
if (OPT(background_image_anchor) == WEST || OPT(background_image_anchor) == CENTER || OPT(background_image_anchor) == EAST) {
|
||||
translate_top = ((float)w->window_height / 2.0f - (float)w->bgimage->height / 2.0f) / (float)w->bgimage->height;
|
||||
} else if (w->bgimage->anchor == SOUTHWEST || w->bgimage->anchor == SOUTH || w->bgimage->anchor == SOUTHEAST) {
|
||||
} else if (OPT(background_image_anchor) == SOUTHWEST || OPT(background_image_anchor) == SOUTH || OPT(background_image_anchor) == SOUTHEAST) {
|
||||
translate_top = ((float)w->window_height - (float)w->bgimage->height) / (float)w->bgimage->height;
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,7 +180,6 @@ add_os_window() {
|
||||
global_state.bgimage = calloc(1, sizeof(BackgroundImage));
|
||||
if (!global_state.bgimage) fatal("Out of memory allocating the global bg image object");
|
||||
global_state.bgimage->refcnt++;
|
||||
global_state.bgimage->anchor = OPT(background_image_anchor);
|
||||
size_t size;
|
||||
if (png_path_to_bitmap(OPT(background_image), &global_state.bgimage->bitmap, &global_state.bgimage->width, &global_state.bgimage->height, &size)) {
|
||||
send_bgimage_to_gpu(OPT(background_image_layout), global_state.bgimage);
|
||||
@ -994,7 +993,6 @@ pyset_background_image(PyObject *self UNUSED, PyObject *args) {
|
||||
make_os_window_context_current(os_window);
|
||||
free_bgimage(&os_window->bgimage, true);
|
||||
os_window->bgimage = bgimage;
|
||||
os_window->bgimage->anchor = anchor;
|
||||
os_window->render_calls = 0;
|
||||
if (bgimage) bgimage->refcnt++;
|
||||
END_WITH_OS_WINDOW
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user