mirror of
https://gitlab.freedesktop.org/wayland/weston
synced 2024-10-15 00:10:38 +00:00
pixel-formats: add RGBA bits and type fields
These fields are necessary when looking for an EGLConfig matching a pixel format, but the configs do not expose a native visual id. Such happens on the EGL surfaceless platform where one does not actually care about the exact pixel format, one just cares it has the right number of bits for each channel and the right component type. FP16 formats are coming, so this paves way for them too, allowing them to be described. The FIXED/FLOAT terminology comes from EGL_EXT_pixel_format_float. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
ad8c7448cd
commit
abd3f3c3ea
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2016 Collabora, Ltd.
|
||||
* Copyright © 2016, 2019 Collabora, Ltd.
|
||||
* Copyright (c) 2018 DisplayLink (UK) Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -53,6 +53,12 @@
|
|||
#endif
|
||||
|
||||
#define DRM_FORMAT(f) .format = DRM_FORMAT_ ## f, .drm_format_name = #f
|
||||
#define BITS_RGBA_FIXED(r_, g_, b_, a_) \
|
||||
.bits.r = r_, \
|
||||
.bits.g = g_, \
|
||||
.bits.b = b_, \
|
||||
.bits.a = a_, \
|
||||
.component_type = PIXEL_COMPONENT_TYPE_FIXED
|
||||
|
||||
#include "weston-egl-ext.h"
|
||||
|
||||
|
@ -64,20 +70,25 @@
|
|||
static const struct pixel_format_info pixel_format_table[] = {
|
||||
{
|
||||
DRM_FORMAT(XRGB4444),
|
||||
BITS_RGBA_FIXED(4, 4, 4, 0),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(ARGB4444),
|
||||
BITS_RGBA_FIXED(4, 4, 4, 4),
|
||||
.opaque_substitute = DRM_FORMAT_XRGB4444,
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(XBGR4444),
|
||||
BITS_RGBA_FIXED(4, 4, 4, 0),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(ABGR4444),
|
||||
BITS_RGBA_FIXED(4, 4, 4, 4),
|
||||
.opaque_substitute = DRM_FORMAT_XBGR4444,
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(RGBX4444),
|
||||
BITS_RGBA_FIXED(4, 4, 4, 0),
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
GL_FORMAT(GL_RGBA),
|
||||
GL_TYPE(GL_UNSIGNED_SHORT_4_4_4_4),
|
||||
|
@ -85,6 +96,7 @@ static const struct pixel_format_info pixel_format_table[] = {
|
|||
},
|
||||
{
|
||||
DRM_FORMAT(RGBA4444),
|
||||
BITS_RGBA_FIXED(4, 4, 4, 4),
|
||||
.opaque_substitute = DRM_FORMAT_RGBX4444,
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
GL_FORMAT(GL_RGBA),
|
||||
|
@ -93,29 +105,36 @@ static const struct pixel_format_info pixel_format_table[] = {
|
|||
},
|
||||
{
|
||||
DRM_FORMAT(BGRX4444),
|
||||
BITS_RGBA_FIXED(4, 4, 4, 0),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(BGRA4444),
|
||||
BITS_RGBA_FIXED(4, 4, 4, 4),
|
||||
.opaque_substitute = DRM_FORMAT_BGRX4444,
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(XRGB1555),
|
||||
BITS_RGBA_FIXED(5, 5, 5, 0),
|
||||
.depth = 15,
|
||||
.bpp = 16,
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(ARGB1555),
|
||||
BITS_RGBA_FIXED(5, 5, 5, 1),
|
||||
.opaque_substitute = DRM_FORMAT_XRGB1555,
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(XBGR1555),
|
||||
BITS_RGBA_FIXED(5, 5, 5, 0),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(ABGR1555),
|
||||
BITS_RGBA_FIXED(5, 5, 5, 1),
|
||||
.opaque_substitute = DRM_FORMAT_XBGR1555,
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(RGBX5551),
|
||||
BITS_RGBA_FIXED(5, 5, 5, 0),
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
GL_FORMAT(GL_RGBA),
|
||||
GL_TYPE(GL_UNSIGNED_SHORT_5_5_5_1),
|
||||
|
@ -123,6 +142,7 @@ static const struct pixel_format_info pixel_format_table[] = {
|
|||
},
|
||||
{
|
||||
DRM_FORMAT(RGBA5551),
|
||||
BITS_RGBA_FIXED(5, 5, 5, 1),
|
||||
.opaque_substitute = DRM_FORMAT_RGBX5551,
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
GL_FORMAT(GL_RGBA),
|
||||
|
@ -131,13 +151,16 @@ static const struct pixel_format_info pixel_format_table[] = {
|
|||
},
|
||||
{
|
||||
DRM_FORMAT(BGRX5551),
|
||||
BITS_RGBA_FIXED(5, 5, 5, 0),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(BGRA5551),
|
||||
BITS_RGBA_FIXED(5, 5, 5, 1),
|
||||
.opaque_substitute = DRM_FORMAT_BGRX5551,
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(RGB565),
|
||||
BITS_RGBA_FIXED(5, 6, 5, 0),
|
||||
.depth = 16,
|
||||
.bpp = 16,
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
|
@ -147,17 +170,21 @@ static const struct pixel_format_info pixel_format_table[] = {
|
|||
},
|
||||
{
|
||||
DRM_FORMAT(BGR565),
|
||||
BITS_RGBA_FIXED(5, 6, 5, 0),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(RGB888),
|
||||
BITS_RGBA_FIXED(8, 8, 8, 0),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(BGR888),
|
||||
BITS_RGBA_FIXED(8, 8, 8, 0),
|
||||
GL_FORMAT(GL_RGB),
|
||||
GL_TYPE(GL_UNSIGNED_BYTE),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(XRGB8888),
|
||||
BITS_RGBA_FIXED(8, 8, 8, 0),
|
||||
.depth = 24,
|
||||
.bpp = 32,
|
||||
GL_FORMAT(GL_BGRA_EXT),
|
||||
|
@ -165,6 +192,7 @@ static const struct pixel_format_info pixel_format_table[] = {
|
|||
},
|
||||
{
|
||||
DRM_FORMAT(ARGB8888),
|
||||
BITS_RGBA_FIXED(8, 8, 8, 8),
|
||||
.opaque_substitute = DRM_FORMAT_XRGB8888,
|
||||
.depth = 32,
|
||||
.bpp = 32,
|
||||
|
@ -173,40 +201,49 @@ static const struct pixel_format_info pixel_format_table[] = {
|
|||
},
|
||||
{
|
||||
DRM_FORMAT(XBGR8888),
|
||||
BITS_RGBA_FIXED(8, 8, 8, 0),
|
||||
GL_FORMAT(GL_RGBA),
|
||||
GL_TYPE(GL_UNSIGNED_BYTE),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(ABGR8888),
|
||||
BITS_RGBA_FIXED(8, 8, 8, 8),
|
||||
.opaque_substitute = DRM_FORMAT_XBGR8888,
|
||||
GL_FORMAT(GL_RGBA),
|
||||
GL_TYPE(GL_UNSIGNED_BYTE),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(RGBX8888),
|
||||
BITS_RGBA_FIXED(8, 8, 8, 0),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(RGBA8888),
|
||||
BITS_RGBA_FIXED(8, 8, 8, 8),
|
||||
.opaque_substitute = DRM_FORMAT_RGBX8888,
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(BGRX8888),
|
||||
BITS_RGBA_FIXED(8, 8, 8, 0),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(BGRA8888),
|
||||
BITS_RGBA_FIXED(8, 8, 8, 8),
|
||||
.opaque_substitute = DRM_FORMAT_BGRX8888,
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(XRGB2101010),
|
||||
BITS_RGBA_FIXED(10, 10, 10, 0),
|
||||
.depth = 30,
|
||||
.bpp = 32,
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(ARGB2101010),
|
||||
BITS_RGBA_FIXED(10, 10, 10, 2),
|
||||
.opaque_substitute = DRM_FORMAT_XRGB2101010,
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(XBGR2101010),
|
||||
BITS_RGBA_FIXED(10, 10, 10, 0),
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
GL_FORMAT(GL_RGBA),
|
||||
GL_TYPE(GL_UNSIGNED_INT_2_10_10_10_REV_EXT),
|
||||
|
@ -214,6 +251,7 @@ static const struct pixel_format_info pixel_format_table[] = {
|
|||
},
|
||||
{
|
||||
DRM_FORMAT(ABGR2101010),
|
||||
BITS_RGBA_FIXED(10, 10, 10, 2),
|
||||
.opaque_substitute = DRM_FORMAT_XBGR2101010,
|
||||
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
GL_FORMAT(GL_RGBA),
|
||||
|
@ -222,16 +260,20 @@ static const struct pixel_format_info pixel_format_table[] = {
|
|||
},
|
||||
{
|
||||
DRM_FORMAT(RGBX1010102),
|
||||
BITS_RGBA_FIXED(10, 10, 10, 0),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(RGBA1010102),
|
||||
BITS_RGBA_FIXED(10, 10, 10, 2),
|
||||
.opaque_substitute = DRM_FORMAT_RGBX1010102,
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(BGRX1010102),
|
||||
BITS_RGBA_FIXED(10, 10, 10, 0),
|
||||
},
|
||||
{
|
||||
DRM_FORMAT(BGRA1010102),
|
||||
BITS_RGBA_FIXED(10, 10, 10, 2),
|
||||
.opaque_substitute = DRM_FORMAT_BGRX1010102,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2016 Collabora, Ltd.
|
||||
* Copyright © 2016, 2019 Collabora, Ltd.
|
||||
* Copyright (c) 2018 DisplayLink (UK) Ltd.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -100,6 +100,20 @@ struct pixel_format_info {
|
|||
ORDER_LUMA_CHROMA = 0,
|
||||
ORDER_CHROMA_LUMA,
|
||||
} luma_chroma_order;
|
||||
|
||||
/** How many significant bits each channel has, or zero if N/A. */
|
||||
struct {
|
||||
int r;
|
||||
int g;
|
||||
int b;
|
||||
int a;
|
||||
} bits;
|
||||
|
||||
/** How channel bits are interpreted, fixed (uint) or floating-point */
|
||||
enum {
|
||||
PIXEL_COMPONENT_TYPE_FIXED = 0,
|
||||
PIXEL_COMPONENT_TYPE_FLOAT,
|
||||
} component_type;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue