From 56dd658e6265fb1902c92d6d88420c3accb79225 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Fri, 27 Jul 2012 12:28:24 +0100 Subject: Simple tester for hammering glyph render function. --- test/Makefile | 2 +- test/text-speed.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 test/text-speed.c diff --git a/test/Makefile b/test/Makefile index c11f489..64210be 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,3 +1,3 @@ -DIR_TEST_ITEMS := plottest:plottest.c bitmap:bitmap.c;nsglobe.c frontend:frontend.c bezier:bezier.c path:path.c polygon:polygon.c polystar:polystar.c polystar2:polystar2.c +DIR_TEST_ITEMS := text-speed:text-speed.c plottest:plottest.c bitmap:bitmap.c;nsglobe.c frontend:frontend.c bezier:bezier.c path:path.c polygon:polygon.c polystar:polystar.c polystar2:polystar2.c include $(NSBUILD)/Makefile.subdir diff --git a/test/text-speed.c b/test/text-speed.c new file mode 100644 index 0000000..e09f606 --- /dev/null +++ b/test/text-speed.c @@ -0,0 +1,112 @@ +/* libnsfb plotter test program */ + +#include +#include +#include +#include +#include +#include +#include + +#include "libnsfb.h" +#include "libnsfb_plot.h" +#include "libnsfb_event.h" + +#define UNUSED(x) ((x) = (x)) + +const struct { + unsigned int w; + unsigned int h; + unsigned char data[16]; +} Mglyph1 = { + 8, 16, + { + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0xc6, /* 11000110 */ + 0xee, /* 11101110 */ + 0xfe, /* 11111110 */ + 0xfe, /* 11111110 */ + 0xd6, /* 11010110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0xc6, /* 11000110 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + 0x00, /* 00000000 */ + } +}; + +int main(int argc, char **argv) +{ + const char *fename; + enum nsfb_type_e fetype; + nsfb_t *nsfb; + + nsfb_bbox_t box; + nsfb_bbox_t box3; + uint8_t *fbptr; + int fbstride; + int i; + unsigned int x, y; + + if (argc < 2) { + fename="sdl"; + } else { + fename = argv[1]; + } + + fetype = nsfb_type_from_name(fename); + if (fetype == NSFB_SURFACE_NONE) { + printf("Unable to convert \"%s\" to nsfb surface type\n", + fename); + return EXIT_FAILURE; + } + + nsfb = nsfb_new(fetype); + if (nsfb == NULL) { + printf("Unable to allocate \"%s\" nsfb surface\n", fename); + return EXIT_FAILURE; + } + + if (nsfb_init(nsfb) == -1) { + printf("Unable to initialise nsfb surface\n"); + nsfb_free(nsfb); + return EXIT_FAILURE; + } + + /* get the geometry of the whole screen */ + box.x0 = box.y0 = 0; + nsfb_get_geometry(nsfb, &box.x1, &box.y1, NULL); + + nsfb_get_buffer(nsfb, &fbptr, &fbstride); + nsfb_claim(nsfb, &box); + + /* Clear to white */ + nsfb_plot_clg(nsfb, 0xffffffff); + nsfb_update(nsfb, &box); + + /* test glyph plotting */ + for (i = 0; i < 1000; i++) { + for (y = 0; y < box.y1 - Mglyph1.h; y += Mglyph1.h) { + for (x = 0; x < box.x1 - Mglyph1.w; x += Mglyph1.w) { + box3.x0 = x; + box3.y0 = y; + box3.x1 = box3.x0 + Mglyph1.w; + box3.y1 = box3.y0 + Mglyph1.h; + + nsfb_plot_glyph1(nsfb, &box3, Mglyph1.data, + Mglyph1.w, 0xff000000); + } + } + nsfb_update(nsfb, &box); + } + + nsfb_update(nsfb, &box); + nsfb_free(nsfb); + + return 0; +} -- cgit v1.2.3