mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-29 10:32:29 +00:00
buffer: handle wl_drm buffers
This allows renderers to choose between implementing the old wlr_renderer_impl.texture_from_wl_drm hook, or opt for the new wlr_drm stub. The stub has the advantage of not requiring any special support code: stubbed wl_drm buffers look exactly like DMA-BUFs from linux-dmabuf-unstable-v1.
This commit is contained in:
parent
c868e509b7
commit
d7b19fb294
@ -2,6 +2,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <wlr/render/wlr_renderer.h>
|
#include <wlr/render/wlr_renderer.h>
|
||||||
#include <wlr/types/wlr_buffer.h>
|
#include <wlr/types/wlr_buffer.h>
|
||||||
|
#include <wlr/types/wlr_drm.h>
|
||||||
#include <wlr/types/wlr_linux_dmabuf_v1.h>
|
#include <wlr/types/wlr_linux_dmabuf_v1.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include "render/pixel_format.h"
|
#include "render/pixel_format.h"
|
||||||
@ -120,6 +121,11 @@ bool wlr_resource_get_buffer_size(struct wl_resource *resource,
|
|||||||
wlr_dmabuf_v1_buffer_from_buffer_resource(resource);
|
wlr_dmabuf_v1_buffer_from_buffer_resource(resource);
|
||||||
*width = dmabuf->attributes.width;
|
*width = dmabuf->attributes.width;
|
||||||
*height = dmabuf->attributes.height;
|
*height = dmabuf->attributes.height;
|
||||||
|
} else if (wlr_drm_buffer_is_resource(resource)) {
|
||||||
|
struct wlr_drm_buffer *drm_buffer =
|
||||||
|
wlr_drm_buffer_from_resource(resource);
|
||||||
|
*width = drm_buffer->base.width;
|
||||||
|
*height = drm_buffer->base.height;
|
||||||
} else {
|
} else {
|
||||||
*width = *height = 0;
|
*width = *height = 0;
|
||||||
return false;
|
return false;
|
||||||
@ -241,6 +247,14 @@ struct wlr_client_buffer *wlr_client_buffer_import(
|
|||||||
wlr_dmabuf_v1_buffer_from_buffer_resource(resource);
|
wlr_dmabuf_v1_buffer_from_buffer_resource(resource);
|
||||||
texture = wlr_texture_from_buffer(renderer, &dmabuf->base);
|
texture = wlr_texture_from_buffer(renderer, &dmabuf->base);
|
||||||
|
|
||||||
|
// The renderer is responsible for releasing the buffer when
|
||||||
|
// appropriate
|
||||||
|
resource_released = true;
|
||||||
|
} else if (wlr_drm_buffer_is_resource(resource)) {
|
||||||
|
struct wlr_drm_buffer *drm_buffer =
|
||||||
|
wlr_drm_buffer_from_resource(resource);
|
||||||
|
texture = wlr_texture_from_buffer(renderer, &drm_buffer->base);
|
||||||
|
|
||||||
// The renderer is responsible for releasing the buffer when
|
// The renderer is responsible for releasing the buffer when
|
||||||
// appropriate
|
// appropriate
|
||||||
resource_released = true;
|
resource_released = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user