gl-renderer: Replace pbuffer-create args with struct
gl_rendererer's output_pbuffer_create has a lot of arguments now. Add a structure for the options to make it more clear what is what. This is in preparation for adding bare-integer arguments which are ripe for confusion when passing positional arguments. Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
committed by
Pekka Paalanen
parent
db6e6e1ec5
commit
786490cb53
@@ -196,12 +196,14 @@ headless_output_enable_gl(struct headless_output *output)
|
|||||||
{
|
{
|
||||||
struct weston_compositor *compositor = output->base.compositor;
|
struct weston_compositor *compositor = output->base.compositor;
|
||||||
struct headless_backend *b = to_headless_backend(compositor);
|
struct headless_backend *b = to_headless_backend(compositor);
|
||||||
|
const struct gl_renderer_pbuffer_options options = {
|
||||||
|
.width = output->base.current_mode->width,
|
||||||
|
.height = output->base.current_mode->height,
|
||||||
|
.drm_formats = headless_formats,
|
||||||
|
.drm_formats_count = ARRAY_LENGTH(headless_formats),
|
||||||
|
};
|
||||||
|
|
||||||
if (b->glri->output_pbuffer_create(&output->base,
|
if (b->glri->output_pbuffer_create(&output->base, &options) < 0) {
|
||||||
output->base.current_mode->width,
|
|
||||||
output->base.current_mode->height,
|
|
||||||
headless_formats,
|
|
||||||
ARRAY_LENGTH(headless_formats)) < 0) {
|
|
||||||
weston_log("failed to create gl renderer output state\n");
|
weston_log("failed to create gl renderer output state\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3198,24 +3198,21 @@ gl_renderer_output_window_create(struct weston_output *output,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
gl_renderer_output_pbuffer_create(struct weston_output *output,
|
gl_renderer_output_pbuffer_create(struct weston_output *output,
|
||||||
int width,
|
const struct gl_renderer_pbuffer_options *options)
|
||||||
int height,
|
|
||||||
const uint32_t *drm_formats,
|
|
||||||
unsigned drm_formats_count)
|
|
||||||
{
|
{
|
||||||
struct gl_renderer *gr = get_renderer(output->compositor);
|
struct gl_renderer *gr = get_renderer(output->compositor);
|
||||||
EGLConfig pbuffer_config;
|
EGLConfig pbuffer_config;
|
||||||
EGLSurface egl_surface;
|
EGLSurface egl_surface;
|
||||||
int ret;
|
int ret;
|
||||||
EGLint pbuffer_attribs[] = {
|
EGLint pbuffer_attribs[] = {
|
||||||
EGL_WIDTH, width,
|
EGL_WIDTH, options->width,
|
||||||
EGL_HEIGHT, height,
|
EGL_HEIGHT, options->height,
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
pbuffer_config = gl_renderer_get_egl_config(gr, EGL_PBUFFER_BIT,
|
pbuffer_config = gl_renderer_get_egl_config(gr, EGL_PBUFFER_BIT,
|
||||||
drm_formats,
|
options->drm_formats,
|
||||||
drm_formats_count);
|
options->drm_formats_count);
|
||||||
if (pbuffer_config == EGL_NO_CONFIG_KHR) {
|
if (pbuffer_config == EGL_NO_CONFIG_KHR) {
|
||||||
weston_log("failed to choose EGL config for PbufferSurface\n");
|
weston_log("failed to choose EGL config for PbufferSurface\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -87,6 +87,17 @@ struct gl_renderer_output_options {
|
|||||||
unsigned drm_formats_count;
|
unsigned drm_formats_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct gl_renderer_pbuffer_options {
|
||||||
|
/** Width of the rendering surface in pixels */
|
||||||
|
int width;
|
||||||
|
/** Height of the rendering surface in pixels */
|
||||||
|
int height;
|
||||||
|
/** Array of DRM pixel formats acceptable for the pbuffer */
|
||||||
|
const uint32_t *drm_formats;
|
||||||
|
/** The \c drm_formats array length */
|
||||||
|
unsigned drm_formats_count;
|
||||||
|
};
|
||||||
|
|
||||||
struct gl_renderer_interface {
|
struct gl_renderer_interface {
|
||||||
/**
|
/**
|
||||||
* Initialize GL-renderer with the given EGL platform and native display
|
* Initialize GL-renderer with the given EGL platform and native display
|
||||||
@@ -150,10 +161,7 @@ struct gl_renderer_interface {
|
|||||||
* Attach GL-renderer to the output with internal pixel storage
|
* Attach GL-renderer to the output with internal pixel storage
|
||||||
*
|
*
|
||||||
* \param output The output to create a rendering surface for.
|
* \param output The output to create a rendering surface for.
|
||||||
* \param width Width of the rendering surface in pixels.
|
* \param options The options struct describing the pbuffer
|
||||||
* \param height Height of the rendering surface in pixels.
|
|
||||||
* \param drm_formats Array of DRM pixel formats that are acceptable.
|
|
||||||
* \param drm_formats_count The drm_formats array length.
|
|
||||||
* \return 0 on success, -1 on failure.
|
* \return 0 on success, -1 on failure.
|
||||||
*
|
*
|
||||||
* This function creates the renderer data structures needed to repaint
|
* This function creates the renderer data structures needed to repaint
|
||||||
@@ -168,10 +176,7 @@ struct gl_renderer_interface {
|
|||||||
* with \c EGL_PBUFFER_BIT in \c egl_surface_type.
|
* with \c EGL_PBUFFER_BIT in \c egl_surface_type.
|
||||||
*/
|
*/
|
||||||
int (*output_pbuffer_create)(struct weston_output *output,
|
int (*output_pbuffer_create)(struct weston_output *output,
|
||||||
int width,
|
const struct gl_renderer_pbuffer_options *options);
|
||||||
int height,
|
|
||||||
const uint32_t *drm_formats,
|
|
||||||
unsigned drm_formats_count);
|
|
||||||
|
|
||||||
void (*output_destroy)(struct weston_output *output);
|
void (*output_destroy)(struct weston_output *output);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user