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 66cbe1a3b25ba7d4c3361d420fa9de364c02557e (commit)
from 446922190513e6535202e8f45ab897bc622390ee (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/66cbe1a3b25ba7d4c3361d420fa9de364c02…
commit 66cbe1a3b25ba7d4c3361d420fa9de364c02557e
Author: Jiri BlueBear Dluhos <jiri.bluebear.dluhos(a)gmail.com>
Date: Sun Jan 22 19:46:51 2012 +0100
First implementation of partial ellipse (plus some angle-related utils).
diff --git a/include/core/GP_AngleUtils.h b/include/core/GP_AngleUtils.h
new file mode 100644
index 0000000..f896b37
--- /dev/null
+++ b/include/core/GP_AngleUtils.h
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * 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-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (c) 2012 Jiri Dluhos <jiri.bluebear.dluhos(a)gmail.com> *
+ * *
+ *****************************************************************************/
+
+#ifndef GP_ANGLE_UTILS_H
+#define GP_ANGLE_UTILS_H
+
+double GP_NormalizeAngle(double phi);
+int GP_AngleInRange(double angle, double start, double end);
+
+#endif
No newline at end of file
diff --git a/libs/core/GP_AngleUtils.c b/libs/core/GP_AngleUtils.c
new file mode 100644
index 0000000..f1c279b
--- /dev/null
+++ b/libs/core/GP_AngleUtils.c
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * 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) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
+ * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2012 Jiri Dluhos <jiri.bluebear.dluhos(a)gmail.com> *
+ * *
+ *****************************************************************************/
+
+#include "GP_AngleUtils.h"
+
+#include <math.h>
+
+double GP_NormalizeAngle(double phi)
+{
+ // clamp angle to <-2*pi, 2*pi>
+ double phi2 = fmod(phi, 2*M_PI);
+
+ // clamp angle to <0, 2*pi>
+ if (phi2 < 0)
+ phi2 += 2*M_PI;
+
+ return phi2;
+}
+
+int GP_AngleInRange(double angle, double start, double end)
+{
+ if (start < end) {
+ return (angle >= start && angle <= end);
+ } else {
+ return (angle >= start && angle <= 2*M_PI)
+ || (angle >= 0 && angle <= end);
+ }
+}
No newline at end of file
diff --git a/libs/gfx/GP_PartialEllipse.c b/libs/gfx/GP_PartialEllipse.c
new file mode 100644
index 0000000..5415a58
--- /dev/null
+++ b/libs/gfx/GP_PartialEllipse.c
@@ -0,0 +1,53 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2012 Jiri "BlueBear" Dluhos *
+ * <jiri.bluebear.dluhos(a)gmail.com> *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include "GP_Gfx.h"
+#include "core/GP_FnPerBpp.h"
+
+#include "algo/PartialEllipse.algo.h"
+
+/* Generate drawing functions for various bit depths. */
+GP_DEF_DRAW_FN_PER_BPP(GP_PartialEllipse_Raw, DEF_PARTIAL_ELLIPSE_FN)
+
+void GP_PartialEllipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size a, GP_Size b, int start, int end, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_FN_PER_BPP_CONTEXT(GP_PartialEllipse_Raw, context, context,
+ xcenter, ycenter, a, b, start, end, pixel);
+}
+
+void GP_PartialEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size a, GP_Size b, int start, int end, 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_PartialEllipse_Raw(context, xcenter, ycenter, a, b, start, end, pixel);
+}
No newline at end of file
diff --git a/libs/gfx/algo/PartialEllipse.algo.h b/libs/gfx/algo/PartialEllipse.algo.h
new file mode 100644
index 0000000..b87826e
--- /dev/null
+++ b/libs/gfx/algo/PartialEllipse.algo.h
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * 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-2010 Jiri "BlueBear" Dluhos *
+ * <jiri.bluebear.dluhos(a)gmail.com> *
+ * *
+ * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include "core/GP_AngleUtils.h"
+
+#include <math.h>
+
+/*
+ * This macro defines a partial ellipse drawing function.
+ * Arguments:
+ * CONTEXT_T - user-defined type of drawing context (passed to PUTPIXEL)
+ * PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL)
+ * PUTPIXEL - a pixel drawing function f(context, x, y, pixval)
+ * FN_NAME - name of the function to be defined
+ */
+#define DEF_PARTIAL_ELLIPSE_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) +void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, int a, int b, + int start, int end, PIXVAL_T pixval) +{ + double startAngle = GP_NormalizeAngle(2*M_PI*(start / 360000.0)); + double endAngle = GP_NormalizeAngle(2*M_PI*(end / 360000.0)); ++ int x; + for (x = -a; x <= a; x++) { + double angle = acos(((double) x) / a); + double y = floor(b*sin(angle)); + if (GP_AngleInRange(angle, startAngle, endAngle)) { + PUTPIXEL(context, xcenter+x, ycenter-y, pixval); + } + if (GP_AngleInRange(2*M_PI - angle, startAngle, endAngle)) { + PUTPIXEL(context, xcenter+x, ycenter+y, pixval); + } + } ++ int y; + for (y = -b; y <= b; y++) { + double angle = asin(((double) y) / b); + double x = floor(a*cos(angle)); + if (GP_AngleInRange(angle, startAngle, endAngle)) { + PUTPIXEL(context, xcenter+x, ycenter-y, pixval); + } + if (GP_AngleInRange(M_PI - angle, startAngle, endAngle)) { + PUTPIXEL(context, x
center-x, ycenter-y, pixval); + } + } +}
No newline at end of file
-----------------------------------------------------------------------
Summary of changes:
.../GP_DefaultFont.h => core/GP_AngleUtils.h} | 14 ++--
libs/core/{GP_GetPutPixel.c => GP_AngleUtils.c} | 38 ++++++-----
libs/gfx/{GP_Arc.c => GP_PartialEllipse.c} | 34 ++++------
.../algo/{Line.algo.h => PartialEllipse.algo.h} | 72 ++++++++------------
4 files changed, 69 insertions(+), 89 deletions(-)
copy include/{text/GP_DefaultFont.h => core/GP_AngleUtils.h} (87%)
copy libs/core/{GP_GetPutPixel.c => GP_AngleUtils.c} (74%)
copy libs/gfx/{GP_Arc.c => GP_PartialEllipse.c} (73%)
copy libs/gfx/algo/{Line.algo.h => PartialEllipse.algo.h} (66%)
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.")
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 446922190513e6535202e8f45ab897bc622390ee (commit)
from 09241d96413a6376d399b4e81219fdf2d9fb1462 (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/446922190513e6535202e8f45ab897bc6223…
commit 446922190513e6535202e8f45ab897bc622390ee
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jan 22 19:05:00 2012 +0100
filters: Blur fix row/column prefill.
diff --git a/libs/filters/GP_Linear.c b/libs/filters/GP_Linear.c
index 447e805..a55d1fe 100644
--- a/libs/filters/GP_Linear.c
+++ b/libs/filters/GP_Linear.c
@@ -154,7 +154,7 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, GP_Context *dst,
GP_Coord x, y;
uint32_t i;
int32_t ikernel[kw];
- uint32_t size = dst->w + kw;
+ uint32_t size = dst->w + kw - 1;
for (i = 0; i < kw; i++)
ikernel[i] = kernel[i] * MUL + 0.5;
@@ -179,15 +179,15 @@ int GP_FilterHLinearConvolution_Raw(const GP_Context *src, GP_Context *dst,
B[i] = GP_Pixel_GET_B_RGB888(pix);
}
- for (i = kw/2; i < src->w; i++) {
+ for (i = 0; i < src->w; i++) {
pix = GP_GetPixel_Raw_24BPP(src, i, y);
- R[i] = GP_Pixel_GET_R_RGB888(pix);
- G[i] = GP_Pixel_GET_G_RGB888(pix);
- B[i] = GP_Pixel_GET_B_RGB888(pix);
+ R[i+kw/2] = GP_Pixel_GET_R_RGB888(pix);
+ G[i+kw/2] = GP_Pixel_GET_G_RGB888(pix);
+ B[i+kw/2] = GP_Pixel_GET_B_RGB888(pix);
}
- for (i = src->w; i < size; i++) {
+ for (i = src->w + kw/2; i < size; i++) {
R[i] = GP_Pixel_GET_R_RGB888(pix);
G[i] = GP_Pixel_GET_G_RGB888(pix);
B[i] = GP_Pixel_GET_B_RGB888(pix);
@@ -233,7 +233,7 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, GP_Context *dst,
GP_Coord x, y;
uint32_t i;
int32_t ikernel[kh];
- uint32_t size = dst->h + kh;
+ uint32_t size = dst->h + kh - 1;
for (i = 0; i < kh; i++)
ikernel[i] = kernel[i] * MUL + 0.5;
@@ -258,15 +258,15 @@ int GP_FilterVLinearConvolution_Raw(const GP_Context *src, GP_Context *dst,
B[i] = GP_Pixel_GET_B_RGB888(pix);
}
- for (i = kh/2; i < src->h; i++) {
+ for (i = 0; i < src->h; i++) {
pix = GP_GetPixel_Raw_24BPP(src, x, i);
- R[i] = GP_Pixel_GET_R_RGB888(pix);
- G[i] = GP_Pixel_GET_G_RGB888(pix);
- B[i] = GP_Pixel_GET_B_RGB888(pix);
+ R[i+kh/2] = GP_Pixel_GET_R_RGB888(pix);
+ G[i+kh/2] = GP_Pixel_GET_G_RGB888(pix);
+ B[i+kh/2] = GP_Pixel_GET_B_RGB888(pix);
}
- for (i = src->h; i < size; i++) {
+ for (i = src->h + kh/2; i < size; i++) {
R[i] = GP_Pixel_GET_R_RGB888(pix);
G[i] = GP_Pixel_GET_G_RGB888(pix);
B[i] = GP_Pixel_GET_B_RGB888(pix);
-----------------------------------------------------------------------
Summary of changes:
libs/filters/GP_Linear.c | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 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.")
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 d093866437ca8adc100d6bc2a40011a26c26e813 (commit)
from c5d3e2a62fabfd142f86d47f51e313680d363ea3 (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/d093866437ca8adc100d6bc2a40011a26c26…
commit d093866437ca8adc100d6bc2a40011a26c26e813
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Jan 21 22:23:24 2012 +0100
demos: fbshow add missing -lrt.
diff --git a/demos/fbshow/Makefile b/demos/fbshow/Makefile
index 74d83fb..c5acfc4 100644
--- a/demos/fbshow/Makefile
+++ b/demos/fbshow/Makefile
@@ -4,7 +4,7 @@ CSOURCES=$(shell echo *.c)
INCLUDE=
CFLAGS+=-pthread
-LDFLAGS+=-pthread
+LDFLAGS+=-pthread -lrt
LDLIBS+=-lGP -lGP_backends -lSDL -L$(TOPDIR)/build/
APPS=fbshow
-----------------------------------------------------------------------
Summary of changes:
demos/fbshow/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
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 c5d3e2a62fabfd142f86d47f51e313680d363ea3 (commit)
from bccb0491d955bfbd1c0cb8d9ca7add8c886c50fe (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/c5d3e2a62fabfd142f86d47f51e313680d36…
commit c5d3e2a62fabfd142f86d47f51e313680d363ea3
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Jan 21 21:59:13 2012 +0100
demos: fbshow add more timers.
diff --git a/demos/fbshow/Makefile b/demos/fbshow/Makefile
index 6b04464..74d83fb 100644
--- a/demos/fbshow/Makefile
+++ b/demos/fbshow/Makefile
@@ -9,5 +9,7 @@ LDLIBS+=-lGP -lGP_backends -lSDL -L$(TOPDIR)/build/
APPS=fbshow
+fbshow: cpu_timer.o
+
include $(TOPDIR)/include.mk
include $(TOPDIR)/app.mk
diff --git a/demos/fbshow/cpu_timer.c b/demos/fbshow/cpu_timer.c
new file mode 100644
index 0000000..88455eb
--- /dev/null
+++ b/demos/fbshow/cpu_timer.c
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include "cpu_timer.h"
+
+void cpu_timer_start(struct cpu_timer *self, const char *name)
+{
+ self->name = name;
+ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &self->t_start);
+}
+
+void cpu_timer_stop(struct cpu_timer *self)
+{
+ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &self->t_stop);
+
+ int sec;
+ int nsec;
+
+ if (self->t_stop.tv_nsec < self->t_start.tv_nsec) {
+ sec = self->t_stop.tv_sec - self->t_start.tv_sec - 1;
+ nsec = self->t_stop.tv_nsec + 1000000000 - self->t_start.tv_nsec;
+ } else {
+ sec = self->t_stop.tv_sec - self->t_start.tv_sec;
+ nsec = self->t_stop.tv_nsec - self->t_start.tv_nsec;
+ }
+
+ printf("TIMER '%s' %i.%09i secn", self->name, sec, nsec);
+}
diff --git a/demos/fbshow/cpu_timer.h b/demos/fbshow/cpu_timer.h
new file mode 100644
index 0000000..1b41144
--- /dev/null
+++ b/demos/fbshow/cpu_timer.h
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * This file is part of gfxprim library. *
+ * *
+ * Gfxprim is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * Gfxprim is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with gfxprim; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
+ * Boston, MA 02110-1301 USA *
+ * *
+ * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+ /*
+
+ Simple timers to count cpu time.
+
+ */
+
+#ifndef __CPU_TIMER_H__
+#define __CPU_TIMER_H__
+
+#include <time.h>
+
+struct cpu_timer {
+ struct timespec t_start;
+ struct timespec t_stop;
+ const char *name;
+};
+
+/*
+ * Inialize cpu timer.
+ */
+void cpu_timer_start(struct cpu_timer *self, const char *name);
+
+/*
+ * Stops cpu timer and prints result.
+ */
+void cpu_timer_stop(struct cpu_timer *self);
+
+#endif /* __CPU_TIMER_H__ */
diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c
index f7ab61f..4d9f6bc 100644
--- a/demos/fbshow/fbshow.c
+++ b/demos/fbshow/fbshow.c
@@ -35,6 +35,8 @@
#include <backends/GP_Backends.h>
#include <input/GP_InputDriverLinux.h>
+#include "cpu_timer.h"
+
static GP_Pixel black_pixel;
static GP_Pixel white_pixel;
@@ -106,40 +108,14 @@ static const char *img_name(const char *img_path)
return NULL;
}
-#include <time.h>
-
-static struct timespec t_start;
-static struct timespec t_stop;
-static const char *t_name;
-
-static void timer_start(const char *name)
-{
- t_name = name;
- clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t_start);
-}
-
-static void timer_stop(void)
-{
- clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t_stop);
-
- int sec;
- int nsec;
-
- if (t_stop.tv_nsec < t_start.tv_nsec) {
- sec = t_stop.tv_sec - t_start.tv_sec - 1;
- nsec = t_stop.tv_nsec + 1000000000 - t_start.tv_nsec;
- } else {
- sec = t_stop.tv_sec - t_start.tv_sec;
- nsec = t_stop.tv_nsec - t_start.tv_nsec;
- }
-
- printf("TIMER '%s' %i.%09i secn", t_name, sec, nsec);
-}
-
static void *image_loader(void *ptr)
{
struct loader_params *params = ptr;
GP_ProgressCallback callback = {.callback = image_loader_callback};
+ struct cpu_timer timer;
+ struct cpu_timer sum_timer;
+
+ cpu_timer_start(&sum_timer, "sum");
show_progress = params->show_progress || params->show_progress_once;
params->show_progress_once = 0;
@@ -149,7 +125,8 @@ static void *image_loader(void *ptr)
GP_Context *img = NULL;
callback.priv = "Loading image";
-
+
+ cpu_timer_start(&timer, "Loading");
if (GP_LoadImage(params->img_path, &img, &callback) != 0) {
GP_Fill(context, black_pixel);
GP_Text(context, NULL, context->w/2, context->h/2,
@@ -157,7 +134,8 @@ static void *image_loader(void *ptr)
"Failed to load image :(");
return NULL;
}
-
+ cpu_timer_stop(&timer);
+
GP_Size w, h;
switch (rotate) {
@@ -189,16 +167,18 @@ static void *image_loader(void *ptr)
GP_Context *ret;
if (rat < 1) {
- timer_start("blur");
+ cpu_timer_start(&timer, "Blur");
callback.priv = "Blurring Image";
if (GP_FilterGaussianBlur(img, img, 0.5/rat, 0.5/rat, &callback) == NULL)
return NULL;
- timer_stop();
+ cpu_timer_stop(&timer);
}
+ cpu_timer_start(&timer, "Resampling");
callback.priv = "Resampling Image";
ret = GP_FilterResize(img, NULL, GP_INTERP_CUBIC_INT, img->w * rat, img->h * rat, &callback);
GP_ContextFree(img);
+ cpu_timer_stop(&timer);
if (ret == NULL)
return NULL;
@@ -240,6 +220,8 @@ static void *image_loader(void *ptr)
GP_FillRectXYWH(context, ret->w+cx, 0, cx, context->h, black_pixel);
GP_FillRectXYWH(context, 0, ret->h+cy, context->w, cy, black_pixel);
+ cpu_timer_stop(&sum_timer);
+
if (!params->show_info) {
GP_BackendFlip(backend);
return NULL;
-----------------------------------------------------------------------
Summary of changes:
demos/fbshow/Makefile | 2 +
.../GP_Backends.h => demos/fbshow/cpu_timer.c | 37 ++++++++------
.../GP_Backends.h => demos/fbshow/cpu_timer.h | 29 +++++++----
demos/fbshow/fbshow.c | 50 ++++++-------------
4 files changed, 57 insertions(+), 61 deletions(-)
copy include/backends/GP_Backends.h => demos/fbshow/cpu_timer.c (71%)
copy include/backends/GP_Backends.h => demos/fbshow/cpu_timer.h (80%)
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.")