From 1c7a7a15af186866ce90d5f62eeb25f506be599f Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Wed, 9 Mar 2016 10:29:23 +0200 Subject: [PATCH] kmsview: show multiple frames --- tests/kmsview.cpp | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/tests/kmsview.cpp b/tests/kmsview.cpp index cafd160..7bd67a4 100644 --- a/tests/kmsview.cpp +++ b/tests/kmsview.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "kms++.h" @@ -8,6 +9,17 @@ using namespace std; using namespace kms; +static void read_frame(ifstream& is, DumbFramebuffer* fb, Crtc* crtc, Plane* plane) +{ + is.read((char*)fb->map(0), fb->size(0)); + + int r = crtc->set_plane(plane, *fb, + 0, 0, fb->width(), fb->height(), + 0, 0, fb->width(), fb->height()); + + ASSERT(r == 0); +} + int main(int argc, char** argv) { if (argc != 5) { @@ -22,6 +34,14 @@ int main(int argc, char** argv) auto pixfmt = FourCCToPixelFormat(modestr); + + ifstream is(filename, ifstream::binary); + + is.seekg(0, std::ios::end); + unsigned fsize = is.tellg(); + is.seekg(0); + + Card card; auto conn = card.get_first_connected_connector(); @@ -29,10 +49,6 @@ int main(int argc, char** argv) auto fb = new DumbFramebuffer(card, w, h, pixfmt); - ifstream is(filename, ifstream::binary); - is.read((char*)fb->map(0), fb->size(0)); - is.close(); - Plane* plane = 0; for (Plane* p : crtc->get_possible_planes()) { @@ -48,14 +64,20 @@ int main(int argc, char** argv) FAIL_IF(!plane, "available plane not found"); - int r = crtc->set_plane(plane, *fb, - 0, 0, w, h, - 0, 0, w, h); - ASSERT(r == 0); + unsigned num_frames = fsize / fb->size(0); + printf("file size %u, frames %u\n", fsize, num_frames); + + for (unsigned i = 0; i < num_frames; ++i) { + printf("frame %d\n", i); + read_frame(is, fb, crtc, plane); + usleep(1000*50); + } printf("press enter to exit\n"); + is.close(); + getchar(); delete fb; -- 2.39.2