kms/update: Encapsulate custom page flip fields in object
Makes more sense to pass around an encapsulated object with the relevant data, than passing around a vfunc and a gpointer. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
This commit is contained in:
parent
4afe3afdf0
commit
8e235768da
@ -527,14 +527,15 @@ typedef struct _RetryPageFlipData
|
|||||||
MetaKmsPageFlipData *page_flip_data;
|
MetaKmsPageFlipData *page_flip_data;
|
||||||
float refresh_rate;
|
float refresh_rate;
|
||||||
uint64_t retry_time_us;
|
uint64_t retry_time_us;
|
||||||
MetaKmsCustomPageFlipFunc custom_page_flip_func;
|
MetaKmsCustomPageFlip *custom_page_flip;
|
||||||
gpointer custom_page_flip_user_data;
|
|
||||||
} RetryPageFlipData;
|
} RetryPageFlipData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
retry_page_flip_data_free (RetryPageFlipData *retry_page_flip_data)
|
retry_page_flip_data_free (RetryPageFlipData *retry_page_flip_data)
|
||||||
{
|
{
|
||||||
g_assert (!retry_page_flip_data->page_flip_data);
|
g_assert (!retry_page_flip_data->page_flip_data);
|
||||||
|
g_clear_pointer (&retry_page_flip_data->custom_page_flip,
|
||||||
|
meta_kms_custom_page_flip_free);
|
||||||
g_free (retry_page_flip_data);
|
g_free (retry_page_flip_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,7 +582,7 @@ retry_page_flips (gpointer user_data)
|
|||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
MetaKmsPageFlipData *page_flip_data;
|
MetaKmsPageFlipData *page_flip_data;
|
||||||
MetaKmsCustomPageFlipFunc custom_page_flip_func;
|
MetaKmsCustomPageFlip *custom_page_flip;
|
||||||
|
|
||||||
if (is_timestamp_earlier_than (now_us,
|
if (is_timestamp_earlier_than (now_us,
|
||||||
retry_page_flip_data->retry_time_us))
|
retry_page_flip_data->retry_time_us))
|
||||||
@ -590,15 +591,15 @@ retry_page_flips (gpointer user_data)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
custom_page_flip_func = retry_page_flip_data->custom_page_flip_func;
|
custom_page_flip = retry_page_flip_data->custom_page_flip;
|
||||||
if (custom_page_flip_func)
|
if (custom_page_flip)
|
||||||
{
|
{
|
||||||
meta_topic (META_DEBUG_KMS,
|
meta_topic (META_DEBUG_KMS,
|
||||||
"[simple] Retrying custom page flip on CRTC %u (%s)",
|
"[simple] Retrying custom page flip on CRTC %u (%s)",
|
||||||
meta_kms_crtc_get_id (crtc),
|
meta_kms_crtc_get_id (crtc),
|
||||||
meta_kms_impl_device_get_path (impl_device));
|
meta_kms_impl_device_get_path (impl_device));
|
||||||
ret = custom_page_flip_func (retry_page_flip_data->custom_page_flip_user_data,
|
ret = custom_page_flip->func (custom_page_flip->user_data,
|
||||||
retry_page_flip_data->page_flip_data);
|
retry_page_flip_data->page_flip_data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -689,13 +690,12 @@ retry_page_flips (gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
schedule_retry_page_flip (MetaKmsImplDeviceSimple *impl_device_simple,
|
schedule_retry_page_flip (MetaKmsImplDeviceSimple *impl_device_simple,
|
||||||
MetaKmsCrtc *crtc,
|
MetaKmsCrtc *crtc,
|
||||||
uint32_t fb_id,
|
uint32_t fb_id,
|
||||||
float refresh_rate,
|
float refresh_rate,
|
||||||
MetaKmsPageFlipData *page_flip_data,
|
MetaKmsPageFlipData *page_flip_data,
|
||||||
MetaKmsCustomPageFlipFunc custom_page_flip_func,
|
MetaKmsCustomPageFlip *custom_page_flip)
|
||||||
gpointer custom_page_flip_user_data)
|
|
||||||
{
|
{
|
||||||
RetryPageFlipData *retry_page_flip_data;
|
RetryPageFlipData *retry_page_flip_data;
|
||||||
uint64_t now_us;
|
uint64_t now_us;
|
||||||
@ -711,8 +711,7 @@ schedule_retry_page_flip (MetaKmsImplDeviceSimple *impl_device_simple,
|
|||||||
.page_flip_data = page_flip_data,
|
.page_flip_data = page_flip_data,
|
||||||
.refresh_rate = refresh_rate,
|
.refresh_rate = refresh_rate,
|
||||||
.retry_time_us = retry_time_us,
|
.retry_time_us = retry_time_us,
|
||||||
.custom_page_flip_func = custom_page_flip_func,
|
.custom_page_flip = custom_page_flip,
|
||||||
.custom_page_flip_user_data = custom_page_flip_user_data,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!impl_device_simple->retry_page_flips_source)
|
if (!impl_device_simple->retry_page_flips_source)
|
||||||
@ -892,8 +891,7 @@ dispatch_page_flip (MetaKmsImplDevice *impl_device,
|
|||||||
META_KMS_IMPL_DEVICE_SIMPLE (impl_device);
|
META_KMS_IMPL_DEVICE_SIMPLE (impl_device);
|
||||||
MetaKmsCrtc *crtc;
|
MetaKmsCrtc *crtc;
|
||||||
MetaKmsPlaneAssignment *plane_assignment;
|
MetaKmsPlaneAssignment *plane_assignment;
|
||||||
MetaKmsCustomPageFlipFunc custom_page_flip_func;
|
g_autoptr (MetaKmsCustomPageFlip) custom_page_flip = NULL;
|
||||||
gpointer custom_page_flip_user_data;
|
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -901,11 +899,9 @@ dispatch_page_flip (MetaKmsImplDevice *impl_device,
|
|||||||
plane_assignment = meta_kms_update_get_primary_plane_assignment (update,
|
plane_assignment = meta_kms_update_get_primary_plane_assignment (update,
|
||||||
crtc);
|
crtc);
|
||||||
|
|
||||||
meta_kms_update_get_custom_page_flip_func (update,
|
custom_page_flip = meta_kms_update_take_custom_page_flip_func (update);
|
||||||
&custom_page_flip_func,
|
|
||||||
&custom_page_flip_user_data);
|
|
||||||
|
|
||||||
if (!plane_assignment && !custom_page_flip_func)
|
if (!plane_assignment && !custom_page_flip)
|
||||||
{
|
{
|
||||||
MetaKmsDevice *device = meta_kms_impl_device_get_device (impl_device);
|
MetaKmsDevice *device = meta_kms_impl_device_get_device (impl_device);
|
||||||
MetaKms *kms = meta_kms_device_get_kms (device);
|
MetaKms *kms = meta_kms_device_get_kms (device);
|
||||||
@ -925,14 +921,14 @@ dispatch_page_flip (MetaKmsImplDevice *impl_device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fd = meta_kms_impl_device_get_fd (impl_device);
|
fd = meta_kms_impl_device_get_fd (impl_device);
|
||||||
if (custom_page_flip_func)
|
if (custom_page_flip)
|
||||||
{
|
{
|
||||||
meta_topic (META_DEBUG_KMS,
|
meta_topic (META_DEBUG_KMS,
|
||||||
"[simple] Invoking custom page flip on CRTC %u (%s)",
|
"[simple] Invoking custom page flip on CRTC %u (%s)",
|
||||||
meta_kms_crtc_get_id (crtc),
|
meta_kms_crtc_get_id (crtc),
|
||||||
meta_kms_impl_device_get_path (impl_device));
|
meta_kms_impl_device_get_path (impl_device));
|
||||||
ret = custom_page_flip_func (custom_page_flip_user_data,
|
ret = custom_page_flip->func (custom_page_flip->user_data,
|
||||||
page_flip_data);
|
page_flip_data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -981,8 +977,7 @@ dispatch_page_flip (MetaKmsImplDevice *impl_device,
|
|||||||
fb_id,
|
fb_id,
|
||||||
refresh_rate,
|
refresh_rate,
|
||||||
page_flip_data,
|
page_flip_data,
|
||||||
custom_page_flip_func,
|
g_steal_pointer (&custom_page_flip));
|
||||||
custom_page_flip_user_data);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -87,6 +87,12 @@ typedef struct _MetaKmsResultListener
|
|||||||
gpointer user_data;
|
gpointer user_data;
|
||||||
} MetaKmsResultListener;
|
} MetaKmsResultListener;
|
||||||
|
|
||||||
|
typedef struct _MetaKmsCustomPageFlip
|
||||||
|
{
|
||||||
|
MetaKmsCustomPageFlipFunc func;
|
||||||
|
gpointer user_data;
|
||||||
|
} MetaKmsCustomPageFlip;
|
||||||
|
|
||||||
void meta_kms_plane_feedback_free (MetaKmsPlaneFeedback *plane_feedback);
|
void meta_kms_plane_feedback_free (MetaKmsPlaneFeedback *plane_feedback);
|
||||||
|
|
||||||
MetaKmsPlaneFeedback * meta_kms_plane_feedback_new_take_error (MetaKmsPlane *plane,
|
MetaKmsPlaneFeedback * meta_kms_plane_feedback_new_take_error (MetaKmsPlane *plane,
|
||||||
@ -126,9 +132,7 @@ GList * meta_kms_update_get_crtc_gammas (MetaKmsUpdate *update);
|
|||||||
|
|
||||||
gboolean meta_kms_update_is_power_save (MetaKmsUpdate *update);
|
gboolean meta_kms_update_is_power_save (MetaKmsUpdate *update);
|
||||||
|
|
||||||
void meta_kms_update_get_custom_page_flip_func (MetaKmsUpdate *update,
|
MetaKmsCustomPageFlip * meta_kms_update_take_custom_page_flip_func (MetaKmsUpdate *update);
|
||||||
MetaKmsCustomPageFlipFunc *custom_page_flip_func,
|
|
||||||
gpointer *custom_page_flip_user_data);
|
|
||||||
|
|
||||||
void meta_kms_update_drop_plane_assignment (MetaKmsUpdate *update,
|
void meta_kms_update_drop_plane_assignment (MetaKmsUpdate *update,
|
||||||
MetaKmsPlane *plane);
|
MetaKmsPlane *plane);
|
||||||
@ -140,7 +144,12 @@ void meta_kms_result_listener_notify (MetaKmsResultListener *listener,
|
|||||||
|
|
||||||
void meta_kms_result_listener_free (MetaKmsResultListener *listener);
|
void meta_kms_result_listener_free (MetaKmsResultListener *listener);
|
||||||
|
|
||||||
|
void meta_kms_custom_page_flip_free (MetaKmsCustomPageFlip *custom_page_flip);
|
||||||
|
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaKmsPlaneFeedback,
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaKmsPlaneFeedback,
|
||||||
meta_kms_plane_feedback_free)
|
meta_kms_plane_feedback_free)
|
||||||
|
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaKmsCustomPageFlip,
|
||||||
|
meta_kms_custom_page_flip_free)
|
||||||
|
|
||||||
#endif /* META_KMS_UPDATE_PRIVATE_H */
|
#endif /* META_KMS_UPDATE_PRIVATE_H */
|
||||||
|
@ -42,8 +42,7 @@ struct _MetaKmsUpdate
|
|||||||
GList *connector_updates;
|
GList *connector_updates;
|
||||||
GList *crtc_gammas;
|
GList *crtc_gammas;
|
||||||
|
|
||||||
MetaKmsCustomPageFlipFunc custom_page_flip_func;
|
MetaKmsCustomPageFlip *custom_page_flip;
|
||||||
gpointer custom_page_flip_user_data;
|
|
||||||
|
|
||||||
GList *page_flip_listeners;
|
GList *page_flip_listeners;
|
||||||
GList *result_listeners;
|
GList *result_listeners;
|
||||||
@ -423,11 +422,16 @@ meta_kms_update_set_custom_page_flip (MetaKmsUpdate *update,
|
|||||||
MetaKmsCustomPageFlipFunc func,
|
MetaKmsCustomPageFlipFunc func,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
MetaKmsCustomPageFlip *custom_page_flip;
|
||||||
|
|
||||||
g_assert (!meta_kms_update_is_locked (update));
|
g_assert (!meta_kms_update_is_locked (update));
|
||||||
g_assert (!update->power_save);
|
g_assert (!update->power_save);
|
||||||
|
|
||||||
update->custom_page_flip_func = func;
|
custom_page_flip = g_new0 (MetaKmsCustomPageFlip, 1);
|
||||||
update->custom_page_flip_user_data = user_data;
|
custom_page_flip->func = func;
|
||||||
|
custom_page_flip->user_data = user_data;
|
||||||
|
|
||||||
|
update->custom_page_flip = custom_page_flip;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -569,13 +573,16 @@ meta_kms_update_get_device (MetaKmsUpdate *update)
|
|||||||
return update->device;
|
return update->device;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
MetaKmsCustomPageFlip *
|
||||||
meta_kms_update_get_custom_page_flip_func (MetaKmsUpdate *update,
|
meta_kms_update_take_custom_page_flip_func (MetaKmsUpdate *update)
|
||||||
MetaKmsCustomPageFlipFunc *custom_page_flip_func,
|
|
||||||
gpointer *custom_page_flip_user_data)
|
|
||||||
{
|
{
|
||||||
*custom_page_flip_func = update->custom_page_flip_func;
|
return g_steal_pointer (&update->custom_page_flip);
|
||||||
*custom_page_flip_user_data = update->custom_page_flip_user_data;
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_kms_custom_page_flip_free (MetaKmsCustomPageFlip *custom_page_flip)
|
||||||
|
{
|
||||||
|
g_free (custom_page_flip);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
@ -610,6 +617,7 @@ meta_kms_update_free (MetaKmsUpdate *update)
|
|||||||
(GDestroyNotify) meta_kms_page_flip_listener_free);
|
(GDestroyNotify) meta_kms_page_flip_listener_free);
|
||||||
g_list_free_full (update->connector_updates, g_free);
|
g_list_free_full (update->connector_updates, g_free);
|
||||||
g_list_free_full (update->crtc_gammas, (GDestroyNotify) meta_kms_crtc_gamma_free);
|
g_list_free_full (update->crtc_gammas, (GDestroyNotify) meta_kms_crtc_gamma_free);
|
||||||
|
g_clear_pointer (&update->custom_page_flip, meta_kms_custom_page_flip_free);
|
||||||
|
|
||||||
g_free (update);
|
g_free (update);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user