Gfxprim
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- 929 discussions
29 Jun '13
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 5381c2dcc328739b9d82e462da5e2135a8d23c2a (commit)
from cf7258563111632ca23dbf29221e16402dc50b24 (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/5381c2dcc328739b9d82e462da5e2135a8d2…
commit 5381c2dcc328739b9d82e462da5e2135a8d23c2a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Jun 29 00:03:11 2013 +0200
loaders: TIFF: A few fixes.
Enable 1bpp
Fix MINISWHITE
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c
index 6d12b2f..ac49d06 100644
--- a/libs/loaders/GP_TIFF.c
+++ b/libs/loaders/GP_TIFF.c
@@ -101,6 +101,38 @@ static const char *compression_name(uint16_t compression)
return "Unknown";
}
+static const char *photometric_name(uint16_t photometric)
+{
+ switch (photometric) {
+ case PHOTOMETRIC_MINISWHITE:
+ return "Min is White";
+ case PHOTOMETRIC_MINISBLACK:
+ return "Min is black";
+ case PHOTOMETRIC_RGB:
+ return "RGB";
+ case PHOTOMETRIC_PALETTE:
+ return "Palette";
+ case PHOTOMETRIC_MASK:
+ return "Mask";
+ case PHOTOMETRIC_SEPARATED:
+ return "Separated";
+ case PHOTOMETRIC_YCBCR:
+ return "YCBCR";
+ case PHOTOMETRIC_CIELAB:
+ return "CIELAB";
+ case PHOTOMETRIC_ICCLAB:
+ return "ICCLAB";
+ case PHOTOMETRIC_ITULAB:
+ return "ITULAB";
+ case PHOTOMETRIC_LOGL:
+ return "LOGL";
+ case PHOTOMETRIC_LOGLUV:
+ return "LOGLUV";
+ default:
+ return "Unknown";
+ }
+}
+
struct tiff_header {
/* compulsory tiff data */
uint32_t w, h;
@@ -174,6 +206,9 @@ static GP_PixelType match_grayscale_pixel_type(TIFF *tiff,
}
switch (header->bits_per_sample) {
+ case 1:
+ GP_DEBUG(1, "Have 1bit Bitmap");
+ return GP_PIXEL_G1;
case 2:
GP_DEBUG(1, "Have 2bit Grayscale");
return GP_PIXEL_G2;
@@ -220,21 +255,19 @@ static GP_PixelType match_pixel_type(TIFF *tiff, struct tiff_header *header)
if (!TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &header->photometric))
return GP_PIXEL_UNKNOWN;
+ GP_DEBUG(1, "Have photometric %s",
+ photometric_name(header->photometric));
+
switch (header->photometric) {
/* 1-bit or 4, 8-bit grayscale */
- case 0:
- case 1:
+ case PHOTOMETRIC_MINISWHITE:
+ case PHOTOMETRIC_MINISBLACK:
return match_grayscale_pixel_type(tiff, header);
- break;
- /* RGB */
- case 2:
+ case PHOTOMETRIC_RGB:
return match_rgb_pixel_type(tiff, header);
- break;
- /* Palette */
- case 3:
- /* The palete is RGB161616 map it to BGR888 for now */
+ /* The palete is RGB161616 map it to BGR888 for now */
+ case PHOTOMETRIC_PALETTE:
return GP_PIXEL_RGB888;
- break;
default:
GP_DEBUG(1, "Unimplemented photometric interpretation %u",
(unsigned) header->photometric);
@@ -335,7 +368,7 @@ int tiff_read_palette(TIFF *tiff, GP_Context *res, struct tiff_header *header,
int tiff_read(TIFF *tiff, GP_Context *res, struct tiff_header *header,
GP_ProgressCallback *callback)
{
- uint32_t y;
+ uint32_t i, y;
uint16_t planar_config, samples, s;
GP_DEBUG(1, "Reading tiff data");
@@ -395,6 +428,11 @@ int tiff_read(TIFF *tiff, GP_Context *res, struct tiff_header *header,
default:
break;
}
+
+ /* We need to negate the values when Min is White */
+ if (header->photometric == PHOTOMETRIC_MINISWHITE)
+ for (i = 0; i < res->bytes_per_row; i++)
+ addr[i] = ~addr[i];
}
if (GP_ProgressCallbackReport(callback, y, res->h, res->w)) {
@@ -433,8 +471,7 @@ GP_Context *GP_ReadTIFF(void *t, GP_ProgressCallback *callback)
}
switch (header.photometric) {
- /* Palette */
- case 3:
+ case PHOTOMETRIC_PALETTE:
err = tiff_read_palette(t, res, &header, callback);
break;
default:
-----------------------------------------------------------------------
Summary of changes:
libs/loaders/GP_TIFF.c | 63 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 50 insertions(+), 13 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
28 Jun '13
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 cf7258563111632ca23dbf29221e16402dc50b24 (commit)
from 7b45cc14bb03dac82ca26db54905482a3f809992 (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/cf7258563111632ca23dbf29221e16402dc5…
commit cf7258563111632ca23dbf29221e16402dc50b24
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 28 20:29:56 2013 +0200
loaders: TIFF: Add saving support.
Add write support for RGB888 and Grayscale TIFFs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/loaders/GP_TIFF.h b/include/loaders/GP_TIFF.h
index cb34585..73acb5f 100644
--- a/include/loaders/GP_TIFF.h
+++ b/include/loaders/GP_TIFF.h
@@ -62,6 +62,12 @@ GP_Context *GP_ReadTIFF(void *t, GP_ProgressCallback *callback);
GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback);
/*
+ * Saves TIFF.
+ */
+int GP_SaveTIFF(const GP_Context *src, const char *dst_path,
+ GP_ProgressCallback *callback);
+
+/*
* Match TIFF signature.
*/
int GP_MatchTIFF(const void *buf);
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c
index cfb1d6d..4f93c3e 100644
--- a/libs/loaders/GP_Loader.c
+++ b/libs/loaders/GP_Loader.c
@@ -108,7 +108,7 @@ static GP_Loader gif_loader = {
static GP_Loader tiff_loader = {
.Load = GP_LoadTIFF,
- .Save = NULL,
+ .Save = GP_SaveTIFF,
.Match = GP_MatchTIFF,
.fmt_name = "Tag Image File Format",
.next = &gif_loader,
diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c
index 89e936e..6d12b2f 100644
--- a/libs/loaders/GP_TIFF.c
+++ b/libs/loaders/GP_TIFF.c
@@ -215,12 +215,6 @@ static GP_PixelType match_rgb_pixel_type(TIFF *tiff, struct tiff_header *header)
return GP_PIXEL_UNKNOWN;
}
-static GP_PixelType match_palette_pixel_type(TIFF *tiff, struct tiff_header *header)
-{
- /* The palete is RGB161616 map it to BGR888 for now */
- return GP_PIXEL_RGB888;
-}
-
static GP_PixelType match_pixel_type(TIFF *tiff, struct tiff_header *header)
{
if (!TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &header->photometric))
@@ -238,7 +232,8 @@ static GP_PixelType match_pixel_type(TIFF *tiff, struct tiff_header *header)
break;
/* Palette */
case 3:
- return match_palette_pixel_type(tiff, header);
+ /* The palete is RGB161616 map it to BGR888 for now */
+ return GP_PIXEL_RGB888;
break;
default:
GP_DEBUG(1, "Unimplemented photometric interpretation %u",
@@ -471,6 +466,163 @@ GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback)
return res;
}
+static int save_grayscale(TIFF *tiff, const GP_Context *src,
+ GP_ProgressCallback *callback)
+{
+ uint32_t x, y;
+ uint8_t buf[src->bytes_per_row];
+ tsize_t ret;
+
+ TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, src->bpp);
+ TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 1);
+ TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
+ TIFFSetField(tiff, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
+
+ for (y = 0; y < src->h; y++) {
+ uint8_t *addr = GP_PIXEL_ADDR(src, 0, y);
+
+ if (src->bpp < 8 && !src->bit_endian) {
+ for (x = 0; x < src->bytes_per_row; x++) {
+ switch (src->pixel_type) {
+ case GP_PIXEL_G1:
+ buf[x] = GP_BIT_SWAP_B1(addr[x]);
+ break;
+ case GP_PIXEL_G2:
+ buf[x] = GP_BIT_SWAP_B2(addr[x]);
+ break;
+ case GP_PIXEL_G4:
+ buf[x] = GP_BIT_SWAP_B4(addr[x]);
+ break;
+ default:
+ GP_BUG("Uh, oh, do we need swap?");
+ }
+ }
+ addr = buf;
+ }
+
+ ret = TIFFWriteEncodedStrip(tiff, y, addr, src->bytes_per_row);
+
+ if (ret == -1) {
+ //TODO TIFF ERROR
+ GP_DEBUG(1, "TIFFWriteEncodedStrip failed");
+ errno = EIO;
+ return 1;
+ }
+
+ if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) {
+ GP_DEBUG(1, "Operation aborted");
+ errno = ECANCELED;
+ return 1;
+ }
+ }
+
+ TIFFClose(tiff);
+
+ GP_ProgressCallbackDone(callback);
+ return 0;
+}
+
+static int save_rgb(TIFF *tiff, const GP_Context *src,
+ GP_ProgressCallback *callback)
+{
+ uint8_t buf[src->w * 3];
+ uint32_t x, y;
+
+ TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8);
+ TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 3);
+ TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
+
+ for (y = 0; y < src->h; y++) {
+ uint8_t *addr = GP_PIXEL_ADDR(src, 0, y);
+
+ switch (src->pixel_type) {
+ case GP_PIXEL_RGB888:
+ for (x = 0; x < src->bytes_per_row; x+=3) {
+ buf[x + 2] = addr[x];
+ buf[x + 1] = addr[x + 1];
+ buf[x] = addr[x + 2];
+ }
+ addr = buf;
+ break;
+ case GP_PIXEL_xRGB8888:
+ for (x = 0; x < src->bytes_per_row; x+=4) {
+ buf[3*(x/4) + 2] = addr[x];
+ buf[3*(x/4) + 1] = addr[x + 1];
+ buf[3*(x/4)] = addr[x + 2];
+ }
+ addr = buf;
+ break;
+ default:
+ break;
+ }
+
+ TIFFWriteEncodedStrip(tiff, y, addr, src->w * 3);
+
+ if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) {
+ GP_DEBUG(1, "Operation aborted");
+ errno = ECANCELED;
+ return 1;
+ }
+ }
+
+ TIFFClose(tiff);
+
+ GP_ProgressCallbackDone(callback);
+ return 0;
+}
+
+int GP_SaveTIFF(const GP_Context *src, const char *dst_path,
+ GP_ProgressCallback *callback)
+{
+ TIFF *tiff;
+
+ if (GP_PixelHasFlags(src->pixel_type, GP_PIXEL_HAS_ALPHA)) {
+ GP_DEBUG(1, "Alpha channel not supported yet");
+ errno = ENOSYS;
+ return 1;
+ }
+
+ switch (src->pixel_type) {
+ case GP_PIXEL_RGB888:
+ case GP_PIXEL_BGR888:
+ case GP_PIXEL_xRGB8888:
+ break;
+ default:
+ GP_DEBUG(1, "Unsupported pixel type %s",
+ GP_PixelTypeName(src->pixel_type));
+ }
+
+ /* Open TIFF image */
+ tiff = TIFFOpen(dst_path, "w");
+
+ if (tiff == NULL) {
+ GP_DEBUG(1, "Failed to open tiff '%s'", dst_path);
+ return 1;
+ }
+
+ /* Set required fields */
+ TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, src->w);
+ TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, src->h);
+ TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, 1);
+ TIFFSetField(tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
+
+ /* Save grayscale */
+ if (GP_PixelHasFlags(src->pixel_type, GP_PIXEL_IS_GRAYSCALE))
+ return save_grayscale(tiff, src, callback);
+
+ switch (src->pixel_type) {
+ case GP_PIXEL_RGB888:
+ case GP_PIXEL_BGR888:
+ case GP_PIXEL_xRGB8888:
+ return save_rgb(tiff, src, callback);
+ default:
+ break;
+ }
+
+ GP_BUG("Should not be reached");
+ return 0;
+}
+
#else
int GP_MatchTIFF(const void GP_UNUSED(*buf))
@@ -500,4 +652,11 @@ GP_Context *GP_LoadTIFF(const char GP_UNUSED(*src_path),
return NULL;
}
+int GP_SaveTIFF(const GP_Context *src, const char *dst_path,
+ GP_ProgressCallback *callback)
+{
+ errno = ENOSYS;
+ return 1;
+}
+
#endif /* HAVE_TIFF */
-----------------------------------------------------------------------
Summary of changes:
include/loaders/GP_TIFF.h | 6 ++
libs/loaders/GP_Loader.c | 2 +-
libs/loaders/GP_TIFF.c | 173 +++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 173 insertions(+), 8 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
28 Jun '13
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 7b45cc14bb03dac82ca26db54905482a3f809992 (commit)
via bd7e97d26552c0e97f36592f7270fe897951026b (commit)
via 5bc943fc5a47fa622d3083545c7141975d958b3d (commit)
via ccba73cabc5a6e324c97f61a557996fbc8f4b60b (commit)
via 541f03f55268a31766b13942a28e54c5fbf35dcb (commit)
via 1b859e4a9f90d27a0e64106c3e6188d6644db3e5 (commit)
via 824ecde7b09c940b797d014492e20a4b179fe030 (commit)
from 7cd59d01dfdab87e6047ba1ad04ad4351a685b44 (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/7b45cc14bb03dac82ca26db54905482a3f80…
commit 7b45cc14bb03dac82ca26db54905482a3f809992
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 28 17:18:27 2013 +0200
loaders: TIFF: Write loader for basic types.
This adds loader support for most common tiff images.
So far we do not support tiled images, images with planar > 1
obscure and too big bits_per_samples.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c
index 3f4a4e9..89e936e 100644
--- a/libs/loaders/GP_TIFF.c
+++ b/libs/loaders/GP_TIFF.c
@@ -33,6 +33,9 @@
#include <string.h>
#include "../../config.h"
+
+#include "core/GP_Pixel.h"
+#include "core/GP_GetPutPixel.h"
#include "core/GP_Debug.h"
#include "GP_TIFF.h"
@@ -98,79 +101,357 @@ static const char *compression_name(uint16_t compression)
return "Unknown";
}
-GP_Context *GP_ReadTIFF(void *t, GP_ProgressCallback *callback)
-{
- uint32_t w, h, y, tile_w, tile_h, rows_per_strip;
- uint16_t compression, bpp;
- TIFF *tiff = t;
- TIFFRGBAImage img;
- GP_Context *res;
- int err;
+struct tiff_header {
+ /* compulsory tiff data */
+ uint32_t w, h;
+ uint16_t compress;
+ uint16_t bits_per_sample;
+
+ /* either strips or tiles should be set */
+ uint32_t rows_per_strip;
+
+ uint32_t tile_w;
+ uint32_t tile_h;
+ /* pixel type related values */
+ uint16_t photometric;
+};
+
+static int read_header(TIFF *tiff, struct tiff_header *header)
+{
/* all these fields are compulsory in tiff image */
- TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w);
- TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h);
- TIFFGetField(tiff, TIFFTAG_COMPRESSION, &compression);
- TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bpp);
+ if (!TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &header->w)) {
+ GP_DEBUG(1, "Failed to read Width");
+ return EIO;
+ }
+
+ if (!TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &header->h)) {
+ GP_DEBUG(1, "Failed to read Height");
+ return EIO;
+ }
+
+ if (!TIFFGetField(tiff, TIFFTAG_COMPRESSION, &header->compress)) {
+ GP_DEBUG(1, "Failed to read Compression Type");
+ return EIO;
+ }
- GP_DEBUG(1, "TIFF image %ux%u compression: %s, bpp: %u",
- w, h, compression_name(compression), bpp);
+ if (!TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE,
+ &header->bits_per_sample)) {
+ GP_DEBUG(1, "Failed to read Bits Per Sample");
+ return EIO;
+ }
+
+ GP_DEBUG(1, "TIFF image %ux%u Compression: %s, Bits Per Sample: %u",
+ header->w, header->h,
+ compression_name(header->compress), header->bits_per_sample);
/* If set tiff is saved in tiles */
- if (TIFFGetField(tiff, TIFFTAG_TILEWIDTH, &tile_w) &&
- TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tile_h)) {
- GP_DEBUG(1, "TIFF is tiled in %ux%u", tile_w, tile_h);
- err = ENOSYS;
- goto err1;
+ if (TIFFGetField(tiff, TIFFTAG_TILEWIDTH, &header->tile_w) &&
+ TIFFGetField(tiff, TIFFTAG_TILELENGTH, &header->tile_h)) {
+ GP_DEBUG(1, "TIFF is tiled in %ux%u",
+ header->tile_w, header->tile_h);
+ header->rows_per_strip = 0;
+ return 0;
}
- if (!TIFFGetField(tiff, TIFFTAG_ROWSPERSTRIP, &rows_per_strip)) {
- GP_DEBUG(1, "TIFF is not stored in strips");
- err = ENOSYS;
- goto err1;
- } else {
- GP_DEBUG(1, "TIFF rows_per_strip = %u", rows_per_strip);
+ if (!TIFFGetField(tiff, TIFFTAG_ROWSPERSTRIP, &header->rows_per_strip)) {
+ GP_DEBUG(1, "TIFF not saved in tiles nor strips");
+ return ENOSYS;
}
- res = GP_ContextAlloc(w, h, GP_PIXEL_xRGB8888);
+ GP_DEBUG(1, "TIFF is saved in strips");
- if (res == NULL) {
- err = errno;
- GP_WARN("Malloc failed");
- goto err1;
+ return 0;
+}
+
+static GP_PixelType match_grayscale_pixel_type(TIFF *tiff,
+ struct tiff_header *header)
+{
+ if (!TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE,
+ &header->bits_per_sample)) {
+ GP_DEBUG(1, "Have 1bit Bitmap");
+ return GP_PIXEL_G1;
+ }
+
+ switch (header->bits_per_sample) {
+ case 2:
+ GP_DEBUG(1, "Have 2bit Grayscale");
+ return GP_PIXEL_G2;
+ case 4:
+ GP_DEBUG(1, "Have 4bit Grayscale");
+ return GP_PIXEL_G4;
+ case 8:
+ GP_DEBUG(1, "Have 8bit Grayscale");
+ return GP_PIXEL_G8;
+ case 16:
+ GP_DEBUG(1, "Have 16bit Grayscale");
+ return GP_PIXEL_G16;
+ default:
+ GP_DEBUG(1, "Unimplemented bits per sample %u",
+ (unsigned) header->bits_per_sample);
+ return GP_PIXEL_UNKNOWN;
+ }
+}
+
+static GP_PixelType match_rgb_pixel_type(TIFF *tiff, struct tiff_header *header)
+{
+ uint16_t samples;
+
+ if (!TIFFGetField(tiff, TIFFTAG_SAMPLESPERPIXEL, &samples)) {
+ GP_DEBUG(1, "Failed to get Samples Per Pixel");
+ return EINVAL;
+ }
+
+ GP_DEBUG(1, "Have %u samples per pixel", (unsigned) samples);
+
+ uint16_t bps = header->bits_per_sample;
+
+ /* Mach RGB pixel type with given pixel sizes */
+ if (samples == 3)
+ return GP_PixelRGBLookup(bps, 0, bps, bps,
+ bps, 2*bps, 0, 0, 3*bps);
+
+ GP_DEBUG(1, "Unsupported");
+ return GP_PIXEL_UNKNOWN;
+}
+
+static GP_PixelType match_palette_pixel_type(TIFF *tiff, struct tiff_header *header)
+{
+ /* The palete is RGB161616 map it to BGR888 for now */
+ return GP_PIXEL_RGB888;
+}
+
+static GP_PixelType match_pixel_type(TIFF *tiff, struct tiff_header *header)
+{
+ if (!TIFFGetField(tiff, TIFFTAG_PHOTOMETRIC, &header->photometric))
+ return GP_PIXEL_UNKNOWN;
+
+ switch (header->photometric) {
+ /* 1-bit or 4, 8-bit grayscale */
+ case 0:
+ case 1:
+ return match_grayscale_pixel_type(tiff, header);
+ break;
+ /* RGB */
+ case 2:
+ return match_rgb_pixel_type(tiff, header);
+ break;
+ /* Palette */
+ case 3:
+ return match_palette_pixel_type(tiff, header);
+ break;
+ default:
+ GP_DEBUG(1, "Unimplemented photometric interpretation %u",
+ (unsigned) header->photometric);
+ return GP_PIXEL_UNKNOWN;
+ }
+}
+
+uint16_t get_idx(uint8_t *row, uint32_t x, uint16_t bps)
+{
+ switch (bps) {
+ case 1:
+ return !!(row[x/8] & (1<<(7 - x%8)));
+ case 2:
+ return (row[x/4] >> (2*(3 - x%4))) & 0x03;
+ case 4:
+ return (row[x/2] >> (4*(!(x%2)))) & 0x0f;
+ case 8:
+ return row[x];
+ case 16:
+ return ((uint16_t*)row)[x];
+ }
+
+ GP_DEBUG(1, "Unsupported bits per sample %u", (unsigned) bps);
+ return 0;
+}
+
+int tiff_read_palette(TIFF *tiff, GP_Context *res, struct tiff_header *header,
+ GP_ProgressCallback *callback)
+{
+ if (TIFFIsTiled(tiff)) {
+ //TODO
+ return ENOSYS;
+ }
+
+ if (header->bits_per_sample > 48) {
+ GP_DEBUG(1, "Bits per sample too big %u",
+ (unsigned)header->bits_per_sample);
+ return EINVAL;
}
- char emsg[1024];
+ unsigned int palette_size = (1<<header->bits_per_sample);
+ uint16_t *palette_r, *palette_g, *palette_b;
+ uint32_t x, y, scanline_size;
+
+ GP_DEBUG(1, "Pallete size %u", palette_size);
- if (TIFFRGBAImageBegin(&img, tiff, 0, emsg) != 1) {
- GP_DEBUG(1, "TIFFRGBAImageBegin failed: %s", emsg);
- err = EINVAL;
- goto err2;
+ if (!TIFFGetField(tiff, TIFFTAG_COLORMAP, &palette_r, &palette_g, &palette_b)) {
+ GP_DEBUG(1, "Failed to read palette");
+ return EIO;
}
- for (y = 0; y < h; y += rows_per_strip) {
- void *row = GP_PIXEL_ADDR(res, 0, y);
+ scanline_size = TIFFScanlineSize(tiff);
+
+ GP_DEBUG(1, "Scanline size %u", (unsigned) scanline_size);
+
+ uint8_t buf[scanline_size];
+
+ /* Read image strips scanline by scanline */
+ for (y = 0; y < header->h; y++) {
+ if (TIFFReadScanline(tiff, buf, y, 0) != 1) {
+ //TODO: Make use of TIFF ERROR
+ GP_DEBUG(1, "Error reading scanline");
+ return EIO;
+ }
+
+ for (x = 0; x < header->w; x++) {
+ uint16_t i = get_idx(buf, x, header->bits_per_sample);
- if (TIFFReadRGBAStrip(tiff, y, row) != 1) {
- err = EINVAL;
- goto err2;
+ if (i >= palette_size) {
+ GP_WARN("Invalid palette index %u",
+ (unsigned) i);
+ i = 0;
+ }
+
+ GP_Pixel p = GP_Pixel_CREATE_RGB888(palette_r[i]>>8,
+ palette_g[i]>>8,
+ palette_b[i]>>8);
+
+ GP_PutPixel_Raw_24BPP(res, x, y, p);
}
- if (GP_ProgressCallbackReport(callback, y, h, w)) {
+ if (GP_ProgressCallbackReport(callback, y, res->h, res->w)) {
GP_DEBUG(1, "Operation aborted");
- err = ECANCELED;
- goto err2;
+ return ECANCELED;
+ }
+ }
+
+ GP_ProgressCallbackDone(callback);
+ return 0;
+}
+
+//Temporary, the bitendians strikes again
+#include "core/GP_BitSwap.h"
+
+/*
+ * Direct read -> data in image are in right format.
+ */
+int tiff_read(TIFF *tiff, GP_Context *res, struct tiff_header *header,
+ GP_ProgressCallback *callback)
+{
+ uint32_t y;
+ uint16_t planar_config, samples, s;
+
+ GP_DEBUG(1, "Reading tiff data");
+
+ if (TIFFIsTiled(tiff)) {
+ //TODO
+ return ENOSYS;
+ }
+
+ //ASSERT ScanlineSize == w!
+
+ /* Figure out number of planes */
+ if (!TIFFGetField(tiff, TIFFTAG_PLANARCONFIG, &planar_config))
+ planar_config = 1;
+
+ switch (planar_config) {
+ case 1:
+ GP_DEBUG(1, "Planar config = 1, all samples are in one plane");
+ samples = 1;
+ break;
+ case 2:
+ if (!TIFFGetField(tiff, TIFFTAG_SAMPLESPERPIXEL, &samples)) {
+ GP_DEBUG(1, "Planar config = 2, samples per pixel undefined");
+ return EINVAL;
}
+ GP_DEBUG(1, "Have %u samples per pixel", (unsigned)samples);
+ break;
+ default:
+ GP_DEBUG(1, "Unimplemented planar config = %u",
+ (unsigned)planar_config);
+ return EINVAL;
}
- TIFFRGBAImageEnd(&img);
+ /* Read image strips scanline by scanline */
+ for (y = 0; y < header->h; y++) {
+ uint8_t *addr = GP_PIXEL_ADDR(res, 0, y);
+
+ //TODO: Does not work with RowsPerStrip > 1 -> needs StripOrientedIO
+ for (s = 0; s < samples; s++) {
+ if (TIFFReadScanline(tiff, addr, y, s) != 1) {
+ //TODO: Make use of TIFF ERROR
+ GP_DEBUG(1, "Error reading scanline");
+ return EIO;
+ }
+
+ //Temporary, till bitendians are fixed
+ switch (res->pixel_type) {
+ case GP_PIXEL_G1:
+ GP_BitSwapRow_B1(addr, res->bytes_per_row);
+ break;
+ case GP_PIXEL_G2:
+ GP_BitSwapRow_B2(addr, res->bytes_per_row);
+ break;
+ case GP_PIXEL_G4:
+ GP_BitSwapRow_B4(addr, res->bytes_per_row);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (GP_ProgressCallbackReport(callback, y, res->h, res->w)) {
+ GP_DEBUG(1, "Operation aborted");
+ return ECANCELED;
+ }
+ }
GP_ProgressCallbackDone(callback);
- return res;
+ return 0;
+}
-err2:
- GP_ContextFree(res);
+GP_Context *GP_ReadTIFF(void *t, GP_ProgressCallback *callback)
+{
+ struct tiff_header header;
+ GP_Context *res = NULL;
+ GP_PixelType pixel_type;
+ int err;
+
+ if ((err = read_header(t, &header)))
+ goto err1;
+
+ pixel_type = match_pixel_type(t, &header);
+
+ if (pixel_type == GP_PIXEL_UNKNOWN) {
+ err = ENOSYS;
+ goto err1;
+ }
+
+ res = GP_ContextAlloc(header.w, header.h, pixel_type);
+
+ if (res == NULL) {
+ err = errno;
+ GP_DEBUG(1, "Malloc failed");
+ goto err1;
+ }
+
+ switch (header.photometric) {
+ /* Palette */
+ case 3:
+ err = tiff_read_palette(t, res, &header, callback);
+ break;
+ default:
+ err = tiff_read(t, res, &header, callback);
+ }
+
+ if (err)
+ goto err1;
+
+ return res;
err1:
+ GP_ContextFree(res);
errno = err;
return NULL;
}
http://repo.or.cz/w/gfxprim.git/commit/bd7e97d26552c0e97f36592f7270fe897951…
commit bd7e97d26552c0e97f36592f7270fe897951026b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 28 15:43:30 2013 +0200
backends: X11: Hotfix for Wait().
Hold the display lock only when processing events.
This fixes lock when main thread sleeps in backend->Wait() and some
other thread calls backend function that works with X11 connection.
The correct fix will be single backend Wait() with poll for all
backends that have filedescriptor to wait on.
Also add XFlush() after update_rect() (it was previously flushed
automatically by the XNextEvent() call).
Lastly but not least remove the WARNING from docs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/backends.txt b/doc/backends.txt
index 10127e6..7130b29 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -368,14 +368,6 @@ Blocks until backend event arrives.
Events received by backend are not necessarily translated into the input
events.
-[WARNING]
-Using GP_BackendWait() in multi-threaded program will most likely cause
-deadlocks. As the backend data structures and connection is guarded by a lock
-any other backend function (called from different thread while
-GP_BackendWait() is blocking) will lock until GP_BackendWait() returns (i.e.
-event was received).
-
-
GP_BackendWaitEvent
^^^^^^^^^^^^^^^^^^^
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index 7392202..8505edc 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -79,6 +79,8 @@ static void x11_update_rect(GP_Backend *self, GP_Coord x0, GP_Coord y0,
putimage(win, x0, y0, x1, y1);
+ XFlush(win->dpy);
+
XUnlockDisplay(win->dpy);
}
@@ -185,17 +187,13 @@ static void x11_poll(GP_Backend *self)
XUnlockDisplay(win->dpy);
}
+#include <poll.h>
+
static void x11_wait(GP_Backend *self)
{
- struct x11_win *win = GP_BACKEND_PRIV(self);
- XEvent ev;
-
- XLockDisplay(win->dpy);
-
- XNextEvent(win->dpy, &ev);
- x11_ev(&ev);
-
- XUnlockDisplay(win->dpy);
+ struct pollfd fd = {.fd = self->fd, .events = POLLIN, .revents = 0};
+ poll(&fd, 1, -1);
+ x11_poll(self);
}
static int resize_buffer(struct GP_Backend *self, uint32_t w, uint32_t h)
http://repo.or.cz/w/gfxprim.git/commit/5bc943fc5a47fa622d3083545c7141975d95…
commit 5bc943fc5a47fa622d3083545c7141975d958b3d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 28 14:31:35 2013 +0200
spiv: Initialize sleep_ms correctly.
So that no timers are scheduled if -s param is not set.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 9b34c35..287cc12 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -669,7 +669,7 @@ int main(int argc, char *argv[])
{
GP_Context *context = NULL;
const char *backend_opts = "X11";
- int sleep_ms = -1;
+ int sleep_ms = 0;
int opt;
int shift_flag;
GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
http://repo.or.cz/w/gfxprim.git/commit/ccba73cabc5a6e324c97f61a557996fbc8f4…
commit ccba73cabc5a6e324c97f61a557996fbc8f4b60b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 28 14:29:15 2013 +0200
libs: backends: BackendWait() fix.
Get the TimeStamp only when there are timers in timer queue.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/backends/GP_Backend.c b/libs/backends/GP_Backend.c
index bcc7ac3..9bf2f7e 100644
--- a/libs/backends/GP_Backend.c
+++ b/libs/backends/GP_Backend.c
@@ -177,9 +177,9 @@ static void wait_timers_poll(GP_Backend *self)
void GP_BackendWait(GP_Backend *self)
{
- uint64_t now = GP_GetTimeStamp();
-
if (self->timers) {
+ uint64_t now = GP_GetTimeStamp();
+
/* Get rid of possibly expired timers */
if (GP_TimerQueueProcess(&self->timers, now))
return;
http://repo.or.cz/w/gfxprim.git/commit/541f03f55268a31766b13942a28e54c5fbf3…
commit 541f03f55268a31766b13942a28e54c5fbf35dcb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 28 13:20:58 2013 +0200
backends: Add GP_BackendTimersInQueue() + docs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/backends.txt b/doc/backends.txt
index 874ba52..10127e6 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -432,6 +432,20 @@ backend 'Poll' or 'Wait' functions.
If timer callback is set to 'NULL' a timer event is pushed to the backend
input queue once timer has expired otherwise timer callback is called.
+GP_BackendTimersInQueue
+^^^^^^^^^^^^^^^^^^^^^^^
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <backends/GP_Backend.h>
+/* or */
+#include <GP.h>
+
+void GP_BackendTimersInQueue(GP_Backend *self);
+-------------------------------------------------------------------------------
+
+Returns number of timers scheduled in backend timer queue.
+
GP_BackendEventsQueued
^^^^^^^^^^^^^^^^^^^^^^
diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h
index f94252c..ec4af3b 100644
--- a/include/backends/GP_Backend.h
+++ b/include/backends/GP_Backend.h
@@ -212,6 +212,14 @@ int GP_BackendWaitEvent(GP_Backend *self, GP_Event *ev);
void GP_BackendAddTimer(GP_Backend *self, GP_Timer *timer);
/*
+ * Returns number of timers scheduled in backend.
+ */
+static inline unsigned int GP_BackendTimersInQueue(GP_Backend *self)
+{
+ return GP_TimerQueueSize(self->timers);
+}
+
+/*
* Sets backend caption, if supported.
*
* When setting caption is not possible/implemented non zero is returned.
http://repo.or.cz/w/gfxprim.git/commit/1b859e4a9f90d27a0e64106c3e6188d6644d…
commit 1b859e4a9f90d27a0e64106c3e6188d6644db3e5
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 28 12:59:37 2013 +0200
input: timers: Implement remove + docs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Input_symbols.txt b/build/syms/Input_symbols.txt
index 700dedc..e6742b7 100644
--- a/build/syms/Input_symbols.txt
+++ b/build/syms/Input_symbols.txt
@@ -28,5 +28,6 @@ GP_EventQueuePushResize
GP_TimerQueueDump
GP_TimerQueueProcess
GP_TimerQueueInsert
+GP_TimerQueueRemove
GP_GetTimeStamp
diff --git a/demos/c_simple/timers.c b/demos/c_simple/timers.c
index 4e863c9..b914fe4 100644
--- a/demos/c_simple/timers.c
+++ b/demos/c_simple/timers.c
@@ -67,6 +67,10 @@ int main(void)
GP_TimerQueueDump(queue);
+ GP_TimerQueueRemove(&queue, &timers[MAX-1]);
+
+ GP_TimerQueueDump(queue);
+
for (now = 0; now < 100; now += 3) {
printf("NOW %un", (unsigned int) now);
printf("-------------------------------------n");
diff --git a/doc/input.txt b/doc/input.txt
index e92c5a5..aa69595 100644
--- a/doc/input.txt
+++ b/doc/input.txt
@@ -275,7 +275,7 @@ typedef struct GP_Timer {
Timers are implemented as a simple structure with a callback, expiration, id
string and internal heap pointers. The priority queue is described simply by
-the pointer to the top timer (soonest time to expire).
+the pointer to the top timer (soonest to expire).
The 'priv' pointer is used to pass a user pointer to the callback function.
@@ -315,6 +315,21 @@ at `now + timer->expire`.
/* or */
#include <input/GP_Timer.h>
+void GP_TimerQueueRemove(GP_Timer **queue, GP_Timer *timer);
+-------------------------------------------------------------------------------
+
+Removes timer from the queue.
+
+If timer is not found in the queue nothing is done but warning is printed.
+
+Runs in 'O(n)' time (the insert and process runs in 'O(nlog(n))').
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <input/GP_Timer.h>
+
int GP_TimerQueueProcess(GP_Timer **queue, uint64_t now);
-------------------------------------------------------------------------------
@@ -325,6 +340,17 @@ into the queue with new expiration time.
Returns number of timers processed.
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <input/GP_Timer.h>
+
+unsigned int GP_TimerQueueSize(GP_Timer *queue);
+-------------------------------------------------------------------------------
+
+Returns number of timers in the queue.
+
[[TimeStamp]]
TimerStamp
~~~~~~~~~~
diff --git a/include/input/GP_Timer.h b/include/input/GP_Timer.h
index 1debab2..9d6c8ed 100644
--- a/include/input/GP_Timer.h
+++ b/include/input/GP_Timer.h
@@ -78,10 +78,11 @@ void GP_TimerQueueDump(GP_Timer *queue);
void GP_TimerQueueInsert(GP_Timer **queue, uint64_t now, GP_Timer *timer);
/*
- * Removes timer from timer queue. Returns NULL if id was not found.
+ * Removes timer from timer queue.
+ *
+ * This operation (in contrast with insert and process) runs in O(n) time.
*/
-GP_Timer GP_TimerQueueRemove(GP_Timer *queue, GP_Timer *timer);
-GP_Timer GP_TimerQueueRemoveById(GP_Timer *queue, const char *id);
+void GP_TimerQueueRemove(GP_Timer **queue, GP_Timer *timer);
/*
* Processes queue, all timers with expires <= now are processed.
@@ -90,4 +91,12 @@ GP_Timer GP_TimerQueueRemoveById(GP_Timer *queue, const char *id);
*/
int GP_TimerQueueProcess(GP_Timer **queue, uint64_t now);
+/*
+ * Returns size of the queue, i.e. number of timers.
+ */
+static inline unsigned int GP_TimerQueueSize(GP_Timer *queue)
+{
+ return queue ? queue->sons + 1 : 0;
+}
+
#endif /* INPUT_GP_TIMER_H */
diff --git a/libs/input/GP_Timer.c b/libs/input/GP_Timer.c
index 3f4adfe..4ee1c10 100644
--- a/libs/input/GP_Timer.c
+++ b/libs/input/GP_Timer.c
@@ -198,6 +198,73 @@ void GP_TimerQueueInsert(GP_Timer **heap, uint64_t now, GP_Timer *timer)
*heap = insert(*heap, timer);
}
+static GP_Timer *rem(GP_Timer *heap, GP_Timer *timer, GP_Timer *last, int *flag)
+{
+ if (heap == NULL)
+ return NULL;
+
+ /* Found -> remove */
+ if (heap == timer) {
+ GP_DEBUG(3, "Timer found -> removing");
+
+ *flag = 1;
+
+ last->left = heap->left;
+ last->right = heap->right;
+ last->sons = heap->sons;
+
+ return bubble_down(last);
+ }
+
+ heap->left = rem(heap->left, timer, last, flag);
+ heap->right = rem(heap->right, timer, last, flag);
+
+ return heap;
+}
+
+static GP_Timer *pre_rem(GP_Timer *heap, GP_Timer *timer)
+{
+ GP_Timer *last;
+ int flag = 0;
+
+ if (!heap) {
+ GP_WARN("Attempt to remove timer %s from empty queue",
+ timer->id);
+ return NULL;
+ }
+
+ /*
+ * Remove last timer from the heap prior the removal,
+ * we will use it in place of the removed timer later.
+ */
+ heap = rem_last(heap, &last);
+
+ if (!heap) {
+ if (timer == last)
+ return NULL;
+
+ GP_WARN("Timer %s not found (queue has one timer)", timer->id);
+ return last;
+ }
+
+ heap = rem(heap, timer, last, &flag);
+
+ if (!flag) {
+ GP_WARN("Timer %s not found", timer->id);
+ /* reinsert the last element */
+ return insert(heap, last);
+ }
+
+ return heap;
+}
+
+void GP_TimerQueueRemove(GP_Timer **queue, GP_Timer *timer)
+{
+ GP_DEBUG(3, "Removing timer %s from queue", timer->id);
+
+ *queue = pre_rem(*queue, timer);
+}
+
static GP_Timer *process_top(GP_Timer *heap, uint64_t now)
{
GP_Timer *timer = heap;
http://repo.or.cz/w/gfxprim.git/commit/824ecde7b09c940b797d014492e20a4b179f…
commit 824ecde7b09c940b797d014492e20a4b179fe030
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 28 11:18:36 2013 +0200
doc: Remove trailing whitespaces.
This should be the last one.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/api.txt b/doc/api.txt
index f005a82..709bb92 100644
--- a/doc/api.txt
+++ b/doc/api.txt
@@ -12,7 +12,7 @@ GFXprim API
+
. link:core.html[Library Core overview]
+
- Describes functions and macros in library core.
+ Describes functions and macros in library core.
+
. link:pixels.html[Pixel Types]
+
diff --git a/doc/backends.txt b/doc/backends.txt
index 151e654..874ba52 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -4,7 +4,7 @@ Drawing Backends
Drawing backends provide means to draw into computer screen or into a window
inside of running operating system. Instead of having one unified
initialization interface each backend has it's specific function and semantics
-but once backend is initialized the backend structure provides unified API for
+but once backend is initialized the backend structure provides unified API for
controlling the drawing.
So far there are backends for Linux mmaped 'frame-buffer', 'libSDL' and
@@ -92,7 +92,7 @@ X Server
enum GP_BackendX11Flags {
/* When set, w and h is ignored and root window is used */
GP_X11_USE_ROOT_WIN = 0x01,
-
+
/* Create new borderless window above the root window */
GP_X11_CREATE_ROOT_WIN = 0x02,
@@ -151,7 +151,7 @@ GP_BackendX11RequestFullscreen
/*
* Changes full screen mode.
- *
+ *
* 0 = off
* 1 = on
* 2 = toggle
@@ -206,15 +206,15 @@ typdef struct GP_Backend {
*/
const char *name;
- /*
+ /*
* Pointer to context APP should draw to.
*/
GP_Context *context;
...
- /*
- * Connection fd. Set to -1 if not available
+ /*
+ * Connection fd. Set to -1 if not available
*/
int fd;
};
@@ -293,7 +293,7 @@ GP_BackendPoll
void GP_BackendPoll(GP_Backend *backend);
-------------------------------------------------------------------------------
-Polls for backend events.
+Polls for backend events.
The poll only reads events from event source (i.e. X11 socket, Linux evdev
file descriptor), process them and may place new event into the backend event
@@ -345,7 +345,7 @@ otherwise.
while (GP_BackendPollEvent(backend, &ev) {
/* process events */
-
+
}
-------------------------------------------------------------------------------
diff --git a/doc/backends_python.txt b/doc/backends_python.txt
index 48f5e01..65ff893 100644
--- a/doc/backends_python.txt
+++ b/doc/backends_python.txt
@@ -23,7 +23,7 @@ import gfxprim.backends as backends
# Create 100x100 X11 window
bk = backends.BackendX11Init(None, x, y, w, h, "Window title", 0)
-
+
# Assert that inicialization was successful
assert(bk)
@@ -58,7 +58,7 @@ import gfxprim.backends as backends
# Initialize backend by init string
bk = backends.BackendInit(backend_string, "Window title", stderr)
-
+
# Assert that inicialization was successful
assert(bk)
@@ -83,7 +83,7 @@ import gfxprim.backends as backends
# Initialize backend
bk = backends.BackendInit("X11:100x100", "Window title", stderr)
-
+
# Assert that inicialization was successful
assert(bk)
@@ -106,11 +106,11 @@ movements.
import gfxprim.core as core
import gfxprim.input as input
import gfxprim.backends as backends
-
-
+
+
# Initialize backend
bk = backends.BackendInit("X11:100x100", "Window title", stderr)
-
+
# Assert that inicialization was successful
assert(bk)
diff --git a/doc/context.txt b/doc/context.txt
index df6ff47..ea7d5ba 100644
--- a/doc/context.txt
+++ b/doc/context.txt
@@ -15,7 +15,7 @@ typedef struct GP_Context {
uint32_t bytes_per_row;
uint32_t w; /* width in pixels */
uint32_t h; /* height in pixels */
- /*
+ /*
* Row bit offset. The offset is ignored for byte aligned pixels.
* Basically it's used for non aligned pixels with combination
* with subcontextes.
@@ -81,7 +81,7 @@ GP_TRANSFORM_POINT(context, x, y)
GP_TRANSFORM_RECT(context, x, y, w, h)
/* Inverse transformation, bitmap coordinates to user coordinates */
-GP_RETRANSFORM_POINT(context, x, y)
+GP_RETRANSFORM_POINT(context, x, y)
-------------------------------------------------------------------------------
[source,c]
@@ -91,7 +91,7 @@ GP_RETRANSFORM_POINT(context, x, y)
#include <GP.h>
/*
- * Rotate context flags clock wise.
+ * Rotate context flags clock wise.
*/
void GP_ContextRotateCW(GP_Context *context);
@@ -170,11 +170,11 @@ appropriate size; the initial contents of the bitmap are undefined.
#include <GP.h>
enum GP_ContextCopyFlags {
- /*
+ /*
* Copy bitmap pixels too. If not set pixels are uninitialized.
*/
GP_COPY_WITH_PIXELS = 0x01,
- /*
+ /*
* Copy image rotation flags. If not set flags are set to (0, 0, 0).
*/
GP_COPY_WITH_ROTATION = 0x02,
@@ -266,7 +266,7 @@ Conversions
#include <GP.h>
GP_Context *GP_ContextConvertAlloc(const GP_Context *src,
- GP_PixelType dst_pixel_type);
+ GP_PixelType dst_pixel_type);
GP_Context *GP_ContextConvert(const GP_Context *src, GP_Context *dst);
diff --git a/doc/core.txt b/doc/core.txt
index ec172a2..c7148fa 100644
--- a/doc/core.txt
+++ b/doc/core.txt
@@ -34,7 +34,7 @@ GP_CONTAINER_OF(ptr, structure, member);
These common macros implements basic functions such as minimum, maximum,
absolute value, swap and sign.
-All macros use 'typeof()' in order to evaluate their arguments exactly once.
+All macros use 'typeof()' in order to evaluate their arguments exactly once.
The 'GP_ARRAY_SIZE()' macro computes size of statically defined array (i.e.
returns +sizeof(array) / sizeof(elem)+).
diff --git a/doc/core_python.txt b/doc/core_python.txt
index 3e7256f..cd60469 100644
--- a/doc/core_python.txt
+++ b/doc/core_python.txt
@@ -27,7 +27,7 @@ import gfxprim.core as core
Creates a context of a particular size and pixel type.
First two parameters are 'width' and 'height' third is pixel type which is an
-enumeration
+enumeration
May raise 'OSError' with 'ENOMEM' errno if allocation has failed.
@@ -78,7 +78,7 @@ import gfxprim.core as core
# sx and sy in the source context
# tx and ty in in the target
context.Blit(sx, sy, target, tx, ty, w, h)
-
+
# Alternatively the size can be described by
# coordinates in the source or target
context.Blit(sx, sy, target, tx, ty, sx2=, sy2=)
@@ -100,7 +100,7 @@ Colors and Pixels
~~~~~~~~~~~~~~~~~
Pixel in gfxprim is a number large enough to store a pixel value. Pixel is
-passed as a parameter to all drawing functions.
+passed as a parameter to all drawing functions.
Color is a more abstract representation for example RGB triplet.
@@ -133,7 +133,7 @@ import gfxprim.core as core
-------------------------------------------------------------------------------
-The PixelTypes array stores all supported pixel types
+The PixelTypes array stores all supported pixel types
Debug Functions
~~~~~~~~~~~~~~~
diff --git a/doc/debug.txt b/doc/debug.txt
index cdc3d4b..aedef2a 100644
--- a/doc/debug.txt
+++ b/doc/debug.txt
@@ -3,7 +3,7 @@ Debug Messages
The GFXprim library includes a debug message infrastructure in order to ease
the debugging.
-
+
Many places of the library uses debug messages to report warnings, bugs, or
generally important events (i.e. context has been allocated, filter function
has been called).
diff --git a/doc/filter_additive_gaussian_noise.txt b/doc/filter_additive_gaussian_noise.txt
index c64de38..8acba98 100644
--- a/doc/filter_additive_gaussian_noise.txt
+++ b/doc/filter_additive_gaussian_noise.txt
@@ -40,27 +40,27 @@ TIP: See the link:example_gaussian_noise.html[source code] used to generate
.Original Image; Gaussian Additive Noise s=0.01, s=0.02, s=0.05, s=0.7, s=0.1, s=0.05 m=0.1, s=0.05 m=-0.1
image:images/dither/lenna_small.png[
- "Original Image",
+ "Original Image",
link="images/dither/lenna.png"]
image:images/gaussian_noise/lenna_small_noise_s_0_01_m_0.png[
- "Additive Noise sigma = 0.01 mu = 0.0",
+ "Additive Noise sigma = 0.01 mu = 0.0",
link="images/gaussian_noise/lenna_noise_s_0_01_m_0.png"]
image:images/gaussian_noise/lenna_small_noise_s_0_02_m_0.png[
- "Additive Noise sigma = 0.02 mu = 0.0",
+ "Additive Noise sigma = 0.02 mu = 0.0",
link="images/gaussian_noise/lenna_noise_s_0_02_m_0.png"]
image:images/gaussian_noise/lenna_small_noise_s_0_05_m_0.png[
- "Additive Noise sigma = 0.05 mu = 0.0",
+ "Additive Noise sigma = 0.05 mu = 0.0",
link="images/gaussian_noise/lenna_noise_s_0_05_m_0.png"]
image:images/gaussian_noise/lenna_small_noise_s_0_07_m_0.png[
- "Additive Noise sigma = 0.07 mu = 0.0",
+ "Additive Noise sigma = 0.07 mu = 0.0",
link="images/gaussian_noise/lenna_noise_s_0_07_m_0.png"]
image:images/gaussian_noise/lenna_small_noise_s_0_1_m_0.png[
- "Additive Noise sigma = 0.1 mu = 0.0",
+ "Additive Noise sigma = 0.1 mu = 0.0",
link="images/gaussian_noise/lenna_noise_s_0_1_m_0.png"]
image:images/gaussian_noise/lenna_small_noise_s_0_05_m_0_1.png[
- "Additive Noise sigma = 0.1 mu = 0.1",
+ "Additive Noise sigma = 0.1 mu = 0.1",
link="images/gaussian_noise/lenna_noise_s_0_05_m_0_1.png"]
image:images/gaussian_noise/lenna_small_noise_s_0_05_m_-0_1.png[
- "Additive Noise sigma = 0.1 mu = -0.1",
+ "Additive Noise sigma = 0.1 mu = -0.1",
link="images/gaussian_noise/lenna_noise_s_0_05_m_-0_1.png"]
diff --git a/doc/filters.txt b/doc/filters.txt
index c4f2049..106be48 100644
--- a/doc/filters.txt
+++ b/doc/filters.txt
@@ -236,7 +236,7 @@ Brightness filter, increments all pixel channels by a fixed value.
-------------------------------------------------------------------------------
#include <GP_Filters.h>
-GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst,
+GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst,
float mul, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
@@ -537,7 +537,7 @@ filter operates on.
The dst coordinates defines offset into the dst context.
The kernel is two-dimensional array of a size kw * kh indexed as
-kernel[x + y*kw].
+kernel[x + y*kw].
The kern_div is a coefficient that is used to divide the resulting values often
used to normalize the result.
@@ -613,7 +613,7 @@ The dst coordinates are offset into the dst.
The kernel is one-dimensional array of floats of size kw or kh.
-The kern_div is a coefficient that is used to divide the resulting values.
+The kern_div is a coefficient that is used to divide the resulting values.
The last function does both vertical and horizontal convolution and takes care
of correct progress callback.
@@ -660,7 +660,7 @@ NOTE: The number of kernel rows and columns is expected to be odd number.
NOTE: The linear convolutions are internally implemented using integer
arithmetics, which works fine, but you need to take a care not to
overflow 32bit signed integer. If the pixel channel size is 8bit
- long and 10bits are used for the fixed point part of the number
+ long and 10bits are used for the fixed point part of the number
the rest must fit into about 10 bits to be safe.
[source,c]
@@ -775,7 +775,7 @@ The convolution kernel is defined as:
begin{bmatrix}
0 & 0 & 0 \
1 & -2 & 1 \
-0 & 0 & 0
+0 & 0 & 0
end{bmatrix}
=
begin{bmatrix}
@@ -817,16 +817,16 @@ O(x,y) = I(x,y) - w * I''(x,y)
.Original Image; Edge Sharpening w=0.1, w=0.3, w=0.5
image:images/dither/lenna_small.png[
- "Original Image",
+ "Original Image",
link="images/dither/lenna.png"]
image:images/edge_sharpening/lenna_small_w_0_1.png[
- "Edge Sharpening w=0.1",
+ "Edge Sharpening w=0.1",
link="images/edge_sharpening/lenna_w_0_1.png"]
image:images/edge_sharpening/lenna_small_w_0_3.png[
- "Edge Sharpening w=0.5",
+ "Edge Sharpening w=0.5",
link="images/edge_sharpening/lenna_w_0_3.png"]
image:images/edge_sharpening/lenna_small_w_0_5.png[
- "Edge Sharpening w=0.5",
+ "Edge Sharpening w=0.5",
link="images/edge_sharpening/lenna_w_0_5.png"]
Gaussian Blur
@@ -962,7 +962,7 @@ int GP_FilterFloydSteinberg_RGB888(const GP_Context *src,
-------------------------------------------------------------------------------
Renders Floyd Steinberg dithering directly into passed context. The
-destination must be at least as large as source.
+destination must be at least as large as source.
If operation was aborted by a callback, non-zero is returned.
@@ -984,7 +984,7 @@ Hilbert-Peano
^^^^^^^^^^^^^
Hilbert-Peano space filling curve based dithering.
-
+
The error value is distributed around the Hilbert curve.
The result is a little more noisy, but doesn't create repeating patterns like
@@ -1001,7 +1001,7 @@ int GP_FilterHilbertPeano_RGB888(const GP_Context *src,
-------------------------------------------------------------------------------
Renders Hilbert Peano dithering directly into passed context. The
-destination must be at least as large as source.
+destination must be at least as large as source.
If operation was aborted by a callback, non-zero is returned.
@@ -1026,7 +1026,7 @@ All following images were generated using 'grinder'.
.Original Image; Floyd-Steinberg, Hilbert-Peano: 1-bit, 2-bit, 4-bit, 8-bit Grayscale; 1-bit, 2-bit, 3-bit (per channel) RGB
image:images/dither/lenna_small.png[
- "Original Image",
+ "Original Image",
link="images/dither/lenna.png"]
image:images/dither/lenna_G1_FS_small.png[
"1-bit Grayscale Floyd-Steinberg",
@@ -1113,7 +1113,7 @@ rectangle of 2 * xmed + 1 x 2 * ymed + 1 pixels.
.Original Image; Median 3x3, 5x5, 7x7, 9x9
image:images/dither/lenna_small.png[
- "Original Image",
+ "Original Image",
link="images/dither/lenna.png"]
image:images/median/lenna_small_med_3_3.png[
"Median 3x3",
diff --git a/doc/gamma.txt b/doc/gamma.txt
index f15f072..317900a 100644
--- a/doc/gamma.txt
+++ b/doc/gamma.txt
@@ -48,8 +48,8 @@ order not to loose precision.
The pointers to gamma tables are storied in 'GP_Gamma' structure and are
organized in the same order as channels. First N tables for each channel and
-gamma value gamma, then N tables for inverse 1/gamma function.
-
+gamma value gamma, then N tables for inverse 1/gamma function.
+
So when we have RGB888 pixel and gamma 2.2 there are two tables in the memory,
one for gamma 2.2 input 8bit output 10bit and it's inverse input 10bit output
8bit. The 'GP_Gamma' contains six pointers. First three points to the gamma
@@ -81,7 +81,7 @@ gamma->tables[chan_count + chan_number].u8[chan_val]
gamma->tables[chan_count + chan_number].u16[chan_val]
-/*
+/*
* When doing more than one conversion it's better to save pointers to
* individual table (example for RGB888):
*/
diff --git a/doc/gen.txt b/doc/gen.txt
index 3f3c0d8..23edf2b 100644
--- a/doc/gen.txt
+++ b/doc/gen.txt
@@ -28,7 +28,7 @@ class PixelSize(object):
def needs_bit_endian(self):
...
-
+
...
-------------------------------------------------------------------------------
@@ -74,7 +74,7 @@ BE
["graphviz", "bit-endian-be-1bit.png"]
------------------------------------------------------------------------------
digraph bit_endian {
- graph [ dpi = 70 ];
+ graph [ dpi = 70 ];
node [shape = record];
rankdir = LR;
@@ -94,7 +94,7 @@ digraph bit_endian {
["graphviz", "bit-endian-be-2bits.png"]
------------------------------------------------------------------------------
digraph bit_endian {
- graph [ dpi = 70 ];
+ graph [ dpi = 70 ];
node [shape = record];
rankdir = LR;
@@ -117,7 +117,7 @@ LE
["graphviz", "bit-endian-le-1bit.png"]
------------------------------------------------------------------------------
digraph bit_endian {
- graph [ dpi = 70 ];
+ graph [ dpi = 70 ];
node [shape = record];
rankdir = LR;
@@ -137,7 +137,7 @@ digraph bit_endian {
["graphviz", "bit-endian-le-2bits.png"]
------------------------------------------------------------------------------
digraph bit_endian {
- graph [ dpi = 70 ];
+ graph [ dpi = 70 ];
node [shape = record];
rankdir = LR;
diff --git a/doc/grabbers.txt b/doc/grabbers.txt
index ce71654..65dd71d 100644
--- a/doc/grabbers.txt
+++ b/doc/grabbers.txt
@@ -27,8 +27,8 @@ typdef struct GP_Grabber {
* Currently loaded frame.
*/
GP_Context *frame;
-
- /*
+
+ /*
* Connection fd usable for select() or poll().
*
* Set to -1 if not available.
diff --git a/doc/input.txt b/doc/input.txt
index 5db6158..e92c5a5 100644
--- a/doc/input.txt
+++ b/doc/input.txt
@@ -35,18 +35,18 @@ typedef struct GP_Event {
/* input device id */
uint32_t dev_id;
-
+
/* event timestamp */
struct timeval time;
- /*
+ /*
* Cursor position, position on screen accumulated
* from all pointer devices
*/
uint32_t cursor_x;
uint32_t cursor_y;
- /*
+ /*
* Bitmap of pressed keys including mouse buttons
* accumulated for all input devices.
*/
@@ -145,7 +145,7 @@ struct GP_EventSys {
The event 'value' is a union that could hold different information. The right
format of the data is known from the 'type' and 'code'. Some types of the
events has no value at all.
-
+
* The relative coordinates are used for 'GP_EV_REL_POS' and absolute coordinates
for 'GP_EV_ABS_POS'.
@@ -157,7 +157,7 @@ events has no value at all.
This image shows GFXprim key names without the 'GP_KEY_' prefix (Click for a
higher resolution). So for example 'LEFTSHIFT' on the image is
'GP_KEY_LEFT_SHIFT'.
-+
++
[[Keyboard Layout]]
.GFXprim key names without the 'GP_KEY_' prefix.
image::keyboard.svg["Keyboard Layout",width=800,link="keyboard.svg"]
@@ -259,8 +259,8 @@ typedef struct GP_Timer {
/* Timer id, showed in debug messages */
char id[10];
- /*
- * Timer Callback
+ /*
+ * Timer Callback
*
* If non-zero is returned, the timer is rescheduled to expire
* return value from now.
@@ -277,7 +277,7 @@ Timers are implemented as a simple structure with a callback, expiration, id
string and internal heap pointers. The priority queue is described simply by
the pointer to the top timer (soonest time to expire).
-The 'priv' pointer is used to pass a user pointer to the callback function.
+The 'priv' pointer is used to pass a user pointer to the callback function.
The number of timers in the queue is the number of sons of the top timer plus
one.
@@ -294,7 +294,7 @@ variables corresponds to the structure members.
void GP_TimerQueueDump(GP_Timer *queue);
-------------------------------------------------------------------------------
-
+
Prints the structure of binary heap into stdout, only for debugging.
[source,c]
diff --git a/doc/loaders.txt b/doc/loaders.txt
index 95eb780..fd10817 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -16,7 +16,7 @@ All saving functions returns zero on success and non-zero on failure. If
image saving is aborted by a callback, the opened file is closed and removed
from a filesystem before the call returns.
-In case of a failure 'errno' is set.
+In case of a failure 'errno' is set.
The signature matching functions takes a 32 bytes long buffer and looks for a
valid image signature. If signature is found 1 is returned.
@@ -48,7 +48,7 @@ Image Loader
GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Loads image from a file.
+Loads image from a file.
The image format is first guessed by the file extension. If loader for the
file extension is found it's called and if it succedes the image data is
@@ -88,7 +88,7 @@ Advanced usage
[source,c]
-------------------------------------------------------------------------------
typedef struct GP_Loader {
- /*
+ /*
* Loads an image.
*
* Returns allocated and initialized bitmap on success, NULL on failure
@@ -96,13 +96,13 @@ typedef struct GP_Loader {
*/
GP_Context *(*Load)(const char *src_path, GP_ProgressCallback *callback);
- /*
+ /*
* Save an image.
*
* Returns zero on succes, non-zero on failure and errno must be set.
*/
int (*Save)(const GP_Context *src, const char *dst_path,
- GP_ProgressCallback *callback);
+ GP_ProgressCallback *callback);
/*
* The buffer is filled with 32 bytes from an image start, returns 1 if
@@ -117,7 +117,7 @@ typedef struct GP_Loader {
/* don't touch */
struct GP_Loader *next;
-
+
/*
* NULL terminated array of file extensions.
*/
@@ -143,7 +143,7 @@ void GP_LoaderUnregister(GP_Loader *self);
The 'GP_Loader' structure describes an image loader.
The 'Load', 'Save' and 'Match' functions could be 'NULL' if the particular
-functionality is not implemented.
+functionality is not implemented.
The 'fmt_name' is a short string that describes the format. For example:
'Netbpm portable pixmap'.
@@ -248,7 +248,7 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path,
Currently only 'RGB888' format is supported, you should convert the
'GP_Context' to 'RGB888' before calling this function otherwise non-zero is
-returned and 'errno' is set to 'ENOSYS'.
+returned and 'errno' is set to 'ENOSYS'.
[source,c]
-------------------------------------------------------------------------------
diff --git a/doc/loaders_python.txt b/doc/loaders_python.txt
index 992cd07..8fa511a 100644
--- a/doc/loaders_python.txt
+++ b/doc/loaders_python.txt
@@ -43,7 +43,7 @@ import gfxprim.loaders as loaders
img.loaders.SavePNG(path, callback=None)
img.loaders.SaveJPG(path, callback=None)
-
+
img.loaders.SaveBMP(path, callback=None)
-------------------------------------------------------------------------------
diff --git a/doc/pixel_types.txt b/doc/pixel_types.txt
index b54ad7a..ee0111c 100644
--- a/doc/pixel_types.txt
+++ b/doc/pixel_types.txt
@@ -12,7 +12,7 @@ Pixel sizes 1, 2 and 4 depend on bit-endian setting and are supported on all sys
Subcontext operations and blits may be slower in case of a different subpixel alignment.
Pixel sizes not divisible by 8 and between 9 and 23 depend on the bit endian -
-the endianity of the system must match the bit-endianity. The other combination
+the endianity of the system must match the bit-endianity. The other combination
is not supported at all - it would be too complicated and probably very inefficient
to decode/encode.
@@ -44,7 +44,7 @@ format, as long as it is not used (compile-time warning is generated).
Bit-endianity
-------------
-With 1, 2 and 4 bpp formats, there are two possible orders of pixels within a byte,
+With 1, 2 and 4 bpp formats, there are two possible orders of pixels within a byte,
both seen in the wild. The two are enumerated in `GP_BIT_ENDIAN`:
`GP_BIT_ENDIAN_LE`::
-----------------------------------------------------------------------
Summary of changes:
build/syms/Input_symbols.txt | 1 +
demos/c_simple/timers.c | 4 +
demos/spiv/spiv.c | 2 +-
doc/api.txt | 2 +-
doc/backends.txt | 38 ++--
doc/backends_python.txt | 12 +-
doc/context.txt | 12 +-
doc/core.txt | 2 +-
doc/core_python.txt | 8 +-
doc/debug.txt | 2 +-
doc/filter_additive_gaussian_noise.txt | 16 +-
doc/filters.txt | 28 ++--
doc/gamma.txt | 6 +-
doc/gen.txt | 10 +-
doc/grabbers.txt | 4 +-
doc/input.txt | 46 +++-
doc/loaders.txt | 16 +-
doc/loaders_python.txt | 2 +-
doc/pixel_types.txt | 4 +-
include/backends/GP_Backend.h | 8 +
include/input/GP_Timer.h | 15 +-
libs/backends/GP_Backend.c | 4 +-
libs/backends/GP_X11.c | 16 +-
libs/input/GP_Timer.c | 67 ++++++
libs/loaders/GP_TIFF.c | 375 ++++++++++++++++++++++++++++----
25 files changed, 550 insertions(+), 150 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
28 Jun '13
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 7cd59d01dfdab87e6047ba1ad04ad4351a685b44 (commit)
from 6fd76586229a017bd0883e58bb9db1e79d29aca9 (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/7cd59d01dfdab87e6047ba1ad04ad4351a68…
commit 7cd59d01dfdab87e6047ba1ad04ad4351a685b44
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 28 10:46:03 2013 +0200
input: timers: Fix well_balaced().
Replace the table with explicit formula
(I had there typos anyway).
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/c_simple/timers.c b/demos/c_simple/timers.c
index cb8c587..4e863c9 100644
--- a/demos/c_simple/timers.c
+++ b/demos/c_simple/timers.c
@@ -38,14 +38,17 @@ uint32_t callback3()
return random() % 30 + 1;
}
+#define MAX 10
+
int main(void)
{
GP_TIMER_DECLARE(oneshot, 30, 0, "Oneshot", callback1, NULL);
GP_TIMER_DECLARE(recurrent, 0, 4, "Recurrent", callback1, NULL);
GP_TIMER_DECLARE(random, 10, 0, "Random", callback3, NULL);
+ GP_Timer timers[MAX];
GP_Timer *queue = NULL;
uint64_t now;
- int ret;
+ int i, ret;
GP_SetDebugLevel(10);
@@ -53,6 +56,17 @@ int main(void)
GP_TimerQueueInsert(&queue, 0, &recurrent);
GP_TimerQueueInsert(&queue, 0, &random);
+ for (i = 0; i < MAX; i++) {
+ timers[i].expires = MAX - i;
+ timers[i].period = 0;
+ timers[i].Callback = callback1;
+ timers[i].priv = NULL;
+ sprintf(timers[i].id, "Timer%i", MAX - i);
+ GP_TimerQueueInsert(&queue, 0, &timers[i]);
+ }
+
+ GP_TimerQueueDump(queue);
+
for (now = 0; now < 100; now += 3) {
printf("NOW %un", (unsigned int) now);
printf("-------------------------------------n");
diff --git a/libs/input/GP_Timer.c b/libs/input/GP_Timer.c
index 519bfe6..3f4adfe 100644
--- a/libs/input/GP_Timer.c
+++ b/libs/input/GP_Timer.c
@@ -65,26 +65,7 @@ static int timer_cmp(GP_Timer *t1, GP_Timer *t2)
*/
static int well_balanced(unsigned int sons)
{
- switch (sons) {
- case 0:
- case 2:
- case 6:
- case 15:
- case 30:
- case 62:
- case 126:
- case 254:
- case 510:
- case 1022:
- case 2046:
- case 4092:
- case 8190:
- case 16382:
- case 32766:
- return 1;
- default:
- return 0;
- }
+ return !((sons + 2) & (sons + 1));
}
static GP_Timer *swap_left(GP_Timer *heap)
@@ -161,7 +142,7 @@ static GP_Timer *rem_last(GP_Timer *heap, GP_Timer **last)
return heap;
}
-static GP_Timer *buble_down(GP_Timer *heap)
+static GP_Timer *bubble_down(GP_Timer *heap)
{
GP_Timer *right = heap->right;
GP_Timer *left = heap->left;
@@ -172,13 +153,13 @@ static GP_Timer *buble_down(GP_Timer *heap)
if (right && timer_cmp(heap, right)) {
swap_right(heap);
- right->right = buble_down(heap);
+ right->right = bubble_down(heap);
return right;
}
if (left && timer_cmp(heap, left)) {
swap_left(heap);
- left->left = buble_down(heap);
+ left->left = bubble_down(heap);
return left;
}
@@ -201,7 +182,7 @@ static GP_Timer *pop(GP_Timer *heap)
last->right = heap->right;
last->sons = heap->sons;
- return buble_down(last);
+ return bubble_down(last);
}
void GP_TimerQueueInsert(GP_Timer **heap, uint64_t now, GP_Timer *timer)
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/timers.c | 16 +++++++++++++++-
libs/input/GP_Timer.c | 29 +++++------------------------
2 files changed, 20 insertions(+), 25 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
28 Jun '13
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 6fd76586229a017bd0883e58bb9db1e79d29aca9 (commit)
via 96bc5c8ddadbd2a8acd894f6c6d8f70779ed7fd0 (commit)
from 62c398e8f845bbe95f0af0e64ab2d9670c6b59af (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/6fd76586229a017bd0883e58bb9db1e79d29…
commit 6fd76586229a017bd0883e58bb9db1e79d29aca9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 28 01:30:14 2013 +0200
demose: Remove tralling whitespaces too.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/bogoman/bogoman.c b/demos/bogoman/bogoman.c
index ea1a4a2..0f74584 100644
--- a/demos/bogoman/bogoman.c
+++ b/demos/bogoman/bogoman.c
@@ -42,7 +42,7 @@ static void save_png(struct bogoman_map *map, unsigned int elem_size,
if (ctx == NULL)
return;
-
+
struct bogoman_render render = {
.map = map,
.map_x_offset = 0,
@@ -50,20 +50,20 @@ static void save_png(struct bogoman_map *map, unsigned int elem_size,
.ctx = ctx,
.map_elem_size = elem_size,
};
-
+
bogoman_render(&render, BOGOMAN_RENDER_ALL);
GP_SavePNG(ctx, filename, NULL);
GP_ContextFree(ctx);
}
-
+
static struct GP_Backend *backend;
static void event_loop(struct bogoman_map *map)
{
while (GP_BackendEventsQueued(backend)) {
GP_Event ev;
-
+
GP_BackendGetEvent(backend, &ev);
switch (ev.type) {
@@ -138,10 +138,10 @@ int main(int argc, char *argv[])
for (;;) {
GP_BackendPoll(backend);
event_loop(map);
-
+
bogoman_render(&render, BOGOMAN_RENDER_DIRTY);
GP_BackendFlip(backend);
-
+
usleep(50000);
}
diff --git a/demos/bogoman/bogoman_debug.c b/demos/bogoman/bogoman_debug.c
index d5ee213..c72c69b 100644
--- a/demos/bogoman/bogoman_debug.c
+++ b/demos/bogoman/bogoman_debug.c
@@ -37,7 +37,7 @@ void bogoman_dbg_print(unsigned int level, const char *file, const char *fn,
fprintf(stderr, "WARNING: %s:%s:%int", file, fn, line);
else
fprintf(stderr, "DEBUG %i:%s:%s:%i:nt", level, file, fn, line);
-
+
va_list va;
va_start(va, fmt);
diff --git a/demos/bogoman/bogoman_loader.c b/demos/bogoman/bogoman_loader.c
index e1f3eed..935bc3e 100644
--- a/demos/bogoman/bogoman_loader.c
+++ b/demos/bogoman/bogoman_loader.c
@@ -45,7 +45,7 @@ static void get_map_info(FILE *f, unsigned int *w, unsigned int *h)
case 'n':
if (*w < curw)
*w = curw;
-
+
if (curw == 0) {
rewind(f);
return;
@@ -130,7 +130,7 @@ static void load_map(FILE *f, struct bogoman_map *map)
for (x = 0; x < line_cur->len; x++) {
struct bogoman_map_elem *elem;
-
+
elem = bogoman_get_map_elem(map, x, y);
elem->id = line_cur->line[x];
@@ -149,7 +149,7 @@ static void load_map(FILE *f, struct bogoman_map *map)
if (y > 0 &&
bogoman_map_is_id(map, x, y-1, BOGOMAN_WALL))
elem->flags |= BOGOMAN_WALL_UP;
-
+
if (x < line_next->len &&
line_next->line[x] == BOGOMAN_WALL)
elem->flags |= BOGOMAN_WALL_DOWN;
@@ -202,11 +202,11 @@ struct bogoman_map *bogoman_load(const char *path)
w * h * sizeof(struct bogoman_map_elem);
map = malloc(map_size);
-
+
if (map == NULL)
goto err0;
- memset(map, 0, map_size);
+ memset(map, 0, map_size);
map->w = w;
map->h = h;
diff --git a/demos/bogoman/bogoman_map.c b/demos/bogoman/bogoman_map.c
index 2f62c64..b911744 100644
--- a/demos/bogoman/bogoman_map.c
+++ b/demos/bogoman/bogoman_map.c
@@ -85,7 +85,7 @@ void bogoman_map_dump(struct bogoman_map *map)
break;
}
}
-
+
printf("n");
}
@@ -208,7 +208,7 @@ void bogoman_map_player_move(struct bogoman_map *map, int x, int y)
player_x = px;
player_y = py;
}
-
+
/* Update the map */
struct bogoman_map_elem *player, *space;
diff --git a/demos/bogoman/bogoman_map.h b/demos/bogoman/bogoman_map.h
index b178dcf..fe7c1f1 100644
--- a/demos/bogoman/bogoman_map.h
+++ b/demos/bogoman/bogoman_map.h
@@ -40,7 +40,7 @@ enum bogoman_map_elem_id {
BOGOMAN_MAX = BOGOMAN_EDIBLE,
};
-/*
+/*
* Wall cal be applied as bitflags. Each bitflag determines wall continuation
* in particular direction.
*/
@@ -91,7 +91,7 @@ static inline enum bogoman_map_elem_id
return elem->id;
}
-static inline int bogoman_map_is_id(struct bogoman_map *map,
+static inline int bogoman_map_is_id(struct bogoman_map *map,
unsigned int x, unsigned int y,
enum bogoman_map_elem_id id)
{
diff --git a/demos/bogoman/bogoman_render.c b/demos/bogoman/bogoman_render.c
index 43a09bd..c2ebc10 100644
--- a/demos/bogoman/bogoman_render.c
+++ b/demos/bogoman/bogoman_render.c
@@ -30,12 +30,12 @@
struct render_colors {
/* global background */
GP_Pixel bg;
-
+
/* player color */
GP_Pixel player;
/* frames around things */
- GP_Pixel frames;
+ GP_Pixel frames;
/* diamod color */
GP_Pixel diamond;
@@ -79,9 +79,9 @@ static void render_player(struct bogoman_render *render,
struct bogoman_map_elem *elem)
{
unsigned int w = render->map_elem_size;
-
+
(void) elem;
-
+
GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg);
GP_FillCircle(render->ctx, x + w/2, y + w/2, w/2 - 1, colors.player);
GP_Circle(render->ctx, x + w/2, y + w/2, w/2 - 1, colors.frames);
@@ -97,7 +97,7 @@ static void render_wall(struct bogoman_render *render,
if (!(elem->flags & BOGOMAN_WALL_LEFT))
GP_VLineXYH(render->ctx, x, y, w, colors.frames);
-
+
if (!(elem->flags & BOGOMAN_WALL_RIGHT))
GP_VLineXYH(render->ctx, x + w - 1, y, w, colors.frames);
@@ -115,7 +115,7 @@ static void render_diamond(struct bogoman_render *render,
unsigned int w = render->map_elem_size;
GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg);
-
+
GP_FillTetragon(render->ctx, x + w/2, y, x + w - 1, y + w/2,
x + w/2, y + w - 1, x, y + w/2, colors.diamond);
@@ -128,7 +128,7 @@ static void render_moveable(struct bogoman_render *render,
struct bogoman_map_elem *elem)
{
unsigned int w = render->map_elem_size;
-
+
GP_FillRectXYWH(render->ctx, x, y, w, w, colors.bg);
GP_FillRectXYWH(render->ctx, x + 1, y + 1, w - 2, w - 2, colors.moveable);
@@ -148,7 +148,7 @@ static void render_edible(struct bogoman_render *render,
static void (*renders[])(struct bogoman_render *render,
unsigned int x, unsigned int y,
- struct bogoman_map_elem *elem) =
+ struct bogoman_map_elem *elem) =
{
render_none,
render_player,
diff --git a/demos/bogoman/bogoman_render.h b/demos/bogoman/bogoman_render.h
index 72c6a48..f813cdc 100644
--- a/demos/bogoman/bogoman_render.h
+++ b/demos/bogoman/bogoman_render.h
@@ -30,7 +30,7 @@ struct bogoman_render {
/* both in map elements */
unsigned int map_x_offset;
unsigned int map_y_offset;
-
+
/* current map */
struct bogoman_map *map;
diff --git a/demos/c_simple/SDL_glue.c b/demos/c_simple/SDL_glue.c
index 3185b67..d5b5cb7 100644
--- a/demos/c_simple/SDL_glue.c
+++ b/demos/c_simple/SDL_glue.c
@@ -24,7 +24,7 @@
*****************************************************************************/
/*
-
+
This example shows how to mix SDL with GFXprim.
*/
@@ -46,7 +46,7 @@ static GP_Pixel black_pixel, darkgray_pixel;
void redraw_screen(void)
{
SDL_LockSurface(display);
-
+
GP_Fill(&context, black_pixel);
GP_Line(&context, 0, 0, W-1, H-1, darkgray_pixel);
@@ -90,7 +90,7 @@ int main(void)
}
display = SDL_SetVideoMode(W, H, 0, SDL_SWSURFACE);
-
+
if (display == NULL) {
fprintf(stderr, "Could not open display: %sn", SDL_GetError());
goto fail;
diff --git a/demos/c_simple/backend_example.c b/demos/c_simple/backend_example.c
index b0faf84..ecf82cc 100644
--- a/demos/c_simple/backend_example.c
+++ b/demos/c_simple/backend_example.c
@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
GP_BackendWaitEvent(backend, &ev);
GP_EventDump(&ev);
-
+
switch (ev.type) {
case GP_EV_KEY:
switch (ev.val.val) {
diff --git a/demos/c_simple/blittest.c b/demos/c_simple/blittest.c
index 1e84efd..3aaf45e 100644
--- a/demos/c_simple/blittest.c
+++ b/demos/c_simple/blittest.c
@@ -55,21 +55,21 @@ void redraw_screen(void)
bitmap_vy = -bitmap_vy;
bitmap_y += bitmap_vy;
}
-
+
if (bitmap_y < 0) {
bitmap_vy = -bitmap_vy;
bitmap_y += bitmap_vy;
}
GP_FillRectXYWH(win->context, 20, 20, 300, 50, black);
-
+
GP_Text(win->context, NULL, 20, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
white, black, text_buf);
GP_Print(win->context, NULL, 250, 20, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
white, black, "%c|%c|%c", bitmap->x_swap ? 'x' : ' ',
bitmap->y_swap ? 'y' : ' ', bitmap->axes_swap ? 'a' : ' ');
-
+
GP_Blit(bitmap, 0, 0, GP_ContextW(bitmap), GP_ContextH(bitmap),
win->context, bitmap_x, bitmap_y);
@@ -84,7 +84,7 @@ static void change_bitmap(void)
bitmap = bitmap_conv;
else
bitmap = bitmap_raw;
-
+
snprintf(text_buf, sizeof(text_buf), "'%s' -> '%s'",
GP_PixelTypeName(bitmap->pixel_type),
GP_PixelTypeName(win->context->pixel_type));
@@ -96,12 +96,12 @@ void event_loop(void)
while (GP_BackendGetEvent(win, &ev)) {
GP_EventDump(&ev);
-
+
switch (ev.type) {
case GP_EV_KEY:
if (ev.code != GP_EV_KEY_DOWN)
continue;
-
+
switch (ev.val.key.key) {
case GP_KEY_X:
bitmap->x_swap = !bitmap->x_swap;
@@ -153,14 +153,14 @@ int main(void)
const char *backend_opts = "X11";
print_instructions();
-
+
bitmap_raw = GP_LoadImage(sprite, NULL);
if (!bitmap_raw) {
fprintf(stderr, "Failed to load '%s'n", sprite);
return 1;
}
-
+
win = GP_BackendInit(backend_opts, "Blit Test", stderr);
if (win == NULL) {
@@ -182,7 +182,7 @@ int main(void)
for (;;) {
GP_BackendPoll(win);
event_loop();
-
+
usleep(8000);
if (pause_flag)
diff --git a/demos/c_simple/convolution.c b/demos/c_simple/convolution.c
index bfbd06a..e0acd17 100644
--- a/demos/c_simple/convolution.c
+++ b/demos/c_simple/convolution.c
@@ -44,8 +44,8 @@ static int progress_callback(GP_ProgressCallback *self)
printf("r%s '%s' %3.1f%%", priv->op, priv->name, self->percentage);
fflush(stdout);
- /*
- * It's important to return zero as non-zero return value
+ /*
+ * It's important to return zero as non-zero return value
* aborts the operation.
*/
return 0;
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
priv.op = "Loading";
priv.name = argv[1];
-
+
img = GP_LoadImage(argv[1], &callback);
if (img == NULL) {
diff --git a/demos/c_simple/debug_handler.c b/demos/c_simple/debug_handler.c
index 9623645..f514769 100644
--- a/demos/c_simple/debug_handler.c
+++ b/demos/c_simple/debug_handler.c
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Example on custom debug message handler.
*/
@@ -56,7 +56,7 @@ int main(void)
{
/* Set custom debug handler */
GP_SetDebugHandler(debug_handler);
-
+
/* Print some debug messages */
GP_WARN("This is a warning");
GP_FATAL("This is a fatal condition");
diff --git a/demos/c_simple/fileview.c b/demos/c_simple/fileview.c
index 26ae4e0..5091ffa 100644
--- a/demos/c_simple/fileview.c
+++ b/demos/c_simple/fileview.c
@@ -89,7 +89,7 @@ void redraw_screen(void)
struct FileLine *line = first_line;
unsigned int i;
- for (i = 0; i < win->h/GP_TextHeight(&style); i++) {
+ for (i = 0; i < win->h/GP_TextHeight(&style); i++) {
if (line == NULL)
break;
GP_Text(win, &style, 16, 16 + (1.0 * GP_TextHeight(&style))*i,
@@ -103,7 +103,7 @@ static void warp_up(int lines)
while (lines-- > 0)
if (first_line->prev != NULL)
first_line = first_line->prev;
-
+
redraw_screen();
GP_BackendFlip(backend);
}
@@ -113,7 +113,7 @@ static void warp_down(int lines)
while (lines-- > 0)
if (first_line->next != NULL)
first_line = first_line->next;
-
+
redraw_screen();
GP_BackendFlip(backend);
}
@@ -129,14 +129,14 @@ void event_loop(void)
case GP_EV_KEY:
if (ev.code != GP_EV_KEY_DOWN)
continue;
-
+
switch (ev.val.key.key) {
case GP_KEY_SPACE:
if (font)
font_flag = (font_flag + 1) % 5;
else
font_flag = (font_flag + 1) % 4;
-
+
redraw_screen();
GP_BackendFlip(backend);
break;
@@ -205,7 +205,7 @@ static int read_file_head(const char *filename)
{
FILE *f = fopen(filename, "r");
char buf[512];
-
+
if (f == NULL) {
fprintf(stderr, "Could not open file: %sn", filename);
return 0;
@@ -215,7 +215,7 @@ static int read_file_head(const char *filename)
if (fgets(buf, 511, f) == NULL)
break;
-
+
struct FileLine *line = malloc(sizeof(*line));
line->text = strdup(buf);
line->next = NULL;
@@ -238,18 +238,18 @@ static int read_file_head(const char *filename)
int main(int argc, char *argv[])
{
const char *backend_opts = "X11";
-
+
if (argc == 1) {
fprintf(stderr, "No file specifiedn");
return 1;
}
-
+
if (argc > 2)
font = GP_FontFaceLoad(argv[2], 0, 16);
if (!read_file_head(argv[1]))
return 1;
-
+
backend = GP_BackendInit(backend_opts, "File View", stderr);
if (backend == NULL) {
@@ -257,7 +257,7 @@ int main(int argc, char *argv[])
backend_opts);
return 1;
}
-
+
win = backend->context;
white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, win);
@@ -269,7 +269,7 @@ int main(int argc, char *argv[])
redraw_screen();
GP_BackendFlip(backend);
-
+
event_loop();
return 0;
diff --git a/demos/c_simple/filters_symmetry.c b/demos/c_simple/filters_symmetry.c
index 3f130a4..735be56 100644
--- a/demos/c_simple/filters_symmetry.c
+++ b/demos/c_simple/filters_symmetry.c
@@ -42,7 +42,7 @@ static void usage_and_exit(int ret)
printf("%s, ", GP_FilterSymmetryNames[i]);
printf("%s} image_in image_outn", GP_FilterSymmetryNames[i]);
-
+
exit(ret);
}
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
usage_and_exit(1);
}
}
-
+
/* Turn on debug messages */
GP_SetDebugLevel(debug);
@@ -111,6 +111,6 @@ int main(int argc, char *argv[])
/* Cleanup */
GP_ContextFree(src);
GP_ContextFree(res);
-
+
return 0;
}
diff --git a/demos/c_simple/fonttest.c b/demos/c_simple/fonttest.c
index f6516cb..4c35110 100644
--- a/demos/c_simple/fonttest.c
+++ b/demos/c_simple/fonttest.c
@@ -87,7 +87,7 @@ static void print_font_properties(const GP_FontFace *font)
GP_FontAscend(font), GP_FontDescend(font));
fprintf(stderr, " Max advance_x: %un",
GP_FontMaxAdvanceX(font));
- fprintf(stderr, " Glyph bitmap format: %sn",
+ fprintf(stderr, " Glyph bitmap format: %sn",
glyph_bitmap_format_name(font->glyph_bitmap_format));
fprintf(stderr, " Bounding box width: %d, heigth: %dn",
GP_FontMaxWidth(font), GP_FontHeight(font));
@@ -155,7 +155,7 @@ void redraw_screen(void)
GP_Text(win->context, &style, 16, SPACING*i + 16, align,
white_pixel, dark_gray_pixel, test_string);
-
+
style.pixel_xmul = 2;
style.pixel_ymul = 2;
style.pixel_yspace = 1;
@@ -169,18 +169,18 @@ void redraw_screen(void)
style.pixel_xmul = 4;
style.pixel_ymul = 2;
-
+
style.pixel_xspace = 1;
style.pixel_yspace = 1;
-
+
if (font_flag == 2 || font_flag == 3) {
style.pixel_xmul = 2;
style.pixel_ymul = 5;
-
+
style.pixel_xspace = 2;
style.pixel_yspace = 2;
}
-
+
GP_Text(win->context, &style, 64, SPACING*i + 88, align,
dark_gray_pixel, black_pixel, test_string);
}
@@ -197,14 +197,14 @@ void event_loop(void)
case GP_EV_KEY:
if (ev.code != GP_EV_KEY_DOWN)
continue;
-
+
switch (ev.val.key.key) {
case GP_KEY_SPACE:
if (font)
font_flag = (font_flag + 1) % 5;
else
font_flag = (font_flag + 1) % 4;
-
+
redraw_screen();
GP_BackendFlip(win);
break;
@@ -257,17 +257,17 @@ void print_instructions(void)
int main(int argc, char *argv[])
{
const char *backend_opts = "X11";
-
+
print_instructions();
GP_SetDebugLevel(10);
-
+
if (argc > 1) {
font_path = argv[1];
fprintf(stderr, "nLoading font '%s'n", argv[1]);
font = GP_FontFaceLoad(argv[1], 0, font_h);
}
-
+
win = GP_BackendInit(backend_opts, "Font Test", stderr);
if (win == NULL) {
@@ -275,7 +275,7 @@ int main(int argc, char *argv[])
backend_opts);
return 1;
}
-
+
white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, win->context);
gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, win->context);
dark_gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, win->context);
diff --git a/demos/c_simple/gfx_koch.c b/demos/c_simple/gfx_koch.c
index dda5e80..c188f3a 100644
--- a/demos/c_simple/gfx_koch.c
+++ b/demos/c_simple/gfx_koch.c
@@ -35,7 +35,7 @@
/* Set to 1 to use Anti Aliased drawing */
static int aa_flag = 0;
-/*
+/*
* Generate color depending on distance from center
*
* We could do this only and only because the context
@@ -51,7 +51,7 @@ static GP_Pixel do_color(int xc, int yc, float x, float y)
int rmask = 0;
int gmask = 0xff * sqrt(dc);
int bmask = 0xff * (1 - dc);
-
+
if (dc < 0.1) {
rmask = 0xff * (1 - dc);
bmask = 0x00;
@@ -72,19 +72,19 @@ static void draw(GP_Context *img, int level, float x0, float y0, float x1, float
GP_Pixel pixel;
pixel = do_color(img->w/2, img->h/2, 1.00 * (x0+x1)/2, 1.00 * (y0 + y1)/2);
-
+
if (aa_flag)
GP_LineAA(img, x0 * 256, y0 * 256, x1 * 256, y1 * 256, pixel);
else
GP_Line(img, x0, y0, x1, y1, pixel);
-
+
return;
}
/* Compute varation of Koch curve */
float x34 = (x0 + 3 * x1) / 4;
float y34 = (y0 + 3 * y1) / 4;
-
+
float x14 = (3 * x0 + x1) / 4;
float y14 = (3 * y0 + y1) / 4;
@@ -107,7 +107,7 @@ static void draw(GP_Context *img, int level, float x0, float y0, float x1, float
int main(void)
{
GP_Context *img;
-
+
/* Create RGB 24 bit image */
img = GP_ContextAlloc(600, 600, GP_PIXEL_RGB888);
@@ -119,7 +119,7 @@ int main(void)
/* Clean up the bitmap */
GP_Fill(img, 0);
- /* Draw a fractal */
+ /* Draw a fractal */
draw(img, 4, 0, 0, img->w - 1, img->h - 1);
draw(img, 4, 0, img->h - 1, img->w - 1, 0);
diff --git a/demos/c_simple/input_example.c b/demos/c_simple/input_example.c
index 820b530..5243c82 100644
--- a/demos/c_simple/input_example.c
+++ b/demos/c_simple/input_example.c
@@ -40,14 +40,14 @@ static void draw_event(GP_Event *ev)
if (ev->type != GP_EV_KEY)
return;
-
+
int align = GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM;
GP_TextClear(win, NULL, 20, 20, align, black, size);
size = GP_Print(win, NULL, 20, 20, align,
white, black, "Key=%s",
GP_EventKeyName(ev->val.key.key));
-
+
GP_BackendFlip(backend);
}
@@ -55,7 +55,7 @@ static void event_loop(void)
{
for (;;) {
GP_BackendWait(backend);
-
+
while (GP_BackendEventsQueued(backend)) {
GP_Event ev;
@@ -90,7 +90,7 @@ static void event_loop(void)
case GP_EV_REL_POS:
if (GP_EventGetKey(&ev, GP_BTN_LEFT)) {
GP_PutPixel(win, ev.cursor_x,
- ev.cursor_y, green);
+ ev.cursor_y, green);
}
int align = GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM;
@@ -147,7 +147,7 @@ int main(int argc, char *argv[])
backend_opts);
return 1;
}
-
+
win = backend->context;
red = GP_ColorToContextPixel(GP_COL_RED, win);
diff --git a/demos/c_simple/koch.c b/demos/c_simple/koch.c
index e546707..6325e35 100644
--- a/demos/c_simple/koch.c
+++ b/demos/c_simple/koch.c
@@ -24,7 +24,7 @@
*****************************************************************************/
/*
-
+
Simple test for triangle drawing runtime.
*/
@@ -50,7 +50,7 @@ static void sierpinsky(double x1, double y1, double x4, double y4, int iter)
double x2, y2, x3, y3, x5, y5;
GP_Pixel pixel;
pixel = GP_RGBToPixel(0, 0, 255-16*iter, context->pixel_type);
-
+
if (iter <= 0) {
if (draw_edge)
GP_Line(context, x1, y1, x4, y4, black);
@@ -85,13 +85,13 @@ static void draw(int x, int y, int l, int iter)
int h = context->h;
l = ((w < h ? w : h) - 20)/(5 - 1.00*iter/120);
-
+
x1 = sin(1.00 * iter/57) * l + x;
y1 = cos(1.00 * iter/57) * l + y;
-
+
x2 = sin(1.00 * (iter+120)/57) * l + x;
y2 = cos(1.00 * (iter+120)/57) * l + y;
-
+
x3 = sin(1.00 * (iter+240)/57) * l + x;
y3 = cos(1.00 * (iter+240)/57) * l + y;
@@ -114,10 +114,10 @@ void redraw(void)
return;
iter += 2 * way;
-
+
if (iter > 350)
way *= -1;
-
+
if (iter < 0)
way *= -1;
@@ -127,7 +127,7 @@ void redraw(void)
int main(void)
{
const char *backend_opts = "X11";
-
+
backend = GP_BackendInit(backend_opts, "Koch", stderr);
if (backend == NULL) {
@@ -135,14 +135,14 @@ int main(void)
backend_opts);
return 1;
}
-
+
context = backend->context;
-
+
black = GP_ColorToContextPixel(GP_COL_BLACK, context);
blue = GP_ColorToContextPixel(GP_COL_BLUE, context);
gray = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, context);
red = GP_ColorToContextPixel(GP_COL_RED, context);
-
+
iter = 0;
draw(context->w/2, context->h/2, l, iter);
@@ -150,17 +150,17 @@ int main(void)
GP_Event ev;
redraw();
-
+
GP_BackendPoll(backend);
-
+
while (GP_BackendGetEvent(backend, &ev)) {
GP_EventDump(&ev);
-
+
switch (ev.type) {
case GP_EV_KEY:
if (ev.code != GP_EV_KEY_DOWN)
continue;
-
+
switch (ev.val.key.key) {
case GP_KEY_P:
paused = !paused;
@@ -177,6 +177,6 @@ int main(void)
}
usleep(TIMER_TICK);
}
-
+
return 0;
}
diff --git a/demos/c_simple/linetest.c b/demos/c_simple/linetest.c
index e0be94d..8c91cf5 100644
--- a/demos/c_simple/linetest.c
+++ b/demos/c_simple/linetest.c
@@ -47,19 +47,19 @@ void redraw_screen(void)
int ycenter = h/2;
GP_Fill(win->context, black);
-
+
for (angle = 0.0; angle < 2*M_PI; angle += 0.1) {
x = (int) (w/2 * cos(start_angle + angle));
y = (int) (h/2 * sin(start_angle + angle));
int r = 127.0 + 127.0 * cos(start_angle + angle);
int b = 127.0 + 127.0 * sin(start_angle + angle);
-
+
GP_Pixel pixel;
pixel = GP_RGBToPixel(r, 0, b, win->context->pixel_type);
-
+
if (aa_flag) {
- GP_LineAA_Raw(win->context, GP_FP_FROM_INT(xcenter), GP_FP_FROM_INT(ycenter),
+ GP_LineAA_Raw(win->context, GP_FP_FROM_INT(xcenter), GP_FP_FROM_INT(ycenter),
GP_FP_FROM_INT(xcenter + x), GP_FP_FROM_INT(ycenter + y), pixel);
} else {
GP_Line(win->context, xcenter + x, ycenter + y, xcenter, ycenter, pixel);
@@ -83,7 +83,7 @@ void event_loop(void)
case GP_EV_KEY:
if (ev.code != GP_EV_KEY_DOWN)
continue;
-
+
switch (ev.val.key.key) {
case GP_KEY_A:
aa_flag = !aa_flag;
@@ -103,7 +103,7 @@ void event_loop(void)
int main(void)
{
const char *backend_opts = "X11";
-
+
win = GP_BackendInit(backend_opts, "Line Test", stderr);
if (win == NULL) {
@@ -111,7 +111,7 @@ int main(void)
backend_opts);
return 1;
}
-
+
white = GP_ColorToContextPixel(GP_COL_WHITE, win->context);
black = GP_ColorToContextPixel(GP_COL_BLACK, win->context);
@@ -120,7 +120,7 @@ int main(void)
for (;;) {
GP_BackendPoll(win);
event_loop();
-
+
usleep(20000);
if (pause_flag)
@@ -128,7 +128,7 @@ int main(void)
redraw_screen();
GP_BackendFlip(win);
-
+
start_angle += 0.01;
if (start_angle > 2*M_PI) {
start_angle = 0.0;
diff --git a/demos/c_simple/loaders.c b/demos/c_simple/loaders.c
index 8239b90..369ec48 100644
--- a/demos/c_simple/loaders.c
+++ b/demos/c_simple/loaders.c
@@ -44,8 +44,8 @@ static int progress_callback(GP_ProgressCallback *self)
printf("r%s '%s' %3.1f%%", priv->op, priv->name, self->percentage);
fflush(stdout);
- /*
- * It's important to return zero as non-zero return value
+ /*
+ * It's important to return zero as non-zero return value
* aborts the operation.
*/
return 0;
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
priv.op = "Loading";
priv.name = argv[1];
-
+
img = GP_LoadImage(argv[1], &callback);
if (img == NULL) {
diff --git a/demos/c_simple/loaders_example.c b/demos/c_simple/loaders_example.c
index 76ffe07..9c0a65a 100644
--- a/demos/c_simple/loaders_example.c
+++ b/demos/c_simple/loaders_example.c
@@ -43,7 +43,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Takes an image as an parametern");
return 1;
}
-
+
img = GP_LoadImage(argv[1], NULL);
if (img == NULL) {
diff --git a/demos/c_simple/loaders_register.c b/demos/c_simple/loaders_register.c
index 2140af5..877bff9 100644
--- a/demos/c_simple/loaders_register.c
+++ b/demos/c_simple/loaders_register.c
@@ -73,7 +73,7 @@ static int save(const GP_Context *img, const char *dst_path,
}
fprintf(f, "n");
-
+
if (GP_ProgressCallbackReport(callback, img->h, j, img->w)) {
fclose(f);
unlink(dst_path);
@@ -101,7 +101,7 @@ GP_Loader loader = {
int main(int argc, char *argv[])
{
GP_Context *c, *gc;
-
+
GP_LoaderRegister(&loader);
/* List all loaders */
@@ -127,7 +127,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "FloydSteinberg: %sn", strerror(errno));
return 1;
}
-
+
printf("Saving to test.txtn");
if (GP_SaveImage(gc, "test.txt", NULL)) {
diff --git a/demos/c_simple/meta_data.c b/demos/c_simple/meta_data.c
index 746f6b7..a2c9a64 100644
--- a/demos/c_simple/meta_data.c
+++ b/demos/c_simple/meta_data.c
@@ -46,7 +46,7 @@ int main(void)
if (data == NULL)
return 1;
- /*
+ /*
* Create integer
*
* May fail, if there is allready record with id 'dpi' or
diff --git a/demos/c_simple/meta_data_dump.c b/demos/c_simple/meta_data_dump.c
index d9aacfb..8fc2526 100644
--- a/demos/c_simple/meta_data_dump.c
+++ b/demos/c_simple/meta_data_dump.c
@@ -44,15 +44,15 @@ int main(int argc, char *argv[])
fprintf(stderr, "Takes an image(s) as parameter(s)n");
return 1;
}
-
+
//GP_SetDebugLevel(10);
for (i = 1; i < argc; i++) {
puts(SEP);
printf("Opening '%s'n", argv[i]);
-
+
GP_MetaDataClear(data);
-
+
if (GP_LoadMetaData(argv[i], data)) {
fprintf(stderr, "Failed to read '%s' meta-data: %sn",
argv[1], strerror(errno));
@@ -60,7 +60,7 @@ int main(int argc, char *argv[])
GP_MetaDataPrint(data);
}
}
-
+
puts(SEP);
return 0;
diff --git a/demos/c_simple/pretty_print.c b/demos/c_simple/pretty_print.c
index ef010da..82e9d08 100644
--- a/demos/c_simple/pretty_print.c
+++ b/demos/c_simple/pretty_print.c
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Pretty print function for pixel and context.
*/
diff --git a/demos/c_simple/shapetest.c b/demos/c_simple/shapetest.c
index 9cebdd3..6444445 100644
--- a/demos/c_simple/shapetest.c
+++ b/demos/c_simple/shapetest.c
@@ -86,7 +86,7 @@ void draw_testing_triangle(int x, int y, int xradius, int yradius)
y1 = y;
x2 = x + xradius;
y2 = y + yradius;
- break;
+ break;
case 3:
x0 = x - xradius;
y0 = y - yradius;
@@ -171,7 +171,7 @@ void draw_testing_rectangle(int x, int y, int xradius, int yradius)
{
int x0 = x - xradius, y0 = y - yradius;
int x1 = x + xradius, y1 = y + yradius;
-
+
if (outline == 1)
GP_Rect(win, x0, y0, x1, y1, yellow);
@@ -191,7 +191,7 @@ void draw_testing_tetragon(int x, int y, int xradius, int yradius)
if (outline == 1)
GP_Tetragon(win, x0, y0, x1, y1, x2, y2, x3, y3, yellow);
-
+
if (fill)
GP_FillTetragon(win, x0, y0, x1, y1, x2, y2, x3, y3, red);
@@ -206,7 +206,7 @@ void draw_testing_polygon(int x, int y, int xradius, int yradius)
xy[0] = x + xradius;
xy[1] = y;
-
+
xy[2] = x + 3 * xradius / 4;
xy[3] = y + yradius / 4;
@@ -308,7 +308,7 @@ static void xradius_add(int xradius_add)
xradius + xradius_add < (int)win->w)
xradius += xradius_add;
}
-
+
static void yradius_add(int yradius_add)
{
@@ -316,14 +316,14 @@ static void yradius_add(int yradius_add)
yradius + yradius_add < (int)win->h)
yradius += yradius_add;
}
-
+
static void xcenter_add(int xcenter_add)
{
if (center_x + xcenter_add > 1 &&
center_x + xcenter_add < (int)win->w/2)
center_x += xcenter_add;
}
-
+
static void ycenter_add(int ycenter_add)
{
if (center_y + ycenter_add > 1 &&
@@ -341,7 +341,7 @@ void event_loop(void)
GP_BackendWaitEvent(backend, &ev);
GP_EventDump(&ev);
-
+
shift_pressed = GP_EventGetKey(&ev, GP_KEY_LEFT_SHIFT) ||
GP_EventGetKey(&ev, GP_KEY_RIGHT_SHIFT);
@@ -349,7 +349,7 @@ void event_loop(void)
case GP_EV_KEY:
if (ev.code != GP_EV_KEY_DOWN)
continue;
-
+
switch (ev.val.key.key) {
case GP_KEY_X:
win->x_swap = !win->x_swap;
@@ -446,7 +446,7 @@ void event_loop(void)
}
break;
}
-
+
redraw_screen();
}
}
@@ -484,7 +484,7 @@ int main(void)
backend_opts);
return 1;
}
-
+
win = backend->context;
center_x = win->w / 2;
diff --git a/demos/c_simple/showimage.c b/demos/c_simple/showimage.c
index 3394230..14873d0 100644
--- a/demos/c_simple/showimage.c
+++ b/demos/c_simple/showimage.c
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Simple example that shows X11 window with image.
*/
@@ -36,7 +36,7 @@ int main(int argc, char *argv[])
{
GP_Backend *backend;
GP_Context *image;
-
+
GP_SetDebugLevel(10);
if (argc != 2) {
@@ -51,7 +51,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Failed to load bitmap: %sn", strerror(errno));
return 1;
}
-
+
/* Initalize backend */
backend = GP_BackendX11Init(NULL, 0, 0, image->w, image->h, argv[1], 0);
diff --git a/demos/c_simple/sin_AA.c b/demos/c_simple/sin_AA.c
index 80c9086..20e3202 100644
--- a/demos/c_simple/sin_AA.c
+++ b/demos/c_simple/sin_AA.c
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Simple example that shows HLineAA() usage.
*/
@@ -65,11 +65,11 @@ static void redraw(GP_Context *context)
if (flag) {
param -= 0.02;
-
+
if (param <= -2.40) {
flag = 0;
param2 += 0.01;
-
+
if (param2 > 0.02)
param2 = 0.01;
}
@@ -100,9 +100,9 @@ int main(void)
redraw(backend->context);
GP_BackendFlip(backend);
}
-
+
GP_BackendPoll(backend);
-
+
GP_Event ev;
while (GP_BackendGetEvent(backend, &ev)) {
diff --git a/demos/c_simple/textaligntest.c b/demos/c_simple/textaligntest.c
index 39391b4..99a6a3f 100644
--- a/demos/c_simple/textaligntest.c
+++ b/demos/c_simple/textaligntest.c
@@ -80,7 +80,7 @@ static void event_loop(void)
case GP_EV_KEY:
if (ev.code != GP_EV_KEY_DOWN)
continue;
-
+
switch (ev.val.key.key) {
case GP_KEY_X:
win->context->x_swap = !win->context->x_swap;
@@ -118,7 +118,7 @@ static void event_loop(void)
}
break;
}
-
+
redraw_screen();
GP_BackendFlip(win);
}
diff --git a/demos/c_simple/timers.c b/demos/c_simple/timers.c
index 112223a..cb8c587 100644
--- a/demos/c_simple/timers.c
+++ b/demos/c_simple/timers.c
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Simple example how to use raw timer priority queue.
*/
@@ -52,7 +52,7 @@ int main(void)
GP_TimerQueueInsert(&queue, 0, &oneshot);
GP_TimerQueueInsert(&queue, 0, &recurrent);
GP_TimerQueueInsert(&queue, 0, &random);
-
+
for (now = 0; now < 100; now += 3) {
printf("NOW %un", (unsigned int) now);
printf("-------------------------------------n");
diff --git a/demos/c_simple/tmp_file.c b/demos/c_simple/tmp_file.c
index 99becbc..6daf399 100644
--- a/demos/c_simple/tmp_file.c
+++ b/demos/c_simple/tmp_file.c
@@ -62,7 +62,7 @@ int main(int argc, char *argv[])
priv.op = "Loading";
priv.name = argv[1];
-
+
img = GP_LoadImage(argv[1], &callback);
if (img == NULL) {
@@ -80,13 +80,13 @@ int main(int argc, char *argv[])
fprintf(stderr, "Failed to save temp file %sn", strerror(errno));
return 1;
}
-
+
printf("n");
GP_ContextFree(img);
-
+
priv.op = "Loading";
-
+
img = GP_LoadTmpFile(priv.name, &callback);
if (img == NULL) {
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
priv.op = "Saving";
priv.name = "out.png";
-
+
printf("n");
if (GP_SavePNG(img, "out.png", &callback)) {
diff --git a/demos/c_simple/v4l2_grab.c b/demos/c_simple/v4l2_grab.c
index 7aa8469..c43cc32 100644
--- a/demos/c_simple/v4l2_grab.c
+++ b/demos/c_simple/v4l2_grab.c
@@ -42,7 +42,7 @@ static int get_image(const char *filename, GP_Grabber *grabber)
/* throw away first frame, it's usually wrong */
while (!GP_GrabberPoll(grabber))
usleep(100000);
-
+
while (!GP_GrabberPoll(grabber))
usleep(100000);
@@ -52,7 +52,7 @@ static int get_image(const char *filename, GP_Grabber *grabber)
filename, strerror(errno));
return 1;
}
-
+
/* turn off grabber */
if (GP_GrabberStop(grabber)) {
fprintf(stderr, "Failed to start grabbern");
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
unsigned int w = 640, h = 480;
int secs = 0;
int opt;
-
+
while ((opt = getopt(argc, argv, "d:hH:o:W:l:s:")) != -1) {
switch (opt) {
case 'o':
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
return 1;
}
}
-
+
GP_Grabber *grabber = GP_GrabberV4L2Init(v4l2_device, w, h);
if (grabber == NULL) {
@@ -122,12 +122,12 @@ int main(int argc, char *argv[])
}
int i = 0;
-
+
for (;;) {
char buf[128];
snprintf(buf, sizeof(buf), "frame%03i.jpg", i++);
-
+
if (get_image(buf, grabber)) {
fprintf(stderr, "Failed to get image, exitting...n");
return 1;
diff --git a/demos/c_simple/v4l2_show.c b/demos/c_simple/v4l2_show.c
index a65202c..a88a891 100644
--- a/demos/c_simple/v4l2_show.c
+++ b/demos/c_simple/v4l2_show.c
@@ -42,7 +42,7 @@ int main(int argc, char *argv[])
/* Turn on debug messages */
//GP_SetDebugLevel(10);
-
+
while ((opt = getopt(argc, argv, "d:hH:W:l:")) != -1) {
switch (opt) {
case 'd':
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
v4l2_device, strerror(errno));
return 1;
}
-
+
backend = GP_BackendX11Init(NULL, 0, 0, grabber->frame->w,
grabber->frame->h, "V4L2", 0);
@@ -114,16 +114,16 @@ int main(int argc, char *argv[])
res = GP_FilterFloydSteinberg_RGB888_Alloc(img, GP_PIXEL_G2, NULL);
break;
}
-
+
GP_Blit_Clipped(res, 0, 0, res->w, res->h, backend->context, 0, 0);
GP_BackendFlip(backend);
-
+
if (mode)
GP_ContextFree(res);
}
-
+
usleep(1000);
-
+
GP_BackendPoll(backend);
/* Read and parse events */
@@ -132,7 +132,7 @@ int main(int argc, char *argv[])
while (GP_BackendGetEvent(backend, &ev)) {
switch (ev.type) {
case GP_EV_KEY:
-
+
/* ignore key up events */
if (!ev.code)
continue;
@@ -145,7 +145,7 @@ int main(int argc, char *argv[])
return 0;
break;
case GP_KEY_SPACE:
-
+
mode++;
if (mode > 2)
diff --git a/demos/c_simple/version.c b/demos/c_simple/version.c
index 3f83d7e..874bf2b 100644
--- a/demos/c_simple/version.c
+++ b/demos/c_simple/version.c
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Prints GFXprim version.
*/
diff --git a/demos/c_simple/virtual_backend_example.c b/demos/c_simple/virtual_backend_example.c
index d1ce089..d149bc8 100644
--- a/demos/c_simple/virtual_backend_example.c
+++ b/demos/c_simple/virtual_backend_example.c
@@ -70,10 +70,10 @@ int main(int argc, char *argv[])
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.
@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
green_pixel = GP_ColorToContextPixel(GP_COL_GREEN, context);
GP_Fill(context, white_pixel);
-
+
unsigned int i, j;
for (i = 0; i < 40; i++) {
GP_HLineXYW(context, 0, i, i, black_pixel);
@@ -124,16 +124,16 @@ int main(int argc, char *argv[])
GP_Text(context, NULL, 60, 270, GP_VALIGN_BELOW|GP_ALIGN_RIGHT,
black_pixel, white_pixel, "Lorem Ipsum dolor sit...");
-
+
GP_Text(context, NULL, 60, 290, GP_VALIGN_BELOW|GP_ALIGN_RIGHT,
red_pixel, white_pixel, "Lorem Ipsum dolor sit...");
-
+
GP_Text(context, NULL, 60, 310, GP_VALIGN_BELOW|GP_ALIGN_RIGHT,
green_pixel, white_pixel, "Lorem Ipsum dolor sit...");
GP_Text(context, NULL, 60, 330, GP_VALIGN_BELOW|GP_ALIGN_RIGHT,
blue_pixel, white_pixel, "Lorem Ipsum dolor sit...");
-
+
/* Update the backend screen */
GP_BackendFlip(backend);
@@ -149,7 +149,7 @@ int main(int argc, char *argv[])
while (GP_BackendGetEvent(backend, &ev)) {
GP_EventDump(&ev);
-
+
switch (ev.type) {
case GP_EV_KEY:
switch (ev.val.key.key) {
diff --git a/demos/c_simple/weighted_median.c b/demos/c_simple/weighted_median.c
index fbbd8c5..a0b09fd 100644
--- a/demos/c_simple/weighted_median.c
+++ b/demos/c_simple/weighted_median.c
@@ -44,8 +44,8 @@ static int progress_callback(GP_ProgressCallback *self)
printf("r%s '%s' %3.1f%%", priv->op, priv->name, self->percentage);
fflush(stdout);
- /*
- * It's important to return zero as non-zero return value
+ /*
+ * It's important to return zero as non-zero return value
* aborts the operation.
*/
return 0;
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
priv.op = "Loading";
priv.name = argv[1];
-
+
img = GP_LoadImage(argv[1], &callback);
if (img == NULL) {
diff --git a/demos/c_simple/x11_windows.c b/demos/c_simple/x11_windows.c
index 7ed43e4..39252ed 100644
--- a/demos/c_simple/x11_windows.c
+++ b/demos/c_simple/x11_windows.c
@@ -31,7 +31,7 @@
static void redraw(struct GP_Context *context)
{
GP_Pixel white_pixel, black_pixel;
-
+
black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context);
white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context);
@@ -50,9 +50,9 @@ static int ev_loop(struct GP_Backend *backend, const char *name)
while (GP_BackendGetEvent(backend, &ev)) {
printf("-------------------------- %sn", name);
-
+
GP_EventDump(&ev);
-
+
switch (ev.type) {
case GP_EV_KEY:
switch (ev.val.val) {
@@ -75,7 +75,7 @@ static int ev_loop(struct GP_Backend *backend, const char *name)
}
break;
}
-
+
printf("-----------------------------n");
}
@@ -98,12 +98,12 @@ int main(void)
/* Update the backend screen */
redraw(win_1->context);
redraw(win_2->context);
-
+
GP_BackendFlip(win_1);
GP_BackendFlip(win_2);
for (;;) {
- /*
+ /*
* Wait for backend event.
*
* Either window is fine as they share connection.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c
index d74eb0f..6bdf006 100644
--- a/demos/grinder/grinder.c
+++ b/demos/grinder/grinder.c
@@ -39,7 +39,7 @@ static int show_progress(GP_ProgressCallback *self)
{
fprintf(stderr, "r%s %3.2f%%",
progress_prefix, self->percentage);
-
+
return 0;
}
@@ -51,11 +51,11 @@ static int param_err(const struct param *self, const char *val, void *priv)
(char*)priv, val);
return 1;
}
-
+
/* just regular error */
fprintf(stderr, "ERROR: %s: Invalid %s parameter value %s = '%s'",
(char *)priv, param_type_name(self->type), self->name, val);
-
+
if (self->type == PARAM_ENUM) {
unsigned int i;
@@ -96,7 +96,7 @@ static int resize_check_ratio(const struct param *self __attribute__((unused)),
if (f <= 0)
return -1;
-
+
return 0;
}
@@ -125,7 +125,7 @@ static int resize(GP_Context **c, const char *params)
GP_Context *res = NULL;
res = GP_FilterResize(*c, NULL, alg, w, h, progress_callback);
-
+
if (res == NULL)
return EINVAL;
@@ -153,7 +153,7 @@ static int scale_check_size(const struct param *self __attribute__((unused)),
if (i <= 0)
return 1;
-
+
return 0;
}
@@ -181,7 +181,7 @@ static int scale(GP_Context **c, const char *params)
if (w == -1)
w = (*c)->w * (1.00 * h/(*c)->h) + 0.5;
-
+
if (h == -1)
h = (*c)->h * (1.00 * w/(*c)->w) + 0.5;
@@ -236,10 +236,10 @@ static int rotate(GP_Context **c, const char *params)
res = GP_FilterRotate270Alloc(*c, progress_callback);
break;
}
-
+
if (res == NULL)
return ENOMEM;
-
+
GP_ContextFree(*c);
*c = res;
@@ -263,7 +263,7 @@ static int mirror(GP_Context **c, const char *params)
if (vert)
GP_FilterMirrorV(*c, *c, progress_callback);
-
+
if (horiz)
GP_FilterMirrorH(*c, *c, progress_callback);
@@ -292,12 +292,12 @@ static int bright(GP_Context **c, const char *params)
}
GP_FILTER_PARAMS((*c)->pixel_type, filter_params);
-
+
if (chann == NULL) {
GP_FilterParamSetIntAll(filter_params, bright);
} else {
GP_FilterParam *param = GP_FilterParamChannel(filter_params, chann);
-
+
if (param == NULL) {
print_error("bright: Invalid channel name");
return EINVAL;
@@ -332,14 +332,14 @@ static int contrast(GP_Context **c, const char *params)
print_error("contrast: mul parameter must be >= 0");
return EINVAL;
}
-
+
GP_FILTER_PARAMS((*c)->pixel_type, filter_params);
-
+
if (chann == NULL) {
GP_FilterParamSetFloatAll(filter_params, mul);
} else {
GP_FilterParam *param = GP_FilterParamChannel(filter_params, chann);
-
+
if (param == NULL) {
print_error("contrast: Invalid channel name");
return EINVAL;
@@ -368,7 +368,7 @@ static int noise(GP_Context **c, const char *params)
return EINVAL;
GP_FILTER_PARAMS((*c)->pixel_type, filter_params);
-
+
GP_FilterParamSetFloatAll(filter_params, rat);
GP_FilterNoise(*c, *c, filter_params, progress_callback);
@@ -458,7 +458,7 @@ static int dither(GP_Context **c, const char *params)
if (param_parse(params, dither_params, "dither", param_err, &fmt))
return EINVAL;
-
+
if (fmt == -1) {
print_error("dither: invalid format or format param missing");
return EINVAL;
@@ -490,7 +490,7 @@ static int save_jpg(GP_Context **c, const char *params)
if (param_parse(params, save_jpg_params, "jpg", param_err, &file))
return EINVAL;
-
+
if (file == NULL) {
print_error("jpg: filename missing");
return EINVAL;
@@ -514,7 +514,7 @@ static int save_png(GP_Context **c, const char *params)
if (param_parse(params, save_png_params, "png", param_err, &file))
return EINVAL;
-
+
if (file == NULL) {
print_error("png: filename missing");
return EINVAL;
@@ -564,22 +564,22 @@ static int add_noise(GP_Context **c, const char *params)
if (param_parse(params, add_noise_params, "add_noise", param_err, &percents, &chann))
return EINVAL;
-
+
GP_FILTER_PARAMS((*c)->pixel_type, priv);
GP_FilterParamSetFloatAll(priv, percents/100);
GP_FILTER_PARAMS((*c)->pixel_type, op_callbacks);
-
+
if (chann == NULL) {
GP_FilterParamSetPtrAll(op_callbacks, add_noise_op);
} else {
GP_FilterParam *param = GP_FilterParamChannel(op_callbacks, chann);
-
+
if (param == NULL) {
print_error("add_noise: Invalid channel name");
return EINVAL;
}
-
+
GP_FilterParamSetPtrAll(op_callbacks, no_op);
param->val.ptr = add_noise_op;
}
@@ -604,7 +604,7 @@ static int median(GP_Context **c, const char *params)
if (param_parse(params, median_params, "median", param_err, &rad, &rad_x, &rad_y))
return EINVAL;
-
+
if (rad != -1) {
rad_x = rad;
rad_y = rad;
@@ -643,7 +643,7 @@ static int sigma_mean(GP_Context **c, const char *params)
if (param_parse(params, sigma_mean_params, "sigma", param_err,
&rad, &min, &sigma, &rad_x, &rad_y))
return EINVAL;
-
+
if (rad != -1) {
rad_x = rad;
rad_y = rad;
@@ -678,7 +678,7 @@ static int sharpen(GP_Context **c, const char *params)
if (param_parse(params, sharpen_params, "sigma", param_err, &weight))
return EINVAL;
-
+
GP_Context *ret = GP_FilterEdgeSharpeningAlloc(*c, weight, progress_callback);
if (ret == NULL)
@@ -705,7 +705,7 @@ static int gauss_noise(GP_Context **c, const char *params)
if (param_parse(params, gauss_noise_params, "gaussian noise", param_err, &sigma, &mu))
return EINVAL;
-
+
GP_FilterGaussianNoiseAdd(*c, *c, sigma, mu, progress_callback);
return 0;
@@ -735,7 +735,7 @@ static int arithmetic(GP_Context **c, const char *params)
if (param_parse(params, arithmetic_params, "arithmetic", param_err, &file, &op))
return EINVAL;
-
+
if (file == NULL) {
print_error("arithmetic: Filename missing");
return EINVAL;
@@ -789,7 +789,7 @@ static int histogram(GP_Context **c, const char *params)
if (param_parse(params, histogram_params, "histogram", param_err, &file))
return EINVAL;
-
+
if (file == NULL) {
print_error("histogram: Filename missing");
return EINVAL;
@@ -851,7 +851,7 @@ static void print_filter_help(void)
printf("%sn", filter_table[i].name);
j = strlen(filter_table[i].name);
-
+
while (j--)
putchar('-');
putchar('n');
@@ -883,7 +883,7 @@ static void add_filter(char *params)
const char *name = strsep(¶ms, ":");
filters[filter_cnt] = get_filter(name);
-
+
if (filters[filter_cnt] == NULL) {
fprintf(stderr, "Invalid filter name '%s'n", name);
exit(1);
@@ -908,7 +908,7 @@ static void apply_filters(GP_Context **src)
fprintf(stderr, "Error: %sn", strerror(ret));
exit(1);
}
-
+
if (progress_callback != NULL)
fprintf(stderr, " donen");
}
@@ -986,13 +986,13 @@ static void save_by_fmt(struct GP_Context *bitmap, const char *name, const char
ret = GP_SaveJPG(bitmap, name, progress_callback);
else if (!strcmp(fmt, "png"))
ret = GP_SavePNG(bitmap, name, progress_callback);
-
+
if (ret) {
fprintf(stderr, "Failed to save bitmap: %sn",
strerror(errno));
exit(1);
}
-
+
if (progress_callback != NULL)
fprintf(stderr, " donen");
}
@@ -1048,7 +1048,7 @@ int main(int argc, char *argv[])
for (i = optind; i < argc; i++) {
char buf[255];
-
+
snprintf(buf, sizeof(buf), "out_%03i.%s", i - optind + 1, out_fmt);
fprintf(stderr, "Processing '%s' -> '%s'n", argv[i], buf);
@@ -1058,7 +1058,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Failed to load bitmap: %sn", strerror(errno));
return 1;
}
-
+
if (progress_callback != NULL)
fprintf(stderr, " donen");
@@ -1066,6 +1066,6 @@ int main(int argc, char *argv[])
save_by_fmt(bitmap, buf, out_fmt);
}
-
+
return 0;
}
diff --git a/demos/grinder/histogram.c b/demos/grinder/histogram.c
index ab6929a..00bffbd 100644
--- a/demos/grinder/histogram.c
+++ b/demos/grinder/histogram.c
@@ -25,31 +25,31 @@
void histogram_to_png(const GP_Context *src, const char *filename)
{
GP_FILTER_PARAMS(src->pixel_type, params);
-
+
GP_FilterHistogramAlloc(src->pixel_type, params);
GP_FilterHistogram(src, params, NULL);
unsigned int i, j;
GP_Context *res = GP_ContextAlloc(257*4, 256, GP_PIXEL_RGB888);
-
+
GP_Fill(res, 0xffffff);
GP_Histogram *hist_r;
hist_r = (GP_FilterParamChannel(params, "R"))->val.ptr;
-
+
for (i = 0; i < hist_r->len; i++)
GP_VLineXYH(res, i, 256, -255.00 * hist_r->hist[i] / hist_r->max + 0.5 , 0xff0000);
-
+
GP_Histogram *hist_g;
hist_g = (GP_FilterParamChannel(params, "G"))->val.ptr;
-
+
for (i = 0; i < hist_g->len; i++)
GP_VLineXYH(res, i+257, 256, -255.00 * hist_g->hist[i] / hist_g->max + 0.5 , 0x00ff00);
-
+
GP_Histogram *hist_b;
hist_b = (GP_FilterParamChannel(params, "B"))->val.ptr;
-
+
for (i = 0; i < hist_b->len; i++)
GP_VLineXYH(res, i+514, 256, -255.00 * hist_b->hist[i] / hist_b->max + 0.5 , 0x0000ff);
@@ -60,10 +60,10 @@ void histogram_to_png(const GP_Context *src, const char *filename)
for (i = 0; i < hist_r->len; i++) {
for (j = 0; j < hist_r->len; j++) {
GP_Pixel pix = 0;
-
+
if (255 * hist_r->hist[i] / max + 0.5 > j)
pix |= 0xff0000;
-
+
if (255 * hist_g->hist[i] / max + 0.5 > j)
pix |= 0x00ff00;
diff --git a/demos/grinder/params.c b/demos/grinder/params.c
index 6d2b1aa..3f39a36 100644
--- a/demos/grinder/params.c
+++ b/demos/grinder/params.c
@@ -103,7 +103,7 @@ static unsigned int count_params(const char *params)
char prev = ':';
for (i = 0; params[i] != '0'; i++) {
-
+
if (params[i] == ':' && prev != ':')
ret++;
@@ -119,7 +119,7 @@ static void split_params(char *params, char **names)
char prev = ':';
for (i = 0; params[i] != '0'; i++) {
-
+
if (params[i] != ':' && prev == ':')
names[n++] = ¶ms[i];
@@ -137,7 +137,7 @@ static void do_split(char *param, char **value)
*value = NULL;
for (i = 0; param[i] != '0'; i++) {
-
+
if (param[i] == '=' || isspace(param[i])) {
param[i] = '0';
*value = ¶m[i+1];
@@ -206,7 +206,7 @@ int set_bool(int *res, char *val)
*res = 0;
return 0;
}
-
+
for (i = 0; bool_true[i] != NULL; i++)
if (!strcasecmp(val, bool_true[i])) {
*res = 1;
@@ -229,7 +229,7 @@ int set_float(float *res, char *val)
if (errno != 0)
return 1;
-
+
*res = d;
return 0;
@@ -272,7 +272,7 @@ int param_parse(const char *params, const struct param *param_desc, void *priv,
if (params == NULL || *params == '0')
return 0;
-
+
par = strdup(params);
if (par == NULL) {
@@ -290,7 +290,7 @@ int param_parse(const char *params, const struct param *param_desc, void *priv,
split_params(par, names);
split_values(names, values, n);
-
+
va_start(va, err);
for (i = 0; param_desc[i].name != NULL; i++) {
@@ -298,12 +298,12 @@ int param_parse(const char *params, const struct param *param_desc, void *priv,
int pos = 0;
while ((pos = param_pos(names, param_desc[i].name, pos, n)) >= 0) {
-
+
if (values[pos] == NULL || *values[pos] == '0') {
CALL_ERR_CALLBACK(err, ¶m_desc[i], "", priv);
goto err;
}
-
+
flags[pos]++;
switch (param_desc[i].type) {
diff --git a/demos/grinder/params.h b/demos/grinder/params.h
index f726282..04fe00f 100644
--- a/demos/grinder/params.h
+++ b/demos/grinder/params.h
@@ -45,7 +45,7 @@ const char *param_type_name(enum param_type type);
void param_describe(const struct param *param_desc, const char *prefix);
-int param_parse(const char *params, const struct param *param_desc, void *priv,
+int param_parse(const char *params, const struct param *param_desc, void *priv,
int (*err)(const struct param *self, const char *val, void *priv), ...);
#endif /* PARAMS_H */
diff --git a/demos/particle/particle_demo.c b/demos/particle/particle_demo.c
index 9b708c5..6fcc11d 100644
--- a/demos/particle/particle_demo.c
+++ b/demos/particle/particle_demo.c
@@ -43,7 +43,7 @@ static void sighandler(int signo)
{
if (backend != NULL)
GP_BackendExit(backend);
-
+
fprintf(stderr, "Got signal %in", signo);
exit(1);
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Invalid paramter '%c'n", opt);
}
}
-
+
// GP_SetDebugLevel(10);
signal(SIGINT, sighandler);
@@ -85,7 +85,7 @@ int main(int argc, char *argv[])
init_backend(backend_opts);
context = backend->context;
-
+
black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context);
white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, context);
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
while (GP_BackendGetEvent(backend, &ev)) {
GP_EventDump(&ev);
-
+
switch (ev.type) {
case GP_EV_KEY:
if (ev.code != GP_EV_KEY_DOWN)
@@ -133,7 +133,7 @@ int main(int argc, char *argv[])
break;
}
}
-
+
if (!pause_flag) {
space_time_tick(space, 1);
space_draw_particles(context, space);
diff --git a/demos/particle/space.c b/demos/particle/space.c
index 928798a..c53b9e3 100644
--- a/demos/particle/space.c
+++ b/demos/particle/space.c
@@ -40,7 +40,7 @@ struct space *space_create(unsigned int particle_count, int min_w, int min_h,
new->gax = 0;
new->gay = 0;
-
+
new->elasticity = (1<<8) - (1<<6);
new->mass_kappa = 1<<1;
@@ -70,12 +70,12 @@ void space_destroy(struct space *space)
void space_draw_particles(GP_Context *context, struct space *space)
{
unsigned int i;
-
+
GP_Fill(context, 0x000000);
for (i = 0; i < space->particle_count; i++) {
GP_Pixel color;
-
+
GP_Coord x = space->particles[i].x;
GP_Coord y = space->particles[i].y;
GP_Coord a1 = GP_FP_1 * 4;
@@ -89,7 +89,7 @@ void space_draw_particles(GP_Context *context, struct space *space)
*/
color = GP_RGBToContextPixel(0xee, 0xee, 0xee, context);
-
+
GP_PutPixelAA(context, x, y, color);
int val = SQUARE(space->particles[i].vx) + SQUARE(space->particles[i].vy);
@@ -110,19 +110,19 @@ void space_draw_particles(GP_Context *context, struct space *space)
// GP_LineAA(context, x - a2, y + a1, x - a1, y + a2, color);
GP_LineAA(context, x - a1, y + a2, x - a1, y - a2, color);
// GP_LineAA(context, x - a1, y - a2, x - a2, y - a1, color);
-/*
+/*
GP_PutPixelAA(context, x + a2, y - a1, 0xffffff);
GP_PutPixelAA(context, x + a1, y - a2, 0xffffff);
GP_PutPixelAA(context, x + a1, y + a2, 0xffffff);
GP_PutPixelAA(context, x + a2, y + a1, 0xffffff);
-
+
GP_PutPixelAA(context, x - a2, y + a1, 0xffffff);
GP_PutPixelAA(context, x - a1, y + a2, 0xffffff);
-
+
GP_PutPixelAA(context, x - a1, y - a2, 0xffffff);
GP_PutPixelAA(context, x - a2, y - a1, 0xffffff);
-*/
+*/
}
}
@@ -130,9 +130,9 @@ static void central_gravity(struct space *space, int time)
{
unsigned int i;
- for (i = 0; i < space->particle_count; i++) {
- space->particles[i].vx += space->gax * time;
- space->particles[i].vy += space->gay * time;
+ for (i = 0; i < space->particle_count; i++) {
+ space->particles[i].vx += space->gax * time;
+ space->particles[i].vy += space->gay * time;
}
}
@@ -161,7 +161,7 @@ static void gravity_forces(struct space *space, int time)
int a = GP_FP_DIV(space->mass_kappa, dist_squared) * time;
space->particles[i].vx -= (a * dist_x) / dist;
- space->particles[i].vy -= (a * dist_y) / dist;
+ space->particles[i].vy -= (a * dist_y) / dist;
}
}
@@ -177,11 +177,11 @@ void space_time_tick(struct space *space, int time)
if ((space->particles[i].x < space->min_w && space->particles[i].vx < 0) ||
(space->particles[i].x >= space->max_w && space->particles[i].vx > 0))
space->particles[i].vx = GP_FP_MUL(space->particles[i].vx, -space->elasticity);
-
+
if ((space->particles[i].y < space->min_h && space->particles[i].vy < 0) ||
(space->particles[i].y >= space->max_h && space->particles[i].vy > 0))
space->particles[i].vy = GP_FP_MUL(space->particles[i].vy, -space->elasticity);
-
+
space->particles[i].x += space->particles[i].vx * time;
space->particles[i].y += space->particles[i].vy * time;
}
diff --git a/demos/particle/space.h b/demos/particle/space.h
index 9b58037..7878b11 100644
--- a/demos/particle/space.h
+++ b/demos/particle/space.h
@@ -47,7 +47,7 @@ struct space {
/* space is an rectanle */
int min_w;
int min_h;
-
+
int max_w;
int max_h;
diff --git a/demos/py_simple/blit.py b/demos/py_simple/blit.py
index 14fa361..2b3a694 100755
--- a/demos/py_simple/blit.py
+++ b/demos/py_simple/blit.py
@@ -51,7 +51,7 @@ def main():
# Load Backgroudn Image and ball sprite
bg = loaders.Load(sys.argv[1])
assert(bg)
-
+
ball1 = Ball(bg.w//2, bg.h//2, -3, -3, 'ball_red.png', bg)
ball2 = Ball(bg.w//2, bg.h//2, -2, 3, 'ball_green.png', bg)
ball3 = Ball(bg.w//2, bg.h//2, 2, -3, 'ball_blue.png', bg)
@@ -65,7 +65,7 @@ def main():
# Event loop
while True:
-
+
while True:
ev = bk.PollEvent()
@@ -79,7 +79,7 @@ def main():
elif (ev.type == input.EV_SYS):
if (ev.code == input.EV_SYS_QUIT):
sys.exit(0)
-
+
sleep(0.005)
ball1.move(bk);
diff --git a/demos/py_simple/cam_view.py b/demos/py_simple/cam_view.py
index 4159609..6692abb 100755
--- a/demos/py_simple/cam_view.py
+++ b/demos/py_simple/cam_view.py
@@ -32,7 +32,7 @@ def main():
if (ev is None):
continue
-
+
input.EventDump(ev)
if (ev.type == input.EV_KEY):
diff --git a/demos/py_simple/gfx.py b/demos/py_simple/gfx.py
index 9d82a1b..81d78b3 100755
--- a/demos/py_simple/gfx.py
+++ b/demos/py_simple/gfx.py
@@ -103,33 +103,33 @@ def polygon(bk):
bk.Flip()
def next(bk, i):
-
+
if (i == 0):
fill(bk)
if (i == 1):
hline(bk)
-
+
if (i == 2):
vline(bk)
-
+
if (i == 3):
line(bk)
-
+
if (i == 4):
rect(bk)
if (i == 5):
- triangle(bk)
-
+ triangle(bk)
+
if (i == 6):
- tetragon(bk)
+ tetragon(bk)
if (i == 7):
polygon(bk)
i = i + 1;
-
+
if (i >= 8):
i = 0
diff --git a/demos/py_simple/progress_callback.py b/demos/py_simple/progress_callback.py
index 4055f1a..f712faf 100755
--- a/demos/py_simple/progress_callback.py
+++ b/demos/py_simple/progress_callback.py
@@ -26,8 +26,8 @@ def main():
exit(1)
try:
- img = filters.FilterGaussianBlurAlloc(img, 50, 50, callback)
- print('')
+ img = filters.FilterGaussianBlurAlloc(img, 50, 50, callback)
+ print('')
except OSError:
print("Filter Aborted")
diff --git a/demos/py_simple/pygtk_example.py b/demos/py_simple/pygtk_example.py
index e2ef4a0..e7b1643 100755
--- a/demos/py_simple/pygtk_example.py
+++ b/demos/py_simple/pygtk_example.py
@@ -23,13 +23,13 @@ class HelloWorld:
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_border_width(1)
-
+
self.image = gtk.Image();
self.window.add(self.image)
-
+
self.window.show()
self.image.show()
-
+
img = loaders.LoadImage(sys.argv[2], None)
self.pixmap = gtk.gdk.Pixmap(None, img.w, img.h, 24)
self.gc = gtk.gdk.Drawable.new_gc(self.pixmap)
diff --git a/demos/py_simple/x11_windows.py b/demos/py_simple/x11_windows.py
index 1766087..133be6e 100755
--- a/demos/py_simple/x11_windows.py
+++ b/demos/py_simple/x11_windows.py
@@ -18,11 +18,11 @@ def redraw(bk, id):
align = text.C.ALIGN_CENTER | text.C.VALIGN_CENTER
c.text.Text(None, c.w//2, c.h//2, align, white, black, "%s - %sx%s" % (id, c.w, c.h))
-
+
bk.Flip()
def parse_events(bk, id):
-
+
print("------ Window %s -------" % (id))
while True:
diff --git a/demos/spiv/cpu_timer.c b/demos/spiv/cpu_timer.c
index 6c26d61..2071ada 100644
--- a/demos/spiv/cpu_timer.c
+++ b/demos/spiv/cpu_timer.c
@@ -38,7 +38,7 @@ static void to_time(int *sec, int *nsec, struct timespec *start,
void cpu_timer_start(struct cpu_timer *self, const char *name)
{
self->name = name;
-
+
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &self->t_cpu_start);
clock_gettime(CLOCK_MONOTONIC, &self->t_real_start);
}
diff --git a/demos/spiv/image_actions.c b/demos/spiv/image_actions.c
index de35255..b153af4 100644
--- a/demos/spiv/image_actions.c
+++ b/demos/spiv/image_actions.c
@@ -143,7 +143,7 @@ static size_t get_name_ext(const char *path,
*extension = NULL;
for (i = len; i > 0; i--) {
-
+
if (*extension)
name_len++;
@@ -222,7 +222,7 @@ static int cmd_append(const char *str, size_t len)
if (cmd_size - cmd_pos <= len) {
char *new_cmd = realloc(cmd, cmd_size + 1024);
-
+
if (new_cmd == NULL) {
fprintf(stderr, "Failed to allocated command buffern");
return 1;
@@ -245,7 +245,7 @@ static int cmd_append_escape(const char *str, size_t len)
while ((ret = escape(str, len, cmd + cmd_pos, cmd_size - cmd_pos)) < 0) {
char *new_cmd = realloc(cmd, cmd_size + 1024);
-
+
if (new_cmd == NULL) {
fprintf(stderr, "Failed to allocated command buffern");
return 1;
@@ -283,7 +283,7 @@ static int prepare_cmd(unsigned int action, const char *img_path)
if (cmd_append(prev, len - 1))
return 1;
-
+
switch (actions[action]->params[i].type) {
case 'f':
cmd_append(img_path, 0);
diff --git a/demos/spiv/image_actions.h b/demos/spiv/image_actions.h
index b03fbb1..efff308 100644
--- a/demos/spiv/image_actions.h
+++ b/demos/spiv/image_actions.h
@@ -40,6 +40,6 @@
void image_action_set(unsigned int action, const char *cmd);
-int image_action_run(unsigned int action, const char *img_path);
+int image_action_run(unsigned int action, const char *img_path);
#endif /* __IMAGE_ACTIONS_H__ */
diff --git a/demos/spiv/image_cache.c b/demos/spiv/image_cache.c
index 496489e..22f3b70 100644
--- a/demos/spiv/image_cache.c
+++ b/demos/spiv/image_cache.c
@@ -42,7 +42,7 @@ struct image {
struct image_cache {
unsigned int max_size;
unsigned int cur_size;
-
+
struct image *root;
struct image *end;
};
@@ -126,7 +126,7 @@ static void remove_img_free(struct image_cache *self,
{
GP_DEBUG(2, "Freeing image '%s:%10li:%10li' size %zu",
img->path, img->cookie1, img->cookie2, size);
-
+
remove_img(self, img, size);
GP_ContextFree(img->ctx);
free(img);
@@ -138,10 +138,10 @@ static void remove_img_free(struct image_cache *self,
static void add_img(struct image_cache *self, struct image *img, size_t size)
{
img->next = self->root;
-
+
if (img->next)
img->next->prev = img;
-
+
img->prev = NULL;
self->root = img;
@@ -155,7 +155,7 @@ GP_Context *image_cache_get(struct image_cache *self, const char *path,
long cookie1, long cookie2, int elevate)
{
struct image *i;
-
+
if (self == NULL)
return NULL;
@@ -165,7 +165,7 @@ GP_Context *image_cache_get(struct image_cache *self, const char *path,
if (!strcmp(path, i->path) &&
i->cookie1 == cookie1 && i->cookie2 == cookie2)
break;
-
+
if (i == NULL)
return NULL;
@@ -175,10 +175,10 @@ GP_Context *image_cache_get(struct image_cache *self, const char *path,
GP_DEBUG(2, "Refreshing image '%s:%10li:%10li",
path, cookie1, cookie2);
-
+
remove_img(self, i, size);
add_img(self, i, size);
-
+
i->elevated++;
}
@@ -207,7 +207,7 @@ static int assert_size(struct image_cache *self, size_t size)
return 0;
while (self->cur_size + size > self->max_size) {
-
+
if (self->end == NULL) {
GP_WARN("Cache too small for image size %zu", size);
return 1;
@@ -223,13 +223,13 @@ int image_cache_put(struct image_cache *self, GP_Context *ctx, const char *path,
long cookie1, long cookie2)
{
size_t size;
-
+
if (self == NULL)
return 1;
-
+
size = image_size2(ctx, path);
- /*
+ /*
* We try to create room for the image. If this fails we add the image
* anyway because we need to store it while we are showing it (and it
* will be removed from cache by next image for sure).
@@ -242,13 +242,13 @@ int image_cache_put(struct image_cache *self, GP_Context *ctx, const char *path,
GP_WARN("Malloc failed :(");
return 1;
}
-
+
img->ctx = ctx;
img->cookie1 = cookie1;
img->cookie2 = cookie2;
img->elevated = 0;
strcpy(img->path, path);
-
+
GP_DEBUG(2, "Adding image '%s:%10li:%10li' size %zu",
img->path, img->cookie1, img->cookie2, size);
@@ -261,9 +261,9 @@ void image_cache_drop(struct image_cache *self)
{
if (self == NULL)
return;
-
+
GP_DEBUG(1, "Dropping images in cache");
-
+
while (self->end != NULL)
remove_img_free(self, self->end, 0);
@@ -279,6 +279,6 @@ void image_cache_destroy(struct image_cache *self)
while (self->end != NULL)
remove_img_free(self, self->end, 0);
-
+
free(self);
}
diff --git a/demos/spiv/image_cache.h b/demos/spiv/image_cache.h
index 023ccd8..1c03545 100644
--- a/demos/spiv/image_cache.h
+++ b/demos/spiv/image_cache.h
@@ -43,7 +43,7 @@ struct image_cache *image_cache_create(unsigned int max_size_bytes);
/*
* Returns cached image, or NULL.
- *
+ *
* If elevate set and image is found, the image is elevated to the top so
* it has lesser chance of being freed.
*/
@@ -54,7 +54,7 @@ GP_Context *image_cache_get(struct image_cache *self, const char *path,
* Puts an image into a cache.
*/
int image_cache_put(struct image_cache *self, GP_Context *img,
- const char *path, long cookie1, long cookie2);
+ const char *path, long cookie1, long cookie2);
/*
* Drop all image in cache.
diff --git a/demos/spiv/image_list.c b/demos/spiv/image_list.c
index 042ef4b..afaff25 100644
--- a/demos/spiv/image_list.c
+++ b/demos/spiv/image_list.c
@@ -44,7 +44,7 @@ struct image_list {
/* path to the currently loaded image */
char path[1024];
int path_loaded:1;
-
+
/* directory handling */
int in_dir:1;
@@ -63,17 +63,17 @@ static int dir_filter(const struct dirent *d)
/* Ignore some filenames */
if (!strcmp(d->d_name, "."))
return 0;
-
+
if (!strcmp(d->d_name, ".."))
return 0;
-
+
//TODO: filter out directories
-
+
if (GP_MatchExtension(d->d_name) == NULL)
return 0;
GP_DEBUG(4, "Adding file '%s'", d->d_name);
-
+
return 1;
}
@@ -100,7 +100,7 @@ static void try_load_dir(struct image_list *self)
GP_WARN("Failed to scandir '%s': %s", path, strerror(errno));
return;
}
-
+
if (self->arg_file_counts[self->cur_arg] != ret) {
GP_DEBUG(1, "Updating arg counter to %i", ret);
self->arg_file_counts[self->cur_arg] = ret;
@@ -125,7 +125,7 @@ static void exit_dir(struct image_list *self)
for (i = 0; i < self->max_file; i++)
free(self->dir_files[i]);
-
+
free(self->dir_files);
self->in_dir = 0;
@@ -141,10 +141,10 @@ static void next_img(struct image_list *self)
return;
}
}
-
+
if (++self->cur_arg == self->max_arg)
self->cur_arg = 0;
-
+
try_load_dir(self);
self->path_loaded = 0;
@@ -202,7 +202,7 @@ static void set_dir_cur_img(struct image_list *self, int img)
/*
* Returns current argument from arg list we are in.
- *
+ *
* Either it's image file or directory.
*/
static const char *cur_arg(struct image_list *self)
@@ -297,14 +297,14 @@ const char *image_list_dir_move(struct image_list *self, int direction)
set_dir_cur_img(self, 0);
}
}
-
+
return image_list_img_path(self);
}
const char *image_list_first(struct image_list *self)
{
GP_DEBUG(2, "Moving to the first image in the list");
-
+
set_cur_arg(self, 0);
if (self->in_dir)
@@ -336,7 +336,7 @@ static unsigned int count_img_to(struct image_list *self, unsigned int arg_to)
if (self->arg_file_counts[i] == -1)
set_cur_arg(self, i);
- /*
+ /*
* if the counter is still at -1
* directory couldn't be loaded
*/
@@ -346,7 +346,7 @@ static unsigned int count_img_to(struct image_list *self, unsigned int arg_to)
/* restore the original position */
set_cur_arg(self, cur_arg);
-
+
if (self->in_dir)
set_dir_cur_img(self, cur_file);
@@ -386,7 +386,7 @@ struct image_list *image_list_create(const char *args[])
unsigned int i;
GP_DEBUG(1, "Creating image list");
-
+
self = malloc(sizeof(struct image_list));
if (self == NULL) {
@@ -396,9 +396,9 @@ struct image_list *image_list_create(const char *args[])
self->args = args;
self->cur_arg = 0;
-
+
self->path_loaded = 0;
-
+
self->dir_files = 0;
self->in_dir = 0;
@@ -426,7 +426,7 @@ const char *image_list_img_path(struct image_list *self)
{
if (!self->path_loaded)
load_path(self);
-
+
GP_DEBUG(2, "Returning path '%s'", self->path);
return self->path;
diff --git a/demos/spiv/image_list.h b/demos/spiv/image_list.h
index 17f21d0..54dbfab 100644
--- a/demos/spiv/image_list.h
+++ b/demos/spiv/image_list.h
@@ -51,18 +51,18 @@ const char *image_list_move(struct image_list *self, int direction);
* If we are in directory:
* if direction > 0: move to its end and if allready there, to the next arg
* if direction < 0: move to its begining and if allready there, to the previous arg
- *
+ *
* If we aren't in directory move by one in corresponding direction.
*/
const char *image_list_dir_move(struct image_list *self, int direction);
/*
- * Move to the first image in the list.
+ * Move to the first image in the list.
*/
const char *image_list_first(struct image_list *self);
/*
- * Move to the last image in the list.
+ * Move to the last image in the list.
*/
const char *image_list_last(struct image_list *self);
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 11b8f4b..9b34c35 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -52,17 +52,17 @@ static int abort_flag = 0;
static int show_progress = 0;
enum zoom_type {
- /*
+ /*
* Resize image to fit current size of the window.
*/
ZOOM_FIT,
-
- /*
+
+ /*
* Use zoom set in zoom float and zoom offsets.
*/
ZOOM_FIXED,
-
- /*
+
+ /*
* Fixed zoom but spiv tries to change
* the window size to fit the image size
*/
@@ -100,10 +100,10 @@ struct loader_params {
/* offset in pixels */
unsigned int zoom_x_offset;
unsigned int zoom_y_offset;
-
+
/* zoom */
enum zoom_type zoom_type;
- float zoom;
+ float zoom;
/* caches for loaded images */
struct image_cache *img_resized_cache;
@@ -130,7 +130,7 @@ static int image_loader_callback(GP_ProgressCallback *self)
(const char*)self->priv, self->percentage);
int align = GP_ALIGN_CENTER|GP_VALIGN_ABOVE;
-
+
size = GP_TextWidth(NULL, buf);
int start = c->w/2 - size/2 - 10;
@@ -177,7 +177,7 @@ static float calc_img_size(struct loader_params *params,
{
float w_rat;
float h_rat;
-
+
switch (params->zoom_type) {
case ZOOM_FIT_DOWNSCALE:
if (img_w <= src_w && img_h <= src_h)
@@ -224,7 +224,7 @@ static GP_Context *load_image(struct loader_params *params, int elevate)
{
struct cpu_timer timer;
GP_Context *img, *context = backend->context;
-
+
GP_ProgressCallback callback = {.callback = image_loader_callback,
.priv = "Loading image"};
@@ -236,7 +236,7 @@ static GP_Context *load_image(struct loader_params *params, int elevate)
cpu_timer_start(&timer, "Loading");
if ((img = GP_LoadImage(params->img_path, &callback)) == NULL) {
-
+
if (errno == ECANCELED)
return NULL;
@@ -245,12 +245,12 @@ static GP_Context *load_image(struct loader_params *params, int elevate)
GP_ALIGN_CENTER|GP_VALIGN_CENTER, white_pixel, black_pixel,
"'%s'", params->img_path);
GP_Print(context, NULL, context->w/2, context->h/2 + 10,
- GP_ALIGN_CENTER|GP_VALIGN_CENTER, white_pixel, black_pixel,
+ GP_ALIGN_CENTER|GP_VALIGN_CENTER, white_pixel, black_pixel,
"Failed to load image :( (%s)", strerror(errno));
GP_BackendFlip(backend);
return NULL;
}
-
+
/* Workaround */
// if (img->pixel_type != GP_PIXEL_RGB888) {
// GP_Context *tmp;
@@ -260,11 +260,11 @@ static GP_Context *load_image(struct loader_params *params, int elevate)
// }
image_cache_put(params->img_orig_cache, img, params->img_path, 0, 0);
-
+
cpu_timer_stop(&timer);
}
- return img;
+ return img;
}
/*
@@ -321,7 +321,7 @@ static void update_display(struct loader_params *params, GP_Context *img)
img = GP_FilterRotate270Alloc(img, &callback);
break;
}
-
+
if (img == NULL)
return;
@@ -344,7 +344,7 @@ static void update_display(struct loader_params *params, GP_Context *img)
GP_Context sub_display;
cpu_timer_start(&timer, "Blitting");
-
+
if (params->use_dithering) {
callback.priv = "Dithering";
GP_SubContext(context, &sub_display, cx, cy, img->w, img->h);
@@ -356,18 +356,18 @@ static void update_display(struct loader_params *params, GP_Context *img)
GP_Blit_Clipped(img, 0, 0, img->w, img->h, context, cx, cy);
}
-
+
cpu_timer_stop(&timer);
-
+
if (params->rotate)
GP_ContextFree(img);
-
+
/* clean up the rest of the display */
GP_FillRectXYWH(context, 0, 0, cx, context->h, black_pixel);
GP_FillRectXYWH(context, 0, 0, context->w, cy, black_pixel);
-
+
int w = context->w - img->w - cx;
-
+
if (w > 0)
GP_FillRectXYWH(context, img->w + cx, 0, w, context->h, black_pixel);
@@ -375,8 +375,8 @@ static void update_display(struct loader_params *params, GP_Context *img)
if (h > 0)
GP_FillRectXYWH(context, 0, img->h + cy, context->w, h, black_pixel);
-
- set_caption(params->img_path, params->rat);
+
+ set_caption(params->img_path, params->rat);
if (!params->show_info) {
GP_BackendFlip(backend);
@@ -384,53 +384,53 @@ static void update_display(struct loader_params *params, GP_Context *img)
}
GP_Size th = GP_TextHeight(NULL);
-
+
GP_Print(context, NULL, 11, 11, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
black_pixel, white_pixel, "%ux%u", img->w, img->h);
-
+
GP_Print(context, NULL, 10, 10, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
white_pixel, black_pixel, "%ux%u", img->w, img->h);
-
+
GP_Print(context, NULL, 11, 13 + th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
black_pixel, white_pixel, "1:%3.3f", params->rat);
-
+
GP_Print(context, NULL, 10, 12 + th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
white_pixel, black_pixel, "1:%3.3f", params->rat);
-
+
GP_Print(context, NULL, 11, 15 + 2 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
black_pixel, white_pixel, "%s", img_name(params->img_path));
-
+
GP_Print(context, NULL, 10, 14 + 2 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
white_pixel, black_pixel, "%s", img_name(params->img_path));
-
+
GP_Print(context, NULL, 11, 17 + 3 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
black_pixel, white_pixel, "%s%s",
params->use_low_pass && params->rat < 1 ? "Gaussian LP + " : "",
GP_InterpolationTypeName(params->resampling_method));
-
+
GP_Print(context, NULL, 10, 16 + 3 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- white_pixel, black_pixel, "%s%s",
+ white_pixel, black_pixel, "%s%s",
params->use_low_pass && params->rat < 1 ? "Gaussian LP + " : "",
GP_InterpolationTypeName(params->resampling_method));
unsigned int count = image_list_count(params->img_list);
unsigned int pos = image_list_pos(params->img_list) + 1;
-
+
GP_Print(context, NULL, 11, 19 + 4 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
black_pixel, white_pixel, "%u of %u", pos, count);
-
+
GP_Print(context, NULL, 10, 18 + 4 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- white_pixel, black_pixel, "%u of %u", pos, count);
-
+ white_pixel, black_pixel, "%u of %u", pos, count);
+
unsigned int dir_count = image_list_dir_count(params->img_list);
unsigned int dir_pos = image_list_dir_pos(params->img_list) + 1;
if (dir_count > 1 && dir_count != count) {
GP_Print(context, NULL, 11, 21 + 5 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- black_pixel, white_pixel, "%u of %u in directory", dir_pos, dir_count);
-
+ black_pixel, white_pixel, "%u of %u in directory", dir_pos, dir_count);
+
GP_Print(context, NULL, 10, 20 + 5 * th, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
- white_pixel, black_pixel, "%u of %u in directory", dir_pos, dir_count);
+ white_pixel, black_pixel, "%u of %u in directory", dir_pos, dir_count);
}
GP_BackendFlip(backend);
@@ -442,7 +442,7 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size
GP_Context *img, *res = NULL;
struct cpu_timer timer;
GP_ProgressCallback callback = {.callback = image_loader_callback};
-
+
int key = (params->resampling_method<<1) | !!(params->use_low_pass);
/* Try to get resized cached image */
@@ -450,7 +450,7 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size
if (img != NULL)
return img;
-
+
/* Otherwise load image and resize it */
if ((img = load_image(params, 1)) == NULL)
return NULL;
@@ -468,18 +468,18 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size
if (params->use_low_pass && params->rat < 1) {
cpu_timer_start(&timer, "Blur");
callback.priv = "Blurring Image";
-
+
res = GP_FilterGaussianBlurAlloc(img, 0.3/params->rat,
0.3/params->rat, &callback);
if (res == NULL)
return NULL;
-
+
img = res;
-
+
cpu_timer_stop(&timer);
}
-
+
// img->gamma = GP_GammaAcquire(img->pixel_type, 0.45);
cpu_timer_start(&timer, "Resampling");
@@ -510,7 +510,7 @@ GP_Context *load_resized_image(struct loader_params *params, GP_Size w, GP_Size
return NULL;
image_cache_put(params->img_resized_cache, img, params->img_path, cookie, key);
-
+
return img;
}
@@ -521,7 +521,7 @@ static void *image_loader(void *ptr)
GP_Context *img, *context = backend->context;
cpu_timer_start(&sum_timer, "sum");
-
+
show_progress = params->show_progress || params->show_progress_once;
params->show_progress_once = 0;
@@ -565,7 +565,7 @@ static void *image_loader(void *ptr)
update:
update_display(params, img);
cpu_timer_stop(&sum_timer);
-
+
return NULL;
}
@@ -617,7 +617,7 @@ static void sighandler(int signo)
{
if (backend != NULL)
GP_BackendExit(backend);
-
+
fprintf(stderr, "Got signal %in", signo);
_exit(1);
@@ -625,8 +625,8 @@ static void sighandler(int signo)
static void init_backend(const char *backend_opts)
{
- backend = GP_BackendInit(backend_opts, "Spiv", stderr);
-
+ backend = GP_BackendInit(backend_opts, "Spiv", stderr);
+
if (backend == NULL) {
fprintf(stderr, "Failed to initalize backend '%s'n", backend_opts);
exit(1);
@@ -675,8 +675,8 @@ int main(int argc, char *argv[])
GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
struct loader_params params = {
- .img_path = NULL,
-
+ .img_path = NULL,
+
.show_progress = 0,
.show_progress_once = 0,
.show_info = 0,
@@ -767,7 +767,7 @@ int main(int argc, char *argv[])
signal(SIGSEGV, sighandler);
signal(SIGBUS, sighandler);
signal(SIGABRT, sighandler);
-
+
init_caches(¶ms);
init_backend(backend_opts);
@@ -801,10 +801,10 @@ int main(int argc, char *argv[])
GP_Event ev;
while (GP_BackendGetEvent(backend, &ev)) {
-
+
shift_flag = GP_EventGetKey(&ev, GP_KEY_LEFT_SHIFT) ||
GP_EventGetKey(&ev, GP_KEY_RIGHT_SHIFT);
-
+
switch (ev.type) {
case GP_EV_REL:
switch (ev.code) {
@@ -838,7 +838,7 @@ int main(int argc, char *argv[])
break;
case GP_KEY_I:
params.show_info = !params.show_info;
-
+
params.show_progress_once = 1;
show_image(¶ms, NULL);
break;
@@ -849,7 +849,7 @@ int main(int argc, char *argv[])
params.rotate += 90;
if (params.rotate > 270)
params.rotate = 0;
-
+
params.show_progress_once = 1;
show_image(¶ms, NULL);
break;
@@ -858,7 +858,7 @@ int main(int argc, char *argv[])
if (params.resampling_method > GP_INTERP_MAX)
params.resampling_method = 0;
-
+
if (params.resampling_method == GP_INTERP_LINEAR_LF_INT) {
params.use_low_pass = 0;
params.show_nn_first = 0;
@@ -875,7 +875,7 @@ int main(int argc, char *argv[])
params.resampling_method = GP_INTERP_MAX;
else
params.resampling_method--;
-
+
if (params.resampling_method == GP_INTERP_LINEAR_LF_INT) {
params.use_low_pass = 0;
params.show_nn_first = 0;
@@ -883,13 +883,13 @@ int main(int argc, char *argv[])
params.use_low_pass = 1;
params.show_nn_first = 1;
}
-
+
params.show_progress_once = 1;
show_image(¶ms, image_list_img_path(list));
break;
case GP_KEY_L:
params.use_low_pass = !params.use_low_pass;
-
+
params.show_progress_once = 1;
show_image(¶ms, image_list_img_path(list));
break;
@@ -926,7 +926,7 @@ int main(int argc, char *argv[])
set_zoom_offset(¶ms, 1, 0);
else
set_zoom_offset(¶ms, 10, 0);
-
+
break;
case GP_KEY_LEFT:
if (shift_flag)
diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c
index f8d3c40..4a80fd2 100644
--- a/demos/spiv/spiv_help.c
+++ b/demos/spiv/spiv_help.c
@@ -99,10 +99,10 @@ void print_help(void)
printf(" %%N shell escaped image filename without extensionn");
printf(" %%e current image file extensionn");
puts("n");
-
+
for (i = 0; i < keys_help_len; i++)
puts(keys_help[i]);
-
+
puts("");
printf("Some cool options to try:nn");
@@ -114,7 +114,7 @@ void print_help(void)
printf("truns spiv using X root window as backend windownn");
printf("spiv -b 'X11:CREATE_ROOT' [images]n");
printf("tSame as abowe but works in KDEn");
-
+
}
static int redraw_help(GP_Backend *backend, unsigned int loff, GP_Coord xoff)
@@ -131,7 +131,7 @@ static int redraw_help(GP_Backend *backend, unsigned int loff, GP_Coord xoff)
if (h + 2 >= (GP_Coord)c->h)
goto out;
-
+
GP_Print(c, NULL, 20 + 10 * xoff, h, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM,
white, black, "%s", keys_help[i]);
}
@@ -154,7 +154,7 @@ void draw_help(GP_Backend *backend)
for (;;) {
GP_Event ev;
-
+
while (GP_BackendWaitEvent(backend, &ev)) {
switch (ev.type) {
case GP_EV_KEY:
diff --git a/demos/ttf2img/ttf2img.c b/demos/ttf2img/ttf2img.c
index d027139..9bc4558 100644
--- a/demos/ttf2img/ttf2img.c
+++ b/demos/ttf2img/ttf2img.c
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
print_help(1);
GP_SetDebugLevel(debug_level);
-
+
GP_Context *context = GP_ContextAlloc(img_w, img_h, GP_PIXEL_RGB888);
GP_Pixel black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, context);
@@ -89,7 +89,7 @@ int main(int argc, char *argv[])
black_pixel, white_pixel, string);
GP_SavePNG(context, img_path, NULL);
-
+
GP_ContextFree(context);
return 0;
diff --git a/libs/filters/GP_LinearThreads.c b/libs/filters/GP_LinearThreads.c
index 554d492..218110b 100644
--- a/libs/filters/GP_LinearThreads.c
+++ b/libs/filters/GP_LinearThreads.c
@@ -89,7 +89,7 @@ int GP_FilterHConvolutionMP_Raw(const GP_ConvolutionParams *params)
convs[i].y_dst = y_dst_2;
convs[i].callback = params->callback ? &callback_mp : NULL;
- pthread_create(&threads[i], NULL, h_linear_convolution, &convs[i]);
+ pthread_create(&threads[i], NULL, h_linear_convolution, &convs[i]);
}
int ret = 0;
@@ -137,7 +137,7 @@ int GP_FilterVConvolutionMP_Raw(const GP_ConvolutionParams *params)
convs[i].y_dst = y_dst_2;
convs[i].callback = params->callback ? &callback_mp : NULL;
- pthread_create(&threads[i], NULL, v_linear_convolution, &convs[i]);
+ pthread_create(&threads[i], NULL, v_linear_convolution, &convs[i]);
}
int ret = 0;
@@ -184,7 +184,7 @@ int GP_FilterConvolutionMP_Raw(const GP_ConvolutionParams *params)
convs[i].y_dst = y_dst_2;
convs[i].callback = params->callback ? &callback_mp : NULL;
- pthread_create(&threads[i], NULL, linear_convolution, &convs[i]);
+ pthread_create(&threads[i], NULL, linear_convolution, &convs[i]);
}
int ret = 0;
http://repo.or.cz/w/gfxprim.git/commit/96bc5c8ddadbd2a8acd894f6c6d8f70779ed…
commit 96bc5c8ddadbd2a8acd894f6c6d8f70779ed7fd0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 28 01:15:44 2013 +0200
core: Straigten up the blit code a bit.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/core/GP_Blit.c b/libs/core/GP_Blit.c
index 1651ca9..cb8223e 100644
--- a/libs/core/GP_Blit.c
+++ b/libs/core/GP_Blit.c
@@ -17,16 +17,16 @@
* Boston, MA 02110-1301 USA *
* *
* Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
- * Copyright (C) 2011-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2011-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-#include "GP_Pixel.h"
-#include "GP_GetPutPixel.h"
-#include "GP_Context.h"
-#include "GP_Convert.h"
-#include "GP_Debug.h"
-#include "GP_Blit.h"
+#include "core/GP_Pixel.h"
+#include "core/GP_GetPutPixel.h"
+#include "core/GP_Context.h"
+#include "core/GP_Convert.h"
+#include "core/GP_Debug.h"
+#include "core/GP_Blit.h"
/* Generated functions */
void GP_BlitXYXY_Raw_Fast(const GP_Context *src,
@@ -37,25 +37,6 @@ void GP_BlitXYXY_Fast(const GP_Context *src,
GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
GP_Context *dst, GP_Coord x2, GP_Coord y2);
-/*
-void GP_BlitXYXY_Naive(const GP_Context *src,
- GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
- GP_Context *dst, GP_Coord x2, GP_Coord y2)
-{
- GP_Coord x, y;
-
- for (y = y0; y <= y1; y++)
- for (x = x0; x <= x1; x++) {
- GP_Pixel p = GP_GetPixel(src, x, y);
-
- if (src->pixel_type != dst->pixel_type)
- p = GP_ConvertContextPixel(p, src, dst);
-
- GP_PutPixel(dst, x2 + (x - x0), y2 + (y - y0), p);
- }
-}
-*/
-
void GP_BlitXYXY(const GP_Context *src,
GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
GP_Context *dst, GP_Coord x2, GP_Coord y2)
@@ -77,10 +58,7 @@ void GP_BlitXYXY(const GP_Context *src,
GP_CHECK(x2 + (x1 - x0) < (GP_Coord)GP_ContextW(dst));
GP_CHECK(y2 + (y1 - y0) < (GP_Coord)GP_ContextH(dst));
- if (GP_ContextRotationEqual(src, dst))
- GP_BlitXYXY_Raw_Fast(src, x0, y0, x1, y1, dst, x2, y2);
- else
- GP_BlitXYXY_Fast(src, x0, y0, x1, y1, dst, x2, y2);
+ GP_BlitXYXY_Fast(src, x0, y0, x1, y1, dst, x2, y2);
}
void GP_BlitXYXY_Clipped(const GP_Context *src,
@@ -138,10 +116,7 @@ void GP_BlitXYXY_Clipped(const GP_Context *src,
x0, y0, x1, y1, GP_ContextW(src), GP_ContextH(src),
x2, y2, GP_ContextW(dst), GP_ContextH(dst));
- if (GP_ContextRotationEqual(src, dst))
- GP_BlitXYXY_Raw_Fast(src, x0, y0, x1, y1, dst, x2, y2);
- else
- GP_BlitXYXY_Fast(src, x0, y0, x1, y1, dst, x2, y2);
+ GP_BlitXYXY_Fast(src, x0, y0, x1, y1, dst, x2, y2);
}
void GP_BlitXYWH(const GP_Context *src,
diff --git a/libs/core/GP_Blit.gen.c.t b/libs/core/GP_Blit.gen.c.t
index 80c7f68..2046350 100644
--- a/libs/core/GP_Blit.gen.c.t
+++ b/libs/core/GP_Blit.gen.c.t
@@ -68,7 +68,7 @@ static void blitXYXY_Raw_{{ ps.suffix }}(const GP_Context *src,
GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
GP_Context *dst, GP_Coord x2, GP_Coord y2)
{
-%% if not ps.needs_bit_endian()
+%% if not ps.needs_bit_endian()
/* memcpy() each horizontal line */
GP_Coord y;
@@ -76,7 +76,7 @@ static void blitXYXY_Raw_{{ ps.suffix }}(const GP_Context *src,
memcpy(GP_PIXEL_ADDR_{{ ps.suffix }}(dst, x2, y2 + y),
GP_PIXEL_ADDR_{{ ps.suffix }}(src, x0, y0 + y),
{{ int(ps.size/8) }} * (x1 - x0 + 1));
-%% else
+%% else
{# /* Rectangles may not be bit-aligned in the same way! */
/* Alignment (index) of first bits in the first byte */
//TODO: This is wrong for subcontexts where the offset
@@ -111,7 +111,7 @@ static void blitXYXY_Raw_{{ ps.suffix }}(const GP_Context *src,
} else /* Different bit-alignment, can't use memcpy() */
#}
blitXYXY_Naive_Raw(src, x0, y0, x1, y1, dst, x2, y2);
-%% endif
+%% endif
}
%% endfor
@@ -174,24 +174,24 @@ void GP_BlitXYXY_Raw_Fast(const GP_Context *src,
/* Specialized functions */
switch (src->pixel_type) {
%% for src in pixeltypes
-%% if not src.is_unknown() and not src.is_palette()
+%% if not src.is_unknown() and not src.is_palette()
case GP_PIXEL_{{ src.name }}:
switch (dst->pixel_type) {
-%% for dst in pixeltypes
-%% if not dst.is_unknown() and not dst.is_palette()
-%% if dst.name != src.name
+%% for dst in pixeltypes
+%% if not dst.is_unknown() and not dst.is_palette()
+%% if dst.name != src.name
case GP_PIXEL_{{ dst.name }}:
blitXYXY_Raw_{{ src.name }}_{{ dst.name }}(src, x0, y0, x1, y1, dst, x2, y2);
break;
-%% endif
-%% endif
-%% endfor
+%% endif
+%% endif
+%% endfor
default:
GP_ABORT("Invalid destination pixel %s",
GP_PixelTypeName(dst->pixel_type));
}
break;
-%% endif
+%% endif
%% endfor
default:
GP_ABORT("Invalid source pixel %s",
@@ -203,10 +203,10 @@ void GP_BlitXYXY_Raw_Fast(const GP_Context *src,
* And the same for non-raw variants.
*/
%% for src in pixeltypes
-%% if not src.is_unknown() and not src.is_palette()
-%% for dst in pixeltypes
-%% if not dst.is_unknown() and not dst.is_palette()
-%% if dst.name != src.name
+%% if not src.is_unknown() and not src.is_palette()
+%% for dst in pixeltypes
+%% if not dst.is_unknown() and not dst.is_palette()
+%% if dst.name != src.name
/*
* Blits {{ src.name }} to {{ dst.name }}
*/
@@ -231,10 +231,10 @@ static void blitXYXY_{{ src.name }}_{{ dst.name }}(const GP_Context *src,
}
}
-%% endif
-%% endif
-%% endfor
-%% endif
+%% endif
+%% endif
+%% endfor
+%% endif
%% endfor
/*
@@ -274,28 +274,33 @@ void GP_BlitXYXY_Fast(const GP_Context *src,
src, x0, y0, x1, y1, dst, x2, y2);
return;
}
-
+
+ if (GP_ContextRotationEqual(src, dst)) {
+ GP_BlitXYXY_Raw_Fast(src, x0, y0, x1, y1, dst, x2, y2);
+ return;
+ }
+
/* Specialized functions */
switch (src->pixel_type) {
%% for src in pixeltypes
-%% if not src.is_unknown() and not src.is_palette()
+%% if not src.is_unknown() and not src.is_palette()
case GP_PIXEL_{{ src.name }}:
switch (dst->pixel_type) {
-%% for dst in pixeltypes
-%% if not dst.is_unknown() and not dst.is_palette()
-%% if dst.name != src.name
+%% for dst in pixeltypes
+%% if not dst.is_unknown() and not dst.is_palette()
+%% if dst.name != src.name
case GP_PIXEL_{{ dst.name }}:
blitXYXY_{{ src.name }}_{{ dst.name }}(src, x0, y0, x1, y1, dst, x2, y2);
break;
-%% endif
-%% endif
-%% endfor
+%% endif
+%% endif
+%% endfor
default:
GP_ABORT("Invalid destination pixel %s",
GP_PixelTypeName(dst->pixel_type));
}
break;
-%% endif
+%% endif
%% endfor
default:
GP_ABORT("Invalid source pixel %s",
-----------------------------------------------------------------------
Summary of changes:
demos/bogoman/bogoman.c | 12 ++--
demos/bogoman/bogoman_debug.c | 2 +-
demos/bogoman/bogoman_loader.c | 10 +-
demos/bogoman/bogoman_map.c | 4 +-
demos/bogoman/bogoman_map.h | 4 +-
demos/bogoman/bogoman_render.c | 16 ++--
demos/bogoman/bogoman_render.h | 2 +-
demos/c_simple/SDL_glue.c | 6 +-
demos/c_simple/backend_example.c | 2 +-
demos/c_simple/blittest.c | 18 ++--
demos/c_simple/convolution.c | 6 +-
demos/c_simple/debug_handler.c | 4 +-
demos/c_simple/fileview.c | 24 +++---
demos/c_simple/filters_symmetry.c | 6 +-
demos/c_simple/fonttest.c | 24 +++---
demos/c_simple/gfx_koch.c | 14 ++--
demos/c_simple/input_example.c | 10 +-
demos/c_simple/koch.c | 32 ++++----
demos/c_simple/linetest.c | 18 ++--
demos/c_simple/loaders.c | 6 +-
demos/c_simple/loaders_example.c | 2 +-
demos/c_simple/loaders_register.c | 6 +-
demos/c_simple/meta_data.c | 2 +-
demos/c_simple/meta_data_dump.c | 8 +-
demos/c_simple/pretty_print.c | 2 +-
demos/c_simple/shapetest.c | 22 +++---
demos/c_simple/showimage.c | 6 +-
demos/c_simple/sin_AA.c | 10 +-
demos/c_simple/textaligntest.c | 4 +-
demos/c_simple/timers.c | 4 +-
demos/c_simple/tmp_file.c | 10 +-
demos/c_simple/v4l2_grab.c | 12 ++--
demos/c_simple/v4l2_show.c | 16 ++--
demos/c_simple/version.c | 2 +-
demos/c_simple/virtual_backend_example.c | 16 ++--
demos/c_simple/weighted_median.c | 6 +-
demos/c_simple/x11_windows.c | 12 ++--
demos/grinder/grinder.c | 74 +++++++++---------
demos/grinder/histogram.c | 18 ++--
demos/grinder/params.c | 18 ++--
demos/grinder/params.h | 2 +-
demos/particle/particle_demo.c | 10 +-
demos/particle/space.c | 28 +++---
demos/particle/space.h | 2 +-
demos/py_simple/blit.py | 6 +-
demos/py_simple/cam_view.py | 2 +-
demos/py_simple/gfx.py | 16 ++--
demos/py_simple/progress_callback.py | 4 +-
demos/py_simple/pygtk_example.py | 6 +-
demos/py_simple/x11_windows.py | 4 +-
demos/spiv/cpu_timer.c | 2 +-
demos/spiv/image_actions.c | 8 +-
demos/spiv/image_actions.h | 2 +-
demos/spiv/image_cache.c | 34 ++++----
demos/spiv/image_cache.h | 4 +-
demos/spiv/image_list.c | 36 ++++----
demos/spiv/image_list.h | 6 +-
demos/spiv/spiv.c | 128 +++++++++++++++---------------
demos/spiv/spiv_help.c | 10 +-
demos/ttf2img/ttf2img.c | 4 +-
libs/core/GP_Blit.c | 43 ++--------
libs/core/GP_Blit.gen.c.t | 61 ++++++++-------
libs/filters/GP_LinearThreads.c | 6 +-
63 files changed, 437 insertions(+), 457 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
27 Jun '13
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 62c398e8f845bbe95f0af0e64ab2d9670c6b59af (commit)
via 7bec5898aaebb798e08f348503b7df5df1d515ad (commit)
from 88500942a4e2dda6951c5abaf6bc05e4bb5d6efc (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/62c398e8f845bbe95f0af0e64ab2d9670c6b…
commit 62c398e8f845bbe95f0af0e64ab2d9670c6b59af
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Jun 27 22:24:22 2013 +0200
tests: filters: Add common.o to CLEAN.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/filters/Makefile b/tests/filters/Makefile
index bda08a5..986710f 100644
--- a/tests/filters/Makefile
+++ b/tests/filters/Makefile
@@ -11,6 +11,8 @@ include ../tests.mk
FilterMirrorH: common.o
+CLEAN+=common.o
+
include $(TOPDIR)/gen.mk
include $(TOPDIR)/app.mk
include $(TOPDIR)/post.mk
http://repo.or.cz/w/gfxprim.git/commit/7bec5898aaebb798e08f348503b7df5df1d5…
commit 7bec5898aaebb798e08f348503b7df5df1d515ad
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Jun 27 22:22:22 2013 +0200
Remove traling whitespaces.
Remove all trailing whitespaces, spaces before tabs and add GPL headers
to two sources in gfx.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/configure b/configure
index 107db2d..971a960 100755
--- a/configure
+++ b/configure
@@ -9,9 +9,9 @@ import subprocess
def header_exists(cfg, filename):
fpath = cfg['include_path'][0] + '/' + filename
-
+
sys.stderr.write("Checking for '%s' ... " % fpath)
-
+
try:
st = os.stat(fpath)
sys.stderr.write("Yesn")
@@ -23,9 +23,9 @@ def header_exists(cfg, filename):
def c_try_compile(cfg, code, msg):
sys.stderr.write(msg)
- ret = os.system("echo '%s' | %s -x c -o /dev/null - > /dev/null 2>&1" %
+ ret = os.system("echo '%s' | %s -x c -o /dev/null - > /dev/null 2>&1" %
(code, cfg["CC"][0]))
-
+
if ret:
sys.stderr.write("Non")
return False
@@ -111,7 +111,7 @@ class libraries:
sys.stderr.write("Libraries to link againstn")
sys.stderr.write("-------------------------n")
-
+
for i in self.libraries:
sys.stderr.write("%10s" % i[0])
@@ -208,8 +208,8 @@ def basic_checks(cfg):
check_for_swig(cfg)
check_for_python_config(cfg)
-
- cfg['PYTHON_VER'][0] = python_version(cfg)
+
+ cfg['PYTHON_VER'][0] = python_version(cfg)
if cfg['libdir'][0] == '':
sys.stderr.write("Checking for lib directory ... ")
@@ -266,7 +266,7 @@ def write_gfxprim_config(cfg, libs):
f.write('t--cflags) echo -n "-I/usr/include/GP/%s";;n' %
libs.get_cflags('core'))
f.write('t--libs) echo -n "-lGP -lrt -lm %s ";;n' % libs.get_linker_flags('core'))
-
+
# ldflags for specific modules
for i in modules:
ldflags = ''
@@ -348,8 +348,8 @@ if __name__ == '__main__':
# Get configuration parameters from environment variables
for i in cfg:
- if i in os.environ:
- cfg[i][0] = os.environ[i]
+ if i in os.environ:
+ cfg[i][0] = os.environ[i]
# Enable disable libraries for linking
parser.add_option("-e", "--enable", dest="enable", action="append",
@@ -363,10 +363,10 @@ if __name__ == '__main__':
(options, args) = parser.parse_args();
- #
+ #
# Enable/Disable libraries as user requested
# These are not checked later
- #
+ #
if options.enable:
for i in options.enable:
l.set(i, True);
@@ -379,7 +379,7 @@ if __name__ == '__main__':
cfg[i][0] = getattr(options, i)
basic_checks(cfg);
-
+
l.check()
l.print_summary()
diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h
index e623eda..f94252c 100644
--- a/include/backends/GP_Backend.h
+++ b/include/backends/GP_Backend.h
@@ -45,7 +45,7 @@
#include "core/GP_Context.h"
#include "input/GP_EventQueue.h"
-#include "input/GP_Timer.h"
+#include "input/GP_Timer.h"
typedef struct GP_Backend {
/*
@@ -53,7 +53,7 @@ typedef struct GP_Backend {
*/
const char *name;
- /*
+ /*
* Pointer to context app should draw to.
*
* This MAY change upon a flip operation.
@@ -107,8 +107,8 @@ typedef struct GP_Backend {
*/
void (*Exit)(struct GP_Backend *self);
- /*
- * Connection fd. Set to -1 if not available
+ /*
+ * Connection fd. Set to -1 if not available
*/
int fd;
diff --git a/include/backends/GP_BackendInit.h b/include/backends/GP_BackendInit.h
index 6fcc997..db9fdda 100644
--- a/include/backends/GP_BackendInit.h
+++ b/include/backends/GP_BackendInit.h
@@ -43,9 +43,9 @@
* The caption parameter may, or may not be used. For example in windowed
* enviroment caption will become caption of a window. When running on
* framebuffer it may be ignored completly.
- *
+ *
* Returns initalized backend or NULL in case of failure.
- *
+ *
* If initialization has failed or params is NULL and help is not NULL, help
* text is printed to a given file.
*/
diff --git a/include/backends/GP_BackendVirtual.h b/include/backends/GP_BackendVirtual.h
index a050dc3..720f8c6 100644
--- a/include/backends/GP_BackendVirtual.h
+++ b/include/backends/GP_BackendVirtual.h
@@ -33,7 +33,7 @@
#include "GP_Backend.h"
enum GP_BackendVirtFlags {
- /*
+ /*
* If set virtual backend exit calls 'parent' Exit as well.
*/
GP_BACKEND_CALL_EXIT = 0x01,
diff --git a/include/backends/GP_SDL.h b/include/backends/GP_SDL.h
index 514f65d..7a88f05 100644
--- a/include/backends/GP_SDL.h
+++ b/include/backends/GP_SDL.h
@@ -35,12 +35,12 @@ enum GP_BackendSDLFlags {
* Initalize SDL as drawing backend.
*
* * SDL doesn't expose file descriptors.
- *
+ *
* * The backend is thread safe (the critical parts are guarded with a mutex)
- *
+ *
* * The backend is singleton, you can't have two SDL backends running at the
* same time.
- *
+ *
* * When backend is allready initalized, this function ignores it's parameters
* and returns pointer to allready initalized SDL backend.
*
@@ -51,7 +51,7 @@ enum GP_BackendSDLFlags {
* The parameters w h and bpp are directly passed to SDL_SetVideoMode().
*
* * If w, h and/or bpp are set to zero, SDL tries to do best fit.
- *
+ *
* * The GP_BackendSDLFlags are converted into SDL equivalents.
*
* Upon failure, or if SDL wasn't compiled in, NULL is returned.
diff --git a/include/backends/GP_X11.h b/include/backends/GP_X11.h
index a196a31..192afc6 100644
--- a/include/backends/GP_X11.h
+++ b/include/backends/GP_X11.h
@@ -28,7 +28,7 @@
enum GP_BackendX11Flags {
/* When set, w and h is ignored and root window is used */
GP_X11_USE_ROOT_WIN = 0x01,
-
+
/* Create new borderless window above the root window */
GP_X11_CREATE_ROOT_WIN = 0x02,
@@ -45,9 +45,9 @@ enum GP_BackendX11Flags {
*
* The display may be NULL for default display ($DISPLAY shell variable will
* be used).
- *
+ *
* The coordinates are position and geometry for newly created window.
- *
+ *
* Upon failure NULL is returned.
*/
GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
@@ -62,7 +62,7 @@ int GP_BackendIsX11(GP_Backend *self);
/*
* Changes full screen mode.
- *
+ *
* 0 = off
* 1 = on
* 2 = toggle
diff --git a/include/core/GP_BitSwap.h b/include/core/GP_BitSwap.h
index 5ad76ad..b0f694b 100644
--- a/include/core/GP_BitSwap.h
+++ b/include/core/GP_BitSwap.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Inline functions for swapping bits inside of the byte
*/
diff --git a/include/core/GP_Blit.h b/include/core/GP_Blit.h
index 693d73b..caa4112 100644
--- a/include/core/GP_Blit.h
+++ b/include/core/GP_Blit.h
@@ -22,14 +22,14 @@
*****************************************************************************/
/*
-
+
These blits automatically converts pixel types, that's good (and fast), but
there is a catch. This works rather well when the number of colors per
pixel/color channel is increased (the gamma correction is still on TODO).
However when the number of colors is decreased it's generally better to use
dithering, which will yield into far better (you can use Floyd Steinberg
filter for that).
-
+
Also variants without the _Raw suffix do honor the rotation flags, that may
get a little tricky as the flags for rotation are put together but don't
worry althouth there is some algebra involved the result is quite intuitive.
diff --git a/include/core/GP_Clamp.h b/include/core/GP_Clamp.h
index 6b6443a..ac87cb7 100644
--- a/include/core/GP_Clamp.h
+++ b/include/core/GP_Clamp.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Fast clamping.
*/
diff --git a/include/core/GP_Color.h b/include/core/GP_Color.h
index 4c3233b..de87e6a 100644
--- a/include/core/GP_Color.h
+++ b/include/core/GP_Color.h
@@ -26,7 +26,7 @@
/*
Color is enumeration of color names which may be converted into pixel values
- in desired pixel format.
+ in desired pixel format.
*/
@@ -63,7 +63,7 @@ typedef enum GP_Color {
GP_Pixel GP_ColorToPixel(GP_Color color, GP_PixelType pixel_type);
/*
- * Converts GP_Color to GP_Pixel.
+ * Converts GP_Color to GP_Pixel.
*/
static inline GP_Pixel GP_ColorToContextPixel(GP_Color color,
GP_Context *context)
@@ -93,7 +93,7 @@ bool GP_ColorNameToPixel(const char *color_name, GP_PixelType pixel_type,
/*
* Converts Color name to Pixel.
- *
+ *
* Returns true if conversion was successful false otherwise.
*/
static inline bool GP_ColorNameToContextPixel(const char *color_name,
diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h
index 17d61b8..40b3c09 100644
--- a/include/core/GP_Common.h
+++ b/include/core/GP_Common.h
@@ -120,7 +120,7 @@
abort(); } while (0)
-/*
+/*
* Print as much trace info as possible. Currently, the (C) call stack and
* the Python stack if a Python interpreter is set up. In case more wrappers
* are written, it should print a trace for the currently active.
diff --git a/include/core/GP_Context.h b/include/core/GP_Context.h
index 83d3c10..a575522 100644
--- a/include/core/GP_Context.h
+++ b/include/core/GP_Context.h
@@ -41,15 +41,15 @@ typedef struct GP_Context {
uint8_t bpp; /* pixel size in bits */
uint32_t bytes_per_row;
uint32_t w; /* width in pixels */
- uint32_t h; /* height in pixels */
- /*
+ uint32_t h; /* height in pixels */
+ /*
* Row bit offset. The offset is ignored for byte aligned pixels.
* Basically it's used for non aligned pixels with combination
* with subcontextes.
*/
- uint8_t offset;
+ uint8_t offset;
- /*
+ /*
* Pixel format. See GP_Pixel.gen.h and GP_Pixel.gen.c.
*/
enum GP_PixelType pixel_type;
@@ -63,7 +63,7 @@ typedef struct GP_Context {
*/
struct GP_Gamma *gamma;
- /*
+ /*
* Image orientation. Most common is landscape (0, 0, 0),
* portrait with normal topleft corner is (1, 0, 0).
*/
@@ -137,11 +137,11 @@ GP_Context *GP_ContextInit(GP_Context *context, GP_Size w, GP_Size h,
int GP_ContextResize(GP_Context *context, GP_Size w, GP_Size h);
enum GP_ContextCopyFlags {
- /*
+ /*
* Copy bitmap pixels too. If not set pixels are uninitalized.
*/
GP_COPY_WITH_PIXELS = 0x01,
- /*
+ /*
* Copy image rotation flags. If not set flags are set to (0, 0, 0).
*/
GP_COPY_WITH_ROTATION = 0x02,
@@ -234,7 +234,7 @@ static inline void GP_ContextCopyRotation(const GP_Context *src,
}
/*
- * Returns context width and height taking the rotation flags into a account.
+ * Returns context width and height taking the rotation flags into a account.
*/
static inline GP_Size GP_ContextW(const GP_Context *context)
{
diff --git a/include/core/GP_Convert.h b/include/core/GP_Convert.h
index 8b5fb6a..abf2df2 100644
--- a/include/core/GP_Convert.h
+++ b/include/core/GP_Convert.h
@@ -79,7 +79,7 @@ static inline GP_Pixel GP_RGBAToPixel(uint8_t r, uint8_t g, uint8_t b,
* Converts a color specified by its R, G, B components to a pixel value
* compatible with the specified context.
*/
-static inline GP_Pixel GP_RGBToContextPixel(uint8_t r, uint8_t g, uint8_t b,
+static inline GP_Pixel GP_RGBToContextPixel(uint8_t r, uint8_t g, uint8_t b,
const GP_Context *context)
{
return GP_RGBToPixel(r, g, b, context->pixel_type);
@@ -89,7 +89,7 @@ static inline GP_Pixel GP_RGBToContextPixel(uint8_t r, uint8_t g, uint8_t b,
* Converts a color specified by its R, G, B, A components to a pixel value
* compatible with the specified context.
*/
-static inline GP_Pixel GP_RGBAToContextPixel(uint8_t r, uint8_t g,
+static inline GP_Pixel GP_RGBAToContextPixel(uint8_t r, uint8_t g,
uint8_t b, uint8_t a,
const GP_Context *context)
{
@@ -104,7 +104,7 @@ static inline GP_Pixel GP_ConvertPixel(GP_Pixel pixel, GP_PixelType from,
{
return GP_RGBA8888ToPixel(GP_PixelToRGBA8888(pixel, from), to);
}
-
+
/*
* Convert between pixel types of given contexts (excl. palette types) via
* RGBA8888.
diff --git a/include/core/GP_FnPerBpp.h b/include/core/GP_FnPerBpp.h
index 11d12a3..8586468 100644
--- a/include/core/GP_FnPerBpp.h
+++ b/include/core/GP_FnPerBpp.h
@@ -34,7 +34,7 @@
* GP_Context or given GP_PixelType.
*
* Extra arguments are arguments to be passed to the function.
- * Note that if the function takes the context/type/bpp as an argument,
+ * Note that if the function takes the context/type/bpp as an argument,
* you still need to provide it in __VA_ARGS__
*
* The GP_FN_PER_* variants ignore the return value of the called function.
@@ -47,24 +47,24 @@
#include "GP_FnPerBpp.gen.h"
/*
- * Branch on GP_Context argument.
+ * Branch on GP_Context argument.
*/
#define GP_FN_PER_BPP_CONTEXT(FN_NAME, context, ...) GP_FN_PER_BPP(FN_NAME, (context)->bpp, (context)->bit_endian, __VA_ARGS__)
/*
- * Branch on GP_PixelType argument.
+ * Branch on GP_PixelType argument.
*/
#define GP_FN_PER_BPP_PIXELTYPE(FN_NAME, type, ...) GP_FN_PER_BPP(FN_NAME, GP_PixelTypes[type].size, GP_PixelTypes[type].bit_endian, __VA_ARGS__)
/*
- * Branch on GP_Context argument.
+ * Branch on GP_Context argument.
*/
#define GP_FN_RET_PER_BPP_CONTEXT(FN_NAME, context, ...) GP_FN_RET_PER_BPP(FN_NAME, (context)->bpp, (context)->bit_endian, __VA_ARGS__)
/*
- * Branch on GP_PixelType argument.
+ * Branch on GP_PixelType argument.
*/
#define GP_FN_RET_PER_BPP_PIXELTYPE(FN_NAME, type, ...) GP_FN_RET_PER_BPP(FN_NAME, GP_PixelTypes[type].size, GP_PixelTypes[type].bit_endian, __VA_ARGS__)
diff --git a/include/core/GP_Gamma.h b/include/core/GP_Gamma.h
index 53e217e..6fffaac 100644
--- a/include/core/GP_Gamma.h
+++ b/include/core/GP_Gamma.h
@@ -57,7 +57,7 @@
*/
/*
-
+
This code implements management functions for easy, per context, per
channel, gamma tables.
@@ -66,11 +66,11 @@
Also the table output, for linear values, has two more bits than original in
order not to loose precision.
-
+
The pointers to gamma tables are storied in GP_Gamma structure and are
organized in the same order as channels. First N tables for each channel and
- gamma value gamma, then N tables for inverse 1/gamma function.
-
+ gamma value gamma, then N tables for inverse 1/gamma function.
+
So when we have RGB888 pixel and gamma 2.2 there are two tables in the
memory, one for gamma 2.2 input 8bit output 10bit and it's inverse input
10bit output 8bit. The GP_Gamma contains six pointers. First three points to
@@ -136,7 +136,7 @@ typedef struct GP_GammaTable {
float gamma;
uint8_t in_bits;
uint8_t out_bits;
-
+
/* Used for internal purpose */
unsigned int ref_count;
struct GP_GammaTable *next;
@@ -153,7 +153,7 @@ typedef struct GP_GammaTable {
*
* The GP_Gamma structure contains pointers to tables for each pixel
* channel and for gamma and it's inverse transformation.
- *
+ *
* The interface is specially designed so that getting Gamma corrected value is
* a matter of indexing two arrays.
*/
diff --git a/include/core/GP_GetPutPixel.h b/include/core/GP_GetPutPixel.h
index 671a16e..6faf7b2 100644
--- a/include/core/GP_GetPutPixel.h
+++ b/include/core/GP_GetPutPixel.h
@@ -29,7 +29,7 @@
#include "GP_FnPerBpp.h"
#include "GP_Pixel.h"
-/*
+/*
* Generated header
*/
#include "GP_GetPutPixel.gen.h"
@@ -46,9 +46,9 @@ GP_Pixel GP_GetPixel(const GP_Context *context, GP_Coord x, GP_Coord y);
static inline GP_Pixel GP_GetPixel_Raw(const GP_Context *context,
GP_Coord x, GP_Coord y)
{
- GP_FN_RET_PER_BPP(GP_GetPixel_Raw, context->bpp, context->bit_endian,
+ GP_FN_RET_PER_BPP(GP_GetPixel_Raw, context->bpp, context->bit_endian,
context, x, y);
-
+
GP_ABORT("Invalid context pixel type");
}
@@ -76,7 +76,7 @@ void GP_PutPixel(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel p);
static inline void GP_PutPixel_Raw(GP_Context *context,
GP_Coord x, GP_Coord y, GP_Pixel p)
{
- GP_FN_PER_BPP(GP_PutPixel_Raw, context->bpp, context->bit_endian,
+ GP_FN_PER_BPP(GP_PutPixel_Raw, context->bpp, context->bit_endian,
context, x, y, p);
}
diff --git a/include/core/GP_GetSetBits.h b/include/core/GP_GetSetBits.h
index 40d6b81..1cd1e36 100644
--- a/include/core/GP_GetSetBits.h
+++ b/include/core/GP_GetSetBits.h
@@ -22,7 +22,7 @@
*****************************************************************************/
/*
-
+
Helper macros to get/set bits given offset and lenght.
The GP_GET_BITS() and GP_SET_BITS() works __ONLY__ on aligned data types.
@@ -42,10 +42,10 @@
#define CORE_GP_GET_SET_BITS_H
/*
- * Helper macros to read/write parts of words
+ * Helper macros to read/write parts of words
*
* Return (shifted) count bits at offset of value
- * Note: operates with value types same as val
+ * Note: operates with value types same as val
*/
#define GP_GET_BITS(offset, len, val) (sizeof(val) * 8 <= len ? @@ -91,9 +91,9 @@
/*
* Set count bits of dest at ofset to val (shifted by offset)
- *
+ *
* Does not check val for overflow
- * Operates on 8, 16, and 32 bit values, depending on the type of dest,
+ * Operates on 8, 16, and 32 bit values, depending on the type of dest,
* this should be unsigned
*
* GP_SET_BITS_OR anly sets (|=) the bits, assuming these are clear beforehand
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h
index 642f8b3..8c060f0 100644
--- a/include/core/GP_Pixel.h
+++ b/include/core/GP_Pixel.h
@@ -37,8 +37,8 @@
struct GP_Context;
/*
- * GP_PixelType is typedef enum of PixelTypes,
- *
+ * GP_PixelType is typedef enum of PixelTypes,
+ *
* each named GP_PIXEL_<TYPENAME>, such as GP_PIXEL_RGB888
* see the beginning of GP_Pixel.gen.h for a complete list
*
@@ -58,8 +58,8 @@ typedef uint32_t GP_Pixel;
#include "GP_GetSetBits.h"
/*
- * Information about ordering of pixels in byte for 1, 2 and 4 bpp
- * used in a one bit variable in GP_Context
+ * Information about ordering of pixels in byte for 1, 2 and 4 bpp
+ * used in a one bit variable in GP_Context
*/
typedef enum {
/* less significant bits contain pixels with lower indices */
@@ -172,7 +172,7 @@ GP_PixelType GP_PixelTypeByName(const char *name);
/*
* Match pixel type to known pixel types.
*
- * Returns either valid PixelType or GP_PIXEL_UNKNOWN
+ * Returns either valid PixelType or GP_PIXEL_UNKNOWN
*/
GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
GP_Pixel bmask, GP_Pixel amask,
@@ -181,7 +181,7 @@ GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
/*
* Similar to GP_PixelRGBMatch but works with offsets and sizes
*
- * Returns either valid PixelType or GP_PIXEL_UNKNOWN
+ * Returns either valid PixelType or GP_PIXEL_UNKNOWN
*/
GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff,
uint32_t gsize, uint32_t goff,
@@ -195,7 +195,7 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff,
* Call as:
*
* if (GP_PixelHasFlags(pixel_type, GP_PIXEL_IS_RGB | GP_PIXEL_HAS_ALPHA))
- * ...
+ * ...
*/
int GP_PixelHasFlags(GP_PixelType pixel_type, GP_PixelFlags flags);
diff --git a/include/core/GP_ProgressCallback.h b/include/core/GP_ProgressCallback.h
index e944154..850f480 100644
--- a/include/core/GP_ProgressCallback.h
+++ b/include/core/GP_ProgressCallback.h
@@ -43,15 +43,15 @@
*/
typedef struct GP_ProgressCallback {
float percentage;
-
+
int (*callback)(struct GP_ProgressCallback *self);
void *priv;
-
+
/*
* Number of threads to use (if supported). This setting could be used
* to override the default number of threads as returned by
* GP_NrThreads().
- *
+ *
* 0 == use number returned from GP_NrThreads().
*
* >= 1 use exactly n threads
@@ -77,7 +77,7 @@ static inline void GP_ProgressCallbackDone(GP_ProgressCallback *callback)
{
if (callback == NULL)
return;
-
+
callback->percentage = 100;
callback->callback(callback);
}
diff --git a/include/core/GP_Threads.h b/include/core/GP_Threads.h
index 6cc4be6..69da584 100644
--- a/include/core/GP_Threads.h
+++ b/include/core/GP_Threads.h
@@ -81,7 +81,7 @@ struct GP_ProgressCallbackMPPriv {
* ...
*
* for n threads:
- * run_filter(..., callback ? &callback_mp : NULL);
+ * run_filter(..., callback ? &callback_mp : NULL);
*/
#define GP_PROGRESS_CALLBACK_MP(name, callback) struct GP_ProgressCallbackMPPriv name_priv = { diff --git a/include/core/GP_Transform.h b/include/core/GP_Transform.h
index e903d69..5915c89 100644
--- a/include/core/GP_Transform.h
+++ b/include/core/GP_Transform.h
@@ -31,8 +31,8 @@
#include "GP_Common.h"
#include "GP_FixedPoint.h"
-/*
- * Flip a coordinate within context according to context transformation.
+/*
+ * Flip a coordinate within context according to context transformation.
*/
#define GP_TRANSFORM_X(context, x) do { if ((context)->x_swap) @@ -57,17 +57,17 @@
y = GP_FP_FROM_INT((context)->h - 1) - y; } while (0)
-/*
- * Swap coordinates (axes) according to context transformation.
+/*
+ * Swap coordinates (axes) according to context transformation.
*/
#define GP_TRANSFORM_SWAP(context, x, y) do { if ((context)->axes_swap) GP_SWAP(x, y); } while (0)
-/*
- * Transform "user"-coordinates to "real"-coordinates according to context
- * transformation.
+/*
+ * Transform "user"-coordinates to "real"-coordinates according to context
+ * transformation.
*/
#define GP_TRANSFORM_POINT(context, x, y) do { GP_TRANSFORM_SWAP(context, x, y); @@ -81,10 +81,10 @@
GP_TRANSFORM_Y_FP(context, y); } while (0)
-/*
+/*
* Transform "user"-coordinates to "real"-coordinates of a rectangle corner
- * according to context transformation. Corner with min-coordinates is
- * transformed to (different) corner with min-coordinates etc.
+ * according to context transformation. Corner with min-coordinates is
+ * transformed to (different) corner with min-coordinates etc.
* Arguments x, y, w, h are modified.
*/
#define GP_TRANSFORM_RECT(context, x, y, w, h) do { @@ -109,7 +109,7 @@
y = GP_FP_FROM_INT((context)->h) - y - h; } while (0)
-/*
+/*
* Transform "user"-coordinates to "real"-coordinates for a blit
* called as GP_Blit(c1, x1, y1, w, h, c2, x2, y2).
* All x1, y1, x2, y2, w, h are adjusted.
@@ -122,7 +122,7 @@
} while (0)
/*
- * Inverse transformation to GP_TRANSFORM_POINT.
+ * Inverse transformation to GP_TRANSFORM_POINT.
* Use for translating mouse pointer coordinates to coordinates on context.
*/
#define GP_RETRANSFORM_POINT(context, x, y) do { diff --git a/include/core/GP_Types.h b/include/core/GP_Types.h
index e3d0f55..1b94743 100644
--- a/include/core/GP_Types.h
+++ b/include/core/GP_Types.h
@@ -25,8 +25,8 @@
#include <stdint.h>
-/*
- * Integer type for coordinates: x, y, width, height, ...
+/*
+ * Integer type for coordinates: x, y, width, height, ...
* Should be signed to hold negative values as well.
*/
typedef int GP_Coord;
diff --git a/include/filters/GP_Blur.h b/include/filters/GP_Blur.h
index c008774..691955e 100644
--- a/include/filters/GP_Blur.h
+++ b/include/filters/GP_Blur.h
@@ -33,7 +33,7 @@
/*
* Gaussian blur implemented using linear separable convolution.
- *
+ *
* The x_sigma defines the blur size in horizontal direction and y_sigma
* defines blur on vertical direction.
*/
diff --git a/include/filters/GP_Convolution.h b/include/filters/GP_Convolution.h
index 0cd9089..e8d30d0 100644
--- a/include/filters/GP_Convolution.h
+++ b/include/filters/GP_Convolution.h
@@ -36,23 +36,23 @@
* 2D convolution kernel.
*
* The kernel array size must be w * h.
- *
+ *
* The div is used to divide the resulting value which is commonly used for
* normalization.
*
* Example box smoothing filter kernel initialization:
*
* float box_filter[] = {
- * 1, 1, 1,
- * 1, 1, 1,
- * 1, 1, 1,
+ * 1, 1, 1,
+ * 1, 1, 1,
+ * 1, 1, 1,
* };
*
* GP_FilterKernel2D box_kernel = {
- * .w = 3,
- * .h = 3,
- * .div = 9,
- * .kernel = box_filter,
+ * .w = 3,
+ * .h = 3,
+ * .div = 9,
+ * .kernel = box_filter,
* };
*/
typedef struct GP_FilterKernel2D {
diff --git a/include/filters/GP_FilterParam.h b/include/filters/GP_FilterParam.h
index 6520354..31b7ab6 100644
--- a/include/filters/GP_FilterParam.h
+++ b/include/filters/GP_FilterParam.h
@@ -66,7 +66,7 @@ void GP_FilterParamDestroy(GP_FilterParam *self);
/*
* Takes array of filter parameters and returns filter parameter by a channel
* name.
- *
+ *
* Returns NULL if channel wasn't found.
*/
GP_FilterParam *GP_FilterParamChannel(GP_FilterParam params[],
diff --git a/include/filters/GP_GaussianNoise.h b/include/filters/GP_GaussianNoise.h
index 135712b..e67fc2f 100644
--- a/include/filters/GP_GaussianNoise.h
+++ b/include/filters/GP_GaussianNoise.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Additive Gaussian noise filters.
The sigma and mu parameters define the noise parameters. The sigma defines
diff --git a/include/filters/GP_HilbertCurve.h b/include/filters/GP_HilbertCurve.h
index f5283c8..d7ebd7c 100644
--- a/include/filters/GP_HilbertCurve.h
+++ b/include/filters/GP_HilbertCurve.h
@@ -55,7 +55,7 @@ static inline void GP_HilbertCurveInit(struct GP_CurveState *state, int n)
static inline void GP_HilbertCurveGetXY(struct GP_CurveState *state)
{
int sa, sb;
- /*
+ /*
* Older gcc thinks that x and y are used uninitialized that is not
* true so we silence the warning by initializing them.
*/
@@ -70,7 +70,7 @@ static inline void GP_HilbertCurveGetXY(struct GP_CurveState *state)
x = y ^ (-sa);
y = temp ^ (-sa);
}
-
+
x = (x >> 1) | (sa << 31);
y = (y >> 1) | ((sa ^ sb) << 31);
}
diff --git a/include/filters/GP_Linear.h b/include/filters/GP_Linear.h
index fe938f5..62ff12d 100644
--- a/include/filters/GP_Linear.h
+++ b/include/filters/GP_Linear.h
@@ -36,7 +36,7 @@
*
* The kernel is array of kw * kh floats and is indexed as two directional
* array.
- *
+ *
* The src coordinates and size defines rectangle in the source on which the
* filter operates.
*
@@ -51,7 +51,7 @@
* };
*
* kw = kh = 3
- *
+ *
* kern_div = 9
*/
int GP_FilterLinearConvolution_Raw(const GP_Context *src,
diff --git a/include/filters/GP_Median.h b/include/filters/GP_Median.h
index 4755961..0274b29 100644
--- a/include/filters/GP_Median.h
+++ b/include/filters/GP_Median.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Constant time Median Filter (the computational complexity is independent of
radius).
diff --git a/include/filters/GP_Point.h b/include/filters/GP_Point.h
index 7032af3..42248a9 100644
--- a/include/filters/GP_Point.h
+++ b/include/filters/GP_Point.h
@@ -56,7 +56,7 @@ int GP_FilterContrast_Raw(const GP_Context *src, GP_Context *dst,
GP_FilterParam params[],
GP_ProgressCallback *callback);
-GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst,
+GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst,
GP_FilterParam params[],
GP_ProgressCallback *callback);
diff --git a/include/filters/GP_Resize.h b/include/filters/GP_Resize.h
index 7b1473c..31b96a0 100644
--- a/include/filters/GP_Resize.h
+++ b/include/filters/GP_Resize.h
@@ -44,7 +44,7 @@
Bicubic
~~~~~~~
-
+
Works well for upscaling as is. To get decent result on downscaling,
low-pass filter (for example gaussian blur) must be used on original image
before scaling is done.
@@ -86,7 +86,7 @@ int GP_FilterResize_Raw(const GP_Context *src, GP_Context *dst,
/*
* If destination is non NULL, the w and h are used to create subcontext from
* destination which is then used to interpolate the image to.
- *
+ *
* Otherwise if destination is NULL, the context of size w and h is allocated
* and returned.
*
diff --git a/include/filters/GP_Rotate.h b/include/filters/GP_Rotate.h
index 1da96c8..356ceb1 100644
--- a/include/filters/GP_Rotate.h
+++ b/include/filters/GP_Rotate.h
@@ -34,7 +34,7 @@
/*
* Mirror horizontally.
- *
+ *
* Works 'in place'. The contexts must have equal pixel_type and size.
*
* This is semi-internal function without any assertions on destination.
@@ -101,7 +101,7 @@ GP_Context *GP_FilterMirrorVAlloc(const GP_Context *src,
/*
* Rotate context by 90, 180 and 270.
*
- * Doesn't work 'in place'. The contexts must have equal pixel_type size must
+ * Doesn't work 'in place'. The contexts must have equal pixel_type size must
* match the rotated size (is equal for 180 and swapped for 90 and 270).
*
* These are semi-internal functions without any assertions on destination.
@@ -139,7 +139,7 @@ GP_Context *GP_FilterRotate270Alloc(const GP_Context *src,
GP_ProgressCallback *callback);
/*
- * Calls a symmetry filter on bitmap.
+ * Calls a symmetry filter on bitmap.
*
* If dst is NULL, new bitmap is allocated.
*
@@ -162,7 +162,7 @@ extern const char **GP_FilterSymmetryNames;
/*
* Symmetry by name (as defined in GP_FilerSymmetryNames).
- *
+ *
* Returns either one of the GP_FilterSymmetries enums or -1 in case of
* failure.
*/
diff --git a/include/filters/GP_Sigma.h b/include/filters/GP_Sigma.h
index e7db9d0..01f1cf4 100644
--- a/include/filters/GP_Sigma.h
+++ b/include/filters/GP_Sigma.h
@@ -21,14 +21,14 @@
*****************************************************************************/
/*
-
+
Sigma Lee filter.
The xrad and yrad denotes radius the filter works on. The number of neighbor
pixels is exactly 2 * rad + 1 for both directions.
-
+
The sigma denotes maximal symetric difference of pixels scaled to [0,1]
- interval. Greater sigma causes results to be closer to mean linear filter.
+ interval. Greater sigma causes results to be closer to mean linear filter.
The min parameter defines minimial number of pixels that must be in the two
sigma iterval, if there is a less pixels in this interval the new pixel
diff --git a/include/filters/GP_WeightedMedian.h b/include/filters/GP_WeightedMedian.h
index 82dd8e4..167b454 100644
--- a/include/filters/GP_WeightedMedian.h
+++ b/include/filters/GP_WeightedMedian.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
*/
diff --git a/include/gfx/GP_CircleSeg.h b/include/gfx/GP_CircleSeg.h
index fddc5ef..3bd41e2 100644
--- a/include/gfx/GP_CircleSeg.h
+++ b/include/gfx/GP_CircleSeg.h
@@ -34,10 +34,10 @@
* First segment is where both x and y are possitive, second is where only y is
* possitive, third is for both x and y negative and the last one for only y
* negative.
- *
+ *
* Note that on computer screen (and in in-memory bitmaps) cordinates for y
* grows in the opposite direction to the standard cartesian plane.
- *
+ *
* So first segment is actually down right, second is down left, third is up
* left, and fourth is up right.
*/
diff --git a/include/gfx/GP_HLineAA.h b/include/gfx/GP_HLineAA.h
index b253ae2..cbb34e7 100644
--- a/include/gfx/GP_HLineAA.h
+++ b/include/gfx/GP_HLineAA.h
@@ -21,12 +21,12 @@
*****************************************************************************/
/*
-
+
Anti Aliased Horizontal line.
The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h
for helper macros.
-
+
For RGB contexts gamma correction tables are used to generate correct
intensity for pixels.
diff --git a/include/gfx/GP_LineAA.h b/include/gfx/GP_LineAA.h
index 34ec028..c8a0ac6 100644
--- a/include/gfx/GP_LineAA.h
+++ b/include/gfx/GP_LineAA.h
@@ -21,12 +21,12 @@
*****************************************************************************/
/*
-
+
Anti Aliased line.
The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h
for helper macros.
-
+
For RGB contexts gamma correction tables are used to generate correct
intensity for pixels.
@@ -40,7 +40,7 @@
/*
* Anti Aliased Line respecting context rotation flags and with clipping.
*/
-void GP_LineAA(GP_Context *context, GP_Coord x0, GP_Coord y0,
+void GP_LineAA(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
/*
diff --git a/include/gfx/GP_PutPixelAA.h b/include/gfx/GP_PutPixelAA.h
index 7d697c7..2852cc4 100644
--- a/include/gfx/GP_PutPixelAA.h
+++ b/include/gfx/GP_PutPixelAA.h
@@ -21,12 +21,12 @@
*****************************************************************************/
/*
-
+
Puts an anti aliased pixel to context.
The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h
for helper macros.
-
+
For RGB contexts gamma correction tables are used to generate correct
intensity for pixels.
diff --git a/include/gfx/GP_VLineAA.h b/include/gfx/GP_VLineAA.h
index 4bbce5a..87bf586 100644
--- a/include/gfx/GP_VLineAA.h
+++ b/include/gfx/GP_VLineAA.h
@@ -21,12 +21,12 @@
*****************************************************************************/
/*
-
+
Anti Aliased Vertical line.
The coordinates are in XX.8 fixed point format, see core/GP_FixedPoint.h
for helper macros.
-
+
For RGB contexts gamma correction tables are used to generate correct
intensity for pixels.
diff --git a/include/grabbers/GP_Grabber.h b/include/grabbers/GP_Grabber.h
index 5591297..f47fd86 100644
--- a/include/grabbers/GP_Grabber.h
+++ b/include/grabbers/GP_Grabber.h
@@ -75,7 +75,7 @@ static inline int GP_GrabberStart(struct GP_Grabber *self)
{
if (self->Start)
return self->Start(self);
-
+
return 0;
}
@@ -83,7 +83,7 @@ static inline int GP_GrabberStop(struct GP_Grabber *self)
{
if (self->Stop)
return self->Stop(self);
-
+
return 0;
}
diff --git a/include/input/GP_Event.h b/include/input/GP_Event.h
index fa71742..eaef373 100644
--- a/include/input/GP_Event.h
+++ b/include/input/GP_Event.h
@@ -23,12 +23,12 @@
/*
Gfxprim event layer.
-
+
Events are lowlevel interface to input devices (human interface).
- Events are notifications that something has changed, eg. button pressed
- Each event carries some information about global state
-
+
*/
#ifndef INPUT_GP_EVENT_H
@@ -145,7 +145,7 @@ enum GP_EventKeyValue {
GP_KEY_KP_3 = 81,
GP_KEY_KP_0 = 82,
GP_KEY_KP_DOT = 83,
-
+
GP_KEY_F11 = 87,
GP_KEY_F12 = 88,
@@ -154,7 +154,7 @@ enum GP_EventKeyValue {
GP_KEY_KP_SLASH = 98,
GP_KEY_SYSRQ = 99,
GP_KEY_RIGHT_ALT = 100,
-
+
GP_KEY_HOME = 102,
GP_KEY_UP = 103,
GP_KEY_PAGE_UP = 104,
@@ -279,18 +279,18 @@ typedef struct GP_Event {
/* input device id */
uint32_t dev_id;
-
+
/* event timestamp */
struct timeval time;
- /*
+ /*
* Cursor position, position on screen accumulated
* from all pointer devices
*/
uint32_t cursor_x;
uint32_t cursor_y;
- /*
+ /*
* Bitmap of pressed keys including mouse buttons
* accumulated for all input devices.
*/
diff --git a/include/input/GP_InputDriverLinux.h b/include/input/GP_InputDriverLinux.h
index bb1b352..031769a 100644
--- a/include/input/GP_InputDriverLinux.h
+++ b/include/input/GP_InputDriverLinux.h
@@ -34,18 +34,18 @@
typedef struct GP_InputDriverLinux {
/* fd */
int fd;
-
+
/* to store rel coordinates */
int rel_x;
int rel_y;
-
+
uint8_t rel_flag;
/* to store abs coordinates */
int abs_x;
int abs_y;
int abs_press;
-
+
int abs_x_max;
int abs_y_max;
int abs_press_max;
diff --git a/include/input/GP_TimeStamp.h b/include/input/GP_TimeStamp.h
index 32bd575..f232f8b 100644
--- a/include/input/GP_TimeStamp.h
+++ b/include/input/GP_TimeStamp.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Returns monotonously incrementing timestamps in milliseconds.
*/
diff --git a/include/input/GP_Timer.h b/include/input/GP_Timer.h
index 6026268..1debab2 100644
--- a/include/input/GP_Timer.h
+++ b/include/input/GP_Timer.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Timers and priority queue implementation.
*/
@@ -48,8 +48,8 @@ typedef struct GP_Timer {
/* Timer id, showed in debug messages */
char id[10];
- /*
- * Timer Callback
+ /*
+ * Timer Callback
*
* If non-zero is returned, the timer is rescheduled to expire
* return value from now.
@@ -73,7 +73,7 @@ typedef struct GP_Timer {
void GP_TimerQueueDump(GP_Timer *queue);
/*
- * Inserts timer into the timer priority queue.
+ * Inserts timer into the timer priority queue.
*/
void GP_TimerQueueInsert(GP_Timer **queue, uint64_t now, GP_Timer *timer);
diff --git a/include/loaders/GP_BMP.h b/include/loaders/GP_BMP.h
index e5ad3a7..4c5ca26 100644
--- a/include/loaders/GP_BMP.h
+++ b/include/loaders/GP_BMP.h
@@ -49,7 +49,7 @@ int GP_OpenBMP(const char *src_path, FILE **f,
/*
* Reads a BMP from a opened file.
- *
+ *
* Upon successful return, context to store bitmap is allocated and image is
* loaded.
*
diff --git a/include/loaders/GP_ByteUtils.h b/include/loaders/GP_ByteUtils.h
index cfa4bea..8a26e9c 100644
--- a/include/loaders/GP_ByteUtils.h
+++ b/include/loaders/GP_ByteUtils.h
@@ -35,7 +35,7 @@
* The format string examples:
*
* Type Modifiers:
- *
+ *
* L - little endian (passed as value to write, passed as pointer to read)
* B - big endian
* A - byte array (passed as bointer for both read and write)
@@ -51,10 +51,10 @@
* char sig[2];
*
* if (GP_FWrite(f, "A2 0x00 0x00 L2 L2", "SG", w, h) != 5)
- * //ERROR
+ * //ERROR
*
* if (GP_FRead(f, "A2 I2 L2 L2", sig, &w, &h) != 4)
- * //ERROR
+ * //ERROR
*/
/*
diff --git a/include/loaders/GP_GIF.h b/include/loaders/GP_GIF.h
index 62284d0..b2ee363 100644
--- a/include/loaders/GP_GIF.h
+++ b/include/loaders/GP_GIF.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
GIF support using giflib library.
*/
diff --git a/include/loaders/GP_JPG.h b/include/loaders/GP_JPG.h
index 5ee57ce..8f6a920 100644
--- a/include/loaders/GP_JPG.h
+++ b/include/loaders/GP_JPG.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
JPG support using jpeg library.
*/
diff --git a/include/loaders/GP_Loader.h b/include/loaders/GP_Loader.h
index f80cf58..6522c0a 100644
--- a/include/loaders/GP_Loader.h
+++ b/include/loaders/GP_Loader.h
@@ -50,13 +50,13 @@ int GP_LoadMetaData(const char *src_path, GP_MetaData *data);
* Simple saving function, the image format is matched by file extension.
*
* Retruns zero on succes.
- *
+ *
* On failure non-zero is returned.
*
* When file type wasn't recognized by extension or if support for requested
* image format wasn't compiled in non-zero is returned and errno is set to
* ENOSYS.
- *
+ *
* The resulting errno may also be set to any possible error from fopen(3), open(3),
* write(3), fwrite(3), seek(3), etc..
*/
@@ -67,7 +67,7 @@ int GP_SaveImage(const GP_Context *src, const char *dst_path,
* You can register your own loader here.
*/
typedef struct GP_Loader {
- /*
+ /*
* Loads an image.
*
* Returns allocated and initialized bitmap on success, NULL on failure
@@ -75,12 +75,12 @@ typedef struct GP_Loader {
*/
GP_Context *(*Load)(const char *src_path, GP_ProgressCallback *callback);
- /*
+ /*
* Save an image.
*
* Returns zero on succes, non-zero on failure and errno must be set.
*/
- int (*Save)(const GP_Context *src, const char *dst_path, GP_ProgressCallback *callback);
+ int (*Save)(const GP_Context *src, const char *dst_path, GP_ProgressCallback *callback);
/*
* The buffer is filled with 32 bytes from an image start, returns 1 if
@@ -95,7 +95,7 @@ typedef struct GP_Loader {
/* don't touch */
struct GP_Loader *next;
-
+
/*
* NULL terminated array of file extensions.
*/
diff --git a/include/loaders/GP_MetaData.h b/include/loaders/GP_MetaData.h
index 2c529d2..5416193 100644
--- a/include/loaders/GP_MetaData.h
+++ b/include/loaders/GP_MetaData.h
@@ -119,7 +119,7 @@ GP_MetaRecord *GP_MetaDataCreateDouble(GP_MetaData *self, const char *id,
*
* If len == 0, string is copied to the terminating '0', otherwise len
* characters is copied. This has no effect if dup == 0.
- *
+ *
* If dup is set to 1, the string is duplicated inside of the MetaData
* structure, otherwise only the pointer is saved.
*/
diff --git a/include/loaders/GP_PNG.h b/include/loaders/GP_PNG.h
index cbb4b70..e9b72ce 100644
--- a/include/loaders/GP_PNG.h
+++ b/include/loaders/GP_PNG.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
PNG support using libpng library.
*/
@@ -55,7 +55,7 @@ int GP_OpenPNG(const char *src_path, FILE **f);
/*
* Reads PNG from an open FILE. Expects the file position set after the eight
* bytes PNG signature.
- *
+ *
* Upon succesfull return pointer to newly allocated context is returned.
* Otherwise NULL is returned and errno is filled.
*/
diff --git a/include/loaders/GP_PSP.h b/include/loaders/GP_PSP.h
index a44ae9b..3ddf75c 100644
--- a/include/loaders/GP_PSP.h
+++ b/include/loaders/GP_PSP.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Experimental Paint Shop Pro image loader.
*/
diff --git a/include/loaders/GP_TIFF.h b/include/loaders/GP_TIFF.h
index f6cb428..cb34585 100644
--- a/include/loaders/GP_TIFF.h
+++ b/include/loaders/GP_TIFF.h
@@ -48,7 +48,7 @@ int GP_OpenTIFF(const char *src_path, void **t);
/*
* Reads a TIFF from a opened file.
- *
+ *
* Upon successful return, context to store bitmap is allocated and image is
* loaded.
*
diff --git a/include/loaders/GP_TmpFile.h b/include/loaders/GP_TmpFile.h
index fe1f8d1..819962b 100644
--- a/include/loaders/GP_TmpFile.h
+++ b/include/loaders/GP_TmpFile.h
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
This is interface for saving GP_Context into non-portable uncompressed file,
which is usefull for caching GP_Context to disk.
diff --git a/include/text/GP_Font.h b/include/text/GP_Font.h
index 3612873..a6a584c 100644
--- a/include/text/GP_Font.h
+++ b/include/text/GP_Font.h
@@ -27,9 +27,9 @@
#define GP_FONT_NAME_MAX 64
-/*
+/*
* Data describing single Glyph.
- *
+ *
* Note that glyph do not necessarily correspond to one character (for example
* ligature is a glyph but corresponds to at least two characters).
*
@@ -67,7 +67,7 @@ typedef struct GP_GlyphBitmap {
*/
uint8_t advance_x;
- /*
+ /*
* Character bitmap, byte aligned bitmap.
*/
uint8_t bitmap[];
@@ -79,7 +79,7 @@ typedef enum GP_CharSet {
/*
* Glyph bitmap data format.
- *
+ *
* The bitmap is byte aligned and for 1BPP the number of bytes per row is
* rounted to bytes.
*
@@ -90,7 +90,7 @@ typedef enum GP_FontBitmapFormat {
} GP_FontBitmapFormat;
/*
- * Font face
+ * Font face
*/
typedef struct GP_FontFace {
/*
@@ -112,7 +112,7 @@ typedef struct GP_FontFace {
* Maximal height of font glyph from baseline to the top.
*/
uint16_t ascend;
-
+
/*
* Maximal length of font glyph from baseline to the bottom.
*/
@@ -120,7 +120,7 @@ typedef struct GP_FontFace {
/*
* Maximal width of font glyph.
- *
+ *
* (basically max from glyph->width + glyph->bearing_x)
*/
uint16_t max_glyph_width;
@@ -136,7 +136,7 @@ typedef struct GP_FontFace {
GP_FontBitmapFormat glyph_bitmap_format;
/*
- * Pointer to glyph bitmap buffer.
+ * Pointer to glyph bitmap buffer.
*/
void *glyphs;
diff --git a/include/text/GP_Text.h b/include/text/GP_Text.h
index 6ee567f..6834417 100644
--- a/include/text/GP_Text.h
+++ b/include/text/GP_Text.h
@@ -73,7 +73,7 @@ void GP_Text_Raw(GP_Context *context, const GP_TextStyle *style,
/*
* Draws a string.
- *
+ *
* The string is rendered to context (horizontally) with defined text style.
* The x and y coordinates determines point defined by aligment flags.
*
diff --git a/include/text/GP_TextMetric.h b/include/text/GP_TextMetric.h
index 16d44bc..e12bdb0 100644
--- a/include/text/GP_TextMetric.h
+++ b/include/text/GP_TextMetric.h
@@ -50,13 +50,13 @@ GP_Size GP_TextMaxStrWidth(const GP_TextStyle *style, const char *str,
*/
GP_Size GP_TextHeight(const GP_TextStyle *style);
-/*
+/*
* Returns the ascent (height from the baseline to the top of characters),
* for the given text style. (Result is in pixels.)
*/
GP_Size GP_TextAscent(const GP_TextStyle *style);
-/*
+/*
* Returns the descent (height from the baseline to the bottom of characters),
* for the given text style. (Result is in pixels.)
*/
diff --git a/lib.mk b/lib.mk
index 2aa9b00..b8e4a20 100644
--- a/lib.mk
+++ b/lib.mk
@@ -27,7 +27,7 @@ LIBS=$(BUILD_DIR)$(STATIC_LIB) $(BUILD_DIR)$(DYNAMIC_LIB)
ALL+=$(LIBS) $(SYMLINKS)
CLEAN+=$(LIBS) $(addprefix $(BUILD_DIR),$(SYMLINKS))
-#
+#
# OBJECTS are set in post.mk so we need to duplicate the values in
# OBJS here too to have correct dependencies
#
diff --git a/libs/backends/GP_Backend.c b/libs/backends/GP_Backend.c
index c216177..bcc7ac3 100644
--- a/libs/backends/GP_Backend.c
+++ b/libs/backends/GP_Backend.c
@@ -58,7 +58,7 @@ void GP_BackendUpdateRectXYXY(GP_Backend *backend,
GP_WARN("Negative x coordinate %i, clipping to 0", x0);
x0 = 0;
}
-
+
if (y0 < 0) {
GP_WARN("Negative y coordinate %i, clipping to 0", y0);
y0 = 0;
@@ -70,14 +70,14 @@ void GP_BackendUpdateRectXYXY(GP_Backend *backend,
GP_WARN("Too large x coordinate %i, clipping to %u", x1, w - 1);
x1 = w - 1;
}
-
+
GP_Coord h = backend->context->h;
if (y1 >= h) {
GP_WARN("Too large y coordinate %i, clipping to %u", y1, h - 1);
y1 = h - 1;
}
-
+
backend->UpdateRect(backend, x0, y0, x1, y1);
}
@@ -86,7 +86,7 @@ int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h)
{
if (backend->SetAttributes == NULL)
return 1;
-
+
if (w == 0)
w = backend->context->w;
@@ -102,7 +102,7 @@ int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h)
int GP_BackendResizeAck(GP_Backend *self)
{
GP_DEBUG(2, "Calling backend %s ResizeAck()", self->name);
-
+
if (self->ResizeAck)
return self->ResizeAck(self);
@@ -144,7 +144,7 @@ static void wait_timers_fd(GP_Backend *self, uint64_t now)
int timeout;
timeout = self->timers->expires - now;
-
+
struct pollfd fd = {.fd = self->fd, .events = POLLIN, fd.revents = 0};
if (poll(&fd, 1, timeout))
@@ -203,7 +203,7 @@ int GP_BackendWaitEvent(GP_Backend *self, GP_Event *ev)
for (;;) {
if ((ret = GP_BackendGetEvent(self, ev)))
return ret;
-
+
GP_BackendWait(self);
}
}
@@ -211,12 +211,12 @@ int GP_BackendWaitEvent(GP_Backend *self, GP_Event *ev)
int GP_BackendPollEvent(GP_Backend *self, GP_Event *ev)
{
int ret;
-
+
if ((ret = GP_BackendGetEvent(self, ev)))
return ret;
GP_BackendPoll(self);
-
+
if ((ret = GP_BackendGetEvent(self, ev)))
return ret;
diff --git a/libs/backends/GP_BackendInit.c b/libs/backends/GP_BackendInit.c
index 1234a1c..f0a20f1 100644
--- a/libs/backends/GP_BackendInit.c
+++ b/libs/backends/GP_BackendInit.c
@@ -50,7 +50,7 @@ static int sdl_params_to_flags(const char *param, GP_Size *w, GP_Size *h,
*flags |= GP_SDL_FULLSCREEN;
return 0;
}
-
+
/*
* Accepts only string with format "intxint" or "intXint"
*/
@@ -73,10 +73,10 @@ static GP_Backend *backend_sdl_init(char *params, const char *caption,
{
if (params == NULL)
return GP_BackendSDLInit(0, 0, 0, 0, caption);
-
+
GP_Size w = 0, h = 0;
uint8_t flags = GP_SDL_RESIZABLE;
-
+
char *s = params;
for (;;) {
@@ -91,7 +91,7 @@ static GP_Backend *backend_sdl_init(char *params, const char *caption,
case '0':
if (sdl_params_to_flags(params, &w, &h, &flags, help))
return NULL;
-
+
return GP_BackendSDLInit(w, h, 0, flags, caption);
break;
}
@@ -116,7 +116,7 @@ static GP_Backend *backend_fb_init(char *params, const char *caption,
FILE *help)
{
const char *fb = "/dev/fb0";
-
+
(void) help;
(void) caption;
@@ -153,7 +153,7 @@ static int x11_params_to_flags(const char *param, GP_Size *w, GP_Size *h,
*flags |= GP_X11_USE_ROOT_WIN;
return 0;
}
-
+
if (!strcasecmp(param, "CREATE_ROOT")) {
*flags |= GP_X11_CREATE_ROOT_WIN;
return 0;
@@ -163,7 +163,7 @@ static int x11_params_to_flags(const char *param, GP_Size *w, GP_Size *h,
*flags |= GP_X11_DISABLE_SHM;
return 0;
}
-
+
if (!strcasecmp(param, "FS")) {
*flags |= GP_X11_FULLSCREEN;
return 0;
@@ -192,7 +192,7 @@ static GP_Backend *backend_x11_init(char *params, const char *caption,
{
GP_Size w = 640, h = 480;
enum GP_BackendX11Flags flags = 0;
-
+
if (params == NULL)
return GP_BackendX11Init(NULL, 0, 0, w, h, caption, 0);
@@ -210,7 +210,7 @@ static GP_Backend *backend_x11_init(char *params, const char *caption,
case '0':
if (x11_params_to_flags(params, &w, &h, &flags, help))
return NULL;
-
+
return GP_BackendX11Init(NULL, 0, 0, w, h, caption, flags);
break;
}
@@ -267,7 +267,7 @@ static int get_backend(const char *name)
for (i = 0; backend_names[i] != 0; i++)
if (!strcasecmp(name, backend_names[i]))
return i;
-
+
return -1;
}
@@ -295,11 +295,11 @@ GP_Backend *GP_BackendInit(const char *params, const char *caption, FILE *help)
print_help(help, NULL);
return NULL;
}
-
+
/* parse backend name */
int i, len = strlen(params);
char buf[len+1], *backend_params = NULL;
-
+
strcpy(buf, params);
for (i = 0; i < len; i++) {
diff --git a/libs/backends/GP_BackendVirtual.c b/libs/backends/GP_BackendVirtual.c
index 7ea1238..5ebf621 100644
--- a/libs/backends/GP_BackendVirtual.c
+++ b/libs/backends/GP_BackendVirtual.c
@@ -31,7 +31,7 @@
struct virt_priv {
/* Original backend */
GP_Backend *backend;
-
+
int flags;
};
@@ -51,11 +51,11 @@ 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);
}
@@ -96,7 +96,7 @@ static void virt_wait(GP_Backend *self)
struct virt_priv *virt = GP_BACKEND_PRIV(self);
virt->backend->Wait(virt->backend);
-
+
struct GP_Event ev;
while (GP_BackendGetEvent(virt->backend, &ev))
@@ -106,9 +106,9 @@ static void virt_wait(GP_Backend *self)
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);
@@ -128,7 +128,7 @@ GP_Backend *GP_BackendVirtualInit(GP_Backend *backend,
GP_DEBUG(1, "Malloc failed :(");
return NULL;
}
-
+
memset(self, 0, sizeof(GP_Backend));
/* Create new buffer with different context type */
@@ -137,7 +137,7 @@ GP_Backend *GP_BackendVirtualInit(GP_Backend *backend,
if (self->context == NULL)
goto err0;
-
+
virt = GP_BACKEND_PRIV(self);
virt->backend = backend;
virt->flags = flags;
diff --git a/libs/backends/GP_InputDriverSDL.c b/libs/backends/GP_InputDriverSDL.c
index d94272d..6b478c8 100644
--- a/libs/backends/GP_InputDriverSDL.c
+++ b/libs/backends/GP_InputDriverSDL.c
@@ -143,7 +143,7 @@ void GP_InputDriverSDLEventPut(struct GP_EventQueue *event_queue,
GP_WARN("Unmapped SDL keysym %u", keysym);
return;
}
-
+
GP_EventQueuePushKey(event_queue, key, ev->key.state, NULL);
break;
case SDL_VIDEORESIZE:
diff --git a/libs/backends/GP_InputDriverX11.c b/libs/backends/GP_InputDriverX11.c
index 750dc17..fc6149f 100644
--- a/libs/backends/GP_InputDriverX11.c
+++ b/libs/backends/GP_InputDriverX11.c
@@ -183,7 +183,7 @@ static void init_table(Display *dpy)
GP_WARN("Key '%s' keycode %u collides with key '%s'",
GP_EventKeyName(sym_to_key[i].key), keycode,
GP_EventKeyName(keycode_table[keycode - 9]));
- continue;
+ continue;
}
keycode_table[keycode - 9] = sym_to_key[i].key;
@@ -239,7 +239,7 @@ void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue,
GP_EV_REL_WHEEL, -1, NULL);
return;
}
-
+
if (key == 0) {
GP_WARN("Unmapped X11 button %02x",
ev->xbutton.button);
@@ -258,7 +258,7 @@ void GP_InputDriverX11EventPut(struct GP_EventQueue *event_queue,
if (ev->xmotion.x < 0 || ev->xmotion.y < 0 ||
ev->xmotion.x > w || ev->xmotion.y > h)
return;
-
+
GP_EventQueuePushRelTo(event_queue,
ev->xmotion.x, ev->xmotion.y, NULL);
break;
diff --git a/libs/backends/GP_LinuxFB.c b/libs/backends/GP_LinuxFB.c
index 49566aa..9f5c83c 100644
--- a/libs/backends/GP_LinuxFB.c
+++ b/libs/backends/GP_LinuxFB.c
@@ -50,7 +50,7 @@ struct fb_priv {
int con_nr;
int last_con_nr;
int saved_kb_mode;
-
+
int fb_fd;
char path[];
};
@@ -74,7 +74,7 @@ static int allocate_console(struct fb_priv *fb, int flag)
strerror(errno));
return -1;
}
-
+
if (ioctl(fd, VT_OPENQRY, &nr) < 0) {
GP_DEBUG(1, "Failed to ioctl VT_OPENQRY /dev/tty1: %s",
strerror(errno));
@@ -94,7 +94,7 @@ static int allocate_console(struct fb_priv *fb, int flag)
buf, strerror(errno));
return -1;
}
-
+
if (ioctl(fd, VT_GETSTATE, &vts) == 0)
fb->last_con_nr = vts.v_active;
else
@@ -128,14 +128,14 @@ static int allocate_console(struct fb_priv *fb, int flag)
if (flag) {
struct termios t;
cfmakeraw(&t);
-
+
if (tcsetattr(fd, TCSANOW, &t) < 0) {
GP_DEBUG(1, "Failed to tcsetattr(): %s",
strerror(errno));
close(fd);
return -1;
}
-
+
if (ioctl(fd, KDGKBMODE, &fb->saved_kb_mode)) {
GP_DEBUG(1, "Failed to ioctl KDGKBMODE %s: %s",
buf, strerror(errno));
@@ -164,7 +164,7 @@ static int allocate_console(struct fb_priv *fb, int flag)
static void fb_poll(GP_Backend *self)
{
- struct fb_priv *fb = GP_BACKEND_PRIV(self);
+ struct fb_priv *fb = GP_BACKEND_PRIV(self);
unsigned char buf[16];
int i, res;
@@ -176,7 +176,7 @@ static void fb_poll(GP_Backend *self)
static void fb_wait(GP_Backend *self)
{
- struct fb_priv *fb = GP_BACKEND_PRIV(self);
+ struct fb_priv *fb = GP_BACKEND_PRIV(self);
struct pollfd fd = {.fd = fb->con_fd, .events = POLLIN, .revents = 0};
@@ -188,15 +188,15 @@ static void fb_wait(GP_Backend *self)
static void fb_exit(GP_Backend *self)
{
- struct fb_priv *fb = GP_BACKEND_PRIV(self);
+ struct fb_priv *fb = GP_BACKEND_PRIV(self);
/* unmap framebuffer */
munmap(fb->context.pixels, fb->bsize);
close(fb->fb_fd);
-
+
/* 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) {
@@ -204,11 +204,11 @@ static void fb_exit(GP_Backend *self)
" /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);
-
+
close(fb->con_fd);
free(self);
}
@@ -220,7 +220,7 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag)
struct fb_fix_screeninfo fscri;
struct fb_var_screeninfo vscri;
int fd;
-
+
backend = malloc(sizeof(GP_Backend) +
sizeof(struct fb_priv) + strlen(path) + 1);
@@ -236,7 +236,7 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag)
GP_DEBUG(1, "Opening framebuffer '%s'", path);
fd = open(path, O_RDWR);
-
+
if (fd < 0) {
GP_DEBUG(1, "Opening framebuffer failed: %s", strerror(errno));
goto err2;
@@ -247,7 +247,7 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag)
strerror(errno));
goto err3;
}
-
+
if (ioctl(fd, FBIOGET_VSCREENINFO, &vscri) < 0) {
GP_DEBUG(1, "Failed to ioctl FBIOGET_VSCREENINFO: %s",
strerror(errno));
@@ -293,7 +293,7 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag)
fb->context.w = vscri.xres;
fb->context.h = vscri.yres;
-
+
fb->context.axes_swap = 0;
fb->context.x_swap = 0;
fb->context.y_swap = 0;
@@ -322,10 +322,10 @@ err3:
close(fd);
err2:
close(fb->con_fd);
-
+
/* reset keyboard */
ioctl(fb->con_fd, KDSETMODE, KD_TEXT);
-
+
/* switch back console */
if (fb->last_con_nr != -1)
ioctl(fb->con_fd, VT_ACTIVATE, fb->last_con_nr);
diff --git a/libs/backends/GP_SDL.c b/libs/backends/GP_SDL.c
index 1e73ecf..ab87c82 100644
--- a/libs/backends/GP_SDL.c
+++ b/libs/backends/GP_SDL.c
@@ -73,7 +73,7 @@ static void sdl_update_rect(struct GP_Backend *self __attribute__((unused)),
if (x1 != 0 && y1 != 0)
SDL_UpdateRect(sdl_surface, x0, y0,
GP_ABS(x1 - x0) + 1, GP_ABS(y1 - y0) + 1);
-
+
SDL_mutexV(mutex);
}
@@ -158,7 +158,7 @@ static int sdl_set_attributes(struct GP_Backend *self,
{
SDL_mutexP(mutex);
- if (caption != NULL)
+ if (caption != NULL)
SDL_WM_SetCaption(caption, caption);
/* Send only resize event, the actual resize is done in resize_ack */
@@ -173,7 +173,7 @@ static int sdl_set_attributes(struct GP_Backend *self,
static int sdl_resize_ack(struct GP_Backend *self __attribute__((unused)))
{
GP_DEBUG(2, "Resizing the buffer to %ux%u", new_w, new_h);
-
+
SDL_mutexP(mutex);
sdl_surface = SDL_SetVideoMode(new_w, new_h, 0, sdl_flags);
@@ -183,7 +183,7 @@ static int sdl_resize_ack(struct GP_Backend *self __attribute__((unused)))
backend.context->w, backend.context->h);
SDL_mutexV(mutex);
-
+
return 0;
}
@@ -206,9 +206,9 @@ static struct GP_Backend backend = {
static void sdl_exit(struct GP_Backend *self __attribute__((unused)))
{
SDL_mutexP(mutex);
-
+
SDL_Quit();
-
+
SDL_DestroyMutex(mutex);
backend.context = NULL;
@@ -253,11 +253,11 @@ GP_Backend *GP_BackendSDLInit(GP_Size w, GP_Size h, uint8_t bpp, uint8_t flags,
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,
SDL_DEFAULT_REPEAT_INTERVAL);
-
+
GP_EventQueueInit(&backend.event_queue, w, h, 0);
backend.context = &context;
-
+
return &backend;
}
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index b0aff6d..7392202 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -149,12 +149,12 @@ static void x11_ev(XEvent *ev)
case ConfigureNotify:
if (ev->xconfigure.width == (int)self->context->w &&
ev->xconfigure.height == (int)self->context->h)
- break;
-
+ break;
+
if (ev->xconfigure.width == (int)win->new_w &&
ev->xconfigure.height == (int)win->new_h)
- break;
-
+ break;
+
win->new_w = ev->xconfigure.width;
win->new_h = ev->xconfigure.height;
diff --git a/libs/backends/GP_X11_Conn.h b/libs/backends/GP_X11_Conn.h
index f8bf3bf..87a188c 100644
--- a/libs/backends/GP_X11_Conn.h
+++ b/libs/backends/GP_X11_Conn.h
@@ -39,7 +39,7 @@ static unsigned int x11_open(const char *display)
{
if (x11_conn.ref_cnt != 0)
return ++x11_conn.ref_cnt;
-
+
GP_DEBUG(1, "Opening X11 display '%s'", display);
if (!XInitThreads()) {
@@ -65,14 +65,14 @@ static void x11_close(void)
/* Ignore close requests if connection is closed */
if (x11_conn.ref_cnt == 0)
return;
-
+
if (--x11_conn.ref_cnt != 0)
return;
GP_DEBUG(1, "Closing X11 display");
XLockDisplay(x11_conn.dpy);
-
+
/* I wonder if this is right sequence... */
//XUnlockDisplay(x11_conn.dpy);
XCloseDisplay(x11_conn.dpy);
diff --git a/libs/backends/GP_X11_Win.h b/libs/backends/GP_X11_Win.h
index eb6905b..b2dfec3 100644
--- a/libs/backends/GP_X11_Win.h
+++ b/libs/backends/GP_X11_Win.h
@@ -109,7 +109,7 @@ static void x11_win_fullscreen(struct x11_win *win, int mode)
GP_DEBUG(2, "Requesting fullscreen mode = %u", mode);
Atom wm_state, fullscreen;
-
+
wm_state = XInternAtom(win->dpy, "_NET_WM_STATE", True);
fullscreen = XInternAtom(win->dpy, "_NET_WM_STATE_FULLSCREEN", True);
@@ -193,7 +193,7 @@ static int x11_win_open(struct x11_wreq *wreq)
KeyReleaseMask | PointerMotionMask;
attr_mask |= CWEventMask;
- /*
+ /*
* If root window was selected, resize w and h and set win->win to root
* window.
*/
@@ -202,66 +202,66 @@ static int x11_win_open(struct x11_wreq *wreq)
win->win = DefaultRootWindow(win->dpy);
x11_get_screen_size(wreq);
-
+
GP_DEBUG(2, "Using root window, owerriding size to %ux%u",
- wreq->w, wreq->h);
+ wreq->w, wreq->h);
win_list_add(win);
-
+
XChangeWindowAttributes(win->dpy, win->win, attr_mask, &attrs);
-
+
return 0;
}
- /*
+ /*
* For some reason reading mouse button clicks on root win are not
* allowed...
*/
attrs.event_mask |= ButtonPressMask | ButtonReleaseMask;
-
+
/*
* Create undecoreated root window on background
*/
if (wreq->flags & GP_X11_CREATE_ROOT_WIN) {
Atom xa;
-
+
x11_get_screen_size(wreq);
-
+
GP_DEBUG(2, "Creating a window above root, owerriding size to %ux%u",
wreq->w, wreq->h);
win->win = XCreateWindow(win->dpy, DefaultRootWindow(win->dpy),
0, 0, wreq->w, wreq->h, 0, CopyFromParent,
InputOutput, CopyFromParent, attr_mask, &attrs);
-
+
/* Set empty WM_PROTOCOLS */
GP_DEBUG(2, "Setting empty MW_PROTOCOLS");
XSetWMProtocols(win->dpy, win->win, NULL, 0);
/* Set window type to desktop */
xa = XInternAtom(win->dpy, "_NET_WM_WINDOW_TYPE", False);
-
+
if (xa != None) {
GP_DEBUG(2, "Setting Atom _NET_WM_WINDOW_TYPE to _NET_WM_WINDOW_TYPE_DESKTOP");
-
+
Atom xa_prop = XInternAtom(win->dpy, "_NET_WM_WINDOW_TYPE_DESKTOP", False);
-
+
XChangeProperty(win->dpy, win->win, xa, XA_ATOM, 32,
PropModeReplace, (unsigned char *) &xa_prop, 1);
}
-
+
/* Turn off window decoration */
xa = XInternAtom(win->dpy, "_MOTIF_WM_HINTS", False);
-
+
if (xa != None) {
GP_DEBUG(2, "Setting Atom _MOTIF_WM_HINTS to 2, 0, 0, 0, 0");
-
+
long prop[5] = {2, 0, 0, 0, 0};
XChangeProperty(win->dpy, win->win, xa, xa, 32,
PropModeReplace, (unsigned char *) prop, 5);
}
-
+
/* Set below other windows */
xa = XInternAtom(win->dpy, "_WIN_LAYER", False);
@@ -273,26 +273,26 @@ static int x11_win_open(struct x11_wreq *wreq)
XChangeProperty(win->dpy, win->win, xa, XA_CARDINAL, 32,
PropModeAppend, (unsigned char *) &prop, 1);
}
-
+
xa = XInternAtom(win->dpy, "_NET_WM_STATE", False);
if (xa != None) {
GP_DEBUG(2, "Setting Atom _NET_WM_STATE to _NET_WM_STATE_BELOW");
-
+
Atom xa_prop = XInternAtom(win->dpy, "_NET_WM_STATE_BELOW", False);
XChangeProperty(win->dpy, win->win, xa, XA_ATOM, 32,
PropModeAppend, (unsigned char *) &xa_prop, 1);
}
-
+
/* Set sticky */
xa = XInternAtom(win->dpy, "_NET_WM_DESKTOP", False);
-
+
if (xa != None) {
GP_DEBUG(2, "Setting Atom _NET_WM_DESKTOP to 0xffffffff");
CARD32 xa_prop = 0xffffffff;
-
+
XChangeProperty(win->dpy, win->win, xa, XA_CARDINAL, 32,
PropModeAppend, (unsigned char *) &xa_prop, 1);
}
@@ -307,10 +307,10 @@ static int x11_win_open(struct x11_wreq *wreq)
XChangeProperty(win->dpy, win->win, xa, XA_ATOM, 32,
PropModeAppend, (unsigned char *) &xa_prop, 1);
}
-
+
/* Skip taskbar */
xa = XInternAtom(win->dpy, "_NET_WM_STATE", False);
-
+
if (xa != None) {
GP_DEBUG(2, "Appending to Atom _NET_WM_STATE atom _NET_STATE_SKIP_TASKBAR");
@@ -319,10 +319,10 @@ static int x11_win_open(struct x11_wreq *wreq)
XChangeProperty(win->dpy, win->win, xa, XA_ATOM, 32,
PropModeAppend, (unsigned char *) &xa_prop, 1);
}
-
+
/* Skip pager */
xa = XInternAtom(win->dpy, "_NET_WM_STATE", False);
-
+
if (xa != None) {
GP_DEBUG(2, "Appending to Atom _NET_WM_STATE atom _NET_STATE_SKIP_PAGER");
@@ -331,7 +331,7 @@ static int x11_win_open(struct x11_wreq *wreq)
XChangeProperty(win->dpy, win->win, xa, XA_ATOM, 32,
PropModeAppend, (unsigned char *) &xa_prop, 1);
}
-
+
/* Set 100% opacity */
xa = XInternAtom(win->dpy, "_NET_WM_WINDOW_OPACITY", False);
@@ -343,7 +343,7 @@ static int x11_win_open(struct x11_wreq *wreq)
XChangeProperty(win->dpy, win->win, xa, XA_CARDINAL, 32,
PropModeAppend, (unsigned char *) &prop, 1);
}
-
+
win_list_add(win);
/* Show window */
@@ -358,7 +358,7 @@ static int x11_win_open(struct x11_wreq *wreq)
wreq->x, wreq->y, wreq->w, wreq->h, 0,
CopyFromParent, InputOutput, CopyFromParent,
attr_mask, &attrs);
-
+
/* Set window caption */
XmbSetWMProperties(win->dpy, win->win, wreq->caption, wreq->caption,
NULL, 0, NULL, NULL, NULL);
@@ -373,9 +373,9 @@ static int x11_win_open(struct x11_wreq *wreq)
} else {
GP_DEBUG(2, "Failed to set WM_DELETE_WINDOW Atom to True");
}
-
+
win_list_add(win);
-
+
/* Show window */
XMapWindow(win->dpy, win->win);
@@ -395,9 +395,9 @@ static void x11_win_close(struct x11_win *win)
destroy_ximage(self);
*/
XUnmapWindow(win->dpy, win->win);
-
+
XDestroyWindow(win->dpy, win->win);
-
+
XUnlockDisplay(win->dpy);
/* Close connection/Decrease ref count */
diff --git a/libs/core/GP_Blit.c b/libs/core/GP_Blit.c
index 58e818a..1651ca9 100644
--- a/libs/core/GP_Blit.c
+++ b/libs/core/GP_Blit.c
@@ -48,7 +48,7 @@ void GP_BlitXYXY_Naive(const GP_Context *src,
for (x = x0; x <= x1; x++) {
GP_Pixel p = GP_GetPixel(src, x, y);
- if (src->pixel_type != dst->pixel_type)
+ if (src->pixel_type != dst->pixel_type)
p = GP_ConvertContextPixel(p, src, dst);
GP_PutPixel(dst, x2 + (x - x0), y2 + (y - y0), p);
@@ -93,11 +93,11 @@ void GP_BlitXYXY_Clipped(const GP_Context *src,
if (y1 < y0)
GP_SWAP(y0, y1);
-
+
/* Noting to blit return now */
if (x2 >= (GP_Coord)GP_ContextW(dst) ||
y2 >= (GP_Coord)GP_ContextH(dst))
- return;
+ return;
/* We need to shift source rectangle */
if (x2 < 0) {
@@ -140,7 +140,7 @@ void GP_BlitXYXY_Clipped(const GP_Context *src,
if (GP_ContextRotationEqual(src, dst))
GP_BlitXYXY_Raw_Fast(src, x0, y0, x1, y1, dst, x2, y2);
- else
+ else
GP_BlitXYXY_Fast(src, x0, y0, x1, y1, dst, x2, y2);
}
diff --git a/libs/core/GP_Blit.gen.c.t b/libs/core/GP_Blit.gen.c.t
index d743fc4..80c7f68 100644
--- a/libs/core/GP_Blit.gen.c.t
+++ b/libs/core/GP_Blit.gen.c.t
@@ -140,7 +140,7 @@ static void blitXYXY_Raw_{{ src.name }}_{{ dst.name }}(const GP_Context *src,
dy = y2 + (y - y0);
GP_Pixel p1, p2 = 0, p3 = 0;
-
+
p1 = GP_GetPixel_Raw_{{ src.pixelsize.suffix }}(src, x, y);
%% if src.is_alpha()
p2 = GP_GetPixel_Raw_{{ dst.pixelsize.suffix }}(dst, dx, dy);
diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c
index a7855c7..8e61ce0 100644
--- a/libs/core/GP_Context.c
+++ b/libs/core/GP_Context.c
@@ -129,7 +129,7 @@ GP_Context *GP_ContextInit(GP_Context *context, GP_Size w, GP_Size h,
context->pixel_type = type;
context->bit_endian = 0;
-
+
context->gamma = NULL;
/* rotation and mirroring */
@@ -196,10 +196,10 @@ GP_Context *GP_ContextCopy(const GP_Context *src, int flags)
GP_ContextCopyRotation(src, new);
else
GP_ContextSetRotation(new, 0, 0, 0);
-
+
//TODO: Copy the gamma too
new->gamma = NULL;
-
+
new->free_pixels = 1;
return new;
@@ -216,8 +216,8 @@ GP_Context *GP_ContextConvertAlloc(const GP_Context *src,
if (ret == NULL)
return NULL;
-
- /*
+
+ /*
* Fill the buffer with zeroes, otherwise it will
* contain random data which will generate mess
* when converting image with alpha channel.
@@ -225,7 +225,7 @@ GP_Context *GP_ContextConvertAlloc(const GP_Context *src,
memset(ret->pixels, 0, ret->bytes_per_row * ret->h);
GP_Blit(src, 0, 0, w, h, ret, 0, 0);
-
+
return ret;
}
@@ -234,14 +234,14 @@ GP_Context *GP_ContextConvert(const GP_Context *src, GP_Context *dst)
//TODO: Asserts
int w = GP_ContextW(src);
int h = GP_ContextH(src);
-
- /*
+
+ /*
* Fill the buffer with zeroes, otherwise it will
* contain random data which will generate mess
* when converting image with alpha channel.
*/
memset(dst->pixels, 0, dst->bytes_per_row * dst->h);
-
+
GP_Blit(src, 0, 0, w, h, dst, 0, 0);
return dst;
@@ -270,7 +270,7 @@ GP_Context *GP_SubContext(const GP_Context *context, GP_Context *subcontext,
GP_CHECK(context->w >= x + w, "Subcontext w out of original context.");
GP_CHECK(context->h >= y + h, "Subcontext h out of original context.");
-
+
subcontext->bpp = context->bpp;
subcontext->bytes_per_row = context->bytes_per_row;
subcontext->offset = (context->offset +
@@ -281,7 +281,7 @@ GP_Context *GP_SubContext(const GP_Context *context, GP_Context *subcontext,
subcontext->pixel_type = context->pixel_type;
subcontext->bit_endian = context->bit_endian;
-
+
/* gamma */
subcontext->gamma = context->gamma;
@@ -307,7 +307,7 @@ void GP_ContextPrintInfo(const GP_Context *self)
printf("Offsett%u (only unaligned pixel types)n", self->offset);
printf("Flagstaxes_swap=%u x_swap=%u y_swap=%u free_pixels=%un",
self->axes_swap, self->x_swap, self->y_swap, self->free_pixels);
-
+
if (self->gamma)
GP_GammaPrint(self->gamma);
}
@@ -343,12 +343,12 @@ void GP_ContextRotateCW(GP_Context *context)
context->x_swap = 1;
return;
}
-
+
if (context->x_swap && !context->y_swap) {
context->y_swap = 1;
return;
}
-
+
if (context->x_swap && context->y_swap) {
context->x_swap = 0;
return;
@@ -365,12 +365,12 @@ void GP_ContextRotateCCW(GP_Context *context)
context->y_swap = 1;
return;
}
-
+
if (context->x_swap && !context->y_swap) {
context->x_swap = 0;
return;
}
-
+
if (context->x_swap && context->y_swap) {
context->y_swap = 0;
return;
@@ -389,7 +389,7 @@ int GP_ContextEqual(const GP_Context *ctx1, const GP_Context *ctx2)
if (GP_ContextH(ctx1) != GP_ContextH(ctx2))
return 0;
-
+
GP_Coord x, y, w = GP_ContextW(ctx1), h = GP_ContextH(ctx1);
for (x = 0; x < w; x++)
diff --git a/libs/core/GP_Debug.c b/libs/core/GP_Debug.c
index 89d6047..9605507 100644
--- a/libs/core/GP_Debug.c
+++ b/libs/core/GP_Debug.c
@@ -50,15 +50,15 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line,
const char *fmt, ...)
{
int i;
-
+
if (!env_used) {
char *level = getenv("GP_DEBUG");
-
+
env_used = 1;
-
+
if (level != NULL) {
int new_level = atoi(level);
-
+
if (new_level >= 0) {
debug_level = new_level;
@@ -67,10 +67,10 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line,
debug_level);
}
}
-
+
GP_DEBUG(1, "GFXprim library version " GP_VER_STR);
}
-
+
if (level > (int)debug_level)
return;
@@ -78,7 +78,7 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line,
if (debug_handler) {
char buf[256];
- va_list va;
+ va_list va;
va_start(va, fmt);
vsnprintf(buf, sizeof(buf), fmt, va);
va_end(va);
@@ -92,7 +92,7 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line,
};
debug_handler(&msg);
-
+
return;
}
@@ -122,6 +122,6 @@ void GP_DebugPrint(int level, const char *file, const char *function, int line,
va_start(va, fmt);
vfprintf(stderr, fmt, va);
va_end(va);
-
+
fputc('n', stderr);
}
diff --git a/libs/core/GP_Gamma.c b/libs/core/GP_Gamma.c
index 6268b91..05500f9 100644
--- a/libs/core/GP_Gamma.c
+++ b/libs/core/GP_Gamma.c
@@ -48,7 +48,7 @@ static void fill_table16(GP_GammaTable *table, float gamma,
unsigned int i;
unsigned int in_max = (1<<in_bits) - 1;
unsigned int out_max = (1<<out_bits) - 1;
-
+
GP_DEBUG(3, "Initalizing gamma table %f", gamma);
for (i = 0; i < (1U<<in_bits); i++)
@@ -86,13 +86,13 @@ static GP_GammaTable *get_table(float gamma, uint8_t in_bits, uint8_t out_bits)
i->in_bits = in_bits;
i->out_bits = out_bits;
i->ref_count = 1;
- i->type = GP_CORRECTION_GAMMA;
-
+ i->type = GP_CORRECTION_GAMMA;
+
if (out_bits > 8)
fill_table16(i, gamma, in_bits, out_bits);
else
fill_table8(i, gamma, in_bits, out_bits);
-
+
/* Insert it into link list */
i->next = tables;
tables = i;
@@ -104,7 +104,7 @@ static void put_table(GP_GammaTable *table)
{
if (table == NULL)
return;
-
+
table->ref_count--;
GP_DEBUG(2, "Putting gamma table Gamma %f, in_bits %u, out_bits %u, "
@@ -113,9 +113,9 @@ static void put_table(GP_GammaTable *table)
if (table->ref_count == 0) {
GP_DEBUG(2, "Gamma table ref_count == 0, removing...");
-
+
GP_GammaTable *i, *prev = NULL;
-
+
/* Remove from link list and free */
for (i = tables; i != NULL; i = i->next) {
if (table == i)
@@ -127,7 +127,7 @@ static void put_table(GP_GammaTable *table)
tables = table->next;
else
prev->next = table->next;
-
+
free(table);
}
}
@@ -136,7 +136,7 @@ GP_Gamma *GP_GammaAcquire(GP_PixelType pixel_type, float gamma)
{
GP_CHECK_VALID_PIXELTYPE(pixel_type);
int channels = GP_PixelTypes[pixel_type].numchannels, i;
-
+
GP_DEBUG(1, "Acquiring Gamma table %s gamma %f", GP_PixelTypeName(pixel_type), gamma);
GP_Gamma *res = malloc(sizeof(struct GP_Gamma) + 2 * channels * sizeof(void*));
@@ -157,18 +157,18 @@ GP_Gamma *GP_GammaAcquire(GP_PixelType pixel_type, float gamma)
for (i = 0; i < channels; i++) {
unsigned int chan_size = GP_PixelTypes[pixel_type].channels[i].size;
res->tables[i] = get_table(gamma, chan_size, chan_size + 2);
-
+
if (res->tables[i] == NULL) {
GP_GammaRelease(res);
return NULL;
}
}
-
+
/* And reverse tables, n + 2 bits -> n bits */
for (i = 0; i < channels; i++) {
unsigned int chan_size = GP_PixelTypes[pixel_type].channels[i].size;
res->tables[i + channels] = get_table(1/gamma, chan_size + 2, chan_size);
-
+
if (res->tables[i] == NULL) {
GP_GammaRelease(res);
return NULL;
@@ -222,13 +222,13 @@ void GP_GammaPrint(const GP_Gamma *self)
for (i = 0; i < desc->numchannels; i++) {
enum GP_CorrectionType type = self->tables[i]->type;
-
+
printf(" %s: %s", desc->channels[i].name,
correction_type_name(type));
if (type == GP_CORRECTION_GAMMA)
printf(" gamma = %.2f", self->tables[i]->gamma);
-
+
printf("n");
}
}
diff --git a/libs/core/GP_GetPutPixel.c b/libs/core/GP_GetPutPixel.c
index 83e4ff2..4a083ac 100644
--- a/libs/core/GP_GetPutPixel.c
+++ b/libs/core/GP_GetPutPixel.c
@@ -27,7 +27,7 @@
GP_Pixel GP_GetPixel(const GP_Context *context, GP_Coord x, GP_Coord y)
{
GP_TRANSFORM_POINT(context, x, y);
- if (GP_PIXEL_IS_CLIPPED(context, x, y))
+ if (GP_PIXEL_IS_CLIPPED(context, x, y))
return 0;
return GP_GetPixel_Raw(context, x, y);
}
@@ -35,7 +35,7 @@ GP_Pixel GP_GetPixel(const GP_Context *context, GP_Coord x, GP_Coord y)
void GP_PutPixel(GP_Context *context, GP_Coord x, GP_Coord y, GP_Pixel p)
{
GP_TRANSFORM_POINT(context, x, y);
- if (!GP_PIXEL_IS_CLIPPED(context, x, y))
+ if (!GP_PIXEL_IS_CLIPPED(context, x, y))
GP_PutPixel_Raw(context, x, y, p);
}
diff --git a/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c
index a210892..4fb13fb 100644
--- a/libs/core/GP_Pixel.c
+++ b/libs/core/GP_Pixel.c
@@ -94,16 +94,16 @@ GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
if (r)
GP_DEBUG(3, "Matching R %i %i", r->size, r->offset);
-
+
if (g)
GP_DEBUG(3, "Matching G %i %i", g->size, g->offset);
-
+
if (b)
GP_DEBUG(3, "Matching B %i %i", b->size, b->offset);
-
+
if (a)
GP_DEBUG(3, "Matching A %i %i", a->size, a->offset);
-
+
res = match(r, rmask) && match(g, gmask) &&
match(b, bmask) && match(a, amask);
@@ -125,28 +125,28 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff,
uint8_t bits_per_pixel)
{
unsigned int i;
-
+
GP_DEBUG(1, "Looking up Pixel R %08x %08x G %08x %08x B %08x %08x "
"size %u", rsize, roff, gsize, goff, bsize, boff,
bits_per_pixel);
for (i = 0; i < GP_PIXEL_MAX; i++) {
const GP_PixelTypeChannel *r, *g, *b, *a;
-
+
if (GP_PixelTypes[i].size != bits_per_pixel)
continue;
-
+
GP_DEBUG(2, "Trying Pixel %s %u",
GP_PixelTypes[i].name, bits_per_pixel);
-
+
r = get_channel(&GP_PixelTypes[i], "R");
g = get_channel(&GP_PixelTypes[i], "G");
b = get_channel(&GP_PixelTypes[i], "B");
a = get_channel(&GP_PixelTypes[i], "A");
-
+
if (a == NULL && asize != 0)
continue;
-
+
if (a != NULL && (a->offset != aoff || a->size != asize))
continue;
@@ -155,7 +155,7 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff,
b->offset == boff && b->size == bsize) {
GP_DEBUG(1, "Pixel found type id %u name '%s'",
GP_PixelTypes[i].type, GP_PixelTypes[i].name);
-
+
return GP_PixelTypes[i].type;
}
}
diff --git a/libs/core/GP_Pixel.gen.c.t b/libs/core/GP_Pixel.gen.c.t
index 9dc56f8..96ba421 100644
--- a/libs/core/GP_Pixel.gen.c.t
+++ b/libs/core/GP_Pixel.gen.c.t
@@ -40,8 +40,8 @@ Pixel type definitions and functions
{% if pt.is_cmyk() %} | GP_PIXEL_IS_CMYK{% endif -%}
%%- endmacro
-/*
- * Description of all known pixel types
+/*
+ * Description of all known pixel types
*/
const GP_PixelTypeDescription const GP_PixelTypes [GP_PIXEL_MAX] = {
%% for pt in pixeltypes
@@ -64,7 +64,7 @@ const GP_PixelTypeDescription const GP_PixelTypes [GP_PIXEL_MAX] = {
%% for pt in pixeltypes
%% if not pt.is_unknown()
/*
- * snprintf a human readable value of pixel type {{pt.name}}
+ * snprintf a human readable value of pixel type {{pt.name}}
*/
static void GP_PixelSNPrint_{{ pt.name }}(char *buf, size_t len, GP_Pixel p)
{
diff --git a/libs/core/GP_Threads.c b/libs/core/GP_Threads.c
index ff59d75..0f396d2 100644
--- a/libs/core/GP_Threads.c
+++ b/libs/core/GP_Threads.c
@@ -58,9 +58,9 @@ unsigned int GP_NrThreads(GP_Size w, GP_Size h, GP_ProgressCallback *callback)
count = nr_threads;
GP_DEBUG(1, "Using nr_threads=%i", count);
}
-
+
threads = GP_MIN(count, (int)(w * h / 1024) + 1);
-
+
/* Call to the sysconf may return -1 if unsupported */
if (threads < -1)
threads = 1;
@@ -74,7 +74,7 @@ unsigned int GP_NrThreads(GP_Size w, GP_Size h, GP_ProgressCallback *callback)
void GP_NrThreadsSet(unsigned int nr)
{
nr_threads = nr;
-
+
GP_DEBUG(1, "Setting default number of threads to %u", nr);
}
@@ -82,7 +82,7 @@ int GP_ProgressCallbackMP(GP_ProgressCallback *self)
{
struct GP_ProgressCallbackMPPriv *priv = self->priv;
- /*
+ /*
* If any thread got non-zero return value from a callback abort all.
*/
if (priv->abort)
@@ -99,7 +99,7 @@ int GP_ProgressCallbackMP(GP_ProgressCallback *self)
/* Call the original callback */
int ret = priv->orig_callback->callback(priv->orig_callback);
-
+
/* Turn on abort flag if callback returned nonzero */
if (ret)
priv->abort = 1;
diff --git a/libs/filters/GP_Blur.c b/libs/filters/GP_Blur.c
index 420073e..bd66c9c 100644
--- a/libs/filters/GP_Blur.c
+++ b/libs/filters/GP_Blur.c
@@ -43,7 +43,7 @@ static inline float gaussian_kernel_init(float sigma, float *kernel)
float ret = 0;
double sigma2 = sigma * sigma;
-
+
for (i = 0; i < N; i++) {
double r = center - i;
kernel[i] = exp(-0.5 * (r * r) / sigma2);
@@ -79,10 +79,10 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src,
{
unsigned int size_x = gaussian_kernel_size(sigma_x);
unsigned int size_y = gaussian_kernel_size(sigma_y);
-
+
GP_DEBUG(1, "Gaussian blur sigma_x=%2.3f sigma_y=%2.3f kernel %ix%i image %ux%u",
sigma_x, sigma_y, size_x, size_y, w_src, h_src);
-
+
GP_ProgressCallback *new_callback = NULL;
GP_ProgressCallback gaussian_callback = {
@@ -117,7 +117,7 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src,
if (GP_FilterHConvolutionMP_Raw(¶ms))
return 1;
}
-
+
if (new_callback != NULL)
new_callback->callback = gaussian_callback_vert;
@@ -125,7 +125,7 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src,
if (sigma_y > 0) {
float kernel_y[size_y];
float sum = gaussian_kernel_init(sigma_y, kernel_y);
-
+
GP_ConvolutionParams params = {
.src = src,
.x_src = x_src,
@@ -141,7 +141,7 @@ int GP_FilterGaussianBlur_Raw(const GP_Context *src,
.kern_div = sum,
.callback = new_callback,
};
-
+
if (GP_FilterVConvolutionMP_Raw(¶ms))
return 1;
}
@@ -159,11 +159,11 @@ int GP_FilterGaussianBlurEx(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_CHECK(src->pixel_type == dst->pixel_type);
-
+
/* Check that destination is large enough */
GP_CHECK(x_dst + (GP_Coord)w_src <= (GP_Coord)dst->w);
GP_CHECK(y_dst + (GP_Coord)h_src <= (GP_Coord)dst->h);
-
+
return GP_FilterGaussianBlur_Raw(src, x_src, y_src, w_src, h_src,
dst, x_dst, y_dst,
sigma_x, sigma_y, callback);
diff --git a/libs/filters/GP_Convolution.c b/libs/filters/GP_Convolution.c
index 0b81e55..b01f768 100644
--- a/libs/filters/GP_Convolution.c
+++ b/libs/filters/GP_Convolution.c
@@ -33,7 +33,7 @@ int GP_FilterConvolutionEx(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_CHECK(src->pixel_type == dst->pixel_type);
-
+
/* Check that destination is large enough */
GP_CHECK(x_dst + (GP_Coord)w_src <= (GP_Coord)dst->w);
GP_CHECK(y_dst + (GP_Coord)h_src <= (GP_Coord)dst->h);
diff --git a/libs/filters/GP_Dither.c b/libs/filters/GP_Dither.c
index ad87e9b..a050513 100644
--- a/libs/filters/GP_Dither.c
+++ b/libs/filters/GP_Dither.c
@@ -39,9 +39,9 @@ GP_Context *GP_FilterFloydSteinberg_RGB888_Alloc(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_Context *ret;
-
+
ret = GP_ContextAlloc(src->w, src->h, pixel_type);
-
+
if (ret == NULL)
return NULL;
diff --git a/libs/filters/GP_Edge.c b/libs/filters/GP_Edge.c
index 349c36b..7d55077 100644
--- a/libs/filters/GP_Edge.c
+++ b/libs/filters/GP_Edge.c
@@ -47,7 +47,7 @@ static int prewitt(const GP_Context *src, GP_Context *dx, GP_Context *dy,
grad_kern, 3, 1,
smooth_kern, 3, 1, callback))
return 1;
-
+
return 0;
}
@@ -81,13 +81,13 @@ static int sobel(const GP_Context *src, GP_Context *dx, GP_Context *dy,
if (GP_FilterConvolution_Raw(&dx_conv))
return 1;
-
+
float dy_kern[] = {
-1, -2, -1,
0, 0, 0,
1, 2, 1,
};
-
+
GP_ConvolutionParams dy_conv = {
.src = src,
.x_src = 0,
@@ -137,9 +137,9 @@ static int edge_detect(const GP_Context *src,
default:
goto err0;
}
-
+
uint32_t i, j;
-
+
for (i = 0; i < src->w; i++) {
for (j = 0; j < src->h; j++) {
GP_Pixel pix_x = GP_GetPixel_Raw_24BPP(dx, i, j);
@@ -152,43 +152,43 @@ static int edge_detect(const GP_Context *src,
Rx = GP_Pixel_GET_R_RGB888(pix_x);
Gx = GP_Pixel_GET_G_RGB888(pix_x);
Bx = GP_Pixel_GET_B_RGB888(pix_x);
-
+
Ry = GP_Pixel_GET_R_RGB888(pix_y);
Gy = GP_Pixel_GET_G_RGB888(pix_y);
By = GP_Pixel_GET_B_RGB888(pix_y);
-
+
RE = sqrt(Rx*Rx + Ry*Ry) + 0.5;
GE = sqrt(Gx*Gx + Gy*Gy) + 0.5;
BE = sqrt(Bx*Bx + By*By) + 0.5;
-
+
GP_PutPixel_Raw_24BPP(dx, i, j,
GP_Pixel_CREATE_RGB888(RE, GE, BE));
-
+
if (Rx != 0 && Ry != 0)
RPhi = ((atan2(Rx, Ry) + M_PI) * 255)/(2*M_PI);
else
RPhi = 0;
-
+
if (Gx != 0 && Gy != 0)
GPhi = ((atan2(Gx, Gy) + M_PI) * 255)/(2*M_PI);
else
GPhi = 0;
-
+
if (Bx != 0 && By != 0)
BPhi = ((atan2(Bx, By) + M_PI) * 255)/(2*M_PI);
else
BPhi = 0;
-
+
GP_PutPixel_Raw_24BPP(dy, i, j,
GP_Pixel_CREATE_RGB888(RPhi, GPhi, BPhi));
}
}
-
+
if (Phi != NULL)
*Phi = dy;
else
GP_ContextFree(dy);
-
+
if (E != NULL)
*E = dx;
else
diff --git a/libs/filters/GP_FilterParam.c b/libs/filters/GP_FilterParam.c
index e6c0f6b..fe7537c 100644
--- a/libs/filters/GP_FilterParam.c
+++ b/libs/filters/GP_FilterParam.c
@@ -28,8 +28,8 @@
GP_FilterParam *GP_FilterParamCreate(GP_PixelType pixel_type)
{
- GP_FilterParam *ret;
-
+ GP_FilterParam *ret;
+
ret = malloc((GP_PixelTypes[pixel_type].numchannels + 1)
* sizeof(GP_FilterParam));
@@ -51,7 +51,7 @@ void GP_FilterParamDestroy(GP_FilterParam *self)
static unsigned int count_channels(GP_FilterParam params[])
{
unsigned int i = 0;
-
+
while (params[i].channel_name[0] != '0')
i++;
@@ -80,7 +80,7 @@ int GP_FilterParamCheckPixelType(GP_FilterParam params[],
{
unsigned int i, num_channels;
const GP_PixelTypeChannel *channels;
-
+
num_channels = GP_PixelTypes[pixel_type].numchannels;
channels = GP_PixelTypes[pixel_type].channels;
@@ -92,7 +92,7 @@ int GP_FilterParamCheckPixelType(GP_FilterParam params[],
for (i = 0; i < num_channels; i++)
if (GP_FilterParamChannel(params, channels[i].name) == NULL)
return 1;
-
+
return 0;
}
@@ -104,7 +104,7 @@ int GP_FilterParamCheckChannels(GP_FilterParam params[],
for (i = 0; channel_names[i] != NULL; i++)
if (GP_FilterParamChannel(params, channel_names[i]) == NULL)
return 1;
-
+
if (i != count_channels(params))
return 1;
@@ -116,15 +116,15 @@ void GP_FilterParamInitChannels(GP_FilterParam params[],
{
unsigned int i, num_channels;
const GP_PixelTypeChannel *channels;
-
+
num_channels = GP_PixelTypes[pixel_type].numchannels;
channels = GP_PixelTypes[pixel_type].channels;
-
+
for (i = 0; i < num_channels; i++) {
strcpy(params[i].channel_name, channels[i].name);
memset(¶ms[i].val, 0, sizeof(GP_FilterParamVal));
}
-
+
params[i].channel_name[0] = '0';
}
@@ -219,7 +219,7 @@ int GP_FilterParamSetPtr(GP_FilterParam params[], const char *channel_name,
void GP_FilterParamFreePtrAll(GP_FilterParam params[])
{
unsigned int i;
-
+
for (i = 0; params[i].channel_name[0] != '0'; i++)
free(params[i].val.ptr);
}
@@ -227,7 +227,7 @@ void GP_FilterParamFreePtrAll(GP_FilterParam params[])
void GP_FilterParamPrintInt(GP_FilterParam params[])
{
unsigned int i;
-
+
for (i = 0; params[i].channel_name[0] != '0'; i++)
printf("Chann '%s' = %in", params[i].channel_name, params[i].val.i);
}
@@ -235,7 +235,7 @@ void GP_FilterParamPrintInt(GP_FilterParam params[])
void GP_FilterParamPrintUInt(GP_FilterParam params[])
{
unsigned int i;
-
+
for (i = 0; params[i].channel_name[0] != '0'; i++)
printf("Chann '%s' = %un", params[i].channel_name, params[i].val.ui);
}
@@ -243,7 +243,7 @@ void GP_FilterParamPrintUInt(GP_FilterParam params[])
void GP_FilterParamPrintFloat(GP_FilterParam params[])
{
unsigned int i;
-
+
for (i = 0; params[i].channel_name[0] != '0'; i++)
printf("Chann '%s' = %fn", params[i].channel_name, params[i].val.f);
}
@@ -251,7 +251,7 @@ void GP_FilterParamPrintFloat(GP_FilterParam params[])
void GP_FilterParamPrintPtr(GP_FilterParam params[])
{
unsigned int i;
-
+
for (i = 0; params[i].channel_name[0] != '0'; i++)
printf("Chann '%s' = %pn", params[i].channel_name, params[i].val.ptr);
}
diff --git a/libs/filters/GP_FloydSteinberg.gen.c.t b/libs/filters/GP_FloydSteinberg.gen.c.t
index fde40d9..2d4d401 100644
--- a/libs/filters/GP_FloydSteinberg.gen.c.t
+++ b/libs/filters/GP_FloydSteinberg.gen.c.t
@@ -38,7 +38,7 @@
if ({{ x }} > 1)
{{ errors }}[!({{ y }}%2)][{{ x }}-1] += 3 * {{ err }} / 16;
-
+
{{ errors }}[!({{ y }}%2)][{{ x }}] += 5 * {{ err }} / 16;
if ({{ x }} + 1 < {{ w }})
@@ -70,9 +70,9 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G
%% endfor
for (y = 0; y < (GP_Coord)src->h; y++) {
- for (x = 0; x < (GP_Coord)src->w; x++) {
+ for (x = 0; x < (GP_Coord)src->w; x++) {
GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, x, y);
-
+
%% for c in pt.chanslist
%% if pt.is_gray()
float val_{{ c[0] }} = GP_Pixel_GET_R_RGB888(pix) +
@@ -80,9 +80,9 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G
GP_Pixel_GET_B_RGB888(pix);
%% else
float val_{{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_RGB888(pix);
-%% endif
+%% endif
val_{{ c[0] }} += errors_{{ c[0] }}[y%2][x];
-
+
float err_{{ c[0] }} = val_{{ c[0] }};
%% if pt.is_gray()
GP_Pixel res_{{ c[0] }} = {{ 2 ** c[2] - 1}} * val_{{ c[0] }} / (3 * 255);
@@ -96,7 +96,7 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G
{{ clamp_val("res_%s"|format(c[0]), c[2]) }}
%% endfor
-
+
%% if pt.is_gray()
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, res_V);
%% else
@@ -109,7 +109,7 @@ int GP_FilterFloydSteinberg_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src, G
%% for c in pt.chanslist
memset(errors_{{ c[0] }}[y%2], 0, src->w * sizeof(float));
%% endfor
-
+
if (GP_ProgressCallbackReport(callback, y, src->h, src->w))
return 1;
}
diff --git a/libs/filters/GP_GaussianNoise.gen.c.t b/libs/filters/GP_GaussianNoise.gen.c.t
index bc37bdf..3e4764b 100644
--- a/libs/filters/GP_GaussianNoise.gen.c.t
+++ b/libs/filters/GP_GaussianNoise.gen.c.t
@@ -48,7 +48,7 @@ static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src,
{
GP_DEBUG(1, "Additive Gaussian noise filter %ux%u sigma=%f mu=%f",
w_src, h_src, sigma, mu);
-
+
%% for c in pt.chanslist
int sigma_{{ c[0] }} = {{ 2 ** c[2] - 1 }} * sigma;
int mu_{{ c[0] }} = {{ 2 ** c[2] - 1 }} * mu;
@@ -62,7 +62,7 @@ static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src,
%% for c in pt.chanslist
int *{{ c[0] }} = GP_TempAllocGet(temp, size * sizeof(int));
%% endfor
-
+
/* Apply the additive noise filter */
unsigned int x, y;
@@ -70,15 +70,15 @@ static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src,
%% for c in pt.chanslist
GP_NormInt({{ c[0] }}, size, sigma_{{ c[0] }}, mu_{{ c[0] }});
%% endfor
-
+
for (x = 0; x < w_src; x++) {
GP_Pixel pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, x + x_src, y + y_src);
-
+
%% for c in pt.chanslist
{{ c[0] }}[x] += GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix);
{{ c[0] }}[x] = GP_CLAMP({{ c[0] }}[x], 0, {{ 2 ** c[2] - 1 }});
%% endfor
-
+
pix = GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "", "[x]") }});
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x + x_dst, y + y_dst, pix);
}
@@ -88,7 +88,7 @@ static int GP_FilterGaussianNoiseAdd_{{ pt.name }}_Raw(const GP_Context *src,
return 1;
}
}
-
+
GP_TempAllocFree(temp);
GP_ProgressCallbackDone(callback);
@@ -130,7 +130,7 @@ int GP_FilterGaussianNoiseAddEx(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_CHECK(src->pixel_type == dst->pixel_type);
-
+
/* Check that destination is large enough */
GP_CHECK(x_dst + (GP_Coord)w_src <= (GP_Coord)dst->w);
GP_CHECK(y_dst + (GP_Coord)h_src <= (GP_Coord)dst->h);
diff --git a/libs/filters/GP_HilbertPeano.gen.c.t b/libs/filters/GP_HilbertPeano.gen.c.t
index 9c84bee..90ed943 100644
--- a/libs/filters/GP_HilbertPeano.gen.c.t
+++ b/libs/filters/GP_HilbertPeano.gen.c.t
@@ -65,7 +65,7 @@ int GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src,
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;
@@ -85,7 +85,7 @@ int GP_FilterHilbertPeano_RGB888_to_{{ pt.name }}_Raw(const GP_Context *src,
GP_Pixel_GET_B_RGB888(pix);
%% else
int pix_{{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_RGB888(pix);
-%% endif
+%% endif
pix_{{ c[0] }} += err_{{ c[0] }};
diff --git a/libs/filters/GP_Laplace.c b/libs/filters/GP_Laplace.c
index a21be78..3081ace 100644
--- a/libs/filters/GP_Laplace.c
+++ b/libs/filters/GP_Laplace.c
@@ -50,7 +50,7 @@ GP_Context *GP_FilterLaplaceAlloc(const GP_Context *src,
if (ret == NULL)
return NULL;
-
+
if (GP_FilterLaplace(src, ret, callback)) {
GP_ContextFree(ret);
return NULL;
@@ -67,7 +67,7 @@ int GP_FilterEdgeSharpening(const GP_Context *src, GP_Context *dst,
float kern[9] = {0, 0, 0,
0, 1, 0,
0, 0, 0};
-
+
GP_DEBUG(1, "Laplace Edge Sharpening filter %ux%u w=%f",
src->w, src->h, w);
@@ -92,7 +92,7 @@ GP_Context *GP_FilterEdgeSharpeningAlloc(const GP_Context *src, float w,
if (ret == NULL)
return NULL;
-
+
if (GP_FilterEdgeSharpening(src, ret, w, callback)) {
GP_ContextFree(ret);
return NULL;
diff --git a/libs/filters/GP_Linear.c b/libs/filters/GP_Linear.c
index a87372f..5956b09 100644
--- a/libs/filters/GP_Linear.c
+++ b/libs/filters/GP_Linear.c
@@ -68,7 +68,7 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src,
int *G = GP_TempAllocGet(temp, size * sizeof(int));
int *B = GP_TempAllocGet(temp, size * sizeof(int));
- /* Do horizontal linear convolution */
+ /* Do horizontal linear convolution */
for (y = 0; y < (GP_Coord)h_src; y++) {
int yi = GP_MIN(y_src + y, (int)src->h - 1);
@@ -83,7 +83,7 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src,
R[i] = GP_Pixel_GET_R_RGB888(pix);
G[i] = GP_Pixel_GET_G_RGB888(pix);
B[i] = GP_Pixel_GET_B_RGB888(pix);
-
+
i++;
xi++;
}
@@ -95,7 +95,7 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src,
R[i] = GP_Pixel_GET_R_RGB888(pix);
G[i] = GP_Pixel_GET_G_RGB888(pix);
B[i] = GP_Pixel_GET_B_RGB888(pix);
-
+
i++;
xi++;
}
@@ -105,7 +105,7 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src,
R[i] = GP_Pixel_GET_R_RGB888(pix);
G[i] = GP_Pixel_GET_G_RGB888(pix);
B[i] = GP_Pixel_GET_B_RGB888(pix);
-
+
i++;
}
@@ -119,12 +119,12 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src,
g += (*pG++) * ikernel[i];
b += (*pB++) * ikernel[i];
}
-
+
/* divide the result */
r /= ikern_div;
g /= ikern_div;
b /= ikern_div;
-
+
/* and clamp just to be extra sure */
r = GP_CLAMP(r, 0, 255);
g = GP_CLAMP(g, 0, 255);
@@ -139,7 +139,7 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src,
return 1;
}
}
-
+
GP_TempAllocFree(temp);
GP_ProgressCallbackDone(callback);
@@ -165,7 +165,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
GP_DEBUG(1, "Vertical linear convolution kernel width %u "
"offset %ix%i rectangle %ux%u",
kh, x_src, y_src, w_src, h_src);
-
+
/* Not yet implemented */
if (src->pixel_type != GP_PIXEL_RGB888) {
errno = ENOSYS;
@@ -173,7 +173,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
}
ikern_div = kern_div * MUL + 0.5;
-
+
/* Create temporary buffers */
GP_TempAllocCreate(temp, 3 * size * sizeof(int));
@@ -181,10 +181,10 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
int *G = GP_TempAllocGet(temp, size * sizeof(int));
int *B = GP_TempAllocGet(temp, size * sizeof(int));
- /* Do vertical linear convolution */
+ /* Do vertical linear convolution */
for (x = 0; x < (GP_Coord)w_src; x++) {
int xi = GP_MIN(x_src + x, (int)src->w - 1);
-
+
/* Fetch the whole row */
GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, xi, 0);
@@ -196,7 +196,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
R[i] = GP_Pixel_GET_R_RGB888(pix);
G[i] = GP_Pixel_GET_G_RGB888(pix);
B[i] = GP_Pixel_GET_B_RGB888(pix);
-
+
i++;
yi++;
}
@@ -208,7 +208,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
R[i] = GP_Pixel_GET_R_RGB888(pix);
G[i] = GP_Pixel_GET_G_RGB888(pix);
B[i] = GP_Pixel_GET_B_RGB888(pix);
-
+
i++;
yi++;
}
@@ -218,10 +218,10 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
R[i] = GP_Pixel_GET_R_RGB888(pix);
G[i] = GP_Pixel_GET_G_RGB888(pix);
B[i] = GP_Pixel_GET_B_RGB888(pix);
-
+
i++;
}
-
+
for (y = 0; y < (GP_Coord)h_src; y++) {
int32_t r = MUL/2, g = MUL/2, b = MUL/2;
int *pR = R + y, *pG = G + y, *pB = B + y;
@@ -237,7 +237,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
r /= ikern_div;
g /= ikern_div;
b /= ikern_div;
-
+
/* and clamp just to be extra sure */
r = GP_CLAMP(r, 0, 255);
g = GP_CLAMP(g, 0, 255);
@@ -246,7 +246,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
GP_PutPixel_Raw_24BPP(dst, x_dst + x, y_dst + y,
GP_Pixel_CREATE_RGB888(r, g, b));
}
-
+
if (GP_ProgressCallbackReport(callback, x, w_src, h_src)) {
GP_TempAllocFree(temp);
return 1;
@@ -254,7 +254,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src,
}
GP_TempAllocFree(temp);
-
+
GP_ProgressCallbackDone(callback);
return 0;
}
@@ -298,15 +298,15 @@ int GP_FilterVHLinearConvolution_Raw(const GP_Context *src,
hkernel, kw, hkern_div,
new_callback))
return 1;
-
+
conv_callback.callback = v_callback;
-
+
if (GP_FilterHLinearConvolution_Raw(dst, x_src, y_src, w_src, h_src,
dst, x_dst, y_dst,
vkernel, kh, vkern_div,
new_callback))
return 1;
-
+
GP_ProgressCallbackDone(callback);
return 0;
}
@@ -324,14 +324,14 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src,
GP_DEBUG(1, "Linear convolution kernel %ix%i rectangle %ux%u",
kw, kh, w_src, h_src);
-
+
/* Not yet implemented */
if (src->pixel_type != GP_PIXEL_RGB888) {
errno = ENOSYS;
return 1;
}
- /* Do linear convolution */
+ /* Do linear convolution */
for (y = 0; y < (GP_Coord)h_src; y++) {
uint32_t R[kw][kh], G[kw][kh], B[kw][kh];
GP_Pixel pix;
@@ -343,8 +343,8 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src,
int yi = y_src + y + j - kh/2;
xi = GP_CLAMP(xi, 0, (int)src->w - 1);
- yi = GP_CLAMP(yi, 0, (int)src->h - 1);
-
+ yi = GP_CLAMP(yi, 0, (int)src->h - 1);
+
pix = GP_GetPixel_Raw_24BPP(src, xi, yi);
R[i][j] = GP_Pixel_GET_R_RGB888(pix);
@@ -361,9 +361,9 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src,
for (j = 0; j < kh; j++) {
int xi = x_src + x + kw/2;
int yi = y_src + y + j - kh/2;
-
+
xi = GP_CLAMP(xi, 0, (int)src->w - 1);
- yi = GP_CLAMP(yi, 0, (int)src->h - 1);
+ yi = GP_CLAMP(yi, 0, (int)src->h - 1);
pix = GP_GetPixel_Raw_24BPP(src, xi, yi);
@@ -371,7 +371,7 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src,
G[idx][j] = GP_Pixel_GET_G_RGB888(pix);
B[idx][j] = GP_Pixel_GET_B_RGB888(pix);
}
-
+
/* Count the pixel value from neighbours weighted by kernel */
for (i = 0; i < kw; i++) {
int k;
@@ -401,13 +401,13 @@ int GP_FilterLinearConvolution_Raw(const GP_Context *src,
pix = GP_Pixel_CREATE_RGB888((uint32_t)r, (uint32_t)g, (uint32_t)b);
GP_PutPixel_Raw_24BPP(dst, x_dst + x, y_dst + y, pix);
-
+
idx++;
if (idx >= (int)kw)
idx = 0;
}
-
+
if (GP_ProgressCallbackReport(callback, y, h_src, w_src))
return 1;
}
diff --git a/libs/filters/GP_LinearThreads.c b/libs/filters/GP_LinearThreads.c
index 2ab625e..554d492 100644
--- a/libs/filters/GP_LinearThreads.c
+++ b/libs/filters/GP_LinearThreads.c
@@ -36,14 +36,14 @@ static void *h_linear_convolution(void *arg)
struct GP_ConvolutionParams *params = arg;
long ret = GP_FilterHConvolution_Raw(params);
-
+
return (void*)ret;
}
static void *v_linear_convolution(void *arg)
{
struct GP_ConvolutionParams *params = arg;
-
+
long ret = GP_FilterVConvolution_Raw(params);
return (void*)ret;
@@ -52,7 +52,7 @@ static void *v_linear_convolution(void *arg)
static void *linear_convolution(void *arg)
{
struct GP_ConvolutionParams *params = arg;
-
+
long ret = GP_FilterConvolution_Raw(params);
return (void*)ret;
@@ -79,7 +79,7 @@ int GP_FilterHConvolutionMP_Raw(const GP_ConvolutionParams *params)
GP_Coord y_src_2 = params->y_src + i * h;
GP_Coord y_dst_2 = params->y_dst + i * h;
GP_Size h_src_2 = h;
-
+
if (i == t - 1)
h_src_2 = params->h_src - i * h;
@@ -101,7 +101,7 @@ int GP_FilterHConvolutionMP_Raw(const GP_ConvolutionParams *params)
ret |= (int)r;
}
-
+
return ret;
}
@@ -112,12 +112,12 @@ int GP_FilterVConvolutionMP_Raw(const GP_ConvolutionParams *params)
if (t == 1)
return GP_FilterVConvolution_Raw(params);
-
+
GP_ASSERT(params->src != params->dst,
"Multithreaded convolution can't work in-place");
-
+
GP_PROGRESS_CALLBACK_MP(callback_mp, params->callback);
-
+
/* Run t threads */
pthread_t threads[t];
struct GP_ConvolutionParams convs[t];
@@ -127,7 +127,7 @@ int GP_FilterVConvolutionMP_Raw(const GP_ConvolutionParams *params)
GP_Coord y_src_2 = params->y_src + i * h;
GP_Coord y_dst_2 = params->y_dst + i * h;
GP_Size h_src_2 = h;
-
+
if (i == t - 1)
h_src_2 = params->h_src - i * h;
@@ -136,7 +136,7 @@ int GP_FilterVConvolutionMP_Raw(const GP_ConvolutionParams *params)
convs[i].h_src = h_src_2;
convs[i].y_dst = y_dst_2;
convs[i].callback = params->callback ? &callback_mp : NULL;
-
+
pthread_create(&threads[i], NULL, v_linear_convolution, &convs[i]);
}
@@ -148,7 +148,7 @@ int GP_FilterVConvolutionMP_Raw(const GP_ConvolutionParams *params)
ret |= (int)r;
}
-
+
return ret;
}
@@ -159,12 +159,12 @@ int GP_FilterConvolutionMP_Raw(const GP_ConvolutionParams *params)
if (t == 1)
return GP_FilterConvolution_Raw(params);
-
+
GP_ASSERT(params->src != params->dst,
"Multithreaded convolution can't work in-place");
GP_PROGRESS_CALLBACK_MP(callback_mp, params->callback);
-
+
/* Run t threads */
pthread_t threads[t];
struct GP_ConvolutionParams convs[t];
@@ -174,7 +174,7 @@ int GP_FilterConvolutionMP_Raw(const GP_ConvolutionParams *params)
GP_Coord y_src_2 = params->y_src + i * h;
GP_Coord y_dst_2 = params->y_dst + i * h;
GP_Size h_src_2 = h;
-
+
if (i == t - 1)
h_src_2 = params->h_src - i * h;
@@ -183,7 +183,7 @@ int GP_FilterConvolutionMP_Raw(const GP_ConvolutionParams *params)
convs[i].h_src = h_src_2;
convs[i].y_dst = y_dst_2;
convs[i].callback = params->callback ? &callback_mp : NULL;
-
+
pthread_create(&threads[i], NULL, linear_convolution, &convs[i]);
}
@@ -195,6 +195,6 @@ int GP_FilterConvolutionMP_Raw(const GP_ConvolutionParams *params)
ret |= (int)r;
}
-
+
return ret;
}
diff --git a/libs/filters/GP_Median.c b/libs/filters/GP_Median.c
index 130ad92..170ce24 100644
--- a/libs/filters/GP_Median.c
+++ b/libs/filters/GP_Median.c
@@ -77,7 +77,7 @@ static inline void hist8_add_fine(struct hist8u *out, struct hist8 *in, unsigned
out->coarse[i + 1] += in[x].coarse[i + 1];
out->coarse[i + 2] += in[x].coarse[i + 2];
out->coarse[i + 3] += in[x].coarse[i + 3];
-
+
for (j = 0; j < 16; j++) {
out->fine[i + 0][j] += in[x].fine[i + 0][j];
out->fine[i + 1][j] += in[x].fine[i + 1][j];
@@ -147,22 +147,22 @@ static inline unsigned int hist8_median(struct hist8u *h, struct hist8 *row,
for (i = 0; i < 16; i++) {
acc += h->coarse[i];
-
+
if (acc >= trigger) {
acc -= h->coarse[i];
-
+
/* update fine on position i */
hist8_update(h, i, row, x, xmed);
for (j = 0; j < 16; j++) {
acc += h->fine[i][j];
-
+
if (acc >= trigger)
return (i<<4) | j;
}
}
}
-
+
GP_BUG("Trigger not reached");
return 0;
}
@@ -185,7 +185,7 @@ static int GP_FilterMedian_Raw(const GP_Context *src,
GP_DEBUG(1, "Median filter size %ux%u xmed=%u ymed=%u",
w_src, h_src, 2 * xmed + 1, 2 * ymed + 1);
-
+
/* The buffer is w + 2*xmed + 1 size because we read the last value but we don't use it */
unsigned int size = (w_src + 2 * xmed + 1);
@@ -195,7 +195,7 @@ static int GP_FilterMedian_Raw(const GP_Context *src,
struct hist8 *R = GP_TempAllocGet(temp, sizeof(struct hist8) * size);
struct hist8 *G = GP_TempAllocGet(temp, sizeof(struct hist8) * size);
struct hist8 *B = GP_TempAllocGet(temp, sizeof(struct hist8) * size);
-
+
memset(R, 0, sizeof(*R) * size);
memset(G, 0, sizeof(*G) * size);
memset(B, 0, sizeof(*B) * size);
@@ -207,15 +207,15 @@ static int GP_FilterMedian_Raw(const GP_Context *src,
/* Prefill row of histograms */
for (x = 0; x < (int)w_src + 2*xmed; x++) {
int xi = GP_CLAMP(x_src + x - xmed, 0, (int)src->w - 1);
-
+
for (y = -ymed; y <= ymed; y++) {
int yi = GP_CLAMP(y_src + y, 0, (int)src->h - 1);
-
+
GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, xi, yi);
-
+
hist8_inc(R, x, GP_Pixel_GET_R_RGB888(pix));
- hist8_inc(G, x, GP_Pixel_GET_G_RGB888(pix));
- hist8_inc(B, x, GP_Pixel_GET_B_RGB888(pix));
+ hist8_inc(G, x, GP_Pixel_GET_G_RGB888(pix));
+ hist8_inc(B, x, GP_Pixel_GET_B_RGB888(pix));
}
}
@@ -224,7 +224,7 @@ static int GP_FilterMedian_Raw(const GP_Context *src,
memset(XR, 0, sizeof(*XR));
memset(XG, 0, sizeof(*XG));
memset(XB, 0, sizeof(*XB));
-
+
/* Compute first histogram */
for (i = 0; i <= 2*xmed; i++) {
hist8_add_fine(XR, R, i);
@@ -240,7 +240,7 @@ static int GP_FilterMedian_Raw(const GP_Context *src,
GP_PutPixel_Raw_24BPP(dst, x_dst + x, y_dst + y,
GP_Pixel_CREATE_RGB888(r, g, b));
-
+
/* Recompute histograms */
hist8_sub(XR, R, x);
hist8_sub(XG, G, x);
@@ -255,22 +255,22 @@ static int GP_FilterMedian_Raw(const GP_Context *src,
for (x = 0; x < (int)w_src + 2*xmed; x++) {
int xi = GP_CLAMP(x_src + x - xmed, 0, (int)src->w - 1);
int yi = GP_CLAMP(y_src + y - ymed, 0, (int)src->h - 1);
-
+
GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, xi, yi);
-
- hist8_dec(R, x, GP_Pixel_GET_R_RGB888(pix));
- hist8_dec(G, x, GP_Pixel_GET_G_RGB888(pix));
- hist8_dec(B, x, GP_Pixel_GET_B_RGB888(pix));
-
+
+ hist8_dec(R, x, GP_Pixel_GET_R_RGB888(pix));
+ hist8_dec(G, x, GP_Pixel_GET_G_RGB888(pix));
+ hist8_dec(B, x, GP_Pixel_GET_B_RGB888(pix));
+
yi = GP_MIN(y_src + y + ymed + 1, (int)src->h - 1);
-
+
pix = GP_GetPixel_Raw_24BPP(src, xi, yi);
-
- hist8_inc(R, x, GP_Pixel_GET_R_RGB888(pix));
- hist8_inc(G, x, GP_Pixel_GET_G_RGB888(pix));
+
+ hist8_inc(R, x, GP_Pixel_GET_R_RGB888(pix));
+ hist8_inc(G, x, GP_Pixel_GET_G_RGB888(pix));
hist8_inc(B, x, GP_Pixel_GET_B_RGB888(pix));
}
-
+
if (GP_ProgressCallbackReport(callback, y, h_src, w_src)) {
GP_TempAllocFree(temp);
return 1;
@@ -292,7 +292,7 @@ int GP_FilterMedianEx(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_CHECK(src->pixel_type == dst->pixel_type);
-
+
/* Check that destination is large enough */
GP_CHECK(x_dst + (GP_Coord)w_src <= (GP_Coord)dst->w);
GP_CHECK(y_dst + (GP_Coord)h_src <= (GP_Coord)dst->h);
diff --git a/libs/filters/GP_MirrorV.gen.c.t b/libs/filters/GP_MirrorV.gen.c.t
index b2d4b86..99599af 100644
--- a/libs/filters/GP_MirrorV.gen.c.t
+++ b/libs/filters/GP_MirrorV.gen.c.t
@@ -39,7 +39,7 @@ static int GP_MirrorV_Raw_{{ ps.suffix }}(const GP_Context *src,
GP_Pixel tmp;
GP_DEBUG(1, "Mirroring image vertically %ux%u", src->w, src->h);
-
+
for (x = 0; x < src->w/2; x++) {
uint32_t xm = src->w - x - 1;
for (y = 0; y < src->h; y++) {
diff --git a/libs/filters/GP_Resize.c b/libs/filters/GP_Resize.c
index 8641321..24d58a2 100644
--- a/libs/filters/GP_Resize.c
+++ b/libs/filters/GP_Resize.c
@@ -158,7 +158,7 @@ const char *GP_InterpolationTypeName(enum GP_InterpolationType interp_type)
if (interp_type > GP_INTERP_MAX)
return "Unknown";
- return interp_types[interp_type];
+ return interp_types[interp_type];
}
#define A 0.5
@@ -223,26 +223,26 @@ int GP_FilterInterpolate_Cubic(const GP_Context *src, GP_Context *dst,
float x = (1.00 * i / (dst->w - 1)) * (src->w - 1);
v4f cvx;
int xi[4];
-
+
xi[0] = floor(x - 1);
xi[1] = x;
xi[2] = x + 1;
xi[3] = x + 2;
-
+
cvx.f[0] = cubic(xi[0] - x);
cvx.f[1] = cubic(xi[1] - x);
cvx.f[2] = cubic(xi[2] - x);
cvx.f[3] = cubic(xi[3] - x);
-
+
if (xi[0] < 0)
xi[0] = 0;
if (xi[2] >= (int)src->w)
xi[2] = src->w - 1;
-
+
if (xi[3] >= (int)src->w)
xi[3] = src->w - 1;
-
+
/* Generate interpolated column */
for (j = 0; j < src->h; j++) {
v4f rv, gv, bv;
@@ -252,17 +252,17 @@ int GP_FilterInterpolate_Cubic(const GP_Context *src, GP_Context *dst,
pix[1] = GP_GetPixel_Raw_24BPP(src, xi[1], j);
pix[2] = GP_GetPixel_Raw_24BPP(src, xi[2], j);
pix[3] = GP_GetPixel_Raw_24BPP(src, xi[3], j);
-
+
rv.f[0] = GP_Pixel_GET_R_RGB888(pix[0]);
rv.f[1] = GP_Pixel_GET_R_RGB888(pix[1]);
rv.f[2] = GP_Pixel_GET_R_RGB888(pix[2]);
rv.f[3] = GP_Pixel_GET_R_RGB888(pix[3]);
-
+
gv.f[0] = GP_Pixel_GET_G_RGB888(pix[0]);
gv.f[1] = GP_Pixel_GET_G_RGB888(pix[1]);
gv.f[2] = GP_Pixel_GET_G_RGB888(pix[2]);
gv.f[3] = GP_Pixel_GET_G_RGB888(pix[3]);
-
+
bv.f[0] = GP_Pixel_GET_B_RGB888(pix[0]);
bv.f[1] = GP_Pixel_GET_B_RGB888(pix[1]);
bv.f[2] = GP_Pixel_GET_B_RGB888(pix[2]);
@@ -271,7 +271,7 @@ int GP_FilterInterpolate_Cubic(const GP_Context *src, GP_Context *dst,
rv = MUL_V4SF(rv, cvx);
gv = MUL_V4SF(gv, cvx);
bv = MUL_V4SF(bv, cvx);
-
+
col_r[j] = SUM_V4SF(rv);
col_g[j] = SUM_V4SF(gv);
col_b[j] = SUM_V4SF(bv);
@@ -283,41 +283,41 @@ int GP_FilterInterpolate_Cubic(const GP_Context *src, GP_Context *dst,
v4f cvy, rv, gv, bv;
float r, g, b;
int yi[4];
-
+
yi[0] = floor(y - 1);
yi[1] = y;
yi[2] = y + 1;
yi[3] = y + 2;
-
+
cvy.f[0] = cubic(yi[0] - y);
cvy.f[1] = cubic(yi[1] - y);
cvy.f[2] = cubic(yi[2] - y);
cvy.f[3] = cubic(yi[3] - y);
-
+
if (yi[0] < 0)
yi[0] = 0;
-
+
if (yi[2] >= (int)src->h)
yi[2] = src->h - 1;
-
+
if (yi[3] >= (int)src->h)
yi[3] = src->h - 1;
-
+
rv.f[0] = col_r[yi[0]];
rv.f[1] = col_r[yi[1]];
rv.f[2] = col_r[yi[2]];
rv.f[3] = col_r[yi[3]];
-
+
gv.f[0] = col_g[yi[0]];
gv.f[1] = col_g[yi[1]];
gv.f[2] = col_g[yi[2]];
gv.f[3] = col_g[yi[3]];
-
+
bv.f[0] = col_b[yi[0]];
bv.f[1] = col_b[yi[1]];
bv.f[2] = col_b[yi[2]];
bv.f[3] = col_b[yi[3]];
-
+
rv = MUL_V4SF(rv, cvy);
gv = MUL_V4SF(gv, cvy);
bv = MUL_V4SF(bv, cvy);
@@ -333,7 +333,7 @@ int GP_FilterInterpolate_Cubic(const GP_Context *src, GP_Context *dst,
GP_Pixel pix = GP_Pixel_CREATE_RGB888((uint8_t)r, (uint8_t)g, (uint8_t)b);
GP_PutPixel_Raw_24BPP(dst, i, j, pix);
}
-
+
if (GP_ProgressCallbackReport(callback, i, dst->w, dst->h))
return 1;
}
@@ -379,18 +379,18 @@ GP_Context *GP_FilterResize(const GP_Context *src, GP_Context *dst,
"The src and dst pixel types must match");
/*
* The size of w and h is asserted in subcontext initalization
- */
+ */
res = GP_SubContext(dst, &sub, 0, 0, w, h);
}
/*
* Operation was aborted by progress callback.
- *
+ *
* Free any alloacted data and exit.
*/
if (GP_FilterResize_Raw(src, res, type, callback)) {
GP_DEBUG(1, "Operation aborted");
-
+
if (dst == NULL)
GP_ContextFree(dst);
diff --git a/libs/filters/GP_ResizeCubic.gen.c.t b/libs/filters/GP_ResizeCubic.gen.c.t
index a515a2d..a273d14 100644
--- a/libs/filters/GP_ResizeCubic.gen.c.t
+++ b/libs/filters/GP_ResizeCubic.gen.c.t
@@ -67,24 +67,24 @@ static int GP_FilterResizeCubicInt_{{ pt.name }}_Raw(const GP_Context *src,
1.00 * dst->w / src->w, 1.00 * dst->h / src->h);
{{ fetch_gamma_tables(pt, "src") }}
-
+
/* pre-generate x mapping and constants */
int32_t xmap[dst->w][4];
int32_t xmap_c[dst->w][4];
for (i = 0; i < dst->w; i++) {
- float x = (1.00 * i / (dst->w - 1)) * (src->w - 1);
-
+ float x = (1.00 * i / (dst->w - 1)) * (src->w - 1);
+
xmap[i][0] = floor(x - 1);
xmap[i][1] = x;
xmap[i][2] = x + 1;
xmap[i][3] = x + 2;
-
+
xmap_c[i][0] = cubic_int((xmap[i][0] - x) * MUL + 0.5);
xmap_c[i][1] = cubic_int((xmap[i][1] - x) * MUL + 0.5);
xmap_c[i][2] = cubic_int((xmap[i][2] - x) * MUL + 0.5);
xmap_c[i][3] = cubic_int((xmap[i][3] - x) * MUL + 0.5);
-
+
xmap[i][0] = GP_MAX(xmap[i][0], 0);
xmap[i][2] = GP_MIN(xmap[i][2], (int)src->w - 1);
xmap[i][3] = GP_MIN(xmap[i][3], (int)src->w - 1);
@@ -95,17 +95,17 @@ static int GP_FilterResizeCubicInt_{{ pt.name }}_Raw(const GP_Context *src,
float y = (1.00 * i / (dst->h - 1)) * (src->h - 1);
int32_t cvy[4];
int yi[4];
-
+
yi[0] = floor(y - 1);
yi[1] = y;
yi[2] = y + 1;
yi[3] = y + 2;
-
+
cvy[0] = cubic_int((yi[0] - y) * MUL + 0.5);
cvy[1] = cubic_int((yi[1] - y) * MUL + 0.5);
cvy[2] = cubic_int((yi[2] - y) * MUL + 0.5);
cvy[3] = cubic_int((yi[3] - y) * MUL + 0.5);
-
+
yi[0] = GP_MAX(yi[0], 0);
yi[2] = GP_MIN(yi[2], (int)src->h - 1);
yi[3] = GP_MIN(yi[3], (int)src->h - 1);
@@ -121,27 +121,27 @@ static int GP_FilterResizeCubicInt_{{ pt.name }}_Raw(const GP_Context *src,
pix[1] = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, j, yi[1]);
pix[2] = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, j, yi[2]);
pix[3] = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, j, yi[3]);
-
+
%% for c in pt.chanslist
{{ c[0] }}v[0] = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix[0]);
{{ c[0] }}v[1] = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix[1]);
{{ c[0] }}v[2] = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix[2]);
{{ c[0] }}v[3] = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix[3]);
%% endfor
-
+
if (src->gamma) {
%% for c in pt.chanslist
{{ c[0] }}v[0] = {{ c[0] }}_2_LIN[{{ c[0] }}v[0]];
{{ c[0] }}v[1] = {{ c[0] }}_2_LIN[{{ c[0] }}v[1]];
{{ c[0] }}v[2] = {{ c[0] }}_2_LIN[{{ c[0] }}v[2]];
{{ c[0] }}v[3] = {{ c[0] }}_2_LIN[{{ c[0] }}v[3]];
- %% endfor
+ %% endfor
}
-
+
%% for c in pt.chanslist
MUL_I({{ c[0] }}v, cvy);
%% endfor
-
+
%% for c in pt.chanslist
col_{{ c[0] }}[j] = SUM_I({{ c[0] }}v);
%% endfor
@@ -153,18 +153,18 @@ static int GP_FilterResizeCubicInt_{{ pt.name }}_Raw(const GP_Context *src,
int32_t {{ c[0] }}v[4];
int32_t {{ c[0] }};
%% endfor
-
+
%% for c in pt.chanslist
{{ c[0] }}v[0] = col_{{ c[0] }}[xmap[j][0]];
{{ c[0] }}v[1] = col_{{ c[0] }}[xmap[j][1]];
{{ c[0] }}v[2] = col_{{ c[0] }}[xmap[j][2]];
{{ c[0] }}v[3] = col_{{ c[0] }}[xmap[j][3]];
%% endfor
-
+
%% for c in pt.chanslist
MUL_I({{ c[0] }}v, xmap_c[j]);
%% endfor
-
+
%% for c in pt.chanslist
{{ c[0] }} = (SUM_I({{ c[0] }}v) + MUL*MUL/2) / MUL / MUL;
%% endfor
@@ -181,11 +181,11 @@ static int GP_FilterResizeCubicInt_{{ pt.name }}_Raw(const GP_Context *src,
{{ c[0] }} = GP_CLAMP_GENERIC({{ c[0] }}, 0, {{ 2 ** c[2] - 1 }});
%% endfor
}
-
+
GP_Pixel pix = GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "(uint8_t)") }});
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, j, i, pix);
}
-
+
if (GP_ProgressCallbackReport(callback, i, dst->h, dst->w))
return 1;
}
diff --git a/libs/filters/GP_ResizeLinear.gen.c.t b/libs/filters/GP_ResizeLinear.gen.c.t
index 06f584a..e01b2c2 100644
--- a/libs/filters/GP_ResizeLinear.gen.c.t
+++ b/libs/filters/GP_ResizeLinear.gen.c.t
@@ -57,7 +57,7 @@
for (i = (1<<14) - xoff[x]; i > xpix_dist; i -= xpix_dist) {
if (mx < src->w - 1)
mx++;
-
+
pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, mx, y0);
%% for c in pt.chanslist
@@ -68,9 +68,9 @@
if (i > 0) {
if (mx < src->w - 1)
mx++;
-
+
pix = GP_GetPixel_Raw_{{ pt.pixelsize.suffix }}(src, mx, y0);
-
+
%% for c in pt.chanslist
{{ c[0] }}{{ suff }} += (GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix) * i) >> 9;
%% endfor
@@ -100,7 +100,7 @@
*
* The pixels are weighted by how much they are 'hit' by the rectangle defined
* by the sampled pixel.
- *
+ *
* The implementation is inspired by imlib2 downscaling algorithm.
*/
static int GP_FilterResizeLinearLFInt_{{ pt.name }}_Raw(const GP_Context *src, GP_Context *dst,
@@ -152,12 +152,12 @@ static int GP_FilterResizeLinearLFInt_{{ pt.name }}_Raw(const GP_Context *src, G
%% endfor
for (j = (1<<14) - yoff[y]; j > ypix_dist; j -= ypix_dist) {
-
+
x0 = xmap[x];
-
+
if (y0 < src->h - 1)
y0++;
-
+
{{ sample_x(pt, '1') }}
%% for c in pt.chanslist
@@ -167,10 +167,10 @@ static int GP_FilterResizeLinearLFInt_{{ pt.name }}_Raw(const GP_Context *src, G
if (j > 0) {
x0 = xmap[x];
-
+
if (y0 < src->h - 1)
y0++;
-
+
{{ sample_x(pt, '1') }}
%% for c in pt.chanslist
@@ -181,11 +181,11 @@ static int GP_FilterResizeLinearLFInt_{{ pt.name }}_Raw(const GP_Context *src, G
%% for c in pt.chanslist
{{ c[0] }} = ({{ c[0] }} + (1<<4))>>5;
%% endfor
-
+
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y,
GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "") }}));
}
-
+
if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w))
return 1;
}
@@ -207,7 +207,7 @@ static int GP_FilterResizeLinearInt_{{ pt.name }}_Raw(const GP_Context *src, GP_
uint8_t xoff[dst->w + 1];
uint8_t yoff[dst->h + 1];
uint32_t x, y, i;
-
+
GP_DEBUG(1, "Scaling image %ux%u -> %ux%u %2.2f %2.2f",
src->w, src->h, dst->w, dst->h,
1.00 * dst->w / src->w, 1.00 * dst->h / src->h);
@@ -243,7 +243,7 @@ static int GP_FilterResizeLinearInt_{{ pt.name }}_Raw(const GP_Context *src, GP_
if (x1 >= (GP_Coord)src->w)
x1 = src->w - 1;
-
+
y0 = ymap[y];
y1 = ymap[y] + 1;
@@ -274,11 +274,11 @@ static int GP_FilterResizeLinearInt_{{ pt.name }}_Raw(const GP_Context *src, GP_
%% for c in pt.chanslist
{{ c[0] }} = ({{ c[0] }}1 * yoff[y] + {{ c[0] }}0 * (255 - yoff[y]) + (1<<15)) >> 16;
%% endfor
-
+
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y,
GP_Pixel_CREATE_{{ pt.name }}({{ expand_chanslist(pt, "") }}));
}
-
+
if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w))
return 1;
}
@@ -318,7 +318,7 @@ int GP_FilterResizeLinearLFInt_Raw(const GP_Context *src, GP_Context *dst,
GP_DEBUG(1, "Downscaling image %ux%u -> %ux%u %2.2f %2.2f",
src->w, src->h, dst->w, dst->h, x_rat, y_rat);
-
+
switch (src->pixel_type) {
%% for pt in pixeltypes
%% if not pt.is_unknown() and not pt.is_palette()
diff --git a/libs/filters/GP_ResizeNN.gen.c.t b/libs/filters/GP_ResizeNN.gen.c.t
index 65d12bb..55eb34d 100644
--- a/libs/filters/GP_ResizeNN.gen.c.t
+++ b/libs/filters/GP_ResizeNN.gen.c.t
@@ -43,7 +43,7 @@ static int GP_FilterResizeNN_{{ pt.name }}_Raw(const GP_Context *src,
uint32_t ymap[dst->h];
uint32_t i;
GP_Coord x, y;
-
+
GP_DEBUG(1, "Scaling image %ux%u -> %ux%u %2.2f %2.2f",
src->w, src->h, dst->w, dst->h,
1.00 * dst->w / src->w, 1.00 * dst->h / src->h);
@@ -62,7 +62,7 @@ static int GP_FilterResizeNN_{{ pt.name }}_Raw(const GP_Context *src,
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, pix);
}
-
+
if (GP_ProgressCallbackReport(callback, y, dst->h, dst->w))
return 1;
}
diff --git a/libs/filters/GP_Rotate.c b/libs/filters/GP_Rotate.c
index 4adb911..6aff0ba 100644
--- a/libs/filters/GP_Rotate.c
+++ b/libs/filters/GP_Rotate.c
@@ -50,7 +50,7 @@ int GP_FilterMirrorH_Raw(const GP_Context *src, GP_Context *dst,
memcpy(buf, sl1, bpr);
memcpy(dl1, sl2, bpr);
memcpy(dl2, buf, bpr);
-
+
if (GP_ProgressCallbackReport(callback, 2 * y, src->h, src->w)) {
GP_DEBUG(1, "Operation aborted");
errno = ECANCELED;
@@ -77,7 +77,7 @@ int GP_FilterMirrorH(const GP_Context *src, GP_Context *dst,
{
GP_ASSERT(src->pixel_type == dst->pixel_type,
"The src and dst pixel types must match");
-
+
GP_ASSERT(src->w <= dst->w && src->h <= dst->h,
"Destination is not large enough");
@@ -91,9 +91,9 @@ GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_Context *res;
-
+
res = GP_ContextCopy(src, 0);
-
+
if (res == NULL)
return NULL;
@@ -101,7 +101,7 @@ GP_Context *GP_FilterMirrorHAlloc(const GP_Context *src,
GP_ContextFree(res);
return NULL;
}
-
+
return res;
}
diff --git a/libs/filters/GP_Rotate.gen.c.t b/libs/filters/GP_Rotate.gen.c.t
index 391d04f..364dd77 100644
--- a/libs/filters/GP_Rotate.gen.c.t
+++ b/libs/filters/GP_Rotate.gen.c.t
@@ -35,7 +35,7 @@ static int GP_FilterRotate90_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Conte
GP_ProgressCallback *callback)
{
uint32_t x, y;
-
+
GP_DEBUG(1, "Rotating image by 90 %ux%u", src->w, src->h);
for (x = 0; x < src->w; x++) {
@@ -43,11 +43,11 @@ static int GP_FilterRotate90_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Conte
uint32_t yr = src->h - y - 1;
GP_PutPixel_Raw_{{ ps.suffix }}(dst, yr, x, GP_GetPixel_Raw_{{ ps.suffix }}(src, x, y));
}
-
+
if (GP_ProgressCallbackReport(callback, x, src->w, src->h))
return 1;
}
-
+
GP_ProgressCallbackDone(callback);
return 0;
}
@@ -73,21 +73,21 @@ static int GP_FilterRotate180_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont
GP_ProgressCallback *callback)
{
uint32_t x, y;
-
+
GP_DEBUG(1, "Rotating image by 180 %ux%u", src->w, src->h);
for (x = 0; x < src->w; x++) {
for (y = 0; y < src->h; y++) {
uint32_t xr = src->w - x - 1;
uint32_t yr = src->h - y - 1;
-
+
{{ swap_pixels(ps, 'src', 'dst', 'x', 'y', 'xr', 'yr') }}
}
-
+
if (GP_ProgressCallbackReport(callback, x, src->w, src->h))
return 1;
}
-
+
GP_ProgressCallbackDone(callback);
return 0;
}
@@ -106,7 +106,7 @@ static int GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont
GP_ProgressCallback *callback)
{
uint32_t x, y;
-
+
GP_DEBUG(1, "Rotating image by 270 %ux%u", src->w, src->h);
for (x = 0; x < src->w; x++) {
@@ -118,7 +118,7 @@ static int GP_FilterRotate270_Raw_{{ ps.suffix }}(const GP_Context *src, GP_Cont
if (GP_ProgressCallbackReport(callback, x, src->w, src->h))
return 1;
}
-
+
GP_ProgressCallbackDone(callback);
return 0;
}
diff --git a/libs/filters/GP_Sigma.c b/libs/filters/GP_Sigma.c
index d6d78c8..63e016a 100644
--- a/libs/filters/GP_Sigma.c
+++ b/libs/filters/GP_Sigma.c
@@ -45,7 +45,7 @@ static int GP_FilterSigma_Raw(const GP_Context *src,
{
int x, y;
unsigned int x1, y1;
-
+
if (src->pixel_type != GP_PIXEL_RGB888) {
errno = ENOSYS;
return -1;
@@ -69,11 +69,11 @@ static int GP_FilterSigma_Raw(const GP_Context *src,
unsigned int *R = GP_TempAllocGet(temp, size * sizeof(unsigned int));
unsigned int *G = GP_TempAllocGet(temp, size * sizeof(unsigned int));
unsigned int *B = GP_TempAllocGet(temp, size * sizeof(unsigned int));
-
+
/* prefil the sampled array */
for (x = 0; x < (int)w; x++) {
int xi = GP_CLAMP(x_src + x - xrad, 0, (int)src->w - 1);
-
+
for (y = 0; y < (int)ydiam; y++) {
int yi = GP_CLAMP(y_src + y - yrad, 0, (int)src->h - 1);
@@ -116,7 +116,7 @@ static int GP_FilterSigma_Raw(const GP_Context *src,
R_sum = 0;
G_sum = 0;
B_sum = 0;
-
+
R_ssum = 0;
G_ssum = 0;
B_ssum = 0;
@@ -144,14 +144,14 @@ static int GP_FilterSigma_Raw(const GP_Context *src,
G_ssum += G_cur;
G_cnt++;
}
-
+
if (abs(B_cur - B_center) < B_sigma) {
B_ssum += B_cur;
B_cnt++;
}
}
}
-
+
R_sum -= R_center;
G_sum -= G_center;
B_sum -= B_center;
@@ -159,12 +159,12 @@ static int GP_FilterSigma_Raw(const GP_Context *src,
unsigned int r;
unsigned int g;
unsigned int b;
-
+
if (R_cnt >= min)
r = R_ssum / R_cnt;
else
r = R_sum / cnt;
-
+
if (G_cnt >= min)
g = G_ssum / G_cnt;
else
@@ -174,27 +174,26 @@ static int GP_FilterSigma_Raw(const GP_Context *src,
b = B_ssum / B_cnt;
else
b = B_sum / cnt;
-
+
GP_PutPixel_Raw_24BPP(dst, x_dst + x, y_dst + y,
GP_Pixel_CREATE_RGB888(r, g, b));
}
-
+
int yi = GP_CLAMP(y_src + y + yrad + 1, 0, (int)src->h - 1);
-
+
for (x = 0; x < (int)w; x++) {
int xi = GP_CLAMP(x_src + x - xrad, 0, (int)src->w - 1);
-
+
GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, xi, yi);
-
+
R[yl * w + x] = GP_Pixel_GET_R_RGB888(pix);
G[yl * w + x] = GP_Pixel_GET_G_RGB888(pix);
B[yl * w + x] = GP_Pixel_GET_B_RGB888(pix);
-
}
-
+
yc = (yc+1) % ydiam;
yl = (yl+1) % ydiam;
-
+
if (GP_ProgressCallbackReport(callback, y, h_src, w_src)) {
GP_TempAllocFree(temp);
return 1;
@@ -217,7 +216,7 @@ int GP_FilterSigmaEx(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_CHECK(src->pixel_type == dst->pixel_type);
-
+
/* Check that destination is large enough */
GP_CHECK(x_dst + (GP_Coord)w_src <= (GP_Coord)dst->w);
GP_CHECK(y_dst + (GP_Coord)h_src <= (GP_Coord)dst->h);
diff --git a/libs/filters/GP_Stats.c b/libs/filters/GP_Stats.c
index df65794..3ed5b68 100644
--- a/libs/filters/GP_Stats.c
+++ b/libs/filters/GP_Stats.c
@@ -44,7 +44,7 @@ int GP_FilterHistogram(const GP_Context *src, GP_FilterParam histogram[],
for (i = 0; histogram[i].channel_name[0] != '0'; i++) {
unsigned int j;
GP_Histogram *hist = histogram[i].val.ptr;
-
+
hist->max = hist->hist[0];
hist->min = hist->hist[0];
@@ -65,7 +65,7 @@ void GP_FilterHistogramAlloc(GP_PixelType type, GP_FilterParam params[])
uint32_t i;
GP_FilterParamSetPtrAll(params, NULL);
-
+
const GP_PixelTypeChannel *channels = GP_PixelTypes[type].channels;
for (i = 0; i < GP_PixelTypes[type].numchannels; i++) {
@@ -73,12 +73,12 @@ void GP_FilterHistogramAlloc(GP_PixelType type, GP_FilterParam params[])
GP_Histogram *hist = malloc(sizeof(struct GP_Histogram) +
sizeof(uint32_t) * chan_size);
-
+
if (hist == NULL) {
GP_FilterHistogramFree(params);
return;
}
-
+
hist->len = chan_size;
memset(hist->hist, 0, sizeof(uint32_t) * chan_size);
diff --git a/libs/filters/GP_WeightedMedian.c b/libs/filters/GP_WeightedMedian.c
index aac0c75..62732ee 100644
--- a/libs/filters/GP_WeightedMedian.c
+++ b/libs/filters/GP_WeightedMedian.c
@@ -89,7 +89,7 @@ static int GP_FilterWeightedMedian_Raw(const GP_Context *src,
unsigned int x1, y1;
if (src->pixel_type != GP_PIXEL_RGB888) {
- errno = ENOSYS;
+ errno = ENOSYS;
return -1;
}
@@ -108,7 +108,7 @@ static int GP_FilterWeightedMedian_Raw(const GP_Context *src,
/* prefil the sampled array */
for (x = 0; x < (int)w; x++) {
int xi = GP_CLAMP(x_src + x - (int)weights->w/2, 0, (int)src->w - 1);
-
+
for (y = 0; y < (int)weights->h; y++) {
int yi = GP_CLAMP(y_src + y - (int)weights->h, 0, (int)src->h - 1);
@@ -144,7 +144,7 @@ static int GP_FilterWeightedMedian_Raw(const GP_Context *src,
unsigned int r = hist_med(hist_R, 256, sum/2);
unsigned int g = hist_med(hist_G, 256, sum/2);
unsigned int b = hist_med(hist_B, 256, sum/2);
-
+
GP_PutPixel_Raw_24BPP(dst, x_dst + x, y_dst + y,
GP_Pixel_CREATE_RGB888(r, g, b));
@@ -152,10 +152,10 @@ static int GP_FilterWeightedMedian_Raw(const GP_Context *src,
hist_clear(hist_G, 256);
hist_clear(hist_B, 256);
}
-
+
for (x = 0; x < (int)w; x++) {
int xi = GP_CLAMP(x_src + x - (int)weights->w/2, 0, (int)src->w - 1);
-
+
for (y1 = 0; y1 < weights->h; y1++) {
int yi = GP_CLAMP(y_src + y + (int)y1 - (int)weights->h/2, 0, (int)src->h - 1);
@@ -165,8 +165,8 @@ static int GP_FilterWeightedMedian_Raw(const GP_Context *src,
G[y1 * w + x] = GP_Pixel_GET_G_RGB888(pix);
B[y1 * w + x] = GP_Pixel_GET_B_RGB888(pix);
}
- }
-
+ }
+
if (GP_ProgressCallbackReport(callback, y, h_src, w_src)) {
GP_TempAllocFree(temp);
return 1;
@@ -188,7 +188,7 @@ int GP_FilterWeightedMedianEx(const GP_Context *src,
GP_ProgressCallback *callback)
{
GP_CHECK(src->pixel_type == dst->pixel_type);
-
+
/* Check that destination is large enough */
GP_CHECK(x_dst + (GP_Coord)w_src <= (GP_Coord)dst->w);
GP_CHECK(y_dst + (GP_Coord)h_src <= (GP_Coord)dst->h);
diff --git a/libs/gfx/GP_Arc.c b/libs/gfx/GP_Arc.c
index ac0360a..0b9a66c 100644
--- a/libs/gfx/GP_Arc.c
+++ b/libs/gfx/GP_Arc.c
@@ -51,11 +51,11 @@ void GP_ArcSegment(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
/* recalculate center point and swap a and b when axes are swapped */
GP_TRANSFORM_POINT(context, xcenter, ycenter);
GP_TRANSFORM_SWAP(context, a, b);
-
+
GP_ArcSegment_Raw(context, xcenter, ycenter, a, b, direction,
start, end, pixel);
}
diff --git a/libs/gfx/GP_Circle.c b/libs/gfx/GP_Circle.c
index a19e98f..2b39928 100644
--- a/libs/gfx/GP_Circle.c
+++ b/libs/gfx/GP_Circle.c
@@ -49,25 +49,25 @@ void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_CHECK_CONTEXT(context);
GP_TRANSFORM_POINT(context, xcenter, ycenter);
-
+
GP_Circle_Raw(context, xcenter, ycenter, r, pixel);
}
void GP_Ring_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size r1, GP_Size r2, GP_Pixel pixel)
{
- GP_Circle_Raw(context, xcenter, ycenter, r1, pixel);
- GP_Circle_Raw(context, xcenter, ycenter, r2, pixel);
+ GP_Circle_Raw(context, xcenter, ycenter, r1, pixel);
+ GP_Circle_Raw(context, xcenter, ycenter, r2, pixel);
}
void GP_Ring(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size r1, GP_Size r2, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
GP_TRANSFORM_POINT(context, xcenter, ycenter);
- GP_Ring_Raw(context, xcenter, ycenter, r1, r2, pixel);
+ GP_Ring_Raw(context, xcenter, ycenter, r1, r2, pixel);
}
#include "algo/FillRing.algo.h"
@@ -88,8 +88,8 @@ void GP_FillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size r1, GP_Size r2, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
GP_TRANSFORM_POINT(context, xcenter, ycenter);
-
+
GP_FillRing_Raw(context, xcenter, ycenter, r1, r2, pixel);
}
diff --git a/libs/gfx/GP_CircleSeg.c b/libs/gfx/GP_CircleSeg.c
index 4d7dc19..feeaf9e 100644
--- a/libs/gfx/GP_CircleSeg.c
+++ b/libs/gfx/GP_CircleSeg.c
@@ -77,7 +77,7 @@ void GP_CircleSeg(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_CHECK_CONTEXT(context);
GP_TRANSFORM_POINT(context, xcenter, ycenter);
-
+
GP_CircleSeg_Raw(context, xcenter, ycenter, r,
transform_segments(context, seg_flag), pixel);
}
@@ -100,9 +100,9 @@ void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size r, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
GP_TRANSFORM_POINT(context, xcenter, ycenter);
-
+
GP_FillCircle_Raw(context, xcenter, ycenter, r, pixel);
}
*/
diff --git a/libs/gfx/GP_Ellipse.c b/libs/gfx/GP_Ellipse.c
index bd7d31b..1d2085e 100644
--- a/libs/gfx/GP_Ellipse.c
+++ b/libs/gfx/GP_Ellipse.c
@@ -47,10 +47,10 @@ void GP_Ellipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size a, GP_Size b, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
/* recalculate center point and swap a and b when axes are swapped */
GP_TRANSFORM_POINT(context, xcenter, ycenter);
GP_TRANSFORM_SWAP(context, a, b);
-
+
GP_Ellipse_Raw(context, xcenter, ycenter, a, b, pixel);
}
diff --git a/libs/gfx/GP_FillEllipse.gen.c.t b/libs/gfx/GP_FillEllipse.gen.c.t
index aed7d1f..325106e 100644
--- a/libs/gfx/GP_FillEllipse.gen.c.t
+++ b/libs/gfx/GP_FillEllipse.gen.c.t
@@ -58,7 +58,7 @@ static void GP_FillEllipse_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord xce
GP_VLine_Raw_{{ ps.suffix }}(context, xcenter, ycenter - b, ycenter + b, pixel);
return;
}
-
+
int x, y, error;
for (x = 0, error = -b2*a, y = b; y >= 0; y--) {
while (error < 0) {
@@ -66,7 +66,7 @@ static void GP_FillEllipse_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord xce
x++;
}
error += a2 * (-2*y + 1);
-
+
/* Draw two horizontal lines reflected across Y. */
GP_HLine_Raw_{{ ps.suffix }}(context, xcenter-x+1, xcenter+x-1, ycenter-y, pixel);
GP_HLine_Raw_{{ ps.suffix }}(context, xcenter-x+1, xcenter+x-1, ycenter+y, pixel);
@@ -88,10 +88,10 @@ void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size a, GP_Size b, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
GP_TRANSFORM_POINT(context, xcenter, ycenter);
GP_TRANSFORM_SWAP(context, a, b);
-
+
GP_FillEllipse_Raw(context, xcenter, ycenter, a, b, pixel);
}
diff --git a/libs/gfx/GP_HLine.gen.c.t b/libs/gfx/GP_HLine.gen.c.t
index 72f1555..4a9ea1e 100644
--- a/libs/gfx/GP_HLine.gen.c.t
+++ b/libs/gfx/GP_HLine.gen.c.t
@@ -58,7 +58,7 @@ void GP_HLine_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int x1, int y,
x0 = GP_MAX(x0, 0);
x1 = GP_MIN(x1, (int) context->w - 1);
-%% if ps.suffix in have_writepixels
+%% if ps.suffix in have_writepixels
size_t length = 1 + x1 - x0;
void *start = GP_PIXEL_ADDR(context, x0, y);
diff --git a/libs/gfx/GP_HLineAA.c b/libs/gfx/GP_HLineAA.c
index 01770f4..93b5e04 100644
--- a/libs/gfx/GP_HLineAA.c
+++ b/libs/gfx/GP_HLineAA.c
@@ -31,7 +31,7 @@ void GP_HLineXXYAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
GP_Coord y, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
GP_FN_PER_BPP_CONTEXT(GP_HLine_Raw, context, context, x0, x1, y,
pixel);
}
@@ -41,7 +41,7 @@ void GP_HLineAA(GP_Context *context, GP_Coord x0, GP_Coord x1,
GP_Coord y, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
if (context->axes_swap) {
GP_TRANSFORM_Y_FP(context, x0);
GP_TRANSFORM_Y_FP(context, x1);
diff --git a/libs/gfx/GP_HLineAA.gen.c.t b/libs/gfx/GP_HLineAA.gen.c.t
index 8d3240d..63fc0d6 100644
--- a/libs/gfx/GP_HLineAA.gen.c.t
+++ b/libs/gfx/GP_HLineAA.gen.c.t
@@ -49,10 +49,10 @@ void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
/* Nothing to draw */
if (x0 == x1)
return;
-
+
if (x1 < x0)
GP_SWAP(x1, x0);
-
+
GP_Coord int_x0 = TO_X_S(x0);
GP_Coord int_x1 = TO_X_E(x1);
GP_Coord int_y = GP_FP_FLOOR_TO_INT(y);
@@ -62,31 +62,31 @@ void GP_HLineAA_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
/* Draw the four starting and ending pixels */
unsigned int perc;
unsigned int w;
-
+
w = GP_FP_RFRAC(x0 + GP_FP_1_2);
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(y), w));
GP_MixPixel_Raw_Clipped(context, int_x0, int_y, pixel, perc);
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(y), w));
- GP_MixPixel_Raw_Clipped(context, int_x0, int_y+1, pixel, perc);
+ GP_MixPixel_Raw_Clipped(context, int_x0, int_y+1, pixel, perc);
if (int_x0 != int_x1) {
w = GP_FP_FRAC(x1 + GP_FP_1_2);
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(y), w));
GP_MixPixel_Raw_Clipped(context, int_x1, int_y, pixel, perc);
-
+
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(y), w));
- GP_MixPixel_Raw_Clipped(context, int_x1, int_y+1, pixel, perc);
+ GP_MixPixel_Raw_Clipped(context, int_x1, int_y+1, pixel, perc);
}
GP_Coord x;
-
+
/* Now fill the inner part of the HLine */
uint8_t up = FP_TO_PERC(GP_FP_RFRAC(y));
uint8_t lp = FP_TO_PERC(GP_FP_FRAC(y));
-
+
for (x = int_x0 + 1; x < int_x1; x++) {
GP_MixPixel_Raw_Clipped(context, x, int_y, pixel, up);
GP_MixPixel_Raw_Clipped(context, x, int_y+1, pixel, lp);
diff --git a/libs/gfx/GP_Line.gen.c.t b/libs/gfx/GP_Line.gen.c.t
index a2dbd9d..d91b45a 100644
--- a/libs/gfx/GP_Line.gen.c.t
+++ b/libs/gfx/GP_Line.gen.c.t
@@ -56,7 +56,7 @@ void GP_Line_Raw_{{ ps.suffix }}(GP_Context *context, int x0, int y0,
GP_ASSERT(x1 >= 0 && x1 <= (int) context->w-1);
GP_ASSERT(y0 >= 0 && y0 <= (int) context->h-1);
GP_ASSERT(y1 >= 0 && y1 <= (int) context->h-1);
-
+
/* special cases: vertical line, horizontal line, single point */
if (x0 == x1) {
if (y0 == y1) {
diff --git a/libs/gfx/GP_LineAA.c b/libs/gfx/GP_LineAA.c
index 6d30df0..5c2ad8e 100644
--- a/libs/gfx/GP_LineAA.c
+++ b/libs/gfx/GP_LineAA.c
@@ -43,9 +43,9 @@ void GP_LineAA(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
GP_TRANSFORM_POINT_FP(context, x0, y0);
GP_TRANSFORM_POINT_FP(context, x1, y1);
-
+
GP_LineAA_Raw(context, x0, y0, x1, y1, pixel);
}
diff --git a/libs/gfx/GP_LineAA.gen.c.t b/libs/gfx/GP_LineAA.gen.c.t
index c5796d5..845819e 100644
--- a/libs/gfx/GP_LineAA.gen.c.t
+++ b/libs/gfx/GP_LineAA.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.c.t"
{% block descr %}Anti Aliased Line{% endblock %}
@@ -20,10 +42,10 @@ static inline void line_aa_x(GP_Context *context,
{
GP_Coord xend, yend, xgap, xpx0, ypx0, xpx1, ypx1;
uint8_t perc;
-
+
int64_t dx = x1 - x0;
int64_t dy = y1 - y0;
-
+
if (x1 < x0) {
GP_SWAP(x0, x1);
GP_SWAP(y0, y1);
@@ -56,7 +78,7 @@ static inline void line_aa_x(GP_Context *context,
for (x = xpx0 + 1; x < xpx1; x++) {
intery = yend + GP_FP_DIV((x - xpx0) * dy, dx);
-
+
perc = FP_TO_PERC(GP_FP_RFRAC(intery));
GP_MixPixel_Raw_Clipped(context, x, GP_FP_TO_INT(intery), pixel, perc);
perc = FP_TO_PERC(GP_FP_FRAC(intery));
@@ -70,10 +92,10 @@ static inline void line_aa_y(GP_Context *context,
{
GP_Coord xend, yend, ygap, xpx0, ypx0, xpx1, ypx1;
uint8_t perc;
-
+
int64_t dx = x1 - x0;
int64_t dy = y1 - y0;
-
+
if (y1 < y0) {
GP_SWAP(x0, x1);
GP_SWAP(y0, y1);
@@ -106,7 +128,7 @@ static inline void line_aa_y(GP_Context *context,
for (y = ypx0 + 1; y < ypx1; y++) {
intery = xend + GP_FP_DIV((y - ypx0) * dx, dy);
-
+
perc = FP_TO_PERC(GP_FP_RFRAC(intery));
GP_MixPixel_Raw_Clipped(context, GP_FP_TO_INT(intery), y, pixel, perc);
perc = FP_TO_PERC(GP_FP_FRAC(intery));
diff --git a/libs/gfx/GP_LineClip.c b/libs/gfx/GP_LineClip.c
index 6a1f76e..570a2e3 100644
--- a/libs/gfx/GP_LineClip.c
+++ b/libs/gfx/GP_LineClip.c
@@ -52,7 +52,7 @@ int GP_LineClip(int *px0, int *py0, int *px1, int *py1, int xmax, int ymax)
goto give_result;
}
if (x0 == x1) {
-
+
/* orient the line from top to down */
if (x1 < x0) {
GP_SWAP(x0, x1);
@@ -95,7 +95,7 @@ int GP_LineClip(int *px0, int *py0, int *px1, int *py1, int xmax, int ymax)
x1 = xmax;
y1 = y0 + (x1-x0)*dyx;
}
-
+
if (y0 < 0.0f) {
x0 = x0 - y0*dxy;
y0 = 0.0f;
@@ -118,7 +118,7 @@ int GP_LineClip(int *px0, int *py0, int *px1, int *py1, int xmax, int ymax)
/* the line misses the clip rectangle around the corner */
return 0;
}
-
+
give_result:
*px0 = (int) x0;
diff --git a/libs/gfx/GP_PutPixelAA.gen.c.t b/libs/gfx/GP_PutPixelAA.gen.c.t
index da47d7a..b061bf9 100644
--- a/libs/gfx/GP_PutPixelAA.gen.c.t
+++ b/libs/gfx/GP_PutPixelAA.gen.c.t
@@ -47,13 +47,13 @@ void GP_PutPixelAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_1 - frac_x, GP_FP_1 - frac_y));
GP_MixPixel_Raw_Clipped(context, int_x, int_y, pixel, perc);
-
+
perc = FP_TO_PERC(GP_FP_MUL(frac_x, GP_FP_1 - frac_y));
GP_MixPixel_Raw_Clipped(context, int_x + 1, int_y, pixel, perc);
-
+
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_1 - frac_x, frac_y));
GP_MixPixel_Raw_Clipped(context, int_x, int_y + 1, pixel, perc);
-
+
perc = FP_TO_PERC(GP_FP_MUL(frac_x, frac_y));
GP_MixPixel_Raw_Clipped(context, int_x + 1, int_y + 1, pixel, perc);
}
diff --git a/libs/gfx/GP_Rect.c b/libs/gfx/GP_Rect.c
index 9c30385..be07b8b 100644
--- a/libs/gfx/GP_Rect.c
+++ b/libs/gfx/GP_Rect.c
@@ -43,7 +43,7 @@ void GP_RectXYWH_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
{
if (w == 0 || h == 0)
return;
-
+
GP_RectXYXY_Raw(context, x, y, x + w - 1, y + h - 1, pixel);
}
@@ -51,7 +51,7 @@ void GP_RectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
GP_TRANSFORM_POINT(context, x0, y0);
GP_TRANSFORM_POINT(context, x1, y1);
@@ -63,7 +63,7 @@ void GP_RectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
{
if (w == 0 || h == 0)
return;
-
+
GP_RectXYXY(context, x, y, x + w - 1, y + h - 1, pixel);
}
@@ -93,7 +93,7 @@ void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
GP_TRANSFORM_POINT(context, x0, y0);
GP_TRANSFORM_POINT(context, x1, y1);
diff --git a/libs/gfx/GP_RectAA.c b/libs/gfx/GP_RectAA.c
index 812c6bd..6026cad 100644
--- a/libs/gfx/GP_RectAA.c
+++ b/libs/gfx/GP_RectAA.c
@@ -28,8 +28,6 @@
#include "GP_Rect.h"
#include "GP_RectAA.h"
-
-
void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
{
@@ -46,7 +44,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord out_y0 = GP_FP_FLOOR_TO_INT(y0 + GP_FP_1_2);
GP_Coord out_x1 = GP_FP_CEIL_TO_INT(x1 - GP_FP_1_2);
GP_Coord out_y1 = GP_FP_CEIL_TO_INT(y1 - GP_FP_1_2);
-
+
/* Size */
GP_Size w = x1 - x0;
GP_Size h = y1 - y0;
@@ -73,7 +71,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
if (out_y0 == out_y1) {
uint8_t mix = w;
GP_Coord i;
-
+
/* Special case 1px 100% height line */
if (h == GP_FP_1)
mix = 255;
@@ -92,14 +90,14 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord in_y0 = GP_FP_CEIL_TO_INT(y0 + GP_FP_1_2);
GP_Coord in_x1 = GP_FP_FLOOR_TO_INT(x1 - GP_FP_1_2);
GP_Coord in_y1 = GP_FP_FLOOR_TO_INT(y1 - GP_FP_1_2);
-
- /*
+
+ /*
* Draw the inner rectanle in 100% intensity.
*
* Note that if out_x0 == in_x1 is 2px wide and both lines has less than
* 100% intensity. The same goes for out_y0 == in_y1.
*/
- if (in_x1 >= in_x0 && (out_x0 != in_x1 || out_x1 != in_x0)
+ if (in_x1 >= in_x0 && (out_x0 != in_x1 || out_x1 != in_x0)
&& in_y1 >= in_y0 && (out_y0 != in_y1 || out_y1 != in_y0))
GP_FillRectXYXY_Raw(context, in_x0, in_y0, in_x1, in_y1, pixel);
@@ -107,18 +105,18 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
if (in_y0 != out_y0) {
uint8_t mix = GP_FP_FROM_INT(in_y0) + GP_FP_1_2 - y0;
GP_Coord i;
-
+
for (i = out_x0; i <= out_x1; i++) {
GP_Pixel p = GP_GetPixel_Raw_Clipped(context, i, out_y0);
p = GP_MixPixels(pixel, p, mix, context->pixel_type);
GP_PutPixel_Raw_Clipped(context, i, out_y0, p);
}
}
-
+
if (in_y1 != out_y1) {
uint8_t mix = y1 - GP_FP_FROM_INT(in_y0) - GP_FP_1_2;
GP_Coord i;
-
+
for (i = out_x0; i <= out_x1; i++) {
GP_Pixel p = GP_GetPixel_Raw_Clipped(context, i, out_y1);
p = GP_MixPixels(pixel, p, mix, context->pixel_type);
@@ -129,7 +127,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
if (in_x0 != out_x0) {
uint8_t mix = GP_FP_FROM_INT(in_x0) + GP_FP_1_2 - x0;
GP_Coord i;
-
+
for (i = out_y0; i <= out_y1; i++) {
GP_Pixel p = GP_GetPixel_Raw_Clipped(context, out_x0, i);
p = GP_MixPixels(pixel, p, mix, context->pixel_type);
@@ -140,7 +138,7 @@ void GP_FillRectXYXY_AA_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
if (in_x1 != out_x1) {
uint8_t mix = x1 - GP_FP_FROM_INT(in_x1) - GP_FP_1_2;
GP_Coord i;
-
+
for (i = out_y0; i <= out_y1; i++) {
GP_Pixel p = GP_GetPixel_Raw_Clipped(context, out_x1, i);
p = GP_MixPixels(pixel, p, mix, context->pixel_type);
@@ -165,7 +163,7 @@ void GP_FillRectXYXY_AA(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
GP_TRANSFORM_POINT_FP(context, x0, y0);
GP_TRANSFORM_POINT_FP(context, x1, y1);
diff --git a/libs/gfx/GP_Tetragon.c b/libs/gfx/GP_Tetragon.c
index e087d12..66ed426 100644
--- a/libs/gfx/GP_Tetragon.c
+++ b/libs/gfx/GP_Tetragon.c
@@ -46,7 +46,7 @@ void GP_Tetragon(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x3, GP_Coord y3, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
GP_TRANSFORM_POINT(context, x0, y0);
GP_TRANSFORM_POINT(context, x1, y1);
GP_TRANSFORM_POINT(context, x2, y2);
@@ -60,7 +60,7 @@ void GP_FillTetragon_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x3, GP_Coord y3, GP_Pixel pixel)
{
const GP_Coord xy[8] = {x0, y0, x1, y1, x2, y2, x3, y3};
-
+
GP_FillPolygon_Raw(context, 4, xy, pixel);
}
@@ -69,7 +69,7 @@ void GP_FillTetragon(GP_Context* context, GP_Coord x0, GP_Coord y0,
GP_Coord x3, GP_Coord y3, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
GP_TRANSFORM_POINT(context, x0, y0);
GP_TRANSFORM_POINT(context, x1, y1);
GP_TRANSFORM_POINT(context, x2, y2);
diff --git a/libs/gfx/GP_Triangle.c b/libs/gfx/GP_Triangle.c
index 724e407..5f1e4e7 100644
--- a/libs/gfx/GP_Triangle.c
+++ b/libs/gfx/GP_Triangle.c
@@ -43,7 +43,7 @@ void GP_Triangle(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x2, GP_Coord y2, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
GP_TRANSFORM_POINT(context, x0, y0);
GP_TRANSFORM_POINT(context, x1, y1);
GP_TRANSFORM_POINT(context, x2, y2);
diff --git a/libs/gfx/GP_VLine.c b/libs/gfx/GP_VLine.c
index 08d075c..166aa03 100644
--- a/libs/gfx/GP_VLine.c
+++ b/libs/gfx/GP_VLine.c
@@ -30,7 +30,7 @@
#include "gfx/GP_VLine.h"
#include "gfx/GP_HLine.h"
-/*
+/*
* Ensures that coordinates are in correct order, and clips them.
* Exits immediately if the line is completely clipped out.
*/
@@ -48,7 +48,7 @@ void GP_VLineXYY_Raw(GP_Context *context, GP_Coord x, GP_Coord y0,
GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
ORDER_AND_CLIP_COORDS;
GP_FN_PER_BPP_CONTEXT(GP_VLine_Raw, context, context, x, y0, y1, pixel);
@@ -67,7 +67,7 @@ void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0,
GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
if (context->axes_swap) {
GP_TRANSFORM_Y(context, x);
GP_TRANSFORM_X(context, y0);
diff --git a/libs/gfx/GP_VLine.gen.c.t b/libs/gfx/GP_VLine.gen.c.t
index ad949e9..d894f14 100644
--- a/libs/gfx/GP_VLine.gen.c.t
+++ b/libs/gfx/GP_VLine.gen.c.t
@@ -27,14 +27,14 @@
{% block body %}
#include "core/GP_GetPutPixel.h"
-#include "gfx/GP_VLine.gen.h"
+#include "gfx/GP_VLine.gen.h"
%% for ps in pixelsizes
void GP_VLine_Raw_{{ ps.suffix }}(GP_Context *context, GP_Coord x,
GP_Coord y0, GP_Coord y1, GP_Pixel pixel)
{
int y;
-
+
for (y = y0; y <= y1; y++)
GP_PutPixel_Raw_{{ ps.suffix }}(context, x, y, pixel);
}
diff --git a/libs/gfx/GP_VLineAA.c b/libs/gfx/GP_VLineAA.c
index 6b5b1d4..4af9f69 100644
--- a/libs/gfx/GP_VLineAA.c
+++ b/libs/gfx/GP_VLineAA.c
@@ -40,7 +40,7 @@ void GP_VLineAA(GP_Context *context, GP_Coord x, GP_Coord y0,
GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
if (context->axes_swap) {
GP_TRANSFORM_Y_FP(context, x);
GP_TRANSFORM_X_FP(context, y0);
diff --git a/libs/gfx/GP_VLineAA.gen.c.t b/libs/gfx/GP_VLineAA.gen.c.t
index e754d3e..7c5f3fb 100644
--- a/libs/gfx/GP_VLineAA.gen.c.t
+++ b/libs/gfx/GP_VLineAA.gen.c.t
@@ -1,3 +1,25 @@
+/*****************************************************************************
+ * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
%% extends "base.c.t"
{% block descr %}Anti Aliased Vertical Line{% endblock %}
@@ -27,32 +49,31 @@ void GP_VLineAA_Raw(GP_Context *context, GP_Coord x, GP_Coord y0,
/* Line is shorter than two pixels */
if (int_y0 == int_y1) {
- //TODO
+ //TODO
return;
}
/* Draw the starting and ending pixel */
uint8_t perc;
-
+
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(x), GP_FP_RFRAC(y0)));
GP_MixPixel_Raw_Clipped(context, int_x, int_y0, pixel, perc);
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(x), GP_FP_RFRAC(y0)));
- GP_MixPixel_Raw_Clipped(context, int_x+1, int_y0, pixel, perc);
-
-
+ GP_MixPixel_Raw_Clipped(context, int_x+1, int_y0, pixel, perc);
+
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_RFRAC(x), GP_FP_FRAC(y1)));
GP_MixPixel_Raw_Clipped(context, int_x, int_y1, pixel, perc);
perc = FP_TO_PERC(GP_FP_MUL(GP_FP_FRAC(x), GP_FP_FRAC(y1)));
- GP_MixPixel_Raw_Clipped(context, int_x+1, int_y1, pixel, perc);
+ GP_MixPixel_Raw_Clipped(context, int_x+1, int_y1, pixel, perc);
/* Draw the middle pixels */
uint8_t up = FP_TO_PERC(GP_FP_RFRAC(x));
uint8_t lp = FP_TO_PERC(GP_FP_FRAC(x));
GP_Coord y;
-
+
for (y = int_y0 + 1; y < int_y1; y++) {
GP_MixPixel_Raw_Clipped(context, int_x, y, pixel, up);
GP_MixPixel_Raw_Clipped(context, int_x+1, y, pixel, lp);
diff --git a/libs/grabbers/GP_V4L2.c b/libs/grabbers/GP_V4L2.c
index fc97e9b..baef263 100644
--- a/libs/grabbers/GP_V4L2.c
+++ b/libs/grabbers/GP_V4L2.c
@@ -21,7 +21,7 @@
*****************************************************************************/
/*
-
+
Based on V4L2 example code.
*/
@@ -50,8 +50,8 @@
#include "GP_V4L2.h"
struct v4l2_priv {
- int mode;
-
+ int mode;
+
/* pointer to page aligned user buffer */
void *bufptr[4];
size_t buf_len[4];
@@ -67,9 +67,9 @@ static void v4l2_exit(struct GP_Grabber *self)
int i;
GP_DEBUG(1, "Grabber '%s' exitting", priv->device);
-
+
v4l2_stop(self);
-
+
if (priv->mode == 2) {
for (i = 0; i < 4; i++)
munmap(priv->bufptr[i], priv->buf_len[i]);
@@ -107,7 +107,7 @@ static void v4l2_yuv422_fillframe(struct GP_Grabber *self, void *buf)
int32_t G = MUL * (*py) - ((int32_t)(MUL * 0.344)) * PU
- ((int32_t)(MUL * 0.714)) * PV;
int32_t B = MUL * (*py) + ((int32_t)(MUL * 1.402)) * PV;
-
+
R = (R + MUL/2)/MUL;
G = (G + MUL/2)/MUL;
B = (B + MUL/2)/MUL;
@@ -115,13 +115,13 @@ static void v4l2_yuv422_fillframe(struct GP_Grabber *self, void *buf)
CLAMP(R, 255);
CLAMP(G, 255);
CLAMP(B, 255);
-
+
*tmp++ = R;
*tmp++ = G;
- *tmp++ = B;
+ *tmp++ = B;
py += 2;
-
+
if ((j & 1) == 1) {
pu += 4;
pv += 4;
@@ -133,9 +133,9 @@ static void v4l2_yuv422_fillframe(struct GP_Grabber *self, void *buf)
static int v4l2_poll(struct GP_Grabber *self)
{
struct v4l2_priv *priv = GP_GRABBER_PRIV(self);
-
+
GP_DEBUG(3, "Grabber '%s' poll", priv->device);
-
+
/* read/write interface */
if (priv->mode == 1) {
GP_WARN("Read/write I/O not implemented.");
@@ -154,7 +154,7 @@ static int v4l2_poll(struct GP_Grabber *self)
switch (errno) {
case EAGAIN:
return 0;
- default:
+ default:
GP_WARN("Failed to ioctl VIDIOC_DQBUF on '%s' : %s",
priv->device, strerror(errno));
return 0;
@@ -188,12 +188,12 @@ static int v4l2_start(struct GP_Grabber *self)
int i;
struct v4l2_buffer buf;
memset(&buf, 0, sizeof(buf));
-
+
for (i = 0; i < 4; i++) {
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = i;
-
+
if (ioctl(self->fd, VIDIOC_QBUF, &buf)) {
GP_WARN("Failed to ioclt VIDIOC_QBUF on '%s': %s",
priv->device, strerror(errno));
@@ -248,9 +248,9 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device,
GP_WARN("Failed to open V4L2 grabber '%s'", device);
goto err;
}
-
+
struct v4l2_capability cap;
-
+
if (ioctl(fd, VIDIOC_QUERYCAP, &cap)) {
err = errno;
GP_WARN("ioctl VIDIOC_QUERYCAP failed, '%s' not V4L2 device?",
@@ -294,7 +294,7 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device,
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
/* reset to default */
crop.c = cropcap.defrect;
-
+
if (ioctl(fd, VIDIOC_S_CROP, &crop)) {
/* error/cropping not supported */
}
@@ -306,7 +306,7 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device,
}
struct v4l2_format fmt;
-
+
memset(&fmt, 0, sizeof(fmt));
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@@ -330,7 +330,7 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device,
}
new->frame = GP_ContextAlloc(fmt.fmt.pix.width, fmt.fmt.pix.height, GP_PIXEL_RGB888);
-
+
if (new->frame == NULL) {
err = ENOMEM;
goto err1;
@@ -340,7 +340,7 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device,
strcpy(priv->device, device);
priv->mode = mode;
-
+
switch (mode) {
case 1:
break;
@@ -353,7 +353,7 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device,
req.count = 4;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_MMAP;
-
+
if (ioctl(fd, VIDIOC_REQBUFS, &req)) {
err = errno;
GP_WARN("Failed to ioctl VIDIOC_REQBUFS on '%s' : %s",
@@ -366,7 +366,7 @@ struct GP_Grabber *GP_GrabberV4L2Init(const char *device,
GP_WARN("Unexpected number of buffers on '%s'", device);
goto err2;
}
-
+
struct v4l2_buffer buf;
memset(&buf, 0, sizeof(buf));
diff --git a/libs/input/GP_Event.c b/libs/input/GP_Event.c
index d7ec7cd..ce96a89 100644
--- a/libs/input/GP_Event.c
+++ b/libs/input/GP_Event.c
@@ -34,7 +34,7 @@
static char *key_names[] = {
"Reserved", "Escape", "1", "2", "3",
"4", "5", "6", "7", "8",
- "9", "0", "Minus", "Equal", "BackSpace",
+ "9", "0", "Minus", "Equal", "BackSpace",
"Tab", "Q", "W", "E", "R",
"T", "Y", "U", "I", "O",
"P", "LeftBrace", "RightBrace", "Enter", "LeftCtrl",
diff --git a/libs/input/GP_EventQueue.c b/libs/input/GP_EventQueue.c
index a3732f1..f13a733 100644
--- a/libs/input/GP_EventQueue.c
+++ b/libs/input/GP_EventQueue.c
@@ -46,10 +46,10 @@ struct GP_EventQueue *GP_EventQueueAlloc(unsigned int screen_w,
{
size_t size;
struct GP_EventQueue *new;
-
+
size = sizeof(struct GP_EventQueue) +
(queue_size - GP_EVENT_QUEUE_SIZE) * sizeof(struct GP_Event);
-
+
new = malloc(size);
if (new == NULL) {
@@ -78,7 +78,7 @@ void GP_EventQueueSetScreenSize(struct GP_EventQueue *self,
/* clip cursor */
if (self->cur_state.cursor_x >= w)
self->cur_state.cursor_x = w - 1;
-
+
if (self->cur_state.cursor_y >= h)
self->cur_state.cursor_y = h - 1;
}
@@ -91,7 +91,7 @@ void GP_EventQueueSetCursorPosition(struct GP_EventQueue *self,
x, y, self->screen_w, self->screen_h);
return;
}
-
+
self->cur_state.cursor_x = x;
self->cur_state.cursor_y = y;
}
@@ -134,7 +134,7 @@ static void event_put(struct GP_EventQueue *self, struct GP_Event *ev)
GP_WARN("Event queue full, dropping event.");
return;
}
-
+
self->events[self->queue_last] = *ev;
self->queue_last = next;
}
@@ -200,11 +200,13 @@ void GP_EventQueuePushRel(struct GP_EventQueue *self,
self->cur_state.val.rel.rx = rx;
self->cur_state.val.rel.ry = ry;
- set_time(self, time);
+ set_time(self, time);
/* move the global cursor */
- self->cur_state.cursor_x = clip_rel(self->cur_state.cursor_x, self->screen_w, rx);
- self->cur_state.cursor_y = clip_rel(self->cur_state.cursor_y, self->screen_h, ry);
+ self->cur_state.cursor_x = clip_rel(self->cur_state.cursor_x,
+ self->screen_w, rx);
+ self->cur_state.cursor_y = clip_rel(self->cur_state.cursor_y,
+ self->screen_h, ry);
/* put it into queue */
event_put(self, &self->cur_state);
@@ -217,7 +219,7 @@ void GP_EventQueuePushRelTo(struct GP_EventQueue *self,
GP_WARN("x > screen_w or y > screen_h");
return;
}
-
+
int32_t rx = x - self->cur_state.cursor_x;
int32_t ry = y - self->cur_state.cursor_y;
@@ -232,22 +234,22 @@ void GP_EventQueuePushAbs(struct GP_EventQueue *self,
/* event header */
self->cur_state.type = GP_EV_ABS;
self->cur_state.code = GP_EV_ABS_POS;
- self->cur_state.val.abs.x = x;
+ self->cur_state.val.abs.x = x;
self->cur_state.val.abs.y = y;
self->cur_state.val.abs.pressure = pressure;
- self->cur_state.val.abs.x_max = x_max;
+ self->cur_state.val.abs.x_max = x_max;
self->cur_state.val.abs.y_max = y_max;
self->cur_state.val.abs.pressure_max = pressure_max;
-
+
set_time(self, time);
- /*
+ /*
* Set global cursor, the packet could be partial, eg. update only x or
* only y. In such case x_max or y_max is zero.
*/
- if (x_max != 0)
+ if (x_max != 0)
self->cur_state.cursor_x = x * (self->screen_w - 1) / x_max;
-
+
if (y_max != 0)
self->cur_state.cursor_y = y * (self->screen_h - 1) / y_max;
@@ -287,7 +289,7 @@ static void key_to_ascii(struct GP_Event *ev)
unsigned int key = ev->val.key.key;
ev->val.key.ascii = 0;
-
+
if (GP_EventGetKey(ev, GP_KEY_LEFT_SHIFT) ||
GP_EventGetKey(ev, GP_KEY_RIGHT_SHIFT)) {
if (ev->val.key.key < sizeof(keys_to_ascii_shift))
@@ -303,10 +305,10 @@ void GP_EventQueuePushKey(struct GP_EventQueue *self,
{
switch (code) {
case GP_EV_KEY_UP:
- GP_EventResetKey(&self->cur_state, key);
+ GP_EventResetKey(&self->cur_state, key);
break;
case GP_EV_KEY_DOWN:
- GP_EventSetKey(&self->cur_state, key);
+ GP_EventSetKey(&self->cur_state, key);
break;
case GP_EV_KEY_REPEAT:
break;
@@ -321,7 +323,7 @@ void GP_EventQueuePushKey(struct GP_EventQueue *self,
self->cur_state.val.key.key = key;
key_to_ascii(&self->cur_state);
-
+
set_time(self, time);
/* put it into queue */
@@ -338,7 +340,7 @@ void GP_EventQueuePushResize(struct GP_EventQueue *self,
self->cur_state.val.sys.w = w;
self->cur_state.val.sys.h = h;
- set_time(self, time);
+ set_time(self, time);
/* put it into queue */
event_put(self, &self->cur_state);
diff --git a/libs/input/GP_InputDriverKBD.c b/libs/input/GP_InputDriverKBD.c
index ae575c3..020f45c 100644
--- a/libs/input/GP_InputDriverKBD.c
+++ b/libs/input/GP_InputDriverKBD.c
@@ -69,7 +69,7 @@ void GP_InputDriverKBDEventPut(struct GP_EventQueue *event_queue,
if (keycode > 0 && keycode <= GP_ARRAY_SIZE(keycode_table)) {
key = keycode_table[keycode - 1];
-
+
if (key != 0) {
GP_EventQueuePushKey(event_queue, key, press, NULL);
return;
diff --git a/libs/input/GP_InputDriverLinux.c b/libs/input/GP_InputDriverLinux.c
index 09415c5..93bbdef 100644
--- a/libs/input/GP_InputDriverLinux.c
+++ b/libs/input/GP_InputDriverLinux.c
@@ -38,7 +38,7 @@ static int get_version(int fd)
if (ioctl(fd, EVIOCGVERSION, &ver))
return -1;
-
+
GP_DEBUG(2, "Input version %u.%u.%u",
ver>>16, (ver>>8)&0xff, ver&0xff);
@@ -57,7 +57,7 @@ static int get_name(int fd, char *buf, size_t buf_len)
return ret;
}
-
+
static void print_name(int fd)
{
char name[64];
@@ -86,13 +86,13 @@ static void try_load_callibration(struct GP_InputDriverLinux *self)
abs[1], abs[2], abs[3], abs[4]);
self->abs_x_max = abs[2];
}
-
+
if (!ioctl(self->fd, EVIOCGABS(ABS_Y), abs)) {
GP_DEBUG(3, "ABS Y = <%i,%i> Fuzz %i Flat %i",
abs[1], abs[2], abs[3], abs[4]);
self->abs_y_max = abs[2];
}
-
+
if (!ioctl(self->fd, EVIOCGABS(ABS_PRESSURE), abs)) {
GP_DEBUG(3, "ABS P = <%i,%i> Fuzz %i Flat %i",
abs[1], abs[2], abs[3], abs[4]);
@@ -130,7 +130,7 @@ struct GP_InputDriverLinux *GP_InputDriverLinuxOpen(const char *path)
}
ret->fd = fd;
-
+
ret->rel_x = 0;
ret->rel_y = 0;
ret->rel_flag = 0;
@@ -177,7 +177,7 @@ static void input_rel(struct GP_InputDriverLinux *self, struct input_event *ev)
static void input_abs(struct GP_InputDriverLinux *self, struct input_event *ev)
{
GP_DEBUG(4, "Absolute event");
-
+
switch (ev->code) {
case ABS_X:
self->abs_x = ev->value;
@@ -235,12 +235,12 @@ static void do_sync(struct GP_InputDriverLinux *self,
/* clipping */
if (self->abs_x > self->abs_x_max)
self->abs_x = self->abs_x_max;
-
+
if (self->abs_x < 0)
self->abs_x = 0;
-
+
x = self->abs_x;
- x_max = self->abs_x_max;
+ x_max = self->abs_x_max;
self->abs_flag_x = 0;
}
@@ -249,19 +249,19 @@ static void do_sync(struct GP_InputDriverLinux *self,
/* clipping */
if (self->abs_y > self->abs_y_max)
self->abs_y = self->abs_y_max;
-
+
if (self->abs_y < 0)
self->abs_y = 0;
-
+
y = self->abs_y;
- y_max = self->abs_y_max;
+ y_max = self->abs_y_max;
self->abs_flag_y = 0;
}
GP_EventQueuePushAbs(event_queue, x, y, self->abs_press,
x_max, y_max, self->abs_press_max, NULL);
-
+
self->abs_press = 0;
if (self->abs_pen_flag) {
@@ -276,7 +276,7 @@ static void input_syn(struct GP_InputDriverLinux *self,
struct input_event *ev)
{
GP_DEBUG(4, "Sync event");
-
+
switch (ev->code) {
case 0:
do_sync(self, event_queue);
diff --git a/libs/input/GP_TimeStamp.c b/libs/input/GP_TimeStamp.c
index 4185ee6..c22b478 100644
--- a/libs/input/GP_TimeStamp.c
+++ b/libs/input/GP_TimeStamp.c
@@ -40,7 +40,7 @@ static int choose_clock(clockid_t *clock)
#ifdef CLOCK_MONOTONIC_COARSE
GP_DEBUG(1, "Trying CLOCK_MONOTONIC_COARSE");
-
+
if (clock_getres(CLOCK_MONOTONIC_COARSE, &ts)) {
GP_DEBUG(1, "CLOCK_MONOTONIC_COARSE: %s", strerror(errno));
} else {
diff --git a/libs/input/GP_Timer.c b/libs/input/GP_Timer.c
index 39f63f5..519bfe6 100644
--- a/libs/input/GP_Timer.c
+++ b/libs/input/GP_Timer.c
@@ -101,7 +101,7 @@ static GP_Timer *swap_left(GP_Timer *heap)
static GP_Timer *swap_right(GP_Timer *heap)
{
- GP_Timer *right = heap->right;
+ GP_Timer *right = heap->right;
heap->right = right->right;
right->right = heap;
@@ -127,13 +127,13 @@ static GP_Timer *insert(GP_Timer *heap, GP_Timer *timer)
if (!heap->left || !well_balanced(heap->left->sons) ||
(heap->right && heap->left->sons == heap->right->sons)) {
-
+
heap->left = insert(heap->left, timer);
-
+
if (timer_cmp(heap, heap->left))
return swap_left(heap);
} else {
-
+
heap->right = insert(heap->right, timer);
if (timer_cmp(heap, heap->right))
@@ -239,7 +239,7 @@ static GP_Timer *process_top(GP_Timer *heap, uint64_t now)
PRIu32" expires at %"PRIu64,
period ? "periodic " : "",
timer->id, now, ret, timer->expires);
- heap = insert(heap, timer);
+ heap = insert(heap, timer);
}
return heap;
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c
index 44fb147..effb301 100644
--- a/libs/loaders/GP_BMP.c
+++ b/libs/loaders/GP_BMP.c
@@ -50,7 +50,7 @@
#define BUF_TO_2(buf, off) (buf[off] + (buf[off+1]<<8))
-
+
struct bitmap_info_header {
/*
@@ -63,19 +63,19 @@ struct bitmap_info_header {
*/
uint32_t header_size;
- /*
+ /*
* Image size in pixels.
* If h is negative image is top-down (bottom-up is default)
*/
int32_t w;
- int32_t h;
-
+ int32_t h;
+
uint16_t bpp;
uint32_t compress_type;
- /*
+ /*
* if 0 image uses whole range (2^bpp colors)
*/
- uint32_t palette_colors;
+ uint32_t palette_colors;
/*
* RGBA masks for bitfields compression
*/
@@ -158,7 +158,7 @@ static uint32_t get_palette_size(struct bitmap_info_header *header)
static int read_bitfields(FILE *f, struct bitmap_info_header *header)
{
int ret;
-
+
ret = GP_FRead(f, "L4 L4 L4",
&header->R_mask,
&header->G_mask,
@@ -206,7 +206,7 @@ static int read_bitmap_info_header(FILE *f, struct bitmap_info_header *header)
if (GP_FRead(f, "L4 L4 L2 L2 L4 I12 L4 I4",
&header->w, &header->h, &nr_planes, &header->bpp,
&header->compress_type, &header->palette_colors) != 8) {
-
+
GP_DEBUG(1, "Failed to read bitmap info header");
return EIO;
}
@@ -251,7 +251,7 @@ static int read_bitmap_core_header(FILE *f, struct bitmap_info_header *header)
GP_DEBUG(1, "Failed to read bitmap core header");
return EIO;
}
-
+
header->w = BUF_TO_2(buf, 0);
header->h = BUF_TO_2(buf, 2);
header->bpp = BUF_TO_2(buf, 6);
@@ -356,13 +356,13 @@ static int read_bitmap_palette(FILE *f, struct bitmap_info_header *header,
GP_DEBUG(1, "Failed to read palette %"PRIu32, i);
return EIO;
}
-
+
palette[i] = GP_Pixel_CREATE_RGB888(buf[2], buf[1], buf[0]);
-
+
GP_DEBUG(3, "Palette[%"PRIu32"] = [0x%02x, 0x%02x, 0x%02x]", i,
- GP_Pixel_GET_R_RGB888(palette[i]),
- GP_Pixel_GET_G_RGB888(palette[i]),
- GP_Pixel_GET_B_RGB888(palette[i]));
+ GP_Pixel_GET_R_RGB888(palette[i]),
+ GP_Pixel_GET_G_RGB888(palette[i]),
+ GP_Pixel_GET_B_RGB888(palette[i]));
}
return 0;
@@ -427,7 +427,7 @@ static GP_PixelType match_pixel_type(struct bitmap_info_header *header)
static uint32_t bitmap_row_size(struct bitmap_info_header *header)
{
uint32_t row_size = 0;
-
+
/* align width to whole bytes */
switch (header->bpp) {
case 1:
@@ -458,7 +458,7 @@ static uint32_t bitmap_row_size(struct bitmap_info_header *header)
GP_DEBUG(2, "bpp = %"PRIu16", width = %"PRId32", row_size = %"PRIu32,
header->bpp, header->w, row_size);
-
+
return row_size;
}
@@ -491,10 +491,10 @@ static int read_palette(FILE *f, struct bitmap_info_header *header,
if ((err = read_bitmap_palette(f, header, palette)))
return err;
-
+
if ((err = seek_pixels_offset(header, f)))
return err;
-
+
uint32_t row_size = bitmap_row_size(header);
int32_t y;
@@ -517,7 +517,7 @@ static int read_palette(FILE *f, struct bitmap_info_header *header,
} else {
p = palette[idx];
}
-
+
int32_t ry;
if (header->h < 0)
@@ -527,14 +527,14 @@ static int read_palette(FILE *f, struct bitmap_info_header *header,
GP_PutPixel_Raw_24BPP(context, x, ry, p);
}
-
+
if (GP_ProgressCallbackReport(callback, y,
context->h, context->w)) {
GP_DEBUG(1, "Operation aborted");
return ECANCELED;
}
}
-
+
GP_ProgressCallbackDone(callback);
return 0;
}
@@ -557,7 +557,7 @@ static int read_bitfields_or_rgb(FILE *f, struct bitmap_info_header *header,
ry = y;
else
ry = GP_ABS(header->h) - 1 - y;
-
+
uint8_t *row = GP_PIXEL_ADDR(context, 0, ry);
if (fread(row, 1, row_size, f) != row_size) {
@@ -639,19 +639,19 @@ int GP_OpenBMP(const char *src_path, FILE **f,
err = EIO;
goto err1;
}
-
+
if (w != NULL || h != NULL || pixel_type != NULL) {
struct bitmap_info_header header;
-
+
if ((err = read_bitmap_header(*f, &header)))
goto err1;
if (w != NULL)
*w = header.w;
-
+
if (h != NULL)
*h = header.h;
-
+
if (pixel_type != NULL)
*pixel_type = match_pixel_type(&header);
}
@@ -679,7 +679,7 @@ GP_Context *GP_ReadBMP(FILE *f, GP_ProgressCallback *callback)
err = EIO;
goto err1;
}
-
+
switch (header.compress_type) {
case COMPRESS_RGB:
case COMPRESS_BITFIELDS:
@@ -760,7 +760,7 @@ static int bmp_write_header(struct bitmap_info_header *header, FILE *f)
if (GP_FWrite(f, "A2 L4 0x00 0x00 0x00 0x00 L4", "BM",
file_size, header->pixel_offset) != 7)
return EIO;
-
+
/* Bitmap Info Header */
if (GP_FWrite(f, "L4 L4 L4 L2 L2 L4 L4 L4 L4 L4 L4",
header->header_size, header->w, header->h, 1,
diff --git a/libs/loaders/GP_ByteUtils.c b/libs/loaders/GP_ByteUtils.c
index 32abdd1..134c74e 100644
--- a/libs/loaders/GP_ByteUtils.c
+++ b/libs/loaders/GP_ByteUtils.c
@@ -112,8 +112,8 @@ static const char *get_int(const char *fmt, int *val)
*val *= 10;
*val += add;
i++;
- }
-
+ }
+
return fmt + i;
}
@@ -240,7 +240,7 @@ int GP_FRead(FILE *f, const char *fmt, ...)
if (fread(ptr, val, 1, f) != 1)
goto end;
-
+
swap_bytes(ptr, val, type);
break;
case IGNORE:
@@ -251,7 +251,7 @@ int GP_FRead(FILE *f, const char *fmt, ...)
GP_BUG("Wrong format type for reading (%i)", type);
goto end;
}
-
+
ret++;
}
@@ -296,17 +296,17 @@ int GP_FWrite(FILE *f, const char *fmt, ...)
break;
case 2:
u16 = va_arg(va, int);
-
+
swap_bytes(&u16, 2, type);
-
+
if (fwrite(&u16, 2, 1, f) != 1)
goto end;
break;
case 4:
u32 = va_arg(va, int);
-
+
swap_bytes(&u32, 4, type);
-
+
if (fwrite(&u32, 4, 1, f) != 1)
goto end;
break;
diff --git a/libs/loaders/GP_GIF.c b/libs/loaders/GP_GIF.c
index b8554e8..59df688 100644
--- a/libs/loaders/GP_GIF.c
+++ b/libs/loaders/GP_GIF.c
@@ -23,7 +23,7 @@
/*
GIF image support using giflib.
-
+
*/
#include <stdint.h>
@@ -54,7 +54,7 @@ int GP_MatchGIF(const void *buf)
{
if (!memcmp(buf, GIF_SIGNATURE1, GIF_SIGNATURE1_LEN))
return 1;
-
+
if (!memcmp(buf, GIF_SIGNATURE2, GIF_SIGNATURE2_LEN))
return 1;
@@ -83,7 +83,7 @@ int GP_OpenGIF(const char *src_path, void **f)
*/
if (errno == 0)
errno = EIO;
-
+
return 1;
}
@@ -206,14 +206,14 @@ static inline GP_Pixel get_color(GifFileType *gf, uint32_t idx)
static int get_bg_color(GifFileType *gf, GP_Pixel *pixel)
{
GifColorType *color;
-
+
if (gf->SColorMap == NULL)
return 0;
color = get_color_from_map(gf->SColorMap, gf->SBackGroundColor);
*pixel = GP_Pixel_CREATE_RGB888(color->Red, color->Green, color->Blue);
-
+
return 1;
}
@@ -228,7 +228,7 @@ static inline unsigned int interlace_real_y(GifFileType *gf, unsigned int y)
/* Pass 1: Line 0 for each strip */
real_y = 8 * y;
-
+
if (real_y < h)
return real_y;
@@ -240,16 +240,16 @@ static inline unsigned int interlace_real_y(GifFileType *gf, unsigned int y)
/* Pass 3: Lines 2 and 6 */
real_y = 4 * (y - (h - 1)/4 - 1) + 2;
-
+
if (real_y < h)
return real_y;
-
+
/* Pass 4: Lines 1, 3, 5, and 7 */
real_y = 2 * (y - h/2 - h%2) + 1;
-
+
if (real_y < h)
return real_y;
-
+
GP_BUG("real_y > h");
return 0;
@@ -272,7 +272,7 @@ GP_Context *GP_ReadGIF(void *f, GP_ProgressCallback *callback)
err = EIO;
goto err1;
}
-
+
GP_DEBUG(2, "Have GIF record type %s",
rec_type_name(rec_type));
@@ -301,15 +301,15 @@ GP_Context *GP_ReadGIF(void *f, GP_ProgressCallback *callback)
gf->Image.ColorMap ? gf->Image.ColorMap->BitsPerPixel : -1);
res = GP_ContextAlloc(gf->SWidth, gf->SHeight, GP_PIXEL_RGB888);
-
+
if (res == NULL) {
err = ENOMEM;
goto err1;
}
-
+
/* If background color is defined, use it */
if (get_bg_color(gf, &bg)) {
- GP_DEBUG(1, "Filling bg color %x", bg);
+ GP_DEBUG(1, "Filling bg color %x", bg);
GP_Fill(res, bg);
}
@@ -318,18 +318,18 @@ GP_Context *GP_ReadGIF(void *f, GP_ProgressCallback *callback)
uint8_t line[gf->Image.Width];
DGifGetLine(gf, line, gf->Image.Width);
-
+
unsigned int real_y = y;
if (gf->Image.Interlace == 64) {
real_y = interlace_real_y(gf, y);
GP_DEBUG(3, "Interlace y -> real_y %u %u", y, real_y);
}
-
+
//TODO: just now we have only 8BPP
for (x = 0; x < gf->Image.Width; x++)
GP_PutPixel_Raw_24BPP(res, x + gf->Image.Left, real_y, get_color(gf, line[x]));
-
+
if (GP_ProgressCallbackReport(callback, y - gf->Image.Top,
gf->Image.Height,
gf->Image.Width)) {
@@ -343,7 +343,6 @@ GP_Context *GP_ReadGIF(void *f, GP_ProgressCallback *callback)
break;
} while (rec_type != TERMINATE_RECORD_TYPE);
-
DGifCloseFile(gf);
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index 11c34d1..0cf10f7 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -23,7 +23,7 @@
/*
JPG image support using jpeg library.
-
+
*/
#include <stdint.h>
@@ -58,7 +58,7 @@ int GP_MatchJPG(const void *buf)
int GP_OpenJPG(const char *src_path, FILE **f)
{
int err;
-
+
*f = fopen(src_path, "rb");
if (*f == NULL) {
@@ -70,7 +70,7 @@ int GP_OpenJPG(const char *src_path, FILE **f)
}
//TODO: check signature and rewind the stream
-
+
return 0;
}
@@ -175,12 +175,12 @@ GP_Context *GP_ReadJPG(FILE *f, GP_ProgressCallback *callback)
//TODO: fixme bigendian?
/* fix the pixel, as we want in fact BGR */
unsigned int i;
-
+
for (i = 0; i < ret->w; i++) {
uint8_t *pix = GP_PIXEL_ADDR(ret, i, y);
GP_SWAP(pix[0], pix[2]);
}
-
+
if (GP_ProgressCallbackReport(callback, y, ret->h, ret->w)) {
GP_DEBUG(1, "Operation aborted");
err = ECANCELED;
@@ -207,7 +207,7 @@ GP_Context *GP_ReadJPG(FILE *f, GP_ProgressCallback *callback)
jpeg_destroy_decompress(&cinfo);
GP_ProgressCallbackDone(callback);
-
+
return ret;
err2:
GP_ContextFree(ret);
@@ -226,7 +226,7 @@ GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback)
return NULL;
res = GP_ReadJPG(f, callback);
-
+
fclose(f);
return res;
@@ -259,10 +259,10 @@ static void save_jpg_markers(struct jpeg_decompress_struct *cinfo)
{
/* Comment marker */
jpeg_save_markers(cinfo, JPEG_COM, JPEG_COM_MAX);
-
+
/* APP0 marker = JFIF data */
jpeg_save_markers(cinfo, JPEG_APP0 + 1, 0xffff);
-
+
/* APP1 marker = Exif data */
jpeg_save_markers(cinfo, JPEG_APP0 + 1, 0xffff);
}
@@ -292,9 +292,9 @@ int GP_ReadJPGMetaData(FILE *f, GP_MetaData *data)
get_colorspace(cinfo.jpeg_color_space),
cinfo.image_width, cinfo.image_height,
cinfo.num_components);
-
+
read_jpg_metadata(&cinfo, data);
-
+
// jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
@@ -346,7 +346,7 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
dst_path, strerror(errno));
goto err0;
}
-
+
if (setjmp(my_err.setjmp_buf)) {
err = EIO;
//TODO: is cinfo allocated?
@@ -355,7 +355,7 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
cinfo.err = jpeg_std_error(&my_err.error_mgr);
my_err.error_mgr.error_exit = my_error_exit;
-
+
jpeg_create_compress(&cinfo);
jpeg_stdio_dest(&cinfo, f);
@@ -390,7 +390,7 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
JSAMPROW row = (void*)GP_PIXEL_ADDR(src, 0, y);
jpeg_write_scanlines(&cinfo, &row, 1);
}
-
+
if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) {
GP_DEBUG(1, "Operation aborted");
err = ECANCELED;
@@ -407,7 +407,7 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
dst_path, strerror(errno));
goto err1;
}
-
+
GP_ProgressCallbackDone(callback);
return 0;
err3:
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c
index e86c39a..cfb1d6d 100644
--- a/libs/loaders/GP_Loader.c
+++ b/libs/loaders/GP_Loader.c
@@ -23,7 +23,7 @@
/*
General functions for loading and saving bitmaps.
-
+
*/
#include <string.h>
@@ -78,7 +78,7 @@ static GP_Loader ppm_loader = {
static GP_Loader pnm_loader = {
.Load = GP_LoadPNM,
.Save = NULL,
- /*
+ /*
* Avoid double Match
* This format is covered by PBM, PGM and PPM
*/
@@ -181,7 +181,7 @@ void GP_ListLoaders(void)
for (j = 0; i->extensions[j] != NULL; j++)
printf("%s ", i->extensions[j]);
printf("n");
-
+
if (i->next != NULL)
printf("n");
}
@@ -274,12 +274,11 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
{
int err;
struct stat st;
-
+
if (access(src_path, R_OK)) {
err = errno;
GP_DEBUG(1, "Failed to access file '%s' : %s",
src_path, strerror(errno));
-
errno = err;
return NULL;
}
@@ -300,14 +299,14 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
if (ext_load != NULL && ext_load->Load != NULL) {
img = ext_load->Load(src_path, callback);
-
+
if (img)
return img;
}
sig_load = loader_by_signature(src_path);
- /*
+ /*
* Avoid further work if extension matches the signature but image
* couldn't be loaded. Probably unimplemented format or damaged file.
*/
@@ -346,7 +345,7 @@ int GP_LoadMetaData(const char *src_path, GP_MetaData *data)
if (!strcasecmp(ext, "jpg") || !strcasecmp(ext, "jpeg"))
return GP_LoadJPGMetaData(src_path, data);
-
+
if (!strcasecmp(ext, "png"))
return GP_LoadPNGMetaData(src_path, data);
@@ -364,7 +363,7 @@ int GP_SaveImage(const GP_Context *src, const char *dst_path,
errno = EINVAL;
return 1;
}
-
+
if (l->Save)
return l->Save(src, dst_path, callback);
@@ -375,7 +374,7 @@ int GP_SaveImage(const GP_Context *src, const char *dst_path,
const GP_Loader *GP_MatchSignature(const void *buf)
{
struct GP_Loader *i;
-
+
for (i = loaders; i != NULL; i = i->next) {
if (i->Match && i->Match(buf) == 1) {
GP_DEBUG(1, "Found loader '%s'", i->fmt_name);
diff --git a/libs/loaders/GP_MetaData.c b/libs/loaders/GP_MetaData.c
index a81480f..e695953 100644
--- a/libs/loaders/GP_MetaData.c
+++ b/libs/loaders/GP_MetaData.c
@@ -76,7 +76,7 @@ void GP_MetaDataClear(GP_MetaData *self)
{
GP_DEBUG(1, "Clearing MetaData %p with %u records",
self, self->rec_count);
-
+
self->root = NULL;
self->last = NULL;
self->rec_count = 0;
@@ -124,7 +124,7 @@ static GP_MetaRecord *record_lookup(GP_MetaData *self, const char *id,
for (rec = self->root; rec != NULL; rec = rec->next)
if (rec->hash == hash && !strcmp(rec->id, id))
return rec;
-
+
return NULL;
}
@@ -138,7 +138,7 @@ static void *do_alloc(struct GP_MetaData *self, size_t size)
void *ret = ((char*)self) + sizeof(struct GP_MetaData) + (self->size - self->free);
self->free -= size;
-
+
return ret;
}
@@ -146,7 +146,7 @@ static GP_MetaRecord *record_create(GP_MetaData *self, const char *id,
unsigned int hash)
{
GP_MetaRecord *rec;
-
+
if (strlen(id) + 1 > GP_META_RECORD_ID_MAX) {
GP_DEBUG(0, "Can't create id '%s' longer than %i chars",
id, GP_META_RECORD_ID_MAX - 1);
@@ -154,14 +154,14 @@ static GP_MetaRecord *record_create(GP_MetaData *self, const char *id,
}
rec = do_alloc(self, sizeof(struct GP_MetaRecord));
-
+
if (rec == NULL)
return NULL;
strcpy(rec->id, id);
rec->hash = hash;
rec->next = NULL;
-
+
if (self->root == NULL) {
self->root = rec;
self->last = rec;
@@ -169,7 +169,7 @@ static GP_MetaRecord *record_create(GP_MetaData *self, const char *id,
self->last->next = rec;
self->last = rec;
}
-
+
self->rec_count++;
return rec;
@@ -184,15 +184,15 @@ GP_MetaRecord *GP_MetaDataCreateRecord(GP_MetaData *self, const char *id)
return NULL;
}
- return record_create(self, id, hash);
+ return record_create(self, id, hash);
}
int GP_MetaDataGetInt(GP_MetaData *self, const char *id, int *res)
{
GP_MetaRecord *rec;
-
+
GP_DEBUG(2, "Looking for GP_META_INT id '%s'", id);
-
+
rec = record_lookup(self, id, do_hash(id));
if (rec == NULL) {
@@ -215,9 +215,9 @@ int GP_MetaDataGetInt(GP_MetaData *self, const char *id, int *res)
int GP_MetaDataGetDouble(GP_MetaData *self, const char *id, double *res)
{
GP_MetaRecord *rec;
-
+
GP_DEBUG(2, "Looking for GP_META_DOUBLE id '%s'", id);
-
+
rec = record_lookup(self, id, do_hash(id));
if (rec == NULL) {
@@ -240,9 +240,9 @@ int GP_MetaDataGetDouble(GP_MetaData *self, const char *id, double *res)
const char *GP_MetaDataGetString(GP_MetaData *self, const char *id)
{
GP_MetaRecord *rec;
-
+
GP_DEBUG(2, "Looking for GP_META_STRING id '%s'", id);
-
+
rec = record_lookup(self, id, do_hash(id));
if (rec == NULL) {
@@ -265,12 +265,12 @@ GP_MetaRecord *GP_MetaDataCreateInt(GP_MetaData *self, const char *id, int val)
GP_MetaRecord *rec;
GP_DEBUG(2, "Creating GP_META_INT id '%s' = %i", id, val);
-
+
rec = GP_MetaDataCreateRecord(self, id);
if (rec == NULL)
return NULL;
-
+
rec->type = GP_META_INT;
rec->val.i = val;
@@ -283,7 +283,7 @@ GP_MetaRecord *GP_MetaDataCreateRat(GP_MetaData *self, const char *id,
GP_MetaRecord *rec;
GP_DEBUG(2, "Creating GP_META_RATIONAL id '%s' = %i/%i", id, num, den);
-
+
if (den == 0) {
GP_DEBUG(1, "Would not create '%s' with denominator == 0", id);
return NULL;
@@ -293,7 +293,7 @@ GP_MetaRecord *GP_MetaDataCreateRat(GP_MetaData *self, const char *id,
if (rec == NULL)
return NULL;
-
+
rec->type = GP_META_RATIONAL;
rec->val.r.num = num;
rec->val.r.den = den;
@@ -307,12 +307,12 @@ GP_MetaRecord *GP_MetaDataCreateDouble(GP_MetaData *self, const char *id,
GP_MetaRecord *rec;
GP_DEBUG(2, "Creating GP_META_DOUBLE id '%s' = %lf", id, val);
-
+
rec = GP_MetaDataCreateRecord(self, id);
if (rec == NULL)
return NULL;
-
+
rec->type = GP_META_DOUBLE;
rec->val.d = val;
@@ -334,10 +334,10 @@ GP_MetaRecord *GP_MetaDataCreateString(GP_MetaData *self, const char *id,
if (dup) {
size_t size;
char *s;
-
+
if (len == 0)
len = strlen(str);
-
+
size = len + 1;
/* Play safe with aligment */
diff --git a/libs/loaders/GP_MetaExif.c b/libs/loaders/GP_MetaExif.c
index f188e00..0bd1c84 100644
--- a/libs/loaders/GP_MetaExif.c
+++ b/libs/loaders/GP_MetaExif.c
@@ -89,7 +89,7 @@ enum IFD_tags {
IFD_RESOLUTION_UNIT = 0x0128,
/* Software string. */
IFD_SOFTWARE = 0x0131,
- /* YYYY:MM:DD HH:MM:SS in 24 hours format */
+ /* YYYY:MM:DD HH:MM:SS in 24 hours format */
IFD_DATE_TIME = 0x0132,
/* White Point */
IFD_WHITE_POINT = 0x013e,
@@ -195,7 +195,7 @@ static const struct IFD_tag IFD_tags[] = {
/* TAGs from Exif SubIFD */
{IFD_EXPOSURE_TIME, "Exposure Time", IFD_UNSIGNED_RATIONAL, 1},
{IFD_F_NUMBER, "F-Number", IFD_UNSIGNED_RATIONAL, 1},
-
+
/* TAG from IFD0 */
{IFD_EXIF_OFFSET, "Exif Offset", IFD_UNSIGNED_LONG, 1},
@@ -222,8 +222,8 @@ static const struct IFD_tag IFD_tags[] = {
{IFD_FLASH_PIX_VERSION, "Flash Pix Version", IFD_UNDEFINED, 4},
{IFD_COLOR_SPACE, "Color Space", IFD_UNSIGNED_SHORT, 1},
/* these two may be short in some cases */
- {IFD_EXIF_IMAGE_WIDTH, "Exif Image Width", IFD_UNSIGNED_LONG, 1},
- {IFD_EXIF_IMAGE_HEIGHT, "Exif Image Height", IFD_UNSIGNED_LONG, 1},
+ {IFD_EXIF_IMAGE_WIDTH, "Exif Image Width", IFD_UNSIGNED_LONG, 1},
+ {IFD_EXIF_IMAGE_HEIGHT, "Exif Image Height", IFD_UNSIGNED_LONG, 1},
{IFD_RELATED_SOUND_FILE, "Related Soundfile", IFD_ASCII_STRING, 0},
};
@@ -258,7 +258,7 @@ static const struct IFD_tag *IFD_tag_get(uint16_t tag)
if (IFD_tags[right].tag == tag)
return &IFD_tags[right];
-
+
return NULL;
}
@@ -325,13 +325,13 @@ static const char *get_string(void *buf, size_t buf_len,
{
if (num_comp <= 4)
return (const char*)val;
-
+
if (*val + num_comp >= buf_len) {
GP_DEBUG(1, "String out of buffer offset 0x%08x length %u",
*val, num_comp);
return NULL;
}
-
+
return ((const char*)buf) + *val;
}
@@ -340,14 +340,14 @@ static int rat_num(void *buf, uint32_t offset, size_t buf_len, int swap)
int ret;
GET_32(ret, buf, offset, buf_len, swap);
-
+
return ret;
}
static int rat_den(void *buf, uint32_t offset, size_t buf_len, int swap)
{
int ret;
-
+
GET_32(ret, buf, offset + 4, buf_len, swap);
return ret;
@@ -376,7 +376,7 @@ static void load_tag(GP_MetaData *self, void *buf, size_t buf_len, int swap,
GP_WARN("Unexpected tag '%s' num_components %u expected %u",
res->name, num_comp, res->num_components);
}
-
+
const char *addr;
switch (format) {
@@ -408,7 +408,7 @@ static void load_tag(GP_MetaData *self, void *buf, size_t buf_len, int swap,
case IFD_EXIF_VERSION:
case IFD_FLASH_PIX_VERSION:
addr = get_string(buf, buf_len, num_comp, &val);
-
+
if (addr == NULL)
return;
@@ -437,7 +437,7 @@ static int load_IFD(GP_MetaData *self, void *buf, size_t buf_len,
GP_DEBUG(2, "-- IFD Offset 0x%08x Entries 0x%04x --",
IFD_offset, IFD_entries_count);
-
+
int i;
for (i = 0; i < IFD_entries_count; i++) {
@@ -448,19 +448,19 @@ static int load_IFD(GP_MetaData *self, void *buf, size_t buf_len,
GET_16_INC(format, buf, IFD_offset, buf_len, swap);
GET_32_INC(num_components, buf, IFD_offset, buf_len, swap);
GET_32_INC(val, buf, IFD_offset, buf_len, swap);
-
+
GP_DEBUG(3, "IFD Entry tag 0x%04x format (0x%04x) components 0x%08x val 0x%08x",
tag, format, num_components, val);
-
+
GP_DEBUG(3, "IFD Entry tag '%s' format '%s'",
IFD_tag_name(tag), IFD_format_name(format));
-
+
if (tag == IFD_EXIF_OFFSET)
load_IFD(self, buf, buf_len, val, swap);
else
load_tag(self, buf, buf_len, swap, tag, format, num_components, val);
}
-/*
+/*
GET_32(IFD_offset, buf, IFD_offset, buf_len, swap);
if (IFD_offset != 0x00000000)
@@ -478,10 +478,10 @@ int GP_MetaDataFromExif(GP_MetaData *self, void *buf, size_t buf_len)
int c1, c2;
if (buf_char(buf, 0, buf_len) != 'E' ||
- buf_char(buf, 1, buf_len) != 'x' ||
- buf_char(buf, 2, buf_len) != 'i' ||
- buf_char(buf, 3, buf_len) != 'f' ||
- buf_char(buf, 4, buf_len) != 0 ||
+ buf_char(buf, 1, buf_len) != 'x' ||
+ buf_char(buf, 2, buf_len) != 'i' ||
+ buf_char(buf, 3, buf_len) != 'f' ||
+ buf_char(buf, 4, buf_len) != 0 ||
buf_char(buf, 5, buf_len) != 0) {
GP_WARN("Missing ASCII 'Exif
"the start of the buffer");
@@ -496,7 +496,7 @@ int GP_MetaDataFromExif(GP_MetaData *self, void *buf, size_t buf_len)
}
swap = (c1 == 'M');
-
+
GP_DEBUG(2, "TIFF aligment is '%c%c' swap = %i", c1, c1, swap);
uint16_t tag;
@@ -517,6 +517,5 @@ int GP_MetaDataFromExif(GP_MetaData *self, void *buf, size_t buf_len)
/* The offset starts from the II or MM */
load_IFD(self, (char*)buf + TIFF_OFFSET, buf_len - TIFF_OFFSET, IFD_offset, swap);
-
return 0;
}
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index ce03c85..47a4d6a 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -23,7 +23,7 @@
/*
PNG image support using libpng.
-
+
*/
#include <stdint.h>
@@ -73,7 +73,7 @@ int GP_OpenPNG(const char *src_path, FILE **f)
GP_DEBUG(1, "Invalid file header, '%s' not a PNG image?",
src_path);
err = EINVAL;
- goto err2;
+ goto err2;
}
GP_DEBUG(1, "Found PNG signature in '%s'", src_path);
@@ -199,7 +199,7 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback)
break;
}
}
-
+
/* Convert everything else to RGB888 */
//TODO: add palette matching to G2 G4 and G8
png_set_palette_to_rgb(png);
@@ -208,7 +208,7 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback)
png_read_update_info(png, png_info);
png_get_IHDR(png, png_info, &w, &h, &depth,
- &color_type, NULL, NULL, NULL);
+ &color_type, NULL, NULL, NULL);
if (color_type & PNG_COLOR_MASK_ALPHA) {
pixel_type = GP_PIXEL_RGBA8888;
@@ -238,7 +238,7 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback)
uint32_t y;
int p;
- /*
+ /*
* Do the actuall reading.
*
* The passes are needed for adam7 interlacing.
@@ -259,7 +259,7 @@ GP_Context *GP_ReadPNG(FILE *f, GP_ProgressCallback *callback)
png_destroy_read_struct(&png, &png_info, NULL);
GP_ProgressCallbackDone(callback);
-
+
return res;
err3:
GP_ContextFree(res);
@@ -279,7 +279,7 @@ GP_Context *GP_LoadPNG(const char *src_path, GP_ProgressCallback *callback)
return NULL;
res = GP_ReadPNG(f, callback);
-
+
fclose(f);
return res;
@@ -289,7 +289,7 @@ static void load_meta_data(png_structp png, png_infop png_info, GP_MetaData *dat
{
double gamma;
- if (png_get_gAMA(png, png_info, &gamma))
+ if (png_get_gAMA(png, png_info, &gamma))
GP_MetaDataCreateInt(data, "gamma", gamma * 100000);
png_uint_32 res_x, res_y;
@@ -298,14 +298,14 @@ static void load_meta_data(png_structp png, png_infop png_info, GP_MetaData *dat
if (png_get_pHYs(png, png_info, &res_x, &res_y, &unit)) {
GP_MetaDataCreateInt(data, "res_x", res_x);
GP_MetaDataCreateInt(data, "res_y", res_y);
-
+
const char *unit_name;
-
+
if (unit == PNG_RESOLUTION_METER)
unit_name = "meter";
else
unit_name = "unknown";
-
+
GP_MetaDataCreateString(data, "res_unit", unit_name, 0, 0);
}
@@ -333,12 +333,12 @@ static void load_meta_data(png_structp png, png_infop png_info, GP_MetaData *dat
if (png_get_text(png, png_info, &text_ptr, &text_cnt)) {
int i;
-
+
for (i = 0; i < text_cnt; i++) {
if (text_ptr[i].compression != PNG_TEXT_COMPRESSION_NONE)
continue;
-
+
char buf[GP_META_RECORD_ID_MAX];
snprintf(buf, GP_META_RECORD_ID_MAX, "text:%s", text_ptr[i].key);
GP_MetaDataCreateString(data, buf, text_ptr[i].text, 0, 1);
@@ -359,7 +359,7 @@ int GP_ReadPNGMetaData(FILE *f, GP_MetaData *data)
err = ENOMEM;
goto err1;
}
-
+
png_info = png_create_info_struct(png);
if (png_info == NULL) {
@@ -446,10 +446,10 @@ static int prepare_png_header(const GP_Context *src, png_structp png,
png_set_IHDR(png, png_info, src->w, src->h, bit_depth, color_type,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
-
+
/* start the actuall writing */
png_write_info(png, png_info);
-
+
//png_set_packing(png);
/* prepare for format conversion */
@@ -551,7 +551,7 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path,
}
png_init_io(png, f);
-
+
int bit_endian_flag = 0;
/* Fill png header and prepare for data */
prepare_png_header(src, png, png_info, &bit_endian_flag);
@@ -571,7 +571,7 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path,
}
GP_ProgressCallbackDone(callback);
-
+
return 0;
err3:
png_destroy_write_struct(&png, png_info == NULL ? NULL : &png_info);
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c
index 374bad0..a0b5fab 100644
--- a/libs/loaders/GP_PNM.c
+++ b/libs/loaders/GP_PNM.c
@@ -24,9 +24,9 @@
PNM portable bitmap header
--------------------------
-
+
Format:
-
+
a magic number value of 'P' and one of
'1' - PBM Bitmap ASCII
'2' - PGM Gray ASCII
@@ -40,10 +40,10 @@
ascii height
whitespace
maximal value (interval is 0 ... max) (not applicable for PBM)
- width * height ascii or binary values
-
+ width * height ascii or binary values
+
lines starting with '#' are comments to the end of line
-
+
*/
#include <stdio.h>
@@ -648,9 +648,9 @@ int GP_SavePBM(const GP_Context *src, const char *dst_path,
GP_DEBUG(1, "Invalid pixel type '%s'",
GP_PixelTypeName(src->pixel_type));
errno = EINVAL;
- return 1;
+ return 1;
}
-
+
f = fopen(dst_path, "w");
if (f == NULL)
@@ -695,7 +695,7 @@ static GP_Context *read_graymap(FILE *f, struct pnm_header *header, int flag,
GP_Context *ret;
GP_PixelType pixel_type;
int err;
-
+
if (!is_graymap(header->magic)) {
GP_DEBUG(1, "Invalid graymap magic P%c", header->magic);
err = EINVAL;
@@ -791,9 +791,9 @@ int GP_SavePGM(const GP_Context *src, const char *dst_path,
GP_DEBUG(1, "Invalid pixel type '%s'",
GP_PixelTypeName(src->pixel_type));
errno = EINVAL;
- return 1;
+ return 1;
}
-
+
f = fopen(dst_path, "w");
if (f == NULL) {
@@ -830,7 +830,7 @@ static GP_Context *read_pixmap(FILE *f, struct pnm_header *header, int flag,
{
GP_Context *ret;
int err;
-
+
if (!is_pixmap(header->magic)) {
GP_DEBUG(1, "Invalid Pixmap magic P%c", header->magic);
err = EINVAL;
@@ -872,7 +872,7 @@ err1:
fclose(f);
err0:
errno = err;
- return NULL;
+ return NULL;
}
GP_Context *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback)
@@ -895,8 +895,8 @@ static int write_binary_ppm(FILE *f, GP_Context *src)
for (y = 0; y < src->h; y++)
for (x = 0; x < src->w; x++) {
GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, x, y);
-
- uint8_t buf[3] = {GP_Pixel_GET_R_RGB888(pix),
+
+ uint8_t buf[3] = {GP_Pixel_GET_R_RGB888(pix),
GP_Pixel_GET_G_RGB888(pix),
GP_Pixel_GET_B_RGB888(pix)};
@@ -916,9 +916,9 @@ static int save_ascii_rgb888(FILE *f, const GP_Context *ctx,
for (y = 0; y < ctx->h; y++) {
for (x = 0; x < ctx->w; x++) {
GP_Pixel pix = GP_GetPixel_Raw_24BPP(ctx, x, y);
-
+
ret = fprintf(f, "%u %u %u ",
- GP_Pixel_GET_R_RGB888(pix),
+ GP_Pixel_GET_R_RGB888(pix),
GP_Pixel_GET_G_RGB888(pix),
GP_Pixel_GET_B_RGB888(pix));
@@ -952,9 +952,9 @@ int GP_SavePPM(const GP_Context *src, const char *dst_path,
GP_DEBUG(1, "Invalid pixel type '%s'",
GP_PixelTypeName(src->pixel_type));
errno = EINVAL;
- return 1;
+ return 1;
}
-
+
f = fopen(dst_path, "w");
if (f == NULL) {
@@ -990,7 +990,6 @@ err0:
GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback)
{
-
FILE *f;
GP_Context *ret = NULL;
struct pnm_header header;
@@ -1022,7 +1021,7 @@ err1:
fclose(f);
err0:
errno = err;
- return NULL;
+ return NULL;
}
int GP_SavePNM(const GP_Context *src, const char *dst_path,
diff --git a/libs/loaders/GP_PSP.c b/libs/loaders/GP_PSP.c
index 7585d91..f5c6c28 100644
--- a/libs/loaders/GP_PSP.c
+++ b/libs/loaders/GP_PSP.c
@@ -304,13 +304,13 @@ static int psp_read_composite_image_block(FILE *f, struct psp_img_attrs *attrs,
{
uint8_t buf[8];
uint32_t i, composite_image_count;
-
+
/* we are allready in subblock -> error */
if (attrs->subblock) {
GP_WARN("Composite Image Bank block inside of a Subblock");
return EINVAL;
}
-
+
if (fread(buf, sizeof(buf), 1, f) < 1) {
GP_DEBUG(1, "Failed to read Composite Image Bank Info Chunk");
return EIO;
@@ -398,9 +398,9 @@ static int psp_read_composite_attributes_block(FILE *f, struct psp_img_attrs *at
static int psp_read_jpeg(FILE *f, struct psp_img_attrs *attrs,
GP_ProgressCallback *callback)
{
- uint8_t buf[14];
+ uint8_t buf[14];
int err;
-
+
if (fread(buf, sizeof(buf), 1, f) < 1) {
GP_DEBUG(1, "Failed to read JPEG Information Chunk");
return EIO;
@@ -409,7 +409,7 @@ static int psp_read_jpeg(FILE *f, struct psp_img_attrs *attrs,
//TODO: utilize chunk_size
GP_DEBUG(5, "JPEG Chunk");
-
+
attrs->img = GP_ReadJPG(f, callback);
if (attrs->img == NULL) {
@@ -489,10 +489,10 @@ GP_Context *GP_ReadPSP(FILE *f, GP_ProgressCallback *callback)
while (!err) {
err = psp_next_block(f, &attrs, callback);
-
+
if (err)
goto err1;
-
+
if (attrs.img != NULL) {
fclose(f);
return attrs.img;
diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c
index f88d21e..3f4a4e9 100644
--- a/libs/loaders/GP_TIFF.c
+++ b/libs/loaders/GP_TIFF.c
@@ -23,7 +23,7 @@
/*
TIFF image support using libtiff.
-
+
*/
#include <stdint.h>
@@ -61,7 +61,7 @@ int GP_OpenTIFF(const char *src_path, void **t)
if (tiff == NULL)
return 1;
-
+
*t = tiff;
return 0;
}
@@ -115,7 +115,7 @@ GP_Context *GP_ReadTIFF(void *t, GP_ProgressCallback *callback)
GP_DEBUG(1, "TIFF image %ux%u compression: %s, bpp: %u",
w, h, compression_name(compression), bpp);
-
+
/* If set tiff is saved in tiles */
if (TIFFGetField(tiff, TIFFTAG_TILEWIDTH, &tile_w) &&
TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tile_h)) {
@@ -184,9 +184,9 @@ GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback)
return NULL;
res = GP_ReadTIFF(t, callback);
-
+
TIFFClose(t);
-
+
return res;
}
diff --git a/libs/loaders/GP_TmpFile.c b/libs/loaders/GP_TmpFile.c
index 2796652..3704946 100644
--- a/libs/loaders/GP_TmpFile.c
+++ b/libs/loaders/GP_TmpFile.c
@@ -139,13 +139,13 @@ int GP_SaveTmpFile(const GP_Context *src, const char *dst_path,
i += fwrite(&src->pixel_type, sizeof(src->pixel_type), 1, f);
uint8_t flags = 0;
-
+
if (src->axes_swap)
flags |= 0x01;
if (src->x_swap)
flags |= 0x02;
-
+
if (src->y_swap)
flags |= 0x04;
@@ -162,13 +162,13 @@ int GP_SaveTmpFile(const GP_Context *src, const char *dst_path,
err = EIO;
goto err1;
}
-
+
GP_ProgressCallbackReport(callback, y, src->h, src->w);
}
if (fclose(f))
goto err0;
-
+
GP_ProgressCallbackDone(callback);
return 0;
diff --git a/libs/text/GP_Font.c b/libs/text/GP_Font.c
index 633e45d..d723239 100644
--- a/libs/text/GP_Font.c
+++ b/libs/text/GP_Font.c
@@ -53,7 +53,7 @@ GP_GlyphBitmap *GP_GetGlyphBitmap(const GP_FontFace *font, int c)
uint32_t offset;
- if (font->glyph_offsets[0] == 0)
+ if (font->glyph_offsets[0] == 0)
offset = font->glyph_offsets[i];
else
offset = font->glyph_offsets[0] * i;
diff --git a/libs/text/GP_FontTiny.c b/libs/text/GP_FontTiny.c
index a210997..52d3c3b 100644
--- a/libs/text/GP_FontTiny.c
+++ b/libs/text/GP_FontTiny.c
@@ -97,7 +97,7 @@ static int8_t tiny_glyphs[] = {
0x70, 0x80, 0x80, 0x80, 0x70, 0x00, 0x00,
/* 'D' */ 4, 5, 0, 5, 5,
0xe0, 0x90, 0x90, 0x90, 0xe0, 0x00, 0x00,
- /* 'E' */ 4, 5, 0, 5, 5,
+ /* 'E' */ 4, 5, 0, 5, 5,
0xf0, 0x80, 0xe0, 0x80, 0xf0, 0x00, 0x00,
/* 'F' */ 4, 5, 0, 5, 5,
0xf0, 0x80, 0xe0, 0x80, 0x80, 0x00, 0x00,
diff --git a/libs/text/GP_FontTinyMono.c b/libs/text/GP_FontTinyMono.c
index 2859472..5b1b86f 100644
--- a/libs/text/GP_FontTinyMono.c
+++ b/libs/text/GP_FontTinyMono.c
@@ -97,7 +97,7 @@ static int8_t tiny_mono_glyphs[] = {
0x70, 0x80, 0x80, 0x80, 0x70, 0x00, 0x00,
/* 'D' */ 5, 5, 0, 5, 6,
0xe0, 0x90, 0x90, 0x90, 0xe0, 0x00, 0x00,
- /* 'E' */ 5, 5, 0, 5, 6,
+ /* 'E' */ 5, 5, 0, 5, 6,
0xf0, 0x80, 0xe0, 0x80, 0xf0, 0x00, 0x00,
/* 'F' */ 5, 5, 0, 5, 6,
0xf0, 0x80, 0xe0, 0x80, 0x80, 0x00, 0x00,
diff --git a/libs/text/GP_FreeType.c b/libs/text/GP_FreeType.c
index 29b3977..3b88667 100644
--- a/libs/text/GP_FreeType.c
+++ b/libs/text/GP_FreeType.c
@@ -70,14 +70,14 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height)
font_face_size = sizeof(GP_FontFace) +
sizeof(uint32_t) * GP_GetGlyphCount(GP_CHARSET_7BIT);
-
+
GP_FontFace *font = malloc(font_face_size);
-
+
if (font == NULL) {
GP_DEBUG(1, "Malloc failed :(");
goto err1;
}
-
+
/* Copy font metadata */
strncpy(font->family_name, face->family_name,
sizeof(font->family_name));
@@ -95,14 +95,14 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height)
for (i = 0x20; i < 0x7f; i++) {
FT_UInt glyph_idx = FT_Get_Char_Index(face, i);
-
+
err = FT_Load_Glyph(face, glyph_idx, FT_LOAD_DEFAULT);
if (err) {
GP_DEBUG(1, "Failed to load glyph '%c'", i);
goto err2;
}
-
+
err = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
if (err) {
@@ -132,7 +132,7 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height)
GP_DEBUG(1, "Malloc failed :(");
goto err2;
}
-
+
font->max_glyph_width = 0;
font->max_glyph_advance = 0;
font->ascend = 0;
@@ -140,16 +140,16 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height)
for (i = 0x20; i < 0x7f; i++) {
FT_UInt glyph_idx = FT_Get_Char_Index(face, i);
-
+
err = FT_Load_Glyph(face, glyph_idx, FT_LOAD_DEFAULT);
-
+
GP_DEBUG(2, "Loading and rendering glyph '%c'", i);
if (err) {
GP_DEBUG(1, "Failed to load glyph '%c'", i);
goto err3;
}
-
+
err = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
if (err) {
@@ -172,7 +172,7 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height)
if (font->ascend < ascend)
font->ascend = ascend;
-
+
if (font->descend < descend)
font->descend = descend;
@@ -183,7 +183,7 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height)
font->max_glyph_width = width;
int x, y;
-
+
for (y = 0; y < glyph_bitmap->height; y++) {
for (x = 0; x < glyph_bitmap->width; x++) {
unsigned int addr = glyph_bitmap->width * y + x;
diff --git a/libs/text/GP_Text.c b/libs/text/GP_Text.c
index 2c83a3a..8a712ec 100644
--- a/libs/text/GP_Text.c
+++ b/libs/text/GP_Text.c
@@ -36,7 +36,7 @@ static int do_align(GP_Coord *topleft_x, GP_Coord *topleft_y, int align,
GP_Size width)
{
int height = GP_TextHeight(style);
-
+
switch (align & 0x0f) {
case GP_ALIGN_LEFT:
*topleft_x = x - width + 1;
@@ -85,7 +85,7 @@ void GP_Text(GP_Context *context, const GP_TextStyle *style,
if (style == NULL)
style = &GP_DefaultStyle;
-
+
GP_Coord topleft_x, topleft_y;
GP_Size w = GP_TextWidth(style, str);
@@ -121,7 +121,7 @@ GP_Size GP_Print(GP_Context *context, const GP_TextStyle *style,
void GP_TextClear(GP_Context *context, const GP_TextStyle *style,
GP_Coord x, GP_Coord y, int align,
GP_Pixel bg_color, GP_Size size)
-{
+{
GP_Coord topleft_x, topleft_y;
GP_ASSERT(do_align(&topleft_x, &topleft_y, align, x, y, style, size) == 0,
diff --git a/libs/text/GP_TextMetric.c b/libs/text/GP_TextMetric.c
index 26b26f8..9c98ad7 100644
--- a/libs/text/GP_TextMetric.c
+++ b/libs/text/GP_TextMetric.c
@@ -34,7 +34,7 @@ static const GP_GlyphBitmap *get_glyph(const GP_TextStyle *style, int c)
if (glyph == NULL)
glyph = GP_GetGlyphBitmap(style->font, ' ');
-
+
return glyph;
}
@@ -74,9 +74,9 @@ static unsigned int max_glyph_advance_x(const GP_TextStyle *style,
static unsigned int glyph_width(const GP_TextStyle *style, int c)
{
unsigned int size, advance;
-
+
const GP_GlyphBitmap *glyph = get_glyph(style, c);
-
+
advance = multiply_width(style, glyph->advance_x - glyph->bearing_x);
size = multiply_width(style, glyph->width);
@@ -84,14 +84,14 @@ static unsigned int glyph_width(const GP_TextStyle *style, int c)
}
/*
- * Returns size occupied by the last glyph. Here we take advance_x into account.
+ * Returns size occupied by the last glyph. Here we take advance_x into account.
*/
static unsigned int last_glyph_width(const GP_TextStyle *style, int c)
{
unsigned int size, advance;
-
+
const GP_GlyphBitmap *glyph = get_glyph(style, c);
-
+
advance = multiply_width(style, glyph->advance_x);
size = multiply_width(style, glyph->width + glyph->bearing_x);
@@ -151,7 +151,7 @@ unsigned int GP_TextWidth(const GP_TextStyle *style, const char *str)
/* first letter */
len = first_glyph_width(style, str[0]) + style->char_xspace;
-
+
/* middle letters */
for (i = 1; str[i+1] != '0'; i++)
len += glyph_advance_x(style, str[i]) + style->char_xspace;
@@ -173,7 +173,7 @@ GP_Size GP_TextMaxWidth(const GP_TextStyle *style, unsigned int len)
return 0;
return multiply_width(style, len * style->font->max_glyph_advance) +
- (len - 1) * style->char_xspace;
+ (len - 1) * style->char_xspace;
}
/*
diff --git a/pylib/gfxprim/backends/_extend_backend.py b/pylib/gfxprim/backends/_extend_backend.py
index efd010f..0a03acb 100644
--- a/pylib/gfxprim/backends/_extend_backend.py
+++ b/pylib/gfxprim/backends/_extend_backend.py
@@ -43,7 +43,7 @@ def extend_backend(_backend):
def Wait(self):
"Waits for backend."
c_backends.GP_BackendWait(self)
-
+
@extend(_backend)
def WaitEvent(self):
"Waits for backend event."
@@ -92,7 +92,7 @@ def extend_backend(_backend):
def Resize(self, w, h):
"Resize backend window (if possible)"
return c_backends.GP_BackendResize(self, w, h)
-
+
@extend(_backend)
def ResizeAck(self):
"Acknowledge backend resize."
diff --git a/pylib/gfxprim/backends/backends.i b/pylib/gfxprim/backends/backends.i
index 6e5dc44..e893674 100644
--- a/pylib/gfxprim/backends/backends.i
+++ b/pylib/gfxprim/backends/backends.i
@@ -56,7 +56,7 @@ ERROR_ON_NULL(GP_BackendLinuxX11Init);
*
* This is a ugly hack because Python 3 uses its own I/O buffers for file
* objects.
- *
+ *
*/
%typemap(in) FILE* {
if ($input != Py_None) {
@@ -66,17 +66,17 @@ ERROR_ON_NULL(GP_BackendLinuxX11Init);
PyErr_SetString(PyExc_TypeError, "$1_name must be a file type.");
return NULL;
}
-
+
$1 = fdopen(dup(fd), "w");
}
}
%exception GP_BackendInit {
$action
-
+
//HACK: fclose the FILE*
fclose(arg3);
-
+
if (result == NULL)
return PyErr_SetFromErrno(PyExc_OSError);
}
diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i
index afca013..74dbb04 100644
--- a/pylib/gfxprim/core/core.i
+++ b/pylib/gfxprim/core/core.i
@@ -17,7 +17,7 @@
%include "GP_Transform.h"
/*
- * Make members of GP_DebugMsg structure immutable
+ * Make members of GP_DebugMsg structure immutable
*/
%immutable GP_DebugMsg::level;
%immutable GP_DebugMsg::file;
@@ -75,7 +75,7 @@ static int GP_ProgressCallbackProxy(GP_ProgressCallback *self)
}
GP_ProgressCallback(PyObject* obj) {
GP_ProgressCallback *res;
-
+
if (!PyCallable_Check(obj)) {
GP_WARN("Callback must be callable python object");
return NULL;
@@ -90,7 +90,7 @@ static int GP_ProgressCallbackProxy(GP_ProgressCallback *self)
res->priv = obj;
res->callback = GP_ProgressCallbackProxy;
-
+
GP_DEBUG(2, "[wrapper] creating Proxy Callback");
return res;
diff --git a/pylib/gfxprim/filters/__init__.py b/pylib/gfxprim/filters/__init__.py
index 32b2efd..f847331 100644
--- a/pylib/gfxprim/filters/__init__.py
+++ b/pylib/gfxprim/filters/__init__.py
@@ -2,7 +2,7 @@ from . import c_filters
def _init(module):
"Extend Context with filters submodule"
-
+
# Imports from the SWIG module
import re
def strip_GP(s):
@@ -15,6 +15,6 @@ def _init(module):
'^GP_Filter.*Alloc',
'^GP_Filter[A-Za-z0-9]*$',
])
-
+
_init(locals())
del _init
diff --git a/pylib/gp_codegen/gfxprimconfig.py b/pylib/gp_codegen/gfxprimconfig.py
index 39ad70f..a0f1e8e 100644
--- a/pylib/gp_codegen/gfxprimconfig.py
+++ b/pylib/gp_codegen/gfxprimconfig.py
@@ -17,7 +17,7 @@ class GfxPrimConfig(object):
pixel_type: name of C type for a pixel value
pixel_size: number of bits of pixel_type
pixelsizes: list of generated and allowed PixelSizes
- pixelsizes_by_bpp: dictionary of bitendians by BPP
+ pixelsizes_by_bpp: dictionary of bitendians by BPP
pixeltypes: list of generated PixelTypes, not incl. UNKNOWN
"""
diff --git a/pylib/gp_codegen/pixeltype.py b/pylib/gp_codegen/pixeltype.py
index 9e89ddc..2e89931 100644
--- a/pylib/gp_codegen/pixeltype.py
+++ b/pylib/gp_codegen/pixeltype.py
@@ -88,7 +88,7 @@ class PixelType(object):
def is_gray(self):
return ('V' in self.chans)
-
+
def is_cmyk(self):
for i in 'CMYK':
if i not in self.chans: return False
diff --git a/pylib/templates/filter.arithmetic.c.t b/pylib/templates/filter.arithmetic.c.t
index 1bbeab1..e3bb60f 100644
--- a/pylib/templates/filter.arithmetic.c.t
+++ b/pylib/templates/filter.arithmetic.c.t
@@ -40,7 +40,7 @@ static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src_a, const GP_C
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, pix);
}
-
+
if (GP_ProgressCallbackReport(callback, y, h, w))
return 1;
}
@@ -63,7 +63,7 @@ static int GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src_a, const GP
{
{{ caller(ps) }}
uint32_t x, y, w, h;
-
+
w = GP_MIN(src_a->w, src_b->w);
h = GP_MIN(src_a->h, src_b->h);
@@ -75,7 +75,7 @@ static int GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src_a, const GP
{{ filter_op('pix', ps.size) }}
GP_PutPixel_Raw_{{ ps.suffix }}(dst, x, y, pix);
}
-
+
if (GP_ProgressCallbackReport(callback, y, h, w))
return 1;
}
@@ -122,7 +122,7 @@ int GP_Filter{{ name }}(const GP_Context *src_a, const GP_Context *src_b,
{
GP_Size w = GP_MIN(src_a->w, src_b->w);
GP_Size h = GP_MIN(src_a->h, src_b->h);
-
+
GP_ASSERT(src_a->pixel_type == dst->pixel_type,
"The src and dst pixel types must match");
GP_ASSERT(w <= dst->w && h <= dst->h,
@@ -146,7 +146,7 @@ GP_Context *GP_Filter{{ name }}Alloc(const GP_Context *src_a, const GP_Context *
GP_Size w = GP_MIN(src_a->w, src_b->w);
GP_Size h = GP_MIN(src_a->h, src_b->h);
-
+
res = GP_ContextAlloc(w, h, src_a->pixel_type);
if (res == NULL)
@@ -156,7 +156,7 @@ GP_Context *GP_Filter{{ name }}Alloc(const GP_Context *src_a, const GP_Context *
GP_DEBUG(1, "Operation aborted");
GP_ContextFree(res);
-
+
return NULL;
}
diff --git a/pylib/templates/filter.c.t b/pylib/templates/filter.c.t
index 335ffbc..da61c79 100644
--- a/pylib/templates/filter.c.t
+++ b/pylib/templates/filter.c.t
@@ -17,7 +17,7 @@
if ({{ var }} > {{ 2 ** size - 1}})
{{ var }} = {{ 2 ** size - 1}};
-%% endmacro
+%% endmacro
/*
* Load parameters from params structure into variables
@@ -25,7 +25,7 @@
%% macro filter_params(pt, params, c_type, suffix, id)
GP_ASSERT(GP_FilterParamCheckPixelType({{ params }}, GP_PIXEL_{{ pt.name }}) == 0,
"Invalid params channels for context pixel type");
-
+
%% for chann in pt.chanslist
{{ c_type }}{{ chann[0] }}{{ suffix }} = (GP_FilterParamChannel({{ params }}, "{{ chann[0] }}"))->val.{{ id }};
%% endfor
@@ -34,7 +34,7 @@
%% macro filter_params_raw(pt, params, suffix)
GP_ASSERT(GP_FilterParamCheckPixelType({{ params }}, GP_PIXEL_{{ pt.name }}) == 0,
"Invalid params channels for context pixel type");
-
+
%% for chann in pt.chanslist
GP_FilterParam *{{ chann[0] }}{{ suffix }} = GP_FilterParamChannel({{ params }}, "{{ chann[0] }}");
%% endfor
diff --git a/pylib/templates/filter.point.c.t b/pylib/templates/filter.point.c.t
index dde4ce4..7789bb1 100644
--- a/pylib/templates/filter.point.c.t
+++ b/pylib/templates/filter.point.c.t
@@ -32,7 +32,7 @@ static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src, GP_Context *
GP_PutPixel_Raw_{{ pt.pixelsize.suffix }}(dst, x, y, pix);
}
-
+
if (GP_ProgressCallbackReport(callback, y, src->h, src->w))
return 1;
}
@@ -63,7 +63,7 @@ static int GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src, GP_Context
{{ filter_op('pix', ps.size) }}
GP_PutPixel_Raw_{{ ps.suffix }}(dst, x, y, pix);
}
-
+
if (GP_ProgressCallbackReport(callback, y, src->h, src->w))
return 1;
}
@@ -126,7 +126,7 @@ GP_Context *GP_Filter{{ name }}(const GP_Context *src, GP_Context *dst{{ maybe_o
if (dst == NULL)
GP_ContextFree(res);
-
+
return NULL;
}
diff --git a/pylib/templates/filter.stats.c.t b/pylib/templates/filter.stats.c.t
index 5b65f3b..7c137db 100644
--- a/pylib/templates/filter.stats.c.t
+++ b/pylib/templates/filter.stats.c.t
@@ -28,7 +28,7 @@ static int GP_Filter{{ name }}_{{ pt.name }}(const GP_Context *src,
{{ filter_op(c[0], c[2]) }}
%% endfor
}
-
+
if (GP_ProgressCallbackReport(callback, y, src->h, src->w))
return 1;
}
@@ -58,7 +58,7 @@ static int GP_Filter{{ name }}_{{ ps.suffix }}(const GP_Context *src,
int32_t pix = GP_GetPixel_Raw_{{ ps.suffix }}(src, x, y);
{{ filter_op('pix', ps.size) }}
}
-
+
if (GP_ProgressCallbackReport(callback, y, src->h, src->w))
return 1;
}
-----------------------------------------------------------------------
Summary of changes:
configure | 26 ++++++------
include/backends/GP_Backend.h | 8 ++--
include/backends/GP_BackendInit.h | 4 +-
include/backends/GP_BackendVirtual.h | 2 +-
include/backends/GP_SDL.h | 8 ++--
include/backends/GP_X11.h | 8 ++--
include/core/GP_BitSwap.h | 2 +-
include/core/GP_Blit.h | 4 +-
include/core/GP_Clamp.h | 2 +-
include/core/GP_Color.h | 6 +-
include/core/GP_Common.h | 2 +-
include/core/GP_Context.h | 16 +++---
include/core/GP_Convert.h | 6 +-
include/core/GP_FnPerBpp.h | 10 ++--
include/core/GP_Gamma.h | 12 +++---
include/core/GP_GetPutPixel.h | 8 ++--
include/core/GP_GetSetBits.h | 10 ++--
include/core/GP_Pixel.h | 14 +++---
include/core/GP_ProgressCallback.h | 8 ++--
include/core/GP_Threads.h | 2 +-
include/core/GP_Transform.h | 24 +++++-----
include/core/GP_Types.h | 4 +-
include/filters/GP_Blur.h | 2 +-
include/filters/GP_Convolution.h | 16 +++---
include/filters/GP_FilterParam.h | 2 +-
include/filters/GP_GaussianNoise.h | 2 +-
include/filters/GP_HilbertCurve.h | 4 +-
include/filters/GP_Linear.h | 4 +-
include/filters/GP_Median.h | 2 +-
include/filters/GP_Point.h | 2 +-
include/filters/GP_Resize.h | 4 +-
include/filters/GP_Rotate.h | 8 ++--
include/filters/GP_Sigma.h | 6 +-
include/filters/GP_WeightedMedian.h | 2 +-
include/gfx/GP_CircleSeg.h | 4 +-
include/gfx/GP_HLineAA.h | 4 +-
include/gfx/GP_LineAA.h | 6 +-
include/gfx/GP_PutPixelAA.h | 4 +-
include/gfx/GP_VLineAA.h | 4 +-
include/grabbers/GP_Grabber.h | 4 +-
include/input/GP_Event.h | 14 +++---
include/input/GP_InputDriverLinux.h | 6 +-
include/input/GP_TimeStamp.h | 2 +-
include/input/GP_Timer.h | 8 ++--
include/loaders/GP_BMP.h | 2 +-
include/loaders/GP_ByteUtils.h | 6 +-
include/loaders/GP_GIF.h | 2 +-
include/loaders/GP_JPG.h | 2 +-
include/loaders/GP_Loader.h | 12 +++---
include/loaders/GP_MetaData.h | 2 +-
include/loaders/GP_PNG.h | 4 +-
include/loaders/GP_PSP.h | 2 +-
include/loaders/GP_TIFF.h | 2 +-
include/loaders/GP_TmpFile.h | 2 +-
include/text/GP_Font.h | 16 +++---
include/text/GP_Text.h | 2 +-
include/text/GP_TextMetric.h | 4 +-
lib.mk | 2 +-
libs/backends/GP_Backend.c | 18 ++++----
libs/backends/GP_BackendInit.c | 24 +++++-----
libs/backends/GP_BackendVirtual.c | 16 +++---
libs/backends/GP_InputDriverSDL.c | 2 +-
libs/backends/GP_InputDriverX11.c | 6 +-
libs/backends/GP_LinuxFB.c | 36 ++++++++--------
libs/backends/GP_SDL.c | 16 +++---
libs/backends/GP_X11.c | 8 ++--
libs/backends/GP_X11_Conn.h | 6 +-
libs/backends/GP_X11_Win.h | 68 ++++++++++++++--------------
libs/core/GP_Blit.c | 8 ++--
libs/core/GP_Blit.gen.c.t | 2 +-
libs/core/GP_Context.c | 34 +++++++-------
libs/core/GP_Debug.c | 18 ++++----
libs/core/GP_Gamma.c | 28 ++++++------
libs/core/GP_GetPutPixel.c | 4 +-
libs/core/GP_Pixel.c | 22 +++++-----
libs/core/GP_Pixel.gen.c.t | 6 +-
libs/core/GP_Threads.c | 10 ++--
libs/filters/GP_Blur.c | 16 +++---
libs/filters/GP_Convolution.c | 2 +-
libs/filters/GP_Dither.c | 4 +-
libs/filters/GP_Edge.c | 28 ++++++------
libs/filters/GP_FilterParam.c | 28 ++++++------
libs/filters/GP_FloydSteinberg.gen.c.t | 14 +++---
libs/filters/GP_GaussianNoise.gen.c.t | 14 +++---
libs/filters/GP_HilbertPeano.gen.c.t | 4 +-
libs/filters/GP_Laplace.c | 6 +-
libs/filters/GP_Linear.c | 60 +++++++++++++-------------
libs/filters/GP_LinearThreads.c | 32 +++++++-------
libs/filters/GP_Median.c | 52 +++++++++++-----------
libs/filters/GP_MirrorV.gen.c.t | 2 +-
libs/filters/GP_Resize.c | 46 ++++++++++----------
libs/filters/GP_ResizeCubic.gen.c.t | 36 ++++++++--------
libs/filters/GP_ResizeLinear.gen.c.t | 32 +++++++-------
libs/filters/GP_ResizeNN.gen.c.t | 4 +-
libs/filters/GP_Rotate.c | 10 ++--
libs/filters/GP_Rotate.gen.c.t | 18 ++++----
libs/filters/GP_Sigma.c | 33 +++++++-------
libs/filters/GP_Stats.c | 8 ++--
libs/filters/GP_WeightedMedian.c | 16 +++---
libs/gfx/GP_Arc.c | 4 +-
libs/gfx/GP_Circle.c | 14 +++---
libs/gfx/GP_CircleSeg.c | 6 +-
libs/gfx/GP_Ellipse.c | 4 +-
libs/gfx/GP_FillEllipse.gen.c.t | 8 ++--
libs/gfx/GP_HLine.gen.c.t | 2 +-
libs/gfx/GP_HLineAA.c | 4 +-
libs/gfx/GP_HLineAA.gen.c.t | 16 +++---
libs/gfx/GP_Line.gen.c.t | 2 +-
libs/gfx/GP_LineAA.c | 4 +-
libs/gfx/GP_LineAA.gen.c.t | 34 ++++++++++++---
libs/gfx/GP_LineClip.c | 6 +-
libs/gfx/GP_PutPixelAA.gen.c.t | 6 +-
libs/gfx/GP_Rect.c | 8 ++--
libs/gfx/GP_RectAA.c | 24 +++++------
libs/gfx/GP_Tetragon.c | 6 +-
libs/gfx/GP_Triangle.c | 2 +-
libs/gfx/GP_VLine.c | 6 +-
libs/gfx/GP_VLine.gen.c.t | 4 +-
libs/gfx/GP_VLineAA.c | 2 +-
libs/gfx/GP_VLineAA.gen.c.t | 35 ++++++++++++---
libs/grabbers/GP_V4L2.c | 44 +++++++++---------
libs/input/GP_Event.c | 2 +-
libs/input/GP_EventQueue.c | 42 +++++++++--------
libs/input/GP_InputDriverKBD.c | 2 +-
libs/input/GP_InputDriverLinux.c | 28 ++++++------
libs/input/GP_TimeStamp.c | 2 +-
libs/input/GP_Timer.c | 10 ++--
libs/loaders/GP_BMP.c | 56 ++++++++++++------------
libs/loaders/GP_ByteUtils.c | 16 +++---
libs/loaders/GP_GIF.c | 35 +++++++--------
libs/loaders/GP_JPG.c | 30 ++++++------
libs/loaders/GP_Loader.c | 19 ++++----
libs/loaders/GP_MetaData.c | 44 +++++++++---------
libs/loaders/GP_MetaExif.c | 43 +++++++++---------
libs/loaders/GP_PNG.c | 36 ++++++++--------
libs/loaders/GP_PNM.c | 39 ++++++++--------
libs/loaders/GP_PSP.c | 14 +++---
libs/loaders/GP_TIFF.c | 10 ++--
libs/loaders/GP_TmpFile.c | 8 ++--
libs/text/GP_Font.c | 2 +-
libs/text/GP_FontTiny.c | 2 +-
libs/text/GP_FontTinyMono.c | 2 +-
libs/text/GP_FreeType.c | 22 +++++-----
libs/text/GP_Text.c | 6 +-
libs/text/GP_TextMetric.c | 16 +++---
pylib/gfxprim/backends/_extend_backend.py | 4 +-
pylib/gfxprim/backends/backends.i | 8 ++--
pylib/gfxprim/core/core.i | 6 +-
pylib/gfxprim/filters/__init__.py | 4 +-
pylib/gp_codegen/gfxprimconfig.py | 2 +-
pylib/gp_codegen/pixeltype.py | 2 +-
pylib/templates/filter.arithmetic.c.t | 12 +++---
pylib/templates/filter.c.t | 6 +-
pylib/templates/filter.point.c.t | 6 +-
pylib/templates/filter.stats.c.t | 4 +-
tests/filters/Makefile | 2 +
156 files changed, 988 insertions(+), 948 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
27 Jun '13
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 88500942a4e2dda6951c5abaf6bc05e4bb5d6efc (commit)
via d6f1b011de7a541ecd56b6479d649bb8d6a26109 (commit)
via a45c066497e510b339d3b9280859530ecf6e5b0c (commit)
from b287df058124c3d9039a8bfe5475927a1d5fc68e (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/88500942a4e2dda6951c5abaf6bc05e4bb5d…
commit 88500942a4e2dda6951c5abaf6bc05e4bb5d6efc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Jun 27 20:26:39 2013 +0200
tests: runtest.py: Print name of tests directory.
Prints name of tests directory we are about to run testsuite from.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/runtests.py b/tests/runtests.py
index d6619a5..8cd1477 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -98,10 +98,11 @@ def run_tests(resdir, testsdir):
runtest = path + '/test_list.txt'
if (os.access(runtest, os.R_OK)):
- # Create result directory
+ # Create result directory
curresdir = resdir + '/' + name
os.mkdir(curresdir)
# Run tests
+ print("n========= Running " + name + " testsuites =========n")
run_test(curresdir, path, runtest)
def main():
http://repo.or.cz/w/gfxprim.git/commit/d6f1b011de7a541ecd56b6479d649bb8d6a2…
commit d6f1b011de7a541ecd56b6479d649bb8d6a26109
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Jun 27 20:22:20 2013 +0200
tests: input: Simple test for TimeStamp.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/input/Makefile b/tests/input/Makefile
index e5e49bc..7f8726c 100644
--- a/tests/input/Makefile
+++ b/tests/input/Makefile
@@ -2,9 +2,9 @@ TOPDIR=../..
include $(TOPDIR)/pre.mk
-CSOURCES=Timer.c
+CSOURCES=Timer.c TimeStamp.c
-APPS=Timer
+APPS=Timer TimeStamp
include ../tests.mk
diff --git a/tests/input/TimeStamp.c b/tests/input/TimeStamp.c
new file mode 100644
index 0000000..5ab2dc2
--- /dev/null
+++ b/tests/input/TimeStamp.c
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+/*
+
+ Test for TimeStamp monotonicity.
+
+ */
+
+#include <stdlib.h>
+#include <input/GP_TimeStamp.h>
+
+#include "tst_test.h"
+
+#define MAX 2048
+
+static int time_stamp_monotonicity(void)
+{
+ uint64_t ts = 0, nts;
+ int i, fail = 0;
+
+ for (i = 0; i < MAX; i++) {
+ nts = GP_GetTimeStamp();
+ if (nts < ts) {
+ tst_msg("TimeStamp failed at %i %llu < %llu", i,
+ (long long unsigned)nts,
+ (long long unsigned) ts);
+ fail++;
+ }
+ }
+
+ if (fail)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
+const struct tst_suite tst_suite = {
+ .suite_name = "TimeStamp Testsuite",
+ .tests = {
+ {.name = "TimeStamp monotonicity",
+ .tst_fn = time_stamp_monotonicity},
+ {.name = NULL},
+ }
+};
http://repo.or.cz/w/gfxprim.git/commit/a45c066497e510b339d3b9280859530ecf6e…
commit a45c066497e510b339d3b9280859530ecf6e5b0c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Jun 27 20:16:57 2013 +0200
tests: input: Add timers testsuite.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/Makefile b/tests/Makefile
index 6eb167d..56d5c28 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,7 +1,7 @@
TOPDIR=..
include $(TOPDIR)/pre.mk
-SUBDIRS=core framework loaders gfx filters
+SUBDIRS=core framework loaders gfx filters input
loaders: framework
gfx: framework
diff --git a/tests/input/Makefile b/tests/input/Makefile
new file mode 100644
index 0000000..e5e49bc
--- /dev/null
+++ b/tests/input/Makefile
@@ -0,0 +1,12 @@
+TOPDIR=../..
+
+include $(TOPDIR)/pre.mk
+
+CSOURCES=Timer.c
+
+APPS=Timer
+
+include ../tests.mk
+
+include $(TOPDIR)/app.mk
+include $(TOPDIR)/post.mk
diff --git a/tests/input/Timer.c b/tests/input/Timer.c
new file mode 100644
index 0000000..34ce1eb
--- /dev/null
+++ b/tests/input/Timer.c
@@ -0,0 +1,207 @@
+/*****************************************************************************
+ * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+/*
+
+ Test for Timers code.
+
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <input/GP_Timer.h>
+
+#include "tst_test.h"
+
+static uint32_t callback_set_priv(GP_Timer *self)
+{
+ self->priv = (void*)1;
+
+ return 0;
+}
+
+static int callback_is_called(void)
+{
+ GP_TIMER_DECLARE(timer, 10, 0, "Timer", callback_set_priv, NULL);
+ GP_Timer *head = NULL;
+ int fail = 0;
+
+ GP_TimerQueueInsert(&head, 10, &timer);
+
+ /* Now call process before the timer expiration */
+ if (GP_TimerQueueProcess(&head, 10)) {
+ tst_msg("GP_TimerQueueProcess() reported non-zero");
+ fail++;
+ }
+
+ if (timer.priv) {
+ tst_msg("Callback was called");
+ fail++;
+ }
+
+ /* Now call process after the expiration time */
+ if (GP_TimerQueueProcess(&head, 30) != 1) {
+ tst_msg("GP_TimerQueueProcess() reported wrong number");
+ fail++;
+ }
+
+ if (!timer.priv) {
+ tst_msg("Callback was not called");
+ fail++;
+ }
+
+ if (fail)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
+#define MAX 2048
+
+static int monotonicity_failed = 0;
+static uint64_t prev_expires;
+
+static uint32_t callback_check_monotonicity(GP_Timer *self)
+{
+ if (self->expires < prev_expires) {
+ monotonicity_failed = 1;
+ tst_msg("Wrong order of expirations detected");
+ }
+
+ prev_expires = self->expires;
+
+ return 0;
+}
+
+static int expirations_sorted(void)
+{
+ GP_Timer *head = NULL;
+ GP_Timer timers[MAX];
+ int i;
+ uint64_t expires;
+
+ for (i = 0; i < MAX; i++) {
+ timers[i].expires = random();
+ timers[i].period = 0;
+ timers[i].Callback = callback_check_monotonicity;
+ timers[i].priv = &expires;
+ strcpy(timers[i].id, "Timer");
+ GP_TimerQueueInsert(&head, 0, &timers[i]);
+ }
+
+ prev_expires = head->expires;
+
+ for (i = 0; i < MAX; i++)
+ GP_TimerQueueProcess(&head, head ? head->expires : 0);
+
+ if (monotonicity_failed)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
+static int process_with_NULL_head(void)
+{
+ GP_Timer *head = NULL;
+
+ if (GP_TimerQueueProcess(&head, 1024)) {
+ tst_msg("GP_TimerQueueProcess returned non-zero");
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
+/*
+ * Test that periodic timers are rescheduled
+ */
+static int periodic_timers(void)
+{
+ GP_TIMER_DECLARE(timer1, 0, 10, "Timer1", callback_set_priv, NULL);
+ GP_TIMER_DECLARE(timer2, 0, 20, "Timer2", callback_set_priv, NULL);
+ GP_Timer *head = NULL;
+ int fail = 0;
+
+ GP_TimerQueueInsert(&head, 10, &timer1);
+ GP_TimerQueueInsert(&head, 10, &timer2);
+
+ /* Make timer1 expire */
+ if (GP_TimerQueueProcess(&head, 20) != 1) {
+ tst_msg("GP_TimerQueueProcess() reported wrong number");
+ fail++;
+ }
+
+ if (!timer1.priv) {
+ tst_msg("Timer1 callback was not called");
+ fail++;
+ }
+
+ /* check that there are two timers in the queue */
+ if (head->sons != 1) {
+ tst_msg("Queue head has wrong number of sons %u", head->sons);
+ fail++;
+ }
+
+ timer1.priv = NULL;
+
+ /* Make both timers expire */
+ if (GP_TimerQueueProcess(&head, 30) != 2) {
+ tst_msg("GP_TimerQueueProcess() reported wrong number");
+ fail++;
+ }
+
+ if (!timer1.priv) {
+ tst_msg("Timer1 callback was not called");
+ fail++;
+ }
+
+ if (!timer2.priv) {
+ tst_msg("Timer2 callback was not called");
+ fail++;
+ }
+
+ /* check that there are two timers in the queue */
+ if (head->sons != 1) {
+ tst_msg("Queue head has wrong number of sons %u", head->sons);
+ fail++;
+ }
+
+ if (fail)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
+const struct tst_suite tst_suite = {
+ .suite_name = "Timer Testsuite",
+ .tests = {
+ {.name = "Callback is called",
+ .tst_fn = callback_is_called},
+ {.name = "Call process with NULL head",
+ .tst_fn = process_with_NULL_head},
+ {.name = "Expirations are sorted",
+ .tst_fn = expirations_sorted},
+ {.name = "Periodic timers",
+ .tst_fn = periodic_timers},
+ {.name = NULL},
+ }
+};
diff --git a/tests/input/runtest.sh b/tests/input/runtest.sh
new file mode 100755
index 0000000..b3039a3
--- /dev/null
+++ b/tests/input/runtest.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#
+# By default the glibc __libc_message() writes to /dev/tty before calling
+# the abort(). Exporting this macro makes it to use stderr instead.
+#
+# The main usage of the function are malloc assertions, so this makes us catch
+# the malloc error message by catching stderr output.
+#
+export LIBC_FATAL_STDERR_=1
+
+TEST="$1"
+shift
+
+LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ "./$TEST" "$@"
diff --git a/tests/input/test_list.txt b/tests/input/test_list.txt
new file mode 100644
index 0000000..777c39b
--- /dev/null
+++ b/tests/input/test_list.txt
@@ -0,0 +1,3 @@
+# Input test list
+
+Timer
-----------------------------------------------------------------------
Summary of changes:
tests/Makefile | 2 +-
tests/{loaders => input}/Makefile | 5 +-
tests/{core/Pixel.c => input/TimeStamp.c} | 46 +++----
tests/input/Timer.c | 207 +++++++++++++++++++++++++++++
tests/{core => input}/runtest.sh | 0
tests/input/test_list.txt | 3 +
tests/runtests.py | 3 +-
7 files changed, 235 insertions(+), 31 deletions(-)
copy tests/{loaders => input}/Makefile (64%)
copy tests/{core/Pixel.c => input/TimeStamp.c} (72%)
create mode 100644 tests/input/Timer.c
copy tests/{core => input}/runtest.sh (100%)
create mode 100644 tests/input/test_list.txt
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
24 Jun '13
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 b287df058124c3d9039a8bfe5475927a1d5fc68e (commit)
via def91911864e39790b6a69b674b65c7b59c6933c (commit)
via 4576af9cfc5ff38fb8b5cd804d0f05eb891b83f6 (commit)
via 2b7cd8c924e4a9b4b0a946d9f5b22067789cf18c (commit)
via b26b80ae54cda6dc76f1b002e221ae62dd5989de (commit)
via 32a00d3651aa79bc3db01c0f2ce4e1c89c6e3c97 (commit)
via cf00485b00ae80031789a382a764e21cd70ec706 (commit)
via ec6f972853a8eec5ccea7df42077ab6745938ccc (commit)
via d9a8b27f7b932cc340d5d0251ab292fe388216a7 (commit)
from 1f9af7dcef377ae227faa484f8f7183583bfefe4 (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/b287df058124c3d9039a8bfe5475927a1d5f…
commit b287df058124c3d9039a8bfe5475927a1d5fc68e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Jun 24 19:53:41 2013 +0200
doc: backends: Add GP_BackendAddTimer() docs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/backends.txt b/doc/backends.txt
index ff8cffb..151e654 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -412,6 +412,25 @@ queue and the call returns.
}
-------------------------------------------------------------------------------
+GP_BackendAddTimer
+^^^^^^^^^^^^^^^^^^
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <backends/GP_Backend.h>
+/* or */
+#include <GP.h>
+
+void GP_BackendAddTimer(GP_Backend *self, GP_Timer *timer);
+-------------------------------------------------------------------------------
+
+Adds a link:input.html#Timers[timer] to the backend timer queue.
+
+Timers added to the backend are processed automatically while you call any of
+backend 'Poll' or 'Wait' functions.
+
+If timer callback is set to 'NULL' a timer event is pushed to the backend
+input queue once timer has expired otherwise timer callback is called.
GP_BackendEventsQueued
^^^^^^^^^^^^^^^^^^^^^^
http://repo.or.cz/w/gfxprim.git/commit/def91911864e39790b6a69b674b65c7b59c6…
commit def91911864e39790b6a69b674b65c7b59c6933c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Jun 24 19:41:51 2013 +0200
doc: input: Add GP_Timer and GP_TimeStamp docs.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/input.txt b/doc/input.txt
index a98428e..5db6158 100644
--- a/doc/input.txt
+++ b/doc/input.txt
@@ -5,7 +5,7 @@ are stored in the link:event_queue.html[event queue].
Possibly in contrast with other libraries there is not always 1:1
correspondence between input driver and backend graphics driver. That means
-that you can, for example, use linux input events together with X Window
+that you can, for example, use Linux input events together with X Window
without any problems. You can even write application that doesn't draw any
graphics at all and still use some of the input drivers. There are, of course,
cases where input driver is created only together with graphics driver, this
@@ -40,7 +40,7 @@ typedef struct GP_Event {
struct timeval time;
/*
- * Cursor position, possition on screen accumulated
+ * Cursor position, position on screen accumulated
* from all pointer devices
*/
uint32_t cursor_x;
@@ -64,17 +64,19 @@ enum GP_EventType {
GP_EV_REL, /* relative event */
GP_EV_ABS, /* absolute event */
GP_EV_SYS, /* system events window close, resize... */
- GP_EV_MAX = GP_EV_SYS, /* maximum, greater values are free */
+ GP_EV_TMR, /* timer expired event */
+ GP_EV_MAX = GP_EV_TMR, /* maximum, greater values are free */
};
-------------------------------------------------------------------------------
-The event 'type' determines highlevel nature of the event.
+The event 'type' determines high-level nature of the event.
* Key events covers keyboard button presses, mouse buttons, etc.
* Relative events covers mouse coordinates, mouse wheel, etc.
* Absolute events covers touchscreens and tablets
* System events are used for propagating window close and window
resize events
+* Timer expired event are generated by when a link:#Timers[timer] has expired.
* Values greater than 'GP_EV_MAX' are free for user events
[source,c]
@@ -115,6 +117,8 @@ union GP_EventValue {
struct GP_EventPosAbs abs;
/* system event */
struct GP_EventSys sys;
+ /* timer event */
+ GP_Timer *tmr;
};
struct GP_EventPosRel {
@@ -145,7 +149,7 @@ events has no value at all.
* The relative coordinates are used for 'GP_EV_REL_POS' and absolute coordinates
for 'GP_EV_ABS_POS'.
-* The key event value is used for keypresses, additionally it holds the key
+* The key event value is used for key-presses, additionally it holds the key
value mapped to ASCII if conversion is applicable otherwise it's set to
zero. You should consult the header 'input/GP_Event.h' for the comprehensive
list of key values.
@@ -158,15 +162,17 @@ higher resolution). So for example 'LEFTSHIFT' on the image is
.GFXprim key names without the 'GP_KEY_' prefix.
image::keyboard.svg["Keyboard Layout",width=800,link="keyboard.svg"]
-* And finally the system event is used with 'GP_EV_SYS_RESIZE' and informs you
+* The system event is used with 'GP_EV_SYS_RESIZE' and informs you
of the new window size.
+* The value of timer event is simply pointer to the expired timer.
+
The 'dev_id' is not used at the moment and may be removed.
The timeval structure 'time' holds time when the event was created (or
received by GFXprim input driver).
-The 'cursor_x' and 'cursor_y' holds current pointer coodinates. (All relative
+The 'cursor_x' and 'cursor_y' holds current pointer coordinates. (All relative
and absolute events are mixed together to compute current cursor position.)
The 'key_pressed' is bitflag array of currently pressed keys which is useful
@@ -219,3 +225,121 @@ These functions are helpers for setting/getting key pressed bits in the
You will mostly need the 'GP_EventGetKey' function to figure out if some of
the modificator keys (such as Ctrl or Shift) was pressed at the time the event
was received.
+
+[[Timers]]
+Timers
+~~~~~~
+
+Input layer also implements 'priority queue' (implemented using binary heap)
+to store multiple timer events. This part of the code is used in
+link:backends.html[backends] where you can simply add timer which gets
+processed automatically in the program main loop (while you call the backend
+Wait or Poll functions).
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <input/GP_Timer.h>
+
+typedef struct GP_Timer {
+ /* Heap pointers and number of sons */
+ struct GP_Timer *left;
+ struct GP_Timer *right;
+ unsigned int sons;
+
+ /* Expiration time */
+ uint64_t expires;
+ /*
+ * If not zero return value from Callback is ignored and
+ * timer is rescheduled each time it expires.
+ */
+ uint32_t period;
+
+ /* Timer id, showed in debug messages */
+ char id[10];
+
+ /*
+ * Timer Callback
+ *
+ * If non-zero is returned, the timer is rescheduled to expire
+ * return value from now.
+ */
+ uint32_t (*Callback)(struct GP_Timer *self);
+ void *priv;
+} GP_Timer;
+
+#define GP_TIMER_DECLARE(name, expires, period, id, Callback, priv) + ...
+-------------------------------------------------------------------------------
+
+Timers are implemented as a simple structure with a callback, expiration, id
+string and internal heap pointers. The priority queue is described simply by
+the pointer to the top timer (soonest time to expire).
+
+The 'priv' pointer is used to pass a user pointer to the callback function.
+
+The number of timers in the queue is the number of sons of the top timer plus
+one.
+
+The 'GP_TIMER_DECLARE()' creates and initializes timer on the program stack.
+The 'name' is the name of the declared timer structure and the rest of the
+variables corresponds to the structure members.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <input/GP_Timer.h>
+
+void GP_TimerQueueDump(GP_Timer *queue);
+-------------------------------------------------------------------------------
+
+Prints the structure of binary heap into stdout, only for debugging.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <input/GP_Timer.h>
+
+void GP_TimerQueueInsert(GP_Timer **queue, uint64_t now, GP_Timer *timer);
+-------------------------------------------------------------------------------
+
+Inserts timer into the timer priority queue. The timer is scheduled to expire
+at `now + timer->expire`.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <input/GP_Timer.h>
+
+int GP_TimerQueueProcess(GP_Timer **queue, uint64_t now);
+-------------------------------------------------------------------------------
+
+Processes all expired timers (all timers with `timer->expires <= now` are processed).
+
+Recurrent timers and timers that returned non-zero from callback are reinserted
+into the queue with new expiration time.
+
+Returns number of timers processed.
+
+[[TimeStamp]]
+TimerStamp
+~~~~~~~~~~
+
+Timestamp provides fast monotonously increasing timestamps in milliseconds.
+
+Timestamp is used together with link:#Timers[timers].
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <GP.h>
+/* or */
+#include <input/GP_TimeStamp.h>
+
+uint64_t GP_GetTimeStamp(void);
+-------------------------------------------------------------------------------
+
+Returns timestamp (i.e. time elapsed since some point) in milliseconds.
http://repo.or.cz/w/gfxprim.git/commit/4576af9cfc5ff38fb8b5cd804d0f05eb891b…
commit 4576af9cfc5ff38fb8b5cd804d0f05eb891b83f6
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 21 21:47:32 2013 +0200
spiv: Get rid of the ugly slideshow code, use timers!
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 5f03205..11b8f4b 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -620,7 +620,7 @@ static void sighandler(int signo)
fprintf(stderr, "Got signal %in", signo);
- exit(1);
+ _exit(1);
}
static void init_backend(const char *backend_opts)
@@ -633,78 +633,6 @@ static void init_backend(const char *backend_opts)
}
}
-static int alarm_fired = 0;
-
-static void alarm_handler(int signo)
-{
- alarm_fired = 1;
-}
-
-static int wait_for_event(int sleep_msec)
-{
- static int sleep_msec_count = 0;
- static int alarm_set = 0;
-
- if (sleep_msec < 0) {
- GP_BackendPoll(backend);
- usleep(10000);
- return 0;
- }
-
- /* We can't sleep on backend fd, because the backend doesn't export it. */
- if (backend->fd < 0) {
- GP_BackendPoll(backend);
- usleep(10000);
-
- sleep_msec_count += 10;
-
- if (sleep_msec_count >= sleep_msec) {
- sleep_msec_count = 0;
- return 1;
- }
-
- return 0;
- }
-
- /* Initalize select */
- fd_set rfds;
- FD_ZERO(&rfds);
-
- FD_SET(backend->fd, &rfds);
-
- if (!alarm_set) {
- signal(SIGALRM, alarm_handler);
- alarm(sleep_msec / 1000);
- alarm_fired = 0;
- alarm_set = 1;
- }
-
- struct timeval tv = {.tv_sec = sleep_msec / 1000,
- .tv_usec = (sleep_msec % 1000) * 1000};
-
- int ret = select(backend->fd + 1, &rfds, NULL, NULL, &tv);
-
- switch (ret) {
- case -1:
- if (errno == EINTR)
- return 1;
-
- GP_BackendExit(backend);
- exit(1);
- break;
- case 0:
- if (alarm_fired) {
- alarm_set = 0;
- return 1;
- }
-
- return 0;
- break;
- default:
- GP_BackendPoll(backend);
- return 0;
- }
-}
static void init_caches(struct loader_params *params)
{
@@ -728,11 +656,20 @@ static void init_caches(struct loader_params *params)
// params->img_orig_cache = NULL;
}
+static uint32_t timer_callback(GP_Timer *self)
+{
+ struct loader_params *params = self->priv;
+
+ show_image(params, image_list_move(params->img_list, 1));
+
+ return 0;
+}
+
int main(int argc, char *argv[])
{
GP_Context *context = NULL;
const char *backend_opts = "X11";
- int sleep_sec = -1;
+ int sleep_ms = -1;
int opt;
int shift_flag;
GP_PixelType emul_type = GP_PIXEL_UNKNOWN;
@@ -755,6 +692,8 @@ int main(int argc, char *argv[])
.img_orig_cache = NULL,
};
+ GP_TIMER_DECLARE(timer, 0, 0, "Slideshow", timer_callback, ¶ms);
+
while ((opt = getopt(argc, argv, "b:ce:fhIPs:r:z:0:1:2:3:4:5:6:7:8:9:")) != -1) {
switch (opt) {
case 'I':
@@ -767,7 +706,7 @@ int main(int argc, char *argv[])
params.use_dithering = 1;
break;
case 's':
- sleep_sec = atoi(optarg);
+ sleep_ms = atoi(optarg);
break;
case 'c':
params.resampling_method = GP_INTERP_CUBIC_INT;
@@ -850,13 +789,15 @@ int main(int argc, char *argv[])
params.show_progress_once = 1;
show_image(¶ms, image_list_img_path(list));
-
+
+ if (sleep_ms) {
+ timer.period = sleep_ms;
+ GP_BackendAddTimer(backend, &timer);
+ }
+
for (;;) {
- /* wait for event or a timeout */
- if (wait_for_event(sleep_sec * 1000))
- show_image(¶ms, image_list_move(list, 1));
+ GP_BackendWait(backend);
- /* Read and parse events */
GP_Event ev;
while (GP_BackendGetEvent(backend, &ev)) {
diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c
index 701b5ae..f8d3c40 100644
--- a/demos/spiv/spiv_help.c
+++ b/demos/spiv/spiv_help.c
@@ -75,7 +75,7 @@ void print_help(void)
printf(" -I show image info boxn");
printf(" -P show loading progressn");
printf(" -f use floyd-steinberg ditheringn");
- printf(" -s sec sleep interval in secondsn");
+ printf(" -s msec slideshow interval in milisecondsn");
printf(" -c turns on bicubic resampling (experimental)n");
printf(" -e pixel_type turns on backend type emulationn");
printf(" for example -e G1 sets 1-bit grayscalen");
http://repo.or.cz/w/gfxprim.git/commit/2b7cd8c924e4a9b4b0a946d9f5b22067789c…
commit 2b7cd8c924e4a9b4b0a946d9f5b22067789cf18c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 21 21:46:34 2013 +0200
build: Update list of exported symbols.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Backend_symbols.txt b/build/syms/Backend_symbols.txt
index 74e2967..7d5128e 100644
--- a/build/syms/Backend_symbols.txt
+++ b/build/syms/Backend_symbols.txt
@@ -16,8 +16,11 @@ GP_BackendResize
GP_BackendResizeAck
GP_BackendUpdateRectXYXY
GP_BackendFlip
+GP_BackendWait
+GP_BackendPoll
GP_BackendWaitEvent
GP_BackendPollEvent
+GP_BackendAddTimer
GP_InputDriverX11EventPut
GP_InputDriverX11Init
diff --git a/build/syms/Input_symbols.txt b/build/syms/Input_symbols.txt
index 2062806..700dedc 100644
--- a/build/syms/Input_symbols.txt
+++ b/build/syms/Input_symbols.txt
@@ -24,3 +24,9 @@ GP_EventQueuePushKey
GP_EventQueuePushAbs
GP_EventQueuePush
GP_EventQueuePushResize
+
+GP_TimerQueueDump
+GP_TimerQueueProcess
+GP_TimerQueueInsert
+
+GP_GetTimeStamp
http://repo.or.cz/w/gfxprim.git/commit/b26b80ae54cda6dc76f1b002e221ae62dd59…
commit b26b80ae54cda6dc76f1b002e221ae62dd5989de
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 21 21:45:16 2013 +0200
backends: Add support for timers to backends.
Now you can add any number of timers to backend and
the timers are processed while you call Wait or Poll.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/backends/GP_Backend.h b/include/backends/GP_Backend.h
index 792d603..e623eda 100644
--- a/include/backends/GP_Backend.h
+++ b/include/backends/GP_Backend.h
@@ -45,8 +45,7 @@
#include "core/GP_Context.h"
#include "input/GP_EventQueue.h"
-
-struct GP_Backend;
+#include "input/GP_Timer.h"
typedef struct GP_Backend {
/*
@@ -136,6 +135,11 @@ typedef struct GP_Backend {
*/
struct GP_EventQueue event_queue;
+ /*
+ * Priority queue for timers.
+ */
+ struct GP_Timer *timers;
+
/* Backed private data */
char priv[];
} GP_Backend;
@@ -180,10 +184,7 @@ static inline void GP_BackendExit(GP_Backend *backend)
/*
* Polls backend, the events are filled into event queue.
*/
-static inline void GP_BackendPoll(GP_Backend *backend)
-{
- backend->Poll(backend);
-}
+void GP_BackendPoll(GP_Backend *self);
/*
* Poll and GetEvent combined.
@@ -193,10 +194,7 @@ int GP_BackendPollEvent(GP_Backend *self, GP_Event *ev);
/*
* Waits for backend events.
*/
-static inline void GP_BackendWait(GP_Backend *backend)
-{
- backend->Wait(backend);
-}
+void GP_BackendWait(GP_Backend *self);
/*
* Wait and GetEvent combined.
@@ -204,6 +202,16 @@ static inline void GP_BackendWait(GP_Backend *backend)
int GP_BackendWaitEvent(GP_Backend *self, GP_Event *ev);
/*
+ * Adds timer to backend.
+ *
+ * If timer Callback is NULL a timer event is pushed into
+ * the backend event queue once timer expires.
+ *
+ * See input/GP_Timer.h for more information about timers.
+ */
+void GP_BackendAddTimer(GP_Backend *self, GP_Timer *timer);
+
+/*
* Sets backend caption, if supported.
*
* When setting caption is not possible/implemented non zero is returned.
diff --git a/include/input/GP_Event.h b/include/input/GP_Event.h
index 3159ad0..fa71742 100644
--- a/include/input/GP_Event.h
+++ b/include/input/GP_Event.h
@@ -37,6 +37,8 @@
#include <stdint.h>
#include <sys/time.h>
+#include "input/GP_Timer.h"
+
#define GP_EVENT_QUEUE_SIZE 32
#define GP_EVENT_KEYMAP_BYTES 36
@@ -46,7 +48,8 @@ enum GP_EventType {
GP_EV_REL = 2, /* relative event */
GP_EV_ABS = 3, /* absolute event */
GP_EV_SYS = 4, /* system events window close, resize... */
- GP_EV_MAX = 4, /* maximum, greater values are free */
+ GP_EV_TMR = 5, /* timer expired event */
+ GP_EV_MAX = 5, /* maximum, greater values are free */
};
enum GP_EventKeyCode {
@@ -264,6 +267,8 @@ union GP_EventValue {
struct GP_EventPosAbs abs;
/* system event */
struct GP_EventSys sys;
+ /* timer event */
+ GP_Timer *tmr;
};
typedef struct GP_Event {
diff --git a/libs/backends/GP_Backend.c b/libs/backends/GP_Backend.c
index 9d80d55..c216177 100644
--- a/libs/backends/GP_Backend.c
+++ b/libs/backends/GP_Backend.c
@@ -20,10 +20,16 @@
* *
*****************************************************************************/
+#include <inttypes.h>
+#include <poll.h>
+
#include "core/GP_Common.h"
#include "core/GP_Transform.h"
#include "core/GP_Debug.h"
+#include "input/GP_EventQueue.h"
+#include "input/GP_TimeStamp.h"
+
#include "backends/GP_Backend.h"
void GP_BackendFlip(GP_Backend *backend)
@@ -103,6 +109,93 @@ int GP_BackendResizeAck(GP_Backend *self)
return 0;
}
+static uint32_t pushevent_callback(GP_Timer *self)
+{
+ GP_Event ev;
+
+ ev.type = GP_EV_TMR;
+ ev.val.tmr = self;
+
+ GP_EventQueuePut(self->priv, &ev);
+
+ return 0;
+}
+
+void GP_BackendAddTimer(GP_Backend *self, GP_Timer *timer)
+{
+ if (timer->Callback == NULL) {
+ timer->Callback = pushevent_callback;
+ timer->priv = &self->event_queue;
+ }
+
+ GP_TimerQueueInsert(&self->timers, GP_GetTimeStamp(), timer);
+}
+
+void GP_BackendPoll(GP_Backend *self)
+{
+ self->Poll(self);
+
+ if (self->timers)
+ GP_TimerQueueProcess(&self->timers, GP_GetTimeStamp());
+}
+
+static void wait_timers_fd(GP_Backend *self, uint64_t now)
+{
+ int timeout;
+
+ timeout = self->timers->expires - now;
+
+ struct pollfd fd = {.fd = self->fd, .events = POLLIN, fd.revents = 0};
+
+ if (poll(&fd, 1, timeout))
+ self->Poll(self);
+
+ now = GP_GetTimeStamp();
+
+ GP_TimerQueueProcess(&self->timers, now);
+}
+
+/*
+ * Polling for backends that does not expose FD to wait on (namely SDL).
+ */
+static void wait_timers_poll(GP_Backend *self)
+{
+ for (;;) {
+ uint64_t now = GP_GetTimeStamp();
+
+ if (GP_TimerQueueProcess(&self->timers, now))
+ return;
+
+ self->Poll(self);
+
+ if (GP_BackendEventsQueued(self))
+ return;
+
+ usleep(10000);
+ }
+}
+
+void GP_BackendWait(GP_Backend *self)
+{
+ uint64_t now = GP_GetTimeStamp();
+
+ if (self->timers) {
+ /* Get rid of possibly expired timers */
+ if (GP_TimerQueueProcess(&self->timers, now))
+ return;
+
+ /* Wait for events or timer expiration */
+ if (self->fd != -1)
+ wait_timers_fd(self, now);
+ else
+ wait_timers_poll(self);
+
+ return;
+ }
+
+ self->Wait(self);
+}
+
int GP_BackendWaitEvent(GP_Backend *self, GP_Event *ev)
{
int ret;
diff --git a/libs/backends/GP_BackendVirtual.c b/libs/backends/GP_BackendVirtual.c
index 41e947a..7ea1238 100644
--- a/libs/backends/GP_BackendVirtual.c
+++ b/libs/backends/GP_BackendVirtual.c
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -150,6 +150,7 @@ GP_Backend *GP_BackendVirtualInit(GP_Backend *backend,
self->Poll = backend->Poll ? virt_poll : NULL;
self->Wait = backend->Wait ? virt_wait : NULL;
self->SetAttributes = backend->SetAttributes ? virt_set_attrs : NULL;
+ self->timers = NULL;
GP_EventQueueInit(&self->event_queue, backend->context->w,
backend->context->h, 0);
diff --git a/libs/backends/GP_LinuxFB.c b/libs/backends/GP_LinuxFB.c
index b203109..49566aa 100644
--- a/libs/backends/GP_LinuxFB.c
+++ b/libs/backends/GP_LinuxFB.c
@@ -313,6 +313,7 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flag)
backend->Poll = flag ? fb_poll : NULL;
backend->Wait = flag ? fb_wait : NULL;
backend->fd = fb->con_fd;
+ backend->timers = NULL;
GP_EventQueueInit(&backend->event_queue, vscri.xres, vscri.yres, 0);
diff --git a/libs/backends/GP_SDL.c b/libs/backends/GP_SDL.c
index 4dcfeb3..1e73ecf 100644
--- a/libs/backends/GP_SDL.c
+++ b/libs/backends/GP_SDL.c
@@ -200,6 +200,7 @@ static struct GP_Backend backend = {
.fd = -1,
.Poll = sdl_poll,
.Wait = sdl_wait,
+ .timers = NULL,
};
static void sdl_exit(struct GP_Backend *self __attribute__((unused)))
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index a95e626..b0aff6d 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -618,6 +618,7 @@ GP_Backend *GP_BackendX11Init(const char *display, int x, int y,
backend->SetAttributes = x11_set_attributes;
backend->ResizeAck = x11_resize_ack;
backend->fd = XConnectionNumber(win->dpy);
+ backend->timers = NULL;
return backend;
err1:
diff --git a/libs/input/GP_Event.c b/libs/input/GP_Event.c
index 7bfb9f8..d7ec7cd 100644
--- a/libs/input/GP_Event.c
+++ b/libs/input/GP_Event.c
@@ -148,6 +148,9 @@ void GP_EventDump(struct GP_Event *ev)
case GP_EV_SYS:
dump_sys(ev);
break;
+ case GP_EV_TMR:
+ printf("Timer %s expiredn", ev->val.tmr->id);
+ break;
default:
printf("Unknown %un", ev->type);
}
http://repo.or.cz/w/gfxprim.git/commit/32a00d3651aa79bc3db01c0f2ce4e1c89c6e…
commit 32a00d3651aa79bc3db01c0f2ce4e1c89c6e3c97
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Jun 21 19:23:35 2013 +0200
input: Add GP_GetTimeStamp() function.
The function returns number of miliseconds from some point
(boot of the machine, start of the program, 1. 1. 1970 or anything else).
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/configure b/configure
index 36450a1..107db2d 100755
--- a/configure
+++ b/configure
@@ -265,7 +265,7 @@ def write_gfxprim_config(cfg, libs):
f.write('t--list-modules) echo "%s"; exit 0;;n' % ' '.join(modules))
f.write('t--cflags) echo -n "-I/usr/include/GP/%s";;n' %
libs.get_cflags('core'))
- f.write('t--libs) echo -n "-lGP -lm %s ";;n' % libs.get_linker_flags('core'))
+ f.write('t--libs) echo -n "-lGP -lrt -lm %s ";;n' % libs.get_linker_flags('core'))
# ldflags for specific modules
for i in modules:
diff --git a/include/input/GP_Input.h b/include/input/GP_Input.h
index 4c67e12..cd3e8ca 100644
--- a/include/input/GP_Input.h
+++ b/include/input/GP_Input.h
@@ -33,4 +33,9 @@
*/
#include "input/GP_Timer.h"
+/*
+ * Timestamp.
+ */
+#include "input/GP_TimeStamp.h"
+
#endif /* INPUT_GP_INPUT_H */
diff --git a/include/input/GP_Input.h b/include/input/GP_TimeStamp.h
similarity index 88%
copy from include/input/GP_Input.h
copy to include/input/GP_TimeStamp.h
index 4c67e12..32bd575 100644
--- a/include/input/GP_Input.h
+++ b/include/input/GP_TimeStamp.h
@@ -20,17 +20,17 @@
* *
*****************************************************************************/
-#ifndef INPUT_GP_INPUT_H
-#define INPUT_GP_INPUT_H
-
/*
- * Base GP_Event definitions.
- */
-#include "input/GP_Event.h"
+
+ Returns monotonously incrementing timestamps in milliseconds.
-/*
- * Timers and priority queue
*/
-#include "input/GP_Timer.h"
-#endif /* INPUT_GP_INPUT_H */
+#ifndef INPUT_GP_TIME_STAMP_H
+#define INPUT_GP_TIME_STAMP_H
+
+#include <stdint.h>
+
+uint64_t GP_GetTimeStamp(void);
+
+#endif /* INPUT_GP_TIME_STAMP_H */
diff --git a/libs/input/GP_TimeStamp.c b/libs/input/GP_TimeStamp.c
new file mode 100644
index 0000000..4185ee6
--- /dev/null
+++ b/libs/input/GP_TimeStamp.c
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <errno.h>
+#include <string.h>
+#include <time.h>
+
+#include "core/GP_Common.h"
+#include "core/GP_Debug.h"
+
+#include "input/GP_TimeStamp.h"
+
+#define MS_IN_US 1000000
+
+/*
+ * Chooses fastest clock with milisecond resolution.
+ */
+static int choose_clock(clockid_t *clock)
+{
+ struct timespec ts;
+
+#ifdef CLOCK_MONOTONIC_COARSE
+ GP_DEBUG(1, "Trying CLOCK_MONOTONIC_COARSE");
+
+ if (clock_getres(CLOCK_MONOTONIC_COARSE, &ts)) {
+ GP_DEBUG(1, "CLOCK_MONOTONIC_COARSE: %s", strerror(errno));
+ } else {
+ GP_DEBUG(1, "CLOCK_MONOTONIC_COARSE resolution is %lis %lins",
+ (long)ts.tv_sec, ts.tv_nsec);
+
+ /* Depends on CONFIG_HZ */
+ if (ts.tv_sec == 0 && ts.tv_nsec <= MS_IN_US) {
+ *clock = CLOCK_MONOTONIC_COARSE;
+ return 0;
+ }
+ }
+#endif
+
+ if (clock_getres(CLOCK_MONOTONIC, &ts)) {
+ GP_DEBUG(1, "CLOCK_MONOTONIC: %s", strerror(errno));
+ return 1;
+ }
+
+ GP_DEBUG(1, "CLOCK_MONOTONIC resulution is %lis %lins",
+ (long)ts.tv_sec, ts.tv_nsec);
+
+ if (ts.tv_sec == 0 && ts.tv_nsec <= MS_IN_US) {
+ *clock = CLOCK_MONOTONIC;
+ return 0;
+ }
+
+ GP_DEBUG(1, "No suitable clock id found.");
+ //TODO: Fallback to gettimeofday?
+
+ return 1;
+}
+
+uint64_t GP_GetTimeStamp(void)
+{
+ struct timespec ts;
+ static clockid_t clock = -1;
+
+ if (clock == -1)
+ choose_clock(&clock);
+
+ if (clock_gettime(clock, &ts)) {
+ GP_ABORT("clock_gettime(%i) failed unexpectedly: %s",
+ clock, strerror(errno));
+ }
+
+ return (uint64_t)ts.tv_sec * 1000 + ts.tv_nsec / MS_IN_US;
+}
http://repo.or.cz/w/gfxprim.git/commit/cf00485b00ae80031789a382a764e21cd70e…
commit cf00485b00ae80031789a382a764e21cd70ec706
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Jun 20 23:28:32 2013 +0200
input: Add timers and timer priority queues.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile
index e086f75..e430cc4 100644
--- a/demos/c_simple/Makefile
+++ b/demos/c_simple/Makefile
@@ -18,7 +18,7 @@ APPS=backend_example loaders_example loaders filters_symmetry gfx_koch v4l2_show v4l2_grab convolution weighted_median shapetest koch input_example fileview linetest randomshapetest fonttest loaders_register blittest textaligntest abort sin_AA x11_windows- debug_handler gaussian_noise byte_utils version pretty_print
+ debug_handler gaussian_noise byte_utils version pretty_print timers
ifeq ($(HAVE_LIBSDL),yes)
APPS+=SDL_glue
diff --git a/include/input/GP_Input.h b/demos/c_simple/timers.c
similarity index 61%
copy from include/input/GP_Input.h
copy to demos/c_simple/timers.c
index 80ebe2b..112223a 100644
--- a/include/input/GP_Input.h
+++ b/demos/c_simple/timers.c
@@ -16,16 +16,52 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
-#ifndef INPUT_GP_INPUT_H
-#define INPUT_GP_INPUT_H
-
/*
- * Base GP_Event definitions.
+
+ Simple example how to use raw timer priority queue.
+
*/
-#include "input/GP_Event.h"
-#endif /* INPUT_GP_INPUT_H */
+#include <GP.h>
+
+uint32_t callback1()
+{
+ return 0;
+}
+
+uint32_t callback3()
+{
+ return random() % 30 + 1;
+}
+
+int main(void)
+{
+ GP_TIMER_DECLARE(oneshot, 30, 0, "Oneshot", callback1, NULL);
+ GP_TIMER_DECLARE(recurrent, 0, 4, "Recurrent", callback1, NULL);
+ GP_TIMER_DECLARE(random, 10, 0, "Random", callback3, NULL);
+ GP_Timer *queue = NULL;
+ uint64_t now;
+ int ret;
+
+ GP_SetDebugLevel(10);
+
+ GP_TimerQueueInsert(&queue, 0, &oneshot);
+ GP_TimerQueueInsert(&queue, 0, &recurrent);
+ GP_TimerQueueInsert(&queue, 0, &random);
+
+ for (now = 0; now < 100; now += 3) {
+ printf("NOW %un", (unsigned int) now);
+ printf("-------------------------------------n");
+ ret = GP_TimerQueueProcess(&queue, now);
+ printf("Processed %i timer eventsn", ret);
+ printf("--------------------------------------n");
+ GP_TimerQueueDump(queue);
+ printf("--------------------------------------nn");
+ }
+
+ return 0;
+}
diff --git a/include/input/GP_Input.h b/include/input/GP_Input.h
index 80ebe2b..4c67e12 100644
--- a/include/input/GP_Input.h
+++ b/include/input/GP_Input.h
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -28,4 +28,9 @@
*/
#include "input/GP_Event.h"
+/*
+ * Timers and priority queue
+ */
+#include "input/GP_Timer.h"
+
#endif /* INPUT_GP_INPUT_H */
diff --git a/include/input/GP_Timer.h b/include/input/GP_Timer.h
new file mode 100644
index 0000000..6026268
--- /dev/null
+++ b/include/input/GP_Timer.h
@@ -0,0 +1,93 @@
+/*****************************************************************************
+ * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+/*
+
+ Timers and priority queue implementation.
+
+ */
+
+#ifndef INPUT_GP_TIMER_H
+#define INPUT_GP_TIMER_H
+
+#include <stdint.h>
+
+typedef struct GP_Timer {
+ /* Heap pointers and number of sons */
+ struct GP_Timer *left;
+ struct GP_Timer *right;
+ unsigned int sons;
+
+ /* Expiration time */
+ uint64_t expires;
+ /*
+ * If not zero return value from Callback is ignored and
+ * timer is rescheduled each time it expires.
+ */
+ uint32_t period;
+
+ /* Timer id, showed in debug messages */
+ char id[10];
+
+ /*
+ * Timer Callback
+ *
+ * If non-zero is returned, the timer is rescheduled to expire
+ * return value from now.
+ */
+ uint32_t (*Callback)(struct GP_Timer *self);
+ void *priv;
+} GP_Timer;
+
+#define GP_TIMER_DECLARE(name, texpires, tperiod, tid, tCallback, tpriv) + GP_Timer name = { + .expires = texpires, + .period = tperiod, + .id = tid, + .Callback = tCallback, + .priv = tpriv + }
+
+/*
+ * Prints the structrue of binary heap into stdout, only for debugging.
+ */
+void GP_TimerQueueDump(GP_Timer *queue);
+
+/*
+ * Inserts timer into the timer priority queue.
+ */
+void GP_TimerQueueInsert(GP_Timer **queue, uint64_t now, GP_Timer *timer);
+
+/*
+ * Removes timer from timer queue. Returns NULL if id was not found.
+ */
+GP_Timer GP_TimerQueueRemove(GP_Timer *queue, GP_Timer *timer);
+GP_Timer GP_TimerQueueRemoveById(GP_Timer *queue, const char *id);
+
+/*
+ * Processes queue, all timers with expires <= now are processed.
+ *
+ * Returns number of timers processed.
+ */
+int GP_TimerQueueProcess(GP_Timer **queue, uint64_t now);
+
+#endif /* INPUT_GP_TIMER_H */
diff --git a/libs/input/GP_Timer.c b/libs/input/GP_Timer.c
new file mode 100644
index 0000000..39f63f5
--- /dev/null
+++ b/libs/input/GP_Timer.c
@@ -0,0 +1,263 @@
+/*****************************************************************************
+ * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <inttypes.h>
+#include <string.h>
+
+#include "core/GP_Debug.h"
+#include "core/GP_Common.h"
+
+#include "input/GP_Timer.h"
+
+static void dump_level(GP_Timer *heap, unsigned int level, unsigned int cur)
+{
+ if (level == cur) {
+ if (heap)
+ printf("[%9s %8"PRIu64"] ", heap->id, heap->expires);
+ else
+ printf(" ");
+ return;
+ }
+
+ dump_level(heap ? heap->left : NULL, level, cur+1);
+ dump_level(heap ? heap->right : NULL , level, cur+1);
+}
+
+void GP_TimerQueueDump(GP_Timer *heap)
+{
+ unsigned int i, j = 0;
+
+ if (heap == NULL)
+ return;
+
+ for (i = 1; heap->sons + 1 >= i; i = i*2) {
+ dump_level(heap, j++, 0);
+ printf("n");
+ }
+}
+
+static int timer_cmp(GP_Timer *t1, GP_Timer *t2)
+{
+ return t1->expires > t2->expires;
+}
+
+/*
+ * Returns true if subtree is well balanced i.e. we have 2^n - 2 sons
+ */
+static int well_balanced(unsigned int sons)
+{
+ switch (sons) {
+ case 0:
+ case 2:
+ case 6:
+ case 15:
+ case 30:
+ case 62:
+ case 126:
+ case 254:
+ case 510:
+ case 1022:
+ case 2046:
+ case 4092:
+ case 8190:
+ case 16382:
+ case 32766:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static GP_Timer *swap_left(GP_Timer *heap)
+{
+ GP_Timer *left = heap->left;
+
+ heap->left = left->left;
+ left->left = heap;
+ GP_SWAP(heap->right, left->right);
+ GP_SWAP(heap->sons, left->sons);
+
+ return left;
+}
+
+static GP_Timer *swap_right(GP_Timer *heap)
+{
+ GP_Timer *right = heap->right;
+
+ heap->right = right->right;
+ right->right = heap;
+ GP_SWAP(heap->left, right->left);
+ GP_SWAP(heap->sons, right->sons);
+
+ return right;
+}
+
+/*
+ * Inserts timer into binary heap. Returns new root for the tree.
+ */
+static GP_Timer *insert(GP_Timer *heap, GP_Timer *timer)
+{
+ if (heap == NULL) {
+ timer->left = NULL;
+ timer->right = NULL;
+ timer->sons = 0;
+ return timer;
+ }
+
+ heap->sons++;
+
+ if (!heap->left || !well_balanced(heap->left->sons) ||
+ (heap->right && heap->left->sons == heap->right->sons)) {
+
+ heap->left = insert(heap->left, timer);
+
+ if (timer_cmp(heap, heap->left))
+ return swap_left(heap);
+ } else {
+
+ heap->right = insert(heap->right, timer);
+
+ if (timer_cmp(heap, heap->right))
+ return swap_right(heap);
+ }
+
+ return heap;
+}
+
+static GP_Timer *rem_last(GP_Timer *heap, GP_Timer **last)
+{
+ if (!heap->left) {
+ *last = heap;
+ return NULL;
+ }
+
+ if (!well_balanced(heap->left->sons) ||
+ !heap->right || (heap->right->sons < heap->left->sons/2))
+ heap->left = rem_last(heap->left, last);
+ else
+ heap->right = rem_last(heap->right, last);
+
+ heap->sons--;
+
+ return heap;
+}
+
+static GP_Timer *buble_down(GP_Timer *heap)
+{
+ GP_Timer *right = heap->right;
+ GP_Timer *left = heap->left;
+
+ /* Make sure we choose smaller one */
+ if (right && left && timer_cmp(right, left))
+ right = NULL;
+
+ if (right && timer_cmp(heap, right)) {
+ swap_right(heap);
+ right->right = buble_down(heap);
+ return right;
+ }
+
+ if (left && timer_cmp(heap, left)) {
+ swap_left(heap);
+ left->left = buble_down(heap);
+ return left;
+ }
+
+ return heap;
+}
+
+static GP_Timer *pop(GP_Timer *heap)
+{
+ GP_Timer *last;
+
+ if (heap == NULL)
+ return NULL;
+
+ heap = rem_last(heap, &last);
+
+ if (!heap)
+ return NULL;
+
+ last->left = heap->left;
+ last->right = heap->right;
+ last->sons = heap->sons;
+
+ return buble_down(last);
+}
+
+void GP_TimerQueueInsert(GP_Timer **heap, uint64_t now, GP_Timer *timer)
+{
+ uint32_t after = timer->period ? timer->period : timer->expires;
+ uint64_t expires = now + after;
+
+ GP_DEBUG(3, "Inserting timer %s (now is %"PRIu64") expires after %"
+ PRIu32" at %"PRIu64, timer->id, now, after, expires);
+
+ timer->expires = expires;
+
+ *heap = insert(*heap, timer);
+}
+
+static GP_Timer *process_top(GP_Timer *heap, uint64_t now)
+{
+ GP_Timer *timer = heap;
+ uint32_t ret, period;
+
+ GP_DEBUG(3, "Timer %s expired at %"PRIu64" now is %"PRIu64,
+ timer->id, timer->expires, now);
+
+ heap = pop(heap);
+
+ period = timer->period;
+ ret = timer->Callback(timer);
+
+ if (period)
+ ret = period;
+
+ if (ret) {
+ timer->expires = now + ret;
+ GP_DEBUG(3, "Rescheduling %stimer %s (now is %"PRIu64") after %"
+ PRIu32" expires at %"PRIu64,
+ period ? "periodic " : "",
+ timer->id, now, ret, timer->expires);
+ heap = insert(heap, timer);
+ }
+
+ return heap;
+}
+
+int GP_TimerQueueProcess(GP_Timer **heap, uint64_t now)
+{
+ int ret = 0;
+
+ for (;;) {
+ if (*heap == NULL)
+ return ret;
+
+ if ((*heap)->expires <= now) {
+ *heap = process_top(*heap, now);
+ ret++;
+ } else {
+ return ret;
+ }
+ }
+}
http://repo.or.cz/w/gfxprim.git/commit/ec6f972853a8eec5ccea7df42077ab674593…
commit ec6f972853a8eec5ccea7df42077ab6745938ccc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Jun 19 23:18:34 2013 +0200
doc: loaders, environment_variables: Update.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/environment_variables.txt b/doc/environment_variables.txt
index dec32e7..26d7209 100644
--- a/doc/environment_variables.txt
+++ b/doc/environment_variables.txt
@@ -4,6 +4,7 @@ Environment Variables
The GFXprim library behavior may be changed by a couple of environment
variables:
+[[GP_THREADS]]
GP_THREADS
~~~~~~~~~~
@@ -21,10 +22,39 @@ bellow:
| >=2 | Use N threads unless the image buffer is too small.
|=============================================================================
+[[GP_DEBUG]]
GP_DEBUG
~~~~~~~~
The 'GP_DEBUG' environment variable may be used to set library debug level.
+See link:debug.html[debug messages] description for more information.
+
The variable and its value is used only once at the time first debug message
is about to be printed.
+The debug level is an integer number, the higher it is the more verbose
+messages are printed. Current the maximum used in GFXprim sources is 4, this
+may change in the future. Use 'GP_DEBUG=10' to enable all debug messages for
+sure.
+
+The output is, by default, written to 'stderr' and will look like:
+------------------------------------------------------------------------------
+1: GP_Debug.c:GP_DebugPrint():67: Using debug level GP_DEBUG=10 from enviroment variable
+1: GP_Debug.c:GP_DebugPrint():71: GFXprim library version 1.0.0-rc0
+1: GP_X11_Conn.h:x11_open():43: Opening X11 display '(null)'
+1: GP_InputDriverX11.c:init_table():154: Initializing X11 KeyCode table
+ 3: GP_InputDriverX11.c:init_table():174: Mapping Key 'Up' KeySym 'Up' (65362) to KeyCode 111
+...
+1: GP_Loader.c:loader_by_filename():222: Loading file by filename extension 'pgm'
+1: GP_Loader.c:loader_by_extension():198: Found loader 'Netpbm portable Graymap'
+1: GP_PNM.c:load_header():244: Have header P2 (ASCII encoded PGM) 24x7 depth=15
+1: GP_Context.c:GP_ContextAlloc():62: Allocating context 24 x 7 - G4
+ 4: GP_X11.c:x11_update_rect():71: Updating rect 222x458-418x479
+ 4: GP_X11.c:x11_update_rect():71: Updating rect 214x458-426x479
+ 2: GP_Blit.c:GP_BlitXYXY_Clipped():129: Blitting 23x6, available 332x244
+ 2: GP_Blit.c:GP_BlitXYXY_Clipped():139: Blitting 0x0->23x6 in 24x7 to 308x236 in 640x480
+ 3: GP_X11.c:x11_set_attributes():225: Setting window caption to 'Spiv ~ test.pgm 1:1.000'
+ 4: GP_X11.c:x11_flip():91: Flipping context
+1: GP_Context.c:GP_ContextFree():102: Freeing context (0x7f5008000b60)
+1: GP_X11_Conn.h:x11_close():72: Closing X11 display
+------------------------------------------------------------------------------
diff --git a/doc/loaders.txt b/doc/loaders.txt
index 907a171..95eb780 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -3,8 +3,8 @@ Context loaders
This part of GFXprim library aims to create API to load and save images
from/to common image file formats.
-Currently we support JPEG, PNG and some PNM images for loading and saving and
-BMP, GIF and PSP for loading.
+Currently we support JPEG, PNG, BPM and PNM images for loading and saving and
+GIF and PSP for loading.
Loaders API
~~~~~~~~~~~
@@ -30,11 +30,11 @@ The possible 'errno' values are:
* 'ENOSYS' if GFXprim wasn't compiled with particular library support
* 'ENOMEM' if returned by +malloc()+
-* 'EIO' invalid image data (wrong signature, header or image data)
+* 'EIO', 'EINVAL' invalid image data (wrong signature, wrong or too short header or image data)
* 'ECANCELED' action canceled by returning non-zero from within a callback
You can get more information about the error condition by turning on GFXprim
-debug messages.
+link:environment_variables.html#GP_DEBUG[debug messages].
Image Loader
~~~~~~~~~~~~
@@ -62,7 +62,7 @@ matching. If image signature is found particular image loader it is called
and the result is returned.
If file extension disagrees with file signature a warning is printed into the
-stdout.
+'stderr'.
[source,c]
-------------------------------------------------------------------------------
@@ -195,8 +195,6 @@ PNG Loader
~~~~~~~~~~
The 'PNG' image support is implemented by the libpng library.
-NOTE: PNG images with alpha channel are not supported yet.
-
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_PNG.h>
@@ -404,7 +402,7 @@ BMP Loader
~~~~~~~~~~
The 'BMP' loading support is nearly complete the only missing features should
-be fancy RGB compressions and RLE support.
+be exotic RGB compressions (RGB101010 for example) and RLE4 support.
[source,c]
-------------------------------------------------------------------------------
@@ -437,8 +435,6 @@ file. 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'.
-Currently this function loads only first image from the 'GIF' container.
-
[source,c]
-------------------------------------------------------------------------------
#include <loaders/GP_BMP.h>
@@ -451,6 +447,17 @@ GP_Context *GP_LoadBMP(const char *src_path, GP_ProgressCallback *callback);
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]
+-------------------------------------------------------------------------------
+#include <loaders/GP_BMP.h>
+/* or */
+#include <GP.h>
+
+int GP_SaveBMP(const GP_Context *src, const char *dst_path,
+ GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Saves 'RGB888' (24 bit RGB) image into BMP bitmap.
[source,c]
-------------------------------------------------------------------------------
@@ -501,7 +508,7 @@ Reads 'PSP' image into a context.
GP_Context *GP_LoadPSP(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Same as above 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 checks for the
signature. Basically this combines both of the calls above.
[source,c]
@@ -515,8 +522,95 @@ int GP_MatchPSP(const void *buf);
Matches a PSP signature.
-PBM, PGM, PPM
-~~~~~~~~~~~~~
+PNM
+~~~
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_PNM.h>
+/* or */
+#include <GP.h>
+
+GP_Context *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback);
+
+GP_Context *GP_LoadPGM(const char *src_path, GP_ProgressCallback *callback);
+
+GP_Context *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback);
+
+GP_Context *GP_LoadPNM(const char *src_path, GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Loads either ASCII or Rawbits (binary) PBM, PGM and PPM.
+
+The PNM can load all of them i.e. PBM, PGM and PPM.
+
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_PNM.h>
+/* or */
+#include <GP.h>
+
+GP_Context *GP_SavePBM(const GP_Context *src, const char *dst_path,
+ GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Saves 'G1' (1 bit grayscale) image into ASCII PBM.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_PNM.h>
+/* or */
+#include <GP.h>
+
+GP_Context *GP_SavePGM(const GP_Context *src, const char *dst_path,
+ GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Saves 'G1', 'G2', 'G4' and 'G8' (1, 2, 4 and 8 bit grayscale) image into ASCII
+PGM.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_PNM.h>
+/* or */
+#include <GP.h>
+
+GP_Context *GP_SavePPM(const GP_Context *src, const char *dst_path,
+ GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Saves 'RGB888' (24 bit RGB) image into ASCII PPM.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_PNM.h>
+/* or */
+#include <GP.h>
+
+GP_Context *GP_SavePNM(const GP_Context *src, const char *dst_path,
+ GP_ProgressCallback *callback);
+-------------------------------------------------------------------------------
+
+Saves 'G1', 'G2', 'G4' and 'G8' (1, 2, 4, 8 bit grayscale) or 'RGB888' (24 bit
+RGB) image into ASCII PNM.
+
+[source,c]
+-------------------------------------------------------------------------------
+#include <loaders/GP_PNM.h>
+/* or */
+#include <GP.h>
+
+int GP_MatchPBM(const void *buf);
+
+int GP_MatchPGM(const void *buf);
+
+int GP_MatchPPM(const void *buf);
+
+int GP_MatchPNM(const void *buf);
+-------------------------------------------------------------------------------
+
+Matches either ASCII or Rawbits (binary) PBM, PGM and PPM.
+
+The PNM matches all of them i.e. PBM, PGM and PPM.
-There is a code do load and write 'PBM', 'PGM' and 'PPM' images too. However
-it's not finished and its API is outdated. Use at your own risk.
http://repo.or.cz/w/gfxprim.git/commit/d9a8b27f7b932cc340d5d0251ab292fe3882…
commit d9a8b27f7b932cc340d5d0251ab292fe388216a7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Jun 19 00:15:03 2013 +0200
libs: loaders: GP_Loader.c: Cleanup.
Get finally rid of the big piece of old code.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c
index fb1bee0..e86c39a 100644
--- a/libs/loaders/GP_Loader.c
+++ b/libs/loaders/GP_Loader.c
@@ -204,10 +204,9 @@ static struct GP_Loader *loader_by_extension(const char *ext)
return NULL;
}
-static struct GP_Loader *loader_by_filename(const char *path)
+static const char *get_ext(const char *path)
{
size_t len = strlen(path);
- const char *ext;
int i;
for (i = len - 1; i >= 0; i--)
@@ -217,7 +216,15 @@ static struct GP_Loader *loader_by_filename(const char *path)
if (path[i] != '.')
return NULL;
- ext = path + i + 1;
+ return path + i + 1;
+}
+
+static struct GP_Loader *loader_by_filename(const char *path)
+{
+ const char *ext = get_ext(path);
+
+ if (ext == NULL)
+ return NULL;
GP_DEBUG(1, "Loading file by filename extension '%s'", ext);
@@ -265,18 +272,15 @@ err0:
GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
{
- int saved_errno;
+ int err;
struct stat st;
if (access(src_path, R_OK)) {
-
- saved_errno = errno;
-
+ err = errno;
GP_DEBUG(1, "Failed to access file '%s' : %s",
src_path, strerror(errno));
- errno = saved_errno;
-
+ errno = err;
return NULL;
}
@@ -322,139 +326,31 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
return NULL;
}
-enum GP_ImageFmt {
- GP_FMT_UNKNOWN,
- GP_FMT_PNG,
- GP_FMT_JPG,
- GP_FMT_BMP,
- GP_FMT_GIF,
- GP_FMT_PSP,
- GP_FMT_PBM,
- GP_FMT_PGM,
- GP_FMT_PPM,
-};
-
-static enum GP_ImageFmt filename_to_fmt(const char *path)
-{
- size_t len = strlen(path);
-
- if (len < 3)
- return GP_FMT_UNKNOWN;
-
- switch (path[len - 1]) {
- /* PNG, JPG, JPEG */
- case 'g':
- case 'G':
- switch (path[len - 2]) {
- case 'n':
- case 'N':
- if (path[len - 3] == 'p' ||
- path[len - 3] == 'P')
- return GP_FMT_PNG;
- break;
- case 'p':
- case 'P':
- if (path[len - 3] == 'j' ||
- path[len - 3] == 'J')
- return GP_FMT_JPG;
- break;
- case 'e':
- case 'E':
- if ((path[len - 3] == 'p' ||
- path[len - 3] == 'P') &&
- (path[len - 4] == 'j' ||
- path[len - 4] == 'J'))
- return GP_FMT_JPG;
- break;
- }
- break;
- /* PPM, PGM, PBM, PNM */
- case 'm':
- case 'M':
- switch (path[len - 2]) {
- case 'b':
- case 'B':
- if (path[len - 3] == 'p' ||
- path[len - 3] == 'P')
- return GP_FMT_PBM;
- break;
- case 'g':
- case 'G':
- if (path[len - 3] == 'p' ||
- path[len - 3] == 'P')
- return GP_FMT_PGM;
- break;
- case 'p':
- case 'P':
- if (path[len - 3] == 'p' ||
- path[len - 3] == 'P')
- return GP_FMT_PPM;
- break;
- }
- break;
- /* BMP, PSP */
- case 'P':
- case 'p':
- switch (path[len - 2]) {
- case 'M':
- case 'm':
- if (path[len - 3] == 'B' ||
- path[len - 3] == 'b')
- return GP_FMT_BMP;
- break;
- case 'S':
- case 's':
- if (path[len - 3] == 'P' ||
- path[len - 3] == 'p')
- return GP_FMT_PSP;
- break;
- }
- break;
- /* GIF */
- case 'F':
- case 'f':
- switch (path[len - 2]) {
- case 'I':
- case 'i':
- if (path[len - 3] == 'G' ||
- path[len - 3] == 'g')
- return GP_FMT_GIF;
- break;
- }
- break;
- }
-
- return GP_FMT_UNKNOWN;
-}
-
int GP_LoadMetaData(const char *src_path, GP_MetaData *data)
{
- int saved_errno;
-
- if (access(src_path, R_OK)) {
-
- saved_errno = errno;
+ const char *ext;
+ int err;
+ if (access(src_path, R_OK)) {
+ err = errno;
GP_DEBUG(1, "Failed to access file '%s' : %s",
src_path, strerror(errno));
-
- errno = saved_errno;
-
+ errno = err;
return 1;
}
- enum GP_ImageFmt fmt = filename_to_fmt(src_path);
+ ext = get_ext(src_path);
- switch (fmt) {
- case GP_FMT_JPG:
+ if (ext == NULL)
+ goto out;
+
+ if (!strcasecmp(ext, "jpg") || !strcasecmp(ext, "jpeg"))
return GP_LoadJPGMetaData(src_path, data);
- case GP_FMT_PNG:
- return GP_LoadPNGMetaData(src_path, data);
- default:
- break;
- }
+ if (!strcasecmp(ext, "png"))
+ return GP_LoadPNGMetaData(src_path, data);
+out:
errno = ENOSYS;
return 1;
}
-----------------------------------------------------------------------
Summary of changes:
build/syms/Backend_symbols.txt | 3 +
build/syms/Input_symbols.txt | 6 +
configure | 2 +-
demos/c_simple/Makefile | 2 +-
demos/c_simple/{debug_handler.c => timers.c} | 55 ++---
demos/spiv/spiv.c | 101 ++------
demos/spiv/spiv_help.c | 2 +-
doc/backends.txt | 19 ++
doc/environment_variables.txt | 30 +++
doc/input.txt | 138 ++++++++++-
doc/loaders.txt | 124 ++++++++--
include/backends/GP_Backend.h | 28 ++-
include/input/GP_Event.h | 7 +-
include/input/GP_Input.h | 12 +-
.../version.c => include/input/GP_TimeStamp.h | 15 +-
.../input/{GP_InputDriverLinux.h => GP_Timer.h} | 87 ++++---
libs/backends/GP_Backend.c | 93 +++++++
libs/backends/GP_BackendVirtual.c | 3 +-
libs/backends/GP_LinuxFB.c | 1 +
libs/backends/GP_SDL.c | 1 +
libs/backends/GP_X11.c | 1 +
libs/input/GP_Event.c | 3 +
.../showimage.c => libs/input/GP_TimeStamp.c | 87 ++++---
libs/input/GP_Timer.c | 263 ++++++++++++++++++++
libs/loaders/GP_Loader.c | 156 ++----------
25 files changed, 878 insertions(+), 361 deletions(-)
copy demos/c_simple/{debug_handler.c => timers.c} (67%)
copy demos/c_simple/version.c => include/input/GP_TimeStamp.h (88%)
copy include/input/{GP_InputDriverLinux.h => GP_Timer.h} (53%)
copy demos/c_simple/showimage.c => libs/input/GP_TimeStamp.c (56%)
create mode 100644 libs/input/GP_Timer.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
18 Jun '13
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 1f9af7dcef377ae227faa484f8f7183583bfefe4 (commit)
via 64874ffe03a6cdf99dc21faaa6ff2243538b78f9 (commit)
from 2dacc1816fc4a182ba2054ec12b2c2b7de223565 (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/1f9af7dcef377ae227faa484f8f7183583bf…
commit 1f9af7dcef377ae227faa484f8f7183583bfefe4
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jun 18 23:35:54 2013 +0200
tests: core: Fix copy & paste error in name.
Fix copy and paste error in Convert Scale testsuite name.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/Convert_Scale.gen.c.t b/tests/core/Convert_Scale.gen.c.t
index f61e9bd..2da4e03 100644
--- a/tests/core/Convert_Scale.gen.c.t
+++ b/tests/core/Convert_Scale.gen.c.t
@@ -93,7 +93,7 @@ static int check_convert_{{ i }}_{{ j }}(void)
%% endfor
const struct tst_suite tst_suite = {
- .suite_name = "Pixel Conversions Testsuite",
+ .suite_name = "Convert Scale Testsuite",
.tests = {
%% for i in range(1, max_in)
%% for j in range(1, max_out)
http://repo.or.cz/w/gfxprim.git/commit/64874ffe03a6cdf99dc21faaa6ff2243538b…
commit 64874ffe03a6cdf99dc21faaa6ff2243538b78f9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jun 18 23:34:17 2013 +0200
loaders: PBM: Add support for Rawbits PBM + tests.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c
index dc4c29c..374bad0 100644
--- a/libs/loaders/GP_PNM.c
+++ b/libs/loaders/GP_PNM.c
@@ -290,7 +290,7 @@ static int get_ascii_int(FILE *f, int *val)
}
/*
- * The PBM has the values inverted
+ * The PBM ASCII has the values inverted
*/
static int load_ascii_g1_inv(FILE *f, GP_Context *ctx, GP_ProgressCallback *cb)
{
@@ -316,6 +316,35 @@ static int load_ascii_g1_inv(FILE *f, GP_Context *ctx, GP_ProgressCallback *cb)
return 0;
}
+//TODO: This is temporary till blit works with bitendian
+#include "core/GP_BitSwap.h"
+
+static int load_raw_g1_inv(FILE *f, GP_Context *ctx, GP_ProgressCallback *cb)
+{
+ uint32_t x, y;
+ uint8_t *addr;
+ int val;
+
+ for (y = 0; y < ctx->h; y++) {
+ for (x = 0; x < ctx->w; x+=8) {
+
+ if ((val = fgetc(f)) == EOF)
+ return EIO;
+
+ addr = GP_PIXEL_ADDR(ctx, x, y);
+ *addr = ~GP_BIT_SWAP_B1(val);
+ }
+
+ if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) {
+ GP_DEBUG(1, "Operation aborted");
+ return ECANCELED;
+ }
+ }
+
+ GP_ProgressCallbackDone(cb);
+ return 0;
+}
+
static int load_ascii_g1(FILE *f, GP_Context *ctx, GP_ProgressCallback *cb)
{
uint32_t x, y;
@@ -572,7 +601,12 @@ static GP_Context *read_bitmap(FILE *f, struct pnm_header *header, int flag,
goto err1;
}
- if ((err = load_ascii_g1_inv(f, ret, callback)))
+ if (header->magic == '1')
+ err = load_ascii_g1_inv(f, ret, callback);
+ else
+ err = load_raw_g1_inv(f, ret, callback);
+
+ if (err)
goto err1;
if (flag)
diff --git a/tests/loaders/PBM.c b/tests/loaders/PBM.c
index 290d5a9..ac87f25 100644
--- a/tests/loaders/PBM.c
+++ b/tests/loaders/PBM.c
@@ -69,6 +69,27 @@ struct testcase white_1x1 = {
.path = "white_1x1.pbm",
};
+struct testcase black_1x1_bin = {
+ .w = 1,
+ .h = 1,
+ .pix = 0,
+ .path = "black_1x1_bin.pbm",
+};
+
+struct testcase black_2x2_bin = {
+ .w = 2,
+ .h = 2,
+ .pix = 0,
+ .path = "black_2x2_bin.pbm",
+};
+
+struct testcase black_3x9_bin = {
+ .w = 3,
+ .h = 9,
+ .pix = 0,
+ .path = "black_3x9_bin.pbm",
+};
+
struct testcase_save_load save_load = {
.w = 100,
.h = 100,
@@ -108,7 +129,25 @@ const struct tst_suite tst_suite = {
.res_path = "data/pbm/valid/black_1x1_4.pbm",
.data = &black_1x1_4,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PBM Load 1x1 (black) Raw",
+ .tst_fn = test_load,
+ .res_path = "data/pbm/valid/black_1x1_bin.pbm",
+ .data = &black_1x1_bin,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PBM Load 2x2 (black) Raw",
+ .tst_fn = test_load,
+ .res_path = "data/pbm/valid/black_2x2_bin.pbm",
+ .data = &black_2x2_bin,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+ {.name = "PBM Load 3x9 (black) Raw",
+ .tst_fn = test_load,
+ .res_path = "data/pbm/valid/black_3x9_bin.pbm",
+ .data = &black_3x9_bin,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
{.name = "PBM Load corrupt",
.tst_fn = test_load_fail,
.res_path = "data/pbm/corrupt/short.pbm",
diff --git a/tests/loaders/data/pbm/valid/black_1x1_bin.pbm b/tests/loaders/data/pbm/valid/black_1x1_bin.pbm
new file mode 100644
index 0000000..238c2bf
--- /dev/null
+++ b/tests/loaders/data/pbm/valid/black_1x1_bin.pbm
@@ -0,0 +1,4 @@
+P4
+# CREATOR: GIMP PNM Filter Version 1.1
+1 1
+
No newline at end of file
diff --git a/tests/loaders/data/pbm/valid/black_2x2_bin.pbm b/tests/loaders/data/pbm/valid/black_2x2_bin.pbm
new file mode 100644
index 0000000..d827eeb
--- /dev/null
+++ b/tests/loaders/data/pbm/valid/black_2x2_bin.pbm
@@ -0,0 +1,4 @@
+P4
+# CREATOR: GIMP PNM Filter Version 1.1
+2 2
+ÀÀ
No newline at end of file
diff --git a/tests/loaders/data/pbm/valid/black_3x9_bin.pbm b/tests/loaders/data/pbm/valid/black_3x9_bin.pbm
new file mode 100644
index 0000000..6e56972
--- /dev/null
+++ b/tests/loaders/data/pbm/valid/black_3x9_bin.pbm
@@ -0,0 +1,4 @@
+P4
+# CREATOR: GIMP PNM Filter Version 1.1
+3 9
+ààààààààà
No newline at end of file
-----------------------------------------------------------------------
Summary of changes:
libs/loaders/GP_PNM.c | 38 ++++++++++++++++++++++-
tests/core/Convert_Scale.gen.c.t | 2 +-
tests/loaders/PBM.c | 39 ++++++++++++++++++++++++
tests/loaders/data/pbm/valid/black_1x1_bin.pbm | 4 ++
tests/loaders/data/pbm/valid/black_2x2_bin.pbm | 4 ++
tests/loaders/data/pbm/valid/black_3x9_bin.pbm | 4 ++
6 files changed, 88 insertions(+), 3 deletions(-)
create mode 100644 tests/loaders/data/pbm/valid/black_1x1_bin.pbm
create mode 100644 tests/loaders/data/pbm/valid/black_2x2_bin.pbm
create mode 100644 tests/loaders/data/pbm/valid/black_3x9_bin.pbm
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
18 Jun '13
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 2dacc1816fc4a182ba2054ec12b2c2b7de223565 (commit)
via ce4f03056c460eee0a3ff777c1a05fe1f927b268 (commit)
via e388310e407c77e1510e5ffa9d7b5653273c5dbe (commit)
from 1969d4407b36047206e4e846594570086f4d5dde (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/2dacc1816fc4a182ba2054ec12b2c2b7de22…
commit 2dacc1816fc4a182ba2054ec12b2c2b7de223565
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jun 18 20:11:36 2013 +0200
loaders: PNM: Implemented GP_SavePPM, GP_SavePNM
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/loaders/GP_PNM.h b/include/loaders/GP_PNM.h
index 917a10d..150ff21 100644
--- a/include/loaders/GP_PNM.h
+++ b/include/loaders/GP_PNM.h
@@ -48,7 +48,7 @@ int GP_SavePGM(const GP_Context *src, const char *dst_path,
*/
GP_Context *GP_LoadPPM(const char *src_path, GP_ProgressCallback *callback);
-int GP_SavePPM(GP_Context *src, const char *dst_path,
+int GP_SavePPM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
/*
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c
index b08e783..dc4c29c 100644
--- a/libs/loaders/GP_PNM.c
+++ b/libs/loaders/GP_PNM.c
@@ -770,7 +770,7 @@ int GP_SavePGM(const GP_Context *src, const char *dst_path,
}
if (fprintf(f, "P2n%u %un%un",
- (unsigned int) src->w, (unsigned int) src->h, depth) < 3)
+ (unsigned int) src->w, (unsigned int) src->h, depth) < 0)
goto err1;
if ((err = save_ascii(f, src, callback)))
@@ -873,9 +873,83 @@ static int write_binary_ppm(FILE *f, GP_Context *src)
return 0;
}
-int GP_SavePPM(GP_Context *src, const char *dst_path,
+static int save_ascii_rgb888(FILE *f, const GP_Context *ctx,
+ GP_ProgressCallback *cb)
+{
+ uint32_t x, y;
+ int ret;
+
+ for (y = 0; y < ctx->h; y++) {
+ for (x = 0; x < ctx->w; x++) {
+ GP_Pixel pix = GP_GetPixel_Raw_24BPP(ctx, x, y);
+
+ ret = fprintf(f, "%u %u %u ",
+ GP_Pixel_GET_R_RGB888(pix),
+ GP_Pixel_GET_G_RGB888(pix),
+ GP_Pixel_GET_B_RGB888(pix));
+
+ if (ret < 0)
+ return errno;
+ }
+
+ if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) {
+ GP_DEBUG(1, "Operation aborted");
+ return ECANCELED;
+ }
+
+ if (fprintf(f, "n") < 0)
+ return errno;
+ }
+
+ GP_ProgressCallbackDone(cb);
+ return 0;
+}
+
+int GP_SavePPM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
+ FILE *f;
+ int err = EIO;
+
+ GP_DEBUG(1, "Saving context %ux%u %s to '%s'",
+ src->w, src->h, GP_PixelTypeName(src->pixel_type), dst_path);
+
+ if (src->pixel_type != GP_PIXEL_RGB888) {
+ GP_DEBUG(1, "Invalid pixel type '%s'",
+ GP_PixelTypeName(src->pixel_type));
+ errno = EINVAL;
+ return 1;
+ }
+
+ f = fopen(dst_path, "w");
+
+ if (f == NULL) {
+ err = errno;
+ GP_DEBUG(1, "Failed to open file '%s': %s",
+ dst_path, strerror(errno));
+ goto err0;
+ }
+
+ if (fprintf(f, "P3n%u %un255n",
+ (unsigned int) src->w, (unsigned int) src->h) < 0)
+ goto err1;
+
+ if ((err = save_ascii_rgb888(f, src, callback)))
+ goto err1;
+
+ if (fclose(f)) {
+ err = errno;
+ GP_DEBUG(1, "Failed to close file '%s': %s",
+ dst_path, strerror(errno));
+ goto err0;
+ }
+
+ return 0;
+err1:
+ fclose(f);
+err0:
+ errno = err;
+ return 1;
errno = ENOSYS;
return -1;
}
@@ -920,6 +994,16 @@ err0:
int GP_SavePNM(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
- errno = ENOSYS;
- return -1;
+ switch (src->pixel_type) {
+ case GP_PIXEL_G1:
+ case GP_PIXEL_G2:
+ case GP_PIXEL_G4:
+ case GP_PIXEL_G8:
+ return GP_SavePGM(src, dst_path, callback);
+ case GP_PIXEL_RGB888:
+ return GP_SavePPM(src, dst_path, callback);
+ default:
+ errno = EINVAL;
+ return 1;
+ }
}
http://repo.or.cz/w/gfxprim.git/commit/ce4f03056c460eee0a3ff777c1a05fe1f927…
commit ce4f03056c460eee0a3ff777c1a05fe1f927b268
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jun 18 19:38:36 2013 +0200
loaders: PNM: Fix a few issues found by tests.
* The fprintf() returns number of bytes not
number of converted formatting chars, ouch.
* Fix errno propagation from read_header()
* The PBM has inverted the black and white
but the PGM is normal again.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c
index 1104f8f..b08e783 100644
--- a/libs/loaders/GP_PNM.c
+++ b/libs/loaders/GP_PNM.c
@@ -289,7 +289,10 @@ static int get_ascii_int(FILE *f, int *val)
}
}
-static int load_ascii_g1(FILE *f, GP_Context *ctx, GP_ProgressCallback *cb)
+/*
+ * The PBM has the values inverted
+ */
+static int load_ascii_g1_inv(FILE *f, GP_Context *ctx, GP_ProgressCallback *cb)
{
uint32_t x, y;
int val, err;
@@ -313,6 +316,35 @@ static int load_ascii_g1(FILE *f, GP_Context *ctx, GP_ProgressCallback *cb)
return 0;
}
+static int load_ascii_g1(FILE *f, GP_Context *ctx, GP_ProgressCallback *cb)
+{
+ uint32_t x, y;
+ int val, err;
+
+ for (y = 0; y < ctx->h; y++) {
+ for (x = 0; x < ctx->w; x++) {
+
+ if ((err = get_ascii_int(f, &val)))
+ return err;
+
+ if (val > 1) {
+ GP_WARN("Value too large for 2BPP (%i)", val);
+ val = 1;
+ }
+
+ GP_PutPixel_Raw_1BPP_LE(ctx, x, y, val);
+ }
+
+ if (GP_ProgressCallbackReport(cb, y, ctx->h, ctx->w)) {
+ GP_DEBUG(1, "Operation aborted");
+ return ECANCELED;
+ }
+ }
+
+ GP_ProgressCallbackDone(cb);
+ return 0;
+}
+
static int load_ascii_g2(FILE *f, GP_Context *ctx, GP_ProgressCallback *cb)
{
uint32_t x, y;
@@ -484,7 +516,7 @@ static int save_ascii(FILE *f, const GP_Context *ctx, GP_ProgressCallback *cb)
for (y = 0; y < ctx->h; y++) {
for (x = 0; x < ctx->w; x++) {
- if (fprintf(f, "%i ", GP_GetPixel_Raw(ctx, x, y)) != 1) {
+ if (fprintf(f, "%i ", GP_GetPixel_Raw(ctx, x, y)) < 0) {
err = errno;
GP_DEBUG(1, "Failed to write data");
return err;
@@ -514,6 +546,7 @@ static FILE *read_header(const char *src_path, struct pnm_header *header)
if ((err = load_header(f, header))) {
fclose(f);
+ errno = err;
return NULL;
}
@@ -539,7 +572,7 @@ static GP_Context *read_bitmap(FILE *f, struct pnm_header *header, int flag,
goto err1;
}
- if ((err = load_ascii_g1(f, ret, callback)))
+ if ((err = load_ascii_g1_inv(f, ret, callback)))
goto err1;
if (flag)
@@ -574,7 +607,12 @@ int GP_SavePBM(const GP_Context *src, const char *dst_path,
{
FILE *f;
+ GP_DEBUG(1, "Saving context %ux%u %s to '%s'",
+ src->w, src->h, GP_PixelTypeName(src->pixel_type), dst_path);
+
if (src->pixel_type != GP_PIXEL_G1) {
+ GP_DEBUG(1, "Invalid pixel type '%s'",
+ GP_PixelTypeName(src->pixel_type));
errno = EINVAL;
return 1;
}
@@ -584,8 +622,8 @@ int GP_SavePBM(const GP_Context *src, const char *dst_path,
if (f == NULL)
return 1;
- if (fprintf(f, "P1n%u %u",
- (unsigned int) src->w, (unsigned int) src->h) < 2)
+ if (fprintf(f, "P1n%u %un",
+ (unsigned int) src->w, (unsigned int) src->h) < 0)
goto err;
if (save_ascii(f, src, callback))
@@ -712,6 +750,9 @@ int GP_SavePGM(const GP_Context *src, const char *dst_path,
int depth;
int err = EIO;
+ GP_DEBUG(1, "Saving context %ux%u %s to '%s'",
+ src->w, src->h, GP_PixelTypeName(src->pixel_type), dst_path);
+
if ((depth = pixel_to_depth(src->pixel_type)) == -1) {
GP_DEBUG(1, "Invalid pixel type '%s'",
GP_PixelTypeName(src->pixel_type));
@@ -728,7 +769,7 @@ int GP_SavePGM(const GP_Context *src, const char *dst_path,
goto err0;
}
- if (fprintf(f, "P2n%u %un%un# Generated by gfxprimn",
+ if (fprintf(f, "P2n%u %un%un",
(unsigned int) src->w, (unsigned int) src->h, depth) < 3)
goto err1;
http://repo.or.cz/w/gfxprim.git/commit/e388310e407c77e1510e5ffa9d7b5653273c…
commit e388310e407c77e1510e5ffa9d7b5653273c5dbe
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Jun 18 18:04:45 2013 +0200
tests: loaders: PBM, PGM, PPM, more tests.
Add more tests for the PNM image loaders.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/loaders/PBM.c b/tests/loaders/Loader.h
similarity index 56%
copy from tests/loaders/PBM.c
copy to tests/loaders/Loader.h
index 2c76792..d8a916d 100644
--- a/tests/loaders/PBM.c
+++ b/tests/loaders/Loader.h
@@ -20,16 +20,6 @@
* *
*****************************************************************************/
-#include <string.h>
-#include <errno.h>
-#include <sys/stat.h>
-
-#include <core/GP_Context.h>
-#include <core/GP_GetPutPixel.h>
-#include <loaders/GP_Loaders.h>
-
-#include "tst_test.h"
-
struct testcase {
GP_Size w;
GP_Size h;
@@ -37,14 +27,14 @@ struct testcase {
char *path;
};
-static int test_load_PBM(struct testcase *test)
+static int test_load(struct testcase *test)
{
GP_Context *img;
unsigned int x, y, err = 0;
errno = 0;
- img = GP_LoadPBM(test->path, NULL);
+ img = LOAD(test->path, NULL);
if (img == NULL) {
switch (errno) {
@@ -86,13 +76,13 @@ static int test_load_PBM(struct testcase *test)
return TST_SUCCESS;
}
-static int test_load_fail_PBM(const char *path)
+static int test_load_fail(const char *path)
{
GP_Context *img;
errno = 0;
- img = GP_LoadPBM(path, NULL);
+ img = LOAD(path, NULL);
if (img != NULL) {
tst_msg("Succeeded unexpectedly");
@@ -104,93 +94,86 @@ static int test_load_fail_PBM(const char *path)
case ENOSYS:
tst_msg("Not Implemented");
return TST_SKIPPED;
+ case 0:
+ tst_msg("Load failed and errno == 0");
+ return TST_FAILED;
default:
tst_msg("Got %s", strerror(errno));
return TST_SUCCESS;
}
}
-struct testcase black_1x1_1 = {
- .w = 1,
- .h = 1,
- .pix = 0,
- .path = "black_1x1_1.pbm",
+/*
+ * Saves and loads image using the SAVE and LOAD functions
+ * and compares the results.
+ */
+struct testcase_save_load {
+ GP_PixelType pixel_type;
+ GP_Size w, h;
};
-struct testcase black_1x1_2 = {
- .w = 1,
- .h = 1,
- .pix = 0,
- .path = "black_1x1_2.pbm",
-};
+static int test_save_load(struct testcase_save_load *test)
+{
+ GP_Context *img, *img2;
-struct testcase black_1x1_3 = {
- .w = 1,
- .h = 1,
- .pix = 0,
- .path = "black_1x1_3.pbm",
-};
+ img = GP_ContextAlloc(test->w, test->h, test->pixel_type);
-struct testcase black_1x1_4 = {
- .w = 1,
- .h = 1,
- .pix = 0,
- .path = "black_1x1_4.pbm",
-};
+ if (img == NULL) {
+ tst_msg("Failed to allocate context %ux%u %s",
+ test->w, test->h, GP_PixelTypeName(test->pixel_type));
+ return TST_FAILED;
+ }
-struct testcase white_1x1 = {
- .w = 1,
- .h = 1,
- .pix = 1,
- .path = "white_1x1.pbm",
-};
+ errno = 0;
+
+ if (SAVE(img, "testfile", NULL)) {
+ if (errno == ENOSYS) {
+ tst_msg("Not implemented");
+ return TST_SKIPPED;
+ }
-const struct tst_suite tst_suite = {
- .suite_name = "PBM",
- .tests = {
- {.name = "PBM Load 1x1 (black)",
- .tst_fn = test_load_PBM,
- //TODO: Add copy to to res path
- .res_path = "data/pbm/valid/black_1x1_1.pbm",
- .data = &black_1x1_1,
- .flags = TST_TMPDIR | TST_CHECK_MALLOC},
-
- {.name = "PBM Load 1x1 (white)",
- .tst_fn = test_load_PBM,
- .res_path = "data/pbm/valid/white_1x1.pbm",
- .data = &white_1x1,
- .flags = TST_TMPDIR | TST_CHECK_MALLOC},
-
- {.name = "PBM Load 1x1 +comments",
- .tst_fn = test_load_PBM,
- .res_path = "data/pbm/valid/black_1x1_2.pbm",
- .data = &black_1x1_2,
- .flags = TST_TMPDIR | TST_CHECK_MALLOC},
-
- {.name = "PBM Load 1x1 +comments +whitespaces",
- .tst_fn = test_load_PBM,
- .res_path = "data/pbm/valid/black_1x1_3.pbm",
- .data = &black_1x1_3,
- .flags = TST_TMPDIR | TST_CHECK_MALLOC},
-
- {.name = "PBM Load 1x1 (invalid loadable)",
- .tst_fn = test_load_PBM,
- .res_path = "data/pbm/valid/black_1x1_4.pbm",
- .data = &black_1x1_4,
- .flags = TST_TMPDIR | TST_CHECK_MALLOC},
-
- {.name = "PBM Load corrupt",
- .tst_fn = test_load_fail_PBM,
- .res_path = "data/pbm/corrupt/short.pbm",
- .data = "short.pbm",
- .flags = TST_TMPDIR | TST_CHECK_MALLOC},
-
- {.name = "PBM Load empty",
- .tst_fn = test_load_fail_PBM,
- .res_path = "data/pbm/corrupt/empty.pbm",
- .data = "empty.pbm",
- .flags = TST_TMPDIR | TST_CHECK_MALLOC},
-
- {.name = NULL},
+ tst_msg("Failed to save context %ux%u %s: %s",
+ test->w, test->h, GP_PixelTypeName(test->pixel_type),
+ strerror(errno));
+ return TST_FAILED;
}
-};
+
+
+ img2 = LOAD("testfile", NULL);
+
+ if (img2 == NULL) {
+ switch (errno) {
+ case ENOSYS:
+ tst_msg("Not Implemented");
+ GP_ContextFree(img);
+ return TST_SKIPPED;
+ default:
+ tst_msg("Got %s", strerror(errno));
+ GP_ContextFree(img);
+ return TST_FAILED;
+ }
+ }
+
+ if (img->w != img2->w || img->h != img2->h) {
+ tst_msg("Source size %ux%u and loaded size %ux%u differs",
+ img->w, img->h, img2->w, img2->h);
+ GP_ContextFree(img);
+ GP_ContextFree(img2);
+ return TST_FAILED;
+ }
+
+ if (img->pixel_type != img2->pixel_type) {
+ GP_ContextFree(img);
+ GP_ContextFree(img2);
+ tst_msg("Source pixel type %s and loaded type %s differs",
+ GP_PixelTypeName(img->pixel_type),
+ GP_PixelTypeName(img2->pixel_type));
+ }
+
+ GP_ContextFree(img);
+ GP_ContextFree(img2);
+
+ //TODO: Check pixels
+
+ return TST_SUCCESS;
+}
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile
index 304e956..1d8cc2e 100644
--- a/tests/loaders/Makefile
+++ b/tests/loaders/Makefile
@@ -3,7 +3,7 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-APPS=loaders_suite PNG PBM
+APPS=loaders_suite PNG PBM PGM PPM
include ../tests.mk
diff --git a/tests/loaders/PBM.c b/tests/loaders/PBM.c
index 2c76792..290d5a9 100644
--- a/tests/loaders/PBM.c
+++ b/tests/loaders/PBM.c
@@ -30,85 +30,9 @@
#include "tst_test.h"
-struct testcase {
- GP_Size w;
- GP_Size h;
- GP_Pixel pix;
- char *path;
-};
-
-static int test_load_PBM(struct testcase *test)
-{
- GP_Context *img;
- unsigned int x, y, err = 0;
-
- errno = 0;
-
- img = GP_LoadPBM(test->path, NULL);
-
- if (img == NULL) {
- switch (errno) {
- case ENOSYS:
- tst_msg("Not Implemented");
- return TST_SKIPPED;
- default:
- tst_msg("Got %s", strerror(errno));
- return TST_FAILED;
- }
- }
-
- if (img->w != test->w || img->h != test->h) {
- tst_msg("Invalid image size have %ux%u expected %ux%u",
- img->w, img->h, test->w, test->h);
- GP_ContextFree(img);
- return TST_FAILED;
- }
-
- for (x = 0; x < img->w; x++) {
- for (y = 0; y < img->h; y++) {
-
- GP_Pixel pix = GP_GetPixel(img, x, y);
-
- if (pix != test->pix) {
- if (err < 5)
- tst_msg("%08x instead of %08x (%ux%u)",
- pix, test->pix, x, y);
- err++;
- }
- }
- }
-
- GP_ContextFree(img);
-
- if (err)
- return TST_FAILED;
-
- return TST_SUCCESS;
-}
-
-static int test_load_fail_PBM(const char *path)
-{
- GP_Context *img;
-
- errno = 0;
-
- img = GP_LoadPBM(path, NULL);
-
- if (img != NULL) {
- tst_msg("Succeeded unexpectedly");
- GP_ContextFree(img);
- return TST_FAILED;
- }
-
- switch (errno) {
- case ENOSYS:
- tst_msg("Not Implemented");
- return TST_SKIPPED;
- default:
- tst_msg("Got %s", strerror(errno));
- return TST_SUCCESS;
- }
-}
+#define LOAD GP_LoadPBM
+#define SAVE GP_SavePBM
+#include "Loader.h"
struct testcase black_1x1_1 = {
.w = 1,
@@ -145,51 +69,68 @@ struct testcase white_1x1 = {
.path = "white_1x1.pbm",
};
+struct testcase_save_load save_load = {
+ .w = 100,
+ .h = 100,
+ .pixel_type = GP_PIXEL_G1,
+};
+
const struct tst_suite tst_suite = {
.suite_name = "PBM",
.tests = {
{.name = "PBM Load 1x1 (black)",
- .tst_fn = test_load_PBM,
+ .tst_fn = test_load,
//TODO: Add copy to to res path
.res_path = "data/pbm/valid/black_1x1_1.pbm",
.data = &black_1x1_1,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = "PBM Load 1x1 (white)",
- .tst_fn = test_load_PBM,
+ .tst_fn = test_load,
.res_path = "data/pbm/valid/white_1x1.pbm",
.data = &white_1x1,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = "PBM Load 1x1 +comments",
- .tst_fn = test_load_PBM,
+ .tst_fn = test_load,
.res_path = "data/pbm/valid/black_1x1_2.pbm",
.data = &black_1x1_2,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = "PBM Load 1x1 +comments +whitespaces",
- .tst_fn = test_load_PBM,
+ .tst_fn = test_load,
.res_path = "data/pbm/valid/black_1x1_3.pbm",
.data = &black_1x1_3,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = "PBM Load 1x1 (invalid loadable)",
- .tst_fn = test_load_PBM,
+ .tst_fn = test_load,
.res_path = "data/pbm/valid/black_1x1_4.pbm",
.data = &black_1x1_4,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = "PBM Load corrupt",
- .tst_fn = test_load_fail_PBM,
+ .tst_fn = test_load_fail,
.res_path = "data/pbm/corrupt/short.pbm",
.data = "short.pbm",
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
+ {.name = "PBM Load wrong header",
+ .tst_fn = test_load_fail,
+ .res_path = "data/pbm/corrupt/wrong_header.pbm",
+ .data = "wrong_header.pbm",
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
{.name = "PBM Load empty",
- .tst_fn = test_load_fail_PBM,
+ .tst_fn = test_load_fail,
.res_path = "data/pbm/corrupt/empty.pbm",
.data = "empty.pbm",
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PBM Save Load",
+ .tst_fn = test_save_load,
+ .data = &save_load,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = NULL},
}
diff --git a/tests/loaders/PGM.c b/tests/loaders/PGM.c
new file mode 100644
index 0000000..f914a8e
--- /dev/null
+++ b/tests/loaders/PGM.c
@@ -0,0 +1,150 @@
+/*****************************************************************************
+ * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include <core/GP_Context.h>
+#include <core/GP_GetPutPixel.h>
+#include <loaders/GP_Loaders.h>
+
+#include "tst_test.h"
+
+#define LOAD GP_LoadPGM
+#define SAVE GP_SavePGM
+#include "Loader.h"
+
+struct testcase black_1x1_1bpp = {
+ .w = 1,
+ .h = 1,
+ .pix = 0,
+ .path = "black_1x1_1bpp.pgm",
+};
+
+struct testcase black_1x1_2bpp = {
+ .w = 1,
+ .h = 1,
+ .pix = 0,
+ .path = "black_1x1_2bpp.pgm",
+};
+
+struct testcase black_1x1_4bpp = {
+ .w = 1,
+ .h = 1,
+ .pix = 0,
+ .path = "black_1x1_4bpp.pgm",
+};
+
+struct testcase black_1x1_8bpp = {
+ .w = 1,
+ .h = 1,
+ .pix = 0,
+ .path = "black_1x1_8bpp.pgm",
+};
+
+struct testcase_save_load save_load_1bpp = {
+ .w = 100,
+ .h = 100,
+ .pixel_type = GP_PIXEL_G1,
+};
+
+struct testcase_save_load save_load_2bpp = {
+ .w = 100,
+ .h = 100,
+ .pixel_type = GP_PIXEL_G2,
+};
+
+struct testcase_save_load save_load_4bpp = {
+ .w = 100,
+ .h = 100,
+ .pixel_type = GP_PIXEL_G4,
+};
+
+struct testcase_save_load save_load_8bpp = {
+ .w = 100,
+ .h = 100,
+ .pixel_type = GP_PIXEL_G8,
+};
+
+const struct tst_suite tst_suite = {
+ .suite_name = "PGM",
+ .tests = {
+ {.name = "PGM Load 1x1 1bpp (black)",
+ .tst_fn = test_load,
+ .res_path = "data/pgm/valid/black_1x1_1bpp.pgm",
+ .data = &black_1x1_1bpp,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PGM Load 1x1 2bpp (black)",
+ .tst_fn = test_load,
+ .res_path = "data/pgm/valid/black_1x1_2bpp.pgm",
+ .data = &black_1x1_2bpp,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PGM Load 1x1 4bpp (black)",
+ .tst_fn = test_load,
+ .res_path = "data/pgm/valid/black_1x1_4bpp.pgm",
+ .data = &black_1x1_4bpp,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PGM Load 1x1 8bpp (black)",
+ .tst_fn = test_load,
+ .res_path = "data/pgm/valid/black_1x1_8bpp.pgm",
+ .data = &black_1x1_8bpp,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PGM Save Load 1bpp",
+ .tst_fn = test_save_load,
+ .data = &save_load_1bpp,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PGM Save Load 2bpp",
+ .tst_fn = test_save_load,
+ .data = &save_load_2bpp,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PGM Save Load 4bpp",
+ .tst_fn = test_save_load,
+ .data = &save_load_4bpp,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PGM Save Load 8bpp",
+ .tst_fn = test_save_load,
+ .data = &save_load_8bpp,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PGM Load wrong header",
+ .tst_fn = test_load_fail,
+ .res_path = "data/pgm/corrupt/wrong_header.pgm",
+ .data = "wrong_header.pgm",
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PGM Load incomplete",
+ .tst_fn = test_load_fail,
+ .res_path = "data/pgm/corrupt/incomplete.pgm",
+ .data = "incomplete.pgm",
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = NULL},
+ }
+};
diff --git a/tests/loaders/PPM.c b/tests/loaders/PPM.c
new file mode 100644
index 0000000..b4790cf
--- /dev/null
+++ b/tests/loaders/PPM.c
@@ -0,0 +1,78 @@
+/*****************************************************************************
+ * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+
+#include <core/GP_Context.h>
+#include <core/GP_GetPutPixel.h>
+#include <loaders/GP_Loaders.h>
+
+#include "tst_test.h"
+
+#define LOAD GP_LoadPPM
+#define SAVE GP_SavePPM
+#include "Loader.h"
+
+struct testcase black_1x1 = {
+ .w = 1,
+ .h = 1,
+ .pix = 0,
+ .path = "black_1x1.ppm",
+};
+
+struct testcase_save_load save_load = {
+ .w = 100,
+ .h = 100,
+ .pixel_type = GP_PIXEL_RGB888,
+};
+
+const struct tst_suite tst_suite = {
+ .suite_name = "PPM",
+ .tests = {
+ {.name = "PPM Load 1x1 (black)",
+ .tst_fn = test_load,
+ .res_path = "data/ppm/valid/black_1x1.ppm",
+ .data = &black_1x1,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PPM Save Load",
+ .tst_fn = test_save_load,
+ .data = &save_load,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PPM Load wrong header",
+ .tst_fn = test_load_fail,
+ .res_path = "data/ppm/corrupt/wrong_header.ppm",
+ .data = "wrong_header.ppm",
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = "PPM Load incomplete",
+ .tst_fn = test_load_fail,
+ .res_path = "data/ppm/corrupt/incomplete.ppm",
+ .data = "incomplete.ppm",
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
+ {.name = NULL},
+ }
+};
diff --git a/tests/loaders/data/pbm/corrupt/wrong_header.pbm b/tests/loaders/data/pbm/corrupt/wrong_header.pbm
new file mode 100644
index 0000000..19a875f
--- /dev/null
+++ b/tests/loaders/data/pbm/corrupt/wrong_header.pbm
@@ -0,0 +1,2 @@
+P1
+10 A
diff --git a/tests/loaders/data/pgm/corrupt/incomplete.pgm b/tests/loaders/data/pgm/corrupt/incomplete.pgm
new file mode 100644
index 0000000..03fa100
--- /dev/null
+++ b/tests/loaders/data/pgm/corrupt/incomplete.pgm
@@ -0,0 +1,4 @@
+P2
+1 3
+15
+0 0
diff --git a/tests/loaders/data/pgm/corrupt/wrong_header.pgm b/tests/loaders/data/pgm/corrupt/wrong_header.pgm
new file mode 100644
index 0000000..5dab55e
--- /dev/null
+++ b/tests/loaders/data/pgm/corrupt/wrong_header.pgm
@@ -0,0 +1,2 @@
+P2
+1 3
diff --git a/tests/loaders/data/pgm/valid/black_1x1_1bpp.pgm b/tests/loaders/data/pgm/valid/black_1x1_1bpp.pgm
new file mode 100644
index 0000000..ff6cb6d
--- /dev/null
+++ b/tests/loaders/data/pgm/valid/black_1x1_1bpp.pgm
@@ -0,0 +1,4 @@
+P2
+1 1
+1
+0
diff --git a/tests/loaders/data/pgm/valid/black_1x1_2bpp.pgm b/tests/loaders/data/pgm/valid/black_1x1_2bpp.pgm
new file mode 100644
index 0000000..41adfe6
--- /dev/null
+++ b/tests/loaders/data/pgm/valid/black_1x1_2bpp.pgm
@@ -0,0 +1,4 @@
+P2
+1 1
+3
+0
diff --git a/tests/loaders/data/pgm/valid/black_1x1_4bpp.pgm b/tests/loaders/data/pgm/valid/black_1x1_4bpp.pgm
new file mode 100644
index 0000000..6fceab5
--- /dev/null
+++ b/tests/loaders/data/pgm/valid/black_1x1_4bpp.pgm
@@ -0,0 +1,4 @@
+P2
+1 1
+15
+0
diff --git a/tests/loaders/data/pgm/valid/black_1x1_8bpp.pgm b/tests/loaders/data/pgm/valid/black_1x1_8bpp.pgm
new file mode 100644
index 0000000..d999143
--- /dev/null
+++ b/tests/loaders/data/pgm/valid/black_1x1_8bpp.pgm
@@ -0,0 +1,4 @@
+P2
+1 1
+255
+0
diff --git a/tests/loaders/data/ppm/corrupt/incomplete.ppm b/tests/loaders/data/ppm/corrupt/incomplete.ppm
new file mode 100644
index 0000000..0903994
--- /dev/null
+++ b/tests/loaders/data/ppm/corrupt/incomplete.ppm
@@ -0,0 +1,4 @@
+P3
+3 2
+255
+0
diff --git a/tests/loaders/data/ppm/corrupt/wrong_header.ppm b/tests/loaders/data/ppm/corrupt/wrong_header.ppm
new file mode 100644
index 0000000..e55f93a
--- /dev/null
+++ b/tests/loaders/data/ppm/corrupt/wrong_header.ppm
@@ -0,0 +1,3 @@
+P3
+2 3
+#
diff --git a/tests/loaders/data/ppm/valid/black_1x1.ppm b/tests/loaders/data/ppm/valid/black_1x1.ppm
new file mode 100644
index 0000000..ca9e908
--- /dev/null
+++ b/tests/loaders/data/ppm/valid/black_1x1.ppm
@@ -0,0 +1,4 @@
+P3
+1 1
+255
+0 0 0
diff --git a/tests/loaders/test_list.txt b/tests/loaders/test_list.txt
index 8a20a1d..1593ff6 100644
--- a/tests/loaders/test_list.txt
+++ b/tests/loaders/test_list.txt
@@ -2,3 +2,5 @@
loaders_suite
PNG
PBM
+PGM
+PPM
-----------------------------------------------------------------------
Summary of changes:
include/loaders/GP_PNM.h | 2 +-
libs/loaders/GP_PNM.c | 145 ++++++++++++++++--
tests/loaders/{PBM.c => Loader.h} | 165 +++++++++-----------
tests/loaders/Makefile | 2 +-
tests/loaders/PBM.c | 113 ++++----------
tests/loaders/PGM.c | 150 ++++++++++++++++++
tests/{core/Pixel.c => loaders/PPM.c} | 80 +++++-----
tests/loaders/data/pbm/corrupt/wrong_header.pbm | 2 +
tests/loaders/data/pgm/corrupt/incomplete.pgm | 4 +
tests/loaders/data/pgm/corrupt/wrong_header.pgm | 2 +
.../valid/black_1x1_1bpp.pgm} | 3 +-
.../white_1x1.pbm => pgm/valid/black_1x1_2bpp.pgm} | 3 +-
.../white_1x1.pbm => pgm/valid/black_1x1_4bpp.pgm} | 3 +-
tests/loaders/data/pgm/valid/black_1x1_8bpp.pgm | 4 +
tests/loaders/data/ppm/corrupt/incomplete.ppm | 4 +
tests/loaders/data/ppm/corrupt/wrong_header.ppm | 3 +
tests/loaders/data/ppm/valid/black_1x1.ppm | 4 +
tests/loaders/test_list.txt | 2 +
18 files changed, 462 insertions(+), 229 deletions(-)
copy tests/loaders/{PBM.c => Loader.h} (56%)
create mode 100644 tests/loaders/PGM.c
copy tests/{core/Pixel.c => loaders/PPM.c} (62%)
create mode 100644 tests/loaders/data/pbm/corrupt/wrong_header.pbm
create mode 100644 tests/loaders/data/pgm/corrupt/incomplete.pgm
create mode 100644 tests/loaders/data/pgm/corrupt/wrong_header.pgm
copy tests/loaders/data/{pbm/valid/black_1x1_1.pbm => pgm/valid/black_1x1_1bpp.pgm} (54%)
copy tests/loaders/data/{pbm/valid/white_1x1.pbm => pgm/valid/black_1x1_2bpp.pgm} (54%)
copy tests/loaders/data/{pbm/valid/white_1x1.pbm => pgm/valid/black_1x1_4bpp.pgm} (50%)
create mode 100644 tests/loaders/data/pgm/valid/black_1x1_8bpp.pgm
create mode 100644 tests/loaders/data/ppm/corrupt/incomplete.ppm
create mode 100644 tests/loaders/data/ppm/corrupt/wrong_header.ppm
create mode 100644 tests/loaders/data/ppm/valid/black_1x1.ppm
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