output: use DRM format in wlr_output_preferred_read_format

This commit is contained in:
Simon Ser 2021-02-16 19:30:26 +01:00
parent ddfee63055
commit 00bf6674b3
5 changed files with 17 additions and 14 deletions

View file

@ -1,5 +1,6 @@
#define _POSIX_C_SOURCE 200809L
#include <assert.h>
#include <drm_fourcc.h>
#include <stdlib.h>
#include <string.h>
#include <tgmath.h>
@ -450,19 +451,18 @@ bool wlr_output_attach_render(struct wlr_output *output, int *buffer_age) {
return true;
}
bool wlr_output_preferred_read_format(struct wlr_output *output,
enum wl_shm_format *fmt) {
uint32_t wlr_output_preferred_read_format(struct wlr_output *output) {
struct wlr_renderer *renderer = wlr_backend_get_renderer(output->backend);
if (!renderer->impl->preferred_read_format || !renderer->impl->read_pixels) {
return false;
return DRM_FORMAT_INVALID;
}
if (!output->impl->attach_render(output, NULL)) {
return false;
return DRM_FORMAT_INVALID;
}
*fmt = renderer->impl->preferred_read_format(renderer);
uint32_t fmt = renderer->impl->preferred_read_format(renderer);
output->impl->rollback_render(output);
return true;
return fmt;
}
void wlr_output_set_damage(struct wlr_output *output,

View file

@ -8,6 +8,7 @@
#include <wlr/backend.h>
#include <wlr/util/log.h>
#include "wlr-screencopy-unstable-v1-protocol.h"
#include "render/shm_format.h"
#include "util/signal.h"
#define SCREENCOPY_MANAGER_VERSION 3
@ -551,12 +552,14 @@ static void capture_output(struct wl_client *wl_client,
struct wlr_renderer *renderer = wlr_backend_get_renderer(output->backend);
assert(renderer);
if (!wlr_output_preferred_read_format(frame->output, &frame->format)) {
uint32_t drm_format = wlr_output_preferred_read_format(frame->output);
if (drm_format == DRM_FORMAT_INVALID) {
wlr_log(WLR_ERROR,
"Failed to capture output: no read format supported by renderer");
goto error;
}
frame->format = convert_drm_format_to_wl_shm(drm_format);
frame->fourcc = get_output_fourcc(output);
struct wlr_box buffer_box = {0};