32#include <glm/gtc/matrix_transform.hpp>
33#include <glm/gtc/type_ptr.hpp>
53#define GRIDPOINTSTEXT 1
56#define GRIDPOINTSIZE 3
57#define GRIDPOINTOFFSET 4
58#define GRIDPOINTSTXTSIZE 14
59#define GRIDPOINTBG clrTransparent
60#define GRIDPOINTCLR 0xFFFF0000
67 col.a = ((
colARGB & 0xFF000000) >> 24) / 255.0;
68 col.r = ((
colARGB & 0x00FF0000) >> 16) / 255.0;
69 col.g = ((
colARGB & 0x0000FF00) >> 8 ) / 255.0;
209#define KERNING_UNKNOWN (-10000)
436 LOGDEBUG2(
L_OPENGL,
"openglosd: %s: Created a %d x %d (%d kB) FontAtlas for fontsize %d, rowH %d, rowW %d",
498 LOGDEBUG2(
L_OPENGL,
"openglosd: %s: Created new font: %s (%d) height: %d, bottom: %d - %d chars (%d - %d)",
__FUNCTION__,
fontName,
m_size,
m_height,
m_bottom,
count,
minIndex,
maxIndex);
598 glyph->LoadTexture();
608 if (
glyph && prevSym) {
609 kerning =
glyph->GetKerningCache(prevSym);
615 kerning =
delta.x / 64;
616 glyph->SetKerningCache(prevSym, kerning);
1147 for (
int i=0;
i <= 180;
i++) {
1214 for (
int i = 0;
i <= 45;
i++) {
1269 for (
int i=0;
i <= 90;
i++) {
1453 xGlyph += kerning +
g->AdvanceX();
1454 yGlyph += kerning +
g->AdvanceY();
1499 xGlyph += kerning +
g->AdvanceX();
1648 : cThread(
"oglThread"),
1651 m_pRender(device->Render())
1689 cCondWait::SleepMs(10);
1714 LOGERROR(
"openglosd: %s: cannot store image of %dpx x %dpx (maximum size is %dpx x %dpx) - falling back to cOsdProvider::StoreImageData()",
1749 cCondWait::SleepMs(2);
1752 LOGERROR(
"openglosd: %s: failed to store OSD image texture! (%s)",
__FUNCTION__,
timer.TimedOut() ?
"timed out" :
"allocation failed");
1840 LOGINFO(
"OpenGL context initialized");
1864 std::unique_lock<std::mutex>
lock(
m_mutex, std::defer_lock);
1866 if (
cmd->NeedsLockingAgainstStateChange())
1878 if (
strcmp(
cmd->Description(),
"Copy buffer to OutputFramebuffer") == 0) {
1888 LOGINFO(
"OpenGL worker thread stopped");
1985 LOGWARNING(
"openglosd: %s: cannot allocate pixmap of %dpx x %dpx, clipped to %dpx x %dpx!",
__FUNCTION__,
1987 width = std::min(width,
m_pOglThread->MaxTextureSize());
1988 height = std::min(height,
m_pOglThread->MaxTextureSize());
2012 cPixmap::MarkViewPortDirty(
rect);
2018 cPixmap::SetClean();
2024 cPixmap::SetLayer(
layer);
2031 if (
alpha != cPixmap::Alpha()) {
2032 cPixmap::SetAlpha(
alpha);
2039 cPixmap::SetTile(
tile);
2045 cPixmap::SetViewPort(
rect);
2192 int w =
font->Width(
s);
2193 int h =
font->Height();
2195 int cw = width ? width : w;
2196 int ch = height ? height : h;
2207 if (width || height)
2221 x += (width - w) / 2;
2233 y += (height - h) / 2;
2330#ifdef GRIDPOINTSTEXT
2333 if (
Rect.Width() &&
Rect.Height()) {
2337#ifdef GRIDPOINTSTEXT
2392 tArea area = {
r.Left(),
r.Top(),
r.Right(),
r.Bottom(), 32 };
2404 return cOsd::SetAreas(&
area, 1);
2414 if (cOsd::AddPixmap(
p)) {
2441 if (
Pixmap->Layer() >= 0)
2446 cOsd::DestroyPixmap(
Pixmap);
Glyph on a Texture Atlas.
cOglOutputFb * m_pOutputFramebuffer
cSoftHdDevice * m_pDevice
unsigned int * m_pSymbols
cOglOutputFb * m_pOutputFramebuffer
OpenGL Framebuffer/ Texture Object.
GLint ViewportHeight(void)
GLint ViewportWidth(void)
Texture Atlas for a Font.
cOglAtlasGlyph * m_pGlyph[MAX_CHARCODE - MIN_CHARCODE+1]
OpenGL Representation of a VDR Font.
cOglFontAtlas * Atlas(void)
cList< cOglGlyph > m_glyphCache
unsigned char * m_pBuffer
cVector< tKerning > m_pKerningCache
std::shared_ptr< cOglThread > m_pOglThread
pointer to thread, which executes the commands
bool m_isSubtitleOsd
true, if this is a subtitle osd
cSoftHdDevice * m_pDevice
pointer to cSofthdDevice
cOglFb * m_pBufferFramebuffer
all pixmaps are composed onto this framebuffer after each other, before this one is blit onto the OSD...
cRect m_pDirtyViewport
the dirty viewport
cVector< cOglPixmap * > m_pOglPixmaps
array of pixmaps
cSize m_maxPixmapSize
maximum allowed size of a pixmap (depends on the maximum OpenGL texture size)
Main Framebuffer/ Texture Object for OSD.
OpenGL Implementation of a cPixmap.
cOglFb * m_pFramebuffer
everything is drawn onto this framebuffer (one per pixmap)
std::shared_ptr< cOglThread > m_pOglThread
virtual void SetDirty(bool dirty=true)
virtual void DrawScaledImage(const cPoint &, const cImage &, double FactorX=1.0f, double FactorY=1.0f, bool AntiAlias=false)
sOglImage m_imageCache[OGL_MAX_OSDIMAGES]
std::queue< cOglCmd * > m_commands
Output Device Implementation.
EGLSurface EglSurface(void)
EGLDisplay EglDisplay(void)
EGLContext EglContext(void)
void OsdDrawARGB(int, int, int, int, int, const uint8_t *, int, int)
Draw an OSD pixmap.
virtual void GetOsdSize(int &, int &, double &)
Returns the width, height and aspect ratio the OSD.
void OsdClose(void)
Close the OSD.
__attribute__((weak)) union gbm_bo_handle gbm_bo_get_handle_for_plane(struct gbm_bo *bo
#define LOGDEBUG2
log to LOG_DEBUG and add a prefix
#define LOGERROR
log to LOG_ERR
#define GL_CHECK(stmt)
glCheckError macro
#define LOGWARNING
log to LOG_WARN
#define LOGINFO
log to LOG_INFO
#define EGL_CHECK(stmt)
eglCheckError macro
@ L_OPENGL_TIME
opengl osd flush time measurement
@ L_OPENGL
opengl osd logs
@ L_OPENGL_TIME_ALL
opengl osd all commands time measurement
virtual bool Execute(void)
#define OGL_MAX_OSDIMAGES
static void Cleanup(void)
virtual void Unbind(void)
cOglFont(const char *, int)
bool CheckCompileErrors(GLuint, bool program=false)
virtual void SetClean(void)
void EnableBlending(void)
virtual void Unbind(void)
virtual bool Execute(void)
virtual bool Execute(void)
cOglGlyph * Glyph(FT_ULong) const
virtual void DrawRectangle(const cRect &, tColor)
static cOglOutputFb * OutputFramebuffer
main OSD output framebuffer - this keeps our finished "OSD" (one per OSD)
bool InitVertexBuffers(void)
virtual bool Execute(void)
virtual void Pan(const cPoint &, const cRect &Source=cRect::Null)
virtual bool Execute(void)
virtual bool Execute(void)
cOglGlyph(FT_ULong, FT_BitmapGlyph)
void CleanupImageCache(void)
void SetMatrix4(const GLchar *, const glm::mat4 &)
virtual void DrawPixel(const cPoint &, tColor)
void DrawTextInternal(const cPoint &, const char *, tColor, tColor, const cFont *, int Width=0, int Height=0, int Alignment=taDefault, bool isGridText=false)
virtual void DrawImage(const cPoint &, const cImage &)
void SetVector4f(const GLchar *, GLfloat, GLfloat, GLfloat, GLfloat)
virtual ~cOglPixmap(void)
cOglFontAtlas(FT_Face, int)
static cOglFont * Get(const char *, int)
const char * textureFragmentShaderSwapBR
Texture Fragment Shader (swapped blue/red)
cOglFb(GLint, GLint, GLint, GLint)
GLfloat * CreateVerticesFull(int &)
GLfloat * CreateVerticesHalf(int &)
virtual bool Execute(void)
GLfloat * CreateVerticesQuadrant(int &)
void SetFloat(const GLchar *, GLfloat)
void SetKerningCache(FT_ULong, int)
void SetInteger(const GLchar *, GLint)
void SetShaderColor(GLint)
virtual eOsdError SetAreas(const tArea *, int)
const char * rectVertexShader
Rectangle Vertex Shader.
cOglPixmap(std::shared_ptr< cOglThread >, int, const cRect &, const cRect &DrawPort=cRect::Null)
int Kerning(cOglGlyph *glyph, FT_ULong prevSym) const
virtual void DrawSlope(const cRect &, tColor, int)
virtual void DrawText(const cPoint &, const char *, tColor, tColor, const cFont *, int Width=0, int Height=0, int Alignment=taDefault)
static cOglVb * VertexBuffers[vbCount]
void SetShaderTexture(GLint)
virtual bool Execute(void)
void DisableBlending(void)
void SetVertexSubData(GLfloat *, int count=0)
virtual void SetTile(bool)
const char * textureFragmentShader
Texture Fragment Shader.
cOglThread(cCondWait *startWait, int maxCacheSize, cSoftHdDevice *device)
void SetVector3f(const GLchar *, GLfloat, GLfloat, GLfloat)
const char * rectFragmentShader
Rectangle Fragment Shader.
const char * textFragmentShader
Text Fragment Shader.
virtual void DrawScaledBitmap(int, int, const cBitmap &, double, double, bool AntiAlias=false)
void SetShaderProjectionMatrix(GLint, GLint)
virtual bool Execute(void)
virtual void MarkViewPortDirty(const cRect &)
virtual void Scroll(const cPoint &, const cRect &Source=cRect::Null)
void SetVertexData(GLfloat *, int count=0)
static void ConvertColor(const GLint &colARGB, glm::vec4 &col)
virtual bool Execute(void)
cOglAtlasGlyph * GetGlyph(int) const
const char * textureVertexShader
Texture Vertex Shader.
virtual bool Execute(void)
void DrawArrays(int count=0)
virtual void Action(void)
virtual ~cOglFontAtlas(void)
static cOglShader * Shaders[stCount]
void ActivateShader(void)
virtual bool Execute(void)
int StoreImage(const cImage &)
bool Compile(const char *, const char *)
virtual cPixmap * CreatePixmap(int, const cRect &, const cRect &DrawPort=cRect::Null)
const char * textVertexShader
Text Vertex Shader.
virtual void SetLayer(int)
void SetVector2f(const GLchar *, GLfloat, GLfloat)
#define OGL_CMDQUEUE_SIZE
virtual void Fill(tColor)
sOglImage * GetImageRef(int)
void SetShaderAlpha(GLint)
int GetKerningCache(FT_ULong)
cOglOsd(int, int, uint, std::shared_ptr< cOglThread >, cSoftHdDevice *)
virtual bool Execute(void)
virtual void SetDrawPortPoint(const cPoint &, bool Dirty=true)
virtual void DrawBitmap(const cPoint &, const cBitmap &, tColor ColorFg=0, tColor ColorBg=0, bool Overlay=false)
static FT_Library s_ftLib
void DeleteVertexBuffers(void)
virtual void Render(const cPixmap *, const cRect &, const cPoint &)
virtual void Copy(const cPixmap *, const cRect &, const cPoint &)
virtual void DrawEllipse(const cRect &, tColor, int Quadrants=0)
virtual void SetAlpha(int)
virtual void SetViewPort(const cRect &)
virtual bool Execute(void)
void SetShaderBorderColor(GLint)
virtual void DestroyPixmap(cPixmap *)
void eglAcquireContext(void)
static cList< cOglFont > * s_pFonts
virtual bool Execute(void)
const struct @0 FT_Errors[]
Shader Definitions for OpenGL OSD.
Output Device Header File.
Video Renderer (Display) Header File.