swaywm / wlroots

A modular Wayland compositor library
https://gitlab.freedesktop.org/wlroots/wlroots/
MIT License
2.15k stars 343 forks source link

renderer: switch to a more high-level API #3188

Open emersion opened 3 years ago

emersion commented 3 years ago

Remove clear, scissor. Replace other functions with something like:

struct wlr_render_texture_options {
    const struct wlr_fbox *src_box;
    const struct wlr_box *dst_box;
    float alpha;
    pixman_region32_t *clip;
};

void wlr_render_texture(struct wlr_renderer *r, struct wlr_texture *texture,
    const struct wlr_render_texture_options *options);

struct wlr_render_rect_options {
    pixman_region32_t *clip;
};

void wlr_render_rect(struct wlr_renderer *r, const struct wlr_box *box,
    const float color[static 4], const struct wlr_render_rect_options *options);

This would help with https://github.com/swaywm/wlroots/issues/2930 and https://github.com/swaywm/wlroots/issues/2644.


wlroots has migrated to gitlab.freedesktop.org. This issue has been moved to:

https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3188

nyorain commented 3 years ago

Do we really want/need a pixman_region32_t for clipping? I think a rect should be enough for most common cases. Implementing clipping for arbitrary regions isn't trivial in OpenGL/Vulkan. I guess it could be implemented by rendering the surface for each rect in the region or by using some custom fragment-shader clipping but that's quite some hidden cost for complex regions. EDIT: ok nevermind, just saw the extensions in OpenGL/Vulkan. I guess this makes sense if they are available on all targeted hardware.

emersion commented 3 years ago

Yes, we really need clipping for damage tracking purposes. I guess we could rename it to damage and let the renderer take the bounding box if it wants to. Or draw instanced maybe.