summaryrefslogtreecommitdiffstats
path: root/libdimension/png.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-05-08 23:21:48 -0600
committerTavian Barnes <tavianator@gmail.com>2010-05-08 23:21:48 -0600
commit7a21db5914dd7a5666e603d66ed3948b659ba2fc (patch)
treebde8e00a1677ba865adae8a82780d1cc832ece8e /libdimension/png.c
parent152362a57dc7fe9dce830ef69118984f854d6375 (diff)
downloaddimension-7a21db5914dd7a5666e603d66ed3948b659ba2fc.tar.xz
New DMNSN_ARRAY_FOREACH() macro, faster than iterating with dmnsn_array_get().
Diffstat (limited to 'libdimension/png.c')
-rw-r--r--libdimension/png.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/libdimension/png.c b/libdimension/png.c
index 021b9f2..177293c 100644
--- a/libdimension/png.c
+++ b/libdimension/png.c
@@ -39,9 +39,8 @@ dmnsn_png_optimize_canvas(dmnsn_canvas *canvas)
dmnsn_canvas_optimizer optimizer;
/* Check if we've already optimized this canvas */
- for (size_t i = 0; i < dmnsn_array_size(canvas->optimizers); ++i) {
- dmnsn_array_get(canvas->optimizers, i, &optimizer);
- if (optimizer.optimizer_fn == &dmnsn_png_optimizer_fn) {
+ DMNSN_ARRAY_FOREACH (dmnsn_canvas_optimizer *, i, canvas->optimizers) {
+ if (i->optimizer_fn == &dmnsn_png_optimizer_fn) {
return 0;
}
}
@@ -287,12 +286,11 @@ dmnsn_png_write_canvas_impl(dmnsn_progress *progress,
}
/* Check if we can optimize this */
- for (size_t i = 0; i < dmnsn_array_size(canvas->optimizers); ++i) {
- dmnsn_array_get(canvas->optimizers, i, &optimizer);
- if (optimizer.optimizer_fn == &dmnsn_png_optimizer_fn) {
+ DMNSN_ARRAY_FOREACH (dmnsn_canvas_optimizer *, i, canvas->optimizers) {
+ if (i->optimizer_fn == &dmnsn_png_optimizer_fn) {
for (size_t y = 0; y < height; ++y) {
/* Invert the rows. PNG coordinates are fourth quadrant. */
- uint16_t *row = (uint16_t *)optimizer.ptr + 4*(height - y - 1)*width;
+ uint16_t *row = (uint16_t *)i->ptr + 4*(height - y - 1)*width;
png_write_row(png_ptr, (png_bytep)row);
dmnsn_increment_progress(progress);
}