Accepting request 722945 from home:StefanBruens:branches:graphics
Port to SDL2 OBS-URL: https://build.opensuse.org/request/show/722945 OBS-URL: https://build.opensuse.org/package/show/graphics/gegl?expand=0&rev=78
This commit is contained in:
parent
e2895a444b
commit
1fa7a2756e
82
0001-Extend-configure-checks-with-checks-for-SDL2.patch
Normal file
82
0001-Extend-configure-checks-with-checks-for-SDL2.patch
Normal file
@ -0,0 +1,82 @@
|
||||
From 825c0934a34a6627fe85f671a3086ca42ea4f73e Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
|
||||
Date: Sun, 4 Aug 2019 17:55:20 +0200
|
||||
Subject: [PATCH 1/3] Extend configure checks with checks for SDL2
|
||||
|
||||
---
|
||||
configure.ac | 34 +++++++++++++++++++++++++++++-----
|
||||
1 file changed, 29 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 974113404..6e42abd2a 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -57,6 +57,7 @@ m4_define([popplerglib_required_version], [0.71.0])
|
||||
m4_define([zlib_required_version], [1.2.0])
|
||||
m4_define([png_required_version], [1.6.0])
|
||||
m4_define([sdl_required_version], [1.2.0])
|
||||
+m4_define([sdl2_required_version], [2.0.5])
|
||||
m4_define([libtiff_required_version], [4.0.0])
|
||||
m4_define([webp_required_version], [0.5.0])
|
||||
m4_define([poly2tri-c_required_version], [0.0.0])
|
||||
@@ -948,14 +949,36 @@ AC_SUBST(OPENEXR_CFLAGS)
|
||||
AC_SUBST(OPENEXR_LIBS)
|
||||
|
||||
|
||||
-###############
|
||||
-# Check for SDL
|
||||
-###############
|
||||
+######################
|
||||
+# Check for SDL2 / SDL
|
||||
+######################
|
||||
|
||||
+AC_ARG_WITH(sdl, [ --without-sdl2 build without SDL2 support])
|
||||
AC_ARG_WITH(sdl, [ --without-sdl build without SDL support])
|
||||
|
||||
+have_sdl2="no"
|
||||
+if test "x$with_sdl2" != "xno"; then
|
||||
+ AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no)
|
||||
+ if test "$SDL2_CONFIG" = "no"; then
|
||||
+ have_sdl2="no (SDL2 library not found)"
|
||||
+ AC_MSG_RESULT([*** Check for SDL2 library failed.])
|
||||
+ else
|
||||
+ have_sdl2="yes"
|
||||
+ SDL2_CFLAGS=`$SDL2_CONFIG --cflags`
|
||||
+ SDL2_LIBS=`$SDL2_CONFIG --libs`
|
||||
+ fi
|
||||
+fi
|
||||
+
|
||||
+AM_CONDITIONAL(HAVE_SDL2, test "$have_sdl2" = "yes")
|
||||
+
|
||||
+AC_SUBST(SDL2_CFLAGS)
|
||||
+AC_SUBST(SDL2_LIBS)
|
||||
+
|
||||
have_sdl="no"
|
||||
-if test "x$with_sdl" != "xno"; then
|
||||
+if test "$have_sdl2" = "yes"; then
|
||||
+ AC_MSG_NOTICE([Skipping SDL check (SDL2 and SDL are exclusive)])
|
||||
+ have_sdl="no (skipped)"
|
||||
+elif test "x$with_sdl" != "xno"; then
|
||||
AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
|
||||
if test "$SDL_CONFIG" = "no"; then
|
||||
have_sdl="no (SDL library not found)"
|
||||
@@ -968,7 +991,7 @@ if test "x$with_sdl" != "xno"; then
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(HAVE_SDL, test "$have_sdl" = "yes")
|
||||
-
|
||||
+
|
||||
AC_SUBST(SDL_CFLAGS)
|
||||
AC_SUBST(SDL_LIBS)
|
||||
|
||||
@@ -1417,6 +1440,7 @@ Optional dependencies:
|
||||
PNG: $have_libpng
|
||||
OpenEXR: $have_openexr
|
||||
rsvg: $have_librsvg
|
||||
+ SDL2: $have_sdl2
|
||||
SDL: $have_sdl
|
||||
libraw: $have_libraw
|
||||
Jasper: $have_jasper
|
||||
--
|
||||
2.22.0
|
||||
|
263
0002-Port-sdl-display-to-SDL2.patch
Normal file
263
0002-Port-sdl-display-to-SDL2.patch
Normal file
@ -0,0 +1,263 @@
|
||||
From c07813452c658f1f441b104fbe836380a6ddd18d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
|
||||
Date: Sun, 4 Aug 2019 01:22:01 +0200
|
||||
Subject: [PATCH 2/3] Port sdl-display to SDL2
|
||||
|
||||
The SDL2 Video API is split into several orthogonal parts, see
|
||||
https://wiki.libsdl.org/MigrationGuide#Video.
|
||||
|
||||
Fixes half of #184
|
||||
---
|
||||
operations/common/display.c | 1 +
|
||||
operations/external/Makefile.am | 6 +
|
||||
operations/external/sdl2-display.c | 209 +++++++++++++++++++++++++++++
|
||||
3 files changed, 216 insertions(+)
|
||||
create mode 100644 operations/external/sdl2-display.c
|
||||
|
||||
diff --git a/operations/common/display.c b/operations/common/display.c
|
||||
index 826ae4caa..9e06f1eb5 100644
|
||||
--- a/operations/common/display.c
|
||||
+++ b/operations/common/display.c
|
||||
@@ -60,6 +60,7 @@ set_display_handler (GeglOperation *operation)
|
||||
GeglOp *self = GEGL_OP (operation);
|
||||
const gchar *known_handlers[] = {"gegl-gtk3:display",
|
||||
"gegl-gtk2:display",
|
||||
+ "gegl:sdl2-display",
|
||||
"gegl:sdl-display"};
|
||||
char *handler = NULL;
|
||||
gchar **operations = NULL;
|
||||
diff --git a/operations/external/Makefile.am b/operations/external/Makefile.am
|
||||
index 498ffb062..719698401 100644
|
||||
--- a/operations/external/Makefile.am
|
||||
+++ b/operations/external/Makefile.am
|
||||
@@ -81,6 +81,12 @@ exr_save_la_LIBADD = $(op_libs) $(OPENEXR_LIBS)
|
||||
exr_save_la_CXXFLAGS = $(AM_CFLAGS) $(OPENEXR_CFLAGS)
|
||||
endif
|
||||
|
||||
+if HAVE_SDL2
|
||||
+ops += sdl2-display.la
|
||||
+sdl2_display_la_LIBADD = $(op_libs) $(SDL2_LIBS)
|
||||
+sdl2_display_la_CFLAGS = $(AM_CFLAGS) $(SDL2_CFLAGS)
|
||||
+endif
|
||||
+
|
||||
if HAVE_SDL
|
||||
ops += sdl-display.la
|
||||
sdl_display_la_LIBADD = $(op_libs) $(SDL_LIBS)
|
||||
diff --git a/operations/external/sdl2-display.c b/operations/external/sdl2-display.c
|
||||
new file mode 100644
|
||||
index 000000000..a3bab50a5
|
||||
--- /dev/null
|
||||
+++ b/operations/external/sdl2-display.c
|
||||
@@ -0,0 +1,209 @@
|
||||
+/* This file is an image processing operation for GEGL
|
||||
+ *
|
||||
+ * GEGL is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 3 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * GEGL is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
|
||||
+ *
|
||||
+ * Copyright 2019 Stefan Brüns <stefan.bruens@rwth-aachen.de>
|
||||
+ *
|
||||
+ * Based on sdl-display.c:
|
||||
+ * Copyright 2006 Øyvind Kolås <pippin@gimp.org>
|
||||
+ */
|
||||
+
|
||||
+#include "config.h"
|
||||
+#include <glib/gi18n-lib.h>
|
||||
+
|
||||
+
|
||||
+#ifdef GEGL_PROPERTIES
|
||||
+
|
||||
+property_string (window_title, _("Window title"), "window_title")
|
||||
+ description (_("Title to be given to output window"))
|
||||
+#else
|
||||
+
|
||||
+#define GEGL_OP_SINK
|
||||
+#define GEGL_OP_NAME sdl2_display
|
||||
+#define GEGL_OP_C_SOURCE sdl2-display.c
|
||||
+
|
||||
+#include "gegl-op.h"
|
||||
+#include <SDL.h>
|
||||
+
|
||||
+typedef struct {
|
||||
+ SDL_Window *window;
|
||||
+ SDL_Renderer *renderer;
|
||||
+ SDL_Texture *texture;
|
||||
+ SDL_Surface *screen;
|
||||
+ gint width;
|
||||
+ gint height;
|
||||
+} SDLState;
|
||||
+
|
||||
+static void
|
||||
+init_sdl (void)
|
||||
+{
|
||||
+ static int inited = 0;
|
||||
+
|
||||
+ if (!inited)
|
||||
+ {
|
||||
+ inited = 1;
|
||||
+
|
||||
+ if (SDL_Init (SDL_INIT_VIDEO) < 0)
|
||||
+ {
|
||||
+ fprintf (stderr, "Unable to init SDL: %s\n", SDL_GetError ());
|
||||
+ return;
|
||||
+ }
|
||||
+ atexit (SDL_Quit);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static gboolean idle (gpointer data)
|
||||
+{
|
||||
+ SDL_Event event;
|
||||
+ while (SDL_PollEvent (&event))
|
||||
+ {
|
||||
+ switch (event.type)
|
||||
+ {
|
||||
+ case SDL_QUIT:
|
||||
+ exit (0);
|
||||
+ }
|
||||
+ }
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+static guint handle = 0;
|
||||
+
|
||||
+static gboolean
|
||||
+process (GeglOperation *operation,
|
||||
+ GeglBuffer *input,
|
||||
+ const GeglRectangle *result,
|
||||
+ gint level)
|
||||
+{
|
||||
+ GeglProperties *o = GEGL_PROPERTIES (operation);
|
||||
+ SDLState *state = NULL;
|
||||
+
|
||||
+ if(!o->user_data)
|
||||
+ o->user_data = g_new0 (SDLState, 1);
|
||||
+ state = o->user_data;
|
||||
+
|
||||
+ init_sdl ();
|
||||
+
|
||||
+ if (!handle)
|
||||
+ handle = g_timeout_add (500, idle, NULL);
|
||||
+
|
||||
+ if (!state->window ||
|
||||
+ state->width != result->width ||
|
||||
+ state->height != result->height)
|
||||
+ {
|
||||
+
|
||||
+ if (state->window)
|
||||
+ {
|
||||
+ SDL_SetWindowSize (state->window,
|
||||
+ result->width, result->height);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ if (SDL_CreateWindowAndRenderer (result->width,
|
||||
+ result->height, 0,
|
||||
+ &state->window, &state->renderer))
|
||||
+ {
|
||||
+ fprintf (stderr, "Unable to create window: %s\n",
|
||||
+ SDL_GetError ());
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ SDL_FreeSurface (state->screen);
|
||||
+ state->screen = SDL_CreateRGBSurfaceWithFormat (0,
|
||||
+ result->width, result->height, 32, SDL_PIXELFORMAT_RGBA32);
|
||||
+ if (!state->screen)
|
||||
+ {
|
||||
+ fprintf (stderr, "Unable to create surface: %s\n",
|
||||
+ SDL_GetError ());
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (state->texture)
|
||||
+ SDL_DestroyTexture (state->texture);
|
||||
+ state->texture = SDL_CreateTextureFromSurface (state->renderer, state->screen);
|
||||
+ if (!state->texture)
|
||||
+ {
|
||||
+ fprintf (stderr, "Unable to create texture: %s\n",
|
||||
+ SDL_GetError ());
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ state->width = result->width ;
|
||||
+ state->height = result->height;
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * There seems to be a valid faster path to the SDL desired display format
|
||||
+ * in B'G'R'A, perhaps babl should have been able to figure this out ito?
|
||||
+ *
|
||||
+ */
|
||||
+ gegl_buffer_get (input,
|
||||
+ NULL,
|
||||
+ 1.0,
|
||||
+ babl_format_new (babl_model ("R'G'B'A"),
|
||||
+ babl_type ("u8"),
|
||||
+ babl_component ("B'"),
|
||||
+ babl_component ("G'"),
|
||||
+ babl_component ("R'"),
|
||||
+ babl_component ("A"),
|
||||
+ NULL),
|
||||
+ state->screen->pixels, GEGL_AUTO_ROWSTRIDE,
|
||||
+ GEGL_ABYSS_NONE);
|
||||
+
|
||||
+ SDL_UpdateTexture (state->texture, NULL, state->screen->pixels, state->screen->pitch);
|
||||
+
|
||||
+ SDL_RenderClear (state->renderer);
|
||||
+ SDL_RenderCopy (state->renderer, state->texture, NULL, NULL);
|
||||
+ SDL_RenderPresent (state->renderer);
|
||||
+ SDL_SetWindowTitle (state->window, o->window_title);
|
||||
+
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+finalize (GObject *object)
|
||||
+{
|
||||
+ GeglProperties *o = GEGL_PROPERTIES (object);
|
||||
+
|
||||
+ g_clear_pointer (&o->user_data, g_free);
|
||||
+
|
||||
+ G_OBJECT_CLASS (gegl_op_parent_class)->finalize (object);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+gegl_op_class_init (GeglOpClass *klass)
|
||||
+{
|
||||
+ GObjectClass *object_class;
|
||||
+ GeglOperationClass *operation_class;
|
||||
+ GeglOperationSinkClass *sink_class;
|
||||
+
|
||||
+ object_class = G_OBJECT_CLASS (klass);
|
||||
+ operation_class = GEGL_OPERATION_CLASS (klass);
|
||||
+ sink_class = GEGL_OPERATION_SINK_CLASS (klass);
|
||||
+
|
||||
+ object_class->finalize = finalize;
|
||||
+
|
||||
+ sink_class->process = process;
|
||||
+ sink_class->needs_full = TRUE;
|
||||
+
|
||||
+ gegl_operation_class_set_keys (operation_class,
|
||||
+ "name", "gegl:sdl2-display",
|
||||
+ "title", _("SDL2 Display"),
|
||||
+ "categories", "display",
|
||||
+ "description",
|
||||
+ _("Displays the input buffer in an SDL2 window (restricted to one"
|
||||
+ " display op/process, due to SDL2 implementation issues)."),
|
||||
+ NULL);
|
||||
+}
|
||||
+#endif
|
||||
--
|
||||
2.22.0
|
||||
|
226
0003-Port-sdl-draw-example-to-SDL2.patch
Normal file
226
0003-Port-sdl-draw-example-to-SDL2.patch
Normal file
@ -0,0 +1,226 @@
|
||||
From e93eac9f1752bee533eb4222231946bd5be56359 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
|
||||
Date: Sun, 4 Aug 2019 17:52:55 +0200
|
||||
Subject: [PATCH 3/3] Port sdl-draw example to SDL2
|
||||
|
||||
---
|
||||
examples/Makefile.am | 7 ++--
|
||||
examples/sdl-draw.c | 85 +++++++++++++++++++++++++-------------------
|
||||
2 files changed, 51 insertions(+), 41 deletions(-)
|
||||
|
||||
diff --git a/examples/Makefile.am b/examples/Makefile.am
|
||||
index eae72ae4f..f45b857aa 100644
|
||||
--- a/examples/Makefile.am
|
||||
+++ b/examples/Makefile.am
|
||||
@@ -50,12 +50,11 @@ geglbuffer_add_image_SOURCES = geglbuffer-add-image.c
|
||||
geglbuffer_clock_SOURCES = geglbuffer-clock.c
|
||||
hello_world_SOURCES = hello-world.c
|
||||
|
||||
-if HAVE_SDL
|
||||
+if HAVE_SDL2
|
||||
noinst_PROGRAMS += sdl-draw
|
||||
sdl_draw_SOURCES = sdl-draw.c
|
||||
-sdl_draw_LDADD = $(SDL_LIBS)
|
||||
-sdl_draw_CFLAGS = $(AM_CFLAGS) $(SDL_CFLAGS)
|
||||
-
|
||||
+sdl_draw_LDADD = $(SDL2_LIBS)
|
||||
+sdl_draw_CFLAGS = $(AM_CFLAGS) $(SDL2_CFLAGS)
|
||||
endif
|
||||
|
||||
if HAVE_GEXIV2
|
||||
diff --git a/examples/sdl-draw.c b/examples/sdl-draw.c
|
||||
index 0ff635192..8d061dfe3 100644
|
||||
--- a/examples/sdl-draw.c
|
||||
+++ b/examples/sdl-draw.c
|
||||
@@ -5,7 +5,10 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
- SDL_Surface *main_window;
|
||||
+ SDL_Window *window;
|
||||
+ SDL_Renderer *renderer;
|
||||
+ SDL_Surface *surface;
|
||||
+ SDL_Texture *texture;
|
||||
GeglBuffer *paint_buffer;
|
||||
GeglNode *graph;
|
||||
GeglNode *output_node;
|
||||
@@ -15,8 +18,8 @@ typedef struct
|
||||
int last_y;
|
||||
} MainContext;
|
||||
|
||||
-int run_main_loop (SDL_Surface *main_window, MainContext *context);
|
||||
-void init_main_context (SDL_Surface *main_window, MainContext *context);
|
||||
+int run_main_loop (MainContext *context);
|
||||
+void init_main_context (MainContext *context);
|
||||
void destroy_main_context (MainContext *context);
|
||||
void draw_circle (GeglBuffer *buffer, int x, int y, float r);
|
||||
|
||||
@@ -25,7 +28,6 @@ const Babl *sdl_format = NULL;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int retval;
|
||||
- SDL_Surface *main_window;
|
||||
MainContext context = {0, };
|
||||
|
||||
if((retval = SDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMER)) > 0)
|
||||
@@ -34,15 +36,31 @@ int main(int argc, char *argv[])
|
||||
return retval;
|
||||
}
|
||||
|
||||
- main_window = SDL_SetVideoMode (640, 480, 24, SDL_SWSURFACE);
|
||||
-
|
||||
- if (!main_window)
|
||||
+ if (SDL_CreateWindowAndRenderer (640, 480, 0,
|
||||
+ &context.window, &context.renderer))
|
||||
{
|
||||
printf("SDL failed to create a window\n");
|
||||
SDL_Quit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
+ context.surface = SDL_CreateRGBSurfaceWithFormat (0,
|
||||
+ 640, 480, 24, SDL_PIXELFORMAT_RGB24);
|
||||
+ if (!context.surface)
|
||||
+ {
|
||||
+ fprintf (stderr, "Unable to create surface: %s\n",
|
||||
+ SDL_GetError ());
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ context.texture = SDL_CreateTextureFromSurface (context.renderer, context.surface);
|
||||
+ if (!context.surface)
|
||||
+ {
|
||||
+ fprintf (stderr, "Unable to create texture: %s\n",
|
||||
+ SDL_GetError ());
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
gegl_init (NULL, NULL);
|
||||
|
||||
/* We don't have a native format that matches SDL, but we can use
|
||||
@@ -56,9 +74,9 @@ int main(int argc, char *argv[])
|
||||
babl_component ("R'"),
|
||||
NULL);
|
||||
|
||||
- init_main_context (main_window, &context);
|
||||
+ init_main_context (&context);
|
||||
|
||||
- run_main_loop (main_window, &context);
|
||||
+ run_main_loop (&context);
|
||||
|
||||
destroy_main_context (&context);
|
||||
|
||||
@@ -69,13 +87,12 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* init_main_context:
|
||||
- * @main_window: The output window.
|
||||
* @context: The context.
|
||||
*
|
||||
* Initialize the main context object that will hold our graph.
|
||||
*/
|
||||
void
|
||||
-init_main_context (SDL_Surface *main_window, MainContext *context)
|
||||
+init_main_context (MainContext *context)
|
||||
{
|
||||
GeglNode *ptn = gegl_node_new ();
|
||||
GeglNode *background_node, *over, *buffer_src;
|
||||
@@ -111,7 +128,6 @@ init_main_context (SDL_Surface *main_window, MainContext *context)
|
||||
context->output_node = over;
|
||||
context->paint_buffer = paint_buffer;
|
||||
|
||||
- context->main_window = main_window;
|
||||
}
|
||||
|
||||
/* destroy_main_context:
|
||||
@@ -125,6 +141,9 @@ destroy_main_context (MainContext *context)
|
||||
g_object_unref (context->graph);
|
||||
g_object_unref (context->paint_buffer);
|
||||
|
||||
+ SDL_FreeSurface (context->surface);
|
||||
+ SDL_DestroyTexture (context->texture);
|
||||
+ SDL_DestroyRenderer (context->renderer);
|
||||
|
||||
context->graph = NULL;
|
||||
context->output_node = NULL;
|
||||
@@ -140,28 +159,29 @@ destroy_main_context (MainContext *context)
|
||||
* to the sdl window.
|
||||
*/
|
||||
static void
|
||||
-invalidate_signal (GeglNode *node, GeglRectangle *rect, SDL_Surface *main_window)
|
||||
+invalidate_signal (GeglNode *node, GeglRectangle *rect, MainContext *context)
|
||||
{
|
||||
- GeglRectangle output_rect = {0, 0, main_window->w, main_window->h};
|
||||
+ SDL_Surface *surface = context->surface;
|
||||
+ GeglRectangle output_rect = {0, 0, surface->w, surface->h};
|
||||
guchar *blit_origin = NULL;
|
||||
|
||||
- SDL_LockSurface (main_window);
|
||||
-
|
||||
gegl_rectangle_intersect (&output_rect, &output_rect, rect);
|
||||
|
||||
- blit_origin = (guchar *)main_window->pixels + (output_rect.x * 3 + output_rect.y * main_window->pitch);
|
||||
+ blit_origin = (guchar *)surface->pixels + (output_rect.x * surface->format->BytesPerPixel + output_rect.y * surface->pitch);
|
||||
|
||||
gegl_node_blit (node,
|
||||
1.0,
|
||||
&output_rect,
|
||||
sdl_format,
|
||||
blit_origin,
|
||||
- main_window->pitch,
|
||||
+ surface->pitch,
|
||||
0);
|
||||
|
||||
- SDL_UnlockSurface (main_window);
|
||||
+ SDL_UpdateTexture (context->texture, NULL, surface->pixels, surface->pitch);
|
||||
|
||||
- SDL_UpdateRect (main_window, output_rect.x, output_rect.y, output_rect.width, output_rect.height);
|
||||
+ SDL_RenderClear (context->renderer);
|
||||
+ SDL_RenderCopy (context->renderer, context->texture, NULL, NULL);
|
||||
+ SDL_RenderPresent (context->renderer);
|
||||
}
|
||||
|
||||
/* draw_circle:
|
||||
@@ -247,31 +267,22 @@ draw_circle (GeglBuffer *buffer, int x, int y, float r)
|
||||
}
|
||||
|
||||
int
|
||||
-run_main_loop (SDL_Surface *main_window,
|
||||
- MainContext *context)
|
||||
+run_main_loop (MainContext *context)
|
||||
{
|
||||
- gegl_buffer_set_extent (context->paint_buffer, GEGL_RECTANGLE (0, 0, main_window->w, main_window->h));
|
||||
-
|
||||
- SDL_LockSurface (main_window);
|
||||
-
|
||||
- gegl_node_blit (context->output_node,
|
||||
- 1.0,
|
||||
- GEGL_RECTANGLE (0, 0, main_window->w, main_window->h),
|
||||
- sdl_format,
|
||||
- main_window->pixels,
|
||||
- main_window->pitch,
|
||||
- 0);
|
||||
+ SDL_Surface *surface = context->surface;
|
||||
+ GeglRectangle initial_rect = {0, 0, surface->w, surface->h};
|
||||
|
||||
- SDL_UnlockSurface (main_window);
|
||||
+ gegl_buffer_set_extent (context->paint_buffer, GEGL_RECTANGLE (0, 0, surface->w, surface->h));
|
||||
|
||||
- SDL_UpdateRect (main_window, 0, 0, 0, 0);
|
||||
+ /* initial buffers update */
|
||||
+ invalidate_signal (context->output_node, &initial_rect, context);
|
||||
|
||||
- /* This signal will trigger to update main_window when the output node's
|
||||
+ /* This signal will trigger to update the surface when the output node's
|
||||
* contents change. Updating instantly is very inefficient but is good
|
||||
* enough for this example.
|
||||
*/
|
||||
g_signal_connect (context->output_node, "invalidated",
|
||||
- G_CALLBACK (invalidate_signal), main_window);
|
||||
+ G_CALLBACK (invalidate_signal), context);
|
||||
|
||||
while(1)
|
||||
{
|
||||
--
|
||||
2.22.0
|
||||
|
@ -1,3 +1,11 @@
|
||||
-------------------------------------------------------------------
|
||||
Sun Aug 4 16:56:39 UTC 2019 - Stefan Brüns <stefan.bruens@rwth-aachen.de>
|
||||
|
||||
- Port sdl-display operation to SDL2: glgo#GNOME/gegl!184.
|
||||
* 0001-Extend-configure-checks-with-checks-for-SDL2.patch
|
||||
* 0002-Port-sdl-display-to-SDL2.patch
|
||||
* 0003-Port-sdl-draw-example-to-SDL2.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Aug 3 19:08:48 UTC 2019 - Stefan Brüns <stefan.bruens@rwth-aachen.de>
|
||||
|
||||
|
10
gegl.spec
10
gegl.spec
@ -27,11 +27,18 @@ Source0: https://download.gimp.org/pub/gegl/0.4/%{name}-%{version}.tar.bz
|
||||
Source99: baselibs.conf
|
||||
# PATCH-FIX-OPENSUSE -- install bundled documentation even if enscript is not installed
|
||||
Patch0: fix_doc_installation.patch
|
||||
# PATCH-FIX-UPSTREAM -- glgo#GNOME/gegl!184 1/3
|
||||
Patch1: 0001-Extend-configure-checks-with-checks-for-SDL2.patch
|
||||
# PATCH-FIX-UPSTREAM -- glgo#GNOME/gegl!184 2/3
|
||||
Patch2: 0002-Port-sdl-display-to-SDL2.patch
|
||||
# PATCH-FIX-UPSTREAM -- glgo#GNOME/gegl!184 3/3
|
||||
Patch3: 0003-Port-sdl-draw-example-to-SDL2.patch
|
||||
|
||||
BuildRequires: ImageMagick
|
||||
BuildRequires: SDL-devel >= 1.2.0
|
||||
BuildRequires: autoconf
|
||||
BuildRequires: gcc-c++
|
||||
BuildRequires: gobject-introspection-devel >= 1.32.0
|
||||
BuildRequires: libSDL2-devel
|
||||
BuildRequires: libjpeg-devel
|
||||
BuildRequires: libspiro-devel
|
||||
BuildRequires: libstdc++-devel
|
||||
@ -144,6 +151,7 @@ input and output.
|
||||
%autosetup -p1
|
||||
|
||||
%build
|
||||
./autogen.sh
|
||||
%configure \
|
||||
--disable-static \
|
||||
%{nil}
|
||||
|
Loading…
Reference in New Issue
Block a user