calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / external / skia / tdf147342.patch.0
blob72ec8adf9a46b92656b02d4588a00a9f33c2e1f2
1 --- tools/sk_app/mac/WindowContextFactory_mac.h 2022-02-16 06:03:39.000000000 -0500
2 +++ tools/sk_app/mac/WindowContextFactory_mac.h 2023-01-25 08:09:00.000000000 -0500
3 @@ -19,15 +19,8 @@
4  
5  struct DisplayParams;
6  
7 -static inline CGFloat GetBackingScaleFactor(NSView* view) {
8 -    #ifdef SK_BUILD_FOR_IOS
9 -    UIScreen* screen = view.window.screen ?: [UIScreen mainScreen];
10 -    return screen.nativeScale;
11 -    #else
12 -    NSScreen* screen = view.window.screen ?: [NSScreen mainScreen];
13 -    return screen.backingScaleFactor;
14 -    #endif
16 +SK_API CGFloat GetBackingScaleFactor(NSView* view);
17 +SK_API void ResetBackingScaleFactor();
19  namespace window_context_factory {
21 --- tools/sk_app/mac/MetalWindowContext_mac.mm  2021-11-25 10:39:27.000000000 -0500
22 +++ tools/sk_app/mac/MetalWindowContext_mac.mm  2023-01-25 08:20:32.000000000 -0500
23 @@ -87,6 +91,12 @@
24      fMetalLayer.drawableSize = backingSize;
25      fMetalLayer.contentsScale = backingScaleFactor;
27 +    // Related tdf#147342 Copy layer's colorspace to window's colorspace
28 +    // This method is now called when the window's backing properties have
29 +    // changed so copy any colorspace changes.
30 +    NSColorSpace* cs = fMainView.window.colorSpace;
31 +    fMetalLayer.colorspace = cs.CGColorSpace;
33      fWidth = backingSize.width;
34      fHeight = backingSize.height;
35  }
36 --- /dev/null   2023-01-25 09:20:55.000000000 -0500
37 +++ tools/sk_app/mac/WindowContextFactory_mac.mm        2023-01-25 09:21:22.000000000 -0500
38 @@ -0,0 +1,57 @@
39 +/*
40 + * Use of this source code is governed by a BSD-style license that can be
41 + * found in the LICENSE file.
42 + */
44 +#include "tools/sk_app/mac/WindowContextFactory_mac.h"
46 +namespace sk_app {
48 +static bool  bWindowScaling = false;
49 +static float fWindowScale = 1.0f;
51 +CGFloat GetBackingScaleFactor(NSView* view) {
52 +    #ifdef SK_BUILD_FOR_IOS
53 +    UIScreen* screen = view.window.screen ?: [UIScreen mainScreen];
54 +    return screen.nativeScale;
55 +    #else
56 +    // Related: tdf#147342 This should always be an exact copy of the
57 +    // sal::aqua::getWindowScaling() function in the following file:
58 +    // vcl/osx/salgdiutils.cxx
59 +    (void)view;
61 +    if (!bWindowScaling)
62 +    {
63 +        NSArray *aScreens = [NSScreen screens];
64 +        if (aScreens)
65 +        {
66 +            for (NSScreen *aScreen : aScreens)
67 +            {
68 +                float fScale = [aScreen backingScaleFactor];
69 +                if (fScale > fWindowScale)
70 +                  fWindowScale = fScale;
71 +            }
72 +            bWindowScaling = true;
73 +        }
74 +        if( const char* env = getenv("SAL_FORCE_HIDPI_SCALING"))
75 +        {
76 +            fWindowScale = atof(env);
77 +            bWindowScaling = true;
78 +        }
79 +    }
80 +    return fWindowScale;
81 +    #endif
84 +void ResetBackingScaleFactor() {
85 +    #ifndef SK_BUILD_FOR_IOS
86 +    // Related: tdf#147342 Force recalculation of the window scaling but keep
87 +    // the previous window scaling as the minimum so that we don't lose the
88 +    // resolution in cached images if a HiDPI monitor is disconnected and
89 +    // then reconnected.
90 +    bWindowScaling = false;
91 +    GetBackingScaleFactor(nil);
92 +    #endif
95 +}  // namespace sk_app