*/
void (*device_changed)(struct weston_compositor *compositor,
dev_t device, bool added);
+
+ /** Verifies if the dmabuf can be used directly/scanned-out by the HW.
+ *
+ * @param compositor The compositor.
+ * @param buffer The dmabuf to verify.
+ *
+ * Determines if the buffer can be imported directly by the display
+ * controller/HW. Back-ends can use this to check if the supplied
+ * buffer can be scanned-out, as to void importing it into the GPU.
+ */
+ bool (*can_scanout_dmabuf)(struct weston_compositor *compositor,
+ struct linux_dmabuf_buffer *buffer);
};
/* weston_head */
return renderer->import_dmabuf(compositor, buffer);
}
+WL_EXPORT bool
+weston_compositor_dmabuf_can_scanout(struct weston_compositor *compositor,
+ struct linux_dmabuf_buffer *buffer)
+{
+ struct weston_backend *backend = compositor->backend;
+
+ if (backend->can_scanout_dmabuf == NULL)
+ return false;
+
+ return backend->can_scanout_dmabuf(compositor, buffer);
+}
+
WL_EXPORT void
weston_version(int *major, int *minor, int *micro)
{
bool
weston_compositor_import_dmabuf(struct weston_compositor *compositor,
struct linux_dmabuf_buffer *buffer);
+bool
+weston_compositor_dmabuf_can_scanout(struct weston_compositor *compositor,
+ struct linux_dmabuf_buffer *buffer);
void
weston_compositor_offscreen(struct weston_compositor *compositor);
}
}
+ if (buffer->direct_display) {
+ if (!weston_compositor_dmabuf_can_scanout(buffer->compositor,
+ buffer))
+ goto err_failed;
+
+ goto avoid_gpu_import;
+ }
+
if (!weston_compositor_import_dmabuf(buffer->compositor, buffer))
goto err_failed;
+avoid_gpu_import:
buffer->buffer_resource = wl_resource_create(client,
&wl_buffer_interface,
1, buffer_id);
wl_resource_create(client,
&zwp_linux_buffer_params_v1_interface,
version, params_id);
+ buffer->direct_display = false;
if (!buffer->params_resource)
goto err_dealloc;