render: use DRM formats in wlr_renderer_get_shm_texture_formats

This commit is contained in:
Simon Ser 2021-02-16 19:20:00 +01:00
parent 549435aee5
commit ddfee63055
6 changed files with 17 additions and 17 deletions

View File

@ -113,7 +113,7 @@ struct wlr_gles2_texture {
const struct wlr_gles2_pixel_format *get_gles2_format_from_drm(uint32_t fmt); const struct wlr_gles2_pixel_format *get_gles2_format_from_drm(uint32_t fmt);
const struct wlr_gles2_pixel_format *get_gles2_format_from_gl( const struct wlr_gles2_pixel_format *get_gles2_format_from_gl(
GLint gl_format, GLint gl_type, bool alpha); GLint gl_format, GLint gl_type, bool alpha);
const enum wl_shm_format *get_gles2_wl_formats(size_t *len); const uint32_t *get_gles2_shm_formats(size_t *len);
struct wlr_gles2_renderer *gles2_get_renderer( struct wlr_gles2_renderer *gles2_get_renderer(
struct wlr_renderer *wlr_renderer); struct wlr_renderer *wlr_renderer);

View File

@ -32,8 +32,8 @@ struct wlr_renderer_impl {
const float color[static 4], const float matrix[static 9]); const float color[static 4], const float matrix[static 9]);
void (*render_ellipse_with_matrix)(struct wlr_renderer *renderer, void (*render_ellipse_with_matrix)(struct wlr_renderer *renderer,
const float color[static 4], const float matrix[static 9]); const float color[static 4], const float matrix[static 9]);
const enum wl_shm_format *(*get_shm_texture_formats)( const uint32_t *(*get_shm_texture_formats)(struct wlr_renderer *renderer,
struct wlr_renderer *renderer, size_t *len); size_t *len);
bool (*resource_is_wl_drm_buffer)(struct wlr_renderer *renderer, bool (*resource_is_wl_drm_buffer)(struct wlr_renderer *renderer,
struct wl_resource *resource); struct wl_resource *resource);
void (*wl_drm_buffer_get_size)(struct wlr_renderer *renderer, void (*wl_drm_buffer_get_size)(struct wlr_renderer *renderer,

View File

@ -85,7 +85,7 @@ void wlr_render_ellipse_with_matrix(struct wlr_renderer *r,
* Get the shared-memory formats supporting import usage. Buffers allocated * Get the shared-memory formats supporting import usage. Buffers allocated
* with a format from this list may be imported via wlr_texture_from_pixels. * with a format from this list may be imported via wlr_texture_from_pixels.
*/ */
const enum wl_shm_format *wlr_renderer_get_shm_texture_formats( const uint32_t *wlr_renderer_get_shm_texture_formats(
struct wlr_renderer *r, size_t *len); struct wlr_renderer *r, size_t *len);
/** /**
* Returns true if this wl_buffer is a wl_drm buffer. * Returns true if this wl_buffer is a wl_drm buffer.

View File

@ -2,7 +2,6 @@
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>
#include "render/gles2.h" #include "render/gles2.h"
#include "render/shm_format.h"
/* /*
* The DRM formats are little endian while the GL formats are big endian, * The DRM formats are little endian while the GL formats are big endian,
@ -66,11 +65,11 @@ const struct wlr_gles2_pixel_format *get_gles2_format_from_gl(
return NULL; return NULL;
} }
const enum wl_shm_format *get_gles2_wl_formats(size_t *len) { const uint32_t *get_gles2_shm_formats(size_t *len) {
static enum wl_shm_format wl_formats[sizeof(formats) / sizeof(formats[0])]; static uint32_t shm_formats[sizeof(formats) / sizeof(formats[0])];
*len = sizeof(formats) / sizeof(formats[0]); *len = sizeof(formats) / sizeof(formats[0]);
for (size_t i = 0; i < sizeof(formats) / sizeof(formats[0]); i++) { for (size_t i = 0; i < sizeof(formats) / sizeof(formats[0]); i++) {
wl_formats[i] = convert_drm_format_to_wl_shm(formats[i].drm_format); shm_formats[i] = formats[i].drm_format;
} }
return wl_formats; return shm_formats;
} }

View File

@ -389,9 +389,9 @@ static void gles2_render_ellipse_with_matrix(struct wlr_renderer *wlr_renderer,
pop_gles2_debug(renderer); pop_gles2_debug(renderer);
} }
static const enum wl_shm_format *gles2_get_shm_texture_formats( static const uint32_t *gles2_get_shm_texture_formats(
struct wlr_renderer *wlr_renderer, size_t *len) { struct wlr_renderer *wlr_renderer, size_t *len) {
return get_gles2_wl_formats(len); return get_gles2_shm_formats(len);
} }
static bool gles2_resource_is_wl_drm_buffer(struct wlr_renderer *wlr_renderer, static bool gles2_resource_is_wl_drm_buffer(struct wlr_renderer *wlr_renderer,

View File

@ -9,6 +9,7 @@
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "util/signal.h" #include "util/signal.h"
#include "render/shm_format.h"
#include "render/wlr_renderer.h" #include "render/wlr_renderer.h"
#include "backend/backend.h" #include "backend/backend.h"
@ -151,8 +152,8 @@ void wlr_render_ellipse_with_matrix(struct wlr_renderer *r,
r->impl->render_ellipse_with_matrix(r, color, matrix); r->impl->render_ellipse_with_matrix(r, color, matrix);
} }
const enum wl_shm_format *wlr_renderer_get_shm_texture_formats( const uint32_t *wlr_renderer_get_shm_texture_formats(struct wlr_renderer *r,
struct wlr_renderer *r, size_t *len) { size_t *len) {
return r->impl->get_shm_texture_formats(r, len); return r->impl->get_shm_texture_formats(r, len);
} }
@ -217,8 +218,7 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
} }
size_t len; size_t len;
const enum wl_shm_format *formats = const uint32_t *formats = wlr_renderer_get_shm_texture_formats(r, &len);
wlr_renderer_get_shm_texture_formats(r, &len);
if (formats == NULL) { if (formats == NULL) {
wlr_log(WLR_ERROR, "Failed to initialize shm: cannot get formats"); wlr_log(WLR_ERROR, "Failed to initialize shm: cannot get formats");
return false; return false;
@ -228,7 +228,8 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
for (size_t i = 0; i < len; ++i) { for (size_t i = 0; i < len; ++i) {
// ARGB8888 and XRGB8888 must be supported and are implicitly // ARGB8888 and XRGB8888 must be supported and are implicitly
// advertised by wl_display_init_shm // advertised by wl_display_init_shm
switch (formats[i]) { enum wl_shm_format fmt = convert_drm_format_to_wl_shm(formats[i]);
switch (fmt) {
case WL_SHM_FORMAT_ARGB8888: case WL_SHM_FORMAT_ARGB8888:
argb8888 = true; argb8888 = true;
break; break;
@ -236,7 +237,7 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
xrgb8888 = true; xrgb8888 = true;
break; break;
default: default:
wl_display_add_shm_format(wl_display, formats[i]); wl_display_add_shm_format(wl_display, fmt);
} }
} }
assert(argb8888 && xrgb8888); assert(argb8888 && xrgb8888);