Commit 6a157949 authored by Lubosz Sarnecki's avatar Lubosz Sarnecki

src: Improve struct declarations.

Add Xrd prefixes to all structs.
Remove redundant names in declarations.
Remove newlines before { in declartion so gtkdoc picks them up.
parent 2915f89b
......@@ -12,11 +12,10 @@
#include <gulkan.h>
#include <openvr-glib.h>
typedef struct VertexDataScene
{
typedef struct {
graphene_point3d_t position;
graphene_point_t uv;
} VertexDataScene;
} XrdSceneVertex;
struct _XrdSceneRenderer
{
......@@ -243,7 +242,7 @@ _init_pipeline_cache (XrdSceneRenderer *self)
return true;
}
typedef struct __attribute__((__packed__)) PipelineConfig {
typedef struct __attribute__((__packed__)) {
VkPrimitiveTopology topology;
uint32_t stride;
const VkVertexInputAttributeDescription *attribs;
......@@ -251,19 +250,19 @@ typedef struct __attribute__((__packed__)) PipelineConfig {
const VkPipelineDepthStencilStateCreateInfo *depth_stencil_state;
const VkPipelineColorBlendAttachmentState *blend_attachments;
const VkPipelineRasterizationStateCreateInfo *rasterization_state;
} PipelineConfig;
} XrdPipelineConfig;
static bool
_init_graphics_pipelines (XrdSceneRenderer *self)
{
PipelineConfig config[PIPELINE_COUNT] = {
XrdPipelineConfig config[PIPELINE_COUNT] = {
// PIPELINE_WINDOWS
{
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
.stride = sizeof (VertexDataScene),
.stride = sizeof (XrdSceneVertex),
.attribs = (VkVertexInputAttributeDescription []) {
{0, 0, VK_FORMAT_R32G32B32_SFLOAT, 0},
{1, 0, VK_FORMAT_R32G32_SFLOAT, offsetof (VertexDataScene, uv)},
{1, 0, VK_FORMAT_R32G32_SFLOAT, offsetof (XrdSceneVertex, uv)},
},
.attrib_count = 2,
.depth_stencil_state = &(VkPipelineDepthStencilStateCreateInfo) {
......@@ -287,10 +286,10 @@ _init_graphics_pipelines (XrdSceneRenderer *self)
// PIPELINE_TIP
{
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
.stride = sizeof (VertexDataScene),
.stride = sizeof (XrdSceneVertex),
.attribs = (VkVertexInputAttributeDescription []) {
{0, 0, VK_FORMAT_R32G32B32_SFLOAT, 0},
{1, 0, VK_FORMAT_R32G32_SFLOAT, offsetof (VertexDataScene, uv)},
{1, 0, VK_FORMAT_R32G32_SFLOAT, offsetof (XrdSceneVertex, uv)},
},
.attrib_count = 2,
.depth_stencil_state = &(VkPipelineDepthStencilStateCreateInfo) {
......
......@@ -748,7 +748,7 @@ _perform_push_pull (XrdClient *self,
{
XrdClientPrivate *priv = xrd_client_get_instance_private (self);
HoverState *hover_state = xrd_controller_get_hover_state (controller);
XrdHoverState *hover_state = xrd_controller_get_hover_state (controller);
float new_dist =
hover_state->distance +
......@@ -786,7 +786,7 @@ _action_push_pull_scale_cb (OpenVRAction *action,
float ms_since_last_poll =
(g_get_monotonic_time () - priv->last_poll_timestamp) / 1000.f;
GrabState *grab_state = xrd_controller_get_grab_state (controller);
XrdGrabState *grab_state = xrd_controller_get_grab_state (controller);
double x_state = (double) graphene_vec3_get_x (&event->state);
double y_state = (double) graphene_vec3_get_y (&event->state);
......@@ -843,7 +843,7 @@ _action_push_pull_cb (OpenVRAction *action,
float ms_since_last_poll =
(g_get_monotonic_time () - priv->last_poll_timestamp) / 1000.f;
GrabState *grab_state = xrd_controller_get_grab_state (controller);
XrdGrabState *grab_state = xrd_controller_get_grab_state (controller);
double y_state = (double) graphene_vec3_get_y (&event->state);
if (grab_state->window && fabs (y_state) > priv->analog_threshold)
......@@ -899,22 +899,22 @@ _action_menu_cb (OpenVRAction *action,
g_free (event);
}
typedef struct OrientationTransition
{
GrabState *grab_state;
typedef struct {
XrdGrabState *grab_state;
graphene_quaternion_t from;
graphene_quaternion_t from_neg;
graphene_quaternion_t to;
float interpolate;
gint64 last_timestamp;
} OrientationTransition;
} XrdOrientationTransition;
static gboolean
_interpolate_orientation_cb (gpointer _transition)
{
OrientationTransition *transition = (OrientationTransition *) _transition;
XrdOrientationTransition *transition =
(XrdOrientationTransition*) _transition;
GrabState *grab_state = transition->grab_state;
XrdGrabState *grab_state = transition->grab_state;
graphene_quaternion_slerp (&transition->from,
&transition->to,
......@@ -961,11 +961,12 @@ _action_reset_orientation_cb (OpenVRAction *action,
if (controller == NULL)
return;
GrabState *grab_state = xrd_controller_get_grab_state (controller);
XrdGrabState *grab_state = xrd_controller_get_grab_state (controller);
if (grab_state->window == NULL)
return;
OrientationTransition *transition = g_malloc (sizeof (OrientationTransition));
XrdOrientationTransition *transition =
g_malloc (sizeof (XrdOrientationTransition));
/* TODO: Check if animation is already in progress */
......
......@@ -14,8 +14,8 @@ struct _XrdController
guint64 controller_handle;
XrdPointer *pointer_ray;
XrdPointerTip *pointer_tip;
HoverState hover_state;
GrabState grab_state;
XrdHoverState hover_state;
XrdGrabState grab_state;
graphene_matrix_t pose_hand_grip;
};
......@@ -90,13 +90,13 @@ xrd_controller_get_handle (XrdController *self)
return self->controller_handle;
}
HoverState *
XrdHoverState *
xrd_controller_get_hover_state (XrdController *self)
{
return &self->hover_state;
}
GrabState *
XrdGrabState *
xrd_controller_get_grab_state (XrdController *self)
{
return &self->grab_state;
......
......@@ -36,16 +36,14 @@ typedef enum {
XRD_TRANSFORM_LOCK_SCALE
} XrdTransformLock;
typedef struct HoverState
{
typedef struct {
XrdWindow *window;
graphene_matrix_t pose;
float distance;
graphene_point_t intersection_2d;
} HoverState;
} XrdHoverState;
typedef struct GrabState
{
typedef struct {
XrdWindow *window;
/* window rotation, controller rotation, offset at the moment the window
......@@ -55,7 +53,7 @@ typedef struct GrabState
graphene_point3d_t grab_offset;
XrdTransformLock transform_lock;
} GrabState;
} XrdGrabState;
XrdController *xrd_controller_new (guint64 controller_handle);
......@@ -74,10 +72,10 @@ xrd_controller_set_pointer_tip (XrdController *self, XrdPointerTip *tip);
guint64
xrd_controller_get_handle (XrdController *self);
HoverState *
XrdHoverState *
xrd_controller_get_hover_state (XrdController *self);
GrabState *
XrdGrabState *
xrd_controller_get_grab_state (XrdController *self);
void
......
......@@ -23,8 +23,7 @@ G_BEGIN_DECLS
G_DECLARE_INTERFACE (XrdDesktopCursor, xrd_desktop_cursor,
XRD, DESKTOP_CURSOR, GObject)
typedef struct _XrdDesktopCursorData
{
typedef struct {
XrdDesktopCursor *cursor;
gboolean keep_apparent_size;
......
......@@ -34,7 +34,7 @@ G_DECLARE_FINAL_TYPE (XrdInputSynth, xrd_input_synth, XRD, INPUT_SYNTH, GObject)
*
* A 2D mouse click event.
**/
typedef struct XrdClickEvent {
typedef struct {
XrdWindow *window;
graphene_point_t *position;
int button;
......@@ -54,7 +54,7 @@ typedef struct XrdClickEvent {
* does not appear frozen, but don't actually synthesize mouse move events.
*
**/
typedef struct XrdMoveCursorEvent {
typedef struct {
XrdWindow *window;
graphene_point_t *position;
gboolean ignore;
......
......@@ -33,15 +33,13 @@ G_DECLARE_INTERFACE (XrdPointerTip, xrd_pointer_tip, XRD, POINTER_TIP, GObject)
*/
#define XRD_TIP_APPARENT_SIZE_DISTANCE 3.0f
typedef struct XrdPointerTipAnimation
{
typedef struct {
XrdPointerTip *tip;
float progress;
guint callback_id;
} XrdPointerTipAnimation;
typedef struct _XrdPointerTipSettings
{
typedef struct {
gboolean keep_apparent_size;
float width_meters;
......@@ -54,8 +52,7 @@ typedef struct _XrdPointerTipSettings
int texture_height;
} XrdPointerTipSettings;
typedef struct _XrdPointerTipData
{
typedef struct {
XrdPointerTip *tip;
gboolean active;
......
......@@ -22,7 +22,7 @@ G_BEGIN_DECLS
#define XRD_TYPE_POINTER xrd_pointer_get_type()
G_DECLARE_INTERFACE (XrdPointer, xrd_pointer, XRD, POINTER, GObject)
typedef struct _XrdPointerData {
typedef struct {
float start_offset;
float length;
float default_length;
......
......@@ -9,12 +9,6 @@
#include "graphene-ext.h"
#include "xrd-settings.h"
typedef struct
{
int x;
int y;
} PixelPos;
struct _XrdShakeCompensator
{
GObject parent;
......
......@@ -105,7 +105,7 @@ xrd_window_manager_finalize (GObject *gobject)
static gboolean
_interpolate_cb (gpointer _transition)
{
TransformTransition *transition = (TransformTransition *) _transition;
XrdTransformTransition *transition = (XrdTransformTransition *) _transition;
XrdWindow *window = transition->window;
......@@ -170,7 +170,7 @@ xrd_window_manager_arrange_reset (XrdWindowManager *self)
{
XrdWindow *window = (XrdWindow *) l->data;
TransformTransition *transition = g_malloc (sizeof *transition);
XrdTransformTransition *transition = g_malloc (sizeof *transition);
transition->last_timestamp = g_get_monotonic_time ();
XrdWindowData *data = xrd_window_get_data (window);
......@@ -262,7 +262,7 @@ xrd_window_manager_arrange_sphere (XrdWindowManager *self)
{
for (float phi = phi_start; phi < phi_end + 0.01f; phi += phi_step)
{
TransformTransition *transition = g_malloc (sizeof *transition);
XrdTransformTransition *transition = g_malloc (sizeof *transition);
transition->last_timestamp = g_get_monotonic_time ();
float const x = sinf (theta) * cosf (phi);
......@@ -454,7 +454,7 @@ _test_hover (XrdWindowManager *self,
}
}
HoverState *hover_state = xrd_controller_get_hover_state (controller);
XrdHoverState *hover_state = xrd_controller_get_hover_state (controller);
xrd_pointer_set_selected_window (pointer, closest);
......@@ -526,8 +526,8 @@ _drag_window (XrdWindowManager *self,
XrdController *controller)
{
(void) self;
HoverState *hover_state = xrd_controller_get_hover_state (controller);
GrabState *grab_state = xrd_controller_get_grab_state (controller);
XrdHoverState *hover_state = xrd_controller_get_hover_state (controller);
XrdGrabState *grab_state = xrd_controller_get_grab_state (controller);
graphene_point3d_t controller_translation_point;
graphene_matrix_get_translation_point3d (pose, &controller_translation_point);
......@@ -598,8 +598,8 @@ void
xrd_window_manager_drag_start (XrdWindowManager *self,
XrdController *controller)
{
HoverState *hover_state = xrd_controller_get_hover_state (controller);
GrabState *grab_state = xrd_controller_get_grab_state (controller);
XrdHoverState *hover_state = xrd_controller_get_hover_state (controller);
XrdGrabState *grab_state = xrd_controller_get_grab_state (controller);
if (!_is_in_list (self->draggable_windows, hover_state->window))
return;
......@@ -660,7 +660,7 @@ _valid_float_prop (GObject *object, const gchar *prop, float value)
*/
void
xrd_window_manager_scale (XrdWindowManager *self,
GrabState *grab_state,
XrdGrabState *grab_state,
float factor,
float update_rate_ms)
{
......@@ -691,7 +691,7 @@ xrd_window_manager_check_grab (XrdWindowManager *self,
XrdController *controller)
{
(void) self;
HoverState *hover_state = xrd_controller_get_hover_state (controller);
XrdHoverState *hover_state = xrd_controller_get_hover_state (controller);
if (hover_state->window == NULL)
return;
......@@ -707,7 +707,7 @@ xrd_window_manager_check_release (XrdWindowManager *self,
XrdController *controller)
{
(void) self;
GrabState *grab_state = xrd_controller_get_grab_state (controller);
XrdGrabState *grab_state = xrd_controller_get_grab_state (controller);
if (grab_state->window == NULL)
return;
......
......@@ -26,14 +26,12 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (XrdWindowManager, xrd_window_manager, XRD,
WINDOW_MANAGER, GObject)
typedef struct XrdNoHoverEvent
{
typedef struct {
graphene_matrix_t pose;
guint64 controller_handle;
} XrdNoHoverEvent;
typedef struct TransformTransition
{
typedef struct {
XrdWindow *window;
graphene_matrix_t from;
graphene_matrix_t to;
......@@ -41,7 +39,7 @@ typedef struct TransformTransition
float to_scaling;
float interpolate;
gint64 last_timestamp;
} TransformTransition;
} XrdTransformTransition;
/**
* XrdWindowFlags:
......@@ -108,7 +106,7 @@ xrd_window_manager_drag_start (XrdWindowManager *self,
void
xrd_window_manager_scale (XrdWindowManager *self,
GrabState *grab_state,
XrdGrabState *grab_state,
float factor,
float update_rate_ms);
......@@ -128,11 +126,11 @@ xrd_window_manager_update_pose (XrdWindowManager *self,
void
xrd_window_manager_poll_window_events (XrdWindowManager *self);
GrabState *
XrdGrabState *
xrd_window_manager_get_grab_state (XrdWindowManager *self,
XrdController *controller);
HoverState *
XrdHoverState *
xrd_window_manager_get_hover_state (XrdWindowManager *self,
XrdController *controller);
......
......@@ -19,35 +19,30 @@
#include "xrd-pointer.h"
typedef struct XrdPixelSize
{
typedef struct {
uint32_t width;
uint32_t height;
} XrdPixelSize;
typedef struct XrdHoverEvent
{
typedef struct {
graphene_point3d_t point;
graphene_matrix_t pose;
float distance;
guint64 controller_handle;
} XrdHoverEvent;
typedef struct XrdGrabEvent
{
typedef struct {
graphene_matrix_t pose;
guint64 controller_handle;
} XrdGrabEvent;
typedef struct XrdControllerIndexEvent
{
typedef struct {
guint64 controller_handle;
} XrdControllerIndexEvent;
/** _XrdWindowState:
* copy of the state of a window carried over an overlay<->scene switch */
typedef struct
{
typedef struct {
gpointer native;
gchar *title;
float scale;
......@@ -73,8 +68,7 @@ G_BEGIN_DECLS
#define XRD_TYPE_WINDOW xrd_window_get_type()
G_DECLARE_INTERFACE (XrdWindow, xrd_window, XRD, WINDOW, GObject)
typedef struct XrdWindowData
{
typedef struct {
GObject parent;
gpointer native;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment