mirror of
https://github.com/labwc/labwc.git
synced 2026-04-10 08:21:07 -04:00
ssd: rework titlebar button rendering
- fix that icons for normal/hovered/rounded buttons are not placed exactly the same position - fix blurry window button icons in scaled outputs This commit introduces lab_img and scaled_img_buffer and uses them for rendering icons in the window titlebar. Now the process of rendering button icons are split into 2 phases: loading with lab_img_load() and creating scene-nodes for them with scaled_img_buffer_create(). This might incur some additional overhead since we no longer preload icon textures, but the rendering of icon only happens for the first window as backing buffers are shared and the overhead won't be noticeable. This commit also simplifies the process of centering icon buffer in the button, by creating icon buffers in a fixed geometry via lab_img_render().
This commit is contained in:
parent
9a3412324d
commit
16dbdc64e5
25 changed files with 647 additions and 391 deletions
|
|
@ -13,6 +13,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <drm_fourcc.h>
|
||||
#include "img/img.h"
|
||||
#include "img/img-xbm.h"
|
||||
#include "common/grab-file.h"
|
||||
#include "common/mem.h"
|
||||
|
|
@ -255,32 +256,23 @@ parse_xbm_builtin(const char *button, int size)
|
|||
return pixmap;
|
||||
}
|
||||
|
||||
void
|
||||
img_xbm_from_bitmap(const char *bitmap, struct lab_data_buffer **buffer,
|
||||
float *rgba)
|
||||
struct lab_data_buffer *
|
||||
img_xbm_load_from_bitmap(const char *bitmap, float *rgba)
|
||||
{
|
||||
struct pixmap pixmap = {0};
|
||||
if (*buffer) {
|
||||
wlr_buffer_drop(&(*buffer)->base);
|
||||
*buffer = NULL;
|
||||
}
|
||||
color = argb32(rgba);
|
||||
pixmap = parse_xbm_builtin(bitmap, 6);
|
||||
*buffer = buffer_create_from_data(pixmap.data, pixmap.width, pixmap.height,
|
||||
|
||||
return buffer_create_from_data(pixmap.data, pixmap.width, pixmap.height,
|
||||
pixmap.width * 4);
|
||||
}
|
||||
|
||||
void
|
||||
img_xbm_load(const char *filename, struct lab_data_buffer **buffer,
|
||||
float *rgba)
|
||||
struct lab_data_buffer *
|
||||
img_xbm_load(const char *filename, float *rgba)
|
||||
{
|
||||
struct pixmap pixmap = {0};
|
||||
if (*buffer) {
|
||||
wlr_buffer_drop(&(*buffer)->base);
|
||||
*buffer = NULL;
|
||||
}
|
||||
if (string_null_or_empty(filename)) {
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
color = argb32(rgba);
|
||||
|
||||
|
|
@ -295,12 +287,9 @@ img_xbm_load(const char *filename, struct lab_data_buffer **buffer,
|
|||
}
|
||||
buf_reset(&token_buf);
|
||||
if (!pixmap.data) {
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Create buffer */
|
||||
if (pixmap.data) {
|
||||
*buffer = buffer_create_from_data(pixmap.data, pixmap.width,
|
||||
pixmap.height, pixmap.width * 4);
|
||||
}
|
||||
return buffer_create_from_data(pixmap.data, pixmap.width,
|
||||
pixmap.height, pixmap.width * 4);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue