[sysprof/wip/chergert/sysprof-3] libsysprof-ui: add fit-width zoom helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/chergert/sysprof-3] libsysprof-ui: add fit-width zoom helper
- Date: Wed, 15 May 2019 04:09:37 +0000 (UTC)
commit 01acbd81b11c280ad991402670432283ef479ca9
Author: Christian Hergert <chergert redhat com>
Date: Tue May 14 21:09:24 2019 -0700
libsysprof-ui: add fit-width zoom helper
src/libsysprof-ui/sysprof-zoom-manager.c | 12 ++++++++++++
src/libsysprof-ui/sysprof-zoom-manager.h | 4 ++++
2 files changed, 16 insertions(+)
---
diff --git a/src/libsysprof-ui/sysprof-zoom-manager.c b/src/libsysprof-ui/sysprof-zoom-manager.c
index cdb0665..41a74fe 100644
--- a/src/libsysprof-ui/sysprof-zoom-manager.c
+++ b/src/libsysprof-ui/sysprof-zoom-manager.c
@@ -515,3 +515,15 @@ sysprof_zoom_manager_get_width_for_duration (SysprofZoomManager *self,
return (gdouble)duration / (gdouble)NSEC_PER_SEC * DEFAULT_PIXELS_PER_SEC * self->zoom;
}
+
+gdouble
+sysprof_zoom_manager_fit_zoom_for_duration (SysprofZoomManager *self,
+ gint64 duration,
+ gint width)
+{
+ g_return_val_if_fail (SYSPROF_IS_ZOOM_MANAGER (self), 1.0);
+ g_return_val_if_fail (duration >= 0, 1.0);
+
+ return ((gdouble)width / DEFAULT_PIXELS_PER_SEC) /
+ ((gdouble)duration / (gdouble)NSEC_PER_SEC);
+}
diff --git a/src/libsysprof-ui/sysprof-zoom-manager.h b/src/libsysprof-ui/sysprof-zoom-manager.h
index 78e4b57..5b777b2 100644
--- a/src/libsysprof-ui/sysprof-zoom-manager.h
+++ b/src/libsysprof-ui/sysprof-zoom-manager.h
@@ -70,5 +70,9 @@ gint sysprof_zoom_manager_get_width_for_duration (SysprofZoomMana
SYSPROF_AVAILABLE_IN_ALL
gint64 sysprof_zoom_manager_get_duration_for_width (SysprofZoomManager *self,
gint width);
+SYSPROF_AVAILABLE_IN_ALL
+gdouble sysprof_zoom_manager_fit_zoom_for_duration (SysprofZoomManager *self,
+ gint64 duration,
+ gint width);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]