mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-02 18:31:12 +02:00
fontrenderer: allow to render into a memory buffer
might be useful for offscreen font rendering
Origin commit data
------------------
Commit: 33dba78f92
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2018-01-28 (Sun, 28 Jan 2018)
This commit is contained in:
committed by
vanhofen
parent
1ee4d57e87
commit
6e248cfad0
@@ -4,6 +4,7 @@
|
|||||||
Copyright (C) 2001 Steffen Hehn 'McClean'
|
Copyright (C) 2001 Steffen Hehn 'McClean'
|
||||||
Copyright (C) 2003 thegoodguy
|
Copyright (C) 2003 thegoodguy
|
||||||
Copyright (C) 2013-2017 M. Liebmann (micha-bbg)
|
Copyright (C) 2013-2017 M. Liebmann (micha-bbg)
|
||||||
|
Copyright (C) 2009-2013,2017-2018 Stefan Seyfried
|
||||||
|
|
||||||
License: GPL
|
License: GPL
|
||||||
|
|
||||||
@@ -466,11 +467,21 @@ void Font::paintFontPixel(fb_pixel_t *td, uint8_t src)
|
|||||||
*td = colors[src];
|
*td = colors[src];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Font::RenderString(int x, int y, const int width, const char *text, const fb_pixel_t color, const int boxheight, const unsigned int flags)
|
void Font::RenderString(int x, int y, const int width, const char *text, const fb_pixel_t color, const int boxheight, const unsigned int flags, fb_pixel_t *buffer, int _stride)
|
||||||
{
|
{
|
||||||
if (!frameBuffer->getActive())
|
if (buffer == NULL && !frameBuffer->getActive())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
fb_pixel_t *buff;
|
||||||
|
int stride;
|
||||||
|
if (buffer) {
|
||||||
|
buff = buffer;
|
||||||
|
stride = _stride;
|
||||||
|
} else {
|
||||||
|
buff = frameBuffer->getFrameBufferPointer();
|
||||||
|
stride = frameBuffer->getStride();
|
||||||
|
}
|
||||||
|
|
||||||
const bool utf8_encoded = flags & IS_UTF8;
|
const bool utf8_encoded = flags & IS_UTF8;
|
||||||
#if HAVE_TRIPLEDRAGON
|
#if HAVE_TRIPLEDRAGON
|
||||||
/* the TD Framebufffer is ARGB; the others are BGRA. The fullbg code does not handle that
|
/* the TD Framebufffer is ARGB; the others are BGRA. The fullbg code does not handle that
|
||||||
@@ -491,7 +502,8 @@ void Font::RenderString(int x, int y, const int width, const char *text, const f
|
|||||||
- font rendering slower
|
- font rendering slower
|
||||||
*/
|
*/
|
||||||
|
|
||||||
frameBuffer->checkFbArea(x, y-height, width, height, true);
|
if (buffer == NULL)
|
||||||
|
frameBuffer->checkFbArea(x, y-height, width, height, true);
|
||||||
|
|
||||||
pthread_mutex_lock( &renderer->render_mutex );
|
pthread_mutex_lock( &renderer->render_mutex );
|
||||||
|
|
||||||
@@ -563,11 +575,11 @@ void Font::RenderString(int x, int y, const int width, const char *text, const f
|
|||||||
/* the GXA seems to do it's job asynchonously, so we need to wait until
|
/* the GXA seems to do it's job asynchonously, so we need to wait until
|
||||||
it's ready, otherwise the font will sometimes "be overwritten" with
|
it's ready, otherwise the font will sometimes "be overwritten" with
|
||||||
background color or bgcolor will be wrong */
|
background color or bgcolor will be wrong */
|
||||||
frameBuffer->waitForIdle("Font::RenderString 1");
|
if (buffer != NULL)
|
||||||
|
frameBuffer->waitForIdle("Font::RenderString 1");
|
||||||
if (!useFullBG) {
|
if (!useFullBG) {
|
||||||
/* fetch bgcolor from framebuffer, using lower left edge of the font... */
|
/* fetch bgcolor from framebuffer, using lower left edge of the font... */
|
||||||
bg_color = *(frameBuffer->getFrameBufferPointer() + x +
|
bg_color = *(buff + x + y * stride / sizeof(fb_pixel_t));
|
||||||
y * frameBuffer->getStride() / sizeof(fb_pixel_t));
|
|
||||||
|
|
||||||
if (bg_color == (fb_pixel_t)0)
|
if (bg_color == (fb_pixel_t)0)
|
||||||
bg_color = 0x80808080;
|
bg_color = 0x80808080;
|
||||||
@@ -636,9 +648,8 @@ void Font::RenderString(int x, int y, const int width, const char *text, const f
|
|||||||
if (x + glyph->xadvance + spread_by > left + width)
|
if (x + glyph->xadvance + spread_by > left + width)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int stride = frameBuffer->getStride();
|
|
||||||
int ap=(x + glyph->left) * sizeof(fb_pixel_t) + stride * (y - glyph->top);
|
int ap=(x + glyph->left) * sizeof(fb_pixel_t) + stride * (y - glyph->top);
|
||||||
uint8_t * d = ((uint8_t *)frameBuffer->getFrameBufferPointer()) + ap;
|
uint8_t * d = ((uint8_t *)buff) + ap;
|
||||||
uint8_t * s = glyph->buffer;
|
uint8_t * s = glyph->buffer;
|
||||||
int w = glyph->width;
|
int w = glyph->width;
|
||||||
int h = glyph->height;
|
int h = glyph->height;
|
||||||
@@ -678,14 +689,16 @@ void Font::RenderString(int x, int y, const int width, const char *text, const f
|
|||||||
}
|
}
|
||||||
//printf("RenderStat: %d %d %d \n", renderer->cacheManager->num_nodes, renderer->cacheManager->num_bytes, renderer->cacheManager->max_bytes);
|
//printf("RenderStat: %d %d %d \n", renderer->cacheManager->num_nodes, renderer->cacheManager->num_bytes, renderer->cacheManager->max_bytes);
|
||||||
pthread_mutex_unlock( &renderer->render_mutex );
|
pthread_mutex_unlock( &renderer->render_mutex );
|
||||||
frameBuffer->checkFbArea(x, y-height, width, height, false);
|
if (buffer == NULL) {
|
||||||
/* x is the rightmost position of the last drawn character */
|
frameBuffer->checkFbArea(x, y-height, width, height, false);
|
||||||
frameBuffer->mark(left, y + lower - height, x, y + lower);
|
/* x is the rightmost position of the last drawn character */
|
||||||
|
frameBuffer->mark(left, y + lower - height, x, y + lower);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Font::RenderString(int x, int y, const int width, const std::string & text, const fb_pixel_t color, const int boxheight, const unsigned int flags)
|
void Font::RenderString(int x, int y, const int width, const std::string & text, const fb_pixel_t color, const int boxheight, const unsigned int flags, fb_pixel_t *buffer, int stride)
|
||||||
{
|
{
|
||||||
RenderString(x, y, width, text.c_str(), color, boxheight, flags);
|
RenderString(x, y, width, text.c_str(), color, boxheight, flags, buffer, stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Font::getRenderWidth(const char *text, const bool utf8_encoded)
|
int Font::getRenderWidth(const char *text, const bool utf8_encoded)
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
Copyright (C) 2001 Steffen Hehn 'McClean'
|
Copyright (C) 2001 Steffen Hehn 'McClean'
|
||||||
Copyright (C) 2003 thegoodguy
|
Copyright (C) 2003 thegoodguy
|
||||||
Copyright (C) 2013-2017 M. Liebmann (micha-bbg)
|
Copyright (C) 2013-2017 M. Liebmann (micha-bbg)
|
||||||
|
Copyright (C) 2009,2017-2018 Stefan Seyfried
|
||||||
|
|
||||||
License: GPL
|
License: GPL
|
||||||
|
|
||||||
@@ -75,8 +76,8 @@ class Font
|
|||||||
FULLBG = 2
|
FULLBG = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
void RenderString(int x, int y, const int width, const char * text, const fb_pixel_t color, const int boxheight = 0, const unsigned int flags = IS_UTF8);
|
void RenderString(int x, int y, const int width, const char * text, const fb_pixel_t color, const int boxheight = 0, const unsigned int flags = IS_UTF8, fb_pixel_t *buffer = NULL, int stride = 0);
|
||||||
void RenderString(int x, int y, const int width, const std::string & text, const fb_pixel_t color, const int boxheight = 0, const unsigned int flags = IS_UTF8);
|
void RenderString(int x, int y, const int width, const std::string & text, const fb_pixel_t color, const int boxheight = 0, const unsigned int flags = IS_UTF8, fb_pixel_t *buffer = NULL, int stride = 0);
|
||||||
|
|
||||||
int getRenderWidth(const char * text, const bool utf8_encoded = true);
|
int getRenderWidth(const char * text, const bool utf8_encoded = true);
|
||||||
int getRenderWidth(const std::string & text, const bool utf8_encoded = true);
|
int getRenderWidth(const std::string & text, const bool utf8_encoded = true);
|
||||||
|
Reference in New Issue
Block a user