mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-25 00:22:25 +00:00
renderer: replace get_render_buffer_caps() with struct field
This commit is contained in:
parent
0686666cf5
commit
ebef710746
@ -13,11 +13,5 @@ struct wlr_renderer *renderer_autocreate_with_drm_fd(int drm_fd);
|
||||
*/
|
||||
const struct wlr_drm_format_set *wlr_renderer_get_render_formats(
|
||||
struct wlr_renderer *renderer);
|
||||
/**
|
||||
* Get the supported buffer capabilities.
|
||||
*
|
||||
* This functions returns a bitfield of supported wlr_buffer_cap.
|
||||
*/
|
||||
uint32_t renderer_get_render_buffer_caps(struct wlr_renderer *renderer);
|
||||
|
||||
#endif
|
||||
|
@ -26,7 +26,6 @@ struct wlr_renderer_impl {
|
||||
struct wlr_renderer *renderer);
|
||||
void (*destroy)(struct wlr_renderer *renderer);
|
||||
int (*get_drm_fd)(struct wlr_renderer *renderer);
|
||||
uint32_t (*get_render_buffer_caps)(struct wlr_renderer *renderer);
|
||||
struct wlr_texture *(*texture_from_buffer)(struct wlr_renderer *renderer,
|
||||
struct wlr_buffer *buffer);
|
||||
struct wlr_render_pass *(*begin_buffer_pass)(struct wlr_renderer *renderer,
|
||||
@ -35,7 +34,7 @@ struct wlr_renderer_impl {
|
||||
};
|
||||
|
||||
void wlr_renderer_init(struct wlr_renderer *renderer,
|
||||
const struct wlr_renderer_impl *impl);
|
||||
const struct wlr_renderer_impl *impl, uint32_t render_buffer_caps);
|
||||
|
||||
struct wlr_texture_impl {
|
||||
bool (*update_from_buffer)(struct wlr_texture *texture,
|
||||
|
@ -26,6 +26,10 @@ struct wlr_fbox;
|
||||
* A renderer for basic 2D operations.
|
||||
*/
|
||||
struct wlr_renderer {
|
||||
// Capabilities required for the buffer used as a render target (bitmask of
|
||||
// enum wlr_buffer_cap)
|
||||
uint32_t render_buffer_caps;
|
||||
|
||||
struct {
|
||||
struct wl_signal destroy;
|
||||
/**
|
||||
|
@ -94,7 +94,7 @@ static int reopen_drm_node(int drm_fd, bool allow_render_node) {
|
||||
struct wlr_allocator *allocator_autocreate_with_drm_fd(
|
||||
uint32_t backend_caps, struct wlr_renderer *renderer,
|
||||
int drm_fd) {
|
||||
uint32_t renderer_caps = renderer_get_render_buffer_caps(renderer);
|
||||
uint32_t renderer_caps = renderer->render_buffer_caps;
|
||||
|
||||
struct wlr_allocator *alloc = NULL;
|
||||
|
||||
|
@ -194,10 +194,6 @@ static int gles2_get_drm_fd(struct wlr_renderer *wlr_renderer) {
|
||||
return renderer->drm_fd;
|
||||
}
|
||||
|
||||
static uint32_t gles2_get_render_buffer_caps(struct wlr_renderer *wlr_renderer) {
|
||||
return WLR_BUFFER_CAP_DMABUF;
|
||||
}
|
||||
|
||||
struct wlr_egl *wlr_gles2_renderer_get_egl(struct wlr_renderer *wlr_renderer) {
|
||||
struct wlr_gles2_renderer *renderer =
|
||||
gles2_get_renderer(wlr_renderer);
|
||||
@ -361,7 +357,6 @@ static const struct wlr_renderer_impl renderer_impl = {
|
||||
.get_texture_formats = gles2_get_texture_formats,
|
||||
.get_render_formats = gles2_get_render_formats,
|
||||
.get_drm_fd = gles2_get_drm_fd,
|
||||
.get_render_buffer_caps = gles2_get_render_buffer_caps,
|
||||
.texture_from_buffer = gles2_texture_from_buffer,
|
||||
.begin_buffer_pass = gles2_begin_buffer_pass,
|
||||
.render_timer_create = gles2_render_timer_create,
|
||||
@ -530,7 +525,7 @@ struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_egl *egl) {
|
||||
if (renderer == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl);
|
||||
wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl, WLR_BUFFER_CAP_DMABUF);
|
||||
|
||||
wl_list_init(&renderer->buffers);
|
||||
wl_list_init(&renderer->textures);
|
||||
|
@ -292,10 +292,6 @@ static void pixman_destroy(struct wlr_renderer *wlr_renderer) {
|
||||
free(renderer);
|
||||
}
|
||||
|
||||
static uint32_t pixman_get_render_buffer_caps(struct wlr_renderer *renderer) {
|
||||
return WLR_BUFFER_CAP_DATA_PTR;
|
||||
}
|
||||
|
||||
static struct wlr_render_pass *pixman_begin_buffer_pass(struct wlr_renderer *wlr_renderer,
|
||||
struct wlr_buffer *wlr_buffer, const struct wlr_buffer_pass_options *options) {
|
||||
struct wlr_pixman_renderer *renderer = get_renderer(wlr_renderer);
|
||||
@ -320,7 +316,6 @@ static const struct wlr_renderer_impl renderer_impl = {
|
||||
.get_render_formats = pixman_get_render_formats,
|
||||
.texture_from_buffer = pixman_texture_from_buffer,
|
||||
.destroy = pixman_destroy,
|
||||
.get_render_buffer_caps = pixman_get_render_buffer_caps,
|
||||
.begin_buffer_pass = pixman_begin_buffer_pass,
|
||||
};
|
||||
|
||||
@ -331,7 +326,7 @@ struct wlr_renderer *wlr_pixman_renderer_create(void) {
|
||||
}
|
||||
|
||||
wlr_log(WLR_INFO, "Creating pixman renderer");
|
||||
wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl);
|
||||
wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl, WLR_BUFFER_CAP_DATA_PTR);
|
||||
wl_list_init(&renderer->buffers);
|
||||
wl_list_init(&renderer->textures);
|
||||
|
||||
|
@ -1299,10 +1299,6 @@ static int vulkan_get_drm_fd(struct wlr_renderer *wlr_renderer) {
|
||||
return renderer->dev->drm_fd;
|
||||
}
|
||||
|
||||
static uint32_t vulkan_get_render_buffer_caps(struct wlr_renderer *wlr_renderer) {
|
||||
return WLR_BUFFER_CAP_DMABUF;
|
||||
}
|
||||
|
||||
static struct wlr_render_pass *vulkan_begin_buffer_pass(struct wlr_renderer *wlr_renderer,
|
||||
struct wlr_buffer *buffer, const struct wlr_buffer_pass_options *options) {
|
||||
struct wlr_vk_renderer *renderer = vulkan_get_renderer(wlr_renderer);
|
||||
@ -1327,7 +1323,6 @@ static const struct wlr_renderer_impl renderer_impl = {
|
||||
.get_render_formats = vulkan_get_render_formats,
|
||||
.destroy = vulkan_destroy,
|
||||
.get_drm_fd = vulkan_get_drm_fd,
|
||||
.get_render_buffer_caps = vulkan_get_render_buffer_caps,
|
||||
.texture_from_buffer = vulkan_texture_from_buffer,
|
||||
.begin_buffer_pass = vulkan_begin_buffer_pass,
|
||||
};
|
||||
@ -2151,7 +2146,7 @@ struct wlr_renderer *vulkan_renderer_create_for_device(struct wlr_vk_device *dev
|
||||
}
|
||||
|
||||
renderer->dev = dev;
|
||||
wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl);
|
||||
wlr_renderer_init(&renderer->wlr_renderer, &renderer_impl, WLR_BUFFER_CAP_DMABUF);
|
||||
wl_list_init(&renderer->stage.buffers);
|
||||
wl_list_init(&renderer->foreign_textures);
|
||||
wl_list_init(&renderer->textures);
|
||||
|
@ -30,13 +30,14 @@
|
||||
#include "util/env.h"
|
||||
|
||||
void wlr_renderer_init(struct wlr_renderer *renderer,
|
||||
const struct wlr_renderer_impl *impl) {
|
||||
const struct wlr_renderer_impl *impl, uint32_t render_buffer_caps) {
|
||||
assert(impl->begin_buffer_pass);
|
||||
assert(impl->get_texture_formats);
|
||||
assert(impl->get_render_buffer_caps);
|
||||
assert(render_buffer_caps != 0);
|
||||
|
||||
*renderer = (struct wlr_renderer){
|
||||
.impl = impl,
|
||||
.render_buffer_caps = render_buffer_caps,
|
||||
};
|
||||
|
||||
wl_signal_init(&renderer->events.destroy);
|
||||
@ -70,10 +71,6 @@ const struct wlr_drm_format_set *wlr_renderer_get_render_formats(
|
||||
return r->impl->get_render_formats(r);
|
||||
}
|
||||
|
||||
uint32_t renderer_get_render_buffer_caps(struct wlr_renderer *r) {
|
||||
return r->impl->get_render_buffer_caps(r);
|
||||
}
|
||||
|
||||
bool wlr_renderer_init_wl_shm(struct wlr_renderer *r,
|
||||
struct wl_display *wl_display) {
|
||||
return wlr_shm_create_with_renderer(wl_display, 1, r) != NULL;
|
||||
|
@ -18,7 +18,7 @@ bool wlr_output_init_render(struct wlr_output *output,
|
||||
assert(allocator != NULL && renderer != NULL);
|
||||
|
||||
uint32_t backend_caps = backend_get_buffer_caps(output->backend);
|
||||
uint32_t renderer_caps = renderer_get_render_buffer_caps(renderer);
|
||||
uint32_t renderer_caps = renderer->render_buffer_caps;
|
||||
|
||||
if (!(backend_caps & allocator->buffer_caps)) {
|
||||
wlr_log(WLR_ERROR, "output backend and allocator buffer capabilities "
|
||||
|
Loading…
Reference in New Issue
Block a user