mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2025-12-20 12:50:11 +01:00
pixman-renderer: use pixel_format_info instead of pixman_format_code_t
Use struct pixel_format_info pointers instead of pixman_format_code_t values at the API surface for output and image creation. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This commit is contained in:
parent
889c2e3f0d
commit
c67773bc5c
8 changed files with 39 additions and 32 deletions
|
|
@ -1180,19 +1180,16 @@ drm_output_init_pixman(struct drm_output *output, struct drm_backend *b)
|
||||||
int w = output->base.current_mode->width;
|
int w = output->base.current_mode->width;
|
||||||
int h = output->base.current_mode->height;
|
int h = output->base.current_mode->height;
|
||||||
uint32_t format = output->gbm_format;
|
uint32_t format = output->gbm_format;
|
||||||
uint32_t pixman_format;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
const struct pixman_renderer_output_options options = {
|
const struct pixman_renderer_output_options options = {
|
||||||
.use_shadow = b->use_pixman_shadow,
|
.use_shadow = b->use_pixman_shadow,
|
||||||
.fb_size = { .width = w, .height = h },
|
.fb_size = { .width = w, .height = h },
|
||||||
|
.format = pixel_format_get_info(format)
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case DRM_FORMAT_XRGB8888:
|
case DRM_FORMAT_XRGB8888:
|
||||||
pixman_format = PIXMAN_x8r8g8b8;
|
|
||||||
break;
|
|
||||||
case DRM_FORMAT_RGB565:
|
case DRM_FORMAT_RGB565:
|
||||||
pixman_format = PIXMAN_r5g6b5;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
weston_log("Unsupported pixman format 0x%x\n", format);
|
weston_log("Unsupported pixman format 0x%x\n", format);
|
||||||
|
|
@ -1210,7 +1207,7 @@ drm_output_init_pixman(struct drm_output *output, struct drm_backend *b)
|
||||||
|
|
||||||
output->renderbuffer[i] =
|
output->renderbuffer[i] =
|
||||||
pixman->create_image_from_ptr(&output->base,
|
pixman->create_image_from_ptr(&output->base,
|
||||||
pixman_format, w, h,
|
options.format, w, h,
|
||||||
output->dumb[i]->map,
|
output->dumb[i]->map,
|
||||||
output->dumb[i]->strides[0]);
|
output->dumb[i]->strides[0]);
|
||||||
if (!output->renderbuffer[i])
|
if (!output->renderbuffer[i])
|
||||||
|
|
|
||||||
|
|
@ -295,24 +295,22 @@ static int
|
||||||
headless_output_enable_pixman(struct headless_output *output)
|
headless_output_enable_pixman(struct headless_output *output)
|
||||||
{
|
{
|
||||||
const struct pixman_renderer_interface *pixman;
|
const struct pixman_renderer_interface *pixman;
|
||||||
const struct pixel_format_info *pfmt;
|
|
||||||
const struct pixman_renderer_output_options options = {
|
const struct pixman_renderer_output_options options = {
|
||||||
.use_shadow = true,
|
.use_shadow = true,
|
||||||
.fb_size = {
|
.fb_size = {
|
||||||
.width = output->base.current_mode->width,
|
.width = output->base.current_mode->width,
|
||||||
.height = output->base.current_mode->height
|
.height = output->base.current_mode->height
|
||||||
},
|
},
|
||||||
.drm_format = headless_formats[0]
|
.format = pixel_format_get_info(headless_formats[0])
|
||||||
};
|
};
|
||||||
|
|
||||||
pixman = output->base.compositor->renderer->pixman;
|
pixman = output->base.compositor->renderer->pixman;
|
||||||
pfmt = pixel_format_get_info(headless_formats[0]);
|
|
||||||
|
|
||||||
if (pixman->output_create(&output->base, &options) < 0)
|
if (pixman->output_create(&output->base, &options) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
output->renderbuffer =
|
output->renderbuffer =
|
||||||
pixman->create_image(&output->base, pfmt->pixman_format,
|
pixman->create_image(&output->base, options.format,
|
||||||
output->base.current_mode->width,
|
output->base.current_mode->width,
|
||||||
output->base.current_mode->height);
|
output->base.current_mode->height);
|
||||||
if (!output->renderbuffer)
|
if (!output->renderbuffer)
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@
|
||||||
#include "shared/xalloc.h"
|
#include "shared/xalloc.h"
|
||||||
#include <libweston/libweston.h>
|
#include <libweston/libweston.h>
|
||||||
#include <libweston/backend-rdp.h>
|
#include <libweston/backend-rdp.h>
|
||||||
|
#include <libweston/pixel-formats.h>
|
||||||
#include "pixman-renderer.h"
|
#include "pixman-renderer.h"
|
||||||
|
|
||||||
/* These can be removed when we bump FreeRDP dependency past 3.0.0 in the future */
|
/* These can be removed when we bump FreeRDP dependency past 3.0.0 in the future */
|
||||||
|
|
@ -405,6 +406,7 @@ rdp_output_set_mode(struct weston_output *base, struct weston_mode *mode)
|
||||||
base->native_mode = cur;
|
base->native_mode = cur;
|
||||||
if (base->enabled) {
|
if (base->enabled) {
|
||||||
const struct pixman_renderer_interface *pixman;
|
const struct pixman_renderer_interface *pixman;
|
||||||
|
const struct pixel_format_info *pfmt;
|
||||||
pixman_image_t *old_image, *new_image;
|
pixman_image_t *old_image, *new_image;
|
||||||
|
|
||||||
weston_renderer_resize_output(output, &(struct weston_size){
|
weston_renderer_resize_output(output, &(struct weston_size){
|
||||||
|
|
@ -415,8 +417,9 @@ rdp_output_set_mode(struct weston_output *base, struct weston_mode *mode)
|
||||||
|
|
||||||
old_image =
|
old_image =
|
||||||
pixman->renderbuffer_get_image(rdpOutput->renderbuffer);
|
pixman->renderbuffer_get_image(rdpOutput->renderbuffer);
|
||||||
|
pfmt = pixel_format_get_info_by_pixman(PIXMAN_x8r8g8b8);
|
||||||
new_renderbuffer =
|
new_renderbuffer =
|
||||||
pixman->create_image_from_ptr(output, PIXMAN_x8r8g8b8,
|
pixman->create_image_from_ptr(output, pfmt,
|
||||||
mode->width, mode->height,
|
mode->width, mode->height,
|
||||||
0, mode->width * 4);
|
0, mode->width * 4);
|
||||||
new_image = pixman->renderbuffer_get_image(new_renderbuffer);
|
new_image = pixman->renderbuffer_get_image(new_renderbuffer);
|
||||||
|
|
@ -483,6 +486,7 @@ rdp_output_enable(struct weston_output *base)
|
||||||
.width = output->base.current_mode->width,
|
.width = output->base.current_mode->width,
|
||||||
.height = output->base.current_mode->height
|
.height = output->base.current_mode->height
|
||||||
},
|
},
|
||||||
|
.format = pixel_format_get_info_by_pixman(PIXMAN_x8r8g8b8)
|
||||||
};
|
};
|
||||||
|
|
||||||
assert(output);
|
assert(output);
|
||||||
|
|
@ -494,7 +498,7 @@ rdp_output_enable(struct weston_output *base)
|
||||||
}
|
}
|
||||||
|
|
||||||
output->renderbuffer =
|
output->renderbuffer =
|
||||||
pixman->create_image_from_ptr(&output->base, PIXMAN_x8r8g8b8,
|
pixman->create_image_from_ptr(&output->base, options.format,
|
||||||
output->base.current_mode->width,
|
output->base.current_mode->width,
|
||||||
output->base.current_mode->height,
|
output->base.current_mode->height,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
||||||
|
|
@ -512,8 +512,7 @@ vnc_update_buffer(struct nvnc_display *display, struct pixman_region32 *damage)
|
||||||
pfmt = pixel_format_get_info(DRM_FORMAT_XRGB8888);
|
pfmt = pixel_format_get_info(DRM_FORMAT_XRGB8888);
|
||||||
fb_side_data->renderer = ec->renderer;
|
fb_side_data->renderer = ec->renderer;
|
||||||
fb_side_data->renderbuffer =
|
fb_side_data->renderbuffer =
|
||||||
pixman->create_image_from_ptr(&output->base,
|
pixman->create_image_from_ptr(&output->base, pfmt,
|
||||||
pfmt->pixman_format,
|
|
||||||
output->base.width,
|
output->base.width,
|
||||||
output->base.height,
|
output->base.height,
|
||||||
nvnc_fb_get_addr(fb),
|
nvnc_fb_get_addr(fb),
|
||||||
|
|
@ -614,6 +613,7 @@ vnc_output_enable(struct weston_output *base)
|
||||||
.width = output->base.width,
|
.width = output->base.width,
|
||||||
.height = output->base.height,
|
.height = output->base.height,
|
||||||
},
|
},
|
||||||
|
.format = pixel_format_get_info(DRM_FORMAT_XRGB8888),
|
||||||
};
|
};
|
||||||
|
|
||||||
assert(output);
|
assert(output);
|
||||||
|
|
@ -631,7 +631,7 @@ vnc_output_enable(struct weston_output *base)
|
||||||
|
|
||||||
output->fb_pool = nvnc_fb_pool_new(output->base.width,
|
output->fb_pool = nvnc_fb_pool_new(output->base.width,
|
||||||
output->base.height,
|
output->base.height,
|
||||||
DRM_FORMAT_XRGB8888,
|
options.format->format,
|
||||||
output->base.width);
|
output->base.width);
|
||||||
|
|
||||||
output->display = nvnc_display_new(0, 0);
|
output->display = nvnc_display_new(0, 0);
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@
|
||||||
#include "xdg-shell-client-protocol.h"
|
#include "xdg-shell-client-protocol.h"
|
||||||
#include "presentation-time-server-protocol.h"
|
#include "presentation-time-server-protocol.h"
|
||||||
#include "linux-dmabuf.h"
|
#include "linux-dmabuf.h"
|
||||||
|
#include <libweston/pixel-formats.h>
|
||||||
#include <libweston/windowed-output-api.h>
|
#include <libweston/windowed-output-api.h>
|
||||||
|
|
||||||
#define WINDOW_TITLE "Weston Compositor"
|
#define WINDOW_TITLE "Weston Compositor"
|
||||||
|
|
@ -388,8 +389,11 @@ wayland_output_get_shm_buffer(struct wayland_output *output)
|
||||||
|
|
||||||
/* Address only the interior, excluding output decorations */
|
/* Address only the interior, excluding output decorations */
|
||||||
if (renderer->type == WESTON_RENDERER_PIXMAN) {
|
if (renderer->type == WESTON_RENDERER_PIXMAN) {
|
||||||
|
const struct pixel_format_info *pfmt;
|
||||||
|
|
||||||
|
pfmt = pixel_format_get_info_by_pixman(PIXMAN_a8r8g8b8);
|
||||||
sb->renderbuffer =
|
sb->renderbuffer =
|
||||||
pixman->create_image_from_ptr(&output->base, PIXMAN_a8r8g8b8,
|
pixman->create_image_from_ptr(&output->base, pfmt,
|
||||||
area.width, area.height,
|
area.width, area.height,
|
||||||
(uint32_t *)(data + area.y * stride) + area.x,
|
(uint32_t *)(data + area.y * stride) + area.x,
|
||||||
stride);
|
stride);
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@
|
||||||
#include "presentation-time-server-protocol.h"
|
#include "presentation-time-server-protocol.h"
|
||||||
#include "linux-dmabuf.h"
|
#include "linux-dmabuf.h"
|
||||||
#include "linux-explicit-synchronization.h"
|
#include "linux-explicit-synchronization.h"
|
||||||
|
#include <libweston/pixel-formats.h>
|
||||||
#include <libweston/windowed-output-api.h>
|
#include <libweston/windowed-output-api.h>
|
||||||
|
|
||||||
#define DEFAULT_AXIS_STEP_DISTANCE 10
|
#define DEFAULT_AXIS_STEP_DISTANCE 10
|
||||||
|
|
@ -731,7 +732,7 @@ x11_output_init_shm(struct x11_backend *b, struct x11_output *output,
|
||||||
xcb_generic_error_t *err;
|
xcb_generic_error_t *err;
|
||||||
const xcb_query_extension_reply_t *ext;
|
const xcb_query_extension_reply_t *ext;
|
||||||
int bitsperpixel = 0;
|
int bitsperpixel = 0;
|
||||||
pixman_format_code_t pixman_format;
|
const struct pixel_format_info *pfmt;
|
||||||
|
|
||||||
/* Check if SHM is available */
|
/* Check if SHM is available */
|
||||||
ext = xcb_get_extension_data(b->conn, &xcb_shm_id);
|
ext = xcb_get_extension_data(b->conn, &xcb_shm_id);
|
||||||
|
|
@ -773,13 +774,13 @@ x11_output_init_shm(struct x11_backend *b, struct x11_output *output,
|
||||||
visual_type->green_mask == 0x00ff00 &&
|
visual_type->green_mask == 0x00ff00 &&
|
||||||
visual_type->blue_mask == 0x0000ff) {
|
visual_type->blue_mask == 0x0000ff) {
|
||||||
weston_log("Will use x8r8g8b8 format for SHM surfaces\n");
|
weston_log("Will use x8r8g8b8 format for SHM surfaces\n");
|
||||||
pixman_format = PIXMAN_x8r8g8b8;
|
pfmt = pixel_format_get_info_by_pixman(PIXMAN_x8r8g8b8);
|
||||||
} else if (bitsperpixel == 16 &&
|
} else if (bitsperpixel == 16 &&
|
||||||
visual_type->red_mask == 0x00f800 &&
|
visual_type->red_mask == 0x00f800 &&
|
||||||
visual_type->green_mask == 0x0007e0 &&
|
visual_type->green_mask == 0x0007e0 &&
|
||||||
visual_type->blue_mask == 0x00001f) {
|
visual_type->blue_mask == 0x00001f) {
|
||||||
weston_log("Will use r5g6b5 format for SHM surfaces\n");
|
weston_log("Will use r5g6b5 format for SHM surfaces\n");
|
||||||
pixman_format = PIXMAN_r5g6b5;
|
pfmt = pixel_format_get_info_by_pixman(PIXMAN_r5g6b5);
|
||||||
} else {
|
} else {
|
||||||
weston_log("Can't find appropriate format for SHM pixmap\n");
|
weston_log("Can't find appropriate format for SHM pixmap\n");
|
||||||
errno = ENOTSUP;
|
errno = ENOTSUP;
|
||||||
|
|
@ -813,8 +814,8 @@ x11_output_init_shm(struct x11_backend *b, struct x11_output *output,
|
||||||
/* Now create pixman image */
|
/* Now create pixman image */
|
||||||
output->renderbuffer =
|
output->renderbuffer =
|
||||||
renderer->pixman->create_image_from_ptr(&output->base,
|
renderer->pixman->create_image_from_ptr(&output->base,
|
||||||
pixman_format, width,
|
pfmt, width, height,
|
||||||
height, output->buf,
|
output->buf,
|
||||||
width * (bitsperpixel / 8));
|
width * (bitsperpixel / 8));
|
||||||
|
|
||||||
output->gc = xcb_generate_id(b->conn);
|
output->gc = xcb_generate_id(b->conn);
|
||||||
|
|
|
||||||
|
|
@ -1109,7 +1109,7 @@ pixman_renderer_output_create(struct weston_output *output,
|
||||||
weston_output_update_capture_info(output,
|
weston_output_update_capture_info(output,
|
||||||
WESTON_OUTPUT_CAPTURE_SOURCE_FRAMEBUFFER,
|
WESTON_OUTPUT_CAPTURE_SOURCE_FRAMEBUFFER,
|
||||||
area.width, area.height,
|
area.width, area.height,
|
||||||
options->drm_format);
|
options->format->format);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1138,8 +1138,9 @@ pixman_renderer_renderbuffer_destroy(struct weston_renderbuffer *renderbuffer);
|
||||||
|
|
||||||
static struct weston_renderbuffer *
|
static struct weston_renderbuffer *
|
||||||
pixman_renderer_create_image_from_ptr(struct weston_output *output,
|
pixman_renderer_create_image_from_ptr(struct weston_output *output,
|
||||||
pixman_format_code_t format, int width,
|
const struct pixel_format_info *format,
|
||||||
int height, uint32_t *ptr, int rowstride)
|
int width, int height, uint32_t *ptr,
|
||||||
|
int rowstride)
|
||||||
{
|
{
|
||||||
struct pixman_output_state *po = get_output_state(output);
|
struct pixman_output_state *po = get_output_state(output);
|
||||||
struct pixman_renderbuffer *renderbuffer;
|
struct pixman_renderbuffer *renderbuffer;
|
||||||
|
|
@ -1148,8 +1149,9 @@ pixman_renderer_create_image_from_ptr(struct weston_output *output,
|
||||||
|
|
||||||
renderbuffer = xzalloc(sizeof(*renderbuffer));
|
renderbuffer = xzalloc(sizeof(*renderbuffer));
|
||||||
|
|
||||||
renderbuffer->image = pixman_image_create_bits(format, width, height,
|
renderbuffer->image = pixman_image_create_bits(format->pixman_format,
|
||||||
ptr, rowstride);
|
width, height, ptr,
|
||||||
|
rowstride);
|
||||||
if (!renderbuffer->image) {
|
if (!renderbuffer->image) {
|
||||||
free(renderbuffer);
|
free(renderbuffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -1165,7 +1167,8 @@ pixman_renderer_create_image_from_ptr(struct weston_output *output,
|
||||||
|
|
||||||
static struct weston_renderbuffer *
|
static struct weston_renderbuffer *
|
||||||
pixman_renderer_create_image(struct weston_output *output,
|
pixman_renderer_create_image(struct weston_output *output,
|
||||||
pixman_format_code_t format, int width, int height)
|
const struct pixel_format_info *format, int width,
|
||||||
|
int height)
|
||||||
{
|
{
|
||||||
struct pixman_output_state *po = get_output_state(output);
|
struct pixman_output_state *po = get_output_state(output);
|
||||||
struct pixman_renderbuffer *renderbuffer;
|
struct pixman_renderbuffer *renderbuffer;
|
||||||
|
|
@ -1175,8 +1178,8 @@ pixman_renderer_create_image(struct weston_output *output,
|
||||||
renderbuffer = xzalloc(sizeof(*renderbuffer));
|
renderbuffer = xzalloc(sizeof(*renderbuffer));
|
||||||
|
|
||||||
renderbuffer->image =
|
renderbuffer->image =
|
||||||
pixman_image_create_bits_no_clear(format, width, height,
|
pixman_image_create_bits_no_clear(format->pixman_format, width,
|
||||||
NULL, 0);
|
height, NULL, 0);
|
||||||
if (!renderbuffer->image) {
|
if (!renderbuffer->image) {
|
||||||
free(renderbuffer);
|
free(renderbuffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ struct pixman_renderer_output_options {
|
||||||
bool use_shadow;
|
bool use_shadow;
|
||||||
/** Initial framebuffer size */
|
/** Initial framebuffer size */
|
||||||
struct weston_size fb_size;
|
struct weston_size fb_size;
|
||||||
/** Initial DRM pixel format */
|
/** Initial pixel format */
|
||||||
uint32_t drm_format;
|
const struct pixel_format_info *format;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pixman_renderer_interface {
|
struct pixman_renderer_interface {
|
||||||
|
|
@ -48,13 +48,13 @@ struct pixman_renderer_interface {
|
||||||
void (*output_destroy)(struct weston_output *output);
|
void (*output_destroy)(struct weston_output *output);
|
||||||
|
|
||||||
struct weston_renderbuffer *(*create_image_from_ptr)(struct weston_output *output,
|
struct weston_renderbuffer *(*create_image_from_ptr)(struct weston_output *output,
|
||||||
pixman_format_code_t format,
|
const struct pixel_format_info *format,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
uint32_t *ptr,
|
uint32_t *ptr,
|
||||||
int stride);
|
int stride);
|
||||||
struct weston_renderbuffer *(*create_image)(struct weston_output *output,
|
struct weston_renderbuffer *(*create_image)(struct weston_output *output,
|
||||||
pixman_format_code_t format,
|
const struct pixel_format_info *format,
|
||||||
int width, int height);
|
int width, int height);
|
||||||
pixman_image_t *(*renderbuffer_get_image)(struct weston_renderbuffer *renderbuffer);
|
pixman_image_t *(*renderbuffer_get_image)(struct weston_renderbuffer *renderbuffer);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue