forked from external/yambar
cairo: replace cairo with pixman in decos, particles and modules
All decoration, particle and module interfaces now takes a pixman_image_t parameter, and all drawing is done using pixman APIs. The wayland/xcb backends implement a new interface functions, get_pixman_image(), that should return a pixman image instance that is suitable for rendering. In the wayland backend, the image uses the same backing data as the cairo surface. In the XCB backend, we create a new image each time, and then blit it to the cairo surface at commit time.
This commit is contained in:
parent
95385863ae
commit
c11fee4ce3
24 changed files with 162 additions and 141 deletions
|
@ -6,7 +6,8 @@
|
|||
#include "../plugin.h"
|
||||
|
||||
struct private {
|
||||
struct rgba color;
|
||||
//struct rgba color;
|
||||
pixman_color_t color;
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -18,17 +19,16 @@ destroy(struct deco *deco)
|
|||
}
|
||||
|
||||
static void
|
||||
expose(const struct deco *deco, cairo_t *cr, int x, int y, int width, int height)
|
||||
expose(const struct deco *deco, pixman_image_t *pix, int x, int y, int width, int height)
|
||||
{
|
||||
const struct private *d = deco->private;
|
||||
cairo_set_source_rgba(
|
||||
cr, d->color.red, d->color.green, d->color.blue, d->color.alpha);
|
||||
cairo_rectangle(cr, x, y, width, height);
|
||||
cairo_fill(cr);
|
||||
pixman_image_fill_rectangles(
|
||||
PIXMAN_OP_OVER, pix, &d->color, 1,
|
||||
&(pixman_rectangle16_t){x, y, width, height});
|
||||
}
|
||||
|
||||
static struct deco *
|
||||
background_new(struct rgba color)
|
||||
background_new(pixman_color_t color)
|
||||
{
|
||||
struct private *priv = calloc(1, sizeof(*priv));
|
||||
priv->color = color;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
deco_sdk = declare_dependency(dependencies: [cairo, cairo_ft])
|
||||
deco_sdk = declare_dependency(dependencies: [pixman])
|
||||
|
||||
decorations = []
|
||||
foreach deco : ['background', 'stack', 'underline']
|
||||
|
|
|
@ -24,11 +24,11 @@ destroy(struct deco *deco)
|
|||
}
|
||||
|
||||
static void
|
||||
expose(const struct deco *deco, cairo_t *cr, int x, int y, int width, int height)
|
||||
expose(const struct deco *deco, pixman_image_t *pix, int x, int y, int width, int height)
|
||||
{
|
||||
const struct private *d = deco->private;
|
||||
for (size_t i = 0; i < d->count; i++)
|
||||
d->decos[i]->expose(d->decos[i], cr, x, y, width, height);
|
||||
d->decos[i]->expose(d->decos[i], pix, x, y, width, height);
|
||||
}
|
||||
|
||||
static struct deco *
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
struct private {
|
||||
int size;
|
||||
struct rgba color;
|
||||
pixman_color_t color;
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -19,17 +19,16 @@ destroy(struct deco *deco)
|
|||
}
|
||||
|
||||
static void
|
||||
expose(const struct deco *deco, cairo_t *cr, int x, int y, int width, int height)
|
||||
expose(const struct deco *deco, pixman_image_t *pix, int x, int y, int width, int height)
|
||||
{
|
||||
const struct private *d = deco->private;
|
||||
cairo_set_source_rgba(
|
||||
cr, d->color.red, d->color.green, d->color.blue, d->color.alpha);
|
||||
cairo_rectangle(cr, x, y + height - d->size, width, d->size);
|
||||
cairo_fill(cr);
|
||||
pixman_image_fill_rectangles(
|
||||
PIXMAN_OP_OVER, pix, &d->color, 1,
|
||||
&(pixman_rectangle16_t){x, y + height - d->size, width, d->size});
|
||||
}
|
||||
|
||||
static struct deco *
|
||||
underline_new(int size, struct rgba color)
|
||||
underline_new(int size, pixman_color_t color)
|
||||
{
|
||||
struct private *priv = calloc(1, sizeof(*priv));
|
||||
priv->size = size;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue