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
April 2014
- 1 participants
- 3 discussions
25 Apr '14
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 ac5ab1fc384840bd63b923cd8d02043176676d01 (commit)
from 34edb5f159d98fccc62cfdcd268f51109320dafd (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/ac5ab1fc384840bd63b923cd8d0204317667…
commit ac5ab1fc384840bd63b923cd8d02043176676d01
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Apr 25 23:37:17 2014 +0200
spiv: Fix slow blit for images with alpha channel
The pattern_fill() function that draws chessboard like pattern before
images with alpha channel are blitted was drawing the pattern pixel by
pixel, which is quite slow and caused dropped events when moving such
image in the spiv window.
This commit optimizes the function a bit (about then times faster) which
fixes the problem.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index 6d26c600..d4785e0a 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -171,26 +171,21 @@ static GP_Context *load_image(int elevate)
static void pattern_fill(GP_Context *ctx, unsigned int x0, unsigned int y0,
unsigned int w, unsigned int h)
{
- unsigned int x, y;
+ unsigned int x, y, i, j = 0;
+ GP_Pixel col[2];
- GP_Pixel g1 = GP_RGBToContextPixel(0x64, 0x64, 0x64, ctx);
- GP_Pixel g2 = GP_RGBToContextPixel(0x80, 0x80, 0x80, ctx);
+ col[0] = GP_RGBToContextPixel(0x64, 0x64, 0x64, ctx);
+ col[1] = GP_RGBToContextPixel(0x80, 0x80, 0x80, ctx);
- unsigned int wm = w/10 < 10 ? 10 : w/10;
- unsigned int hm = h/10 < 10 ? 10 : h/10;
- unsigned int wt = w/20 < 5 ? 5 : w/20;
- unsigned int ht = h/20 < 5 ? 5 : h/20;
+ unsigned int wm = w/20 < 5 ? 5 : w/20;
+ unsigned int hm = h/20 < 5 ? 5 : h/20;
- for (y = 0; y < h; y++) {
- for (x = 0; x < w; x++) {
- GP_Pixel pix;
-
- if ((x % wm < wt) ^ (y % hm < ht))
- pix = g1;
- else
- pix = g2;
-
- GP_PutPixel(ctx, x0 + x, y0 + y, pix);
+ for (y = 0; y < h; y += hm) {
+ i = j;
+ j = !j;
+ for (x = 0; x < w; x += wm) {
+ GP_FillRectXYWH(ctx, x0 + x, y0 + y, wm, hm, col[i]);
+ i = !i;
}
}
}
@@ -323,7 +318,6 @@ static void update_display(struct loader_params *params, GP_Context *img,
} else {
if (GP_PixelHasFlags(img->pixel_type, GP_PIXEL_HAS_ALPHA))
pattern_fill(context, cx, cy, img->w, img->h);
-
GP_Blit_Clipped(img, 0, 0, img->w, img->h, context, cx, cy);
}
-----------------------------------------------------------------------
Summary of changes:
demos/spiv/spiv.c | 30 ++++++++++++------------------
1 files changed, 12 insertions(+), 18 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
25 Apr '14
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 34edb5f159d98fccc62cfdcd268f51109320dafd (commit)
from e667b1019551a0036d4ff8e7852bc51e2336440c (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/34edb5f159d98fccc62cfdcd268f51109320…
commit 34edb5f159d98fccc62cfdcd268f51109320dafd
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Apr 25 22:39:02 2014 +0200
loaders: PNG: Enable 8bit grayscale with alpha.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 770bb123..0ea37379 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -145,6 +145,13 @@ GP_Context *GP_ReadPNG(GP_IO *io, GP_ProgressCallback *callback)
#endif
}
break;
+ case PNG_COLOR_TYPE_GRAY | PNG_COLOR_MASK_ALPHA:
+ switch (depth) {
+ case 8:
+ pixel_type = GP_PIXEL_GA88;
+ break;
+ }
+ break;
case PNG_COLOR_TYPE_RGB:
png_set_bgr(png);
-----------------------------------------------------------------------
Summary of changes:
libs/loaders/GP_PNG.c | 7 +++++++
1 files changed, 7 insertions(+), 0 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
06 Apr '14
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 e667b1019551a0036d4ff8e7852bc51e2336440c (commit)
via 5cd65fd591736dece2f3765bd0ad8c2293a962fb (commit)
via 503997cdf771f276e66b81248040ea7c871453d1 (commit)
via b57c2a045e194efe832221f8b39f3321e138ef2e (commit)
via ef9820803deba6c74d0add5b20e6b05337d5b5ff (commit)
via d05cd390e18afe7121de02baf14db33c594718e0 (commit)
via c7229164ab9fd1a0b2cd56a5160c645cee47fc8f (commit)
via cca2aa0a2f23dc952ec63d022320053c4d532b04 (commit)
via 5e47080df0990f3c9deb18ecb83a98ae6dce0671 (commit)
via 9495fa1e62cd01f4dbbab631abcdc5ff0114c49d (commit)
from c4cb658954c2cd3de44939d096b48eb40438d674 (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/e667b1019551a0036d4ff8e7852bc51e2336…
commit e667b1019551a0036d4ff8e7852bc51e2336440c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 30 16:57:45 2014 +0200
pywrap: core: Add GP_Fill
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i
index 59b17e8a..ff0c0629 100644
--- a/pylib/gfxprim/core/core.i
+++ b/pylib/gfxprim/core/core.i
@@ -124,9 +124,8 @@ ERROR_ON_NULL(GP_SubContextAlloc);
/*
* Context manipulation
*/
-
%include "GP_GetPutPixel.h"
%import "GP_GetPutPixel.gen.h"
%include "GP_WritePixel.h"
%include "GP_Blit.h"
-
+%include "GP_Fill.h"
http://repo.or.cz/w/gfxprim.git/commit/5cd65fd591736dece2f3765bd0ad8c2293a9…
commit 5cd65fd591736dece2f3765bd0ad8c2293a962fb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 30 16:57:00 2014 +0200
core: Include GP_Fill.h in GP_Core.h.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/include/core/GP_Core.h b/include/core/GP_Core.h
index 38ee3c33..b9f1b6ac 100644
--- a/include/core/GP_Core.h
+++ b/include/core/GP_Core.h
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -77,4 +77,6 @@
/* Mix Pixel */
#include "core/GP_MixPixels.h"
+#include "core/GP_Fill.h"
+
#endif /* GP_CORE_H */
http://repo.or.cz/w/gfxprim.git/commit/503997cdf771f276e66b81248040ea7c8714…
commit 503997cdf771f276e66b81248040ea7c871453d1
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 30 16:48:13 2014 +0200
Fix typos.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.1 b/demos/spiv/spiv.1
index bca63dd6..30bd5d9f 100644
--- a/demos/spiv/spiv.1
+++ b/demos/spiv/spiv.1
@@ -24,7 +24,7 @@ Spiv implements feh-like image actions, which are short shell scripts with
printf-like modifiers.
See
.B ACTIONS
-bellow for further information.
+below for further information.
.SH KEYBOARD CONTROL
.IP "Esc, Enter, Q"
diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c
index cecd1ecb..9d018872 100644
--- a/demos/spiv/spiv_help.c
+++ b/demos/spiv/spiv_help.c
@@ -175,7 +175,7 @@ const char *man_head =
".PPn"
"Spiv implements feh-like image actions, which are short shell scripts withn"
"printf-like modifiers.n"
- "Seen.B ACTIONSnbellow for further information.n";
+ "Seen.B ACTIONSnbelow for further information.n";
static const char *man_tail =
".SH BUGSn"
diff --git a/include/core/GP_Debug.h b/include/core/GP_Debug.h
index 4008bcd6..0c6af6fd 100644
--- a/include/core/GP_Debug.h
+++ b/include/core/GP_Debug.h
@@ -37,7 +37,7 @@
There are few special debug message types with negative debug level (that
means that they are always printed), and as so these are used on various error
- conditions, see bellow for more information.
+ conditions, see below for more information.
*/
diff --git a/include/input/GP_EventQueue.h b/include/input/GP_EventQueue.h
index df251594..089fbfac 100644
--- a/include/input/GP_EventQueue.h
+++ b/include/input/GP_EventQueue.h
@@ -115,7 +115,7 @@ int GP_EventQueuePeek(struct GP_EventQueue *self, struct GP_Event *ev);
* Puts the event in the queue.
*
* This is bare call that just copies the event into the queue. Use the calls
- * bellow instead.
+ * below instead.
*/
void GP_EventQueuePut(struct GP_EventQueue *self, struct GP_Event *ev);
diff --git a/include/loaders/GP_Container.h b/include/loaders/GP_Container.h
index d3e9d0f5..2670bc58 100644
--- a/include/loaders/GP_Container.h
+++ b/include/loaders/GP_Container.h
@@ -44,7 +44,7 @@ enum GP_ContainerWhence {
struct GP_ContainerOps {
/*
* Loads next image from container, use the inline function defined
- * bellow.
+ * below.
*/
GP_Context *(*LoadNext)(struct GP_Container *self,
GP_ProgressCallback *callback);
@@ -56,7 +56,7 @@ struct GP_ContainerOps {
GP_ProgressCallback *callback);
/*
- * Close callback, use the inline function defined bellow.
+ * Close callback, use the inline function defined below.
*/
void (*Close)(struct GP_Container *self);
diff --git a/libs/loaders/GP_IOZlib.c b/libs/loaders/GP_IOZlib.c
index d0a7e00c..21b7fc72 100644
--- a/libs/loaders/GP_IOZlib.c
+++ b/libs/loaders/GP_IOZlib.c
@@ -137,7 +137,6 @@ static int zlib_reset(struct priv *priv)
priv->strm.avail_out = 0;
priv->strm.next_out = Z_NULL;
-
priv->bytes_read = 0;
priv->comp_avail = priv->comp_size;
priv->crc = crc32(0, NULL, 0);
@@ -151,7 +150,7 @@ static off_t zlib_seek(GP_IO *io, off_t offset, enum GP_IOWhence whence)
struct priv *priv = GP_IO_PRIV(io);
off_t ret;
- GP_DEBUG(3, "Seek %li %un", (long)offset, whence);
+ GP_DEBUG(3, "Seek %li %u", (long)offset, whence);
if (whence == GP_IO_SEEK_CUR) {
if (offset == 0)
http://repo.or.cz/w/gfxprim.git/commit/b57c2a045e194efe832221f8b39f3321e138…
commit b57c2a045e194efe832221f8b39f3321e138ef2e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Mar 30 16:47:36 2014 +0200
doc: Add filter images, fix typos.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/doc/backends.txt b/doc/backends.txt
index 9b0c392c..944c13f3 100644
--- a/doc/backends.txt
+++ b/doc/backends.txt
@@ -176,7 +176,7 @@ void GP_BackendX11RequestFullscreen(GP_Backend *self, int mode);
The 'GP_BackendX11RequestFullscreen' can toggle fullscreen mode at runtime.
-It will most likely generate resize event. See the 'GP_BackendResizeAck()' bellow.
+It will most likely generate resize event. See the 'GP_BackendResizeAck()' below.
AA-lib
~~~~~~
@@ -344,7 +344,7 @@ when data are ready on file-descriptor.
If the backend is the only source of events in your application, you should
consider using the 'GP_BackendWait()' or 'GP_BackendEventWait()' described
-bellow.
+below.
GP_BackendPollEvent
^^^^^^^^^^^^^^^^^^^
@@ -593,7 +593,7 @@ int GP_BackendResize(GP_Backend *backend, uint32_t w, uint32_t h);
Requests backend resize. If backend resize is supported and the resize request
was successful (i.e. X server allowed us to resize the window) the resize
event will be send and should be handled in your event loop. You must respond
-to it by the 'GP_BackendResizeAck()' described bellow.
+to it by the 'GP_BackendResizeAck()' described below.
NOTE: The backend->context pointer may change upon calling this function and
at least backend->context->pixels pointer will change.
diff --git a/doc/blits.txt b/doc/blits.txt
index e2982e6e..d2e4e372 100644
--- a/doc/blits.txt
+++ b/doc/blits.txt
@@ -45,7 +45,7 @@ WARNING: For these functions the behavior is undefined when you pass
coordinates or width or height outside of the source or destination
pixmap. If you need safe variant that automatically clips the
coordinates and rectangle to fit both the source and destination use
- the Clipped variants described bellow.
+ the Clipped variants described below.
[source,c]
diff --git a/doc/context.txt b/doc/context.txt
index c59c714e..37287f7e 100644
--- a/doc/context.txt
+++ b/doc/context.txt
@@ -58,7 +58,7 @@ gamma correction. Unfortunatelly very few parts of the library use it at the
moment (this will be fixed in subsequent releases).
The bitfield at the the end of the structure describes image orientation (see
-bellow) and a flag that tell if 'pixels' data should be freed, which is
+below) and a flag that tell if 'pixels' data should be freed, which is
usefull for example for <<Sub_Context, subcontexts>>.
Rotation
diff --git a/doc/debug.txt b/doc/debug.txt
index e5f0015e..09c80aa0 100644
--- a/doc/debug.txt
+++ b/doc/debug.txt
@@ -17,7 +17,7 @@ debug level lower or equal to debug level are printed.
There are few special debug message types with negative debug level (that
means that they are always printed), and as so these are used on various error
-conditions, see bellow for more information.
+conditions, see below for more information.
[source,c]
-------------------------------------------------------------------------------
diff --git a/doc/environment_variables.txt b/doc/environment_variables.txt
index 85b6758d..5ce7488a 100644
--- a/doc/environment_variables.txt
+++ b/doc/environment_variables.txt
@@ -10,7 +10,7 @@ GP_THREADS
'GP_THREADS' overrides GP_NrThreadsSet() settings. The value is the same as it
would have been set by GP_NrThreadsSet() which is described in the table
-bellow:
+below:
.GP_THREADS possible values
[width="60%",options="header"]
diff --git a/doc/filters.txt b/doc/filters.txt
index 1ed37f09..c0cc5466 100644
--- a/doc/filters.txt
+++ b/doc/filters.txt
@@ -322,6 +322,8 @@ Works 'in-place'.
The destination has to have the same pixel type and the size must be at least
as large as source.
+include::images/mirror_h/images.txt[]
+
[source,c]
-------------------------------------------------------------------------------
#include <filters/GP_Rotate.h>
@@ -342,6 +344,8 @@ Works 'in-place'.
The destination has to have the same pixel type and the size must be at least
as large as source.
+include::images/mirror_v/images.txt[]
+
[source,c]
-------------------------------------------------------------------------------
#include <filters/GP_Rotate.h>
@@ -362,6 +366,8 @@ Doesn't work 'in-place' (yet).
The destination has to have the same pixel type and size must be large enough to
fit rotated context (i.e. W and H are swapped).
+include::images/rotate_90/images.txt[]
+
[source,c]
-------------------------------------------------------------------------------
#include <filters/GP_Rotate.h>
@@ -382,6 +388,8 @@ Doesn't work 'in-place' (yet).
The destination has to have the same pixel type and the size must be at least
as large as source.
+include::images/rotate_180/images.txt[]
+
[source,c]
-------------------------------------------------------------------------------
#include <filters/GP_Rotate.h>
@@ -402,6 +410,8 @@ Doesn't work 'in-place' (yet).
The destination has to have the same pixel type and destination size must be
large enough to fit rotated context (i.e. W and H are swapped).
+include::images/rotate_270/images.txt[]
+
[source,c]
-------------------------------------------------------------------------------
#include <filters/GP_Rotate.h>
http://repo.or.cz/w/gfxprim.git/commit/ef9820803deba6c74d0add5b20e6b05337d5…
commit ef9820803deba6c74d0add5b20e6b05337d5b5ff
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Mar 19 23:46:17 2014 +0100
loaders: zip: Make use of Zlib stream.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c
index 7928023d..440aabbf 100644
--- a/libs/loaders/GP_ZIP.c
+++ b/libs/loaders/GP_ZIP.c
@@ -34,12 +34,12 @@
#endif /* HAVE_ZLIB */
-#include "core/GP_Common.h"
-#include "core/GP_Debug.h"
-
-#include "loaders/GP_ByteUtils.h"
-#include "loaders/GP_Loader.h"
+#include <core/GP_Common.h>
+#include <core/GP_Debug.h>
+#include <loaders/GP_ByteUtils.h>
+#include <loaders/GP_Loader.h>
+#include <loaders/GP_IOZlib.h>
#include "loaders/GP_ZIP.h"
#ifdef HAVE_ZLIB
@@ -132,7 +132,7 @@ enum zip_flags {
/* File is encrypted */
FLAG_ENCRYPTED = 0x0001,
/* Size and CRC are in data descriptor after the compressed data */
- FLAG_ZERO_SIZE_CRC = 0x0008,
+ FLAG_DATA_DESC_HEADER = 0x0008,
/* Filename and comment fileds are in UTF-8 */
FLAG_UTF8 = 0x0800,
};
@@ -142,7 +142,7 @@ static void print_flags(struct zip_local_header *header)
if (header->flags & FLAG_ENCRYPTED)
GP_DEBUG(2, "File is encrypted");
- if (header->flags & FLAG_ZERO_SIZE_CRC)
+ if (header->flags & FLAG_DATA_DESC_HEADER)
GP_DEBUG(2, "File size and CRC are after compressed data");
if (header->flags & FLAG_UTF8)
@@ -165,162 +165,6 @@ static int seek_bytes(GP_IO *io, uint32_t bytes)
return 0;
}
-#define CHUNK 512
-
-struct deflate_inbuf {
- struct zip_local_header *zip_header;
- uint32_t to_read;
- unsigned char buf[CHUNK];
- GP_IO *io;
-};
-
-struct deflate_outbuf {
- uint32_t crc;
- uint32_t size;
- uint32_t fill;
- uint8_t *buf;
-};
-
-static unsigned deflate_in(void *in_desc, unsigned char **buf)
-{
- struct deflate_inbuf *in = in_desc;
- int chunk, ret;
-
- if (in->to_read)
- chunk = in->to_read >= CHUNK ? CHUNK : in->to_read;
- else
- chunk = CHUNK;
-
- ret = GP_IORead(in->io, in->buf, chunk);
-
- if (ret <= 0)
- return ret;
-
- *buf = in->buf;
-
- if (in->to_read)
- in->to_read -= ret;
-
- return ret;
-}
-
-#define BUFINC (1024 * 128)
-
-static int deflate_out(void *out_desc, unsigned char *buf, unsigned len)
-{
- struct deflate_outbuf *out = out_desc;
-
- if (out->fill + len >= out->size) {
- out->buf = realloc(out->buf, out->size + GP_MAX(len, BUFINC));
- if (!out->buf)
- return 1;
- out->size += GP_MAX(len, BUFINC);
- GP_DEBUG(1, "Realloc %u %p", out->size, out->buf);
- }
-
- out->crc = crc32(out->crc, buf, len);
- memcpy(out->buf + out->fill, buf, len);
- out->fill += len;
-
- return 0;
-}
-
-static int read_deflate(GP_IO *io, struct zip_local_header *header, GP_IO **rio)
-{
- uint8_t *window;
- int err = 0, ret;
- uint8_t *buf;
- unsigned int bufsize = header->uncomp_size ? header->uncomp_size : BUFINC;
-
- window = malloc(32 * 1024);
-
- //TODO: Unsafe
- buf = malloc(bufsize);
-
- if (!window || !buf) {
- err = ENOMEM;
- goto err1;
- }
-
- z_stream strm = {
- .zalloc = Z_NULL,
- .zfree = Z_NULL,
- .opaque = Z_NULL,
- .next_in = Z_NULL,
- };
-
- if (inflateBackInit(&strm, 15, window) != Z_OK) {
- GP_DEBUG(1, "Failed to initialize inflate stream");
- //TODO: Better errno?
- err = EIO;
- goto err1;
- }
-
- struct deflate_outbuf outbuf = {
- .crc = crc32(0, NULL, 0),
- .size = bufsize,
- .fill = 0,
- .buf = buf,
- };
-
- struct deflate_inbuf inbuf = {
- .zip_header = header,
- .io = io,
- .to_read = header->comp_size,
- };
-
- ret = inflateBack(&strm, deflate_in, &inbuf, deflate_out, &outbuf);
-
- if (ret != Z_STREAM_END) {
- GP_DEBUG(1, "Failed to inflate stream %i", ret);
- err = EINVAL;
- goto err2;
- }
-
- if (header->flags & FLAG_ZERO_SIZE_CRC) {
- GP_DEBUG(2, "In buffer %i, seeking back", strm.avail_in);
- GP_IOSeek(io, -(int)strm.avail_in, GP_IO_SEEK_CUR);
- uint16_t data_desc_header[] = {
- 'P', 'K', 0x07, 0x08, /* Data desc header */
- GP_IO_L4, /* CRC */
- GP_IO_L4, /* Compressed size */
- GP_IO_L4, /* Uncompressed size */
- GP_IO_END
- };
-
- if (GP_IOReadF(io, data_desc_header, &header->crc,
- &header->comp_size, &header->uncomp_size) != 7) {
- GP_DEBUG(1, "Failed to read Data Description Header");
- goto err2;
- }
- }
-
- if (outbuf.crc != header->crc) {
- GP_DEBUG(1, "CRC does not match");
- err = EIO;
- goto err2;
- }
-
- if (outbuf.fill != header->uncomp_size) {
- GP_DEBUG(1, "Decompressed size does not match");
- err = EIO;
- goto err2;
- }
-
- inflateBackEnd(&strm);
- free(window);
-
- //TODO: Failure
- *rio = GP_IOMem(outbuf.buf, outbuf.size, free);
- return 0;
-err2:
- inflateBackEnd(&strm);
-err1:
- free(window);
- free(outbuf.buf);
- return err;
-}
-
static int zip_load_header(GP_IO *io, struct zip_local_header *header)
{
int ret;
@@ -379,6 +223,25 @@ static int zip_load_header(GP_IO *io, struct zip_local_header *header)
return 0;
}
+static int zip_read_data_desc(GP_IO *io, struct zip_local_header *header)
+{
+ uint16_t data_desc_header[] = {
+ 'P', 'K', 0x07, 0x08, /* Data desc header */
+ GP_IO_L4, /* CRC */
+ GP_IO_L4, /* Compressed size */
+ GP_IO_L4, /* Uncompressed size */
+ GP_IO_END
+ };
+
+ if (GP_IOReadF(io, data_desc_header, &header->crc,
+ &header->comp_size, &header->uncomp_size) != 7) {
+ GP_DEBUG(1, "Failed to read Data Description Header");
+ return 1;
+ }
+
+ return 0;
+}
+
static GP_Context *zip_next_file(struct zip_priv *priv,
GP_ProgressCallback *callback)
{
@@ -415,7 +278,7 @@ static GP_Context *zip_next_file(struct zip_priv *priv,
}
header.file_name[header.fname_len] = '0';
-
+ //FILL
if (GP_IORead(priv->io, header.file_name, header.fname_len) != header.fname_len) {
GP_DEBUG(1, "Failed to read filename");
err = EIO;
@@ -449,7 +312,7 @@ static GP_Context *zip_next_file(struct zip_priv *priv,
goto out;
break;
case COMPRESS_DEFLATE:
- if ((err = read_deflate(priv->io, &header, &io))) {
+ /* if ((err = read_deflate(priv->io, &header, &io))) {
err = errno;
goto out;
}
@@ -460,6 +323,24 @@ static GP_Context *zip_next_file(struct zip_priv *priv,
GP_IOClose(io);
goto out;
+ */
+ io = GP_IOZlib(priv->io, header.comp_size);
+ if (!io)
+ goto out;
+
+ GP_DEBUG(1, "Reading image");
+ ret = GP_ReadImage(io, callback);
+ if (errno == ECANCELED)
+ err = errno;
+
+ GP_IOClose(io);
+
+ if (header.flags & FLAG_DATA_DESC_HEADER) {
+ if (zip_read_data_desc(priv->io, &header))
+ goto out;
+ }
+
+ goto out;
break;
default:
GP_DEBUG(1, "Unimplemented compression %s",
@@ -551,6 +432,8 @@ static GP_Context *zip_load_next(GP_Container *self,
if (ret)
record_offset(priv, offset);
+ record_offset(priv, GP_IOTell(priv->io));
+
priv->cur_pos++;
//self->cur_img++;
self->cur_img = priv->cur_pos;
http://repo.or.cz/w/gfxprim.git/commit/d05cd390e18afe7121de02baf14db33c5947…
commit d05cd390e18afe7121de02baf14db33c594718e0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Mar 19 23:45:22 2014 +0100
libs: loaders: Create Zlib decompression stream
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Loaders_symbols.txt b/build/syms/Loaders_symbols.txt
index dfbb1e54..f8c1d68c 100644
--- a/build/syms/Loaders_symbols.txt
+++ b/build/syms/Loaders_symbols.txt
@@ -109,3 +109,6 @@ GP_IOFill
GP_IOReadF
GP_IOReadB2
GP_IOReadB4
+
+GP_IOZlib
+GP_IOZlibReset
diff --git a/include/loaders/GP_Loaders.h b/include/loaders/GP_IOZlib.h
similarity index 65%
copy from include/loaders/GP_Loaders.h
copy to include/loaders/GP_IOZlib.h
index a80eb6e2..70486dfb 100644
--- a/include/loaders/GP_Loaders.h
+++ b/include/loaders/GP_IOZlib.h
@@ -16,43 +16,37 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
* Copyright (C) 2009-2014 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
/*
- Core include file for loaders API.
+ Zlib decompression stream.
*/
-#ifndef LOADERS_GP_LOADERS_H
-#define LOADERS_GP_LOADERS_H
-
-#include "core/GP_Context.h"
-#include "core/GP_ProgressCallback.h"
-
-#include "loaders/GP_PNM.h"
-#include "loaders/GP_BMP.h"
-#include "loaders/GP_PNG.h"
-#include "loaders/GP_JPG.h"
-#include "loaders/GP_JP2.h"
-#include "loaders/GP_GIF.h"
-#include "loaders/GP_TIFF.h"
-#include "loaders/GP_PCX.h"
-#include "loaders/GP_PSP.h"
-#include "loaders/GP_PSD.h"
-
-#include "loaders/GP_TmpFile.h"
-
-#include "loaders/GP_MetaData.h"
-
-#include "loaders/GP_Loader.h"
-
-#include "loaders/GP_Container.h"
-#include "loaders/GP_ZIP.h"
-
-#endif /* LOADERS_GP_LOADERS_H */
+#ifndef LOADERS_GP_IO_ZLIB_H
+#define LOADERS_GP_IO_ZLIB_H
+
+#include <loaders/GP_IO.h>
+
+/*
+ * Create an Zlib RAW inflate stream on the top of the existing I/O stream.
+ *
+ * The stream will read up to comp_size bytes from the parent I/O.
+ *
+ * If comp_size is 0, no limit on number bytes from the parent stream is set.
+ * However if end of compressed stream is reached the last read will attempt to
+ * seek back by the number of extra buffered bytes.
+ */
+GP_IO *GP_IOZlib(GP_IO *io, size_t comp_size);
+
+/*
+ * Repurposes existing Zlib stream for new decompression.
+ *
+ * Returns zero on success. Returns non-zero on failure and errno is set.
+ */
+int GP_IOZlibReset(GP_IO *io, GP_IO *sub_io, size_t comp_size);
+
+#endif /* LOADERS_GP_IO_ZLIB_H */
diff --git a/include/loaders/GP_Loaders.h b/include/loaders/GP_Loaders.h
index a80eb6e2..e93412c6 100644
--- a/include/loaders/GP_Loaders.h
+++ b/include/loaders/GP_Loaders.h
@@ -55,4 +55,6 @@
#include "loaders/GP_Container.h"
#include "loaders/GP_ZIP.h"
+#include "loaders/GP_IOZlib.h"
+
#endif /* LOADERS_GP_LOADERS_H */
diff --git a/libs/loaders/GP_IOZlib.c b/libs/loaders/GP_IOZlib.c
new file mode 100644
index 00000000..d0a7e00c
--- /dev/null
+++ b/libs/loaders/GP_IOZlib.c
@@ -0,0 +1,259 @@
+/*****************************************************************************
+ * 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-2014 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include "../../config.h"
+
+#ifdef HAVE_ZLIB
+
+#include <zlib.h>
+#include <errno.h>
+#include <stdint.h>
+#include <core/GP_Debug.h>
+#include <core/GP_Common.h>
+#include <loaders/GP_IOZlib.h>
+
+#define BUFS 512u
+
+struct priv {
+ z_stream strm;
+
+ GP_IO *io;
+ off_t io_start;
+ int eos;
+
+ uint32_t crc;
+ size_t comp_avail;
+ size_t comp_size;
+ size_t bytes_read;
+
+ char inbuf[BUFS];
+};
+
+static int zlib_close(GP_IO *io)
+{
+ struct priv *priv = GP_IO_PRIV(io);
+
+ GP_DEBUG(1, "Closing IO (%p)", io);
+
+ inflateEnd(&priv->strm);
+ free(io);
+
+ return 0;
+}
+
+static ssize_t zlib_read(GP_IO *io, void *buf, size_t size)
+{
+ struct priv *priv = GP_IO_PRIV(io);
+ size_t bread;
+ int ret;
+
+ GP_DEBUG(3, "Read %p %zu", buf, size);
+
+ if (priv->eos)
+ return 0;
+
+ priv->strm.avail_out = size;
+ priv->strm.next_out = buf;
+
+ do {
+ if (priv->strm.avail_in == 0) {
+ size_t to_read = BUFS;
+
+ if (priv->comp_avail)
+ to_read = GP_MIN(BUFS, priv->comp_avail);
+
+ ret = GP_IORead(priv->io, priv->inbuf, to_read);
+
+ if (ret <= 0)
+ return ret;
+
+ if (priv->comp_avail)
+ priv->comp_avail -= ret;
+
+ priv->strm.avail_in = ret;
+ priv->strm.next_in = (void*)priv->inbuf;
+ }
+
+ //priv->strm.next_out = buf + (size - priv->strm.avail_out);
+ ret = inflate(&priv->strm, Z_NO_FLUSH);
+
+ switch (ret) {
+ case Z_OK:
+ break;
+ case Z_STREAM_END:
+ GP_DEBUG(1, "End of stream");
+
+ priv->eos = 1;
+
+ /* Attempt to seek back in the parent I/O stream */
+ if (priv->strm.avail_in) {
+ GP_DEBUG(1, "Seeking back by %zu", (size_t)priv->strm.avail_in);
+ GP_IOSeek(priv->io, -(int)priv->strm.avail_in, GP_IO_SEEK_CUR);
+ }
+
+ goto out;
+ break;
+ default:
+ GP_DEBUG(1, "inflate() failed %i", ret);
+ errno = EIO;
+ return -1;
+ }
+ } while (priv->strm.avail_out == size);
+
+out:
+ bread = size - priv->strm.avail_out;
+ priv->bytes_read += bread;
+ priv->crc = crc32(priv->crc, buf, bread);
+
+ return bread;
+}
+
+static int zlib_reset(struct priv *priv)
+{
+ inflateReset(&priv->strm);
+
+ priv->strm.avail_in = 0;
+ priv->strm.next_in = Z_NULL;
+
+ priv->strm.avail_out = 0;
+ priv->strm.next_out = Z_NULL;
+
+
+ priv->bytes_read = 0;
+ priv->comp_avail = priv->comp_size;
+ priv->crc = crc32(0, NULL, 0);
+ priv->eos = 0;
+
+ return 0;
+}
+
+static off_t zlib_seek(GP_IO *io, off_t offset, enum GP_IOWhence whence)
+{
+ struct priv *priv = GP_IO_PRIV(io);
+ off_t ret;
+
+ GP_DEBUG(3, "Seek %li %un", (long)offset, whence);
+
+ if (whence == GP_IO_SEEK_CUR) {
+ if (offset == 0)
+ return priv->bytes_read;
+ if (offset < 0)
+ goto out;
+ char b[offset];
+ priv->bytes_read += offset;
+ GP_IOFill(io, b, offset);
+ return priv->bytes_read;
+ }
+
+ if (whence == GP_IO_SEEK_SET && offset == 0) {
+ ret = GP_IOSeek(priv->io, priv->io_start, GP_IO_SEEK_SET);
+
+ if (ret == (off_t)-1)
+ return ret;
+
+ if (zlib_reset(priv))
+ return (off_t)-1;
+
+ return 0;
+ }
+out:
+ errno = ENOSYS;
+ return (off_t)-1;
+}
+
+int GP_IOZlibReset(GP_IO *io, GP_IO *sub_io, size_t comp_size)
+{
+ struct priv *priv = GP_IO_PRIV(io);
+
+ GP_DEBUG(1, "Resseting I/O (%p) (parent %p) size %zu",
+ io, sub_io, comp_size);
+
+ priv->io = sub_io;
+ priv->comp_size = comp_size;
+
+ return zlib_reset(priv);
+}
+
+GP_IO *GP_IOZlib(GP_IO *io, size_t comp_size)
+{
+ GP_IO *new = malloc(sizeof(GP_IO) + sizeof(struct priv));
+ struct priv *priv;
+ int err, ret;
+
+ if (!new) {
+ GP_DEBUG(1, "Malloc failed :(");
+ return NULL;
+ }
+
+ priv = GP_IO_PRIV(new);
+
+ priv->io = io;
+ priv->comp_avail = comp_size;
+ priv->comp_size = comp_size;
+ priv->bytes_read = 0;
+ priv->crc = crc32(0, NULL, 0);
+ priv->io_start = GP_IOTell(io);
+ priv->eos = 0;
+
+ priv->strm.zalloc = Z_NULL;
+ priv->strm.zfree = Z_NULL;
+ priv->strm.opaque = Z_NULL;
+ priv->strm.avail_in = Z_NULL;
+ priv->strm.next_in = Z_NULL;
+
+ ret = inflateInit2(&priv->strm, -15);
+ if (ret != Z_OK) {
+ //TODO better err and message
+ GP_DEBUG(1, "inflateInit() failed: %i", ret);
+ err = EIO;
+ goto err1;
+ }
+
+ //INIT IO
+ new->Close = zlib_close;
+ new->Read = zlib_read;
+ new->Write = NULL;
+ new->Seek = zlib_seek;
+
+ GP_DEBUG(1, "Initialized ZlibIO (%p)", new);
+
+ return new;
+err1:
+ free(new);
+ errno = err;
+ return NULL;
+}
+
+#else
+
+GP_IO *GP_IOZlib(GP_IO *io, size_t comp_size)
+{
+ errno = ENOSYS;
+ return NULL;
+}
+
+int GP_IOZlibReset(GP_IO *io, GP_IO *sub_io, size_t comp_size)
+{
+ errno = ENOSYS;
+ return 1;
+}
+#endif /* HAVE_ZLIB */
http://repo.or.cz/w/gfxprim.git/commit/c7229164ab9fd1a0b2cd56a5160c645cee47…
commit c7229164ab9fd1a0b2cd56a5160c645cee47fc8f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Mar 19 23:44:55 2014 +0100
spiv: Show pixel type in info.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c
index ca374085..6d26c600 100644
--- a/demos/spiv/spiv.c
+++ b/demos/spiv/spiv.c
@@ -231,9 +231,9 @@ static void show_info(struct loader_params *params, GP_Context *img,
GP_Size th = GP_TextHeight(NULL), y = 10;
- info_printf(context, 10, y, "%ux%u (%ux%u) 1:%3.3f %3.1f%%",
+ info_printf(context, 10, y, "%ux%u (%ux%u) 1:%3.3f %3.1f%% %s",
img->w, img->h, orig_img->w, orig_img->h, params->zoom_rat,
- params->zoom_rat * 100);
+ params->zoom_rat * 100, GP_PixelTypeName(img->pixel_type));
y += th + 2;
info_printf(context, 10, y, "%s", img_name(img_path));
http://repo.or.cz/w/gfxprim.git/commit/cca2aa0a2f23dc952ec63d022320053c4d53…
commit cca2aa0a2f23dc952ec63d022320053c4d532b04
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Mar 19 23:25:24 2014 +0100
loaders: PNG: Use GP_IOFill() to fill whole buffer
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 71812ba2..770bb123 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -63,12 +63,9 @@ static const char *interlace_type_name(int interlace)
static void read_data(png_structp png_ptr, png_bytep data, png_size_t len)
{
- int res;
GP_IO *io = png_get_io_ptr(png_ptr);
- res = GP_IORead(io, data, len);
-
- if (res < 0 || (png_size_t)res != len)
+ if (GP_IOFill(io, data, len))
png_error(png_ptr, "Read Error");
}
http://repo.or.cz/w/gfxprim.git/commit/5e47080df0990f3c9deb18ecb83a98ae6dce…
commit 5e47080df0990f3c9deb18ecb83a98ae6dce0671
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Mar 19 23:17:21 2014 +0100
spiv: Fix -t for zip container.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/spiv/image_loader.c b/demos/spiv/image_loader.c
index e03426e0..d0335294 100644
--- a/demos/spiv/image_loader.c
+++ b/demos/spiv/image_loader.c
@@ -67,7 +67,9 @@ GP_Context *image_loader_get_image(GP_ProgressCallback *callback, int elevate)
return cur_img;
if (cur_cont) {
+ cpu_timer_start(&timer, "Loading");
cur_img = GP_ContainerLoad(cur_cont, callback);
+ cpu_timer_stop(&timer);
return cur_img;
}
@@ -97,6 +99,7 @@ GP_Context *image_loader_get_image(GP_ProgressCallback *callback, int elevate)
if (img) {
cur_img = img;
+ cpu_timer_stop(&timer);
return img;
}
http://repo.or.cz/w/gfxprim.git/commit/9495fa1e62cd01f4dbbab631abcdc5ff0114…
commit 9495fa1e62cd01f4dbbab631abcdc5ff0114c49d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Mar 19 21:44:36 2014 +0100
loaders: JPG: Fix two bugs.
* The fill_input_buffer() should use return from read not the buffer size
* The skip_input_data() should at least print warning if Seek failed
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index 9d19d9c2..a0eabd97 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -161,18 +161,22 @@ static boolean fill_input_buffer(struct jpeg_decompress_struct *cinfo)
}
src->mgr.next_input_byte = src->buffer;
- src->mgr.bytes_in_buffer = src->size;
+ src->mgr.bytes_in_buffer = ret;
return 1;
}
static void skip_input_data(struct jpeg_decompress_struct *cinfo, long num_bytes)
{
struct my_source_mgr* src = (void*)cinfo->src;
+ off_t ret;
GP_DEBUG(3, "Skipping %li bytes", num_bytes);
if (src->mgr.bytes_in_buffer < (unsigned long)num_bytes) {
- GP_IOSeek(src->io, num_bytes - src->mgr.bytes_in_buffer, GP_IO_SEEK_CUR);
+ ret = GP_IOSeek(src->io, num_bytes - src->mgr.bytes_in_buffer, GP_IO_SEEK_CUR);
+ //TODO: Call jpeg error
+ if (ret == (off_t)-1)
+ GP_FATAL("Failed to skip data: %s", strerror(errno));
src->mgr.bytes_in_buffer = 0;
} else {
src->mgr.bytes_in_buffer -= num_bytes;
-----------------------------------------------------------------------
Summary of changes:
build/syms/Loaders_symbols.txt | 3 +
demos/spiv/image_loader.c | 3 +
demos/spiv/spiv.1 | 2 +-
demos/spiv/spiv.c | 4 +-
demos/spiv/spiv_help.c | 2 +-
doc/backends.txt | 6 +-
doc/blits.txt | 2 +-
doc/context.txt | 2 +-
doc/debug.txt | 2 +-
doc/environment_variables.txt | 2 +-
doc/filters.txt | 10 +
include/core/GP_Core.h | 4 +-
include/core/GP_Debug.h | 2 +-
include/input/GP_EventQueue.h | 2 +-
include/loaders/GP_Container.h | 4 +-
include/loaders/{GP_PSP.h => GP_IOZlib.h} | 36 ++---
include/loaders/GP_Loaders.h | 2 +
libs/loaders/GP_IOZlib.c | 258 +++++++++++++++++++++++++++++
libs/loaders/GP_JPG.c | 8 +-
libs/loaders/GP_PNG.c | 5 +-
libs/loaders/GP_ZIP.c | 213 ++++++------------------
pylib/gfxprim/core/core.i | 3 +-
22 files changed, 366 insertions(+), 209 deletions(-)
copy include/loaders/{GP_PSP.h => GP_IOZlib.h} (69%)
create mode 100644 libs/loaders/GP_IOZlib.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