From 81fc7ded7869e86c1277b365b36b6a54ea8e12be Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 22 Nov 2023 11:46:36 -0800 Subject: [PATCH] Removed the window shape API for SDL 3.0 Fixes https://github.com/libsdl-org/SDL/issues/6654 Fixes https://github.com/libsdl-org/SDL/issues/6897 --- VisualC-GDK/SDL/SDL.vcxproj | 5 - VisualC-GDK/SDL/SDL.vcxproj.filters | 15 -- VisualC-WinRT/SDL-UWP.vcxproj | 3 - VisualC-WinRT/SDL-UWP.vcxproj.filters | 9 - VisualC/SDL/SDL.vcxproj | 5 - VisualC/SDL/SDL.vcxproj.filters | 15 -- Xcode/SDL/SDL.xcodeproj/project.pbxproj | 41 ---- docs/README-migration.md | 4 + include/SDL3/SDL.h | 1 - include/SDL3/SDL_shape.h | 150 ------------- src/dynapi/SDL_dynapi.sym | 4 - src/dynapi/SDL_dynapi_overrides.h | 4 - src/dynapi/SDL_dynapi_procs.h | 4 - src/video/SDL_shape.c | 274 ------------------------ src/video/SDL_shape_internals.h | 59 ----- src/video/SDL_sysvideo.h | 32 --- src/video/cocoa/SDL_cocoashape.h | 38 ---- src/video/cocoa/SDL_cocoashape.m | 115 ---------- src/video/cocoa/SDL_cocoavideo.m | 4 - src/video/cocoa/SDL_cocoawindow.m | 7 - src/video/windows/SDL_windowsevents.c | 1 - src/video/windows/SDL_windowsshape.c | 90 -------- src/video/windows/SDL_windowsshape.h | 38 ---- src/video/windows/SDL_windowsvideo.c | 4 - src/video/windows/SDL_windowswindow.c | 13 -- src/video/x11/SDL_x11shape.c | 98 --------- src/video/x11/SDL_x11shape.h | 37 ---- src/video/x11/SDL_x11video.c | 4 - src/video/x11/SDL_x11window.c | 11 - test/testshape.c | 30 +++ 30 files changed, 34 insertions(+), 1081 deletions(-) delete mode 100644 include/SDL3/SDL_shape.h delete mode 100644 src/video/SDL_shape.c delete mode 100644 src/video/SDL_shape_internals.h delete mode 100644 src/video/cocoa/SDL_cocoashape.h delete mode 100644 src/video/cocoa/SDL_cocoashape.m delete mode 100644 src/video/windows/SDL_windowsshape.c delete mode 100644 src/video/windows/SDL_windowsshape.h delete mode 100644 src/video/x11/SDL_x11shape.c delete mode 100644 src/video/x11/SDL_x11shape.h diff --git a/VisualC-GDK/SDL/SDL.vcxproj b/VisualC-GDK/SDL/SDL.vcxproj index 3d6451e2f..6cae7db95 100644 --- a/VisualC-GDK/SDL/SDL.vcxproj +++ b/VisualC-GDK/SDL/SDL.vcxproj @@ -342,7 +342,6 @@ - @@ -523,7 +522,6 @@ - @@ -538,7 +536,6 @@ - @@ -774,7 +771,6 @@ - @@ -790,7 +786,6 @@ - diff --git a/VisualC-GDK/SDL/SDL.vcxproj.filters b/VisualC-GDK/SDL/SDL.vcxproj.filters index 2396f04b6..5b5c77da1 100644 --- a/VisualC-GDK/SDL/SDL.vcxproj.filters +++ b/VisualC-GDK/SDL/SDL.vcxproj.filters @@ -339,9 +339,6 @@ API Headers - - API Headers - API Headers @@ -600,9 +597,6 @@ video - - video - video @@ -660,9 +654,6 @@ video\windows - - video\windows - video\windows @@ -1195,9 +1186,6 @@ video - - video - video @@ -1255,9 +1243,6 @@ video\windows - - video\windows - video\windows diff --git a/VisualC-WinRT/SDL-UWP.vcxproj b/VisualC-WinRT/SDL-UWP.vcxproj index 2fad76fd3..9c2d387d2 100644 --- a/VisualC-WinRT/SDL-UWP.vcxproj +++ b/VisualC-WinRT/SDL-UWP.vcxproj @@ -80,7 +80,6 @@ - @@ -180,7 +179,6 @@ - @@ -520,7 +518,6 @@ - diff --git a/VisualC-WinRT/SDL-UWP.vcxproj.filters b/VisualC-WinRT/SDL-UWP.vcxproj.filters index 747841ba1..586b0d2a5 100644 --- a/VisualC-WinRT/SDL-UWP.vcxproj.filters +++ b/VisualC-WinRT/SDL-UWP.vcxproj.filters @@ -138,9 +138,6 @@ Header Files - - Header Files - Header Files @@ -405,9 +402,6 @@ Source Files - - Source Files - Source Files @@ -807,9 +801,6 @@ Source Files - - Source Files - Source Files diff --git a/VisualC/SDL/SDL.vcxproj b/VisualC/SDL/SDL.vcxproj index 0dee2d500..528a3fba5 100644 --- a/VisualC/SDL/SDL.vcxproj +++ b/VisualC/SDL/SDL.vcxproj @@ -293,7 +293,6 @@ - @@ -451,7 +450,6 @@ - @@ -466,7 +464,6 @@ - @@ -650,7 +647,6 @@ - @@ -667,7 +663,6 @@ - diff --git a/VisualC/SDL/SDL.vcxproj.filters b/VisualC/SDL/SDL.vcxproj.filters index fbaadb802..8a79f83f0 100644 --- a/VisualC/SDL/SDL.vcxproj.filters +++ b/VisualC/SDL/SDL.vcxproj.filters @@ -333,9 +333,6 @@ API Headers - - API Headers - API Headers @@ -594,9 +591,6 @@ video - - video - video @@ -654,9 +648,6 @@ video\windows - - video\windows - video\windows @@ -1176,9 +1167,6 @@ video - - video - video @@ -1239,9 +1227,6 @@ video\windows - - video\windows - video\windows diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index 66ead99a1..6153aa020 100644 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -43,27 +43,6 @@ 00D0D0D810675E46004B05EF /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 007317C10858E15000B2BC32 /* Carbon.framework */; platformFilters = (macos, ); }; 557D0CFA254586CA003913E3 /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F37DC5F225350EBC0002E6F7 /* CoreHaptics.framework */; platformFilters = (ios, maccatalyst, macos, tvos, ); }; 557D0CFB254586D7003913E3 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A75FDABD23E28B6200529352 /* GameController.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; - 63125C002A790B12008EF011 /* SDL_pen.h in Headers */ = {isa = PBXBuildFile; fileRef = 63125BFF2A790B12008EF011 /* SDL_pen.h */; }; - 63125C012A790B12008EF011 /* SDL_pen.h in Headers */ = {isa = PBXBuildFile; fileRef = 63125BFF2A790B12008EF011 /* SDL_pen.h */; }; - 63125C022A790B12008EF011 /* SDL_pen.h in Headers */ = {isa = PBXBuildFile; fileRef = 63125BFF2A790B12008EF011 /* SDL_pen.h */; }; - 63125C0A2A790B69008EF011 /* SDL_pen.c in Sources */ = {isa = PBXBuildFile; fileRef = 63125C092A790B69008EF011 /* SDL_pen.c */; }; - 63125C0B2A790B69008EF011 /* SDL_pen.c in Sources */ = {isa = PBXBuildFile; fileRef = 63125C092A790B69008EF011 /* SDL_pen.c */; }; - 63125C0C2A790B69008EF011 /* SDL_pen.c in Sources */ = {isa = PBXBuildFile; fileRef = 63125C092A790B69008EF011 /* SDL_pen.c */; }; - 63125C0D2A790B69008EF011 /* SDL_pen.c in Sources */ = {isa = PBXBuildFile; fileRef = 63125C092A790B69008EF011 /* SDL_pen.c */; }; - 63125C0E2A790B69008EF011 /* SDL_pen.c in Sources */ = {isa = PBXBuildFile; fileRef = 63125C092A790B69008EF011 /* SDL_pen.c */; }; - 63125C0F2A790B69008EF011 /* SDL_pen.c in Sources */ = {isa = PBXBuildFile; fileRef = 63125C092A790B69008EF011 /* SDL_pen.c */; }; - 63125C102A790B69008EF011 /* SDL_pen.c in Sources */ = {isa = PBXBuildFile; fileRef = 63125C092A790B69008EF011 /* SDL_pen.c */; }; - 63125C112A790B69008EF011 /* SDL_pen.c in Sources */ = {isa = PBXBuildFile; fileRef = 63125C092A790B69008EF011 /* SDL_pen.c */; }; - 63125C122A790B69008EF011 /* SDL_pen.c in Sources */ = {isa = PBXBuildFile; fileRef = 63125C092A790B69008EF011 /* SDL_pen.c */; }; - 63125C142A790B9A008EF011 /* SDL_pen_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 63125C132A790B9A008EF011 /* SDL_pen_c.h */; }; - 63125C152A790B9A008EF011 /* SDL_pen_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 63125C132A790B9A008EF011 /* SDL_pen_c.h */; }; - 63125C162A790B9A008EF011 /* SDL_pen_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 63125C132A790B9A008EF011 /* SDL_pen_c.h */; }; - 63125C172A790B9A008EF011 /* SDL_pen_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 63125C132A790B9A008EF011 /* SDL_pen_c.h */; }; - 63125C182A790B9A008EF011 /* SDL_pen_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 63125C132A790B9A008EF011 /* SDL_pen_c.h */; }; - 63125C192A790B9A008EF011 /* SDL_pen_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 63125C132A790B9A008EF011 /* SDL_pen_c.h */; }; - 63125C1A2A790B9A008EF011 /* SDL_pen_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 63125C132A790B9A008EF011 /* SDL_pen_c.h */; }; - 63125C1B2A790B9A008EF011 /* SDL_pen_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 63125C132A790B9A008EF011 /* SDL_pen_c.h */; }; - 63125C1C2A790B9A008EF011 /* SDL_pen_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 63125C132A790B9A008EF011 /* SDL_pen_c.h */; }; 5616CA4C252BB2A6005D5928 /* SDL_url.c in Sources */ = {isa = PBXBuildFile; fileRef = 5616CA49252BB2A5005D5928 /* SDL_url.c */; }; 5616CA4D252BB2A6005D5928 /* SDL_sysurl.h in Headers */ = {isa = PBXBuildFile; fileRef = 5616CA4A252BB2A6005D5928 /* SDL_sysurl.h */; }; 5616CA4E252BB2A6005D5928 /* SDL_sysurl.m in Sources */ = {isa = PBXBuildFile; fileRef = 5616CA4B252BB2A6005D5928 /* SDL_sysurl.m */; }; @@ -136,7 +115,6 @@ A7D8ABF723E2514100DCD162 /* SDL_nullvideo.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A60A23E2513D00DCD162 /* SDL_nullvideo.h */; }; A7D8ABFD23E2514100DCD162 /* SDL_nullevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A60B23E2513D00DCD162 /* SDL_nullevents_c.h */; }; A7D8AC0323E2514100DCD162 /* SDL_rect_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A60C23E2513D00DCD162 /* SDL_rect_c.h */; }; - A7D8AC0923E2514100DCD162 /* SDL_shape_internals.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A60D23E2513D00DCD162 /* SDL_shape_internals.h */; }; A7D8AC0F23E2514100DCD162 /* SDL_video.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A60E23E2513D00DCD162 /* SDL_video.c */; }; A7D8AC2D23E2514100DCD162 /* SDL_surface.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A61423E2513D00DCD162 /* SDL_surface.c */; }; A7D8AC3323E2514100DCD162 /* SDL_RLEaccel.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A61523E2513D00DCD162 /* SDL_RLEaccel.c */; }; @@ -154,7 +132,6 @@ A7D8ADF223E2514100DCD162 /* SDL_blit_A.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A66423E2513E00DCD162 /* SDL_blit_A.c */; }; A7D8AE7623E2514100DCD162 /* SDL_clipboard.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A67B23E2513E00DCD162 /* SDL_clipboard.c */; }; A7D8AE7C23E2514100DCD162 /* SDL_yuv.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A67C23E2513E00DCD162 /* SDL_yuv.c */; }; - A7D8AE8223E2514100DCD162 /* SDL_cocoashape.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A67E23E2513E00DCD162 /* SDL_cocoashape.h */; }; A7D8AE8823E2514100DCD162 /* SDL_cocoaopengl.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A67F23E2513E00DCD162 /* SDL_cocoaopengl.m */; }; A7D8AE8E23E2514100DCD162 /* SDL_cocoakeyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68023E2513E00DCD162 /* SDL_cocoakeyboard.h */; }; A7D8AE9423E2514100DCD162 /* SDL_cocoamodes.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A68123E2513E00DCD162 /* SDL_cocoamodes.m */; }; @@ -169,7 +146,6 @@ A7D8AED023E2514100DCD162 /* SDL_cocoamessagebox.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A68B23E2513E00DCD162 /* SDL_cocoamessagebox.m */; }; A7D8AED623E2514100DCD162 /* SDL_cocoakeyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A68C23E2513E00DCD162 /* SDL_cocoakeyboard.m */; }; A7D8AEDC23E2514100DCD162 /* SDL_cocoaopengl.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68D23E2513E00DCD162 /* SDL_cocoaopengl.h */; }; - A7D8AEE223E2514100DCD162 /* SDL_cocoashape.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A68E23E2513E00DCD162 /* SDL_cocoashape.m */; }; A7D8AEE823E2514100DCD162 /* SDL_cocoavulkan.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68F23E2513E00DCD162 /* SDL_cocoavulkan.h */; }; A7D8AEEE23E2514100DCD162 /* SDL_cocoaopengles.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A69023E2513E00DCD162 /* SDL_cocoaopengles.h */; }; A7D8AEF423E2514100DCD162 /* SDL_cocoamodes.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A69123E2513E00DCD162 /* SDL_cocoamodes.h */; }; @@ -212,7 +188,6 @@ A7D8B39823E2514200DCD162 /* SDL_blit_copy.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A76623E2513E00DCD162 /* SDL_blit_copy.h */; }; A7D8B39E23E2514200DCD162 /* SDL_RLEaccel_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A76723E2513E00DCD162 /* SDL_RLEaccel_c.h */; }; A7D8B3A423E2514200DCD162 /* SDL_fillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A76823E2513E00DCD162 /* SDL_fillrect.c */; }; - A7D8B3AA23E2514200DCD162 /* SDL_shape.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A76923E2513E00DCD162 /* SDL_shape.c */; }; A7D8B3B023E2514200DCD162 /* SDL_yuv_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A76A23E2513E00DCD162 /* SDL_yuv_c.h */; }; A7D8B3B623E2514200DCD162 /* SDL_blit.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A76B23E2513E00DCD162 /* SDL_blit.h */; }; A7D8B3BF23E2514200DCD162 /* yuv_rgb.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A76E23E2513E00DCD162 /* yuv_rgb.c */; }; @@ -466,7 +441,6 @@ F3F7D9212933074E00816151 /* SDL_log.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8B72933074A00816151 /* SDL_log.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3F7D9252933074E00816151 /* SDL_egl.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8B82933074A00816151 /* SDL_egl.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3F7D9292933074E00816151 /* SDL_atomic.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8B92933074A00816151 /* SDL_atomic.h */; settings = {ATTRIBUTES = (Public, ); }; }; - F3F7D92D2933074E00816151 /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8BA2933074A00816151 /* SDL_shape.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3F7D9312933074E00816151 /* SDL_surface.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8BB2933074A00816151 /* SDL_surface.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3F7D9352933074E00816151 /* SDL_error.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8BC2933074A00816151 /* SDL_error.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3F7D9392933074E00816151 /* SDL_opengles2_gl2ext.h in Headers */ = {isa = PBXBuildFile; fileRef = F3F7D8BD2933074A00816151 /* SDL_opengles2_gl2ext.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -632,7 +606,6 @@ A7D8A60A23E2513D00DCD162 /* SDL_nullvideo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullvideo.h; sourceTree = ""; }; A7D8A60B23E2513D00DCD162 /* SDL_nullevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_nullevents_c.h; sourceTree = ""; }; A7D8A60C23E2513D00DCD162 /* SDL_rect_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_rect_c.h; sourceTree = ""; }; - A7D8A60D23E2513D00DCD162 /* SDL_shape_internals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_shape_internals.h; sourceTree = ""; }; A7D8A60E23E2513D00DCD162 /* SDL_video.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_video.c; sourceTree = ""; }; A7D8A61423E2513D00DCD162 /* SDL_surface.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_surface.c; sourceTree = ""; }; A7D8A61523E2513D00DCD162 /* SDL_RLEaccel.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_RLEaccel.c; sourceTree = ""; }; @@ -676,7 +649,6 @@ A7D8A66423E2513E00DCD162 /* SDL_blit_A.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_blit_A.c; sourceTree = ""; }; A7D8A67B23E2513E00DCD162 /* SDL_clipboard.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboard.c; sourceTree = ""; }; A7D8A67C23E2513E00DCD162 /* SDL_yuv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv.c; sourceTree = ""; }; - A7D8A67E23E2513E00DCD162 /* SDL_cocoashape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoashape.h; sourceTree = ""; }; A7D8A67F23E2513E00DCD162 /* SDL_cocoaopengl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoaopengl.m; sourceTree = ""; }; A7D8A68023E2513E00DCD162 /* SDL_cocoakeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoakeyboard.h; sourceTree = ""; }; A7D8A68123E2513E00DCD162 /* SDL_cocoamodes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoamodes.m; sourceTree = ""; }; @@ -691,7 +663,6 @@ A7D8A68B23E2513E00DCD162 /* SDL_cocoamessagebox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoamessagebox.m; sourceTree = ""; }; A7D8A68C23E2513E00DCD162 /* SDL_cocoakeyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoakeyboard.m; sourceTree = ""; }; A7D8A68D23E2513E00DCD162 /* SDL_cocoaopengl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoaopengl.h; sourceTree = ""; }; - A7D8A68E23E2513E00DCD162 /* SDL_cocoashape.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoashape.m; sourceTree = ""; }; A7D8A68F23E2513E00DCD162 /* SDL_cocoavulkan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoavulkan.h; sourceTree = ""; }; A7D8A69023E2513E00DCD162 /* SDL_cocoaopengles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoaopengles.h; sourceTree = ""; }; A7D8A69123E2513E00DCD162 /* SDL_cocoamodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoamodes.h; sourceTree = ""; }; @@ -734,7 +705,6 @@ A7D8A76623E2513E00DCD162 /* SDL_blit_copy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_blit_copy.h; sourceTree = ""; }; A7D8A76723E2513E00DCD162 /* SDL_RLEaccel_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_RLEaccel_c.h; sourceTree = ""; }; A7D8A76823E2513E00DCD162 /* SDL_fillrect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_fillrect.c; sourceTree = ""; }; - A7D8A76923E2513E00DCD162 /* SDL_shape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_shape.c; sourceTree = ""; }; A7D8A76A23E2513E00DCD162 /* SDL_yuv_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_yuv_c.h; sourceTree = ""; }; A7D8A76B23E2513E00DCD162 /* SDL_blit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_blit.h; sourceTree = ""; }; A7D8A76E23E2513E00DCD162 /* yuv_rgb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = yuv_rgb.c; sourceTree = ""; }; @@ -980,7 +950,6 @@ F3F7D8B72933074A00816151 /* SDL_log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_log.h; path = SDL3/SDL_log.h; sourceTree = ""; }; F3F7D8B82933074A00816151 /* SDL_egl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_egl.h; path = SDL3/SDL_egl.h; sourceTree = ""; }; F3F7D8B92933074A00816151 /* SDL_atomic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_atomic.h; path = SDL3/SDL_atomic.h; sourceTree = ""; }; - F3F7D8BA2933074A00816151 /* SDL_shape.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_shape.h; path = SDL3/SDL_shape.h; sourceTree = ""; }; F3F7D8BB2933074A00816151 /* SDL_surface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_surface.h; path = SDL3/SDL_surface.h; sourceTree = ""; }; F3F7D8BC2933074A00816151 /* SDL_error.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_error.h; path = SDL3/SDL_error.h; sourceTree = ""; }; F3F7D8BD2933074A00816151 /* SDL_opengles2_gl2ext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_opengles2_gl2ext.h; path = SDL3/SDL_opengles2_gl2ext.h; sourceTree = ""; }; @@ -1133,7 +1102,6 @@ F3F7D8C82933074B00816151 /* SDL_rwops.h */, F3F7D8C12933074B00816151 /* SDL_scancode.h */, F3F7D8C22933074B00816151 /* SDL_sensor.h */, - F3F7D8BA2933074A00816151 /* SDL_shape.h */, F3F7D8AC2933074900816151 /* SDL_stdinc.h */, F3F7D8BB2933074A00816151 /* SDL_surface.h */, F3F7D8E82933074E00816151 /* SDL_system.h */, @@ -1468,8 +1436,6 @@ A7D8A63423E2513D00DCD162 /* SDL_rect.c */, A7D8A76723E2513E00DCD162 /* SDL_RLEaccel_c.h */, A7D8A61523E2513D00DCD162 /* SDL_RLEaccel.c */, - A7D8A60D23E2513D00DCD162 /* SDL_shape_internals.h */, - A7D8A76923E2513E00DCD162 /* SDL_shape.c */, A7D8A60323E2513D00DCD162 /* SDL_stretch.c */, F3DDCC4E2AFD42B500B0842B /* SDL_surface_pixel_impl.h */, A7D8A61423E2513D00DCD162 /* SDL_surface.c */, @@ -1574,8 +1540,6 @@ A7D8A67F23E2513E00DCD162 /* SDL_cocoaopengl.m */, A7D8A69023E2513E00DCD162 /* SDL_cocoaopengles.h */, A7D8A68223E2513E00DCD162 /* SDL_cocoaopengles.m */, - A7D8A67E23E2513E00DCD162 /* SDL_cocoashape.h */, - A7D8A68E23E2513E00DCD162 /* SDL_cocoashape.m */, A7D8A69323E2513E00DCD162 /* SDL_cocoavideo.h */, A7D8A68523E2513E00DCD162 /* SDL_cocoavideo.m */, A7D8A68F23E2513E00DCD162 /* SDL_cocoavulkan.h */, @@ -2190,7 +2154,6 @@ A7D8AF1E23E2514100DCD162 /* SDL_cocoamouse.h in Headers */, A7D8AEDC23E2514100DCD162 /* SDL_cocoaopengl.h in Headers */, A7D8AEEE23E2514100DCD162 /* SDL_cocoaopengles.h in Headers */, - A7D8AE8223E2514100DCD162 /* SDL_cocoashape.h in Headers */, A7D8AF0023E2514100DCD162 /* SDL_cocoavideo.h in Headers */, A7D8AEE823E2514100DCD162 /* SDL_cocoavulkan.h in Headers */, A7D8AEFA23E2514100DCD162 /* SDL_cocoawindow.h in Headers */, @@ -2299,8 +2262,6 @@ A7D8B98C23E2514400DCD162 /* SDL_shaders_metal_ios.h in Headers */, A7D8B99B23E2514400DCD162 /* SDL_shaders_metal_macos.h in Headers */, A7D8B9A123E2514400DCD162 /* SDL_shaders_metal_tvos.h in Headers */, - F3F7D92D2933074E00816151 /* SDL_shape.h in Headers */, - A7D8AC0923E2514100DCD162 /* SDL_shape_internals.h in Headers */, F3F7D8F52933074E00816151 /* SDL_stdinc.h in Headers */, A7D8BBC723E2561500DCD162 /* SDL_steamcontroller.h in Headers */, F3F7D9312933074E00816151 /* SDL_surface.h in Headers */, @@ -2536,7 +2497,6 @@ A7D8AE7623E2514100DCD162 /* SDL_clipboard.c in Sources */, A7D8AEC423E2514100DCD162 /* SDL_cocoaevents.m in Sources */, A7D8B86623E2514400DCD162 /* SDL_audiocvt.c in Sources */, - A7D8B3AA23E2514200DCD162 /* SDL_shape.c in Sources */, A7D8B9F523E2514400DCD162 /* SDL_rotate.c in Sources */, F3DDCC5E2AFD42B600B0842B /* SDL_video_capture_v4l2.c in Sources */, A7D8BBE323E2574800DCD162 /* SDL_uikitvideo.m in Sources */, @@ -2606,7 +2566,6 @@ A7D8AED023E2514100DCD162 /* SDL_cocoamessagebox.m in Sources */, F376F6552559B4E300CFC0BC /* SDL_hidapi.c in Sources */, A7D8BA2B23E2514400DCD162 /* SDL_blendfillrect.c in Sources */, - A7D8AEE223E2514100DCD162 /* SDL_cocoashape.m in Sources */, A7D8BBD323E2574800DCD162 /* SDL_uikitappdelegate.m in Sources */, A7D8AEB823E2514100DCD162 /* SDL_cocoamouse.m in Sources */, F32DDAD12AB795A30041EAA5 /* SDL_audioqueue.c in Sources */, diff --git a/docs/README-migration.md b/docs/README-migration.md index 0601988fc..ff1e8f976 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -1084,6 +1084,10 @@ The following functions have been removed: * SDL_SensorGetDeviceType() - replaced with SDL_GetSensorInstanceType() * SDL_UnlockSensors() +## SDL_shape.h + +This header has been removed. You can create a window with the SDL_WINDOW_TRANSPARENT flag and then render using the alpha channel to achieve a similar effect. You can see an example of this in test/testshape.c + ## SDL_stdinc.h The standard C headers like stdio.h and stdlib.h are no longer included, you should include them directly in your project if you use non-SDL C runtime functions. diff --git a/include/SDL3/SDL.h b/include/SDL3/SDL.h index 6db0e69d4..422c6cc4a 100644 --- a/include/SDL3/SDL.h +++ b/include/SDL3/SDL.h @@ -68,7 +68,6 @@ #include #include #include -#include #include #include #include diff --git a/include/SDL3/SDL_shape.h b/include/SDL3/SDL_shape.h deleted file mode 100644 index 92d7db7a5..000000000 --- a/include/SDL3/SDL_shape.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SDL_shape_h_ -#define SDL_shape_h_ - -#include -#include -#include -#include -#include - -#include -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** \file SDL_shape.h - * - * Header file for the shaped window API. - */ - -#define SDL_NONSHAPEABLE_WINDOW -1 -#define SDL_INVALID_SHAPE_ARGUMENT -2 -#define SDL_WINDOW_LACKS_SHAPE -3 - -/** - * Create a window that can be shaped with the specified dimensions and flags. - * - * \param title The title of the window, in UTF-8 encoding. - * \param w The width of the window. - * \param h The height of the window. - * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with - * any of the following: ::SDL_WINDOW_OPENGL, - * ::SDL_WINDOW_MOUSE_GRABBED, ::SDL_WINDOW_HIDDEN, - * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, - * ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_BORDERLESS is always set, - * and ::SDL_WINDOW_FULLSCREEN is always unset. - * \returns the window created, or NULL if window creation failed. - * - * \since This function is available since SDL 3.0.0. - * - * \sa SDL_DestroyWindow - */ -extern DECLSPEC SDL_Window *SDLCALL SDL_CreateShapedWindow(const char *title, int w, int h, Uint32 flags); - -/** - * Return whether the given window is a shaped window. - * - * \param window The window to query for being shaped. - * \returns SDL_TRUE if the window is a window that can be shaped, SDL_FALSE - * if the window is unshaped or NULL. - * - * \since This function is available since SDL 3.0.0. - * - * \sa SDL_CreateShapedWindow - */ -extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); - -/** An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ -typedef enum { - /** The default mode, a binarized alpha cutoff of 1. */ - ShapeModeDefault, - /** A binarized alpha cutoff with a given integer value. */ - ShapeModeBinarizeAlpha, - /** A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ - ShapeModeReverseBinarizeAlpha, - /** A color key is applied. */ - ShapeModeColorKey -} WindowShapeMode; - -#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) - -/** A union containing parameters for shaped windows. */ -typedef union { - /** A cutoff alpha value for binarization of the window shape's alpha channel. */ - Uint8 binarizationCutoff; - SDL_Color colorKey; -} SDL_WindowShapeParams; - -/** A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ -typedef struct SDL_WindowShapeMode { - /** The mode of these window-shape parameters. */ - WindowShapeMode mode; - /** Window-shape parameters. */ - SDL_WindowShapeParams parameters; -} SDL_WindowShapeMode; - -/** - * Set the shape and parameters of a shaped window. - * - * \param window The shaped window whose parameters should be set. - * \param shape A surface encoding the desired shape for the window. - * \param shape_mode The parameters to set for the shaped window. - * \returns 0 on success, SDL_INVALID_SHAPE_ARGUMENT on an invalid shape - * argument, or SDL_NONSHAPEABLE_WINDOW if the SDL_Window given does - * not reference a valid shaped window. - * - * \since This function is available since SDL 3.0.0. - * - * \sa SDL_WindowShapeMode - * \sa SDL_GetShapedWindowMode - */ -extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); - -/** - * Get the shape parameters of a shaped window. - * - * \param window The shaped window whose parameters should be retrieved. - * \param shape_mode An empty shape-mode structure to fill, or NULL to check - * whether the window has a shape. - * \returns 0 if the window has a shape and, provided shape_mode was not NULL, - * shape_mode has been filled with the mode data, - * SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped - * window, or SDL_WINDOW_LACKS_SHAPE if the SDL_Window given is a - * shapeable window currently lacking a shape. - * - * \since This function is available since SDL 3.0.0. - * - * \sa SDL_WindowShapeMode - * \sa SDL_SetWindowShape - */ -extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include - -#endif /* SDL_shape_h_ */ diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index 14bc32ae9..0cb08454f 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -57,7 +57,6 @@ SDL3_0.0.0 { SDL_CreateRWLock; SDL_CreateRenderer; SDL_CreateSemaphore; - SDL_CreateShapedWindow; SDL_CreateSoftwareRenderer; SDL_CreateSurface; SDL_CreateSurfaceFrom; @@ -314,7 +313,6 @@ SDL3_0.0.0 { SDL_GetSensorNonPortableType; SDL_GetSensorType; SDL_GetSensors; - SDL_GetShapedWindowMode; SDL_GetSurfaceAlphaMod; SDL_GetSurfaceBlendMode; SDL_GetSurfaceClipRect; @@ -420,7 +418,6 @@ SDL3_0.0.0 { SDL_IsDeXMode; SDL_IsGamepad; SDL_IsJoystickVirtual; - SDL_IsShapedWindow; SDL_IsTablet; SDL_JoystickConnected; SDL_JoystickEventsEnabled; @@ -612,7 +609,6 @@ SDL3_0.0.0 { SDL_SetWindowOpacity; SDL_SetWindowPosition; SDL_SetWindowResizable; - SDL_SetWindowShape; SDL_SetWindowSize; SDL_SetWindowTitle; SDL_SetWindowsMessageHook; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 83ec2ca33..fcd77a293 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -81,7 +81,6 @@ #define SDL_CreateRWLock SDL_CreateRWLock_REAL #define SDL_CreateRenderer SDL_CreateRenderer_REAL #define SDL_CreateSemaphore SDL_CreateSemaphore_REAL -#define SDL_CreateShapedWindow SDL_CreateShapedWindow_REAL #define SDL_CreateSoftwareRenderer SDL_CreateSoftwareRenderer_REAL #define SDL_CreateSurface SDL_CreateSurface_REAL #define SDL_CreateSurfaceFrom SDL_CreateSurfaceFrom_REAL @@ -338,7 +337,6 @@ #define SDL_GetSensorNonPortableType SDL_GetSensorNonPortableType_REAL #define SDL_GetSensorType SDL_GetSensorType_REAL #define SDL_GetSensors SDL_GetSensors_REAL -#define SDL_GetShapedWindowMode SDL_GetShapedWindowMode_REAL #define SDL_GetSurfaceAlphaMod SDL_GetSurfaceAlphaMod_REAL #define SDL_GetSurfaceBlendMode SDL_GetSurfaceBlendMode_REAL #define SDL_GetSurfaceClipRect SDL_GetSurfaceClipRect_REAL @@ -444,7 +442,6 @@ #define SDL_IsDeXMode SDL_IsDeXMode_REAL #define SDL_IsGamepad SDL_IsGamepad_REAL #define SDL_IsJoystickVirtual SDL_IsJoystickVirtual_REAL -#define SDL_IsShapedWindow SDL_IsShapedWindow_REAL #define SDL_IsTablet SDL_IsTablet_REAL #define SDL_JoystickConnected SDL_JoystickConnected_REAL #define SDL_JoystickEventsEnabled SDL_JoystickEventsEnabled_REAL @@ -635,7 +632,6 @@ #define SDL_SetWindowOpacity SDL_SetWindowOpacity_REAL #define SDL_SetWindowPosition SDL_SetWindowPosition_REAL #define SDL_SetWindowResizable SDL_SetWindowResizable_REAL -#define SDL_SetWindowShape SDL_SetWindowShape_REAL #define SDL_SetWindowSize SDL_SetWindowSize_REAL #define SDL_SetWindowTitle SDL_SetWindowTitle_REAL #define SDL_SetWindowsMessageHook SDL_SetWindowsMessageHook_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 7ddba0e8c..4149b05cd 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -147,7 +147,6 @@ SDL_DYNAPI_PROC(SDL_RWops*,SDL_CreateRW,(void),(),return) SDL_DYNAPI_PROC(SDL_RWLock*,SDL_CreateRWLock,(void),(),return) SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateRenderer,(SDL_Window *a, const char *b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_Semaphore*,SDL_CreateSemaphore,(Uint32 a),(a),return) -SDL_DYNAPI_PROC(SDL_Window*,SDL_CreateShapedWindow,(const char *a, int b, int c, Uint32 d),(a,b,c,d),return) SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateSoftwareRenderer,(SDL_Surface *a),(a),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateSurface,(int a, int b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateSurfaceFrom,(void *a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return) @@ -397,7 +396,6 @@ SDL_DYNAPI_PROC(const char*,SDL_GetSensorName,(SDL_Sensor *a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetSensorNonPortableType,(SDL_Sensor *a),(a),return) SDL_DYNAPI_PROC(SDL_SensorType,SDL_GetSensorType,(SDL_Sensor *a),(a),return) SDL_DYNAPI_PROC(SDL_SensorID*,SDL_GetSensors,(int *a),(a),return) -SDL_DYNAPI_PROC(int,SDL_GetShapedWindowMode,(SDL_Window *a, SDL_WindowShapeMode *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetSurfaceAlphaMod,(SDL_Surface *a, Uint8 *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetSurfaceBlendMode,(SDL_Surface *a, SDL_BlendMode *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetSurfaceClipRect,(SDL_Surface *a, SDL_Rect *b),(a,b),return) @@ -500,7 +498,6 @@ SDL_DYNAPI_PROC(int,SDL_Init,(Uint32 a),(a),return) SDL_DYNAPI_PROC(int,SDL_InitSubSystem,(Uint32 a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_IsGamepad,(SDL_JoystickID a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_IsJoystickVirtual,(SDL_JoystickID a),(a),return) -SDL_DYNAPI_PROC(SDL_bool,SDL_IsShapedWindow,(const SDL_Window *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_IsTablet,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_JoystickConnected,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_JoystickEventsEnabled,(void),(),return) @@ -678,7 +675,6 @@ SDL_DYNAPI_PROC(int,SDL_SetWindowMouseRect,(SDL_Window *a, const SDL_Rect *b),(a SDL_DYNAPI_PROC(int,SDL_SetWindowOpacity,(SDL_Window *a, float b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_SetWindowPosition,(SDL_Window *a, int b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_SetWindowResizable,(SDL_Window *a, SDL_bool b),(a,b),return) -SDL_DYNAPI_PROC(int,SDL_SetWindowShape,(SDL_Window *a, SDL_Surface *b, SDL_WindowShapeMode *c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_SetWindowSize,(SDL_Window *a, int b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_SetWindowTitle,(SDL_Window *a, const char *b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_SetYUVConversionMode,(SDL_YUV_CONVERSION_MODE a),(a),) diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c deleted file mode 100644 index 2362ed7f7..000000000 --- a/src/video/SDL_shape.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -#include "SDL_sysvideo.h" -#include "SDL_shape_internals.h" -#include "SDL_video_c.h" - -SDL_Window *SDL_CreateShapedWindow(const char *title, int w, int h, Uint32 flags) -{ - SDL_Window *result = NULL; - result = SDL_CreateWindow(title, w, h, (flags | SDL_WINDOW_BORDERLESS | SDL_WINDOW_HIDDEN) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE)); - if (result) { - if (SDL_GetVideoDevice()->shape_driver.CreateShaper == NULL) { - SDL_DestroyWindow(result); - return NULL; - } - result->shaper = SDL_GetVideoDevice()->shape_driver.CreateShaper(result); - if (result->shaper) { - result->shaper->mode.mode = ShapeModeDefault; - result->shaper->mode.parameters.binarizationCutoff = 1; - result->shaper->hasshape = SDL_FALSE; - return result; - } else { - SDL_DestroyWindow(result); - return NULL; - } - } - return NULL; -} - -SDL_bool SDL_IsShapedWindow(const SDL_Window *window) -{ - if (window == NULL) { - return SDL_FALSE; - } - return (window->shaper != NULL); -} - -/* REQUIRES that bitmap point to a w-by-h bitmap with ppb pixels-per-byte. */ -void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode, SDL_Surface *shape, Uint8 *bitmap, Uint8 ppb) -{ - int x = 0; - int y = 0; - Uint8 r = 0, g = 0, b = 0, alpha = 0; - Uint32 mask_value = 0; - size_t bytes_per_scanline = (size_t)(shape->w + (ppb - 1)) / ppb; - Uint8 *bitmap_scanline; - SDL_Color key; - - if (SDL_MUSTLOCK(shape)) { - SDL_LockSurface(shape); - } - - SDL_memset(bitmap, 0, shape->h * bytes_per_scanline); - - for (y = 0; y < shape->h; y++) { - bitmap_scanline = bitmap + y * bytes_per_scanline; - for (x = 0; x < shape->w; x++) { - if (SDL_ReadSurfacePixel(shape, x, y, &r, &g, &b, &alpha) != 0) { - continue; - } - - switch (mode.mode) { - case (ShapeModeDefault): - mask_value = (alpha >= 1 ? 1 : 0); - break; - case (ShapeModeBinarizeAlpha): - mask_value = (alpha >= mode.parameters.binarizationCutoff ? 1 : 0); - break; - case (ShapeModeReverseBinarizeAlpha): - mask_value = (alpha <= mode.parameters.binarizationCutoff ? 1 : 0); - break; - case (ShapeModeColorKey): - key = mode.parameters.colorKey; - mask_value = ((key.r != r || key.g != g || key.b != b) ? 1 : 0); - break; - } - bitmap_scanline[x / ppb] |= mask_value << (x % ppb); - } - } - - if (SDL_MUSTLOCK(shape)) { - SDL_UnlockSurface(shape); - } -} - -static SDL_ShapeTree *RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *mask, SDL_Rect dimensions) -{ - int x = 0, y = 0; - Uint8 r = 0, g = 0, b = 0, a = 0; - SDL_bool pixel_opaque = SDL_FALSE; - int last_opaque = -1; - SDL_Color key; - SDL_ShapeTree *result = (SDL_ShapeTree *)SDL_malloc(sizeof(SDL_ShapeTree)); - SDL_Rect next = { 0, 0, 0, 0 }; - - if (!result) { - SDL_OutOfMemory(); - return NULL; - } - - for (y = dimensions.y; y < dimensions.y + dimensions.h; y++) { - for (x = dimensions.x; x < dimensions.x + dimensions.w; x++) { - if (SDL_ReadSurfacePixel(mask, x, y, &r, &g, &b, &a) != 0) { - continue; - } - switch (mode.mode) { - case (ShapeModeDefault): - pixel_opaque = (a >= 1); - break; - case (ShapeModeBinarizeAlpha): - pixel_opaque = (a >= mode.parameters.binarizationCutoff); - break; - case (ShapeModeReverseBinarizeAlpha): - pixel_opaque = (a <= mode.parameters.binarizationCutoff); - break; - case (ShapeModeColorKey): - key = mode.parameters.colorKey; - pixel_opaque = (key.r != r || key.g != g || key.b != b); - break; - } - if (last_opaque == -1) { - last_opaque = pixel_opaque; - } - if (last_opaque != pixel_opaque) { - const int halfwidth = dimensions.w / 2; - const int halfheight = dimensions.h / 2; - - result->kind = QuadShape; - - next.x = dimensions.x; - next.y = dimensions.y; - next.w = halfwidth; - next.h = halfheight; - result->data.children.upleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode, mask, next); - - next.x = dimensions.x + halfwidth; - next.w = dimensions.w - halfwidth; - result->data.children.upright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode, mask, next); - - next.x = dimensions.x; - next.w = halfwidth; - next.y = dimensions.y + halfheight; - next.h = dimensions.h - halfheight; - result->data.children.downleft = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode, mask, next); - - next.x = dimensions.x + halfwidth; - next.w = dimensions.w - halfwidth; - result->data.children.downright = (struct SDL_ShapeTree *)RecursivelyCalculateShapeTree(mode, mask, next); - - return result; - } - } - } - - /* If we never recursed, all the pixels in this quadrant have the same "value". */ - result->kind = (last_opaque == SDL_TRUE ? OpaqueShape : TransparentShape); - result->data.shape = dimensions; - return result; -} - -SDL_ShapeTree *SDL_CalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *shape) -{ - SDL_Rect dimensions; - SDL_ShapeTree *result = NULL; - - dimensions.x = 0; - dimensions.y = 0; - dimensions.w = shape->w; - dimensions.h = shape->h; - - if (SDL_MUSTLOCK(shape)) { - SDL_LockSurface(shape); - } - result = RecursivelyCalculateShapeTree(mode, shape, dimensions); - if (SDL_MUSTLOCK(shape)) { - SDL_UnlockSurface(shape); - } - return result; -} - -void SDL_TraverseShapeTree(SDL_ShapeTree *tree, SDL_TraversalFunction function, void *closure) -{ - SDL_assert(tree != NULL); - if (tree->kind == QuadShape) { - SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upleft, function, closure); - SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upright, function, closure); - SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downleft, function, closure); - SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.downright, function, closure); - } else { - function(tree, closure); - } -} - -void SDL_FreeShapeTree(SDL_ShapeTree **shape_tree) -{ - if ((*shape_tree)->kind == QuadShape) { - SDL_FreeShapeTree((SDL_ShapeTree **)(char *)&(*shape_tree)->data.children.upleft); - SDL_FreeShapeTree((SDL_ShapeTree **)(char *)&(*shape_tree)->data.children.upright); - SDL_FreeShapeTree((SDL_ShapeTree **)(char *)&(*shape_tree)->data.children.downleft); - SDL_FreeShapeTree((SDL_ShapeTree **)(char *)&(*shape_tree)->data.children.downright); - } - SDL_free(*shape_tree); - *shape_tree = NULL; -} - -int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode) -{ - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - int result; - - if (!window || !SDL_IsShapedWindow(window)) { - /* The window given was not a shapeable window. */ - return SDL_NONSHAPEABLE_WINDOW; - } - if (!shape) { - /* Invalid shape argument. */ - return SDL_INVALID_SHAPE_ARGUMENT; - } - - if (shape_mode) { - window->shaper->mode = *shape_mode; - } - result = _this->shape_driver.SetWindowShape(window->shaper, shape, shape_mode); - if (result == 0) { - window->shaper->hasshape = SDL_TRUE; - SDL_ShowWindow(window); - } - return result; -} - -static SDL_bool SDL_WindowHasAShape(SDL_Window *window) -{ - if (!window || !SDL_IsShapedWindow(window)) { - return SDL_FALSE; - } - return window->shaper->hasshape; -} - -int SDL_GetShapedWindowMode(SDL_Window *window, SDL_WindowShapeMode *shape_mode) -{ - if (window && SDL_IsShapedWindow(window)) { - if (!shape_mode) { - if (SDL_WindowHasAShape(window)) { - return 0; /* The window given has a shape. */ - } else { - return SDL_WINDOW_LACKS_SHAPE; /* The window given is shapeable but lacks a shape. */ - } - } else { - *shape_mode = window->shaper->mode; - return 0; - } - } - return SDL_NONSHAPEABLE_WINDOW; /* The window given is not a valid shapeable window. */ -} diff --git a/src/video/SDL_shape_internals.h b/src/video/SDL_shape_internals.h deleted file mode 100644 index fa8e90adb..000000000 --- a/src/video/SDL_shape_internals.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -#ifndef SDL_shape_internals_h_ -#define SDL_shape_internals_h_ - -struct SDL_ShapeTree; - -typedef struct -{ - struct SDL_ShapeTree *upleft, *upright, *downleft, *downright; -} SDL_QuadTreeChildren; - -typedef union -{ - SDL_QuadTreeChildren children; - SDL_Rect shape; -} SDL_ShapeUnion; - -typedef enum -{ - QuadShape, - TransparentShape, - OpaqueShape -} SDL_ShapeKind; - -typedef struct SDL_ShapeTree -{ - SDL_ShapeKind kind; - SDL_ShapeUnion data; -} SDL_ShapeTree; - -typedef void (*SDL_TraversalFunction)(SDL_ShapeTree *, void *); - -extern void SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode, SDL_Surface *shape, Uint8 *bitmap, Uint8 ppb); -extern SDL_ShapeTree *SDL_CalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *shape); -extern void SDL_TraverseShapeTree(SDL_ShapeTree *tree, SDL_TraversalFunction function, void *closure); -extern void SDL_FreeShapeTree(SDL_ShapeTree **shape_tree); - -#endif /* SDL_shape_internals_h_ */ diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 2dccb30d2..df986bdf8 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -27,8 +27,6 @@ /* The SDL video driver */ -typedef struct SDL_WindowShaper SDL_WindowShaper; -typedef struct SDL_ShapeDriver SDL_ShapeDriver; typedef struct SDL_VideoDisplay SDL_VideoDisplay; typedef struct SDL_VideoDevice SDL_VideoDevice; typedef struct SDL_VideoData SDL_VideoData; @@ -36,28 +34,6 @@ typedef struct SDL_DisplayData SDL_DisplayData; typedef struct SDL_DisplayModeData SDL_DisplayModeData; typedef struct SDL_WindowData SDL_WindowData; -/* Define the SDL window-shaper structure */ -struct SDL_WindowShaper -{ - /* The window associated with the shaper */ - SDL_Window *window; - - /* The parameters for shape calculation. */ - SDL_WindowShapeMode mode; - - /* Has this window been assigned a shape? */ - SDL_bool hasshape; - - void *driverdata; -}; - -/* Define the SDL shape driver structure */ -struct SDL_ShapeDriver -{ - SDL_WindowShaper *(*CreateShaper)(SDL_Window *window); - int (*SetWindowShape)(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode); -}; - /* Define the SDL window structure, corresponding to toplevel windows */ struct SDL_Window { @@ -99,8 +75,6 @@ struct SDL_Window SDL_Rect mouse_rect; - SDL_WindowShaper *shaper; - SDL_HitTest hit_test; void *hit_test_data; @@ -257,12 +231,6 @@ struct SDL_VideoDevice int (*FlashWindow)(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); int (*SetWindowFocusable)(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool focusable); - /* * * */ - /* - * Shaped-window functions - */ - SDL_ShapeDriver shape_driver; - /* * * */ /* * OpenGL support diff --git a/src/video/cocoa/SDL_cocoashape.h b/src/video/cocoa/SDL_cocoashape.h deleted file mode 100644 index a7c6d14a5..000000000 --- a/src/video/cocoa/SDL_cocoashape.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SDL_internal.h" - -#ifndef SDL_cocoashape_h_ -#define SDL_cocoashape_h_ - -#include "../SDL_shape_internals.h" - -@interface SDL_ShapeData : NSObject -@property(nonatomic) NSGraphicsContext *context; -@property(nonatomic) SDL_bool saved; -@property(nonatomic) SDL_ShapeTree *shape; -@end - -extern SDL_WindowShaper *Cocoa_CreateShaper(SDL_Window *window); -extern int Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode); - -#endif /* SDL_cocoashape_h_ */ diff --git a/src/video/cocoa/SDL_cocoashape.m b/src/video/cocoa/SDL_cocoashape.m deleted file mode 100644 index 2e16741b7..000000000 --- a/src/video/cocoa/SDL_cocoashape.m +++ /dev/null @@ -1,115 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -#ifdef SDL_VIDEO_DRIVER_COCOA - -#include "SDL_cocoavideo.h" -#include "SDL_cocoashape.h" -#include "../SDL_sysvideo.h" - -@implementation SDL_ShapeData -@end - -@interface SDL_CocoaClosure : NSObject -@property(nonatomic) NSView *view; -@property(nonatomic) NSBezierPath *path; -@property(nonatomic) SDL_Window *window; -@end - -@implementation SDL_CocoaClosure -@end - -SDL_WindowShaper *Cocoa_CreateShaper(SDL_Window *window) -{ - @autoreleasepool { - SDL_WindowShaper *result; - SDL_ShapeData *data; - SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)window->driverdata; - - result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); - if (!result) { - SDL_OutOfMemory(); - return NULL; - } - - [windata.nswindow setOpaque:NO]; - - [windata.nswindow setStyleMask:NSWindowStyleMaskBorderless]; - - result->window = window; - result->mode.mode = ShapeModeDefault; - result->mode.parameters.binarizationCutoff = 1; - window->shaper = result; - - data = [[SDL_ShapeData alloc] init]; - data.context = [windata.nswindow graphicsContext]; - data.saved = SDL_FALSE; - data.shape = NULL; - - /* TODO: There's no place to release this... */ - result->driverdata = (void *)CFBridgingRetain(data); - - return result; - } -} - -void ConvertRects(SDL_ShapeTree *tree, void *closure) -{ - SDL_CocoaClosure *data = (__bridge SDL_CocoaClosure *)closure; - if (tree->kind == OpaqueShape) { - NSRect rect = NSMakeRect(tree->data.shape.x, data.window->h - tree->data.shape.y, tree->data.shape.w, tree->data.shape.h); - [data.path appendBezierPathWithRect:[data.view convertRect:rect toView:nil]]; - } -} - -int Cocoa_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode) -{ - @autoreleasepool { - SDL_ShapeData *data = (__bridge SDL_ShapeData *)shaper->driverdata; - SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)shaper->window->driverdata; - SDL_CocoaClosure *closure; - if (data.saved == SDL_TRUE) { - [data.context restoreGraphicsState]; - data.saved = SDL_FALSE; - } - - /*[data.context saveGraphicsState];*/ - /*data.saved = SDL_TRUE;*/ - [NSGraphicsContext setCurrentContext:data.context]; - - [[NSColor clearColor] set]; - NSRectFill([windata.sdlContentView frame]); - data.shape = SDL_CalculateShapeTree(*shape_mode, shape); - - closure = [[SDL_CocoaClosure alloc] init]; - - closure.view = windata.sdlContentView; - closure.path = [NSBezierPath bezierPath]; - closure.window = shaper->window; - SDL_TraverseShapeTree(data.shape, &ConvertRects, (__bridge void *)closure); - [closure.path addClip]; - - return 0; - } -} - -#endif /* SDL_VIDEO_DRIVER_COCOA */ diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index 1153b2635..0d93a5ef0 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -27,7 +27,6 @@ #endif #include "SDL_cocoavideo.h" -#include "SDL_cocoashape.h" #include "SDL_cocoavulkan.h" #include "SDL_cocoametalview.h" #include "SDL_cocoaopengles.h" @@ -119,9 +118,6 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void) device->FlashWindow = Cocoa_FlashWindow; device->SetWindowFocusable = Cocoa_SetWindowFocusable; - device->shape_driver.CreateShaper = Cocoa_CreateShaper; - device->shape_driver.SetWindowShape = Cocoa_SetWindowShape; - #ifdef SDL_VIDEO_OPENGL_CGL device->GL_LoadLibrary = Cocoa_GL_LoadLibrary; device->GL_GetProcAddress = Cocoa_GL_GetProcAddress; diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index b4c0bf7d2..964cfa0e6 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -36,7 +36,6 @@ #include "../../events/SDL_dropevents_c.h" #include "SDL_cocoavideo.h" -#include "SDL_cocoashape.h" #include "SDL_cocoamouse.h" #include "SDL_cocoaopengl.h" #include "SDL_cocoaopengles.h" @@ -2563,12 +2562,6 @@ void Cocoa_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) } #endif /* SDL_VIDEO_OPENGL */ - - if (window->shaper) { - CFBridgingRelease(window->shaper->driverdata); - SDL_free(window->shaper); - window->shaper = NULL; - } } window->driverdata = NULL; } diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index ef6b3d655..5202955bf 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -23,7 +23,6 @@ #ifdef SDL_VIDEO_DRIVER_WINDOWS #include "SDL_windowsvideo.h" -#include "SDL_windowsshape.h" #include "SDL_vkeys.h" #include "../../events/SDL_events_c.h" #include "../../events/SDL_touch_c.h" diff --git a/src/video/windows/SDL_windowsshape.c b/src/video/windows/SDL_windowsshape.c deleted file mode 100644 index 74026601f..000000000 --- a/src/video/windows/SDL_windowsshape.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) - -#include "SDL_windowsshape.h" -#include "SDL_windowsvideo.h" - -SDL_WindowShaper *Win32_CreateShaper(SDL_Window *window) -{ - SDL_WindowShaper *result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); - if (!result) { - SDL_OutOfMemory(); - return NULL; - } - result->window = window; - result->mode.mode = ShapeModeDefault; - result->mode.parameters.binarizationCutoff = 1; - result->hasshape = SDL_FALSE; - result->driverdata = (SDL_ShapeData *)SDL_calloc(1, sizeof(SDL_ShapeData)); - if (!result->driverdata) { - SDL_free(result); - SDL_OutOfMemory(); - return NULL; - } - window->shaper = result; - - return result; -} - -static void CombineRectRegions(SDL_ShapeTree *node, void *closure) -{ - HRGN mask_region = *((HRGN *)closure), temp_region = NULL; - if (node->kind == OpaqueShape) { - /* Win32 API regions exclude their outline, so we widen the region by one pixel in each direction to include the real outline. */ - temp_region = CreateRectRgn(node->data.shape.x, node->data.shape.y, node->data.shape.x + node->data.shape.w + 1, node->data.shape.y + node->data.shape.h + 1); - if (mask_region != NULL) { - CombineRgn(mask_region, mask_region, temp_region, RGN_OR); - DeleteObject(temp_region); - } else { - *((HRGN *)closure) = temp_region; - } - } -} - -int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode) -{ - SDL_ShapeData *data; - HRGN mask_region = NULL; - - if ((!shaper) || - (!shape) || - ((shape->format->Amask == 0) && (shape_mode->mode != ShapeModeColorKey))) { - return SDL_INVALID_SHAPE_ARGUMENT; - } - - data = (SDL_ShapeData *)shaper->driverdata; - if (data->mask_tree) { - SDL_FreeShapeTree(&data->mask_tree); - } - data->mask_tree = SDL_CalculateShapeTree(*shape_mode, shape); - - SDL_TraverseShapeTree(data->mask_tree, &CombineRectRegions, &mask_region); - SDL_assert(mask_region != NULL); - - SetWindowRgn(shaper->window->driverdata->hwnd, mask_region, TRUE); - - return 0; -} - -#endif /* SDL_VIDEO_DRIVER_WINDOWS */ diff --git a/src/video/windows/SDL_windowsshape.h b/src/video/windows/SDL_windowsshape.h deleted file mode 100644 index 074f7edf4..000000000 --- a/src/video/windows/SDL_windowsshape.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SDL_internal.h" - -#ifndef SDL_windowsshape_h_ -#define SDL_windowsshape_h_ - -#include "../SDL_sysvideo.h" -#include "../SDL_shape_internals.h" - -typedef struct -{ - SDL_ShapeTree *mask_tree; -} SDL_ShapeData; - -extern SDL_WindowShaper *Win32_CreateShaper(SDL_Window *window); -extern int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode); - -#endif /* SDL_windowsshape_h_ */ diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 15ef5a8fe..6cfbc35d2 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -31,7 +31,6 @@ #include "SDL_windowsvideo.h" #include "SDL_windowsframebuffer.h" -#include "SDL_windowsshape.h" #include "SDL_windowsvulkan.h" #ifdef SDL_GDK_TEXTINPUT @@ -210,9 +209,6 @@ static SDL_VideoDevice *WIN_CreateDevice(void) device->FlashWindow = WIN_FlashWindow; device->ShowWindowSystemMenu = WIN_ShowWindowSystemMenu; device->SetWindowFocusable = WIN_SetWindowFocusable; - - device->shape_driver.CreateShaper = Win32_CreateShaper; - device->shape_driver.SetWindowShape = Win32_SetWindowShape; #endif #ifdef SDL_VIDEO_OPENGL_WGL diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 2665a21ae..55e2d700e 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -33,7 +33,6 @@ #include "SDL_windowsvideo.h" #include "SDL_windowswindow.h" -#include "SDL_windowsshape.h" /* Dropfile support */ #include @@ -1230,18 +1229,6 @@ void WIN_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_b void WIN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) { - if (window->shaper) { - SDL_ShapeData *shapedata = (SDL_ShapeData *)window->shaper->driverdata; - if (shapedata) { - if (shapedata->mask_tree) { - SDL_FreeShapeTree(&shapedata->mask_tree); - } - SDL_free(shapedata); - } - SDL_free(window->shaper); - window->shaper = NULL; - } - CleanupWindowData(_this, window); } diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c deleted file mode 100644 index 373d6eba1..000000000 --- a/src/video/x11/SDL_x11shape.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -#ifdef SDL_VIDEO_DRIVER_X11 - -#include "SDL_x11video.h" -#include "SDL_x11shape.h" -#include "SDL_x11window.h" -#include "../SDL_shape_internals.h" - -SDL_WindowShaper *X11_CreateShaper(SDL_Window *window) -{ - SDL_WindowShaper *result = NULL; - -#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE - SDL_ShapeData *data = NULL; - - if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */ - result = SDL_malloc(sizeof(SDL_WindowShaper)); - if (!result) { - SDL_OutOfMemory(); - return NULL; - } - result->window = window; - result->mode.mode = ShapeModeDefault; - result->mode.parameters.binarizationCutoff = 1; - data = SDL_malloc(sizeof(SDL_ShapeData)); - if (!data) { - SDL_free(result); - SDL_OutOfMemory(); - return NULL; - } - result->driverdata = data; - data->bitmapsize = 0; - data->bitmap = NULL; - window->shaper = result; - } -#endif - - return result; -} - -int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode) -{ -#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE - SDL_ShapeData *data = NULL; - SDL_WindowData *windowdata = NULL; - Pixmap shapemask; -#endif - - if (!shaper || !shape || !shaper->driverdata) { - return -1; - } - -#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE - if (shape->format->Amask == 0 && SDL_SHAPEMODEALPHA(shape_mode->mode)) { - return -2; - } - if (shape->w != shaper->window->w || shape->h != shaper->window->h) { - return -3; - } - data = shaper->driverdata; - - /* Assume that shaper->alphacutoff already has a value, because SDL_SetWindowShape() should have given it one. */ - SDL_CalculateShapeBitmap(shaper->mode, shape, data->bitmap, 8); - - windowdata = shaper->window->driverdata; - shapemask = X11_XCreateBitmapFromData(windowdata->videodata->display, windowdata->xwindow, data->bitmap, shaper->window->w, shaper->window->h); - - X11_XShapeCombineMask(windowdata->videodata->display, windowdata->xwindow, ShapeBounding, 0, 0, shapemask, ShapeSet); - X11_XSync(windowdata->videodata->display, False); - - X11_XFreePixmap(windowdata->videodata->display, shapemask); -#endif - - return 0; -} - -#endif /* SDL_VIDEO_DRIVER_X11 */ diff --git a/src/video/x11/SDL_x11shape.h b/src/video/x11/SDL_x11shape.h deleted file mode 100644 index 96ec12184..000000000 --- a/src/video/x11/SDL_x11shape.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -#ifndef SDL_x11shape_h_ -#define SDL_x11shape_h_ - -#include "../SDL_sysvideo.h" - -typedef struct -{ - void *bitmap; - Uint32 bitmapsize; -} SDL_ShapeData; - -extern SDL_WindowShaper *X11_CreateShaper(SDL_Window *window); -extern int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode); - -#endif /* SDL_x11shape_h_ */ diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 8e9b91d2a..32a28ee1a 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -30,7 +30,6 @@ #include "SDL_x11framebuffer.h" #include "SDL_x11pen.h" -#include "SDL_x11shape.h" #include "SDL_x11touch.h" #include "SDL_x11video.h" #include "SDL_x11xfixes.h" @@ -217,9 +216,6 @@ static SDL_VideoDevice *X11_CreateDevice(void) device->SetWindowMouseRect = X11_SetWindowMouseRect; #endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ - device->shape_driver.CreateShaper = X11_CreateShaper; - device->shape_driver.SetWindowShape = X11_SetWindowShape; - #ifdef SDL_VIDEO_OPENGL_GLX device->GL_LoadLibrary = X11_GL_LoadLibrary; device->GL_GetProcAddress = X11_GL_GetProcAddress; diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index c750ea760..5d8000d21 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -31,7 +31,6 @@ #include "SDL_x11video.h" #include "SDL_x11mouse.h" -#include "SDL_x11shape.h" #include "SDL_x11xinput2.h" #include "SDL_x11xfixes.h" @@ -1821,16 +1820,6 @@ void X11_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) { SDL_WindowData *data = window->driverdata; - if (window->shaper) { - SDL_ShapeData *shapedata = (SDL_ShapeData *)window->shaper->driverdata; - if (shapedata) { - SDL_free(shapedata->bitmap); - SDL_free(shapedata); - } - SDL_free(window->shaper); - window->shaper = NULL; - } - if (data) { SDL_VideoData *videodata = data->videodata; Display *display = videodata->display; diff --git a/test/testshape.c b/test/testshape.c index c5950b3f7..459badabe 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -17,6 +17,36 @@ #define SHAPED_WINDOW_DIMENSION 640 +/** An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ +typedef enum +{ + /** The default mode, a binarized alpha cutoff of 1. */ + ShapeModeDefault, + /** A binarized alpha cutoff with a given integer value. */ + ShapeModeBinarizeAlpha, + /** A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ + ShapeModeReverseBinarizeAlpha, + /** A color key is applied. */ + ShapeModeColorKey +} WindowShapeMode; + +/** A union containing parameters for shaped windows. */ +typedef union +{ + /** A cutoff alpha value for binarization of the window shape's alpha channel. */ + Uint8 binarizationCutoff; + SDL_Color colorKey; +} SDL_WindowShapeParams; + +/** A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ +typedef struct SDL_WindowShapeMode +{ + /** The mode of these window-shape parameters. */ + WindowShapeMode mode; + /** Window-shape parameters. */ + SDL_WindowShapeParams parameters; +} SDL_WindowShapeMode; + typedef struct LoadedPicture { SDL_Surface *surface;