mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-08 13:29:45 -05:00
render/pixel_format: make wlr_pixel_format_info part of the public API
This commit is contained in:
parent
4a4c8ca320
commit
ae43cf93dd
16 changed files with 67 additions and 59 deletions
|
|
@ -15,6 +15,7 @@
|
|||
#include <wayland-util.h>
|
||||
#include <wlr/backend/interface.h>
|
||||
#include <wlr/interfaces/wlr_output.h>
|
||||
#include <wlr/render/pixel_format.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/util/box.h>
|
||||
|
|
@ -25,7 +26,6 @@
|
|||
#include "backend/drm/drm.h"
|
||||
#include "backend/drm/iface.h"
|
||||
#include "backend/drm/util.h"
|
||||
#include "render/pixel_format.h"
|
||||
#include "render/drm_format_set.h"
|
||||
#include "render/swapchain.h"
|
||||
#include "render/wlr_renderer.h"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-util.h>
|
||||
#include <wlr/render/pixel_format.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
|
@ -14,7 +15,6 @@
|
|||
#include "backend/drm/util.h"
|
||||
#include "render/drm_format_set.h"
|
||||
#include "render/allocator/allocator.h"
|
||||
#include "render/pixel_format.h"
|
||||
#include "render/swapchain.h"
|
||||
#include "render/wlr_renderer.h"
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ struct wlr_drm_format *drm_plane_pick_render_format(
|
|||
uint32_t fmt = DRM_FORMAT_ARGB8888;
|
||||
if (!wlr_drm_format_set_has(&plane->formats, fmt, DRM_FORMAT_MOD_INVALID)) {
|
||||
const struct wlr_pixel_format_info *format_info =
|
||||
drm_get_pixel_format_info(fmt);
|
||||
wlr_pixel_format_info_from_drm(fmt);
|
||||
assert(format_info != NULL &&
|
||||
format_info->opaque_substitute != DRM_FORMAT_INVALID);
|
||||
fmt = format_info->opaque_substitute;
|
||||
|
|
@ -306,7 +306,7 @@ static struct wlr_drm_fb *drm_fb_create(struct wlr_drm_backend *drm,
|
|||
// The format isn't supported by the plane. Try stripping the alpha
|
||||
// channel, if any.
|
||||
const struct wlr_pixel_format_info *info =
|
||||
drm_get_pixel_format_info(attribs.format);
|
||||
wlr_pixel_format_info_from_drm(attribs.format);
|
||||
if (info != NULL && info->opaque_substitute != DRM_FORMAT_INVALID &&
|
||||
wlr_drm_format_set_has(formats, info->opaque_substitute, attribs.modifier)) {
|
||||
attribs.format = info->opaque_substitute;
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
#include <wlr/backend/interface.h>
|
||||
#include <wlr/interfaces/wlr_input_device.h>
|
||||
#include <wlr/interfaces/wlr_output.h>
|
||||
#include <wlr/render/pixel_format.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#include "backend/backend.h"
|
||||
#include "backend/wayland.h"
|
||||
#include "render/drm_format_set.h"
|
||||
#include "render/pixel_format.h"
|
||||
#include "render/wlr_renderer.h"
|
||||
#include "util/signal.h"
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ static const struct wl_drm_listener legacy_drm_listener = {
|
|||
static void shm_handle_format(void *data, struct wl_shm *shm,
|
||||
uint32_t shm_format) {
|
||||
struct wlr_wl_backend *wl = data;
|
||||
uint32_t drm_format = convert_wl_shm_format_to_drm(shm_format);
|
||||
uint32_t drm_format = wlr_convert_wl_shm_format_to_drm(shm_format);
|
||||
wlr_drm_format_set_add(&wl->shm_formats, drm_format, DRM_FORMAT_MOD_INVALID);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@
|
|||
#include <wayland-client.h>
|
||||
|
||||
#include <wlr/interfaces/wlr_output.h>
|
||||
#include <wlr/render/pixel_format.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#include "backend/wayland.h"
|
||||
#include "render/pixel_format.h"
|
||||
#include "render/swapchain.h"
|
||||
#include "render/wlr_renderer.h"
|
||||
#include "util/signal.h"
|
||||
|
|
@ -178,7 +178,8 @@ static struct wl_buffer *import_dmabuf(struct wlr_wl_backend *wl,
|
|||
|
||||
static struct wl_buffer *import_shm(struct wlr_wl_backend *wl,
|
||||
struct wlr_shm_attributes *shm) {
|
||||
enum wl_shm_format wl_shm_format = convert_drm_format_to_wl_shm(shm->format);
|
||||
enum wl_shm_format wl_shm_format =
|
||||
wlr_convert_drm_format_to_wl_shm(shm->format);
|
||||
uint32_t size = shm->stride * shm->height;
|
||||
struct wl_shm_pool *pool = wl_shm_create_pool(wl->shm, shm->fd, size);
|
||||
if (pool == NULL) {
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
#ifndef RENDER_PIXEL_FORMAT_H
|
||||
#define RENDER_PIXEL_FORMAT_H
|
||||
|
||||
#include <wayland-server-protocol.h>
|
||||
|
||||
struct wlr_pixel_format_info {
|
||||
uint32_t drm_format;
|
||||
|
||||
/* Equivalent of the format if it has an alpha channel,
|
||||
* DRM_FORMAT_INVALID (0) if NA
|
||||
*/
|
||||
uint32_t opaque_substitute;
|
||||
|
||||
/* Bits per pixels */
|
||||
uint32_t bpp;
|
||||
|
||||
/* True if the format has an alpha channel */
|
||||
bool has_alpha;
|
||||
};
|
||||
|
||||
const struct wlr_pixel_format_info *drm_get_pixel_format_info(uint32_t fmt);
|
||||
|
||||
uint32_t convert_wl_shm_format_to_drm(enum wl_shm_format fmt);
|
||||
enum wl_shm_format convert_drm_format_to_wl_shm(uint32_t fmt);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef RENDER_PIXMAN_H
|
||||
#define RENDER_PIXMAN_H
|
||||
|
||||
#include <wlr/render/drm_format_set.h>
|
||||
#include <wlr/render/pixel_format.h>
|
||||
#include <wlr/render/pixman.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/render/drm_format_set.h>
|
||||
#include "render/pixel_format.h"
|
||||
|
||||
struct wlr_pixman_pixel_format {
|
||||
uint32_t drm_format;
|
||||
|
|
|
|||
31
include/wlr/render/pixel_format.h
Normal file
31
include/wlr/render/pixel_format.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef WLR_RENDER_PIXEL_FORMAT_H
|
||||
#define WLR_RENDER_PIXEL_FORMAT_H
|
||||
|
||||
#include <wayland-server-protocol.h>
|
||||
|
||||
struct wlr_pixel_format_info {
|
||||
uint32_t drm_format;
|
||||
|
||||
/* Equivalent of the format if it has an alpha channel,
|
||||
* DRM_FORMAT_INVALID (0) if NA
|
||||
*/
|
||||
uint32_t opaque_substitute;
|
||||
|
||||
/* Bits per pixels */
|
||||
uint32_t bpp;
|
||||
|
||||
/* True if the format has an alpha channel */
|
||||
bool has_alpha;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the pixel format info from a provided fourcc format.
|
||||
* Returns NULL if not found
|
||||
*/
|
||||
const struct wlr_pixel_format_info *wlr_pixel_format_info_from_drm(
|
||||
uint32_t fmt);
|
||||
|
||||
uint32_t wlr_convert_wl_shm_format_to_drm(enum wl_shm_format fmt);
|
||||
enum wl_shm_format wlr_convert_drm_format_to_wl_shm(uint32_t fmt);
|
||||
|
||||
#endif
|
||||
|
|
@ -12,9 +12,9 @@
|
|||
#include <xf86drmMode.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/backend/session.h>
|
||||
#include <wlr/render/pixel_format.h>
|
||||
|
||||
#include "render/allocator/drm_dumb.h"
|
||||
#include "render/pixel_format.h"
|
||||
|
||||
static const struct wlr_buffer_impl buffer_impl;
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ static struct wlr_drm_dumb_buffer *create_buffer(
|
|||
wl_list_insert(&alloc->buffers, &buffer->link);
|
||||
|
||||
const struct wlr_pixel_format_info *info =
|
||||
drm_get_pixel_format_info(format->format);
|
||||
wlr_pixel_format_info_from_drm(format->format);
|
||||
if (info == NULL) {
|
||||
wlr_log(WLR_ERROR, "DRM format 0x%"PRIX32" not supported",
|
||||
format->format);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
#include <stdlib.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <wlr/render/pixel_format.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "render/pixel_format.h"
|
||||
#include "render/allocator/shm.h"
|
||||
#include "util/shm.h"
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ static struct wlr_buffer *allocator_create_buffer(
|
|||
struct wlr_allocator *wlr_allocator, int width, int height,
|
||||
const struct wlr_drm_format *format) {
|
||||
const struct wlr_pixel_format_info *info =
|
||||
drm_get_pixel_format_info(format->format);
|
||||
wlr_pixel_format_info_from_drm(format->format);
|
||||
if (info == NULL) {
|
||||
wlr_log(WLR_ERROR, "Unsupported pixel format 0x%"PRIX32, format->format);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@
|
|||
#include <wayland-util.h>
|
||||
#include <wlr/render/egl.h>
|
||||
#include <wlr/render/interface.h>
|
||||
#include <wlr/render/pixel_format.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/util/box.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "render/egl.h"
|
||||
#include "render/gles2.h"
|
||||
#include "render/pixel_format.h"
|
||||
|
||||
static const GLfloat verts[] = {
|
||||
1, 0, // top right
|
||||
|
|
@ -443,7 +443,7 @@ static bool gles2_read_pixels(struct wlr_renderer *wlr_renderer,
|
|||
}
|
||||
|
||||
const struct wlr_pixel_format_info *drm_fmt =
|
||||
drm_get_pixel_format_info(fmt->drm_format);
|
||||
wlr_pixel_format_info_from_drm(fmt->drm_format);
|
||||
assert(drm_fmt);
|
||||
|
||||
push_gles2_debug(renderer);
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@
|
|||
#include <wayland-util.h>
|
||||
#include <wlr/render/egl.h>
|
||||
#include <wlr/render/interface.h>
|
||||
#include <wlr/render/pixel_format.h>
|
||||
#include <wlr/render/wlr_texture.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "render/egl.h"
|
||||
#include "render/gles2.h"
|
||||
#include "render/pixel_format.h"
|
||||
#include "types/wlr_buffer.h"
|
||||
#include "util/signal.h"
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture,
|
|||
assert(fmt);
|
||||
|
||||
const struct wlr_pixel_format_info *drm_fmt =
|
||||
drm_get_pixel_format_info(texture->drm_format);
|
||||
wlr_pixel_format_info_from_drm(texture->drm_format);
|
||||
assert(drm_fmt);
|
||||
|
||||
if (!check_stride(drm_fmt, stride, width)) {
|
||||
|
|
@ -194,7 +194,7 @@ static struct wlr_texture *gles2_texture_from_pixels(
|
|||
}
|
||||
|
||||
const struct wlr_pixel_format_info *drm_fmt =
|
||||
drm_get_pixel_format_info(drm_format);
|
||||
wlr_pixel_format_info_from_drm(drm_format);
|
||||
assert(drm_fmt);
|
||||
|
||||
if (!check_stride(drm_fmt, stride, width)) {
|
||||
|
|
@ -254,7 +254,7 @@ static struct wlr_texture *gles2_texture_from_dmabuf(
|
|||
(attribs->flags & WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT) != 0;
|
||||
|
||||
const struct wlr_pixel_format_info *drm_fmt =
|
||||
drm_get_pixel_format_info(attribs->format);
|
||||
wlr_pixel_format_info_from_drm(attribs->format);
|
||||
if (drm_fmt != NULL) {
|
||||
texture->has_alpha = drm_fmt->has_alpha;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <drm_fourcc.h>
|
||||
#include "render/pixel_format.h"
|
||||
#include <wlr/render/pixel_format.h>
|
||||
|
||||
static const struct wlr_pixel_format_info pixel_format_info[] = {
|
||||
{
|
||||
|
|
@ -133,7 +133,8 @@ static const struct wlr_pixel_format_info pixel_format_info[] = {
|
|||
static const size_t pixel_format_info_size =
|
||||
sizeof(pixel_format_info) / sizeof(pixel_format_info[0]);
|
||||
|
||||
const struct wlr_pixel_format_info *drm_get_pixel_format_info(uint32_t fmt) {
|
||||
const struct wlr_pixel_format_info *wlr_pixel_format_info_from_drm(
|
||||
uint32_t fmt) {
|
||||
for (size_t i = 0; i < pixel_format_info_size; ++i) {
|
||||
if (pixel_format_info[i].drm_format == fmt) {
|
||||
return &pixel_format_info[i];
|
||||
|
|
@ -143,7 +144,7 @@ const struct wlr_pixel_format_info *drm_get_pixel_format_info(uint32_t fmt) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
uint32_t convert_wl_shm_format_to_drm(enum wl_shm_format fmt) {
|
||||
uint32_t wlr_convert_wl_shm_format_to_drm(enum wl_shm_format fmt) {
|
||||
switch (fmt) {
|
||||
case WL_SHM_FORMAT_XRGB8888:
|
||||
return DRM_FORMAT_XRGB8888;
|
||||
|
|
@ -154,7 +155,7 @@ uint32_t convert_wl_shm_format_to_drm(enum wl_shm_format fmt) {
|
|||
}
|
||||
}
|
||||
|
||||
enum wl_shm_format convert_drm_format_to_wl_shm(uint32_t fmt) {
|
||||
enum wl_shm_format wlr_convert_drm_format_to_wl_shm(uint32_t fmt) {
|
||||
switch (fmt) {
|
||||
case DRM_FORMAT_XRGB8888:
|
||||
return WL_SHM_FORMAT_XRGB8888;
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ static struct wlr_pixman_texture *pixman_texture_create(
|
|||
wlr_texture_init(&texture->wlr_texture, &texture_impl, width, height);
|
||||
texture->renderer = renderer;
|
||||
|
||||
texture->format_info = drm_get_pixel_format_info(drm_format);
|
||||
texture->format_info = wlr_pixel_format_info_from_drm(drm_format);
|
||||
if (!texture->format_info) {
|
||||
wlr_log(WLR_ERROR, "Unsupported drm format 0x%"PRIX32, drm_format);
|
||||
free(texture);
|
||||
|
|
@ -476,7 +476,7 @@ static bool pixman_read_pixels(struct wlr_renderer *wlr_renderer,
|
|||
}
|
||||
|
||||
const struct wlr_pixel_format_info *drm_fmt =
|
||||
drm_get_pixel_format_info(drm_format);
|
||||
wlr_pixel_format_info_from_drm(drm_format);
|
||||
assert(drm_fmt);
|
||||
|
||||
pixman_image_t *dst = pixman_image_create_bits_no_clear(fmt, width, height,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <wlr/render/interface.h>
|
||||
#include <wlr/render/pixel_format.h>
|
||||
#include <wlr/render/pixman.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_drm.h>
|
||||
|
|
@ -18,7 +19,6 @@
|
|||
#endif
|
||||
|
||||
#include "util/signal.h"
|
||||
#include "render/pixel_format.h"
|
||||
#include "render/wlr_renderer.h"
|
||||
|
||||
void wlr_renderer_init(struct wlr_renderer *renderer,
|
||||
|
|
@ -211,7 +211,7 @@ bool wlr_renderer_init_wl_display(struct wlr_renderer *r,
|
|||
for (size_t i = 0; i < len; ++i) {
|
||||
// ARGB8888 and XRGB8888 must be supported and are implicitly
|
||||
// advertised by wl_display_init_shm
|
||||
enum wl_shm_format fmt = convert_drm_format_to_wl_shm(formats[i]);
|
||||
enum wl_shm_format fmt = wlr_convert_drm_format_to_wl_shm(formats[i]);
|
||||
switch (fmt) {
|
||||
case WL_SHM_FORMAT_ARGB8888:
|
||||
argb8888 = true;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
#include <assert.h>
|
||||
#include <drm_fourcc.h>
|
||||
#include <stdlib.h>
|
||||
#include <wlr/render/pixel_format.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_buffer.h>
|
||||
#include <wlr/types/wlr_drm.h>
|
||||
#include <wlr/types/wlr_linux_dmabuf_v1.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "render/pixel_format.h"
|
||||
#include "types/wlr_buffer.h"
|
||||
#include "util/signal.h"
|
||||
|
||||
|
|
@ -427,7 +427,7 @@ static struct wlr_shm_client_buffer *shm_client_buffer_get_or_create(
|
|||
buffer->shm_buffer = shm_buffer;
|
||||
|
||||
enum wl_shm_format wl_shm_format = wl_shm_buffer_get_format(shm_buffer);
|
||||
buffer->format = convert_wl_shm_format_to_drm(wl_shm_format);
|
||||
buffer->format = wlr_convert_wl_shm_format_to_drm(wl_shm_format);
|
||||
buffer->stride = wl_shm_buffer_get_stride(shm_buffer);
|
||||
|
||||
buffer->resource_destroy.notify = shm_client_buffer_resource_handle_destroy;
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@
|
|||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_linux_dmabuf_v1.h>
|
||||
#include <wlr/types/wlr_screencopy_v1.h>
|
||||
#include <wlr/render/pixel_format.h>
|
||||
#include <wlr/backend.h>
|
||||
#include <wlr/util/box.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "wlr-screencopy-unstable-v1-protocol.h"
|
||||
#include "render/pixel_format.h"
|
||||
#include "util/signal.h"
|
||||
|
||||
#define SCREENCOPY_MANAGER_VERSION 3
|
||||
|
|
@ -199,7 +199,7 @@ static bool frame_shm_copy(struct wlr_screencopy_frame_v1 *frame,
|
|||
int y = frame->box.y;
|
||||
|
||||
enum wl_shm_format wl_shm_format = wl_shm_buffer_get_format(shm_buffer);
|
||||
uint32_t drm_format = convert_wl_shm_format_to_drm(wl_shm_format);
|
||||
uint32_t drm_format = wlr_convert_wl_shm_format_to_drm(wl_shm_format);
|
||||
int32_t width = wl_shm_buffer_get_width(shm_buffer);
|
||||
int32_t height = wl_shm_buffer_get_height(shm_buffer);
|
||||
int32_t stride = wl_shm_buffer_get_stride(shm_buffer);
|
||||
|
|
@ -555,7 +555,7 @@ static void capture_output(struct wl_client *wl_client,
|
|||
goto error;
|
||||
}
|
||||
|
||||
frame->format = convert_drm_format_to_wl_shm(drm_format);
|
||||
frame->format = wlr_convert_drm_format_to_wl_shm(drm_format);
|
||||
frame->fourcc = get_output_fourcc(output);
|
||||
|
||||
struct wlr_box buffer_box = {0};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue