32#include <glm/gtc/matrix_transform.hpp>
33#include <glm/gtc/type_ptr.hpp>
46#define GRIDPOINTSTEXT 1
49#define GRIDPOINTSIZE 3
50#define GRIDPOINTOFFSET 4
51#define GRIDPOINTSTXTSIZE 14
52#define GRIDPOINTBG clrTransparent
53#define GRIDPOINTCLR 0xFFFF0000
64 col.a = ((
colARGB & 0xFF000000) >> 24) / 255.0;
65 col.r = ((
colARGB & 0x00FF0000) >> 16) / 255.0;
66 col.g = ((
colARGB & 0x0000FF00) >> 8 ) / 255.0;
218#define KERNING_UNKNOWN (-10000)
445 LOGDEBUG2(
L_OPENGL,
"openglosd: %s: Created a %d x %d (%d kB) FontAtlas for fontsize %d, rowH %d, rowW %d",
507 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);
607 glyph->LoadTexture();
617 if (
glyph && prevSym) {
618 kerning =
glyph->GetKerningCache(prevSym);
624 kerning =
delta.x / 64;
625 glyph->SetKerningCache(prevSym, kerning);
1155 for (
int i=0;
i <= 180;
i++) {
1222 for (
int i = 0;
i <= 45;
i++) {
1277 for (
int i=0;
i <= 90;
i++) {
1461 xGlyph += kerning +
g->AdvanceX();
1462 yGlyph += kerning +
g->AdvanceY();
1507 xGlyph += kerning +
g->AdvanceX();
1656 : cThread(
"oglThread"),
1659 m_pRender(device->Render())
1697 cCondWait::SleepMs(10);
1722 LOGERROR(
"openglosd: %s: cannot store image of %dpx x %dpx (maximum size is %dpx x %dpx) - falling back to cOsdProvider::StoreImageData()",
1757 cCondWait::SleepMs(2);
1760 LOGERROR(
"openglosd: %s: failed to store OSD image texture! (%s)",
__FUNCTION__,
timer.TimedOut() ?
"timed out" :
"allocation failed");
1848 LOGINFO(
"OpenGL context initialized");
1872 std::unique_lock<std::mutex>
lock(
m_mutex, std::defer_lock);
1874 if (
cmd->NeedsLockingAgainstStateChange())
1886 if (
strcmp(
cmd->Description(),
"Copy buffer to OutputFramebuffer") == 0) {
1896 LOGINFO(
"OpenGL worker thread stopped");
1993 LOGWARNING(
"openglosd: %s: cannot allocate pixmap of %dpx x %dpx, clipped to %dpx x %dpx!",
__FUNCTION__,
1995 width = std::min(width,
m_pOglThread->MaxTextureSize());
1996 height = std::min(height,
m_pOglThread->MaxTextureSize());
2020 cPixmap::MarkViewPortDirty(
rect);
2026 cPixmap::SetClean();
2032 cPixmap::SetLayer(
layer);
2039 if (
alpha != cPixmap::Alpha()) {
2040 cPixmap::SetAlpha(
alpha);
2047 cPixmap::SetTile(
tile);
2053 cPixmap::SetViewPort(
rect);
2200 int w =
font->Width(
s);
2201 int h =
font->Height();
2203 int cw = width ? width : w;
2204 int ch = height ? height : h;
2215 if (width || height)
2229 x += (width - w) / 2;
2241 y += (height - h) / 2;
2338#ifdef GRIDPOINTSTEXT
2341 if (
Rect.Width() &&
Rect.Height()) {
2345#ifdef GRIDPOINTSTEXT
2400 tArea area = {
r.Left(),
r.Top(),
r.Right(),
r.Bottom(), 32 };
2412 return cOsd::SetAreas(&
area, 1);
2422 if (cOsd::AddPixmap(
p)) {
2449 if (
Pixmap->Layer() >= 0)
2454 cOsd::DestroyPixmap(
Pixmap);
OpenGL OSD Glyph on a Texture Atlas.
OpenGL command: Fill a framebuffer.
virtual bool Execute(void)
OpenGL command: Render a framebuffer to the output framebuffer.
cOglOutputFb * m_pOutputFramebuffer
virtual bool Execute(void)
cSoftHdDevice * m_pDevice
OpenGL command: Delete a framebuffer.
virtual bool Execute(void)
OpenGL command: Draw an ellipse.
GLfloat * CreateVerticesFull(int &)
GLfloat * CreateVerticesHalf(int &)
GLfloat * CreateVerticesQuadrant(int &)
virtual bool Execute(void)
OpenGL command: Draw an image.
virtual bool Execute(void)
OpenGL command: Draw a rectangle.
virtual bool Execute(void)
OpenGL command: Draw a slope.
virtual bool Execute(void)
OpenGL command: Draw a text.
unsigned int * m_pSymbols
virtual bool Execute(void)
OpenGL command: Draw a texture.
virtual bool Execute(void)
OpenGL command: Drop image from cache.
virtual bool Execute(void)
OpenGL command: Fill a polygon.
virtual bool Execute(void)
OpenGL command: Init a framebuffer.
virtual bool Execute(void)
OpenGL command: Init the output framebuffer.
cOglOutputFb * m_pOutputFramebuffer
virtual bool Execute(void)
OpenGL command: Render a framebuffer to another framebuffer.
virtual bool Execute(void)
OpenGL command: Store image in the cache.
virtual bool Execute(void)
OpenGL OSD Framebuffer/ Texture Object.
virtual void Unbind(void)
GLint ViewportHeight(void)
cOglFb(GLint, GLint, GLint, GLint)
GLint ViewportWidth(void)
OpenGL OSD Texture Atlas for a Font.
cOglFontAtlas(FT_Face, int)
cOglAtlasGlyph * GetGlyph(int) const
virtual ~cOglFontAtlas(void)
cOglAtlasGlyph * m_pGlyph[MAX_CHARCODE - MIN_CHARCODE+1]
OpenGL OSD Representation of a VDR Font.
static void Cleanup(void)
cOglFont(const char *, int)
cOglFontAtlas * Atlas(void)
cOglGlyph * Glyph(FT_ULong) const
static cOglFont * Get(const char *, int)
int Kerning(cOglGlyph *glyph, FT_ULong prevSym) const
cList< cOglGlyph > m_glyphCache
static FT_Library s_ftLib
static cList< cOglFont > * s_pFonts
OpenGL OSD Glyph of a Font.
cOglGlyph(FT_ULong, FT_BitmapGlyph)
unsigned char * m_pBuffer
void SetKerningCache(FT_ULong, int)
int GetKerningCache(FT_ULong)
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...
static cOglOutputFb * OutputFramebuffer
main OSD output framebuffer - this keeps our finished "OSD" (one per OSD)
virtual eOsdError SetAreas(const tArea *, int)
cRect m_pDirtyViewport
the dirty viewport
virtual void DrawScaledBitmap(int, int, const cBitmap &, double, double, bool AntiAlias=false)
virtual cPixmap * CreatePixmap(int, const cRect &, const cRect &DrawPort=cRect::Null)
cVector< cOglPixmap * > m_pOglPixmaps
array of pixmaps
cOglOsd(int, int, uint, std::shared_ptr< cOglThread >, cSoftHdDevice *)
cSize m_maxPixmapSize
maximum allowed size of a pixmap (depends on the maximum OpenGL texture size)
virtual void DestroyPixmap(cPixmap *)
Main Framebuffer/ Texture Object for OSD.
virtual void Unbind(void)
OpenGL Implementation of a cPixmap.
virtual void SetClean(void)
virtual void DrawRectangle(const cRect &, tColor)
virtual void Pan(const cPoint &, const cRect &Source=cRect::Null)
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 &)
virtual ~cOglPixmap(void)
cOglPixmap(std::shared_ptr< cOglThread >, int, const cRect &, const cRect &DrawPort=cRect::Null)
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)
cOglFb * m_pFramebuffer
everything is drawn onto this framebuffer (one per pixmap)
std::shared_ptr< cOglThread > m_pOglThread
virtual void SetTile(bool)
virtual void SetDirty(bool dirty=true)
virtual void MarkViewPortDirty(const cRect &)
virtual void Scroll(const cPoint &, const cRect &Source=cRect::Null)
virtual void SetLayer(int)
virtual void Fill(tColor)
virtual void SetDrawPortPoint(const cPoint &, bool Dirty=true)
virtual void DrawBitmap(const cPoint &, const cBitmap &, tColor ColorFg=0, tColor ColorBg=0, bool Overlay=false)
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 DrawScaledImage(const cPoint &, const cImage &, double FactorX=1.0f, double FactorY=1.0f, bool AntiAlias=false)
virtual void SetViewPort(const cRect &)
OpenGL OSD Vertex/Fragment Shader.
bool CheckCompileErrors(GLuint, bool program=false)
void SetMatrix4(const GLchar *, const glm::mat4 &)
void SetVector4f(const GLchar *, GLfloat, GLfloat, GLfloat, GLfloat)
void SetFloat(const GLchar *, GLfloat)
void SetInteger(const GLchar *, GLint)
void SetVector3f(const GLchar *, GLfloat, GLfloat, GLfloat)
bool Compile(const char *, const char *)
void SetVector2f(const GLchar *, GLfloat, GLfloat)
bool InitVertexBuffers(void)
void CleanupImageCache(void)
sOglImage m_imageCache[OGL_MAX_OSDIMAGES]
cOglThread(cCondWait *startWait, int maxCacheSize, cSoftHdDevice *device)
virtual void Action(void)
int StoreImage(const cImage &)
sOglImage * GetImageRef(int)
void DeleteVertexBuffers(void)
std::queue< cOglCmd * > m_commands
void eglAcquireContext(void)
OpenGL OSD Vertex Buffers.
void EnableBlending(void)
void SetShaderColor(GLint)
void SetShaderTexture(GLint)
void DisableBlending(void)
void SetVertexSubData(GLfloat *, int count=0)
void SetShaderProjectionMatrix(GLint, GLint)
void SetVertexData(GLfloat *, int count=0)
void DrawArrays(int count=0)
void ActivateShader(void)
void SetShaderAlpha(GLint)
void SetShaderBorderColor(GLint)
Output Device Implementation.
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.
EGLSurface EglSurface(void)
EGLDisplay EglDisplay(void)
EGLContext EglContext(void)
__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
const char * textureFragmentShaderSwapBR
Texture Fragment Shader (swapped blue/red)
const char * rectVertexShader
Rectangle Vertex Shader.
static cOglVb * VertexBuffers[vbCount]
OpenGL Vertex Buffers Array.
const char * textureFragmentShader
Texture Fragment Shader.
const char * rectFragmentShader
Rectangle Fragment Shader.
const char * textFragmentShader
Text Fragment Shader.
static void ConvertColor(const GLint &colARGB, glm::vec4 &col)
OpenGL Color Conversion Helper.
const char * textureVertexShader
Texture Vertex Shader.
static cOglShader * Shaders[stCount]
OpenGL Shaders Array.
const char * textVertexShader
Text Vertex Shader.
#define OGL_MAX_OSDIMAGES
const struct @0 FT_Errors[]
#define OGL_CMDQUEUE_SIZE
Shader Definitions for OpenGL OSD.
Output Device Header File.
Video Renderer (Display) Header File.