Gfxprim
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- 929 discussions
[repo.or.cz] gfxprim.git branch generate updated: cbea4b71a8151b445c662f50b12b50dccb7285c9
by metan 23 Oct '11
by metan 23 Oct '11
23 Oct '11
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/cbea4b71a8151b445c662f50b12b50dccb72…
commit cbea4b71a8151b445c662f50b12b50dccb7285c9
Author: Cyril Hrubis <metan(a)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(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)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(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)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(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)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(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)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(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.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: 2f57806a0c4f164121638af4f28a43c73b3bf4c5
by metan 15 Oct '11
by metan 15 Oct '11
15 Oct '11
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 2f57806a0c4f164121638af4f28a43c73b3bf4c5 (commit)
from e5413870bee8686f02e4123c1db175ba61821220 (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/2f57806a0c4f164121638af4f28a43c73b3b…
commit 2f57806a0c4f164121638af4f28a43c73b3bf4c5
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Oct 15 23:41:18 2011 +0200
This one was actually correct before.
diff --git a/libs/gfx/algo/Line.algo.h b/libs/gfx/algo/Line.algo.h
index 3eccb3a..afc37dc 100644
--- a/libs/gfx/algo/Line.algo.h
+++ b/libs/gfx/algo/Line.algo.h
@@ -66,7 +66,7 @@ void FN_NAME(CONTEXT_T context, int x0, int y0, int x1, int y1, int error = deltax / 2; int y = y0, x; int ystep = (y0 < y1) ? 1 : -1; - for (x = x0; x < x1; x++) { + for (x = x0; x <= x1; x++) { if (steep) PUTPIXEL(context, y, x, pixval);
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/algo/Line.algo.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.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: e5413870bee8686f02e4123c1db175ba61821220
by metan 15 Oct '11
by metan 15 Oct '11
15 Oct '11
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 e5413870bee8686f02e4123c1db175ba61821220 (commit)
from 79941fab71a6136cc5ad405d77ff8fb3164b5ce9 (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/e5413870bee8686f02e4123c1db175ba6182…
commit e5413870bee8686f02e4123c1db175ba61821220
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Oct 15 23:16:20 2011 +0200
Fix previous commit.
diff --git a/libs/gfx/GP_HLine.c b/libs/gfx/GP_HLine.c
index 720475c..c249f49 100644
--- a/libs/gfx/GP_HLine.c
+++ b/libs/gfx/GP_HLine.c
@@ -34,8 +34,8 @@ DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_W
DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp)
DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
-DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
-DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
+DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels4bpp)
+DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels4bpp)
DEF_HLINE_FN(GP_HLine_Raw_8BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels8bpp)
DEF_HLINE_FN(GP_HLine_Raw_16BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels16bpp)
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/GP_HLine.c | 4 ++--
1 files changed, 2 insertions(+), 2 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.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: 79941fab71a6136cc5ad405d77ff8fb3164b5ce9
by metan 15 Oct '11
by metan 15 Oct '11
15 Oct '11
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 79941fab71a6136cc5ad405d77ff8fb3164b5ce9 (commit)
from b8038ff42052c3ff217d4739e5501279936d0303 (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/79941fab71a6136cc5ad405d77ff8fb3164b…
commit 79941fab71a6136cc5ad405d77ff8fb3164b5ce9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Oct 15 20:17:46 2011 +0200
Back at the size - 1 for GP_*XYWH GP_*XYW and GP_*XYH.
diff --git a/libs/gfx/GP_HLine.c b/libs/gfx/GP_HLine.c
index 1abb073..720475c 100644
--- a/libs/gfx/GP_HLine.c
+++ b/libs/gfx/GP_HLine.c
@@ -34,8 +34,8 @@ DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_W
DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp)
DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
-DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels4bpp)
-DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels4bpp)
+DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
+DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
DEF_HLINE_FN(GP_HLine_Raw_8BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels8bpp)
DEF_HLINE_FN(GP_HLine_Raw_16BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels16bpp)
@@ -55,7 +55,10 @@ void GP_HLineXXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
void GP_HLineXYW_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
GP_Pixel pixel)
{
- GP_HLineXXY_Raw(context, x, x + w, y, pixel);
+ if (w == 0)
+ return;
+
+ GP_HLineXXY_Raw(context, x, x + w - 1, y, pixel);
}
void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y,
@@ -79,5 +82,8 @@ void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y,
void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
GP_Pixel pixel)
{
- GP_HLineXXY(context, x, x + w, y, pixel);
+ if (w == 0)
+ return;
+
+ GP_HLineXXY(context, x, x + w - 1, y, pixel);
}
diff --git a/libs/gfx/GP_Rect.c b/libs/gfx/GP_Rect.c
index f6a303e..5e8fbc7 100644
--- a/libs/gfx/GP_Rect.c
+++ b/libs/gfx/GP_Rect.c
@@ -37,10 +37,10 @@ void GP_RectXYXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
void GP_RectXYWH_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
GP_Size w, GP_Size h, GP_Pixel pixel)
{
- GP_HLine_Raw(context, x, x + w, y, pixel);
- GP_HLine_Raw(context, x, x + w, y + h, pixel);
- GP_VLine_Raw(context, x, y, y + h, pixel);
- GP_VLine_Raw(context, x + w, y, y + h, pixel);
+ if (w == 0 || h == 0)
+ return;
+
+ GP_RectXYXY_Raw(context, x, y, x + w - 1, y + h - 1, pixel);
}
void GP_RectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
@@ -57,7 +57,10 @@ void GP_RectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
void GP_RectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
GP_Size w, GP_Size h, GP_Pixel pixel)
{
- GP_RectXYXY(context, x, y, x + w, y + h, pixel);
+ if (w == 0 || h == 0)
+ return;
+
+ GP_RectXYXY(context, x, y, x + w - 1, y + h - 1, pixel);
}
void GP_FillRectXYXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
@@ -76,7 +79,10 @@ void GP_FillRectXYXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
void GP_FillRectXYWH_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
GP_Size w, GP_Size h, GP_Pixel pixel)
{
- GP_FillRectXYXY_Raw(context, x, y, x + w, y + h, pixel);
+ if (w == 0 || h == 0)
+ return;
+
+ GP_FillRectXYXY_Raw(context, x, y, x + w - 1, y + h - 1, pixel);
}
void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
@@ -93,5 +99,8 @@ void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
void GP_FillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
GP_Size w, GP_Size h, GP_Pixel pixel)
{
- GP_FillRectXYXY(context, x, y, x + w, y + h, pixel);
+ if (w == 0 || h == 0)
+ return;
+
+ GP_FillRectXYXY(context, x, y, x + w - 1, y + h - 1, pixel);
}
diff --git a/libs/gfx/GP_VLine.c b/libs/gfx/GP_VLine.c
index af9ad15..88cde1e 100644
--- a/libs/gfx/GP_VLine.c
+++ b/libs/gfx/GP_VLine.c
@@ -42,7 +42,10 @@ void GP_VLineXYY_Raw(GP_Context *context, GP_Coord x, GP_Coord y0,
void GP_VLineXYH_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size h,
GP_Pixel pixel)
{
- GP_VLineXYY(context, x, y, y + h, pixel);
+ if (h == 0)
+ return;
+
+ GP_VLineXYY(context, x, y, y + h - 1, pixel);
}
void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0,
@@ -66,5 +69,8 @@ void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0,
void GP_VLineXYH(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size h,
GP_Pixel pixel)
{
- GP_VLineXYY(context, x, y, y + h, pixel);
+ if (h == 0)
+ return;
+
+ GP_VLineXYY(context, x, y, y + h - 1, pixel);
}
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/GP_HLine.c | 14 ++++++++++----
libs/gfx/GP_Rect.c | 23 ++++++++++++++++-------
libs/gfx/GP_VLine.c | 10 ++++++++--
3 files changed, 34 insertions(+), 13 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.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: b8038ff42052c3ff217d4739e5501279936d0303
by metan 15 Oct '11
by metan 15 Oct '11
15 Oct '11
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 b8038ff42052c3ff217d4739e5501279936d0303 (commit)
via 831f6b2be47a611581e47f7616516bc70c9d91c7 (commit)
from f6c5774e42d209fcc3bff4acb515739172dfdb97 (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/b8038ff42052c3ff217d4739e5501279936d…
commit b8038ff42052c3ff217d4739e5501279936d0303
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Oct 15 15:55:41 2011 +0200
Make the GP_Color API match the GP_Pixel API.
diff --git a/include/core/GP_Color.h b/include/core/GP_Color.h
index a636cd0..4e39e07 100644
--- a/include/core/GP_Color.h
+++ b/include/core/GP_Color.h
@@ -36,6 +36,9 @@
#include "GP_Context.h"
#include "GP_Pixel.h"
+/*
+ * Enumeration of color constants.
+ */
typedef enum GP_Color {
GP_COL_INVALID = -1,
GP_COL_BLACK,
@@ -53,21 +56,67 @@ typedef enum GP_Color {
} GP_Color;
/*
- * Converts Color to Pixel
+ * Converts GP_Color to GP_Pixel.
+ */
+GP_Pixel GP_ColorToPixel(GP_Color color, GP_PixelType pixel_type);
+
+/*
+ * Converts GP_Color to GP_Pixel.
*/
-GP_Pixel GP_ColorToPixel(GP_Context *context, GP_Color color);
+static inline GP_Pixel GP_ColorToContextPixel(GP_Color color,
+ GP_Context *context)
+{
+ return GP_ColorToPixel(color, context->pixel_type);
+}
/*
- * Converts Color name to Color.
+ * Converts Color name (eg. string) to GP_Color.
*/
GP_Color GP_ColorNameToColor(const char *color_name);
+/*
+ * Converts GP_Color to color name.
+ *
+ * If color is not valid NULL is returned.
+ */
const char *GP_ColorToColorName(GP_Color color);
/*
* Converts Color name to Pixel.
+ *
+ * Returns true if conversion was successful false otherwise.
*/
-bool GP_ColorNameToPixel(GP_Context *context, const char *color_name,
+bool GP_ColorNameToPixel(const char *color_name, GP_PixelType pixel_type,
GP_Pixel *pixel);
+/*
+ * Converts Color name to Pixel.
+ *
+ * Returns true if conversion was successful false otherwise.
+ */
+static inline bool GP_ColorNameContextToPixel(const char *color_name,
+ GP_PixelType pixel_type,
+ GP_Pixel *pixel)
+{
+ return GP_ColorNameToPixel(color_name, pixel_type, pixel);
+}
+
+/*
+ * Loads all colors into array of GP_Pixel of size GP_COL_MAX.
+ *
+ * The colors are then used as pixels[GP_COL_XXX];
+ */
+void GP_ColorLoadPixels(GP_Pixel pixels[], GP_PixelType pixel_type);
+
+/*
+ * Loads all colors into array of GP_Pixel of size GP_COL_MAX.
+ *
+ * The colors are then used as pixels[GP_COL_XXX];
+ */
+static inline void GP_ColorLoadContextPixels(GP_Pixel pixels[],
+ GP_Context *context)
+{
+ GP_ColorLoadPixels(pixels, context->pixel_type);
+}
+
#endif /* GP_COLOR_H */
diff --git a/libs/core/GP_Color.c b/libs/core/GP_Color.c
index 672089e..bf055b2 100644
--- a/libs/core/GP_Color.c
+++ b/libs/core/GP_Color.c
@@ -19,16 +19,17 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
+#include <stdint.h>
+#include <string.h>
+
#include "GP_Convert.h"
#include "GP_Color.h"
-#include <stdint.h>
-#include <string.h>
static char *color_names[] = {
"Black",
@@ -73,17 +74,18 @@ static uint8_t p8_colors[] = {
0xff, /* White */
};
-GP_Pixel GP_ColorToPixel(GP_Context *context, GP_Color col)
+GP_Pixel GP_ColorToPixel(GP_Color color, GP_PixelType pixel_type)
{
- GP_ASSERT(col < GP_COL_MAX);
- GP_ASSERT(col >= 0);
+ GP_ASSERT(color < GP_COL_MAX);
+ GP_ASSERT(color >= 0);
- if (context->pixel_type == GP_PIXEL_P8)
- return p8_colors[col];
+ if (pixel_type == GP_PIXEL_P8)
+ return p8_colors[color];
- return GP_RGBToPixel(rgb888_colors[col][0],
- rgb888_colors[col][1],
- rgb888_colors[col][2], context->pixel_type);
+ return GP_RGBToPixel(rgb888_colors[color][0],
+ rgb888_colors[color][1],
+ rgb888_colors[color][2],
+ pixel_type);
}
GP_Color GP_ColorNameToColor(const char *color_name)
@@ -97,23 +99,31 @@ GP_Color GP_ColorNameToColor(const char *color_name)
return -1;
}
-const char *GP_ColorToColorName(GP_Color col)
+const char *GP_ColorToColorName(GP_Color color)
{
- if (col < 0 || col >= GP_COL_MAX)
+ if (color < 0 || color >= GP_COL_MAX)
return NULL;
- return color_names[col];
+ return color_names[color];
}
-bool GP_ColorNameToPixel(GP_Context *context, const char *color_name,
+bool GP_ColorNameToPixel(const char *color_name, GP_PixelType pixel_type,
GP_Pixel *pixel)
{
- GP_Color col = GP_ColorNameToColor(color_name);
+ GP_Color color = GP_ColorNameToColor(color_name);
- if (col == GP_COL_INVALID)
+ if (color == GP_COL_INVALID)
return false;
- *pixel = GP_ColorToPixel(context, col);
+ *pixel = GP_ColorToPixel(pixel_type, color);
return true;
}
+
+void GP_ColorLoadPixels(GP_Pixel pixels[], GP_PixelType pixel_type)
+{
+ unsigned int i;
+
+ for (i = 0; i < GP_COL_MAX; i++)
+ pixels[i] = GP_ColorToPixel(i, pixel_type);
+}
diff --git a/tests/SDL/blittest.c b/tests/SDL/blittest.c
index a62d381..be39c83 100644
--- a/tests/SDL/blittest.c
+++ b/tests/SDL/blittest.c
@@ -187,8 +187,8 @@ int main(int argc, char *argv[])
bitmap_conv = GP_ContextConvert(bitmap_raw, context.pixel_type);
change_bitmap();
- black = GP_ColorToPixel(&context, GP_COL_BLACK);
- white = GP_ColorToPixel(&context, GP_COL_WHITE);
+ black = GP_ColorToContextPixel(GP_COL_BLACK, &context);
+ white = GP_ColorToContextPixel(GP_COL_WHITE, &context);
/* Set up the refresh timer */
timer = SDL_AddTimer(60, timer_callback, NULL);
diff --git a/tests/SDL/fileview.c b/tests/SDL/fileview.c
index d4ceeda..c01a7fc 100644
--- a/tests/SDL/fileview.c
+++ b/tests/SDL/fileview.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -238,12 +238,12 @@ int main(int argc, char *argv[])
GP_SDL_ContextFromSurface(&context, display);
/* Load colors suitable for the display */
- white_pixel = GP_ColorToPixel(&context, GP_COL_WHITE);
- gray_pixel = GP_ColorToPixel(&context, GP_COL_GRAY_LIGHT);
- dark_gray_pixel = GP_ColorToPixel(&context, GP_COL_GRAY_DARK);
- black_pixel = GP_ColorToPixel(&context, GP_COL_BLACK);
- red_pixel = GP_ColorToPixel(&context, GP_COL_RED);
- blue_pixel = GP_ColorToPixel(&context, GP_COL_BLUE);
+ white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, &context);
+ gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, &context);
+ dark_gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, &context);
+ black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, &context);
+ red_pixel = GP_ColorToContextPixel(GP_COL_RED, &context);
+ blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, &context);
redraw_screen();
SDL_Flip(display);
diff --git a/tests/SDL/fonttest.c b/tests/SDL/fonttest.c
index 91f42fc..602c526 100644
--- a/tests/SDL/fonttest.c
+++ b/tests/SDL/fonttest.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -231,12 +231,12 @@ int main(int argc, char *argv[])
GP_SDL_ContextFromSurface(&context, display);
/* Load colors suitable for the display */
- white_pixel = GP_ColorToPixel(&context, GP_COL_WHITE);
- gray_pixel = GP_ColorToPixel(&context, GP_COL_GRAY_LIGHT);
- dark_gray_pixel = GP_ColorToPixel(&context, GP_COL_GRAY_DARK);
- black_pixel = GP_ColorToPixel(&context, GP_COL_BLACK);
- red_pixel = GP_ColorToPixel(&context, GP_COL_RED);
- blue_pixel = GP_ColorToPixel(&context, GP_COL_BLUE);
+ white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, &context);
+ gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, &context);
+ dark_gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, &context);
+ black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, &context);
+ red_pixel = GP_ColorToContextPixel(GP_COL_RED, &context);
+ blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, &context);
redraw_screen();
SDL_Flip(display);
diff --git a/tests/SDL/input.c b/tests/SDL/input.c
index ebc7820..c420b09 100644
--- a/tests/SDL/input.c
+++ b/tests/SDL/input.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -30,18 +30,13 @@
#include "GP.h"
#include "GP_SDL.h"
-/* The surface used as a display (in fact it is a software surface). */
SDL_Surface *display = NULL;
GP_Context context;
-/* Timer used for refreshing the display */
SDL_TimerID timer;
-
-/* An event used for signaling that the timer was triggered. */
SDL_UserEvent timer_event;
-/* Values for color pixels in display format. */
-GP_Pixel black_pixel, red_pixel, green_pixel, blue_pixel, white_pixel;
+GP_Pixel black_pixel, red_pixel, green_pixel, white_pixel;
Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
__attribute__((unused)) void *param)
@@ -51,17 +46,7 @@ Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
return 30;
}
-void draw_pixel(void)
-{
-// GP_Color pixel, conv;
- int x = random() % 320;
- int y = random() % 240;
-
-
- GP_PutPixel(&context, x, y, green_pixel);
-}
-
-void draw_event(GP_Event *ev)
+static void draw_event(GP_Event *ev)
{
if (ev->type != GP_EV_KEY)
return;
@@ -72,19 +57,7 @@ void draw_event(GP_Event *ev)
SDL_Flip(display);
}
-void draw_pixels(void)
-{
- SDL_LockSurface(display);
-
- /* Draw some pixels (exact number is not important). */
- int i;
- for (i = 0; i < 30; i++)
- draw_pixel();
-
- SDL_UnlockSurface(display);
-}
-
-void event_loop(void)
+static void event_loop(void)
{
SDL_Event event;
@@ -107,8 +80,12 @@ void event_loop(void)
exit(0);
break;
case GP_BTN_LEFT:
- GP_PutPixel(&context, ev.cursor_x,
- ev.cursor_y, red_pixel);
+ GP_HLineXXY(&context, ev.cursor_x - 3,
+ ev.cursor_x + 3,
+ ev.cursor_y, red_pixel);
+ GP_VLineXYY(&context, ev.cursor_x,
+ ev.cursor_y - 3,
+ ev.cursor_y + 3, red_pixel);
SDL_Flip(display);
break;
default:
@@ -131,7 +108,7 @@ void event_loop(void)
}
}
-int main(int argc, char **argv)
+int main(int argc, char *argv[])
{
int display_bpp = 0;
@@ -150,7 +127,6 @@ int main(int argc, char **argv)
return 1;
}
- /* Create a window with a software back surface */
display = SDL_SetVideoMode(480, 640, display_bpp, SDL_SWSURFACE);
if (display == NULL) {
fprintf(stderr, "Could not open display: %sn", SDL_GetError());
@@ -159,37 +135,20 @@ int main(int argc, char **argv)
GP_EventSetScreenSize(480, 640);
- /* Print basic information about the surface */
- printf("Display surface properties:n");
- printf(" width: %4d, height: %4d, pitch: %4dn",
- display->w, display->h, display->pitch);
- printf(" bits per pixel: %2d, bytes per pixel: %2dn",
- display->format->BitsPerPixel, display->format->BytesPerPixel);
-
- /* Set up a clipping rectangle to test proper clipping of pixels */
- SDL_Rect clip_rect = {10, 10, 300, 220};
- SDL_SetClipRect(display, &clip_rect);
-
GP_SDL_ContextFromSurface(&context, display);
- /* Load pixel values compatible with the display. */
- red_pixel = GP_ColorToPixel(&context, GP_COL_RED);
- green_pixel = GP_ColorToPixel(&context, GP_COL_GREEN);
- blue_pixel = GP_ColorToPixel(&context, GP_COL_BLUE);
- white_pixel = GP_ColorToPixel(&context, GP_COL_WHITE);
- black_pixel = GP_ColorToPixel(&context, GP_COL_BLACK);
+ red_pixel = GP_ColorToContextPixel(GP_COL_RED, &context);
+ green_pixel = GP_ColorToContextPixel(GP_COL_GREEN, &context);
+ white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, &context);
+ black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, &context);
- /* Set up the refresh timer */
timer = SDL_AddTimer(30, timer_callback, NULL);
if (timer == 0) {
fprintf(stderr, "Could not set up timer: %sn", SDL_GetError());
goto fail;
}
- /* Enter the event loop */
event_loop();
-
- /* We're done */
SDL_Quit();
return 0;
diff --git a/tests/SDL/linetest.c b/tests/SDL/linetest.c
index 245b1ce..1b01a3a 100644
--- a/tests/SDL/linetest.c
+++ b/tests/SDL/linetest.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -124,8 +124,8 @@ int main(int argc, char **argv)
GP_SDL_ContextFromSurface(&context, display);
/* Load colors in display format */
- black = GP_ColorToPixel(&context, GP_COL_BLACK);
- white = GP_ColorToPixel(&context, GP_COL_WHITE);
+ black = GP_ColorToContextPixel(GP_COL_BLACK, &context);
+ white = GP_ColorToContextPixel(GP_COL_WHITE, &context);
/* Set up the refresh timer */
timer = SDL_AddTimer(30, timer_callback, NULL);
diff --git a/tests/SDL/pixeltest.c b/tests/SDL/pixeltest.c
index 7102074..6d7ccf0 100644
--- a/tests/SDL/pixeltest.c
+++ b/tests/SDL/pixeltest.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -53,34 +53,25 @@ Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
void draw_pixel(void)
{
-// GP_Color pixel, conv;
+ GP_Pixel pixel;
int x = random() % 320;
int y = random() % 240;
-// pixel = GP_GetPixel(&context, x, y);
+ pixel = GP_GetPixel(&context, x, y);
- GP_PutPixel(&context, x, y, green_pixel);
-
- /* TODO: we cannot switch like this
- we need either to convert blue
- and others into Context format
- at the very beginning, or make
- a copy to convert it and match
- agains what we get from GP_GetPixel
-
- if (pixel == blue) {
- GP_PutPixel(&context, x, y, green);
+ if (pixel == blue_pixel) {
+ GP_PutPixel(&context, x, y, green_pixel);
}
- else if (pixel == red) {
- GP_PutPixel(&context, x, y, white);
+ else if (pixel == red_pixel) {
+ GP_PutPixel(&context, x, y, white_pixel);
}
else {
if (x < 160) {
- GP_PutPixel(&context, x, y, blue);
+ GP_PutPixel(&context, x, y, blue_pixel);
} else {
- GP_PutPixel(&context, x, y, red);
+ GP_PutPixel(&context, x, y, red_pixel);
}
- } */
+ }
}
void draw_pixels(void)
@@ -153,10 +144,10 @@ int main(int argc, char **argv)
GP_SDL_ContextFromSurface(&context, display);
/* Load pixel values compatible with the display. */
- red_pixel = GP_ColorToPixel(&context, GP_COL_RED);
- green_pixel = GP_ColorToPixel(&context, GP_COL_GREEN);
- blue_pixel = GP_ColorToPixel(&context, GP_COL_BLUE);
- white_pixel = GP_ColorToPixel(&context, GP_COL_WHITE);
+ red_pixel = GP_ColorToContextPixel(GP_COL_RED, &context);
+ green_pixel = GP_ColorToContextPixel(GP_COL_GREEN, &context);
+ blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, &context);
+ white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, &context);
/* Set up the refresh timer */
timer = SDL_AddTimer(30, timer_callback, NULL);
diff --git a/tests/SDL/randomshapetest.c b/tests/SDL/randomshapetest.c
index 592d466..edc8554 100644
--- a/tests/SDL/randomshapetest.c
+++ b/tests/SDL/randomshapetest.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -300,8 +300,8 @@ int main(int argc, char *argv[])
GP_SDL_ContextFromSurface(&context, display);
- white = GP_ColorToPixel(&context, GP_COL_WHITE);
- black = GP_ColorToPixel(&context, GP_COL_BLACK);
+ white = GP_ColorToContextPixel(GP_COL_WHITE, &context);
+ black = GP_ColorToContextPixel(GP_COL_BLACK, &context);
/* Set up the refresh timer */
timer = SDL_AddTimer(60, timer_callback, NULL);
diff --git a/tests/SDL/shapetest.c b/tests/SDL/shapetest.c
index 3c61629..d270528 100644
--- a/tests/SDL/shapetest.c
+++ b/tests/SDL/shapetest.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -507,13 +507,13 @@ int main(int argc, char ** argv)
GP_SDL_ContextFromSurface(&context, display);
/* Load colors compatible with the display */
- black = GP_ColorToPixel(&context, GP_COL_BLACK);
- white = GP_ColorToPixel(&context, GP_COL_WHITE);
- yellow = GP_ColorToPixel(&context, GP_COL_YELLOW);
- green = GP_ColorToPixel(&context, GP_COL_GREEN);
- red = GP_ColorToPixel(&context, GP_COL_RED);
- gray = GP_ColorToPixel(&context, GP_COL_GRAY_LIGHT);
- darkgray = GP_ColorToPixel(&context, GP_COL_GRAY_DARK);
+ black = GP_ColorToContextPixel(GP_COL_BLACK, &context);
+ white = GP_ColorToContextPixel(GP_COL_WHITE, &context);
+ yellow = GP_ColorToContextPixel(GP_COL_YELLOW, &context);
+ green = GP_ColorToContextPixel(GP_COL_GREEN, &context);
+ red = GP_ColorToContextPixel(GP_COL_RED, &context);
+ gray = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, &context);
+ darkgray = GP_ColorToContextPixel(GP_COL_GRAY_DARK, &context);
/* Set up the refresh timer */
timer = SDL_AddTimer(60, timer_callback, NULL);
diff --git a/tests/SDL/sierpinsky.c b/tests/SDL/sierpinsky.c
index b2e6dd8..04ad559 100644
--- a/tests/SDL/sierpinsky.c
+++ b/tests/SDL/sierpinsky.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -114,7 +114,8 @@ static void draw(int x, int y, int l, int iter)
int paused = 0;
-Uint32 timer_callback(Uint32 interval __attribute__ ((unused)), void *ptr __attribute__ ((unused)))
+Uint32 timer_callback(Uint32 interval __attribute__ ((unused)),
+ void *ptr __attribute__ ((unused)))
{
if (paused)
return TIMER_TICK;
@@ -162,10 +163,10 @@ int main(void)
display = SDL_GetVideoSurface();
context = GP_GetBackendVideoContext();
- black = GP_ColorToPixel(context, GP_COL_BLACK);
- blue = GP_ColorToPixel(context, GP_COL_BLUE);
- gray = GP_ColorToPixel(context, GP_COL_GRAY_LIGHT);
- red = GP_ColorToPixel(context, GP_COL_RED);
+ black = GP_ColorToContextPixel(GP_COL_BLACK, context);
+ blue = GP_ColorToContextPixel(GP_COL_BLUE, context);
+ gray = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, context);
+ red = GP_ColorToContextPixel(GP_COL_RED, context);
iter = 0;
draw(display->w/2, display->h/2, l, iter);
diff --git a/tests/SDL/subcontext.c b/tests/SDL/subcontext.c
index b8f68c4..bbdfeae 100644
--- a/tests/SDL/subcontext.c
+++ b/tests/SDL/subcontext.c
@@ -31,7 +31,7 @@
#include "GP.h"
#include "GP_SDL.h"
-static GP_Pixel black, white, gray, red, green;
+static GP_Pixel black, white, gray;
SDL_Surface *display = NULL;
GP_Context context, *sub_context;
@@ -256,11 +256,9 @@ int main(int argc, char *argv[])
GP_SDL_ContextFromSurface(&context, display);
- black = GP_ColorToPixel(&context, GP_COL_BLACK);
- white = GP_ColorToPixel(&context, GP_COL_WHITE);
- gray = GP_ColorToPixel(&context, GP_COL_GRAY_DARK);
- red = GP_ColorToPixel(&context, GP_COL_RED);
- green = GP_ColorToPixel(&context, GP_COL_GREEN);
+ black = GP_ColorToContextPixel(GP_COL_BLACK, &context);
+ white = GP_ColorToContextPixel(GP_COL_WHITE, &context);
+ gray = GP_ColorToContextPixel(GP_COL_GRAY_DARK, &context);
sub_context = GP_ContextSubContext(&context, 100, 100, 440, 280);
GP_Fill(sub_context, gray);
diff --git a/tests/SDL/symbolstest.c b/tests/SDL/symbolstest.c
index e7fd0a3..be96422 100644
--- a/tests/SDL/symbolstest.c
+++ b/tests/SDL/symbolstest.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -172,7 +172,7 @@ int main(int argc, char *argv[])
GP_SDL_ContextFromSurface(&context, display);
- black = GP_ColorToPixel(&context, GP_COL_BLACK);
+ black = GP_ColorToContextPixel(GP_COL_BLACK, &context);
/* Set up the refresh timer */
timer = SDL_AddTimer(60, timer_callback, NULL);
diff --git a/tests/SDL/textaligntest.c b/tests/SDL/textaligntest.c
index 0ecad33..507b560 100644
--- a/tests/SDL/textaligntest.c
+++ b/tests/SDL/textaligntest.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -159,12 +159,12 @@ int main(void)
GP_SDL_ContextFromSurface(&context, display);
/* Load colors suitable for the display */
- black_pixel = GP_ColorToPixel(&context, GP_COL_BLACK);
- red_pixel = GP_ColorToPixel(&context, GP_COL_RED);
- blue_pixel = GP_ColorToPixel(&context, GP_COL_BLUE);
- green_pixel = GP_ColorToPixel(&context, GP_COL_GREEN);
- yellow_pixel = GP_ColorToPixel(&context, GP_COL_YELLOW);
- darkgray_pixel = GP_ColorToPixel(&context, GP_COL_GRAY_DARK);
+ black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, &context);
+ red_pixel = GP_ColorToContextPixel(GP_COL_RED, &context);
+ blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, &context);
+ green_pixel = GP_ColorToContextPixel(GP_COL_GREEN, &context);
+ yellow_pixel = GP_ColorToContextPixel(GP_COL_YELLOW, &context);
+ darkgray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, &context);
redraw_screen();
SDL_Flip(display);
diff --git a/tests/SDL/trianglefps.c b/tests/SDL/trianglefps.c
index cf163bf..5eda430 100644
--- a/tests/SDL/trianglefps.c
+++ b/tests/SDL/trianglefps.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -159,8 +159,8 @@ int main(int argc, char ** argv)
GP_SDL_ContextFromSurface(&context, display);
- white = GP_ColorToPixel(&context, GP_COL_WHITE);
- black = GP_ColorToPixel(&context, GP_COL_BLACK);
+ white = GP_ColorToContextPixel(GP_COL_WHITE, &context);
+ black = GP_ColorToContextPixel(GP_COL_BLACK, &context);
/* Set up the timer */
timer = SDL_AddTimer(1000, timer_callback, NULL);
http://repo.or.cz/w/gfxprim.git/commit/831f6b2be47a611581e47f7616516bc70c9d…
commit 831f6b2be47a611581e47f7616516bc70c9d91c7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Oct 15 15:46:36 2011 +0200
Remove unneeded header dependencies.
diff --git a/include/core/GP_Core.h b/include/core/GP_Core.h
index b080db7..9bd927f 100644
--- a/include/core/GP_Core.h
+++ b/include/core/GP_Core.h
@@ -56,4 +56,7 @@
/* Debug and debug level */
#include "core/GP_Debug.h"
+/* Color */
+#include "core/GP_Color.h"
+
#endif /* GP_CORE_H */
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h
index 4639b1f..5ab2f03 100644
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_Gfx.h
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -33,13 +33,9 @@
#define GP_GFX_H
/* basic definitions and structures */
-#include "core/GP_Common.h"
-#include "core/GP_Types.h"
-#include "core/GP_Transform.h"
#include "core/GP_Context.h"
-#include "core/GP_WritePixel.h"
#include "core/GP_GetPutPixel.h"
-#include "core/GP_Color.h"
+#include "core/GP_WritePixel.h"
/* public drawing API */
#include "GP_Fill.h"
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Color.h | 57 ++++++++++++++++++++++++++++++++--
include/core/GP_Core.h | 3 ++
include/gfx/GP_Gfx.h | 8 +----
libs/core/GP_Color.c | 46 +++++++++++++++++-----------
tests/SDL/blittest.c | 4 +-
tests/SDL/fileview.c | 14 ++++----
tests/SDL/fonttest.c | 14 ++++----
tests/SDL/input.c | 71 +++++++++----------------------------------
tests/SDL/linetest.c | 6 ++--
tests/SDL/pixeltest.c | 37 ++++++++--------------
tests/SDL/randomshapetest.c | 6 ++--
tests/SDL/shapetest.c | 16 +++++-----
tests/SDL/sierpinsky.c | 13 ++++----
tests/SDL/subcontext.c | 10 ++----
tests/SDL/symbolstest.c | 4 +-
tests/SDL/textaligntest.c | 14 ++++----
tests/SDL/trianglefps.c | 6 ++--
17 files changed, 168 insertions(+), 161 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.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: f6c5774e42d209fcc3bff4acb515739172dfdb97
by metan 15 Oct '11
by metan 15 Oct '11
15 Oct '11
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 f6c5774e42d209fcc3bff4acb515739172dfdb97 (commit)
from aa38ffc5adc9cd8ed510838924a420eab3e64ce2 (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/f6c5774e42d209fcc3bff4acb515739172df…
commit f6c5774e42d209fcc3bff4acb515739172dfdb97
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Oct 15 11:58:53 2011 +0200
Fix include.
diff --git a/include/filters/GP_Point.h b/include/filters/GP_Point.h
index 8ef935b..b5e7d50 100644
--- a/include/filters/GP_Point.h
+++ b/include/filters/GP_Point.h
@@ -29,7 +29,7 @@
#ifndef GP_POINT_H
#define GP_POINT_H
-#include <GP_Context.h>
+#include "core/GP_Context.h"
/*
* Brightness filter.
-----------------------------------------------------------------------
Summary of changes:
include/filters/GP_Point.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.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: aa38ffc5adc9cd8ed510838924a420eab3e64ce2
by metan 15 Oct '11
by metan 15 Oct '11
15 Oct '11
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 aa38ffc5adc9cd8ed510838924a420eab3e64ce2 (commit)
via ab9ecb3a6e5a775eb10a8e3b82753da21f5d486a (commit)
from 37c452a809960d666b96c68e30349aa8e17041a7 (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/aa38ffc5adc9cd8ed510838924a420eab3e6…
commit aa38ffc5adc9cd8ed510838924a420eab3e64ce2
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 14 13:08:59 2011 +0000
GP_PNG.c: fix printf format warnings.
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 50395b4..dae8120 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -112,7 +112,7 @@ GP_RetCode GP_ReadPNG(FILE *f, GP_Context **res)
color_type & PNG_COLOR_MASK_PALETTE ? "pallete " : "",
color_type & PNG_COLOR_MASK_COLOR ? "color" : "gray",
color_type & PNG_COLOR_MASK_ALPHA ? " with alpha channel" : "",
- w, h, depth);
+ (unsigned int)w, (unsigned int)h, depth);
switch (color_type) {
case PNG_COLOR_TYPE_GRAY:
http://repo.or.cz/w/gfxprim.git/commit/ab9ecb3a6e5a775eb10a8e3b82753da21f5d…
commit ab9ecb3a6e5a775eb10a8e3b82753da21f5d486a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Oct 14 13:06:08 2011 +0000
GP_Polygon.c: remove unused variables.
diff --git a/libs/gfx/GP_Polygon.c b/libs/gfx/GP_Polygon.c
index cef18c0..fa82216 100644
--- a/libs/gfx/GP_Polygon.c
+++ b/libs/gfx/GP_Polygon.c
@@ -161,8 +161,6 @@ void GP_FillPolygon_Raw(GP_Context *context, GP_Coord vertex_count,
GP_LoadPolygon(&poly, vertex_count, xy);
GP_Coord y, startx, endx;
- GP_Coord startx_prev = -INT_MAX;
- GP_Coord endx_prev = INT_MAX;
for (y = poly.ymin; y <= poly.ymax; y++) {
startx = INT_MAX;
@@ -188,9 +186,6 @@ void GP_FillPolygon_Raw(GP_Context *context, GP_Coord vertex_count,
}
GP_HLine_Raw(context, startx, endx, y, pixel);
-
- startx_prev = startx;
- endx_prev = endx;
}
GP_ResetPolygon(&poly);
-----------------------------------------------------------------------
Summary of changes:
libs/gfx/GP_Polygon.c | 5 -----
libs/loaders/GP_PNG.c | 2 +-
2 files changed, 1 insertions(+), 6 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.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: 37c452a809960d666b96c68e30349aa8e17041a7
by metan 13 Oct '11
by metan 13 Oct '11
13 Oct '11
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 37c452a809960d666b96c68e30349aa8e17041a7 (commit)
from 711ed658bc24822ac5d4d08a8eb435352f08036f (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/37c452a809960d666b96c68e30349aa8e170…
commit 37c452a809960d666b96c68e30349aa8e17041a7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Oct 13 22:34:48 2011 +0200
Started to work on framebuffer driver (again).
diff --git a/include/backends/GP_Framebuffer.h b/include/backends/GP_Framebuffer.h
new file mode 100644
index 0000000..010ed7f
--- /dev/null
+++ b/include/backends/GP_Framebuffer.h
@@ -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-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#ifndef GP_FRAMEBUFFER_H
+#define GP_FRAMEBUFFER_H
+
+#include "core/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/include/core/GP_Pixel.h b/include/core/GP_Pixel.h
index fb38acb..2b06cee 100644
--- a/include/core/GP_Pixel.h
+++ b/include/core/GP_Pixel.h
@@ -158,13 +158,23 @@ static inline void GP_PixelPrint(GP_Pixel pixel, GP_PixelType type)
}
/*
- * Match pixel type to known pixel types, pixel_size is in bits.
+ * Match pixel type to known pixel types.
*
* Returns either valid PixelType or GP_PIXEL_UNKNOWN
*/
GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
GP_Pixel bmask, GP_Pixel amask,
- uint8_t pixel_size);
+ uint8_t bits_per_pixel);
+/*
+ * Similar to GP_PixelRGBMatch but works with offsets and sizes
+ *
+ * Returns either valid PixelType or GP_PIXEL_UNKNOWN
+ */
+GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff,
+ uint32_t gsize, uint32_t goff,
+ uint32_t bsize, uint32_t boff,
+ uint32_t asize, uint32_t aoff,
+ uint8_t bits_per_pixel);
#endif /* GP_PIXEL_H */
diff --git a/libs/backends/GP_Framebuffer.c b/libs/backends/GP_Framebuffer.c
new file mode 100644
index 0000000..4eae632
--- /dev/null
+++ b/libs/backends/GP_Framebuffer.c
@@ -0,0 +1,216 @@
+/*****************************************************************************
+ * 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-2011 Cyril Hrubis <metan(a)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 <errno.h>
+
+#include <linux/fb.h>
+#include <linux/kd.h>
+#include <linux/vt.h>
+
+#include "core/GP_Debug.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) {
+ GP_DEBUG(1, "Opening console /dev/tty1 failed: %s",
+ strerror(errno));
+ return -1;
+ }
+
+ if (ioctl(fd, VT_OPENQRY, &nr) < 0) {
+ GP_DEBUG(1, "Failed to ioctl VT_OPENQRY /dev/tty1: %s",
+ strerror(errno));
+ close(fd);
+ return -1;
+ }
+
+ close(fd);
+
+ snprintf(buf, sizeof(buf), "/dev/tty%i", nr);
+ fd = open(buf, O_RDWR);
+
+ if (fd < 0) {
+ GP_DEBUG(1, "Opening console %s failed: %s",
+ buf, strerror(errno));
+ 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) {
+ GP_DEBUG(1, "Failed to ioctl VT_ACTIVATE %s: %s",
+ buf, strerror(errno));
+ close(fd);
+ return -1;
+ }
+
+ if (ioctl(fd, VT_WAITACTIVE, nr) < 0) {
+ GP_DEBUG(1, "Failed to ioctl VT_WAITACTIVE %s: %s",
+ buf, strerror(errno));
+ close(fd);
+ return -1;
+ }
+
+ /* turn off blinking cursor */
+ if (ioctl(fd, KDSETMODE, KD_GRAPHICS) < 0) {
+ GP_DEBUG(1, "Failed to ioctl KDSETMODE %s: %s",
+ buf, strerror(errno));
+ 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) {
+ GP_DEBUG(1, "Opening framebuffer failed: %s", strerror(errno));
+ goto err2;
+ }
+
+ if (ioctl(fd, FBIOGET_FSCREENINFO, &fscri) < 0) {
+ GP_DEBUG(1, "Failed to ioctl FBIOGET_FSCREENINFO: %s",
+ strerror(errno));
+ goto err3;
+ }
+
+ if (ioctl(fd, FBIOGET_VSCREENINFO, &vscri) < 0) {
+ GP_DEBUG(1, "Failed to ioctl FBIOGET_VSCREENINFO: %s",
+ strerror(errno));
+ goto err3;
+ }
+
+ /*
+ * Framebuffer is grayscale.
+ */
+ if (vscri.grayscale) {
+ //TODO
+ goto err3;
+ }
+
+ enum GP_PixelType pixel_type;
+ pixel_type = GP_PixelRGBLookup(vscri.red.length, vscri.red.offset,
+ vscri.green.length, vscri.green.offset,
+ vscri.blue.length, vscri.blue.offset,
+ vscri.transp.length, vscri.transp.offset,
+ vscri.bits_per_pixel);
+
+ if (pixel_type == GP_PIXEL_UNKNOWN) {
+ GP_DEBUG(1, "Unknown pixel typen");
+ 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) {
+ GP_DEBUG(1, "mmaping framebuffer failed: %s", strerror(errno));
+ 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.bpp = vscri.bits_per_pixel;
+ fb->context.bytes_per_row = fscri.line_length;
+ fb->context.pixel_type = pixel_type;
+
+ return fb;
+err3:
+ close(fd);
+err2:
+ close(fb->con_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);
+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/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c
index bd9f463..98dc0d0 100644
--- a/libs/core/GP_Pixel.c
+++ b/libs/core/GP_Pixel.c
@@ -58,19 +58,19 @@ static int match(const GP_PixelTypeChannel *channel, GP_Pixel mask)
GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
GP_Pixel bmask, GP_Pixel amask,
- uint8_t pixel_size)
+ uint8_t bits_per_pixel)
{
unsigned int i;
GP_DEBUG(1, "Matching Pixel R %08x G %08x B %08x A %08x size %u",
- rmask, gmask, bmask, amask, pixel_size);
+ rmask, gmask, bmask, amask, bits_per_pixel);
for (i = 0; i < GP_PIXEL_MAX; i++) {
int res;
const GP_PixelTypeChannel *r, *g, *b, *a;
- if (GP_PixelTypes[i].size != pixel_size)
+ if (GP_PixelTypes[i].size != bits_per_pixel)
continue;
r = get_channel(&GP_PixelTypes[i], "R");
@@ -79,7 +79,7 @@ GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
a = get_channel(&GP_PixelTypes[i], "A");
GP_DEBUG(2, "Trying Pixel %s %u",
- GP_PixelTypes[i].name, pixel_size);
+ GP_PixelTypes[i].name, bits_per_pixel);
if (r)
GP_DEBUG(3, "Matching R %i %i", r->size, r->offset);
@@ -105,3 +105,48 @@ GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
return GP_PIXEL_UNKNOWN;
}
+
+
+GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff,
+ uint32_t gsize, uint32_t goff,
+ uint32_t bsize, uint32_t boff,
+ uint32_t asize, uint32_t aoff,
+ uint8_t bits_per_pixel)
+{
+ unsigned int i;
+
+ GP_DEBUG(1, "Looking up Pixel R %08x %08x G %08x %08x B %08x %08x size %u",
+ rsize, roff, gsize, goff, bsize, boff, bits_per_pixel);
+
+ for (i = 0; i < GP_PIXEL_MAX; i++) {
+ const GP_PixelTypeChannel *r, *g, *b, *a;
+
+ if (GP_PixelTypes[i].size != bits_per_pixel)
+ continue;
+
+ GP_DEBUG(2, "Trying Pixel %s %u",
+ GP_PixelTypes[i].name, bits_per_pixel);
+
+ r = get_channel(&GP_PixelTypes[i], "R");
+ g = get_channel(&GP_PixelTypes[i], "G");
+ b = get_channel(&GP_PixelTypes[i], "B");
+ a = get_channel(&GP_PixelTypes[i], "A");
+
+ if (a == NULL && asize != 0)
+ continue;
+
+ if (a != NULL && (a->offset != aoff || a->size != asize))
+ continue;
+
+ if (r->offset == roff && r->size == rsize &&
+ g->offset == goff && g->size == gsize &&
+ b->offset == boff && b->size == bsize) {
+ GP_DEBUG(1, "Pixel found type id %u name '%s'",
+ GP_PixelTypes[i].type, GP_PixelTypes[i].name);
+
+ return GP_PixelTypes[i].type;
+ }
+ }
+
+ return GP_PIXEL_UNKNOWN;
+}
-----------------------------------------------------------------------
Summary of changes:
.../drivers => include/backends}/GP_Framebuffer.h | 7 +--
include/core/GP_Pixel.h | 14 +++-
{tests/drivers => libs/backends}/GP_Framebuffer.c | 73 +++++++++++++-------
libs/core/GP_Pixel.c | 53 +++++++++++++-
4 files changed, 112 insertions(+), 35 deletions(-)
copy {tests/drivers => include/backends}/GP_Framebuffer.h (86%)
copy {tests/drivers => libs/backends}/GP_Framebuffer.c (70%)
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.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: 711ed658bc24822ac5d4d08a8eb435352f08036f
by metan 13 Oct '11
by metan 13 Oct '11
13 Oct '11
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 711ed658bc24822ac5d4d08a8eb435352f08036f (commit)
via d5456b7fba99b477b44a663264c2fc9fb590e18b (commit)
from 944dcb4637c7daa52ce37d6fde1b84b44b412e5a (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/711ed658bc24822ac5d4d08a8eb435352f08…
commit 711ed658bc24822ac5d4d08a8eb435352f08036f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Oct 13 21:10:38 2011 +0200
Generate the *FN_PER_BPP* macros from config too.
The GP_DEF_FN_PER_BPP, GP_FN_PER_BPP and GP_FN_RET_PER_BPP are
autogenerated accordingly to the gfxprim_config.py.
The code is not really nice, but it seems to work for now.
Next step is to create WritePixels for 18BPP and test on real HW.
diff --git a/include/core/GP_DefFnPerBpp.h b/include/core/GP_DefFnPerBpp.h
deleted file mode 100644
index 277c956..0000000
--- a/include/core/GP_DefFnPerBpp.h
+++ /dev/null
@@ -1,75 +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-2011 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-/*
- * Macros that gets MACRO template for drawing function and generates drawing
- * functions for each BPP.
- *
- * This functions are later used by GP_FN_PER_BPP_CONTEXT() to generate one
- * drawing function for all BPP Yay!
- */
-#ifndef GP_DEF_FN_PER_BPP_H
-#define GP_DEF_FN_PER_BPP_H
-
-#define GP_DEF_DRAW_FN_PER_BPP(fname, MACRO_NAME) - GP_DEF_FN_PER_BPP(fname, MACRO_NAME, GP_PutPixel_Raw_Clipped_)
-
-#define GP_DEF_FILL_FN_PER_BPP(fname, MACRO_NAME) - GP_DEF_FN_PER_BPP(fname, MACRO_NAME, GP_HLine_Raw_)
-
-#define GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, bpp) - MACRO_NAME(fname##_##bpp, GP_Context *, GP_Pixel, fdraw##bpp)
-
-#define GP_DEF_FN_PER_BPP(fname, MACRO_NAME, fdraw) - GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 1BPP_LE) - GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 1BPP_BE) - GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 2BPP_LE) - GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 2BPP_BE) - GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 4BPP_LE) - GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 4BPP_BE) - GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 8BPP) - GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 16BPP) - GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 24BPP) - GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, 32BPP) -
-/*
- * Dtto for filters.
- *
- * Filter is functions that works on Context per pixel.
- */
-#define GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, bpp) - MACRO_NAME(fname##_##bpp, GP_Context *, GP_Pixel, - GP_PutPixel_Raw_##bpp, GP_GetPixel_Raw_##bpp)
-
-#define GP_DEF_FFN_PER_BPP(fname, MACRO_NAME) - GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 1BPP_LE) - GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 1BPP_BE) - GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 2BPP_LE) - GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 2BPP_BE) - GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 4BPP_LE) - GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 4BPP_BE) - GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 8BPP) - GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 16BPP) - GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 24BPP) - GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, 32BPP) -
-#endif /* GP_DEF_FN_PER_BPP_H */
diff --git a/include/core/GP_FnPerBpp.gen.h.t b/include/core/GP_FnPerBpp.gen.h.t
new file mode 100644
index 0000000..b63cba4
--- /dev/null
+++ b/include/core/GP_FnPerBpp.gen.h.t
@@ -0,0 +1,60 @@
+%% extends 'base.h.t'
+
+{% block description %}All FnPerBpp macros{% endblock %}
+
+{% block body %}
+
+/*
+ * Macros used to create draving functions from macros.
+ */
+#define GP_DEF_FN_PER_BPP(fname, MACRO_NAME, fdraw) +%% for ps in pixelsizes
+ GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, {{ ps.suffix }}) +{% endfor %}
+
+#define GP_DEF_FFN_PER_BPP(fname, MACRO_NAME) +%% for ps in pixelsizes
+ GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, {{ ps.suffix }}) +{% endfor %}
+
+{% macro bpp_suffix(suffix) %}{% if not suffix == None %}_{{ suffix }}{% endif %}{% endmacro %}
+
+/*
+ * Branch on bpp and bit_endian.
+ */
+#define GP_FN_PER_BPP(FN_NAME, bpp, bit_endian, ...) + switch (bpp) { +%% for bpp in pixelsizes_by_bpp.keys()
+ case {{ bpp }}: +%% if len(pixelsizes_by_bpp[bpp]) == 1
+ FN_NAME##_{{ bpp }}BPP{{ bpp_suffix(pixelsizes_by_bpp[bpp][0]) }}(__VA_ARGS__); +%% else
+ if (bit_endian == GP_BIT_ENDIAN_LE) + FN_NAME##_{{ bpp }}BPP_LE(__VA_ARGS__); + else + FN_NAME##_{{ bpp }}BPP_BE(__VA_ARGS__); +%% endif
+ break; +%% endfor
+ }
+
+/*
+ * Branch on bpp and bit_endian.
+ */
+#define GP_FN_RET_PER_BPP(FN_NAME, bpp, bit_endian, ...) + switch (bpp) { +%% for bpp in pixelsizes_by_bpp.keys()
+ case {{ bpp }}: +%% if len(pixelsizes_by_bpp[bpp]) == 1
+ return FN_NAME##_{{ bpp }}BPP{{ bpp_suffix(pixelsizes_by_bpp[bpp][0]) }}(__VA_ARGS__); +%% else
+ if (bit_endian == GP_BIT_ENDIAN_LE) + return FN_NAME##_{{ bpp }}BPP_LE(__VA_ARGS__); + else + return FN_NAME##_{{ bpp }}BPP_BE(__VA_ARGS__); +%% endif
+ break; +%% endfor
+ }
+
+{% endblock body %}
diff --git a/include/core/GP_FnPerBpp.h b/include/core/GP_FnPerBpp.h
index 79361b0..daf21c9 100644
--- a/include/core/GP_FnPerBpp.h
+++ b/include/core/GP_FnPerBpp.h
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -41,6 +41,11 @@
* The GP_FN_RET_PER_* variants "return"s the value returned by the function.
*/
+#ifndef GP_FN_PER_BPP_H
+#define GP_FN_PER_BPP_H
+
+#include "GP_FnPerBpp.gen.h"
+
/*
* Branch on GP_Context argument.
*/
@@ -52,53 +57,6 @@
*/
#define GP_FN_PER_BPP_PIXELTYPE(FN_NAME, type, ...) GP_FN_PER_BPP(FN_NAME, GP_PixelTypes[type].size, GP_PixelTypes[type].bit_endian, __VA_ARGS__)
-
-/*
- * Branch on bpp and bit_endian.
- */
-#define GP_FN_PER_BPP(FN_NAME, bpp, bit_endian, ...) -- switch (bpp) { - case 1: - {- if (bit_endian == GP_BIT_ENDIAN_LE)- FN_NAME##_1BPP_LE(__VA_ARGS__);- else - FN_NAME##_1BPP_BE(__VA_ARGS__);- } - break; - case 2: - {- if (bit_endian == GP_BIT_ENDIAN_LE)- FN_NAME##_2BPP_LE(__VA_ARGS__);- else - FN_NAME##_2BPP_BE(__VA_ARGS__);- } - break; - case 4: - {- if (bit_endian == GP_BIT_ENDIAN_LE)- FN_NAME##_4BPP_LE(__VA_ARGS__);- else - FN_NAME##_4BPP_BE(__VA_ARGS__);- } - break; - case 8: - FN_NAME##_8BPP(__VA_ARGS__); - break; - case 16: - FN_NAME##_16BPP(__VA_ARGS__); - break; - case 24: - FN_NAME##_24BPP(__VA_ARGS__); - break; - case 32: - FN_NAME##_32BPP(__VA_ARGS__); - break; - default: - break; - } -
/*
* Branch on GP_Context argument.
*/
@@ -112,38 +70,28 @@
GP_FN_RET_PER_BPP(FN_NAME, GP_PixelTypes[type].size, GP_PixelTypes[type].bit_endian, __VA_ARGS__)
/*
- * Branch on bpp and bit_endian.
+ * Macros that gets MACRO template for drawing function and generates drawing
+ * functions for each BPP.
+ *
+ * This functions are later used by GP_FN_PER_BPP_CONTEXT() to generate one
+ * drawing function for all BPP Yay!
+ */
+#define GP_DEF_DRAW_FN_PER_BPP(fname, MACRO_NAME) + GP_DEF_FN_PER_BPP(fname, MACRO_NAME, GP_PutPixel_Raw_Clipped_)
+
+#define GP_DEF_FILL_FN_PER_BPP(fname, MACRO_NAME) + GP_DEF_FN_PER_BPP(fname, MACRO_NAME, GP_HLine_Raw_)
+
+#define GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, bpp) + MACRO_NAME(fname##_##bpp, GP_Context *, GP_Pixel, fdraw##bpp)
+
+/*
+ * Dtto for filters.
+ *
+ * Filter is functions that works on Context per pixel.
*/
-#define GP_FN_RET_PER_BPP(FN_NAME, bpp, bit_endian, ...) -- switch (bpp) { - case 1: - {- if (bit_endian == GP_BIT_ENDIAN_LE)- return FN_NAME##_1BPP_LE(__VA_ARGS__);- else - return FN_NAME##_1BPP_BE(__VA_ARGS__);- } - case 2: - {- if (bit_endian == GP_BIT_ENDIAN_LE)- return FN_NAME##_2BPP_LE(__VA_ARGS__);- else - return FN_NAME##_2BPP_BE(__VA_ARGS__);- } - case 4: - {- if (bit_endian == GP_BIT_ENDIAN_LE)- return FN_NAME##_4BPP_LE(__VA_ARGS__);- else - return FN_NAME##_4BPP_BE(__VA_ARGS__);- } - case 8: - return FN_NAME##_8BPP(__VA_ARGS__); - case 16: - return FN_NAME##_16BPP(__VA_ARGS__); - case 24: - return FN_NAME##_24BPP(__VA_ARGS__); - case 32: - return FN_NAME##_32BPP(__VA_ARGS__); - }
+#define GP_DEF_FFN_FOR_BPP(fname, MACRO_NAME, bpp) + MACRO_NAME(fname##_##bpp, GP_Context *, GP_Pixel, + GP_PutPixel_Raw_##bpp, GP_GetPixel_Raw_##bpp)
+
+#endif /* GP_FN_PER_BPP_H */
diff --git a/include/core/GP_WritePixel.h b/include/core/GP_WritePixel.h
index 2910111..9295835 100644
--- a/include/core/GP_WritePixel.h
+++ b/include/core/GP_WritePixel.h
@@ -43,6 +43,7 @@ void GP_WritePixels4bpp(uint8_t *start, uint8_t off, size_t cnt, uint8_t val);
void GP_WritePixels8bpp(void *start, size_t count, uint8_t value);
void GP_WritePixels16bpp(void *start, size_t count, uint16_t value);
+void GP_WritePixels18bpp(void *start, size_t count, uint32_t value);
void GP_WritePixels24bpp(void *start, size_t count, uint32_t value);
void GP_WritePixels32bpp(void *start, size_t count, uint32_t value);
diff --git a/include/gfx/GP_HLine.h b/include/gfx/GP_HLine.h
index 96b66de..0737f66 100644
--- a/include/gfx/GP_HLine.h
+++ b/include/gfx/GP_HLine.h
@@ -51,6 +51,9 @@ void GP_HLine_Raw_4BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1,
void GP_HLine_Raw_8BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
GP_Coord y, GP_Pixel pixel);
+void GP_HLine_Raw_18BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel);
+
void GP_HLine_Raw_16BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
GP_Coord y, GP_Pixel pixel);
diff --git a/libs/core/GP_WritePixel.c b/libs/core/GP_WritePixel.c
index 090cb5c..5638ca5 100644
--- a/libs/core/GP_WritePixel.c
+++ b/libs/core/GP_WritePixel.c
@@ -162,6 +162,11 @@ void GP_WritePixels16bpp(void *start, size_t count, uint16_t value)
}
}
+void GP_WritePixels18bpp(void *start, size_t count, uint32_t value)
+{
+ #warning TODO
+}
+
void GP_WritePixels24bpp(void *start, size_t count, uint32_t value)
{
uint8_t *bytep = (uint8_t *) start;
diff --git a/libs/core/Makefile b/libs/core/Makefile
index b8c7cf7..3f0fffd 100644
--- a/libs/core/Makefile
+++ b/libs/core/Makefile
@@ -1,6 +1,7 @@
TOPDIR=../..
GENSOURCES=GP_Pixel.gen.c GP_Blit.gen.c GP_Convert.gen.c
-GENHEADERS=GP_Convert_Scale.gen.h GP_Blit.gen.h GP_Pixel.gen.h GP_GetPutPixel.gen.h GP_Convert.gen.h
+GENHEADERS=GP_Convert_Scale.gen.h GP_Blit.gen.h GP_Pixel.gen.h + GP_GetPutPixel.gen.h GP_Convert.gen.h GP_FnPerBpp.gen.h
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
LIBNAME=core
diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c
index 6967514..513b969 100644
--- a/libs/filters/GP_Rotate.c
+++ b/libs/filters/GP_Rotate.c
@@ -25,7 +25,6 @@
#include "core/GP_Core.h"
#include "core/GP_FnPerBpp.h"
-#include "core/GP_DefFnPerBpp.h"
#include "GP_Rotate.h"
diff --git a/libs/gfx/GP_Circle.c b/libs/gfx/GP_Circle.c
index 95e685f..0cfc88f 100644
--- a/libs/gfx/GP_Circle.c
+++ b/libs/gfx/GP_Circle.c
@@ -25,7 +25,6 @@
#include "GP_Gfx.h"
#include "core/GP_FnPerBpp.h"
-#include "core/GP_DefFnPerBpp.h"
#include "algo/Circle.algo.h"
diff --git a/libs/gfx/GP_Ellipse.c b/libs/gfx/GP_Ellipse.c
index 66f33e0..b416906 100644
--- a/libs/gfx/GP_Ellipse.c
+++ b/libs/gfx/GP_Ellipse.c
@@ -25,7 +25,6 @@
#include "GP_Gfx.h"
#include "core/GP_FnPerBpp.h"
-#include "core/GP_DefFnPerBpp.h"
#include "algo/Ellipse.algo.h"
diff --git a/libs/gfx/GP_HLine.c b/libs/gfx/GP_HLine.c
index b19a146..1abb073 100644
--- a/libs/gfx/GP_HLine.c
+++ b/libs/gfx/GP_HLine.c
@@ -39,6 +39,7 @@ DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_W
DEF_HLINE_FN(GP_HLine_Raw_8BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels8bpp)
DEF_HLINE_FN(GP_HLine_Raw_16BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels16bpp)
+DEF_HLINE_FN(GP_HLine_Raw_18BPP_LE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels18bpp)
DEF_HLINE_FN(GP_HLine_Raw_24BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels24bpp)
DEF_HLINE_FN(GP_HLine_Raw_32BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels32bpp)
diff --git a/libs/gfx/GP_Line.c b/libs/gfx/GP_Line.c
index 4236ee8..947a337 100644
--- a/libs/gfx/GP_Line.c
+++ b/libs/gfx/GP_Line.c
@@ -19,13 +19,12 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
#include "GP_Gfx.h"
#include "core/GP_FnPerBpp.h"
-#include "core/GP_DefFnPerBpp.h"
#include "algo/Line.algo.h"
diff --git a/libs/gfx/GP_VLine.c b/libs/gfx/GP_VLine.c
index 2af65f7..af9ad15 100644
--- a/libs/gfx/GP_VLine.c
+++ b/libs/gfx/GP_VLine.c
@@ -25,7 +25,6 @@
#include "GP_Gfx.h"
#include "core/GP_FnPerBpp.h"
-#include "core/GP_DefFnPerBpp.h"
#include "algo/VLine.algo.h"
diff --git a/libs/text/GP_Text.c b/libs/text/GP_Text.c
index 65f025c..c6fce34 100644
--- a/libs/text/GP_Text.c
+++ b/libs/text/GP_Text.c
@@ -26,7 +26,6 @@
#include "algo/Text.algo.h"
#include "gfx/GP_Gfx.h"
#include "core/GP_FnPerBpp.h"
-#include "core/GP_DefFnPerBpp.h"
#include "GP_Text.h"
GP_TextStyle GP_DefaultStyle = GP_DEFAULT_TEXT_STYLE;
diff --git a/pylib/gfxprim/gfxprimconfig.py b/pylib/gfxprim/gfxprimconfig.py
index 33c03f9..9d90ae4 100644
--- a/pylib/gfxprim/gfxprimconfig.py
+++ b/pylib/gfxprim/gfxprimconfig.py
@@ -2,6 +2,7 @@
# gfxprim.generators.gfxprimconfig - Class for (global) GfxPrim configuration
#
# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+# 2011 - Cyril Hrubis <metan(a)ucw.cz>
import os
import logging as log
@@ -16,6 +17,7 @@ class GfxPrimConfig(object):
pixel_type: name of C type for a pixel value
pixel_size: number of bits of pixel_type
pixelsizes: list of generated and allowed PixelSizes
+ pixelsizes_by_bpp: dictionary of bitendians by BPP
pixeltypes: list of generated PixelTypes, not incl. UNKNOWN
"""
@@ -35,6 +37,14 @@ class GfxPrimConfig(object):
for i in self.pixelsizes:
assert i.size <= self.pixel_size
+ # Dictionary of all pixelsizes by BPP { bpp : list of BE, LE }
+ self.pixelsizes_by_bpp = dict()
+ for i in self.pixelsizes:
+ if i.size not in self.pixelsizes_by_bpp:
+ self.pixelsizes_by_bpp[i.size] = [i.bit_endian]
+ else:
+ self.pixelsizes_by_bpp[i.size].append(i.bit_endian)
+
# Set of all encountered channel names
self.channels = set()
diff --git a/pylib/gfxprim/render_utils.py b/pylib/gfxprim/render_utils.py
index 2c71b50..d99aa3d 100644
--- a/pylib/gfxprim/render_utils.py
+++ b/pylib/gfxprim/render_utils.py
@@ -18,6 +18,7 @@ def create_environment(config, template_dir):
loader = jinja2.FileSystemLoader(template_dir))
env.globals['undefined'] = jinja2.StrictUndefined()
env.globals['pixelsizes'] = config.pixelsizes
+ env.globals['pixelsizes_by_bpp'] = config.pixelsizes_by_bpp
env.globals['pixeltypes'] = config.pixeltypes
env.globals['pixeltypes_dict'] = config.pixeltypes_dict
env.globals['config'] = config
http://repo.or.cz/w/gfxprim.git/commit/d5456b7fba99b477b44a663264c2fc9fb590…
commit d5456b7fba99b477b44a663264c2fc9fb590e18b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Oct 13 20:09:34 2011 +0200
Changed the 19BPP to 18BPP (as I do have 18BPP HW)
diff --git a/gfxprim_config.py b/gfxprim_config.py
index 97446ac..15b06e7 100644
--- a/gfxprim_config.py
+++ b/gfxprim_config.py
@@ -24,8 +24,7 @@ PS_16BPP = PixelSize(16)
PS_24BPP = PixelSize(24)
PS_32BPP = PixelSize(32)
# Experimental:
-PS_19BPP_LE = PixelSize(19, bit_endian=LE)
-
+PS_18BPP_LE = PixelSize(18, bit_endian=LE)
config = GfxPrimConfig(
@@ -35,8 +34,8 @@ config = GfxPrimConfig(
# List of pixel sizes (bpp), explicit on purpose
pixelsizes = [PS_1BPP_LE, PS_1BPP_BE, PS_2BPP_LE, PS_2BPP_BE, PS_4BPP_LE, PS_4BPP_BE,
- PS_8BPP, PS_16BPP, PS_24BPP, PS_32BPP,
- PS_19BPP_LE,
+ PS_8BPP, PS_16BPP, PS_24BPP, PS_32BPP,
+ PS_18BPP_LE,
],
# List of PixelTypes, order defines the numbering.
@@ -68,6 +67,10 @@ config = GfxPrimConfig(
('G', 5, 6),
('B', 0, 5)]),
+ PixelType(name='RGB666', pixelsize=PS_18BPP_LE, chanslist=[
+ ('R', 12, 6),
+ ('G', 6, 6),
+ ('B', 0, 6)]),
#
# Palette types
#
-----------------------------------------------------------------------
Summary of changes:
gfxprim_config.py | 11 +++--
include/core/GP_DefFnPerBpp.h | 75 -------------------------
include/core/GP_FnPerBpp.gen.h.t | 60 ++++++++++++++++++++
include/core/GP_FnPerBpp.h | 112 ++++++++++----------------------------
include/core/GP_WritePixel.h | 1 +
include/gfx/GP_HLine.h | 3 +
libs/core/GP_WritePixel.c | 5 ++
libs/core/Makefile | 3 +-
libs/filters/GP_Rotate.c | 1 -
libs/gfx/GP_Circle.c | 1 -
libs/gfx/GP_Ellipse.c | 1 -
libs/gfx/GP_HLine.c | 1 +
libs/gfx/GP_Line.c | 3 +-
libs/gfx/GP_VLine.c | 1 -
libs/text/GP_Text.c | 1 -
pylib/gfxprim/gfxprimconfig.py | 10 ++++
pylib/gfxprim/render_utils.py | 1 +
17 files changed, 121 insertions(+), 169 deletions(-)
delete mode 100644 include/core/GP_DefFnPerBpp.h
create mode 100644 include/core/GP_FnPerBpp.gen.h.t
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.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: 944dcb4637c7daa52ce37d6fde1b84b44b412e5a
by metan 13 Oct '11
by metan 13 Oct '11
13 Oct '11
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 944dcb4637c7daa52ce37d6fde1b84b44b412e5a (commit)
from bf71ed549471116331486980f67e4f64b840640d (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/944dcb4637c7daa52ce37d6fde1b84b44b41…
commit 944dcb4637c7daa52ce37d6fde1b84b44b412e5a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Oct 11 13:31:53 2011 +0200
Fix some typos in GP_GetPutPixel.gen.h.t
diff --git a/include/core/GP_GetPutPixel.gen.h.t b/include/core/GP_GetPutPixel.gen.h.t
index 2a8529b..f04ea33 100644
--- a/include/core/GP_GetPutPixel.gen.h.t
+++ b/include/core/GP_GetPutPixel.gen.h.t
@@ -13,15 +13,15 @@ Do not include directly, use GP_Pixel.h
Note about byte aligment
~~~~~~~~~~~~~~~~~~~~~~~~
- Unaligned acces happens when instruction that works with multiple byte value
- gets an address that is not divideable by the size of the value. Eg. if 32
- bit integer instruction gets an address that is not a multiple of 4. On
- intel cpus this type of acces works and is supported however the C standard
- defines this as undefined behavior. This fails to work ARM and most of the
- non intel cpus. So some more trickery must be done in order to write
- unaligned multibyte values. First of all we must compute offset and number of
- bytes to be accessed (which is cruicial for speed as we are going to read the
- pixel value byte by byte.
+ Unaligned access happens when instruction that works with multiple byte
+ value gets an address that is not divideable by the size of the value. Eg.
+ if 32 bit integer instruction gets an address that is not a multiple of 4.
+ On intel cpus this type of access works and is supported however the C
+ standard defines this as undefined behavior. This fails to work ARM and most
+ of the non intel cpus. So some more trickery must be done in order to write
+ unaligned multibyte values. First of all we must compute offset and number
+ of bytes to be accessed (which is cruicial for speed as we are going to read
+ the pixel value byte by byte).
The offsets (starting with the first one eg. pixel_size mod 8) forms subgroup
in the mod 8 cyclic group. The maximal count of bits, from the start of the
@@ -30,7 +30,7 @@ Do not include directly, use GP_Pixel.h
For example the offsets of 16 BPP forms subgroup only with {0} so we only
need 2 bytes to write it. As a matter of fact the 16 and 32 BPP are special
- cases that are always aligned and together with the 8 BPP (which is aligned
+ cases that are always aligned together with the 8 BPP (which is aligned
trivially). These three are coded as special cases which yields to faster
operations in case of 16 and 32 BPP. The 24 BPP is not aligned as there are
no instruction to operate 3 byte long numbers.
@@ -38,10 +38,10 @@ Do not include directly, use GP_Pixel.h
For second example take offsets of 20 BPP that forms subgroup {4, 0}
so the max + pixel_size = 24 and indeed we fit into 3 bytes.
- If pixel_size is coprime to 8, the offsets generates whole group and so
- the max + pixel_size = 7 + pixel_size. The 17 BPP fits into 24 bits and
- so also 3 bytes are needed. The 19 BPP fits into 26 bits and because of
- that 4 bytes are needed.
+ If pixel_size is coprime to 8, the offsets generates whole group and so the
+ max + pixel_size = 7 + pixel_size. The 17 BPP fits into 24 bits and so 3
+ bytes are needed. The 19 BPP fits into 26 bits and because of that 4 bytes
+ are needed.
Once we figure maximal number of bytes and the offset all that is to be done
is to fetch first and last byte to combine it together with given pixel value
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_GetPutPixel.gen.h.t | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 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.")
1
0