mirror of
https://github.com/brl/mutter.git
synced 2024-11-28 19:10:43 -05:00
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;
|
||||
float refresh_rate;
|
||||
uint64_t retry_time_us;
|
||||
MetaKmsCustomPageFlipFunc custom_page_flip_func;
|
||||
gpointer custom_page_flip_user_data;
|
||||
MetaKmsCustomPageFlip *custom_page_flip;
|
||||
} RetryPageFlipData;
|
||||
|
||||
static void
|
||||
retry_page_flip_data_free (RetryPageFlipData *retry_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);
|
||||
}
|
||||
|
||||
@ -581,7 +582,7 @@ retry_page_flips (gpointer user_data)
|
||||
int fd;
|
||||
int ret;
|
||||
MetaKmsPageFlipData *page_flip_data;
|
||||
MetaKmsCustomPageFlipFunc custom_page_flip_func;
|
||||
MetaKmsCustomPageFlip *custom_page_flip;
|
||||
|
||||
if (is_timestamp_earlier_than (now_us,
|
||||
retry_page_flip_data->retry_time_us))
|
||||
@ -590,14 +591,14 @@ retry_page_flips (gpointer user_data)
|
||||
continue;
|
||||
}
|
||||
|
||||
custom_page_flip_func = retry_page_flip_data->custom_page_flip_func;
|
||||
if (custom_page_flip_func)
|
||||
custom_page_flip = retry_page_flip_data->custom_page_flip;
|
||||
if (custom_page_flip)
|
||||
{
|
||||
meta_topic (META_DEBUG_KMS,
|
||||
"[simple] Retrying custom page flip on CRTC %u (%s)",
|
||||
meta_kms_crtc_get_id (crtc),
|
||||
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);
|
||||
}
|
||||
else
|
||||
@ -694,8 +695,7 @@ schedule_retry_page_flip (MetaKmsImplDeviceSimple *impl_device_simple,
|
||||
uint32_t fb_id,
|
||||
float refresh_rate,
|
||||
MetaKmsPageFlipData *page_flip_data,
|
||||
MetaKmsCustomPageFlipFunc custom_page_flip_func,
|
||||
gpointer custom_page_flip_user_data)
|
||||
MetaKmsCustomPageFlip *custom_page_flip)
|
||||
{
|
||||
RetryPageFlipData *retry_page_flip_data;
|
||||
uint64_t now_us;
|
||||
@ -711,8 +711,7 @@ schedule_retry_page_flip (MetaKmsImplDeviceSimple *impl_device_simple,
|
||||
.page_flip_data = page_flip_data,
|
||||
.refresh_rate = refresh_rate,
|
||||
.retry_time_us = retry_time_us,
|
||||
.custom_page_flip_func = custom_page_flip_func,
|
||||
.custom_page_flip_user_data = custom_page_flip_user_data,
|
||||
.custom_page_flip = custom_page_flip,
|
||||
};
|
||||
|
||||
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);
|
||||
MetaKmsCrtc *crtc;
|
||||
MetaKmsPlaneAssignment *plane_assignment;
|
||||
MetaKmsCustomPageFlipFunc custom_page_flip_func;
|
||||
gpointer custom_page_flip_user_data;
|
||||
g_autoptr (MetaKmsCustomPageFlip) custom_page_flip = NULL;
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
@ -901,11 +899,9 @@ dispatch_page_flip (MetaKmsImplDevice *impl_device,
|
||||
plane_assignment = meta_kms_update_get_primary_plane_assignment (update,
|
||||
crtc);
|
||||
|
||||
meta_kms_update_get_custom_page_flip_func (update,
|
||||
&custom_page_flip_func,
|
||||
&custom_page_flip_user_data);
|
||||
custom_page_flip = meta_kms_update_take_custom_page_flip_func (update);
|
||||
|
||||
if (!plane_assignment && !custom_page_flip_func)
|
||||
if (!plane_assignment && !custom_page_flip)
|
||||
{
|
||||
MetaKmsDevice *device = meta_kms_impl_device_get_device (impl_device);
|
||||
MetaKms *kms = meta_kms_device_get_kms (device);
|
||||
@ -925,13 +921,13 @@ dispatch_page_flip (MetaKmsImplDevice *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,
|
||||
"[simple] Invoking custom page flip on CRTC %u (%s)",
|
||||
meta_kms_crtc_get_id (crtc),
|
||||
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);
|
||||
}
|
||||
else
|
||||
@ -981,8 +977,7 @@ dispatch_page_flip (MetaKmsImplDevice *impl_device,
|
||||
fb_id,
|
||||
refresh_rate,
|
||||
page_flip_data,
|
||||
custom_page_flip_func,
|
||||
custom_page_flip_user_data);
|
||||
g_steal_pointer (&custom_page_flip));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -87,6 +87,12 @@ typedef struct _MetaKmsResultListener
|
||||
gpointer user_data;
|
||||
} MetaKmsResultListener;
|
||||
|
||||
typedef struct _MetaKmsCustomPageFlip
|
||||
{
|
||||
MetaKmsCustomPageFlipFunc func;
|
||||
gpointer user_data;
|
||||
} MetaKmsCustomPageFlip;
|
||||
|
||||
void meta_kms_plane_feedback_free (MetaKmsPlaneFeedback *plane_feedback);
|
||||
|
||||
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);
|
||||
|
||||
void meta_kms_update_get_custom_page_flip_func (MetaKmsUpdate *update,
|
||||
MetaKmsCustomPageFlipFunc *custom_page_flip_func,
|
||||
gpointer *custom_page_flip_user_data);
|
||||
MetaKmsCustomPageFlip * meta_kms_update_take_custom_page_flip_func (MetaKmsUpdate *update);
|
||||
|
||||
void meta_kms_update_drop_plane_assignment (MetaKmsUpdate *update,
|
||||
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_custom_page_flip_free (MetaKmsCustomPageFlip *custom_page_flip);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaKmsPlaneFeedback,
|
||||
meta_kms_plane_feedback_free)
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaKmsCustomPageFlip,
|
||||
meta_kms_custom_page_flip_free)
|
||||
|
||||
#endif /* META_KMS_UPDATE_PRIVATE_H */
|
||||
|
@ -42,8 +42,7 @@ struct _MetaKmsUpdate
|
||||
GList *connector_updates;
|
||||
GList *crtc_gammas;
|
||||
|
||||
MetaKmsCustomPageFlipFunc custom_page_flip_func;
|
||||
gpointer custom_page_flip_user_data;
|
||||
MetaKmsCustomPageFlip *custom_page_flip;
|
||||
|
||||
GList *page_flip_listeners;
|
||||
GList *result_listeners;
|
||||
@ -423,11 +422,16 @@ meta_kms_update_set_custom_page_flip (MetaKmsUpdate *update,
|
||||
MetaKmsCustomPageFlipFunc func,
|
||||
gpointer user_data)
|
||||
{
|
||||
MetaKmsCustomPageFlip *custom_page_flip;
|
||||
|
||||
g_assert (!meta_kms_update_is_locked (update));
|
||||
g_assert (!update->power_save);
|
||||
|
||||
update->custom_page_flip_func = func;
|
||||
update->custom_page_flip_user_data = user_data;
|
||||
custom_page_flip = g_new0 (MetaKmsCustomPageFlip, 1);
|
||||
custom_page_flip->func = func;
|
||||
custom_page_flip->user_data = user_data;
|
||||
|
||||
update->custom_page_flip = custom_page_flip;
|
||||
}
|
||||
|
||||
void
|
||||
@ -569,13 +573,16 @@ meta_kms_update_get_device (MetaKmsUpdate *update)
|
||||
return update->device;
|
||||
}
|
||||
|
||||
void
|
||||
meta_kms_update_get_custom_page_flip_func (MetaKmsUpdate *update,
|
||||
MetaKmsCustomPageFlipFunc *custom_page_flip_func,
|
||||
gpointer *custom_page_flip_user_data)
|
||||
MetaKmsCustomPageFlip *
|
||||
meta_kms_update_take_custom_page_flip_func (MetaKmsUpdate *update)
|
||||
{
|
||||
*custom_page_flip_func = update->custom_page_flip_func;
|
||||
*custom_page_flip_user_data = update->custom_page_flip_user_data;
|
||||
return g_steal_pointer (&update->custom_page_flip);
|
||||
}
|
||||
|
||||
void
|
||||
meta_kms_custom_page_flip_free (MetaKmsCustomPageFlip *custom_page_flip)
|
||||
{
|
||||
g_free (custom_page_flip);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
@ -610,6 +617,7 @@ meta_kms_update_free (MetaKmsUpdate *update)
|
||||
(GDestroyNotify) meta_kms_page_flip_listener_free);
|
||||
g_list_free_full (update->connector_updates, g_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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user