Commit graph

14 commits

Author SHA1 Message Date
tokyo4j
649773b4f8 buffer: add buffer_create_from_wlr_buffer() 2025-06-07 02:12:56 +09:00
tokyo4j
82b0235aca buffer: add buffer_resize() 2025-06-07 02:12:56 +09:00
tokyo4j
16dbdc64e5 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().
2024-12-23 18:11:32 +09:00
tokyo4j
4502d58eec buffer: remove buffer->cairo
It's more common for cairo_t to have a temporary lifetime and it will
prevent accidentally reusing its previous state.
2024-11-28 18:56:03 +09:00
tokyo4j
c48324975d buffer: always set buffer->{cairo,surface} for simplification 2024-11-28 18:56:03 +09:00
John Lindgren
2e9b5886ce buffer: add buffer_convert_cairo_surface_for_icon()
Which handles:
 - conversion from other pixel formats to ARGB32
 - setting the logical size to the desired display size
 - downscaling very large images using CAIRO_FILTER_GOOD
2024-10-06 22:30:46 -04:00
John Lindgren
d2b161bdf8 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).
2024-10-06 16:51:14 +01:00
Tomi Ollila
7ad5200f2e includes: identifier consistency in include guards
Made all header files to have LABWC_ prefix in include guard identifers.

Converted from __LABWC_ in 35 include/ files.
Converted from __LAB_ in 5 include/ files.
Added LABWC prefix to 3 include/ files.
Added include guards to 3 include/ files.

The double underscores were removed since according to C standard
those "are always reserved for any use".
2023-05-13 22:29:21 +01:00
Consolatis
505f92e733 src/buffer: Automatically adapt to scale attribute
Based on discussion in PR #389
2022-06-14 22:03:08 +01:00
Consolatis
5862b65f89 Convert SSD to scene nodes 2022-02-23 21:47:01 +00:00
Consolatis
044388a5cd Prepare to move from wlr_texture to lab_data_buffer 2022-02-23 21:47:01 +00:00
Johan Malm
f22bfc96b2 buffer: create cairo_t inside buffer_create() 2022-02-23 21:47:01 +00:00
Johan Malm
ba909e4fc7 Refactor buffer implementation to take a cairo_t
Remove buffer_drop() and just destroy it.
2022-02-23 21:47:01 +00:00
Johan Malm
d2552232c7 Add buffer.c to cover cairo-surface to wlr_buffer 2022-02-23 21:41:01 +00:00