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 4d4ca995c2d6ae58d85863cae26c4369d5bd0967 (commit) via 357771c22372e5584d8c0e9126e7877783784073 (commit) via 4c798878c771c9306afdffb5416ca817f625d8cd (commit) from 89f781e8da4907c3e34db57714777601227a3719 (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/4d4ca995c2d6ae58d85863cae26c4369d5bd0...
commit 4d4ca995c2d6ae58d85863cae26c4369d5bd0967 Author: Cyril Hrubis metan@ucw.cz Date: Sun Jan 15 19:16:09 2012 +0100
demos: Port fbshow to SDL backend.
diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c index fb3baeb..fe8a372 100644 --- a/demos/fbshow/fbshow.c +++ b/demos/fbshow/fbshow.c @@ -38,8 +38,8 @@ static GP_Pixel black_pixel; static GP_Pixel white_pixel;
-static GP_Backend *backend; -static GP_Context *context; +static GP_Backend *backend = NULL; +static GP_Context *context = NULL;
/* image loader thread */ static int abort_flag = 0; @@ -73,6 +73,8 @@ static int image_loader_callback(GP_ProgressCallback *self)
size = GP_TextWidth(NULL, buf);
+ GP_BackendFlip(backend); + return 0; }
@@ -204,8 +206,10 @@ static void *image_loader(void *ptr) GP_FillRectXYWH(context, ret->w+cx, 0, cx, context->h, black_pixel); GP_FillRectXYWH(context, 0, ret->h+cy, context->w, cy, black_pixel);
- if (!params->show_info) + if (!params->show_info) { + GP_BackendFlip(backend); return NULL; + }
GP_Size th = GP_TextHeight(NULL); @@ -227,6 +231,8 @@ static void *image_loader(void *ptr) GP_Print(context, NULL, 10, 14 + 2 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, white_pixel, black_pixel, "%s", img_name(params->img_path));
+ GP_BackendFlip(backend); + return NULL; }
@@ -253,23 +259,44 @@ static void show_image(struct loader_params *params) } }
-static void sighandler(int signo __attribute__((unused))) +static void sighandler(int signo) { if (backend != NULL) GP_BackendExit(backend); + + fprintf(stderr, "Got signal %in", signo);
exit(1); }
+static void init_backend(const char *backend_opts) +{ + if (!strcmp(backend_opts, "fb")) { + fprintf(stderr, "Initalizing framebuffer backendn"); + backend = GP_BackendLinuxFBInit("/dev/fb0"); + } + + if (!strcmp(backend_opts, "SDL")) { + fprintf(stderr, "Initalizing SDL backendn"); + backend = GP_BackendSDLInit(800, 600, 0); + } + + if (backend == NULL) { + fprintf(stderr, "Failed to initalize backend '%s'n", backend_opts); + exit(1); + } +} + int main(int argc, char *argv[]) { GP_InputDriverLinux *drv = NULL; - char *input_dev = NULL; + const char *input_dev = NULL; + const char *backend_opts = "fb"; int sleep_sec = -1; struct loader_params params = {NULL, 0, 0, 0}; int opt;
- while ((opt = getopt(argc, argv, "Ii:Ps:r:")) != -1) { + while ((opt = getopt(argc, argv, "b:Ii:Ps:r:")) != -1) { switch (opt) { case 'I': params.show_info = 1; @@ -290,6 +317,9 @@ int main(int argc, char *argv[]) rotate = 180; else if (!strcmp(optarg, "270")) rotate = 270; + case 'b': + backend_opts = optarg; + break; default: fprintf(stderr, "Invalid paramter '%c'n", opt); } @@ -297,9 +327,7 @@ int main(int argc, char *argv[]) GP_SetDebugLevel(10);
- if (input_dev == NULL) { - sleep_sec = 1; - } else { + if (input_dev != NULL) { drv = GP_InputDriverLinuxOpen(input_dev); if (drv == NULL) { @@ -314,12 +342,7 @@ int main(int argc, char *argv[]) signal(SIGBUS, sighandler); signal(SIGABRT, sighandler);
- backend = GP_BackendLinuxFBInit("/dev/fb0"); - - if (backend == NULL) { - fprintf(stderr, "Failed to initalize framebuffern"); - return 1; - } + init_backend(backend_opts);
context = backend->context;
@@ -329,25 +352,26 @@ int main(int argc, char *argv[]) white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context);
GP_Fill(context, black_pixel); + GP_BackendFlip(backend);
int argf = optind; int argn = argf; - + params.show_progress_once = 1; params.img_path = argv[argf]; show_image(¶ms);
- /* Initalize select */ - fd_set rfds; - FD_ZERO(&rfds); - FD_SET(drv->fd, &rfds); - struct timeval tv = {.tv_sec = sleep_sec, .tv_usec = 0}; - struct timeval *tvp = sleep_sec != -1 ? &tv : NULL; - for (;;) { int ret;
if (drv != NULL) { + /* Initalize select */ + fd_set rfds; + FD_ZERO(&rfds); + FD_SET(drv->fd, &rfds); + struct timeval tv = {.tv_sec = sleep_sec, .tv_usec = 0}; + struct timeval *tvp = sleep_sec != -1 ? &tv : NULL; + ret = select(drv->fd + 1, &rfds, NULL, NULL, tvp); tv.tv_sec = sleep_sec; @@ -371,16 +395,23 @@ int main(int argc, char *argv[])
FD_SET(drv->fd, &rfds); } else { - sleep(sleep_sec); - - argn++; - if (argn >= argc) - argn = argf; + if (sleep_sec != -1) { + sleep(sleep_sec); + + argn++; + if (argn >= argc) + argn = argf; - params.img_path = argv[argn]; - show_image(¶ms); + params.img_path = argv[argn]; + show_image(¶ms); + } }
+ if (backend->Poll) + GP_BackendPoll(backend); + + usleep(1000); + /* Read and parse events */ GP_Event ev;
http://repo.or.cz/w/gfxprim.git/commit/357771c22372e5584d8c0e9126e7877783784...
commit 357771c22372e5584d8c0e9126e7877783784073 Author: Cyril Hrubis metan@ucw.cz Date: Sun Jan 15 19:15:52 2012 +0100
backends: Fix SDL backend, seems to be working now.
diff --git a/include/backends/GP_SDL.h b/include/backends/GP_SDL.h index b6f0fab..2b3541b 100644 --- a/include/backends/GP_SDL.h +++ b/include/backends/GP_SDL.h @@ -31,6 +31,6 @@ * * Upon failure, or if SDL wasn't compiled in, NULL is returned. */ -GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint16_t bpp); +GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp);
#endif /* BACKENDS_GP_SDL_H */ diff --git a/libs/backends/GP_SDL.c b/libs/backends/GP_SDL.c index 4083f09..0a97ada 100644 --- a/libs/backends/GP_SDL.c +++ b/libs/backends/GP_SDL.c @@ -26,6 +26,7 @@ #include "../../config.h"
#include "core/GP_Debug.h" +#include "input/GP_InputDriverSDL.h" #include "GP_Backend.h"
#ifdef HAVE_LIBSDL @@ -33,18 +34,24 @@ #include <SDL/SDL.h>
static SDL_Surface *sdl_surface; +static GP_Context context;
/* Backend API funcitons */
static void sdl_flip(struct GP_Backend *self __attribute__((unused))) { + SDL_LockSurface(sdl_surface); SDL_Flip(sdl_surface); + context.pixels = sdl_surface->pixels; + SDL_UnlockSurface(sdl_surface); }
static void sdl_update_rect(struct GP_Backend *self __attribute__((unused)), GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2) { + SDL_LockSurface(sdl_surface); SDL_UpdateRect(sdl_surface, x1, y1, x2, y2); + SDL_UnlockSurface(sdl_surface); }
static void sdl_exit(struct GP_Backend *self __attribute__((unused))) @@ -56,9 +63,8 @@ static void sdl_poll(struct GP_Backend *self __attribute__((unused))) { SDL_Event ev;
- if (SDL_PollEvent(&ev)) { - printf("SDL EVENT!n"); - } + while (SDL_PollEvent(&ev)) + GP_InputDriverSDLEventPut(&ev); }
static struct GP_Backend backend = { @@ -109,28 +115,30 @@ int context_from_surface(GP_Context *context, SDL_Surface *surf) return 0; }
-GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint16_t bpp) +GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp) { /* SDL not yet initalized */ - if (backend.context != NULL) { + if (backend.context == NULL) { if (SDL_Init(SDL_INIT_VIDEO)) { GP_DEBUG(1, "ERROR: SDL_Init: %s", SDL_GetError()); return NULL; }
- sdl_surface = SDL_SetVideoMode(w, h, bpp, SDL_SWSURFACE); + sdl_surface = SDL_SetVideoMode(w, h, bpp, SDL_SWSURFACE|SDL_DOUBLEBUF); if (sdl_surface == NULL) { GP_DEBUG(1, "ERROR: SDL_SetVideoMode: %s", SDL_GetError()); SDL_Quit(); return NULL; } - - if (context_from_surface(backend.context, sdl_surface)) { + + if (context_from_surface(&context, sdl_surface)) { GP_DEBUG(1, "ERROR: Failed to match pixel_type"); SDL_Quit(); return NULL; } + + backend.context = &context; }
return &backend;
http://repo.or.cz/w/gfxprim.git/commit/4c798878c771c9306afdffb5416ca817f625d...
commit 4c798878c771c9306afdffb5416ca817f625d8cd Author: Cyril Hrubis metan@ucw.cz Date: Sun Jan 15 19:15:35 2012 +0100
build: Add -ggdb by default.
diff --git a/configure b/configure index 3f479be..7d0ffd6 100755 --- a/configure +++ b/configure @@ -147,7 +147,7 @@ if __name__ == '__main__': # Dictionary for default configuration parameters # cfg = {'CC' : ['gcc', 'Path/name of the C compiler'], - 'CFLAGS' : ['-W -Wall -Wextra -fPIC -O2', 'C compiler flags'], + 'CFLAGS' : ['-W -Wall -Wextra -fPIC -O2 -ggdb', 'C compiler flags'], 'PYTHON_BIN' : ['python', 'Path/name of python interpreter'], 'include_path': ['/usr/include', 'Path to the system headers']}
-----------------------------------------------------------------------
Summary of changes: configure | 2 +- demos/fbshow/fbshow.c | 91 ++++++++++++++++++++++++++++++--------------- include/backends/GP_SDL.h | 2 +- libs/backends/GP_SDL.c | 24 ++++++++---- 4 files changed, 79 insertions(+), 40 deletions(-)
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.