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 6f9e031b813ac8d42b3faf6011b202d961894677 (commit) from 1a2dd1860b0fa145f2dec2e19af2d4931ac923db (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/6f9e031b813ac8d42b3faf6011b202d961894...
commit 6f9e031b813ac8d42b3faf6011b202d961894677 Author: Cyril Hrubis metan@ucw.cz Date: Sun Feb 10 14:36:37 2013 +0100
backends: Another step towards per backend event queue.
Now the backend has GP_BackendEventsQueued() and GP_BackendEventGet() functions and examples are chaged to use it.
Also the docs are updated.
diff --git a/demos/bogoman/bogoman.c b/demos/bogoman/bogoman.c index f6f969b..82189d8 100644 --- a/demos/bogoman/bogoman.c +++ b/demos/bogoman/bogoman.c @@ -61,10 +61,10 @@ static struct GP_Backend *backend;
static void event_loop(struct bogoman_map *map) { - while (GP_EventsQueued()) { + while (GP_BackendEventsQueued(backend)) { GP_Event ev; - GP_EventGet(&ev); + GP_BackendEventGet(backend, &ev);
switch (ev.type) { case GP_EV_KEY: @@ -142,7 +142,7 @@ int main(int argc, char *argv[]) bogoman_render(&render, BOGOMAN_RENDER_DIRTY); GP_BackendFlip(backend); - usleep(100000); + usleep(50000); }
return 0; diff --git a/demos/c_simple/backend_example.c b/demos/c_simple/backend_example.c index 3d565ef..debba09 100644 --- a/demos/c_simple/backend_example.c +++ b/demos/c_simple/backend_example.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -77,7 +77,7 @@ int main(int argc, char *argv[]) /* Read and parse events */ GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(backend, &ev)) {
GP_EventDump(&ev); diff --git a/demos/c_simple/blittest.c b/demos/c_simple/blittest.c index 5a80233..1ade1d9 100644 --- a/demos/c_simple/blittest.c +++ b/demos/c_simple/blittest.c @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -94,7 +94,7 @@ void event_loop(void) { GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(win, &ev)) { GP_EventDump(&ev); switch (ev.type) { @@ -171,6 +171,9 @@ int main(void) black = GP_ColorToContextPixel(GP_COL_BLACK, win->context); white = GP_ColorToContextPixel(GP_COL_WHITE, win->context);
+ GP_Fill(win->context, black); + GP_BackendFlip(win); + for (;;) { GP_BackendPoll(win); event_loop(); diff --git a/demos/c_simple/fileview.c b/demos/c_simple/fileview.c index 66c2925..6f36565 100644 --- a/demos/c_simple/fileview.c +++ b/demos/c_simple/fileview.c @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -113,7 +113,7 @@ void event_loop(void) { GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(backend, &ev)) { switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) diff --git a/demos/c_simple/fonttest.c b/demos/c_simple/fonttest.c index b9a5898..bf8a169 100644 --- a/demos/c_simple/fonttest.c +++ b/demos/c_simple/fonttest.c @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -175,7 +175,7 @@ void event_loop(void) { GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(win, &ev)) { switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) diff --git a/demos/c_simple/input_example.c b/demos/c_simple/input_example.c index cb4877b..8eda0f5 100644 --- a/demos/c_simple/input_example.c +++ b/demos/c_simple/input_example.c @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -56,10 +56,10 @@ static void event_loop(void) for (;;) { GP_BackendWait(backend); - while (GP_EventsQueued()) { + while (GP_BackendEventsQueued(backend)) { GP_Event ev;
- GP_EventGet(&ev); + GP_BackendEventGet(backend, &ev); GP_EventDump(&ev);
switch (ev.type) { diff --git a/demos/c_simple/koch.c b/demos/c_simple/koch.c index 6668cb0..581a978 100644 --- a/demos/c_simple/koch.c +++ b/demos/c_simple/koch.c @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -153,7 +153,7 @@ int main(void) GP_BackendPoll(backend); - while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(backend, &ev)) { GP_EventDump(&ev); switch (ev.type) { diff --git a/demos/c_simple/linetest.c b/demos/c_simple/linetest.c index 9e7078b..f72d618 100644 --- a/demos/c_simple/linetest.c +++ b/demos/c_simple/linetest.c @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -78,7 +78,7 @@ void event_loop(void) { GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(win, &ev)) { switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) diff --git a/demos/c_simple/randomshapetest.c b/demos/c_simple/randomshapetest.c index 19fcae4..1373ed9 100644 --- a/demos/c_simple/randomshapetest.c +++ b/demos/c_simple/randomshapetest.c @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -214,7 +214,7 @@ void event_loop(void) { GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(win, &ev)) { switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) diff --git a/demos/c_simple/shapetest.c b/demos/c_simple/shapetest.c index a807f5b..02c2bab 100644 --- a/demos/c_simple/shapetest.c +++ b/demos/c_simple/shapetest.c @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -337,7 +337,7 @@ void event_loop(void)
GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(backend, &ev)) { GP_EventDump(&ev); shift_pressed = GP_EventGetKey(&ev, GP_KEY_LEFT_SHIFT) || diff --git a/demos/c_simple/showimage.c b/demos/c_simple/showimage.c index 9b1741b..f91bbec 100644 --- a/demos/c_simple/showimage.c +++ b/demos/c_simple/showimage.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(backend, &ev)) { if (ev.type == GP_EV_KEY && ev.val.val == GP_KEY_Q) { GP_BackendExit(backend); return 0; diff --git a/demos/c_simple/sin_AA.c b/demos/c_simple/sin_AA.c index 94b3563..cd44879 100644 --- a/demos/c_simple/sin_AA.c +++ b/demos/c_simple/sin_AA.c @@ -105,7 +105,7 @@ int main(void) GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(backend, &ev)) { if (ev.type == GP_EV_KEY && ev.code == GP_EV_KEY_DOWN) { switch (ev.val.val) { case GP_KEY_ESC: diff --git a/demos/c_simple/textaligntest.c b/demos/c_simple/textaligntest.c index 0f1b4a3..5d6d53b 100644 --- a/demos/c_simple/textaligntest.c +++ b/demos/c_simple/textaligntest.c @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -73,7 +73,7 @@ static void event_loop(void) { GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(win, &ev)) { switch (ev.type) { case GP_EV_KEY: if (ev.code != GP_EV_KEY_DOWN) diff --git a/demos/c_simple/v4l2_show.c b/demos/c_simple/v4l2_show.c index c7f5cbb..4bb5543 100644 --- a/demos/c_simple/v4l2_show.c +++ b/demos/c_simple/v4l2_show.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -129,7 +129,7 @@ int main(int argc, char *argv[]) /* Read and parse events */ GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(backend, &ev)) { switch (ev.type) { case GP_EV_KEY: diff --git a/demos/c_simple/virtual_backend_example.c b/demos/c_simple/virtual_backend_example.c index 448c72c..0468a14 100644 --- a/demos/c_simple/virtual_backend_example.c +++ b/demos/c_simple/virtual_backend_example.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -148,7 +148,7 @@ int main(int argc, char *argv[]) /* Read and parse events */ GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(backend, &ev)) {
GP_EventDump(&ev); diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c index 4143ffe..e977cc6 100644 --- a/demos/particle/particle_demo.c +++ b/demos/particle/particle_demo.c @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) /* Read and parse events */ GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(backend, &ev)) {
GP_EventDump(&ev); diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index f681b1a..23462b7 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -871,7 +871,7 @@ int main(int argc, char *argv[]) /* Read and parse events */ GP_Event ev;
- while (GP_EventGet(&ev)) { + while (GP_BackendEventGet(backend, &ev)) { shift_flag = GP_EventGetKey(&ev, GP_KEY_LEFT_SHIFT) || GP_EventGetKey(&ev, GP_KEY_RIGHT_SHIFT); diff --git a/doc/backends.txt b/doc/backends.txt index 501baca..678f8c7 100644 --- a/doc/backends.txt +++ b/doc/backends.txt @@ -330,4 +330,30 @@ multithreaded application where one threads waits for events and others draws into the buffer so you can stop the drawing threads before the backend context size change.
+[source,c] +------------------------------------------------------------------------------- +#include <backends/GP_Backend.h> +/* or */ +#include <GP.h> + +unsigned int GP_BackendEventsQueued(GP_Backend *self); +------------------------------------------------------------------------------- + +Returns number of events queued in backend event queue. + +[source,c] +------------------------------------------------------------------------------- +#include <backends/GP_Backend.h> +/* or */ +#include <GP.h> + +int GP_BackendEventGet(GP_Backend *self, GP_Event *ev); +------------------------------------------------------------------------------- + +In case there are any events queued, the top event is removed from the queue, +copied into the event structure that is passed as argument and non-zero is +returned. + +If there are no events queued the call returns immediately returning zero. + TIP: For more information see link:input.html[input events] documentation. diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h index 01bf3c1..900b8d4 100644 --- a/include/backends/GP_Backend.h +++ b/include/backends/GP_Backend.h @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -228,4 +228,21 @@ int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h); */ int GP_BackendResizeAck(GP_Backend *self);
+/* + * Event Queue functions. + */ +#include <input/GP_Event.h> + +static inline unsigned int GP_BackendEventsQueued(GP_Backend *self) +{ + (void) self; + return GP_EventsQueued(); +} + +static inline int GP_BackendEventGet(GP_Backend *self, GP_Event *ev) +{ + (void) self; + return GP_EventGet(ev); +} + #endif /* BACKENDS_GP_BACKEND_H */ diff --git a/include/input/GP_Event.h b/include/input/GP_Event.h index c985cad..2c99bb2 100644 --- a/include/input/GP_Event.h +++ b/include/input/GP_Event.h @@ -31,8 +31,8 @@
*/
-#ifndef GP_EVENT_H -#define GP_EVENT_H +#ifndef INPUT_GP_EVENT_H +#define INPUT_GP_EVENT_H
#include <stdint.h> #include <sys/time.h> @@ -387,4 +387,4 @@ static inline void GP_EventResetKey(struct GP_Event *ev, ev->keys_pressed[(key)/8] &= ~(1<<((key)%8)); }
-#endif /* GP_EVENT_H */ +#endif /* INPUT_GP_EVENT_H */
-----------------------------------------------------------------------
Summary of changes: demos/bogoman/bogoman.c | 6 +++--- demos/c_simple/backend_example.c | 4 ++-- demos/c_simple/blittest.c | 7 +++++-- demos/c_simple/fileview.c | 4 ++-- demos/c_simple/fonttest.c | 4 ++-- demos/c_simple/input_example.c | 6 +++--- demos/c_simple/koch.c | 4 ++-- demos/c_simple/linetest.c | 4 ++-- demos/c_simple/randomshapetest.c | 4 ++-- demos/c_simple/shapetest.c | 4 ++-- demos/c_simple/showimage.c | 4 ++-- demos/c_simple/sin_AA.c | 2 +- demos/c_simple/textaligntest.c | 4 ++-- demos/c_simple/v4l2_show.c | 4 ++-- demos/c_simple/virtual_backend_example.c | 4 ++-- demos/particle/particle_demo.c | 2 +- demos/spiv/spiv.c | 2 +- doc/backends.txt | 26 ++++++++++++++++++++++++++ include/backends/GP_Backend.h | 19 ++++++++++++++++++- include/input/GP_Event.h | 6 +++--- 20 files changed, 83 insertions(+), 37 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.