[gtk/glshader-paintable: 4/4] gtk-demo: Add a shader paintable to the fishbowl
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/glshader-paintable: 4/4] gtk-demo: Add a shader paintable to the fishbowl
- Date: Fri, 25 Sep 2020 04:28:52 +0000 (UTC)
commit 4d4540d6fadb16e03ad80aae12f96d41b83108d8
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Sep 24 21:15:48 2020 -0400
gtk-demo: Add a shader paintable to the fishbowl
This gets around 500 instances at 60fps on my system.
demos/gtk-demo/fishbowl.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
---
diff --git a/demos/gtk-demo/fishbowl.c b/demos/gtk-demo/fishbowl.c
index 40c8203726..a24a1a3939 100644
--- a/demos/gtk-demo/fishbowl.c
+++ b/demos/gtk-demo/fishbowl.c
@@ -149,6 +149,37 @@ create_switch (void)
return w;
}
+static gboolean
+update_paintable (GtkWidget *widget,
+ GdkFrameClock *frame_clock,
+ gpointer user_data)
+{
+ GskShaderPaintable *paintable;
+ gint64 frame_time;
+
+ paintable = GSK_SHADER_PAINTABLE (gtk_picture_get_paintable (GTK_PICTURE (widget)));
+ frame_time = gdk_frame_clock_get_frame_time (frame_clock);
+ gsk_shader_paintable_update_time (paintable, 0, frame_time);
+
+ return G_SOURCE_CONTINUE;
+}
+
+static GtkWidget *
+create_cogs (void)
+{
+ GtkWidget *picture;
+ GskGLShader *shader;
+ GdkPaintable *paintable;
+
+ shader = gsk_gl_shader_new_from_resource ("/gltransition/cogs2.glsl");
+ paintable = gsk_shader_paintable_new (shader, NULL);
+ picture = gtk_picture_new_for_paintable (paintable);
+ gtk_widget_set_size_request (picture, 150, 75);
+ gtk_widget_add_tick_callback (picture, update_paintable, NULL, NULL);
+
+ return picture;
+}
+
static void
mapped (GtkWidget *w)
{
@@ -185,6 +216,7 @@ static const struct {
{ "Gears", create_gears },
{ "Switch", create_switch },
{ "Menubutton", create_menu_button },
+ { "Shader", create_cogs },
};
static int selected_widget_type = -1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]