Remove all references to cairo; we now use pixman only

This commit is contained in:
Daniel Eklöf 2019-08-16 22:11:22 +02:00
parent 81107753bf
commit f45e5c6aef
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
8 changed files with 14 additions and 66 deletions

View file

@ -9,7 +9,7 @@ makedepends=('meson' 'ninja' 'scdoc')
depends=( depends=(
'libxkbcommon' 'libxkbcommon'
'wayland' 'wayland'
'freetype2' 'fontconfig' 'cairo') 'freetype2' 'fontconfig' 'pixman')
source=() source=()
pkgver() { pkgver() {
@ -25,4 +25,3 @@ build() {
package() { package() {
DESTDIR="${pkgdir}/" ninja install DESTDIR="${pkgdir}/" ninja install
} }

View file

@ -7,7 +7,7 @@
* fontconfig * fontconfig
* freetype * freetype
* cairo * pixman
* wayland (_client_ and _cursor_ libraries) * wayland (_client_ and _cursor_ libraries)
* wayland protocols * wayland protocols
* xkbcommon * xkbcommon

2
font.c
View file

@ -386,7 +386,7 @@ glyph_for_wchar(struct font *font, wchar_t wc, struct glyph *glyph)
uint8_t *data = malloc(bitmap->rows * stride); uint8_t *data = malloc(bitmap->rows * stride);
assert(bitmap->pitch >= 0); assert(bitmap->pitch >= 0);
/* Convert FT bitmap to cairo surface (well, the backing image) */ /* Convert FT bitmap to pixman image */
switch (bitmap->pixel_mode) { switch (bitmap->pixel_mode) {
case FT_PIXEL_MODE_MONO: case FT_PIXEL_MODE_MONO:
for (size_t r = 0; r < bitmap->rows; r++) { for (size_t r = 0; r < bitmap->rows; r++) {

2
main.c
View file

@ -1085,8 +1085,6 @@ out:
tll_free(term.render.workers.queue); tll_free(term.render.workers.queue);
config_free(conf); config_free(conf);
cairo_debug_reset_static_data();
return ret; return ret;
} }

View file

@ -45,7 +45,6 @@ threads = dependency('threads')
freetype = dependency('freetype2') freetype = dependency('freetype2')
fontconfig = dependency('fontconfig') fontconfig = dependency('fontconfig')
pixman = dependency('pixman-1') pixman = dependency('pixman-1')
cairo = dependency('cairo')
wayland_protocols = dependency('wayland-protocols') wayland_protocols = dependency('wayland-protocols')
wayland_client = dependency('wayland-client') wayland_client = dependency('wayland-client')
wayland_cursor = dependency('wayland-cursor') wayland_cursor = dependency('wayland-cursor')
@ -101,7 +100,7 @@ executable(
'tllist.h', 'tllist.h',
'vt.c', 'vt.h', 'vt.c', 'vt.h',
wl_proto_src + wl_proto_headers, wl_proto_src + wl_proto_headers,
dependencies: [threads, math, freetype, fontconfig, pixman, cairo, wayland_client, wayland_cursor, xkb], dependencies: [threads, math, freetype, fontconfig, pixman, wayland_client, wayland_cursor, xkb],
install: true) install: true)
custom_target( custom_target(

60
shm.c
View file

@ -47,11 +47,10 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, size_t copies)
* No existing buffer available. Create a new one by: * No existing buffer available. Create a new one by:
* *
* 1. open a memory backed "file" with memfd_create() * 1. open a memory backed "file" with memfd_create()
* 2. mmap() the memory file, to be used by the cairo surface * 2. mmap() the memory file, to be used by the pixman image
* 3. create a wayland shm buffer for the same memory file * 3. create a wayland shm buffer for the same memory file
* *
* The cairo surface and the wayland buffer are now sharing * The pixman image and the wayland buffer are now sharing memory.
* memory.
*/ */
int pool_fd = -1; int pool_fd = -1;
@ -61,8 +60,6 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, size_t copies)
struct wl_shm_pool *pool = NULL; struct wl_shm_pool *pool = NULL;
struct wl_buffer *buf = NULL; struct wl_buffer *buf = NULL;
cairo_surface_t **cairo_surface = NULL;
cairo_t **cairo = NULL;
pixman_image_t **pix = NULL; pixman_image_t **pix = NULL;
/* Backing memory for SHM */ /* Backing memory for SHM */
@ -72,8 +69,12 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, size_t copies)
goto err; goto err;
} }
/* TODO: copied from font.c */
/* Calculate stride. Copied from cairoint.h:CAIRO_STRIDE_FOR_WIDTH_BPP */
int bpp = 32;
const int stride = (((bpp * width + 7) / 8 + 4 - 1) & -4);
/* Total size */ /* Total size */
const uint32_t stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width);
size = stride * height; size = stride * height;
if (ftruncate(pool_fd, size) == -1) { if (ftruncate(pool_fd, size) == -1) {
LOG_ERRNO("failed to truncate SHM pool"); LOG_ERRNO("failed to truncate SHM pool");
@ -103,28 +104,9 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, size_t copies)
wl_shm_pool_destroy(pool); pool = NULL; wl_shm_pool_destroy(pool); pool = NULL;
close(pool_fd); pool_fd = -1; close(pool_fd); pool_fd = -1;
/* Create a cairo surface around the mmapped memory */ /* One pixman image for each worker thread (do we really need multiple?) */
cairo_surface = calloc(copies, sizeof(cairo_surface[0]));
cairo = calloc(copies, sizeof(cairo[0]));
pix = calloc(copies, sizeof(pix[0])); pix = calloc(copies, sizeof(pix[0]));
for (size_t i = 0; i < copies; i++) { for (size_t i = 0; i < copies; i++) {
cairo_surface[i] = cairo_image_surface_create_for_data(
mmapped, CAIRO_FORMAT_ARGB32, width, height, stride);
if (cairo_surface_status(cairo_surface[i]) != CAIRO_STATUS_SUCCESS) {
LOG_ERR("failed to create cairo surface: %s",
cairo_status_to_string(cairo_surface_status(cairo_surface[i])));
goto err;
}
cairo[i] = cairo_create(cairo_surface[i]);
if (cairo_status(cairo[i]) != CAIRO_STATUS_SUCCESS) {
LOG_ERR("failed to create cairo context: %s",
cairo_status_to_string(cairo_status(cairo[i])));
goto err;
}
pix[i] = pixman_image_create_bits_no_clear( pix[i] = pixman_image_create_bits_no_clear(
PIXMAN_a8r8g8b8, width, height, (uint32_t *)mmapped, stride); PIXMAN_a8r8g8b8, width, height, (uint32_t *)mmapped, stride);
@ -146,8 +128,6 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, size_t copies)
.mmapped = mmapped, .mmapped = mmapped,
.wl_buf = buf, .wl_buf = buf,
.copies = copies, .copies = copies,
.cairo_surface = cairo_surface,
.cairo = cairo,
.pix = pix} .pix = pix}
) )
); );
@ -157,18 +137,6 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, size_t copies)
return ret; return ret;
err: err:
if (cairo != NULL) {
for (size_t i = 0; i < copies; i++)
if (cairo[i] != NULL)
cairo_destroy(cairo[i]);
free(cairo);
}
if (cairo_surface != NULL) {
for (size_t i = 0; i < copies; i++)
if (cairo_surface[i] != NULL)
cairo_surface_destroy(cairo_surface[i]);
free(cairo_surface);
}
if (pix != NULL) { if (pix != NULL) {
for (size_t i = 0; i < copies; i++) for (size_t i = 0; i < copies; i++)
if (pix[i] != NULL) if (pix[i] != NULL)
@ -193,18 +161,6 @@ shm_fini(void)
tll_foreach(buffers, it) { tll_foreach(buffers, it) {
struct buffer *buf = &it->item; struct buffer *buf = &it->item;
if (buf->cairo != NULL) {
for (size_t i = 0; i < buf->copies; i++)
if (buf->cairo[i] != NULL)
cairo_destroy(buf->cairo[i]);
free(buf->cairo);
}
if (buf->cairo_surface != NULL) {
for (size_t i = 0; i < buf->copies; i++)
if (buf->cairo_surface[i] != NULL)
cairo_surface_destroy(buf->cairo_surface[i]);
free(buf->cairo_surface);
}
if (buf->pix != NULL) { if (buf->pix != NULL) {
for (size_t i = 0; i < buf->copies; i++) for (size_t i = 0; i < buf->copies; i++)
if (buf->pix[i] != NULL) if (buf->pix[i] != NULL)

7
shm.h
View file

@ -3,7 +3,6 @@
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <cairo.h>
#include <pixman.h> #include <pixman.h>
#include <wayland-client.h> #include <wayland-client.h>
@ -19,11 +18,9 @@ struct buffer {
struct wl_buffer *wl_buf; struct wl_buffer *wl_buf;
size_t copies; size_t copies;
cairo_surface_t **cairo_surface;
cairo_t **cairo;
pixman_image_t **pix; pixman_image_t **pix;
}; };
struct buffer *shm_get_buffer(struct wl_shm *shm, int width, int height, size_t copies); struct buffer *shm_get_buffer(
struct wl_shm *shm, int width, int height, size_t copies);
void shm_fini(void); void shm_fini(void);

View file

@ -8,7 +8,6 @@
#include <threads.h> #include <threads.h>
#include <semaphore.h> #include <semaphore.h>
#include <cairo.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <primary-selection-unstable-v1.h> #include <primary-selection-unstable-v1.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>