mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 23:13:13 +02:00
raw icon cache
git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@185 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -890,13 +890,74 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in
|
|||||||
if (lfd == -1)
|
if (lfd == -1)
|
||||||
lfd = open((iconBasePath + filename).c_str(), O_RDONLY);
|
lfd = open((iconBasePath + filename).c_str(), O_RDONLY);
|
||||||
#endif
|
#endif
|
||||||
|
uint8_t * data;
|
||||||
|
uint8_t transp;
|
||||||
|
|
||||||
|
std::map<std::string, rawIcon>::iterator it;
|
||||||
|
it = icon_cache.find((iconBasePath + filename).c_str());
|
||||||
|
if(it == icon_cache.end()) {
|
||||||
|
struct rawIcon tmpIcon;
|
||||||
|
|
||||||
lfd = open((iconBasePath + filename).c_str(), O_RDONLY);
|
lfd = open((iconBasePath + filename).c_str(), O_RDONLY);
|
||||||
|
|
||||||
if (lfd == -1) {
|
if (lfd == -1) {
|
||||||
printf("paintIcon: error while loading icon: %s%s\n", iconBasePath.c_str(), filename.c_str());
|
printf("paintIcon: error while loading icon: %s%s\n", iconBasePath.c_str(), filename.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
read(lfd, &header, sizeof(struct rawHeader));
|
||||||
|
|
||||||
|
tmpIcon.width = width = (header.width_hi << 8) | header.width_lo;
|
||||||
|
tmpIcon.height = height = (header.height_hi << 8) | header.height_lo;
|
||||||
|
tmpIcon.transp = transp = header.transp;
|
||||||
|
tmpIcon.data = (uint8_t*) malloc(width*height);
|
||||||
|
data = tmpIcon.data;
|
||||||
|
|
||||||
|
unsigned char pixbuf[768];
|
||||||
|
for (int count = 0; count < height; count ++ ) {
|
||||||
|
read(lfd, &pixbuf[0], width >> 1 );
|
||||||
|
unsigned char *pixpos = &pixbuf[0];
|
||||||
|
for (int count2 = 0; count2 < width >> 1; count2 ++ ) {
|
||||||
|
unsigned char compressed = *pixpos;
|
||||||
|
unsigned char pix1 = (compressed & 0xf0) >> 4;
|
||||||
|
unsigned char pix2 = (compressed & 0x0f);
|
||||||
|
*data++ = pix1;
|
||||||
|
*data++ = pix2;
|
||||||
|
pixpos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(lfd);
|
||||||
|
|
||||||
|
data = tmpIcon.data;
|
||||||
|
|
||||||
|
icon_cache.insert(std::pair <std::string, rawIcon> (iconBasePath + filename, tmpIcon));
|
||||||
|
} else {
|
||||||
|
data = it->second.data;
|
||||||
|
width = it->second.width;
|
||||||
|
height = it->second.height;
|
||||||
|
transp = it->second.transp;
|
||||||
|
//printf("paintIcon: cached %s %d x %d\n", (iconBasePath + filename).c_str(), width, height);
|
||||||
|
}
|
||||||
|
if (h != 0)
|
||||||
|
yy += (h - height) / 2;
|
||||||
|
|
||||||
|
uint8_t * d = ((uint8_t *)getFrameBufferPointer()) + x * sizeof(fb_pixel_t) + stride * yy;
|
||||||
|
fb_pixel_t * d2;
|
||||||
|
|
||||||
|
for (int count = 0; count < height; count++ ) {
|
||||||
|
unsigned char *pixpos = &data[count * width];
|
||||||
|
d2 = (fb_pixel_t *) d;
|
||||||
|
for (int count2 = 0; count2 < width; count2++ ) {
|
||||||
|
unsigned char pix = *pixpos;
|
||||||
|
if (pix != transp) {
|
||||||
|
paintPixel(d2, pix + offset);
|
||||||
|
}
|
||||||
|
d2++;
|
||||||
|
pixpos++;
|
||||||
|
}
|
||||||
|
d += stride;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
read(lfd, &header, sizeof(struct rawHeader));
|
read(lfd, &header, sizeof(struct rawHeader));
|
||||||
|
|
||||||
width = (header.width_hi << 8) | header.width_lo;
|
width = (header.width_hi << 8) | header.width_lo;
|
||||||
@@ -930,6 +991,7 @@ bool CFrameBuffer::paintIcon(const std::string & filename, const int x, const in
|
|||||||
}
|
}
|
||||||
|
|
||||||
close(lfd);
|
close(lfd);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#define fb_pixel_t uint32_t
|
#define fb_pixel_t uint32_t
|
||||||
|
|
||||||
@@ -75,6 +76,14 @@ class CFrameBuffer
|
|||||||
uint8_t transp;
|
uint8_t transp;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
|
struct rawIcon
|
||||||
|
{
|
||||||
|
uint16_t width;
|
||||||
|
uint16_t height;
|
||||||
|
uint8_t transp;
|
||||||
|
uint8_t * data;
|
||||||
|
};
|
||||||
|
|
||||||
std::string iconBasePath;
|
std::string iconBasePath;
|
||||||
|
|
||||||
int fd, tty;
|
int fd, tty;
|
||||||
@@ -103,6 +112,8 @@ class CFrameBuffer
|
|||||||
volatile uint8_t *gxa_base; /* base address for the GXA's register access */
|
volatile uint8_t *gxa_base; /* base address for the GXA's register access */
|
||||||
#endif /* USE_NEVIS_GXA */
|
#endif /* USE_NEVIS_GXA */
|
||||||
bool locked;
|
bool locked;
|
||||||
|
std::map<std::string, rawIcon> icon_cache;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifndef FB_USE_PALETTE
|
#ifndef FB_USE_PALETTE
|
||||||
fb_pixel_t realcolor[256];
|
fb_pixel_t realcolor[256];
|
||||||
|
Reference in New Issue
Block a user