Debian Codegraph @

demos/gtk-demo/frames.c

raw symbols SCIP
1 /* Benchmark/Frames
2 *
3 * This demo is intentionally as simple as possible, to see what
4 * framerate the windowing system can deliver on its own.
5 *
6 * It does nothing but change the drawn color, for every frame.
7 */
8
9 #include <gtk/gtk.h>cxx . . $ `<file>/gtk/gtk.h`/
10
11 typedef structcxx . . $ $anonymous_type_b39fec4da6b2c8db_0#
12 {
13 GtkWidgetcxx . . $ GtkWidget# parent_instancecxx . . $ $anonymous_type_b39fec4da6b2c8db_0#parent_instance.;
14
15 GdkRGBAcxx . . $ GdkRGBA# color1cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color1.;
16 GdkRGBAcxx . . $ GdkRGBA# color2cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color2.;
17 guint64cxx . . $ guint64# time2cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#time2.;
18 float tcxx . . $ $anonymous_type_b39fec4da6b2c8db_0#t.;
19
20 guintcxx . . $ guint# tick_cbcxx . . $ $anonymous_type_b39fec4da6b2c8db_0#tick_cb.;
21 } ColorWidgetcxx . . $ ColorWidget#;
22
23 typedef structcxx . . $ $anonymous_type_b39fec4da6b2c8db_1#
24 {
25 GtkWidgetClasscxx . . $ GtkWidgetClass# parent_classcxx . . $ $anonymous_type_b39fec4da6b2c8db_1#parent_class.;
26 } ColorWidgetClasscxx . . $ ColorWidgetClass#;
27
28 G_DEFINE_TYPEcxx . . $ `<external>/9567554376676449156/gtype.h:1834:9`! (ColorWidget, color_widget, GTK_TYPE_WIDGETcxx . . $ `gtk/gtkwidget.h:43:9`!)
29
30 #define TIME_SPANcxx . . $ `demos/gtk-demo/frames.c:30:9`! (3.0 * G_TIME_SPAN_SECONDcxx . . $ `<external>/5362845561472519165/gdatetime.h:71:9`!)
31
32 static gbooleancxx . . $ gboolean#
33 change_colorcxx . . $ change_color(d70983e0fefb11f). (GtkWidgetcxx . . $ GtkWidget# *widget,
34 GdkFrameClockcxx . . $ GdkFrameClock# *frame_clock,
35 gpointercxx . . $ gpointer# data)
36 {
37 ColorWidgetcxx . . $ ColorWidget# *color = (ColorWidgetcxx . . $ ColorWidget# *)widget;
38 gint64cxx . . $ gint64# time;
39
40 time = gdk_frame_clock_get_frame_timecxx . . $ gdk_frame_clock_get_frame_time(417c30ec8704d8fe). (frame_clock);
41
42 if (time >= color->time2cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#time2.)
43 {
44 color->time2cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#time2. = time + TIME_SPANcxx . . $ `demos/gtk-demo/frames.c:30:9`!;
45
46 color->color1cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color1. = color->color2cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color2.;
47 color->color2cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color2..redcxx . . $ _GdkRGBA#red. = g_random_double_rangecxx . . $ g_random_double_range(d8e7e0733fa41c87). (0, 1);
48 color->color2cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color2..greencxx . . $ _GdkRGBA#green. = g_random_double_rangecxx . . $ g_random_double_range(d8e7e0733fa41c87). (0, 1);
49 color->color2cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color2..bluecxx . . $ _GdkRGBA#blue. = g_random_double_rangecxx . . $ g_random_double_range(d8e7e0733fa41c87). (0, 1);
50 color->color2cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color2..alphacxx . . $ _GdkRGBA#alpha. = 1;
51 }
52
53 color->tcxx . . $ $anonymous_type_b39fec4da6b2c8db_0#t. = 1 - (color->time2cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#time2. - time) / TIME_SPANcxx . . $ `demos/gtk-demo/frames.c:30:9`!;
54
55 gtk_widget_queue_drawcxx . . $ gtk_widget_queue_draw(d7cf858254b37903). (widget);
56
57 return G_SOURCE_CONTINUEcxx . . $ `<external>/1856471541377536744/gmain.h:485:9`!;
58 }
59
60 static void
61 color_widget_snapshotcxx . . $ color_widget_snapshot(80012d1141bb3efa). (GtkWidgetcxx . . $ GtkWidget# *widget,
62 GtkSnapshotcxx . . $ GtkSnapshot# *snapshot)
63 {
64 ColorWidgetcxx . . $ ColorWidget# *color = (ColorWidgetcxx . . $ ColorWidget# *)widget;
65 float w, h;
66 GdkRGBAcxx . . $ GdkRGBA# c;
67
68 w = gtk_widget_get_widthcxx . . $ gtk_widget_get_width(9247ef2dc26c5426). (widget);
69 h = gtk_widget_get_heightcxx . . $ gtk_widget_get_height(9247ef2dc26c5426). (widget);
70
71 c.redcxx . . $ _GdkRGBA#red. = (1 - color->tcxx . . $ $anonymous_type_b39fec4da6b2c8db_0#t.) * color->color1cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color1..redcxx . . $ _GdkRGBA#red. + color->tcxx . . $ $anonymous_type_b39fec4da6b2c8db_0#t. * color->color2cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color2..redcxx . . $ _GdkRGBA#red.;
72 c.greencxx . . $ _GdkRGBA#green. = (1 - color->tcxx . . $ $anonymous_type_b39fec4da6b2c8db_0#t.) * color->color1cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color1..greencxx . . $ _GdkRGBA#green. + color->tcxx . . $ $anonymous_type_b39fec4da6b2c8db_0#t. * color->color2cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color2..greencxx . . $ _GdkRGBA#green.;
73 c.bluecxx . . $ _GdkRGBA#blue. = (1 - color->tcxx . . $ $anonymous_type_b39fec4da6b2c8db_0#t.) * color->color1cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color1..bluecxx . . $ _GdkRGBA#blue. + color->tcxx . . $ $anonymous_type_b39fec4da6b2c8db_0#t. * color->color2cxx . . $ $anonymous_type_b39fec4da6b2c8db_0#color2..bluecxx . . $ _GdkRGBA#blue.;
74 c.alphacxx . . $ _GdkRGBA#alpha. = 1;
75
76 gtk_snapshot_append_colorcxx . . $ gtk_snapshot_append_color(402330aed7850122). (snapshot, &c, &GRAPHENE_RECT_INITcxx . . $ `<external>/7539008420172022992/graphene-rect.h:50:9`! (0, 0, w, h));
77 }
78
79 static void
80 color_widget_initcxx . . $ color_widget_init(43a4d16b6dbcd5e). (ColorWidgetcxx . . $ ColorWidget# *color)
81 {
82 gtk_widget_add_tick_callbackcxx . . $ gtk_widget_add_tick_callback(358f9307fc320412). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (color), change_colorcxx . . $ change_color(d70983e0fefb11f)., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
83 gtk_widget_set_hexpandcxx . . $ gtk_widget_set_hexpand(81f145f668a0074f). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (color), TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!);
84 gtk_widget_set_vexpandcxx . . $ gtk_widget_set_vexpand(81f145f668a0074f). (GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (color), TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!);
85 }
86
87 static void
88 color_widget_class_initcxx . . $ color_widget_class_init(4f4d8d0d78fdc7e7). (ColorWidgetClasscxx . . $ ColorWidgetClass# *class)
89 {
90 GtkWidgetClasscxx . . $ GtkWidgetClass# *widget_class = GTK_WIDGET_CLASScxx . . $ `gtk/gtkwidget.h:45:9`! (class);
91
92 widget_class->snapshotcxx . . $ _GtkWidgetClass#snapshot. = color_widget_snapshotcxx . . $ color_widget_snapshot(80012d1141bb3efa).;
93 }
94
95 GtkWidgetcxx . . $ GtkWidget# *
96 color_widget_newcxx . . $ color_widget_new(2369ce5e9f2c7dfd). (void)
97 {
98 return g_object_newcxx . . $ g_object_new(8485fe61b4be4c78). (color_widget_get_typecxx . . $ color_widget_get_type(f708dce9a8856c70). (), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
99 }
100
101 static gbooleancxx . . $ gboolean#
102 update_fps_labelcxx . . $ update_fps_label(dedf1e9b1c614a07). (gpointercxx . . $ gpointer# data)
103 {
104 GtkWidgetcxx . . $ GtkWidget# *label = GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (data);
105 GdkFrameClockcxx . . $ GdkFrameClock# *frame_clock;
106
107 frame_clock = gtk_widget_get_frame_clockcxx . . $ gtk_widget_get_frame_clock(82b8f1b122c490a1). (label);
108
109 if (frame_clock)
110 {
111 char *fps;
112
113 fps = g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("%.2f fps", gdk_frame_clock_get_fpscxx . . $ gdk_frame_clock_get_fps(5c0d1f5e55ed06c8). (frame_clock));
114 gtk_label_set_labelcxx . . $ gtk_label_set_label(3d016a7109913fca). (GTK_LABELcxx . . $ `gtk/gtklabel.h:36:9`! (label), fps);
115 g_freecxx . . $ g_free(5d22bdacc48458e8). (fps);
116 }
117 else
118 gtk_label_set_labelcxx . . $ gtk_label_set_label(3d016a7109913fca). (GTK_LABELcxx . . $ `gtk/gtklabel.h:36:9`! (label), "");
119
120 return G_SOURCE_CONTINUEcxx . . $ `<external>/1856471541377536744/gmain.h:485:9`!;
121 }
122
123 static void
124 remove_idcxx . . $ remove_id(5d22bdacc48458e8). (gpointercxx . . $ gpointer# data)
125 {
126 guintcxx . . $ guint# id = GPOINTER_TO_UINTcxx . . $ `<external>/10505296616216143549/glibconfig.h:104:9`! (data);
127
128 g_source_removecxx . . $ g_source_remove(4c679297bf94b9eb). (id);
129 }
130
131 GtkWidgetcxx . . $ GtkWidget# *
132 do_framescxx . . $ do_frames(ef973e1b01680070). (GtkWidgetcxx . . $ GtkWidget# *do_widget)
133 {
134 static GtkWidgetcxx . . $ GtkWidget# *window = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
135
136 if (!window)
137 {
138 GtkBuildercxx . . $ GtkBuilder# *builder;
139 GtkWidgetcxx . . $ GtkWidget# *box;
140 GtkWidgetcxx . . $ GtkWidget# *label;
141 guintcxx . . $ guint# id;
142
143 builder = gtk_builder_new_from_resourcecxx . . $ gtk_builder_new_from_resource(11ae25fe414babe1). ("/frames/frames.ui");
144 window = GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (gtk_builder_get_object (builder, "window"));
145 g_object_add_weak_pointercxx . . $ g_object_add_weak_pointer(e222a8edb8030d7b). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (window), (gpointercxx . . $ gpointer# *)&window);
146 gtk_window_set_displaycxx . . $ gtk_window_set_display(fabf9475f6d378d0). (GTK_WINDOWcxx . . $ `gtk/gtkwindow.h:39:9`! (window),
147 gtk_widget_get_displaycxx . . $ gtk_widget_get_display(6423c64908d5796a). (do_widget));
148
149 label = GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (gtk_builder_get_object (builder, "fps"));
150 box = GTK_WIDGETcxx . . $ `gtk/gtkwidget.h:44:9`! (gtk_builder_get_object (builder, "box"));
151
152 gtk_box_appendcxx . . $ gtk_box_append(72f3a0256788ecaf). (GTK_BOXcxx . . $ `gtk/gtkbox.h:39:9`! (box), color_widget_newcxx . . $ color_widget_new(2369ce5e9f2c7dfd). ());
153
154 id = g_timeout_addcxx . . $ g_timeout_add(ec6d13059821d355). (500, update_fps_labelcxx . . $ update_fps_label(dedf1e9b1c614a07)., label);
155 g_object_set_data_fullcxx . . $ g_object_set_data_full(218df00be1d2a06c). (G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`! (label), "tick_cb",
156 GUINT_TO_POINTERcxx . . $ `<external>/10505296616216143549/glibconfig.h:107:9`! (id), remove_idcxx . . $ remove_id(5d22bdacc48458e8).);
157
158 g_object_unrefcxx . . $ g_object_unref(5d22bdacc48458e8). (builder);
159 }
160
161 if (!gtk_widget_get_visiblecxx . . $ gtk_widget_get_visible(9247ef2dc26c5426). (window))
162 gtk_widget_set_visiblecxx . . $ gtk_widget_set_visible(81f145f668a0074f). (window, TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!);
163 else
164 gtk_window_destroycxx . . $ gtk_window_destroy(f2417dd135ed86f3). (GTK_WINDOWcxx . . $ `gtk/gtkwindow.h:39:9`! (window));
165
166 return window;
167 }