SDL: cocoawindow: fix wrong content scale with ANGLE EGL context (61680)

From 6168085e455685b081196c0494d56c21decf9279 Mon Sep 17 00:00:00 2001
From: Jari Vetoniemi <[EMAIL REDACTED]>
Date: Wed, 4 Feb 2026 04:36:57 +0900
Subject: [PATCH] cocoawindow: fix wrong content scale with ANGLE EGL context

ANGLE expects that the surface layer content scale is updated
accordingly.

<https://github.com/google/angle/blob/b406401e42080c2f8fe479e6c5fa48dfae97c482/src/libANGLE/renderer/metal/SurfaceMtl.mm#L597-L636>

(cherry picked from commit ef41e0a0f0f9e676cc5dc71b352300cdead9bcad)
---
 src/video/cocoa/SDL_cocoawindow.m | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index cb891d2d6061b..1f7404d3104ba 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -1375,6 +1375,8 @@ - (void)windowDidResignKey:(NSNotification *)aNotification
 
 - (void)windowDidChangeBackingProperties:(NSNotification *)aNotification
 {
+    SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)_data.window->internal;
+    NSView *contentView = windata.sdlContentView;
     NSNumber *oldscale = [[aNotification userInfo] objectForKey:NSBackingPropertyOldScaleFactorKey];
 
     if (inFullscreenTransition) {
@@ -1382,6 +1384,9 @@ - (void)windowDidChangeBackingProperties:(NSNotification *)aNotification
     }
 
     if ([oldscale doubleValue] != [_data.nswindow backingScaleFactor]) {
+        // Update the content scale on the window layer
+        // This is required to keep content scale in sync with ANGLE
+        contentView.layer.contentsScale = [_data.nswindow backingScaleFactor];
         // Send a resize event when the backing scale factor changes.
         [self windowDidResize:aNotification];
     }