]> git.mdlowis.com Git - proto/labwc.git/commit
buffer: reduce unnecessary painting to new cairo surfaces
authorJohn Lindgren <john@jlindgren.net>
Sun, 6 Oct 2024 05:42:54 +0000 (01:42 -0400)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 6 Oct 2024 15:51:14 +0000 (16:51 +0100)
commitd2b161bdf8122f0240075cfcc2c88b4fee8417d9
treea6ee193410d9024043d5bc1d22cb8e55c2311157
parent328f873db3511ba7466804a1c44be2bc8cce277c
buffer: reduce unnecessary painting to new cairo surfaces

Add buffer_adopt_cairo_surface(), which allows wrapping an existing
cairo image surface in a struct lab_data_buffer. This is useful when
loading PNGs since most will be loaded as ARGB32 already.

Fix a memory leak in the non-ARGB32 PNG case, where we do still need to
paint to a new image surface -- we were leaking the original surface.

Eliminate an unnecessary temporary image surface in SVG loading and just
render the SVG to the image surface held by the lab_data_buffer.

I also cleaned up and clarified the buffer API a bit:

- Add a pointer to the held cairo_surface_t (so we can still access it
  if there is no cairo_t).
- Remove the free_on_destroy bool (it was always true).
- Rename unscaled_width/height to logical_width/height and add an
  explanatory comment. It was unclear what "unscaled" meant.
- Rename buffer_create_wrap() to buffer_create_from_data().

This is laying groundwork for some more icon fixes I am working on
(making sure icons are loaded and rendered at the correct scale).
14 files changed:
include/buffer.h
src/buffer.c
src/common/font.c
src/common/graphic-helpers.c
src/common/scaled-font-buffer.c
src/common/scaled-scene-buffer.c
src/img/img-png.c
src/img/img-svg.c
src/img/img-xbm.c
src/img/img-xpm.c
src/osd.c
src/ssd/ssd-shadow.c
src/theme.c
src/workspaces.c