[gtk/glshader-paintable: 3/3] 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: 3/3] gtk-demo: Add a shader paintable to the fishbowl
- Date: Fri, 25 Sep 2020 02:27:12 +0000 (UTC)
commit 9c00609d52153fa46a97aa543127cadcd6991ea1
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 | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
---
diff --git a/demos/gtk-demo/fishbowl.c b/demos/gtk-demo/fishbowl.c
index 40c8203726..1a69e31a87 100644
--- a/demos/gtk-demo/fishbowl.c
+++ b/demos/gtk-demo/fishbowl.c
@@ -149,6 +149,42 @@ create_switch (void)
return w;
}
+static void
+picture_mapped (GtkWidget *picture,
+ GskShaderPaintable *paintable)
+{
+ GskGLShader *shader;
+ int idx;
+ GdkFrameClock *frame_clock;
+
+ shader = gsk_shader_paintable_get_shader (paintable);
+ idx = gsk_gl_shader_find_uniform_by_name (shader, "iTime");
+ frame_clock = gtk_widget_get_frame_clock (picture);
+
+ gsk_shader_paintable_set_frame_clock (paintable, frame_clock,idx);
+}
+
+static GtkWidget *
+create_cogs (void)
+{
+ GtkWidget *picture;
+ GskGLShader *shader;
+ int size;
+ GdkPaintable *paintable;
+
+ shader = gsk_gl_shader_new_from_resource ("/gltransition/cogs2.glsl");
+
+ size = gsk_gl_shader_get_uniforms_size (shader);
+ paintable = gsk_shader_paintable_new (shader, g_bytes_new_take (g_new0 (guchar, size), size));
+
+ picture = gtk_picture_new_for_paintable (paintable);
+ gtk_widget_set_size_request (picture, 150, 75);
+
+ g_signal_connect (picture, "map", G_CALLBACK (picture_mapped), paintable);
+
+ return picture;
+}
+
static void
mapped (GtkWidget *w)
{
@@ -185,6 +221,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]