core.git: vcl/inc vcl/win

2024-04-07 Thread Mike Kaganski (via logerrit)
 vcl/inc/win/DWriteTextRenderer.hxx |   15 ---
 vcl/inc/win/winlayout.hxx  |2 --
 vcl/win/gdi/DWriteTextRenderer.cxx |   28 ++--
 vcl/win/gdi/winlayout.cxx  |8 
 4 files changed, 18 insertions(+), 35 deletions(-)

New commits:
commit 8557ea84c9336ba8061246f1f46ddb6e02f413a1
Author: Mike Kaganski 
AuthorDate: Mon Apr 8 02:45:28 2024 +0500
Commit: Mike Kaganski 
CommitDate: Mon Apr 8 07:12:18 2024 +0200

Exclude getHScale from DirectWrite font rendering

... and drop it, since it's unused now.
Unkike with Skia, where the ratio produces a visible effect, in
DirectWrite the effect seems cancelled by transformations. Yet,
it produced computational instability, noticable in small vertical
text.

Change-Id: I2f3b20913075d1338dc75c5a04c9cc0ef29c75ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165877
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/inc/win/DWriteTextRenderer.hxx 
b/vcl/inc/win/DWriteTextRenderer.hxx
index d4bb45e5895b..b822a6bca488 100644
--- a/vcl/inc/win/DWriteTextRenderer.hxx
+++ b/vcl/inc/win/DWriteTextRenderer.hxx
@@ -71,19 +71,4 @@ private:
 D2DTextAntiAliasMode meTextAntiAliasMode;
 };
 
-/**
- * Sets and unsets the needed DirectWrite transform to support the font's 
horizontal scaling and
- * rotation.
- */
-class WinFontTransformGuard
-{
-public:
-WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float fHScale, 
const GenericSalLayout& rLayout, const D2D1_POINT_2F& rBaseline, bool 
bIsVertical);
-~WinFontTransformGuard();
-
-private:
-ID2D1RenderTarget* mpRenderTarget;
-D2D1::Matrix3x2F maTransform;
-};
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index cfb36e825b54..31066a7db28a 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -36,8 +36,6 @@ class WinFontInstance : public LogicalFontInstance
 public:
 ~WinFontInstance() override;
 
-float getHScale() const;
-
 void SetGraphics(WinSalGraphics*);
 WinSalGraphics* GetGraphics() const { return m_pGraphics; }
 
diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx 
b/vcl/win/gdi/DWriteTextRenderer.cxx
index bb0f7e6b7661..633dcf82b13b 100644
--- a/vcl/win/gdi/DWriteTextRenderer.cxx
+++ b/vcl/win/gdi/DWriteTextRenderer.cxx
@@ -93,6 +93,20 @@ HRESULT checkResult(HRESULT hr, const char* location)
 #endif
 
 
+// Sets and unsets the needed DirectWrite transform to support the font's 
rotation.
+class WinFontTransformGuard
+{
+public:
+WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget,
+  const GenericSalLayout& rLayout, const 
D2D1_POINT_2F& rBaseline,
+  bool bIsVertical);
+~WinFontTransformGuard();
+
+private:
+ID2D1RenderTarget* mpRenderTarget;
+D2D1::Matrix3x2F maTransform;
+};
+
 } // end anonymous namespace
 
 D2DWriteTextOutRenderer::D2DWriteTextOutRenderer(bool bRenderingModeNatural)
@@ -214,7 +228,6 @@ bool 
D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
 }
 
 const WinFontInstance& rWinFont = static_cast(rLayout.GetFont());
-float fHScale = rWinFont.getHScale();
 
 float lfEmHeight = 0;
 IDWriteFontFace* pFontFace = GetDWriteFace(rWinFont, );
@@ -247,11 +260,11 @@ bool 
D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
 while (rLayout.GetNextGlyph(, aPos, nStart))
 {
 UINT16 glyphIndices[] = { static_cast(pGlyph->glyphId()) };
-FLOAT glyphAdvances[] = { static_cast(pGlyph->newWidth()) / 
fHScale };
+FLOAT glyphAdvances[] = { static_cast(pGlyph->newWidth()) };
 DWRITE_GLYPH_OFFSET glyphOffsets[] = { { 0.0f, 0.0f }, };
-D2D1_POINT_2F baseline = { static_cast(aPos.getX() - 
bounds.Left()) / fHScale,
+D2D1_POINT_2F baseline = { static_cast(aPos.getX() - 
bounds.Left()),
static_cast(aPos.getY() - 
bounds.Top()) };
-WinFontTransformGuard aTransformGuard(mpRT, fHScale, rLayout, 
baseline, pGlyph->IsVertical());
+WinFontTransformGuard aTransformGuard(mpRT, rLayout, baseline, 
pGlyph->IsVertical());
 DWRITE_GLYPH_RUN glyphs = {
 pFontFace,
 lfEmHeight,
@@ -302,7 +315,7 @@ IDWriteFontFace* 
D2DWriteTextOutRenderer::GetDWriteFace(const WinFontInstance& r
 return pFontFace;
 }
 
-WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, 
float fHScale,
+WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget,
  const GenericSalLayout& rLayout,
  const D2D1_POINT_2F& rBaseline,
  bool bIsVertical)
@@ -310,11 +323,6 @@ 

core.git: vcl/inc vcl/win

2024-03-28 Thread Mike Kaganski (via logerrit)
 vcl/inc/win/winlayout.hxx |1 -
 vcl/win/gdi/winlayout.cxx |   14 ++
 2 files changed, 2 insertions(+), 13 deletions(-)

New commits:
commit ff7a6711277bda28711cc92540fbd62ebaaf8db7
Author: Mike Kaganski 
AuthorDate: Thu Mar 28 19:52:00 2024 +0500
Commit: Mike Kaganski 
CommitDate: Fri Mar 29 04:17:12 2024 +0100

Simplify and drop unused method

Change-Id: Ie987bce2bb25232d54a4a83631c609ad6dba7213
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165467
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index e1d66a0e1ab2..cfb36e825b54 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -36,7 +36,6 @@ class WinFontInstance : public LogicalFontInstance
 public:
 ~WinFontInstance() override;
 
-bool hasHScale() const;
 float getHScale() const;
 
 void SetGraphics(WinSalGraphics*);
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index eb5c740580c5..19eaae2ecee7 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -146,22 +146,12 @@ WinFontInstance::~WinFontInstance()
 ::DeleteFont(m_hFont);
 }
 
-bool WinFontInstance::hasHScale() const
-{
-const vcl::font::FontSelectPattern& rPattern = GetFontSelectPattern();
-int nHeight(rPattern.mnHeight);
-int nWidth(rPattern.mnWidth ? rPattern.mnWidth * GetAverageWidthFactor() : 
nHeight);
-return nWidth != nHeight;
-}
-
 float WinFontInstance::getHScale() const
 {
 const vcl::font::FontSelectPattern& rPattern = GetFontSelectPattern();
-int nHeight(rPattern.mnHeight);
-if (!nHeight)
+if (!rPattern.mnHeight || !rPattern.mnWidth)
 return 1.0;
-float nWidth(rPattern.mnWidth ? rPattern.mnWidth * GetAverageWidthFactor() 
: nHeight);
-return nWidth / nHeight;
+return rPattern.mnWidth * GetAverageWidthFactor() / rPattern.mnHeight;
 }
 
 void WinFontInstance::ImplInitHbFont(hb_font_t* /*pHbFont*/)


[Libreoffice-commits] core.git: vcl/inc vcl/win

2023-08-16 Thread Mike Kaganski (via logerrit)
 vcl/inc/win/wincomp.hxx |   50 
 vcl/win/window/salframe.cxx |9 ---
 2 files changed, 59 deletions(-)

New commits:
commit ee52f20ec727e5c296cc5d8f4c2a25f1414eb0fe
Author: Mike Kaganski 
AuthorDate: Thu Aug 17 00:43:12 2023 +0300
Commit: Mike Kaganski 
CommitDate: Thu Aug 17 06:53:40 2023 +0200

Drop defines obsoleted by Windows 7 baseline

I.e., those that are guarded in Windows headers by stuff like

  #if(_WIN32_WINNT >= 0x0600)
  #if(WINVER >= 0x0501)

Change-Id: If9ab06663b2c9f511549823f14c8bc759a30a74c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155751
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/inc/win/wincomp.hxx b/vcl/inc/win/wincomp.hxx
index 6f5b0ebc4cdd..4383bc5b77cc 100644
--- a/vcl/inc/win/wincomp.hxx
+++ b/vcl/inc/win/wincomp.hxx
@@ -178,54 +178,4 @@ inline HINSTANCE GetWindowInstance( HWND hWnd )
 
 #define MSH_SCROLL_LINES L"MSH_SCROLL_LINES_MSG"
 
-#ifndef WHEEL_DELTA
-#define WHEEL_DELTA 120
-#endif
-#ifndef WM_MOUSEWHEEL
-#define WM_MOUSEWHEEL   0x020A
-#endif
-#ifndef SPI_GETWHEELSCROLLLINES
-#define SPI_GETWHEELSCROLLLINES 104
-#endif
-#ifndef SPI_SETWHEELSCROLLLINES
-#define SPI_SETWHEELSCROLLLINES 105
-#endif
-#ifndef WHEEL_PAGESCROLL
-#define WHEEL_PAGESCROLL(UINT_MAX)
-#endif
-
-
-// - 5.0 extensions -
-
-#ifndef COLOR_GRADIENTACTIVECAPTION
-#define COLOR_GRADIENTACTIVECAPTION 27
-#endif
-#ifndef COLOR_GRADIENTINACTIVECAPTION
-#define COLOR_GRADIENTINACTIVECAPTION   28
-#endif
-
-#ifndef SPI_GETFLATMENU
-#define SPI_GETFLATMENU 0x1022
-#endif
-#ifndef COLOR_MENUBAR
-#define COLOR_MENUBAR   30
-#endif
-#ifndef COLOR_MENUHILIGHT
-#define COLOR_MENUHILIGHT   29
-#endif
-
-#ifndef CS_DROPSHADOW
-#define CS_DROPSHADOW   0x0002
-#endif
-
-// MT 12/03: From winuser.h, only needed in salframe.cxx
-// Better change salframe.cxx to include winuser.h
-
-#define WS_EX_LAYERED   0x0008
-
-#ifndef WM_UNICHAR
-#define WM_UNICHAR  0x0109
-#define UNICODE_NOCHAR  0x
-#endif
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index c7c0bdd4f328..7ebe68077ec2 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -108,15 +108,6 @@ using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::container;
 using namespace ::com::sun::star::beans;
 
-#ifndef SPI_GETWHEELSCROLLCHARS
-# define SPI_GETWHEELSCROLLCHARS   0x006C
-#endif
-#ifndef SPI_SETWHEELSCROLLCHARS
-# define SPI_SETWHEELSCROLLCHARS   0x006D
-#endif
-#ifndef WM_MOUSEHWHEEL
-# define WM_MOUSEHWHEEL 0x020E
-#endif
 #ifndef IDC_PEN
 # define IDC_PEN MAKEINTRESOURCE(32631)
 #endif


[Libreoffice-commits] core.git: vcl/inc vcl/win

2023-07-25 Thread Michael Weghorn (via logerrit)
 vcl/inc/win/salframe.h  |1 +
 vcl/win/window/salframe.cxx |7 +++
 2 files changed, 8 insertions(+)

New commits:
commit 609ed2944b030a692c942428afa8bf7c3ac93672
Author: Michael Weghorn 
AuthorDate: Tue Jul 25 13:08:14 2023 +0200
Commit: Michael Weghorn 
CommitDate: Tue Jul 25 14:48:38 2023 +0200

tdf#155414 win a11y: Honor system setting to disable animations

Use `SPI_GETCLIENTAREAANIMATION`, the "client area animation
parameter [that] indicates whether the user wants to disable
animations in UI elements" [1] to determine whether
animations should be disabled.

The parameter can be set in Windows, as documented in MDN docs
for the "prefers-reduced-motion" CSS media feature [2]:

> * In Windows 10: Settings > Ease of Access > Display > Show animations in 
Windows.
> * In Windows 11: Settings > Accessibility > Visual Effects > Animation 
Effects

On top of

commit 9d68c794d67259a38de1465090f6f1e7fb588d62
Author: Patrick Luby 
Date:   Fri Jul 21 19:55:02 2023 -0400

tdf#155414 include system "reduce animation" preferences

, this implements the Windows equivalent of what that change does for macOS.

[1] 
https://learn.microsoft.com/en-us/windows/win32/winauto/client-area-animation
[2] 
https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion

Change-Id: I1485cd7dc97b7d93abdeab78ec330874f2a5cb98
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154889
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h
index 676c70c1eca0..564872e65d2c 100644
--- a/vcl/inc/win/salframe.h
+++ b/vcl/inc/win/salframe.h
@@ -141,6 +141,7 @@ public:
 virtual voidEndSetClipRegion() override;
 virtual voidUpdateDarkMode() override;
 virtual boolGetUseDarkMode() const override;
+virtual boolGetUseReducedAnimation() const override;
 
 constexpr vcl::WindowState state() const { return m_eState; }
 void UpdateFrameState();
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index c911fff0840f..d68178ea022f 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -3126,6 +3126,13 @@ bool WinSalFrame::GetUseDarkMode() const
 return UseDarkMode();
 }
 
+bool WinSalFrame::GetUseReducedAnimation() const
+{
+BOOL bEnableAnimation = FALSE;
+SystemParametersInfoW(SPI_GETCLIENTAREAANIMATION, 0, , 0);
+return !bEnableAnimation;
+}
+
 static bool ImplHandleMouseMsg( HWND hWnd, UINT nMsg,
 WPARAM wParam, LPARAM lParam )
 {


[Libreoffice-commits] core.git: vcl/inc vcl/win

2023-07-10 Thread Khaled Hosny (via logerrit)
 vcl/inc/win/winlayout.hxx |2 --
 vcl/win/gdi/salfont.cxx   |   11 ---
 vcl/win/gdi/winlayout.cxx |1 -
 3 files changed, 4 insertions(+), 10 deletions(-)

New commits:
commit 88d72b44a1a9345e7eacdd707cecfb300517df9c
Author: Khaled Hosny 
AuthorDate: Mon Jul 10 09:49:38 2023 +
Commit: خالد حسني 
CommitDate: Mon Jul 10 15:45:31 2023 +0200

Drop unused WinFontInstance scale

Unsed since:

commit 7cb3e475f2fb0162c7290414509de4fb8fe57e30
Author: Jan-Marek Glogowski 
Date:   Thu Sep 6 14:04:25 2018 +0200

WIN add SalGraphics* to WinFontInstance

Change-Id: I7d14f2efce04c919cffee612b09833810ff3f78b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154240
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index fb8e5a1c6e43..07c80e8e8b39 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -43,7 +43,6 @@ public:
 WinSalGraphics* GetGraphics() const { return m_pGraphics; }
 
 HFONT GetHFONT() const { return m_hFont; }
-float GetScale() const { return m_fScale; }
 // Return true if the font is for vertical writing.
 // I.e. the font name of the LOGFONT is prefixed with '@'.
 bool  IsCJKVerticalFont() const { return m_bIsCJKVerticalFont; }
@@ -64,7 +63,6 @@ private:
 
 WinSalGraphics *m_pGraphics;
 HFONT m_hFont;
-float m_fScale;
 bool  m_bIsCJKVerticalFont;
 sal_Int32 m_nTmDescent;
 mutable sal::systools::COMReference mxDWFontFace;
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index f4a3029a454f..3b31028c88bb 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -867,7 +867,7 @@ void WinSalGraphics::GetFontMetric( FontMetricDataRef& 
rxFontMetric, int nFallba
 rxFontMetric->SetSlant( 0 );
 
 // transformation dependent font metrics
-rxFontMetric->SetWidth(static_cast(pFontInstance->GetScale() * 
aWinMetric.tmAveCharWidth));
+rxFontMetric->SetWidth(aWinMetric.tmAveCharWidth);
 }
 
 FontCharMapRef WinSalGraphics::GetFontCharMap() const
@@ -1167,7 +1167,6 @@ bool WinFontInstance::ImplGetGlyphBoundRect(sal_GlyphId 
nId, tools::Rectangle& r
 
 const ::comphelper::ScopeGuard aFontRestoreScopeGuard([hFont, hOrigFont, 
hDC]()
 { if (hFont != hOrigFont) SelectObject(hDC, hOrigFont); });
-const float fFontScale = GetScale();
 
 // use unity matrix
 MAT2 aMat;
@@ -1202,10 +1201,8 @@ bool WinFontInstance::ImplGetGlyphBoundRect(sal_GlyphId 
nId, tools::Rectangle& r
 
 rRect = tools::Rectangle( Point( +aGM.gmptGlyphOrigin.x, 
-aGM.gmptGlyphOrigin.y ),
 Size( aGM.gmBlackBoxX, aGM.gmBlackBoxY ) );
-rRect.SetLeft(static_cast( fFontScale * rRect.Left() ));
-rRect.SetRight(static_cast( fFontScale * rRect.Right() ) + 1);
-rRect.SetTop(static_cast( fFontScale * rRect.Top() ));
-rRect.SetBottom(static_cast( fFontScale * rRect.Bottom() ) + 1);
+rRect.SetRight(rRect.Right() + 1);
+rRect.SetBottom(rRect.Bottom() + 1);
 return true;
 }
 
@@ -1389,7 +1386,7 @@ bool WinFontInstance::GetGlyphOutline(sal_GlyphId nId, 
basegfx::B2DPolyPolygon&
 // rescaling needed for the tools::PolyPolygon conversion
 if( rB2DPolyPoly.count() )
 {
-const double fFactor(GetScale()/256);
+const double fFactor(1.0f/256);
 
rB2DPolyPoly.transform(basegfx::utils::createScaleB2DHomMatrix(fFactor, 
fFactor));
 }
 
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 371bdeb9642e..5081456aaaef 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -135,7 +135,6 @@ WinFontInstance::WinFontInstance(const WinFontFace& rPFF, 
const vcl::font::FontS
 : LogicalFontInstance(rPFF, rFSP)
 , m_pGraphics(nullptr)
 , m_hFont(nullptr)
-, m_fScale(1.0f)
 , m_bIsCJKVerticalFont(false)
 , m_nTmDescent(0)
 {


[Libreoffice-commits] core.git: vcl/inc vcl/win

2023-04-13 Thread Noel Grandin (via logerrit)
 vcl/inc/win/saldata.hxx |   33 +
 vcl/win/app/salinst.cxx |1 -
 vcl/win/gdi/salgdi.cxx  |   11 +++
 3 files changed, 20 insertions(+), 25 deletions(-)

New commits:
commit 209e859c3e78d5818df3e3f84669aaa2a3810c01
Author: Noel Grandin 
AuthorDate: Wed Apr 12 13:46:00 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Apr 13 10:04:42 2023 +0200

no need to allocate these separately

Change-Id: Icc24e0aaf1762e5b318b8364dd9fdb496edfb77c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150279
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index c391086b30a1..b5740d5670a4 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -21,6 +21,7 @@
 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -53,6 +54,21 @@ class SkiaControlsCache;
 #define MAX_STOCKBRUSH  4
 #define SAL_CLIPRECT_COUNT  16
 
+#define CACHESIZE_HDC   3
+#define CACHED_HDC_10
+#define CACHED_HDC_21
+#define CACHED_HDC_DRAW 2
+#define CACHED_HDC_DEFEXT   64
+
+struct HDCCache
+{
+HDC mhDC = 0;
+HPALETTEmhDefPal = 0;
+HBITMAP mhDefBmp = 0;
+HBITMAP mhSelBmp = 0;
+HBITMAP mhActBmp = 0;
+};
+
 struct SalIcon
 {
 int nId;
@@ -96,7 +112,7 @@ public:
 WinSalObject*   mpFirstObject;  // pointer of first object 
window
 WinSalVirtualDevice*mpFirstVD;  // first VirDev
 WinSalPrinter*  mpFirstPrinter; // first printing printer
-HDCCache*   mpHDCCache; // Cache for three DC's
+std::array maHDCCache; // Cache for three DC's
 HBITMAP mh50Bmp;// 50% Bitmap
 HBRUSH  mh50Brush;  // 50% Brush
 COLORREFmaStockPenColorAry[MAX_STOCKPEN];
@@ -139,21 +155,6 @@ struct SalShlData
 
 extern SalShlData aSalShlData;
 
-#define CACHESIZE_HDC   3
-#define CACHED_HDC_10
-#define CACHED_HDC_21
-#define CACHED_HDC_DRAW 2
-#define CACHED_HDC_DEFEXT   64
-
-struct HDCCache
-{
-HDC mhDC;
-HPALETTEmhDefPal;
-HBITMAP mhDefBmp;
-HBITMAP mhSelBmp;
-HBITMAP mhActBmp;
-};
-
 void ImplClearHDCCache( SalData* pData );
 HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp = nullptr );
 void ImplReleaseCachedDC( sal_uLong nID );
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 3e2cc7a04754..a2aabbab2870 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -261,7 +261,6 @@ SalData::SalData()
 mpFirstObject = nullptr;// pointer of first object window
 mpFirstVD = nullptr;// first VirDev
 mpFirstPrinter = nullptr;   // first printing printer
-mpHDCCache = nullptr;   // Cache for three DC's
 mh50Bmp = nullptr;  // 50% Bitmap
 mh50Brush = nullptr;// 50% Brush
 int i;
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 8a38a684ca35..cb3cad6508ed 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -134,10 +134,6 @@ void ImplInitSalGDI()
 pSalData->mhStockBrushAry[3]= CreateSolidBrush( 
pSalData->maStockBrushColorAry[3] );
 pSalData->mnStockBrushCount = 4;
 
-// initialize cache of device contexts
-pSalData->mpHDCCache = new HDCCache[ CACHESIZE_HDC ];
-memset( pSalData->mpHDCCache, 0, CACHESIZE_HDC * sizeof( HDCCache ) );
-
 // initialize temporary font lists
 pSalData->mpSharedTempFontItem = nullptr;
 pSalData->mpOtherTempFontItem = nullptr;
@@ -318,7 +314,6 @@ void ImplFreeSalGDI()
 }
 
 ImplClearHDCCache( pSalData );
-delete[] pSalData->mpHDCCache;
 
 // delete Ditherpalette, if existing
 if ( pSalData->mhDitherPal )
@@ -511,7 +506,7 @@ void WinSalGraphics::setHDC(HDC aNew)
 HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp )
 {
 SalData*pSalData = GetSalData();
-HDCCache*   pC = >mpHDCCache[ nID ];
+HDCCache*   pC = >maHDCCache[ nID ];
 
 if( !pC->mhDC )
 {
@@ -543,7 +538,7 @@ HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp )
 void ImplReleaseCachedDC( sal_uLong nID )
 {
 SalData*pSalData = GetSalData();
-HDCCache*   pC = >mpHDCCache[ nID ];
+HDCCache*   pC = >maHDCCache[ nID ];
 
 if ( pC->mhActBmp )
 SelectObject( pC->mhDC, pC->mhSelBmp );
@@ -553,7 +548,7 @@ void ImplClearHDCCache( SalData* pData )
 {
 for( sal_uLong i = 0; i < CACHESIZE_HDC; i++ )
 {
-HDCCache* pC = >mpHDCCache[ i ];
+HDCCache* pC = >maHDCCache[ i ];
 
 if( pC->mhDC )
 {


[Libreoffice-commits] core.git: vcl/inc vcl/win

2023-04-12 Thread Noel Grandin (via logerrit)
 vcl/inc/win/saldata.hxx |6 +++---
 vcl/win/gdi/salgdi.cxx  |   18 +-
 2 files changed, 12 insertions(+), 12 deletions(-)

New commits:
commit 9cfa99594cc21ad42f3428c4e2c521dd87511fc2
Author: Noel Grandin 
AuthorDate: Wed Apr 12 13:40:08 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Apr 12 15:47:03 2023 +0200

use more unique_ptr in SalData

Change-Id: Ib6e5131bff38b55b2dbf0805b63ca3554c5ee349
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150278
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 3145688e24be..2d20903d6157 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -86,9 +86,9 @@ public:
 HGLOBAL mhDitherDIB;// dither memory handle
 BYTE*   mpDitherDIB;// dither memory
 BYTE*   mpDitherDIBData;// beginning of DIB data
-tools::Long*mpDitherDiff;   // Dither mapping table
-BYTE*   mpDitherLow;// Dither mapping table
-BYTE*   mpDitherHigh;   // Dither mapping table
+std::unique_ptr mpDitherDiff;// Dither mapping table
+std::unique_ptr mpDitherLow;// Dither mapping table
+std::unique_ptr mpDitherHigh;   // Dither mapping table
 HHOOK   mhSalObjMsgHook;// hook to get interesting 
msg for SalObject
 HWNDmhWantLeaveMsg; // window handle, that 
want a MOUSELEAVE message
 AutoTimer*  mpMouseLeaveTimer;  // Timer for MouseLeave 
Test
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 630933192687..8a38a684ca35 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -180,9 +180,9 @@ void ImplInitSalGDI()
 
 pSalData->mhDitherDIB = GlobalAlloc( GMEM_FIXED, sizeof( 
BITMAPINFOHEADER ) + 192 );
 pSalData->mpDitherDIB = static_cast(GlobalLock( 
pSalData->mhDitherDIB ));
-pSalData->mpDitherDiff = new tools::Long[ 256 ];
-pSalData->mpDitherLow = new BYTE[ 256 ];
-pSalData->mpDitherHigh = new BYTE[ 256 ];
+pSalData->mpDitherDiff.reset(new tools::Long[ 256 ]);
+pSalData->mpDitherLow.reset(new BYTE[ 256 ]);
+pSalData->mpDitherHigh.reset(new BYTE[ 256 ]);
 pSalData->mpDitherDIBData = pSalData->mpDitherDIB + sizeof( 
BITMAPINFOHEADER );
 memset( pSalData->mpDitherDIB, 0, sizeof( BITMAPINFOHEADER ) );
 
@@ -254,9 +254,9 @@ void ImplInitSalGDI()
 
 pSalData->mhDitherDIB = GlobalAlloc( GMEM_FIXED, nSize );
 pSalData->mpDitherDIB = static_cast(GlobalLock( 
pSalData->mhDitherDIB ));
-pSalData->mpDitherDiff = new tools::Long[ 256 ];
-pSalData->mpDitherLow = new BYTE[ 256 ];
-pSalData->mpDitherHigh = new BYTE[ 256 ];
+pSalData->mpDitherDiff.reset(new tools::Long[ 256 ]);
+pSalData->mpDitherLow.reset(new BYTE[ 256 ]);
+pSalData->mpDitherHigh.reset(new BYTE[ 256 ]);
 pSalData->mpDitherDIBData = pSalData->mpDitherDIB + sizeof( 
BITMAPINFOHEADER ) + ( 256 * sizeof( short ) );
 memset( pSalData->mpDitherDIB, 0, sizeof( BITMAPINFOHEADER ) );
 
@@ -333,9 +333,9 @@ void ImplFreeSalGDI()
 GlobalUnlock( pSalData->mhDitherDIB );
 GlobalFree( pSalData->mhDitherDIB );
 pSalData->mhDitherDIB = nullptr;
-delete[] pSalData->mpDitherDiff;
-delete[] pSalData->mpDitherLow;
-delete[] pSalData->mpDitherHigh;
+pSalData->mpDitherDiff.reset();
+pSalData->mpDitherLow.reset();
+pSalData->mpDitherHigh.reset();
 }
 
 DeleteSysColorList();


[Libreoffice-commits] core.git: vcl/inc vcl/win

2023-03-02 Thread Noel Grandin (via logerrit)
 vcl/inc/salprn.hxx |2 +-
 vcl/win/gdi/salprn.cxx |8 
 2 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 8774f286e8613717c620b635c93cfd7e7dffd76f
Author: Noel Grandin 
AuthorDate: Thu Mar 2 11:22:34 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Mar 2 10:41:31 2023 +

no need to allocate mpPortName separately

it is only one pointer big

Change-Id: I7c8c99c4dad4289e2f073d73e8b3703ee5c8e64e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148090
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/salprn.hxx b/vcl/inc/salprn.hxx
index d72853b597bf..c6c7657310ca 100644
--- a/vcl/inc/salprn.hxx
+++ b/vcl/inc/salprn.hxx
@@ -42,7 +42,7 @@ struct VCL_PLUGIN_PUBLIC SalPrinterQueueInfo
 OUString   maComment;
 PrintQueueFlagsmnStatus;
 sal_uInt32 mnJobs;
-std::unique_ptr mpPortName; // only used by Windows backend
+std::optional moPortName; // only used by Windows backend
 
 SalPrinterQueueInfo();
 ~SalPrinterQueueInfo();
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 98d39dc02455..71e4753995ae 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -207,8 +207,8 @@ void WinSalInstance::GetPrinterQueueState( 
SalPrinterQueueInfo* pInfo )
 pInfo->maComment = o3tl::toU(pWinInfo2->pComment);
 pInfo->mnStatus  = ImplWinQueueStatusToSal( 
pWinInfo2->Status );
 pInfo->mnJobs= pWinInfo2->cJobs;
-if( ! pInfo->mpPortName )
-pInfo->mpPortName.reset(new OUString(aPortName));
+if( ! pInfo->moPortName )
+pInfo->moPortName = aPortName;
 }
 std::free(pWinInfo2);
 }
@@ -1029,11 +1029,11 @@ SalInfoPrinter* WinSalInstance::CreateInfoPrinter( 
SalPrinterQueueInfo* pQueueIn
ImplJobSetup* pSetupData )
 {
 WinSalInfoPrinter* pPrinter = new WinSalInfoPrinter;
-if( ! pQueueInfo->mpPortName )
+if( ! pQueueInfo->moPortName )
 GetPrinterQueueState( pQueueInfo );
 pPrinter->maDriverName  = pQueueInfo->maDriver;
 pPrinter->maDeviceName  = pQueueInfo->maPrinterName;
-pPrinter->maPortName= pQueueInfo->mpPortName ? *pQueueInfo->mpPortName 
: OUString();
+pPrinter->maPortName= pQueueInfo->moPortName ? *pQueueInfo->moPortName 
: OUString();
 
 // check if the provided setup data match the actual printer
 ImplTestSalJobSetup( pPrinter, pSetupData, true );


[Libreoffice-commits] core.git: vcl/inc vcl/win

2023-01-12 Thread Caolán McNamara (via logerrit)
 vcl/inc/win/salframe.h|1 +
 vcl/inc/win/salinst.h |1 -
 vcl/win/gdi/salnativewidgets-luna.cxx |4 
 3 files changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 8ab24f26626a65e1ce9e1ff8c4eb75a20e4b7629
Author: Caolán McNamara 
AuthorDate: Thu Jan 12 16:36:56 2023 +
Commit: Caolán McNamara 
CommitDate: Thu Jan 12 20:06:19 2023 +

tdf#152994 only query dark mode in Windows >= 10.0.18362

Change-Id: I8d8bd368d9d1ee38dac96dd369484ec74ce4835a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145414
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h
index bbf3506a723f..dedac6906467 100644
--- a/vcl/inc/win/salframe.h
+++ b/vcl/inc/win/salframe.h
@@ -148,6 +148,7 @@ public:
 void ImplSalGetWorkArea( HWND hWnd, RECT *pRect, const RECT *pParentRect );
 
 bool UseDarkMode();
+bool OSSupportsDarkMode();
 
 // get foreign key names
 namespace vcl_sal {
diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h
index 35f2365fb166..7af6e007b562 100644
--- a/vcl/inc/win/salinst.h
+++ b/vcl/inc/win/salinst.h
@@ -85,7 +85,6 @@ public:
 SalFrame* ImplSalCreateFrame( WinSalInstance* pInst, HWND hWndParent, 
SalFrameStyleFlags nSalFrameStyle );
 SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent );
 HWND ImplSalReCreateHWND( HWND hWndParent, HWND oldhWnd, bool bAsChild );
-bool OSSupportsDarkMode();
 
 #endif // INCLUDED_VCL_INC_WIN_SALINST_H
 
diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx 
b/vcl/win/gdi/salnativewidgets-luna.cxx
index e3811020a42e..b2c71bf51b78 100644
--- a/vcl/win/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/gdi/salnativewidgets-luna.cxx
@@ -398,6 +398,10 @@ static bool implDrawNativeMenuMark(HDC hDC, HTHEME hTheme, 
RECT rc, ControlPart
 
 bool UseDarkMode()
 {
+static bool bOSSupportsDarkMode = OSSupportsDarkMode();
+if (!bOSSupportsDarkMode)
+false;
+
 HINSTANCE hUxthemeLib = LoadLibraryExW(L"uxtheme.dll", nullptr, 
LOAD_LIBRARY_SEARCH_SYSTEM32);
 if (!hUxthemeLib)
 return false;


[Libreoffice-commits] core.git: vcl/inc vcl/win

2022-12-01 Thread Stephan Bergmann (via logerrit)
 vcl/inc/win/salgdi.h  |2 
 vcl/win/gdi/salfont.cxx   |4 -
 vcl/win/gdi/salgdi.cxx|   18 --
 vcl/win/gdi/salnativewidgets-luna.cxx |  101 --
 vcl/win/gdi/winlayout.cxx |5 -
 5 files changed, 67 insertions(+), 63 deletions(-)

New commits:
commit ddf8e2c9c366eb7b8757a589fd7b8e30849d2824
Author: Stephan Bergmann 
AuthorDate: Thu Dec 1 16:36:07 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Thu Dec 1 18:35:46 2022 +0100

Avoid dynamic cross casts to WinSalGraphicsImplBase

Change-Id: I1102c5525f47d3e07cadc602dd55f7b78118a709
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143535
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index f26f1d40f0c9..eb41d0304d1c 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -144,6 +144,7 @@ class WinSalGraphics : public SalGraphics
 
 protected:
 std::unique_ptr mpImpl;
+WinSalGraphicsImplBase * mWinSalGraphicsImplBase;
 
 private:
 HDC mhLocalDC;  // HDC
@@ -210,6 +211,7 @@ public:
 virtual ~WinSalGraphics() override;
 
 SalGraphicsImpl* GetImpl() const override;
+WinSalGraphicsImplBase * getWinSalGraphicsImplBase() const { return 
mWinSalGraphicsImplBase; }
 bool isPrinter() const;
 bool isVirtualDevice() const;
 bool isWindow() const;
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 9dde07473845..196932982c28 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -1152,9 +1152,7 @@ void WinSalGraphics::GetDevFontList( 
vcl::font::PhysicalFontCollection* pFontCol
 
 void WinSalGraphics::ClearDevFontCache()
 {
-WinSalGraphicsImplBase* pImpl = 
dynamic_cast(GetImpl());
-assert(pImpl != nullptr);
-pImpl->ClearDevFontCache();
+mWinSalGraphicsImplBase->ClearDevFontCache();
 ImplReleaseTempFonts(*GetSalData(), false);
 }
 
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index c723ed1156ba..48ba63e0b192 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -592,8 +592,7 @@ CompatibleDC::CompatibleDC(SalGraphics , int x, 
int y, int width, int
 return;
 }
 
-mpImpl = dynamic_cast(rWinGraphics.GetImpl());
-assert(mpImpl != nullptr);
+mpImpl = rWinGraphics.getWinSalGraphicsImplBase();
 mhCompatibleDC = CreateCompatibleDC(rWinGraphics.getHDC());
 
 // move the origin so that we always paint at 0,0 - to keep the bitmap
@@ -642,10 +641,18 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type 
eType, bool bScreen, HWND hW
 {
 #if HAVE_FEATURE_SKIA
 if (SkiaHelper::isVCLSkiaEnabled() && !mbPrinter)
-mpImpl.reset(new WinSkiaSalGraphicsImpl(*this, pProvider));
+{
+auto const impl = new WinSkiaSalGraphicsImpl(*this, pProvider);
+mpImpl.reset(impl);
+mWinSalGraphicsImplBase = impl;
+}
 else
 #endif
-mpImpl.reset(new WinSalGraphicsImpl(*this));
+{
+auto const impl = new WinSalGraphicsImpl(*this);
+mpImpl.reset(impl);
+mWinSalGraphicsImplBase = impl;
+}
 }
 
 WinSalGraphics::~WinSalGraphics()
@@ -799,8 +806,7 @@ tools::Long WinSalGraphics::GetGraphicsWidth() const
 
 void WinSalGraphics::Flush()
 {
-if(WinSalGraphicsImplBase* impl = 
dynamic_cast(GetImpl()))
-impl->Flush();
+mWinSalGraphicsImplBase->Flush();
 }
 
 void WinSalGraphics::ResetClipRegion()
diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx 
b/vcl/win/gdi/salnativewidgets-luna.cxx
index 6b676162f7d0..601575a9f58b 100644
--- a/vcl/win/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/gdi/salnativewidgets-luna.cxx
@@ -80,15 +80,14 @@ void SalData::deInitNWF()
 aThemeMap.clear();
 }
 
-static HTHEME getThemeHandle(HWND hWnd, LPCWSTR name, SalGraphicsImpl* 
pGraphicsImpl)
+static HTHEME getThemeHandle(HWND hWnd, LPCWSTR name, WinSalGraphicsImplBase* 
pGraphicsImpl)
 {
 if( GetSalData()->mbThemeChanged )
 {
 // throw away invalid theme handles
 SalData::deInitNWF();
 // throw away native control cache
-if (WinSalGraphicsImplBase* pImpl = 
dynamic_cast(pGraphicsImpl))
-pImpl->ClearNativeControlCache();
+pGraphicsImpl->ClearNativeControlCache();
 GetSalData()->mbThemeChanged = false;
 }
 
@@ -112,33 +111,33 @@ bool WinSalGraphics::isNativeControlSupported( 
ControlType nType, ControlPart nP
 case ControlType::Radiobutton:
 case ControlType::Checkbox:
 if( nPart == ControlPart::Entire )
-hTheme = getThemeHandle(mhWnd, L"Button", mpImpl.get());
+hTheme = getThemeHandle(mhWnd, L"Button", 
mWinSalGraphicsImplBase);
 break;
 case ControlType::Scrollbar:
 if( nPart == ControlPart::DrawBackgroundHorz || nPart == 
ControlPart::DrawBackgroundVert )
 return false;   // no 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2022-11-19 Thread Khaled Hosny (via logerrit)
 vcl/inc/win/DWriteTextRenderer.hxx |   11 -
 vcl/win/gdi/DWriteTextRenderer.cxx |   80 ++---
 2 files changed, 6 insertions(+), 85 deletions(-)

New commits:
commit 0cf71ca47b463c0b944e31aa7bd66fdaf9097f8e
Author: Khaled Hosny 
AuthorDate: Fri Nov 18 22:16:52 2022 +0200
Commit: خالد حسني 
CommitDate: Sat Nov 19 12:43:32 2022 +0100

vcl: remove unused D2DWriteTextOutRenderer code

Change-Id: I873d13e3a230c2679daea2080a102d89003c90c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142955
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/inc/win/DWriteTextRenderer.hxx 
b/vcl/inc/win/DWriteTextRenderer.hxx
index b64cc48a1c6a..5f0dc35ddd58 100644
--- a/vcl/inc/win/DWriteTextRenderer.hxx
+++ b/vcl/inc/win/DWriteTextRenderer.hxx
@@ -47,14 +47,6 @@ public:
 
 HRESULT BindDC(HDC hDC, tools::Rectangle const & rRect = 
tools::Rectangle(0, 0, 1, 1));
 
-bool BindFont(HDC hDC) /*override*/;
-bool ReleaseFont() /*override*/;
-
-std::vector  GetGlyphInkBoxes(uint16_t const * pGid, 
uint16_t const * pGidEnd) const /*override*/;
-ID2D1RenderTarget * GetRenderTarget() const { return mpRT; }
-IDWriteFontFace   * GetFontFace() const { return mpFontFace; }
-float   GetEmHeight() const { return mlfEmHeight; }
-
 HRESULT CreateRenderTarget(bool bRenderingModeNatural);
 
 bool Ready() const;
@@ -77,9 +69,6 @@ private:
 ID2D1DCRenderTarget * mpRT;
 const D2D1_RENDER_TARGET_PROPERTIES mRTProps;
 
-IDWriteFontFace * mpFontFace;
-float mlfEmHeight;
-HDC   mhDC;
 bool mbRenderingModeNatural;
 D2DTextAntiAliasMode meTextAntiAliasMode;
 };
diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx 
b/vcl/win/gdi/DWriteTextRenderer.cxx
index c160166a541e..64d49696b102 100644
--- a/vcl/win/gdi/DWriteTextRenderer.cxx
+++ b/vcl/win/gdi/DWriteTextRenderer.cxx
@@ -107,9 +107,6 @@ D2DWriteTextOutRenderer::D2DWriteTextOutRenderer(bool 
bRenderingModeNatural)
 mRTProps(D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT,
   
D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED),
   0, 0)),
-mpFontFace(nullptr),
-mlfEmHeight(0.0f),
-mhDC(nullptr),
 mbRenderingModeNatural(bRenderingModeNatural),
 meTextAntiAliasMode(D2DTextAntiAliasMode::Default)
 {
@@ -229,8 +226,9 @@ bool 
D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
 return ExTextOutRenderer()(rLayout, rGraphics, hDC, 
bRenderingModeNatural);
 }
 
-mlfEmHeight = 0;
-if (!GetDWriteFaceFromHDC(hDC, , ))
+IDWriteFontFace* pFontFace;
+float lfEmHeight = 0;
+if (!GetDWriteFaceFromHDC(hDC, , ))
 return false;
 
 const WinFontInstance& rWinFont = static_cast(rLayout.GetFont());
@@ -268,8 +266,8 @@ bool 
D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
static_cast(aPos.getY() - 
bounds.Top()) };
 WinFontTransformGuard aTransformGuard(mpRT, fHScale, rLayout, 
baseline, pGlyph->IsVertical());
 DWRITE_GLYPH_RUN glyphs = {
-mpFontFace,
-mlfEmHeight,
+pFontFace,
+lfEmHeight,
 1,
 glyphIndices,
 glyphAdvances,
@@ -287,7 +285,7 @@ bool 
D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
 if (pBrush)
 pBrush->Release();
 
-ReleaseFont();
+pFontFace->Release();
 
 if (hr == D2DERR_RECREATE_TARGET)
 {
@@ -298,72 +296,6 @@ bool 
D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
 return succeeded;
 }
 
-bool D2DWriteTextOutRenderer::BindFont(HDC hDC)
-{
-// A TextOutRender can only be bound to one font at a time, so the
-assert(mpFontFace == nullptr);
-if (mpFontFace)
-{
-ReleaseFont();
-return false;
-}
-
-// Initially bind to an empty rectangle to get access to the font face,
-//  we'll update it once we've calculated a bounding rect in DrawGlyphs
-if (FAILED(BindDC(mhDC = hDC)))
-return false;
-
-mlfEmHeight = 0;
-return GetDWriteFaceFromHDC(hDC, , );
-}
-
-bool D2DWriteTextOutRenderer::ReleaseFont()
-{
-mpFontFace->Release();
-mpFontFace = nullptr;
-mhDC = nullptr;
-
-return true;
-}
-
-// GetGlyphInkBoxes
-// The inkboxes returned have their origin on the baseline, to a -ve value
-// of Top() means the glyph extends abs(Top()) many pixels above the
-// baseline, and +ve means the ink starts that many pixels below.
-std::vector 
D2DWriteTextOutRenderer::GetGlyphInkBoxes(uint16_t const * pGid, uint16_t const 
* pGidEnd) const
-{
-ptrdiff_t nGlyphs = pGidEnd - pGid;
-if (nGlyphs < 0)
-return std::vector();
-
-DWRITE_FONT_METRICS aFontMetrics;
-

[Libreoffice-commits] core.git: vcl/inc vcl/win

2022-11-12 Thread Khaled Hosny (via logerrit)
 vcl/inc/win/salgdi.h|2 --
 vcl/win/gdi/salfont.cxx |   22 --
 2 files changed, 24 deletions(-)

New commits:
commit 755e6939adc9b8b1322f739c8143ae1a7e2995a3
Author: Khaled Hosny 
AuthorDate: Sat Nov 12 20:47:31 2022 +0200
Commit: خالد حسني 
CommitDate: Sat Nov 12 20:39:56 2022 +0100

vcl: remove unused WinFontFace() private members

Change-Id: I0f7f9f03064a63f7c27346fd679e4cb436633cd5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142638
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 6c163d2f1b39..35d723b0bc90 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -78,8 +78,6 @@ private:
 
 BYTEmeWinCharSet;
 BYTEmnPitchAndFamily;
-boolmbAliasSymbolsHigh;
-boolmbAliasSymbolsLow;
 LOGFONTWmaLogFont;
 };
 
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 75080dae4261..e2305d3f49ee 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -509,30 +509,8 @@ WinFontFace::WinFontFace(const ENUMLOGFONTEXW& rEnumFont, 
const NEWTEXTMETRICW&
 mnId( 0 ),
 meWinCharSet(rEnumFont.elfLogFont.lfCharSet),
 mnPitchAndFamily(rMetric.tmPitchAndFamily),
-mbAliasSymbolsHigh( false ),
-mbAliasSymbolsLow( false ),
 maLogFont(rEnumFont.elfLogFont)
 {
-if (meWinCharSet == SYMBOL_CHARSET)
-{
-if ((mnPitchAndFamily & TMPF_TRUETYPE) != 0)
-{
-// truetype fonts need their symbols as U+F0xx
-mbAliasSymbolsHigh = true;
-}
-else if ((mnPitchAndFamily & (TMPF_VECTOR|TMPF_DEVICE))
-  == (TMPF_VECTOR|TMPF_DEVICE))
-{
-// scalable device fonts (e.g. builtin printer fonts)
-// need their symbols as U+00xx
-mbAliasSymbolsLow  = true;
-}
-else if ((mnPitchAndFamily & (TMPF_VECTOR|TMPF_TRUETYPE)) == 0)
-{
-// bitmap fonts need their symbols as U+F0xx
-mbAliasSymbolsHigh = true;
-}
-}
 }
 
 WinFontFace::~WinFontFace()


[Libreoffice-commits] core.git: vcl/inc vcl/win

2022-11-09 Thread Noel Grandin (via logerrit)
 vcl/inc/win/salinst.h   |1 +
 vcl/win/app/salinst.cxx |9 +
 2 files changed, 10 insertions(+)

New commits:
commit 4ff2ee082c5de428d3426005023e7362cb75200d
Author: Noel Grandin 
AuthorDate: Tue Nov 8 09:49:30 2022 +0200
Commit: Noel Grandin 
CommitDate: Wed Nov 9 12:26:01 2022 +0100

give main thread on Windows a name

to make it easier to find in profilers and debuggers

Change-Id: I8ce3ee0b89ca8498683367c2b39176edc571137b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142415
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h
index c62a68ae0455..35f2365fb166 100644
--- a/vcl/inc/win/salinst.h
+++ b/vcl/inc/win/salinst.h
@@ -43,6 +43,7 @@ public:
 WinSalInstance();
 virtual ~WinSalInstance() override;
 
+virtual void AfterAppInit() override;
 virtual SalFrame*   CreateChildFrame( SystemParentData* pParent, 
SalFrameStyleFlags nStyle ) override;
 virtual SalFrame*   CreateFrame( SalFrame* pParent, SalFrameStyleFlags 
nStyle ) override;
 virtual voidDestroyFrame( SalFrame* pFrame ) override;
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index b903247d2d85..5ba2f9cd50e6 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -458,6 +458,15 @@ WinSalInstance::~WinSalInstance()
 #endif
 }
 
+void WinSalInstance::AfterAppInit()
+{
+// (1) Ideally this would be done at the place that creates the thread, but 
since this thread is normally
+// just the default/main thread, that is not possible.
+// (2) Don't do this on unix, where it causes tools like pstree on Linux to
+// confusingly report soffice.bin as VCL Main instead.
+osl_setThreadName("VCL Main");
+}
+
 static LRESULT ImplSalDispatchMessage( const MSG* pMsg )
 {
 SalData* pSalData = GetSalData();


[Libreoffice-commits] core.git: vcl/inc vcl/win

2022-10-13 Thread Mike Kaganski (via logerrit)
 vcl/inc/win/saldata.hxx |1 -
 vcl/win/app/salinst.cxx |1 -
 vcl/win/window/salframe.cxx |   13 -
 3 files changed, 4 insertions(+), 11 deletions(-)

New commits:
commit ba42683fada2abafa18a49cd50ce8298b92851c8
Author: Mike Kaganski 
AuthorDate: Thu Oct 13 13:43:29 2022 +0300
Commit: Mike Kaganski 
CommitDate: Thu Oct 13 16:21:15 2022 +0200

tdf#120326: properly prevent Windows from entering power saving

The previous call to SystemParametersInfoW with SPI_SETSCREENSAVEACTIVE
only prevented screen saver from running (which is not often used these
days), but screen was still turned off (and power saving was started).

Despite SetThreadExecutionState documentation [1] claims that it does
not stop the screen saver from executing, my experiments show that it
does (on my Windows 10). So just use it, because it is designed exactly
for this task (documentation discusses the presentation applications).

[1] 
https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate

Change-Id: I6eced8f0a7c17211a0b68851a40227eed9a22b1a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141289
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 17e9411a3c8e..3145688e24be 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -111,7 +111,6 @@ public:
 boolmbObjClassInit; // is SALOBJECTCLASS 
initialised
 boolmbInPalChange;  // is in WM_QUERYNEWPALETTE
 DWORD   mnAppThreadId;  // Id from 
Application-Thread
-BOOLmbScrSvrEnabled;// ScreenSaver enabled
 SalIcon*mpFirstIcon;// icon cache, points to 
first icon, NULL if none
 TempFontItem*   mpSharedTempFontItem;   // LibreOffice shared fonts
 TempFontItem*   mpOtherTempFontItem;// other temporary fonts 
(embedded?)
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 24c4c508fe9a..56773808fea5 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -291,7 +291,6 @@ SalData::SalData()
 mbObjClassInit = false; // is SALOBJECTCLASS initialised
 mbInPalChange = false;  // is in WM_QUERYNEWPALETTE
 mnAppThreadId = 0;  // Id from Application-Thread
-mbScrSvrEnabled = FALSE;// ScreenSaver enabled
 mpFirstIcon = nullptr;  // icon cache, points to first icon, NULL if 
none
 mpSharedTempFontItem = nullptr;
 mpOtherTempFontItem = nullptr;
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index d2d2f697aeb3..9871eba67edd 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -1887,20 +1887,15 @@ void WinSalFrame::StartPresentation( bool bStart )
 
 mbPresentation = bStart;
 
-SalData* pSalData = GetSalData();
 if ( bStart )
 {
-// turn off screen-saver when in Presentation mode
-SystemParametersInfoW( SPI_GETSCREENSAVEACTIVE, 0,
-  &(pSalData->mbScrSvrEnabled), 0 );
-if ( pSalData->mbScrSvrEnabled )
-SystemParametersInfoW( SPI_SETSCREENSAVEACTIVE, FALSE, nullptr, 0 
);
+// turn off screen-saver / power saving when in Presentation mode
+SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | 
ES_DISPLAY_REQUIRED);
 }
 else
 {
-// turn on screen-saver
-if ( pSalData->mbScrSvrEnabled )
-SystemParametersInfoW( SPI_SETSCREENSAVEACTIVE, 
pSalData->mbScrSvrEnabled, nullptr, 0 );
+// turn on screen-saver / power saving back
+SetThreadExecutionState(ES_CONTINUOUS);
 }
 }
 


[Libreoffice-commits] core.git: vcl/inc vcl/win

2022-09-05 Thread Khaled Hosny (via logerrit)
 vcl/inc/win/salgdi.h|2 +-
 vcl/win/gdi/salfont.cxx |7 ---
 2 files changed, 5 insertions(+), 4 deletions(-)

New commits:
commit e75631211b596df3997f6fe6eb5422b931bd0384
Author: Khaled Hosny 
AuthorDate: Mon Sep 5 19:36:25 2022 +0200
Commit: Mike Kaganski 
CommitDate: Tue Sep 6 07:19:57 2022 +0200

vcl: Create HFNT on WinFontFace when needed

I’m seeing frequent CI failures with warnings like:

warn:sfx.appl:13336:18148:sfx2/source/appl/app.cxx:147: No DDE-Service 
possible. Error: 16399
warn:vcl:13336:18148:vcl/win/gdi/salvd.cxx:99: CreateCompatibleDC failed: 
There are no more files.

Lets see if this is causing us to hit the GDI object limit.

Change-Id: I1257ac7e701277814b5d17b40192ad3bc81a8e0a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139449
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index ef7cdf210c94..b107308ec10b 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -80,7 +80,7 @@ private:
 BYTEmnPitchAndFamily;
 boolmbAliasSymbolsHigh;
 boolmbAliasSymbolsLow;
-HFONT   mhFont;
+LOGFONTWmaLogFont;
 };
 
 /** Class that creates (and destroys) a compatible Device Context.
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 7614bbf4390c..200780426a5b 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -586,7 +586,7 @@ WinFontFace::WinFontFace(const ENUMLOGFONTEXW& rEnumFont, 
const NEWTEXTMETRICW&
 mnPitchAndFamily(rMetric.tmPitchAndFamily),
 mbAliasSymbolsHigh( false ),
 mbAliasSymbolsLow( false ),
-mhFont(CreateFontIndirectW())
+maLogFont(rEnumFont.elfLogFont)
 {
 if (meWinCharSet == SYMBOL_CHARSET)
 {
@@ -612,7 +612,6 @@ WinFontFace::WinFontFace(const ENUMLOGFONTEXW& rEnumFont, 
const NEWTEXTMETRICW&
 
 WinFontFace::~WinFontFace()
 {
-DeleteFont(mhFont);
 }
 
 sal_IntPtr WinFontFace::GetFontId() const
@@ -686,7 +685,8 @@ hb_blob_t* WinFontFace::GetHbTable(hb_tag_t nTag) const
 unsigned char* pBuffer = nullptr;
 
 HDC hDC(::GetDC(nullptr));
-HFONT hOldFont = ::SelectFont(hDC, mhFont);
+HFONT hFont = ::CreateFontIndirectW();
+HFONT hOldFont = ::SelectFont(hDC, hFont);
 
 nLength = ::GetFontData(hDC, OSL_NETDWORD(nTag), 0, nullptr, 0);
 if (nLength > 0 && nLength != GDI_ERROR)
@@ -696,6 +696,7 @@ hb_blob_t* WinFontFace::GetHbTable(hb_tag_t nTag) const
 }
 
 ::SelectFont(hDC, hOldFont);
+::DeleteFont(hFont);
 ::ReleaseDC(nullptr, hDC);
 
 hb_blob_t* pBlob = nullptr;


[Libreoffice-commits] core.git: vcl/inc vcl/win

2022-09-04 Thread Khaled Hosny (via logerrit)
 vcl/inc/win/salgdi.h|7 --
 vcl/win/gdi/salfont.cxx |  120 +++-
 2 files changed, 41 insertions(+), 86 deletions(-)

New commits:
commit 8f9638424f7f88c99ff16a8015ca343f3042b26d
Author: Khaled Hosny 
AuthorDate: Sun Sep 4 19:08:08 2022 +0200
Commit: خالد حسني 
CommitDate: Mon Sep 5 06:08:41 2022 +0200

vcl: make WinFontFace less indirect

Create the associated HFONT right from the start and avoid the
UpdateFromDC() dance. We want to be able to get table data at any point
after the face is created, and for this we need a HDC with the right
HFONT set on it.

Change-Id: Ie1f8a5afa03e0eae49f51359ebb0dbd732269c12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139375
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index cddd59774b43..3f442614c3d3 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -61,15 +61,12 @@ class ImplFontMetricData;
 class WinFontFace : public vcl::font::PhysicalFontFace
 {
 public:
-explicitWinFontFace( const FontAttributes&,
-BYTE eWinCharSet,
-BYTE nPitchAndFamily  );
+explicitWinFontFace(const ENUMLOGFONTEXW&, const 
NEWTEXTMETRICW&);
 virtual ~WinFontFace() override;
 
 virtual rtl::Reference CreateFontInstance( const 
vcl::font::FontSelectPattern& ) const override;
 virtual sal_IntPtr  GetFontId() const override;
 voidSetFontId( sal_IntPtr nId ) { mnId = nId; }
-voidUpdateFromHDC( HDC ) const;
 
 boolHasChar( sal_uInt32 cChar ) const;
 
@@ -93,7 +90,7 @@ private:
 BYTEmnPitchAndFamily;
 boolmbAliasSymbolsHigh;
 boolmbAliasSymbolsLow;
-mutable HDC mhDC;
+HFONT   mhFont;
 
 voidReadCmapTable() const;
 voidGetFontCapabilities() const;
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 2135c7a02860..f2922c186c01 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -169,19 +169,8 @@ class WinGlyphFallbackSubstititution
 :public vcl::font::GlyphFallbackFontSubstitution
 {
 public:
-explicit WinGlyphFallbackSubstititution()
-: mhDC(GetDC(nullptr))
-{
-};
-
-~WinGlyphFallbackSubstititution() override
-{
-ReleaseDC(nullptr, mhDC);
-};
-
 bool FindFontSubstitute(vcl::font::FontSelectPattern&, 
LogicalFontInstance* pLogicalFont, OUString& rMissingChars) const override;
 private:
-HDC mhDC;
 bool HasMissingChars(vcl::font::PhysicalFontFace*, OUString& 
rMissingChars) const;
 };
 
@@ -192,29 +181,6 @@ bool 
WinGlyphFallbackSubstititution::HasMissingChars(vcl::font::PhysicalFontFace
 {
 WinFontFace* pWinFont = static_cast< WinFontFace* >(pFace);
 FontCharMapRef xFontCharMap = pWinFont->GetFontCharMap();
-if( !xFontCharMap.is() )
-{
-// create a FontSelectPattern object for getting s LOGFONT
-const vcl::font::FontSelectPattern aFSD( *pFace, Size(), 0.0, 0, false 
);
-// construct log font
-LOGFONTW aLogFont;
-ImplGetLogFontFromFontSelect( aFSD, pFace, aLogFont );
-
-// create HFONT from log font
-HFONT hNewFont = ::CreateFontIndirectW(  );
-// select the new font into device
-HFONT hOldFont = ::SelectFont( mhDC, hNewFont );
-
-// read CMAP table to update their xFontCharMap
-pWinFont->UpdateFromHDC( mhDC );
-
-// cleanup temporary font
-::SelectFont( mhDC, hOldFont );
-::DeleteFont( hNewFont );
-
-// get the new charmap
-xFontCharMap = pWinFont->GetFontCharMap();
-}
 
 // avoid fonts with unknown CMAP subtables for glyph fallback
 if( !xFontCharMap.is() || xFontCharMap->IsDefaultMap() )
@@ -577,18 +543,6 @@ static FontAttributes WinFont2DevFontAttributes( const 
ENUMLOGFONTEXW& rEnumFont
 return aDFA;
 }
 
-
-static rtl::Reference ImplLogMetricToDevFontDataW( const 
ENUMLOGFONTEXW* pLogFont,
- const NEWTEXTMETRICW* pMetric)
-{
-rtl::Reference pData = new WinFontFace(
-WinFont2DevFontAttributes(*pLogFont, *pMetric),
-pLogFont->elfLogFont.lfCharSet,
-pMetric->tmPitchAndFamily );
-
-return pData;
-}
-
 void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& rLogFont, Font& rFont )
 {
 OUString aFontName( o3tl::toU(rLogFont.lfFaceName) );
@@ -626,32 +580,31 @@ void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& 
rLogFont, Font& rFont )
 }
 }
 
-WinFontFace::WinFontFace( const FontAttributes& rDFS,
-BYTE eWinCharSet, BYTE nPitchAndFamily )
-:   vcl::font::PhysicalFontFace( rDFS ),
+WinFontFace::WinFontFace(const ENUMLOGFONTEXW& rEnumFont, const 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2022-06-17 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/win/salframe.h  |   10 +-
 vcl/win/window/salframe.cxx |  201 +---
 2 files changed, 88 insertions(+), 123 deletions(-)

New commits:
commit 8b6000f6075725b2e17b8fa745251ea96d7185f1
Author: Jan-Marek Glogowski 
AuthorDate: Mon Jun 13 10:26:18 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Fri Jun 17 19:58:08 2022 +0200

WIN drop window state redundancies

So on Windows a window's state is stored in:
- maGeometry, inherited from SalFrame
- maState, which is the same type then maGeometry
- mnWidth and mnHeight, which are just set, never read
- mbFullScreen, which can be encoded in the vcl::WindowState

IMHO we can get rid of mnWidth, mnHeight and mbFullScreen. Which
leaves the mystery of the extra maState. But at least it looks
like we can simply cache an vcl::WindowState instead.

And this is a little start to make WinSalFrame variable members
private; it'll be a long way...

And it also changes a SW_SHOWMAXIMIZED to SW_SHOWMINIMIZED in the
cleaned UpdateFrameState(), which looks like an error.

Change-Id: I5895313d87a6f81371e2b77af6c813d35f591725
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135809
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h
index 0e3cbba81253..bbf3506a723f 100644
--- a/vcl/inc/win/salframe.h
+++ b/vcl/inc/win/salframe.h
@@ -33,6 +33,8 @@ class WinSalGraphics;
 
 class WinSalFrame final: public SalFrame
 {
+vcl::WindowState m_eState;
+
 public:
 HWNDmhWnd;  // Window handle
 HCURSOR mhCursor;   // cursor handle
@@ -43,10 +45,7 @@ public:
 HMENU   mSelectedhMenu; // the menu where 
highlighting is currently going on
 HMENU   mLastActivatedhMenu;// the menu that was most 
recently opened
 SystemEnvData   maSysData;  // system data
-vcl::WindowData maState; ///< frame state
 int mnShowState;// show state
-LONGmnWidth;// client width in pixeln
-LONGmnHeight;   // client height in pixeln
 int mnMinWidth; // min. client width in 
pixeln
 int mnMinHeight;// min. client height in 
pixeln
 int mnMaxWidth; // max. client width in 
pixeln
@@ -64,7 +63,6 @@ public:
 boolmbSizeBorder;   // has window a sizeable 
border
 boolmbNoIcon;   // is a window without an 
icon
 boolmbFloatWin; // is a FloatingWindow
-boolmbFullScreen;   // TRUE: in full screen 
mode
 boolmbPresentation; // TRUE: Presentation Mode 
running
 boolmbInShow;   // inside a show call
 boolmbRestoreMaximize;  // Restore-Maximize
@@ -141,6 +139,10 @@ public:
 virtual voidBeginSetClipRegion( sal_uInt32 nRects ) 
override;
 virtual voidUnionClipRegion( tools::Long nX, tools::Long 
nY, tools::Long nWidth, tools::Long nHeight ) override;
 virtual voidEndSetClipRegion() override;
+
+constexpr vcl::WindowState state() const { return m_eState; }
+void UpdateFrameState();
+constexpr bool isFullScreen() const { return bool(m_eState & 
vcl::WindowState::FullScreen); }
 };
 
 void ImplSalGetWorkArea( HWND hWnd, RECT *pRect, const RECT *pParentRect );
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 2b2bd6cb7b72..567d95eec233 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -128,7 +128,7 @@ bool WinSalFrame::mbInReparent = false;
 // Macros for support of WM_UNICHAR & Keyman 6.0
 #define Uni_SupplementaryPlanesStart0x1
 
-static void UpdateFrameGeometry( HWND hWnd, WinSalFrame* pFrame );
+static void UpdateFrameGeometry(WinSalFrame* pFrame);
 static void SetMaximizedFrameGeometry( HWND hWnd, WinSalFrame* pFrame, RECT* 
pParentRect = nullptr );
 
 static void SetGeometrySize(vcl::WindowPosSize& rWinPosSize, const Size& rSize)
@@ -137,57 +137,37 @@ static void SetGeometrySize(vcl::WindowPosSize& 
rWinPosSize, const Size& rSize)
 rWinPosSize.setHeight(rSize.Height() < 0 ? 0 : rSize.Height());
 }
 
-static void UpdateGeometry(WinSalFrame* pFrame, RECT& aRect)
+// If called with UpdateFrameGeometry, it must be called after it, as 
UpdateFrameGeometry
+// updates the geometry depending on the old state!
+void WinSalFrame::UpdateFrameState()
 {
-RECT aRect2 = aRect;
-AdjustWindowRectEx(, GetWindowStyle(pFrame->mhWnd),
-   FALSE, GetWindowExStyle(pFrame->mhWnd));
-   

[Libreoffice-commits] core.git: vcl/inc vcl/win

2022-05-03 Thread Stephan Bergmann (via logerrit)
 vcl/inc/win/salframe.h  |6 +-
 vcl/win/window/keynames.cxx |5 +++--
 2 files changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 19e4ab8754240e019deae26b861745b91f4044e6
Author: Stephan Bergmann 
AuthorDate: Tue May 3 16:03:32 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Tue May 3 18:56:43 2022 +0200

loplugin:stringviewparam

Change-Id: I32ded64d7e9a86a6226dfbc4a3b9262bc7572ad2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133761
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h
index 0cce466b3173..e3d8b685a229 100644
--- a/vcl/inc/win/salframe.h
+++ b/vcl/inc/win/salframe.h
@@ -20,6 +20,10 @@
 #ifndef INCLUDED_VCL_INC_WIN_SALFRAME_H
 #define INCLUDED_VCL_INC_WIN_SALFRAME_H
 
+#include 
+
+#include 
+
 #include 
 #include 
 #include 
@@ -147,7 +151,7 @@ bool UseDarkMode();
 // get foreign key names
 namespace vcl_sal {
 OUString getKeysReplacementName(
-OUString const & pLang,
+std::u16string_view pLang,
 LONG nSymbol );
 }
 
diff --git a/vcl/win/window/keynames.cxx b/vcl/win/window/keynames.cxx
index d1dac8f08c5c..8f0996445cb6 100644
--- a/vcl/win/window/keynames.cxx
+++ b/vcl/win/window/keynames.cxx
@@ -18,6 +18,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 
@@ -201,11 +202,11 @@ namespace vcl_sal {
 };
 
 // translate keycodes, used within the displayed menu shortcuts
-OUString getKeysReplacementName( OUString const & pLang, LONG nSymbol )
+OUString getKeysReplacementName( std::u16string_view pLang, LONG nSymbol )
 {
 for( unsigned int n = 0; n < SAL_N_ELEMENTS(aKeyboards); n++ )
 {
-if( pLang.equalsAscii( aKeyboards[n].pLangName ) )
+if( o3tl::equalsAscii( pLang, aKeyboards[n].pLangName ) )
 {
 const struct KeysNameReplacement* pRepl = 
aKeyboards[n].pReplacements;
 for( int m = aKeyboards[n].nReplacements ; m ; )


[Libreoffice-commits] core.git: vcl/inc vcl/win

2021-12-28 Thread Caolán McNamara (via logerrit)
 vcl/inc/win/DWriteTextRenderer.hxx |1 -
 vcl/win/gdi/DWriteTextRenderer.cxx |9 -
 2 files changed, 10 deletions(-)

New commits:
commit cfbcbb605dbaaea45dc9ac5ea792d72cb2f2c1bb
Author: Caolán McNamara 
AuthorDate: Mon Dec 27 20:55:50 2021 +
Commit: Caolán McNamara 
CommitDate: Tue Dec 28 20:51:57 2021 +0100

changeTextAntiAliasMode is unused

Change-Id: I421a5402f7765ebe3daa0c47b83ad7109573c1e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127611
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/inc/win/DWriteTextRenderer.hxx 
b/vcl/inc/win/DWriteTextRenderer.hxx
index 6e097546d1e2..77d26e750e5a 100644
--- a/vcl/inc/win/DWriteTextRenderer.hxx
+++ b/vcl/inc/win/DWriteTextRenderer.hxx
@@ -59,7 +59,6 @@ public:
 bool Ready() const;
 
 void applyTextAntiAliasMode();
-void changeTextAntiAliasMode(D2DTextAntiAliasMode eMode);
 
 private:
 // This is a singleton object disable copy ctor and assignment operator
diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx 
b/vcl/win/gdi/DWriteTextRenderer.cxx
index edd0b700bdf6..2f089ee3d2d4 100644
--- a/vcl/win/gdi/DWriteTextRenderer.cxx
+++ b/vcl/win/gdi/DWriteTextRenderer.cxx
@@ -177,15 +177,6 @@ HRESULT D2DWriteTextOutRenderer::CreateRenderTarget()
 return hr;
 }
 
-void D2DWriteTextOutRenderer::changeTextAntiAliasMode(D2DTextAntiAliasMode 
eMode)
-{
-if (meTextAntiAliasMode != eMode)
-{
-meTextAntiAliasMode = eMode;
-applyTextAntiAliasMode();
-}
-}
-
 bool D2DWriteTextOutRenderer::Ready() const
 {
 return mpGdiInterop && mpRT;


[Libreoffice-commits] core.git: vcl/inc vcl/win

2021-12-07 Thread Mark Hung (via logerrit)
 vcl/inc/win/salgdi.h  |4 +++-
 vcl/inc/win/winlayout.hxx |6 ++
 vcl/win/gdi/salfont.cxx   |   32 ++--
 vcl/win/gdi/winlayout.cxx |   42 +++---
 4 files changed, 74 insertions(+), 10 deletions(-)

New commits:
commit 6720e9569d7ab6c20616ec6b97e5d4a56948908b
Author: Mark Hung 
AuthorDate: Mon Nov 1 20:53:19 2021 +0800
Commit: Mark Hung 
CommitDate: Tue Dec 7 10:52:55 2021 +0100

tdf#145322, tdf#144378 fix printing for vertical writing

Printing still uses ExTextOutRenderer to render text because
Skia haven't yet support printing and DWriteTextRenderer can't
bind the printer DC.

ExTextOutRenderer uses win32 API ExtTextOutW. In order to
renderer upright CJK text in vertical writing with that API,
the HFONT created with CreateFontIndirectW needs a font name
prefixed with '@'. OTOH, use '@' prefixed font with Skia break
the vertical writing unit test.

- WinSalGraphics::ImplDoSetFont: use '@' prefixed font name
if the requested font is vertical and is for printing.

- ExTextOutRenderer: use SetTextAlign and text metric tmDescent
to adjust vertical glyphs. It's not consistent with Skia or
DWriteTextRenderer, and is still incorrect in many cases.

The patch is adapted from reverting

commit 5686c1aca40beb9514d40c86b4a3780a8a1334ba
Author: Mark Hung 
Date:   Sun May 2 14:45:45 2021 +0800

vcl: use DWriteTextRenderer for vertical writing.

Change-Id: Ib2d3df8b68cad4bebe0672c9da0a16b62aed99e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125978
Tested-by: Jenkins
Reviewed-by: Mark Hung 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 8c6c1adcdbed..b472ece0a256 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -181,7 +181,9 @@ private:
 void DeInitGraphics();
 
 public:
-HFONT ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const & i_rFont, 
const vcl::font::PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont);
+// Return HFONT, and whether the font is for vertical writing ( prefixed 
with '@' )
+// and tmDescent value for adjusting offset in vertical writing mode.
+std::tuple ImplDoSetFont(HDC hDC, 
vcl::font::FontSelectPattern const & i_rFont, const vcl::font::PhysicalFontFace 
* i_pFontFace, HFONT& o_rOldFont);
 
 HDC getHDC() const { return mhLocalDC; }
 // NOTE: this doesn't transfer ownership! See class comment.
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 29bccf5acf4f..0b43ef4eeca1 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -44,6 +44,10 @@ public:
 
 HFONT GetHFONT() const { return m_hFont; }
 float GetScale() const { return m_fScale; }
+// Return true if the font is for vertical writing.
+// I.e. the font name of the LOGFONT is prefixed with '@'.
+bool  IsCJKVerticalFont() const { return m_bIsCJKVerticalFont; }
+sal_Int32 GetTmDescent() const { return m_nTmDescent; }
 
 const WinFontFace * GetFontFace() const { return static_cast(LogicalFontInstance::GetFontFace()); }
 WinFontFace * GetFontFace() { return static_cast(LogicalFontInstance::GetFontFace()); }
@@ -59,6 +63,8 @@ private:
 WinSalGraphics *m_pGraphics;
 HFONT m_hFont;
 float m_fScale;
+bool  m_bIsCJKVerticalFont;
+sal_Int32 m_nTmDescent;
 };
 
 class TextOutRenderer
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 7682def12661..acaca76584a3 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -762,6 +762,12 @@ void WinSalGraphics::SetTextColor( Color nColor )
 ::SetTextColor( getHDC(), aCol );
 }
 
+static int CALLBACK SalEnumQueryFontProcExW( const LOGFONTW*, const 
TEXTMETRICW*, DWORD, LPARAM lParam )
+{
+*reinterpret_cast(lParam) = true;
+return 0;
+}
+
 void ImplGetLogFontFromFontSelect( const vcl::font::FontSelectPattern& rFont,
const vcl::font::PhysicalFontFace* 
pFontFace,
LOGFONTW& rLogFont )
@@ -811,7 +817,7 @@ void ImplGetLogFontFromFontSelect( const 
vcl::font::FontSelectPattern& rFont,
 
 }
 
-HFONT WinSalGraphics::ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern 
const & i_rFont,
+std::tuple WinSalGraphics::ImplDoSetFont(HDC hDC, 
vcl::font::FontSelectPattern const & i_rFont,
 const vcl::font::PhysicalFontFace * 
i_pFontFace,
 HFONT& o_rOldFont)
 {
@@ -820,6 +826,27 @@ HFONT WinSalGraphics::ImplDoSetFont(HDC hDC, 
vcl::font::FontSelectPattern const
 LOGFONTW aLogFont;
 ImplGetLogFontFromFontSelect( i_rFont, i_pFontFace, aLogFont );
 
+boolbIsCJKVerticalFont = false;
+// select vertical mode for printing if requested and available
+if ( i_rFont.mbVertical && mbPrinter )
+{
+constexpr size_t nLen = 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2021-11-23 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/win/salgdi.h  |2 
 vcl/inc/win/winlayout.hxx |4 -
 vcl/win/gdi/salfont.cxx   |  129 ++
 vcl/win/gdi/winlayout.cxx |3 -
 4 files changed, 54 insertions(+), 84 deletions(-)

New commits:
commit c2a581ffc1f4e3888c5c243932b71c3d96e8ba8f
Author: Jan-Marek Glogowski 
AuthorDate: Mon Nov 22 06:32:55 2021 +0100
Commit: Jan-Marek Glogowski 
CommitDate: Tue Nov 23 19:29:38 2021 +0100

tdf#62812 WIN use a compatible DC for font funcs

All these function work on a temporary font. It's not clear, if
the CreateCompatibleDC is actually needed and if the ScopedFontDC
could actually just use the SalGraphics DC and restore its HFONT,
but this at least now works as expected.

A later patch can just drop the CreateCompatibleDC and DeleteDC
calls.

Change-Id: I6e86d660e69a58fa2eab89ece80c61e2635fc792
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125652
Tested-by: Julien Nabet 
Tested-by: Jenkins
Reviewed-by: Julien Nabet 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 974c58ae81ad..8c6c1adcdbed 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -181,7 +181,7 @@ private:
 void DeInitGraphics();
 
 public:
-HFONT ImplDoSetFont(vcl::font::FontSelectPattern const & i_rFont, const 
vcl::font::PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont);
+HFONT ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const & i_rFont, 
const vcl::font::PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont);
 
 HDC getHDC() const { return mhLocalDC; }
 // NOTE: this doesn't transfer ownership! See class comment.
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 93aa0a3d00de..29bccf5acf4f 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -45,10 +45,6 @@ public:
 HFONT GetHFONT() const { return m_hFont; }
 float GetScale() const { return m_fScale; }
 
-// Prevent deletion of the HFONT in the WinFontInstance destructor
-// Used for the ScopedFont handling
-void SetHFONT(HFONT hFont) { m_hFont = hFont; }
-
 const WinFontFace * GetFontFace() const { return static_cast(LogicalFontInstance::GetFontFace()); }
 WinFontFace * GetFontFace() { return static_cast(LogicalFontInstance::GetFontFace()); }
 
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index f1c621cd5947..7e3197807d10 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -811,7 +811,7 @@ void ImplGetLogFontFromFontSelect( const 
vcl::font::FontSelectPattern& rFont,
 
 }
 
-HFONT WinSalGraphics::ImplDoSetFont(vcl::font::FontSelectPattern const & 
i_rFont,
+HFONT WinSalGraphics::ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern 
const & i_rFont,
 const vcl::font::PhysicalFontFace * 
i_pFontFace,
 HFONT& o_rOldFont)
 {
@@ -834,17 +834,17 @@ HFONT 
WinSalGraphics::ImplDoSetFont(vcl::font::FontSelectPattern const & i_rFont
 // "PRB: Fonts Not Drawn Antialiased on Device Context for DirectDraw 
Surface"
 SelectFont( hdcScreen, SelectFont( hdcScreen , hNewFont ) );
 }
-o_rOldFont = ::SelectFont( getHDC(), hNewFont );
+o_rOldFont = ::SelectFont(hDC, hNewFont);
 
 TEXTMETRICW aTextMetricW;
-if( !::GetTextMetricsW( getHDC(),  ) )
+if (!::GetTextMetricsW(hDC, ))
 {
 // the selected font doesn't work => try a replacement
 // TODO: use its font fallback instead
 lstrcpynW( aLogFont.lfFaceName, L"Courier New", 12 );
 aLogFont.lfPitchAndFamily = FIXED_PITCH;
 HFONT hNewFont2 = CreateFontIndirectW(  );
-SelectFont( getHDC(), hNewFont2 );
+SelectFont(hDC, hNewFont2);
 DeleteFont( hNewFont );
 hNewFont = hNewFont2;
 }
@@ -857,8 +857,6 @@ HFONT 
WinSalGraphics::ImplDoSetFont(vcl::font::FontSelectPattern const & i_rFont
 
 void WinSalGraphics::SetFont(LogicalFontInstance* pFont, int nFallbackLevel)
 {
-// check that we don't change the first font while ScopedFont has replaced 
HFONT
-assert(!mpWinFontEntry[0].is() || nFallbackLevel != 0 || 
mpWinFontEntry[0]->GetHFONT());
 assert(nFallbackLevel >= 0 && nFallbackLevel < MAX_FALLBACK);
 
 // return early if there is no new font
@@ -1470,40 +1468,40 @@ bool WinFontInstance::GetGlyphOutline(sal_GlyphId nId, 
basegfx::B2DPolyPolygon&
 return true;
 }
 
-class ScopedFont
-{
-public:
-explicit ScopedFont(WinSalGraphics & rData);
-
-~ScopedFont();
-
-private:
-WinSalGraphics & m_rData;
-HFONT m_hOrigFont;
-};
+namespace {
 
-ScopedFont::ScopedFont(WinSalGraphics & rData): m_rData(rData), 
m_hOrigFont(nullptr)
+class ScopedFontHDC final
 {
-if (m_rData.mpWinFontEntry[0])
+public:
+explicit ScopedFontHDC(WinSalGraphics& rGraphics, const 
vcl::font::PhysicalFontFace& rFontFace)
+: m_hDC(nullptr)
+, 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2021-10-17 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/win/salgdi.h   |8 
 vcl/win/gdi/salprn.cxx |3 +++
 2 files changed, 11 insertions(+)

New commits:
commit a2adb7fa926c2b9ed053c65e130a9da336cc98b0
Author: Jan-Marek Glogowski 
AuthorDate: Tue Oct 12 10:33:36 2021 +0200
Commit: Mark Hung 
CommitDate: Sun Oct 17 15:33:45 2021 +0200

WIN release SalPrinter's SalGraphics borrowed HDC

Regression from commit d27187b158d7e3f92180b1f2ab79b048dc5318a5
("vcl:use unique_ptr in WinSalPrinter").

Would need something like Rust's Borrowing semantics to prevent.
Ideas on IRC to make this bug more unlikely were some extra HDC +
SalGraphics struct to pass around or something like unique_ptr
reference passing and moving the value into a local copy.

For now just add some additional comments.

Change-Id: I472ee9acb4a4c02177c27ecd1c1277dfc812cadf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123440
Tested-by: Jenkins
Reviewed-by: Mark Hung 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 9555cc158b75..974c58ae81ad 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -141,6 +141,13 @@ public:
 void fill(sal_uInt32 color);
 };
 
+/**
+ * WinSalGraphics never owns the HDC it uses to draw, because the HDC can have
+ * various origins with different ways to correctly free it. And WinSalGraphics
+ * stores all default values (mhDef*) of the HDC, which must be restored when
+ * the HDC changes (setHDC) or the SalGraphics is destructed. So think of the
+ * HDC in terms of Rust's Borrowing semantics.
+ */
 class WinSalGraphics : public SalGraphics
 {
 friend class WinSalGraphicsImpl;
@@ -177,6 +184,7 @@ public:
 HFONT ImplDoSetFont(vcl::font::FontSelectPattern const & i_rFont, const 
vcl::font::PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont);
 
 HDC getHDC() const { return mhLocalDC; }
+// NOTE: this doesn't transfer ownership! See class comment.
 void setHDC(HDC aNew);
 
 HPALETTE getDefPal() const;
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 86e1e616a57f..332c7a8dfaae 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -1373,6 +1373,9 @@ WinSalPrinter::~WinSalPrinter()
 HDC hDC = mhDC;
 if ( hDC )
 {
+// explicitly reset(), so the mxGraphics's borrowed HDC defaults are
+// restored and WinSalGraphics's destructor won't work on a deleted 
HDC.
+mxGraphics.reset();
 DeleteDC( hDC );
 }
 


[Libreoffice-commits] core.git: vcl/inc vcl/win

2021-10-12 Thread Mark Hung (via logerrit)
 vcl/inc/win/salprn.h   |2 +-
 vcl/win/gdi/salprn.cxx |   12 
 2 files changed, 5 insertions(+), 9 deletions(-)

New commits:
commit d27187b158d7e3f92180b1f2ab79b048dc5318a5
Author: Mark Hung 
AuthorDate: Mon Oct 11 10:26:56 2021 +0800
Commit: Noel Grandin 
CommitDate: Tue Oct 12 08:34:28 2021 +0200

vcl:use unique_ptr in WinSalPrinter

to replace plain SalWinGraphics pointer, and get rid
of delete.

Change-Id: If06df98a8ebfdf5797bddfefa37647522b8e711b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123365
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/win/salprn.h b/vcl/inc/win/salprn.h
index 43eaa520c23d..2d02aa5b0e54 100644
--- a/vcl/inc/win/salprn.h
+++ b/vcl/inc/win/salprn.h
@@ -78,7 +78,7 @@ public:
 class WinSalPrinter : public SalPrinter
 {
 public:
-WinSalGraphics* mpGraphics; // current Printer graphics
+std::unique_ptr mxGraphics;// current Printer graphics
 WinSalInfoPrinter*  mpInfoPrinter;  // pointer to the 
compatible InfoPrinter
 WinSalPrinter*  mpNextPrinter;  // next printing printer
 HDC mhDC;   // printer hdc
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 21e779eb6156..86e1e616a57f 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -1350,7 +1350,6 @@ static DEVMODEW const * ImplSalSetCopies( DEVMODEW const 
* pDevMode, sal_uInt32
 
 
 WinSalPrinter::WinSalPrinter() :
-mpGraphics( nullptr ),
 mpInfoPrinter( nullptr ),
 mpNextPrinter( nullptr ),
 mhDC( nullptr ),
@@ -1374,7 +1373,6 @@ WinSalPrinter::~WinSalPrinter()
 HDC hDC = mhDC;
 if ( hDC )
 {
-delete mpGraphics;
 DeleteDC( hDC );
 }
 
@@ -1531,8 +1529,7 @@ bool WinSalPrinter::EndJob()
 HDC hDC = mhDC;
 if (isValid())
 {
-delete mpGraphics;
-mpGraphics = nullptr;
+mxGraphics.reset();
 
 // #i54419# Windows fax printer brings up a dialog in EndDoc
 // which text previously copied in soffice process can be
@@ -1587,14 +1584,13 @@ SalGraphics* WinSalPrinter::StartPage( ImplJobSetup* 
pSetupData, bool bNewJobDat
 SelectPen( hDC, hTempPen );
 SelectBrush( hDC, hTempBrush );
 
-mpGraphics = ImplCreateSalPrnGraphics( hDC );
-return mpGraphics;
+mxGraphics.reset(ImplCreateSalPrnGraphics( hDC ));
+return mxGraphics.get();
 }
 
 void WinSalPrinter::EndPage()
 {
-delete mpGraphics;
-mpGraphics = nullptr;
+mxGraphics.reset();
 
 if (!isValid())
 return;


[Libreoffice-commits] core.git: vcl/inc vcl/win

2021-09-25 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/win/salgdi.h|3 ++-
 vcl/win/gdi/salgdi.cxx  |   17 +
 vcl/win/window/salframe.cxx |   27 +++
 3 files changed, 26 insertions(+), 21 deletions(-)

New commits:
commit 7e571e59559dcf80ee0c195533cb0895da175a07
Author: Jan-Marek Glogowski 
AuthorDate: Wed Sep 15 19:45:58 2021 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Sat Sep 25 19:45:01 2021 +0200

WIN call RealizePalette from setPalette

I have no idea, how to handle a RealizePalette error or when it
can occur. The previous code has ignored it all together, or
handled it as successful. This now doesn't act on GDI_ERROR.

FWIW GDI_ERROR is defined a ~0 in wine, as it's an UINT.

Change-Id: Ib0aaabcaa8c2d7d7ca93678b6b82db864beb8ce3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122370
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 0f5b700cff26..ec7f4fe13fff 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -177,7 +177,8 @@ public:
 void setHDC(HDC aNew);
 
 HPALETTE getDefPal() const;
-void setPalette(HPALETTE, BOOL bForceBkgd = TRUE);
+// returns the result from RealizePalette, otherwise 0 on success or 
GDI_ERROR
+UINT setPalette(HPALETTE, BOOL bForceBkgd = TRUE);
 
 HRGN getRegion() const;
 
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 6bd510b6effa..ee231f1ac7aa 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -705,28 +705,37 @@ HPALETTE WinSalGraphics::getDefPal() const
 return mhDefPal;
 }
 
-void WinSalGraphics::setPalette(HPALETTE hNewPal, BOOL bForceBkgd)
+UINT WinSalGraphics::setPalette(HPALETTE hNewPal, BOOL bForceBkgd)
 {
+UINT res = GDI_ERROR;
+
 if (!getHDC())
 {
 assert(!mhDefPal);
-return;
+return res;
 }
 
 if (hNewPal)
 {
 HPALETTE hOldPal = SelectPalette(getHDC(), hNewPal, bForceBkgd);
-if (!mhDefPal)
-mhDefPal = hOldPal;
+if (hOldPal)
+{
+if (!mhDefPal)
+mhDefPal = hOldPal;
+res = RealizePalette(getHDC());
+}
 }
 else
 {
+res = 0;
 if (mhDefPal)
 {
 SelectPalette(getHDC(), mhDefPal, bForceBkgd);
 mhDefPal = nullptr;
 }
 }
+
+return res;
 }
 
 HRGN WinSalGraphics::getRegion() const
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index e995cae356d4..ec97012fad43 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -992,10 +992,7 @@ bool WinSalFrame::InitFrameGraphicsDC( WinSalGraphics 
*pGraphics, HDC hDC, HWND
 return false;
 
 if ( pSalData->mhDitherPal )
-{
 pGraphics->setPalette(pSalData->mhDitherPal);
-RealizePalette( hDC );
-}
 
 if ( pGraphics == mpThreadGraphics )
 pSalData->mnCacheDCInUse++;
@@ -4153,8 +4150,7 @@ static void ImplHandleForcePalette( HWND hWnd )
 WinSalGraphics* pGraphics = pFrame->mpLocalGraphics;
 if (pGraphics->getDefPal())
 {
-pGraphics->setPalette(hPal, FALSE);
-if ( RealizePalette( pGraphics->getHDC() ) )
+if (pGraphics->setPalette(hPal, FALSE) != GDI_ERROR)
 {
 InvalidateRect( hWnd, nullptr, FALSE );
 UpdateWindow( hWnd );
@@ -4209,7 +4205,7 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, 
UINT nMsg,
 WinSalGraphics* pGraphics;
 HDC hDC;
 HPALETTE hOldPal = nullptr;
-UINTnCols;
+UINT nCols = GDI_ERROR;
 boolbUpdate;
 
 pSalData->mbInPalChange = true;
@@ -4241,15 +4237,16 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND 
hWnd, UINT nMsg,
 {
 hDC = GetDC(hWnd);
 hOldPal = SelectPalette(hDC, hPal, TRUE);
+if (hOldPal)
+nCols = RealizePalette(hDC);
 }
 else
 {
 hDC = pFrame->mpLocalGraphics->getHDC();
-pFrame->mpLocalGraphics->setPalette(hPal);
+nCols = pFrame->mpLocalGraphics->setPalette(hPal);
 }
 
-nCols = RealizePalette( hDC );
-bUpdate = nCols != 0;
+bUpdate = nCols != 0 && nCols != GDI_ERROR;
 
 if ( !bStdDC )
 {
@@ -4264,22 +4261,20 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND 
hWnd, UINT nMsg,
 {
 pGraphics = pTempVD->getGraphics();
 if ( pGraphics->getDefPal() )
-{
 pGraphics->setPalette(hPal);
-RealizePalette( pGraphics->getHDC() );
-}
 pTempVD = pTempVD->getNext();
 }
+
 pTempFrame = pSalData->mpFirstFrame;
 while ( pTempFrame )
 {
 if ( pTempFrame != pFrame )
 {
 pGraphics = pTempFrame->mpLocalGraphics;
-if ( pGraphics && pGraphics->getHDC() && 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2021-09-25 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/win/salgdi.h|2 -
 vcl/win/gdi/salgdi.cxx  |   25 +--
 vcl/win/gdi/salvd.cxx   |4 ---
 vcl/win/window/salframe.cxx |   47 +---
 4 files changed, 44 insertions(+), 34 deletions(-)

New commits:
commit 398ae49ba337a2d2c32611f371132c978cf4db64
Author: Jan-Marek Glogowski 
AuthorDate: Wed Sep 15 17:32:49 2021 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Sat Sep 25 17:44:33 2021 +0200

WIN handle graphics palette with deinit

Manually setting the default palette of the graphics DC seems to
be a bad idea. And I think this fixes a real bug in
ImplHandlePalette, because that would set the graphics DC palette
but didn't set the default palette using setDefPal.

Change-Id: Ic3b176645c68fa33a020791d5b64b04c3cbaacee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122158
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index f43224a861a4..0f5b700cff26 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -177,7 +177,7 @@ public:
 void setHDC(HDC aNew);
 
 HPALETTE getDefPal() const;
-void setDefPal(HPALETTE hDefPal);
+void setPalette(HPALETTE, BOOL bForceBkgd = TRUE);
 
 HRGN getRegion() const;
 
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 43536de1fb01..6bd510b6effa 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -495,6 +495,7 @@ void WinSalGraphics::DeInitGraphics()
 SelectFont( getHDC(), mhDefFont );
 mhDefFont = nullptr;
 }
+setPalette(nullptr);
 
 mpImpl->DeInit();
 }
@@ -700,12 +701,32 @@ void WinSalGraphics::setHWND(HWND hWnd)
 
 HPALETTE WinSalGraphics::getDefPal() const
 {
+assert(getHDC() || !mhDefPal);
 return mhDefPal;
 }
 
-void WinSalGraphics::setDefPal(HPALETTE hDefPal)
+void WinSalGraphics::setPalette(HPALETTE hNewPal, BOOL bForceBkgd)
 {
-mhDefPal = hDefPal;
+if (!getHDC())
+{
+assert(!mhDefPal);
+return;
+}
+
+if (hNewPal)
+{
+HPALETTE hOldPal = SelectPalette(getHDC(), hNewPal, bForceBkgd);
+if (!mhDefPal)
+mhDefPal = hOldPal;
+}
+else
+{
+if (mhDefPal)
+{
+SelectPalette(getHDC(), mhDefPal, bForceBkgd);
+mhDefPal = nullptr;
+}
+}
 }
 
 HRGN WinSalGraphics::getRegion() const
diff --git a/vcl/win/gdi/salvd.cxx b/vcl/win/gdi/salvd.cxx
index 679a32a576cd..7b3e7e11fc5c 100644
--- a/vcl/win/gdi/salvd.cxx
+++ b/vcl/win/gdi/salvd.cxx
@@ -129,7 +129,7 @@ std::unique_ptr 
WinSalInstance::CreateVirtualDevice( SalGraphi
 
 if ( pSalData->mhDitherPal && pVirGraphics->isScreen() )
 {
-pVirGraphics->setDefPal(SelectPalette( hDC, pSalData->mhDitherPal, 
TRUE ));
+pVirGraphics->setPalette(pSalData->mhDitherPal);
 RealizePalette( hDC );
 }
 
@@ -172,8 +172,6 @@ WinSalVirtualDevice::~WinSalVirtualDevice()
 // restore the mpGraphics' original HDC values, so the HDC can be deleted 
in the !mbForeignDC case
 mpGraphics->setHDC(nullptr);
 
-if( mpGraphics->getDefPal() )
-SelectPalette(hDC, mpGraphics->getDefPal(), TRUE);
 if( mhDefBmp )
 SelectBitmap(hDC, mhDefBmp);
 if( !mbForeignDC )
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index d38b0296f3e3..e995cae356d4 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -913,8 +913,6 @@ bool WinSalFrame::ReleaseFrameGraphicsDC( WinSalGraphics* 
pGraphics )
 HDC hDC = pGraphics->getHDC();
 if ( !hDC )
 return false;
-if ( pGraphics->getDefPal() )
-SelectPalette( hDC, pGraphics->getDefPal(), TRUE );
 pGraphics->setHDC(nullptr);
 SendMessageW( pSalData->mpInstance->mhComWnd, SAL_MSG_RELEASEDC,
 reinterpret_cast(mhWnd), reinterpret_cast(hDC) );
@@ -995,7 +993,7 @@ bool WinSalFrame::InitFrameGraphicsDC( WinSalGraphics 
*pGraphics, HDC hDC, HWND
 
 if ( pSalData->mhDitherPal )
 {
-pGraphics->setDefPal(SelectPalette( hDC, pSalData->mhDitherPal, TRUE 
));
+pGraphics->setPalette(pSalData->mhDitherPal);
 RealizePalette( hDC );
 }
 
@@ -4155,7 +4153,7 @@ static void ImplHandleForcePalette( HWND hWnd )
 WinSalGraphics* pGraphics = pFrame->mpLocalGraphics;
 if (pGraphics->getDefPal())
 {
-SelectPalette( pGraphics->getHDC(), hPal, FALSE );
+pGraphics->setPalette(hPal, FALSE);
 if ( RealizePalette( pGraphics->getHDC() ) )
 {
 InvalidateRect( hWnd, nullptr, FALSE );
@@ -4210,9 +4208,8 @@ static LRESULT ImplHandlePalette( bool bFrame, HWND hWnd, 
UINT nMsg,
 WinSalFrame*pTempFrame;
 WinSalGraphics* pGraphics;
 HDC hDC;
-HPALETTEhOldPal;
+HPALETTE hOldPal = nullptr;
 UINT  

[Libreoffice-commits] core.git: vcl/inc vcl/win

2021-09-25 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/win/salprn.h   |2 +-
 vcl/win/gdi/salprn.cxx |7 +++
 2 files changed, 4 insertions(+), 5 deletions(-)

New commits:
commit 3d897530d4cd24e2739c81a39984015b192d110e
Author: Jan-Marek Glogowski 
AuthorDate: Mon Sep 20 18:11:19 2021 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Sat Sep 25 16:08:44 2021 +0200

WIN WinSalPrinter::isValid implies a valid HDC

Change-Id: I7a8bb9fc75165ac1dcd49f14ae983b6eefe8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122372
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/salprn.h b/vcl/inc/win/salprn.h
index c2a47ebb941f..209f064fd157 100644
--- a/vcl/inc/win/salprn.h
+++ b/vcl/inc/win/salprn.h
@@ -105,7 +105,7 @@ public:
 virtual SalPrinterError GetErrorCode() override;
 
 void markInvalid();
-bool isValid() const { return mbValid; }
+bool isValid() const { return mbValid && mhDC; }
 };
 
 #endif // INCLUDED_VCL_INC_WIN_SALPRN_H
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 9e20e0dbb4c9..19e61d08ed03 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -1387,7 +1387,6 @@ WinSalPrinter::~WinSalPrinter()
 
 pTempPrinter->mpNextPrinter = mpNextPrinter;
 }
-mbValid = false;
 }
 
 void WinSalPrinter::markInvalid()
@@ -1527,7 +1526,7 @@ void WinSalPrinter::DoEndDoc(HDC hDC)
 bool WinSalPrinter::EndJob()
 {
 HDC hDC = mhDC;
-if ( isValid() && hDC )
+if (isValid())
 {
 delete mpGraphics;
 mpGraphics = nullptr;
@@ -1551,7 +1550,7 @@ bool WinSalPrinter::EndJob()
 
 SalGraphics* WinSalPrinter::StartPage( ImplJobSetup* pSetupData, bool 
bNewJobData )
 {
-if( ! isValid() || mhDC == nullptr )
+if (!isValid())
 return nullptr;
 
 HDC hDC = mhDC;
@@ -1594,7 +1593,7 @@ void WinSalPrinter::EndPage()
 delete mpGraphics;
 mpGraphics = nullptr;
 
-if( ! isValid() )
+if (!isValid())
 return;
 
 HDC hDC = mhDC;


[Libreoffice-commits] core.git: vcl/inc vcl/win

2021-09-25 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/win/salgdi.h|8 +---
 vcl/win/gdi/salgdi.cxx  |   24 
 vcl/win/gdi/salprn.cxx  |   34 ++
 vcl/win/gdi/salvd.cxx   |   13 +++--
 vcl/win/window/salframe.cxx |4 +---
 5 files changed, 47 insertions(+), 36 deletions(-)

New commits:
commit 42f9d4335bfa4b7299224801fd7ccdd97ae92fbf
Author: Jan-Marek Glogowski 
AuthorDate: Wed Sep 15 17:24:48 2021 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Sat Sep 25 15:47:55 2021 +0200

WIN always (de-)init WinSalGraphics

Originally I thought the whole (de-)initialization was some kind
of lazy SalGraphics init stuff. But reading the existing code
proved me wrong and every InitGraphics came a few lines after a
setHDC call and DeInitGraphics before deletion or setHDC(nullptr).

$ git grep -n "delete.*pGraph\|setHDC\|InitGraphics" vcl/win/

So just make (De-)Init part of setHDC and drop all the other calls
to (De-)InitGraphics, adding a setHDC(nullptr) to the destructor.

I've also added some questionable asserts, like

assert(pPrinter->mpGraphics->getHDC() == pPrinter->mhDC);

As I read the code, you can have a printer object initialized with
a DC but without graphics, which will be initialized on demand.

But AFAIK it's invalid to have a printer DC != graphics DC.

Then there was the hDC check in WinSalPrinter::EndPage, which is
IMHO not needed. AFAIK there is no way the graphics DC might be
"magically" invalidated, so restoring the old DC values should
always work.

Change-Id: I1b961cfa733263ce773575a728bcce5c7d3e97ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122157
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 3e1cac3a5634..f43224a861a4 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -166,19 +166,21 @@ private:
 RGNDATA*mpStdClipRgnData;   // Cache 
Standard-ClipRegion-Data
 int mnPenWidth; // line width
 
+// just call both from setHDC!
+void InitGraphics();
+void DeInitGraphics();
+
 public:
 HFONT ImplDoSetFont(FontSelectPattern const & i_rFont, const 
PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont);
 
 HDC getHDC() const { return mhLocalDC; }
-void setHDC(HDC aNew) { mhLocalDC = aNew; }
+void setHDC(HDC aNew);
 
 HPALETTE getDefPal() const;
 void setDefPal(HPALETTE hDefPal);
 
 HRGN getRegion() const;
 
-void InitGraphics();
-void DeInitGraphics();
 
 enum Type
 {
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 0e868e516b60..43536de1fb01 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -452,6 +452,9 @@ void ImplUpdateSysColorEntries()
 
 void WinSalGraphics::InitGraphics()
 {
+if (!getHDC())
+return;
+
 // calculate the minimal line width for the printer
 if ( isPrinter() )
 {
@@ -471,19 +474,38 @@ void WinSalGraphics::InitGraphics()
 
 void WinSalGraphics::DeInitGraphics()
 {
+if (!getHDC())
+return;
+
 // clear clip region
 SelectClipRgn( getHDC(), nullptr );
 // select default objects
 if ( mhDefPen )
+{
 SelectPen( getHDC(), mhDefPen );
+mhDefPen = nullptr;
+}
 if ( mhDefBrush )
+{
 SelectBrush( getHDC(), mhDefBrush );
+mhDefBrush = nullptr;
+}
 if ( mhDefFont )
+{
 SelectFont( getHDC(), mhDefFont );
+mhDefFont = nullptr;
+}
 
 mpImpl->DeInit();
 }
 
+void WinSalGraphics::setHDC(HDC aNew)
+{
+DeInitGraphics();
+mhLocalDC = aNew;
+InitGraphics();
+}
+
 HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp )
 {
 SalData*pSalData = GetSalData();
@@ -637,6 +659,8 @@ WinSalGraphics::~WinSalGraphics()
 
 // delete cache data
 delete [] reinterpret_cast(mpStdClipRgnData);
+
+setHDC(nullptr);
 }
 
 SalGraphicsImpl* WinSalGraphics::GetImpl() const
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 0c5057797682..9e20e0dbb4c9 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -1032,7 +1032,6 @@ static WinSalGraphics* ImplCreateSalPrnGraphics( HDC hDC )
 WinSalGraphics* pGraphics = new WinSalGraphics(WinSalGraphics::PRINTER, 
false, nullptr, /* CHECKME */ nullptr);
 pGraphics->SetLayout( SalLayoutFlags::NONE );
 pGraphics->setHDC(hDC);
-pGraphics->InitGraphics();
 return pGraphics;
 }
 
@@ -1044,9 +1043,9 @@ static bool ImplUpdateSalPrnIC( WinSalInfoPrinter* 
pPrinter, const ImplJobSetup*
 
 if ( pPrinter->mpGraphics )
 {
-pPrinter->mpGraphics->DeInitGraphics();
-DeleteDC( pPrinter->mpGraphics->getHDC() );
+assert(pPrinter->mpGraphics->getHDC() == pPrinter->mhDC);
 delete pPrinter->mpGraphics;
+DeleteDC(pPrinter->mhDC);
 }
 
 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2021-05-10 Thread Mark Hung (via logerrit)
 vcl/inc/win/salgdi.h|2 -
 vcl/win/gdi/salfont.cxx |   30 ++--
 vcl/win/gdi/winlayout.cxx   |   46 
 vcl/win/window/salframe.cxx |   12 ---
 4 files changed, 10 insertions(+), 80 deletions(-)

New commits:
commit 5686c1aca40beb9514d40c86b4a3780a8a1334ba
Author: Mark Hung 
AuthorDate: Sun May 2 14:45:45 2021 +0800
Commit: Mark Hung 
CommitDate: Mon May 10 21:14:09 2021 +0200

vcl: use DWriteTextRenderer for vertical writing.

It's really not possible to support vertical writing with old
ExTextOutW API, use DWriteTextRenderer in this case. This also get rid of
the hacks to prepend '@' in front of the font name when it's for vertical
writing.

Change-Id: Icf594dd248be35fb101d6c1e296971f1acf56e39
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115017
Tested-by: Jenkins
Reviewed-by: Mark Hung 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 21f1b46ec016..959d8abc0301 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -392,7 +392,7 @@ public:
 // Init/Deinit Graphics
 voidImplUpdateSysColorEntries();
 int ImplIsSysColorEntry( Color nColor );
-voidImplGetLogFontFromFontSelect( HDC, const FontSelectPattern&,
+voidImplGetLogFontFromFontSelect( const FontSelectPattern&,
 const PhysicalFontFace*, LOGFONTW& );
 
 #define MAX_64KSALPOINTSsal_uInt16)0x)-8)/sizeof(POINTS))
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 39f67e26a057..473f743d3cee 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -195,7 +195,7 @@ bool 
WinGlyphFallbackSubstititution::HasMissingChars(PhysicalFontFace* pFace, OU
 const FontSelectPattern aFSD( *pFace, aSize, 
static_cast(aSize.Height()), 0, false );
 // construct log font
 LOGFONTW aLogFont;
-ImplGetLogFontFromFontSelect( mhDC, aFSD, pFace, aLogFont );
+ImplGetLogFontFromFontSelect( aFSD, pFace, aLogFont );
 
 // create HFONT from log font
 HFONT hNewFont = ::CreateFontIndirectW(  );
@@ -768,8 +768,7 @@ static int CALLBACK SalEnumQueryFontProcExW( const 
LOGFONTW*,
 return 0;
 }
 
-void ImplGetLogFontFromFontSelect( HDC hDC,
-   const FontSelectPattern& rFont,
+void ImplGetLogFontFromFontSelect( const FontSelectPattern& rFont,
const PhysicalFontFace* pFontFace,
LOGFONTW& rLogFont )
 {
@@ -816,29 +815,6 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
 if ( rFont.mbNonAntialiased )
 rLogFont.lfQuality = NONANTIALIASED_QUALITY;
 
-// select vertical mode if requested and available
-if ( rFont.mbVertical && nNameLen )
-{
-// vertical fonts start with an '@'
-memmove( [1], [0],
-sizeof(rLogFont.lfFaceName)-sizeof(rLogFont.lfFaceName[0]) );
-rLogFont.lfFaceName[0] = '@';
-
-// check availability of vertical mode for this font
-bool bAvailable = false;
-EnumFontFamiliesExW( hDC, , SalEnumQueryFontProcExW,
- reinterpret_cast(), 0 );
-
-if( !bAvailable )
-{
-// restore non-vertical name if not vertical mode isn't available
-memcpy( [0], aName.getStr(), 
nNameLen*sizeof(wchar_t) );
-rLogFont.lfFaceName[nNameLen] = '\0';
-// keep it upright and create the font for sideway glyphs later.
-rLogFont.lfEscapement = rLogFont.lfEscapement - 2700;
-rLogFont.lfOrientation = rLogFont.lfEscapement;
-}
-}
 }
 
 HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont,
@@ -848,7 +824,7 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const 
& i_rFont,
 HFONT hNewFont = nullptr;
 
 LOGFONTW aLogFont;
-ImplGetLogFontFromFontSelect( getHDC(), i_rFont, i_pFontFace, aLogFont );
+ImplGetLogFontFromFontSelect( i_rFont, i_pFontFace, aLogFont );
 
 hNewFont = ::CreateFontIndirectW(  );
 
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 0f82d1af5bc6..c0fe1e32b863 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -80,53 +80,13 @@ TextOutRenderer& TextOutRenderer::get(bool bUseDWrite)
 bool ExTextOutRenderer::operator()(GenericSalLayout const& rLayout, 
SalGraphics& /*rGraphics*/,
HDC hDC)
 {
-HFONT hFont = static_cast(GetCurrentObject(hDC, OBJ_FONT));
-ScopedHFONT hAltFont;
-bool bUseAltFont = false;
-bool bShift = false;
-if (rLayout.GetFont().GetFontSelectPattern().mbVertical)
-{
-LOGFONTW aLogFont;
-GetObjectW(hFont, sizeof(aLogFont), );
-if (aLogFont.lfFaceName[0] == '@')
-{
-memmove([0], [1],
-sizeof(aLogFont.lfFaceName) - 
sizeof(aLogFont.lfFaceName[0]));
-

[Libreoffice-commits] core.git: vcl/inc vcl/win

2021-05-07 Thread Mark Hung (via logerrit)
 vcl/inc/win/DWriteTextRenderer.hxx |2 +-
 vcl/win/gdi/DWriteTextRenderer.cxx |   14 ++
 2 files changed, 11 insertions(+), 5 deletions(-)

New commits:
commit b35b8079b3f03b93efdaf2d54b4a515df296e71d
Author: Mark Hung 
AuthorDate: Sun May 2 11:28:34 2021 +0800
Commit: Mark Hung 
CommitDate: Sat May 8 06:34:31 2021 +0200

vcl: Rotate glyph in DWriteTextRenderer for vertical writing.

- This is part of the work to make all the text renders
consistently use the positions created from harfbuzz.

- Rotate 90 deg if the glyph is vertical.

Change-Id: I0ef6569cf019ed2cfeec0b7e7b9709a7e8cf8021
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115016
Tested-by: Jenkins
Reviewed-by: Mark Hung 

diff --git a/vcl/inc/win/DWriteTextRenderer.hxx 
b/vcl/inc/win/DWriteTextRenderer.hxx
index 9011a951d277..6e097546d1e2 100644
--- a/vcl/inc/win/DWriteTextRenderer.hxx
+++ b/vcl/inc/win/DWriteTextRenderer.hxx
@@ -88,7 +88,7 @@ private:
 class WinFontTransformGuard
 {
 public:
-WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float fHScale, 
const GenericSalLayout& rLayout, const D2D1_POINT_2F& rBaseline);
+WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float fHScale, 
const GenericSalLayout& rLayout, const D2D1_POINT_2F& rBaseline, bool 
bIsVertical);
 ~WinFontTransformGuard();
 
 private:
diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx 
b/vcl/win/gdi/DWriteTextRenderer.cxx
index abf9be7d5f86..690f569dbeba 100644
--- a/vcl/win/gdi/DWriteTextRenderer.cxx
+++ b/vcl/win/gdi/DWriteTextRenderer.cxx
@@ -268,7 +268,7 @@ bool 
D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
 DWRITE_GLYPH_OFFSET glyphOffsets[] = { { 0.0f, 0.0f }, };
 D2D1_POINT_2F baseline = { static_cast(aPos.X() - 
bounds.Left()) / fHScale,
static_cast(aPos.Y() - 
bounds.Top()) };
-WinFontTransformGuard aTransformGuard(mpRT, fHScale, rLayout, 
baseline);
+WinFontTransformGuard aTransformGuard(mpRT, fHScale, rLayout, 
baseline, pGlyph->IsVertical());
 DWRITE_GLYPH_RUN glyphs = {
 mpFontFace,
 mlfEmHeight,
@@ -389,7 +389,8 @@ bool D2DWriteTextOutRenderer::GetDWriteFaceFromHDC(HDC hDC, 
IDWriteFontFace ** p
 
 WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, 
float fHScale,
  const GenericSalLayout& rLayout,
- const D2D1_POINT_2F& rBaseline)
+ const D2D1_POINT_2F& rBaseline,
+ bool bIsVertical)
 : mpRenderTarget(pRenderTarget)
 {
 pRenderTarget->GetTransform();
@@ -400,13 +401,18 @@ 
WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, f
 = aTransform * D2D1::Matrix3x2F::Scale(D2D1::Size(fHScale, 1.0f), 
D2D1::Point2F(0, 0));
 }
 
-if (rLayout.GetOrientation())
+Degree10 angle = rLayout.GetOrientation();
+
+if (bIsVertical)
+angle += 900_deg10;
+
+if (angle)
 {
 // DWrite angle is in clockwise degrees, our orientation is in 
counter-clockwise 10th
 // degrees.
 aTransform = aTransform
  * D2D1::Matrix3x2F::Rotation(
-   -static_cast(rLayout.GetOrientation().get()) 
/ 10, rBaseline);
+   -static_cast(angle.get()) / 10, rBaseline);
 }
 mpRenderTarget->SetTransform(aTransform);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2021-04-19 Thread Noel Grandin (via logerrit)
 vcl/inc/win/salbmp.h|2 +-
 vcl/win/gdi/gdiimpl.cxx |2 +-
 vcl/win/gdi/salbmp.cxx  |9 +++--
 3 files changed, 5 insertions(+), 8 deletions(-)

New commits:
commit 4bb0afe359a92df09ad5b61b66bc4cb3562aca1e
Author: Noel Grandin 
AuthorDate: Mon Apr 19 14:59:23 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Apr 19 18:39:00 2021 +0200

remove dead code from WinSalBitmap::Create

Change-Id: I345bfba23d6041a631664f5e1dbbe27cd8ba0290
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114271
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/win/salbmp.h b/vcl/inc/win/salbmp.h
index d48203840b76..c8fe3d851011 100644
--- a/vcl/inc/win/salbmp.h
+++ b/vcl/inc/win/salbmp.h
@@ -63,7 +63,7 @@ public:
 
 public:
 
-boolCreate( HANDLE hBitmap, bool bDIB, bool 
bCopyHandle );
+boolCreate( HANDLE hBitmap );
 virtual boolCreate( const Size& rSize, vcl::PixelFormat 
ePixelFormat, const BitmapPalette& rPal ) override;
 virtual boolCreate( const SalBitmap& rSalBmpImpl ) 
override;
 virtual boolCreate( const SalBitmap& rSalBmpImpl, 
SalGraphics* pGraphics ) override;
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index d67e04be765f..2c418732561b 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -820,7 +820,7 @@ std::shared_ptr WinSalGraphicsImpl::getBitmap( 
tools::Long nX, tools:
 {
 pSalBitmap = std::make_shared();
 
-if( !pSalBitmap->Create( hBmpBitmap, false, false ) )
+if( !pSalBitmap->Create( hBmpBitmap ) )
 {
 pSalBitmap.reset();
 }
diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx
index ed35d7b6d3da..0218ca408eec 100644
--- a/vcl/win/gdi/salbmp.cxx
+++ b/vcl/win/gdi/salbmp.cxx
@@ -459,14 +459,11 @@ std::shared_ptr 
WinSalBitmap::ImplCreateGdiPlusBitmap(const Win
 return pRetval;
 }
 
-bool WinSalBitmap::Create( HANDLE hBitmap, bool bDIB, bool bCopyHandle )
+bool WinSalBitmap::Create( HANDLE hBitmap )
 {
 bool bRet = true;
 
-if( bDIB )
-mhDIB = static_cast( bCopyHandle ? ImplCopyDIBOrDDB( hBitmap, 
true ) : hBitmap );
-else
-mhDDB = static_cast( bCopyHandle ? ImplCopyDIBOrDDB( hBitmap, 
false ) : hBitmap );
+mhDDB = static_cast( hBitmap );
 
 if( mhDIB )
 {
@@ -656,7 +653,7 @@ bool WinSalBitmap::Create( const css::uno::Reference< 
css::rendering::XBitmapCan
 sal_Int64 aHBmp64;
 
 if( args[0] >>= aHBmp64 ) {
-return Create( reinterpret_cast(aHBmp64), false, false 
);
+return Create( reinterpret_cast(aHBmp64) );
 }
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2021-02-24 Thread Noel Grandin (via logerrit)
 vcl/inc/win/salbmp.h   |4 ++--
 vcl/win/gdi/salbmp.cxx |   22 ++
 2 files changed, 12 insertions(+), 14 deletions(-)

New commits:
commit e7c723765c90b4a6d1918f6964d15f101b80a88e
Author: Noel Grandin 
AuthorDate: Wed Feb 24 10:15:36 2021 +0200
Commit: Noel Grandin 
CommitDate: Wed Feb 24 19:21:25 2021 +0100

use unique_ptr in WinSalBitmap

Change-Id: I3c536b766d35b3137d79739c232d0d5cff3652b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111446
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/win/salbmp.h b/vcl/inc/win/salbmp.h
index d6acd14e8c7d..80ddb38bfd9e 100644
--- a/vcl/inc/win/salbmp.h
+++ b/vcl/inc/win/salbmp.h
@@ -42,8 +42,8 @@ private:
 
 sal_uInt16  mnBitCount;
 
-Gdiplus::Bitmap*ImplCreateGdiPlusBitmap(const WinSalBitmap& 
rAlphaSource);
-Gdiplus::Bitmap*ImplCreateGdiPlusBitmap();
+std::unique_ptrImplCreateGdiPlusBitmap(const 
WinSalBitmap& rAlphaSource);
+std::unique_ptr ImplCreateGdiPlusBitmap();
 
 public:
 
diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx
index 2f427cc5e70d..b0dffd5394dd 100644
--- a/vcl/win/gdi/salbmp.cxx
+++ b/vcl/win/gdi/salbmp.cxx
@@ -214,12 +214,12 @@ std::shared_ptr< Gdiplus::Bitmap > 
WinSalBitmap::ImplGetGdiPlusBitmap(const WinS
 
 if(pAlphaSource)
 {
-aRetval.reset(const_cast< WinSalBitmap* 
>(this)->ImplCreateGdiPlusBitmap(*pAlphaSource));
+aRetval = const_cast< WinSalBitmap* 
>(this)->ImplCreateGdiPlusBitmap(*pAlphaSource);
 pAssociatedAlpha = pAlphaSource;
 }
 else
 {
-aRetval.reset(const_cast< WinSalBitmap* 
>(this)->ImplCreateGdiPlusBitmap());
+aRetval = const_cast< WinSalBitmap* 
>(this)->ImplCreateGdiPlusBitmap();
 pAssociatedAlpha = nullptr;
 }
 
@@ -233,9 +233,9 @@ std::shared_ptr< Gdiplus::Bitmap > 
WinSalBitmap::ImplGetGdiPlusBitmap(const WinS
 return aRetval;
 }
 
-Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
+std::unique_ptr WinSalBitmap::ImplCreateGdiPlusBitmap()
 {
-Gdiplus::Bitmap* pRetval(nullptr);
+std::unique_ptr pRetval;
 WinSalBitmap* pSalRGB = this;
 std::unique_ptr pExtraWinSalRGB;
 
@@ -271,7 +271,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
 const sal_uInt32 nW(pRGB->mnWidth);
 const sal_uInt32 nH(pRGB->mnHeight);
 
-pRetval = new Gdiplus::Bitmap(nW, nH, PixelFormat24bppRGB);
+pRetval.reset(new Gdiplus::Bitmap(nW, nH, PixelFormat24bppRGB));
 
 if ( pRetval->GetLastStatus() == Gdiplus::Ok )
 {
@@ -296,8 +296,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
 }
 else
 {
-delete pRetval;
-pRetval = nullptr;
+pRetval.reset();
 }
 }
 
@@ -316,9 +315,9 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
 return pRetval;
 }
 
-Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& 
rAlphaSource)
+std::unique_ptr WinSalBitmap::ImplCreateGdiPlusBitmap(const 
WinSalBitmap& rAlphaSource)
 {
-Gdiplus::Bitmap* pRetval(nullptr);
+std::unique_ptr pRetval;
 WinSalBitmap* pSalRGB = this;
 std::unique_ptr pExtraWinSalRGB;
 
@@ -389,7 +388,7 @@ Gdiplus::Bitmap* 
WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
 const sal_uInt32 nW(pRGB->mnWidth);
 const sal_uInt32 nH(pRGB->mnHeight);
 
-pRetval = new Gdiplus::Bitmap(nW, nH, PixelFormat32bppARGB);
+pRetval.reset(new Gdiplus::Bitmap(nW, nH, PixelFormat32bppARGB));
 
 if ( pRetval->GetLastStatus() == Gdiplus::Ok ) // 2nd place to secure 
with new Gdiplus::Bitmap
 {
@@ -425,8 +424,7 @@ Gdiplus::Bitmap* 
WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
 }
 else
 {
-delete pRetval;
-pRetval = nullptr;
+pRetval.reset();
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2020-11-27 Thread Stephan Bergmann (via logerrit)
 vcl/inc/win/salframe.h  |4 ++--
 vcl/win/window/salframe.cxx |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit f4a021a196e8f71b92d9e6b4021a99526cb5cc72
Author: Stephan Bergmann 
AuthorDate: Fri Nov 27 11:15:07 2020 +0100
Commit: Stephan Bergmann 
CommitDate: Fri Nov 27 14:27:21 2020 +0100

WinSalFrame::mnWidth/Height should presumably be of type LONG

...as they are only ever set to LO-/HIWORD values cast to a signed integer 
type

Change-Id: I82f9a80bab7c3b7e3ee5545725efd0d88601b8c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106755
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h
index 05f907dc66b9..5068ecd987aa 100644
--- a/vcl/inc/win/salframe.h
+++ b/vcl/inc/win/salframe.h
@@ -41,8 +41,8 @@ public:
 SystemEnvData   maSysData;  // system data
 SalFrameState   maState = {};   // frame state
 int mnShowState;// show state
-longmnWidth;// client width in pixeln
-longmnHeight;   // client height in pixeln
+LONGmnWidth;// client width in pixeln
+LONGmnHeight;   // client height in pixeln
 int mnMinWidth; // min. client width in 
pixeln
 int mnMinHeight;// min. client height in 
pixeln
 int mnMaxWidth; // max. client width in 
pixeln
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 34a569be39ab..3454ebf885c8 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -4025,8 +4025,8 @@ static void ImplHandleSizeMsg( HWND hWnd, WPARAM wParam, 
LPARAM lParam )
 {
 UpdateFrameGeometry( hWnd, pFrame );
 
-pFrame->mnWidth  = static_cast(LOWORD(lParam));
-pFrame->mnHeight = static_cast(HIWORD(lParam));
+pFrame->mnWidth  = static_cast(LOWORD(lParam));
+pFrame->mnHeight = static_cast(HIWORD(lParam));
 // save state
 ImplSaveFrameState( pFrame );
 // Call Hdl
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2020-10-19 Thread Noel Grandin (via logerrit)
 vcl/inc/win/salgdi.h  |2 +-
 vcl/win/gdi/salfont.cxx   |   31 +++
 vcl/win/gdi/winlayout.cxx |2 +-
 3 files changed, 5 insertions(+), 30 deletions(-)

New commits:
commit 6137de745606e9ccee94119fd1f8b7a90c4aa323
Author: Noel Grandin 
AuthorDate: Mon Sep 21 15:47:31 2020 +0200
Commit: Noel Grandin 
CommitDate: Mon Oct 19 12:20:44 2020 +0200

tdf#127047 fix printing very large font sizes to pdf

The clamping of font sizes was done in #i47675 and #i95867
to deal with issues in the Windows font libraries which are
presumably no longer a problem.

Change-Id: I124a3ff746953ce4d7d934506e76e6d0cba48307
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103113
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index a717286737c0..bec473b296b4 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -184,7 +184,7 @@ private:
 bool DrawCachedGlyphs(const GenericSalLayout& rLayout);
 
 public:
-HFONT ImplDoSetFont(FontSelectPattern const & i_rFont, const 
PhysicalFontFace * i_pFontFace, float& o_rFontScale, HFONT& o_rOldFont);
+HFONT ImplDoSetFont(FontSelectPattern const & i_rFont, const 
PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont);
 
 HDC getHDC() const { return mhLocalDC; }
 void setHDC(HDC aNew) { mhLocalDC = aNew; }
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 3f6082a6b92d..f37ae89a00a8 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -65,8 +65,6 @@
 
 using namespace vcl;
 
-const int MAXFONTHEIGHT = 2048;
-
 static FIXED FixedFromDouble( double d )
 {
 const long l = static_cast( d * 65536. );
@@ -846,7 +844,6 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
 
 HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont,
 const PhysicalFontFace * i_pFontFace,
-float& o_rFontScale,
 HFONT& o_rOldFont)
 {
 HFONT hNewFont = nullptr;
@@ -854,25 +851,6 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern 
const & i_rFont,
 LOGFONTW aLogFont;
 ImplGetLogFontFromFontSelect( getHDC(), i_rFont, i_pFontFace, aLogFont );
 
-// #i47675# limit font requests to MAXFONTHEIGHT
-// TODO: share MAXFONTHEIGHT font instance
-if( (-aLogFont.lfHeight <= MAXFONTHEIGHT)
-&&  (+aLogFont.lfWidth <= MAXFONTHEIGHT) )
-{
-o_rFontScale = 1.0;
-}
-else if( -aLogFont.lfHeight >= +aLogFont.lfWidth )
-{
-o_rFontScale = -aLogFont.lfHeight / float(MAXFONTHEIGHT);
-aLogFont.lfHeight = -MAXFONTHEIGHT;
-aLogFont.lfWidth = FRound( aLogFont.lfWidth / o_rFontScale );
-}
-else // #i95867# also limit font widths
-{
-o_rFontScale = +aLogFont.lfWidth / float(MAXFONTHEIGHT);
-aLogFont.lfWidth = +MAXFONTHEIGHT;
-aLogFont.lfHeight = FRound( aLogFont.lfHeight / o_rFontScale );
-}
 hNewFont = ::CreateFontIndirectW(  );
 
 HDC hdcScreen = nullptr;
@@ -1579,9 +1557,8 @@ bool WinSalGraphics::CreateFontSubset( const OUString& 
rToFile,
 
 // TODO: much better solution: move SetFont and restoration of old font to 
caller
 ScopedFont aOldFont(*this);
-float fScale = 1.0;
 HFONT hOldFont = nullptr;
-ImplDoSetFont(aIFSD, pFont, fScale, hOldFont);
+ImplDoSetFont(aIFSD, pFont, hOldFont);
 
 WinFontFace const * pWinFontData = static_cast(pFont);
 
@@ -1645,9 +1622,8 @@ const void* WinSalGraphics::GetEmbedFontData(const 
PhysicalFontFace* pFont, long
 
 ScopedFont aOldFont(*this);
 
-float fScale = 0.0;
 HFONT hOldFont = nullptr;
-ImplDoSetFont(aIFSD, pFont, fScale, hOldFont);
+ImplDoSetFont(aIFSD, pFont, hOldFont);
 
 // get the raw font file data
 RawFontData aRawFontData( getHDC() );
@@ -1676,9 +1652,8 @@ void WinSalGraphics::GetGlyphWidths( const 
PhysicalFontFace* pFont,
 // TODO: much better solution: move SetFont and restoration of old font to 
caller
 ScopedFont aOldFont(*this);
 
-float fScale = 0.0;
 HFONT hOldFont = nullptr;
-ImplDoSetFont(aIFSD, pFont, fScale, hOldFont);
+ImplDoSetFont(aIFSD, pFont, hOldFont);
 
 // get raw font file data
 const RawFontData xRawFontData( getHDC() );
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 3438e3b79deb..feda998d5759 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -448,7 +448,7 @@ void WinFontInstance::SetGraphics(WinSalGraphics *pGraphics)
 if (m_hFont)
 return;
 HFONT hOrigFont;
-m_hFont = m_pGraphics->ImplDoSetFont(GetFontSelectPattern(), 
GetFontFace(), m_fScale, hOrigFont);
+m_hFont = m_pGraphics->ImplDoSetFont(GetFontSelectPattern(), 
GetFontFace(), hOrigFont);
 SelectObject(m_pGraphics->getHDC(), hOrigFont);
 }
 
___
Libreoffice-commits mailing 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2020-09-10 Thread Julien Nabet (via logerrit)
 vcl/inc/win/salprn.h   |2 +-
 vcl/win/gdi/salprn.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 8cd8cdcfa54ca34dc6365a398e3c69cbfc685891
Author: Julien Nabet 
AuthorDate: Thu Sep 10 09:38:36 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Sep 10 13:36:31 2020 +0200

tdf#75280: Convert some inappropriate use of sal_uIntPtr (+sal_uLong) (vcl)

Change-Id: I8708cb825fbfe8de201a2025b7f988a1db9302ab
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102361
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/vcl/inc/win/salprn.h b/vcl/inc/win/salprn.h
index c0c6e7fb7932..44b88525812e 100644
--- a/vcl/inc/win/salprn.h
+++ b/vcl/inc/win/salprn.h
@@ -78,7 +78,7 @@ public:
 WinSalPrinter*  mpNextPrinter;  // next printing printer
 HDC mhDC;   // printer hdc
 SalPrinterError mnError;// error code
-sal_uIntPtr mnCopies;   // copies
+sal_uInt32  mnCopies;   // copies
 boolmbCollate;  // collated copies
 boolmbAbort;// Job Aborted
 
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 3f27d999d845..9d205b1d9daf 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -1319,7 +1319,7 @@ static BOOL CALLBACK SalPrintAbortProc( HDC hPrnDC, int 
/* nError */ )
 return TRUE;
 }
 
-static DEVMODEW const * ImplSalSetCopies( DEVMODEW const * pDevMode, sal_uLong 
nCopies, bool bCollate )
+static DEVMODEW const * ImplSalSetCopies( DEVMODEW const * pDevMode, 
sal_uInt32 nCopies, bool bCollate )
 {
 if ( pDevMode && (nCopies > 1) )
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2020-05-22 Thread Luboš Luňák (via logerrit)
 vcl/inc/skia/salbmp.hxx |1 +
 vcl/win/gdi/salgdi2.cxx |   19 +++
 2 files changed, 16 insertions(+), 4 deletions(-)

New commits:
commit aff8471dbffdd6d26e63533d7ffa8ddea6b2396b
Author: Luboš Luňák 
AuthorDate: Thu May 21 15:02:37 2020 +
Commit: Luboš Luňák 
CommitDate: Fri May 22 13:25:56 2020 +0200

convert properly SkiaSalBitmap to WinSalBitmap (tdf#133152)

The code didn't account for topdown bitmaps.

Change-Id: Ia326834cfd6d2d022579fdde24828f7e0a8d8b3e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94643
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx
index 7eb2a8eb72a6..0761217d4eb9 100644
--- a/vcl/inc/skia/salbmp.hxx
+++ b/vcl/inc/skia/salbmp.hxx
@@ -60,6 +60,7 @@ public:
 virtual bool InterpretAs8Bit() override;
 virtual bool ConvertToGreyscale() override;
 
+const BitmapPalette& Palette() const { return mPalette; }
 // Returns the contents as SkImage (possibly GPU-backed).
 const sk_sp& GetSkImage() const;
 
diff --git a/vcl/win/gdi/salgdi2.cxx b/vcl/win/gdi/salgdi2.cxx
index 6ccf3140c169..fdac864d0f32 100644
--- a/vcl/win/gdi/salgdi2.cxx
+++ b/vcl/win/gdi/salgdi2.cxx
@@ -43,6 +43,7 @@
 #include 
 #if HAVE_FEATURE_SKIA
 #include 
+#include 
 #endif
 
 
@@ -113,6 +114,10 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, 
WinSalBitmap& rWinSalBitmap)
 {
 aBitmapPalette = pGLSalBitmap->GetBitmapPalette();
 }
+#if HAVE_FEATURE_SKIA
+if(SkiaSalBitmap* pSkiaSalBitmap = 
dynamic_cast())
+aBitmapPalette = pSkiaSalBitmap->Palette();
+#endif
 
 BitmapBuffer* pRead = rSalBitmap.AcquireBuffer(BitmapAccessMode::Read);
 
@@ -121,13 +126,19 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, 
WinSalBitmap& rWinSalBitmap)
 
 sal_uInt8* pSource(pRead->mpBits);
 sal_uInt8* pDestination(pWrite->mpBits);
+long readRowChange = pRead->mnScanlineSize;
+if(pRead->mnFormat & ScanlineFormat::TopDown)
+{
+pSource += pRead->mnScanlineSize * (pRead->mnHeight - 1);
+readRowChange = -readRowChange;
+}
 
 std::unique_ptr pConverter;
 
-if (pRead->mnFormat == ScanlineFormat::N24BitTcRgb)
+if (RemoveScanline(pRead->mnFormat) == ScanlineFormat::N24BitTcRgb)
 pConverter.reset(new 
ColorScanlineConverter(ScanlineFormat::N24BitTcRgb,
 3, pRead->mnScanlineSize));
-else if (pRead->mnFormat == ScanlineFormat::N32BitTcRgba)
+else if (RemoveScanline(pRead->mnFormat) == ScanlineFormat::N32BitTcRgba)
 pConverter.reset(new 
ColorScanlineConverter(ScanlineFormat::N32BitTcRgba,
 4, pRead->mnScanlineSize));
 if (pConverter)
@@ -135,7 +146,7 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, 
WinSalBitmap& rWinSalBitmap)
 for (long y = 0; y < pRead->mnHeight; y++)
 {
 pConverter->convertScanline(pSource, pDestination);
-pSource += pRead->mnScanlineSize;
+pSource += readRowChange;
 pDestination += pWrite->mnScanlineSize;
 }
 }
@@ -144,7 +155,7 @@ void convertToWinSalBitmap(SalBitmap& rSalBitmap, 
WinSalBitmap& rWinSalBitmap)
 for (long y = 0; y < pRead->mnHeight; y++)
 {
 memcpy(pDestination, pSource, pRead->mnScanlineSize);
-pSource += pRead->mnScanlineSize;
+pSource += readRowChange;
 pDestination += pWrite->mnScanlineSize;
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2019-07-05 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/win/saldata.hxx |5 +++--
 vcl/win/app/salinst.cxx |3 ++-
 vcl/win/gdi/salfont.cxx |   39 ---
 vcl/win/gdi/salgdi.cxx  |7 ---
 4 files changed, 37 insertions(+), 17 deletions(-)

New commits:
commit 8e63934c398dd5065f3589c8a7d1b3008f5514d1
Author: Jan-Marek Glogowski 
AuthorDate: Thu Jul 4 19:24:06 2019 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Fri Jul 5 19:38:31 2019 +0200

WIN separate LO shared and embedded fonts

This way we can get rid of the embedded fonts without the reqirement
to re-process all of LO's shared fonts.

Change-Id: I25661a611d43ae05052e5cb9cc21e74ccd06b172
Reviewed-on: https://gerrit.libreoffice.org/75101
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 00f7c787bbea..dd08b7553734 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -108,7 +108,8 @@ public:
 DWORD   mnAppThreadId;  // Id from 
Application-Thread
 BOOLmbScrSvrEnabled;// ScreenSaver enabled
 SalIcon*mpFirstIcon;// icon cache, points to 
first icon, NULL if none
-TempFontItem*   mpTempFontItem;
+TempFontItem*   mpSharedTempFontItem;   // LibreOffice shared fonts
+TempFontItem*   mpOtherTempFontItem;// other temporary fonts 
(embedded?)
 boolmbThemeChanged; // true if visual theme 
was changed: throw away theme handles
 boolmbThemeMenuSupport;
 
@@ -156,7 +157,7 @@ void ImplClearHDCCache( SalData* pData );
 HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp = nullptr );
 void ImplReleaseCachedDC( sal_uLong nID );
 
-void ImplReleaseTempFonts( SalData& );
+void ImplReleaseTempFonts(SalData&, bool bAll);
 
 HCURSOR ImplLoadSalCursor( int nId );
 HBITMAP ImplLoadSalBitmap( int nId );
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index c4a290adb092..3a5fd78f743b 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -289,7 +289,8 @@ SalData::SalData()
 mnAppThreadId = 0;  // Id from Application-Thread
 mbScrSvrEnabled = FALSE;// ScreenSaver enabled
 mpFirstIcon = nullptr;  // icon cache, points to first icon, NULL if 
none
-mpTempFontItem = nullptr;
+mpSharedTempFontItem = nullptr;
+mpOtherTempFontItem = nullptr;
 mbThemeChanged = false; // true if visual theme was changed: throw 
away theme handles
 mbThemeMenuSupport = false;
 
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 4ea93e96ce33..0dfd4fdc62a1 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -1060,7 +1060,7 @@ struct TempFontItem
 TempFontItem* mpNextItem;
 };
 
-static int lcl_AddFontResource(SalData& rSalData, const OUString& rFontFileURL)
+static int lcl_AddFontResource(SalData& rSalData, const OUString& 
rFontFileURL, bool bShared)
 {
 OUString aFontSystemPath;
 OSL_VERIFY(!osl::FileBase::getSystemPathFromFileURL(rFontFileURL, 
aFontSystemPath));
@@ -1071,19 +1071,36 @@ static int lcl_AddFontResource(SalData& rSalData, const 
OUString& rFontFileURL)
 {
 TempFontItem* pNewItem = new TempFontItem;
 pNewItem->maFontResourcePath = aFontSystemPath;
-pNewItem->mpNextItem = rSalData.mpTempFontItem;
-rSalData.mpTempFontItem = pNewItem;
+if (bShared)
+{
+pNewItem->mpNextItem = rSalData.mpSharedTempFontItem;
+rSalData.mpSharedTempFontItem = pNewItem;
+}
+else
+{
+pNewItem->mpNextItem = rSalData.mpOtherTempFontItem;
+rSalData.mpOtherTempFontItem = pNewItem;
+}
 }
 return nRet;
 }
 
-void ImplReleaseTempFonts( SalData& rSalData )
+void ImplReleaseTempFonts(SalData& rSalData, bool bAll)
 {
-while (TempFontItem* p = rSalData.mpTempFontItem)
+while (TempFontItem* p = rSalData.mpOtherTempFontItem)
+{
+RemoveFontResourceExW(o3tl::toW(p->maFontResourcePath.getStr()), 
FR_PRIVATE, nullptr);
+rSalData.mpOtherTempFontItem = p->mpNextItem;
+delete p;
+}
+
+if (!bAll)
+return;
+
+while (TempFontItem* p = rSalData.mpSharedTempFontItem)
 {
-RemoveFontResourceExW(o3tl::toW(p->maFontResourcePath.getStr()),
-  FR_PRIVATE, nullptr);
-rSalData.mpTempFontItem = p->mpNextItem;
+RemoveFontResourceExW(o3tl::toW(p->maFontResourcePath.getStr()), 
FR_PRIVATE, nullptr);
+rSalData.mpSharedTempFontItem = p->mpNextItem;
 delete p;
 }
 }
@@ -1196,7 +1213,7 @@ bool 
WinSalGraphics::AddTempDevFont(PhysicalFontCollection* pFontCollection,
 return false;
 }
 
-int nFonts = lcl_AddFontResource(*GetSalData(), rFontFileURL);
+int nFonts = lcl_AddFontResource(*GetSalData(), rFontFileURL, false);
 if (nFonts 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2019-07-05 Thread Jan-Marek Glogowski (via logerrit)
 vcl/inc/win/saldata.hxx |1 -
 vcl/win/gdi/salfont.cxx |   39 ---
 2 files changed, 20 insertions(+), 20 deletions(-)

New commits:
commit 7dd44125a9c184c21374a47005e303579179805f
Author: Jan-Marek Glogowski 
AuthorDate: Thu Jul 4 01:45:11 2019 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Fri Jul 5 19:38:01 2019 +0200

WIN don't register LO's shared fonts twice

This separates the system registration (AddFontResourceEx) of
LO's shared fonts from the later PhysicalFontCollection
population using EnumFontFamiliesEx.

Calling AddTempDevFont from GetDevFontList creates a new
WinFontFaces, but the later EnumFontFamiliesEx also creates
WinFontFaces for all registered fonts, resulting in duplicate
WinFontFace entries in the PhysicalFontCollection.

Also currently the provided WinFontFace from AddTempDevFont is
much less accurate, compated to the EnumFontFamiliesEx one.

Change-Id: I2cd8af77197429508d0a7112ff98706d7f449659
Reviewed-on: https://gerrit.libreoffice.org/75067
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 74be79774db5..00f7c787bbea 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -156,7 +156,6 @@ void ImplClearHDCCache( SalData* pData );
 HDC ImplGetCachedDC( sal_uLong nID, HBITMAP hBmp = nullptr );
 void ImplReleaseCachedDC( sal_uLong nID );
 
-bool ImplAddTempFont( SalData&, const OUString& rFontFileURL );
 void ImplReleaseTempFonts( SalData& );
 
 HCURSOR ImplLoadSalCursor( int nId );
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index fcdbb6484dda..4ea93e96ce33 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -1060,22 +1060,21 @@ struct TempFontItem
 TempFontItem* mpNextItem;
 };
 
-bool ImplAddTempFont( SalData& rSalData, const OUString& rFontFileURL )
+static int lcl_AddFontResource(SalData& rSalData, const OUString& rFontFileURL)
 {
-int nRet = 0;
-OUString aUSytemPath;
-OSL_VERIFY( !osl::FileBase::getSystemPathFromFileURL( rFontFileURL, 
aUSytemPath ) );
+OUString aFontSystemPath;
+OSL_VERIFY(!osl::FileBase::getSystemPathFromFileURL(rFontFileURL, 
aFontSystemPath));
 
-nRet = AddFontResourceExW( o3tl::toW(aUSytemPath.getStr()), FR_PRIVATE, 
nullptr );
-SAL_WARN_IF(!nRet, "vcl.fonts", "Adding private font failed: " << 
rFontFileURL);
+int nRet = AddFontResourceExW(o3tl::toW(aFontSystemPath.getStr()), 
FR_PRIVATE, nullptr);
+SAL_WARN_IF(nRet <= 0, "vcl.fonts", "AddFontResourceExW failed for " << 
rFontFileURL);
 if (nRet > 0)
 {
 TempFontItem* pNewItem = new TempFontItem;
-pNewItem->maFontResourcePath = aUSytemPath;
+pNewItem->maFontResourcePath = aFontSystemPath;
 pNewItem->mpNextItem = rSalData.mpTempFontItem;
 rSalData.mpTempFontItem = pNewItem;
 }
-return (nRet > 0);
+return nRet;
 }
 
 void ImplReleaseTempFonts( SalData& rSalData )
@@ -1177,10 +1176,9 @@ static bool ImplGetFontAttrFromFile( const OUString& 
rFontFileURL,
 return true;
 }
 
-bool WinSalGraphics::AddTempDevFont( PhysicalFontCollection* pFontCollection,
-const OUString& rFontFileURL, const OUString& rFontName )
+bool WinSalGraphics::AddTempDevFont(PhysicalFontCollection* pFontCollection,
+const OUString& rFontFileURL, const 
OUString& rFontName)
 {
-SAL_INFO("vcl.fonts", "WinSalGraphics::AddTempDevFont(): " << 
rFontFileURL);
 
 FontAttributes aDFA;
 aDFA.SetFamilyName(rFontName);
@@ -1193,10 +1191,13 @@ bool WinSalGraphics::AddTempDevFont( 
PhysicalFontCollection* pFontCollection,
 }
 
 if ( aDFA.GetFamilyName().isEmpty() )
+{
+SAL_WARN("vcl.fonts", "error extracting font family from " << 
rFontFileURL);
 return false;
+}
 
-// remember temp font for cleanup later
-if( !ImplAddTempFont( *GetSalData(), rFontFileURL ) )
+int nFonts = lcl_AddFontResource(*GetSalData(), rFontFileURL);
+if (nFonts <= 0)
 return false;
 
 // create matching FontData struct
@@ -1224,9 +1225,7 @@ bool WinSalGraphics::AddTempDevFont( 
PhysicalFontCollection* pFontCollection,
 
 void WinSalGraphics::GetDevFontList( PhysicalFontCollection* pFontCollection )
 {
-SAL_INFO("vcl.fonts", "WinSalGraphics::GetDevFontList(): enter");
-
-// make sure all fonts are registered at least temporarily
+// make sure all LO shared fonts are registered temporarily
 static bool bOnce = true;
 if( bOnce )
 {
@@ -1245,13 +1244,15 @@ void WinSalGraphics::GetDevFontList( 
PhysicalFontCollection* pFontCollection )
 if( rcOSL == osl::FileBase::E_None )
 {
 osl::DirectoryItem aDirItem;
+SalData* pSalData = GetSalData();
+assert(pSalData);
 
 while( aFontDir.getNextItem( aDirItem, 10 ) == 
osl::FileBase::E_None )
 {
 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2019-06-19 Thread Khaled Hosny (via logerrit)
 vcl/inc/win/salgdi.h|2 +-
 vcl/win/gdi/salfont.cxx |   16 
 2 files changed, 5 insertions(+), 13 deletions(-)

New commits:
commit 362b872305d3b3500ef6f0823e5d30433dcfe48e
Author: Khaled Hosny 
AuthorDate: Thu Jun 20 02:13:04 2019 +0200
Commit: Khaled Hosny 
CommitDate: Thu Jun 20 04:08:25 2019 +0200

Remove leftover from bitmap fonts support on Windows

The condition "nFontType & RASTER_FONTTYPE" can never be true since we 
reject
such fonts, so nHeight is always zero and we can simplify the code a bit
accordingly.

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

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 7dc859a1a551..23f201fea6fa 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -59,7 +59,7 @@ class WinFontFace : public PhysicalFontFace
 {
 public:
 explicitWinFontFace( const FontAttributes&,
-int nFontHeight, BYTE eWinCharSet,
+BYTE eWinCharSet,
 BYTE nPitchAndFamily  );
 virtual ~WinFontFace() override;
 
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 181bbcec633b..fcdbb6484dda 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -559,16 +559,10 @@ static FontAttributes WinFont2DevFontAttributes( const 
ENUMLOGFONTEXW& rEnumFont
 
 
 static rtl::Reference ImplLogMetricToDevFontDataW( const 
ENUMLOGFONTEXW* pLogFont,
- const NEWTEXTMETRICW* pMetric,
- DWORD nFontType )
+ const NEWTEXTMETRICW* pMetric)
 {
-int nHeight = 0;
-if ( nFontType & RASTER_FONTTYPE )
-nHeight = pMetric->tmHeight - pMetric->tmInternalLeading;
-
 rtl::Reference pData = new WinFontFace(
 WinFont2DevFontAttributes(*pLogFont, *pMetric),
-nHeight,
 pLogFont->elfLogFont.lfCharSet,
 pMetric->tmPitchAndFamily );
 
@@ -613,7 +607,7 @@ void ImplSalLogFontToFontW( HDC hDC, const LOGFONTW& 
rLogFont, Font& rFont )
 }
 
 WinFontFace::WinFontFace( const FontAttributes& rDFS,
-int nHeight, BYTE eWinCharSet, BYTE nPitchAndFamily )
+BYTE eWinCharSet, BYTE nPitchAndFamily )
 :   PhysicalFontFace( rDFS ),
 mnId( 0 ),
 mbFontCapabilitiesRead( false ),
@@ -622,8 +616,6 @@ WinFontFace::WinFontFace( const FontAttributes& rDFS,
 mbAliasSymbolsHigh( false ),
 mbAliasSymbolsLow( false )
 {
-SetBitmapSize( 0, nHeight );
-
 if( eWinCharSet == SYMBOL_CHARSET )
 {
 if( (nPitchAndFamily & TMPF_TRUETYPE) != 0 )
@@ -1052,7 +1044,7 @@ static int CALLBACK SalEnumFontsProcExW( const LOGFONTW* 
lpelfe,
 return 1;
 }
 
-rtl::Reference pData = ImplLogMetricToDevFontDataW( 
pLogFont, &(pMetric->ntmTm), nFontType );
+rtl::Reference pData = 
ImplLogMetricToDevFontDataW(pLogFont, &(pMetric->ntmTm));
 pData->SetFontId( sal_IntPtr( pInfo->mnFontCount++ ) );
 
 pInfo->mpList->Add( pData.get() );
@@ -1222,7 +1214,7 @@ bool WinSalGraphics::AddTempDevFont( 
PhysicalFontCollection* pFontCollection,
 aDFS.maMapName = aFontName;
 */
 
-rtl::Reference pFontData = new WinFontFace( aDFA, 0,
+rtl::Reference pFontData = new WinFontFace(aDFA,
 sal::static_int_cast(DEFAULT_CHARSET),
 sal::static_int_cast(TMPF_VECTOR|TMPF_TRUETYPE) );
 pFontData->SetFontId( reinterpret_cast(pFontData.get()) );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/win

2019-04-30 Thread Miklos Vajna (via logerrit)
 vcl/inc/win/DWriteTextRenderer.hxx |   11 +++
 vcl/inc/win/winlayout.hxx  |2 +-
 vcl/win/gdi/DWriteTextRenderer.cxx |   25 ++---
 vcl/win/gdi/winlayout.cxx  |   16 +++-
 4 files changed, 37 insertions(+), 17 deletions(-)

New commits:
commit f7453b956bcf83ec13c805d243f20cb209289179
Author: Miklos Vajna 
AuthorDate: Tue Apr 30 17:38:14 2019 +0200
Commit: Miklos Vajna 
CommitDate: Tue Apr 30 21:56:11 2019 +0200

tdf#114209 vcl win DirectWrite: handle rotated text

Commit a51b7a1c3a7e7cf7b0c733e1dec40288278c1884 (tdf#103831, tdf#100986:
Force using GDI when needed, 2017-03-03) noted that the DirectWrite text
renderer doesn't support vertical text, add initial support for this now
by extending the DirectWrite transform matrix to do rotation as well.

This is initial support, as it can be improved in two ways:

- vertical text is not cached

- only vertical Latin text is handled, which wants rotated glyphs (vs
  e.g. Japanese text that would not rotate the glyphs)

With this, the "unreadable" text in the bugdoc's chart is on par with
the the GDI rendering.

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

diff --git a/vcl/inc/win/DWriteTextRenderer.hxx 
b/vcl/inc/win/DWriteTextRenderer.hxx
index a84cf81b9b66..9011a951d277 100644
--- a/vcl/inc/win/DWriteTextRenderer.hxx
+++ b/vcl/inc/win/DWriteTextRenderer.hxx
@@ -81,12 +81,15 @@ private:
 D2DTextAntiAliasMode meTextAntiAliasMode;
 };
 
-/// Sets and unsets the needed DirectWrite transform to support the font's 
horizontal scaling.
-class WinFontStretchGuard
+/**
+ * Sets and unsets the needed DirectWrite transform to support the font's 
horizontal scaling and
+ * rotation.
+ */
+class WinFontTransformGuard
 {
 public:
-WinFontStretchGuard(ID2D1RenderTarget* pRenderTarget, float fHScale);
-~WinFontStretchGuard();
+WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float fHScale, 
const GenericSalLayout& rLayout, const D2D1_POINT_2F& rBaseline);
+~WinFontTransformGuard();
 
 private:
 ID2D1RenderTarget* mpRenderTarget;
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 257c92e1a672..991c68f15b66 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -165,7 +165,7 @@ public:
 
 const WinFontFace * GetFontFace() const { return static_cast(LogicalFontInstance::GetFontFace()); }
 
-bool CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& 
rGraphics);
+bool CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& 
rGraphics, const GenericSalLayout& rLayout);
 OpenGLGlyphCache& GetOpenGLGlyphCache() { return maOpenGLGlyphCache; }
 
 bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const 
override;
diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx 
b/vcl/win/gdi/DWriteTextRenderer.cxx
index dac6452a41a5..98daff12c4a4 100644
--- a/vcl/win/gdi/DWriteTextRenderer.cxx
+++ b/vcl/win/gdi/DWriteTextRenderer.cxx
@@ -234,7 +234,6 @@ bool 
D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
 
 const WinFontInstance& rWinFont = static_cast(rLayout.GetFont());
 float fHScale = rWinFont.getHScale();
-WinFontStretchGuard aStretchGuard(mpRT, fHScale);
 
 tools::Rectangle bounds;
 bool succeeded = rLayout.GetBoundRect(bounds);
@@ -266,6 +265,7 @@ bool 
D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
 DWRITE_GLYPH_OFFSET glyphOffsets[] = { { 0.0f, 0.0f }, };
 D2D1_POINT_2F baseline = { static_cast(aPos.X() - 
bounds.Left()) / fHScale,
static_cast(aPos.Y() - 
bounds.Top()) };
+WinFontTransformGuard aTransformGuard(mpRT, fHScale, rLayout, 
baseline);
 DWRITE_GLYPH_RUN glyphs = {
 mpFontFace,
 mlfEmHeight,
@@ -384,18 +384,29 @@ bool D2DWriteTextOutRenderer::GetDWriteFaceFromHDC(HDC 
hDC, IDWriteFontFace ** p
 return succeeded;
 }
 
-WinFontStretchGuard::WinFontStretchGuard(ID2D1RenderTarget* pRenderTarget, 
float fHScale)
+WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, 
float fHScale,
+ const GenericSalLayout& rLayout,
+ const D2D1_POINT_2F& rBaseline)
 : mpRenderTarget(pRenderTarget)
 {
 pRenderTarget->GetTransform();
-if (fHScale == 1.0f)
-return;
+D2D1::Matrix3x2F aTransform = maTransform;
+if (fHScale != 1.0f)
+{
+aTransform
+= aTransform * D2D1::Matrix3x2F::Scale(D2D1::Size(fHScale, 1.0f), 
D2D1::Point2F(0, 0));
+}
 
-D2D1::Matrix3x2F aTransform
-= maTransform * D2D1::Matrix3x2F::Scale(D2D1::Size(fHScale, 1.0f), 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2019-04-24 Thread Miklos Vajna (via logerrit)
 vcl/inc/win/DWriteTextRenderer.hxx |   12 
 vcl/inc/win/winlayout.hxx  |1 +
 vcl/win/gdi/DWriteTextRenderer.cxx |   21 +++--
 vcl/win/gdi/winlayout.cxx  |   19 +++
 4 files changed, 47 insertions(+), 6 deletions(-)

New commits:
commit 51bcbfc3596fceedfe019e841aab129425c9
Author: Miklos Vajna 
AuthorDate: Wed Apr 24 17:07:30 2019 +0200
Commit: Miklos Vajna 
CommitDate: Wed Apr 24 18:40:15 2019 +0200

Related: tdf#113076 vcl win DirectWrite: handle stretched text

Commit a51b7a1c3a7e7cf7b0c733e1dec40288278c1884 (tdf#103831, tdf#100986:
Force using GDI when needed, 2017-03-03) noted that the DirectWrite text
renderer doesn't support stretched text, add support for this now by
setting a DirectWrite transform matrix that only does horizontal
scaling.

With this, tdf#113076 is kept fixed, but at the same time manually
stretched text keeps working. Previously the glyphs of the text had the
correct size and position, but the glyphs themselves where not streched,
but simply aligned to the left.

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

diff --git a/vcl/inc/win/DWriteTextRenderer.hxx 
b/vcl/inc/win/DWriteTextRenderer.hxx
index 92e0825bb8b3..a84cf81b9b66 100644
--- a/vcl/inc/win/DWriteTextRenderer.hxx
+++ b/vcl/inc/win/DWriteTextRenderer.hxx
@@ -81,6 +81,18 @@ private:
 D2DTextAntiAliasMode meTextAntiAliasMode;
 };
 
+/// Sets and unsets the needed DirectWrite transform to support the font's 
horizontal scaling.
+class WinFontStretchGuard
+{
+public:
+WinFontStretchGuard(ID2D1RenderTarget* pRenderTarget, float fHScale);
+~WinFontStretchGuard();
+
+private:
+ID2D1RenderTarget* mpRenderTarget;
+D2D1::Matrix3x2F maTransform;
+};
+
 #endif // INCLUDED_VCL_INC_WIN_DWRITERENDERER_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 279c155b0a97..257c92e1a672 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -151,6 +151,7 @@ public:
 ~WinFontInstance() override;
 
 bool hasHScale() const;
+float getHScale() const;
 
 void SetGraphics(WinSalGraphics*);
 WinSalGraphics* GetGraphics() const { return m_pGraphics; }
diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx 
b/vcl/win/gdi/DWriteTextRenderer.cxx
index 117b35989b1c..dac6452a41a5 100644
--- a/vcl/win/gdi/DWriteTextRenderer.cxx
+++ b/vcl/win/gdi/DWriteTextRenderer.cxx
@@ -232,6 +232,10 @@ bool 
D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
 if (!GetDWriteFaceFromHDC(hDC, , ))
 return false;
 
+const WinFontInstance& rWinFont = static_cast(rLayout.GetFont());
+float fHScale = rWinFont.getHScale();
+WinFontStretchGuard aStretchGuard(mpRT, fHScale);
+
 tools::Rectangle bounds;
 bool succeeded = rLayout.GetBoundRect(bounds);
 if (succeeded)
@@ -258,9 +262,10 @@ bool 
D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa
 while (rLayout.GetNextGlyph(, aPos, nStart))
 {
 UINT16 glyphIndices[] = { pGlyph->m_aGlyphId };
-FLOAT glyphAdvances[] = { static_cast(pGlyph->m_nNewWidth) 
};
+FLOAT glyphAdvances[] = { static_cast(pGlyph->m_nNewWidth) 
/ fHScale };
 DWRITE_GLYPH_OFFSET glyphOffsets[] = { { 0.0f, 0.0f }, };
-D2D1_POINT_2F baseline = { static_cast(aPos.X() - 
bounds.Left()), static_cast(aPos.Y() - bounds.Top()) };
+D2D1_POINT_2F baseline = { static_cast(aPos.X() - 
bounds.Left()) / fHScale,
+   static_cast(aPos.Y() - 
bounds.Top()) };
 DWRITE_GLYPH_RUN glyphs = {
 mpFontFace,
 mlfEmHeight,
@@ -379,6 +384,18 @@ bool D2DWriteTextOutRenderer::GetDWriteFaceFromHDC(HDC 
hDC, IDWriteFontFace ** p
 return succeeded;
 }
 
+WinFontStretchGuard::WinFontStretchGuard(ID2D1RenderTarget* pRenderTarget, 
float fHScale)
+: mpRenderTarget(pRenderTarget)
+{
+pRenderTarget->GetTransform();
+if (fHScale == 1.0f)
+return;
+
+D2D1::Matrix3x2F aTransform
+= maTransform * D2D1::Matrix3x2F::Scale(D2D1::Size(fHScale, 1.0f), 
D2D1::Point2F(0, 0));
+mpRenderTarget->SetTransform(aTransform);
+}
 
+WinFontStretchGuard::~WinFontStretchGuard() { 
mpRenderTarget->SetTransform(maTransform); }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index b3fe0132b7df..1d804fcd08d1 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -116,10 +116,11 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT 
hFont, int nGlyphIndex, S
 std::vector aGlyphAdv(1);   // offsets between glyphs
 std::vector aGlyphOffset(1, {0.0f, 0.0f});
 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2019-04-03 Thread Miklos Vajna (via logerrit)
 vcl/inc/win/salframe.h  |1 +
 vcl/win/window/salframe.cxx |   18 ++
 2 files changed, 19 insertions(+)

New commits:
commit c31734d0e49a778cffb1fdc3cd04adb45270e1da
Author: Miklos Vajna 
AuthorDate: Wed Apr 3 12:34:38 2019 +0200
Commit: Miklos Vajna 
CommitDate: Wed Apr 3 14:09:19 2019 +0200

tdf#114316 vcl opengl windows: fix missing context menu in full-screen mode

Full-screen mode on Windows used to work by measuring the space needed
by window caption (title) and borders, then positioning and sizing the
window in a way, so that the caption and borders are not visible.

This approach breaks at least in the OpenGL case where a large enough
negative position results in rendering errors.

Fix the problem by explicitly requesting the window to have no caption,
so we render less outside the screen (30 pixels -> 8 pixels in my case),
which makes the "exit fullscreen" toolbar appear, also the context menu
is visible.

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

diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h
index c556794b64f7..8e94f384b523 100644
--- a/vcl/inc/win/salframe.h
+++ b/vcl/inc/win/salframe.h
@@ -49,6 +49,7 @@ public:
 int mnMaxHeight;// max. client height in 
pixeln
 RECTmaFullScreenRect;   // fullscreen rect
 int mnFullScreenShowState;  // fullscreen restore show 
state
+boolmbFullScreenCaption;// WS_CAPTION reset in 
full screen mode.
 UINTmnInputLang;// current Input Language
 UINTmnInputCodePage;// current Input CodePage
 SalFrameStyleFlags  mnStyle;// style
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 6ecec9c2938f..64d505de56ff 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -843,6 +843,7 @@ WinSalFrame::WinSalFrame()
 mbBorder= false;
 mbFixBorder = false;
 mbSizeBorder= false;
+mbFullScreenCaption = false;
 mbFullScreen= false;
 mbPresentation  = false;
 mbInShow= false;
@@ -1850,6 +1851,15 @@ void WinSalFrame::ShowFullScreen( bool bFullScreen, 
sal_Int32 nDisplay )
 if ( !(GetWindowStyle( mhWnd ) & WS_VISIBLE) )
 mnShowState = SW_SHOW;
 
+// Save caption state.
+mbFullScreenCaption = mbCaption;
+if (mbCaption)
+{
+DWORD nStyle = GetWindowStyle(mhWnd);
+SetWindowStyle(mhWnd, nStyle & ~WS_CAPTION);
+mbCaption = false;
+}
+
 // set window to screen size
 ImplSalFrameFullScreenPos( this, true );
 }
@@ -1865,6 +1875,14 @@ void WinSalFrame::ShowFullScreen( bool bFullScreen, 
sal_Int32 nDisplay )
 SetWindowExStyle( mhWnd, GetWindowExStyle( mhWnd ) | 
WS_EX_TOOLWINDOW );
 mbFullScreenToolWin = false;
 
+// Restore caption state.
+if (mbFullScreenCaption)
+{
+DWORD nStyle = GetWindowStyle(mhWnd);
+SetWindowStyle(mhWnd, nStyle | WS_CAPTION);
+}
+mbCaption = mbFullScreenCaption;
+
 SetWindowPos( mhWnd, nullptr,
   maFullScreenRect.left,
   maFullScreenRect.top,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] core.git: vcl/inc vcl/win

2019-02-01 Thread Libreoffice Gerrit user
 vcl/inc/win/salvd.h   |3 +-
 vcl/win/gdi/salvd.cxx |   55 +++---
 2 files changed, 28 insertions(+), 30 deletions(-)

New commits:
commit cd520894e7092349f1a7aad07066376bb28571fc
Author: Dmitriy Shilin 
AuthorDate: Sun Jan 20 01:24:02 2019 -0800
Commit: Mike Kaganski 
CommitDate: Fri Feb 1 12:45:38 2019 +0100

tdf#107792 vcl/win: use ScopedGDI in WinSalVirtualDevice

Change-Id: Ia804f4ab527870ded8d57aa0d49aae1d357b7ac9
Reviewed-on: https://gerrit.libreoffice.org/66649
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/inc/win/salvd.h b/vcl/inc/win/salvd.h
index f4825836036e..4121d2c89979 100644
--- a/vcl/inc/win/salvd.h
+++ b/vcl/inc/win/salvd.h
@@ -21,6 +21,7 @@
 #define INCLUDED_VCL_INC_WIN_SALVD_H
 
 #include 
+#include 
 
 #include 
 
@@ -33,7 +34,7 @@ class WinSalVirtualDevice : public SalVirtualDevice
 {
 private:
 HDC mhLocalDC;  // HDC or 0 for Cache 
Device
-HBITMAP mhBmp;  // Memory Bitmap
+ScopedHBITMAP   mhBmp;  // Memory Bitmap
 HBITMAP mhDefBmp;   // Default Bitmap
 std::unique_ptr mpGraphics; // current VirDev graphics
 WinSalVirtualDevice*mpNext; // next VirDev
diff --git a/vcl/win/gdi/salvd.cxx b/vcl/win/gdi/salvd.cxx
index f0cf1fc9f47b..6dc94f0b12a2 100644
--- a/vcl/win/gdi/salvd.cxx
+++ b/vcl/win/gdi/salvd.cxx
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 HBITMAP WinSalVirtualDevice::ImplCreateVirDevBitmap(HDC hDC, long nDX, long 
nDY, sal_uInt16 nBitCount, void **ppData)
 {
@@ -184,8 +185,8 @@ WinSalVirtualDevice::~WinSalVirtualDevice()
 SelectBitmap( mpGraphics->getHDC(), mhDefBmp );
 if( !mbForeignDC )
 DeleteDC( mpGraphics->getHDC() );
-if( mhBmp )
-DeleteBitmap( mhBmp );
+
+mhBmp.reset();
 mpGraphics.reset();
 }
 
@@ -209,35 +210,31 @@ bool WinSalVirtualDevice::SetSize( long nDX, long nDY )
 {
 if( mbForeignDC || !mhBmp )
 return true;// ???
-else
+
+HBITMAP hNewBmp = ImplCreateVirDevBitmap(getHDC(), nDX, nDY, mnBitCount,
+ ::temporary(nullptr));
+if (!hNewBmp)
 {
-void *pDummy;
-HBITMAP hNewBmp = ImplCreateVirDevBitmap(getHDC(), nDX, nDY, 
mnBitCount, );
-if ( hNewBmp )
-{
-mnWidth = nDX;
-mnHeight = nDY;
-
-SelectBitmap( getHDC(), hNewBmp );
-DeleteBitmap( mhBmp );
-mhBmp = hNewBmp;
-
-if (mpGraphics)
-{
-WinOpenGLSalGraphicsImpl *pImpl;
-pImpl = dynamic_cast< WinOpenGLSalGraphicsImpl * 
>(mpGraphics->GetImpl());
-if (pImpl)
-pImpl->Init();
-}
-return true;
-}
-else
-{
-mnWidth = 0;
-mnHeight = 0;
-return false;
-}
+mnWidth = 0;
+mnHeight = 0;
+return false;
 }
+
+mnWidth = nDX;
+mnHeight = nDY;
+
+SelectBitmap(getHDC(), hNewBmp);
+mhBmp.reset(hNewBmp);
+
+if (mpGraphics)
+{
+WinOpenGLSalGraphicsImpl *pImpl;
+pImpl = dynamic_cast< WinOpenGLSalGraphicsImpl * 
>(mpGraphics->GetImpl());
+if (pImpl)
+pImpl->Init();
+}
+
+return true;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2019-01-29 Thread Libreoffice Gerrit user
 vcl/inc/win/scoped_gdi.hxx |   17 ++
 vcl/win/gdi/gdiimpl.cxx|   52 +
 2 files changed, 42 insertions(+), 27 deletions(-)

New commits:
commit c2c60eb9969716ef91a83952203948b5e334ec85
Author: Dmitriy Shilin 
AuthorDate: Sun Jan 20 00:08:30 2019 -0800
Commit: Mike Kaganski 
CommitDate: Wed Jan 30 07:14:37 2019 +0100

tdf#107792 vcl/win: introduce ScopedCachedHDC

Change-Id: Ia6c5ca98005642bbcce9d9d66bf16a4d4cbed04e
Reviewed-on: https://gerrit.libreoffice.org/66648
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/inc/win/scoped_gdi.hxx b/vcl/inc/win/scoped_gdi.hxx
index 0fb82112e68c..d02ad9545749 100644
--- a/vcl/inc/win/scoped_gdi.hxx
+++ b/vcl/inc/win/scoped_gdi.hxx
@@ -12,6 +12,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -53,6 +54,22 @@ using ScopedSelectedHPEN = ScopedSelectedGDI;
 using ScopedSelectedHFONT = ScopedSelectedGDI;
 using ScopedSelectedHBRUSH = ScopedSelectedGDI;
 
+template  class ScopedCachedHDC
+{
+public:
+explicit ScopedCachedHDC(HBITMAP hBitmap)
+: m_hDC(ImplGetCachedDC(ID, hBitmap))
+{
+}
+
+~ScopedCachedHDC() { ImplReleaseCachedDC(ID); }
+
+HDC get() const { return m_hDC; }
+
+private:
+HDC m_hDC;
+};
+
 #endif // INCLUDED_VCL_INC_WIN_SCOPED_GDI_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index a9406729fa21..1f654ebbee77 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -559,7 +559,8 @@ void ImplDrawBitmap( HDC hDC, const SalTwoRect& rPosAry, 
const WinSalBitmap& rSa
 }
 else if( hDrawDDB && !bPrintDDB )
 {
-HDC hBmpDC = ImplGetCachedDC( CACHED_HDC_DRAW, hDrawDDB );
+ScopedCachedHDC hBmpDC(hDrawDDB);
+
 COLORREFnOldBkColor = RGB(0xFF,0xFF,0xFF);
 COLORREFnOldTextColor = RGB(0,0,0);
 boolbMono = ( rSalBitmap.GetBitCount() == 1 );
@@ -592,7 +593,7 @@ void ImplDrawBitmap( HDC hDC, const SalTwoRect& rPosAry, 
const WinSalBitmap& rSa
 BitBlt( hDC,
 static_cast(rPosAry.mnDestX), 
static_cast(rPosAry.mnDestY),
 static_cast(rPosAry.mnDestWidth), 
static_cast(rPosAry.mnDestHeight),
-hBmpDC,
+hBmpDC.get(),
 static_cast(rPosAry.mnSrcX), 
static_cast(rPosAry.mnSrcY),
 nDrawMode );
 }
@@ -603,7 +604,7 @@ void ImplDrawBitmap( HDC hDC, const SalTwoRect& rPosAry, 
const WinSalBitmap& rSa
 StretchBlt( hDC,
 static_cast(rPosAry.mnDestX), 
static_cast(rPosAry.mnDestY),
 static_cast(rPosAry.mnDestWidth), 
static_cast(rPosAry.mnDestHeight),
-hBmpDC,
+hBmpDC.get(),
 static_cast(rPosAry.mnSrcX), 
static_cast(rPosAry.mnSrcY),
 static_cast(rPosAry.mnSrcWidth), 
static_cast(rPosAry.mnSrcHeight),
 nDrawMode );
@@ -616,8 +617,6 @@ void ImplDrawBitmap( HDC hDC, const SalTwoRect& rPosAry, 
const WinSalBitmap& rSa
 SetBkColor( hDC, nOldBkColor );
 ::SetTextColor( hDC, nOldTextColor );
 }
-
-ImplReleaseCachedDC( CACHED_HDC_DRAW );
 }
 }
 }
@@ -688,11 +687,11 @@ void WinSalGraphicsImpl::drawBitmap( const SalTwoRect& 
rPosAry,
 hMaskBitmap.reset(CreateCompatibleBitmap(hDC, nDstWidth, nDstHeight));
 }
 
-HDC hMemDC = ImplGetCachedDC( CACHED_HDC_1, hMemBitmap.get() );
-HDC hMaskDC = ImplGetCachedDC( CACHED_HDC_2, hMaskBitmap.get() );
+ScopedCachedHDC hMemDC(hMemBitmap.get());
+ScopedCachedHDC hMaskDC(hMaskBitmap.get());
 
 aPosAry.mnDestX = aPosAry.mnDestY = 0;
-BitBlt( hMemDC, 0, 0, nDstWidth, nDstHeight, hDC, nDstX, nDstY, SRCCOPY );
+BitBlt( hMemDC.get(), 0, 0, nDstWidth, nDstHeight, hDC, nDstX, nDstY, 
SRCCOPY );
 
 // WIN/WNT seems to have a minor problem mapping the correct color of the
 // mask to the palette if we draw the DIB directly ==> draw DDB
@@ -701,35 +700,32 @@ void WinSalGraphicsImpl::drawBitmap( const SalTwoRect& 
rPosAry,
 WinSalBitmap aTmp;
 
 if( aTmp.Create( rTransparentBitmap,  ) )
-ImplDrawBitmap( hMaskDC, aPosAry, aTmp, false, SRCCOPY );
+ImplDrawBitmap( hMaskDC.get(), aPosAry, aTmp, false, SRCCOPY );
 }
 else
-ImplDrawBitmap( hMaskDC, aPosAry, rTransparentBitmap, false, SRCCOPY );
+ImplDrawBitmap( hMaskDC.get(), aPosAry, rTransparentBitmap, false, 
SRCCOPY );
 
 // now MemDC contains background, MaskDC the transparency mask
 
 // #105055# Respect XOR mode
 if( mbXORMode )
 {
-ImplDrawBitmap( hMaskDC, aPosAry, rSalBitmap, 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2019-01-18 Thread Libreoffice Gerrit user
 vcl/inc/win/scoped_gdi.hxx |1 +
 vcl/win/gdi/gdiimpl.cxx|   20 +++-
 2 files changed, 8 insertions(+), 13 deletions(-)

New commits:
commit 643edcb11d635e09042d82d191279b6b1c2f25a9
Author: Dmitriy Shilin 
AuthorDate: Mon Jan 7 01:10:27 2019 -0800
Commit: Mike Kaganski 
CommitDate: Fri Jan 18 16:39:03 2019 +0100

tdf#107792 vcl/win: introduce ScopedHBITMAP

Change-Id: I2af507d9b924644d3a0e8a4bf2e92ca4b8a9a1b4
Reviewed-on: https://gerrit.libreoffice.org/65929
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/inc/win/scoped_gdi.hxx b/vcl/inc/win/scoped_gdi.hxx
index 34e0e60a33c4..0fb82112e68c 100644
--- a/vcl/inc/win/scoped_gdi.hxx
+++ b/vcl/inc/win/scoped_gdi.hxx
@@ -29,6 +29,7 @@ using ScopedHRGN = ScopedGDI;
 using ScopedHDC = ScopedGDI;
 using ScopedHPEN = ScopedGDI;
 using ScopedHFONT = ScopedGDI;
+using ScopedHBITMAP = ScopedGDI;
 
 template  class ScopedSelectedGDI
 {
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index e5013631d9ed..a9406729fa21 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -678,17 +678,18 @@ void WinSalGraphicsImpl::drawBitmap( const SalTwoRect& 
rPosAry,
 int nDstWidth = static_cast(aPosAry.mnDestWidth);
 int nDstHeight = static_cast(aPosAry.mnDestHeight);
 HDC hDC = mrParent.getHDC();
-HBITMAP hMemBitmap = nullptr;
-HBITMAP hMaskBitmap = nullptr;
+
+ScopedHBITMAP hMemBitmap;
+ScopedHBITMAP hMaskBitmap;
 
 if( ( nDstWidth > CACHED_HDC_DEFEXT ) || ( nDstHeight > CACHED_HDC_DEFEXT 
) )
 {
-hMemBitmap = CreateCompatibleBitmap( hDC, nDstWidth, nDstHeight );
-hMaskBitmap = CreateCompatibleBitmap( hDC, nDstWidth, nDstHeight );
+hMemBitmap.reset(CreateCompatibleBitmap(hDC, nDstWidth, nDstHeight));
+hMaskBitmap.reset(CreateCompatibleBitmap(hDC, nDstWidth, nDstHeight));
 }
 
-HDC hMemDC = ImplGetCachedDC( CACHED_HDC_1, hMemBitmap );
-HDC hMaskDC = ImplGetCachedDC( CACHED_HDC_2, hMaskBitmap );
+HDC hMemDC = ImplGetCachedDC( CACHED_HDC_1, hMemBitmap.get() );
+HDC hMaskDC = ImplGetCachedDC( CACHED_HDC_2, hMaskBitmap.get() );
 
 aPosAry.mnDestX = aPosAry.mnDestY = 0;
 BitBlt( hMemDC, 0, 0, nDstWidth, nDstHeight, hDC, nDstX, nDstY, SRCCOPY );
@@ -729,13 +730,6 @@ void WinSalGraphicsImpl::drawBitmap( const SalTwoRect& 
rPosAry,
 
 ImplReleaseCachedDC( CACHED_HDC_1 );
 ImplReleaseCachedDC( CACHED_HDC_2 );
-
-// hMemBitmap != 0 ==> hMaskBitmap != 0
-if( hMemBitmap )
-{
-DeleteObject( hMemBitmap );
-DeleteObject( hMaskBitmap );
-}
 }
 
 bool WinSalGraphicsImpl::drawAlphaRect( long nX, long nY, long nWidth,
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2019-01-18 Thread Libreoffice Gerrit user
 vcl/inc/win/scoped_gdi.hxx |1 +
 vcl/win/gdi/gdiimpl.cxx|   13 -
 2 files changed, 5 insertions(+), 9 deletions(-)

New commits:
commit a40f12c3f18e4262336fcd51d26dd099eae1e070
Author: Dmitriy Shilin 
AuthorDate: Sun Jan 13 05:37:12 2019 -0800
Commit: Mike Kaganski 
CommitDate: Fri Jan 18 15:36:26 2019 +0100

tdf#107792 vcl/win: introduce ScopedSelectedHBRUSH

Change-Id: I39792ce8442f9e7776b44a489b3c15b908e2f773
Reviewed-on: https://gerrit.libreoffice.org/66253
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/inc/win/scoped_gdi.hxx b/vcl/inc/win/scoped_gdi.hxx
index edbc086ada9c..34e0e60a33c4 100644
--- a/vcl/inc/win/scoped_gdi.hxx
+++ b/vcl/inc/win/scoped_gdi.hxx
@@ -50,6 +50,7 @@ private:
 
 using ScopedSelectedHPEN = ScopedSelectedGDI;
 using ScopedSelectedHFONT = ScopedSelectedGDI;
+using ScopedSelectedHBRUSH = ScopedSelectedGDI;
 
 #endif // INCLUDED_VCL_INC_WIN_SCOPED_GDI_HXX
 
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index 3b209075defc..e5013631d9ed 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -778,10 +778,9 @@ void WinSalGraphicsImpl::drawMask(const SalTwoRect& 
rPosAry,
 SalTwoRect  aPosAry = rPosAry;
 const HDC hDC = mrParent.getHDC();
 
-ScopedHBRUSH hMaskBrush(CreateSolidBrush(RGB(nMaskColor.GetRed(),
- nMaskColor.GetGreen(),
- nMaskColor.GetBlue(;
-HBRUSH  hOldBrush = SelectBrush(hDC, hMaskBrush.get());
+ScopedSelectedHBRUSH(hDC, CreateSolidBrush(RGB(nMaskColor.GetRed(),
+   nMaskColor.GetGreen(),
+   nMaskColor.GetBlue(;
 
 // WIN/WNT seems to have a minor problem mapping the correct color of the
 // mask to the palette if we draw the DIB directly ==> draw DDB
@@ -794,8 +793,6 @@ void WinSalGraphicsImpl::drawMask(const SalTwoRect& rPosAry,
 }
 else
 ImplDrawBitmap( hDC, aPosAry, rSalBitmap, false, 0x00B8074AUL );
-
-SelectBrush(hDC, hOldBrush);
 }
 
 std::shared_ptr WinSalGraphicsImpl::getBitmap( long nX, long nY, 
long nDX, long nDY )
@@ -1574,10 +1571,8 @@ void WinSalGraphicsImpl::DrawPixelImpl( long nX, long 
nY, COLORREF crColor )
 return;
 }
 
-ScopedHBRUSH hBrush(CreateSolidBrush(crColor));
-HBRUSH hOldBrush = SelectBrush(hDC, hBrush.get());
+ScopedSelectedHBRUSH(hDC, CreateSolidBrush(crColor));
 PatBlt(hDC, static_cast(nX), static_cast(nY), int(1), int(1), 
PATINVERT);
-SelectBrush(hDC, hOldBrush);
 }
 
 void WinSalGraphicsImpl::drawPixel( long nX, long nY )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2019-01-18 Thread Libreoffice Gerrit user
 vcl/inc/win/scoped_gdi.hxx |   51 +
 vcl/win/gdi/winlayout.cxx  |   22 ---
 2 files changed, 30 insertions(+), 43 deletions(-)

New commits:
commit f00fc7ee17153ff70fa4fb2052a5b555af0c054c
Author: Dmitriy Shilin 
AuthorDate: Tue Jan 8 04:20:29 2019 -0800
Commit: Mike Kaganski 
CommitDate: Fri Jan 18 15:20:43 2019 +0100

tdf#107792 vcl/win: introduce ScopedSelectedHFONT

Change-Id: If06ef869fc68976ee3ac6e671edd1bb4f992e716
Reviewed-on: https://gerrit.libreoffice.org/65964
Reviewed-by: Mike Kaganski 
Tested-by: Jenkins

diff --git a/vcl/inc/win/scoped_gdi.hxx b/vcl/inc/win/scoped_gdi.hxx
index ce6eadc8d0af..edbc086ada9c 100644
--- a/vcl/inc/win/scoped_gdi.hxx
+++ b/vcl/inc/win/scoped_gdi.hxx
@@ -15,53 +15,42 @@
 
 #include 
 
-struct HBRUSHDeleter
+template  struct GDIDeleter
 {
-using pointer = HBRUSH;
-void operator()(HBRUSH hBrush) { DeleteBrush(hBrush); }
+using pointer = H;
+void operator()(H h) { DeleterFunc(h); }
 };
 
-struct HRGNDeleter
-{
-using pointer = HRGN;
-void operator()(HRGN hRgn) { DeleteRegion(hRgn); }
-};
+template 
+using ScopedGDI = std::unique_ptr>;
 
-struct HDCDeleter
-{
-using pointer = HDC;
-void operator()(HDC hDC) { DeleteDC(hDC); }
-};
+using ScopedHBRUSH = ScopedGDI;
+using ScopedHRGN = ScopedGDI;
+using ScopedHDC = ScopedGDI;
+using ScopedHPEN = ScopedGDI;
+using ScopedHFONT = ScopedGDI;
 
-struct HPENDeleter
-{
-using pointer = HPEN;
-void operator()(HPEN hPen) { DeletePen(hPen); }
-};
-
-using ScopedHBRUSH = std::unique_ptr;
-using ScopedHRGN = std::unique_ptr;
-using ScopedHDC = std::unique_ptr;
-using ScopedHPEN = std::unique_ptr;
-
-class ScopedSelectedHPEN
+template  class ScopedSelectedGDI
 {
 public:
-ScopedSelectedHPEN(HDC hDC, HPEN hPen)
+ScopedSelectedGDI(HDC hDC, typename ScopedH::pointer h)
 : m_hDC(hDC)
-, m_hOrigPen(SelectPen(hDC, hPen))
-, m_hSelectedPen(hPen)
+, m_hSelectedH(h)
+, m_hOrigH(SelectorFunc(hDC, h))
 {
 }
 
-~ScopedSelectedHPEN() { SelectPen(m_hDC, m_hOrigPen); }
+~ScopedSelectedGDI() { SelectorFunc(m_hDC, m_hOrigH); }
 
 private:
 HDC m_hDC;
-HPEN m_hOrigPen;
-ScopedHPEN m_hSelectedPen;
+ScopedH m_hSelectedH;
+typename ScopedH::pointer m_hOrigH;
 };
 
+using ScopedSelectedHPEN = ScopedSelectedGDI;
+using ScopedSelectedHFONT = ScopedSelectedGDI;
+
 #endif // INCLUDED_VCL_INC_WIN_SCOPED_GDI_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index ebaf2f1be2d6..120f6bb65e22 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -235,7 +235,7 @@ bool ExTextOutRenderer::operator ()(GenericSalLayout const 
,
 HDC hDC)
 {
 HFONT hFont = static_cast(GetCurrentObject( hDC, OBJ_FONT ));
-HFONT hAltFont = nullptr;
+ScopedHFONT hAltFont;
 bool bUseAltFont = false;
 bool bShift = false;
 if (rLayout.GetFont().GetFontSelectPattern().mbVertical)
@@ -246,14 +246,14 @@ bool ExTextOutRenderer::operator ()(GenericSalLayout 
const ,
 {
 memmove([0], [1],
 sizeof(aLogFont.lfFaceName)-sizeof(aLogFont.lfFaceName[0]));
-hAltFont = CreateFontIndirectW();
+hAltFont.reset(CreateFontIndirectW());
 }
 else
 {
 bShift = true;
 aLogFont.lfEscapement += 2700;
 aLogFont.lfOrientation = aLogFont.lfEscapement;
-hAltFont = CreateFontIndirectW();
+hAltFont.reset(CreateFontIndirectW());
 }
 }
 
@@ -267,7 +267,7 @@ bool ExTextOutRenderer::operator ()(GenericSalLayout const 
,
 if (hAltFont && pGlyph->IsVertical() == bUseAltFont)
 {
 bUseAltFont = !bUseAltFont;
-SelectFont(hDC, bUseAltFont ? hAltFont : hFont);
+SelectFont(hDC, bUseAltFont ? hAltFont.get() : hFont);
 }
 if (bShift && pGlyph->IsVertical())
 SetTextAlign(hDC, TA_TOP|TA_LEFT);
@@ -281,7 +281,6 @@ bool ExTextOutRenderer::operator ()(GenericSalLayout const 
,
 {
 if (bUseAltFont)
 SelectFont(hDC, hFont);
-DeleteObject(hAltFont);
 }
 
 return true;
@@ -364,14 +363,13 @@ hb_font_t* WinFontInstance::ImplInitHbFont()
 // Set width to the default to get the original value in the metrics.
 aLogFont.lfWidth = 0;
 
-// Get the font metrics.
-HDC hDC = m_pGraphics->getHDC();
-HFONT hNewFont = CreateFontIndirectW();
-HGDIOBJ hOrigFont = SelectObject(hDC, hNewFont);
 TEXTMETRICW aFontMetric;
-GetTextMetricsW(hDC, );
-SelectObject(hDC, hOrigFont);
-DeleteObject(hNewFont);
+{
+// Get the font metrics.
+HDC hDC = m_pGraphics->getHDC();
+ScopedSelectedHFONT(hDC, 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2019-01-13 Thread Libreoffice Gerrit user
 vcl/inc/win/scoped_gdi.hxx|   25 +
 vcl/win/gdi/salnativewidgets-luna.cxx |   19 ++-
 2 files changed, 31 insertions(+), 13 deletions(-)

New commits:
commit 889b57e48d94d11cd76578f421ef27534300a894
Author: Dmitriy Shilin 
AuthorDate: Tue Jan 8 04:06:08 2019 -0800
Commit: Mike Kaganski 
CommitDate: Sun Jan 13 16:41:23 2019 +0100

tdf#107792 vcl/win: introduce ScopedSelectedHPEN

Change-Id: Ifbf42e083388c1e678615489ffba1245e2b49665
Reviewed-on: https://gerrit.libreoffice.org/65963
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/inc/win/scoped_gdi.hxx b/vcl/inc/win/scoped_gdi.hxx
index 80fbea8b4463..ce6eadc8d0af 100644
--- a/vcl/inc/win/scoped_gdi.hxx
+++ b/vcl/inc/win/scoped_gdi.hxx
@@ -33,9 +33,34 @@ struct HDCDeleter
 void operator()(HDC hDC) { DeleteDC(hDC); }
 };
 
+struct HPENDeleter
+{
+using pointer = HPEN;
+void operator()(HPEN hPen) { DeletePen(hPen); }
+};
+
 using ScopedHBRUSH = std::unique_ptr;
 using ScopedHRGN = std::unique_ptr;
 using ScopedHDC = std::unique_ptr;
+using ScopedHPEN = std::unique_ptr;
+
+class ScopedSelectedHPEN
+{
+public:
+ScopedSelectedHPEN(HDC hDC, HPEN hPen)
+: m_hDC(hDC)
+, m_hOrigPen(SelectPen(hDC, hPen))
+, m_hSelectedPen(hPen)
+{
+}
+
+~ScopedSelectedHPEN() { SelectPen(m_hDC, m_hOrigPen); }
+
+private:
+HDC m_hDC;
+HPEN m_hOrigPen;
+ScopedHPEN m_hSelectedPen;
+};
 
 #endif // INCLUDED_VCL_INC_WIN_SCOPED_GDI_HXX
 
diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx 
b/vcl/win/gdi/salnativewidgets-luna.cxx
index bda55c40fabf..7f5a33737d15 100644
--- a/vcl/win/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/gdi/salnativewidgets-luna.cxx
@@ -44,6 +44,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -52,6 +53,7 @@
 #include 
 #include 
 #include 
+
 using namespace std;
 
 typedef map< wstring, HTHEME > ThemeMap;
@@ -457,20 +459,15 @@ static void impl_drawAeroToolbar( HDC hDC, RECT rc, bool 
bHorizontal )
 GdiGradientFill( hDC, vert, 2, g_rect, 1, GRADIENT_FILL_RECT_V );
 
 // and a darker horizontal line under that
-HPEN hpen = CreatePen( PS_SOLID, 1, RGB( 0xb0, 0xb0, 0xb0 ) );
-HPEN hOrigPen = static_cast(SelectObject(hDC, hpen));
+ScopedSelectedHPEN(hDC, CreatePen(PS_SOLID, 1, RGB( 0xb0, 0xb0, 
0xb0)));
 
 MoveToEx( hDC, rc.left, gradient_bottom, nullptr );
 LineTo( hDC, rc.right, gradient_bottom );
-
-SelectObject(hDC, hOrigPen);
-DeleteObject(hpen);
 }
 else
 {
-HBRUSH hbrush = CreateSolidBrush( RGB( 0xf0, 0xf0, 0xf0 ) );
-FillRect( hDC, , hbrush );
-DeleteObject( hbrush );
+ScopedHBRUSH hbrush(CreateSolidBrush(RGB(0xf0, 0xf0, 0xf0)));
+FillRect(hDC, , hbrush.get());
 
 // darker line to distinguish the toolbar and viewshell
 // it is drawn only for the horizontal toolbars; it did not look well
@@ -483,14 +480,10 @@ static void impl_drawAeroToolbar( HDC hDC, RECT rc, bool 
bHorizontal )
 to_x = rc.right;
 from_y = to_y = rc.top;
 
-HPEN hpen = CreatePen( PS_SOLID, 1, RGB( 0xb0, 0xb0, 0xb0 ) );
-HPEN hOrigPen = static_cast(SelectObject(hDC, hpen));
+ScopedSelectedHPEN(hDC, CreatePen(PS_SOLID, 1, RGB( 0xb0, 0xb0, 
0xb0)));
 
 MoveToEx( hDC, from_x, from_y, nullptr );
 LineTo( hDC, to_x, to_y );
-
-SelectObject(hDC, hOrigPen);
-DeleteObject(hpen);
 }
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2019-01-09 Thread Libreoffice Gerrit user
 vcl/inc/win/ScopedHDC.hxx  |   45 -
 vcl/win/gdi/scoped_gdi.hxx |7 +++
 vcl/win/gdi/winlayout.cxx  |2 +-
 3 files changed, 8 insertions(+), 46 deletions(-)

New commits:
commit 8addcffd4c4b1ce8d7e4c8dee01c312b68f1de71
Author: Dmitriy Shilin 
AuthorDate: Tue Jan 8 03:39:16 2019 -0800
Commit: Noel Grandin 
CommitDate: Wed Jan 9 11:06:02 2019 +0100

tdf#107792 vcl/win: replace ScopedHDC with type alias

Change-Id: I2d12ebc2a7e353ce685ec5132b0a65b393c36212
Reviewed-on: https://gerrit.libreoffice.org/65962
Reviewed-by: Noel Grandin 
Tested-by: Noel Grandin 

diff --git a/vcl/inc/win/ScopedHDC.hxx b/vcl/inc/win/ScopedHDC.hxx
deleted file mode 100644
index bd4642ee6642..
--- a/vcl/inc/win/ScopedHDC.hxx
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- 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_INC_WIN_SCOPEDHDC_HXX
-#define INCLUDED_VCL_INC_WIN_SCOPEDHDC_HXX
-
-class ScopedHDC
-{
-private:
-HDC m_hDC;
-
-public:
-explicit ScopedHDC(HDC hDC)
-: m_hDC(hDC)
-{}
-
-ScopedHDC(const ScopedHDC&) = delete;
-ScopedHDC& operator=(const ScopedHDC&) = delete;
-
-~ScopedHDC()
-{
-if (m_hDC)
-DeleteDC(m_hDC);
-}
-
-HDC get() const
-{
-return m_hDC;
-}
-
-explicit operator bool() const
-{
-return m_hDC != nullptr;
-}
-};
-
-#endif // INCLUDED_VCL_INC_WIN_SCOPEDHDC_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/gdi/scoped_gdi.hxx b/vcl/win/gdi/scoped_gdi.hxx
index 90af7340f06a..b5a66d9d3698 100644
--- a/vcl/win/gdi/scoped_gdi.hxx
+++ b/vcl/win/gdi/scoped_gdi.hxx
@@ -27,8 +27,15 @@ struct HRGNDeleter
 void operator()(HRGN hRgn) { DeleteRegion(hRgn); }
 };
 
+struct HDCDeleter
+{
+using pointer = HDC;
+void operator()(HDC hDC) { DeleteDC(hDC); }
+};
+
 using ScopedHBRUSH = std::unique_ptr;
 using ScopedHRGN = std::unique_ptr;
+using ScopedHDC = std::unique_ptr;
 
 #endif // INCLUDED_VCL_WIN_GDI_SCOPED_GDI_HXX
 
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 91e82e8ba40e..f5e2c025e965 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -38,7 +38,7 @@
 
 #include 
 #include 
-#include 
+#include "scoped_gdi.hxx"
 
 #include 
 #include 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-10-06 Thread Libreoffice Gerrit user
 vcl/inc/win/saldata.hxx   |4 ++--
 vcl/inc/win/winlayout.hxx |   37 +++--
 vcl/win/gdi/winlayout.cxx |   16 
 3 files changed, 29 insertions(+), 28 deletions(-)

New commits:
commit 7d8a756164dda3b5b08eef68a2925fa4704c33ab
Author: Jan-Marek Glogowski 
AuthorDate: Fri Oct 5 09:41:32 2018 +
Commit: Jan-Marek Glogowski 
CommitDate: Sat Oct 6 10:06:44 2018 +0200

WIN rename GlyphCache to OpenGLGlyphCache

The Windows-backend based GlyphCache is OpenGL specific, so
reflect that by renaming it.

Change-Id: I1034bfde14792f0b6a807f8e938742556a31fcfb
Reviewed-on: https://gerrit.libreoffice.org/61452
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index ae43b12af4ab..d036ffb30a23 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -38,7 +38,7 @@ class WinSalFrame;
 class WinSalVirtualDevice;
 class WinSalPrinter;
 namespace vcl { class Font; }
-struct GlobalGlyphCache;
+struct GlobalOpenGLGlyphCache;
 struct HDCCache;
 struct TempFontItem;
 class TextOutRenderer;
@@ -121,7 +121,7 @@ public:
 std::unique_ptr m_pD2DWriteTextOutRenderer;
 // tdf#107205 need 2 instances because D2DWrite can't rotate text
 std::unique_ptr m_pExTextOutRenderer;
-std::unique_ptr m_pGlobalGlyphCache;
+std::unique_ptr m_pGlobalOpenGLGlyphCache;
 std::unique_ptr m_pTextureCache;
 };
 
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index b08a5d0ab78f..036c1d3bcbbd 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -58,48 +58,48 @@ struct OpenGLGlyphDrawElement
 }
 };
 
-class GlyphCache;
+class OpenGLGlyphCache;
 
-struct GlobalGlyphCache
+struct GlobalOpenGLGlyphCache
 {
-GlobalGlyphCache()
+GlobalOpenGLGlyphCache()
 : maPackedTextureAtlas(2048, 2048)
 {}
 
 PackedTextureAtlasManager maPackedTextureAtlas;
-std::unordered_set maGlyphCaches;
+std::unordered_set maOpenGLGlyphCaches;
 
-static GlobalGlyphCache * get();
+static GlobalOpenGLGlyphCache * get();
 };
 
-class GlyphCache
+class OpenGLGlyphCache
 {
 private:
 std::unordered_map maOpenGLTextureCache;
 
 public:
-GlyphCache()
+OpenGLGlyphCache()
 {
-GlobalGlyphCache::get()->maGlyphCaches.insert(this);
+GlobalOpenGLGlyphCache::get()->maOpenGLGlyphCaches.insert(this);
 }
 
-~GlyphCache()
+~OpenGLGlyphCache()
 {
-GlobalGlyphCache::get()->maGlyphCaches.erase(this);
+GlobalOpenGLGlyphCache::get()->maOpenGLGlyphCaches.erase(this);
 }
 
 static bool ReserveTextureSpace(OpenGLGlyphDrawElement& rElement, int 
nWidth, int nHeight)
 {
-GlobalGlyphCache* pGlobalGlyphCache = GlobalGlyphCache::get();
-rElement.maTexture = 
pGlobalGlyphCache->maPackedTextureAtlas.Reserve(nWidth, nHeight);
+GlobalOpenGLGlyphCache* pGlobalOpenGLGlyphCache = 
GlobalOpenGLGlyphCache::get();
+rElement.maTexture = 
pGlobalOpenGLGlyphCache->maPackedTextureAtlas.Reserve(nWidth, nHeight);
 if (!rElement.maTexture)
 return false;
-std::vector aTextureIDs = 
pGlobalGlyphCache->maPackedTextureAtlas.ReduceTextureNumber(8);
+std::vector aTextureIDs = 
pGlobalOpenGLGlyphCache->maPackedTextureAtlas.ReduceTextureNumber(8);
 if (!aTextureIDs.empty())
 {
-for (auto& pGlyphCache: pGlobalGlyphCache->maGlyphCaches)
+for (auto& pOpenGLGlyphCache: 
pGlobalOpenGLGlyphCache->maOpenGLGlyphCaches)
 {
-pGlyphCache->RemoveTextures(aTextureIDs);
+pOpenGLGlyphCache->RemoveTextures(aTextureIDs);
 }
 }
 return true;
@@ -150,8 +150,6 @@ class WinFontInstance : public LogicalFontInstance
 public:
 virtual ~WinFontInstance() override;
 
-bool CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& 
rGraphics);
-GlyphCache& GetGlyphCache() { return maGlyphCache; }
 bool hasHScale() const;
 
 void SetGraphics(WinSalGraphics*);
@@ -166,6 +164,9 @@ public:
 
 const WinFontFace * GetFontFace() const { return static_cast(LogicalFontInstance::GetFontFace()); }
 
+bool CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& 
rGraphics);
+OpenGLGlyphCache& GetOpenGLGlyphCache() { return maOpenGLGlyphCache; }
+
 private:
 explicit WinFontInstance(const WinFontFace&, const FontSelectPattern&);
 
@@ -174,7 +175,7 @@ private:
 WinSalGraphics *m_pGraphics;
 HFONT m_hFont;
 float m_fScale;
-GlyphCache maGlyphCache;
+OpenGLGlyphCache maOpenGLGlyphCache;
 };
 
 class TextOutRenderer
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 84cc3600de3b..35303fc5c8a5 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -48,12 +48,12 @@
 #include 
 #include 
 
-GlobalGlyphCache * GlobalGlyphCache::get() {

[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-09-14 Thread Libreoffice Gerrit user
 vcl/inc/win/winlayout.hxx |6 --
 vcl/win/gdi/salfont.cxx   |6 +++---
 vcl/win/gdi/winlayout.cxx |2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)

New commits:
commit 9e568efaad811e57e89ca68649d5112d77c7957a
Author: Noel Grandin 
AuthorDate: Fri Sep 14 08:50:51 2018 +0200
Commit: Noel Grandin 
CommitDate: Fri Sep 14 10:47:39 2018 +0200

make WinFontInstance take and return a WinFontFace

to make the handling more explicit here

Change-Id: I934fcc7b0da8a160acd904440f18fc6c01ec1ad3
Reviewed-on: https://gerrit.libreoffice.org/60475
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 161b3666e06a..b08a5d0ab78f 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -142,7 +142,7 @@ public:
 }
 };
 
-// win32 specific physical font instance
+// win32 specific logical font instance
 class WinFontInstance : public LogicalFontInstance
 {
 friend rtl::Reference 
WinFontFace::CreateFontInstance(const FontSelectPattern&) const;
@@ -164,8 +164,10 @@ public:
 // Used for the ScopedFont handling
 void SetHFONT(HFONT hFont) { m_hFont = hFont; }
 
+const WinFontFace * GetFontFace() const { return static_cast(LogicalFontInstance::GetFontFace()); }
+
 private:
-explicit WinFontInstance(const PhysicalFontFace&, const 
FontSelectPattern&);
+explicit WinFontInstance(const WinFontFace&, const FontSelectPattern&);
 
 virtual hb_font_t* ImplInitHbFont() override;
 
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index ae8628079021..6b50e55433f2 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -950,7 +950,7 @@ void WinSalGraphics::SetFont(LogicalFontInstance* pFont, 
int nFallbackLevel)
 }
 
 // now the font is live => update font face
-const WinFontFace* pFontFace = static_cast(pFontInstance->GetFontFace());
+const WinFontFace* pFontFace = pFontInstance->GetFontFace();
 pFontFace->UpdateFromHDC(getHDC());
 }
 
@@ -1004,14 +1004,14 @@ const FontCharMapRef WinSalGraphics::GetFontCharMap() 
const
 FontCharMapRef xDefFontCharMap( new FontCharMap() );
 return xDefFontCharMap;
 }
-return static_cast(mpWinFontEntry[0]->GetFontFace())->GetFontCharMap();
+return mpWinFontEntry[0]->GetFontFace()->GetFontCharMap();
 }
 
 bool WinSalGraphics::GetFontCapabilities(vcl::FontCapabilities 
) const
 {
 if (!mpWinFontEntry[0])
 return false;
-return static_cast(mpWinFontEntry[0]->GetFontFace())->GetFontCapabilities(rFontCapabilities);
+return 
mpWinFontEntry[0]->GetFontFace()->GetFontCapabilities(rFontCapabilities);
 }
 
 int CALLBACK SalEnumFontsProcExW( const LOGFONTW* lpelfe,
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 5cef9f5534aa..84cc3600de3b 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -312,7 +312,7 @@ std::unique_ptr 
WinSalGraphics::GetTextLayout(ImplLayoutArgs& /*rArgs
 return std::unique_ptr(aLayout);
 }
 
-WinFontInstance::WinFontInstance(const PhysicalFontFace& rPFF, const 
FontSelectPattern& rFSP)
+WinFontInstance::WinFontInstance(const WinFontFace& rPFF, const 
FontSelectPattern& rFSP)
 : LogicalFontInstance(rPFF, rFSP)
 , m_pGraphics(nullptr)
 , m_hFont(nullptr)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-09-07 Thread Libreoffice Gerrit user
 vcl/inc/win/salgdi.h  |3 ++-
 vcl/inc/win/winlayout.hxx |8 +---
 vcl/win/gdi/salfont.cxx   |   11 ---
 vcl/win/gdi/winlayout.cxx |   26 +-
 4 files changed, 28 insertions(+), 20 deletions(-)

New commits:
commit 7cb3e475f2fb0162c7290414509de4fb8fe57e30
Author: Jan-Marek Glogowski 
AuthorDate: Thu Sep 6 14:04:25 2018 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Fri Sep 7 20:27:01 2018 +0200

WIN add SalGraphics* to WinFontInstance

HFONT lookup in ImplDoSetFont depends on the mbVirDev of the
WinSalGraphics. Since we need too look up HFONTs for SalLayout
without changing the corresponding SalGraphics, add a pointer
to the WinFontInstance.

Change-Id: Idb6573ce7267f0019c2183be47621d0eaef8e57b
Reviewed-on: https://gerrit.libreoffice.org/60093
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 243d2cdc8fc5..9f30f57ecac8 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -170,9 +170,10 @@ private:
 
 bool CacheGlyphs(const GenericSalLayout& rLayout);
 bool DrawCachedGlyphs(const GenericSalLayout& rLayout);
-HFONT ImplDoSetFont(FontSelectPattern const & i_rFont, const 
PhysicalFontFace * i_pFontFace, float& o_rFontScale, HFONT& o_rOldFont);
 
 public:
+HFONT ImplDoSetFont(FontSelectPattern const & i_rFont, const 
PhysicalFontFace * i_pFontFace, float& o_rFontScale, HFONT& o_rOldFont);
+
 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 066f7b587f6d..161b3666e06a 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -154,20 +154,22 @@ public:
 GlyphCache& GetGlyphCache() { return maGlyphCache; }
 bool hasHScale() const;
 
-void SetHFONT(const HFONT);
+void SetGraphics(WinSalGraphics*);
+WinSalGraphics* GetGraphics() const { return m_pGraphics; }
+
 HFONT GetHFONT() const { return m_hFont; }
-void SetScale(float fScale) { m_fScale = fScale; }
 float GetScale() const { return m_fScale; }
 
 // Prevent deletion of the HFONT in the WinFontInstance destructor
 // Used for the ScopedFont handling
-void UnsetHFONT() { m_hFont = nullptr; }
+void SetHFONT(HFONT hFont) { m_hFont = hFont; }
 
 private:
 explicit WinFontInstance(const PhysicalFontFace&, const 
FontSelectPattern&);
 
 virtual hb_font_t* ImplInitHbFont() override;
 
+WinSalGraphics *m_pGraphics;
 HFONT m_hFont;
 float m_fScale;
 GlyphCache maGlyphCache;
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index e2734052c9c0..15a95ee98668 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -934,13 +934,10 @@ void WinSalGraphics::SetFont(LogicalFontInstance* pFont, 
int nFallbackLevel)
 HFONT hNewFont = pFontInstance->GetHFONT();
 if (!hNewFont)
 {
-float fFontScale = 1.0;
-hNewFont = ImplDoSetFont(pFont->GetFontSelectPattern(), 
pFont->GetFontFace(), fFontScale, hOldFont);
-mpWinFontEntry[ nFallbackLevel ]->SetHFONT(hNewFont);
-mpWinFontEntry[ nFallbackLevel ]->SetScale(fFontScale);
+pFontInstance->SetGraphics(this);
+hNewFont = pFontInstance->GetHFONT();
 }
-else
-hOldFont = ::SelectFont( getHDC(), hNewFont );
+hOldFont = ::SelectFont(getHDC(), hNewFont);
 
 // keep default font
 if( !mhDefFont )
@@ -1588,7 +1585,7 @@ ScopedFont::ScopedFont(WinSalGraphics & rData): 
m_rData(rData), m_hOrigFont(null
 if (m_rData.mpWinFontEntry[0])
 {
 m_hOrigFont = m_rData.mpWinFontEntry[0]->GetHFONT();
-m_rData.mpWinFontEntry[0]->UnsetHFONT();
+m_rData.mpWinFontEntry[0]->SetHFONT(nullptr);
 }
 }
 
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 3800fcd9adc3..a1d76c8026a4 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -307,13 +307,16 @@ std::unique_ptr 
WinSalGraphics::GetTextLayout(ImplLayoutArgs& /*rArgs
 
 assert(mpWinFontEntry[nFallbackLevel]->GetFontFace());
 
+mpWinFontEntry[nFallbackLevel]->SetGraphics(this);
 GenericSalLayout *aLayout = new 
GenericSalLayout(*mpWinFontEntry[nFallbackLevel]);
 return std::unique_ptr(aLayout);
 }
 
 WinFontInstance::WinFontInstance(const PhysicalFontFace& rPFF, const 
FontSelectPattern& rFSP)
 : LogicalFontInstance(rPFF, rFSP)
+, m_pGraphics(nullptr)
 , m_hFont(nullptr)
+, m_fScale(1.0f)
 {
 }
 
@@ -335,8 +338,12 @@ static hb_blob_t* getFontTable(hb_face_t* /*face*/, 
hb_tag_t nTableTag, void* pU
 {
 sal_uLong nLength = 0;
 unsigned char* pBuffer = nullptr;
-HFONT hFont = static_cast(pUserData);
-HDC hDC = GetDC(nullptr);
+WinFontInstance* pFont = static_cast(pUserData);
+HDC hDC = pFont->GetGraphics()->getHDC();
+HFONT hFont = pFont->GetHFONT();
+assert(hDC);
+

[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-09-07 Thread Libreoffice Gerrit user
 vcl/inc/win/salgdi.h|   13 ---
 vcl/win/gdi/salfont.cxx |   55 ++--
 vcl/win/gdi/salgdi.cxx  |6 -
 3 files changed, 17 insertions(+), 57 deletions(-)

New commits:
commit 334df91c6e464fe6434500f63e2fb12438722845
Author: Jan-Marek Glogowski 
AuthorDate: Thu Sep 6 14:00:29 2018 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Fri Sep 7 20:26:18 2018 +0200

WIN drop mhFonts[MAX_FALLBACK]

Everything now uses the HFONT from WinFontInstance, so there
is no need for the additional fallback array.

Change-Id: I15a197b262633569cb95c37689561db5323e1115
Reviewed-on: https://gerrit.libreoffice.org/60092
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 32a104bef88e..243d2cdc8fc5 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -156,19 +156,6 @@ private:
 boolmbScreen : 1;   // is Screen compatible
 HWNDmhWnd;  // Window-Handle, when 
Window-Graphics
 
-/** HFONT lifecycle
- *
- * The HFONT has to be shared between mhFonts and mpWinFontEntry.
- * As mpWinFontEntry is reference counted and just freed in SetFont, the 
HFONT is
- * transferred from mhFonts to the mpWinFontEntry.
- *
- * We need the mhFonts list, as embedded fonts don't have a corresponding 
WinFontInstance
- * so for these there is just the mhFonts entry.
- *
- * The HFONT object can just be assigned to mhFonts _or_ mpWinFontEntry!
- **/
-
-HFONT   mhFonts[ MAX_FALLBACK ];// Font + Fallbacks
 rtl::Reference
 mpWinFontEntry[ MAX_FALLBACK ]; // pointer to the 
most recent font instance
 HRGNmhRegion;   // vcl::Region Handle
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index bed9c7a22376..e2734052c9c0 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -913,22 +913,17 @@ void WinSalGraphics::SetFont(LogicalFontInstance* pFont, 
int nFallbackLevel)
 // return early if there is no new font
 if( !pFont )
 {
-// deselect still active font
-if (mhDefFont)
-{
-::SelectFont(getHDC(), mhDefFont);
-mhDefFont = nullptr;
-}
+if (!mpWinFontEntry[nFallbackLevel].is())
+return;
+
+// select original DC font
+assert(mhDefFont);
+::SelectFont(getHDC(), mhDefFont);
+mhDefFont = nullptr;
+
 // release no longer referenced font handles
 for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i )
-{
-if( mhFonts[i] )
-{
-::DeleteFont( mhFonts[i] );
-mhFonts[ i ] = nullptr;
-}
 mpWinFontEntry[i] = nullptr;
-}
 return;
 }
 
@@ -953,16 +948,8 @@ void WinSalGraphics::SetFont(LogicalFontInstance* pFont, 
int nFallbackLevel)
 else
 {
 // release no longer referenced font handles
-for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i )
-{
-if( mhFonts[i] )
-{
-::DeleteFont( mhFonts[i] );
-mhFonts[i] = nullptr;
-}
-if (i > nFallbackLevel)
-mpWinFontEntry[i] = nullptr;
-}
+for( int i = nFallbackLevel + 1; mpWinFontEntry[i].is() && i < 
MAX_FALLBACK; ++i )
+mpWinFontEntry[i] = nullptr;
 }
 
 // now the font is live => update font face
@@ -973,8 +960,8 @@ void WinSalGraphics::SetFont(LogicalFontInstance* pFont, 
int nFallbackLevel)
 void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int 
nFallbackLevel )
 {
 // temporarily change the HDC to the font in the fallback level
-assert(!mhFonts[nFallbackLevel] && mpWinFontEntry[nFallbackLevel]);
-const HFONT hOldFont = SelectFont(getHDC(), 
mpWinFontEntry[nFallbackLevel]->GetHFONT());
+rtl::Reference pFontInstance = 
mpWinFontEntry[nFallbackLevel];
+const HFONT hOldFont = SelectFont(getHDC(), pFontInstance->GetHFONT());
 
 wchar_t aFaceName[LF_FACESIZE+60];
 if( GetTextFaceW( getHDC(), SAL_N_ELEMENTS(aFaceName), aFaceName ) )
@@ -985,7 +972,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& 
rxFontMetric, int nFa
 const RawFontData aHheaRawData(getHDC(), nHheaTag);
 const RawFontData aOS2RawData(getHDC(), nOS2Tag);
 
-
rxFontMetric->SetMinKashida(mpWinFontEntry[nFallbackLevel]->GetKashidaWidth());
+rxFontMetric->SetMinKashida(pFontInstance->GetKashidaWidth());
 
 // get the font metric
 OUTLINETEXTMETRICW aOutlineMetric;
@@ -1006,7 +993,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& 
rxFontMetric, int nFa
 rxFontMetric->SetSlant( 0 );
 
 // transformation dependent font metrics
-

[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-09-06 Thread Libreoffice Gerrit user
 vcl/inc/win/salgdi.h  |2 --
 vcl/inc/win/winlayout.hxx |3 +++
 vcl/win/gdi/salfont.cxx   |   46 ++
 vcl/win/gdi/salgdi.cxx|2 --
 4 files changed, 33 insertions(+), 20 deletions(-)

New commits:
commit c177c305fc839e7a64d228ec56209d133588572b
Author: Jan-Marek Glogowski 
AuthorDate: Thu Sep 6 13:46:28 2018 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Thu Sep 6 18:46:06 2018 +0200

tdf#119302 WIN better font scale handling

Moves the scale factor into the LogicalFontInstance and uses the
Glyphs font fallback level to use the correct font and scale.

Probably the glyphs should be using a rtl::Reference to the
LogcalFontInstance instead of the fallback level. I don't know if
glyphs are evicted from the cache, if the fallback changes. There
is now an assert and all places will use 1.0 as the default
scaling factor, so LO should at least not crash.

Change-Id: I9dd4fc3a5b5924fc379b48a7f71c9eed26b4779d
Reviewed-on: https://gerrit.libreoffice.org/60091
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 51d14cb7ddda..32a104bef88e 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -171,8 +171,6 @@ private:
 HFONT   mhFonts[ MAX_FALLBACK ];// Font + Fallbacks
 rtl::Reference
 mpWinFontEntry[ MAX_FALLBACK ]; // pointer to the 
most recent font instance
-float   mfFontScale[ MAX_FALLBACK ];// allows 
metrics emulation of huge font sizes
-float   mfCurrentFontScale;
 HRGNmhRegion;   // vcl::Region Handle
 HPENmhDefPen;   // DefaultPen
 HBRUSH  mhDefBrush; // DefaultBrush
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 598d90c60588..066f7b587f6d 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -156,6 +156,8 @@ public:
 
 void SetHFONT(const HFONT);
 HFONT GetHFONT() const { return m_hFont; }
+void SetScale(float fScale) { m_fScale = fScale; }
+float GetScale() const { return m_fScale; }
 
 // Prevent deletion of the HFONT in the WinFontInstance destructor
 // Used for the ScopedFont handling
@@ -167,6 +169,7 @@ private:
 virtual hb_font_t* ImplInitHbFont() override;
 
 HFONT m_hFont;
+float m_fScale;
 GlyphCache maGlyphCache;
 };
 
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 8c1a6651bbd5..bed9c7a22376 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -919,7 +919,6 @@ void WinSalGraphics::SetFont(LogicalFontInstance* pFont, 
int nFallbackLevel)
 ::SelectFont(getHDC(), mhDefFont);
 mhDefFont = nullptr;
 }
-mfCurrentFontScale = mfFontScale[nFallbackLevel];
 // release no longer referenced font handles
 for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i )
 {
@@ -933,25 +932,24 @@ void WinSalGraphics::SetFont(LogicalFontInstance* pFont, 
int nFallbackLevel)
 return;
 }
 
-mpWinFontEntry[ nFallbackLevel ] = static_cast(pFont);
+WinFontInstance *pFontInstance = static_cast(pFont);
+mpWinFontEntry[ nFallbackLevel ] = pFontInstance;
 
 HFONT hOldFont = nullptr;
-HFONT hNewFont = mpWinFontEntry[ nFallbackLevel ]->GetHFONT();
+HFONT hNewFont = pFontInstance->GetHFONT();
 if (!hNewFont)
 {
-hNewFont = ImplDoSetFont(pFont->GetFontSelectPattern(), 
pFont->GetFontFace(), mfFontScale[ nFallbackLevel ], hOldFont);
+float fFontScale = 1.0;
+hNewFont = ImplDoSetFont(pFont->GetFontSelectPattern(), 
pFont->GetFontFace(), fFontScale, hOldFont);
 mpWinFontEntry[ nFallbackLevel ]->SetHFONT(hNewFont);
+mpWinFontEntry[ nFallbackLevel ]->SetScale(fFontScale);
 }
 else
 hOldFont = ::SelectFont( getHDC(), hNewFont );
 
-mfCurrentFontScale = mfFontScale[nFallbackLevel];
-
+// keep default font
 if( !mhDefFont )
-{
-// keep default font
 mhDefFont = hOldFont;
-}
 else
 {
 // release no longer referenced font handles
@@ -968,7 +966,7 @@ void WinSalGraphics::SetFont(LogicalFontInstance* pFont, 
int nFallbackLevel)
 }
 
 // now the font is live => update font face
-const WinFontFace* pFontFace = static_cast(mpWinFontEntry[nFallbackLevel]->GetFontFace());
+const WinFontFace* pFontFace = static_cast(pFontInstance->GetFontFace());
 pFontFace->UpdateFromHDC(getHDC());
 }
 
@@ -1008,7 +1006,7 @@ void WinSalGraphics::GetFontMetric( 
ImplFontMetricDataRef& rxFontMetric, int nFa
 rxFontMetric->SetSlant( 0 );
 
 // transformation dependent font metrics
-rxFontMetric->SetWidth(static_cast( mfFontScale[nFallbackLevel] * 
aWinMetric.tmAveCharWidth ));
+

[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-08-27 Thread Libreoffice Gerrit user
 vcl/inc/win/saltimer.h   |1 +
 vcl/win/app/saltimer.cxx |   11 +--
 2 files changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 0073101ec520e40727800f1d90b3b211fd6ec8d8
Author: Jan-Marek Glogowski 
AuthorDate: Sat Aug 25 02:56:32 2018 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Mon Aug 27 15:12:58 2018 +0200

WIN use the SetTimer timer as one-shot

SetTimer is a continuous timer, but we want to use it as a
one-shot, so make sure we actually kill it when not needed.

Change-Id: If6f5374346dc530eb664545ade2c2955885941b5
Reviewed-on: https://gerrit.libreoffice.org/59589
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/saltimer.h b/vcl/inc/win/saltimer.h
index e3fc25a3f542..3dd18f0a485f 100644
--- a/vcl/inc/win/saltimer.h
+++ b/vcl/inc/win/saltimer.h
@@ -39,6 +39,7 @@ class WinSalTimer final : public SalTimer, protected 
VersionedEvent
 HANDLE   m_nTimerId;  ///< Windows timer id
 bool m_bDirectTimeout;///< timeout can be processed directly
 bool m_bForceRealTimer;   ///< enforce using a real timer for 0ms
+bool m_bSetTimerRunning;  ///< true, if a SetTimer is running
 
 void ImplStart( sal_uIntPtr nMS );
 void ImplStop();
diff --git a/vcl/win/app/saltimer.cxx b/vcl/win/app/saltimer.cxx
index 17478bf58fdd..e89dbd561425 100644
--- a/vcl/win/app/saltimer.cxx
+++ b/vcl/win/app/saltimer.cxx
@@ -42,8 +42,11 @@ void WinSalTimer::ImplStop()
 const WinSalInstance *pInst = pSalData->mpInstance;
 assert( !pInst || pSalData->mnAppThreadId == GetCurrentThreadId() );
 
-if ( m_bForceRealTimer && m_bDirectTimeout )
+if ( m_bSetTimerRunning )
+{
+m_bSetTimerRunning = false;
 KillTimer( GetSalData()->mpInstance->mhComWnd, m_aWmTimerId );
+}
 m_bDirectTimeout = false;
 
 const HANDLE hTimer = m_nTimerId;
@@ -83,6 +86,7 @@ void WinSalTimer::ImplStart( sal_uLong nMS )
 // with posted 0ms SAL_MSG_TIMER_CALLBACK messages
 SetTimer( GetSalData()->mpInstance->mhComWnd, m_aWmTimerId,
   USER_TIMER_MINIMUM, nullptr );
+m_bSetTimerRunning = true;
 }
 // we don't need any wakeup message, as this code can just run in the
 // main thread!
@@ -92,6 +96,7 @@ WinSalTimer::WinSalTimer()
 : m_nTimerId( nullptr )
 , m_bDirectTimeout( false )
 , m_bForceRealTimer( false )
+, m_bSetTimerRunning( false )
 {
 }
 
@@ -183,9 +188,11 @@ void WinSalTimer::SetForceRealTimer( const bool bVal )
 void WinSalTimer::ImplHandle_WM_TIMER( const WPARAM aWPARAM )
 {
 assert( m_aWmTimerId == aWPARAM );
-if ( !(m_aWmTimerId == aWPARAM && m_bDirectTimeout && m_bForceRealTimer) )
+if ( !(m_aWmTimerId == aWPARAM && m_bSetTimerRunning) )
 return;
 
+m_bSetTimerRunning = false;
+KillTimer( GetSalData()->mpInstance->mhComWnd, m_aWmTimerId );
 ImplHandleElapsedTimer();
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-08-27 Thread Libreoffice Gerrit user
 vcl/inc/win/saltimer.h   |4 ++--
 vcl/win/app/salinst.cxx  |4 ++--
 vcl/win/app/saltimer.cxx |   10 --
 3 files changed, 8 insertions(+), 10 deletions(-)

New commits:
commit 4c356a3e5eafea92856824f902181b59ffed4fcc
Author: Jan-Marek Glogowski 
AuthorDate: Fri Aug 24 23:45:08 2018 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Mon Aug 27 15:11:31 2018 +0200

WIN ignore the timer results

Nobody else will handle our scheduler or WM_TIMER event, so
there is really no point to return any error value from the
handlers to some lower level function.

Change-Id: I33eac11076a30220cfa11cec8f352bd5c8b69209
Reviewed-on: https://gerrit.libreoffice.org/59588
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/saltimer.h b/vcl/inc/win/saltimer.h
index 61d284d82ddb..e3fc25a3f542 100644
--- a/vcl/inc/win/saltimer.h
+++ b/vcl/inc/win/saltimer.h
@@ -42,9 +42,9 @@ class WinSalTimer final : public SalTimer, protected 
VersionedEvent
 
 void ImplStart( sal_uIntPtr nMS );
 void ImplStop();
-bool ImplHandleTimerEvent( WPARAM aWPARAM );
+void ImplHandleTimerEvent( WPARAM aWPARAM );
 void ImplHandleElapsedTimer();
-bool ImplHandle_WM_TIMER( WPARAM aWPARAM );
+void ImplHandle_WM_TIMER( WPARAM aWPARAM );
 
 public:
 WinSalTimer();
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 75044a5e00d3..af97c82f752e 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -661,12 +661,12 @@ LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM 
wParam, LPARAM lParam, b
 
 case SAL_MSG_TIMER_CALLBACK:
 assert( pTimer != nullptr );
-nRet = static_cast( pTimer->ImplHandleTimerEvent( wParam 
) );
+pTimer->ImplHandleTimerEvent( wParam );
 break;
 
 case WM_TIMER:
 assert( pTimer != nullptr );
-nRet = static_cast( pTimer->ImplHandle_WM_TIMER( wParam ) 
);
+pTimer->ImplHandle_WM_TIMER( wParam );
 break;
 
 case SAL_MSG_DUMMY:
diff --git a/vcl/win/app/saltimer.cxx b/vcl/win/app/saltimer.cxx
index 689c055a55f5..17478bf58fdd 100644
--- a/vcl/win/app/saltimer.cxx
+++ b/vcl/win/app/saltimer.cxx
@@ -159,14 +159,13 @@ void WinSalTimer::ImplHandleElapsedTimer()
 ImplSalYieldMutexRelease();
 }
 
-bool WinSalTimer::ImplHandleTimerEvent( const WPARAM aWPARAM )
+void WinSalTimer::ImplHandleTimerEvent( const WPARAM aWPARAM )
 {
 assert( aWPARAM <= SAL_MAX_INT32 );
 if ( !IsValidEventVersion( static_cast( aWPARAM ) ) )
-return false;
+return;
 
 ImplHandleElapsedTimer();
-return true;
 }
 
 void WinSalTimer::SetForceRealTimer( const bool bVal )
@@ -181,14 +180,13 @@ void WinSalTimer::SetForceRealTimer( const bool bVal )
 Start( 0 );
 }
 
-bool WinSalTimer::ImplHandle_WM_TIMER( const WPARAM aWPARAM )
+void WinSalTimer::ImplHandle_WM_TIMER( const WPARAM aWPARAM )
 {
 assert( m_aWmTimerId == aWPARAM );
 if ( !(m_aWmTimerId == aWPARAM && m_bDirectTimeout && m_bForceRealTimer) )
-return false;
+return;
 
 ImplHandleElapsedTimer();
-return true;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-08-24 Thread Libreoffice Gerrit user
 vcl/inc/win/salinst.h   |2 +-
 vcl/win/app/salinst.cxx |   22 ++
 2 files changed, 11 insertions(+), 13 deletions(-)

New commits:
commit bf0a63dc93a746a008fb1656457c77de8df693ba
Author: Jan-Marek Glogowski 
AuthorDate: Fri Aug 24 09:14:47 2018 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Aug 24 15:14:53 2018 +0200

tdf#118786 WIN just assert in Yield

This reminds me - again - that Jenkins doesn't run make check.

It turns out InSendMessage() also returns true, if you process a
nested SendMessage in the same thread. Therefore we have to
remove the SalComWndProc assert and just keep the one in the
Yield call.

Why? Because there seem to be no way to get the information
ReplyMessage has access to, so we could detect the caller /
origin of the send message and implement proper nested call
checks. The alternative would be to change all call sites of
SendMessage to:

if ( !pSalData->mpInstance->IsMainThread() )
SendMessage(...)
else
SalComWndProc(...)

which is the same SendMessage already does.

Change-Id: I991d68a64952dc5d47ba51edd8635c9e8c46614c
Reviewed-on: https://gerrit.libreoffice.org/59538
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h
index cea4aff964bc..a43d52e2f8ce 100644
--- a/vcl/inc/win/salinst.h
+++ b/vcl/inc/win/salinst.h
@@ -39,7 +39,7 @@ public:
 SalYieldMutex*  mpSalYieldMutex;
 
 osl::Condition  maWaitingYieldCond;
-boolmbNoYieldLock;
+unsignedm_nNoYieldLock;
 
 public:
 WinSalInstance();
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 154a125f2069..75044a5e00d3 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -130,7 +130,7 @@ void SalYieldMutex::doAcquire( sal_uInt32 nLockCount )
 WinSalInstance* pInst = GetSalData()->mpInstance;
 if ( pInst && pInst->IsMainThread() )
 {
-if ( pInst->mbNoYieldLock )
+if ( pInst->m_nNoYieldLock )
 return;
 // tdf#96887 If this is the main thread, then we must wait for two 
things:
 // - the mpSalYieldMutex being freed
@@ -161,7 +161,7 @@ void SalYieldMutex::doAcquire( sal_uInt32 nLockCount )
 sal_uInt32 SalYieldMutex::doRelease( const bool bUnlockAll )
 {
 WinSalInstance* pInst = GetSalData()->mpInstance;
-if ( pInst && pInst->mbNoYieldLock && pInst->IsMainThread() )
+if ( pInst && pInst->m_nNoYieldLock && pInst->IsMainThread() )
 return 1;
 
 sal_uInt32 nCount = comphelper::SolarMutex::doRelease( bUnlockAll );
@@ -176,7 +176,7 @@ bool SalYieldMutex::tryToAcquire()
 WinSalInstance* pInst = GetSalData()->mpInstance;
 if ( pInst )
 {
-if ( pInst->mbNoYieldLock && pInst->IsMainThread() )
+if ( pInst->m_nNoYieldLock && pInst->IsMainThread() )
 return true;
 else
 return comphelper::SolarMutex::tryToAcquire();
@@ -210,7 +210,7 @@ void ImplSalYieldMutexRelease()
 
 bool SalYieldMutex::IsCurrentThread() const
 {
-if ( !GetSalData()->mpInstance->mbNoYieldLock )
+if ( !GetSalData()->mpInstance->m_nNoYieldLock )
 // For the Windows backend, the LO identifier is the system thread ID
 return m_nThreadId == GetCurrentThreadId();
 else
@@ -423,7 +423,7 @@ void DestroySalInstance( SalInstance* pInst )
 
 WinSalInstance::WinSalInstance()
 : mhComWnd( nullptr )
-, mbNoYieldLock( false )
+, m_nNoYieldLock( 0 )
 {
 mpSalYieldMutex = new SalYieldMutex();
 mpSalYieldMutex->acquire();
@@ -469,7 +469,7 @@ bool ImplSalYield( bool bWait, bool bHandleAllCurrentEvents 
)
 bool bWasMsg = false, bOneEvent = false, bWasTimeoutMsg = false;
 ImplSVData *const pSVData = ImplGetSVData();
 WinSalTimer* pTimer = static_cast( 
pSVData->maSchedCtx.mpSalTimer );
-const bool bNoYieldLock = GetSalData()->mpInstance->mbNoYieldLock;
+const bool bNoYieldLock = (GetSalData()->mpInstance->m_nNoYieldLock > 0);
 
 assert( !bNoYieldLock );
 if ( bNoYieldLock )
@@ -570,10 +570,9 @@ bool WinSalInstance::DoYield(bool bWait, bool 
bHandleAllCurrentEvents)
 case salmsg: \
 if (bIsOtherThreadMessage) \
 { \
-assert( !pInst->mbNoYieldLock ); \
-pInst->mbNoYieldLock = true; \
+++pInst->m_nNoYieldLock; \
 function; \
-pInst->mbNoYieldLock = false; \
+--pInst->m_nNoYieldLock; \
 } \
 else \
 { \
@@ -586,10 +585,9 @@ bool WinSalInstance::DoYield(bool bWait, bool 
bHandleAllCurrentEvents)
 case salmsg: \
 if (bIsOtherThreadMessage) \
 { \
-assert( !pInst->mbNoYieldLock ); \
-pInst->mbNoYieldLock = true; \
+++pInst->m_nNoYieldLock; \
 nRet = reinterpret_cast( function ); \
-pInst->mbNoYieldLock = false; \
+

[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-08-22 Thread Libreoffice Gerrit user
 vcl/inc/win/salgdi.h|2 +-
 vcl/win/gdi/salfont.cxx |   30 +++---
 vcl/win/window/salframe.cxx |2 +-
 3 files changed, 17 insertions(+), 17 deletions(-)

New commits:
commit 5f1451f0b0b3184b85ae357f90e9a01a3c51d278
Author: Caolán McNamara 
AuthorDate: Tue Aug 21 09:07:27 2018 +0100
Commit: Caolán McNamara 
CommitDate: Wed Aug 22 11:36:36 2018 +0200

arg is never null

Change-Id: Ifde85786e9e0b0d9c1bdb1163b7c4a0889005323
Reviewed-on: https://gerrit.libreoffice.org/59386
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index c55193e255e9..0540b66b34f7 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -402,7 +402,7 @@ public:
 // Init/Deinit Graphics
 voidImplUpdateSysColorEntries();
 int ImplIsSysColorEntry( Color nColor );
-voidImplGetLogFontFromFontSelect( HDC, const FontSelectPattern*,
+voidImplGetLogFontFromFontSelect( HDC, const FontSelectPattern&,
 const PhysicalFontFace*, LOGFONTW& );
 
 #define MAX_64KSALPOINTSsal_uInt16)0x)-8)/sizeof(POINTS))
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 526f924b18d7..969cefd17279 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -185,7 +185,7 @@ bool 
WinGlyphFallbackSubstititution::HasMissingChars(PhysicalFontFace* pFace, OU
 const FontSelectPattern aFSD( *pFace, aSize, 
static_cast(aSize.Height()), 0, false );
 // construct log font
 LOGFONTW aLogFont;
-ImplGetLogFontFromFontSelect( mhDC, , pFace, aLogFont );
+ImplGetLogFontFromFontSelect( mhDC, aFSD, pFace, aLogFont );
 
 // create HFONT from log font
 HFONT hNewFont = ::CreateFontIndirectW(  );
@@ -760,7 +760,7 @@ int CALLBACK SalEnumQueryFontProcExW( const LOGFONTW*,
 }
 
 void ImplGetLogFontFromFontSelect( HDC hDC,
-   const FontSelectPattern* pFont,
+   const FontSelectPattern& rFont,
const PhysicalFontFace* pFontFace,
LOGFONTW& rLogFont )
 {
@@ -768,7 +768,7 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
 if (pFontFace)
 aName = pFontFace->GetFamilyName();
 else
-aName = pFont->GetFamilyName().getToken( 0, ';' );
+aName = rFont.GetFamilyName().getToken( 0, ';' );
 
 UINT nNameLen = aName.getLength();
 if ( nNameLen > (sizeof( rLogFont.lfFaceName )/sizeof( wchar_t ))-1 )
@@ -784,9 +784,9 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
 }
 else
 {
-rLogFont.lfCharSet = pFont->IsSymbolFont() ? SYMBOL_CHARSET : 
DEFAULT_CHARSET;
-rLogFont.lfPitchAndFamily = ImplPitchToWin( pFont->GetPitch() )
-  | ImplFamilyToWin( pFont->GetFamilyType() );
+rLogFont.lfCharSet = rFont.IsSymbolFont() ? SYMBOL_CHARSET : 
DEFAULT_CHARSET;
+rLogFont.lfPitchAndFamily = ImplPitchToWin( rFont.GetPitch() )
+  | ImplFamilyToWin( rFont.GetFamilyType() );
 }
 
 static BYTE nDefaultQuality = NONANTIALIASED_QUALITY;
@@ -798,26 +798,26 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
 nDefaultQuality = DEFAULT_QUALITY;
 }
 
-rLogFont.lfWeight  = ImplWeightToWin( pFont->GetWeight() );
-rLogFont.lfHeight  = static_cast(-pFont->mnHeight);
-rLogFont.lfWidth   = static_cast(pFont->mnWidth);
+rLogFont.lfWeight  = ImplWeightToWin( rFont.GetWeight() );
+rLogFont.lfHeight  = static_cast(-rFont.mnHeight);
+rLogFont.lfWidth   = static_cast(rFont.mnWidth);
 rLogFont.lfUnderline   = 0;
 rLogFont.lfStrikeOut   = 0;
-rLogFont.lfItalic  = BYTE(pFont->GetItalic() != ITALIC_NONE);
-rLogFont.lfEscapement  = pFont->mnOrientation;
+rLogFont.lfItalic  = BYTE(rFont.GetItalic() != ITALIC_NONE);
+rLogFont.lfEscapement  = rFont.mnOrientation;
 rLogFont.lfOrientation = rLogFont.lfEscapement;
 rLogFont.lfClipPrecision   = CLIP_DEFAULT_PRECIS;
 rLogFont.lfQuality = nDefaultQuality;
 rLogFont.lfOutPrecision= OUT_TT_PRECIS;
-if ( pFont->mnOrientation )
+if ( rFont.mnOrientation )
 rLogFont.lfClipPrecision |= CLIP_LH_ANGLES;
 
 // disable antialiasing if requested
-if ( pFont->mbNonAntialiased )
+if ( rFont.mbNonAntialiased )
 rLogFont.lfQuality = NONANTIALIASED_QUALITY;
 
 // select vertical mode if requested and available
-if ( pFont->mbVertical && nNameLen )
+if ( rFont.mbVertical && nNameLen )
 {
 // vertical fonts start with an '@'
 memmove( [1], [0],
@@ -857,7 +857,7 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const 
& i_rFont,
 hdcScreen = GetDC(nullptr);
 
 LOGFONTW aLogFont;
-

[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-08-21 Thread Libreoffice Gerrit user
 vcl/inc/win/salgdi.h|6 +++---
 vcl/win/gdi/salfont.cxx |   22 +++---
 2 files changed, 14 insertions(+), 14 deletions(-)

New commits:
commit 232992fa65358e7bc493c9f19f724457eed4feb5
Author: Caolán McNamara 
AuthorDate: Tue Aug 21 09:12:16 2018 +0100
Commit: Caolán McNamara 
CommitDate: Tue Aug 21 21:35:55 2018 +0200

can now use just FontSelectPatternAttributes

Change-Id: I1857afa0a9aff39118ba3c242134985f865e37c1
Reviewed-on: https://gerrit.libreoffice.org/59387
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
Tested-by: Caolán McNamara 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index c55193e255e9..ebb9fc8eac3d 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -42,7 +42,7 @@
 #include 
 #include 
 
-class FontSelectPattern;
+class FontSelectPatternAttributes;
 class WinFontInstance;
 class ImplFontAttrCache;
 class OpenGLTexture;
@@ -185,7 +185,7 @@ private:
 
 bool CacheGlyphs(const GenericSalLayout& rLayout);
 bool DrawCachedGlyphs(const GenericSalLayout& rLayout);
-HFONT ImplDoSetFont(FontSelectPattern const & i_rFont, const 
PhysicalFontFace * i_pFontFace, float& o_rFontScale, HFONT& o_rOldFont);
+HFONT ImplDoSetFont(FontSelectPatternAttributes const & i_rFont, const 
PhysicalFontFace * i_pFontFace, float& o_rFontScale, HFONT& o_rOldFont);
 
 public:
 HDC getHDC() const { return mhLocalDC; }
@@ -402,7 +402,7 @@ public:
 // Init/Deinit Graphics
 voidImplUpdateSysColorEntries();
 int ImplIsSysColorEntry( Color nColor );
-voidImplGetLogFontFromFontSelect( HDC, const FontSelectPattern*,
+voidImplGetLogFontFromFontSelect( HDC, const FontSelectPatternAttributes*,
 const PhysicalFontFace*, LOGFONTW& );
 
 #define MAX_64KSALPOINTSsal_uInt16)0x)-8)/sizeof(POINTS))
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index a51a06a0d4c4..3fe7b6171453 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -179,10 +179,10 @@ bool 
WinGlyphFallbackSubstititution::HasMissingChars(PhysicalFontFace* pFace, OU
 FontCharMapRef xFontCharMap = pWinFont->GetFontCharMap();
 if( !xFontCharMap.is() )
 {
-// construct a Size structure as the parameter of constructor of class 
FontSelectPattern
+// construct a Size structure as the parameter of constructor of class 
FontSelectPatternAttributes
 const Size aSize( pFace->GetWidth(), pFace->GetHeight() );
-// create a FontSelectPattern object for getting s LOGFONT
-const FontSelectPattern aFSD( *pFace, aSize, 
static_cast(aSize.Height()), 0, false );
+// create a FontSelectPatternAttributes object for getting s LOGFONT
+const FontSelectPatternAttributes aFSD( *pFace, aSize, 
static_cast(aSize.Height()), 0, false );
 // construct log font
 LOGFONTW aLogFont;
 ImplGetLogFontFromFontSelect( mhDC, , pFace, aLogFont );
@@ -760,7 +760,7 @@ int CALLBACK SalEnumQueryFontProcExW( const LOGFONTW*,
 }
 
 void ImplGetLogFontFromFontSelect( HDC hDC,
-   const FontSelectPattern* pFont,
+   const FontSelectPatternAttributes* pFont,
const PhysicalFontFace* pFontFace,
LOGFONTW& rLogFont )
 {
@@ -842,7 +842,7 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
 }
 }
 
-HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont,
+HFONT WinSalGraphics::ImplDoSetFont(FontSelectPatternAttributes const & 
i_rFont,
 const PhysicalFontFace * i_pFontFace,
 float& o_rFontScale,
 HFONT& o_rOldFont)
@@ -1647,10 +1647,10 @@ bool WinSalGraphics::CreateFontSubset( const OUString& 
rToFile,
 {
 // TODO: use more of the central font-subsetting code, move stuff there if 
needed
 
-// create matching FontSelectPattern
+// create matching FontSelectPatternAttributes
 // we need just enough to get to the font file data
 // use height=1000 for easier debugging (to match psprint's font units)
-FontSelectPattern aIFSD( *pFont, Size(0,1000), 1000.0, 0, false );
+FontSelectPatternAttributes aIFSD( *pFont, Size(0,1000), 1000.0, 0, false 
);
 
 // TODO: much better solution: move SetFont and restoration of old font to 
caller
 ScopedFont aOldFont(*this);
@@ -1769,9 +1769,9 @@ bool WinSalGraphics::CreateFontSubset( const OUString& 
rToFile,
 
 const void* WinSalGraphics::GetEmbedFontData(const PhysicalFontFace* pFont, 
long* pDataLen)
 {
-// create matching FontSelectPattern
+// create matching FontSelectPatternAttributes
 // we need just enough to get to the font file data
-FontSelectPattern aIFSD( *pFont, Size(0,1000), 1000.0, 0, false );
+FontSelectPatternAttributes aIFSD( *pFont, Size(0,1000), 1000.0, 0, false 
);
 
 ScopedFont aOldFont(*this);
 
@@ 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-07-10 Thread Jan-Marek Glogowski
 vcl/inc/win/winlayout.hxx |2 +-
 vcl/win/gdi/winlayout.cxx |   24 +---
 2 files changed, 22 insertions(+), 4 deletions(-)

New commits:
commit ca4e75d694a5fb41a1c800146319aa6ba34d8bab
Author: Jan-Marek Glogowski 
Date:   Tue Jul 10 09:23:10 2018 +0200

Revert "tdf#117517: Fix OpenGL text rendering on Windows"

This actually breaks the OpenGL glyph cache, which forced a full
redraw all the time working around the original problem, which
is now fixed with commit fad862e290d727fc9fefe206f6e4b807482c4175.

This reverts commit c5f8a296fcfc08f8ac441cb8300a7565caa50b53.

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

diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 0b7c23bfc9a5..0ef5cc03b846 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -150,7 +150,7 @@ class WinFontInstance : public LogicalFontInstance
 public:
 virtual ~WinFontInstance() override;
 
-bool CacheGlyphToAtlas(HDC hDC, int nGlyphIndex, SalGraphics& rGraphics);
+bool CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& 
rGraphics);
 GlyphCache& GetGlyphCache() { return maGlyphCache; }
 bool hasHScale() const;
 
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 0cd916952b3e..fa0c2b683387 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -55,10 +55,24 @@ GlobalGlyphCache * GlobalGlyphCache::get() {
 return data->m_pGlobalGlyphCache.get();
 }
 
-bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, int nGlyphIndex, SalGraphics& 
rGraphics)
+bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, 
SalGraphics& rGraphics)
 {
 OpenGLGlyphDrawElement aElement;
 
+ScopedHDC aHDC(CreateCompatibleDC(hDC));
+
+if (!aHDC)
+{
+SAL_WARN("vcl.gdi", "CreateCompatibleDC failed: " << 
WindowsErrorString(GetLastError()));
+return false;
+}
+HFONT hOrigFont = static_cast(SelectObject(aHDC.get(), hFont));
+if (hOrigFont == nullptr)
+{
+SAL_WARN("vcl.gdi", "SelectObject failed: " << 
WindowsErrorString(GetLastError()));
+return false;
+}
+
 // For now we assume DWrite is present and we won't bother with fallback 
paths.
 D2DWriteTextOutRenderer * pTxt = dynamic_cast(::get(true));
 if (!pTxt)
@@ -66,7 +80,7 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, int 
nGlyphIndex, SalGraphics& r
 
 pTxt->changeTextAntiAliasMode(D2DTextAntiAliasMode::AntiAliased);
 
-if (!pTxt->BindFont(hDC))
+if (!pTxt->BindFont(aHDC.get()))
 {
 SAL_WARN("vcl.gdi", "Binding of font failed. The font might not be 
supported by DirectWrite.");
 return false;
@@ -179,6 +193,7 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, int 
nGlyphIndex, SalGraphics& r
 break;
 default:
 SAL_WARN("vcl.gdi", "DrawGlyphRun-EndDraw failed: " << 
WindowsErrorString(GetLastError()));
+SelectFont(aDC.getCompatibleHDC(), hOrigFont);
 return false;
 }
 
@@ -191,6 +206,8 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, int 
nGlyphIndex, SalGraphics& r
 
 maGlyphCache.PutDrawElementInCache(aElement, nGlyphIndex);
 
+SelectFont(aDC.getCompatibleHDC(), hOrigFont);
+
 return true;
 }
 
@@ -386,6 +403,7 @@ bool WinSalGraphics::CacheGlyphs(const GenericSalLayout& 
rLayout)
 
 HDC hDC = getHDC();
 WinFontInstance& rFont = 
*static_cast(());
+HFONT hFONT = rFont.GetHFONT();
 
 int nStart = 0;
 Point aPos(0, 0);
@@ -394,7 +412,7 @@ bool WinSalGraphics::CacheGlyphs(const GenericSalLayout& 
rLayout)
 {
 if (!rFont.GetGlyphCache().IsGlyphCached(pGlyph->maGlyphId))
 {
-if (!rFont.CacheGlyphToAtlas(hDC, pGlyph->maGlyphId, *this))
+if (!rFont.CacheGlyphToAtlas(hDC, hFONT, pGlyph->maGlyphId, *this))
 return false;
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-07-09 Thread Jan-Marek Glogowski
 vcl/inc/win/salgdi.h  |   14 +-
 vcl/inc/win/winlayout.hxx |9 --
 vcl/win/gdi/salfont.cxx   |   63 +++---
 vcl/win/gdi/winlayout.cxx |   45 
 4 files changed, 90 insertions(+), 41 deletions(-)

New commits:
commit fad862e290d727fc9fefe206f6e4b807482c4175
Author: Jan-Marek Glogowski 
Date:   Mon Jul 9 09:06:55 2018 +0200

tdf#118555 fix HFONT fallback handing / lifecycle

Instead of storing the never changing DC in the WinFontInstance
store the HFONT, which is Windows logical font instance.

Then set the correct HFONT instance from the layout when rendering
its text.

This also changes the HFONT ownership and lifecycle. The HFONT
is moved from the mhFonts to the WinFontInstance, if available,
so it has a proper referenced lifecycle. The mhFonts is still
needed, as embedded font just supply an HFONT and no
WinFontInstance.

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

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 6b2e464bb0a1..85b92946226e 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -156,6 +156,18 @@ private:
 boolmbScreen : 1;   // is Screen compatible
 HWNDmhWnd;  // Window-Handle, when 
Window-Graphics
 
+/** HFONT lifecycle
+ *
+ * The HFONT has to be shared between mhFonts and mpWinFontEntry.
+ * As mpWinFontEntry is reference counted and just freed in SetFont, the 
HFONT is
+ * transferred from mhFonts to the mpWinFontEntry.
+ *
+ * We need the mhFonts list, as embedded fonts don't have a corresponding 
WinFontInstance
+ * so for these there is just the mhFonts entry.
+ *
+ * The HFONT object can just be assigned to mhFonts _or_ mpWinFontEntry!
+ **/
+
 HFONT   mhFonts[ MAX_FALLBACK ];// Font + Fallbacks
 rtl::Reference
 mpWinFontEntry[ MAX_FALLBACK ]; // pointer to the 
most recent font instance
@@ -173,6 +185,7 @@ private:
 
 bool CacheGlyphs(const GenericSalLayout& rLayout);
 bool DrawCachedGlyphs(const GenericSalLayout& rLayout);
+HFONT ImplDoSetFont(FontSelectPattern const * i_pFont, const 
PhysicalFontFace * i_pFontFace, float& o_rFontScale, HFONT& o_rOldFont);
 
 public:
 HDC getHDC() const { return mhLocalDC; }
@@ -198,7 +211,6 @@ public:
 
 HWND gethWnd();
 
-HFONT   ImplDoSetFont( FontSelectPattern const * i_pFont, 
const PhysicalFontFace * i_pFontFace, float& o_rFontScale, HFONT& o_rOldFont );
 
 public:
 explicit WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND 
hWnd,
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index d15b3d124472..0b7c23bfc9a5 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -148,21 +148,24 @@ class WinFontInstance : public LogicalFontInstance
 friend rtl::Reference 
WinFontFace::CreateFontInstance(const FontSelectPattern&) const;
 
 public:
-virtual ~WinFontInstance() override;
+virtual ~WinFontInstance() override;
 
 bool CacheGlyphToAtlas(HDC hDC, int nGlyphIndex, SalGraphics& rGraphics);
 GlyphCache& GetGlyphCache() { return maGlyphCache; }
 bool hasHScale() const;
 
-void SetHDC(const HDC);
+void SetHFONT(const HFONT);
 HFONT GetHFONT() const { return m_hFont; }
 
+// Prevend deletion of the HFONT in the WinFontInstance destructor
+// Used for the ScopedFont handling
+void UnsetHFONT() { m_hFont = nullptr; }
+
 private:
 explicit WinFontInstance(const PhysicalFontFace&, const 
FontSelectPattern&);
 
 virtual hb_font_t* ImplInitHbFont() override;
 
-HDC m_hDC;
 HFONT m_hFont;
 GlyphCache maGlyphCache;
 };
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 2796f8686255..5cf7f4354480 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -884,6 +884,7 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const 
* i_pFont,
 if( hdcScreen )
 {
 // select font into screen hdc first to get an antialiased font
+// and instantly restore the default font!
 // see knowledge base article 305290:
 // "PRB: Fonts Not Drawn Antialiased on Device Context for DirectDraw 
Surface"
 SelectFont( hdcScreen, SelectFont( hdcScreen , hNewFont ) );
@@ -915,18 +916,22 @@ void WinSalGraphics::SetFont( const FontSelectPattern* 
pFont, int nFallbackLevel
 if( !pFont )
 {
 // deselect still active font
-if( mhDefFont )
-::SelectFont( getHDC(), mhDefFont );
+if (mhDefFont)
+{
+::SelectFont(getHDC(), mhDefFont);
+mhDefFont = nullptr;
+}
 mfCurrentFontScale = 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-05-09 Thread Khaled Hosny
 vcl/inc/win/winlayout.hxx |2 +-
 vcl/win/gdi/winlayout.cxx |   24 +++-
 2 files changed, 4 insertions(+), 22 deletions(-)

New commits:
commit c5f8a296fcfc08f8ac441cb8300a7565caa50b53
Author: Khaled Hosny 
Date:   Wed May 9 19:41:27 2018 +0200

tdf#117517: Fix OpenGL text rendering on Windows

Use the HDC we already selected the HFONT on instead of creating a new HDC 
and
selecting the font on it, apparently selecting the font the second time 
fails.

Change-Id: I2a26469ce70bce763562b6cd2171707e482fb1d8
Reviewed-on: https://gerrit.libreoffice.org/54046
Tested-by: Jenkins 
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index ca0945949265..bd10aa997aa8 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -151,7 +151,7 @@ class WinFontInstance : public LogicalFontInstance
 public:
 virtual ~WinFontInstance() override;
 
-bool CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& 
rGraphics);
+bool CacheGlyphToAtlas(HDC hDC, int nGlyphIndex, SalGraphics& rGraphics);
 GlyphCache& GetGlyphCache() { return maGlyphCache; }
 bool hasHScale() const;
 
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 3188f7f3d0bb..3b7b6c044083 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -56,24 +56,10 @@ GlobalGlyphCache * GlobalGlyphCache::get() {
 return data->m_pGlobalGlyphCache.get();
 }
 
-bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, 
SalGraphics& rGraphics)
+bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, int nGlyphIndex, SalGraphics& 
rGraphics)
 {
 OpenGLGlyphDrawElement aElement;
 
-ScopedHDC aHDC(CreateCompatibleDC(hDC));
-
-if (!aHDC)
-{
-SAL_WARN("vcl.gdi", "CreateCompatibleDC failed: " << 
WindowsErrorString(GetLastError()));
-return false;
-}
-HFONT hOrigFont = static_cast(SelectObject(aHDC.get(), hFont));
-if (hOrigFont == nullptr)
-{
-SAL_WARN("vcl.gdi", "SelectObject failed: " << 
WindowsErrorString(GetLastError()));
-return false;
-}
-
 // For now we assume DWrite is present and we won't bother with fallback 
paths.
 D2DWriteTextOutRenderer * pTxt = dynamic_cast(::get(true));
 if (!pTxt)
@@ -81,7 +67,7 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT hFont, 
int nGlyphIndex, S
 
 pTxt->changeTextAntiAliasMode(D2DTextAntiAliasMode::AntiAliased);
 
-if (!pTxt->BindFont(aHDC.get()))
+if (!pTxt->BindFont(hDC))
 {
 SAL_WARN("vcl.gdi", "Binding of font failed. The font might not be 
supported by DirectWrite.");
 return false;
@@ -194,7 +180,6 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT 
hFont, int nGlyphIndex, S
 break;
 default:
 SAL_WARN("vcl.gdi", "DrawGlyphRun-EndDraw failed: " << 
WindowsErrorString(GetLastError()));
-SelectFont(aDC.getCompatibleHDC(), hOrigFont);
 return false;
 }
 
@@ -207,8 +192,6 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT 
hFont, int nGlyphIndex, S
 
 maGlyphCache.PutDrawElementInCache(aElement, nGlyphIndex);
 
-SelectFont(aDC.getCompatibleHDC(), hOrigFont);
-
 return true;
 }
 
@@ -406,7 +389,6 @@ bool WinSalGraphics::CacheGlyphs(const CommonSalLayout& 
rLayout)
 
 HDC hDC = getHDC();
 WinFontInstance& rFont = 
*static_cast(());
-HFONT hFONT = rFont.GetHFONT();
 
 int nStart = 0;
 Point aPos(0, 0);
@@ -415,7 +397,7 @@ bool WinSalGraphics::CacheGlyphs(const CommonSalLayout& 
rLayout)
 {
 if (!rFont.GetGlyphCache().IsGlyphCached(pGlyph->maGlyphId))
 {
-if (!rFont.CacheGlyphToAtlas(hDC, hFONT, pGlyph->maGlyphId, *this))
+if (!rFont.CacheGlyphToAtlas(hDC, pGlyph->maGlyphId, *this))
 return false;
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-05-04 Thread Noel Grandin
 vcl/inc/win/salgdi.h|1 -
 vcl/win/gdi/salfont.cxx |   24 +++-
 vcl/win/gdi/salgdi.cxx  |3 +--
 3 files changed, 8 insertions(+), 20 deletions(-)

New commits:
commit e74fd983e3195ea2867acd4b925e9899571a1651
Author: Noel Grandin 
Date:   Thu May 3 13:38:44 2018 +0200

tdf#117364 Special Character dialog grid font issues

Revert "tdf#113643 Editing tables in Impress lags terribly"
This reverts commit 13a1bc409d9b2f0d14f4d316b7977b1fc2eb3c8a.

Will probably need more sophisticated caching, so just revert this
for now.

Change-Id: I05cc26b911d3d138b57098656ea0c9c3c4e82592
Reviewed-on: https://gerrit.libreoffice.org/53784
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index f45d85c4c89c..23531842dde3 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -177,7 +177,6 @@ private:
 RGNDATA*mpClipRgnData;  // ClipRegion-Data
 RGNDATA*mpStdClipRgnData;   // Cache 
Standard-ClipRegion-Data
 int mnPenWidth; // line width
-const PhysicalFontFace* mpCurrentPhysicalFontFace; // the font face 
currently selected into the DC
 
 LogicalFontInstance* GetWinFontEntry(int nFallbackLevel);
 
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 0acdbd666bef..6fe84173c710 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -57,22 +57,10 @@
 
 using namespace vcl;
 
-using BoundRectCacheKey = std::pair;
-namespace std
-{
-template<> struct hash
-{
-std::size_t operator()(const BoundRectCacheKey & key ) const
-{
-return std::hash()(key.first)
-^  std::hash()(key.second);
-}
-};
-};
 // GetGlyphOutlineW() seems to be a little slow, and doesn't seem to do it's 
own caching (tested on Windows10).
 // TODO include the font as part of the cache key, then we won't need to clear 
it on font change
 // The cache limit is set by the rough number of characters needed to read 
your average Asian newspaper.
-static o3tl::lru_map 
g_BoundRectCache(3000);
+static o3tl::lru_map g_BoundRectCache(3000);
 
 static const int MAXFONTHEIGHT = 2048;
 
@@ -852,9 +840,10 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
 
 HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const * i_pFont, float& 
o_rFontScale, HFONT& o_rOldFont)
 {
-mpCurrentPhysicalFontFace = i_pFont->mpFontData;
-
+// clear the cache on font change
+g_BoundRectCache.clear();
 HFONT hNewFont = nullptr;
+
 HDC hdcScreen = nullptr;
 if( mbVirDev )
 // only required for virtual devices, see below for details
@@ -1366,7 +1355,7 @@ void WinSalGraphics::ClearDevFontCache()
 
 bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, 
tools::Rectangle& rRect)
 {
-auto it = 
g_BoundRectCache.find({mpCurrentPhysicalFontFace,rGlyph.maGlyphId});
+auto it = g_BoundRectCache.find(rGlyph.maGlyphId);
 if (it != g_BoundRectCache.end())
 {
 rRect = it->second;
@@ -1397,7 +1386,8 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& 
rGlyph, tools::Rectangle
 rRect.SetTop(static_cast( mfCurrentFontScale * rRect.Top() ));
 rRect.SetBottom(static_cast( mfCurrentFontScale * rRect.Bottom() ) + 
1);
 
-g_BoundRectCache.insert({{mpCurrentPhysicalFontFace,rGlyph.maGlyphId}, 
rRect});
+g_BoundRectCache.insert({rGlyph.maGlyphId, rRect});
+
 return true;
 }
 
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 890b28cc0c57..8aa601a461b2 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -614,8 +614,7 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, 
bool bScreen, HWND hW
 mhDefFont(nullptr),
 mhDefPal(nullptr),
 mpStdClipRgnData(nullptr),
-mnPenWidth(GSL_PEN_WIDTH),
-mpCurrentPhysicalFontFace(nullptr)
+mnPenWidth(GSL_PEN_WIDTH)
 {
 if (OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter)
 mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this, pProvider));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-04-26 Thread Noel Grandin
 vcl/inc/win/salgdi.h|1 +
 vcl/win/gdi/salfont.cxx |   24 +---
 vcl/win/gdi/salgdi.cxx  |3 ++-
 3 files changed, 20 insertions(+), 8 deletions(-)

New commits:
commit 13a1bc409d9b2f0d14f4d316b7977b1fc2eb3c8a
Author: Noel Grandin 
Date:   Tue Apr 24 08:36:58 2018 +0200

tdf#113643 Editing tables in Impress lags terribly

Despite my previous commit here, the time was still being spent building
bound rect's for font glyphs, so improve the caching so we don't need to
clear it when we change the font selected into the DC.

Change-Id: Iee8230fc76d9d809f3521d016e4ce9a6555e6f65
Reviewed-on: https://gerrit.libreoffice.org/53371
Reviewed-by: Noel Grandin 
Tested-by: Noel Grandin 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 23531842dde3..f45d85c4c89c 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -177,6 +177,7 @@ private:
 RGNDATA*mpClipRgnData;  // ClipRegion-Data
 RGNDATA*mpStdClipRgnData;   // Cache 
Standard-ClipRegion-Data
 int mnPenWidth; // line width
+const PhysicalFontFace* mpCurrentPhysicalFontFace; // the font face 
currently selected into the DC
 
 LogicalFontInstance* GetWinFontEntry(int nFallbackLevel);
 
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 6fe84173c710..0acdbd666bef 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -57,10 +57,22 @@
 
 using namespace vcl;
 
+using BoundRectCacheKey = std::pair;
+namespace std
+{
+template<> struct hash
+{
+std::size_t operator()(const BoundRectCacheKey & key ) const
+{
+return std::hash()(key.first)
+^  std::hash()(key.second);
+}
+};
+};
 // GetGlyphOutlineW() seems to be a little slow, and doesn't seem to do it's 
own caching (tested on Windows10).
 // TODO include the font as part of the cache key, then we won't need to clear 
it on font change
 // The cache limit is set by the rough number of characters needed to read 
your average Asian newspaper.
-static o3tl::lru_map g_BoundRectCache(3000);
+static o3tl::lru_map 
g_BoundRectCache(3000);
 
 static const int MAXFONTHEIGHT = 2048;
 
@@ -840,10 +852,9 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
 
 HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const * i_pFont, float& 
o_rFontScale, HFONT& o_rOldFont)
 {
-// clear the cache on font change
-g_BoundRectCache.clear();
-HFONT hNewFont = nullptr;
+mpCurrentPhysicalFontFace = i_pFont->mpFontData;
 
+HFONT hNewFont = nullptr;
 HDC hdcScreen = nullptr;
 if( mbVirDev )
 // only required for virtual devices, see below for details
@@ -1355,7 +1366,7 @@ void WinSalGraphics::ClearDevFontCache()
 
 bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, 
tools::Rectangle& rRect)
 {
-auto it = g_BoundRectCache.find(rGlyph.maGlyphId);
+auto it = 
g_BoundRectCache.find({mpCurrentPhysicalFontFace,rGlyph.maGlyphId});
 if (it != g_BoundRectCache.end())
 {
 rRect = it->second;
@@ -1386,8 +1397,7 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& 
rGlyph, tools::Rectangle
 rRect.SetTop(static_cast( mfCurrentFontScale * rRect.Top() ));
 rRect.SetBottom(static_cast( mfCurrentFontScale * rRect.Bottom() ) + 
1);
 
-g_BoundRectCache.insert({rGlyph.maGlyphId, rRect});
-
+g_BoundRectCache.insert({{mpCurrentPhysicalFontFace,rGlyph.maGlyphId}, 
rRect});
 return true;
 }
 
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 8aa601a461b2..890b28cc0c57 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -614,7 +614,8 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, 
bool bScreen, HWND hW
 mhDefFont(nullptr),
 mhDefPal(nullptr),
 mpStdClipRgnData(nullptr),
-mnPenWidth(GSL_PEN_WIDTH)
+mnPenWidth(GSL_PEN_WIDTH),
+mpCurrentPhysicalFontFace(nullptr)
 {
 if (OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter)
 mpImpl.reset(new WinOpenGLSalGraphicsImpl(*this, pProvider));
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-04-17 Thread Khaled Hosny
 vcl/inc/win/salgdi.h|4 +++-
 vcl/win/gdi/salfont.cxx |   48 ++--
 vcl/win/gdi/salgdi.cxx  |2 ++
 3 files changed, 43 insertions(+), 11 deletions(-)

New commits:
commit 335036f0d05bdfde49cacf245863c686d07a2d5f
Author: Khaled Hosny 
Date:   Mon Apr 16 22:30:50 2018 +0200

tdf#116812: Revert "The mfFontScale[n] is always 1.0"

This reverts commit 1b7e788eb3bf9cbe56ed5cc4a3fa7fa5e70ac40a
and followup commit 843c6d6eec95b99e867c28ab27860215d5d72b37.

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

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index b1edef997d85..23531842dde3 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -166,6 +166,8 @@ private:
 HFONT   mhFonts[ MAX_FALLBACK ];// Font + Fallbacks
 const WinFontFace*  mpWinFontData[ MAX_FALLBACK ];  // pointer to the most 
recent font face
 WinFontInstance*   mpWinFontEntry[ MAX_FALLBACK ]; // pointer to the 
most recent font instance
+float   mfFontScale[ MAX_FALLBACK ];// allows 
metrics emulation of huge font sizes
+float   mfCurrentFontScale;
 HRGNmhRegion;   // vcl::Region Handle
 HPENmhDefPen;   // DefaultPen
 HBRUSH  mhDefBrush; // DefaultBrush
@@ -205,7 +207,7 @@ public:
 
 HWND gethWnd();
 
-HFONT   ImplDoSetFont( FontSelectPattern const * i_pFont, 
HFONT& o_rOldFont );
+HFONT   ImplDoSetFont( FontSelectPattern const * i_pFont, 
float& o_rFontScale, HFONT& o_rOldFont );
 
 public:
 explicit WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND 
hWnd,
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 7c6bb027f245..f9b9418ccb75 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -62,6 +62,8 @@ using namespace vcl;
 // The cache limit is set by the rough number of characters needed to read 
your average Asian newspaper.
 static o3tl::lru_map g_BoundRectCache(3000);
 
+static const int MAXFONTHEIGHT = 2048;
+
 inline FIXED FixedFromDouble( double d )
 {
 const long l = static_cast( d * 65536. );
@@ -838,11 +840,10 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
 }
 }
 
-HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const * i_pFont, HFONT& 
o_rOldFont)
+HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const * i_pFont, float& 
o_rFontScale, HFONT& o_rOldFont)
 {
 // clear the cache on font change
 g_BoundRectCache.clear();
-
 HFONT hNewFont = nullptr;
 
 HDC hdcScreen = nullptr;
@@ -853,6 +854,26 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern 
const * i_pFont, HFONT& o_
 LOGFONTW aLogFont;
 ImplGetLogFontFromFontSelect( getHDC(), i_pFont, aLogFont, true );
 
+// #i47675# limit font requests to MAXFONTHEIGHT
+// TODO: share MAXFONTHEIGHT font instance
+if( (-aLogFont.lfHeight <= MAXFONTHEIGHT)
+&&  (+aLogFont.lfWidth <= MAXFONTHEIGHT) )
+{
+o_rFontScale = 1.0;
+}
+else if( -aLogFont.lfHeight >= +aLogFont.lfWidth )
+{
+o_rFontScale = -aLogFont.lfHeight / (float)MAXFONTHEIGHT;
+aLogFont.lfHeight = -MAXFONTHEIGHT;
+aLogFont.lfWidth = FRound( aLogFont.lfWidth / o_rFontScale );
+}
+else // #i95867# also limit font widths
+{
+o_rFontScale = +aLogFont.lfWidth / (float)MAXFONTHEIGHT;
+aLogFont.lfWidth = +MAXFONTHEIGHT;
+aLogFont.lfHeight = FRound( aLogFont.lfHeight / o_rFontScale );
+}
+
 hNewFont = ::CreateFontIndirectW(  );
 if( hdcScreen )
 {
@@ -890,6 +911,7 @@ void WinSalGraphics::SetFont( const FontSelectPattern* 
pFont, int nFallbackLevel
 // deselect still active font
 if( mhDefFont )
 ::SelectFont( getHDC(), mhDefFont );
+mfCurrentFontScale = mfFontScale[nFallbackLevel];
 // release no longer referenced font handles
 for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i )
 {
@@ -922,7 +944,8 @@ void WinSalGraphics::SetFont( const FontSelectPattern* 
pFont, int nFallbackLevel
 mpWinFontData[ nFallbackLevel ] = static_cast( 
pFont->mpFontData );
 
 HFONT hOldFont = nullptr;
-HFONT hNewFont = ImplDoSetFont(pFont, hOldFont);
+HFONT hNewFont = ImplDoSetFont(pFont, mfFontScale[ nFallbackLevel ], 
hOldFont);
+mfCurrentFontScale = mfFontScale[nFallbackLevel];
 
 if( !mhDefFont )
 {
@@ -971,7 +994,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& 
rxFontMetric, int nFa
 {
 int nKashidaWidth = 0;
 if (GetCharWidthI(getHDC(), nKashidaGid, 1, nullptr, ))
-

[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-03-19 Thread Jan-Marek Glogowski
 vcl/inc/win/saldata.hxx |2 +-
 vcl/inc/win/salframe.h  |4 ++--
 vcl/win/app/salinst.cxx |2 +-
 vcl/win/window/salframe.cxx |   17 -
 4 files changed, 8 insertions(+), 17 deletions(-)

New commits:
commit 8939cb9456ee76a848cc8089747f280751092cf8
Author: Jan-Marek Glogowski 
Date:   Wed Mar 14 20:05:50 2018 +0100

tdf#115420 fix DC usecount and drop wrong asserts

For DC initialization we check the thread ID to assign a normal
or cached DC to the corresponding WinSalGraphics variable.
The cached DC has a usage count, as there are some limits on
cached DCs count (DCX_CACHE).

But for the WinSalGraphics DC init and release the variable just
matters for the accounting, and generally which thread is doing
the calls: the non-main thread always has to relay them to the
main application thread.

Since we're releasing all WinSalGraphics in ~WinSalFrame and do
all release and re-init in ImplSetParentFrame, there is no way
to correspond the thread ID to the WinSalGraphics variable.

So this drops the wrong assertions based on the WinSalGraphics
variables and renames the GETDC message to GETCACHEDDC to make
usage of a cached DC (DCX_CACHE) more obvious.
As a consequence of the different release DC handling this also
fixes the accounting of the cached DCs, wich was broken in the
initial fix; commit c15ea73f960bbd3d2a4b0c43b467ac62eeba3505

Change-Id: I11ce52a1b4005f26567f92588437fa37bf227a2e
Reviewed-on: https://gerrit.libreoffice.org/51318
Tested-by: Jenkins 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 45c402363119..8f5a3b87b415 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -215,7 +215,7 @@ int ImplSalWICompareAscii( const wchar_t* pStr1, const 
char* pStr2 );
 // wParam == 0; lParam == pObject;
 #define SAL_MSG_DESTROYOBJECT   (WM_USER+117)
 // wParam == hWnd; lParam == 0; lResult == hDC
-#define SAL_MSG_GETDC   (WM_USER+120)
+#define SAL_MSG_GETCACHEDDC (WM_USER+120)
 // wParam == hWnd; lParam == 0
 #define SAL_MSG_RELEASEDC   (WM_USER+121)
 // wParam == newParentHwnd; lParam == oldHwnd; lResult == newhWnd
diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h
index 77902a40034e..36e4a041c955 100644
--- a/vcl/inc/win/salframe.h
+++ b/vcl/inc/win/salframe.h
@@ -33,8 +33,8 @@ public:
 HWNDmhWnd;  // Window handle
 HCURSOR mhCursor;   // cursor handle
 HIMCmhDefIMEContext;// default IME-Context
-WinSalGraphics* mpLocalGraphics;// current local frame 
graphics
-WinSalGraphics* mpThreadGraphics;   // current frame graphics 
for other threads
+WinSalGraphics* mpLocalGraphics;// current main thread 
frame graphics
+WinSalGraphics* mpThreadGraphics;   // current frame graphics 
for other threads (DCX_CACHE)
 WinSalFrame*mpNextFrame;// pointer to next frame
 HMENU   mSelectedhMenu; // the menu where 
highlighting is currently going on
 HMENU   mLastActivatedhMenu;// the menu that was most 
recently opened
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index c5274364f747..02b9e76d65c1 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -630,7 +630,7 @@ LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM 
wParam, LPARAM lParam, b
 CASE_NOYIELDLOCK_RESULT( SAL_MSG_CREATEOBJECT, ImplSalCreateObject(
 GetSalData()->mpInstance, reinterpret_cast(lParam)) )
 CASE_NOYIELDLOCK( SAL_MSG_DESTROYOBJECT, delete 
reinterpret_cast(lParam) )
-CASE_NOYIELDLOCK_RESULT( SAL_MSG_GETDC, GetDCEx(
+CASE_NOYIELDLOCK_RESULT( SAL_MSG_GETCACHEDDC, GetDCEx(
 reinterpret_cast(wParam), nullptr, DCX_CACHE) )
 CASE_NOYIELDLOCK( SAL_MSG_RELEASEDC, ReleaseDC(
 reinterpret_cast(wParam), reinterpret_cast(lParam)) )
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index b7e8472a0934..57ac8512daf7 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -920,17 +920,12 @@ bool WinSalFrame::ReleaseFrameGraphicsDC( WinSalGraphics* 
pGraphics )
 // we don't want to run the WinProc in the main thread directly
 // so we don't hit the mbNoYieldLock assert
 if ( !pSalData->mpInstance->IsMainThread() )
-{
-assert( pGraphics == mpThreadGraphics );
 SendMessageW( pSalData->mpInstance->mhComWnd, SAL_MSG_RELEASEDC,
 reinterpret_cast(mhWnd), reinterpret_cast(hDC) );
-pSalData->mnCacheDCInUse--;
-}
 else
-{
-assert( pGraphics == mpLocalGraphics );

[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-03-08 Thread Jan-Marek Glogowski
 vcl/inc/win/salframe.h  |6 
 vcl/win/window/salframe.cxx |  302 
 2 files changed, 147 insertions(+), 161 deletions(-)

New commits:
commit c15ea73f960bbd3d2a4b0c43b467ac62eeba3505
Author: Jan-Marek Glogowski 
Date:   Wed Mar 7 12:48:59 2018 +0100

tdf#115420 WIN clean up WinSalFrames DC handling

We still don't return a SalGraphics object from AcquireGraphics
without a valid DC. But internally we keep the WinSalGraphics
objects around, so we now have to verify the DC before using it.

In the end this also fixes the leak of the threaded SalGraphics
of the frame.

Change-Id: I267c96c04b7d00cb66a6c84c63d1373ebe0f529f
Reviewed-on: https://gerrit.libreoffice.org/50908
Tested-by: Jenkins 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h
index 002b6731c72b..77902a40034e 100644
--- a/vcl/inc/win/salframe.h
+++ b/vcl/inc/win/salframe.h
@@ -82,6 +82,12 @@ public:
 boolmbPropertiesStored; // has values stored in 
the window property store
 
 void updateScreenNumber();
+
+private:
+void ImplSetParentFrame( HWND hNewParentWnd, bool bAsChild );
+bool InitFrameGraphicsDC( WinSalGraphics *pGraphics, HDC hDC, HWND hWnd );
+bool ReleaseFrameGraphicsDC( WinSalGraphics* pGraphics );
+
 public:
 WinSalFrame();
 virtual ~WinSalFrame() override;
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 74fb14120c6c..75784736c4e8 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -907,6 +907,34 @@ void WinSalFrame::updateScreenNumber()
 }
 }
 
+bool WinSalFrame::ReleaseFrameGraphicsDC( WinSalGraphics* pGraphics )
+{
+assert( pGraphics );
+SalData* pSalData = GetSalData();
+HDC hDC = pGraphics->getHDC();
+if ( !hDC )
+return FALSE;
+if ( pGraphics->getDefPal() )
+SelectPalette( hDC, pGraphics->getDefPal(), TRUE );
+pGraphics->DeInitGraphics();
+// we don't want to run the WinProc in the main thread directly
+// so we don't hit the mbNoYieldLock assert
+if ( !pSalData->mpInstance->IsMainThread() )
+{
+assert( pGraphics == mpThreadGraphics );
+SendMessageW( pSalData->mpInstance->mhComWnd, SAL_MSG_RELEASEDC,
+reinterpret_cast(mhWnd), reinterpret_cast(hDC) );
+pSalData->mnCacheDCInUse--;
+}
+else
+{
+assert( pGraphics == mpLocalGraphics );
+ReleaseDC( mhWnd, hDC );
+}
+pGraphics->setHDC(nullptr);
+return TRUE;
+}
+
 WinSalFrame::~WinSalFrame()
 {
 SalData* pSalData = GetSalData();
@@ -921,18 +949,18 @@ WinSalFrame::~WinSalFrame()
 *ppFrame = mpNextFrame;
 mpNextFrame = nullptr;
 
-// Release Cache DC
-if ( mpThreadGraphics &&
- mpThreadGraphics->getHDC() )
-ReleaseGraphics( mpThreadGraphics );
+// destroy the thread SalGraphics
+if ( mpThreadGraphics )
+{
+ReleaseFrameGraphicsDC( mpThreadGraphics );
+delete mpThreadGraphics;
+mpThreadGraphics = nullptr;
+}
 
-// destroy saved DC
+// destroy the local SalGraphics
 if ( mpLocalGraphics )
 {
-if ( mpLocalGraphics->getDefPal() )
-SelectPalette( mpLocalGraphics->getHDC(), 
mpLocalGraphics->getDefPal(), TRUE );
-mpLocalGraphics->DeInitGraphics();
-ReleaseDC( mhWnd, mpLocalGraphics->getHDC() );
+ReleaseFrameGraphicsDC( mpLocalGraphics );
 delete mpLocalGraphics;
 mpLocalGraphics = nullptr;
 }
@@ -962,16 +990,50 @@ WinSalFrame::~WinSalFrame()
 }
 }
 
+bool WinSalFrame::InitFrameGraphicsDC( WinSalGraphics *pGraphics, HDC hDC, 
HWND hWnd )
+{
+SalData* pSalData = GetSalData();
+assert( pGraphics );
+if ( !pSalData->mpInstance->IsMainThread() )
+assert( pGraphics == mpThreadGraphics );
+else
+assert( pGraphics == mpLocalGraphics );
+pGraphics->setHWND( hWnd );
+
+HDC hCurrentDC = pGraphics->getHDC();
+assert( !hCurrentDC || (hCurrentDC == hDC) );
+if ( hCurrentDC )
+return TRUE;
+pGraphics->setHDC( hDC );
+
+if ( !hDC )
+return FALSE;
+
+if ( pSalData->mhDitherPal )
+{
+pGraphics->setDefPal(SelectPalette( hDC, pSalData->mhDitherPal, TRUE 
));
+RealizePalette( hDC );
+}
+pGraphics->InitGraphics();
+
+if ( pGraphics == mpThreadGraphics )
+pSalData->mnCacheDCInUse++;
+return TRUE;
+}
+
 SalGraphics* WinSalFrame::AcquireGraphics()
 {
-if ( mbGraphics )
+if ( mbGraphics || !mhWnd )
 return nullptr;
 
+SalData* pSalData = GetSalData();
+WinSalGraphics *pGraphics = nullptr;
+HDC hDC = 0;
+
 // Other threads get an own DC, because Windows modify in the
 // other case our DC (changing clip region), when they send a
 // WM_ERASEBACKGROUND message
- 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2018-03-08 Thread Jan-Marek Glogowski
 vcl/inc/win/salframe.h  |4 -
 vcl/win/window/salframe.cxx |  144 ++--
 2 files changed, 74 insertions(+), 74 deletions(-)

New commits:
commit 352bd98892c1cdf95756a49f38c84212eebffd7b
Author: Jan-Marek Glogowski 
Date:   Wed Mar 7 17:16:55 2018 +0100

WIN rename SalFrames SalGraphics pointers

This renames mpGraphics => mpLocalGraphics and mpGraphics2 to
mpThreadGraphics.

Change-Id: I649b956abc9587f1be74872d439fefc5f5b21135
Reviewed-on: https://gerrit.libreoffice.org/50907
Tested-by: Jenkins 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/salframe.h b/vcl/inc/win/salframe.h
index 3ee87512c9cc..002b6731c72b 100644
--- a/vcl/inc/win/salframe.h
+++ b/vcl/inc/win/salframe.h
@@ -33,8 +33,8 @@ public:
 HWNDmhWnd;  // Window handle
 HCURSOR mhCursor;   // cursor handle
 HIMCmhDefIMEContext;// default IME-Context
-WinSalGraphics* mpGraphics; // current frame graphics
-WinSalGraphics* mpGraphics2;// current frame graphics 
for other threads
+WinSalGraphics* mpLocalGraphics;// current local frame 
graphics
+WinSalGraphics* mpThreadGraphics;   // current frame graphics 
for other threads
 WinSalFrame*mpNextFrame;// pointer to next frame
 HMENU   mSelectedhMenu; // the menu where 
highlighting is currently going on
 HMENU   mLastActivatedhMenu;// the menu that was most 
recently opened
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 06f3b709cb5f..74fb14120c6c 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -826,8 +826,8 @@ WinSalFrame::WinSalFrame()
 mhWnd   = nullptr;
 mhCursor= LoadCursor( nullptr, IDC_ARROW );
 mhDefIMEContext = nullptr;
-mpGraphics  = nullptr;
-mpGraphics2 = nullptr;
+mpLocalGraphics = nullptr;
+mpThreadGraphics= nullptr;
 mnShowState = SW_SHOWNORMAL;
 mnWidth = 0;
 mnHeight= 0;
@@ -922,19 +922,19 @@ WinSalFrame::~WinSalFrame()
 mpNextFrame = nullptr;
 
 // Release Cache DC
-if ( mpGraphics2 &&
- mpGraphics2->getHDC() )
-ReleaseGraphics( mpGraphics2 );
+if ( mpThreadGraphics &&
+ mpThreadGraphics->getHDC() )
+ReleaseGraphics( mpThreadGraphics );
 
 // destroy saved DC
-if ( mpGraphics )
+if ( mpLocalGraphics )
 {
-if ( mpGraphics->getDefPal() )
-SelectPalette( mpGraphics->getHDC(), mpGraphics->getDefPal(), TRUE 
);
-mpGraphics->DeInitGraphics();
-ReleaseDC( mhWnd, mpGraphics->getHDC() );
-delete mpGraphics;
-mpGraphics = nullptr;
+if ( mpLocalGraphics->getDefPal() )
+SelectPalette( mpLocalGraphics->getHDC(), 
mpLocalGraphics->getDefPal(), TRUE );
+mpLocalGraphics->DeInitGraphics();
+ReleaseDC( mhWnd, mpLocalGraphics->getHDC() );
+delete mpLocalGraphics;
+mpLocalGraphics = nullptr;
 }
 
 if ( mhWnd )
@@ -978,10 +978,10 @@ SalGraphics* WinSalFrame::AcquireGraphics()
 if ( pSalData->mnCacheDCInUse >= 3 )
 return nullptr;
 
-if ( !mpGraphics2 )
+if ( !mpThreadGraphics )
 {
-mpGraphics2 = new WinSalGraphics(WinSalGraphics::WINDOW, true, 
mhWnd, this);
-mpGraphics2->setHDC(nullptr);
+mpThreadGraphics = new WinSalGraphics(WinSalGraphics::WINDOW, 
true, mhWnd, this);
+mpThreadGraphics->setHDC(nullptr);
 }
 
 HDC hDC = reinterpret_cast(static_cast(SendMessageW( 
pSalData->mpInstance->mhComWnd,
@@ -989,66 +989,66 @@ SalGraphics* WinSalFrame::AcquireGraphics()
 reinterpret_cast(mhWnd), 0 )));
 if ( hDC )
 {
-mpGraphics2->setHDC(hDC);
+mpThreadGraphics->setHDC(hDC);
 if ( pSalData->mhDitherPal )
 {
-mpGraphics2->setDefPal(SelectPalette( hDC, 
pSalData->mhDitherPal, TRUE ));
+mpThreadGraphics->setDefPal(SelectPalette( hDC, 
pSalData->mhDitherPal, TRUE ));
 RealizePalette( hDC );
 }
-mpGraphics2->InitGraphics();
+mpThreadGraphics->InitGraphics();
 mbGraphics = TRUE;
 
 pSalData->mnCacheDCInUse++;
-return mpGraphics2;
+return mpThreadGraphics;
 }
 else
 return nullptr;
 }
 else
 {
-if ( !mpGraphics )
+if ( !mpLocalGraphics )
 {
 HDC hDC = GetDC( mhWnd );
 if ( hDC )
 {
-mpGraphics = new 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-10-13 Thread Jan-Marek Glogowski
 vcl/inc/win/saltimer.h  |6 +
 vcl/win/app/salinst.cxx |  175 +++-
 2 files changed, 150 insertions(+), 31 deletions(-)

New commits:
commit 3bf6c97029d26ddf20007c47ca6b68e5cc52d846
Author: Jan-Marek Glogowski 
Date:   Thu Oct 12 10:20:17 2017 +0200

tdf#112975 WIN correctly handle VclInputFlags::OTHER

On Windows we can just check the message queue for existing
messages. But VclInputFlags::OTHER is used to check for any
messages, which can't be explicitly checked.

In the case of checking for VclInputFlags::OTHER while
excluding an other message type, we have to make multiple
PeekMessage calls and exclude all non-checked message ids.

Change-Id: I1cedd4b76444769842c74228fc547f0d924f8b60
Reviewed-on: https://gerrit.libreoffice.org/43337
Tested-by: Jenkins 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/saltimer.h b/vcl/inc/win/saltimer.h
index 37976bbfaf8b..68973e1cadc3 100644
--- a/vcl/inc/win/saltimer.h
+++ b/vcl/inc/win/saltimer.h
@@ -47,6 +47,7 @@ public:
 virtual void Stop() override;
 
 inline bool IsDirectTimeout() const;
+inline bool HasTimerElapsed() const;
 };
 
 inline bool WinSalTimer::IsDirectTimeout() const
@@ -54,6 +55,11 @@ inline bool WinSalTimer::IsDirectTimeout() const
 return m_bDirectTimeout;
 }
 
+inline bool WinSalTimer::HasTimerElapsed() const
+{
+return m_bDirectTimeout || ExistsValidEvent();
+}
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 38db3d3bb17c..ade332297fc6 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -689,10 +689,119 @@ LRESULT CALLBACK SalComWndProcW( HWND hWnd, UINT nMsg, 
WPARAM wParam, LPARAM lPa
 return nRet;
 }
 
+struct MsgRange
+{
+UINT nStart;
+UINT nEnd;
+};
+
+static std::vector GetOtherRanges( VclInputFlags nType )
+{
+assert( nType != VCL_INPUT_ANY );
+
+// this array must be kept sorted!
+const UINT nExcludeMsgIds[] =
+{
+0,
+
+WM_MOVE, // 3
+WM_SIZE, // 5
+WM_PAINT, // 15
+WM_KEYDOWN, // 256
+WM_TIMER, // 275
+
+WM_MOUSEFIRST, // 512
+513,
+514,
+515,
+516,
+517,
+518,
+519,
+520,
+WM_MOUSELAST, // 521
+
+SAL_MSG_POSTMOVE, // WM_USER+136
+SAL_MSG_POSTCALLSIZE, // WM_USER+137
+
+SAL_MSG_TIMER_CALLBACK, // WM_USER+162
+
+UINT_MAX
+};
+const unsigned MAX_EXCL = SAL_N_ELEMENTS( nExcludeMsgIds );
+
+bool aExcludeMsgList[ MAX_EXCL ] = { false, };
+std::vector aResult;
+
+// set the excluded values
+if ( !(nType & VclInputFlags::MOUSE) )
+{
+for ( unsigned i = 0; nExcludeMsgIds[ 6 + i ] <= WM_MOUSELAST; ++i )
+aExcludeMsgList[ 6 + i ] = true;
+}
+
+if ( !(nType & VclInputFlags::KEYBOARD) )
+aExcludeMsgList[ 4 ] = true;
+
+if ( !(nType & VclInputFlags::PAINT) )
+{
+aExcludeMsgList[ 1 ] = true;
+aExcludeMsgList[ 2 ] = true;
+aExcludeMsgList[ 3 ] = true;
+aExcludeMsgList[ 16 ] = true;
+aExcludeMsgList[ 17 ] = true;
+}
+
+if ( !(nType & VclInputFlags::TIMER) )
+{
+aExcludeMsgList[ 5 ]  = true;
+aExcludeMsgList[ 18 ]  = true;
+}
+
+// build the message ranges to check
+MsgRange aRange = { 0, 0 };
+bool doEnd = true;
+for ( unsigned i = 1; i < MAX_EXCL; ++i )
+{
+if ( aExcludeMsgList[ i ] )
+{
+if ( !doEnd )
+{
+if ( nExcludeMsgIds[ i ] == aRange.nStart )
+++aRange.nStart;
+else
+doEnd = true;
+}
+if ( doEnd )
+{
+aRange.nEnd = nExcludeMsgIds[ i ] - 1;
+aResult.push_back( aRange );
+doEnd = false;
+aRange.nStart = aRange.nEnd + 2;
+}
+}
+}
+
+if ( aRange.nStart != UINT_MAX )
+{
+aRange.nEnd = UINT_MAX;
+aResult.push_back( aRange );
+}
+
+return aResult;
+}
+
 bool WinSalInstance::AnyInput( VclInputFlags nType )
 {
 MSG aMsg;
 
+if ( nType & VclInputFlags::TIMER )
+{
+const WinSalTimer* pTimer = static_cast( 
ImplGetSVData()->maSchedCtx.mpSalTimer );
+if ( pTimer && pTimer->HasTimerElapsed() )
+return true;
+}
+
 if ( (nType & VCL_INPUT_ANY) == VCL_INPUT_ANY )
 {
 // revert bugfix for #108919# which never reported timeouts when 
called from the timer handler
@@ -702,32 +811,52 @@ bool WinSalInstance::AnyInput( VclInputFlags nType )
 }
 else
 {
-if ( nType & VclInputFlags::MOUSE )
-{
-// Test for mouse input
-if ( PeekMessageW( , 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-09-27 Thread Noel Grandin
 vcl/inc/win/saldata.hxx |2 +-
 vcl/win/app/salinst.cxx |   30 +++---
 vcl/win/app/saltimer.cxx|   10 +-
 vcl/win/gdi/salprn.cxx  |4 ++--
 vcl/win/window/salframe.cxx |   12 ++--
 5 files changed, 29 insertions(+), 29 deletions(-)

New commits:
commit 7c52d86f7b05fe7e0178f6d98a12a531b88a32ff
Author: Noel Grandin 
Date:   Wed Sep 20 09:06:34 2017 +0200

rename mpFirstInstance->mpInstance

Change-Id: I472df5821cb74a16d5ea00a1939b0e1bdf9072aa
Reviewed-on: https://gerrit.libreoffice.org/42518
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 245d986915b1..db6771c8095e 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -87,7 +87,7 @@ public:
 HHOOK   mhSalObjMsgHook;// hook to get interesting 
msg for SalObject
 HWNDmhWantLeaveMsg; // window handle, that 
want a MOUSELEAVE message
 AutoTimer*  mpMouseLeaveTimer;  // Timer for MouseLeave 
Test
-WinSalInstance* mpFirstInstance;// pointer of first 
instance
+WinSalInstance* mpInstance;
 WinSalFrame*mpFirstFrame;   // pointer of first frame
 WinSalObject*   mpFirstObject;  // pointer of first object 
window
 WinSalVirtualDevice*mpFirstVD;  // first VirDev
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index b77e84eac739..487cf7fb09d2 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -137,7 +137,7 @@ void SalYieldMutex::BeforeReleaseHandler()
 /// this function to avoid deadlock
 void SalYieldMutex::doAcquire( sal_uInt32 nLockCount )
 {
-WinSalInstance* pInst = GetSalData()->mpFirstInstance;
+WinSalInstance* pInst = GetSalData()->mpInstance;
 if ( pInst && pInst->IsMainThread() )
 {
 if ( pInst->mbNoYieldLock )
@@ -170,7 +170,7 @@ void SalYieldMutex::doAcquire( sal_uInt32 nLockCount )
 
 sal_uInt32 SalYieldMutex::doRelease( const bool bUnlockAll )
 {
-WinSalInstance* pInst = GetSalData()->mpFirstInstance;
+WinSalInstance* pInst = GetSalData()->mpInstance;
 if ( pInst && pInst->mbNoYieldLock && pInst->IsMainThread() )
 return 1;
 
@@ -183,7 +183,7 @@ sal_uInt32 SalYieldMutex::doRelease( const bool bUnlockAll )
 
 bool SalYieldMutex::tryToAcquire()
 {
-WinSalInstance* pInst = GetSalData()->mpFirstInstance;
+WinSalInstance* pInst = GetSalData()->mpInstance;
 if ( pInst )
 {
 if ( pInst->mbNoYieldLock && pInst->IsMainThread() )
@@ -197,20 +197,20 @@ bool SalYieldMutex::tryToAcquire()
 
 void ImplSalYieldMutexAcquireWithWait( sal_uInt32 nCount )
 {
-WinSalInstance* pInst = GetSalData()->mpFirstInstance;
+WinSalInstance* pInst = GetSalData()->mpInstance;
 if ( pInst )
 pInst->mpSalYieldMutex->acquire( nCount );
 }
 
 bool ImplSalYieldMutexTryToAcquire()
 {
-WinSalInstance* pInst = GetSalData()->mpFirstInstance;
+WinSalInstance* pInst = GetSalData()->mpInstance;
 return pInst ? pInst->mpSalYieldMutex->tryToAcquire() : false;
 }
 
 void ImplSalYieldMutexRelease()
 {
-WinSalInstance* pInst = GetSalData()->mpFirstInstance;
+WinSalInstance* pInst = GetSalData()->mpInstance;
 if ( pInst )
 {
 GdiFlush();
@@ -220,11 +220,11 @@ void ImplSalYieldMutexRelease()
 
 bool SalYieldMutex::IsCurrentThread() const
 {
-if ( !GetSalData()->mpFirstInstance->mbNoYieldLock )
+if ( !GetSalData()->mpInstance->mbNoYieldLock )
 // For the Windows backend, the LO identifier is the system thread ID
 return m_nThreadId == GetCurrentThreadId();
 else
-return GetSalData()->mpFirstInstance->IsMainThread();
+return GetSalData()->mpInstance->IsMainThread();
 }
 
 void SalData::initKeyCodeMap()
@@ -270,7 +270,7 @@ SalData::SalData()
 mhSalObjMsgHook = nullptr;  // hook to get interesting msg for SalObject
 mhWantLeaveMsg = nullptr;   // window handle, that want a MOUSELEAVE 
message
 mpMouseLeaveTimer = nullptr; // Timer for MouseLeave Test
-mpFirstInstance = nullptr;  // pointer of first instance
+mpInstance = nullptr;  // pointer of first instance
 mpFirstFrame = nullptr; // pointer of first frame
 mpFirstObject = nullptr;// pointer of first object window
 mpFirstVD = nullptr;// first VirDev
@@ -436,7 +436,7 @@ SalInstance* CreateSalInstance()
 WinSalInstance* pInst = new WinSalInstance;
 
 // init instance (only one instance in this version !!!)
-pSalData->mpFirstInstance   = pInst;
+pSalData->mpInstance   = pInst;
 pInst->mhInst= pSalData->mhInst;
 pInst->mhComWnd  = hComWnd;
 
@@ -455,8 +455,8 @@ void DestroySalInstance( SalInstance* pInst )
 ImplFreeSalGDI();
 
 // reset instance
-if ( 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-08-01 Thread Jan-Marek Glogowski
 vcl/inc/win/saldata.hxx  |2 +-
 vcl/win/app/salinst.cxx  |   39 +--
 vcl/win/app/saltimer.cxx |   22 ++
 3 files changed, 20 insertions(+), 43 deletions(-)

New commits:
commit 50799a721c7ddcf9475a1b79984ed64ddd7cdf57
Author: Jan-Marek Glogowski 
Date:   Mon Jul 31 19:49:34 2017 +0200

tdf#109997 WIN don't post a callback event directly

I doesn't seem possible to post an event deterministically to the
end of the Windows message queue and then process this queued
events "in order".

PeekMessage and now even DispatchMessage process events out of
order - that's how this assert was hit. I was quite sure it would
not hit, but a simple resize proved me wrong. And the assert just
proved that all my assumptions were wrong :-(

So this gives up the whole idea of a short-circuit message queue
handling on Windows for busy processing of LO Idles and goes back
to some kind of the original "always timer" implementation. Since
the "parallel" processing of LO events after system messages
during DoYield  was dropped, this might be slower; or not.

In the end this simplifies the main loop almost to the starting
point, except for a little busy loop, if we wait for an Idle event
timer - not so busy acually, as we just switch to another local
thread, which hopefully is our idle timer waiting to fire.
A short-circuit with a little detour.

Change-Id: Id63a2a9e2a3b1501ad50a2c6f308a36efe55e68f

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index ed1d225b14b8..9ad5d9cfddf1 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -85,7 +85,7 @@ public:
 BYTE*   mpDitherLow;// Dither mapping table
 BYTE*   mpDitherHigh;   // Dither mapping table
 HANDLE  mnTimerId;  ///< Windows timer id
-boolmbOnIdleRunScheduler;   ///< Run the scheduler, if 
yield is idle
+boolmbOnIdleRunScheduler;   ///< Run yield until the 
scheduler processed the idle
 HHOOK   mhSalObjMsgHook;// hook to get interesting 
msg for SalObject
 HWNDmhWantLeaveMsg; // window handle, that 
want a MOUSELEAVE message
 AutoTimer*  mpMouseLeaveTimer;  // Timer for MouseLeave 
Test
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 6458fca73c43..7ea3bd526675 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -575,29 +575,20 @@ ImplSalYield( bool bWait, bool bHandleAllCurrentEvents )
 if ( bOneEvent )
 {
 bWasMsg = true;
-if ( !(aMsg.message == SAL_MSG_TIMER_CALLBACK && 1 == aMsg.wParam) 
)
-{
-TranslateMessage(  );
-ImplSalDispatchMessage(  );
-}
-else
-{
-// This is just the scheduler wakeup message, in case we're
-// waiting in GetMessageW
-// So we can just drop it, but we have to fix the accounting!
-assert( pSalData->mbOnIdleRunScheduler );
-++nMaxEvents;
-}
+TranslateMessage(  );
+ImplSalDispatchMessage(  );
 }
 else
-{
-if ( nMaxEvents && pSalData->mbOnIdleRunScheduler )
+// busy loop to catch the 0ms timeout
+// We don't need to busy loop, if we wait anyway.
+// Even if we didn't process the event directly, report it.
+if ( pSalData->mbOnIdleRunScheduler && !bWait )
 {
-pSalData->mbOnIdleRunScheduler = false;
-EmitTimerCallback();
+SwitchToThread();
+nMaxEvents++;
 bOneEvent = true;
+bWasMsg = true;
 }
-}
 } while( --nMaxEvents && bOneEvent );
 
 // Also check that we don't wait when application already has quit
@@ -606,11 +597,8 @@ ImplSalYield( bool bWait, bool bHandleAllCurrentEvents )
 if ( GetMessageW( , nullptr, 0, 0 ) )
 {
 // Ignore the scheduler wakeup message
-if ( !(aMsg.message == SAL_MSG_TIMER_CALLBACK && 1 == aMsg.wParam) 
)
-{
-TranslateMessage(  );
-ImplSalDispatchMessage(  );
-}
+TranslateMessage(  );
+ImplSalDispatchMessage(  );
 }
 }
 return bWasMsg;
@@ -735,9 +723,8 @@ LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM 
wParam, LPARAM lParam, i
 while ( PeekMessageW(, nullptr, SAL_MSG_TIMER_CALLBACK,
  SAL_MSG_TIMER_CALLBACK, PM_REMOVE | 
PM_NOYIELD | PM_QS_POSTMESSAGE) )
 assert( "Multiple timer messages in queue" );
-assert( 0 == 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-07-20 Thread Tomaž Vajngerl
 vcl/inc/win/DWriteTextRenderer.hxx |   13 ++--
 vcl/win/gdi/DWriteTextRenderer.cxx |  106 ++---
 vcl/win/gdi/winlayout.cxx  |3 -
 3 files changed, 84 insertions(+), 38 deletions(-)

New commits:
commit 3fdc41af6370a53f7db4e52104cfd3328ee40563
Author: Tomaž Vajngerl 
Date:   Wed Jul 19 23:28:31 2017 +0200

tdf#107166 improve AA mode selection, retry, more checks

Major problem when setting the render mode and the text antialias
mode is that when you set the render mode to something that isn't
compatible with the text antialias mode, then every next call will
cause an error (invalid parameters). So we need to be sure that we
never set incompatible modes. Additionally we just need to set it
one time when we create the surface and not every time we draw.

If we get the D2DERR_RECREATE_TARGET we can create a new render
target and retry the whole call. Somethimes this is not possible
so we try 3 times and the give up.

We need to add more checks where we exit early or not continue with
some calls as any additional calls could taint the draw state and
some things wouldn't be drawn. For example if we calculate the
sizes of 0 glyphs we shouldn't continue with binding the hDC with
an "empty" rectangle. This will fail and cause some text that is
called afterwards to not draw.

Change-Id: Iabbdbd7956e90ea84aea96824c0d985ca9020c59
Reviewed-on: https://gerrit.libreoffice.org/40211
Tested-by: Jenkins 
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/inc/win/DWriteTextRenderer.hxx 
b/vcl/inc/win/DWriteTextRenderer.hxx
index 611a134396f7..e87ef5fe977b 100755
--- a/vcl/inc/win/DWriteTextRenderer.hxx
+++ b/vcl/inc/win/DWriteTextRenderer.hxx
@@ -29,8 +29,9 @@
 enum class D2DTextAntiAliasMode
 {
 Default,
-ClearType,
+Aliased,
 AntiAliased,
+ClearType,
 };
 
 class D2DWriteTextOutRenderer : public TextOutRenderer
@@ -55,7 +56,7 @@ public:
 SalGraphics ,
 HDC hDC) override;
 
-bool BindDC(HDC hDC, tools::Rectangle const & rRect = tools::Rectangle(0, 
0, 1, 1));
+HRESULT BindDC(HDC hDC, tools::Rectangle const & rRect = 
tools::Rectangle(0, 0, 1, 1));
 
 bool BindFont(HDC hDC) /*override*/;
 bool ReleaseFont() /*override*/;
@@ -70,10 +71,8 @@ public:
 bool Ready() const;
 
 void applyTextAntiAliasMode();
-void setTextAntiAliasMode(D2DTextAntiAliasMode eMode)
-{
-meTextAntiAliasMode = eMode;
-}
+void changeTextAntiAliasMode(D2DTextAntiAliasMode eMode);
+
 private:
 static void CleanupModules();
 
@@ -82,6 +81,7 @@ private:
 D2DWriteTextOutRenderer & operator = (const D2DWriteTextOutRenderer &) = 
delete;
 
 bool GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** ppFontFace, float * 
lfSize) const;
+bool performRender(CommonSalLayout const , SalGraphics , 
HDC hDC, bool& bRetry);
 
 ID2D1Factory* mpD2DFactory;
 IDWriteFactory  * mpDWriteFactory;
@@ -93,7 +93,6 @@ private:
 float mlfEmHeight;
 HDC   mhDC;
 D2DTextAntiAliasMode meTextAntiAliasMode;
-IDWriteRenderingParams* mpRenderingParameters;
 };
 
 #endif // INCLUDED_VCL_INC_WIN_DWRITERENDERER_HXX
diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx 
b/vcl/win/gdi/DWriteTextRenderer.cxx
index f876f368e882..11469aadb597 100755
--- a/vcl/win/gdi/DWriteTextRenderer.cxx
+++ b/vcl/win/gdi/DWriteTextRenderer.cxx
@@ -80,12 +80,15 @@ D2DTextAntiAliasMode lclGetSystemTextAntiAliasMode()
 
 if (bFontSmoothing)
 {
-UINT nType;
-if (!SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, , 0))
-return eMode;
+eMode = D2DTextAntiAliasMode::AntiAliased;
 
-eMode = (nType == FE_FONTSMOOTHINGCLEARTYPE) ? 
D2DTextAntiAliasMode::ClearType
- : 
D2DTextAntiAliasMode::AntiAliased;
+UINT nType;
+if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, , 0) && 
nType == FE_FONTSMOOTHINGCLEARTYPE)
+eMode = D2DTextAntiAliasMode::ClearType;
+}
+else
+{
+eMode = D2DTextAntiAliasMode::Aliased;
 }
 
 return eMode;
@@ -150,7 +153,6 @@ D2DWriteTextOutRenderer::D2DWriteTextOutRenderer()
 hr = CreateRenderTarget();
 }
 meTextAntiAliasMode = lclGetSystemTextAntiAliasMode();
-mpRenderingParameters = lclSetRenderingMode(mpDWriteFactory, 
DWRITE_RENDERING_MODE_GDI_CLASSIC);
 }
 
 D2DWriteTextOutRenderer::~D2DWriteTextOutRenderer()
@@ -169,23 +171,31 @@ D2DWriteTextOutRenderer::~D2DWriteTextOutRenderer()
 
 void D2DWriteTextOutRenderer::applyTextAntiAliasMode()
 {
-D2D1_TEXT_ANTIALIAS_MODE eMode = D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
+D2D1_TEXT_ANTIALIAS_MODE eTextAAMode = D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
+DWRITE_RENDERING_MODE eRenderingMode = DWRITE_RENDERING_MODE_DEFAULT;

[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-07-20 Thread Jan-Marek Glogowski
 vcl/inc/win/saldata.hxx  |2 ++
 vcl/win/app/salinst.cxx  |   43 ++-
 vcl/win/app/saltimer.cxx |   12 +++-
 3 files changed, 43 insertions(+), 14 deletions(-)

New commits:
commit 37436815970b14f8940fc0c547862452a2dc3e1e
Author: Jan-Marek Glogowski 
Date:   Wed Jul 19 15:48:39 2017 +0200

tdf#109123 WIN Run instant timerout with low priority

This busy-lock happens, because user messages have a higher priority
then some system messages. What happens:

1. The main system loop picks up the LO scheduler
2. The idle worker (IW) is started
3. IW checks using AnyInput( VCL_INPUT_ANY ) for system events
4. A system event is found
5. The LO scheduler gets posted again
6. The main system loop picks up the LO scheduler instead of the
   system message => goto 2

Normally it's suggested to use WM_TIMER in this case, as these messages
are supposed to have the lowest priority. But this doesn't work, if
you use PostMessage to generate them and SetTimer doesn't accept a
0ms timeout. At least PeakMessage also picks up the WM_TIMER message
before the system message, probably because PostMessage is somehow
related to the threads queue - who knows.

In the end this implements a manual, low priority event, which is checked
at the end of the ImplSalYield function. It just runs, if there is
nothing else to do. We still have to emit the timer callback event,
as ImplSalYield may wait in GetMessage, but wParam now indicates, if
it's a wakeup and can be ignored. We use the same event, so it's
easier to filter.

Thanks to Mike Kaganski for the missing information and ideas for the
final implementation.

Change-Id: Ib8e4f214ab8d3731d5594d68f38f46982c2eb36d
Reviewed-on: https://gerrit.libreoffice.org/40190
Tested-by: Jenkins 
Reviewed-by: Jan-Marek Glogowski 

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index b28f3e2c09be..ed1d225b14b8 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -85,6 +85,7 @@ public:
 BYTE*   mpDitherLow;// Dither mapping table
 BYTE*   mpDitherHigh;   // Dither mapping table
 HANDLE  mnTimerId;  ///< Windows timer id
+boolmbOnIdleRunScheduler;   ///< Run the scheduler, if 
yield is idle
 HHOOK   mhSalObjMsgHook;// hook to get interesting 
msg for SalObject
 HWNDmhWantLeaveMsg; // window handle, that 
want a MOUSELEAVE message
 AutoTimer*  mpMouseLeaveTimer;  // Timer for MouseLeave 
Test
@@ -274,6 +275,7 @@ int ImplSalWICompareAscii( const wchar_t* pStr1, const 
char* pStr2 );
 #define SALOBJ_MSG_POSTFOCUS(WM_USER+161)
 
 // Call the Timer's callback from the main thread
+// wParam = 1 == run when yield is idle instead of direct
 #define SAL_MSG_TIMER_CALLBACK  (WM_USER+162)
 // Stop the timer from the main thread; wParam = 0, lParam = 0
 #define SAL_MSG_STOPTIMER   (WM_USER+163)
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index d6a970e7eca8..7e76cd921273 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -322,6 +322,7 @@ SalData::SalData()
 mpDitherLow = nullptr;  // Dither mapping table
 mpDitherHigh = nullptr; // Dither mapping table
 mnTimerId = nullptr;// windows timer id
+mbOnIdleRunScheduler = false; // if yield is idle, run the scheduler
 mhSalObjMsgHook = nullptr;  // hook to get interesting msg for SalObject
 mhWantLeaveMsg = nullptr;   // window handle, that want a MOUSELEAVE 
message
 mpMouseLeaveTimer = nullptr; // Timer for MouseLeave Test
@@ -565,19 +566,38 @@ ImplSalYield( bool bWait, bool bHandleAllCurrentEvents )
 {
 MSG aMsg;
 bool bWasMsg = false, bOneEvent = false;
+SalData *const pSalData = GetSalData();
 
 int nMaxEvents = bHandleAllCurrentEvents ? 100 : 1;
 do
 {
-if ( PeekMessageW( , nullptr, 0, 0, PM_REMOVE ) )
+bOneEvent = PeekMessageW( , nullptr, 0, 0, PM_REMOVE );
+if ( bOneEvent )
 {
-TranslateMessage(  );
-ImplSalDispatchMessage(  );
-
-bOneEvent = bWasMsg = true;
+bWasMsg = true;
+if ( !(aMsg.message == SAL_MSG_TIMER_CALLBACK && 1 == aMsg.wParam) 
)
+{
+TranslateMessage(  );
+ImplSalDispatchMessage(  );
+}
+else
+{
+// This is just the scheduler wakeup message, in case we're
+// waiting in GetMessageW
+// So we can just drop it, but we have to fix the accounting!
+assert( pSalData->mbOnIdleRunScheduler );
+++nMaxEvents;
+

[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-07-17 Thread Tomaž Vajngerl
 vcl/inc/win/DWriteTextRenderer.hxx |   15 +++
 vcl/win/gdi/DWriteTextRenderer.cxx |   23 +++
 2 files changed, 26 insertions(+), 12 deletions(-)

New commits:
commit 8134fb802635f3798eb72e414450b64409de5ef9
Author: Tomaž Vajngerl 
Date:   Sun Jul 16 22:00:42 2017 +0200

DWrite: move impl. of some methods to the cxx

Change-Id: I34b4163176dc5a4a8f5cd326918df375c3475a1a
Reviewed-on: https://gerrit.libreoffice.org/40019
Tested-by: Jenkins 
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/inc/win/DWriteTextRenderer.hxx 
b/vcl/inc/win/DWriteTextRenderer.hxx
index 462e99050083..611a134396f7 100755
--- a/vcl/inc/win/DWriteTextRenderer.hxx
+++ b/vcl/inc/win/DWriteTextRenderer.hxx
@@ -55,13 +55,7 @@ public:
 SalGraphics ,
 HDC hDC) override;
 
-bool BindDC(HDC hDC, tools::Rectangle const & rRect = tools::Rectangle(0, 
0, 1, 1))
-{
-if (rRect.GetWidth() == 0 || rRect.GetHeight() == 0)
-return false;
-RECT const rc = { rRect.Left(), rRect.Top(), rRect.Right(), 
rRect.Bottom() };
-return SUCCEEDED(mpRT->BindDC(hDC, ));
-}
+bool BindDC(HDC hDC, tools::Rectangle const & rRect = tools::Rectangle(0, 
0, 1, 1));
 
 bool BindFont(HDC hDC) /*override*/;
 bool ReleaseFont() /*override*/;
@@ -71,12 +65,9 @@ public:
 IDWriteFontFace   * GetFontFace() const { return mpFontFace; }
 float   GetEmHeight() const { return mlfEmHeight; }
 
-HRESULT CreateRenderTarget() {
-if (mpRT) mpRT->Release(); mpRT = nullptr;
-return mpD2DFactory->CreateDCRenderTarget(, );
-}
+HRESULT CreateRenderTarget();
 
-bool Ready() const { return mpGdiInterop && mpRT; }
+bool Ready() const;
 
 void applyTextAntiAliasMode();
 void setTextAntiAliasMode(D2DTextAntiAliasMode eMode)
diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx 
b/vcl/win/gdi/DWriteTextRenderer.cxx
index ea13e05b8a60..8ccb1f451cda 100755
--- a/vcl/win/gdi/DWriteTextRenderer.cxx
+++ b/vcl/win/gdi/DWriteTextRenderer.cxx
@@ -169,6 +169,29 @@ void D2DWriteTextOutRenderer::applyTextAntiAliasMode()
 mpRT->SetTextRenderingParams(mpRenderingParameters);
 }
 
+HRESULT D2DWriteTextOutRenderer::CreateRenderTarget()
+{
+if (mpRT)
+{
+mpRT->Release();
+mpRT = nullptr;
+}
+return mpD2DFactory->CreateDCRenderTarget(, );
+}
+
+bool D2DWriteTextOutRenderer::Ready() const
+{
+return mpGdiInterop && mpRT;
+}
+
+bool D2DWriteTextOutRenderer::BindDC(HDC hDC, tools::Rectangle const & rRect)
+{
+if (rRect.GetWidth() == 0 || rRect.GetHeight() == 0)
+return false;
+RECT const rc = { rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom() 
};
+return SUCCEEDED(mpRT->BindDC(hDC, ));
+}
+
 bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const ,
 SalGraphics ,
 HDC hDC)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-07-06 Thread Tomaž Vajngerl
 vcl/inc/win/winlayout.hxx |   14 
 vcl/win/gdi/winlayout.cxx |   75 --
 2 files changed, 86 insertions(+), 3 deletions(-)

New commits:
commit a5a3e82e99e7a60ec65c339dd0463af5c680cead
Author: Tomaž Vajngerl 
Date:   Mon Jul 3 15:00:21 2017 +0200

tdf#106990 set cleartype setting / force to use GDI render mode

With this we read the system setting for cleartype and set it to
the render target we are using.

Additionally we set the GDI like rendering mode which forces that
the text is rendered similar as this was done with GDI.

Change-Id: If6fb72bc371accf50278c968c94e625aee3f0953
Reviewed-on: https://gerrit.libreoffice.org/39602
Tested-by: Jenkins 
Reviewed-by: Michael Meeks 

diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 456d371b52b8..9d2a40eba5be 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -196,6 +196,13 @@ public:
 HDC hDC) override;
 };
 
+enum class D2DTextAntiAliasMode
+{
+Default,
+ClearType,
+AntiAliased,
+};
+
 class D2DWriteTextOutRenderer : public TextOutRenderer
 {
 typedef HRESULT(WINAPI *pD2D1CreateFactory_t)(D2D1_FACTORY_TYPE,
@@ -238,6 +245,11 @@ public:
 
 bool Ready() const { return mpGdiInterop && mpRT; }
 
+void applyTextAntiAliasMode();
+void setTextAntiAliasMode(D2DTextAntiAliasMode eMode)
+{
+meTextAntiAliasMode = eMode;
+}
 private:
 static void CleanupModules();
 
@@ -256,6 +268,8 @@ private:
 IDWriteFontFace * mpFontFace;
 float mlfEmHeight;
 HDC   mhDC;
+D2DTextAntiAliasMode meTextAntiAliasMode;
+IDWriteRenderingParams* mpRenderingParameters;
 };
 
 #endif // INCLUDED_VCL_INC_WIN_WINLAYOUT_HXX
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index a510eba4d61a..e7257d38bacd 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -77,6 +77,8 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT hFont, 
int nGlyphIndex, S
 if (!pTxt)
 return false;
 
+pTxt->setTextAntiAliasMode(D2DTextAntiAliasMode::AntiAliased);
+
 if (!pTxt->BindFont(aHDC.get()))
 {
 SAL_WARN("vcl.gdi", "Binding of font failed. The font might not be 
supported by Direct Write.");
@@ -173,6 +175,7 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT 
hFont, int nGlyphIndex, S
 };
 
 pRT->BeginDraw();
+pTxt->applyTextAntiAliasMode();
 pRT->DrawGlyphRun(baseline, , pBrush);
 HRESULT hResult = pRT->EndDraw();
 
@@ -315,6 +318,47 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const 
,
 
 return true;
 }
+namespace
+{
+
+D2DTextAntiAliasMode lclGetSystemTextAntiAliasMode()
+{
+D2DTextAntiAliasMode eMode = D2DTextAntiAliasMode::Default;
+
+BOOL bFontSmoothing;
+if (!SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, , 0))
+return eMode;
+
+if (bFontSmoothing)
+{
+UINT nType;
+if (!SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, , 0))
+return eMode;
+
+eMode = (nType == FE_FONTSMOOTHINGCLEARTYPE) ? 
D2DTextAntiAliasMode::ClearType
+ : 
D2DTextAntiAliasMode::AntiAliased;
+}
+
+return eMode;
+}
+
+IDWriteRenderingParams* lclSetRenderingMode(IDWriteFactory* pDWriteFactory, 
DWRITE_RENDERING_MODE eRenderingMode)
+{
+IDWriteRenderingParams* pDefaultParameters = nullptr;
+pDWriteFactory->CreateRenderingParams();
+
+IDWriteRenderingParams* pParameters = nullptr;
+pDWriteFactory->CreateCustomRenderingParams(
+pDefaultParameters->GetGamma(),
+pDefaultParameters->GetEnhancedContrast(),
+pDefaultParameters->GetClearTypeLevel(),
+pDefaultParameters->GetPixelGeometry(),
+eRenderingMode,
+);
+return pParameters;
+}
+
+} // end anonymous namespace
 
 D2DWriteTextOutRenderer::D2DWriteTextOutRenderer()
 : mpD2DFactory(nullptr),
@@ -322,11 +366,12 @@ D2DWriteTextOutRenderer::D2DWriteTextOutRenderer()
 mpGdiInterop(nullptr),
 mpRT(nullptr),
 mRTProps(D2D1::RenderTargetProperties(D2D1_RENDER_TARGET_TYPE_DEFAULT,
-D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, 
D2D1_ALPHA_MODE_PREMULTIPLIED),
-0, 0)),
+  
D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED),
+  0, 0)),
 mpFontFace(nullptr),
 mlfEmHeight(0.0f),
-mhDC(nullptr)
+mhDC(nullptr),
+meTextAntiAliasMode(D2DTextAntiAliasMode::Default)
 {
 HRESULT hr = S_OK;
 hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, 
__uuidof(ID2D1Factory), nullptr, reinterpret_cast());
@@ -336,6 +381,8 @@ D2DWriteTextOutRenderer::D2DWriteTextOutRenderer()
 hr = mpDWriteFactory->GetGdiInterop();
 hr = 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-05-07 Thread Tomaž Vajngerl
 vcl/inc/win/ScopedHDC.hxx |   45 +
 vcl/win/gdi/winlayout.cxx |   12 ++--
 2 files changed, 51 insertions(+), 6 deletions(-)

New commits:
commit dae61482df7ae540a1fb8feefbb92b5e7238444d
Author: Tomaž Vajngerl 
Date:   Sun May 7 16:19:34 2017 +0200

tdf#106265 ScopedHDC to clean-up hDC when rendering glyphs

Change-Id: I96ecf625126740610200c012c3c7002fac7e1548
Reviewed-on: https://gerrit.libreoffice.org/37347
Tested-by: Jenkins 
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/inc/win/ScopedHDC.hxx b/vcl/inc/win/ScopedHDC.hxx
new file mode 100644
index ..bd4642ee6642
--- /dev/null
+++ b/vcl/inc/win/ScopedHDC.hxx
@@ -0,0 +1,45 @@
+/* -*- 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_INC_WIN_SCOPEDHDC_HXX
+#define INCLUDED_VCL_INC_WIN_SCOPEDHDC_HXX
+
+class ScopedHDC
+{
+private:
+HDC m_hDC;
+
+public:
+explicit ScopedHDC(HDC hDC)
+: m_hDC(hDC)
+{}
+
+ScopedHDC(const ScopedHDC&) = delete;
+ScopedHDC& operator=(const ScopedHDC&) = delete;
+
+~ScopedHDC()
+{
+if (m_hDC)
+DeleteDC(m_hDC);
+}
+
+HDC get() const
+{
+return m_hDC;
+}
+
+explicit operator bool() const
+{
+return m_hDC != nullptr;
+}
+};
+
+#endif // INCLUDED_VCL_INC_WIN_SCOPEDHDC_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index d262f0633f92..feb5565be153 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -34,6 +34,7 @@
 #include "sft.hxx"
 #include "sallayout.hxx"
 #include "CommonSalLayout.hxx"
+#include "win/ScopedHDC.hxx"
 
 #include 
 #include 
@@ -57,17 +58,17 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT 
hFont, int nGlyphIndex, S
 {
 OpenGLGlyphDrawElement aElement;
 
-HDC hNewDC = CreateCompatibleDC(hDC);
-if (hNewDC == nullptr)
+ScopedHDC aHDC(CreateCompatibleDC(hDC));
+
+if (!aHDC)
 {
 SAL_WARN("vcl.gdi", "CreateCompatibleDC failed: " << 
WindowsErrorString(GetLastError()));
 return false;
 }
-HFONT hOrigFont = static_cast(SelectObject(hNewDC, hFont));
+HFONT hOrigFont = static_cast(SelectObject(aHDC.get(), hFont));
 if (hOrigFont == nullptr)
 {
 SAL_WARN("vcl.gdi", "SelectObject failed: " << 
WindowsErrorString(GetLastError()));
-DeleteDC(hNewDC);
 return false;
 }
 
@@ -76,10 +77,9 @@ bool WinFontInstance::CacheGlyphToAtlas(HDC hDC, HFONT 
hFont, int nGlyphIndex, S
 if (!pTxt)
 return false;
 
-if (!pTxt->BindFont(hNewDC))
+if (!pTxt->BindFont(aHDC.get()))
 {
 SAL_WARN("vcl.gdi", "Binding of font failed. The font might not be 
supported by Direct Write.");
-DeleteDC(hNewDC);
 return false;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-04-24 Thread Michael Stahl
 vcl/inc/win/saldata.hxx   |4 +++-
 vcl/win/gdi/winlayout.cxx |   18 --
 2 files changed, 15 insertions(+), 7 deletions(-)

New commits:
commit 2eb91035c2f60e9dc476336474d51b23b666bb04
Author: Michael Stahl 
Date:   Mon Apr 24 18:21:50 2017 +0200

tdf#107205 vcl: don't always use D2DWriteTextOutRenderer

... because it cannot rotate text.

(regression from commit df556aa47da22f96b3fcd356c12419d3035cba3c)

Change-Id: If9bc6e98b8979c5eb02f1a5cfc12b4d19bdc481b

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index c38cc56a71bf..698e923f7b03 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -123,7 +123,9 @@ public:
 std::map< UINT,sal_uInt16 > maVKMap;  // map some dynamic VK_* entries
 
 // must be deleted before exit(), so delete it in DeInitSalData()
-std::unique_ptr m_pTextOutRenderer;
+std::unique_ptr m_pD2DWriteTextOutRenderer;
+// tdf#107205 need 2 instances because D2DWrite can't rotate text
+std::unique_ptr m_pExTextOutRenderer;
 std::unique_ptr m_pGlobalGlyphCache;
 std::unique_ptr m_pTextureCache;
 };
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 8bea277c8dde..de1b852fed5f 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -258,18 +258,24 @@ TextOutRenderer & TextOutRenderer::get(bool bUseDWrite)
 abort();
 }
 
-if (!pSalData->m_pTextOutRenderer)
+if (bUseDWrite)
 {
-if (bUseDWrite && D2DWriteTextOutRenderer::InitModules())
+static bool const bSuccess(D2DWriteTextOutRenderer::InitModules());
+if (bSuccess && !pSalData->m_pD2DWriteTextOutRenderer)
 {
-pSalData->m_pTextOutRenderer.reset(new D2DWriteTextOutRenderer());
+pSalData->m_pD2DWriteTextOutRenderer.reset(new 
D2DWriteTextOutRenderer());
 }
-else
+if (pSalData->m_pD2DWriteTextOutRenderer)
 {
-pSalData->m_pTextOutRenderer.reset(new ExTextOutRenderer);
+return *pSalData->m_pD2DWriteTextOutRenderer;
 }
+// else: fall back to GDI
 }
-return *pSalData->m_pTextOutRenderer;
+if (!pSalData->m_pExTextOutRenderer)
+{
+pSalData->m_pExTextOutRenderer.reset(new ExTextOutRenderer);
+}
+return *pSalData->m_pExTextOutRenderer;
 }
 
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-04-13 Thread Michael Stahl
 vcl/inc/win/saldata.hxx   |4 
 vcl/win/app/salinst.cxx   |1 +
 vcl/win/gdi/winlayout.cxx |   26 --
 3 files changed, 21 insertions(+), 10 deletions(-)

New commits:
commit df556aa47da22f96b3fcd356c12419d3035cba3c
Author: Michael Stahl 
Date:   Thu Apr 13 17:28:46 2017 +0200

tdf#106933 vcl: delete D2DWriteTextOutRenderer before exit()

As it happens this DirectWrite stuff is using some thread pool
internally, and that must be shutdown before exit(), as Win32 will
terminate all other threads at that point, and then the thread pool
wants to talk to threads that don't exist any more.

https://blogs.msdn.microsoft.com/oldnewthing/20120427-00/?p=7763/

So convert this from a global variable that is deleted from DllMain()
to a member of SalData, so it is deleted from DeInitVCL().

Change-Id: I51408a07c78758cf0c193ab66b9214d0c9dbd9e3

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 2fb1b49d5177..0e13cef9970a 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -39,6 +39,7 @@ class WinSalPrinter;
 namespace vcl { class Font; }
 struct HDCCache;
 struct TempFontItem;
+class TextOutRenderer;
 
 #define MAX_STOCKPEN4
 #define MAX_STOCKBRUSH  4
@@ -118,6 +119,9 @@ public:
 
 std::set< HMENU >   mhMenuSet;  // keeps track of menu 
handles created by VCL, used by IsKnownMenuHandle()
 std::map< UINT,sal_uInt16 > maVKMap;  // map some dynamic VK_* entries
+
+// must be deleted before exit(), so delete it in DeInitSalData()
+std::unique_ptr m_pTextOutRenderer;
 };
 
 inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = pData; 
}
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index d0a8d01e5cca..c5cab1fd2d82 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -39,6 +39,7 @@
 #include "win/salobj.h"
 #include "win/saltimer.h"
 #include "win/salbmp.h"
+#include "win/winlayout.hxx"
 
 #include "salimestatus.hxx"
 #include "salsys.hxx"
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 3f12664b8d96..7c593371790a 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -245,20 +245,26 @@ void D2DWriteTextOutRenderer::CleanupModules()
 
 TextOutRenderer & TextOutRenderer::get(bool bUseDWrite)
 {
-if (bUseDWrite)
-{
-static std::unique_ptr 
_impl(D2DWriteTextOutRenderer::InitModules()
-? static_cast(new D2DWriteTextOutRenderer())
-: static_cast(new ExTextOutRenderer));
+SalData *const pSalData = GetSalData();
 
-return *_impl;
+if (!pSalData)
+{   // don't call this after DeInitVCL()
+fprintf(stderr, "TextOutRenderer fatal error: no SalData");
+abort();
 }
-else
-{
-static std::unique_ptr _impl(new ExTextOutRenderer);
 
-return *_impl;
+if (!pSalData->m_pTextOutRenderer)
+{
+if (bUseDWrite && D2DWriteTextOutRenderer::InitModules())
+{
+pSalData->m_pTextOutRenderer.reset(new D2DWriteTextOutRenderer());
+}
+else
+{
+pSalData->m_pTextOutRenderer.reset(new ExTextOutRenderer());
+}
 }
+return *pSalData->m_pTextOutRenderer;
 }
 
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-03-05 Thread Caolán McNamara
 vcl/inc/win/winlayout.hxx |   12 +++-
 vcl/win/gdi/winlayout.cxx |   38 --
 2 files changed, 19 insertions(+), 31 deletions(-)

New commits:
commit 29d2f85e198d5b844d5a10562723a65173cf22ea
Author: Caolán McNamara 
Date:   Sun Mar 5 21:35:23 2017 +

Restore "pPos and pGetNextGlypInfo always have the same value"

and...

"pEraseRect is always null"

This reverts commit b398dacbb471913e573e9b0b4cd31d94a9109223.

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

diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 42b25b6..bc1890b 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -179,9 +179,7 @@ public:
 
 virtual bool operator ()(CommonSalLayout const ,
 SalGraphics ,
-HDC hDC,
-const Rectangle* pRectToErase,
-Point* pPos, int* pGetNextGlypInfo) = 0;
+HDC hDC) = 0;
 };
 
 class ExTextOutRenderer : public TextOutRenderer
@@ -194,9 +192,7 @@ public:
 
 bool operator ()(CommonSalLayout const ,
 SalGraphics ,
-HDC hDC,
-const Rectangle* pRectToErase,
-Point* pPos, int* pGetNextGlypInfo) override;
+HDC hDC) override;
 };
 
 class D2DWriteTextOutRenderer : public TextOutRenderer
@@ -219,9 +215,7 @@ public:
 
 bool operator ()(CommonSalLayout const ,
 SalGraphics ,
-HDC hDC,
-const Rectangle* pRectToErase,
-Point* pPos, int* pGetNextGlypInfo) override;
+HDC hDC) override;
 
 inline bool BindDC(HDC hDC, Rectangle const & rRect = Rectangle(0, 0, 0, 
0)) {
 RECT const rc = { rRect.Left(), rRect.Top(), rRect.Right(), 
rRect.Bottom() };
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index c884c9e..a8d71fc 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -264,12 +264,8 @@ TextOutRenderer & TextOutRenderer::get(bool bUseDWrite)
 
 bool ExTextOutRenderer::operator ()(CommonSalLayout const ,
 SalGraphics & /*rGraphics*/,
-HDC hDC,
-const Rectangle* pRectToErase,
-Point* pPos, int* pGetNextGlypInfo)
+HDC hDC)
 {
-bool bGlyphs = false;
-const GlyphItem* pGlyph;
 HFONT hFont = static_cast(GetCurrentObject( hDC, OBJ_FONT ));
 HFONT hAltFont = nullptr;
 bool bUseAltFont = false;
@@ -284,16 +280,19 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const 
,
 hAltFont = CreateFontIndirectW();
 }
 }
-while (rLayout.GetNextGlyphs(1, , *pPos, *pGetNextGlypInfo))
+
+int nStart = 0;
+Point aPos(0, 0);
+const GlyphItem* pGlyph;
+while (rLayout.GetNextGlyphs(1, , aPos, nStart))
 {
-bGlyphs = true;
 WORD glyphWStr[] = { pGlyph->maGlyphId };
 if (hAltFont && pGlyph->IsVertical() == bUseAltFont)
 {
 bUseAltFont = !bUseAltFont;
 SelectFont(hDC, bUseAltFont ? hAltFont : hFont);
 }
-ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, 
LPCWSTR(), 1, nullptr);
+ExtTextOutW(hDC, aPos.X(), aPos.Y(), ETO_GLYPH_INDEX, nullptr, 
LPCWSTR(), 1, nullptr);
 }
 if (hAltFont)
 {
@@ -302,7 +301,7 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const 
,
 DeleteObject(hAltFont);
 }
 
-return (pRectToErase && bGlyphs);
+return true;
 }
 
 D2DWriteTextOutRenderer::D2DWriteTextOutRenderer()
@@ -343,9 +342,7 @@ D2DWriteTextOutRenderer::~D2DWriteTextOutRenderer()
 
 bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const ,
 SalGraphics ,
-HDC hDC,
-const Rectangle* pRectToErase,
-Point* pPos, int* pGetNextGlypInfo)
+HDC hDC)
 {
 if (!Ready())
 return false;
@@ -353,7 +350,7 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout 
const ,
 if (!BindFont(hDC))
 {
 // If for any reason we can't bind fallback to legacy APIs.
-return ExTextOutRenderer()(rLayout, rGraphics, hDC, pRectToErase, 
pPos, pGetNextGlypInfo);
+return ExTextOutRenderer()(rLayout, rGraphics, hDC);
 }
 
 Rectangle bounds;
@@ -365,19 +362,19 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout 
const ,
 succeeded &= 
SUCCEEDED(mpRT->CreateSolidColorBrush(D2D1::ColorF(GetRValue(bgrTextColor) / 
255.0f, GetGValue(bgrTextColor) / 255.0f, GetBValue(bgrTextColor) / 255.0f), 
));
 
 HRESULT hr = S_OK;
-bool bGlyphs = false;
 if (succeeded)
 {
 mpRT->BeginDraw();
 
+int nStart = 0;
+Point aPos(0, 0);
 const GlyphItem* pGlyph;
-while (rLayout.GetNextGlyphs(1, , *pPos, *pGetNextGlypInfo))
+while (rLayout.GetNextGlyphs(1, , aPos, nStart))
 {
-bGlyphs = true;
 UINT16 glyphIndices[] = { pGlyph->maGlyphId };
  

[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-03-05 Thread Caolán McNamara
 vcl/inc/win/winlayout.hxx |   12 +---
 vcl/win/gdi/winlayout.cxx |   39 ++-
 2 files changed, 31 insertions(+), 20 deletions(-)

New commits:
commit b398dacbb471913e573e9b0b4cd31d94a9109223
Author: Caolán McNamara 
Date:   Sun Mar 5 21:31:09 2017 +

Revert "pPos and pGetNextGlypInfo always have the same value"

This reverts commit 7453cb58df4ce434a1252567f961cfe497064aca.

and...

Revert "pEraseRect is always null"

I suspect the problem is the change to D2DWriteTextOutRenderer::operator
in 7453cb58df4ce434a1252567f961cfe497064aca

aborts during windows tinderboxes CppunitTest_dbaccess_empty_stdlib_save etc

This reverts commit 073d920ef5914b5dfe491dbaf7fb18ba56293b85.

Change-Id: I372e104bd09e49bcf08306169db9777f2f26fff5

diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index bc1890b..42b25b6 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -179,7 +179,9 @@ public:
 
 virtual bool operator ()(CommonSalLayout const ,
 SalGraphics ,
-HDC hDC) = 0;
+HDC hDC,
+const Rectangle* pRectToErase,
+Point* pPos, int* pGetNextGlypInfo) = 0;
 };
 
 class ExTextOutRenderer : public TextOutRenderer
@@ -192,7 +194,9 @@ public:
 
 bool operator ()(CommonSalLayout const ,
 SalGraphics ,
-HDC hDC) override;
+HDC hDC,
+const Rectangle* pRectToErase,
+Point* pPos, int* pGetNextGlypInfo) override;
 };
 
 class D2DWriteTextOutRenderer : public TextOutRenderer
@@ -215,7 +219,9 @@ public:
 
 bool operator ()(CommonSalLayout const ,
 SalGraphics ,
-HDC hDC) override;
+HDC hDC,
+const Rectangle* pRectToErase,
+Point* pPos, int* pGetNextGlypInfo) override;
 
 inline bool BindDC(HDC hDC, Rectangle const & rRect = Rectangle(0, 0, 0, 
0)) {
 RECT const rc = { rRect.Left(), rRect.Top(), rRect.Right(), 
rRect.Bottom() };
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index cf555de..c884c9e 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -264,8 +264,12 @@ TextOutRenderer & TextOutRenderer::get(bool bUseDWrite)
 
 bool ExTextOutRenderer::operator ()(CommonSalLayout const ,
 SalGraphics & /*rGraphics*/,
-HDC hDC)
+HDC hDC,
+const Rectangle* pRectToErase,
+Point* pPos, int* pGetNextGlypInfo)
 {
+bool bGlyphs = false;
+const GlyphItem* pGlyph;
 HFONT hFont = static_cast(GetCurrentObject( hDC, OBJ_FONT ));
 HFONT hAltFont = nullptr;
 bool bUseAltFont = false;
@@ -280,19 +284,16 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const 
,
 hAltFont = CreateFontIndirectW();
 }
 }
-
-int nStart = 0;
-Point aPos(0, 0);
-const GlyphItem* pGlyph;
-while (rLayout.GetNextGlyphs(1, , aPos, nStart))
+while (rLayout.GetNextGlyphs(1, , *pPos, *pGetNextGlypInfo))
 {
+bGlyphs = true;
 WORD glyphWStr[] = { pGlyph->maGlyphId };
 if (hAltFont && pGlyph->IsVertical() == bUseAltFont)
 {
 bUseAltFont = !bUseAltFont;
 SelectFont(hDC, bUseAltFont ? hAltFont : hFont);
 }
-ExtTextOutW(hDC, aPos.X(), aPos.Y(), ETO_GLYPH_INDEX, nullptr, 
LPCWSTR(), 1, nullptr);
+ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, 
LPCWSTR(), 1, nullptr);
 }
 if (hAltFont)
 {
@@ -301,7 +302,7 @@ bool ExTextOutRenderer::operator ()(CommonSalLayout const 
,
 DeleteObject(hAltFont);
 }
 
-return true;
+return (pRectToErase && bGlyphs);
 }
 
 D2DWriteTextOutRenderer::D2DWriteTextOutRenderer()
@@ -342,7 +343,9 @@ D2DWriteTextOutRenderer::~D2DWriteTextOutRenderer()
 
 bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout const ,
 SalGraphics ,
-HDC hDC)
+HDC hDC,
+const Rectangle* pRectToErase,
+Point* pPos, int* pGetNextGlypInfo)
 {
 if (!Ready())
 return false;
@@ -350,7 +353,7 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout 
const ,
 if (!BindFont(hDC))
 {
 // If for any reason we can't bind fallback to legacy APIs.
-return ExTextOutRenderer()(rLayout, rGraphics, hDC);
+return ExTextOutRenderer()(rLayout, rGraphics, hDC, pRectToErase, 
pPos, pGetNextGlypInfo);
 }
 
 Rectangle bounds;
@@ -362,19 +365,19 @@ bool D2DWriteTextOutRenderer::operator ()(CommonSalLayout 
const ,
 succeeded &= 
SUCCEEDED(mpRT->CreateSolidColorBrush(D2D1::ColorF(GetRValue(bgrTextColor) / 
255.0f, GetGValue(bgrTextColor) / 255.0f, GetBValue(bgrTextColor) / 255.0f), 
));
 
 HRESULT hr = S_OK;
+bool bGlyphs = false;
 if (succeeded)
 {
 mpRT->BeginDraw();
 
-int nStart = 0;
-Point aPos(0, 0);
 const GlyphItem* pGlyph;
-while (rLayout.GetNextGlyphs(1, , aPos, nStart))
+while 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-01-07 Thread Khaled Hosny
 vcl/inc/win/salgdi.h  |1 -
 vcl/inc/win/winlayout.hxx |   16 
 vcl/win/gdi/salfont.cxx   |   12 ++--
 vcl/win/gdi/winlayout.cxx |   34 --
 4 files changed, 10 insertions(+), 53 deletions(-)

New commits:
commit d1bad9c12d61c9f662abe6439b87a057bb54c8ca
Author: Khaled Hosny 
Date:   Mon Jan 2 01:22:32 2017 +0200

Simplify setting Kashida width on Windows

This should also make sure we are getting it from the current font, which
the old, convoluted way does not seem to guarantee.

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

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index d974e76..f6faf4a 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -376,7 +376,6 @@ public:
 bool bVertical,
 std::vector< sal_Int32 >& rWidths,
 Ucs2UIntMap& rUnicodeEnc ) 
override;
-int GetMinKashidaWidth();
 
 virtual boolGetGlyphBoundRect(const GlyphItem&, Rectangle&) 
override;
 virtual boolGetGlyphOutline(const GlyphItem&, 
basegfx::B2DPolyPolygon&) override;
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index d339df3..ecd25746 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -157,18 +157,6 @@ public:
 private:
 // TODO: also add HFONT??? Watch out for issues with too many active 
fonts...
 
-public:
-SCRIPT_CACHE&   GetScriptCache() const
-{ return maScriptCache; }
-private:
-mutable SCRIPT_CACHEmaScriptCache;
-
-public:
-boolInitKashidaHandling( HDC );
-int GetMinKashidaWidth() const { return 
mnMinKashidaWidth; }
-int GetMinKashidaGlyph() const { return 
mnMinKashidaGlyph; }
-
-private:
 GlyphCache maGlyphCache;
 public:
 bool CacheGlyphToAtlas(HDC hDC, HFONT hFont, int nGlyphIndex, SalGraphics& 
rGraphics);
@@ -177,10 +165,6 @@ public:
 {
 return maGlyphCache;
 }
-
-private:
-mutable int mnMinKashidaWidth;
-mutable int mnMinKashidaGlyph;
 };
 
 class TextOutRenderer
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index b8da03d..9860d5f 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -980,6 +980,16 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& 
rxFontMetric, int nFa
 const RawFontData aHheaRawData(getHDC(), nHheaTag);
 const RawFontData aOS2RawData(getHDC(), nOS2Tag);
 
+WCHAR nKashidaCh = 0x0640;
+WORD nKashidaGid;
+DWORD ret = GetGlyphIndicesW(getHDC(), , 1, , 
GGI_MARK_NONEXISTING_GLYPHS);
+if (ret != GDI_ERROR && nKashidaGid != 0x)
+{
+int nKashidaWidth = 0;
+if (GetCharWidthI(getHDC(), nKashidaGid, 1, nullptr, ))
+rxFontMetric->SetMinKashida(nKashidaWidth);
+}
+
 // get the font metric
 OUTLINETEXTMETRICW aOutlineMetric;
 const bool bOK = GetOutlineTextMetricsW(getHDC(), 
sizeof(OUTLINETEXTMETRICW), );
@@ -1004,8 +1014,6 @@ void WinSalGraphics::GetFontMetric( 
ImplFontMetricDataRef& rxFontMetric, int nFa
 const std::vector rHhea(aHheaRawData.get(), aHheaRawData.get() + 
aHheaRawData.size());
 const std::vector rOS2(aOS2RawData.get(), aOS2RawData.get() + 
aOS2RawData.size());
 rxFontMetric->ImplCalcLineSpacing(rHhea, rOS2, aOutlineMetric.otmEMSquare);
-
-rxFontMetric->SetMinKashida( GetMinKashidaWidth() );
 }
 
 const FontCharMapRef WinSalGraphics::GetFontCharMap() const
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 04724d8..6436c61 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -596,14 +596,6 @@ SalLayout* WinSalGraphics::GetTextLayout(ImplLayoutArgs& 
/*rArgs*/, int nFallbac
 return new CommonSalLayout(getHDC(), *mpWinFontEntry[nFallbackLevel], 
*mpWinFontData[nFallbackLevel]);
 }
 
-intWinSalGraphics::GetMinKashidaWidth()
-{
-if( !mpWinFontEntry[0] )
-return 0;
-mpWinFontEntry[0]->InitKashidaHandling( getHDC() );
-return mpWinFontEntry[0]->GetMinKashidaWidth();
-}
-
 LogicalFontInstance * WinSalGraphics::GetWinFontEntry(int const nFallbackLevel)
 {
 return mpWinFontEntry[nFallbackLevel];
@@ -611,37 +603,11 @@ LogicalFontInstance * WinSalGraphics::GetWinFontEntry(int 
const nFallbackLevel)
 
 WinFontInstance::WinFontInstance( FontSelectPattern& rFSD )
 :   LogicalFontInstance( rFSD )
-,mnMinKashidaWidth( -1 )
-,mnMinKashidaGlyph( -1 )
 {
-maScriptCache = nullptr;
 }
 
 WinFontInstance::~WinFontInstance()
 {
-if( maScriptCache != nullptr )
-

[Libreoffice-commits] core.git: vcl/inc vcl/win

2017-01-01 Thread Khaled Hosny
 vcl/inc/win/salgdi.h  |4 +---
 vcl/win/gdi/salfont.cxx   |   33 ++---
 vcl/win/gdi/salgdi.cxx|2 --
 vcl/win/gdi/winlayout.cxx |3 +--
 4 files changed, 16 insertions(+), 26 deletions(-)

New commits:
commit 1b7e788eb3bf9cbe56ed5cc4a3fa7fa5e70ac40a
Author: Khaled Hosny 
Date:   Sun Jan 1 22:20:22 2017 +0200

The mfFontScale[n] is always 1.0

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

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 65cf06f..d974e76 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -166,8 +166,6 @@ private:
 HFONT   mhFonts[ MAX_FALLBACK ];// Font + Fallbacks
 const WinFontFace*  mpWinFontData[ MAX_FALLBACK ];  // pointer to the most 
recent font face
 WinFontInstance*   mpWinFontEntry[ MAX_FALLBACK ]; // pointer to the 
most recent font instance
-float   mfFontScale[ MAX_FALLBACK ];// allows 
metrics emulation of huge font sizes
-float   mfCurrentFontScale;
 HRGNmhRegion;   // vcl::Region Handle
 HPENmhDefPen;   // DefaultPen
 HBRUSH  mhDefBrush; // DefaultBrush
@@ -207,7 +205,7 @@ public:
 
 HWND gethWnd();
 
-HFONT   ImplDoSetFont( FontSelectPattern* i_pFont, float& 
o_rFontScale, HFONT& o_rOldFont );
+HFONT   ImplDoSetFont( FontSelectPattern* i_pFont, HFONT& 
o_rOldFont );
 
 public:
 explicit WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND 
hWnd,
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 6be5acd..b8da03d 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -836,8 +836,9 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
 }
 }
 
-HFONT WinSalGraphics::ImplDoSetFont( FontSelectPattern* i_pFont, float& 
o_rFontScale, HFONT& o_rOldFont )
+HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern* i_pFont, HFONT& 
o_rOldFont)
 {
+float fFontScale;
 HFONT hNewFont = nullptr;
 
 HDC hdcScreen = nullptr;
@@ -853,19 +854,19 @@ HFONT WinSalGraphics::ImplDoSetFont( FontSelectPattern* 
i_pFont, float& o_rFontS
 if( (-aLogFont.lfHeight <= MAXFONTHEIGHT)
 &&  (+aLogFont.lfWidth <= MAXFONTHEIGHT) )
 {
-o_rFontScale = 1.0;
+fFontScale = 1.0;
 }
 else if( -aLogFont.lfHeight >= +aLogFont.lfWidth )
 {
-o_rFontScale = -aLogFont.lfHeight / (float)MAXFONTHEIGHT;
+fFontScale = -aLogFont.lfHeight / (float)MAXFONTHEIGHT;
 aLogFont.lfHeight = -MAXFONTHEIGHT;
-aLogFont.lfWidth = FRound( aLogFont.lfWidth / o_rFontScale );
+aLogFont.lfWidth = FRound( aLogFont.lfWidth / fFontScale );
 }
 else // #i95867# also limit font widths
 {
-o_rFontScale = +aLogFont.lfWidth / (float)MAXFONTHEIGHT;
+fFontScale = +aLogFont.lfWidth / (float)MAXFONTHEIGHT;
 aLogFont.lfWidth = +MAXFONTHEIGHT;
-aLogFont.lfHeight = FRound( aLogFont.lfHeight / o_rFontScale );
+aLogFont.lfHeight = FRound( aLogFont.lfHeight / fFontScale );
 }
 
 hNewFont = ::CreateFontIndirectW(  );
@@ -905,7 +906,6 @@ void WinSalGraphics::SetFont( FontSelectPattern* pFont, int 
nFallbackLevel )
 // deselect still active font
 if( mhDefFont )
 ::SelectFont( getHDC(), mhDefFont );
-mfCurrentFontScale = mfFontScale[nFallbackLevel];
 // release no longer referenced font handles
 for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i )
 {
@@ -938,8 +938,7 @@ void WinSalGraphics::SetFont( FontSelectPattern* pFont, int 
nFallbackLevel )
 mpWinFontData[ nFallbackLevel ] = static_cast( 
pFont->mpFontData );
 
 HFONT hOldFont = nullptr;
-HFONT hNewFont = ImplDoSetFont( pFont, mfFontScale[ nFallbackLevel ], 
hOldFont );
-mfCurrentFontScale = mfFontScale[nFallbackLevel];
+HFONT hNewFont = ImplDoSetFont(pFont, hOldFont);
 
 if( !mhDefFont )
 {
@@ -1000,7 +999,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& 
rxFontMetric, int nFa
 rxFontMetric->SetSlant( 0 );
 
 // transformation dependent font metrics
-rxFontMetric->SetWidth( static_cast( mfFontScale[nFallbackLevel] * 
aWinMetric.tmAveCharWidth ) );
+rxFontMetric->SetWidth(aWinMetric.tmAveCharWidth);
 
 const std::vector rHhea(aHheaRawData.get(), aHheaRawData.get() + 
aHheaRawData.size());
 const std::vector rOS2(aOS2RawData.get(), aOS2RawData.get() + 
aOS2RawData.size());
@@ -1370,10 +1369,8 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& 
rGlyph, Rectangle& rRect
 
 rRect = Rectangle( Point( +aGM.gmptGlyphOrigin.x, -aGM.gmptGlyphOrigin.y ),
 Size( aGM.gmBlackBoxX, aGM.gmBlackBoxY ) );
-   

[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-12-10 Thread Khaled Hosny
 vcl/inc/salglyphid.hxx|8 
 vcl/win/gdi/winlayout.cxx |2 +-
 2 files changed, 1 insertion(+), 9 deletions(-)

New commits:
commit a7b9af59ea331cbc5495d2eb0f89ce6e6105ab09
Author: Khaled Hosny 
Date:   Thu Dec 8 06:21:23 2016 +0200

GF_VERT is only used once, move it

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

diff --git a/vcl/inc/salglyphid.hxx b/vcl/inc/salglyphid.hxx
index 6d5480e..8047d50 100644
--- a/vcl/inc/salglyphid.hxx
+++ b/vcl/inc/salglyphid.hxx
@@ -22,14 +22,6 @@
 typedef sal_uInt32 sal_GlyphId;
 
 // Glyph Flags
-#ifdef _WIN32
-// caution !!!
-#define GF_VERT 0x0200
-// GF_VERT is only for windows implementation
-// (win/gdi/salgdi3.cxx, win/gdi/winlayout.cxx)
-// don't use this elsewhere !!!
-#endif
-
 #define GF_FONTMASK 0xF000
 #define GF_FONTSHIFT 28
 
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 708c931..d0d9615 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -296,7 +296,7 @@ bool ExTextOutRenderer::operator ()(SalLayout const 
, HDC hDC,
 bGlyphs = true;
 WORD glyphWStr[] = { pGlyph->maGlyphId };
 if (pGlyph->IsVertical())
-glyphWStr[0] |= GF_VERT;
+glyphWStr[0] |= 0x0200; // A (undocumented?) GDI flag for 
vertical glyphs
 ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, 
LPCWSTR(), 1, nullptr);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-12-01 Thread Khaled Hosny
 vcl/inc/win/salgdi.h  |   39 
 vcl/inc/win/winlayout.hxx |  161 --
 vcl/win/gdi/salfont.cxx   |  129 -
 vcl/win/gdi/salgdi.cxx|5 
 vcl/win/gdi/winlayout.cxx | 3173 +-
 5 files changed, 132 insertions(+), 3375 deletions(-)

New commits:
commit 6c436ba09cb35235ce6f4065cf74c9a6ff14a4bd
Author: Khaled Hosny 
Date:   Thu Dec 1 03:33:30 2016 +0200

Kill old Windows layout engines

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

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 8471699..d3a7185 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -74,27 +74,16 @@ public:
 
 BYTEGetCharSet() const  { return meWinCharSet; 
}
 BYTEGetPitchAndFamily() const   { return 
mnPitchAndFamily; }
-boolSupportsCJK() const { return 
mbHasCJKSupport; }
-boolSupportsArabic() const  { return 
mbHasArabicSupport; }
 
 FontCharMapRef  GetFontCharMap() const;
 bool GetFontCapabilities(vcl::FontCapabilities ) const;
-const Ucs2SIntMap* GetEncodingVector() const { return mpEncodingVector; }
-void SetEncodingVector( const Ucs2SIntMap* pNewVec ) const
-{
-if( mpEncodingVector )
-delete mpEncodingVector;
-mpEncodingVector = pNewVec;
-}
+
 private:
 sal_IntPtr  mnId;
 
 // some members that are initalized lazily when the font gets selected 
into a HDC
-mutable boolmbHasCJKSupport;
-mutable boolmbHasArabicSupport;
 mutable boolmbFontCapabilitiesRead;
 mutable FontCharMapRef  mxUnicodeMap;
-mutable const Ucs2SIntMap*  mpEncodingVector;
 mutable vcl::FontCapabilities   maFontCapabilities;
 
 BYTEmeWinCharSet;
@@ -105,14 +94,8 @@ private:
 voidReadCmapTable( HDC ) const;
 voidGetFontCapabilities( HDC hDC ) const;
 
-voidReadGsubTable( HDC ) const;
-
-mutable std::unordered_set  maGsubTable;
-mutable boolmbGsubRead;
 mutable hb_font_t*  mpHbFont;
 public:
-boolHasGSUBstitutions( HDC ) const;
-boolIsGSUBstituted( sal_UCS4 ) const;
 hb_font_t*  GetHbFont() const { return mpHbFont; }
 voidSetHbFont( hb_font_t* pHbFont ) const { mpHbFont = 
pHbFont; }
 };
@@ -168,9 +151,6 @@ class WinSalGraphics : public SalGraphics
 friend class WinOpenGLSalGraphicsImpl;
 friend class ScopedFont;
 friend class OpenGLCompatibleDC;
-friend class WinLayout;
-friend class SimpleWinLayout;
-friend class UniscribeLayout;
 
 protected:
 std::unique_ptr mpImpl;
@@ -196,9 +176,6 @@ private:
 COLORREFmnTextColor;// TextColor
 RGNDATA*mpClipRgnData;  // ClipRegion-Data
 RGNDATA*mpStdClipRgnData;   // Cache 
Standard-ClipRegion-Data
-boolmbFontKernInit; // FALSE: FontKerns must be 
queried
-KERNINGPAIR*mpFontKernPairs;// Kerning Pairs of the 
current Font
-sal_uIntPtr mnFontKernPairCount;// Number of Kerning Pairs of 
the current Font
 int mnPenWidth; // Linienbreite
 
 LogicalFontInstance* GetWinFontEntry(int nFallbackLevel);
@@ -321,9 +298,6 @@ protected:
 private:
 // local helpers
 
-// get kernign pairs of the current font
-sal_uLong   GetKernPairs();
-
 static void DrawTextLayout(const CommonSalLayout&, HDC, bool 
bUseDWrite);
 
 public:
@@ -427,17 +401,6 @@ voidImplGetLogFontFromFontSelect( HDC, const 
FontSelectPattern*,
 
 #define MAX_64KSALPOINTSsal_uInt16)0x)-8)/sizeof(POINTS))
 
-// #102411# Win's GCP mishandles kerning => we need to do it ourselves
-// SalGraphicsData::mpFontKernPairs is sorted by
-inline bool ImplCmpKernData( const KERNINGPAIR& a, const KERNINGPAIR& b )
-{
-if( a.wFirst < b.wFirst )
-return true;
-if( a.wFirst > b.wFirst )
-return false;
-return (a.wSecond < b.wSecond);
-}
-
 // called extremely often from just one spot => inline
 inline bool WinFontFace::HasChar( sal_uInt32 cChar ) const
 {
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index ff57506..d339df3 100644
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -35,7 +35,6 @@
 typedef std::unordered_map IntMap;
 
 class WinFontInstance;
-struct VisualItem;
 
 namespace
 {
@@ -53,7 +52,6 @@ struct OpenGLGlyphDrawElement
 int mnBaselineOffset;
 int mnHeight;
 bool mbVertical;
-bool 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-11-15 Thread Khaled Hosny
 vcl/inc/win/salgdi.h  |2 +-
 vcl/inc/win/winlayout.hxx |2 +-
 vcl/win/gdi/salfont.cxx   |2 +-
 vcl/win/gdi/winlayout.cxx |   40 +---
 4 files changed, 32 insertions(+), 14 deletions(-)

New commits:
commit d436065bc1c68fc2d90e73253d8c00503c72dfd0
Author: Khaled Hosny 
Date:   Tue Nov 15 13:48:45 2016 +0200

tdf#103725: Default to GDI even with the new layout engine

It seems that our DirectWrite integration is missing few key features,
so back to GDI so at least people who need these feature can have away
to make them work.

So the situation is now with the new layout engine is like the old one;
GDI when OpenGL is not use and DirectWrite when OpenGL is used.

Fixing DirectWrite is now someone else’s problem.

Should also fix tdf#100986.

Change-Id: I102cac8a324f77b050d5183911b5cfda0b6b8f2b
Reviewed-on: https://gerrit.libreoffice.org/30868
Reviewed-by: Mike Kaganski 
Tested-by: Jenkins 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 8f75c1b..3050055 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -357,7 +357,7 @@ private:
 // get kernign pairs of the current font
 sal_uLong   GetKernPairs();
 
-static void DrawTextLayout(const CommonSalLayout&, HDC);
+static void DrawTextLayout(const CommonSalLayout&, HDC, bool 
bUseDWrite);
 
 public:
 // public SalGraphics methods, the interface to the independent vcl part
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 64e78d4..0e30e07 100755
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -421,7 +421,7 @@ protected:
 TextOutRenderer & operator = (const TextOutRenderer &) = delete;
 
 public:
-static TextOutRenderer & get();
+static TextOutRenderer & get(bool bUseDWrite);
 
 virtual ~TextOutRenderer() = default;
 
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index f290bdd..d2e11f8 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -1072,7 +1072,7 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
 rLogFont.lfQuality = NONANTIALIASED_QUALITY;
 
 // select vertical mode if requested and available
-if (!SalLayout::UseCommonLayout() && pFont->mbVertical && nNameLen )
+if ( pFont->mbVertical && nNameLen )
 {
 // vertical fonts start with an '@'
 memmove( [1], [0],
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 335bb8c..f4ead1d 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -93,7 +93,7 @@ bool WinFontInstance::CacheGlyphToAtlas(bool 
bRealGlyphIndices, int nGlyphIndex,
 }
 
 // For now we assume DWrite is present and we won't bother with fallback 
paths.
-D2DWriteTextOutRenderer * pTxt = dynamic_cast(::get());
+D2DWriteTextOutRenderer * pTxt = dynamic_cast(::get(true));
 if (!pTxt)
 return false;
 
@@ -3366,13 +3366,22 @@ void D2DWriteTextOutRenderer::CleanupModules()
 DWriteCreateFactory = nullptr;
 }
 
-TextOutRenderer & TextOutRenderer::get()
+TextOutRenderer & TextOutRenderer::get(bool bUseDWrite)
 {
-static std::unique_ptr 
_impl(D2DWriteTextOutRenderer::InitModules()
-? static_cast(new D2DWriteTextOutRenderer())
-: static_cast(new ExTextOutRenderer()));
+if (bUseDWrite)
+{
+static std::unique_ptr 
_impl(D2DWriteTextOutRenderer::InitModules()
+? static_cast(new D2DWriteTextOutRenderer())
+: static_cast(new ExTextOutRenderer()));
+
+return *_impl;
+}
+else
+{
+static std::unique_ptr _impl(new ExTextOutRenderer());
 
-return *_impl;
+return *_impl;
+}
 }
 
 
@@ -3390,6 +3399,15 @@ bool ExTextOutRenderer::operator ()(SalLayout const 
, HDC hDC,
 if (nGlyphs < 1)
 break;
 
+if (SalLayout::UseCommonLayout())
+{
+for (int i = 0; i < nGlyphs; i++)
+{
+if ((glyphIntStr[i] & GF_ROTMASK) == GF_ROTL)
+glyphIntStr[i] |= GF_VERT;
+}
+}
+
 std::copy_n(glyphIntStr, nGlyphs, glyphWStr);
 ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, 
LPCWSTR(), nGlyphs, nullptr);
 } while (!pRectToErase);
@@ -3788,7 +3806,7 @@ bool GraphiteWinLayout::DrawTextImpl(HDC hDC,
 maImpl.DrawBase() = WinLayout::maDrawBase;
 maImpl.DrawOffset() = WinLayout::maDrawOffset;
 
-TextOutRenderer & render = TextOutRenderer::get();
+TextOutRenderer & render = TextOutRenderer::get(true);
 bool const ok = render(*this, hDC, pRectToErase, pPos, pGetNextGlypInfo);
 if( hOrigFont )
 DeleteFont(SelectFont(hDC, hOrigFont));
@@ -4035,11 +4053,11 @@ LogicalFontInstance* 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-10-28 Thread Khaled Hosny
 vcl/inc/CommonSalLayout.hxx |1 
 vcl/inc/win/winlayout.hxx   |4 ++
 vcl/win/gdi/salfont.cxx |2 -
 vcl/win/gdi/winlayout.cxx   |   85 +++-
 4 files changed, 67 insertions(+), 25 deletions(-)

New commits:
commit 3d456dfa6637c6c3ebe7a21f1f1a5b05039cee2a
Author: Khaled Hosny 
Date:   Fri Oct 28 04:19:46 2016 +0200

tdf#98879: Fix vertical text on Windows for the new layout

The DirectWrite rendering code wasn’t handling vertical text correctly
at least when used with CommonSalLayout. It has been fixed and now made
the default.

We are also doing all vertical text handling on our own, so loading
special vertical fonts on Windows is now disabled.

Change-Id: I10d150367fe59c77459bb1b813b6f31a0ff0c5d0
Reviewed-on: https://gerrit.libreoffice.org/30346
Reviewed-by: Khaled Hosny 
Tested-by: Khaled Hosny 

diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx
index 0dd44b2..86fe5d0 100644
--- a/vcl/inc/CommonSalLayout.hxx
+++ b/vcl/inc/CommonSalLayout.hxx
@@ -56,6 +56,7 @@ class CommonSalLayout : public GenericSalLayout
 public:
 #if defined(_WIN32)
 explicitCommonSalLayout(HDC, WinFontInstance&, const 
WinFontFace&);
+const FontSelectPattern& getFontSelData() const { return mrFontSelData; };
 #elif defined(MACOSX) || defined(IOS)
 explicitCommonSalLayout(const CoreTextStyle&);
 const CoreTextStyle&getFontData() const { return mrCoreTextStyle; };
diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx
index 1f04251..b137a4b 100755
--- a/vcl/inc/win/winlayout.hxx
+++ b/vcl/inc/win/winlayout.hxx
@@ -455,11 +455,15 @@ class D2DWriteTextOutRenderer : public TextOutRenderer
 typedef HRESULT(WINAPI *pD2D1CreateFactory_t)(D2D1_FACTORY_TYPE,
 REFIID, const D2D1_FACTORY_OPTIONS *, void **);
 
+typedef HRESULT(WINAPI *pD2D1MakeRotateMatrix_t)(float, D2D1_POINT_2F,
+D2D1_MATRIX_3X2_F*);
+
 typedef HRESULT(WINAPI *pDWriteCreateFactory_t)(DWRITE_FACTORY_TYPE,
 REFIID, IUnknown **);
 
 static HINSTANCE mmD2d1, mmDWrite;
 static pD2D1CreateFactory_t D2D1CreateFactory;
+static pD2D1MakeRotateMatrix_t  D2D1MakeRotateMatrix;
 static pDWriteCreateFactory_t   DWriteCreateFactory;
 
 public:
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index d3e4e5e..b434184 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -1219,7 +1219,7 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
 rLogFont.lfQuality = NONANTIALIASED_QUALITY;
 
 // select vertical mode if requested and available
-if( pFont->mbVertical && nNameLen )
+if (!SalLayout::UseCommonLayout() && pFont->mbVertical && nNameLen )
 {
 // vertical fonts start with an '@'
 memmove( [1], [0],
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index d82f86d..83db103 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -3339,6 +3339,7 @@ sal_GlyphId GraphiteLayoutWinImpl::getKashidaGlyph(int & 
rWidth)
 HINSTANCE D2DWriteTextOutRenderer::mmD2d1 = nullptr,
   D2DWriteTextOutRenderer::mmDWrite = nullptr;
 D2DWriteTextOutRenderer::pD2D1CreateFactory_t 
D2DWriteTextOutRenderer::D2D1CreateFactory = nullptr;
+D2DWriteTextOutRenderer::pD2D1MakeRotateMatrix_t 
D2DWriteTextOutRenderer::D2D1MakeRotateMatrix = nullptr;
 D2DWriteTextOutRenderer::pDWriteCreateFactory_t 
D2DWriteTextOutRenderer::DWriteCreateFactory = nullptr;
 
 bool D2DWriteTextOutRenderer::InitModules()
@@ -3348,10 +3349,11 @@ bool D2DWriteTextOutRenderer::InitModules()
 if (mmD2d1 && mmDWrite)
 {
 D2D1CreateFactory = pD2D1CreateFactory_t(GetProcAddress(mmD2d1, 
"D2D1CreateFactory"));
+D2D1MakeRotateMatrix = pD2D1MakeRotateMatrix_t(GetProcAddress(mmD2d1, 
"D2D1MakeRotateMatrix"));
 DWriteCreateFactory = pDWriteCreateFactory_t(GetProcAddress(mmDWrite, 
"DWriteCreateFactory"));
 }
 
-if (!D2D1CreateFactory || !DWriteCreateFactory)
+if (!D2D1CreateFactory || !DWriteCreateFactory || !D2D1MakeRotateMatrix)
 {
 CleanupModules();
 return false;
@@ -3370,6 +3372,7 @@ void D2DWriteTextOutRenderer::CleanupModules()
 mmD2d1 = nullptr;
 mmDWrite = nullptr;
 D2D1CreateFactory = nullptr;
+D2D1MakeRotateMatrix = nullptr;
 DWriteCreateFactory = nullptr;
 }
 #endif // ENABLE_GRAPHITE_DWRITE
@@ -3479,7 +3482,24 @@ bool D2DWriteTextOutRenderer::operator ()(SalLayout 
const , HDC hDC,
 FLOAT  glyphAdvances[MAX_GLYPHS];
 DWRITE_GLYPH_OFFSET glyphOffsets[MAX_GLYPHS] = { { 0.0f, 0.0f }, };
 
+bool bVertical = false;
+double nYDiff = 0.0f;
+const CommonSalLayout* pCSL = dynamic_cast();
+if (pCSL)
+bVertical = pCSL->getFontSelData().mbVertical;
+
+if (bVertical)
+{
+

[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-10-21 Thread Khaled Hosny
 vcl/inc/win/salgdi.h  |2 +
 vcl/win/gdi/winlayout.cxx |   88 --
 2 files changed, 87 insertions(+), 3 deletions(-)

New commits:
commit 36bafd3d4ad7fa75649eeab0c9cd1b3d6f53d8e8
Author: Khaled Hosny 
Date:   Fri Oct 21 03:01:43 2016 +0200

tdf#103365: Try to fix Windows OpenGL rendering

Essentially an adapted copy of WinLayout::DrawText(). Avoiding code
duplication would have been nicer, but it is going to be too complicated
and the other copy is going away soonish anyway.

Change-Id: I7db4008a0db3d01d71d106e06fe413658f9bf42d
Reviewed-on: https://gerrit.libreoffice.org/30123
Reviewed-by: akash 
Reviewed-by: Khaled Hosny 
Tested-by: Khaled Hosny 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 9837a06..d694cf6 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -357,6 +357,8 @@ private:
 // get kernign pairs of the current font
 sal_uLong   GetKernPairs();
 
+voidDrawTextLayout(const CommonSalLayout&, HDC);
+
 public:
 static sal_uLongGetTable( const char pTagName[5], const unsigned 
char*&, void*&, IDWriteFontFace*& );
 // public SalGraphics methods, the interface to the independent vcl part
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 8c16b9d..476248e 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -4004,10 +4004,8 @@ LogicalFontInstance* WinFontFace::CreateFontInstance( 
FontSelectPattern& rFSD )
 return pFontInstance;
 }
 
-void WinSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
+void WinSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout, HDC hDC)
 {
-HDC hDC = getHDC();
-
 if (getenv("SAL_DWRITE_COMMON_LAYOUT"))
 {
 Point aPos(0, 0);
@@ -4032,4 +4030,88 @@ void WinSalGraphics::DrawSalLayout(const 
CommonSalLayout& rLayout)
 }
 }
 
+void WinSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout)
+{
+HDC hDC = getHDC();
+bool bUseOpenGL = OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter;
+if (!bUseOpenGL)
+{
+// no OpenGL, just classic rendering
+DrawTextLayout(rLayout, hDC);
+}
+else
+{
+// We have to render the text to a hidden texture, and draw it.
+//
+// Note that Windows GDI does not really support the alpha correctly
+// when drawing - ie. it draws nothing to the alpha channel when
+// rendering the text, even the antialiasing is done as 'real' pixels,
+// not alpha...
+//
+// Luckily, this does not really limit us:
+//
+// To blend properly, we draw the texture, but then use it as an alpha
+// channel for solid color (that will define the text color).  This
+// destroys the subpixel antialiasing - turns it into 'classic'
+// antialiasing - but that is the best we can do, because the subpixel
+// antialiasing needs to know what is in the background: When the
+// background is white, or white-ish, it does the subpixel, but when
+// there is a color, it just darkens the color (and does this even
+// when part of the character is on a colored background, and part on
+// white).  It has to work this way, the results would look strange
+// otherwise.
+//
+// For the GL rendering to work even with the subpixel antialiasing,
+// we would need to get the current texture from the screen, let GDI
+// draw the text to it (so that it can decide well where to use the
+// subpixel and where not), and draw the result - but in that case we
+// don't need alpha anyway.
+//
+// TODO: check the performance of this 2nd approach at some stage and
+// switch to that if it performs well.
+
+Rectangle aRect;
+rLayout.GetBoundRect(*this, aRect);
+
+WinOpenGLSalGraphicsImpl *pImpl = 
dynamic_cast(mpImpl.get());
+
+if (pImpl)
+{
+pImpl->PreDraw();
+
+OpenGLCompatibleDC aDC(*this, aRect.Left(), aRect.Top(), 
aRect.GetWidth(), aRect.GetHeight());
+
+// we are making changes to the DC, make sure we got a new one
+assert(aDC.getCompatibleHDC() != hDC);
+
+RECT aWinRect = { aRect.Left(), aRect.Top(), aRect.Left() + 
aRect.GetWidth(), aRect.Top() + aRect.GetHeight() };
+::FillRect(aDC.getCompatibleHDC(), , 
static_cast(::GetStockObject(WHITE_BRUSH)));
+
+// setup the hidden DC with black color and white background, we 
will
+// use the result of the text drawing later as a mask only
+HFONT hOrigFont = ::SelectFont(aDC.getCompatibleHDC(), 
static_cast(::GetCurrentObject(hDC, OBJ_FONT)));
+
+

[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-10-20 Thread Mike Kaganski
 vcl/inc/win/salvd.h |   20 +++---
 vcl/win/gdi/salvd.cxx   |   59 +++-
 vcl/win/window/salframe.cxx |8 ++---
 3 files changed, 40 insertions(+), 47 deletions(-)

New commits:
commit acfe9c225a8905f9742a9d9494ee242a45a15d50
Author: Mike Kaganski 
Date:   Thu Oct 20 15:11:01 2016 +1000

Incapsulate WinSalVirtualDevice better

Change-Id: I8de745e2318c69ccec2ffabb69df598a4bf60480
Reviewed-on: https://gerrit.libreoffice.org/30071
Reviewed-by: Mike Kaganski 
Tested-by: Jenkins 

diff --git a/vcl/inc/win/salvd.h b/vcl/inc/win/salvd.h
index d6ef119..a695bc7 100644
--- a/vcl/inc/win/salvd.h
+++ b/vcl/inc/win/salvd.h
@@ -29,12 +29,6 @@ class WinSalVirtualDevice : public SalVirtualDevice
 {
 private:
 HDC mhLocalDC;  // HDC or 0 for Cache 
Device
-
-public:
-HDC getHDC() { return mhLocalDC; }
-void setHDC(HDC aNew) { mhLocalDC = aNew; }
-
-public:
 HBITMAP mhBmp;  // Memory Bitmap
 HBITMAP mhDefBmp;   // Default Bitmap
 WinSalGraphics* mpGraphics; // current VirDev graphics
@@ -44,13 +38,19 @@ public:
 boolmbForeignDC;// uses a foreign DC 
instead of a bitmap
 longmnWidth;
 longmnHeight;
+public:
+HDC getHDC() const { return mhLocalDC; }
+WinSalGraphics* getGraphics() const { return mpGraphics; }
+void setGraphics(WinSalGraphics* pVirGraphics) { mpGraphics = 
pVirGraphics; }
+WinSalVirtualDevice* getNext() const { return mpNext; }
 
-WinSalVirtualDevice();
+public:
+WinSalVirtualDevice(HDC hDC = nullptr, HBITMAP hBMP = nullptr, sal_uInt16 
nBitCount = 0, bool bForeignDC = false, long nWidth = 0, long nHeight = 0);
 virtual ~WinSalVirtualDevice() override;
 
-virtual SalGraphics*AcquireGraphics() override;
-virtual voidReleaseGraphics( SalGraphics* pGraphics ) 
override;
-virtual boolSetSize( long nNewDX, long nNewDY ) 
override;
+virtual SalGraphics*AcquireGraphics() override;
+virtual voidReleaseGraphics( SalGraphics* pGraphics ) override;
+virtual boolSetSize( long nNewDX, long nNewDY ) override;
 
 static HBITMAP ImplCreateVirDevBitmap(HDC hDC, long nDX, long nDY, 
sal_uInt16 nBitCount, void **ppDummy);
 
diff --git a/vcl/win/gdi/salvd.cxx b/vcl/win/gdi/salvd.cxx
index 5735ccd..65d8600 100644
--- a/vcl/win/gdi/salvd.cxx
+++ b/vcl/win/gdi/salvd.cxx
@@ -125,7 +125,7 @@ SalVirtualDevice* WinSalInstance::CreateVirtualDevice( 
SalGraphics* pSGraphics,
 
 if ( bOk )
 {
-WinSalVirtualDevice*pVDev = new WinSalVirtualDevice;
+WinSalVirtualDevice*pVDev = new WinSalVirtualDevice(hDC, hBmp, 
nBitCount, (pData != nullptr && pData->hDC != nullptr ), nDX, nDY);
 SalData*pSalData = GetSalData();
 WinSalGraphics* pVirGraphics = new 
WinSalGraphics(WinSalGraphics::VIRTUAL_DEVICE, pGraphics->isScreen(), nullptr, 
pVDev);
 pVirGraphics->SetLayout( SalLayoutFlags::NONE );   // by default no! 
mirroring for VirtualDevices, can be enabled with EnableRTL()
@@ -137,22 +137,7 @@ SalVirtualDevice* WinSalInstance::CreateVirtualDevice( 
SalGraphics* pSGraphics,
 }
 pVirGraphics->InitGraphics();
 
-pVDev->mnWidth = nDX;
-pVDev->mnHeight = nDY;
-pVDev->setHDC(hDC);
-pVDev->mhBmp= hBmp;
-if( hBmp )
-pVDev->mhDefBmp = SelectBitmap( hDC, hBmp );
-else
-pVDev->mhDefBmp = nullptr;
-pVDev->mpGraphics   = pVirGraphics;
-pVDev->mnBitCount   = nBitCount;
-pVDev->mbGraphics   = FALSE;
-pVDev->mbForeignDC  = (pData != nullptr && pData->hDC != nullptr );
-
-// insert VirDev in VirDevList
-pVDev->mpNext = pSalData->mpFirstVD;
-pSalData->mpFirstVD = pVDev;
+pVDev->setGraphics(pVirGraphics);
 
 return pVDev;
 }
@@ -166,18 +151,26 @@ SalVirtualDevice* WinSalInstance::CreateVirtualDevice( 
SalGraphics* pSGraphics,
 }
 }
 
-WinSalVirtualDevice::WinSalVirtualDevice()
+WinSalVirtualDevice::WinSalVirtualDevice(HDC hDC, HBITMAP hBMP, sal_uInt16 
nBitCount, bool bForeignDC, long nWidth, long nHeight)
+: mhLocalDC(hDC),  // HDC or 0 for Cache Device
+  mhBmp(hBMP), // Memory Bitmap
+  mpGraphics(nullptr), // current VirDev graphics
+  mnBitCount(nBitCount),   // BitCount (0 or 1)
+  mbGraphics(false),   // is Graphics used
+  mbForeignDC(bForeignDC), // uses a foreign DC instead of a bitmap
+  mnWidth(nWidth),
+  mnHeight(nHeight)
 {
-setHDC(nullptr);// HDC or 0 for Cache Device
-mhBmp = nullptr;// Memory 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-09-30 Thread Michael Stahl
 vcl/inc/win/salgdi.h|1 
 vcl/win/gdi/salfont.cxx |  159 
 vcl/win/gdi/salgdi.cxx  |1 
 3 files changed, 161 deletions(-)

New commits:
commit 966677bea718d95b3931c4ec86f5add1bca6cb1f
Author: Michael Stahl 
Date:   Fri Sep 30 13:37:23 2016 +0200

vcl: remove WNT ImplFontAttrCache

The fontnames.dat cache turns out to be unused in release builds; it
contains the fonts in instdir/share/fonts but in the MSI these are
always installed into C:/Windows/Fonts nowadays.

Change-Id: Ibaac87515310d659566622e006b3b7ec01c7551e

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 931c25b..5c3d85f 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -222,7 +222,6 @@ private:
 COLORREFmnTextColor;// TextColor
 RGNDATA*mpClipRgnData;  // ClipRegion-Data
 RGNDATA*mpStdClipRgnData;   // Cache 
Standard-ClipRegion-Data
-ImplFontAttrCache*  mpFontAttrCache;// Cache font attributes from 
files in so/share/fonts
 boolmbFontKernInit; // FALSE: FontKerns must be 
queried
 KERNINGPAIR*mpFontKernPairs;// Kerning Pairs of the 
current Font
 sal_uIntPtr mnFontKernPairCount;// Number of Kerning Pairs of 
the current Font
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 9741098..a923c2b 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -73,146 +73,6 @@ inline int IntTimes256FromFixed(FIXED f)
 static bool bImplSalCourierScalable = false;
 static bool bImplSalCourierNew = false;
 
-// TODO: also support temporary TTC font files
-typedef std::map< OUString, FontAttributes > FontAttrMap;
-
-class ImplFontAttrCache
-{
-private:
-FontAttrMap aFontAttributes;
-OUStringaCacheFileName;
-OUStringaBaseURL;
-boolbModified;
-
-protected:
-OUString OptimizeURL( const OUString& rURL ) const;
-
-enum{ MAGIC = 0x12346789 }; // change if fontattrcache format changes
-
-public:
-ImplFontAttrCache(const OUString& rCacheFileName,
-  const OUString& rBaseURL);
-~ImplFontAttrCache();
-
-FontAttributes  GetFontAttr( const OUString& rFontFileName ) const;
-void   AddFontAttr( const OUString& rFontFileName, const 
FontAttributes& );
-};
-
-ImplFontAttrCache::ImplFontAttrCache( const OUString& rFileNameURL, const 
OUString& rBaseURL ) : aBaseURL( rBaseURL )
-{
-bModified = FALSE;
-aBaseURL = aBaseURL.toAsciiLowerCase();// Windows only, no problem...
-
-// open the cache file
-osl::FileBase::getSystemPathFromFileURL( rFileNameURL, aCacheFileName );
-SvFileStream aCacheFile( aCacheFileName, StreamMode::READ );
-if( !aCacheFile.IsOpen() )
-return;
-
-// check the cache version
-sal_uInt32 nCacheMagic;
-aCacheFile.ReadUInt32(nCacheMagic);
-if( nCacheMagic != ImplFontAttrCache::MAGIC )
-return;  // ignore cache and rewrite if no match
-
-// read the cache entries from the file
-OUString aFontFileURL;
-FontAttributes aDFA;
-for(;;)
-{
-aFontFileURL = read_uInt16_lenPrefixed_uInt8s_ToOUString(aCacheFile, 
RTL_TEXTENCODING_UTF8);
-if( aFontFileURL.isEmpty() )
-break;
-
aDFA.SetFamilyName(read_uInt16_lenPrefixed_uInt8s_ToOUString(aCacheFile, 
RTL_TEXTENCODING_UTF8));
-
-short n;
-aCacheFile.ReadInt16(n);
-aDFA.SetWeight(static_cast(n));
-aCacheFile.ReadInt16(n);
-aDFA.SetItalic(static_cast(n));
-aCacheFile.ReadInt16(n);
-aDFA.SetPitch(static_cast(n));
-aCacheFile.ReadInt16(n);
-aDFA.SetWidthType(static_cast(n));
-aCacheFile.ReadInt16(n);
-aDFA.SetFamilyType(static_cast(n));
-aCacheFile.ReadInt16(n);
-aDFA.SetSymbolFlag(n != 0);
-
-OUString const styleName = read_uInt16_lenPrefixed_uInt8s_ToOUString(
-aCacheFile, RTL_TEXTENCODING_UTF8);
-aDFA.SetStyleName( styleName );
-
-aFontAttributes[ aFontFileURL ] = aDFA;
-}
-}
-
-ImplFontAttrCache::~ImplFontAttrCache()
-{
-if ( bModified )
-{
-SvFileStream aCacheFile( aCacheFileName, 
StreamMode::WRITE|StreamMode::TRUNC );
-if ( aCacheFile.IsWritable() )
-{
-sal_uInt32 nCacheMagic = ImplFontAttrCache::MAGIC;
-aCacheFile.WriteUInt32( nCacheMagic );
-
-// write the cache entries to the file
-FontAttrMap::const_iterator aIter = aFontAttributes.begin();
-while ( aIter != aFontAttributes.end() )
-{
-const OUString rFontFileURL( (*aIter).first );
-const FontAttributes& rDFA( (*aIter).second );
-write_uInt16_lenPrefixed_uInt8s_FromOUString(aCacheFile, 
rFontFileURL, RTL_TEXTENCODING_UTF8);
-  

[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-05-04 Thread Stephan Bergmann
 vcl/inc/opengl/texture.hxx |1 +
 vcl/win/app/salinst.cxx|1 +
 2 files changed, 2 insertions(+)

New commits:
commit ce3951edd4bb06bc8f7b6bba55dbb56ac9c96f10
Author: Stephan Bergmann 
Date:   Wed May 4 15:38:55 2016 +0200

Missing includes

Change-Id: Ic0618ff8a8f01937a467e4ba5184fe68f14cd24b

diff --git a/vcl/inc/opengl/texture.hxx b/vcl/inc/opengl/texture.hxx
index e7804af..5b4ccff 100644
--- a/vcl/inc/opengl/texture.hxx
+++ b/vcl/inc/opengl/texture.hxx
@@ -26,6 +26,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 4ca2a64..1f2d22c 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-04-18 Thread Michael Stahl
 vcl/inc/win/saldata.hxx  |2 ++
 vcl/inc/win/salinst.h|1 +
 vcl/win/app/salinst.cxx  |4 
 vcl/win/app/saltimer.cxx |   38 --
 4 files changed, 31 insertions(+), 14 deletions(-)

New commits:
commit 8a0e6b25219e59b12034348b8b264117059755ec
Author: Michael Stahl 
Date:   Mon Apr 11 23:49:12 2016 +0200

tdf#96887 vcl: stop using periodic timers on WNT

Every time the periodic timer fires, it does a PostMessage() to the
main thread.  The main thread will only process the first message and
discard the rest anyway, but with a short enough timer and other
threads hogging the SolarMutex it's possible that the message queue
overflows and other PostMessage calls fail with ERROR_NOT_ENOUGH_QUOTA.

Try to avoid the problem by having the WinSalTimer always be a one-shot
timer; when it fires and the main thread processes the posted message,
it is restarted with the new due time.

This requires creating a new TimerQueueTimer because
ChangeTimerQueueTimer only works on periodic timers.

Change-Id: I816bd3fa5fbfbea4f26be8ff680a1c916618d3f9
Reviewed-on: https://gerrit.libreoffice.org/24024
Tested-by: Jenkins 
Reviewed-by: Jan Holesovsky 
Reviewed-by: Michael Stahl 

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 03c9faa7..79ad3fb 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -269,6 +269,8 @@ int ImplSalWICompareAscii( const wchar_t* pStr1, const 
char* pStr2 );
 
 // Call the Timer's callback from the main thread
 #define SAL_MSG_TIMER_CALLBACK  (WM_USER+162)
+// Stop the timer from the main thread; wParam = 0, lParam = 0
+#define SAL_MSG_STOPTIMER   (WM_USER+163)
 
 inline void SetWindowPtr( HWND hWnd, WinSalFrame* pThis )
 {
diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h
index fe2c341..43c0313 100644
--- a/vcl/inc/win/salinst.h
+++ b/vcl/inc/win/salinst.h
@@ -83,6 +83,7 @@ SalFrame* ImplSalCreateFrame( WinSalInstance* pInst, HWND 
hWndParent, SalFrameSt
 SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent );
 HWND ImplSalReCreateHWND( HWND hWndParent, HWND oldhWnd, bool bAsChild );
 void ImplSalStartTimer( sal_uIntPtr nMS, bool bMutex = false );
+void ImplSalStopTimer();
 
 #endif // INCLUDED_VCL_INC_WIN_SALINST_H
 
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index dd687d8..bd5b49e 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -672,6 +672,10 @@ LRESULT CALLBACK SalComWndProc( HWND, UINT nMsg, WPARAM 
wParam, LPARAM lParam, i
 ImplSalStartTimer( (sal_uLong) lParam, FALSE );
 rDef = FALSE;
 break;
+case SAL_MSG_STOPTIMER:
+ImplSalStopTimer();
+rDef = FALSE;
+break;
 case SAL_MSG_CREATEFRAME:
 nRet = (LRESULT)ImplSalCreateFrame( GetSalData()->mpFirstInstance, 
(HWND)lParam, (SalFrameStyleFlags)wParam );
 rDef = FALSE;
diff --git a/vcl/win/app/saltimer.cxx b/vcl/win/app/saltimer.cxx
index 30aa816..ff230c2 100644
--- a/vcl/win/app/saltimer.cxx
+++ b/vcl/win/app/saltimer.cxx
@@ -34,12 +34,22 @@ void CALLBACK SalTimerProc(PVOID pParameter, BOOLEAN 
bTimerOrWaitFired);
 // See 
http://msdn.microsoft.com/en-us/library/windows/desktop/ms687003%28v=vs.85%29.aspx
 // (and related pages) for details about the Timer Queues.
 
-void ImplSalStopTimer(SalData* pSalData)
+// in order to prevent concurrent execution of ImplSalStartTimer and double
+// deletion of timer (which is extremely likely, given that
+// INVALID_HANDLE_VALUE waits for the callback to run on the main thread),
+// this must run on the main thread too
+void ImplSalStopTimer()
 {
+SalData *const pSalData = GetSalData();
 HANDLE hTimer = pSalData->mnTimerId;
-pSalData->mnTimerId = 0;
-DeleteTimerQueueTimer(NULL, hTimer, INVALID_HANDLE_VALUE);
+if (hTimer)
+{
+pSalData->mnTimerId = 0; // reset so it doesn't restart
+DeleteTimerQueueTimer(NULL, hTimer, INVALID_HANDLE_VALUE);
+pSalData->mnNextTimerTime = 0;
+}
 MSG aMsg;
+// this needs to run on the main thread
 while (PeekMessageW(, 0, SAL_MSG_TIMER_CALLBACK, 
SAL_MSG_TIMER_CALLBACK, PM_REMOVE))
 {
 // just remove all the SAL_MSG_TIMER_CALLBACKs
@@ -61,11 +71,13 @@ void ImplSalStartTimer( sal_uLong nMS, bool bMutex )
 if (nMS > MAX_SYSPERIOD)
 nMS = MAX_SYSPERIOD;
 
-// change if it exists, create if not
+// cannot change a one-shot timer, so delete it and create new one
 if (pSalData->mnTimerId)
-ChangeTimerQueueTimer(NULL, pSalData->mnTimerId, nMS, nMS);
-else
-CreateTimerQueueTimer(>mnTimerId, NULL, SalTimerProc, NULL, 
nMS, nMS, WT_EXECUTEINTIMERTHREAD);
+{
+DeleteTimerQueueTimer(NULL, pSalData->mnTimerId, INVALID_HANDLE_VALUE);
+   

[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-04-14 Thread Noel Grandin
 vcl/inc/win/salsys.h|   14 --
 vcl/inc/win/wincomp.hxx |2 --
 vcl/win/app/salinfo.cxx |8 ++--
 3 files changed, 6 insertions(+), 18 deletions(-)

New commits:
commit 6656693836a382e6dac3a8c7ae794517b5f92bcc
Author: Noel Grandin 
Date:   Thu Apr 14 09:12:31 2016 +0200

remove dead fields from WinSalSystem::DisplayMonitor

Change-Id: I76254f194ac1bbd019b8c46f3f3f0f28e4e7f0ec
Reviewed-on: https://gerrit.libreoffice.org/24074
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/win/salsys.h b/vcl/inc/win/salsys.h
index 7efce50..5dd8de6 100644
--- a/vcl/inc/win/salsys.h
+++ b/vcl/inc/win/salsys.h
@@ -31,19 +31,13 @@ public:
 struct DisplayMonitor
 {
 OUStringm_aName;
-OUStringm_aDeviceName;
-Rectanglem_aArea;
-sal_Int32m_nStateFlags;
+Rectangle   m_aArea;
 
-DisplayMonitor() : m_nStateFlags( 0 ) {}
+DisplayMonitor() {}
 DisplayMonitor( const OUString& rName,
-const OUString& rDevName,
-const Rectangle& rArea,
-DWORD nStateFlags )
+const Rectangle& rArea )
 : m_aName( rName ),
-  m_aDeviceName( rDevName ),
-  m_aArea( rArea ),
-  m_nStateFlags( nStateFlags )
+  m_aArea( rArea )
 {
 }
 ~DisplayMonitor() {}
diff --git a/vcl/inc/win/wincomp.hxx b/vcl/inc/win/wincomp.hxx
index 549b3f4..8d13770 100644
--- a/vcl/inc/win/wincomp.hxx
+++ b/vcl/inc/win/wincomp.hxx
@@ -171,8 +171,6 @@ inline HINSTANCE GetWindowInstance( HWND hWnd )
 }
 
 
-#define MSH_MOUSEWHEEL "MSWHEEL_ROLLMSG"
-
 #define MOUSEZ_CLASSNAME  "MouseZ"// wheel window class
 #define MOUSEZ_TITLE  "Magellan MSWHEEL"  // wheel window title
 
diff --git a/vcl/win/app/salinfo.cxx b/vcl/win/app/salinfo.cxx
index ae80798..8b70632 100644
--- a/vcl/win/app/salinfo.cxx
+++ b/vcl/win/app/salinfo.cxx
@@ -94,9 +94,7 @@ bool WinSalSystem::initMonitors()
 int w = GetSystemMetrics( SM_CXSCREEN );
 int h = GetSystemMetrics( SM_CYSCREEN );
 m_aMonitors.push_back( DisplayMonitor( OUString(),
-   OUString(),
-   Rectangle( Point(), Size( w, h 
) ),
-   0 ) );
+   Rectangle( Point(), Size( w, h 
) ) ) );
 m_aDeviceNameToMonitor[ OUString() ] = 0;
 m_nPrimary = 0;
 }
@@ -121,9 +119,7 @@ bool WinSalSystem::initMonitors()
 aDeviceStringCount[ aDeviceString ]++;
 m_aDeviceNameToMonitor[ aDeviceName ] = m_aMonitors.size();
 m_aMonitors.push_back( DisplayMonitor( aDeviceString,
-   aDeviceName,
-   Rectangle(),
-   aDev.StateFlags ) );
+   Rectangle() ) );
 }
 }
 HDC aDesktopRC = GetDC( NULL );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-04-13 Thread Noel Grandin
 vcl/inc/win/saldata.hxx   |9 
 vcl/inc/win/wincomp.hxx   |5 
 vcl/win/app/salinst.cxx   |4 ---
 vcl/win/gdi/salnativewidgets-luna.cxx |6 +
 vcl/win/window/salframe.cxx   |   37 +++---
 vcl/win/window/salobj.cxx |2 -
 6 files changed, 8 insertions(+), 55 deletions(-)

New commits:
commit 9a2ff36b51f86ca3ade8093d7698314c0d3db6a6
Author: Noel Grandin 
Date:   Wed Apr 13 09:36:25 2016 +0200

remove dead stuff from Windows SalData

- drop mbInTimerProc field
- drop mnSageStatus,mpSageEnableProc fields i.e. SAGE.DLL (System Agent) 
workaround, which died out with Win95/98
- convert some TRUE/FALSE constants to true/false where the field is a bool
- drop maDwmLib, mpDwmIsCompositionEnabled fields

Change-Id: I7b773f915dbc329eb0262bc8fee2ea7c72d25c66
Reviewed-on: https://gerrit.libreoffice.org/24047
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index c921514..03c9faa7 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -40,8 +40,6 @@ namespace vcl { class Font; }
 struct HDCCache;
 struct TempFontItem;
 
-typedef HRESULT (WINAPI  *DwmIsCompositionEnabled_ptr)(BOOL*);
-
 #define MAX_STOCKPEN4
 #define MAX_STOCKBRUSH  4
 #define SAL_CLIPRECT_COUNT  16
@@ -87,7 +85,6 @@ public:
 DWORD   mnNextTimerTime;
 DWORD   mnLastEventTime;
 HANDLE  mnTimerId;  ///< Windows timer id
-boolmbInTimerProc;  // timer event is 
currently being dispatched
 HHOOK   mhSalObjMsgHook;// hook to get interesting 
msg for SalObject
 HWNDmhWantLeaveMsg; // window handle, that 
want a MOUSELEAVE message
 AutoTimer*  mpMouseLeaveTimer;  // Timer for MouseLeave 
Test
@@ -109,10 +106,8 @@ public:
 BYTEmnCacheDCInUse; // count of CacheDC in use
 boolmbObjClassInit; // is SALOBJECTCLASS 
initialised
 boolmbInPalChange;  // is in WM_QUERYNEWPALETTE
-DWORD   mnAppThreadId;  // Id from 
Applikation-Thread
+DWORD   mnAppThreadId;  // Id from 
Application-Thread
 BOOLmbScrSvrEnabled;// ScreenSaver enabled
-int mnSageStatus;   // status of Sage-DLL 
(DISABLE_AGENT == does not exist)
-SysAgt_Enable_PROC  mpSageEnableProc;   // funktion to deactivate 
the system agent
 SalIcon*mpFirstIcon;// icon cache, points to 
first icon, NULL if none
 TempFontItem*   mpTempFontItem;
 boolmbThemeChanged; // true if visual theme 
was changed: throw away theme handles
@@ -123,8 +118,6 @@ public:
 
 std::set< HMENU >   mhMenuSet;  // keeps track of menu 
handles created by VCL, used by IsKnownMenuHandle()
 std::map< UINT,sal_uInt16 > maVKMap;  // map some dynamic VK_* entries
-oslModule   maDwmLib;
-DwmIsCompositionEnabled_ptr mpDwmIsCompositionEnabled;
 };
 
 inline void SetSalData( SalData* pData ) { ImplGetSVData()->mpSalData = pData; 
}
diff --git a/vcl/inc/win/wincomp.hxx b/vcl/inc/win/wincomp.hxx
index b1f0fa7..549b3f4 100644
--- a/vcl/inc/win/wincomp.hxx
+++ b/vcl/inc/win/wincomp.hxx
@@ -198,11 +198,6 @@ inline HINSTANCE GetWindowInstance( HWND hWnd )
 #endif
 
 
-#define ENABLE_AGENT1
-#define DISABLE_AGENT   2
-#define GET_AGENT_STATUS3
-typedef int (APIENTRY* SysAgt_Enable_PROC)( int );
-
 // - 5.0-Erweiterungen -
 
 #ifndef COLOR_GRADIENTACTIVECAPTION
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 346d439..dd687d8 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -363,8 +363,6 @@ SalData::SalData()
 mbInPalChange = false;  // is in WM_QUERYNEWPALETTE
 mnAppThreadId = 0;  // Id from Applikation-Thread
 mbScrSvrEnabled = FALSE;// ScreenSaver enabled
-mnSageStatus = 0;   // status of Sage-DLL (DISABLE_AGENT == not 
available)
-mpSageEnableProc = 0;   // funktion to deactivate the system agent
 mpFirstIcon = 0;// icon cache, points to first icon, NULL if 
none
 mpTempFontItem = 0;
 mbThemeChanged = false; // true if visual theme was changed: throw 
away theme handles
@@ -372,8 +370,6 @@ SalData::SalData()
 
 // init with NULL
 gdiplusToken = 0;
-maDwmLib = 0;
-mpDwmIsCompositionEnabled = 0;
 
 initKeyCodeMap();
 
diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx 
b/vcl/win/gdi/salnativewidgets-luna.cxx
index d9db4a0..e659747 100644
--- 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-04-13 Thread Noel Grandin
 vcl/inc/win/saldata.hxx |1 -
 vcl/win/window/salframe.cxx |   36 
 2 files changed, 37 deletions(-)

New commits:
commit 32102b9aa75a296b99f3fdaf370bd83bfd629f4e
Author: Noel Grandin 
Date:   Wed Apr 13 09:45:32 2016 +0200

remove Windows95 MouseWheel support

since we no longer support Windows95

Change-Id: I6b2fe5fdb2cde3c69fc0d18bcaac25afccbffc16
Reviewed-on: https://gerrit.libreoffice.org/24049
Tested-by: Jenkins 
Reviewed-by: Michael Stahl 

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 66b8a7f..c921514 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -135,7 +135,6 @@ struct SalShlData
 HINSTANCE   mhInst; // Instance of SAL-DLL
 UINTmnWheelScrollLines; // WheelScrollLines
 UINTmnWheelScrollChars; // WheelScrollChars
-UINTmnWheelMsgId;   // Wheel-Message-Id fuer 
W95
 BOOLmbWXP;  // Windows XP
 BOOLmbWVista;   // Windows Vista
 BOOLmbW7;   // Windows 7
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 7a6f5c6..ad2693e 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -880,8 +880,6 @@ WinSalFrame::WinSalFrame()
 // get data, when making 1st frame
 if ( !pSalData->mpFirstFrame )
 {
-if ( !aSalShlData.mnWheelMsgId )
-aSalShlData.mnWheelMsgId = RegisterWindowMessage( MSH_MOUSEWHEEL );
 if ( !aSalShlData.mnWheelScrollLines )
 aSalShlData.mnWheelScrollLines = ImplSalGetWheelScrollLines();
 if ( !aSalShlData.mnWheelScrollChars )
@@ -5892,40 +5890,6 @@ LRESULT CALLBACK SalFrameWndProc( HWND hWnd, UINT nMsg, 
WPARAM wParam, LPARAM lP
 break;
 }
 
-// catch WheelMouse-Message
-if ( rDef && (nMsg == aSalShlData.mnWheelMsgId) && 
aSalShlData.mnWheelMsgId )
-{
-// protect against recursion, in case the message is returned
-// by IE or the external window
-if ( !bInWheelMsg )
-{
-bInWheelMsg++;
-// First dispatch the message; and then give the SystemWindow a 
turn
-WORD nKeyState = 0;
-if ( GetKeyState( VK_SHIFT ) & 0x8000 )
-nKeyState |= MK_SHIFT;
-if ( GetKeyState( VK_CONTROL ) & 0x8000 )
-nKeyState |= MK_CONTROL;
-// Mutex handling is inside from this call
-rDef = !ImplHandleWheelMsg( hWnd,
-WM_MOUSEWHEEL,
-MAKEWPARAM( nKeyState, (WORD)wParam ),
-lParam );
-if ( rDef )
-{
-HWND hWheelWnd = ::GetFocus();
-if ( hWheelWnd && (hWheelWnd != hWnd) )
-{
-nRet = SendMessageW( hWheelWnd, nMsg, wParam, lParam );
-rDef = FALSE;
-}
-else
-rDef = ImplSalWheelMousePos( hWnd, nMsg, wParam, lParam, 
nRet );
-}
-bInWheelMsg--;
-}
-}
-
 if( bCheckTimers )
 {
 SalData* pSalData = GetSalData();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-04-12 Thread Armin Le Grand
 vcl/inc/win/saldata.hxx |2 
 vcl/inc/win/salinst.h   |8 ---
 vcl/win/app/salinst.cxx |  117 +---
 3 files changed, 34 insertions(+), 93 deletions(-)

New commits:
commit 9c9970952b0adec4a8c6de9a4cd54d0980cd47ec
Author: Armin Le Grand 
Date:   Fri Apr 8 15:14:43 2016 +0200

tdf#96887 enhance SolarMutex AcquireWithWait for Windows

Currently the Windows-specific method ImplSalYieldMutexAcquireWithWait()
uses a messaging mechanism to learn about the SolarMutex being free again.
This is not reliable when the MessageQueue overflows (MS allows 1
messages per queue). It is more safe to use MsgWaitForMultipleObjects.
This also allows to not only wait for the SolarMutex to be freed, but
also to detect when SendMessage() is used which needs to lead to a
reschedule to not block current Window handling.

Change-Id: Id317dda62aaa1fe7677d8d28929e6936e5a22705
Reviewed-on: https://gerrit.libreoffice.org/23921
Tested-by: Jenkins 
Reviewed-by: Armin Le Grand 

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index ed8a2fd..66b8a7f 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -214,8 +214,6 @@ int ImplSalWICompareAscii( const wchar_t* pStr1, const 
char* pStr2 );
 
 // wParam == bWait; lParam == 0
 #define SAL_MSG_THREADYIELD (WM_USER+111)
-// wParam == 0; lParam == 0
-#define SAL_MSG_RELEASEWAITYIELD(WM_USER+112)
 // wParam == 0; lParam == nMS
 #define SAL_MSG_STARTTIMER  (WM_USER+113)
 // wParam == nFrameStyle; lParam == pParent; lResult == pFrame
diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h
index b6408ea..fe2c341 100644
--- a/vcl/inc/win/salinst.h
+++ b/vcl/inc/win/salinst.h
@@ -33,14 +33,6 @@ public:
 HWNDmhComWnd;
 /// The Yield mutex ensures that only one thread calls into VCL
 SalYieldMutex*  mpSalYieldMutex;
-/// The Wait mutex ensures increment of mnYieldWaitCount and acquisition
-/// or release of mpSalYieldMutex is atomic
-osl::Mutex* mpSalWaitMutex;
-/// count main thread's pending ImplSalYieldMutexAcquireWithWait() calls
-/// (it's not clear to me if this will be > 1 in practice; it would be
-/// possible if main thread's handling of SAL_MSG_* sent by other threads
-/// via SendMessage() ends up calling ImplSalYieldMutexAcquireWithWait())
-sal_uInt16  mnYieldWaitCount;
 
 public:
 WinSalInstance();
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 1e37ece..a44e930 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -109,9 +109,9 @@ LRESULT CALLBACK SalComWndProcW( HWND hWnd, UINT nMsg, 
WPARAM wParam, LPARAM lPa
 
 class SalYieldMutex : public comphelper::SolarMutex
 {
-osl::Mutex m_mutex;
-
-public: // for ImplSalYield()
+public: // for ImplSalYield() and ImplSalYieldMutexAcquireWithWait()
+osl::Mutex  m_mutex;
+osl::Condition  m_condition; /// for 
MsgWaitForMultipleObjects()
 WinSalInstance* mpInstData;
 sal_uLong   mnCount;
 DWORD   mnThreadId;
@@ -147,10 +147,11 @@ void SalYieldMutex::release()
 m_mutex.release();
 else
 {
-SalData* pSalData = GetSalData();
-if ( pSalData->mnAppThreadId != nThreadId )
+bool isRelease(1 == mnCount);
+if ( isRelease )
 {
-if ( mnCount == 1 )
+SalData* pSalData = GetSalData();
+if ( pSalData->mnAppThreadId != nThreadId )
 {
 OpenGLContext::prepareForYield();
 
@@ -158,31 +159,21 @@ void SalYieldMutex::release()
 // Java clients doesn't come in the right order
 GdiFlush();
 
-// lock here to ensure that the test of mnYieldWaitCount and
-// m_mutex.release() is atomic
-mpInstData->mpSalWaitMutex->acquire();
-if ( mpInstData->mnYieldWaitCount )
-PostMessageW( mpInstData->mhComWnd, 
SAL_MSG_RELEASEWAITYIELD, 0, 0 );
 mnThreadId = 0;
-mnCount--;
-m_mutex.release();
-mpInstData->mpSalWaitMutex->release();
 }
 else
 {
-mnCount--;
-m_mutex.release();
-}
-}
-else
-{
-if ( mnCount == 1 )
-{
 mnThreadId = 0;
 OpenGLContext::prepareForYield();
 }
-mnCount--;
-m_mutex.release();
+}
+
+mnCount--;
+m_mutex.release();
+
+if ( isRelease )
+{   // do this *after* release
+m_condition.set(); // wake up ImplSalYieldMutexAcquireWithWait()
 }
 }
 }
@@ -216,57 +207,33 @@ void 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-03-21 Thread Marco Cecchetti
 vcl/inc/opengl/salbmp.hxx |1 +
 vcl/win/gdi/salgdi2.cxx   |   10 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

New commits:
commit f5a53794e188c8ee49173749578a6b81b52a82f4
Author: Marco Cecchetti 
Date:   Sun Mar 20 20:37:31 2016 +0100

tdf#98324 - PNG prints as black block with OpenGL - fixed

Now the correct color palette is used.

Change-Id: If26c7cb149d1d6c24ae78137ff54669b3091fdb2
Reviewed-on: https://gerrit.libreoffice.org/23378
Tested-by: Jenkins 
Reviewed-by: Michael Meeks 

diff --git a/vcl/inc/opengl/salbmp.hxx b/vcl/inc/opengl/salbmp.hxx
index 4eb0b01..5a9270e 100644
--- a/vcl/inc/opengl/salbmp.hxx
+++ b/vcl/inc/opengl/salbmp.hxx
@@ -85,6 +85,7 @@ public:
 boolCreate( const OpenGLTexture& rTex, long nX, long nY, long 
nWidth, long nHeight );
 OpenGLTexture&  GetTexture() const;
 static rtl::Reference GetBitmapContext();
+const BitmapPalette& GetBitmapPalette() const { return maPalette; }
 
 private:
 
diff --git a/vcl/win/gdi/salgdi2.cxx b/vcl/win/gdi/salgdi2.cxx
index 1500ae8..f8b8fe7 100644
--- a/vcl/win/gdi/salgdi2.cxx
+++ b/vcl/win/gdi/salgdi2.cxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -73,9 +74,16 @@ namespace
 
 void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap)
 {
+ BitmapPalette aBitmapPalette;
+ OpenGLSalBitmap* pGLSalBitmap = 
dynamic_cast();
+ if (pGLSalBitmap != nullptr)
+ {
+ aBitmapPalette = pGLSalBitmap->GetBitmapPalette();
+ }
+
 BitmapBuffer* pRead = rSalBitmap.AcquireBuffer(BITMAP_READ_ACCESS);
 
-rWinSalBitmap.Create(rSalBitmap.GetSize(), rSalBitmap.GetBitCount(), 
BitmapPalette());
+rWinSalBitmap.Create(rSalBitmap.GetSize(), rSalBitmap.GetBitCount(), 
aBitmapPalette);
 BitmapBuffer* pWrite = 
rWinSalBitmap.AcquireBuffer(BITMAP_WRITE_ACCESS);
 
 sal_uInt8* pSource(pRead->mpBits);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-02-12 Thread Stephan Bergmann
 vcl/inc/win/salprn.h   |2 +-
 vcl/win/gdi/salprn.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 74b4e5ebbfd232e4d8862abfe9bd5ce13da1
Author: Stephan Bergmann 
Date:   Fri Feb 12 13:47:34 2016 +0100

Blind Windows fix attempt

Change-Id: If4f83dfa0b2977f404715b7a95a73cbcdfc4f5df

diff --git a/vcl/inc/win/salprn.h b/vcl/inc/win/salprn.h
index 33795a4..8736680 100644
--- a/vcl/inc/win/salprn.h
+++ b/vcl/inc/win/salprn.h
@@ -92,7 +92,7 @@ public:
 virtual boolStartJob( const OUString* pFileName,
   const OUString& rJobName,
   const OUString& rAppName,
-  sal_uIntPtr nCopies,
+  sal_uInt32 nCopies,
   bool bCollate,
   bool bDirect,
   ImplJobSetup* pSetupData ) 
override;
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 174a1a3..0a81d11 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -1445,7 +1445,7 @@ static int lcl_StartDocW( HDC hDC, DOCINFOW* pInfo, 
WinSalPrinter* pPrt )
 bool WinSalPrinter::StartJob( const OUString* pFileName,
const OUString& rJobName,
const OUString&,
-   sal_uLong nCopies,
+   sal_uInt32 nCopies,
bool bCollate,
bool /*bDirect*/,
ImplJobSetup* pSetupData )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-01-21 Thread Tor Lillqvist
 vcl/inc/win/salgdi.h  |   12 
 vcl/win/gdi/salfont.cxx   |   40 +
 vcl/win/gdi/salgdi.cxx|5 
 vcl/win/gdi/winlayout.cxx |  944 --
 vcl/win/gdi/winlayout.hxx |   45 ++
 5 files changed, 1020 insertions(+), 26 deletions(-)

New commits:
commit 4622689fad7ddff72cd08da9611ccfacdb0aa7bd
Author: Tor Lillqvist 
Date:   Thu Jan 7 15:05:58 2016 +0200

tdf#96420: Re-introduce SimpleWinLayout

Should fix lots of the problems with glyph layout. The UniscribeLayout
class turned out to be much less correct that one might have hoped.

Use OpenGL glyph caching also for SimpleWinLayout to avoid performance
decrease.

Change-Id: Ia0cf2f5c1ff21b9347fa7662ded69abc347e77b7
Reviewed-on: https://gerrit.libreoffice.org/21656
Reviewed-by: Tor Lillqvist 
Tested-by: Tor Lillqvist 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index d90e429..a889b45 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -186,6 +186,7 @@ class WinSalGraphics : public SalGraphics
 friend class ScopedFont;
 friend class OpenGLCompatibleDC;
 friend class WinLayout;
+friend class SimpleWinLayout;
 friend class UniscribeLayout;
 
 protected:
@@ -213,6 +214,9 @@ private:
 RGNDATA*mpClipRgnData;  // ClipRegion-Data
 RGNDATA*mpStdClipRgnData;   // Cache 
Standard-ClipRegion-Data
 ImplFontAttrCache*  mpFontAttrCache;// Cache font attributes from 
files in so/share/fonts
+boolmbFontKernInit; // FALSE: FontKerns must be 
queried
+KERNINGPAIR*mpFontKernPairs;// Kerning Pairs of the 
current Font
+sal_uIntPtr mnFontKernPairCount;// Number of Kerning Pairs of 
the current Font
 int mnPenWidth; // Linienbreite
 
 public:
@@ -329,6 +333,12 @@ protected:
const SalBitmap* pAlphaBitmap) override;
 virtual bool   drawAlphaRect( long nX, long nY, long nWidth, long 
nHeight, sal_uInt8 nTransparency ) override;
 
+private:
+// local helpers
+
+// get kernign pairs of the current font
+sal_uLong   GetKernPairs();
+
 public:
 // public SalGraphics methods, the interface to the independent vcl part
 
@@ -448,7 +458,7 @@ voidImplGetLogFontFromFontSelect( HDC, const 
FontSelectPattern*,
 #define MAX_64KSALPOINTSsal_uInt16)0x)-8)/sizeof(POINTS))
 
 // #102411# Win's GCP mishandles kerning => we need to do it ourselves
-// kerning pairs is sorted by
+// SalGraphicsData::mpFontKernPairs is sorted by
 inline bool ImplCmpKernData( const KERNINGPAIR& a, const KERNINGPAIR& b )
 {
 if( a.wFirst < b.wFirst )
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 1bd1423..e7dd594 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -1470,6 +1470,17 @@ sal_uInt16 WinSalGraphics::SetFont( FontSelectPattern* 
pFont, int nFallbackLevel
 if( mpWinFontData[ nFallbackLevel ] )
 mpWinFontData[ nFallbackLevel ]->UpdateFromHDC( getHDC() );
 
+if( !nFallbackLevel )
+{
+mbFontKernInit = TRUE;
+if ( mpFontKernPairs )
+{
+delete[] mpFontKernPairs;
+mpFontKernPairs = NULL;
+}
+mnFontKernPairCount = 0;
+}
+
 // some printers have higher internal resolution, so their
 // text output would be different from what we calculated
 // => suggest DrawTextArray to workaround this problem
@@ -1556,6 +1567,35 @@ void WinSalGraphics::GetFontMetric( 
ImplFontMetricDataPtr& rxFontMetric, int nFa
 rxFontMetric->SetMinKashida( GetMinKashidaWidth() );
 }
 
+sal_uLong WinSalGraphics::GetKernPairs()
+{
+if ( mbFontKernInit )
+{
+if( mpFontKernPairs )
+{
+delete[] mpFontKernPairs;
+mpFontKernPairs = NULL;
+}
+mnFontKernPairCount = 0;
+
+KERNINGPAIR* pPairs = NULL;
+int nCount = ::GetKerningPairsW( getHDC(), 0, NULL );
+if( nCount )
+{
+pPairs = new KERNINGPAIR[ nCount+1 ];
+mpFontKernPairs = pPairs;
+mnFontKernPairCount = nCount;
+::GetKerningPairsW( getHDC(), nCount, pPairs );
+}
+
+mbFontKernInit = FALSE;
+
+std::sort( mpFontKernPairs, mpFontKernPairs + mnFontKernPairCount, 
ImplCmpKernData );
+}
+
+return mnFontKernPairCount;
+}
+
 const FontCharMapPtr WinSalGraphics::GetFontCharMap() const
 {
 if( !mpWinFontData[0] )
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 36ff322..6783cc1 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -607,6 +607,9 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, 
bool bScreen, HWND hW
 mhDefPal(0),
 mpStdClipRgnData(NULL),
 mpFontAttrCache(NULL),
+mpFontKernPairs(NULL),
+

[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-01-09 Thread Chris Sherlock
 vcl/inc/win/salgdi.h  |   10 
 vcl/win/gdi/salfont.cxx   |   52 +++---
 vcl/win/gdi/winlayout.cxx |   14 ++--
 vcl/win/gdi/winlayout.hxx |8 +++
 4 files changed, 42 insertions(+), 42 deletions(-)

New commits:
commit d538eb2bfa45e07ddb1303330c1e0e80c7c0ead0
Author: Chris Sherlock 
Date:   Sun Jan 10 09:54:07 2016 +1100

vcl: (Windows only) Changed ImplWinFontData name to WinFontFace

The base class name for WinFontFace is PhysicalFontFace, which gives
the actual font installed on Windows (this is eventually mapped and
realized into a LogicalFontInstance). However, PhysicalFontFace is
not just a data structure, it also holds the function CreateFontInstance
which must be implemented by the subclasses for each platform to allow
fonts to be used in LibreOffice.

Therefore, to keep the naming consistent I am following the lead of the
base class and renaming ImplWinFontData to WinFontFace (and removing
the "Impl" business, as this is not necessary).

Change-Id: I4debb3af3ab5067b7e12e3659f2c71aba91e848c
Reviewed-on: https://gerrit.libreoffice.org/21298
Tested-by: Jenkins 
Reviewed-by: Chris Sherlock 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 29f519a..00931f0 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -71,13 +71,13 @@ private:
 #endif
 
 // win32 specific physically available font face
-class ImplWinFontData : public PhysicalFontFace
+class WinFontFace : public PhysicalFontFace
 {
 public:
-explicitImplWinFontData( const ImplFontAttributes&,
+explicitWinFontFace( const ImplFontAttributes&,
 int nFontHeight, BYTE eWinCharSet,
 BYTE nPitchAndFamily  );
-virtual ~ImplWinFontData();
+virtual ~WinFontFace();
 
 virtual PhysicalFontFace* Clone() const override;
 virtual LogicalFontInstance* CreateFontInstance( FontSelectPattern& ) 
const override;
@@ -199,7 +199,7 @@ private:
 HWNDmhWnd;  // Window-Handle, when 
Window-Graphics
 
 HFONT   mhFonts[ MAX_FALLBACK ];// Font + Fallbacks
-const ImplWinFontData*  mpWinFontData[ MAX_FALLBACK ];  // pointer to the 
most recent font face
+const WinFontFace*  mpWinFontData[ MAX_FALLBACK ];  // pointer to the most 
recent font face
 WinFontInstance*   mpWinFontEntry[ MAX_FALLBACK ]; // pointer to the 
most recent font instance
 float   mfFontScale[ MAX_FALLBACK ];// allows 
metrics emulation of huge font sizes
 float   mfCurrentFontScale;
@@ -458,7 +458,7 @@ inline bool ImplCmpKernData( const KERNINGPAIR& a, const 
KERNINGPAIR& b )
 }
 
 // called extremely often from just one spot => inline
-inline bool ImplWinFontData::HasChar( sal_uInt32 cChar ) const
+inline bool WinFontFace::HasChar( sal_uInt32 cChar ) const
 {
 if( mpUnicodeMap->HasChar( cChar ) )
 return true;
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 76a9da5..9c917f3 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -444,7 +444,7 @@ void ImplGetLogFontFromFontSelect( HDC, const 
FontSelectPattern*,
 // does a font face hold the given missing characters?
 bool WinGlyphFallbackSubstititution::HasMissingChars( PhysicalFontFace* pFace, 
const OUString& rMissingChars ) const
 {
-ImplWinFontData* pWinFont = static_cast< ImplWinFontData* >(pFace);
+WinFontFace* pWinFont = static_cast< WinFontFace* >(pFace);
 FontCharMapPtr pCharMap = pWinFont->GetFontCharMap();
 if( !pCharMap )
 {
@@ -844,7 +844,7 @@ static ImplFontAttributes WinFont2DevFontAttributes( const 
ENUMLOGFONTEXW& rEnum
 }
 
 
-static ImplWinFontData* ImplLogMetricToDevFontDataW( const ENUMLOGFONTEXW* 
pLogFont,
+static WinFontFace* ImplLogMetricToDevFontDataW( const ENUMLOGFONTEXW* 
pLogFont,
  const NEWTEXTMETRICW* pMetric,
  DWORD nFontType )
 {
@@ -852,7 +852,7 @@ static ImplWinFontData* ImplLogMetricToDevFontDataW( const 
ENUMLOGFONTEXW* pLogF
 if ( nFontType & RASTER_FONTTYPE )
 nHeight = pMetric->tmHeight - pMetric->tmInternalLeading;
 
-ImplWinFontData* pData = new ImplWinFontData(
+WinFontFace* pData = new WinFontFace(
 WinFont2DevFontAttributes(*pLogFont, *pMetric, nFontType),
 nHeight,
 pLogFont->elfLogFont.lfCharSet,
@@ -994,7 +994,7 @@ const void * GrFontData::getTable(unsigned int name, size_t 
*len) const
 }
 #endif
 
-ImplWinFontData::ImplWinFontData( const ImplFontAttributes& rDFS,
+WinFontFace::WinFontFace( const ImplFontAttributes& rDFS,
 int nHeight, BYTE eWinCharSet, BYTE nPitchAndFamily )
 :   PhysicalFontFace( rDFS 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-01-09 Thread Chris Sherlock
 vcl/inc/win/salgdi.h  |4 ++--
 vcl/win/gdi/salfont.cxx   |2 +-
 vcl/win/gdi/winlayout.cxx |   32 
 vcl/win/gdi/winlayout.hxx |   14 +++---
 4 files changed, 26 insertions(+), 26 deletions(-)

New commits:
commit 15dae2693e807014d20415085673ad3af7c79f8f
Author: Chris Sherlock 
Date:   Sun Jan 10 09:50:50 2016 +1100

vcl: (Windows only) Changed ImplWinFontEntry name to WinFontInstance

The base class is no longer called ImplFontEntry, but is now
LogicalFontInstance. I want to bring the names in the class hierachy
into line for consistency, so this change is necessary.

Change-Id: Ie24197c140bf152f78ed7faf46b7509b82bcbdee
Reviewed-on: https://gerrit.libreoffice.org/21297
Tested-by: Jenkins 
Reviewed-by: Chris Sherlock 

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index f1c8c3a..29f519a 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -40,7 +40,7 @@
 #endif
 
 class FontSelectPattern;
-class ImplWinFontEntry;
+class WinFontInstance;
 class ImplFontAttrCache;
 class OpenGLTexture;
 class PhysicalFontCollection;
@@ -200,7 +200,7 @@ private:
 
 HFONT   mhFonts[ MAX_FALLBACK ];// Font + Fallbacks
 const ImplWinFontData*  mpWinFontData[ MAX_FALLBACK ];  // pointer to the 
most recent font face
-ImplWinFontEntry*   mpWinFontEntry[ MAX_FALLBACK ]; // pointer to the 
most recent font instance
+WinFontInstance*   mpWinFontEntry[ MAX_FALLBACK ]; // pointer to the 
most recent font instance
 float   mfFontScale[ MAX_FALLBACK ];// allows 
metrics emulation of huge font sizes
 float   mfCurrentFontScale;
 HRGNmhRegion;   // vcl::Region Handle
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index bf32700..76a9da5 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -1437,7 +1437,7 @@ sal_uInt16 WinSalGraphics::SetFont( FontSelectPattern* 
pFont, int nFallbackLevel
 }
 
 DBG_ASSERT( pFont->mpFontData, "WinSalGraphics mpFontData==NULL");
-mpWinFontEntry[ nFallbackLevel ] = reinterpret_cast( 
pFont->mpFontInstance );
+mpWinFontEntry[ nFallbackLevel ] = reinterpret_cast( 
pFont->mpFontInstance );
 mpWinFontData[ nFallbackLevel ] = static_cast( 
pFont->mpFontData );
 
 HFONT hOldFont = 0;
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 828634d..5810c34 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -86,11 +86,11 @@ struct OpenGLGlyphCacheChunk
 };
 
 // win32 specific physical font instance
-class ImplWinFontEntry : public LogicalFontInstance
+class WinFontInstance : public LogicalFontInstance
 {
 public:
-explicitImplWinFontEntry( FontSelectPattern& );
-virtual ~ImplWinFontEntry();
+explicitWinFontInstance( FontSelectPattern& );
+virtual ~WinFontInstance();
 voidsetupGLyphy(HDC hDC);
 
 private:
@@ -122,7 +122,7 @@ private:
 boolmbGLyphySetupCalled;
 };
 
-GLuint ImplWinFontEntry::mnGLyphyProgram = 0;
+GLuint WinFontInstance::mnGLyphyProgram = 0;
 
 #ifdef SAL_LOG_INFO
 
@@ -192,7 +192,7 @@ inline std::basic_ostream & operator <<(
 return stream << "}";
 }
 
-bool ImplWinFontEntry::GlyphIsCached(int nGlyphIndex) const
+bool WinFontInstance::GlyphIsCached(int nGlyphIndex) const
 {
 if (nGlyphIndex == DROPPED_OUTGLYPH)
 return true;
@@ -205,7 +205,7 @@ bool ImplWinFontEntry::GlyphIsCached(int nGlyphIndex) const
 return false;
 }
 
-bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout& 
rLayout, SalGraphics& rGraphics)
+bool WinFontInstance::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout& 
rLayout, SalGraphics& rGraphics)
 {
 const int DEFAULT_CHUNK_SIZE = 20;
 
@@ -443,7 +443,7 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, 
const WinLayout& rLayou
 return true;
 }
 
-const OpenGLGlyphCacheChunk& ImplWinFontEntry::GetCachedGlyphChunkFor(int 
nGlyphIndex) const
+const OpenGLGlyphCacheChunk& WinFontInstance::GetCachedGlyphChunkFor(int 
nGlyphIndex) const
 {
 auto i = maOpenGLGlyphCache.cbegin();
 while (i != maOpenGLGlyphCache.cend() && nGlyphIndex >= i->mnFirstGlyph + 
i->mnGlyphCount)
@@ -453,7 +453,7 @@ const OpenGLGlyphCacheChunk& 
ImplWinFontEntry::GetCachedGlyphChunkFor(int nGlyph
 return *i;
 }
 
-void ImplWinFontEntry::setupGLyphy(HDC hDC)
+void WinFontInstance::setupGLyphy(HDC hDC)
 {
 if (mbGLyphySetupCalled)
 return;
@@ -508,7 +508,7 @@ void ImplWinFontEntry::setupGLyphy(HDC hDC)
 mpGLyphyFont = demo_font_create(hNewDC, mpGLyphyAtlas);
 }
 
-WinLayout::WinLayout(HDC hDC, const ImplWinFontData& rWFD, ImplWinFontEntry& 
rWFE, 

[Libreoffice-commits] core.git: vcl/inc vcl/win

2016-01-06 Thread Tor Lillqvist
 vcl/inc/win/salgdi.h|4 
 vcl/win/gdi/salfont.cxx |3 ---
 2 files changed, 7 deletions(-)

New commits:
commit 3576a87d72dd138d3bb2ce6bbba8df05ca983289
Author: Tor Lillqvist 
Date:   Wed Jan 6 10:59:38 2016 +0200

Bin some unused functions and fields

Change-Id: I679bae7734c655afe956845980e885b6b68002cd

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index c58c17a..26b6c2f 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -89,11 +89,8 @@ public:
 
 BYTEGetCharSet() const  { return meWinCharSet; 
}
 BYTEGetPitchAndFamily() const   { return 
mnPitchAndFamily; }
-boolSupportsKorean() const  { return 
mbHasKoreanRange; }
 boolSupportsCJK() const { return 
mbHasCJKSupport; }
 boolSupportsArabic() const  { return 
mbHasArabicSupport; }
-boolAliasSymbolsHigh() const{ return 
mbAliasSymbolsHigh; }
-boolAliasSymbolsLow() const { return 
mbAliasSymbolsLow; }
 #if ENABLE_GRAPHITE
 boolSupportsGraphite() const{ return 
mbHasGraphiteSupport; }
 const gr_face*  GraphiteFace() const;
@@ -112,7 +109,6 @@ private:
 sal_IntPtr  mnId;
 
 // some members that are initalized lazily when the font gets selected 
into a HDC
-mutable boolmbHasKoreanRange;
 mutable boolmbHasCJKSupport;
 #if ENABLE_GRAPHITE
 mutable GrFontData* mpGraphiteData;
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 26ade82..e2b4c2e 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -998,7 +998,6 @@ ImplWinFontData::ImplWinFontData( const ImplFontAttributes& 
rDFS,
 int nHeight, BYTE eWinCharSet, BYTE nPitchAndFamily )
 :   PhysicalFontFace( rDFS ),
 mnId( 0 ),
-mbHasKoreanRange( false ),
 mbHasCJKSupport( false ),
 #if ENABLE_GRAPHITE
 mpGraphiteData(NULL),
@@ -1244,8 +1243,6 @@ void ImplWinFontData::GetFontCapabilities( HDC hDC ) const
 sal_uInt32 ulUnicodeRange2 = GetUInt( pTable + 46 );
 
 mbHasCJKSupport = (ulUnicodeRange2 & 0x2DF0);
-mbHasKoreanRange= (ulUnicodeRange1 & 0x1000)
-| (ulUnicodeRange2 & 0x0110);
 mbHasArabicSupport = (ulUnicodeRange1 & 0x2000);
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


  1   2   >