@@ -1028,6 +1028,60 @@ bool cOglCmdCopyBufferToOutputFb::Execute(void)
10281028 return true ;
10291029}
10301030
1031+ // ------------------ cOglCmdRenderFbToFb ------------------------
1032+ bool cOglCmdRenderFbToFb::Execute (void ) {
1033+ if (!m_pFramebuffer || !m_pSrcFb || m_srcRect.IsEmpty () || m_pFramebuffer == m_pSrcFb)
1034+ return false ;
1035+
1036+ GLfloat x1 = m_dstPoint.X ();
1037+ GLfloat y1 = m_dstPoint.Y ();
1038+ GLfloat x2 = x1 + m_srcRect.Width ();
1039+ GLfloat y2 = y1 + m_srcRect.Height ();
1040+
1041+ GLfloat texX1 = (GLfloat) m_srcRect.X () / (GLfloat)m_pSrcFb->Width ();
1042+ GLfloat texX2 = (GLfloat)(m_srcRect.X () + m_srcRect.Width ()) / (GLfloat)m_pSrcFb->Width ();
1043+ GLfloat texY1 = (GLfloat)(m_pSrcFb->Height () - m_srcRect.Y () - 1 ) / (GLfloat)m_pSrcFb->Height ();
1044+ GLfloat texY2 = (GLfloat)(m_pSrcFb->Height () - m_srcRect.Y () - m_srcRect.Height () - 1 ) / (GLfloat)m_pSrcFb->Height ();
1045+
1046+ GLfloat quadVertices[] = {
1047+ // Position Texture
1048+ x1, y1, texX1, texY2,
1049+ x1, y2, texX1, texY1,
1050+ x2, y2, texX2, texY1,
1051+
1052+ x1, y1, texX1, texY2,
1053+ x2, y2, texX2, texY1,
1054+ x2, y1, texX2, texY2
1055+ };
1056+
1057+ VertexBuffers[vbTexture]->ActivateShader ();
1058+ VertexBuffers[vbTexture]->SetShaderAlpha (m_alpha);
1059+ VertexBuffers[vbTexture]->SetShaderProjectionMatrix (m_pFramebuffer->Width (), m_pFramebuffer->Height ());
1060+ VertexBuffers[vbTexture]->SetShaderBorderColor (clrTransparent);
1061+
1062+ m_pFramebuffer->Bind ();
1063+
1064+ if (!m_pSrcFb->BindTexture ()) {
1065+ m_pFramebuffer->Unbind ();
1066+ return false ;
1067+ }
1068+
1069+ if (m_alpha == ALPHA_OPAQUE )
1070+ VertexBuffers[vbTexture]->DisableBlending ();
1071+
1072+ VertexBuffers[vbTexture]->Bind ();
1073+ VertexBuffers[vbTexture]->SetVertexSubData (quadVertices);
1074+ VertexBuffers[vbTexture]->DrawArrays ();
1075+ VertexBuffers[vbTexture]->Unbind ();
1076+
1077+ if (m_alpha == ALPHA_OPAQUE )
1078+ VertexBuffers[vbTexture]->EnableBlending ();
1079+
1080+ m_pFramebuffer->Unbind ();
1081+
1082+ return true ;
1083+ }
1084+
10311085// ------------------ cOglCmdFill ----------------------------
10321086bool cOglCmdFill::Execute (void )
10331087{
@@ -2297,12 +2351,58 @@ void cOglPixmap::DrawSlope(const cRect &rect, tColor color, int type)
22972351
22982352void cOglPixmap::Render (const cPixmap *pixmap, const cRect &source, const cPoint &dest)
22992353{
2300- LOGWARNING ( " openglosd: %s: %d %d %d not implemented in OpenGl OSD " , __FUNCTION__, pixmap-> ViewPort (). X () , source. X () , dest. X () );
2354+ RenderPixmapInternal ( pixmap, source, dest, true );
23012355}
23022356
23032357void cOglPixmap::Copy (const cPixmap *pixmap, const cRect &source, const cPoint &dest)
23042358{
2305- LOGWARNING (" openglosd: %s: %d %d %d not implemented in OpenGl OSD" , __FUNCTION__, pixmap->ViewPort ().X (), source.X (), dest.X ());
2359+ // render without respect to alpha values
2360+ RenderPixmapInternal (pixmap, source, dest, false );
2361+ }
2362+
2363+ void cOglPixmap::RenderPixmapInternal (const cPixmap *pixmap, const cRect &source, const cPoint &dest, bool useAlpha)
2364+ {
2365+ LOGDEBUG2 (L_OPENGL , " openglosd: %s: %s" , __FUNCTION__, useAlpha ? " Render()" : " Copy()" );
2366+
2367+ if (!m_pOglThread->Active () || !pixmap || source.IsEmpty ())
2368+ return ;
2369+
2370+ LOCK_PIXMAPS ;
2371+
2372+ const cOglPixmap *sourceOgl = dynamic_cast <const cOglPixmap *>(pixmap);
2373+
2374+ // Self-rendering is not allowed according to VDR API
2375+ if (sourceOgl && sourceOgl != this ) {
2376+ cRect sourceRect = source.Intersected (cRect (0 , 0 , sourceOgl->DrawPort ().Width (), sourceOgl->DrawPort ().Height ()));
2377+ sourceRect.SetX (sourceRect.X () + sourceOgl->DrawPort ().X ());
2378+ sourceRect.SetY (sourceRect.Y () + sourceOgl->DrawPort ().Y ());
2379+
2380+ cRect destRect (dest, sourceRect.Size ());
2381+ cRect clippedDest = destRect.Intersected (cRect (0 , 0 , m_pFramebuffer->Width (), m_pFramebuffer->Height ()));
2382+ if (clippedDest.IsEmpty ())
2383+ return ;
2384+
2385+ sourceRect.SetX (sourceRect.X () + clippedDest.X () - destRect.X ());
2386+ sourceRect.SetY (sourceRect.Y () + clippedDest.Y () - destRect.Y ());
2387+ sourceRect.SetWidth (clippedDest.Width ());
2388+ sourceRect.SetHeight (clippedDest.Height ());
2389+ if (sourceRect.IsEmpty ())
2390+ return ;
2391+
2392+ m_pOglThread->DoCmd (new cOglCmdRenderFbToFb (m_pFramebuffer,
2393+ sourceOgl->Framebuffer (),
2394+ sourceRect,
2395+ clippedDest.Point (),
2396+ useAlpha ? sourceOgl->Alpha () : ALPHA_OPAQUE ));
2397+
2398+ SetDirty ();
2399+ MarkDrawPortDirty (cRect (clippedDest.X (), clippedDest.Y (), sourceRect.Width (), sourceRect.Height ()));
2400+
2401+ return ;
2402+ }
2403+
2404+ if (!sourceOgl)
2405+ LOGWARNING (" openglosd: %s: %s is not implemented in OpenGl OSD for your VDR version" , __FUNCTION__, useAlpha ? " Render()" : " Copy()" );
23062406}
23072407
23082408void cOglPixmap::Scroll (const cPoint &dest, const cRect &source)
0 commit comments