mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-10 13:29:44 -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
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue