From 116aba09b038f1e11bc044867d3970efd2d0bbc0 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 28 Sep 2013 11:57:26 +0200 Subject: [PATCH] fbaccel: auto-blit, obsoleting the explicit blit() calls probably needs refining on some platforms --- src/driver/fbaccel.cpp | 31 ++++++++++++++++++++++++------- src/driver/framebuffer_ng.cpp | 7 +++---- src/driver/framebuffer_ng.h | 2 +- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/driver/fbaccel.cpp b/src/driver/fbaccel.cpp index 8c1e8dec2..3a952c4fb 100644 --- a/src/driver/fbaccel.cpp +++ b/src/driver/fbaccel.cpp @@ -57,6 +57,13 @@ extern GLFramebuffer *glfb; #endif #include +#include + +#if HAVE_COOL_HARDWARE || HAVE_TRIPLEDRAGON +#define NEED_BLIT_THREAD 0 +#else +#define NEED_BLIT_THREAD 1 +#endif //#undef USE_NEVIS_GXA //FIXME /*******************************************************************************/ @@ -185,6 +192,7 @@ void CFbAccel::waitForIdle(void) CFbAccel::CFbAccel(CFrameBuffer *_fb) { + blit_thread = false; fb = _fb; lastcol = 0xffffffff; lbb = fb->lfb; /* the memory area to draw to... */ @@ -245,9 +253,6 @@ CFbAccel::CFbAccel(CFrameBuffer *_fb) return; } #endif -#if HAVE_SPARK_HARDWARE || HAVE_AZBOX_HARDWARE - OpenThreads::Thread::start(); -#endif #ifdef USE_NEVIS_GXA /* Open /dev/mem for HW-register access */ @@ -269,18 +274,21 @@ CFbAccel::CFbAccel(CFrameBuffer *_fb) /* TODO: what to do here? does this really happen? */ ; #endif /* USE_NEVIS_GXA */ + +#if NEED_BLIT_THREAD + /* start the autoblit-thread (run() function) */ + OpenThreads::Thread::start(); +#endif }; CFbAccel::~CFbAccel() { -#if HAVE_SPARK_HARDWARE || HAVE_AZBOX_HARDWARE if (blit_thread) { blit_thread = false; blit(); /* wakes up the thread */ OpenThreads::Thread::join(); } -#endif #if HAVE_SPARK_HARDWARE if (backbuffer) { @@ -434,6 +442,7 @@ void CFbAccel::paintRect(const int x, const int y, const int dx, const int dy, c line++; } #endif + blit(); } void CFbAccel::paintPixel(const int x, const int y, const fb_pixel_t col) @@ -557,6 +566,7 @@ void CFbAccel::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col) paintPixel(x, y, col); } } + blit(); #endif } @@ -663,6 +673,7 @@ void CFbAccel::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t x } d += fb->stride; } + blit(); #if 0 for(int i = 0; i < yc; i++){ memmove(clfb + (i + yoff)*stride + xoff*4, ip + (i + yp)*width + xp, xc*4); @@ -731,22 +742,28 @@ void CFbAccel::run() { printf("CFbAccel::run start\n"); time_t last_blit = 0; + bool finished = false; /* one last blit after everything is done */ blit_pending = false; blit_thread = true; blit_mutex.lock(); + set_threadname("fb::autoblit"); while (blit_thread) { - if (blit_pending) - blit_cond.wait(&blit_mutex, BLIT_INTERVAL+1); + // printf("blit_pending: %d finish: %d\n", blit_pending, finish); + if (blit_pending || finished) + blit_cond.wait(&blit_mutex, BLIT_INTERVAL); else blit_cond.wait(&blit_mutex); time_t now = time_monotonic_ms(); if (now - last_blit < BLIT_INTERVAL) { blit_pending = true; + finished = false; //printf("CFbAccel::run: skipped, time %ld\n", now - last_blit); } else { + /* we timed out => add one more blit, just to make sure */ + finished = !finished; blit_pending = false; blit_mutex.unlock(); _blit(); diff --git a/src/driver/framebuffer_ng.cpp b/src/driver/framebuffer_ng.cpp index 14d079569..af8e8f92b 100644 --- a/src/driver/framebuffer_ng.cpp +++ b/src/driver/framebuffer_ng.cpp @@ -786,7 +786,7 @@ bool CFrameBuffer::paintIcon8(const std::string & filename, const int x, const i d += stride; } close(lfd); - blit(); + accel->blit(); return true; } @@ -1081,12 +1081,12 @@ void CFrameBuffer::paintBackground() for (int i = 0; i < 576; i++) memmove(((uint8_t *)getFrameBufferPointer()) + i * stride, (background + i * BACKGROUNDIMAGEWIDTH), BACKGROUNDIMAGEWIDTH * sizeof(fb_pixel_t)); checkFbArea(0, 0, xRes, yRes, false); + accel->blit(); } else { paintBoxRel(0, 0, xRes, yRes, backgroundColor); } - blit(); } void CFrameBuffer::SaveScreen(int x, int y, int dx, int dy, fb_pixel_t * const memp) @@ -1131,7 +1131,7 @@ void CFrameBuffer::RestoreScreen(int x, int y, int dx, int dy, fb_pixel_t * cons fbpos += stride; bkpos += dx; } - blit(); + accel->blit(); checkFbArea(x, y, dx, dy, false); } @@ -1253,7 +1253,6 @@ void CFrameBuffer::paintMuteIcon(bool paint, int ax, int ay, int dx, int dy, boo } else paintBackgroundBoxRel(ax, ay, dx, dy); - blit(); } void CFrameBuffer::setFbArea(int element, int _x, int _y, int _dx, int _dy) diff --git a/src/driver/framebuffer_ng.h b/src/driver/framebuffer_ng.h index 82296041b..50789be42 100644 --- a/src/driver/framebuffer_ng.h +++ b/src/driver/framebuffer_ng.h @@ -270,7 +270,7 @@ class CFrameBuffer bool blitToPrimary(unsigned int * data, int dx, int dy, int sw, int sh); void mark(int x, int y, int dx, int dy) { accel->mark(x, y, dx, dy); }; - void blit() { accel->blit(); }; + void blit() {}; void paintMuteIcon(bool paint, int ax, int ay, int dx, int dy, bool paintFrame=true); enum