Gfxprim
Threads by month
- ----- 2026 -----
- February
- 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 master updated: b4569232ecafc8e3fc6bfd877588b42ca8a21452
by metan 21 May '12
by metan 21 May '12
21 May '12
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/b4569232ecafc8e3fc6bfd877588b42ca8a2…
commit b4569232ecafc8e3fc6bfd877588b42ca8a21452
Author: Cyril Hrubis <metan(a)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(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)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(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)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/1db9952e987f46349fe20c9d640cc7a322b2…
commit 1db9952e987f46349fe20c9d640cc7a322b2a2b0
Author: Cyril Hrubis <metan(a)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/5386daff4c7167a5e5fa86b6d22964528ad6…
commit 5386daff4c7167a5e5fa86b6d22964528ad6569c
Author: Cyril Hrubis <metan(a)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/b0bc589726647eb0271d5869e354f865736a…
commit b0bc589726647eb0271d5869e354f865736a4808
Author: Cyril Hrubis <metan(a)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(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 master updated: 60acd49d53dd05fdfe61c875d1d7d09ac62a018b
by metan 21 May '12
by metan 21 May '12
21 May '12
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 60acd49d53dd05fdfe61c875d1d7d09ac62a018b (commit)
via 52f483d206017a87e76ec9541539bf7d3beb7efb (commit)
from 2bea36d5281f8683a1215177d6a162581de40521 (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/60acd49d53dd05fdfe61c875d1d7d09ac62a…
commit 60acd49d53dd05fdfe61c875d1d7d09ac62a018b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 21 00:51:53 2012 +0200
spiv: Add option to turn on dithering.
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 2062015..931c3f0 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -49,6 +49,7 @@ static int abort_flag = 0;
static int rotate = 0;
static int show_progress = 0;
static int resampling_method = GP_INTERP_LINEAR_LF_INT;
+static int dithering = 0;
static int image_loader_callback(GP_ProgressCallback *self)
{
@@ -278,8 +279,19 @@ static void *image_loader(void *ptr)
uint32_t cx = (context->w - ret->w)/2;
uint32_t cy = (context->h - ret->h)/2;
+ GP_Context sub_display;
+
cpu_timer_start(&timer, "Blitting");
- GP_Blit_Raw(ret, 0, 0, ret->w, ret->h, context, cx, cy);
+
+ if (dithering) {
+ callback.priv = "Dithering";
+ GP_ContextSubContext(context, &sub_display, cx, cy, ret->w, ret->h);
+ // GP_FilterFloydSteinberg_from_RGB888(ret, &sub_display, 0, NULL);
+ GP_FilterHilbertPeano_from_RGB888(ret, &sub_display, NULL);
+ } else {
+ GP_Blit_Raw(ret, 0, 0, ret->w, ret->h, context, cx, cy);
+ }
+
cpu_timer_stop(&timer);
GP_ContextFree(ret);
@@ -385,7 +397,7 @@ int main(int argc, char *argv[])
int opt, debug_level = 0;
GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
- while ((opt = getopt(argc, argv, "b:cd:e:Ii:Ps:r:")) != -1) {
+ while ((opt = getopt(argc, argv, "b:cd:e:fIi:Ps:r:")) != -1) {
switch (opt) {
case 'I':
params.show_info = 1;
@@ -396,6 +408,9 @@ int main(int argc, char *argv[])
case 'i':
input_dev = optarg;
break;
+ case 'f':
+ dithering = 1;
+ break;
case 's':
sleep_sec = atoi(optarg);
break;
http://repo.or.cz/w/gfxprim.git/commit/52f483d206017a87e76ec9541539bf7d3beb…
commit 52f483d206017a87e76ec9541539bf7d3beb7efb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 21 00:45:56 2012 +0200
filters: Hilbert-Peano fix curve size calculation.
diff --git a/libs/filters/GP_HilbertPeanoDithering.gen.c.t b/libs/filters/GP_HilbertPeanoDithering.gen.c.t
index a925c9c..78a9b53 100644
--- a/libs/filters/GP_HilbertPeanoDithering.gen.c.t
+++ b/libs/filters/GP_HilbertPeanoDithering.gen.c.t
@@ -21,6 +21,8 @@ static unsigned int count_bits(unsigned int n)
i++;
} while (n);
+ i--;
+
return (i + (s != (1U<<i)));
}
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 19 +++++++++++++++++--
libs/filters/GP_HilbertPeanoDithering.gen.c.t | 2 ++
2 files changed, 19 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 master updated: 2bea36d5281f8683a1215177d6a162581de40521
by metan 21 May '12
by metan 21 May '12
21 May '12
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 2bea36d5281f8683a1215177d6a162581de40521 (commit)
via 28e1f1872424ff83ed2eceafcbdd6b9b293b8866 (commit)
from c2f10f3f488c6f32fb2c516153689a1fcc317ff0 (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/2bea36d5281f8683a1215177d6a162581de4…
commit 2bea36d5281f8683a1215177d6a162581de40521
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon May 21 00:10:36 2012 +0200
filters: Templatized Hilbert Peano Dithering.
diff --git a/libs/filters/GP_Dither.c b/libs/filters/GP_Dither.c
index e0c6be1..d258ef4 100644
--- a/libs/filters/GP_Dither.c
+++ b/libs/filters/GP_Dither.c
@@ -133,3 +133,14 @@ GP_Context *GP_FilterFloydSteinberg_from_RGB888(const GP_Context *src,
return ret;
}
+
+int GP_FilterHilbertPeano_RGB888_to_XXX_Raw(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+int GP_FilterHilbertPeano_from_RGB888(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ return GP_FilterHilbertPeano_RGB888_to_XXX_Raw(src, dst, callback);
+}
diff --git a/libs/filters/GP_Dither.gen.c.t b/libs/filters/GP_Dither.gen.c.t
index 8b9e237..c1ec2bf 100644
--- a/libs/filters/GP_Dither.gen.c.t
+++ b/libs/filters/GP_Dither.gen.c.t
@@ -1,9 +1,7 @@
%% extends "base.c.t"
-%% block descr
-Floyd Steinberg dithering RGB888 -> any pixel
-%% endblock
+{% block descr %}Floyd Steinberg dithering RGB888 -> any pixel{% endblock %}
%% block body
@@ -52,7 +50,7 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G
for (y = 0; y < (GP_Coord)src->h; y++) {
for (x = 0; x < (GP_Coord)src->w; x++) {
- GP_Pixel pix = GP_GetPixel(src, x, y);
+ GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, x, y);
%% for c in pt.chanslist
%% if pt.is_gray()
diff --git a/libs/filters/GP_HilbertPeanoDithering.c b/libs/filters/GP_HilbertPeanoDithering.c
deleted file mode 100644
index decaebf..0000000
--- a/libs/filters/GP_HilbertPeanoDithering.c
+++ /dev/null
@@ -1,97 +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-2012 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#include "core/GP_Debug.h"
-#include "core/GP_GetPutPixel.h"
-#include "core/GP_Core.h"
-
-#include "GP_HilbertCurve.h"
-#include "GP_Dither.h"
-
-/*
- * Returns closest greater square of two, used to determine the curve size.
- */
-static unsigned int count_bits(unsigned int n)
-{
- unsigned int i = 0, s = n;
-
- do {
- n>>=1;
- i++;
- } while (n);
-
- return (i + (s != (1<<i)));
-}
-
-int GP_FilterHilbertPeano_from_RGB888(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback)
-{
- struct GP_CurveState state;
-
- unsigned int n = GP_MAX(count_bits(src->w), count_bits(src->h));
-
- GP_DEBUG(1, "Hilbert Peano dithering %ux%u -> n = %u", src->w, src->h, n);
-
- GP_HilbertCurveInit(&state, n);
-
- int err = 0, cnt = 0;
-
- while (GP_HilbertCurveContinues(&state)) {
-
- if (state.x < src->w && state.y < src->h) {
- int pix = GP_GetPixel_Raw(src, state.x, state.y);
-
- pix = GP_ConvertPixel(pix, src->pixel_type, GP_PIXEL_G8);
-
- pix += err;
-
- if (pix > 127) {
- err = pix - 255;
- pix = 1;
- } else {
- err = pix;
- pix = 0;
- }
-
- GP_PutPixel_Raw_1BPP_LE(dst, state.x, state.y, pix);
-
- cnt++;
-
- if (GP_ProgressCallbackReport(callback, cnt/src->h, src->w, src->h))
- return 1;
-
- /* We are done, exit */
- if (cnt == src->w * src->h - 1) {
- GP_ProgressCallbackDone(callback);
- return 0;
- }
- } else {
- err = 0;
- }
-
- GP_HilbertCurveNext(&state);
- }
-
- GP_ProgressCallbackDone(callback);
- return 0;
-}
diff --git a/libs/filters/GP_HilbertPeanoDithering.gen.c.t b/libs/filters/GP_HilbertPeanoDithering.gen.c.t
new file mode 100644
index 0000000..a925c9c
--- /dev/null
+++ b/libs/filters/GP_HilbertPeanoDithering.gen.c.t
@@ -0,0 +1,126 @@
+%% extends "base.c.t"
+
+{% block descr %}Hilbert Peano dithering RGB888 -> any pixel{% endblock %}
+
+%% block body
+
+#include "core/GP_Core.h"
+#include "core/GP_GetPutPixel.h"
+#include "GP_HilbertCurve.h"
+#include "GP_Filter.h"
+
+/*
+ * Returns closest greater square of two, used to determine the curve size.
+ */
+static unsigned int count_bits(unsigned int n)
+{
+ unsigned int i = 0, s = n;
+
+ do {
+ n>>=1;
+ i++;
+ } while (n);
+
+ return (i + (s != (1U<<i)));
+}
+
+%% for pt in pixeltypes
+%% if not pt.is_unknown() and not pt.is_alpha() and not pt.is_palette()
+/*
+ * Hilbert Peano RGB888 to {{ pt.name }}
+ */
+int GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ struct GP_CurveState state;
+ unsigned int n;
+
+ n = GP_MAX(count_bits(src->w), count_bits(src->h));
+
+ GP_DEBUG(1, "Hilbert Peano dithering %ux%u -> n = %u", src->w, src->h, n);
+
+ GP_HilbertCurveInit(&state, n);
+
+ /* processed pixels counter */
+ unsigned int cnt = 0;
+
+ /* error counters */
+%% for c in pt.chanslist
+ int err_{{ c[0] }} = 0;
+%% endfor
+
+ while (GP_HilbertCurveContinues(&state)) {
+ if (state.x < src->w && state.y < src->h) {
+ GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, state.x, state.y);
+
+%% for c in pt.chanslist
+%% if pt.is_gray()
+ int pix_{{ c[0] }} = GP_Pixel_GET_R_RGB888(pix) +
+ GP_Pixel_GET_G_RGB888(pix) +
+ GP_Pixel_GET_B_RGB888(pix);
+%% else
+ int pix_{{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_RGB888(pix);
+%% endif
+
+ pix_{{ c[0] }} += err_{{ c[0] }};
+
+%% if pt.is_gray()
+ int res_{{ c[0] }} = ({{ 2 ** c[2] - 1}} * pix_{{ c[0] }} + 382) / {{ 3 * 255 }};
+ err_{{ c[0] }} = pix_{{ c[0] }} - {{ 3 * 255 }} * res_{{ c[0] }} / {{ 2 ** c[2] - 1 }};
+%% else
+ int res_{{ c[0] }} = ({{ 2 ** c[2] - 1}} * pix_{{ c[0] }} + 127) / 255;
+ err_{{ c[0] }} = pix_{{ c[0] }} - 255 * res_{{ c[0] }} / {{ 2 ** c[2] - 1 }};
+%% endif
+%% endfor
+
+%% if pt.is_gray()
+ GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, state.x, state.y, res_V);
+%% else
+ GP_Pixel res = GP_Pixel_CREATE_{{ pt.name }}(res_{{ pt.chanslist[0][0] }}{% for c in pt.chanslist[1:] %}, res_{{ c[0] }}{% endfor %});
+
+ GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, state.x, state.y, res);
+%% endif
+ cnt++;
+
+ if (GP_ProgressCallbackReport(callback, cnt/src->h, src->w, src->h))
+ return 1;
+
+ /* We are done, exit */
+ if (cnt == src->w * src->h - 1) {
+ GP_ProgressCallbackDone(callback);
+ return 0;
+ }
+ } else {
+%% for c in pt.chanslist
+ err_{{ c[0] }} = 0;
+%% endfor
+ }
+
+ GP_HilbertCurveNext(&state);
+ }
+
+ GP_ProgressCallbackDone(callback);
+ return 0;
+}
+
+%% endif
+%% endfor
+
+int GP_FilterHilbertPeano_RGB888_to_XXX_Raw(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ switch (dst->pixel_type) {
+%% for pt in pixeltypes
+%% if not pt.is_unknown() and not pt.is_alpha() and not pt.is_palette()
+ case GP_PIXEL_{{ pt.name }}:
+ return GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(src, dst, callback);
+%% endif
+%% endfor
+ default:
+ return 1;
+ }
+}
+
+%% endblock body
diff --git a/libs/filters/Makefile b/libs/filters/Makefile
index 216d06d..7a9a670 100644
--- a/libs/filters/Makefile
+++ b/libs/filters/Makefile
@@ -8,7 +8,7 @@ POINT_FILTERS=GP_Contrast.gen.c GP_Brightness.gen.c GP_Invert.gen.c ARITHMETIC_FILTERS=GP_Difference.gen.c GP_Addition.gen.c GP_Min.gen.c GP_Max.gen.c GP_Multiply.gen.c
-GENSOURCES=GP_MirrorV.gen.c GP_Rotate.gen.c GP_Dither.gen.c+GENSOURCES=GP_MirrorV.gen.c GP_Rotate.gen.c GP_Dither.gen.c GP_HilbertPeanoDithering.gen.c $(POINT_FILTERS) $(ARITHMETIC_FILTERS) $(STATS_FILTERS)
CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c))
http://repo.or.cz/w/gfxprim.git/commit/28e1f1872424ff83ed2eceafcbdd6b9b293b…
commit 28e1f1872424ff83ed2eceafcbdd6b9b293b8866
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 20 22:00:46 2012 +0200
filters: Initial version of Hilbert Peano Dithering.
* For G1 only now.
diff --git a/include/filters/GP_Dither.h b/include/filters/GP_Dither.h
index b0b5157..07a8da2 100644
--- a/include/filters/GP_Dither.h
+++ b/include/filters/GP_Dither.h
@@ -61,4 +61,12 @@ int GP_FilterFloydSteinberg_XXX_to_G1_Raw(const GP_Context *src,
GP_ProgressCallback *callback);
+/*
+ * Hilbert-peano space filling curve based dithering.
+ */
+int GP_FilterHilbertPeano_from_RGB888(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
+
+
#endif /* FILTERS_GP_DITHER_H */
diff --git a/include/filters/GP_Dither.h b/include/filters/GP_HilbertCurve.h
similarity index 53%
copy from include/filters/GP_Dither.h
copy to include/filters/GP_HilbertCurve.h
index b0b5157..fecac22 100644
--- a/include/filters/GP_Dither.h
+++ b/include/filters/GP_HilbertCurve.h
@@ -16,49 +16,84 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
/*
- Dithering algorithms.
+ Hilbert curve implementation.
*/
-#ifndef FILTERS_GP_DITHER_H
-#define FILTERS_GP_DITHER_H
+#ifndef FILTERS_GP_HILBERT_CURVE_H
+#define FILTERS_GP_HILBERT_CURVE_H
-#include "GP_Filter.h"
+struct GP_CurveState {
+ /* half of the number of bits of curve size */
+ unsigned int n;
+ /* coordinates */
+ unsigned int x, y;
+ /* current curve lenght */
+ unsigned int s;
+};
/*
- * Floyd Steinberg
+ * Resets curve to initial state i.e. x = 0, y = 0, (length) s = 0.
*/
-GP_Context *GP_FilterFloydSteinberg_to_G1(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+static inline void GP_HilbertCurveInit(struct GP_CurveState *state, int n)
+{
+ state->n = n;
+ state->s = 0;
+ state->x = 0;
+ state->y = 0;
+}
/*
- * Floyd Steinberg
+ * Variant of Lam and Shapiro
*/
-GP_Context *GP_FilterFloydSteinberg_from_RGB888(const GP_Context *src,
- GP_Context *dst,
- GP_PixelType dst_pixel_type,
- GP_ProgressCallback *callback);
+static inline void GP_HilbertCurveGetXY(struct GP_CurveState *state)
+{
+ int sa, sb;
+ unsigned int i, temp, x, y;
+
+ for (i = 0; i < 2 * state->n; i += 2) {
+ sa = (state->s >> (i+1)) & 0x01;
+ sb = (state->s >> i) & 0x01;
+
+ if ((sa ^ sb) == 0) {
+ temp = x;
+ x = y ^ (-sa);
+ y = temp ^ (-sa);
+ }
+
+ x = (x >> 1) | (sa << 31);
+ y = (y >> 1) | ((sa ^ sb) << 31);
+ }
+
+ state->x = x >> (32 - state->n);
+ state->y = y >> (32 - state->n);
+}
+
/*
- * Converts RGB888 to RGB or Grayscale bitmap.
+ * Finds next X and Y
*/
-int GP_FilterFloydSteinberg_RGB888_to_XXX_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+static inline void GP_HilbertCurveNext(struct GP_CurveState *state)
+{
+
+ /* increment length */
+ state->s++;
+ /* get X and Y */
+ GP_HilbertCurveGetXY(state);
+}
/*
- * Converts any bitmap to 1-bit Grayscale.
+ * Returns true if we are not at curve endpoint
*/
-int GP_FilterFloydSteinberg_XXX_to_G1_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
-
+static inline int GP_HilbertCurveContinues(struct GP_CurveState *state)
+{
+ return state->s < (1U<<(2*state->n));
+}
-#endif /* FILTERS_GP_DITHER_H */
+#endif /* FILTERS_GP_HILBERT_CURVE_H */
diff --git a/include/filters/GP_Dither.h b/libs/filters/GP_HilbertPeanoDithering.c
similarity index 51%
copy from include/filters/GP_Dither.h
copy to libs/filters/GP_HilbertPeanoDithering.c
index b0b5157..decaebf 100644
--- a/include/filters/GP_Dither.h
+++ b/libs/filters/GP_HilbertPeanoDithering.c
@@ -16,49 +16,82 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-/*
+#include "core/GP_Debug.h"
+#include "core/GP_GetPutPixel.h"
+#include "core/GP_Core.h"
- Dithering algorithms.
+#include "GP_HilbertCurve.h"
+#include "GP_Dither.h"
+/*
+ * Returns closest greater square of two, used to determine the curve size.
*/
+static unsigned int count_bits(unsigned int n)
+{
+ unsigned int i = 0, s = n;
-#ifndef FILTERS_GP_DITHER_H
-#define FILTERS_GP_DITHER_H
+ do {
+ n>>=1;
+ i++;
+ } while (n);
-#include "GP_Filter.h"
+ return (i + (s != (1<<i)));
+}
-/*
- * Floyd Steinberg
- */
-GP_Context *GP_FilterFloydSteinberg_to_G1(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+int GP_FilterHilbertPeano_from_RGB888(const GP_Context *src,
+ GP_Context *dst,
+ GP_ProgressCallback *callback)
+{
+ struct GP_CurveState state;
-/*
- * Floyd Steinberg
- */
-GP_Context *GP_FilterFloydSteinberg_from_RGB888(const GP_Context *src,
- GP_Context *dst,
- GP_PixelType dst_pixel_type,
- GP_ProgressCallback *callback);
+ unsigned int n = GP_MAX(count_bits(src->w), count_bits(src->h));
-/*
- * Converts RGB888 to RGB or Grayscale bitmap.
- */
-int GP_FilterFloydSteinberg_RGB888_to_XXX_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+ GP_DEBUG(1, "Hilbert Peano dithering %ux%u -> n = %u", src->w, src->h, n);
-/*
- * Converts any bitmap to 1-bit Grayscale.
- */
-int GP_FilterFloydSteinberg_XXX_to_G1_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+ GP_HilbertCurveInit(&state, n);
+
+ int err = 0, cnt = 0;
+
+ while (GP_HilbertCurveContinues(&state)) {
+
+ if (state.x < src->w && state.y < src->h) {
+ int pix = GP_GetPixel_Raw(src, state.x, state.y);
+
+ pix = GP_ConvertPixel(pix, src->pixel_type, GP_PIXEL_G8);
+
+ pix += err;
+
+ if (pix > 127) {
+ err = pix - 255;
+ pix = 1;
+ } else {
+ err = pix;
+ pix = 0;
+ }
+
+ GP_PutPixel_Raw_1BPP_LE(dst, state.x, state.y, pix);
+
+ cnt++;
+
+ if (GP_ProgressCallbackReport(callback, cnt/src->h, src->w, src->h))
+ return 1;
+
+ /* We are done, exit */
+ if (cnt == src->w * src->h - 1) {
+ GP_ProgressCallbackDone(callback);
+ return 0;
+ }
+ } else {
+ err = 0;
+ }
+ GP_HilbertCurveNext(&state);
+ }
-#endif /* FILTERS_GP_DITHER_H */
+ GP_ProgressCallbackDone(callback);
+ return 0;
+}
-----------------------------------------------------------------------
Summary of changes:
include/filters/GP_Dither.h | 8 ++
.../GP_GIF.h => filters/GP_HilbertCurve.h} | 84 ++++++++++----
libs/filters/GP_Dither.c | 11 ++
libs/filters/GP_Dither.gen.c.t | 6 +-
libs/filters/GP_HilbertPeanoDithering.gen.c.t | 126 ++++++++++++++++++++
libs/filters/Makefile | 2 +-
6 files changed, 209 insertions(+), 28 deletions(-)
copy include/{loaders/GP_GIF.h => filters/GP_HilbertCurve.h} (55%)
create mode 100644 libs/filters/GP_HilbertPeanoDithering.gen.c.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 master updated: c2f10f3f488c6f32fb2c516153689a1fcc317ff0
by metan 18 May '12
by metan 18 May '12
18 May '12
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 c2f10f3f488c6f32fb2c516153689a1fcc317ff0 (commit)
via 76df7a3b73ab206fcb98801c38c0d5507af80c9e (commit)
via 0aef2153ab52e46219ddb032d5c0920903d4f7ee (commit)
via bef941cfec1236983582823bf2d0b45b7c5a2d10 (commit)
from cfc171705f4af25d48d768ed3b5e89e1ef668393 (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/c2f10f3f488c6f32fb2c516153689a1fcc31…
commit c2f10f3f488c6f32fb2c516153689a1fcc317ff0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 18 20:16:07 2012 +0200
spiv: Add option to use pixel type emulation for backend.
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 5d0dcab..2062015 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -34,6 +34,7 @@
#include <GP.h>
#include <backends/GP_Backends.h>
+#include <backends/GP_BackendVirtual.h>
#include <input/GP_InputDriverLinux.h>
#include "cpu_timer.h"
@@ -382,8 +383,9 @@ int main(int argc, char *argv[])
int sleep_sec = -1;
struct loader_params params = {NULL, 0, 0, 0, .img = NULL};
int opt, debug_level = 0;
+ GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
- while ((opt = getopt(argc, argv, "b:cd:Ii:Ps:r:")) != -1) {
+ while ((opt = getopt(argc, argv, "b:cd:e:Ii:Ps:r:")) != -1) {
switch (opt) {
case 'I':
params.show_info = 1;
@@ -403,6 +405,14 @@ int main(int argc, char *argv[])
case 'd':
debug_level = atoi(optarg);
break;
+ case 'e':
+ emul_type = GP_PixelTypeByName(optarg);
+
+ if (emul_type == GP_PIXEL_UNKNOWN) {
+ fprintf(stderr, "Invalid pixel type '%s'n", optarg);
+ return 1;
+ }
+ break;
case 'r':
if (!strcmp(optarg, "90"))
rotate = 90;
@@ -437,6 +447,9 @@ int main(int argc, char *argv[])
init_backend(backend_opts);
+ if (emul_type != GP_PIXEL_UNKNOWN)
+ backend = GP_BackendVirtualInit(backend, emul_type, GP_BACKEND_CALL_EXIT);
+
context = backend->context;
GP_EventSetScreenSize(context->w, context->h);
http://repo.or.cz/w/gfxprim.git/commit/76df7a3b73ab206fcb98801c38c0d5507af8…
commit 76df7a3b73ab206fcb98801c38c0d5507af80c9e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 18 20:13:16 2012 +0200
core: Add GP_PixelTypeByName().
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h
index c8d82e4..8fb84a2 100644
--- a/include/core/GP_Pixel.h
+++ b/include/core/GP_Pixel.h
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
* Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
* *
@@ -159,6 +159,11 @@ static inline void GP_PixelPrint(GP_Pixel pixel, GP_PixelType type)
}
/*
+ * Returns pixel type for passed human-readable name (e.g. RGB888).
+ */
+GP_PixelType GP_PixelTypeByName(const char *name);
+
+/*
* Match pixel type to known pixel types.
*
* Returns either valid PixelType or GP_PIXEL_UNKNOWN
diff --git a/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c
index bedaf14..b14d5b0 100644
--- a/libs/core/GP_Pixel.c
+++ b/libs/core/GP_Pixel.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -56,6 +56,17 @@ static int match(const GP_PixelTypeChannel *channel, GP_Pixel mask)
return (chmask == mask);
}
+GP_PixelType GP_PixelTypeByName(const char *name)
+{
+ unsigned int i;
+
+ for (i = 0; i < GP_PIXEL_MAX; i++)
+ if (!strcasecmp(name, GP_PixelTypes[i].name))
+ return i;
+
+ return GP_PIXEL_UNKNOWN;
+}
+
GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
GP_Pixel bmask, GP_Pixel amask,
uint8_t bits_per_pixel)
http://repo.or.cz/w/gfxprim.git/commit/0aef2153ab52e46219ddb032d5c0920903d4…
commit 0aef2153ab52e46219ddb032d5c0920903d4f7ee
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 18 20:00:26 2012 +0200
backends: Add virtual emulation backend for testing.
diff --git a/include/backends/GP_BackendVirtual.h b/include/backends/GP_BackendVirtual.h
new file mode 100644
index 0000000..a050dc3
--- /dev/null
+++ b/include/backends/GP_BackendVirtual.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-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+/*
+
+ Virtual backend, could emulate backed with any pixel type on the top of
+ initalized backend. Useful for testing.
+
+ */
+
+#ifndef BACKENDS_GP_BACKEND_VIRTUAL_H
+#define BACKENDS_GP_BACKEND_VIRTUAL_H
+
+#include "GP_Backend.h"
+
+enum GP_BackendVirtFlags {
+ /*
+ * If set virtual backend exit calls 'parent' Exit as well.
+ */
+ GP_BACKEND_CALL_EXIT = 0x01,
+};
+
+/*
+ * Create an virtual backend on the top of the existing backend.
+ */
+GP_Backend *GP_BackendVirtualInit(GP_Backend *backend,
+ GP_PixelType pixel_type, int flags);
+
+#endif /* BACKENDS_GP_BACKEND_VIRTUAL_H */
diff --git a/libs/backends/GP_BackendVirtual.c b/libs/backends/GP_BackendVirtual.c
new file mode 100644
index 0000000..b28c3cb
--- /dev/null
+++ b/libs/backends/GP_BackendVirtual.c
@@ -0,0 +1,145 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+
+#include "core/GP_Context.h"
+#include "core/GP_Blit.h"
+#include "core/GP_Debug.h"
+
+#include "GP_BackendVirtual.h"
+
+struct virt_priv {
+ /* Original backend */
+ GP_Backend *backend;
+
+ int flags;
+};
+
+static void virt_flip(GP_Backend *self)
+{
+ struct virt_priv *virt = GP_BACKEND_PRIV(self);
+
+ /* Convert and copy the buffer */
+ GP_Blit(self->context, 0, 0, self->context->w, self->context->h,
+ virt->backend->context, 0, 0);
+
+ /* Call blit on original backend */
+ virt->backend->Flip(virt->backend);
+}
+
+static void virt_update_rect(GP_Backend *self, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1)
+{
+ struct virt_priv *virt = GP_BACKEND_PRIV(self);
+
+ /* Convert and copy the buffer */
+ GP_BlitXYXY(self->context, x0, y0, x1, y1,
+ virt->backend->context, x0, y0);
+
+ /* Call blit on original backend */
+ virt->backend->UpdateRect(virt->backend, x0, y0, x1, y1);
+}
+
+static int virt_set_attributes(struct GP_Backend *self,
+ uint32_t w, uint32_t h,
+ const char *caption)
+{
+ struct virt_priv *virt = GP_BACKEND_PRIV(self);
+ int ret;
+
+ ret = virt->backend->SetAttributes(virt->backend, w, h, caption);
+
+ if (ret)
+ return ret;
+
+ /* If backend was resized, update our buffer as well */
+ if (h != 0 && w != 0)
+ GP_ContextResize(self->context, w, h);
+
+ return 0;
+}
+
+static void virt_poll(GP_Backend *self)
+{
+ struct virt_priv *virt = GP_BACKEND_PRIV(self);
+
+ virt->backend->Poll(virt->backend);
+}
+
+static void virt_exit(GP_Backend *self)
+{
+ struct virt_priv *virt = GP_BACKEND_PRIV(self);
+
+ GP_ContextFree(self->context);
+
+ if (virt->flags & GP_BACKEND_CALL_EXIT)
+ virt->backend->Exit(virt->backend);
+
+ free(self);
+}
+
+GP_Backend *GP_BackendVirtualInit(GP_Backend *backend,
+ GP_PixelType pixel_type, int flags)
+{
+ GP_Backend *self;
+ struct virt_priv *virt;
+
+ self = malloc(sizeof(GP_Backend) +
+ sizeof(struct virt_priv));
+
+ if (self == NULL) {
+ GP_DEBUG(1, "Malloc failed :(");
+ return NULL;
+ }
+
+ memset(self, 0, sizeof(GP_Backend));
+
+ /* Create new buffer with different context type */
+ self->context = GP_ContextAlloc(backend->context->w, backend->context->h,
+ pixel_type);
+
+ if (self->context == NULL)
+ goto err0;
+
+ virt = GP_BACKEND_PRIV(self);
+ virt->backend = backend;
+ virt->flags = flags;
+
+ /* Initalize new backend */
+ self->name = "Virtual Backend";
+ self->Flip = virt_flip;
+ self->UpdateRect = virt_update_rect;
+ self->Exit = virt_exit;
+
+ if (backend->Poll)
+ self->Poll = virt_poll;
+
+ if (backend->SetAttributes)
+ self->SetAttributes = virt_set_attributes;
+
+ return self;
+
+err0:
+ free(self);
+ return NULL;
+}
http://repo.or.cz/w/gfxprim.git/commit/bef941cfec1236983582823bf2d0b45b7c5a…
commit bef941cfec1236983582823bf2d0b45b7c5a2d10
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri May 18 18:51:31 2012 +0200
backends: X11: More error checking and pixel matching.
The XImage interface is _strange_ I did best effort
to match reasonable pixel type. Still not sure if this
will actually work on unexpected xserver configurations.
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index af98a67..1c5dd91 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -34,23 +34,28 @@
struct x11_priv {
Display *dpy;
int scr;
+ Screen *scr_ptr;
+ int scr_depth;
Window win;
Visual *vis;
+
XImage *img;
int resized_flag;
};
+static void destroy_ximage(GP_Backend *self);
+
+static int resize_ximage(GP_Backend *self, int w, int h);
+
static void x11_exit(GP_Backend *self)
{
struct x11_priv *x11 = GP_BACKEND_PRIV(self);
XLockDisplay(x11->dpy);
-
- GP_ContextFree(self->context);
- x11->img->data = NULL;
- XDestroyImage(x11->img);
+ destroy_ximage(self);
+
XDestroyWindow(x11->dpy, x11->win);
/* I wonder if this is right sequence... */
XUnlockDisplay(x11->dpy);
@@ -148,8 +153,6 @@ static int x11_set_attributes(struct GP_Backend *self,
}
if (w != 0 || h != 0) {
- XImage *img;
-
if (w == 0)
w = self->context->w;
@@ -157,30 +160,14 @@ static int x11_set_attributes(struct GP_Backend *self,
h = self->context->h;
GP_DEBUG(3, "Setting window size to %ux%u", w, h);
-
- /* Create new X image */
- img = XCreateImage(x11->dpy, x11->vis, 24, ZPixmap, 0, NULL,
- w, h, 32, 0);
-
- /* Allocate new context */
-
- if (GP_ContextResize(self->context, w, h)) {
- XDestroyImage(img);
+
+ if (resize_ximage(self, w, h))
return 1;
- }
-
- /* Free old image */
- x11->img->data = NULL;
- XDestroyImage(x11->img);
-
- /* Swap the pointers */
- img->data = (char*)self->context->pixels;
- x11->img = img;
/* Resize X11 window */
XResizeWindow(x11->dpy, x11->win, w, h);
XFlush(x11->dpy);
-
+
x11->resized_flag = 1;
}
@@ -189,6 +176,90 @@ static int x11_set_attributes(struct GP_Backend *self,
return 0;
}
+static int create_ximage(GP_Backend *self, GP_Size w, GP_Size h)
+{
+ struct x11_priv *x11 = GP_BACKEND_PRIV(self);
+ int depth;
+ enum GP_PixelType pixel_type;
+
+ /*
+ * Eh, the XImage supports either 8, 16 or 32 bit pixels
+ *
+ * Do best effor on selecting appropriate pixel type
+ */
+ for (depth = 8; depth <= 32; depth<<=1) {
+ pixel_type = GP_PixelRGBMatch(x11->vis->red_mask,
+ x11->vis->green_mask,
+ x11->vis->blue_mask,
+ 0x0, depth);
+
+ if (pixel_type != GP_PIXEL_UNKNOWN)
+ break;
+ }
+
+ if (pixel_type == GP_PIXEL_UNKNOWN) {
+ GP_DEBUG(1, "Unknown pixel type");
+ return 1;
+ }
+
+ self->context = GP_ContextAlloc(w, h, pixel_type);
+
+ if (self->context == NULL)
+ return 1;
+
+ x11->img = XCreateImage(x11->dpy, x11->vis, x11->scr_depth, ZPixmap, 0,
+ NULL, w, h, depth, 0);
+
+ if (x11->img == NULL) {
+ GP_DEBUG(1, "Failed to create XImage");
+ GP_ContextFree(self->context);
+ return 1;
+ }
+
+ x11->img->data = (char*)self->context->pixels;
+ return 0;
+}
+
+static void destroy_ximage(GP_Backend *self)
+{
+ struct x11_priv *x11 = GP_BACKEND_PRIV(self);
+
+ GP_ContextFree(self->context);
+ x11->img->data = NULL;
+ XDestroyImage(x11->img);
+}
+
+static int resize_ximage(GP_Backend *self, int w, int h)
+{
+ struct x11_priv *x11 = GP_BACKEND_PRIV(self);
+ XImage *img;
+
+ /* Create new X image */
+ img = XCreateImage(x11->dpy, x11->vis, x11->scr_depth, ZPixmap, 0, NULL,
+ w, h, x11->img->bitmap_pad, 0);
+
+ if (img == NULL) {
+ GP_DEBUG(2, "XCreateImage failed");
+ return 1;
+ }
+
+ /* Resize context */
+ if (GP_ContextResize(self->context, w, h)) {
+ XDestroyImage(img);
+ return 1;
+ }
+
+ /* Free old image */
+ x11->img->data = NULL;
+ XDestroyImage(x11->img);
+
+ /* Swap the pointers */
+ img->data = (char*)self->context->pixels;
+ x11->img = img;
+
+ return 0;
+}
+
GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
unsigned int w, unsigned int h,
const char *caption)
@@ -197,6 +268,11 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
struct x11_priv *x11;
GP_DEBUG(1, "Initalizing X11 display '%s'", display);
+
+ if (!XInitThreads()) {
+ GP_DEBUG(2, "XInitThreads failed");
+ return NULL;
+ }
backend = malloc(sizeof(GP_Backend) +
sizeof(struct x11_priv));
@@ -206,30 +282,24 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
x11 = GP_BACKEND_PRIV(backend);
- backend->context = GP_ContextAlloc(w, h, GP_PIXEL_xRGB8888);
-
- if (backend->context == NULL)
- goto err0;
-
- //TODO: Error checking
- XInitThreads();
-
x11->dpy = XOpenDisplay(display);
if (x11->dpy == NULL)
- goto err1;
+ goto err0;
x11->scr = DefaultScreen(x11->dpy);
x11->vis = DefaultVisual(x11->dpy, x11->scr);
+ x11->scr_ptr = DefaultScreenOfDisplay(x11->dpy);
+ x11->scr_depth = DefaultDepthOfScreen(x11->scr_ptr);
+
+ GP_DEBUG(2, "Have Visual id %i, depth %u", (int)x11->vis->visualid, x11->scr_depth);
+
+ if (create_ximage(backend, w, h))
+ goto err1;
GP_DEBUG(2, "Opening window '%s' %ix%i-%ux%u",
caption, x, y, w, h);
- x11->img = XCreateImage(x11->dpy, x11->vis, 24, ZPixmap, 0, NULL,
- w, h, 32, 0);
-
- x11->img->data = (char*)backend->context->pixels;
-
x11->win = XCreateWindow(x11->dpy, DefaultRootWindow(x11->dpy),
x, y, w, h, 0, CopyFromParent,
InputOutput, CopyFromParent, 0, NULL);
@@ -257,22 +327,6 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
x11->resized_flag = 0;
-/*
- 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;
- }
-
-
-*/
-
backend->name = "X11";
backend->Flip = x11_flip;
backend->UpdateRect = x11_update_rect;
@@ -281,14 +335,11 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
backend->Poll = x11_poll;
backend->SetAttributes = x11_set_attributes;
-
return backend;
-//err3:
-// XDestroyWindow(x11->dpy, x11->win);
err2:
- XCloseDisplay(x11->dpy);
+ destroy_ximage(backend);
err1:
- GP_ContextFree(backend->context);
+ XCloseDisplay(x11->dpy);
err0:
free(backend);
return NULL;
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 15 ++-
include/backends/{GP_X11.h => GP_BackendVirtual.h} | 32 +++--
include/core/GP_Pixel.h | 7 +-
libs/backends/GP_BackendVirtual.c | 145 +++++++++++++++++
libs/backends/GP_X11.c | 171 +++++++++++++-------
libs/core/GP_Pixel.c | 13 ++-
6 files changed, 308 insertions(+), 75 deletions(-)
copy include/backends/{GP_X11.h => GP_BackendVirtual.h} (74%)
create mode 100644 libs/backends/GP_BackendVirtual.c
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 master updated: cfc171705f4af25d48d768ed3b5e89e1ef668393
by metan 13 May '12
by metan 13 May '12
13 May '12
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 cfc171705f4af25d48d768ed3b5e89e1ef668393 (commit)
from 33a4746b83e0cebb41776cc50b9d44a5c31a06fd (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/cfc171705f4af25d48d768ed3b5e89e1ef66…
commit cfc171705f4af25d48d768ed3b5e89e1ef668393
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 13 16:14:02 2012 +0200
doc: Used spell checker to fix typos.
diff --git a/doc/backends.txt b/doc/backends.txt
index ced9548..2a614ff 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -3,14 +3,14 @@ Drawing Backends
Drawing backends provide means to draw into computer screen or into an window
inside of running operating system. Instead of having one unified
-initalization interface each backend has it's specific function and sematics
-but once backend is initalized the backend structure provides unified API for
-controling the drawing.
+initialization interface each backend has it's specific function and semantics
+but once backend is initialized the backend structure provides unified API for
+controlling the drawing.
-So far there are three backends implemented, linux mmaped framebuffer, libSDL
+So far there are three backends implemented, Linux mmaped frame-buffer, libSDL
and X11 backend.
-Initalization functions
+Initialization functions
~~~~~~~~~~~~~~~~~~~~~~~
[source,c]
@@ -18,12 +18,12 @@ Initalization functions
GP_Backend *GP_BackendLinuxFBInit(const char *path);
-------------------------------------------------------------------------------
-Initalizes mmaped framebuffer backend. The path is path to the framebuffer
-device ie. '/dev/fbX'. This backend is not buffered, everything you draw
-appears on the screen right away (an swich may be added for that purpose).
+Initializes mmaped frame-buffer backend. The path is path to the frame-buffer
+device i.e. '/dev/fbX'. This backend is not buffered, everything you draw
+appears on the screen right away (an switch may be added for that purpose).
-Also note that this backend doesn't initalize any input driver. You need to
-initalize input driver in order to get keystrokes and/or pointer events.
+Also note that this backend doesn't initialize any input driver. You need to
+initialize input driver in order to get keystrokes and/or pointer events.
[source,c]
@@ -38,15 +38,15 @@ GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h,
const char *caption);
-------------------------------------------------------------------------------
-Initalize SDL as an backend driver. The backend is thread safe as all the
-operations are guarded by locks. You can't initalize more than one backend at a
-time, that is inherited SDL limiation. If you call the initalizaiton for a
-second time, you will get a pointer to allready running backend. This driver
+Initialize SDL as an backend driver. The backend is thread safe as all the
+operations are guarded by locks. You can't initialize more than one backend at a
+time, that is inherited SDL limitation. If you call the initialization for a
+second time, you will get a pointer to already running backend. This driver
feeds input events into global input event queue (see input docs for details).
If w, h and/or bpp are zero SDL tries to do a guess, most of the time wrong for
w and h though. The caption is window caption and may be ignored for some of
-the backends. And finally flags may change the SDL to go to fullscreen mode or
-make the window resizeable.
+the backends. And finally flags may change the SDL to go to full-screen mode or
+make the window resizable.
[source,c]
-------------------------------------------------------------------------------
@@ -65,7 +65,7 @@ windows at a time.
Overall init function
~~~~~~~~~~~~~~~~~~~~~
-Althoug there is no unified backend initalization, there is something close to
+Although there is no unified backend initialization, there is something close to
it.
[source,c]
@@ -76,23 +76,23 @@ GP_Backend *GP_BackendInit(const char *params, const char *caption, FILE *help);
-------------------------------------------------------------------------------
This function takes a params string as an parameter which is used for
-determining backend-dependend parametrs. The format is
+determining backend-dependent parameters. The format is
'backend_name:backend_parameters' where backend parameters may be window size
(either 'WxH' or 'FS' in case of SDL backend). The caption is window caption
(which is ignored in some of the cases) and the 'FILE' is file, where an error
is printed in case of failure, you should mostly use 'stderr' for that
purpose. If params is set to 'NULL' the the call only prints help into the
-passed help 'FILE'. If intitalizaton was succesfull pointer to allocated and
-initalized backend is returned otherwise 'NULL' is returned and some helpful
-infomation should be printed into the passed help 'FILE'.
+passed help 'FILE'. If initialization was successful pointer to allocated and
+initialized backend is returned otherwise 'NULL' is returned and some helpful
+information should be printed into the passed help 'FILE'.
Drawing Backend API
~~~~~~~~~~~~~~~~~~~
The drawing backend API consist of structure with callbacks. Every backend
-initalization yields pointer to this structure. Although is possible to call
-these pointers directly it's not recomended and everbody should rather use
+initialization yields pointer to this structure. Although is possible to call
+these pointers directly it's not recommended and everybody should rather use
backend inline functions instead.
The backend API consist of several functions:
@@ -109,7 +109,7 @@ Calls an backend exit callback.
GP_BackendFlip(GP_Backend *backend);
-------------------------------------------------------------------------------
-Flips a screen. Updates rect for a buffered backends.
+Flips a screen. Updates rectangle for a buffered backends.
[source,c]
-------------------------------------------------------------------------------
@@ -127,4 +127,4 @@ void GP_BackendPoll(GP_Backend *backend);
Polls for backend events. For backends that do not expose file descriptor
(namely SDL) this should be called repeatedly. For other backend it may be
-called either repeatedly or when data are ready on filedescriptor.
+called either repeatedly or when data are ready on file-descriptor.
diff --git a/doc/context.txt b/doc/context.txt
index 00c6c08..809f995 100644
--- a/doc/context.txt
+++ b/doc/context.txt
@@ -54,7 +54,7 @@ you could use variants with _Raw suffix (although this is not recommended).
There are various helper macros for transforming coordinates and sizes in
'core/GP_Transform.h'. And context helper functions to "rotate" the flags
clock wise and counter clock wise as well as functions to get the context size
-when taking into the accout the widht and height.
+when taking into the account the width and height.
[source,c]
-------------------------------------------------------------------------------
@@ -108,7 +108,7 @@ void GP_ContextInit(GP_Context *context, GP_Size w, GP_Size h,
GP_PixelType type, void *pixels);
-------------------------------------------------------------------------------
-Initalize given context accordingly to parameters, the rest of context
+Initialize given context accordingly to parameters, the rest of context
parameters are set to the default values (i.e. rotation flags are all set to
zero, 'free_pixels' flag is not set). Number of bits per pixel and
bytes per row are computed from the given pixel type and size.
@@ -125,7 +125,7 @@ will *not* try to allocate the pixel memory automatically).
GP_Context *GP_ContextAlloc(GP_Size w, GP_Size h, GP_PixelType type);
-------------------------------------------------------------------------------
-The 'GP_ContextAlloc()' allocates and initalizes a context.
+The 'GP_ContextAlloc()' allocates and initializes a context.
The orientation flags are all set to zero, the 'free_pixels' flag is set and the
rest of the metadata are calculated accordingly to width, height and
@@ -141,7 +141,7 @@ appropriate size; the initial contents of the bitmap are undefined.
GP_Context *GP_ContextCopy(const GP_Context *src, int flag);
-------------------------------------------------------------------------------
-The 'GP_ContextCopy()' allocates and initalizes a copy of the context passed
+The 'GP_ContextCopy()' allocates and initializes a copy of the context passed
as argument. If 'flag' is set, the bitmap contents ('src->pixels')
are also copied; otherwise the copy will have the same dimensions but
undefined contents.
diff --git a/doc/drawing_api.txt b/doc/drawing_api.txt
index d836680..a7f65c9 100644
--- a/doc/drawing_api.txt
+++ b/doc/drawing_api.txt
@@ -292,6 +292,6 @@ The Descent is the height in pixels from baseline to the bottom.
unsigned int GP_TextHeight(const GP_TextStyle *style);
--------------------------------------------------------------------------------
-The Height is size of the font from top to the bottom, eg. equals exactly to
+The Height is size of the font from top to the bottom, i.e. equals exactly to
the sum of ascent and descent.
diff --git a/doc/filters.txt b/doc/filters.txt
index 6750a70..a2647b7 100644
--- a/doc/filters.txt
+++ b/doc/filters.txt
@@ -25,7 +25,7 @@ type and the context size must be big enough to store the result.
For filters that work 'in-place' (which is explicitly said for each filter)
the source and the destination could be the same context. Note that this is
-not expected to work if you do several overlaping subcontexts and pass these
+not expected to work if you do several overlapping subcontexts and pass these
as arguments.
When 'NULL' is passed as destination new context for storing the result is
@@ -38,7 +38,7 @@ pixel_type, parameters, etc...
[source,c]
-------------------------------------------------------------------------------
/*
- * Filter common api.
+ * Filter common API.
*/
GP_Context *GP_FilterFoo(const GP_Context *src, GP_Context *dst,
foo params ...,
@@ -69,7 +69,7 @@ Point operation filters
Point operations are filters that works with pixels as with independent values
(the value of destination pixel depends only on the pixel on the same
-coodrdinates in source image). All of these filters works 'in-place' and the
+coordinates in source image). All of these filters works 'in-place' and the
result has always the same size as the source.
[source,c]
@@ -90,7 +90,7 @@ GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst,
float mul, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Constrast filter, multiplies all pixel channels by a fixed value.
+Contrast filter, multiplies all pixel channels by a fixed value.
[source,c]
-------------------------------------------------------------------------------
@@ -149,7 +149,7 @@ Rotate context by 90 degrees.
Doesn't work 'in-place' (yet).
The destination has to have the same pixel type and destination size must be
-big enough to fit rotated context (eg. W and H are swapped).
+big enough to fit rotated context (i.e. W and H are swapped).
[source,c]
-------------------------------------------------------------------------------
@@ -178,7 +178,7 @@ Rotate context by 270 degrees.
Doesn't work 'in-place' (yet).
-The destinatoin has to have the same pixel type and destination size must be
+The destination has to have the same pixel type and destination size must be
big enough to fit rotated context (eg. W and H are swapped).
[source,c]
@@ -253,14 +253,14 @@ Nearest Neighbour Interpolation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Fast, but produces "pixelated" images. May however work better for images with
-sharp edges mostly consisting of big one colour regions (it doesn't blur the
+sharp edges mostly consisting of big one color regions (it doesn't blur the
result on upscaling).
Bicubic Interpolation
^^^^^^^^^^^^^^^^^^^^^
Works well as is on image upscaling. To get decent result on downscaling
-low-pass filter (gaussian blur) must be used on original image before actuall
+low-pass filter (Gaussian blur) must be used on original image before actual
downscaling. To do this reasonably fast we could cheat a little: first resize
big images a little without the low-pass filter, then apply low-pass filter and
finally downscale it to desired size.
diff --git a/doc/general.txt b/doc/general.txt
index 96310bb..d71ec1f 100644
--- a/doc/general.txt
+++ b/doc/general.txt
@@ -22,7 +22,7 @@ Graphics Rendering
** PutPixel/GetPixel
** Lines
** Circles
-** Elipses
+** Ellipses
** Polygons
* Text Drawing
@@ -30,7 +30,7 @@ Graphics Rendering
** Basic fonts are compiled in the library
** Font rendering can be altered by style attributes
** Supports, for example, pixel multiplication and tracking
-** Includes basic suppport for freetype
+** Includes basic support for freetype
* Bitmaps and Blitting
** Create, Destroy bitmap
@@ -44,7 +44,7 @@ Graphics Rendering
** Read support for GIF
* Graphic backed input event handling
-** Linux Framebuffer
+** Linux Frame-buffer
** SDL support
** Experimental X11 support
@@ -60,7 +60,7 @@ Bitmap Filters
** Separable Convolution
** General Convolution
-* Arihtmetics filters
+* Arithmetics filters
** Addition
** Multiplication
** Difference
diff --git a/doc/loaders.txt b/doc/loaders.txt
index 72aae8c..0f31498 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -9,7 +9,7 @@ a failure 'NULL' is returned and 'errno' is set.
The possible errno values are:
* anything returned by fopen(), fclose(), fseek(), ...
-* 'ENOSYS' if library wasn't compiled with particual library support
+* 'ENOSYS' if library wasn't compiled with particular library support
* 'ENOMEM' as returned by malloc()
* 'EIO'/'EILSEQ' invalid image data
* 'ECANCELED' loading canceled from callback
@@ -27,7 +27,7 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Loads image from a file. The format is now matched by an image file extension.
-File sinature loading method is on the TODO.
+File signature loading method is on the TODO.
[source,c]
-------------------------------------------------------------------------------
@@ -40,16 +40,17 @@ int GP_SaveImage(GP_Context *src, const char *dst_path,
-------------------------------------------------------------------------------
Saves a context into a file. The file format is matched accordingly to the
-file extension, if extension is invalid or if support for request image format
-wasn't compiled in, non-zero is returned and 'errno' is set to 'ENOSYS'.
+file extension, if extension is invalid or if support for requested image
+format wasn't compiled in, non-zero is returned and 'errno' is set to
+'ENOSYS'.
-Returns zero on succes and non-zero on failure and 'errno' is set. The
+Returns zero on success and non-zero on failure and 'errno' is set. The
possible errno values are 'ENOSYS' for unknown format and anything that could
be returned by 'fopen()', 'open()', 'fwrite()', 'write()', 'seek()', etc...
PNG
~~~
-The 'PNG' loading support is optionaly implemented by libpng.
+The 'PNG' loading support is optionally implemented by libpng.
Just now, the 'PNG' support is not fully finished. Images with alpha channel
are not supported yet.
@@ -65,7 +66,7 @@ int GP_OpenPNG(const char *src_path, FILE **f);
Opens file and checks for 'PNG' signature. Returns zero on success (file
could be opened, signature matches), the opened file is returned and the file
-possition points right after the end of the 'PNG' signature.
+position points right after the end of the 'PNG' signature.
Upon failure 'errno' is filled.
@@ -81,7 +82,7 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Loads 'PNG' file into context the file pointer must point to the start of the
-'PNG' data stream (eg. should point right after the signature). The context,
+'PNG' data stream (i.e. should point right after the signature). The context,
to store the image to, is allocated. The loading process could by aborted by a
callback, in such case all memory is freed.
@@ -94,7 +95,7 @@ callback, in such case all memory is freed.
GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Same as abowe but takes path to the file as a parameter and check for the
+Same as above but takes path to the file as a parameter and check for the
signature. Basically this combines both of the calls above.
[source,c]
@@ -117,7 +118,7 @@ returned and 'errno' is set to 'ENOSYS'.
JPEG
~~~~
-The 'JPEG' loading support is optionaly implemented by jpeg library.
+The 'JPEG' loading support is optionally implemented by jpeg library.
[source,c]
-------------------------------------------------------------------------------
@@ -130,7 +131,7 @@ int GP_OpenJPG(const char *src_path, FILE **f);
Opens file and checks for 'JPG' signature upon successful return (file could
be opened, signature matches), the opened file is returned and the file
-possition points right after the end of the 'JPG' signature.
+position points right after the end of the 'JPG' signature.
This function is semi-internal, you should rather use functions listed below.
@@ -147,7 +148,7 @@ GP_Context *GP_ReadJPG(FILE *f, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Loads 'JPG' file into context the file pointer must point to the start of the
-'JPG' data stream (eg. should point right after the signature). The context,
+'JPG' data stream (i.e. should point right after the signature). The context,
to store the image to, is allocated. The loading process could by aborted by a
callback, in such case all memory is freed and the call returns 'NULL' and
'errno' is set to 'ECANCELED'.
@@ -161,7 +162,7 @@ callback, in such case all memory is freed and the call returns 'NULL' and
GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Same as abowe but takes path to the file as a parameter and check for the
+Same as above but takes path to the file as a parameter and check for the
signature. Basically this combines both of the calls above.
[source,c]
@@ -179,12 +180,12 @@ is closed and removed before the call returns non-zero and 'errno' is set to
'ECANCELED'.
The 'JPG' format could store either 'G8' or 'RGB888' pixeltypes and you must
-convert the context into one of them before this fucntions is called.
+convert the context into one of them before this functions is called.
GIF
~~~
-The 'GIF' format is supported optionaly by giflib library.
+The 'GIF' format is supported optionally by giflib library.
[source,c]
-------------------------------------------------------------------------------
@@ -227,7 +228,7 @@ Currently this function loads only first image from the gif container.
GP_Context *GP_LoadGIF(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Same as abowe but takes path to the file as a parameter and check for the
+Same as above but takes path to the file as a parameter and check for the
signature. Basically this combines both of the calls above.
BMP
@@ -248,7 +249,7 @@ int GP_OpenBMP(const char *src_path, FILE **f,
Opens file and checks for 'BMP' signature upon successful return (file could
be opened, signature matches) zero is returned and the parameters, if
-non-'NULL', are initalized. Upon failure non-zero is returned and 'errno' is
+non-'NULL', are initialized. Upon failure non-zero is returned and 'errno' is
set.
This function is semi-internal, you should rather use functions listed below.
@@ -278,7 +279,7 @@ Currently this function loads only first image from the 'GIF' container.
GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Same as abowe but takes path to the file as a parameter and check for the
+Same as above but takes path to the file as a parameter and check for the
signature. Basically this combines both of the calls above.
PBM, PGM, PPM
diff --git a/doc/pixel_types.txt b/doc/pixel_types.txt
index bf5acd8..b54ad7a 100644
--- a/doc/pixel_types.txt
+++ b/doc/pixel_types.txt
@@ -2,10 +2,10 @@ Supported pixel sizes
---------------------
The default maximum size of a single pixel is 32 bits. The limitations would
-be analoguous for other settings (8, 16 and 64).
+be analogous for other settings (8, 16 and 64).
Pixel sizes 8, 16 and 32 are supported on all systems and generally very efficient
-(assigment is used for all operations). 24 bpp is supported, but the operations may be
+(assignment is used for all operations). 24 bpp is supported, but the operations may be
slightly slower.
Pixel sizes 1, 2 and 4 depend on bit-endian setting and are supported on all systems.
@@ -19,7 +19,7 @@ to decode/encode.
Pixel sizes between 25 and 31 are not supported at all, as these pixels might not fit
into a 32-bit byte-aligned window.
-The pixel sizes to be supported must be explicitely listed in the configuration file,
+The pixel sizes to be supported must be explicitly listed in the configuration file,
each including the bit-endian if required (see below).
Supported pixel types
-----------------------------------------------------------------------
Summary of changes:
doc/backends.txt | 50 +++++++++++++++++++++++++-------------------------
doc/context.txt | 8 ++++----
doc/drawing_api.txt | 2 +-
doc/filters.txt | 16 ++++++++--------
doc/general.txt | 8 ++++----
doc/loaders.txt | 37 +++++++++++++++++++------------------
doc/pixel_types.txt | 6 +++---
7 files changed, 64 insertions(+), 63 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 master updated: 33a4746b83e0cebb41776cc50b9d44a5c31a06fd
by metan 13 May '12
by metan 13 May '12
13 May '12
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 33a4746b83e0cebb41776cc50b9d44a5c31a06fd (commit)
from 16abe6513b0fa77891c43da149b891edea2a912b (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/33a4746b83e0cebb41776cc50b9d44a5c31a…
commit 33a4746b83e0cebb41776cc50b9d44a5c31a06fd
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 13 14:23:13 2012 +0200
spiv: A few fixes for spiv.
* The image is now cached, so rotation and resize is faster
* Cleaned the code a little
* Added debug level command line option
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index ce97389..5d0dcab 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -86,6 +86,9 @@ struct loader_params {
int show_progress;
int show_progress_once;
int show_info;
+
+ /* cached loaded image */
+ GP_Context *img;
};
static float calc_img_size(uint32_t img_w, uint32_t img_h,
@@ -118,23 +121,27 @@ static void set_caption(const char *path, float rat)
GP_BackendSetCaption(backend, buf);
}
-static void *image_loader(void *ptr)
+/*
+ * Loads image
+ */
+int load_image(struct loader_params *params)
{
- struct loader_params *params = ptr;
- GP_ProgressCallback callback = {.callback = image_loader_callback};
struct cpu_timer timer;
- struct cpu_timer sum_timer;
GP_Context *img, *context = backend->context;
- cpu_timer_start(&sum_timer, "sum");
-
+ if (params->img != NULL) {
+ fprintf(stderr, "Image cached!n");
+ return 0;
+ }
+
+ GP_ProgressCallback callback = {.callback = image_loader_callback,
+ .priv = "Loading image"};
+
show_progress = params->show_progress || params->show_progress_once;
params->show_progress_once = 0;
fprintf(stderr, "Loading '%s'n", params->img_path);
- callback.priv = "Loading image";
-
cpu_timer_start(&timer, "Loading");
if ((img = GP_LoadImage(params->img_path, &callback)) == NULL) {
GP_Fill(context, black_pixel);
@@ -142,10 +149,56 @@ static void *image_loader(void *ptr)
GP_ALIGN_CENTER|GP_VALIGN_CENTER, white_pixel, black_pixel,
"Failed to load image :( (%s)", strerror(errno));
GP_BackendFlip(backend);
- return NULL;
+ return 1;
}
cpu_timer_stop(&timer);
+ params->img = img;
+
+ return 0;
+}
+
+/*
+ * This function tries to resize spiv window
+ * and if succedes blits the image directly to the screen.
+ */
+static int resize_backend_and_blit(GP_Context *img,
+ struct loader_params *params)
+{
+ if (GP_BackendResize(backend, img->w, img->h))
+ return 1;
+
+ GP_Blit_Raw(img, 0, 0, img->w, img->h, backend->context, 0, 0);
+ GP_BackendFlip(backend);
+ set_caption(params->img_path, 1);
+
+ return 0;
+}
+
+static void *image_loader(void *ptr)
+{
+ struct loader_params *params = ptr;
+ struct cpu_timer timer;
+ struct cpu_timer sum_timer;
+ GP_Context *img, *context = backend->context;
+ GP_ProgressCallback callback = {.callback = image_loader_callback};
+
+ cpu_timer_start(&sum_timer, "sum");
+
+ /* Load Image */
+ if (load_image(params))
+ return NULL;
+
+ img = params->img;
+
+ /*
+ if (img->w < 320 && img->h < 240) {
+ if (!resize_backend_and_blit(img, params))
+ return NULL;
+ }
+ */
+
+ /* Figure out rotation */
GP_Size w, h;
switch (rotate) {
@@ -162,19 +215,6 @@ static void *image_loader(void *ptr)
break;
}
- /* Try to resize window */
- /*
- if (!GP_BackendResize(backend, img->w, img->h)) {
- context = backend->context;
-
- GP_Blit_Raw(img, 0, 0, img->w, img->h, context, 0, 0);
- GP_BackendFlip(backend);
- set_caption(params->img_path, 1);
-
- return NULL;
- }
- */
-
float rat = calc_img_size(img->w, img->h, w, h);
w = img->w;
@@ -204,7 +244,6 @@ static void *image_loader(void *ptr)
cpu_timer_start(&timer, "Resampling");
callback.priv = "Resampling Image";
ret = GP_FilterResize(img, NULL, resampling_method, img->w * rat, img->h * rat, &callback);
- GP_ContextFree(img);
cpu_timer_stop(&timer);
if (ret == NULL)
@@ -285,10 +324,10 @@ static void *image_loader(void *ptr)
static pthread_t loader_thread = (pthread_t)0;
-static void show_image(struct loader_params *params)
+static void show_image(struct loader_params *params, const char *path)
{
int ret;
-
+
/* stop previous loader thread */
if (loader_thread) {
abort_flag = 1;
@@ -296,6 +335,14 @@ static void show_image(struct loader_params *params)
loader_thread = (pthread_t)0;
abort_flag = 0;
}
+
+ /* invalidate cached image if path has changed */
+ if (params->img_path == NULL ||
+ (path != NULL && strcmp(params->img_path, path))) {
+ GP_ContextFree(params->img);
+ params->img = NULL;
+ params->img_path = path;
+ }
ret = pthread_create(&loader_thread, NULL, image_loader, (void*)params);
@@ -331,12 +378,12 @@ int main(int argc, char *argv[])
GP_InputDriverLinux *drv = NULL;
GP_Context *context = NULL;
const char *input_dev = NULL;
- const char *backend_opts = "SDL";
+ const char *backend_opts = "X11";
int sleep_sec = -1;
- struct loader_params params = {NULL, 0, 0, 0};
- int opt;
+ struct loader_params params = {NULL, 0, 0, 0, .img = NULL};
+ int opt, debug_level = 0;
- while ((opt = getopt(argc, argv, "b:cIi:Ps:r:")) != -1) {
+ while ((opt = getopt(argc, argv, "b:cd:Ii:Ps:r:")) != -1) {
switch (opt) {
case 'I':
params.show_info = 1;
@@ -353,6 +400,9 @@ int main(int argc, char *argv[])
case 'c':
resampling_method = GP_INTERP_CUBIC_INT;
break;
+ case 'd':
+ debug_level = atoi(optarg);
+ break;
case 'r':
if (!strcmp(optarg, "90"))
rotate = 90;
@@ -368,7 +418,7 @@ int main(int argc, char *argv[])
}
}
- GP_SetDebugLevel(10);
+ GP_SetDebugLevel(debug_level);
if (input_dev != NULL) {
drv = GP_InputDriverLinuxOpen(input_dev);
@@ -399,10 +449,9 @@ int main(int argc, char *argv[])
int argf = optind;
int argn = argf;
-
+
params.show_progress_once = 1;
- params.img_path = argv[argf];
- show_image(¶ms);
+ show_image(¶ms, argv[argf]);
for (;;) {
int ret;
@@ -429,8 +478,7 @@ int main(int argc, char *argv[])
if (argn >= argc)
argn = argf;
- params.img_path = argv[argn];
- show_image(¶ms);
+ show_image(¶ms, argv[argn]);
break;
default:
while (GP_InputDriverLinuxRead(drv));
@@ -445,8 +493,7 @@ int main(int argc, char *argv[])
if (argn >= argc)
argn = argf;
- params.img_path = argv[argn];
- show_image(¶ms);
+ show_image(¶ms, argv[argn]);
}
}
@@ -472,7 +519,7 @@ int main(int argc, char *argv[])
params.show_info = !params.show_info;
params.show_progress_once = 1;
- show_image(¶ms);
+ show_image(¶ms, NULL);
break;
case GP_KEY_P:
params.show_progress = !params.show_progress;
@@ -483,7 +530,7 @@ int main(int argc, char *argv[])
rotate = 0;
params.show_progress_once = 1;
- show_image(¶ms);
+ show_image(¶ms, NULL);
break;
case GP_KEY_ESC:
case GP_KEY_ENTER:
@@ -499,8 +546,7 @@ int main(int argc, char *argv[])
argn = argf;
params.show_progress_once = 1;
- params.img_path = argv[argn];
- show_image(¶ms);
+ show_image(¶ms, argv[argn]);
break;
case GP_KEY_BACKSPACE:
case GP_KEY_LEFT:
@@ -511,8 +557,7 @@ int main(int argc, char *argv[])
argn = argc - 1;
params.show_progress_once = 1;
- params.img_path = argv[argn];
- show_image(¶ms);
+ show_image(¶ms, argv[argn]);
break;
}
break;
@@ -522,7 +567,7 @@ int main(int argc, char *argv[])
GP_BackendResize(backend, ev.val.sys.w, ev.val.sys.h);
GP_Fill(backend->context, 0);
params.show_progress_once = 1;
- show_image(¶ms);
+ show_image(¶ms, NULL);
break;
case GP_EV_SYS_QUIT:
GP_BackendExit(backend);
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 133 +++++++++++++++++++++++++++++++++++-----------------
1 files changed, 89 insertions(+), 44 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 master updated: 16abe6513b0fa77891c43da149b891edea2a912b
by metan 13 May '12
by metan 13 May '12
13 May '12
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 16abe6513b0fa77891c43da149b891edea2a912b (commit)
via f966f16f2202d808c1286a6e06b4d6c182741986 (commit)
from 5da172bec1439fa9219e02da0f1e68383d56caad (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/16abe6513b0fa77891c43da149b891edea2a…
commit 16abe6513b0fa77891c43da149b891edea2a912b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 13 13:47:45 2012 +0200
doc: Fix typo.
diff --git a/doc/context.txt b/doc/context.txt
index 294d026..00c6c08 100644
--- a/doc/context.txt
+++ b/doc/context.txt
@@ -203,6 +203,6 @@ GP_Context *GP_ContextConvert(const GP_Context *src, GP_Context *dst,
Provides basic context conversion functionality. A newly allocated context is
returned.
-This fuction does no error distribution, it only multiplies or rounds the pixel
+This function does no error distribution, it only multiplies or rounds the pixel
values. If you need something better use Floyd Steinberg dithering instead.
http://repo.or.cz/w/gfxprim.git/commit/f966f16f2202d808c1286a6e06b4d6c18274…
commit f966f16f2202d808c1286a6e06b4d6c182741986
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun May 13 13:47:13 2012 +0200
backends: GP_BackendInit() Add default size for X11.
diff --git a/libs/backends/GP_BackendInit.c b/libs/backends/GP_BackendInit.c
index fb49b92..b00fd10 100644
--- a/libs/backends/GP_BackendInit.c
+++ b/libs/backends/GP_BackendInit.c
@@ -140,9 +140,13 @@ static void backend_x11_help(FILE *help, const char *err)
static GP_Backend *backend_x11_init(char *params, const char *caption,
FILE *help)
{
- unsigned int w, h, n;
+ unsigned int n, w = 640, h = 480;
- if (sscanf(params, "%u%*[xX]%u%n", &w, &h, &n) == 2 && n == strlen(params))
+ if (params == NULL)
+ return GP_BackendX11Init(NULL, 0, 0, w, h, caption);
+
+ if (sscanf(params, "%u%*[xX]%u%n", &w, &h, &n) == 2 &&
+ n == strlen(params))
return GP_BackendX11Init(NULL, 0, 0, w, h, caption);
backend_x11_help(help, "X11: Invalid parameters");
-----------------------------------------------------------------------
Summary of changes:
doc/context.txt | 2 +-
libs/backends/GP_BackendInit.c | 8 ++++++--
2 files changed, 7 insertions(+), 3 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 master updated: 5da172bec1439fa9219e02da0f1e68383d56caad
by metan 12 May '12
by metan 12 May '12
12 May '12
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 5da172bec1439fa9219e02da0f1e68383d56caad (commit)
from 92cadf14e3dddf0bc97848999152f3ae2e8d53a5 (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/5da172bec1439fa9219e02da0f1e68383d56…
commit 5da172bec1439fa9219e02da0f1e68383d56caad
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 12 21:56:31 2012 +0200
backends: fb: restore KB mode on exit.
diff --git a/libs/backends/GP_LinuxFB.c b/libs/backends/GP_LinuxFB.c
index 3a2cf7e..d6de2de 100644
--- a/libs/backends/GP_LinuxFB.c
+++ b/libs/backends/GP_LinuxFB.c
@@ -41,9 +41,15 @@
struct fb_priv {
GP_Context context;
uint32_t bsize;
+
+ int flag;
+
+ /* console fd, nr and saved data */
int con_fd;
int con_nr;
int last_con_nr;
+ int saved_kb_mode;
+
int fb_fd;
char path[];
};
@@ -91,7 +97,7 @@ static int allocate_console(struct fb_priv *fb, int flag)
if (ioctl(fd, VT_GETSTATE, &vts) == 0)
fb->last_con_nr = vts.v_active;
- else
+ else
fb->last_con_nr = -1;
if (ioctl(fd, VT_ACTIVATE, nr) < 0) {
@@ -130,6 +136,16 @@ static int allocate_console(struct fb_priv *fb, int flag)
return -1;
}
+ if (ioctl(fd, KDGKBMODE, &fb->saved_kb_mode)) {
+ GP_DEBUG(1, "Failed to ioctl KDGKBMODE %s: %s",
+ buf, strerror(errno));
+ close(fd);
+ return -1;
+ }
+
+ GP_DEBUG(2, "Previous keyboard mode was '%i'",
+ fb->saved_kb_mode);
+
if (ioctl(fd, KDSKBMODE, K_MEDIUMRAW) < 0) {
GP_DEBUG(1, "Failed to ioctl KDSKBMODE %s: %s",
buf, strerror(errno));
@@ -183,6 +199,14 @@ static void fb_exit(GP_Backend *self)
/* reset keyboard */
ioctl(fb->con_fd, KDSETMODE, KD_TEXT);
+ /* restore keyboard mode */
+ if (fb->flag) {
+ if (ioctl(fb->con_fd, KDSKBMODE, fb->saved_kb_mode) < 0) {
+ GP_DEBUG(1, "Failed to ioctl KDSKBMODE (restore KBMODE)"
+ " /dev/tty%i: %s", fb->con_nr, strerror(errno));
+ }
+ }
+
/* switch back console */
if (fb->last_con_nr != -1)
ioctl(fb->con_fd, VT_ACTIVATE, fb->last_con_nr);
@@ -267,6 +291,7 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag)
fb->fb_fd = fd;
fb->bsize = fscri.smem_len;
strcpy(fb->path, path);
+ fb->flag = flag;
fb->context.w = vscri.xres;
fb->context.h = vscri.yres;
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_LinuxFB.c | 27 ++++++++++++++++++++++++++-
1 files changed, 26 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 master updated: 92cadf14e3dddf0bc97848999152f3ae2e8d53a5
by metan 12 May '12
by metan 12 May '12
12 May '12
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 92cadf14e3dddf0bc97848999152f3ae2e8d53a5 (commit)
from e6ffc65a598d5e457fab45f6f968642e3036be08 (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/92cadf14e3dddf0bc97848999152f3ae2e8d…
commit 92cadf14e3dddf0bc97848999152f3ae2e8d53a5
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 12 21:17:02 2012 +0200
backends: A few fixes for linux fb.
* Back at tty1 (tty0 has root root permissions while tty1 is root tty)
* Added O_NONBLOCK for console open() (so that poll wouldn't block)
* Added more debug messages
diff --git a/libs/backends/GP_LinuxFB.c b/libs/backends/GP_LinuxFB.c
index 654989d..3a2cf7e 100644
--- a/libs/backends/GP_LinuxFB.c
+++ b/libs/backends/GP_LinuxFB.c
@@ -58,25 +58,29 @@ static int allocate_console(struct fb_priv *fb, int flag)
char buf[255];
/* allocate and switch to new console */
- fd = open("/dev/tty0", O_WRONLY);
+ GP_DEBUG(1, "Allocating new console");
+
+ fd = open("/dev/tty1", O_WRONLY);
if (fd < 0) {
- GP_DEBUG(1, "Opening console /dev/tty0 failed: %s",
+ 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/tty0: %s",
+ GP_DEBUG(1, "Failed to ioctl VT_OPENQRY /dev/tty1: %s",
strerror(errno));
close(fd);
return -1;
}
+ GP_DEBUG(1, "Has been granted tty%i", nr);
+
close(fd);
snprintf(buf, sizeof(buf), "/dev/tty%i", nr);
- fd = open(buf, O_RDWR);
+ fd = open(buf, O_RDWR | O_NONBLOCK);
if (fd < 0) {
GP_DEBUG(1, "Opening console %s failed: %s",
@@ -97,6 +101,8 @@ static int allocate_console(struct fb_priv *fb, int flag)
return -1;
}
+ GP_DEBUG(1, "Waiting for tty%i to activate", nr);
+
if (ioctl(fd, VT_WAITACTIVE, nr) < 0) {
GP_DEBUG(1, "Failed to ioctl VT_WAITACTIVE %s: %s",
buf, strerror(errno));
@@ -205,6 +211,8 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag)
goto err1;
/* open and mmap framebuffer */
+ GP_DEBUG(1, "Opening framebuffer '%s'", path);
+
fd = open(path, O_RDWR);
if (fd < 0) {
@@ -224,6 +232,9 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag)
goto err3;
}
+ GP_DEBUG(1, "Have framebufer %ix%i %s %ibpp", vscri.xres, vscri.yres,
+ vscri.grayscale ? "Gray" : "RGB", vscri.bits_per_pixel);
+
/*
* Framebuffer is grayscale.
*/
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_LinuxFB.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: e6ffc65a598d5e457fab45f6f968642e3036be08
by metan 12 May '12
by metan 12 May '12
12 May '12
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 e6ffc65a598d5e457fab45f6f968642e3036be08 (commit)
from 2b7d85a804de2382d10e8f6ea2153b0e47b3e6e0 (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/e6ffc65a598d5e457fab45f6f968642e3036…
commit e6ffc65a598d5e457fab45f6f968642e3036be08
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat May 12 20:31:44 2012 +0200
tests: Fix build.
diff --git a/tests/drivers/framebuffer_test.c b/tests/drivers/framebuffer_test.c
index 29cdb3a..518d3b4 100644
--- a/tests/drivers/framebuffer_test.c
+++ b/tests/drivers/framebuffer_test.c
@@ -63,7 +63,7 @@ int main(void)
GP_SetDebugLevel(10);
- backend = GP_BackendLinuxFBInit("/dev/fb0");
+ backend = GP_BackendLinuxFBInit("/dev/fb0", 0);
if (backend == NULL) {
fprintf(stderr, "Failed to initalize framebuffern");
-----------------------------------------------------------------------
Summary of changes:
tests/drivers/framebuffer_test.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0