[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - 9 commits - include/vcl vcl/headless vcl/inc vcl/opengl vcl/Package_opengl.mk vcl/quartz vcl/source vcl/unx vcl/win
Jan Holesovsky
kendy at collabora.com
Wed Dec 3 05:42:31 PST 2014
include/vcl/opengl/OpenGLContext.hxx | 2 -
vcl/Package_opengl.mk | 1
vcl/headless/svpbmp.cxx | 10 ++++++++
vcl/inc/headless/svpbmp.hxx | 3 ++
vcl/inc/impbmp.hxx | 2 +
vcl/inc/opengl/program.hxx | 2 +
vcl/inc/opengl/salbmp.hxx | 2 +
vcl/inc/opengl/win/gdiimpl.hxx | 1
vcl/inc/opengl/x11/gdiimpl.hxx | 1
vcl/inc/openglgdiimpl.hxx | 6 ++--
vcl/inc/quartz/salbmp.h | 2 +
vcl/inc/salbmp.hxx | 3 ++
vcl/inc/unx/salbmp.h | 2 +
vcl/inc/win/salbmp.h | 4 ++-
vcl/opengl/gdiimpl.cxx | 21 +++++++++--------
vcl/opengl/program.cxx | 19 +++++++++++++++
vcl/opengl/replaceColorFragmentShader.glsl | 23 +++++++++++++++++++
vcl/opengl/salbmp.cxx | 35 +++++++++++++++++++++++++++++
vcl/opengl/texture.cxx | 22 ++++++++----------
vcl/opengl/win/gdiimpl.cxx | 11 +--------
vcl/opengl/x11/gdiimpl.cxx | 10 --------
vcl/quartz/salbmp.cxx | 10 ++++++++
vcl/source/app/svdata.cxx | 8 ++++++
vcl/source/app/svmain.cxx | 6 ++++
vcl/source/gdi/bitmap.cxx | 18 ++++++++++++++
vcl/source/gdi/impbmp.cxx | 10 ++++++++
vcl/source/opengl/OpenGLContext.cxx | 25 --------------------
vcl/unx/generic/gdi/salbmp.cxx | 10 ++++++++
vcl/win/source/gdi/salbmp.cxx | 10 ++++++++
29 files changed, 205 insertions(+), 74 deletions(-)
New commits:
commit d0b24883c2189f77982d64e481061d9ce430fed5
Author: Jan Holesovsky <kendy at collabora.com>
Date: Wed Dec 3 14:24:33 2014 +0100
vcl: Fix Linux build.
Change-Id: I3b6e870dc5bcbc227b2ab02c0e622abd3f8c9a98
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 16db85f..30a23b5 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -654,20 +654,6 @@ bool OpenGLContext::init(Display* dpy, Window win, int screen)
return ImplInit();
}
-void OpenGLContext::resetToReInitialize()
-{
- if( !mbInitialized )
- return;
- resetCurrent();
-
- if (mbPixmap)
- {
- glXDestroyPixmap(m_aGLWin.dpy, m_aGLWin.glPix);
- m_aGLWin.glPix = None;
- }
- mbInitialized = false;
-}
-
bool OpenGLContext::init(Display* dpy, Pixmap pix, unsigned int width, unsigned int height, int nScreen)
{
if(mbInitialized)
commit 2d1f090e7ae0c05a30531fa13d82047d898512e9
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Tue Dec 2 17:18:26 2014 -0500
vcl: Fix color-replacement fragment shader
Change-Id: I82a0a45961ea3f0ceca7dab67c8736b5e1205bb0
diff --git a/vcl/opengl/replaceColorFragmentShader.glsl b/vcl/opengl/replaceColorFragmentShader.glsl
index 7c5b4c5..6e845f0 100644
--- a/vcl/opengl/replaceColorFragmentShader.glsl
+++ b/vcl/opengl/replaceColorFragmentShader.glsl
@@ -18,8 +18,6 @@ void main() {
vec4 diff = clamp(abs(texel - search_color) - epsilon, 0.0, 1.0);
float bump = max(0.0, 1.0 - ceil(diff.x + diff.y + diff.z));
gl_FragColor = texel + bump * (replace_color - search_color);
- gl_FragColor.r = 1.0;
- gl_FragColor.g = 0.0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 1a5f00fd1da5d3ff13dd3ddb961ad09dc7d919c4
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Tue Dec 2 16:42:32 2014 -0500
vcl: Acquire framebuffer from current context when reading back texture
Change-Id: I410ac2d10ec2e498d9d8444e5584bfb14727c90b
diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx
index cc5be78..e4bc532 100644
--- a/vcl/opengl/texture.cxx
+++ b/vcl/opengl/texture.cxx
@@ -18,10 +18,14 @@
*/
#include <sal/config.h>
+#include <vcl/opengl/OpenGLContext.hxx>
#include <vcl/opengl/OpenGLHelper.hxx>
+#include "svdata.hxx"
+
#include "vcl/salbtype.hxx"
+#include "opengl/framebuffer.hxx"
#include "opengl/texture.hxx"
// texture with allocated size
@@ -299,21 +303,15 @@ void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData )
}
else
{
- GLuint nFramebufferId;
- glGenFramebuffers( 1, &nFramebufferId );
- glBindFramebuffer( GL_FRAMEBUFFER, nFramebufferId );
- CHECK_GL_ERROR();
+ // Retrieve current context
+ ImplSVData* pSVData = ImplGetSVData();
+ OpenGLContext* pContext = pSVData->maGDIData.mpLastContext;
+ OpenGLFramebuffer* pFramebuffer;
- glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, Id(), 0 );
- CHECK_GL_ERROR();
+ pFramebuffer = pContext->AcquireFramebuffer( *this );
glReadPixels( maRect.Left(), mpImpl->mnHeight - maRect.Top(), GetWidth(), GetHeight(), nFormat, nType, pData );
+ pContext->ReleaseFramebuffer( pFramebuffer );
CHECK_GL_ERROR();
-
- glBindFramebuffer( GL_FRAMEBUFFER, 0 );
- glDeleteFramebuffers( 1, &nFramebufferId );
-
- int bpp = (nFormat == GL_RGB) ? 3 : 4;
- memset( pData, 255, GetWidth() * GetHeight() * bpp );
}
Unbind();
commit 2ab7c0c055939a3219fc6fd3e4053fe4b82d4cda
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Tue Dec 2 16:41:02 2014 -0500
vcl: Implement bitmap color replacement operation in OpenGL backend
Change-Id: Ia86b67e92985eeb4fb2a5f6cd74c65fab2ac5566
diff --git a/vcl/Package_opengl.mk b/vcl/Package_opengl.mk
index 98ff78b..0aa324f 100644
--- a/vcl/Package_opengl.mk
+++ b/vcl/Package_opengl.mk
@@ -19,6 +19,7 @@ $(eval $(call gb_Package_add_files,vcl_opengl_shader,$(LIBO_ETC_FOLDER)/opengl,\
maskFragmentShader.glsl \
maskedTextureFragmentShader.glsl \
radialGradientFragmentShader.glsl \
+ replaceColorFragmentShader.glsl \
solidFragmentShader.glsl \
textureFragmentShader.glsl \
textureVertexShader.glsl \
diff --git a/vcl/inc/opengl/program.hxx b/vcl/inc/opengl/program.hxx
index 2aeb2fd..96fed09 100644
--- a/vcl/inc/opengl/program.hxx
+++ b/vcl/inc/opengl/program.hxx
@@ -47,9 +47,11 @@ public:
void SetTextureCoord( const GLvoid* pData );
void SetAlphaCoord( const GLvoid* pData );
+ void SetUniform1f( const OString& rName, GLfloat v1 );
void SetUniform2f( const OString& rName, GLfloat v1, GLfloat v2 );
void SetUniform1fv( const OString& rName, GLsizei nCount, GLfloat* aValues );
void SetUniform2fv( const OString& rName, GLsizei nCount, GLfloat* aValues );
+ void SetColor( const OString& rName, const Color& rColor );
void SetColor( const OString& rName, SalColor nColor, sal_uInt8 nTransparency );
void SetColorf( const OString& rName, SalColor nColor, double fTransparency );
void SetColorWithIntensity( const OString& rName, const Color& rColor, long nFactor );
diff --git a/vcl/opengl/program.cxx b/vcl/opengl/program.cxx
index 320b06f..8b92c4b 100644
--- a/vcl/opengl/program.cxx
+++ b/vcl/opengl/program.cxx
@@ -126,6 +126,12 @@ GLuint OpenGLProgram::GetUniformLocation( const OString& rName )
return it->second;
}
+void OpenGLProgram::SetUniform1f( const OString& rName, GLfloat v1 )
+{
+ GLuint nUniform = GetUniformLocation( rName );
+ glUniform1f( nUniform, v1 );
+}
+
void OpenGLProgram::SetUniform2f( const OString& rName, GLfloat v1, GLfloat v2 )
{
GLuint nUniform = GetUniformLocation( rName );
@@ -170,6 +176,19 @@ void OpenGLProgram::SetColorf( const OString& rName, SalColor nColor, double fTr
SetBlendMode( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
}
+void OpenGLProgram::SetColor( const OString& rName, const Color& rColor )
+{
+ GLuint nUniform = GetUniformLocation( rName );
+ glUniform4f( nUniform,
+ ((float) rColor.GetRed()) / 255,
+ ((float) rColor.GetGreen()) / 255,
+ ((float) rColor.GetBlue()) / 255,
+ 1.0f - ((float) rColor.GetTransparency()) / 255 );
+
+ if( rColor.GetTransparency() > 0 )
+ SetBlendMode( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+}
+
void OpenGLProgram::SetColorWithIntensity( const OString& rName, const Color& rColor, long nFactor )
{
GLuint nUniform = GetUniformLocation( rName );
diff --git a/vcl/opengl/replaceColorFragmentShader.glsl b/vcl/opengl/replaceColorFragmentShader.glsl
new file mode 100644
index 0000000..7c5b4c5
--- /dev/null
+++ b/vcl/opengl/replaceColorFragmentShader.glsl
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+varying vec2 tex_coord;
+uniform sampler2D sampler;
+uniform vec4 search_color;
+uniform vec4 replace_color;
+uniform float epsilon;
+
+void main() {
+ vec4 texel = texture2D(sampler, tex_coord);
+ vec4 diff = clamp(abs(texel - search_color) - epsilon, 0.0, 1.0);
+ float bump = max(0.0, 1.0 - ceil(diff.x + diff.y + diff.z));
+ gl_FragColor = texel + bump * (replace_color - search_color);
+ gl_FragColor.r = 1.0;
+ gl_FragColor.g = 0.0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 078e050..94c0c87 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -27,6 +27,7 @@
#include "svdata.hxx"
#include "salgdi.hxx"
+#include "opengl/program.hxx"
#include "opengl/salbmp.hxx"
static bool isValidBitCount( sal_uInt16 nBitCount )
@@ -579,9 +580,33 @@ bool OpenGLSalBitmap::Erase( const ::Color& /*rFillColor*/ )
return false;
}
-bool OpenGLSalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uLong /*nTol*/ )
+bool OpenGLSalBitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol )
{
- return false;
+ OpenGLFramebuffer* pFramebuffer;
+ OpenGLProgram* pProgram;
+
+ GetTexture();
+ makeCurrent();
+ pProgram = mpContext->UseProgram( "textureVertexShader",
+ "replaceColorFragmentShader" );
+ if( !pProgram )
+ return false;
+
+ OpenGLTexture aNewTex = OpenGLTexture( mnWidth, mnHeight );
+ pFramebuffer = mpContext->AcquireFramebuffer( aNewTex );
+
+ pProgram->SetTexture( "sampler", maTexture );
+ pProgram->SetColor( "search_color", rSearchColor );
+ pProgram->SetColor( "replace_color", rReplaceColor );
+ pProgram->SetUniform1f( "epsilon", nTol / 255.0f );
+ pProgram->DrawTexture( maTexture );
+ pProgram->Clean();
+
+ mpContext->ReleaseFramebuffer( pFramebuffer );
+ maTexture = aNewTex;
+
+ CHECK_GL_ERROR();
+ return true;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 6a48cfafca153aadd7b093e0a33720959edfa16b
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Tue Dec 2 14:19:33 2014 -0500
vcl: Add dummy Replace to SalBitmap implementations
Change-Id: I2f8b11a3f7cb8872a1d8f6eeeae8ce3f30223496
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index e4080da..014b0e9 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -354,6 +354,11 @@ bool SvpSalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/,
return false;
}
+bool SvpSalBitmap::Replace( const ::Color& /*rSearchColor*/, const ::Color& /*rReplaceColor*/, sal_uLong /*nTol*/ )
+{
+ return false;
+}
+
sal_uInt32 SvpSalBitmap::getBitCountFromScanlineFormat( basebmp::Format nFormat )
{
sal_uInt32 nBitCount = 1;
diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx
index eda1be4..61672fc 100644
--- a/vcl/inc/headless/svpbmp.hxx
+++ b/vcl/inc/headless/svpbmp.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_VCL_INC_HEADLESS_SVPBMP_HXX
#include "sal/config.h"
+#include "tools/solar.h"
#include "basebmp/bitmapdevice.hxx"
@@ -61,6 +62,7 @@ public:
virtual bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
virtual bool Erase( const Color& rFillColor ) SAL_OVERRIDE;
virtual bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) SAL_OVERRIDE;
+ virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) SAL_OVERRIDE;
static sal_uInt32 getBitCountFromScanlineFormat( basebmp::Format nFormat );
};
diff --git a/vcl/inc/impbmp.hxx b/vcl/inc/impbmp.hxx
index 3b2abea..de70989 100644
--- a/vcl/inc/impbmp.hxx
+++ b/vcl/inc/impbmp.hxx
@@ -71,6 +71,7 @@ public:
bool ImplCrop( const Rectangle& rRectPixel );
bool ImplErase( const Color& rFillColor );
bool ImplScale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag );
+ bool ImplReplace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol );
};
#endif // INCLUDED_VCL_INC_IMPBMP_HXX
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index c25dfa8..2a30764 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -82,6 +82,7 @@ public:
bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
bool Erase( const Color& rFillColor ) SAL_OVERRIDE;
bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) SAL_OVERRIDE;
+ bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) SAL_OVERRIDE;
public:
diff --git a/vcl/inc/quartz/salbmp.h b/vcl/inc/quartz/salbmp.h
index 9ece5a3..6b1fa04 100644
--- a/vcl/inc/quartz/salbmp.h
+++ b/vcl/inc/quartz/salbmp.h
@@ -82,6 +82,7 @@ public:
bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
bool Erase( const Color& rFillColor ) SAL_OVERRIDE;
bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) SAL_OVERRIDE;
+ bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) SAL_OVERRIDE;
private:
// quartz helper
diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx
index 12e7954..9760bc6 100644
--- a/vcl/inc/salbmp.hxx
+++ b/vcl/inc/salbmp.hxx
@@ -59,6 +59,7 @@ public:
virtual bool Crop( const Rectangle& rRectPixel ) = 0;
virtual bool Erase( const Color& rFillColor ) = 0;
virtual bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) = 0;
+ virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) = 0;
};
#endif
diff --git a/vcl/inc/unx/salbmp.h b/vcl/inc/unx/salbmp.h
index 0dfbb2f..0b5cbc7 100644
--- a/vcl/inc/unx/salbmp.h
+++ b/vcl/inc/unx/salbmp.h
@@ -149,6 +149,7 @@ public:
virtual bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
virtual bool Erase( const Color& rFillColor ) SAL_OVERRIDE;
virtual bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) SAL_OVERRIDE;
+ virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) SAL_OVERRIDE;
};
// - ImplSalDDB -
diff --git a/vcl/inc/win/salbmp.h b/vcl/inc/win/salbmp.h
index 7329449..12fd4ca 100644
--- a/vcl/inc/win/salbmp.h
+++ b/vcl/inc/win/salbmp.h
@@ -99,7 +99,8 @@ public:
virtual bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
virtual bool Erase( const Color& rFillColor ) SAL_OVERRIDE;
- virtual bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag );
+ virtual bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) SAL_OVERRIDE;
+ virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) SAL_OVERRIDE;
};
#endif // INCLUDED_VCL_INC_WIN_SALBMP_H
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 9fde118..078e050 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -579,4 +579,9 @@ bool OpenGLSalBitmap::Erase( const ::Color& /*rFillColor*/ )
return false;
}
+bool OpenGLSalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uLong /*nTol*/ )
+{
+ return false;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx
index e77f9d4..d3fc899 100644
--- a/vcl/quartz/salbmp.cxx
+++ b/vcl/quartz/salbmp.cxx
@@ -978,4 +978,9 @@ bool QuartzSalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*
return false;
}
+bool QuartzSalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uLong /*nTol*/ )
+{
+ return false;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/bitmap.cxx b/vcl/source/gdi/bitmap.cxx
index c034b27..9b24f4c 100644
--- a/vcl/source/gdi/bitmap.cxx
+++ b/vcl/source/gdi/bitmap.cxx
@@ -1583,6 +1583,24 @@ bool Bitmap::Replace( const AlphaMask& rAlpha, const Color& rMergeColor )
bool Bitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol )
{
+ if( mpImpBmp )
+ {
+ // implementation specific replace
+ ImpBitmap* pImpBmp = new ImpBitmap;
+
+ if( pImpBmp->ImplCreate( *mpImpBmp ) && pImpBmp->ImplReplace( rSearchColor, rReplaceColor, nTol ) )
+ {
+ ImplSetImpBitmap( pImpBmp );
+ maPrefMapMode = MapMode( MAP_PIXEL );
+ maPrefSize = pImpBmp->ImplGetSize();
+ return true;
+ }
+ else
+ {
+ delete pImpBmp;
+ }
+ }
+
// Bitmaps with 1 bit color depth can cause problems
// if they have other entries than black/white in their palette
if( 1 == GetBitCount() )
diff --git a/vcl/source/gdi/impbmp.cxx b/vcl/source/gdi/impbmp.cxx
index bcb5b75..5a47845 100644
--- a/vcl/source/gdi/impbmp.cxx
+++ b/vcl/source/gdi/impbmp.cxx
@@ -108,4 +108,9 @@ bool ImpBitmap::ImplScale( const double& rScaleX, const double& rScaleY, sal_uIn
return mpSalBitmap->Scale( rScaleX, rScaleY, nScaleFlag );
}
+bool ImpBitmap::ImplReplace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol )
+{
+ return mpSalBitmap->Replace( rSearchColor, rReplaceColor, nTol );
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index a08aa7d..3495ede 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -875,6 +875,11 @@ bool X11SalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/,
return false;
}
+bool X11SalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uLong /*nTol*/ )
+{
+ return false;
+}
+
// - ImplSalDDB -
ImplSalDDB::ImplSalDDB( XImage* pImage, Drawable aDrawable,
diff --git a/vcl/win/source/gdi/salbmp.cxx b/vcl/win/source/gdi/salbmp.cxx
index 9af94ee..b32067d 100644
--- a/vcl/win/source/gdi/salbmp.cxx
+++ b/vcl/win/source/gdi/salbmp.cxx
@@ -1077,4 +1077,9 @@ bool WinSalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/,
return false;
}
+bool WinSalBitmap::Replace( const Color& /*rSearchColor*/, const Color& /*rReplaceColor*/, sal_uLong /*nTol*/ )
+{
+ return false;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit d2b86b1eb241aa37e2335af351f706226047cd21
Author: Matúš Kukan <matus.kukan at collabora.com>
Date: Mon Nov 24 22:18:56 2014 +0100
Add dummy Erase to SalBitmap implementations
Change-Id: I5790deb9ab5af6f8678c964af5321264d3bce733
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index d5a1e79..e4080da 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -344,6 +344,11 @@ bool SvpSalBitmap::Crop( const Rectangle& /*rRectPixel*/ )
return false;
}
+bool SvpSalBitmap::Erase( const ::Color& /*rFillColor*/ )
+{
+ return false;
+}
+
bool SvpSalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/, sal_uInt32 /*nScaleFlag*/ )
{
return false;
diff --git a/vcl/inc/headless/svpbmp.hxx b/vcl/inc/headless/svpbmp.hxx
index 0de0d78..eda1be4 100644
--- a/vcl/inc/headless/svpbmp.hxx
+++ b/vcl/inc/headless/svpbmp.hxx
@@ -59,6 +59,7 @@ public:
virtual bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE;
virtual bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
+ virtual bool Erase( const Color& rFillColor ) SAL_OVERRIDE;
virtual bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) SAL_OVERRIDE;
static sal_uInt32 getBitCountFromScanlineFormat( basebmp::Format nFormat );
diff --git a/vcl/inc/impbmp.hxx b/vcl/inc/impbmp.hxx
index 8f373c5..3b2abea 100644
--- a/vcl/inc/impbmp.hxx
+++ b/vcl/inc/impbmp.hxx
@@ -69,6 +69,7 @@ public:
inline sal_uLong ImplGetChecksum() const { return mnChecksum; }
bool ImplCrop( const Rectangle& rRectPixel );
+ bool ImplErase( const Color& rFillColor );
bool ImplScale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag );
};
diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index 6938a22..c25dfa8 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -80,6 +80,7 @@ public:
bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE;
bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
+ bool Erase( const Color& rFillColor ) SAL_OVERRIDE;
bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) SAL_OVERRIDE;
public:
diff --git a/vcl/inc/quartz/salbmp.h b/vcl/inc/quartz/salbmp.h
index c98cf2f..9ece5a3 100644
--- a/vcl/inc/quartz/salbmp.h
+++ b/vcl/inc/quartz/salbmp.h
@@ -80,6 +80,7 @@ public:
bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE;
bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
+ bool Erase( const Color& rFillColor ) SAL_OVERRIDE;
bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) SAL_OVERRIDE;
private:
diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx
index 5eb977d..12e7954 100644
--- a/vcl/inc/salbmp.hxx
+++ b/vcl/inc/salbmp.hxx
@@ -26,6 +26,7 @@
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
struct BitmapBuffer;
+class Color;
class SalGraphics;
class BitmapPalette;
struct BitmapSystemData;
@@ -56,6 +57,7 @@ public:
virtual bool GetSystemData( BitmapSystemData& rData ) = 0;
virtual bool Crop( const Rectangle& rRectPixel ) = 0;
+ virtual bool Erase( const Color& rFillColor ) = 0;
virtual bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) = 0;
};
diff --git a/vcl/inc/unx/salbmp.h b/vcl/inc/unx/salbmp.h
index df6e8bd..0dfbb2f 100644
--- a/vcl/inc/unx/salbmp.h
+++ b/vcl/inc/unx/salbmp.h
@@ -147,6 +147,7 @@ public:
virtual bool GetSystemData( BitmapSystemData& rData ) SAL_OVERRIDE;
virtual bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
+ virtual bool Erase( const Color& rFillColor ) SAL_OVERRIDE;
virtual bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag ) SAL_OVERRIDE;
};
diff --git a/vcl/inc/win/salbmp.h b/vcl/inc/win/salbmp.h
index b74ba73..7329449 100644
--- a/vcl/inc/win/salbmp.h
+++ b/vcl/inc/win/salbmp.h
@@ -98,6 +98,7 @@ public:
virtual bool GetSystemData( BitmapSystemData& rData );
virtual bool Crop( const Rectangle& rRectPixel ) SAL_OVERRIDE;
+ virtual bool Erase( const Color& rFillColor ) SAL_OVERRIDE;
virtual bool Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag );
};
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index db2bb1c..9fde118 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -574,4 +574,9 @@ bool OpenGLSalBitmap::Crop( const Rectangle& /*rRectPixel*/ )
return false;
}
+bool OpenGLSalBitmap::Erase( const ::Color& /*rFillColor*/ )
+{
+ return false;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx
index c3245b6..e77f9d4 100644
--- a/vcl/quartz/salbmp.cxx
+++ b/vcl/quartz/salbmp.cxx
@@ -968,6 +968,11 @@ bool QuartzSalBitmap::Crop( const Rectangle& /*rRectPixel*/ )
return false;
}
+bool QuartzSalBitmap::Erase( const ::Color& /*rFillColor*/ )
+{
+ return false;
+}
+
bool QuartzSalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/, sal_uInt32 /*nScaleFlag*/ )
{
return false;
diff --git a/vcl/source/gdi/impbmp.cxx b/vcl/source/gdi/impbmp.cxx
index b402d5b..bcb5b75 100644
--- a/vcl/source/gdi/impbmp.cxx
+++ b/vcl/source/gdi/impbmp.cxx
@@ -98,6 +98,11 @@ bool ImpBitmap::ImplCrop( const Rectangle& rRectPixel )
return mpSalBitmap->Crop( rRectPixel );
}
+bool ImpBitmap::ImplErase( const ::Color& rFillColor )
+{
+ return mpSalBitmap->Erase( rFillColor );
+}
+
bool ImpBitmap::ImplScale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag )
{
return mpSalBitmap->Scale( rScaleX, rScaleY, nScaleFlag );
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index 5d442f1..a08aa7d 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -865,6 +865,11 @@ bool X11SalBitmap::Crop( const Rectangle& /*rRectPixel*/ )
return false;
}
+bool X11SalBitmap::Erase( const ::Color& /*rFillColor*/ )
+{
+ return false;
+}
+
bool X11SalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/, sal_uInt32 /*nScaleFlag*/ )
{
return false;
diff --git a/vcl/win/source/gdi/salbmp.cxx b/vcl/win/source/gdi/salbmp.cxx
index fd02f54..9af94ee 100644
--- a/vcl/win/source/gdi/salbmp.cxx
+++ b/vcl/win/source/gdi/salbmp.cxx
@@ -1067,6 +1067,11 @@ bool WinSalBitmap::Crop( const Rectangle& /*rRectPixel*/ )
return false;
}
+bool WinSalBitmap::Erase( const ::Color& /*rFillColor*/ )
+{
+ return false;
+}
+
bool WinSalBitmap::Scale( const double& /*rScaleX*/, const double& /*rScaleY*/, sal_uInt32 /*nScaleFlag*/ )
{
return false;
commit 966fb80512545d2bdfb3afdb247ee3b9d111aa23
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Tue Dec 2 10:29:00 2014 -0500
vcl: Add reference on default window's context so it doesn't get destroyed
Change-Id: Ifce8903ce75b1d2ff6acfd717c689f8893d80802
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
index 0aaff4a..1485305 100644
--- a/vcl/source/app/svdata.cxx
+++ b/vcl/source/app/svdata.cxx
@@ -39,6 +39,7 @@
#include "vcl/dockwin.hxx"
#include "salinst.hxx"
#include "salframe.hxx"
+#include "salgdi.hxx"
#include "svdata.hxx"
#include "window.h"
#include "salimestatus.hxx"
@@ -49,6 +50,8 @@
#include "officecfg/Office/Common.hxx"
+#include "vcl/opengl/OpenGLContext.hxx"
+
#include <stdio.h>
using namespace com::sun::star::uno;
@@ -132,6 +135,11 @@ vcl::Window* ImplGetDefaultWindow()
DBG_WARNING( "ImplGetDefaultWindow(): No AppWindow" );
pSVData->mpDefaultWin = new WorkWindow( 0, WB_DEFAULTWIN );
pSVData->mpDefaultWin->SetText( OUString( "VCL ImplGetDefaultWindow" ) );
+
+ // Add a reference to the default context so it never gets deleted
+ OpenGLContext* pContext = pSVData->mpDefaultWin->GetGraphics()->GetOpenGLContext();
+ if( pContext )
+ pContext->AddRef();
}
Application::GetSolarMutex().release();
}
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index bd3544b..2fc122c 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -65,12 +65,15 @@
#include "outfont.hxx"
#include "PhysicalFontCollection.hxx"
#include "print.h"
+#include "salgdi.hxx"
#include "salsys.hxx"
#include "saltimer.hxx"
#include "salimestatus.hxx"
#include "impimagetree.hxx"
#include "xconnection.hxx"
+#include "vcl/opengl/OpenGLContext.hxx"
+
#include "osl/process.h"
#include "com/sun/star/lang/XMultiServiceFactory.hpp"
#include "com/sun/star/lang/XComponent.hpp"
@@ -448,6 +451,9 @@ void DeInitVCL()
}
if ( pSVData->mpDefaultWin )
{
+ OpenGLContext* pContext = pSVData->mpDefaultWin->GetGraphics()->GetOpenGLContext();
+ if( pContext )
+ pContext->DeRef();
delete pSVData->mpDefaultWin;
pSVData->mpDefaultWin = NULL;
}
commit 1f81123d8cb42fe1ba4d7f5922474fdabb171d1d
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Tue Dec 2 09:08:57 2014 -0500
vcl: Release the OpenGL context for offscreen rendering after each operation
Change-Id: If253a4c0a1f64b1cc54e0079d4455abf39620ac0
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index e836e82..f4fb17d 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -161,6 +161,11 @@ void OpenGLSalGraphicsImpl::PostDraw()
mpFramebuffer = NULL;
CHECK_GL_ERROR();
+
+ // release the context as there is no guarantee the underlying window
+ // will still be valid for the next draw operation
+ if( mbOffscreen )
+ ReleaseContext();
}
void OpenGLSalGraphicsImpl::freeResources()
commit b1cfad5e8b38fc02de498993cf46e2404ced1058
Author: Louis-Francis Ratté-Boulianne <lfrb at collabora.com>
Date: Tue Dec 2 09:05:19 2014 -0500
vcl: Don't create new contexts for Virtual Devices on Windows
Change-Id: I561a8142f986aca89e796ce2c4a0902fae41f9e6
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index 595a2ae..a78972c 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -238,8 +238,6 @@ public:
return mbInitialized;
}
- void resetToReInitialize();
-
bool supportMultiSampling() const;
static SystemWindowData generateWinData(vcl::Window* pParent, bool bRequestLegacyContext);
diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx
index 30ade23..03007c9 100644
--- a/vcl/inc/opengl/win/gdiimpl.hxx
+++ b/vcl/inc/opengl/win/gdiimpl.hxx
@@ -30,7 +30,6 @@ public:
protected:
virtual OpenGLContext* CreateWinContext() SAL_OVERRIDE;
virtual bool UseContext( OpenGLContext* pContext ) SAL_OVERRIDE;
- virtual OpenGLContext* CreatePixmapContext() SAL_OVERRIDE;
public:
virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
diff --git a/vcl/inc/opengl/x11/gdiimpl.hxx b/vcl/inc/opengl/x11/gdiimpl.hxx
index d6ef010..feb3961 100644
--- a/vcl/inc/opengl/x11/gdiimpl.hxx
+++ b/vcl/inc/opengl/x11/gdiimpl.hxx
@@ -27,7 +27,6 @@ public:
protected:
virtual OpenGLContext* CreateWinContext() SAL_OVERRIDE;
- virtual OpenGLContext* CreatePixmapContext() SAL_OVERRIDE;
virtual bool UseContext( OpenGLContext* pContext ) SAL_OVERRIDE;
public:
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index d328ab7..03d1c23 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -110,12 +110,12 @@ protected:
bool AcquireContext();
bool ReleaseContext();
+ // retrieve the default context for offscreen rendering
+ virtual OpenGLContext* GetDefaultContext();
+
// create a new context for window rendering
virtual OpenGLContext* CreateWinContext() = 0;
- // create a new context for offscreen rendering
- virtual OpenGLContext* CreatePixmapContext() = 0;
-
// check whether the given context can be used by this instance
virtual bool UseContext( OpenGLContext* pContext ) = 0;
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 970957c..e836e82 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -61,6 +61,11 @@ OpenGLContext* OpenGLSalGraphicsImpl::GetOpenGLContext()
return mpContext;
}
+OpenGLContext* OpenGLSalGraphicsImpl::GetDefaultContext()
+{
+ return ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext();
+}
+
bool OpenGLSalGraphicsImpl::AcquireContext( )
{
ImplSVData* pSVData = ImplGetSVData();
@@ -81,7 +86,7 @@ bool OpenGLSalGraphicsImpl::AcquireContext( )
if( pContext )
pContext->AddRef();
else
- pContext = mbOffscreen ? CreatePixmapContext() : CreateWinContext();
+ pContext = mbOffscreen ? GetDefaultContext() : CreateWinContext();
mpContext = pContext;
return (mpContext != NULL);
@@ -112,15 +117,6 @@ void OpenGLSalGraphicsImpl::Init()
maOffscreenTex.GetHeight() != GetHeight() )
{
maOffscreenTex = OpenGLTexture();
-#if defined(WNT)
- // URGH ... VirtualDevice may have destroyed the underlying resource
- // our context is associated with - FIXME: can we do better here ?
- if (mpContext)
- {
- mpContext->resetToReInitialize();
- ReleaseContext();
- }
-#endif
}
}
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index 939d4e0..a56ea30 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -38,16 +38,9 @@ bool WinOpenGLSalGraphicsImpl::UseContext( OpenGLContext* pContext )
{
if( !pContext || !pContext->isInitialized() )
return false;
+ if( IsOffscreen() )
+ return true;
return ( pContext->getOpenGLWindow().hWnd == mrParent.mhWnd );
}
-OpenGLContext* WinOpenGLSalGraphicsImpl::CreatePixmapContext()
-{
- OpenGLContext* pContext = new OpenGLContext();
- pContext->requestVirtualDevice();
- pContext->requestSingleBufferedRendering();
- pContext->init( mrParent.mhLocalDC, mrParent.mhWnd );
- return pContext;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index e5070d7..d0d890b 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -56,16 +56,6 @@ OpenGLContext* X11OpenGLSalGraphicsImpl::CreateWinContext()
return pContext;
}
-OpenGLContext* X11OpenGLSalGraphicsImpl::CreatePixmapContext()
-{
- X11OpenGLSalVirtualDevice* pVDev = dynamic_cast<X11OpenGLSalVirtualDevice*>(mrParent.m_pVDev);
-
- if( pVDev == NULL )
- return NULL;
-
- return ImplGetDefaultWindow()->GetGraphics()->GetOpenGLContext();
-}
-
bool X11OpenGLSalGraphicsImpl::UseContext( OpenGLContext* pContext )
{
X11WindowProvider *pProvider = dynamic_cast<X11WindowProvider*>(mrParent.m_pFrame);
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 01b74b9..16db85f 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -634,17 +634,6 @@ bool OpenGLContext::init(SystemChildWindow* pChildWindow)
return ImplInit();
}
-#if defined( WNT )
-// FIXME share resetToReInitialize() across platforms...
-void OpenGLContext::resetToReInitialize()
-{
- if( !mbInitialized )
- return;
- resetCurrent();
- mbInitialized = false;
-}
-#endif
-
#if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID
bool OpenGLContext::init(Display* dpy, Window win, int screen)
{
More information about the Libreoffice-commits
mailing list