X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fmain.h;h=bfd9fac554aa17b40c51de97c961864eb8d09629;hp=7cfa22c739ef14edac3f0e85fd0ac4d4e9b9ecea;hb=c9ce50e17952b0feeec68758444a50302a0aafba;hpb=4f0feb025e48aaaa0ffe0226c5135e116d1cb986 diff --git a/src/main.h b/src/main.h index 7cfa22c..bfd9fac 100644 --- a/src/main.h +++ b/src/main.h @@ -13,22 +13,31 @@ inline void OverlayBMP(Document & doc, const char * input, const char * output, { View view(doc, bounds, c); Screen scr; - //view.Render(); - scr.RenderBMP(input); + if (input != NULL) + scr.RenderBMP(input); + view.Render(); + if (output != NULL) + scr.ScreenShot(output); scr.Present(); - sleep(1); - scr.ScreenShot(output); - sleep(1); } inline void MainLoop(Document & doc, const Rect & bounds = Rect(0,0,1,1), const Colour & c = Colour(0.f,0.f,0.f,1.f)) { View view(doc,bounds, c); Screen scr; + scr.DebugFontInit("DejaVuSansMono.ttf"); scr.SetMouseHandler([&](int x, int y, int buttons, int wheel) // [?] wtf { static bool oldButtonDown = false; static int oldx, oldy; + if (buttons > 1 && !oldButtonDown) + { + oldButtonDown = true; + view.ToggleGPUTransform(); + oldx = x; + oldy = y; + return; + } if (buttons && !oldButtonDown) { // We're beginning a drag. @@ -56,9 +65,22 @@ inline void MainLoop(Document & doc, const Rect & bounds = Rect(0,0,1,1), const } ); + double init_time = SDL_GetPerformanceCounter(); while (scr.PumpEvents()) { + scr.Clear(); view.Render(); + scr.DebugFontPrintF("[CPU] Render took %lf ms (%lf FPS)\n", (SDL_GetPerformanceCounter() - init_time)* 1000.0/SDL_GetPerformanceFrequency(), SDL_GetPerformanceFrequency()/(SDL_GetPerformanceCounter() - init_time)); + scr.DebugFontPrintF("View bounds: (%f, %f) - (%f, %f)\n", view.GetBounds().x, view.GetBounds().y, view.GetBounds().w, view.GetBounds().h); + if (view.UsingGPUTransform()) + { + scr.DebugFontPrint("Doing coordinate transform on the GPU.\n"); + } + else + { + scr.DebugFontPrint("Doing coordinate transform on the CPU.\n"); + } scr.Present(); + init_time = SDL_GetPerformanceCounter(); } }