mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
render: introduce wlr_texture_from_buffer
This adds a a function to create a wlr_texture from a wlr_buffer. The main motivation for this is to allow the renderer to create a single wlr_texture per wlr_buffer. This can avoid needless imports by re-using existing textures.
This commit is contained in:
parent
9221ed7b4c
commit
9d55f712e3
3 changed files with 27 additions and 0 deletions
15
include/render/wlr_texture.h
Normal file
15
include/render/wlr_texture.h
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef RENDER_WLR_TEXTURE_H
|
||||||
|
#define RENDER_WLR_TEXTURE_H
|
||||||
|
|
||||||
|
#include <wlr/render/wlr_texture.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new texture from a buffer.
|
||||||
|
*
|
||||||
|
* Should not be called in a rendering block like renderer_begin()/end() or
|
||||||
|
* between attaching a renderer to an output and committing it.
|
||||||
|
*/
|
||||||
|
struct wlr_texture *wlr_texture_from_buffer(struct wlr_renderer *renderer,
|
||||||
|
struct wlr_buffer *buffer);
|
||||||
|
|
||||||
|
#endif
|
|
@ -57,6 +57,8 @@ struct wlr_renderer_impl {
|
||||||
struct wl_display *wl_display);
|
struct wl_display *wl_display);
|
||||||
int (*get_drm_fd)(struct wlr_renderer *renderer);
|
int (*get_drm_fd)(struct wlr_renderer *renderer);
|
||||||
uint32_t (*get_render_buffer_caps)(void);
|
uint32_t (*get_render_buffer_caps)(void);
|
||||||
|
struct wlr_texture *(*texture_from_buffer)(struct wlr_renderer *renderer,
|
||||||
|
struct wlr_buffer *buffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
void wlr_renderer_init(struct wlr_renderer *renderer,
|
void wlr_renderer_init(struct wlr_renderer *renderer,
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <wlr/render/interface.h>
|
#include <wlr/render/interface.h>
|
||||||
#include <wlr/render/wlr_texture.h>
|
#include <wlr/render/wlr_texture.h>
|
||||||
|
#include "render/wlr_texture.h"
|
||||||
|
|
||||||
void wlr_texture_init(struct wlr_texture *texture,
|
void wlr_texture_init(struct wlr_texture *texture,
|
||||||
const struct wlr_texture_impl *impl, uint32_t width, uint32_t height) {
|
const struct wlr_texture_impl *impl, uint32_t width, uint32_t height) {
|
||||||
|
@ -46,6 +47,15 @@ struct wlr_texture *wlr_texture_from_dmabuf(struct wlr_renderer *renderer,
|
||||||
return renderer->impl->texture_from_dmabuf(renderer, attribs);
|
return renderer->impl->texture_from_dmabuf(renderer, attribs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct wlr_texture *wlr_texture_from_buffer(struct wlr_renderer *renderer,
|
||||||
|
struct wlr_buffer *buffer) {
|
||||||
|
assert(!renderer->rendering);
|
||||||
|
if (!renderer->impl->texture_from_buffer) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return renderer->impl->texture_from_buffer(renderer, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
bool wlr_texture_is_opaque(struct wlr_texture *texture) {
|
bool wlr_texture_is_opaque(struct wlr_texture *texture) {
|
||||||
if (!texture->impl->is_opaque) {
|
if (!texture->impl->is_opaque) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue