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, generate has been updated via cbea4b71a8151b445c662f50b12b50dccb7285c9 (commit) from 2f57806a0c4f164121638af4f28a43c73b3bf4c5 (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/cbea4b71a8151b445c662f50b12b50dccb728...
commit cbea4b71a8151b445c662f50b12b50dccb7285c9 Author: Cyril Hrubis metan@ucw.cz Date: Sun Oct 23 20:11:29 2011 +0000
Fixed the framebuffer tests.
diff --git a/tests/Makefile b/tests/Makefile index e002663..cfeab1c 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,3 +1,3 @@ TOPDIR=.. -SUBDIRS=core SDL #loaders filters +SUBDIRS=core SDL drivers include $(TOPDIR)/include.mk diff --git a/tests/drivers/GP_Framebuffer.c b/tests/drivers/GP_Framebuffer.c deleted file mode 100644 index 61fc2d8..0000000 --- a/tests/drivers/GP_Framebuffer.c +++ /dev/null @@ -1,191 +0,0 @@ -/***************************************************************************** - * 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-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <sys/mman.h> -#include <fcntl.h> -#include <string.h> - -#include <linux/fb.h> -#include <linux/kd.h> -#include <linux/vt.h> - -#include "GP_Pixel.h" - -#include "GP_Framebuffer.h" - -/* - * Allocates and switches to newly allocated console. - */ -static int allocate_console(struct GP_Framebuffer *fb) -{ - struct vt_stat vts; - int fd, nr; - char buf[255]; - - /* allocate and switch to new console */ - fd = open("/dev/tty1", O_WRONLY); - - if (fd < 0) { - perror("opening console failed"); - return -1; - } - - if (ioctl(fd, VT_OPENQRY, &nr) < 0) { - perror("ioctl VT_OPENQRY"); - close(fd); - return -1; - } - - close(fd); - - snprintf(buf, sizeof(buf), "/dev/tty%i", nr); - fd = open(buf, O_RDWR); - - if (fd < 0) { - perror("opening console failed"); - close(fd); - return -1; - } - - if (ioctl(fd, VT_GETSTATE, &vts) == 0) - fb->last_con_nr = vts.v_active; - else - fb->last_con_nr = -1; - - if (ioctl(fd, VT_ACTIVATE, nr) < 0) { - perror("ioctl VT_ACTIVATE"); - close(fd); - return -1; - } - - if (ioctl(fd, VT_WAITACTIVE, nr) < 0) { - perror("ioctl VT_WAITACTIVE"); - close(fd); - return -1; - } - - /* turn off blinking cursor */ - if (ioctl(fd, KDSETMODE, KD_GRAPHICS) < 0) { - perror("ioctl KDSETMODE"); - close(fd); - } - - fb->con_nr = nr; - fb->con_fd = fd; - - return 0; -} - -GP_Framebuffer *GP_FramebufferInit(const char *path) -{ - GP_Framebuffer *fb = malloc(sizeof (GP_Framebuffer) + strlen(path) + 1); - struct fb_fix_screeninfo fscri; - struct fb_var_screeninfo vscri; - int fd; - - if (fb == NULL) - return NULL; - - if (allocate_console(fb)) - goto err1; - - - /* open and mmap framebuffer */ - fd = open(path, O_RDWR); - - if (fd < 0) { - perror("opening framebuffer failed"); - goto err2; - } - - if (ioctl(fd, FBIOGET_FSCREENINFO, &fscri) < 0) { - perror("ioctl FBIOGET_FSCREENINFO"); - goto err3; - } - - if (ioctl(fd, FBIOGET_VSCREENINFO, &vscri) < 0) { - perror("ioctl FBIOGET_VSCREENINFO"); - goto err3; - } - - fb->context.pixels = mmap(NULL, fscri.smem_len, - PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, - fd, 0); - - if (fb->context.pixels == MAP_FAILED) { - perror("mmaping framebuffer failed"); - goto err3; - } - - fb->fb_fd = fd; - fb->bsize = fscri.smem_len; - strcpy(fb->path, path); - - fb->context.w = vscri.xres; - fb->context.h = vscri.yres; - - fb->context.axes_swap = 0; - fb->context.x_swap = 0; - fb->context.y_swap = 0; - - fb->context.clip_w_min = 0; - fb->context.clip_h_min = 0; - fb->context.clip_w_max = fb->context.w - 1; - fb->context.clip_h_max = fb->context.h - 1; - - fb->context.bpp = vscri.bits_per_pixel; - fb->context.bytes_per_row = fscri.line_length; - - fb->context.pixel_type = GP_PIXEL_RGB565; - - return fb; -err3: - close(fd); -err2: - close(fb->con_fd); -err1: - free(fb); - return NULL; -} - -void GP_FramebufferExit(GP_Framebuffer *fb) -{ - /* unmap framebuffer */ - munmap(fb->context.pixels, fb->bsize); - close(fb->fb_fd); - - /* reset keyboard */ - ioctl(fb->con_fd, KDSETMODE, KD_TEXT); - - /* switch back console */ - if (fb->last_con_nr != -1) - ioctl(fb->con_fd, VT_ACTIVATE, fb->last_con_nr); - - close(fb->con_fd); - free(fb); -} diff --git a/tests/drivers/GP_Framebuffer.h b/tests/drivers/GP_Framebuffer.h deleted file mode 100644 index 0013f09..0000000 --- a/tests/drivers/GP_Framebuffer.h +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************** - * 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-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#ifndef GP_FRAMEBUFFER_H -#define GP_FRAMEBUFFER_H - -#include "GP_Context.h" - -typedef struct GP_Framebuffer { - GP_Context context; - uint32_t bsize; - int con_fd; - int con_nr; - int last_con_nr; - int fb_fd; - char path[]; -} GP_Framebuffer; - -/* - * Initalize framebuffer. - */ -GP_Framebuffer *GP_FramebufferInit(const char *path); - -/* - * Deinitalize framebuffer. - */ -void GP_FramebufferExit(GP_Framebuffer *fb); - -#endif /* GP_FRAMEBUFFER_H */ diff --git a/tests/drivers/tests/Makefile b/tests/drivers/Makefile similarity index 63% rename from tests/drivers/tests/Makefile rename to tests/drivers/Makefile index d6a017f..664900d 100644 --- a/tests/drivers/tests/Makefile +++ b/tests/drivers/Makefile @@ -1,9 +1,8 @@ -LDFLAGS=-L../ -L../../core/ -lGP_core -lGP_drivers - -INCLUDE=-I../ -I../../core/ +LDFLAGS=-L../../build/ -lGP -lpng -ldl +INCLUDE=-I../../include # Some warnings are triggered only with -O2 # thuss added here -CFLAGS=$(INCLUDE) -ggdb -W -Wall -O2 -lm +CFLAGS=$(INCLUDE) -ggdb -W -Wall -O2 SOURCES=$(wildcard *.c) TESTS=$(SOURCES:.c=)
diff --git a/tests/drivers/tests/framebuffer_test.c b/tests/drivers/framebuffer_test.c similarity index 76% rename from tests/drivers/tests/framebuffer_test.c rename to tests/drivers/framebuffer_test.c index 028bd69..c5aceb9 100644 --- a/tests/drivers/tests/framebuffer_test.c +++ b/tests/drivers/framebuffer_test.c @@ -16,16 +16,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/*
- Framebuffer test. + Framebuffer test.
1. Draw to the framebuffer 2. Sleep @@ -36,7 +33,7 @@ #include <math.h>
#include <GP.h> -#include <GP_Framebuffer.h> +#include <backends/GP_Framebuffer.h>
static void draw(GP_Context *context, int x, int y, int l) { @@ -44,27 +41,33 @@ static void draw(GP_Context *context, int x, int y, int l)
GP_Pixel red, blue, green; - GP_RGBToPixel(context, 255, 0, 0, &red); - GP_RGBToPixel(context, 0, 0, 255, &blue); - GP_RGBToPixel(context, 0, 255, 0, &green); + red = GP_RGBToContextPixel(255, 0, 0, context); + blue = GP_RGBToContextPixel(0, 0, 255, context); + green = GP_RGBToContextPixel(0, 255, 0, context);
x2 = x + l/2; y2 = y + sqrt(2)/2 * l; x3 = x - l/2; y3 = y2;
- GP_FillTriangle(context, x, y, x2, y2, x + l, y, red); - GP_FillTriangle(context, x, y, x3, y3, x - l, y, green); - GP_FillTriangle(context, x2, y2, x3, y3, x, y + sqrt(2) * l, blue); + GP_FillTriangle(context, x, y, x2, y2, x + l, y, red); + GP_FillTriangle(context, x, y, x3, y3, x - l, y, green); + GP_FillTriangle(context, x2, y2, x3, y3, x, y + sqrt(2) * l, blue); }
int main(void) { - GP_Framebuffer *fb = GP_FramebufferInit("/dev/fb0"); + GP_Framebuffer *fb; GP_TextStyle style;
- if (fb == NULL) + GP_SetDebugLevel(10); + + fb = GP_FramebufferInit("/dev/fb0"); + + if (fb == NULL) { + fprintf(stderr, "Failed to initalize framebuffern"); return 1; + } GP_DefaultTextStyle(&style);
@@ -73,8 +76,8 @@ int main(void)
GP_Pixel gray, black;
- GP_RGBToPixel(&fb->context, 200, 200, 200, &gray); - GP_RGBToPixel(&fb->context, 0, 0, 0, &black); + gray = GP_RGBToContextPixel(200, 200, 200, &fb->context); + black = GP_RGBToContextPixel( 0, 0, 0, &fb->context); const char *text = "Framebuffer test";
diff --git a/tests/drivers/runtest.sh b/tests/drivers/runtest.sh new file mode 100755 index 0000000..ff2a001 --- /dev/null +++ b/tests/drivers/runtest.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# +# Run dynamically linked test. +# + +PROG="$1" +shift + +echo "LD_LIBRARY_PATH=../../build/ ./$PROG $@" +LD_LIBRARY_PATH="../../build/" ./$PROG $@ diff --git a/tests/drivers/tests/sierpinsky.c b/tests/drivers/sierpinsky.c similarity index 86% rename from tests/drivers/tests/sierpinsky.c rename to tests/drivers/sierpinsky.c index b90fe60..c113e1e 100644 --- a/tests/drivers/tests/sierpinsky.c +++ b/tests/drivers/sierpinsky.c @@ -16,21 +16,18 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/* - + Simple test for triangle drawing runtime.
*/
-#include "GP.h" -#include "GP_Framebuffer.h" +#include <GP.h> +#include <backends/GP_Framebuffer.h>
#include <math.h>
@@ -112,18 +109,24 @@ static void redraw(GP_Context *context)
int main(void) { - GP_Framebuffer *fb = GP_FramebufferInit("/dev/fb0"); + GP_Framebuffer *fb; GP_Context *context; int i;
- if (fb == NULL) + GP_SetDebugLevel(10); + + fb = GP_FramebufferInit("/dev/fb0"); + + if (fb == NULL) { + fprintf(stderr, "failed to initalize framebuffern"); return 1; + }
context = &fb->context;
- GP_ColorNameToPixel(context, GP_COL_GRAY_LIGHT, &gray); - GP_ColorNameToPixel(context, GP_COL_BLUE, &blue); - GP_ColorNameToPixel(context, GP_COL_BLACK, &black); + gray = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, context); + blue = GP_ColorToContextPixel(GP_COL_BLUE, context); + black = GP_ColorToContextPixel(GP_COL_BLACK, context);
iter = 0; draw(context, context->w/2, context->h/2, l, iter); diff --git a/tests/drivers/tests/runtest.sh b/tests/drivers/tests/runtest.sh deleted file mode 100755 index 0a8e20e..0000000 --- a/tests/drivers/tests/runtest.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -# -# Run dynamically linked test. -# - -PROG="$1" -shift - -echo "LD_LIBRARY_PATH=../:../../core/ ./$PROG $@" -LD_LIBRARY_PATH="../:../../core/" ./$PROG $@
-----------------------------------------------------------------------
Summary of changes: tests/Makefile | 2 +- tests/drivers/GP_Framebuffer.c | 191 -------------------------- tests/drivers/GP_Framebuffer.h | 51 ------- tests/drivers/{tests => }/Makefile | 7 +- tests/drivers/{tests => }/framebuffer_test.c | 35 +++-- tests/{SDL => drivers}/runtest.sh | 2 +- tests/drivers/{tests => }/sierpinsky.c | 27 ++-- tests/drivers/tests/runtest.sh | 10 -- 8 files changed, 39 insertions(+), 286 deletions(-) delete mode 100644 tests/drivers/GP_Framebuffer.c delete mode 100644 tests/drivers/GP_Framebuffer.h rename tests/drivers/{tests => }/Makefile (63%) rename tests/drivers/{tests => }/framebuffer_test.c (76%) copy tests/{SDL => drivers}/runtest.sh (72%) rename tests/drivers/{tests => }/sierpinsky.c (86%) delete mode 100755 tests/drivers/tests/runtest.sh
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.