summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/osx/salframeview.h1
-rw-r--r--vcl/inc/quartz/salgdi.h3
-rw-r--r--vcl/inc/skia/gdiimpl.hxx3
-rw-r--r--vcl/inc/skia/osx/gdiimpl.hxx1
-rw-r--r--vcl/osx/salframe.cxx2
-rw-r--r--vcl/osx/salframeview.mm21
-rw-r--r--vcl/osx/salgdiutils.cxx27
-rw-r--r--vcl/quartz/salgdi.cxx5
-rw-r--r--vcl/skia/gdiimpl.cxx13
-rw-r--r--vcl/skia/osx/gdiimpl.cxx2
10 files changed, 74 insertions, 4 deletions
diff --git a/vcl/inc/osx/salframeview.h b/vcl/inc/osx/salframeview.h
index 6242f3d4146a..1282eb10cbee 100644
--- a/vcl/inc/osx/salframeview.h
+++ b/vcl/inc/osx/salframeview.h
@@ -45,6 +45,7 @@ enum class SalEvent;
-(void)windowDidMiniaturize: (NSNotification*)pNotification;
-(void)windowDidDeminiaturize: (NSNotification*)pNotification;
-(BOOL)windowShouldClose: (NSNotification*)pNotification;
+-(void)windowDidChangeBackingProperties:(NSNotification *)pNotification;
//-(void)willEncodeRestorableState:(NSCoder*)pCoderState;
//-(void)didDecodeRestorableState:(NSCoder*)pCoderState;
//-(void)windowWillEnterVersionBrowser:(NSNotification*)pNotification;
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 8886d19700a7..1261beee7d74 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -129,6 +129,7 @@ private:
namespace sal::aqua
{
float getWindowScaling();
+void resetWindowScaling();
}
struct AquaSharedAttributes
@@ -287,6 +288,7 @@ public:
virtual void drawTextLayout(const GenericSalLayout& layout, bool bTextRenderModeForResolutionIndependentLayout) = 0;
virtual void Flush() {}
virtual void Flush( const tools::Rectangle& ) {}
+ virtual void WindowBackingPropertiesChanged() {};
protected:
AquaGraphicsBackendBase(AquaSharedAttributes& rShared, SalGraphicsImpl * impl)
: mrShared( rShared ), mpImpl(impl)
@@ -482,6 +484,7 @@ public:
void Flush();
void Flush( const tools::Rectangle& );
+ void WindowBackingPropertiesChanged();
void UnsetState();
// InvalidateContext does an UnsetState and sets mrContext to 0
diff --git a/vcl/inc/skia/gdiimpl.hxx b/vcl/inc/skia/gdiimpl.hxx
index c4a445aa66c1..d86f89ee6f4e 100644
--- a/vcl/inc/skia/gdiimpl.hxx
+++ b/vcl/inc/skia/gdiimpl.hxx
@@ -340,6 +340,8 @@ protected:
return stream;
}
+ void windowBackingPropertiesChanged();
+
SalGraphics& mParent;
/// Pointer to the SalFrame or SalVirtualDevice
SalGeometryProvider* mProvider;
@@ -371,6 +373,7 @@ protected:
LastPolyPolygonInfo mLastPolyPolygonInfo;
inline static int pendingOperationsToFlush = 0;
int mScaling; // The scale factor for HiDPI screens.
+ bool mInWindowBackingPropertiesChanged;
};
inline SkPaint SkiaSalGraphicsImpl::makePaintInternal() const
diff --git a/vcl/inc/skia/osx/gdiimpl.hxx b/vcl/inc/skia/osx/gdiimpl.hxx
index 71baf24625fc..b90b576a873f 100644
--- a/vcl/inc/skia/osx/gdiimpl.hxx
+++ b/vcl/inc/skia/osx/gdiimpl.hxx
@@ -43,6 +43,7 @@ public:
virtual void Flush() override;
virtual void Flush(const tools::Rectangle&) override;
+ virtual void WindowBackingPropertiesChanged() override;
private:
virtual int getWindowScaling() const override;
diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index 90dd38704bcd..02a3879648db 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -287,6 +287,8 @@ void AquaSalFrame::screenParametersChanged()
{
OSX_SALDATA_RUNINMAIN( screenParametersChanged() )
+ sal::aqua::resetWindowScaling();
+
UpdateFrameGeometry();
if( mpGraphics )
diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm
index b36cd23721ea..9eded8a40fe8 100644
--- a/vcl/osx/salframeview.mm
+++ b/vcl/osx/salframeview.mm
@@ -500,6 +500,27 @@ static AquaSalFrame* getMouseContainerFrame()
(void)pNotification;
}
+-(void)windowDidChangeBackingProperties:(NSNotification *)pNotification
+{
+ (void)pNotification;
+#if HAVE_FEATURE_SKIA
+ SolarMutexGuard aGuard;
+
+ sal::aqua::resetWindowScaling();
+
+ if( mpFrame && AquaSalFrame::isAlive( mpFrame ) )
+ {
+ // tdf#147342 Notify Skia that the window's backing properties changed
+ if ( SkiaHelper::isVCLSkiaEnabled() )
+ {
+ AquaSalGraphics* pGraphics = mpFrame->mpGraphics;
+ if ( pGraphics )
+ pGraphics->WindowBackingPropertiesChanged();
+ }
+ }
+#endif
+}
+
-(void)dockMenuItemTriggered: (id)sender
{
(void)sender;
diff --git a/vcl/osx/salgdiutils.cxx b/vcl/osx/salgdiutils.cxx
index 603a8b612d42..d65897e25a83 100644
--- a/vcl/osx/salgdiutils.cxx
+++ b/vcl/osx/salgdiutils.cxx
@@ -35,6 +35,11 @@
#include <osx/salframe.h>
#include <osx/saldata.hxx>
+#if HAVE_FEATURE_SKIA
+#include <tools/sk_app/mac/WindowContextFactory_mac.h>
+#include <vcl/skia/SkiaHelper.hxx>
+#endif
+
// TODO: Scale will be set to 2.0f as default after implementation of full scaled display support . This will allow moving of
// windows between non retina and retina displays without blurry text and graphics. Static variables have to be removed thereafter.
@@ -50,15 +55,17 @@ namespace sal::aqua
{
float getWindowScaling()
{
+ // Related: tdf#147342 Any changes to this function must be copied to the
+ // sk_app::GetBackingScaleFactor() function in the following file:
+ // workdir/UnpackedTarball/skia/tools/sk_app/mac/WindowContextFactory_mac.h
if (!bWindowScaling)
{
NSArray *aScreens = [NSScreen screens];
if (aScreens != nullptr)
{
- int nScreens = [aScreens count];
- for (int i = 0; i < nScreens; i++)
+ for (NSScreen *aScreen : aScreens)
{
- float fScale = [[aScreens objectAtIndex:i] backingScaleFactor];
+ float fScale = [aScreen backingScaleFactor];
if (fScale > fWindowScale)
fWindowScale = fScale;
}
@@ -72,6 +79,20 @@ float getWindowScaling()
}
return fWindowScale;
}
+
+void resetWindowScaling()
+{
+ // Related: tdf#147342 Force recalculation of the window scaling but keep
+ // the previous window scaling as the minimum so that we don't lose the
+ // resolution in cached images if a HiDPI monitor is disconnected and
+ // then reconnected.
+#if HAVE_FEATURE_SKIA
+ if ( SkiaHelper::isVCLSkiaEnabled() )
+ sk_app::ResetBackingScaleFactor();
+#endif
+ bWindowScaling = false;
+ getWindowScaling();
+}
} // end aqua
void AquaSalGraphics::SetWindowGraphics( AquaSalFrame* pFrame )
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 571e44f23e71..78be62d02963 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -487,6 +487,11 @@ void AquaSalGraphics::Flush( const tools::Rectangle& rRect )
mpBackend->Flush( rRect );
}
+void AquaSalGraphics::WindowBackingPropertiesChanged()
+{
+ mpBackend->WindowBackingPropertiesChanged();
+}
+
#ifdef IOS
bool AquaSharedAttributes::checkContext()
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 15d901d93ff2..d0eb2ceaf51e 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -267,6 +267,7 @@ SkiaSalGraphicsImpl::SkiaSalGraphicsImpl(SalGraphics& rParent, SalGeometryProvid
, mXorMode(XorMode::None)
, mFlush(new SkiaFlushIdle(this))
, mScaling(1)
+ , mInWindowBackingPropertiesChanged(false)
{
}
@@ -485,7 +486,7 @@ void SkiaSalGraphicsImpl::checkSurface()
SAL_INFO("vcl.skia.trace",
"create(" << this << "): " << Size(mSurface->width(), mSurface->height()));
}
- else if (GetWidth() * mScaling != mSurface->width()
+ else if (mInWindowBackingPropertiesChanged || GetWidth() * mScaling != mSurface->width()
|| GetHeight() * mScaling != mSurface->height())
{
if (!avoidRecreateByResize())
@@ -2182,4 +2183,14 @@ void SkiaSalGraphicsImpl::dump(const char* file) const
SkiaHelper::dump(mSurface, file);
}
+void SkiaSalGraphicsImpl::windowBackingPropertiesChanged()
+{
+ if (mInWindowBackingPropertiesChanged || !isGPU())
+ return;
+
+ mInWindowBackingPropertiesChanged = true;
+ performFlush();
+ mInWindowBackingPropertiesChanged = false;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index 17a02fd441cf..e9c2e67fd1a4 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -95,6 +95,8 @@ void AquaSkiaSalGraphicsImpl::Flush() { performFlush(); }
void AquaSkiaSalGraphicsImpl::Flush(const tools::Rectangle&) { performFlush(); }
+void AquaSkiaSalGraphicsImpl::WindowBackingPropertiesChanged() { windowBackingPropertiesChanged(); }
+
void AquaSkiaSalGraphicsImpl::flushSurfaceToWindowContext()
{
if (!isGPU())