fb_accel_td: implement setBlendMode/Level

This commit is contained in:
Stefan Seyfried
2017-02-11 18:52:39 +01:00
parent 6d73a4465d
commit 3d2b56713f
2 changed files with 30 additions and 0 deletions

View File

@@ -150,6 +150,8 @@ class CFbAccelTD
void paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col);
void blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t xoff, uint32_t yoff, uint32_t xp, uint32_t yp, bool transp);
void waitForIdle(const char *func = NULL);
void setBlendMode(uint8_t);
void setBlendLevel(int);
};
#endif

View File

@@ -30,6 +30,7 @@
#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <memory.h>
@@ -143,6 +144,7 @@ void CFbAccelTD::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32_t
void CFbAccelTD::init(const char *)
{
CFrameBuffer::init();
fcntl(fd, F_SETFD, FD_CLOEXEC);
if (lfb == NULL) {
printf(LOGTAG "CFrameBuffer::init() failed.\n");
return; /* too bad... */
@@ -174,3 +176,29 @@ int CFbAccelTD::setMode(unsigned int, unsigned int, unsigned int)
backbuffer = lfb; /* will not work well, but avoid crashes */
return 0;
}
void CFbAccelTD::setBlendMode(uint8_t mode)
{
Stb04GFXOsdControl g;
ioctl(gfxfd, STB04GFX_OSD_GETCONTROL, &g);
g.use_global_alpha = (mode == 2); /* 1 == pixel alpha, 2 == global alpha */
ioctl(gfxfd, STB04GFX_OSD_SETCONTROL, &g);
}
void CFbAccelTD::setBlendLevel(int level)
{
/* this is bypassing directfb, but faster and easier */
Stb04GFXOsdControl g;
ioctl(gfxfd, STB04GFX_OSD_GETCONTROL, &g);
if (g.use_global_alpha == 0)
return;
if (level < 0 || level > 100)
return;
/* this is the same as convertSetupAlpha2Alpha(), but non-float */
g.global_alpha = 255 - (255 * level / 100);
ioctl(gfxfd, STB04GFX_OSD_SETCONTROL, &g);
if (level == 100) // sucks
usleep(20000);
}