mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-04-27 19:26:46 +02:00
At the moment we flip the two buffers, and we backport the damaged area on every frame callback. We completely ignore the compositor sent event buffer->release. This event means that the compositor finished reading the buffer pixels, and will never read them again. So we can keep using the same buffer instead of fliping, if we receive the event before asking for a new frame callback. The change is not complicated, but we have to distinguish drwsurf_attach, and drwsurf_flip. We try to flip before trying to draw anything. And if the buffer has already been released, we don't flip. We also have to track the backport_damage separately than the buffer current damage. Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
62 lines
1.7 KiB
C
62 lines
1.7 KiB
C
#ifndef __DRW_H
|
|
#define __DRW_H
|
|
|
|
#include <pango/pangocairo.h>
|
|
#include <stdbool.h>
|
|
|
|
struct drw {
|
|
struct wl_shm *shm;
|
|
};
|
|
struct drwbuf {
|
|
uint32_t size;
|
|
struct wl_buffer *buf;
|
|
cairo_region_t *damage, *backport_damage;
|
|
cairo_surface_t *cairo_surf;
|
|
cairo_t *cairo;
|
|
PangoLayout *layout;
|
|
unsigned char *pool_data;
|
|
bool released;
|
|
};
|
|
struct drwsurf {
|
|
uint32_t width, height;
|
|
double scale;
|
|
|
|
struct drw *ctx;
|
|
struct wl_surface *surf;
|
|
struct wl_shm *shm;
|
|
struct wl_callback *frame_cb;
|
|
|
|
bool attached;
|
|
|
|
struct drwbuf *back_buffer;
|
|
struct drwbuf *display_buffer;
|
|
};
|
|
struct kbd;
|
|
|
|
void drwsurf_damage(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
|
|
void drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, double s);
|
|
void drwsurf_attach(struct drwsurf *ds);
|
|
void drwsurf_flip(struct drwsurf *ds);
|
|
|
|
typedef union {
|
|
uint8_t bgra[4];
|
|
uint32_t color;
|
|
} Color;
|
|
|
|
void drw_do_clear(struct drwsurf *ds, uint32_t x, uint32_t y,
|
|
uint32_t w, uint32_t h);
|
|
void drw_do_rectangle(struct drwsurf *ds, Color color, uint32_t x, uint32_t y,
|
|
uint32_t w, uint32_t h, bool fill, int rounding);
|
|
void drw_fill_rectangle(struct drwsurf *ds, Color color, uint32_t x, uint32_t y,
|
|
uint32_t w, uint32_t h, int rounding);
|
|
void drw_over_rectangle(struct drwsurf *ds, Color color, uint32_t x, uint32_t y,
|
|
uint32_t w, uint32_t h, int rounding);
|
|
|
|
void drw_draw_text(struct drwsurf *ds, Color color, uint32_t x, uint32_t y,
|
|
uint32_t w, uint32_t h, uint32_t b, const char *label,
|
|
PangoFontDescription *font_description);
|
|
|
|
uint32_t setup_buffer(struct drwsurf *ds, struct drwbuf *db);
|
|
|
|
#endif
|