[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - vcl/inc vcl/source vcl/unx

2017-03-29 Thread Caolán McNamara
 vcl/inc/opengl/zone.hxx |6 ++
 vcl/source/opengl/OpenGLHelper.cxx  |   21 +
 vcl/unx/generic/window/salframe.cxx |3 +++
 3 files changed, 30 insertions(+)

New commits:
commit b96c52baa6b9607d9a31cd1b34162e4ee041f9b6
Author: Caolán McNamara 
Date:   Tue Mar 28 14:15:37 2017 +0100

Resolves: tdf#106155 avoid opengl for toplevel X window icons

because an opengl context requires a toplevel window so it recurses to 
death.

Only the gen/kde4 vclplugs are affected here

Change-Id: If5396d183d90d1872931b170dc90c3a70d8ea6b6
(cherry picked from commit b012e83e1cd09a0b6f9ede94a5c2d72d24459ce4)
Reviewed-on: https://gerrit.libreoffice.org/35803
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/vcl/inc/opengl/zone.hxx b/vcl/inc/opengl/zone.hxx
index 65a7249b16b2..75ebad915b60 100644
--- a/vcl/inc/opengl/zone.hxx
+++ b/vcl/inc/opengl/zone.hxx
@@ -48,6 +48,12 @@ public:
 OpenGLVCLContextZone();
 };
 
+class VCL_DLLPUBLIC PreDefaultWinNoOpenGLZone {
+public:
+PreDefaultWinNoOpenGLZone();
+~PreDefaultWinNoOpenGLZone();
+};
+
 #endif // INCLUDED_VCL_INC_OPENGL_ZONE_H
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/opengl/OpenGLHelper.cxx 
b/vcl/source/opengl/OpenGLHelper.cxx
index f07e7dcbfa8e..e00a93aa4586 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -976,12 +976,28 @@ OpenGLVCLContextZone::OpenGLVCLContextZone()
 OpenGLContext::makeVCLCurrent();
 }
 
+namespace
+{
+bool bTempOpenGLDisabled = false;
+}
+
+PreDefaultWinNoOpenGLZone::PreDefaultWinNoOpenGLZone()
+{
+bTempOpenGLDisabled = true;
+}
+
+PreDefaultWinNoOpenGLZone::~PreDefaultWinNoOpenGLZone()
+{
+bTempOpenGLDisabled = false;
+}
+
 bool OpenGLHelper::isVCLOpenGLEnabled()
 {
 /**
  * The !bSet part should only be called once! Changing the results in the 
same
  * run will mix OpenGL and normal rendering.
  */
+
 static bool bSet = false;
 static bool bEnable = false;
 static bool bForceOpenGL = false;
@@ -990,6 +1006,11 @@ bool OpenGLHelper::isVCLOpenGLEnabled()
 if ( Application::IsConsoleOnly() )
 return false;
 
+//tdf#106155, disable GL while loading certain bitmaps needed for the 
initial toplevel windows
+//under raw X (kde4) vclplug
+if (bTempOpenGLDisabled)
+return false;
+
 if (bSet)
 {
 return bForceOpenGL || bEnable;
diff --git a/vcl/unx/generic/window/salframe.cxx 
b/vcl/unx/generic/window/salframe.cxx
index d0ce7021fe08..f71eecf239ea 100644
--- a/vcl/unx/generic/window/salframe.cxx
+++ b/vcl/unx/generic/window/salframe.cxx
@@ -57,6 +57,7 @@
 #include "unx/i18n_keysym.hxx"
 #include "unx/i18n_status.hxx"
 #include 
+#include "opengl/zone.hxx"
 
 #include "unx/gensys.h"
 #include "sallayout.hxx"
@@ -257,6 +258,8 @@ static bool lcl_SelectAppIconPixmap( SalDisplay *pDisplay, 
SalX11Screen nXScreen
 if( ! ImplGetResMgr() )
 return false;
 
+PreDefaultWinNoOpenGLZone aGuard;
+
 CreateNetWmAppIcon( nIcon, netwm_icon );
 
 sal_uInt16 nIconSizeOffset;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - vcl/inc vcl/source

2017-03-19 Thread Khaled Hosny
 vcl/inc/CommonSalLayout.hxx|2 -
 vcl/source/gdi/CommonSalLayout.cxx |   57 +
 2 files changed, 41 insertions(+), 18 deletions(-)

New commits:
commit 49eadd40b5f0de6fa97498d89f20118b996385d2
Author: Khaled Hosny 
Date:   Sun Mar 5 00:04:35 2017 +0200

Handle Tr vertical orientation before shaping

See https://github.com/behdad/harfbuzz/issues/355

(cherry picked from commit 5c617a811724a45dd8688869eeafac4c44f6a8aa)

Change-Id: Ic82d74046980fae3e7a973fee90fe5bb4f2b8588
Reviewed-on: https://gerrit.libreoffice.org/35387
Tested-by: Jenkins 
Reviewed-by: Mark Hung 

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index 58cba16e63d4..496d17125835 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -60,7 +60,7 @@ class CommonSalLayout : public GenericSalLayout
 voidgetScale(double* nXScale, double* nYScale);
 
 hb_set_t*   mpVertGlyphs;
-boolIsVerticalAlternate(hb_codepoint_t nGlyphIndex);
+boolHasVerticalAlternate(sal_UCS4 aChar, sal_UCS4 
aNextChar);
 
 public:
 #if defined(_WIN32)
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index a6ca683c15f5..df2849828df7 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -409,12 +409,16 @@ void CommonSalLayout::DrawText(SalGraphics& rSalGraphics) 
const
 rSalGraphics.DrawSalLayout( *this );
 }
 
-// Find if the given glyph index can result from applying “vert” feature.
+// Find if the nominal glyph of the character is an input to “vert” 
feature.
 // We don’t check for a specific script or language as it shouldn’t matter
 // here; if the glyph would be the result from applying “vert” for any
 // script/language then we want to always treat it as upright glyph.
-bool CommonSalLayout::IsVerticalAlternate(hb_codepoint_t nGlyphIndex)
+bool CommonSalLayout::HasVerticalAlternate(sal_UCS4 aChar, sal_UCS4 
aVariationSelector)
 {
+hb_codepoint_t nGlyphIndex = 0;
+if (!hb_font_get_glyph(mpHbFont, aChar, aVariationSelector, ))
+return false;
+
 if (!mpVertGlyphs)
 {
 hb_face_t* pHbFace = hb_font_get_face(mpHbFont);
@@ -432,7 +436,11 @@ bool CommonSalLayout::IsVerticalAlternate(hb_codepoint_t 
nGlyphIndex)
 while (hb_set_next(pLookups, ))
 {
 hb_set_t* pGlyphs = hb_set_create();
-hb_ot_layout_lookup_collect_glyphs(pHbFace, HB_OT_TAG_GSUB, 
nIdx, nullptr, nullptr, nullptr, pGlyphs);
+hb_ot_layout_lookup_collect_glyphs(pHbFace, HB_OT_TAG_GSUB, 
nIdx,
+nullptr,  // glyphs before
+pGlyphs,  // glyphs input
+nullptr,  // glyphs after
+nullptr); // glyphs out
 hb_set_union(mpVertGlyphs, pGlyphs);
 }
 }
@@ -516,16 +524,37 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
 {
 sal_Int32 nPrevIdx = nIdx;
 sal_UCS4 aChar = rArgs.mrStr.iterateCodePoints();
-switch (vcl::GetVerticalOrientation(aChar))
+VerticalOrientation aVo = 
vcl::GetVerticalOrientation(aChar);
+
+sal_UCS4 aVariationSelector = 0;
+if (nIdx < nEndRunPos)
+{
+sal_Int32 nNextIdx = nIdx;
+sal_UCS4 aNextChar = 
rArgs.mrStr.iterateCodePoints();
+if (u_hasBinaryProperty(aNextChar, 
UCHAR_VARIATION_SELECTOR))
+{
+nIdx = nNextIdx;
+aVariationSelector = aNextChar;
+}
+}
+
+// Charters with U and Tu vertical orientation should
+// be shaped in vertical direction. But characters
+// with Tr should be shaped in vertical direction
+// only if they have vertical alternates, otherwise
+// they should be shaped in horizontal direction
+// and then rotated.
+// See http://unicode.org/reports/tr50/#vo
+if (aVo == VerticalOrientation::Upright ||
+aVo == VerticalOrientation::TransformedUpright ||
+(aVo == VerticalOrientation::TransformedRotated &&
+ HasVerticalAlternate(aChar, aVariationSelector)))
 {
-case VerticalOrientation::Upright:
-case VerticalOrientation::TransformedUpright:
-case VerticalOrientation::TransformedRotated:
 aDirection = 

[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - vcl/inc vcl/source vcl/win

2017-03-07 Thread Khaled Hosny
 vcl/inc/CommonSalLayout.hxx|1 +
 vcl/source/gdi/CommonSalLayout.cxx |9 -
 vcl/win/gdi/winlayout.cxx  |   31 ---
 3 files changed, 17 insertions(+), 24 deletions(-)

New commits:
commit 4375eefb644d03ab4bafbc091436166a8494dc91
Author: Khaled Hosny 
Date:   Fri Mar 3 05:15:14 2017 +0200

tdf#103831, tdf#100986: Force using GDI when needed

Our DirectWrite renderer is incomplete and can’t handle rotated text or 
text
with horizontal scaling, so route these two through GDI for now.

Reviewed-on: https://gerrit.libreoffice.org/34848
Tested-by: Jenkins 
Reviewed-by: Khaled Hosny 
(cherry picked from commit a51b7a1c3a7e7cf7b0c733e1dec40288278c1884)

Change-Id: I87b85796a29e3acce782e01b4c629fec6f1a9e25
Reviewed-on: https://gerrit.libreoffice.org/34862
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index e2f3a11..58cba16 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -68,6 +68,7 @@ public:
 const FontSelectPattern& getFontSelData() const { return mrFontSelData; };
 HFONT   getHFONT() const { return mhFont; }
 WinFontInstance&getWinFontInstance() const { return 
mrWinFontInstance; }
+boolhasHScale() const;
 #elif defined(MACOSX) || defined(IOS)
 explicitCommonSalLayout(const CoreTextStyle&);
 const CoreTextStyle&getFontData() const { return mrCoreTextStyle; };
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index bd59a6b..21be0c9 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -209,7 +209,7 @@ CommonSalLayout::CommonSalLayout(HDC hDC, WinFontInstance& 
rWinFontInstance, con
 }
 
 // Calculate the mnAveWidthFactor, see the comment where it is used.
-if (mrFontSelData.mnWidth && ! OpenGLHelper::isVCLOpenGLEnabled())
+if (mrFontSelData.mnWidth)
 {
 double nUPEM = hb_face_get_upem(hb_font_get_face(mpHbFont));
 
@@ -233,6 +233,13 @@ CommonSalLayout::CommonSalLayout(HDC hDC, WinFontInstance& 
rWinFontInstance, con
 }
 }
 
+bool CommonSalLayout::hasHScale() const
+{
+int nHeight(mrFontSelData.mnHeight);
+int nWidth(mrFontSelData.mnWidth ? mrFontSelData.mnWidth * 
mnAveWidthFactor : nHeight);
+return nWidth != nHeight;
+}
+
 #elif defined(MACOSX) || defined(IOS)
 CommonSalLayout::CommonSalLayout(const CoreTextStyle& rCoreTextStyle)
 :   mrFontSelData(rCoreTextStyle.maFontSelData)
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 5cfa9b7..482cbd7 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -103,26 +103,6 @@ bool WinFontInstance::CacheGlyphToAtlas(bool 
bRealGlyphIndices, HDC hDC, HFONT h
 return false;
 }
 
-// Bail for non-horizontal text.
-{
-wchar_t sFaceName[200];
-int nFaceNameLen = GetTextFaceW(hNewDC, SAL_N_ELEMENTS(sFaceName), 
sFaceName);
-
-if (!nFaceNameLen)
-SAL_WARN("vcl.gdi", "GetTextFace failed: " << 
WindowsErrorString(GetLastError()));
-
-LOGFONTW aLogFont;
-GetObjectW(hFont, sizeof(LOGFONTW), );
-
-SelectObject(hNewDC, hOrigFont);
-DeleteDC(hNewDC);
-
-if (sFaceName[0] == '@' || aLogFont.lfOrientation != 0 || 
aLogFont.lfEscapement != 0)
-{
-pTxt->ReleaseFont();
-return false;
-}
-}
 std::vector aGlyphIndices(1);
 // Fetch the ink boxes and calculate the size of the atlas.
 if (!bRealGlyphIndices)
@@ -3872,13 +3852,18 @@ void WinSalGraphics::DrawTextLayout(const 
CommonSalLayout& rLayout, HDC hDC, boo
 void WinSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
 {
 HDC hDC = getHDC();
+
+// Our DirectWrite renderer is incomplete, skip it for non-horizontal or
+// stretched text.
+bool bForceGDI = rLayout.GetOrientation() || rLayout.hasHScale();
+
 bool bUseOpenGL = OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter;
 if (!bUseOpenGL)
 {
 // no OpenGL, just classic rendering
-DrawTextLayout(rLayout, hDC, false);
+DrawTextLayout(rLayout, hDC, !bForceGDI);
 }
-else if (CacheGlyphs(rLayout) &&
+else if (!bForceGDI && CacheGlyphs(rLayout) &&
  DrawCachedGlyphs(rLayout))
 {
 // Nothing
@@ -3945,7 +3930,7 @@ void WinSalGraphics::DrawSalLayout(const CommonSalLayout& 
rLayout)
 SalColor salColor = MAKE_SALCOLOR(GetRValue(color), 
GetGValue(color), GetBValue(color));
 
 // the actual drawing
-DrawTextLayout(rLayout, aDC.getCompatibleHDC(), true);
+DrawTextLayout(rLayout, aDC.getCompatibleHDC(), !bForceGDI);
 
 

[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - vcl/inc vcl/source vcl/unx

2017-01-04 Thread Tomaž Vajngerl
 vcl/inc/implimagetree.hxx   |3 ++
 vcl/source/image/ImplImageTree.cxx  |   50 
 vcl/unx/generic/window/salframe.cxx |   11 +--
 3 files changed, 40 insertions(+), 24 deletions(-)

New commits:
commit 377b8de39201b4f2b7f93f6a23f828a27e4ed2bc
Author: Tomaž Vajngerl 
Date:   Thu Dec 22 22:28:23 2016 +0100

tdf#103626 don't scale application icon to prevent a start-up loop

Reviewed-on: https://gerrit.libreoffice.org/32382
Tested-by: Jenkins 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 96b95f5010be090ebae6f755d4d3891a2334332c)

+ commit e36d9ae2cbe45f33aaaef3eb33eff9d13ee04a66
Typo: scalePrecentage->scalePercentage
Author: Julien Nabet 

Change-Id: I2e65ba16d93167dc4abb029c7e941e91be9a62ab
Reviewed-on: https://gerrit.libreoffice.org/32401
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/vcl/inc/implimagetree.hxx b/vcl/inc/implimagetree.hxx
index 108dc97..1a4d4c6 100644
--- a/vcl/inc/implimagetree.hxx
+++ b/vcl/inc/implimagetree.hxx
@@ -53,6 +53,9 @@ struct ImageRequestParameters
 , mbLocalized(bLocalized)
 , meFlags(eFlags)
 {}
+
+bool convertToDarkTheme();
+sal_Int32 scalePercentage();
 };
 
 class ImplImageTree
diff --git a/vcl/source/image/ImplImageTree.cxx 
b/vcl/source/image/ImplImageTree.cxx
index 114f084..614d06a 100644
--- a/vcl/source/image/ImplImageTree.cxx
+++ b/vcl/source/image/ImplImageTree.cxx
@@ -49,6 +49,25 @@
 #include 
 #include 
 
+bool ImageRequestParameters::convertToDarkTheme()
+{
+static bool bIconsForDarkTheme = !!getenv("VCL_ICONS_FOR_DARK_THEME");
+
+bool bConvertToDarkTheme = false;
+if (!(meFlags & ImageLoadFlags::IgnoreDarkTheme))
+bConvertToDarkTheme = bIconsForDarkTheme;
+
+return bConvertToDarkTheme;
+}
+
+sal_Int32 ImageRequestParameters::scalePercentage()
+{
+sal_Int32 aScalePercentage = 100;
+if (!(meFlags & ImageLoadFlags::IgnoreScalingFactor))
+aScalePercentage = 
Application::GetDefaultDevice()->GetDPIScalePercentage();
+return aScalePercentage;
+}
+
 namespace
 {
 
@@ -134,15 +153,8 @@ std::shared_ptr wrapStream(css::uno::Reference< 
css::io::XInputStream
 
 void loadImageFromStream(std::shared_ptr const & xStream, OUString 
const & rPath, ImageRequestParameters& rParameters)
 {
-static bool bIconsForDarkTheme = !!getenv("VCL_ICONS_FOR_DARK_THEME");
-
-bool bConvertToDarkTheme = bIconsForDarkTheme;
-if (rParameters.meFlags & ImageLoadFlags::IgnoreDarkTheme)
-bConvertToDarkTheme = false;
-
-float aScaleFactor = Application::GetDefaultDevice()->GetDPIScaleFactor();
-if (rParameters.meFlags & ImageLoadFlags::IgnoreScalingFactor)
-aScaleFactor = 1.0f;
+bool bConvertToDarkTheme = rParameters.convertToDarkTheme();
+sal_Int32 aScalePercentage = rParameters.scalePercentage();
 
 if (rPath.endsWith(".png"))
 {
@@ -152,7 +164,7 @@ void loadImageFromStream(std::shared_ptr const & 
xStream, OUString con
 }
 else if (rPath.endsWith(".svg"))
 {
-vcl::bitmap::loadFromSvg(*xStream.get(), rPath, rParameters.mrBitmap, 
double(aScaleFactor));
+vcl::bitmap::loadFromSvg(*xStream.get(), rPath, rParameters.mrBitmap, 
aScalePercentage / 100.0);
 if (bConvertToDarkTheme)
 rParameters.mrBitmap = 
BitmapProcessor::createLightImage(rParameters.mrBitmap);
 return;
@@ -165,8 +177,11 @@ void loadImageFromStream(std::shared_ptr const & 
xStream, OUString con
 if (bConvertToDarkTheme)
 rParameters.mrBitmap = 
BitmapProcessor::createLightImage(rParameters.mrBitmap);
 
-if (aScaleFactor > 1.0f)
-rParameters.mrBitmap.Scale(double(aScaleFactor), double(aScaleFactor), 
BmpScaleFlag::Fast);
+if (aScalePercentage > 100)
+{
+double aScaleFactor(aScalePercentage / 100.0);
+rParameters.mrBitmap.Scale(aScaleFactor, aScaleFactor, 
BmpScaleFlag::Fast);
+}
 }
 
 } // end anonymous namespace
@@ -283,15 +298,8 @@ bool ImplImageTree::loadDefaultImage(OUString const & 
style, BitmapEx& bitmap, c
 
 OUString createVariant(ImageRequestParameters& rParameters)
 {
-static bool bIconsForDarkTheme = !!getenv("VCL_ICONS_FOR_DARK_THEME");
-
-bool bConvertToDarkTheme = bIconsForDarkTheme;
-if (rParameters.meFlags & ImageLoadFlags::IgnoreDarkTheme)
-bConvertToDarkTheme = false;
-
-sal_Int32 aScalePercentage = 
Application::GetDefaultDevice()->GetDPIScalePercentage();
-if (rParameters.meFlags & ImageLoadFlags::IgnoreScalingFactor)
-aScalePercentage = 100;
+bool bConvertToDarkTheme = rParameters.convertToDarkTheme();
+sal_Int32 aScalePercentage = rParameters.scalePercentage();
 
 OUString aVariant;
 if (aScalePercentage == 100 && !bConvertToDarkTheme)
diff --git 

[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - vcl/inc vcl/source

2016-12-19 Thread Tomaž Vajngerl
 vcl/inc/implimagetree.hxx  |   25 +++--
 vcl/source/image/ImplImageTree.cxx |  100 +++--
 2 files changed, 74 insertions(+), 51 deletions(-)

New commits:
commit 5b97553b9340e5d23fc1288a3be0ffb998d2e779
Author: Tomaž Vajngerl 
Date:   Sun Dec 18 15:02:59 2016 +0100

ImplImageTree extract parameters to own struct

Change-Id: I56e68ab19e63637d21dea7929f093bb1aceb982a
Reviewed-on: https://gerrit.libreoffice.org/32135
Reviewed-by: Tomaž Vajngerl 
Tested-by: Tomaž Vajngerl 
(cherry picked from commit 6fd7c0c7714a90a6b99003b67a47b28b800cfdff)
Reviewed-on: https://gerrit.libreoffice.org/32166

diff --git a/vcl/inc/implimagetree.hxx b/vcl/inc/implimagetree.hxx
index a229177..108dc97 100644
--- a/vcl/inc/implimagetree.hxx
+++ b/vcl/inc/implimagetree.hxx
@@ -38,6 +38,23 @@ namespace com { namespace sun { namespace star { namespace 
container {
 class XNameAccess;
 
 
+struct ImageRequestParameters
+{
+OUString msName;
+OUString msStyle;
+BitmapEx& mrBitmap;
+bool mbLocalized;
+ImageLoadFlags meFlags;
+
+ImageRequestParameters(const OUString & rName, const OUString & rStyle, 
BitmapEx& rBitmap, bool bLocalized, ImageLoadFlags eFlags)
+: msName(rName)
+, msStyle(rStyle)
+, mrBitmap(rBitmap)
+, mbLocalized(bLocalized)
+, meFlags(eFlags)
+{}
+};
+
 class ImplImageTree
 {
 public:
@@ -100,9 +117,7 @@ private:
 return maIconSets[maCurrentStyle];
 }
 
-bool doLoadImage(
-OUString const & name, OUString const & style,
-BitmapEx & bitmap, bool localized, const ImageLoadFlags eFlags);
+bool doLoadImage(ImageRequestParameters& rParameters);
 
 std::vector getPaths(OUString const & name, LanguageTag& 
rLanguageTag);
 
@@ -112,9 +127,9 @@ private:
 
 void createStyle();
 
-bool iconCacheLookup(OUString const & rName, bool bLocalized, const 
ImageLoadFlags eFlags, BitmapEx & rBitmap);
+bool iconCacheLookup(ImageRequestParameters& rParameters);
 
-bool findImage(std::vector const & rPaths, BitmapEx & rBitmap, 
const ImageLoadFlags eFlags);
+bool findImage(std::vector const & rPaths, 
ImageRequestParameters& rParameters);
 
 void loadImageLinks();
 
diff --git a/vcl/source/image/ImplImageTree.cxx 
b/vcl/source/image/ImplImageTree.cxx
index 744d487..114f084 100644
--- a/vcl/source/image/ImplImageTree.cxx
+++ b/vcl/source/image/ImplImageTree.cxx
@@ -132,44 +132,44 @@ std::shared_ptr wrapStream(css::uno::Reference< 
css::io::XInputStream
 return s;
 }
 
-void loadImageFromStream(std::shared_ptr const & xStream, OUString 
const & rPath, BitmapEx & rBitmap, const ImageLoadFlags eFlags)
+void loadImageFromStream(std::shared_ptr const & xStream, OUString 
const & rPath, ImageRequestParameters& rParameters)
 {
 static bool bIconsForDarkTheme = !!getenv("VCL_ICONS_FOR_DARK_THEME");
 
 bool bConvertToDarkTheme = bIconsForDarkTheme;
-if (eFlags & ImageLoadFlags::IgnoreDarkTheme)
+if (rParameters.meFlags & ImageLoadFlags::IgnoreDarkTheme)
 bConvertToDarkTheme = false;
 
 float aScaleFactor = Application::GetDefaultDevice()->GetDPIScaleFactor();
-if (eFlags & ImageLoadFlags::IgnoreScalingFactor)
+if (rParameters.meFlags & ImageLoadFlags::IgnoreScalingFactor)
 aScaleFactor = 1.0f;
 
 if (rPath.endsWith(".png"))
 {
 vcl::PNGReader aPNGReader(*xStream);
-aPNGReader.SetIgnoreGammaChunk( true );
-rBitmap = aPNGReader.Read();
+aPNGReader.SetIgnoreGammaChunk(true);
+rParameters.mrBitmap = aPNGReader.Read();
 }
 else if (rPath.endsWith(".svg"))
 {
-vcl::bitmap::loadFromSvg(*xStream.get(), rPath, rBitmap, 
double(aScaleFactor));
+vcl::bitmap::loadFromSvg(*xStream.get(), rPath, rParameters.mrBitmap, 
double(aScaleFactor));
 if (bConvertToDarkTheme)
-rBitmap = BitmapProcessor::createLightImage(rBitmap);
+rParameters.mrBitmap = 
BitmapProcessor::createLightImage(rParameters.mrBitmap);
 return;
 }
 else
 {
-ReadDIBBitmapEx(rBitmap, *xStream);
+ReadDIBBitmapEx(rParameters.mrBitmap, *xStream);
 }
 
 if (bConvertToDarkTheme)
-rBitmap = BitmapProcessor::createLightImage(rBitmap);
+rParameters.mrBitmap = 
BitmapProcessor::createLightImage(rParameters.mrBitmap);
 
 if (aScaleFactor > 1.0f)
-rBitmap.Scale(double(aScaleFactor), double(aScaleFactor), 
BmpScaleFlag::Fast);
+rParameters.mrBitmap.Scale(double(aScaleFactor), double(aScaleFactor), 
BmpScaleFlag::Fast);
 }
 
-}
+} // end anonymous namespace
 
 ImplImageTree::ImplImageTree()
 {
@@ -263,7 +263,8 @@ bool ImplImageTree::loadImage(OUString const & name, 
OUString const & style, Bit
 {
 try
 {
-if (doLoadImage(name, aStyle, rBitmap, localized, eFlags))
+

[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - vcl/inc vcl/source vcl/win

2016-12-15 Thread Khaled Hosny
 vcl/inc/CommonSalLayout.hxx|3 +
 vcl/inc/win/salgdi.h   |3 +
 vcl/inc/win/winlayout.hxx  |2 
 vcl/source/gdi/CommonSalLayout.cxx |1 
 vcl/win/gdi/winlayout.cxx  |   95 +++--
 5 files changed, 90 insertions(+), 14 deletions(-)

New commits:
commit d85003a8af8b454b34eea0ac67c8dd9184a0b6d3
Author: Khaled Hosny 
Date:   Thu Dec 15 02:47:13 2016 +0200

tdf#104159: Re-enable OpenGL glyph caching on Windows

Reviewed-on: https://gerrit.libreoffice.org/32026
Tested-by: Jenkins 
Reviewed-by: Khaled Hosny 
(cherry picked from commit 9cf20b5f0473db0b4dd2dcf607b7884f40762995)

Change-Id: Icafec05a8cf4428d806efcb286addf3042fcf021
Reviewed-on: https://gerrit.libreoffice.org/32066
Tested-by: Jenkins 
Reviewed-by: Khaled Hosny 

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index e5345d7..e2f3a11 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -45,6 +45,7 @@ class CommonSalLayout : public GenericSalLayout
 #ifdef _WIN32
 HDC mhDC;
 HFONT   mhFont;
+WinFontInstance&mrWinFontInstance;
 double  mnAveWidthFactor;
 #elif defined(MACOSX) || defined(IOS)
 const CoreTextStyle&mrCoreTextStyle;
@@ -65,6 +66,8 @@ public:
 #if defined(_WIN32)
 explicitCommonSalLayout(HDC, WinFontInstance&, const 
WinFontFace&);
 const FontSelectPattern& getFontSelData() const { return mrFontSelData; };
+HFONT   getHFONT() const { return mhFont; }
+WinFontInstance&getWinFontInstance() const { return 
mrWinFontInstance; }
 #elif defined(MACOSX) || defined(IOS)
 explicitCommonSalLayout(const CoreTextStyle&);
 const CoreTextStyle&getFontData() const { return mrCoreTextStyle; };
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 3050055..14310f9 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -236,6 +236,9 @@ private:
 
 LogicalFontInstance* GetWinFontEntry(int nFallbackLevel);
 
+bool CacheGlyphs(const CommonSalLayout& rLayout);
+bool DrawCachedGlyphs(const CommonSalLayout& rLayout);
+
 public:
 HDC getHDC() const { return mhLocalDC; }
 void setHDC(HDC aNew) { mhLocalDC = aNew; }
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 7b15e7e..8ceebea 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -193,7 +193,7 @@ public:
 private:
 GlyphCache maGlyphCache;
 public:
-bool CacheGlyphToAtlas(bool bRealGlyphIndices, int nGlyphIndex, const 
WinLayout& rLayout, SalGraphics& rGraphics);
+bool CacheGlyphToAtlas(bool bRealGlyphIndices, HDC hDC, HFONT hFont, int 
nGlyphIndex, SalGraphics& rGraphics);
 
 GlyphCache& GetGlyphCache()
 {
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index dbc3fa8..8ab8eb3 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -181,6 +181,7 @@ CommonSalLayout::CommonSalLayout(HDC hDC, WinFontInstance& 
rWinFontInstance, con
 :   mrFontSelData(rWinFontInstance.maFontSelData)
 ,   mhDC(hDC)
 ,   mhFont(static_cast(GetCurrentObject(hDC, OBJ_FONT)))
+,   mrWinFontInstance(rWinFontInstance)
 ,   mnAveWidthFactor(1.0f)
 ,   mpVertGlyphs(nullptr)
 {
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index c693b31..2d35175 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -66,7 +66,7 @@ inline int WinFontInstance::GetCachedGlyphWidth( int 
nCharCode ) const
 return it->second;
 }
 
-bool WinFontInstance::CacheGlyphToAtlas(bool bRealGlyphIndices, int 
nGlyphIndex, const WinLayout& rLayout, SalGraphics& rGraphics)
+bool WinFontInstance::CacheGlyphToAtlas(bool bRealGlyphIndices, HDC hDC, HFONT 
hFont, int nGlyphIndex, SalGraphics& rGraphics)
 {
 if (nGlyphIndex == DROPPED_OUTGLYPH)
 return true;
@@ -77,17 +77,17 @@ bool WinFontInstance::CacheGlyphToAtlas(bool 
bRealGlyphIndices, int nGlyphIndex,
 std::vector aCodePointsOrGlyphIndices(1);
 aCodePointsOrGlyphIndices[0] = nGlyphIndex;
 
-HDC hDC = CreateCompatibleDC(rLayout.mhDC);
-if (hDC == nullptr)
+HDC hNewDC = CreateCompatibleDC(hDC);
+if (hNewDC == nullptr)
 {
 SAL_WARN("vcl.gdi", "CreateCompatibleDC failed: " << 
WindowsErrorString(GetLastError()));
 return false;
 }
-HFONT hOrigFont = static_cast(SelectObject(hDC, rLayout.mhFont));
+HFONT hOrigFont = static_cast(SelectObject(hNewDC, hFont));
 if (hOrigFont == nullptr)
 {
 SAL_WARN("vcl.gdi", "SelectObject failed: " << 
WindowsErrorString(GetLastError()));
-DeleteDC(hDC);
+DeleteDC(hNewDC);
 return false;
 }
 
@@ -96,26 +96,26 @@ bool 

[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - vcl/inc vcl/source

2016-11-29 Thread Tomaž Vajngerl
 vcl/inc/opengl/RenderState.hxx  |2 +-
 vcl/source/opengl/OpenGLContext.cxx |3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 959bf134acb2782f4bf2ab299a96581e016ebc3d
Author: Tomaž Vajngerl 
Date:   Sun Nov 27 22:51:39 2016 +0100

tdf#104139 state can't be set as context may not be available

When RenderState is constructed (and all capability states get
constructed) the OpenGL context may not be available yet, so we
just set the state to whatever value (false) and make sure we sync
with the actual state right away when we have OpenGL context set
up and ready.

Change-Id: I65a669ab76c1834775007d62efe3d6ac061d6f21
Reviewed-on: https://gerrit.libreoffice.org/31278
Reviewed-by: David Tardon 
Tested-by: David Tardon 
(cherry picked from commit 58a6cbfbf309b151b9d1463c734343430f9a1220)
Signed-off-by: David Tardon 

diff --git a/vcl/inc/opengl/RenderState.hxx b/vcl/inc/opengl/RenderState.hxx
index 25dd837..b7b2f18 100644
--- a/vcl/inc/opengl/RenderState.hxx
+++ b/vcl/inc/opengl/RenderState.hxx
@@ -20,7 +20,7 @@ protected:
 bool mbTest;
 
 GenericCapabilityState()
-: mbTest(readState())
+: mbTest(false)
 {
 }
 
diff --git a/vcl/source/opengl/OpenGLContext.cxx 
b/vcl/source/opengl/OpenGLContext.cxx
index 979e2bf..33d8009 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -568,6 +568,9 @@ void OpenGLContext::registerAsCurrent()
 pSVData->maGDIData.mpLastContext->mpNextContext = this;
 pSVData->maGDIData.mpLastContext = this;
 }
+
+// sync the render state with the current context
+mpRenderState->sync();
 }
 
 void OpenGLContext::resetCurrent()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - vcl/inc vcl/source vcl/unx

2016-11-23 Thread Khaled Hosny
 vcl/inc/CommonSalLayout.hxx  |2 -
 vcl/inc/unx/genpspgraphics.h |2 -
 vcl/source/gdi/CommonSalLayout.cxx   |7 +++
 vcl/unx/generic/print/genpspgraphics.cxx |   61 +++
 4 files changed, 64 insertions(+), 8 deletions(-)

New commits:
commit 04f89a0ed1da6bd671007b725bd49e740d0d
Author: Khaled Hosny 
Date:   Wed Nov 23 21:42:47 2016 +0200

Make PS on Unix printing use the new layout engine

I’d rather kill PS printing entirely, but this will do for now.

Change-Id: I112cc4855ab722ac07d31231f2a1ea8842b4159a
Reviewed-on: https://gerrit.libreoffice.org/31133
Tested-by: Jenkins 
Reviewed-by: Khaled Hosny 
(cherry picked from commit f337e95fb50c9edc10aca859aaf08baab5294d2e)
Reviewed-on: https://gerrit.libreoffice.org/31140
Tested-by: Khaled Hosny 

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index 31b9dca..e5345d7 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -64,7 +64,6 @@ class CommonSalLayout : public GenericSalLayout
 public:
 #if defined(_WIN32)
 explicitCommonSalLayout(HDC, WinFontInstance&, const 
WinFontFace&);
-voidInitFont() const override { SelectObject(mhDC, 
mhFont); };
 const FontSelectPattern& getFontSelData() const { return mrFontSelData; };
 #elif defined(MACOSX) || defined(IOS)
 explicitCommonSalLayout(const CoreTextStyle&);
@@ -74,6 +73,7 @@ public:
 const FreetypeFont& getFontData() const { return mrFreetypeFont; };
 #endif
 
+virtual voidInitFont() const override;
 voidSetNeedFallback(ImplLayoutArgs&, sal_Int32, bool);
 voidAdjustLayout(ImplLayoutArgs&) override;
 boolLayoutText(ImplLayoutArgs&) override;
diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h
index 1700267..792e44f 100644
--- a/vcl/inc/unx/genpspgraphics.h
+++ b/vcl/inc/unx/genpspgraphics.h
@@ -132,7 +132,7 @@ public:
 virtual boolGetGlyphBoundRect( sal_GlyphId, Rectangle& ) 
override;
 virtual boolGetGlyphOutline( sal_GlyphId, 
basegfx::B2DPolyPolygon& ) override;
 virtual SalLayout*  GetTextLayout( ImplLayoutArgs&, int nFallbackLevel 
) override;
-virtual voidDrawSalLayout( const CommonSalLayout& ) override 
{};
+virtual voidDrawSalLayout( const CommonSalLayout& ) override;
 virtual voidDrawServerFontLayout( const GenericSalLayout&, 
const FreetypeFont& ) override;
 virtual boolsupportsOperation( OutDevSupportType ) const 
override;
 virtual voiddrawPixel( long nX, long nY ) override;
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index cf6a53a..ea7093d 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -261,6 +261,13 @@ CommonSalLayout::CommonSalLayout(FreetypeFont& 
rFreetypeFont)
 }
 #endif
 
+void CommonSalLayout::InitFont() const
+{
+#if defined(_WIN32)
+SelectObject(mhDC, mhFont);
+#endif
+}
+
 struct SubRun
 {
 int32_t mnMin;
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx 
b/vcl/unx/generic/print/genpspgraphics.cxx
index 0a7c849..b64ca91 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -57,6 +57,7 @@
 #include "PhysicalFontFace.hxx"
 #include "salbmp.hxx"
 #include "salprn.hxx"
+#include "CommonSalLayout.hxx"
 
 #include 
 #if ENABLE_GRAPHITE
@@ -695,9 +696,45 @@ void PspServerFontLayout::InitFont() const
   mnOrientation, mbVertical, mbArtItalic, mbArtBold );
 }
 
+class PspCommonSalLayout : public CommonSalLayout
+{
+public:
+PspCommonSalLayout(psp::PrinterGfx&, FreetypeFont& rFont);
+
+virtual voidInitFont() const override;
+
+private:
+::psp::PrinterGfx&  mrPrinterGfx;
+sal_IntPtr  mnFontID;
+int mnFontHeight;
+int mnFontWidth;
+boolmbVertical;
+boolmbArtItalic;
+boolmbArtBold;
+};
+
+PspCommonSalLayout::PspCommonSalLayout(::psp::PrinterGfx& rGfx, FreetypeFont& 
rFont)
+:   CommonSalLayout(rFont)
+,   mrPrinterGfx(rGfx)
+{
+mnFontID = mrPrinterGfx.GetFontID();
+mnFontHeight = mrPrinterGfx.GetFontHeight();
+mnFontWidth  = mrPrinterGfx.GetFontWidth();
+mbVertical   = mrPrinterGfx.GetFontVertical();
+mbArtItalic  = mrPrinterGfx.GetArtificialItalic();
+mbArtBold= mrPrinterGfx.GetArtificialBold();
+}
+
+void PspCommonSalLayout::InitFont() const
+{
+CommonSalLayout::InitFont();
+mrPrinterGfx.SetFont(mnFontID, mnFontHeight, mnFontWidth,
+ mnOrientation, mbVertical, mbArtItalic, mbArtBold);
+}
+