monado/src/xrt/state_trackers/gui/gui_common.h

222 lines
3.5 KiB
C
Raw Normal View History

2019-07-21 14:45:50 +00:00
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Common file for the Monado GUI program.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup gui
*/
#pragma once
2019-10-09 15:22:34 +00:00
#include "xrt/xrt_compiler.h"
2019-07-21 14:45:50 +00:00
/*!
* @defgroup gui GUI Config Interface
* @ingroup xrt
*
* @brief Small GUI interface to configure Monado based on SDL2.
*/
#ifdef __cplusplus
extern "C" {
#endif
2019-08-31 13:53:14 +00:00
#define NUM_XDEVS 8
2019-10-09 15:22:34 +00:00
2019-08-31 13:53:14 +00:00
struct xrt_device;
struct xrt_prober;
2019-09-02 12:18:50 +00:00
struct xrt_fs;
2019-10-09 15:22:34 +00:00
struct xrt_frame_sink;
2019-09-02 12:18:50 +00:00
struct xrt_frame_context;
struct xrt_settings_tracking;
2019-08-31 13:53:14 +00:00
struct time_state;
2019-09-02 12:15:51 +00:00
struct gui_scene_manager;
2019-08-31 13:53:14 +00:00
2019-10-09 15:22:34 +00:00
2019-07-21 14:45:50 +00:00
/*!
2019-10-09 15:22:34 +00:00
* A gui program.
2019-07-21 14:45:50 +00:00
*
* @ingroup gui
*/
2019-10-09 15:22:34 +00:00
struct gui_program
2019-07-21 14:45:50 +00:00
{
bool stopped;
2019-09-02 12:15:51 +00:00
struct gui_scene_manager *gsm;
2019-08-31 13:53:14 +00:00
struct xrt_device *xdevs[NUM_XDEVS];
struct xrt_prober *xp;
2019-08-31 13:57:19 +00:00
struct gui_ogl_texture *texs[256];
size_t num_texs;
2019-08-31 13:57:19 +00:00
};
2019-09-02 12:15:51 +00:00
/*!
* A single currently running scene.
*/
struct gui_scene
{
2019-10-09 15:22:34 +00:00
void (*render)(struct gui_scene *, struct gui_program *);
void (*destroy)(struct gui_scene *, struct gui_program *);
2019-09-02 12:15:51 +00:00
};
2019-08-31 13:57:19 +00:00
/*!
* A OpenGL texture.
*
* @ingroup gui
*/
struct gui_ogl_texture
{
uint64_t seq;
uint64_t dropped;
const char *name;
uint32_t w, h;
uint32_t id;
bool half;
void *ptr;
2019-07-21 14:45:50 +00:00
};
2019-08-31 13:53:14 +00:00
/*!
* Initialize the prober and open all devices found.
*
* @ingroup gui
*/
int
2019-10-09 15:22:34 +00:00
gui_prober_init(struct gui_program *p);
2019-08-31 13:53:14 +00:00
/*!
* Create devices.
*
* @ingroup gui
*/
int
2019-10-09 15:22:34 +00:00
gui_prober_select(struct gui_program *p);
2019-08-31 13:53:14 +00:00
/*!
* Update all devices.
*
* @ingroup gui
*/
void
2019-10-09 15:22:34 +00:00
gui_prober_update(struct gui_program *p);
2019-08-31 13:53:14 +00:00
/*!
* Destroy all opened devices and destroy the prober.
*
* @ingroup gui
*/
void
2019-10-09 15:22:34 +00:00
gui_prober_teardown(struct gui_program *p);
2019-08-31 13:53:14 +00:00
2019-08-31 13:57:19 +00:00
/*!
* Create a sink that will turn frames into OpenGL textures, since the frame
* can come from another thread @ref gui_ogl_sink_update needs to be called.
*
* Destruction is handled by the frame context.
*
* @ingroup gui
*/
struct gui_ogl_texture *
gui_ogl_sink_create(const char *name,
struct xrt_frame_context *xfctx,
struct xrt_frame_sink **out_sink);
/*!
* Update the texture to the latest received frame.
*
* @ingroup gui
*/
void
gui_ogl_sink_update(struct gui_ogl_texture *);
2019-09-02 12:15:51 +00:00
/*!
* Push the scene to the top of the lists.
*
* @ingroup gui
*/
void
2019-10-09 15:22:34 +00:00
gui_scene_push_front(struct gui_program *p, struct gui_scene *me);
2019-09-02 12:15:51 +00:00
/*!
* Put a scene on the delete list, also removes it from any other list.
*
* @ingroup gui
*/
void
2019-10-09 15:22:34 +00:00
gui_scene_delete_me(struct gui_program *p, struct gui_scene *me);
2019-09-02 12:15:51 +00:00
/*!
* Render the scenes.
*
* @ingroup gui
*/
void
2019-10-09 15:22:34 +00:00
gui_scene_manager_render(struct gui_program *p);
2019-09-02 12:15:51 +00:00
/*!
* Initialize the scene manager.
*
* @ingroup gui
*/
void
2019-10-09 15:22:34 +00:00
gui_scene_manager_init(struct gui_program *p);
2019-09-02 12:15:51 +00:00
/*!
* Destroy the scene manager.
*
* @ingroup gui
*/
void
2019-10-09 15:22:34 +00:00
gui_scene_manager_destroy(struct gui_program *p);
2019-09-02 12:15:51 +00:00
2019-07-21 14:45:50 +00:00
2019-09-02 12:18:50 +00:00
/*
*
* Scene creation functions.
*
*/
/*!
* Shows the main menu.
*
* @ingroup gui
*/
void
2019-10-09 15:22:34 +00:00
gui_scene_main_menu(struct gui_program *p);
2019-09-02 12:18:50 +00:00
/*!
2019-09-23 10:46:06 +00:00
* Shows a UI that lets you select a video device and mode for calibration.
2019-09-02 12:18:50 +00:00
*
* @ingroup gui
*/
void
2019-10-09 15:22:34 +00:00
gui_scene_select_video_calibrate(struct gui_program *p);
2019-09-23 10:46:06 +00:00
/*!
* Regular debug UI.
*
* @ingroup gui
*/
void
2019-10-09 15:22:34 +00:00
gui_scene_debug(struct gui_program *p);
2019-09-23 10:46:06 +00:00
/*!
* Given the frameserver runs the calibration code on it.
* Claims ownership of @p s.
2019-09-23 10:46:06 +00:00
*
* @ingroup gui
*/
void
2019-10-09 15:22:34 +00:00
gui_scene_calibrate(struct gui_program *p,
2019-09-23 10:46:06 +00:00
struct xrt_frame_context *xfctx,
struct xrt_fs *xfs,
struct xrt_settings_tracking *s);
2019-09-23 10:46:06 +00:00
2019-09-02 12:18:50 +00:00
2019-07-21 14:45:50 +00:00
#ifdef __cplusplus
}
#endif