[Libreoffice-commits] core.git: 7 commits - include/vcl vcl/inc vcl/Library_vcl.mk vcl/opengl vcl/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.com
Mon Oct 12 02:40:04 PDT 2015
include/vcl/BitmapProcessor.hxx | 23 ++++++++++++
vcl/Library_vcl.mk | 1
vcl/inc/opengl/win/gdiimpl.hxx | 2 +
vcl/opengl/salbmp.cxx | 63 +++++++++++++++++++---------------
vcl/opengl/win/gdiimpl.cxx | 37 +++++++++----------
vcl/source/bitmap/BitmapProcessor.cxx | 58 +++++++++++++++++++++++++++++++
vcl/source/gdi/image.cxx | 2 -
vcl/source/gdi/impimage.cxx | 23 +-----------
vcl/source/gdi/impimagetree.cxx | 7 +++
9 files changed, 149 insertions(+), 67 deletions(-)
New commits:
commit da5f77b001837c0660197b3ae80f1146eab8b200
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Mon Oct 12 11:34:36 2015 +0200
opengl: convert to RGB buffer, use unique_ptr
User RGB buffer rather then RGBA when converting an unsupported
bitmap buffer for reading into a texture.
Also use unique_ptr rather then manually deleting ImplPixelFormat
instance.
Change-Id: I4c94c22b7e185c176e45a1b9c4db6443fe6c4234
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index b38224c..d3a2ade 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -428,13 +428,14 @@ GLuint OpenGLSalBitmap::CreateTexture()
{
VCL_GL_INFO( "vcl.opengl", "::CreateTexture - convert from " << mnBits << " to 24 bits" );
- // convert to 32 bits RGBA using palette
- pData = new sal_uInt8[mnBufHeight * mnBufWidth * 4];
+ // convert to 24 bits RGB using palette
+ pData = new sal_uInt8[mnBufHeight * mnBufWidth * 3];
bAllocated = true;
- nFormat = GL_RGBA;
+ nFormat = GL_RGB;
nType = GL_UNSIGNED_BYTE;
- ImplPixelFormat* pSrcFormat = ImplPixelFormat::GetFormat( mnBits, maPalette );
+ std::unique_ptr<ImplPixelFormat> pSrcFormat(ImplPixelFormat::GetFormat(mnBits, maPalette));
+
sal_uInt8* pSrcData = maUserBuffer.get();
sal_uInt8* pDstData = pData;
@@ -451,12 +452,10 @@ GLuint OpenGLSalBitmap::CreateTexture()
*pDstData++ = c.GetRed();
*pDstData++ = c.GetGreen();
*pDstData++ = c.GetBlue();
- *pDstData++ = 255;
}
pSrcData += mnBytesPerRow;
}
- delete pSrcFormat;
}
}
commit d4b4483ecdc072b64158fb7376f73e9d83d88c58
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Mon Oct 12 11:07:57 2015 +0200
opengl: Extract calculation - bytes per row into its own function
Change-Id: I24864df3e698704d84f62be25daa3dd54b4dd356
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 1102f82..b38224c 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -38,11 +38,27 @@
namespace
{
-static bool isValidBitCount( sal_uInt16 nBitCount )
+bool isValidBitCount( sal_uInt16 nBitCount )
{
return (nBitCount == 1) || (nBitCount == 4) || (nBitCount == 8) || (nBitCount == 16) || (nBitCount == 24) || (nBitCount == 32);
}
+sal_uInt16 lclBytesPerRow(sal_uInt16 nBits, int nWidth)
+{
+ switch(nBits)
+ {
+ case 1: return (nWidth + 7) >> 3;
+ case 4: return (nWidth + 1) >> 1;
+ case 8: return nWidth;
+ case 16: return nWidth * 2;
+ case 24: return nWidth * 3;
+ case 32: return nWidth * 4;
+ default:
+ OSL_FAIL("vcl::OpenGLSalBitmap::AllocateUserData(), illegal bitcount!");
+ }
+ return 0;
+}
+
static std::vector<std::unique_ptr<FixedTextureAtlasManager>> sTextureAtlases;
}
@@ -192,19 +208,7 @@ bool OpenGLSalBitmap::AllocateUserData()
if( mnWidth && mnHeight )
{
- mnBytesPerRow = 0;
-
- switch( mnBits )
- {
- case 1: mnBytesPerRow = (mnWidth + 7) >> 3; break;
- case 4: mnBytesPerRow = (mnWidth + 1) >> 1; break;
- case 8: mnBytesPerRow = mnWidth; break;
- case 16: mnBytesPerRow = mnWidth << 1; break;
- case 24: mnBytesPerRow = (mnWidth << 1) + mnWidth; break;
- case 32: mnBytesPerRow = mnWidth << 2; break;
- default:
- OSL_FAIL("vcl::OpenGLSalBitmap::AllocateUserData(), illegal bitcount!");
- }
+ mnBytesPerRow = lclBytesPerRow(mnBits, mnWidth);
}
bool alloc = false;
commit 2c91daa5bc317a3afcb314160df6ecb988aaffd3
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Mon Oct 12 11:06:13 2015 +0200
opengl: improve VCL_GL_INFO reporting in OpenGLSalBitmap
Change-Id: I00d695e11f4df140482bba7d8909216515e330be
diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 1e62791..1102f82 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -71,7 +71,8 @@ bool OpenGLSalBitmap::Create( const OpenGLTexture& rTex, long nX, long nY, long
OpenGLZone aZone;
Destroy();
- VCL_GL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from FBO: [" << nX << ", " << nY << "] " << nWidth << "x" << nHeight );
+ VCL_GL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from FBO: ["
+ << nX << ", " << nY << "] " << nWidth << "x" << nHeight );
mnWidth = nWidth;
mnHeight = nHeight;
@@ -127,7 +128,9 @@ bool OpenGLSalBitmap::Create( const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount
const OpenGLSalBitmap& rSourceBitmap = static_cast<const OpenGLSalBitmap&>(rSalBmp);
- VCL_GL_INFO( "vcl.opengl", "OpenGLSalBitmap::Create from BMP: " << rSourceBitmap.mnWidth << "x" << rSourceBitmap.mnHeight );
+ VCL_GL_INFO("vcl.opengl", "OpenGLSalBitmap::Create from BMP: "
+ << rSourceBitmap.mnWidth << "x" << rSourceBitmap.mnHeight
+ << " Bits old: " << mnBits << " new:" << nNewBitCount );
if( isValidBitCount( nNewBitCount ) )
{
@@ -177,7 +180,7 @@ void OpenGLSalBitmap::Destroy()
{
OpenGLZone aZone;
- VCL_GL_INFO( "vcl.opengl", "Destroy OpenGLSalBitmap" );
+ VCL_GL_INFO("vcl.opengl", "Destroy OpenGLSalBitmap texture:" << maTexture.Id());
maPendingOps.clear();
maTexture = OpenGLTexture();
maUserBuffer.reset();
@@ -384,7 +387,7 @@ void OpenGLSalBitmap::ExecuteOperations()
GLuint OpenGLSalBitmap::CreateTexture()
{
- VCL_GL_INFO( "vcl.opengl", "::CreateTexture" );
+ VCL_GL_INFO( "vcl.opengl", "::CreateTexture bits: " << mnBits);
GLenum nFormat = GL_RGBA;
GLenum nType = GL_UNSIGNED_BYTE;
sal_uInt8* pData( NULL );
@@ -419,6 +422,8 @@ GLuint OpenGLSalBitmap::CreateTexture()
}
else
{
+ VCL_GL_INFO( "vcl.opengl", "::CreateTexture - convert from " << mnBits << " to 24 bits" );
+
// convert to 32 bits RGBA using palette
pData = new sal_uInt8[mnBufHeight * mnBufWidth * 4];
bAllocated = true;
@@ -455,7 +460,7 @@ GLuint OpenGLSalBitmap::CreateTexture()
lclInstantiateTexture(maTexture, mnBufWidth, mnBufHeight, nFormat, nType, pData);
- VCL_GL_INFO( "vcl.opengl", "Created texture " << maTexture.Id() );
+ VCL_GL_INFO("vcl.opengl", "Created texture " << maTexture.Id() << " bits: " << mnBits);
if( bAllocated )
delete[] pData;
@@ -471,7 +476,7 @@ bool OpenGLSalBitmap::ReadTexture()
{
sal_uInt8* pData = maUserBuffer.get();
- VCL_GL_INFO( "vcl.opengl", "::ReadTexture " << mnWidth << "x" << mnHeight );
+ VCL_GL_INFO( "vcl.opengl", "::ReadTexture " << mnWidth << "x" << mnHeight << " bits: " << mnBits);
if( pData == NULL )
return false;
@@ -816,6 +821,9 @@ bool OpenGLSalBitmap::GetSystemData( BitmapSystemData& /*rData*/ )
bool OpenGLSalBitmap::Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol )
{
+
+ VCL_GL_INFO("vcl.opengl", "::Replace");
+
OpenGLZone aZone;
OpenGLFramebuffer* pFramebuffer;
commit 9c48fae01c4577cfa1bd8dca5fd44367d25bbaf0
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Mon Oct 12 11:01:13 2015 +0200
opengl: remove code duplication when rendering a texture combo
Change-Id: Ic184e0e96103bb63322c8aaf8758c4c8f423e0b9
diff --git a/vcl/inc/opengl/win/gdiimpl.hxx b/vcl/inc/opengl/win/gdiimpl.hxx
index 5c91727..9e8c26a 100644
--- a/vcl/inc/opengl/win/gdiimpl.hxx
+++ b/vcl/inc/opengl/win/gdiimpl.hxx
@@ -33,6 +33,8 @@ protected:
virtual rtl::Reference<OpenGLContext> CreateWinContext() SAL_OVERRIDE;
virtual bool UseContext( const rtl::Reference<OpenGLContext> &pContext ) SAL_OVERRIDE;
+ bool RenderTextureCombo(TextureCombo& rCombo, int nX, int nY);
+
public:
virtual void Init() SAL_OVERRIDE;
virtual void copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index cc34d67..dba32a8 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -87,19 +87,25 @@ bool WinOpenGLSalGraphicsImpl::TryRenderCachedNativeControl(ControlCacheKey& rCo
const std::unique_ptr<TextureCombo>& pCombo = iterator->second;
+ bool bRet = false;
+
PreDraw();
- OpenGLTexture& rTexture = *pCombo->mpTexture;
+ bRet = RenderTextureCombo(*pCombo, nX, nY);
- SalTwoRect aPosAry(0, 0, rTexture.GetWidth(), rTexture.GetHeight(),
- nX, nY, rTexture.GetWidth(), rTexture.GetHeight());
+ PostDraw();
+
+ return bRet;
+}
- if (pCombo->mpMask)
- DrawTextureDiff(rTexture, *pCombo->mpMask, aPosAry);
- else
- DrawTexture(rTexture, aPosAry);
+bool WinOpenGLSalGraphicsImpl::RenderTextureCombo(TextureCombo& rCombo, int nX, int nY)
+{
+ OpenGLTexture& rTexture = *rCombo.mpTexture;
- PostDraw();
+ SalTwoRect aPosAry(0, 0, rTexture.GetWidth(), rTexture.GetHeight(),
+ nX, nY, rTexture.GetWidth(), rTexture.GetHeight());
+
+ DrawTextureDiff(rTexture, *rCombo.mpMask, aPosAry);
return true;
}
@@ -107,24 +113,17 @@ bool WinOpenGLSalGraphicsImpl::TryRenderCachedNativeControl(ControlCacheKey& rCo
bool WinOpenGLSalGraphicsImpl::RenderCompatibleDC(OpenGLCompatibleDC& rWhite, OpenGLCompatibleDC& rBlack,
int nX, int nY, TextureCombo& rCombo)
{
+ bool bRet = false;
+
PreDraw();
rCombo.mpTexture.reset(rWhite.getTexture());
rCombo.mpMask.reset(rBlack.getTexture());
-
- if (rCombo.mpTexture && rCombo.mpMask)
- {
- OpenGLTexture& rTexture = *rCombo.mpTexture;
-
- SalTwoRect aPosAry(0, 0, rTexture.GetWidth(), rTexture.GetHeight(),
- nX, nY, rTexture.GetWidth(), rTexture.GetHeight());
-
- DrawTextureDiff(*rCombo.mpTexture, *rCombo.mpMask, aPosAry);
- }
+ bRet = RenderTextureCombo(rCombo, nX, nY);
PostDraw();
- return true;
+ return bRet;
}
bool WinOpenGLSalGraphicsImpl::RenderAndCacheNativeControl(OpenGLCompatibleDC& rWhite, OpenGLCompatibleDC& rBlack,
commit c97ca26f2d5790d46b712813c15bb6731f0232b0
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Mon Oct 12 10:49:26 2015 +0200
tdf#94384 fix black icons with OpenGL enabled on Windows
Looks like the Windows specific code in ImplUpdateDisplayBmp is
not needed anymore and causes problems with OpenGL. The icons after
the change still seem to be drawn correctly with OpenGL enabled
or disabled.
Change-Id: I3ae1a0ceb947254aaadbc3d772f0d662b291b594
diff --git a/vcl/source/gdi/impimage.cxx b/vcl/source/gdi/impimage.cxx
index d3f63f4..76e65a3 100644
--- a/vcl/source/gdi/impimage.cxx
+++ b/vcl/source/gdi/impimage.cxx
@@ -328,28 +328,11 @@ void ImplImageBmp::Draw( OutputDevice* pOutDev,
}
}
-void ImplImageBmp::ImplUpdateDisplayBmp( OutputDevice*
-#if defined WNT
-pOutDev
-#endif
-)
+void ImplImageBmp::ImplUpdateDisplayBmp(OutputDevice*)
{
- if( !mpDisplayBmp && !maBmpEx.IsEmpty() )
+ if (!mpDisplayBmp && !maBmpEx.IsEmpty())
{
-#if defined WNT
- if( !maBmpEx.IsAlpha() )
- {
- // FIXME: this looks like rather an obsolete code-path to me.
- const Bitmap aBmp( maBmpEx.GetBitmap().CreateDisplayBitmap( pOutDev ) );
-
- if( maBmpEx.IsTransparent() )
- mpDisplayBmp = new BitmapEx( aBmp, maBmpEx.GetMask().CreateDisplayBitmap( pOutDev ) );
- else
- mpDisplayBmp = new BitmapEx( aBmp );
- }
- else
-#endif
- mpDisplayBmp = new BitmapEx( maBmpEx );
+ mpDisplayBmp = new BitmapEx(maBmpEx);
}
}
commit 78a4e9cb89830191e77c558759e845e5a15b9cc7
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Wed Oct 7 13:12:14 2015 +0200
vcl: recolor images (icons) to be more visible in a dark theme
This adds recoloring of images/icons (suited for breeze and sifr)
so they are more visible when a dark theme is used (for example gtk3
can switch to a dark theme). LO must be started with environment
variable VCL_ICONS_FOR_DARK_THEME set to 1.
open issues - currently all images/icons are recolored but not all
images should get recolored.
Change-Id: Ibc42e30af79bb4c4f04c67b760019311b97b2cc6
diff --git a/include/vcl/BitmapProcessor.hxx b/include/vcl/BitmapProcessor.hxx
new file mode 100644
index 0000000..73f0001
--- /dev/null
+++ b/include/vcl/BitmapProcessor.hxx
@@ -0,0 +1,23 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_VCL_BITMAP_PROCESSOR_HXX
+#define INCLUDED_VCL_BITMAP_PROCESSOR_HXX
+
+#include <vcl/bitmapex.hxx>
+
+class BitmapProcessor
+{
+public:
+ static BitmapEx createLightImage(const BitmapEx& rBitmapEx);
+};
+
+#endif // INCLUDED_VCL_BITMAP_PROCESSOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index f95a999..f2cd719 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -318,6 +318,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/bitmap/bitmapscalesuper \
vcl/source/bitmap/BitmapSymmetryCheck \
vcl/source/bitmap/BitmapFilterStackBlur \
+ vcl/source/bitmap/BitmapProcessor \
vcl/source/bitmap/checksum \
vcl/source/helper/canvasbitmap \
vcl/source/helper/canvastools \
diff --git a/vcl/source/bitmap/BitmapProcessor.cxx b/vcl/source/bitmap/BitmapProcessor.cxx
new file mode 100644
index 0000000..e9d36ed
--- /dev/null
+++ b/vcl/source/bitmap/BitmapProcessor.cxx
@@ -0,0 +1,58 @@
+/* -*- 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/.
+ *
+ */
+
+#include <vcl/BitmapProcessor.hxx>
+#include <vcl/bmpacc.hxx>
+#include <basegfx/color/bcolortools.hxx>
+
+BitmapEx BitmapProcessor::createLightImage(const BitmapEx& rBitmapEx)
+{
+ const Size aSize(rBitmapEx.GetSizePixel());
+
+ Bitmap aBitmap(rBitmapEx.GetBitmap());
+ Bitmap aDarkBitmap(aSize, 24);
+
+ BitmapReadAccess* pRead(aBitmap.AcquireReadAccess());
+ BitmapWriteAccess* pWrite(aDarkBitmap.AcquireWriteAccess());
+
+ if (pRead && pWrite)
+ {
+ for (int nY = 0; nY < aSize.Height(); ++nY)
+ {
+ for (int nX = 0; nX < aSize.Width(); ++nX)
+ {
+ BitmapColor aColor = pRead->HasPalette() ?
+ pRead->GetPaletteColor(pRead->GetPixelIndex(nY, nX)) :
+ pRead->GetPixel(nY, nX);
+ basegfx::BColor aBColor(Color(aColor.Invert()).getBColor());
+ aBColor = basegfx::tools::rgb2hsl(aBColor);
+
+ double fHue = aBColor.getRed();
+ fHue += 180.0;
+ while (fHue > 360.0)
+ fHue -= 360.0;
+ aBColor.setRed(fHue);
+
+ aBColor = basegfx::tools::hsl2rgb(aBColor);
+ aColor.SetRed(((aBColor.getRed() * 255.0) + 0.5));
+ aColor.SetGreen(((aBColor.getGreen() * 255.0) + 0.5));
+ aColor.SetBlue(((aBColor.getBlue() * 255.0) + 0.5));
+
+ pWrite->SetPixel(nY, nX, aColor);
+ }
+ }
+ }
+ Bitmap::ReleaseAccess(pWrite);
+ Bitmap::ReleaseAccess(pRead);
+
+ return BitmapEx(aDarkBitmap, rBitmapEx.GetAlpha());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx
index 5116a36..38cfefd 100644
--- a/vcl/source/gdi/impimagetree.cxx
+++ b/vcl/source/gdi/impimagetree.cxx
@@ -45,6 +45,8 @@
#include "impimagetree.hxx"
#include <vcldemo-debug.hxx>
+#include <vcl/BitmapProcessor.hxx>
+
using namespace css;
namespace {
@@ -123,7 +125,12 @@ bool ImplImageTree::loadImage(OUString const & name, OUString const & style, Bit
{
try {
if (doLoadImage(name, aStyle, bitmap, localized))
+ {
+ static bool bIconsForDarkTheme = !!getenv("VCL_ICONS_FOR_DARK_THEME");
+ if (bIconsForDarkTheme)
+ bitmap = BitmapProcessor::createLightImage(bitmap);
return true;
+ }
}
catch (css::uno::RuntimeException &) {}
commit 09374b5acdec0743a1f860f70ccd15eda24fa399
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Tue Oct 6 14:47:41 2015 +0200
remove unused BitmapEx
Change-Id: I787be4f2da514017fd14100f56ed323d30dbe99d
diff --git a/vcl/source/gdi/image.cxx b/vcl/source/gdi/image.cxx
index 9d8f282..adfec17 100644
--- a/vcl/source/gdi/image.cxx
+++ b/vcl/source/gdi/image.cxx
@@ -374,8 +374,6 @@ void ImageAryData::Load(const OUString &rPrefix)
OUString aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
- BitmapEx aBmpEx;
-
OUString aFileName = rPrefix;
aFileName += maName;
#if OSL_DEBUG_LEVEL > 0
More information about the Libreoffice-commits
mailing list