[Libreoffice-commits] core.git: 7 commits - vcl/inc vcl/opengl vcl/unx vcl/win vcl/workben
Louis-Francis Ratté-Boulianne
lfrb at collabora.com
Tue Nov 11 02:09:05 PST 2014
vcl/inc/opengl/salbmp.hxx | 2
vcl/inc/opengl/texture.hxx | 3
vcl/inc/openglgdiimpl.hxx | 22 +++
vcl/inc/salgdiimpl.hxx | 5
vcl/inc/unx/salgdi.h | 4
vcl/opengl/gdiimpl.cxx | 146 +++++++++++++++++------
vcl/opengl/maskedTextureFragmentShader.glsl | 2
vcl/opengl/salbmp.cxx | 15 +-
vcl/opengl/texture.cxx | 10 +
vcl/opengl/x11/gdiimpl.cxx | 7 -
vcl/unx/generic/gdi/gdiimpl.cxx | 6
vcl/unx/generic/gdi/gdiimpl.hxx | 4
vcl/unx/generic/gdi/openglx11cairotextrender.cxx | 53 ++++++--
vcl/unx/generic/gdi/salgdi2.cxx | 6
vcl/win/source/gdi/gdiimpl.hxx | 5
vcl/workben/vcldemo.cxx | 2
16 files changed, 236 insertions(+), 56 deletions(-)
New commits:
commit 14a1d4da2f49c92caaccfae9cab6940ac6e672a5
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Mon Nov 10 23:30:02 2014 -0500
vcl: Fix text rendering with OpenGL
Change-Id: I7784fa81cb6f9a3d6437b2b628c37e7895c84733
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index e9be665..6f920e5 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -243,6 +243,11 @@ public:
const SalBitmap& rSourceBitmap,
const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE;
+ /** Render 32-bits bitmap with alpha channel */
+ virtual bool drawAlphaBitmap(
+ const SalTwoRect&,
+ const SalBitmap& rBitmap ) SAL_OVERRIDE;
+
/** draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system */
virtual bool drawTransformedBitmap(
const basegfx::B2DPoint& rNull,
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index 5d49952..4b4b735 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -181,6 +181,11 @@ public:
const SalBitmap& rSourceBitmap,
const SalBitmap& rAlphaBitmap ) = 0;
+ /** Render 32-bits bitmap with alpha channel */
+ virtual bool drawAlphaBitmap(
+ const SalTwoRect&,
+ const SalBitmap& rBitmap ) = 0;
+
/** draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system */
virtual bool drawTransformedBitmap(
const basegfx::B2DPoint& rNull,
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 8a5cc0c..2546689 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -251,6 +251,10 @@ public:
virtual bool drawAlphaBitmap( const SalTwoRect&,
const SalBitmap& rSourceBitmap,
const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE;
+
+ virtual bool drawAlphaBitmap( const SalTwoRect&,
+ const SalBitmap& rBitmap );
+
virtual bool drawTransformedBitmap(
const basegfx::B2DPoint& rNull,
const basegfx::B2DPoint& rX,
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 80a5414..e9aaa669 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1025,6 +1025,23 @@ bool OpenGLSalGraphicsImpl::drawAlphaBitmap(
return true;
}
+bool OpenGLSalGraphicsImpl::drawAlphaBitmap(
+ const SalTwoRect& rPosAry,
+ const SalBitmap& rSalBitmap )
+{
+ const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
+ const GLuint nTexture( rBitmap.GetTexture( maContext ) );
+
+ SAL_INFO( "vcl.opengl", "::drawAlphaBitmap" );
+ PreDraw();
+ glEnable( GL_BLEND );
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+ DrawTexture( nTexture, rBitmap.GetSize(), rPosAry );
+ glDisable( GL_BLEND );
+ PostDraw();
+ return true;
+}
+
/** draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system */
bool OpenGLSalGraphicsImpl::drawTransformedBitmap(
const basegfx::B2DPoint& /*rNull*/,
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index efe66d8..4adea62 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -955,6 +955,12 @@ bool X11SalGraphicsImpl::drawAlphaBitmap( const SalTwoRect& rTR,
return true;
}
+bool X11SalGraphicsImpl::drawAlphaBitmap( const SalTwoRect& /*rTR*/,
+ const SalBitmap& /*rBitmap*/ )
+{
+ return false;
+}
+
bool X11SalGraphicsImpl::drawTransformedBitmap(
const basegfx::B2DPoint& rNull,
const basegfx::B2DPoint& rX,
diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx
index 91592eb..5b0062c 100644
--- a/vcl/unx/generic/gdi/gdiimpl.hxx
+++ b/vcl/unx/generic/gdi/gdiimpl.hxx
@@ -242,6 +242,10 @@ public:
const SalBitmap& rSourceBitmap,
const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE;
+ virtual bool drawAlphaBitmap(
+ const SalTwoRect&,
+ const SalBitmap& rBitmap ) SAL_OVERRIDE;
+
/** draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system */
virtual bool drawTransformedBitmap(
const basegfx::B2DPoint& rNull,
diff --git a/vcl/unx/generic/gdi/openglx11cairotextrender.cxx b/vcl/unx/generic/gdi/openglx11cairotextrender.cxx
index 9b7c49e..36a76b0 100644
--- a/vcl/unx/generic/gdi/openglx11cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/openglx11cairotextrender.cxx
@@ -24,26 +24,61 @@ cairo_surface_t* OpenGLX11CairoTextRender::getCairoSurface()
// static size_t id = 0;
// OString aFileName = OString("/tmp/libo_logs/text_rendering") + OString::number(id++) + OString(".svg");
// cairo_surface_t* surface = cairo_svg_surface_create(aFileName.getStr(), GetWidth(), GetHeight());
- cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, GetWidth(), GetHeight());
+ cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, GetWidth(), GetHeight());
return surface;
}
void OpenGLX11CairoTextRender::drawSurface(cairo_t* cr)
{
- cairo_surface_t* surface = cairo_get_target(cr);
- int width = cairo_image_surface_get_width(surface);
- int height = cairo_image_surface_get_height(surface);
+ cairo_surface_t* pSurface = cairo_get_target(cr);
+ int nWidth = cairo_image_surface_get_width( pSurface );
+ int nHeight = cairo_image_surface_get_height( pSurface );
SalBitmap* pBitmap = ImplGetSVData()->mpDefInst->CreateSalBitmap();
- pBitmap->Create(Size(width, height), 24, BitmapPalette());
+ pBitmap->Create(Size(nWidth, nHeight), 32, BitmapPalette());
+
+ cairo_surface_flush( pSurface );
BitmapBuffer* pBuffer = pBitmap->AcquireBuffer(false);
- std::memcpy(pBuffer->mpBits, cairo_image_surface_get_data(surface), width*height*3);
+ unsigned char *pSrc = cairo_image_surface_get_data( pSurface );
+ unsigned int nSrcStride = cairo_image_surface_get_stride( pSurface );
+ unsigned int nDestStride = pBuffer->mnScanlineSize;
+ for( unsigned long y = 0; y < (unsigned long) nHeight; y++ )
+ {
+ // Cairo surface is y-inverse
+ sal_uInt32 *pSrcPix = (sal_uInt32 *)(pSrc + nSrcStride * (nHeight - y - 1));
+ sal_uInt32 *pDestPix = (sal_uInt32 *)(pBuffer->mpBits + nDestStride * y);
+ for( unsigned long x = 0; x < (unsigned long) nWidth; x++ )
+ {
+ sal_uInt8 nAlpha = (*pSrcPix >> 24);
+ sal_uInt8 nR = (*pSrcPix >> 16) & 0xff;
+ sal_uInt8 nG = (*pSrcPix >> 8) & 0xff;
+ sal_uInt8 nB = *pSrcPix & 0xff;
+ if( nAlpha != 0 && nAlpha != 255 )
+ {
+ // Cairo uses pre-multiplied alpha - we do not => re-multiply
+ nR = (sal_uInt8) MinMax( ((sal_uInt32)nR * 255) / nAlpha, 0, 255 );
+ nG = (sal_uInt8) MinMax( ((sal_uInt32)nG * 255) / nAlpha, 0, 255 );
+ nB = (sal_uInt8) MinMax( ((sal_uInt32)nB * 255) / nAlpha, 0, 255 );
+ }
+
+ // FIXME: lfrb: depends on endianness (use BitmapWriteAccess)
+ *pDestPix = (nAlpha << 24) + (nB << 16) + (nG << 8) + nR;
+ pSrcPix++;
+ pDestPix++;
+ }
+ }
pBitmap->ReleaseBuffer(pBuffer, false);
+
SalTwoRect aRect;
aRect.mnSrcX = 0;
aRect.mnSrcY = 0;
- aRect.mnSrcWidth = width;
- aRect.mnSrcHeight = height;
- mrParent.drawBitmap(aRect, *pBitmap);
+ aRect.mnSrcWidth = nWidth;
+ aRect.mnSrcHeight = nHeight;
+ aRect.mnDestX = 0;
+ aRect.mnDestY = 0;
+ aRect.mnDestWidth = nWidth;
+ aRect.mnDestHeight = nHeight;
+
+ mrParent.drawAlphaBitmap(aRect, *pBitmap);
delete pBitmap;
}
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index 63ab32b..fe7199c 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -185,6 +185,12 @@ bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
return mpImpl->drawAlphaBitmap( rTR, rSrcBitmap, rAlphaBmp );
}
+bool X11SalGraphics::drawAlphaBitmap( const SalTwoRect& rTR,
+ const SalBitmap& rBitmap )
+{
+ return mpImpl->drawAlphaBitmap( rTR, rBitmap );
+}
+
bool X11SalGraphics::drawTransformedBitmap(
const basegfx::B2DPoint& rNull,
const basegfx::B2DPoint& rX,
diff --git a/vcl/win/source/gdi/gdiimpl.hxx b/vcl/win/source/gdi/gdiimpl.hxx
index 2a0780f..0159f7c 100644
--- a/vcl/win/source/gdi/gdiimpl.hxx
+++ b/vcl/win/source/gdi/gdiimpl.hxx
@@ -189,6 +189,11 @@ public:
const SalBitmap& rSourceBitmap,
const SalBitmap& rAlphaBitmap ) SAL_OVERRIDE;
+ /** Render 32-bits bitmap with alpha channel */
+ virtual bool drawAlphaBitmap(
+ const SalTwoRect&,
+ const SalBitmap& rBitmap ) SAL_OVERRIDE {return false;}
+
/** draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system */
virtual bool drawTransformedBitmap(
const basegfx::B2DPoint& rNull,
commit 0f839d5ba9e2cc1e9958c46b901c831b01a7d93d
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Mon Nov 10 17:54:52 2014 -0500
vcl: Fix the VirtualDevice rectangle rendering in vcldemo
Change-Id: I43d43d5e81d52560154b102cc469761b51a590d4
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index cd3e32e..16574d9 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -281,7 +281,7 @@ public:
void fetchDrawBitmap(OutputDevice &rDev, Rectangle r)
{
- Bitmap aBitmap(GetBitmap(Point(0,0),rDev.GetOutputSizePixel()));
+ Bitmap aBitmap(rDev.GetBitmap(Point(0,0),rDev.GetOutputSizePixel()));
aBitmap.Scale(r.GetSize(), BMP_SCALE_BESTQUALITY);
rDev.DrawBitmap(r.TopLeft(), aBitmap);
}
commit 2dbd426c3b62b4a5b76da7a4b191059b2432c0e9
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Mon Nov 10 17:28:15 2014 -0500
vcl: Fix alpha value when drawing bitmap with mask
Change-Id: Ie9cbd754383296a9fe6e42346d4a17477eb88242
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 94cba66..80a5414 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -515,7 +515,7 @@ void OpenGLSalGraphicsImpl::DrawTextureWithMask( GLuint nTexture, GLuint nMask,
glBindTexture( GL_TEXTURE_2D, nMask );
glEnable( GL_BLEND );
- glBlendFunc( GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA );
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
DrawTextureRect( rSize, pPosAry );
glDisable( GL_BLEND );
diff --git a/vcl/opengl/maskedTextureFragmentShader.glsl b/vcl/opengl/maskedTextureFragmentShader.glsl
index badf91e..4d79ae9 100644
--- a/vcl/opengl/maskedTextureFragmentShader.glsl
+++ b/vcl/opengl/maskedTextureFragmentShader.glsl
@@ -17,7 +17,7 @@ void main() {
texel0 = texture2D(sampler, tex_coord);
texel1 = texture2D(mask, tex_coord);
gl_FragColor = texel0;
- gl_FragColor.a = texel1.r;
+ gl_FragColor.a = 1.0 - texel1.r;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 243047fd68820e15e13dd9afd33122aef20ca377
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Mon Nov 10 13:46:12 2014 -0500
vcl: Use a different FBO when rendering using a VirtualDevice
Change-Id: I8cb97a4057c06ca09adfcac8dcd3f61ac9508430
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index 6f7a03a..77ac90b 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -81,7 +81,7 @@ public:
public:
- bool Create( OpenGLContext& rContext, long nX, long nY, long nWidth, long nHeight );
+ bool Create( OpenGLContext& rContext, OpenGLTextureSharedPtr pTex, long nX, long nY, long nWidth, long nHeight );
bool Draw( OpenGLContext& rContext, const SalTwoRect& rPosAry );
GLuint GetTexture( OpenGLContext& rContext ) const;
diff --git a/vcl/inc/opengl/texture.hxx b/vcl/inc/opengl/texture.hxx
index f9d3ad8..c0b6541 100644
--- a/vcl/inc/opengl/texture.hxx
+++ b/vcl/inc/opengl/texture.hxx
@@ -39,6 +39,9 @@ public:
virtual ~OpenGLTexture();
GLuint Id() const;
+ int GetWidth() const;
+ int GetHeight() const;
+
void Bind();
void Unbind();
bool Draw();
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 9dfa231..e9be665 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -23,6 +23,8 @@
#include "salgdiimpl.hxx"
#include <vcl/dllapi.h>
+#include "opengl/texture.hxx"
+
#include <vcl/opengl/OpenGLContext.hxx>
class SalFrame;
@@ -36,6 +38,10 @@ protected:
SalFrame* mpFrame;
SalVirtualDevice* mpVDev;
+ bool mbOffscreen;
+ GLuint mnFramebufferId;
+ OpenGLTextureSharedPtr mpOffscreenTex;
+
SalColor mnLineColor;
SalColor mnFillColor;
@@ -90,6 +96,9 @@ protected:
// operations to do after painting
virtual void PostDraw();
+ // enable/disable offscreen rendering
+ virtual void SetOffscreen( bool bOffscreen );
+
public:
OpenGLSalGraphicsImpl();
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 6af704e..94cba66 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -75,16 +75,21 @@ OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl()
void OpenGLSalGraphicsImpl::PreDraw()
{
maContext.makeCurrent();
+ // TODO: lfrb: make sure the render target has the right size
+ if( mbOffscreen )
+ glBindFramebuffer( GL_FRAMEBUFFER, mnFramebufferId );
glViewport( 0, 0, GetWidth(), GetHeight() );
}
void OpenGLSalGraphicsImpl::PostDraw()
{
+ if( mbOffscreen )
+ glBindFramebuffer( GL_FRAMEBUFFER, 0 );
}
void OpenGLSalGraphicsImpl::freeResources()
{
- // Delete shaders, programs and textures if not shared
+ // TODO Delete shaders, programs and textures if not shared
}
bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
@@ -187,6 +192,38 @@ void OpenGLSalGraphicsImpl::SetROPFillColor( SalROPColor /*nROPColor*/ )
{
}
+// enable/disbale offscreen rendering
+void OpenGLSalGraphicsImpl::SetOffscreen( bool bOffscreen )
+{
+ if( bOffscreen == mbOffscreen )
+ {
+ // Already disabled
+ if( !mbOffscreen )
+ return;
+
+ // Already enabled and same size
+ if( mpOffscreenTex->GetWidth() == GetWidth() &&
+ mpOffscreenTex->GetHeight() == GetHeight() )
+ return;
+ }
+ else
+ {
+ mbOffscreen = bOffscreen;
+ if( bOffscreen )
+ glGenFramebuffers( 1, &mnFramebufferId );
+ else
+ glDeleteFramebuffers( 1, &mnFramebufferId );
+ }
+
+ if( mbOffscreen )
+ {
+ glBindFramebuffer( GL_FRAMEBUFFER, mnFramebufferId );
+ mpOffscreenTex.reset( new OpenGLTexture( GetWidth(), GetHeight() ) );
+ glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mpOffscreenTex->Id(), 0 );
+ CHECK_GL_ERROR();
+ }
+}
+
bool OpenGLSalGraphicsImpl::CreateSolidProgram( void )
{
SAL_INFO( "vcl.opengl", "::CreateSolidProgram" );
@@ -879,7 +916,7 @@ SalBitmap* OpenGLSalGraphicsImpl::getBitmap( long nX, long nY, long nWidth, long
SAL_INFO( "vcl.opengl", "::getBitmap " << nX << "," << nY <<
" " << nWidth << "x" << nHeight );
PreDraw();
- if( !pBitmap->Create( maContext, nX, nY, nWidth, nHeight ) )
+ if( !pBitmap->Create( maContext, mpOffscreenTex, nX, nY, nWidth, nHeight ) )
{
delete pBitmap;
pBitmap = NULL;
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index d54ace7..5a93aaa 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -52,7 +52,7 @@ OpenGLSalBitmap::~OpenGLSalBitmap()
SAL_INFO( "vcl.opengl", "~OpenGLSalBitmap" );
}
-bool OpenGLSalBitmap::Create( OpenGLContext& rContext, long nX, long nY, long nWidth, long nHeight )
+bool OpenGLSalBitmap::Create( OpenGLContext& rContext, OpenGLTextureSharedPtr pTex, long nX, long nY, long nWidth, long nHeight )
{
static const BitmapPalette aEmptyPalette;
@@ -60,7 +60,6 @@ bool OpenGLSalBitmap::Create( OpenGLContext& rContext, long nX, long nY, long nW
SAL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from FBO" );
mpContext = &rContext;
- mpContext->makeCurrent();
mnWidth = nWidth;
mnHeight = nHeight;
mnBufWidth = 0;
@@ -70,8 +69,13 @@ bool OpenGLSalBitmap::Create( OpenGLContext& rContext, long nX, long nY, long nW
mnBits = 32;
maPalette = aEmptyPalette;
- mpTexture.reset( new OpenGLTexture( nX, nY, nWidth, nHeight ) );
+ // TODO: lfrb: Crop texture if size doesn't match the texture one
+ if( pTex )
+ mpTexture = pTex;
+ else
+ mpTexture.reset( new OpenGLTexture( nX, nY, nWidth, nHeight ) );
mbDirtyTexture = false;
+ SAL_INFO( "vcl.opengl", "Created texture " << mpTexture->Id() );
return true;
}
@@ -154,6 +158,7 @@ GLuint OpenGLSalBitmap::GetTexture( OpenGLContext& rContext ) const
const_cast<OpenGLSalBitmap*>(this)->mpContext = &rContext;
if( !mpTexture || mbDirtyTexture )
const_cast<OpenGLSalBitmap*>(this)->CreateTexture();
+ SAL_INFO( "vcl.opengl", "Got texture " << mpTexture->Id() );
return mpTexture->Id();
}
@@ -388,9 +393,9 @@ GLuint OpenGLSalBitmap::CreateTexture()
}
}
- SAL_INFO( "vcl.opengl", "::CreateTexture" );
mpContext->makeCurrent();
mpTexture.reset( new OpenGLTexture (mnBufWidth, mnBufHeight, nFormat, nType, pData ) );
+ SAL_INFO( "vcl.opengl", "Created texture " << mpTexture->Id() );
if( bAllocated )
delete pData;
@@ -412,6 +417,8 @@ bool OpenGLSalBitmap::ReadTexture()
GLuint nFramebufferId, nRenderbufferDepthId, nRenderbufferColorId;
sal_uInt8* pData = maUserBuffer.get();
+ SAL_INFO( "vcl.opengl", "::ReadTexture" );
+
// TODO Check mnTexWidth and mnTexHeight
mpContext->makeCurrent();
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index 2770c20..0c8dc1d 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -95,6 +95,16 @@ GLuint OpenGLTexture::Id() const
return mnTexture;
}
+int OpenGLTexture::GetWidth() const
+{
+ return mnWidth;
+}
+
+int OpenGLTexture::GetHeight() const
+{
+ return mnHeight;
+}
+
GLenum OpenGLTexture::GetFilter() const
{
return mnFilter;
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index 353ec76..6e803bd 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -64,12 +64,14 @@ void X11OpenGLSalGraphicsImpl::Init()
{
Window aWin = dynamic_cast<X11WindowProvider*>(mrParent.m_pFrame)->GetX11Window();
maContext.init( mrParent.GetXDisplay(), aWin, mrParent.m_nXScreen.getXScreen());
+ SetOffscreen( false );
}
else if( mrParent.m_pVDev )
{
maContext.init( mrParent.GetXDisplay(), mrParent.m_pVDev->GetDrawable(),
mrParent.m_pVDev->GetWidth(), mrParent.m_pVDev->GetHeight(),
mrParent.m_nXScreen.getXScreen() );
+ SetOffscreen( true );
}
else
{
commit 7baadae3e8f4b0338234bd90135e90a355dc1dba
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Mon Nov 10 13:29:52 2014 -0500
vcl: Remove unused shaders list
Change-Id: I13a25a39cceb184c2bb2b48bc143a951ee982b26
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 4a0005a..9dfa231 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -39,8 +39,6 @@ protected:
SalColor mnLineColor;
SalColor mnFillColor;
- std::vector< GLuint > maShaders;
-
GLuint mnSolidProgram;
GLuint mnColorUniform;
commit a9db0c6448d29ff90916e2e880f850469f66e85e
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Mon Nov 10 13:06:38 2014 -0500
vcl: Add methods to call before and after OpenGL rendering
Change-Id: I937907a3e8eb8f841a2eed6199e86d022be7dc16
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index cfabebe..4a0005a 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -86,6 +86,12 @@ protected:
// get the height of the device
virtual GLfloat GetHeight() const = 0;
+ // operations to do before painting
+ virtual void PreDraw();
+
+ // operations to do after painting
+ virtual void PostDraw();
+
public:
OpenGLSalGraphicsImpl();
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index c67e560..6af704e 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -72,6 +72,16 @@ OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl()
{
}
+void OpenGLSalGraphicsImpl::PreDraw()
+{
+ maContext.makeCurrent();
+ glViewport( 0, 0, GetWidth(), GetHeight() );
+}
+
+void OpenGLSalGraphicsImpl::PostDraw()
+{
+}
+
void OpenGLSalGraphicsImpl::freeResources()
{
// Delete shaders, programs and textures if not shared
@@ -507,11 +517,11 @@ void OpenGLSalGraphicsImpl::drawPixel( long nX, long nY )
SAL_INFO( "vcl.opengl", "::drawPixel" );
if( mnLineColor != SALCOLOR_NONE )
{
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
BeginSolid( mnLineColor );
DrawPoint( nX, nY );
EndSolid();
+ PostDraw();
}
}
@@ -520,11 +530,11 @@ void OpenGLSalGraphicsImpl::drawPixel( long nX, long nY, SalColor nSalColor )
SAL_INFO( "vcl.opengl", "::drawPixel" );
if( nSalColor != SALCOLOR_NONE )
{
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
BeginSolid( nSalColor );
DrawPoint( nX, nY );
EndSolid();
+ PostDraw();
}
}
@@ -533,19 +543,18 @@ void OpenGLSalGraphicsImpl::drawLine( long nX1, long nY1, long nX2, long nY2 )
SAL_INFO( "vcl.opengl", "::drawLine" );
if( mnLineColor != SALCOLOR_NONE )
{
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
BeginSolid( mnLineColor );
DrawLine( nX1, nY1, nX2, nY2 );
EndSolid();
+ PostDraw();
}
}
void OpenGLSalGraphicsImpl::drawRect( long nX, long nY, long nWidth, long nHeight )
{
SAL_INFO( "vcl.opengl", "::drawRect" );
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
if( mnFillColor != SALCOLOR_NONE )
{
@@ -567,19 +576,21 @@ void OpenGLSalGraphicsImpl::drawRect( long nX, long nY, long nWidth, long nHeigh
DrawLines( 4, aPoints, true );
EndSolid();
}
+
+ PostDraw();
}
void OpenGLSalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry )
{
SAL_INFO( "vcl.opengl", "::drawPolyLine" );
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
if( mnLineColor != SALCOLOR_NONE && nPoints > 1 )
{
+ PreDraw();
BeginSolid( mnLineColor );
DrawLines( nPoints, pPtAry, false );
EndSolid();
+ PostDraw();
}
}
@@ -600,8 +611,7 @@ void OpenGLSalGraphicsImpl::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPt
return;
}
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
if( mnFillColor != SALCOLOR_NONE )
{
@@ -616,6 +626,8 @@ void OpenGLSalGraphicsImpl::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPt
DrawLines( nPoints, pPtAry, true );
EndSolid();
}
+
+ PostDraw();
}
void OpenGLSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry )
@@ -624,8 +636,7 @@ void OpenGLSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32*
if( nPoly <= 0 )
return;
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
if( mnFillColor != SALCOLOR_NONE )
{
@@ -643,6 +654,8 @@ void OpenGLSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32*
DrawLines( pPoints[i], pPtAry[i], true );
EndSolid();
}
+
+ PostDraw();
}
bool OpenGLSalGraphicsImpl::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPolygon, double fTransparency )
@@ -651,8 +664,7 @@ bool OpenGLSalGraphicsImpl::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rP
if( rPolyPolygon.count() <= 0 )
return true;
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
if( mnFillColor != SALCOLOR_NONE )
{
@@ -665,6 +677,8 @@ bool OpenGLSalGraphicsImpl::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rP
EndSolid();
}
+ PostDraw();
+
return true;
}
@@ -736,8 +750,7 @@ bool OpenGLSalGraphicsImpl::drawPolyLine(
aPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(1.0, rLineWidth.getY() / rLineWidth.getX()));
}
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
BeginSolid( mnLineColor, fTransparency );
for( sal_uInt32 i = 0; i < aAreaPolyPoly.count(); i++ )
{
@@ -745,6 +758,7 @@ bool OpenGLSalGraphicsImpl::drawPolyLine(
DrawPolyPolygon( aOnePoly );
}
EndSolid();
+ PostDraw();
return true;
}
@@ -816,9 +830,9 @@ void OpenGLSalGraphicsImpl::drawBitmap( const SalTwoRect& rPosAry, const SalBitm
const Size aSize = rSalBitmap.GetSize();
SAL_INFO( "vcl.opengl", "::drawBitmap" );
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
DrawTexture( nTexture, aSize, rPosAry );
+ PostDraw();
}
void OpenGLSalGraphicsImpl::drawBitmap(
@@ -840,9 +854,9 @@ void OpenGLSalGraphicsImpl::drawBitmap(
const GLuint nMask( rMask.GetTexture( maContext ) );
SAL_INFO( "vcl.opengl", "::drawBitmap with MASK" );
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
DrawTextureWithMask( nTexture, nMask, rBitmap.GetSize(), rPosAry );
+ PostDraw();
}
void OpenGLSalGraphicsImpl::drawMask(
@@ -854,9 +868,9 @@ void OpenGLSalGraphicsImpl::drawMask(
const GLuint nTexture( rBitmap.GetTexture( maContext ) );
SAL_INFO( "vcl.opengl", "::drawMask" );
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
DrawMask( nTexture, nMaskColor, rPosAry );
+ PostDraw();
}
SalBitmap* OpenGLSalGraphicsImpl::getBitmap( long nX, long nY, long nWidth, long nHeight )
@@ -864,11 +878,13 @@ SalBitmap* OpenGLSalGraphicsImpl::getBitmap( long nX, long nY, long nWidth, long
OpenGLSalBitmap* pBitmap = new OpenGLSalBitmap;
SAL_INFO( "vcl.opengl", "::getBitmap " << nX << "," << nY <<
" " << nWidth << "x" << nHeight );
+ PreDraw();
if( !pBitmap->Create( maContext, nX, nY, nWidth, nHeight ) )
{
delete pBitmap;
pBitmap = NULL;
}
+ PostDraw();
return pBitmap;
}
@@ -876,9 +892,9 @@ SalColor OpenGLSalGraphicsImpl::getPixel( long nX, long nY )
{
char pixel[3] = { 0, 0, 0 };
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
glReadPixels( nX, nY, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel);
+ PostDraw();
return MAKE_SALCOLOR( pixel[0], pixel[1], pixel[2] );
}
@@ -892,8 +908,7 @@ void OpenGLSalGraphicsImpl::invert(
// * SAL_INVERT_50 (50/50 pattern?)
// * SAL_INVERT_TRACKFRAME (dash-line rectangle?)
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
if( nFlags & SAL_INVERT_TRACKFRAME )
{
@@ -909,12 +924,13 @@ void OpenGLSalGraphicsImpl::invert(
DrawRect( nX, nY, nWidth, nHeight );
EndInvert();
}
+
+ PostDraw();
}
void OpenGLSalGraphicsImpl::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags )
{
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
if( nFlags & SAL_INVERT_TRACKFRAME )
{
@@ -930,6 +946,8 @@ void OpenGLSalGraphicsImpl::invert( sal_uInt32 nPoints, const SalPoint* pPtAry,
DrawPolygon( nPoints, pPtAry );
EndInvert();
}
+
+ PostDraw();
}
bool OpenGLSalGraphicsImpl::drawEPS(
@@ -964,9 +982,9 @@ bool OpenGLSalGraphicsImpl::drawAlphaBitmap(
const GLuint nAlpha( rAlpha.GetTexture( maContext ) );
SAL_INFO( "vcl.opengl", "::drawAlphaBitmap" );
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
DrawTextureWithMask( nTexture, nAlpha, rBitmap.GetSize(), rPosAry );
+ PostDraw();
return true;
}
@@ -995,9 +1013,11 @@ bool OpenGLSalGraphicsImpl::drawAlphaRect(
SAL_INFO( "vcl.opengl", "::drawAlphaRect" );
if( mnFillColor != SALCOLOR_NONE && nTransparency < 100 )
{
+ PreDraw();
BeginSolid( mnFillColor, nTransparency );
DrawRect( nX, nY, nWidth, nHeight );
EndSolid();
+ PostDraw();
}
return true;
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index 11735edb..353ec76 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -114,8 +114,7 @@ bool X11OpenGLSalGraphicsImpl::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX,
pGlxPixmap = glXCreatePixmap( pDisplay, pFbConfig, pPixmap->GetPixmap(), aAttribs);
XSync( pDisplay, 0 );
- maContext.makeCurrent();
- glViewport( 0, 0, GetWidth(), GetHeight() );
+ PreDraw();
glGenTextures( 1, &nTexture );
glActiveTexture( GL_TEXTURE0 );
@@ -133,6 +132,8 @@ bool X11OpenGLSalGraphicsImpl::RenderPixmapToScreen( X11Pixmap* pPixmap, int nX,
glDeleteTextures( 1, &nTexture );
glXDestroyPixmap( pDisplay, pGlxPixmap );
+ PostDraw();
+
return true;
}
commit 03263ee1fdd9171b290359c85e1f43efa38c7fdb
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Mon Nov 10 10:12:20 2014 -0500
vcl: Fix pixel drawing with OpenGL
Change-Id: I5d8e80baec9537e0c5913d821e26566409fe5261
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index e00c9c0..c67e560 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -296,7 +296,7 @@ void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY )
pPoint[1] = 2 * (GetHeight() - nY) / GetHeight() - 1.0f;
glEnableVertexAttribArray( GL_ATTRIB_POS );
- glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_UNSIGNED_SHORT, GL_FALSE, 0, pPoint );
+ glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, pPoint );
glDrawArrays( GL_POINTS, 0, 1 );
glDisableVertexAttribArray( GL_ATTRIB_POS );
}
More information about the Libreoffice-commits
mailing list