libweston: change read_format to struct pixel_format_info

Everywhere we are standardising to drm_fourcc.h pixel format codes, and
using struct pixel_format_info as a general handle that allows us to
access the equivalent format in various APIs. In the name of
standardisation, convert weston_compositor::read_format to
pixel_format_info.

Pixman formats are defined CPU-endian, while DRM formats are defined
always little-endian. OpenGL has various definitions. Correctly mapping
between these when the CPU is big-endian is an extra chore we can
hopefully offload to pixel-formats.c.

GL-renderer read_format is still defined based on Pixman format, because
of the pecualiar way OpenGL defines a pixel format with
GL_UNSIGNED_BYTE. That matches the same Pixman format on big-endian but
not the same drm_fourcc.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen
2022-08-01 13:31:27 +03:00
committed by Marius Vlad
parent 03c229f4ce
commit b966fd07ea
7 changed files with 32 additions and 23 deletions
+5 -5
View File
@@ -1748,7 +1748,7 @@ gl_renderer_repaint_output(struct weston_output *output,
static int
gl_renderer_read_pixels(struct weston_output *output,
pixman_format_code_t format, void *pixels,
const struct pixel_format_info *format, void *pixels,
uint32_t x, uint32_t y,
uint32_t width, uint32_t height)
{
@@ -1758,7 +1758,7 @@ gl_renderer_read_pixels(struct weston_output *output,
x += go->borders[GL_RENDERER_BORDER_LEFT].width;
y += go->borders[GL_RENDERER_BORDER_BOTTOM].height;
switch (format) {
switch (format->pixman_format) {
case PIXMAN_a8r8g8b8:
gl_format = GL_BGRA_EXT;
break;
@@ -3883,9 +3883,9 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
}
if (weston_check_egl_extension(extensions, "GL_EXT_read_format_bgra"))
ec->read_format = PIXMAN_a8r8g8b8;
ec->read_format = pixel_format_get_info_by_pixman(PIXMAN_a8r8g8b8);
else
ec->read_format = PIXMAN_a8b8g8r8;
ec->read_format = pixel_format_get_info_by_pixman(PIXMAN_a8b8g8r8);
if (gr->gl_version < gr_gl_version(3, 0) &&
!weston_check_egl_extension(extensions, "GL_EXT_unpack_subimage")) {
@@ -3935,7 +3935,7 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
gr_gl_version_major(gr->gl_version),
gr_gl_version_minor(gr->gl_version));
weston_log_continue(STAMP_SPACE "read-back format: %s\n",
ec->read_format == PIXMAN_a8r8g8b8 ? "BGRA" : "RGBA");
ec->read_format->drm_format_name);
weston_log_continue(STAMP_SPACE "wl_shm 10 bpc formats: %s\n",
yesno(gr->has_texture_type_2_10_10_10_rev));
weston_log_continue(STAMP_SPACE "wl_shm 16 bpc formats: %s\n",