This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via b4569232ecafc8e3fc6bfd877588b42ca8a21452 (commit) via 1db9952e987f46349fe20c9d640cc7a322b2a2b0 (commit) via 5386daff4c7167a5e5fa86b6d22964528ad6569c (commit) via b0bc589726647eb0271d5869e354f865736a4808 (commit) from 60acd49d53dd05fdfe61c875d1d7d09ac62a018b (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/b4569232ecafc8e3fc6bfd877588b42ca8a21...
commit b4569232ecafc8e3fc6bfd877588b42ca8a21452 Author: Cyril Hrubis metan@ucw.cz Date: Mon May 21 13:19:27 2012 +0200
core: Write better 1BPP WritePixels function.
diff --git a/include/core/GP_WritePixel.h b/include/core/GP_WritePixel.h index 26d072c..991782f 100644 --- a/include/core/GP_WritePixel.h +++ b/include/core/GP_WritePixel.h @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -30,9 +30,8 @@ #include <stdint.h> #include <unistd.h>
-/* - * Calls for writing a linear block of pixels. - */ +void GP_WritePixels_1BPP_LE(uint8_t *start, uint8_t off, + size_t cnt, uint8_t val);
/* * These calls are not byte aligned, thuss needs start offset. diff --git a/libs/core/GP_WritePixel.c b/libs/core/GP_WritePixel.c index c35b7ec..d255223 100644 --- a/libs/core/GP_WritePixel.c +++ b/libs/core/GP_WritePixel.c @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -28,6 +28,82 @@ #include "GP_Core.h" #include "GP_WritePixel.h"
+static const uint8_t bytes_1BPP[] = {0x00, 0xff}; + +void GP_WritePixels_1BPP_LE(uint8_t *start, uint8_t off, + size_t cnt, uint8_t val) +{ + int len = cnt; + + /* Write start of the line */ + switch (off) { + case 0: + break; + case 1: + GP_SET_BITS1_ALIGNED(1, 1, start, val); + + if (--len == 0) + return; + case 2: + GP_SET_BITS1_ALIGNED(2, 1, start, val); + + if (--len == 0) + return; + case 3: + GP_SET_BITS1_ALIGNED(3, 1, start, val); + + if (--len == 0) + return; + case 4: + GP_SET_BITS1_ALIGNED(4, 1, start, val); + + if (--len == 0) + return; + case 5: + GP_SET_BITS1_ALIGNED(5, 1, start, val); + + if (--len == 0) + return; + case 6: + GP_SET_BITS1_ALIGNED(6, 1, start, val); + + if (--len == 0) + return; + case 7: + GP_SET_BITS1_ALIGNED(7, 1, start, val); + + if (--len == 0) + return; + + start++; + break; + } + + /* Write as many bytes as possible */ + memset(start, bytes_1BPP[val & 0x01], len/8); + + start+=len/8; + + /* And the rest */ + switch (len%8) { + case 7: + GP_SET_BITS1_ALIGNED(6, 1, start, val); + case 6: + GP_SET_BITS1_ALIGNED(5, 1, start, val); + case 5: + GP_SET_BITS1_ALIGNED(4, 1, start, val); + case 4: + GP_SET_BITS1_ALIGNED(3, 1, start, val); + case 3: + GP_SET_BITS1_ALIGNED(2, 1, start, val); + case 2: + GP_SET_BITS1_ALIGNED(1, 1, start, val); + case 1: + GP_SET_BITS1_ALIGNED(0, 1, start, val); + break; + } +} + static const uint8_t chunks_1bpp[8] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, }; diff --git a/libs/gfx/GP_HLine.c b/libs/gfx/GP_HLine.c index e9daf45..b31611f 100644 --- a/libs/gfx/GP_HLine.c +++ b/libs/gfx/GP_HLine.c @@ -35,7 +35,7 @@ /* Generate drawing functions for various bit depths. */
//TODO: BIT ENDIANESS -DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp) +DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels_1BPP_LE) 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)
http://repo.or.cz/w/gfxprim.git/commit/1db9952e987f46349fe20c9d640cc7a322b2a...
commit 1db9952e987f46349fe20c9d640cc7a322b2a2b0 Author: Cyril Hrubis metan@ucw.cz Date: Mon May 21 13:18:17 2012 +0200
examples: Add virtual backend example.
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile index 323ae99..eeadcf8 100644 --- a/demos/c_simple/Makefile +++ b/demos/c_simple/Makefile @@ -5,7 +5,8 @@ CSOURCES=$(shell echo *.c) INCLUDE= LDLIBS+=-lGP -lGP_backends -lSDL -L$(TOPDIR)/build/
-APPS=backend_example loaders_example loaders filters_symmetry gfx_koch +APPS=backend_example loaders_example loaders filters_symmetry gfx_koch+ virtual_backend_example
include $(TOPDIR)/pre.mk include $(TOPDIR)/app.mk diff --git a/demos/c_simple/backend_example.c b/demos/c_simple/backend_example.c index 838726b..3f5c199 100644 --- a/demos/c_simple/backend_example.c +++ b/demos/c_simple/backend_example.c @@ -48,6 +48,7 @@ int main(int argc, char *argv[]) break; default: fprintf(stderr, "Invalid paramter '%c'n", opt); + return 1; } }
diff --git a/demos/c_simple/backend_example.c b/demos/c_simple/virtual_backend_example.c similarity index 61% copy from demos/c_simple/backend_example.c copy to demos/c_simple/virtual_backend_example.c index 838726b..8f8858e 100644 --- a/demos/c_simple/backend_example.c +++ b/demos/c_simple/virtual_backend_example.c @@ -22,7 +22,10 @@
/*
- Simple backend example. + Simple virtual backend test. + + Virtual backned allows you to test interactively pixel types that your + hardware/xserverd doesn't support.
*/
@@ -34,27 +37,59 @@ int main(int argc, char *argv[]) GP_Backend *backend; GP_Context *context; GP_Pixel white_pixel, black_pixel; - const char *backend_opts = "X11:100x100"; + const char *backend_opts = "X11:400x400"; int opt; + GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
- while ((opt = getopt(argc, argv, "b:h")) != -1) { + while ((opt = getopt(argc, argv, "b:h:p:")) != -1) { switch (opt) { case 'b': backend_opts = optarg; break; + case 'p': + emul_type = GP_PixelTypeByName(optarg); + + if (emul_type == GP_PIXEL_UNKNOWN) { + fprintf(stderr, "Invalid pixel type '%s'n", optarg); + return 1; + } + break; case 'h': GP_BackendInit(NULL, NULL, stderr); return 0; break; default: fprintf(stderr, "Invalid paramter '%c'n", opt); + return 1; } }
/* Turn on debug messages */ GP_SetDebugLevel(10);
- backend = GP_BackendInit(backend_opts, "Backend Example", stderr); + backend = GP_BackendInit(backend_opts, "Virtual Backend Example", stderr); + + if (emul_type != GP_PIXEL_UNKNOWN) { + GP_Backend *emul; + + /* + * Create an emulated backend on the top of real backend. + * + * The GP_BACKEND_CALL_EXIT says that when calling exit on + * emulated backend, the real backend exit will be called as + * well. + */ + emul = GP_BackendVirtualInit(backend, emul_type, GP_BACKEND_CALL_EXIT); + + if (emul == NULL) { + fprintf(stderr, "Failed to create Virtual Backendn"); + GP_BackendExit(backend); + return 1; + } + + /* Once created virtual backend behaves exactly like a real one */ + backend = emul; + }
context = backend->context;
@@ -63,9 +98,23 @@ int main(int argc, char *argv[]) black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context); white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context);
- GP_Fill(context, black_pixel); - GP_Line(context, 0, 0, context->w - 1, context->h - 1, white_pixel); - GP_Line(context, 0, context->h - 1, context->w - 1, 0, white_pixel); + GP_Fill(context, white_pixel); + + /* Now draw some testing patters */ + unsigned int i; + for (i = 0; i < 40; i++) { + GP_HLineXYW(context, 0, i, i, black_pixel); + + GP_HLineXYW(context, 40 + i, i, i, black_pixel); + + GP_HLineXYW(context, 1, i + 40, i, black_pixel); + GP_HLineXYW(context, 2, i + 80, i, black_pixel); + GP_HLineXYW(context, 3, i + 120, i, black_pixel); + GP_HLineXYW(context, 4, i + 160, i, black_pixel); + GP_HLineXYW(context, 5, i + 200, i, black_pixel); + GP_HLineXYW(context, 6, i + 240, i, black_pixel); + GP_HLineXYW(context, 7, i + 280, i, black_pixel); + }
/* Update the backend screen */ GP_BackendFlip(backend);
http://repo.or.cz/w/gfxprim.git/commit/5386daff4c7167a5e5fa86b6d22964528ad65...
commit 5386daff4c7167a5e5fa86b6d22964528ad6569c Author: Cyril Hrubis metan@ucw.cz Date: Mon May 21 13:17:28 2012 +0200
tests: Fix loaders tests compilation.
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile index e079177..98b817e 100644 --- a/tests/loaders/Makefile +++ b/tests/loaders/Makefile @@ -1,4 +1,5 @@ TOPDIR=../.. +include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
@@ -7,5 +8,5 @@ LDLIBS+=-lGP -L$(TOPDIR)/build/
APPS=PBM_invert PBM_test PGM_invert PGM_test
-include $(TOPDIR)/include.mk include $(TOPDIR)/app.mk +include $(TOPDIR)/post.mk diff --git a/tests/loaders/PBM_test.c b/tests/loaders/PBM_test.c index 8058b00..a33e1c8 100644 --- a/tests/loaders/PBM_test.c +++ b/tests/loaders/PBM_test.c @@ -46,7 +46,7 @@ int main(void) GP_FillCircle(context, 20, 20, 9, 1); GP_FillCircle(context, 20, 20, 7, 0); GP_FillCircle(context, 20, 20, 4, 1); - GP_Text(context, NULL, 10, 40, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, "Test Test", 1); + GP_Text(context, NULL, 10, 40, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, 0, 1, "Test Test");
if (GP_SavePBM("test.pbm", context)) { fprintf(stderr, "Can't save contextn"); diff --git a/tests/loaders/PGM_test.c b/tests/loaders/PGM_test.c index 2480144..8268f4d 100644 --- a/tests/loaders/PGM_test.c +++ b/tests/loaders/PGM_test.c @@ -66,9 +66,9 @@ int main(void) GP_FillCircle(context, W/2, H/2, 7, 2); GP_FillCircle(context, W/2, H/2, 5, 1); GP_FillCircle(context, W/2, H/2, 2, 0); - GP_Text(context, NULL, 60, 10, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, "Test", 3); - GP_Text(context, NULL, 60, 20, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, "Test", 2); - GP_Text(context, NULL, 60, 30, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, "Test", 1); + GP_Text(context, NULL, 60, 10, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, 0, 3, "Test"); + GP_Text(context, NULL, 60, 20, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, 0, 2, "Test"); + GP_Text(context, NULL, 60, 30, GP_VALIGN_BELOW | GP_ALIGN_RIGHT, 0, 1, "Test");
if (GP_SavePGM("test.pgm", context)) { fprintf(stderr, "Can't save contextn");
http://repo.or.cz/w/gfxprim.git/commit/b0bc589726647eb0271d5869e354f865736a4...
commit b0bc589726647eb0271d5869e354f865736a4808 Author: Cyril Hrubis metan@ucw.cz Date: Mon May 21 12:41:11 2012 +0200
backends: Add virtual backend into GP_Backends.h.
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 931c3f0..7095eef 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -34,7 +34,6 @@
#include <GP.h> #include <backends/GP_Backends.h> -#include <backends/GP_BackendVirtual.h> #include <input/GP_InputDriverLinux.h>
#include "cpu_timer.h" diff --git a/include/backends/GP_Backends.h b/include/backends/GP_Backends.h index d9420e1..9d72fc7 100644 --- a/include/backends/GP_Backends.h +++ b/include/backends/GP_Backends.h @@ -40,6 +40,7 @@ #include "backends/GP_LinuxFB.h" #include "backends/GP_SDL.h" #include "backends/GP_X11.h" +#include "backends/GP_BackendVirtual.h"
/* * Simplified backend initalization.
-----------------------------------------------------------------------
Summary of changes: demos/c_simple/Makefile | 3 +- demos/c_simple/backend_example.c | 1 + ...backend_example.c => virtual_backend_example.c} | 63 ++++++++++++++-- demos/spiv/spiv.c | 1 - include/backends/GP_Backends.h | 1 + include/core/GP_WritePixel.h | 7 +- libs/core/GP_WritePixel.c | 78 +++++++++++++++++++- libs/gfx/GP_HLine.c | 2 +- tests/loaders/Makefile | 3 +- tests/loaders/PBM_test.c | 2 +- tests/loaders/PGM_test.c | 6 +- 11 files changed, 147 insertions(+), 20 deletions(-) copy demos/c_simple/{backend_example.c => virtual_backend_example.c} (61%)
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.