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 c5d3e2a62fabfd142f86d47f51e313680d363ea3 (commit)
from bccb0491d955bfbd1c0cb8d9ca7add8c886c50fe (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/c5d3e2a62fabfd142f86d47f51e313680d36…
commit c5d3e2a62fabfd142f86d47f51e313680d363ea3
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Jan 21 21:59:13 2012 +0100
demos: fbshow add more timers.
diff --git a/demos/fbshow/Makefile b/demos/fbshow/Makefile
index 6b04464..74d83fb 100644
--- a/demos/fbshow/Makefile
+++ b/demos/fbshow/Makefile
@@ -9,5 +9,7 @@ LDLIBS+=-lGP -lGP_backends -lSDL -L$(TOPDIR)/build/
APPS=fbshow
+fbshow: cpu_timer.o
+
include $(TOPDIR)/include.mk
include $(TOPDIR)/app.mk
diff --git a/demos/fbshow/cpu_timer.c b/demos/fbshow/cpu_timer.c
new file mode 100644
index 0000000..88455eb
--- /dev/null
+++ b/demos/fbshow/cpu_timer.c
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * 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(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include "cpu_timer.h"
+
+void cpu_timer_start(struct cpu_timer *self, const char *name)
+{
+ self->name = name;
+ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &self->t_start);
+}
+
+void cpu_timer_stop(struct cpu_timer *self)
+{
+ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &self->t_stop);
+
+ int sec;
+ int nsec;
+
+ if (self->t_stop.tv_nsec < self->t_start.tv_nsec) {
+ sec = self->t_stop.tv_sec - self->t_start.tv_sec - 1;
+ nsec = self->t_stop.tv_nsec + 1000000000 - self->t_start.tv_nsec;
+ } else {
+ sec = self->t_stop.tv_sec - self->t_start.tv_sec;
+ nsec = self->t_stop.tv_nsec - self->t_start.tv_nsec;
+ }
+
+ printf("TIMER '%s' %i.%09i secn", self->name, sec, nsec);
+}
diff --git a/demos/fbshow/cpu_timer.h b/demos/fbshow/cpu_timer.h
new file mode 100644
index 0000000..1b41144
--- /dev/null
+++ b/demos/fbshow/cpu_timer.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(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+ /*
+
+ Simple timers to count cpu time.
+
+ */
+
+#ifndef __CPU_TIMER_H__
+#define __CPU_TIMER_H__
+
+#include <time.h>
+
+struct cpu_timer {
+ struct timespec t_start;
+ struct timespec t_stop;
+ const char *name;
+};
+
+/*
+ * Inialize cpu timer.
+ */
+void cpu_timer_start(struct cpu_timer *self, const char *name);
+
+/*
+ * Stops cpu timer and prints result.
+ */
+void cpu_timer_stop(struct cpu_timer *self);
+
+#endif /* __CPU_TIMER_H__ */
diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c
index f7ab61f..4d9f6bc 100644
--- a/demos/fbshow/fbshow.c
+++ b/demos/fbshow/fbshow.c
@@ -35,6 +35,8 @@
#include <backends/GP_Backends.h>
#include <input/GP_InputDriverLinux.h>
+#include "cpu_timer.h"
+
static GP_Pixel black_pixel;
static GP_Pixel white_pixel;
@@ -106,40 +108,14 @@ static const char *img_name(const char *img_path)
return NULL;
}
-#include <time.h>
-
-static struct timespec t_start;
-static struct timespec t_stop;
-static const char *t_name;
-
-static void timer_start(const char *name)
-{
- t_name = name;
- clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t_start);
-}
-
-static void timer_stop(void)
-{
- clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t_stop);
-
- int sec;
- int nsec;
-
- if (t_stop.tv_nsec < t_start.tv_nsec) {
- sec = t_stop.tv_sec - t_start.tv_sec - 1;
- nsec = t_stop.tv_nsec + 1000000000 - t_start.tv_nsec;
- } else {
- sec = t_stop.tv_sec - t_start.tv_sec;
- nsec = t_stop.tv_nsec - t_start.tv_nsec;
- }
-
- printf("TIMER '%s' %i.%09i secn", t_name, sec, nsec);
-}
-
static void *image_loader(void *ptr)
{
struct loader_params *params = ptr;
GP_ProgressCallback callback = {.callback = image_loader_callback};
+ struct cpu_timer timer;
+ struct cpu_timer sum_timer;
+
+ cpu_timer_start(&sum_timer, "sum");
show_progress = params->show_progress || params->show_progress_once;
params->show_progress_once = 0;
@@ -149,7 +125,8 @@ static void *image_loader(void *ptr)
GP_Context *img = NULL;
callback.priv = "Loading image";
-
+
+ cpu_timer_start(&timer, "Loading");
if (GP_LoadImage(params->img_path, &img, &callback) != 0) {
GP_Fill(context, black_pixel);
GP_Text(context, NULL, context->w/2, context->h/2,
@@ -157,7 +134,8 @@ static void *image_loader(void *ptr)
"Failed to load image :(");
return NULL;
}
-
+ cpu_timer_stop(&timer);
+
GP_Size w, h;
switch (rotate) {
@@ -189,16 +167,18 @@ static void *image_loader(void *ptr)
GP_Context *ret;
if (rat < 1) {
- timer_start("blur");
+ cpu_timer_start(&timer, "Blur");
callback.priv = "Blurring Image";
if (GP_FilterGaussianBlur(img, img, 0.5/rat, 0.5/rat, &callback) == NULL)
return NULL;
- timer_stop();
+ cpu_timer_stop(&timer);
}
+ cpu_timer_start(&timer, "Resampling");
callback.priv = "Resampling Image";
ret = GP_FilterResize(img, NULL, GP_INTERP_CUBIC_INT, img->w * rat, img->h * rat, &callback);
GP_ContextFree(img);
+ cpu_timer_stop(&timer);
if (ret == NULL)
return NULL;
@@ -240,6 +220,8 @@ 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);
+ cpu_timer_stop(&sum_timer);
+
if (!params->show_info) {
GP_BackendFlip(backend);
return NULL;
-----------------------------------------------------------------------
Summary of changes:
demos/fbshow/Makefile | 2 +
.../GP_Backends.h => demos/fbshow/cpu_timer.c | 37 ++++++++------
.../GP_Backends.h => demos/fbshow/cpu_timer.h | 29 +++++++----
demos/fbshow/fbshow.c | 50 ++++++-------------
4 files changed, 57 insertions(+), 61 deletions(-)
copy include/backends/GP_Backends.h => demos/fbshow/cpu_timer.c (71%)
copy include/backends/GP_Backends.h => demos/fbshow/cpu_timer.h (80%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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
discards 7bc428fa520fa1091b43319121322378951a347d (commit)
via 36f12d07e7626a423264eca355c4000fc392dbf6 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (7bc428fa520fa1091b43319121322378951a347d)
N -- N -- N (36f12d07e7626a423264eca355c4000fc392dbf6)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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/36f12d07e7626a423264eca355c4000fc392…
commit 36f12d07e7626a423264eca355c4000fc392dbf6
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jan 17 12:25:28 2012 +0100
backends: Add options for SDL fulscreen && docs.
diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c
index fe8a372..c7363fd 100644
--- a/demos/fbshow/fbshow.c
+++ b/demos/fbshow/fbshow.c
@@ -278,7 +278,12 @@ static void init_backend(const char *backend_opts)
if (!strcmp(backend_opts, "SDL")) {
fprintf(stderr, "Initalizing SDL backendn");
- backend = GP_BackendSDLInit(800, 600, 0);
+ backend = GP_BackendSDLInit(800, 600, 0, 0);
+ }
+
+ if (!strcmp(backend_opts, "SDL:FS")) {
+ fprintf(stderr, "Initalizing SDL fullscreenn");
+ backend = GP_BackendSDLInit(0, 0, 0, GP_SDL_FULLSCREEN);
}
if (backend == NULL) {
diff --git a/include/backends/GP_SDL.h b/include/backends/GP_SDL.h
index 2b3541b..bd553b9 100644
--- a/include/backends/GP_SDL.h
+++ b/include/backends/GP_SDL.h
@@ -26,11 +26,37 @@
#include <stdint.h>
#include "GP_Backend.h"
+enum GP_BackendSDLFlags {
+ GP_SDL_FULLSCREEN = 0x01,
+ GP_SDL_RESIZABLE = 0x02,
+};
+
/*
* Initalize SDL as drawing backend.
*
+ * * SDL doesn't expose file descriptors.
+ *
+ * * The backend is thread safe (the critical parts are guarded with a mutex)
+ *
+ * * The backend is singleton, you can't have two SDL backends running at the
+ * same time.
+ *
+ * * When backend is allready initalized, this function ignores it's parameters
+ * and returns pointer to allready initalized SDL backend.
+ *
+ * * The SDL backends (upon calling GP_BackendPoll()) feeds keyboard and mouse
+ * events into global GP event queue (see input/GP_Event.h).
+ *
+ *
+ * The parameters w h and bpp are directly passed to SDL_SetVideoMode().
+ *
+ * * If w, h and/or bpp are set to zero, SDL tries to do best fit.
+ *
+ * * The GP_BackendSDLFlags are converted into SDL equivalents.
+ *
* Upon failure, or if SDL wasn't compiled in, NULL is returned.
*/
-GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp);
+GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h,
+ uint8_t bpp, uint8_t flags);
#endif /* BACKENDS_GP_SDL_H */
diff --git a/libs/backends/GP_SDL.c b/libs/backends/GP_SDL.c
index f50cfed..feabc9b 100644
--- a/libs/backends/GP_SDL.c
+++ b/libs/backends/GP_SDL.c
@@ -28,6 +28,7 @@
#include "core/GP_Debug.h"
#include "input/GP_InputDriverSDL.h"
#include "GP_Backend.h"
+#include "GP_SDL.h"
#ifdef HAVE_LIBSDL
@@ -60,15 +61,6 @@ static void sdl_update_rect(struct GP_Backend *self __attribute__((unused)),
SDL_mutexV(mutex);
}
-static void sdl_exit(struct GP_Backend *self __attribute__((unused)))
-{
- SDL_mutexP(mutex);
-
- SDL_Quit();
-
- SDL_DestroyMutex(mutex);
-}
-
static void sdl_poll(struct GP_Backend *self __attribute__((unused)))
{
SDL_Event ev;
@@ -81,6 +73,8 @@ static void sdl_poll(struct GP_Backend *self __attribute__((unused)))
SDL_mutexV(mutex);
}
+static void sdl_exit(struct GP_Backend *self __attribute__((unused)));
+
static struct GP_Backend backend = {
.name = "SDL",
.context = NULL,
@@ -91,6 +85,17 @@ static struct GP_Backend backend = {
.Poll = sdl_poll,
};
+static void sdl_exit(struct GP_Backend *self __attribute__((unused)))
+{
+ SDL_mutexP(mutex);
+
+ SDL_Quit();
+
+ SDL_DestroyMutex(mutex);
+
+ backend.context = NULL;
+}
+
int context_from_surface(GP_Context *context, SDL_Surface *surf)
{
/* sanity checks on the SDL surface */
@@ -129,7 +134,7 @@ int context_from_surface(GP_Context *context, SDL_Surface *surf)
return 0;
}
-GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp)
+GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp, uint8_t flags)
{
/* SDL not yet initalized */
if (backend.context == NULL) {
@@ -138,7 +143,15 @@ GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp)
return NULL;
}
- sdl_surface = SDL_SetVideoMode(w, h, bpp, SDL_SWSURFACE|SDL_DOUBLEBUF);
+ uint32_t sdl_flags = SDL_SWSURFACE;
+
+ if (flags & GP_SDL_FULLSCREEN)
+ sdl_flags |= SDL_FULLSCREEN;
+
+ if (flags & GP_SDL_RESIZABLE)
+ sdl_flags |= SDL_RESIZABLE;
+
+ sdl_surface = SDL_SetVideoMode(w, h, bpp, sdl_flags);
if (sdl_surface == NULL) {
GP_DEBUG(1, "ERROR: SDL_SetVideoMode: %s", SDL_GetError());
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_SDL.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 b549f66c9fc9e0ccb125692a7a2570bbe2016cdc (commit)
from 4d4ca995c2d6ae58d85863cae26c4369d5bd0967 (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/b549f66c9fc9e0ccb125692a7a2570bbe201…
commit b549f66c9fc9e0ccb125692a7a2570bbe2016cdc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jan 17 11:59:23 2012 +0100
backends: Make the SDL backend thread safe.
The SDL_Flip, SDL_UpdateRect, SDL_Poll and SDL_Quit
are not thread safe. If these clash while running on
xserver, asynchronous communication is detected and
the connection is aborted. Fix that by guarding these
by a mutex.
diff --git a/libs/backends/GP_SDL.c b/libs/backends/GP_SDL.c
index 0a97ada..f50cfed 100644
--- a/libs/backends/GP_SDL.c
+++ b/libs/backends/GP_SDL.c
@@ -32,39 +32,53 @@
#ifdef HAVE_LIBSDL
#include <SDL/SDL.h>
+#include <SDL/SDL_mutex.h>
static SDL_Surface *sdl_surface;
+static SDL_mutex *mutex;
static GP_Context context;
/* Backend API funcitons */
static void sdl_flip(struct GP_Backend *self __attribute__((unused)))
{
- SDL_LockSurface(sdl_surface);
+ SDL_mutexP(mutex);
+
SDL_Flip(sdl_surface);
context.pixels = sdl_surface->pixels;
- SDL_UnlockSurface(sdl_surface);
+
+ SDL_mutexV(mutex);
}
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_mutexP(mutex);
+
SDL_UpdateRect(sdl_surface, x1, y1, x2, y2);
- SDL_UnlockSurface(sdl_surface);
+
+ SDL_mutexV(mutex);
}
static void sdl_exit(struct GP_Backend *self __attribute__((unused)))
{
+ SDL_mutexP(mutex);
+
SDL_Quit();
+
+ SDL_DestroyMutex(mutex);
}
static void sdl_poll(struct GP_Backend *self __attribute__((unused)))
{
SDL_Event ev;
+ SDL_mutexP(mutex);
+
while (SDL_PollEvent(&ev))
GP_InputDriverSDLEventPut(&ev);
+
+ SDL_mutexV(mutex);
}
static struct GP_Backend backend = {
@@ -132,6 +146,8 @@ GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp)
return NULL;
}
+ mutex = SDL_CreateMutex();
+
if (context_from_surface(&context, sdl_surface)) {
GP_DEBUG(1, "ERROR: Failed to match pixel_type");
SDL_Quit();
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_SDL.c | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 713e4f3f13172cb63b59ac501b54992a2309b314 (commit)
from 03dc78a368cf8724cfaf79b6e149bdbe2d709205 (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/713e4f3f13172cb63b59ac501b54992a2309…
commit 713e4f3f13172cb63b59ac501b54992a2309b314
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Jan 14 22:44:23 2012 +0100
input: Fix typos in comment.
diff --git a/include/input/GP_Event.h b/include/input/GP_Event.h
index cb412f1..db4166c 100644
--- a/include/input/GP_Event.h
+++ b/include/input/GP_Event.h
@@ -24,7 +24,7 @@
Gfxprim event layer.
- Events are lowlever interfaace to input devices (human interface).
+ Events are lowlevel interface to input devices (human interface).
- Events are notifications that something has changed, eg. button pressed
- Each event carries some information about global state
-----------------------------------------------------------------------
Summary of changes:
include/input/GP_Event.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")