fbaccel: auto-blit, obsoleting the explicit blit() calls

probably needs refining on some platforms
This commit is contained in:
Stefan Seyfried
2013-09-28 11:57:26 +02:00
parent cfadfe3ae9
commit 116aba09b0
3 changed files with 28 additions and 12 deletions

View File

@@ -57,6 +57,13 @@ extern GLFramebuffer *glfb;
#endif #endif
#include <driver/abstime.h> #include <driver/abstime.h>
#include <system/set_threadname.h>
#if HAVE_COOL_HARDWARE || HAVE_TRIPLEDRAGON
#define NEED_BLIT_THREAD 0
#else
#define NEED_BLIT_THREAD 1
#endif
//#undef USE_NEVIS_GXA //FIXME //#undef USE_NEVIS_GXA //FIXME
/*******************************************************************************/ /*******************************************************************************/
@@ -185,6 +192,7 @@ void CFbAccel::waitForIdle(void)
CFbAccel::CFbAccel(CFrameBuffer *_fb) CFbAccel::CFbAccel(CFrameBuffer *_fb)
{ {
blit_thread = false;
fb = _fb; fb = _fb;
lastcol = 0xffffffff; lastcol = 0xffffffff;
lbb = fb->lfb; /* the memory area to draw to... */ lbb = fb->lfb; /* the memory area to draw to... */
@@ -245,9 +253,6 @@ CFbAccel::CFbAccel(CFrameBuffer *_fb)
return; return;
} }
#endif #endif
#if HAVE_SPARK_HARDWARE || HAVE_AZBOX_HARDWARE
OpenThreads::Thread::start();
#endif
#ifdef USE_NEVIS_GXA #ifdef USE_NEVIS_GXA
/* Open /dev/mem for HW-register access */ /* Open /dev/mem for HW-register access */
@@ -269,18 +274,21 @@ CFbAccel::CFbAccel(CFrameBuffer *_fb)
/* TODO: what to do here? does this really happen? */ /* TODO: what to do here? does this really happen? */
; ;
#endif /* USE_NEVIS_GXA */ #endif /* USE_NEVIS_GXA */
#if NEED_BLIT_THREAD
/* start the autoblit-thread (run() function) */
OpenThreads::Thread::start();
#endif
}; };
CFbAccel::~CFbAccel() CFbAccel::~CFbAccel()
{ {
#if HAVE_SPARK_HARDWARE || HAVE_AZBOX_HARDWARE
if (blit_thread) if (blit_thread)
{ {
blit_thread = false; blit_thread = false;
blit(); /* wakes up the thread */ blit(); /* wakes up the thread */
OpenThreads::Thread::join(); OpenThreads::Thread::join();
} }
#endif
#if HAVE_SPARK_HARDWARE #if HAVE_SPARK_HARDWARE
if (backbuffer) if (backbuffer)
{ {
@@ -434,6 +442,7 @@ void CFbAccel::paintRect(const int x, const int y, const int dx, const int dy, c
line++; line++;
} }
#endif #endif
blit();
} }
void CFbAccel::paintPixel(const int x, const int y, const fb_pixel_t col) 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); paintPixel(x, y, col);
} }
} }
blit();
#endif #endif
} }
@@ -663,6 +673,7 @@ void CFbAccel::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t x
} }
d += fb->stride; d += fb->stride;
} }
blit();
#if 0 #if 0
for(int i = 0; i < yc; i++){ for(int i = 0; i < yc; i++){
memmove(clfb + (i + yoff)*stride + xoff*4, ip + (i + yp)*width + xp, xc*4); 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"); printf("CFbAccel::run start\n");
time_t last_blit = 0; time_t last_blit = 0;
bool finished = false; /* one last blit after everything is done */
blit_pending = false; blit_pending = false;
blit_thread = true; blit_thread = true;
blit_mutex.lock(); blit_mutex.lock();
set_threadname("fb::autoblit");
while (blit_thread) { while (blit_thread) {
if (blit_pending) // printf("blit_pending: %d finish: %d\n", blit_pending, finish);
blit_cond.wait(&blit_mutex, BLIT_INTERVAL+1); if (blit_pending || finished)
blit_cond.wait(&blit_mutex, BLIT_INTERVAL);
else else
blit_cond.wait(&blit_mutex); blit_cond.wait(&blit_mutex);
time_t now = time_monotonic_ms(); time_t now = time_monotonic_ms();
if (now - last_blit < BLIT_INTERVAL) if (now - last_blit < BLIT_INTERVAL)
{ {
blit_pending = true; blit_pending = true;
finished = false;
//printf("CFbAccel::run: skipped, time %ld\n", now - last_blit); //printf("CFbAccel::run: skipped, time %ld\n", now - last_blit);
} }
else else
{ {
/* we timed out => add one more blit, just to make sure */
finished = !finished;
blit_pending = false; blit_pending = false;
blit_mutex.unlock(); blit_mutex.unlock();
_blit(); _blit();

View File

@@ -786,7 +786,7 @@ bool CFrameBuffer::paintIcon8(const std::string & filename, const int x, const i
d += stride; d += stride;
} }
close(lfd); close(lfd);
blit(); accel->blit();
return true; return true;
} }
@@ -1081,12 +1081,12 @@ void CFrameBuffer::paintBackground()
for (int i = 0; i < 576; i++) for (int i = 0; i < 576; i++)
memmove(((uint8_t *)getFrameBufferPointer()) + i * stride, (background + i * BACKGROUNDIMAGEWIDTH), BACKGROUNDIMAGEWIDTH * sizeof(fb_pixel_t)); memmove(((uint8_t *)getFrameBufferPointer()) + i * stride, (background + i * BACKGROUNDIMAGEWIDTH), BACKGROUNDIMAGEWIDTH * sizeof(fb_pixel_t));
checkFbArea(0, 0, xRes, yRes, false); checkFbArea(0, 0, xRes, yRes, false);
accel->blit();
} }
else else
{ {
paintBoxRel(0, 0, xRes, yRes, backgroundColor); paintBoxRel(0, 0, xRes, yRes, backgroundColor);
} }
blit();
} }
void CFrameBuffer::SaveScreen(int x, int y, int dx, int dy, fb_pixel_t * const memp) 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; fbpos += stride;
bkpos += dx; bkpos += dx;
} }
blit(); accel->blit();
checkFbArea(x, y, dx, dy, false); 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 else
paintBackgroundBoxRel(ax, ay, dx, dy); paintBackgroundBoxRel(ax, ay, dx, dy);
blit();
} }
void CFrameBuffer::setFbArea(int element, int _x, int _y, int _dx, int _dy) void CFrameBuffer::setFbArea(int element, int _x, int _y, int _dx, int _dy)

View File

@@ -270,7 +270,7 @@ class CFrameBuffer
bool blitToPrimary(unsigned int * data, int dx, int dy, int sw, int sh); 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 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); void paintMuteIcon(bool paint, int ax, int ay, int dx, int dy, bool paintFrame=true);
enum enum