[gtk: 13/15] gtk-demo: Add a shader paintable to the fishbowl
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 13/15] gtk-demo: Add a shader paintable to the fishbowl
- Date: Tue, 29 Sep 2020 08:30:50 +0000 (UTC)
commit e76cb3e1e44b1bdc86864ab0a6992055d4bf1b9e
Author: Alexander Larsson <alexl redhat com>
Date: Tue Sep 29 09:36:10 2020 +0200
gtk-demo: Add a shader paintable to the fishbowl
This gets around 500 instances at 60fps on my system.
demos/gtk-demo/fishbowl.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
---
diff --git a/demos/gtk-demo/fishbowl.c b/demos/gtk-demo/fishbowl.c
index 40c8203726..659318b7cd 100644
--- a/demos/gtk-demo/fishbowl.c
+++ b/demos/gtk-demo/fishbowl.c
@@ -9,6 +9,7 @@
#include "gtkfishbowl.h"
#include "gtkgears.h"
+#include "gskshaderpaintable.h"
const char *const css =
".blurred-button {"
@@ -149,6 +150,38 @@ 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;
+ static GskGLShader *cog_shader = NULL;
+ GdkPaintable *paintable;
+
+ if (cog_shader == NULL)
+ cog_shader = gsk_gl_shader_new_from_resource ("/gltransition/cogs2.glsl");
+ paintable = gsk_shader_paintable_new (g_object_ref (cog_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 +218,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]