summaryrefslogtreecommitdiff
path: root/test/polygon.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2011-11-21 08:44:10 +0000
committerVincent Sanders <vince@netsurf-browser.org>2011-11-21 08:44:10 +0000
commit2dd32c7adb7116f1ad9ab2632d9fcf57a31e9fa2 (patch)
tree3528ebeb39ee0aadaf7faf0259b583b26172ed5c /test/polygon.c
parent81ad700162a2fa639a69c1c6e3969ed8f7b3f63b (diff)
downloadlibnsfb-2dd32c7adb7116f1ad9ab2632d9fcf57a31e9fa2.tar.gz
libnsfb-2dd32c7adb7116f1ad9ab2632d9fcf57a31e9fa2.tar.bz2
Improve API to allow for RAM surfaces instead of direct blitting
Improve and update tests Fix RAM surface Fix VNC surface svn path=/trunk/libnsfb/; revision=13158
Diffstat (limited to 'test/polygon.c')
-rw-r--r--test/polygon.c55
1 files changed, 45 insertions, 10 deletions
diff --git a/test/polygon.c b/test/polygon.c
index cd7efd8..e91846f 100644
--- a/test/polygon.c
+++ b/test/polygon.c
@@ -14,8 +14,12 @@
int main(int argc, char **argv)
{
+ const char *fename;
+ enum nsfb_type_e fetype;
nsfb_t *nsfb;
nsfb_event_t event;
+ int waitloop = 3;
+
nsfb_bbox_t box;
uint8_t *fbptr;
int fbstride;
@@ -26,25 +30,35 @@ int main(int argc, char **argv)
int loop;
// nsfb_plot_pen_t pen;
- UNUSED(argc);
- UNUSED(argv);
+ if (argc < 2) {
+ fename="sdl";
+ } else {
+ fename = argv[1];
+ }
- nsfb = nsfb_init(NSFB_FRONTEND_SDL);
- if (nsfb == NULL) {
- fprintf(stderr, "Unable to initialise nsfb with SDL frontend\n");
+ fetype = nsfb_type_from_name(fename);
+ if (fetype == NSFB_SURFACE_NONE) {
+ fprintf(stderr, "Unable to convert \"%s\" to nsfb surface type\n", fename);
return 1;
}
- if (nsfb_init_frontend(nsfb) == -1) {
- fprintf(stderr, "Unable to initialise nsfb frontend\n");
+ nsfb = nsfb_new(fetype);
+ if (nsfb == NULL) {
+ fprintf(stderr, "Unable to allocate \"%s\" nsfb surface\n", fename);
return 2;
}
+ if (nsfb_init(nsfb) == -1) {
+ fprintf(stderr, "Unable to initialise nsfb surface\n");
+ nsfb_free(nsfb);
+ return 4;
+ }
+
/* get the geometry of the whole screen */
box.x0 = box.y0 = 0;
nsfb_get_geometry(nsfb, &box.x1, &box.y1, NULL);
- nsfb_get_framebuffer(nsfb, &fbptr, &fbstride);
+ nsfb_get_buffer(nsfb, &fbptr, &fbstride);
/* claim the whole screen for update */
nsfb_claim(nsfb, &box);
@@ -72,8 +86,29 @@ int main(int argc, char **argv)
nsfb_update(nsfb, &box);
- while (event.type != NSFB_EVENT_CONTROL)
- nsfb_event(nsfb, &event, -1);
+ /* wait for quit event or timeout */
+ while (waitloop > 0) {
+ if (nsfb_event(nsfb, &event, 1000) == false) {
+ break;
+ }
+ if (event.type == NSFB_EVENT_CONTROL) {
+ if (event.value.controlcode == NSFB_CONTROL_TIMEOUT) {
+ /* timeout */
+ waitloop--;
+ } else if (event.value.controlcode == NSFB_CONTROL_QUIT) {
+ break;
+ }
+ }
+ }
+
+ nsfb_free(nsfb);
return 0;
}
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * End:
+ */