diff options
author | Louis-Francis Ratté-Boulianne <lfrb@collabora.com> | 2014-11-20 22:07:12 -0500 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-12-02 15:47:20 +0100 |
commit | 9cc36162ccee6cc6d44ddf9d033c947a8280e218 (patch) | |
tree | 787873da491727e8f19cd598b329fa1e8fcb1056 /vcl/opengl/x11/gdiimpl.cxx | |
parent | 8ea069ad2da31d9f478d6766029b0add068a0aee (diff) |
vcl: Draw native widgets twice on black/white background to synthesize alpha
Change-Id: Ic4c073360070a559855732d2de41ae9085d7d51b
Diffstat (limited to 'vcl/opengl/x11/gdiimpl.cxx')
-rw-r--r-- | vcl/opengl/x11/gdiimpl.cxx | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx index bfc1bbbb79f5..afaea924601c 100644 --- a/vcl/opengl/x11/gdiimpl.cxx +++ b/vcl/opengl/x11/gdiimpl.cxx @@ -126,16 +126,17 @@ bool X11OpenGLSalGraphicsImpl::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, return true; } -bool X11OpenGLSalGraphicsImpl::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, int nY ) +bool X11OpenGLSalGraphicsImpl::RenderPixmapToScreen( X11Pixmap* pPixmap, X11Pixmap* pMask, int nX, int nY ) { const int aAttribs[] = { GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, - GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT, + GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT, None }; Display* pDisplay = mrParent.GetXDisplay(); GLXFBConfig pFbConfig; GLXPixmap pGlxPixmap; + GLXPixmap pGlxMask; SalTwoRect aPosAry; bool bInverted; @@ -148,25 +149,48 @@ bool X11OpenGLSalGraphicsImpl::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX, aPosAry.mnSrcWidth = aPosAry.mnDestWidth = pPixmap->GetWidth(); aPosAry.mnSrcHeight = aPosAry.mnDestHeight = pPixmap->GetHeight(); + PreDraw(); + //glClear( GL_COLOR_BUFFER_BIT ); + XSync( pDisplay, 0 ); pFbConfig = OpenGLHelper::GetPixmapFBConfig( pDisplay, bInverted ); pGlxPixmap = glXCreatePixmap( pDisplay, pFbConfig, pPixmap->GetPixmap(), aAttribs); + if( pMask != NULL ) + pGlxMask = glXCreatePixmap( pDisplay, pFbConfig, pMask->GetPixmap(), aAttribs); XSync( pDisplay, 0 ); - PreDraw(); + if( !pGlxPixmap ) + SAL_WARN( "vcl.opengl", "Couldn't create GLXPixmap" ); + + //TODO: lfrb: glXGetProc to get the functions OpenGLTexture aTexture( pPixmap->GetWidth(), pPixmap->GetHeight(), false ); glActiveTexture( GL_TEXTURE0 ); aTexture.Bind(); - - //TODO: lfrb: glXGetProc to get the functions glXBindTexImageEXT( pDisplay, pGlxPixmap, GLX_FRONT_LEFT_EXT, NULL ); + aTexture.Unbind(); + + if( pMask != NULL && pGlxMask ) + { + OpenGLTexture aMaskTexture( pMask->GetWidth(), pMask->GetHeight(), false ); + aMaskTexture.Bind(); + glXBindTexImageEXT( pDisplay, pGlxMask, GLX_FRONT_LEFT_EXT, NULL ); + aMaskTexture.Unbind(); - DrawTexture( aTexture, aPosAry, bInverted ); + DrawTextureDiff( aTexture, aMaskTexture, aPosAry, !bInverted ); + + glXReleaseTexImageEXT( pDisplay, pGlxMask, GLX_FRONT_LEFT_EXT ); + glXDestroyPixmap( pDisplay, pGlxMask ); + } + else + { + DrawTexture( aTexture, aPosAry, !bInverted ); + } + + CHECK_GL_ERROR(); glXReleaseTexImageEXT( pDisplay, pGlxPixmap, GLX_FRONT_LEFT_EXT ); glXDestroyPixmap( pDisplay, pGlxPixmap ); - aTexture.Unbind(); PostDraw(); |