diff options
-rw-r--r-- | src/frontend_linux.c | 6 | ||||
-rw-r--r-- | src/frontend_sdl.c | 1 | ||||
-rw-r--r-- | test/plottest.c | 88 |
3 files changed, 56 insertions, 39 deletions
diff --git a/src/frontend_linux.c b/src/frontend_linux.c index 3790a76..ce34cec 100644 --- a/src/frontend_linux.c +++ b/src/frontend_linux.c @@ -13,18 +13,22 @@ #include "libnsfb_event.h" #include "nsfb.h" #include "frontend.h" +#include "plotters.h" #define UNUSED(x) ((x) = (x)) static int linux_set_geometry(nsfb_t *nsfb, int width, int height, int bpp) { if (nsfb->frontend_priv != NULL) - return -1; /* if were already initialised fail */ + return -1; /* if we are already initialised fail */ nsfb->width = width; nsfb->height = height; nsfb->bpp = bpp; + /* select default sw plotters for bpp */ + select_plotters(nsfb); + return 0; } diff --git a/src/frontend_sdl.c b/src/frontend_sdl.c index cc73f43..d40eb7b 100644 --- a/src/frontend_sdl.c +++ b/src/frontend_sdl.c @@ -386,6 +386,7 @@ sdlcopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox) nsfb_plot_add_rect(srcbox, dstbox, &allbox); + /* clear the cursor if its within the region to be altered */ if ((cursor != NULL) && (cursor->plotted == true) && (nsfb_plot_bbox_intersect(&allbox, &cursor->loc))) { diff --git a/test/plottest.c b/test/plottest.c index 522cf82..3fc4d83 100644 --- a/test/plottest.c +++ b/test/plottest.c @@ -1,3 +1,5 @@ +/* libnsfb plotetr test program */ + #include <stdio.h> #include <stdbool.h> #include <stdlib.h> @@ -21,22 +23,22 @@ const struct { 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 */ + 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 */ } }; @@ -46,22 +48,22 @@ const struct { unsigned char data[16 * 8]; } Mglyph8 = { 8, 16, { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00000000 */ - 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, /* 00000000 */ - 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11000110 */ - 0xaa, 0xff, 0xff, 0x00, 0xff, 0xff, 0xaa, 0x00, /* 11101110 */ - 0xaa, 0xff, 0xff, 0xff, 0xff, 0xff, 0xaa, 0x00, /* 11111110 */ - 0xaa, 0xff, 0xff, 0xff, 0xff, 0xff, 0xaa, 0x00, /* 11111110 */ - 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11010110 */ - 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11000110 */ - 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11000110 */ - 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11000110 */ - 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11000110 */ - 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11000110 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00000000 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00000000 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00000000 */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00000000 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00000000 */ + 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, /* 00000000 */ + 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11000110 */ + 0xaa, 0xff, 0xff, 0x00, 0xff, 0xff, 0xaa, 0x00, /* 11101110 */ + 0xaa, 0xff, 0xff, 0xff, 0xff, 0xff, 0xaa, 0x00, /* 11111110 */ + 0xaa, 0xff, 0xff, 0xff, 0xff, 0xff, 0xaa, 0x00, /* 11111110 */ + 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11010110 */ + 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11000110 */ + 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11000110 */ + 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11000110 */ + 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11000110 */ + 0xaa, 0xff, 0x00, 0x00, 0x00, 0xff, 0xaa, 0x00, /* 11000110 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00000000 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00000000 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00000000 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00000000 */ } }; @@ -100,7 +102,7 @@ int main(int argc, char **argv) /* claim the whole screen for update */ nsfb_claim(nsfb, &box); - /* first test, repeatedly clear the graphics area, should result in teh + /* first test, repeatedly clear the graphics area, should result in the * same operation as a single clear to the final colour */ for (loop = 0; loop < 256;loop++) { @@ -190,7 +192,17 @@ int main(int argc, char **argv) nsfb_plot_ellipse(nsfb, &box3, 0xffff0000); - nsfb_plot_copy(nsfb,400,400,100,100,600,200); + box2.x0 = 400; + box2.y0 = 400; + box2.x1 = 500; + box2.y1 = 500; + + box3.x0 = 600; + box3.y0 = 200; + box3.x1 = 700; + box3.y1 = 300; + + nsfb_plot_copy(nsfb, &box2, &box3); box3.x0 = 50; box3.x1 = 200; @@ -219,7 +231,7 @@ int main(int argc, char **argv) nsfb_plot_glyph8(nsfb, &box3, Mglyph8.data, Mglyph8.w, 0xff000000); } - nsfb_release(nsfb, &box); + nsfb_update(nsfb, &box); /* random rectangles in clipped area*/ box2.x0 = 400; @@ -232,18 +244,18 @@ int main(int argc, char **argv) srand(1234); for (loop=0; loop < 10000; loop++) { - nsfb_claim(nsfb, &box2); + nsfb_claim(nsfb, &box2); box3.x0 = rand() / (RAND_MAX / box.x1); box3.y0 = rand() / (RAND_MAX / box.y1); box3.x1 = rand() / (RAND_MAX / 400); box3.y1 = rand() / (RAND_MAX / 400); nsfb_plot_rectangle_fill(nsfb, &box3, 0xff000000 | rand()); - nsfb_release(nsfb, &box2); + nsfb_update(nsfb, &box2); } while (event.type != NSFB_EVENT_CONTROL) - nsfb_input(nsfb, &event, -1); + nsfb_event(nsfb, &event, -1); return 0; } |