X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Ffbdev%2Fgfx.cc;h=db579ffa0779abe6d34d428789c31d8cb5665d50;hb=c4ab1fa2768863098306862047bdb1116bd62a24;hp=c207b0cb0e3372e4b277577e6717705bbc405114;hpb=8f628fa4e4af94adca4db9c6cc41cf016e0c3677;p=winnie diff --git a/src/fbdev/gfx.cc b/src/fbdev/gfx.cc index c207b0c..db579ff 100644 --- a/src/fbdev/gfx.cc +++ b/src/fbdev/gfx.cc @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -54,6 +55,16 @@ bool init_gfx() return false; } + fb_vblank vblank; + if(ioctl(dev_fd, FBIOGET_VBLANK, &vblank) == -1) { + fprintf(stderr, "FBIOGET_VBLANK error: %s\n", strerror(errno)); + } + else { + printf("flags: %x\n", vblank.flags); + printf("count: %d\n", vblank.count); + printf("beam position: %d, %d\n", vblank.hcount, vblank.vcount); + } + return true; } @@ -96,18 +107,20 @@ void fill_rect(const Rect &rect, int r, int g, int b) Rect drect = rect; if(drect.x < screen_rect.x) { + drect.width -= screen_rect.x - drect.x; drect.x = screen_rect.x; } if(drect.y < screen_rect.y) { + drect.height -= screen_rect.y - drect.y; drect.y = screen_rect.y; } - if(drect.x + drect.width > screen_rect.width) { + if(drect.x + drect.width >= screen_rect.x + screen_rect.width) { drect.width = screen_rect.width - drect.x; } - if(drect.y + drect.height > screen_rect.height) { + if(drect.y + drect.height >= screen_rect.y + screen_rect.height) { drect.height = screen_rect.height - drect.y; } @@ -231,4 +244,19 @@ void gfx_update() { } +void wait_vsync() +{ + unsigned long arg = 0; + + timeval tvstart, tvend; + gettimeofday(&tvstart, 0); + + if(ioctl(dev_fd, FBIO_WAITFORVSYNC, &arg) == -1) { + printf("ioctl error %s\n", strerror(errno)); + } + + gettimeofday(&tvend, 0); + printf("%ld %ld\n", tvend.tv_sec - tvstart.tv_sec, tvend.tv_usec - tvstart.tv_usec); +} + #endif // WINNIE_FBDEV