This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 951e4bf59ad725f05fce1600e8da2ca8f4a8f8c0 (commit) via ddbd27fd085cc515d61fdae1a159922090eb327b (commit) from 3a66b0d92c78955b31e8b825f3b2049ffdf3487a (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/951e4bf59ad725f05fce1600e8da2ca8f4a8f...
commit 951e4bf59ad725f05fce1600e8da2ca8f4a8f8c0 Author: Cyril Hrubis metan@ucw.cz Date: Thu Dec 20 13:46:29 2012 +0100
demos: spiv: Move image listing code into separate file.
diff --git a/demos/spiv/Makefile b/demos/spiv/Makefile index f533179..95e7560 100644 --- a/demos/spiv/Makefile +++ b/demos/spiv/Makefile @@ -8,7 +8,7 @@ LDLIBS+=-lrt `$(TOPDIR)/gfxprim-config --libs --libs-backends`
APPS=spiv
-spiv: cpu_timer.o image_cache.o +spiv: cpu_timer.o image_cache.o image_list.o
include $(TOPDIR)/pre.mk include $(TOPDIR)/app.mk diff --git a/demos/spiv/image_list.c b/demos/spiv/image_list.c new file mode 100644 index 0000000..390275f --- /dev/null +++ b/demos/spiv/image_list.c @@ -0,0 +1,110 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim 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 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim 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 gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +#include <stdlib.h> + +#include <core/GP_Debug.h> + +#include "image_list.h" + +struct image_list { + /* list we got from the app */ + const char **args; + unsigned int cur_arg; + unsigned int max_arg; + + /* path to the currently loaded image */ + char path[1024]; + int path_loaded:1; +}; + +static void next_img(struct image_list *self) +{ + if (++self->cur_arg == self->max_arg) + self->cur_arg = 0; + + self->path_loaded = 0; +} + +static void prev_img(struct image_list *self) +{ + if (self->cur_arg == 0) + self->cur_arg = self->max_arg - 1; + else + self->cur_arg--; + + self->path_loaded = 0; +} + +static void load_path(struct image_list *self) +{ + snprintf(self->path, sizeof(self->path), "%s", self->args[self->cur_arg]); + + self->path_loaded = 1; +} + +const char *image_list_move(struct image_list *self, int direction) +{ + GP_DEBUG(2, "Moving list by %i", direction); + + int i; + + for (i = 0; i < direction; i++) + next_img(self); + + for (i = 0; i > direction; i--) + prev_img(self); + + return image_list_img_path(self); +} + +struct image_list *image_list_create(const char *args[]) +{ + struct image_list *self; + + GP_DEBUG(1, "Creating image list"); + + self = malloc(sizeof(struct image_list)); + + if (self == NULL) + return NULL; + + self->args = args; + self->cur_arg = 0; + + self->path_loaded = 0; + + self->max_arg = 0; + while (args[++self->max_arg] != NULL); + + return self; +} + +const char *image_list_img_path(struct image_list *self) +{ + if (!self->path_loaded) + load_path(self); + + GP_DEBUG(2, "Returning path '%s'", self->path); + + return self->path; +} diff --git a/demos/spiv/image_list.h b/demos/spiv/image_list.h new file mode 100644 index 0000000..e7b299a --- /dev/null +++ b/demos/spiv/image_list.h @@ -0,0 +1,50 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim 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 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim 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 gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + + /* + + Image list. + + */ + +#ifndef __IMAGE_LIST_H__ +#define __IMAGE_LIST_H__ + +struct image_list; + +/* + * Takes NULL-terminated array of paths as parameter + */ +struct image_list *image_list_create(const char *args[]); + +/* + * Returns path to the current image. + */ +const char *image_list_img_path(struct image_list *self); + +/* + * Moves the current image direction images and returns pointer to current + * path. + */ +const char *image_list_move(struct image_list *self, int direction); + +#endif /* __IMAGE_LIST_H__ */ diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 7c3dd20..82a8e75 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -37,6 +37,7 @@ #include <input/GP_InputDriverLinux.h>
#include "image_cache.h" +#include "image_list.h" #include "cpu_timer.h"
static GP_Pixel black_pixel; @@ -325,7 +326,7 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size cpu_timer_stop(&timer); } -// img->gamma = GP_GammaAcquire(img->pixel_type, 2.2); +// img->gamma = GP_GammaAcquire(img->pixel_type, 0.45);
cpu_timer_start(&timer, "Resampling"); callback.priv = "Resampling Image"; @@ -637,7 +638,7 @@ int main(int argc, char *argv[]) int opt, debug_level = 0; int shift_flag; GP_PixelType emul_type = GP_PIXEL_UNKNOWN; - + struct loader_params params = { .img_path = NULL, @@ -730,21 +731,16 @@ int main(int argc, char *argv[]) GP_Fill(context, black_pixel); GP_BackendFlip(backend);
- int argf = optind; - int argn = argf; + + struct image_list *list = image_list_create((const char**)argv + optind);
params.show_progress_once = 1; - show_image(¶ms, argv[argf]); + show_image(¶ms, image_list_img_path(list)); for (;;) { /* wait for event or a timeout */ - if (wait_for_event(sleep_sec * 1000)) { - argn++; - if (argn >= argc) - argn = argf; - - show_image(¶ms, argv[argn]); - } + if (wait_for_event(sleep_sec * 1000)) + show_image(¶ms, image_list_move(list, 1));
/* Read and parse events */ GP_Event ev; @@ -809,7 +805,7 @@ int main(int argc, char *argv[]) }
params.show_progress_once = 1; - show_image(¶ms, argv[argn]); + show_image(¶ms, image_list_img_path(list)); break; case GP_KEY_LEFT_BRACE: if (params.resampling_method == 0) @@ -826,13 +822,13 @@ int main(int argc, char *argv[]) } params.show_progress_once = 1; - show_image(¶ms, argv[argn]); + show_image(¶ms, image_list_img_path(list)); break; case GP_KEY_L: params.use_low_pass = !params.use_low_pass; params.show_progress_once = 1; - show_image(¶ms, argv[argn]); + show_image(¶ms, image_list_img_path(list)); break; case GP_KEY_D: image_cache_drop(params.img_resized_cache); @@ -847,45 +843,26 @@ int main(int argc, char *argv[]) return 0; break; case GP_KEY_PAGE_UP: - argn+=10; - //TODO - if (argn >= argc) - argn = argf; - params.show_progress_once = 1; - show_image(¶ms, argv[argn]); + show_image(¶ms, image_list_move(list, 10)); break; case GP_KEY_PAGE_DOWN: - argn-=10; - //TODO - if (argn < argf) - argn = argc - 1 ; - params.show_progress_once = 1; - show_image(¶ms, argv[argn]); + show_image(¶ms, image_list_move(list, -10)); break; next: case GP_KEY_RIGHT: case GP_KEY_UP: case GP_KEY_SPACE: - argn++; - if (argn >= argc) - argn = argf; - params.show_progress_once = 1; - show_image(¶ms, argv[argn]); + show_image(¶ms, image_list_move(list, 1)); break; prev: case GP_KEY_BACKSPACE: case GP_KEY_LEFT: case GP_KEY_DOWN: - argn--; - - if (argn < argf) - argn = argc - 1; - params.show_progress_once = 1; - show_image(¶ms, argv[argn]); + show_image(¶ms, image_list_move(list, -1)); break; case GP_KEY_1: resize_backend(¶ms, 1, shift_flag);
http://repo.or.cz/w/gfxprim.git/commit/ddbd27fd085cc515d61fdae1a159922090eb3...
commit ddbd27fd085cc515d61fdae1a159922090eb327b Author: Cyril Hrubis metan@ucw.cz Date: Thu Dec 20 13:16:51 2012 +0100
build: configure: The -lXext should be in LDFLAGS.
diff --git a/configure b/configure index a13f914..db5733f 100755 --- a/configure +++ b/configure @@ -255,7 +255,7 @@ if __name__ == '__main__': [header_exists, "X11/Xlib.h"], "", "-lX11", ["backends"]], ["X_SHM", "MIT-SHM X Extension", - [header_exists, "X11/extensions/XShm.h"], "-lXext", "", ["backends"]], + [header_exists, "X11/extensions/XShm.h"], "", "-lXext", ["backends"]], ["freetype", "A high-quality and portable font engine", [header_exists, "ft2build.h"], "", "`freetype-config --libs`", ["core"]],
-----------------------------------------------------------------------
Summary of changes: configure | 2 +- demos/spiv/Makefile | 2 +- .../framework/tst_msg.c => demos/spiv/image_list.c | 122 +++++++++++--------- demos/spiv/{cpu_timer.h => image_list.h} | 30 +++--- demos/spiv/spiv.c | 53 +++------ 5 files changed, 100 insertions(+), 109 deletions(-) copy tests/framework/tst_msg.c => demos/spiv/image_list.c (53%) copy demos/spiv/{cpu_timer.h => image_list.h} (77%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.