Commit Graph

917 Commits

Author SHA1 Message Date
Sylvain Becker
1aa2ad2fe8 Better naming for the blit permutation variables 2019-02-09 17:40:32 +01:00
Sylvain Becker
f6a2ae6007 Faster blit colorkey or not, applied to bpp: 3->4 and 4->3
===== BlitNtoNKey ========
ABGR8888 -> BGR24 :  faster x3   (2168709 -> 562738)
ABGR8888 -> RGB24 :  faster x3   (2165055 -> 567458)

ARGB8888 -> BGR24 :  faster x3   (2169109 -> 564338)
ARGB8888 -> RGB24 :  faster x3   (2165266 -> 567081)

BGR24 -> ABGR8888 :  faster x3   (2997675 -> 891636)
BGR24 -> ARGB8888 :  faster x3   (2985449 -> 892028)
BGR24 -> BGR888 :  faster x3   (2961611 -> 891913)
BGR24 -> BGRA8888 :  faster x3   (3116305 -> 891534)
BGR24 -> BGRX8888 :  faster x3   (3179654 -> 896978)
BGR24 -> RGB888 :  faster x3   (2968191 -> 895112)
BGR24 -> RGBA8888 :  faster x3   (2998428 -> 893147)
BGR24 -> RGBX8888 :  faster x3   (2976529 -> 914853)

BGR888 -> BGR24 :  faster x3   (2161906 -> 563921)
BGR888 -> RGB24 :  faster x3   (2168228 -> 566634)

BGRA8888 -> BGR24 :  faster x4   (2270501 -> 561873)
BGRA8888 -> RGB24 :  faster x3   (2163179 -> 567330)

BGRX8888 -> BGR24 :  faster x3   (2162911 -> 562322)
BGRX8888 -> RGB24 :  faster x3   (2169617 -> 570927)

RGB24 -> ABGR8888 :  faster x3   (2977061 -> 925975)
RGB24 -> ARGB8888 :  faster x3   (2978148 -> 923680)
RGB24 -> BGR888 :  faster x3   (3001413 -> 935074)
RGB24 -> BGRA8888 :  faster x3   (2959003 -> 924096)
RGB24 -> BGRX8888 :  faster x3   (2965240 -> 927100)
RGB24 -> RGB888 :  faster x3   (2983921 -> 926063)
RGB24 -> RGBA8888 :  faster x3   (2963908 -> 925457)
RGB24 -> RGBX8888 :  faster x3   (2967957 -> 931700)

RGB888 -> BGR24 :  faster x3   (2173299 -> 563226)
RGB888 -> RGB24 :  faster x3   (2218374 -> 566164)

RGBA8888 -> BGR24 :  faster x3   (2166355 -> 561381)
RGBA8888 -> RGB24 :  faster x3   (2170322 -> 566729)

RGBX8888 -> BGR24 :  faster x3   (2168524 -> 564072)
RGBX8888 -> RGB24 :  faster x3   (2163680 -> 566956)

===== BlitNtoN ========

BGR24 -> BGRA8888 :  faster x3   (2458958 -> 797557)
BGR24 -> BGRX8888 :  faster x3   (2486085 -> 797745)
BGR24 -> RGBA8888 :  faster x3   (2422116 -> 797637)
BGR24 -> RGBX8888 :  faster x3   (2454426 -> 799085)

BGRA8888 -> BGR24 :  faster x4   (2468206 -> 524486)
BGRA8888 -> RGB24 :  faster x4   (2463581 -> 525561)

BGRX8888 -> BGR24 :  faster x4   (2583355 -> 524468)
BGRX8888 -> RGB24 :  faster x4   (2477242 -> 524284)

RGB24 -> BGRA8888 :  faster x2   (2453414 -> 818415)
RGB24 -> BGRX8888 :  faster x3   (2414915 -> 800863)
RGB24 -> RGBA8888 :  faster x3   (2461114 -> 798148)
RGB24 -> RGBX8888 :  faster x3   (2400922 -> 799203)

RGBA8888 -> BGR24 :  faster x4   (2494472 -> 526428)
RGBA8888 -> RGB24 :  faster x4   (2462260 -> 526791)

RGBX8888 -> BGR24 :  faster x4   (2541115 -> 524390)
RGBX8888 -> RGB24 :  faster x4   (2469059 -> 525416)
2019-02-09 17:20:53 +01:00
Sylvain Becker
604b44f20f Fix wrong access and simplify 2019-02-08 17:15:30 +01:00
Sylvain Becker
5ed30f844d Some simplification of previous commit 2019-02-07 22:45:50 +01:00
Sylvain Becker
5fd228921c Faster blit with CopyAlpha, no ColorKey
Applied to following formats:

ABGR8888 -> BGRA8888 :  faster x3   (2727179 -> 704761)
ABGR8888 -> RGBA8888 :  faster x3   (2707808 -> 705309)

ARGB8888 -> BGRA8888 :  faster x3   (2745371 -> 712437)
ARGB8888 -> RGBA8888 :  faster x3   (2746230 -> 705236)

BGRA8888 -> ABGR8888 :  faster x3   (2745026 -> 707045)
BGRA8888 -> ARGB8888 :  faster x3   (2752760 -> 727373)
BGRA8888 -> RGBA8888 :  faster x3   (2769544 -> 704607)

RGBA8888 -> ABGR8888 :  faster x3   (2725058 -> 706669)
RGBA8888 -> ARGB8888 :  faster x3   (2704866 -> 707132)
RGBA8888 -> BGRA8888 :  faster x3   (2710351 -> 704615)
2019-02-07 22:03:30 +01:00
Sylvain Becker
704e62bbf4 Code factorization of the pixel format permutation 2019-02-07 21:49:24 +01:00
Sylvain Becker
0a007a9bea Fix wrong comment 2019-02-07 18:52:49 +01:00
Sylvain Becker
e5192384d0 Faster blit with no ColorKey
Applied to following formats:

ABGR8888 -> BGRX8888 :  faster x5   (3177493 -> 630439)
ABGR8888 -> RGBX8888 :  faster x5   (3178104 -> 628925)

ARGB8888 -> BGRX8888 :  faster x4   (3141089 -> 629448)
ARGB8888 -> RGBX8888 :  faster x5   (3216413 -> 630465)

BGR888 -> BGRA8888 :  faster x4   (3145403 -> 637701)
BGR888 -> BGRX8888 :  faster x4   (3142106 -> 630144)
BGR888 -> RGBA8888 :  faster x4   (3202685 -> 649384)
BGR888 -> RGBX8888 :  faster x4   (3170617 -> 658670)

BGRA8888 -> BGR888 :  faster x4   (3203308 -> 657697)
BGRA8888 -> RGB888 :  faster x5   (3201475 -> 631747)
BGRA8888 -> RGBX8888 :  faster x5   (3274544 -> 630409)

BGRX8888 -> ABGR8888 :  faster x4   (3149753 -> 638682)
BGRX8888 -> ARGB8888 :  faster x5   (3164101 -> 631273)
BGRX8888 -> BGR888 :  faster x4   (3144454 -> 630712)
BGRX8888 -> RGB888 :  faster x4   (3160490 -> 638047)
BGRX8888 -> RGBA8888 :  faster x5   (3308988 -> 631232)
BGRX8888 -> RGBX8888 :  faster x5   (3216775 -> 638065)

RGB888 -> BGRA8888 :  faster x4   (3143135 -> 655146)
RGB888 -> BGRX8888 :  faster x4   (3141790 -> 653771)
RGB888 -> RGBA8888 :  faster x5   (3214402 -> 637001)
RGB888 -> RGBX8888 :  faster x4   (3143082 -> 630009)

RGBA8888 -> BGR888 :  faster x3   (3157048 -> 920375)
RGBA8888 -> BGRX8888 :  faster x5   (3196692 -> 632996)
RGBA8888 -> RGB888 :  faster x4   (3141570 -> 652151)

RGBX8888 -> ABGR8888 :  faster x5   (3175401 -> 631218)
RGBX8888 -> ARGB8888 :  faster x4   (3144690 -> 639440)
RGBX8888 -> BGR888 :  faster x4   (3144250 -> 630171)
RGBX8888 -> BGRA8888 :  faster x5   (3220321 -> 630731)
RGBX8888 -> BGRX8888 :  faster x4   (3178453 -> 637445)
RGBX8888 -> RGB888 :  faster x5   (3203623 -> 632596)
2019-02-07 18:51:14 +01:00
Sylvain Becker
7372295ec9 Faster blit when using No Alpha or Set Alpha, + ColorKey
Applied to following formats:

ABGR8888 -> BGRX8888 :  faster x4   (2794295 -> 610587)
ABGR8888 -> RGB888 :  faster x4   (2835693 -> 615561)
ABGR8888 -> RGBX8888 :  faster x4   (2880475 -> 610479)

ARGB8888 -> BGR888 :  faster x4   (2802718 -> 610702)
ARGB8888 -> BGRX8888 :  faster x4   (2792481 -> 606311)
ARGB8888 -> RGBX8888 :  faster x4   (2821621 -> 624745)

BGR888 -> ARGB8888 :  faster x4   (2791705 -> 637889)
BGR888 -> BGRA8888 :  faster x4   (2793195 -> 652299)
BGR888 -> BGRX8888 :  faster x4   (2800713 -> 609326)
BGR888 -> RGB888 :  faster x4   (2812260 -> 610471)
BGR888 -> RGBA8888 :  faster x4   (2792327 -> 629288)
BGR888 -> RGBX8888 :  faster x4   (2799224 -> 607073)

BGRA8888 -> BGR888 :  faster x4   (2800520 -> 606897)
BGRA8888 -> RGB888 :  faster x4   (2825274 -> 616156)
BGRA8888 -> RGBX8888 :  faster x4   (2812530 -> 610340)

BGRX8888 -> ABGR8888 :  faster x4   (2793940 -> 628596)
BGRX8888 -> ARGB8888 :  faster x4   (2822686 -> 638899)
BGRX8888 -> BGR888 :  faster x4   (2818141 -> 613659)
BGRX8888 -> RGB888 :  faster x4   (2929017 -> 611794)
BGRX8888 -> RGBA8888 :  faster x4   (2799709 -> 629750)
BGRX8888 -> RGBX8888 :  faster x4   (2911010 -> 605640)

RGB888 -> ABGR8888 :  faster x4   (2800671 -> 631542)
RGB888 -> BGR888 :  faster x4   (2802644 -> 604461)
RGB888 -> BGRA8888 :  faster x4   (2801919 -> 628729)
RGB888 -> BGRX8888 :  faster x4   (2938244 -> 604135)
RGB888 -> RGBA8888 :  faster x4   (2912447 -> 642185)
RGB888 -> RGBX8888 :  faster x4   (2831676 -> 634293)

RGBA8888 -> BGR888 :  faster x4   (2928896 -> 614960)
RGBA8888 -> BGRX8888 :  faster x4   (2821422 -> 608146)
RGBA8888 -> RGB888 :  faster x4   (2825927 -> 617184)

RGBX8888 -> ABGR8888 :  faster x4   (2803852 -> 654129)
RGBX8888 -> ARGB8888 :  faster x4   (2923615 -> 642644)
RGBX8888 -> BGR888 :  faster x4   (2806523 -> 610447)
RGBX8888 -> BGRA8888 :  faster x4   (2813388 -> 630305)
RGBX8888 -> BGRX8888 :  faster x4   (2800052 -> 607881)
RGBX8888 -> RGB888 :  faster x4   (2807722 -> 610263)
2019-02-07 17:52:28 +01:00
Sylvain Becker
bb9a9080dc Fix pointer warnings 2019-02-07 16:13:25 +01:00
Sylvain Becker
3543a44ae4 Faster blit when using CopyAlpha + ColorKey
Applied to following formats:

ABGR8888 -> ARGB8888 :  faster x7   (3959672 -> 537227)
ABGR8888 -> BGRA8888 :  faster x7   (4008716 -> 532064)
ABGR8888 -> RGBA8888 :  faster x7   (3998576 -> 530964)

ARGB8888 -> ABGR8888 :  faster x7   (3942420 -> 532503)
ARGB8888 -> BGRA8888 :  faster x7   (3995382 -> 527722)
ARGB8888 -> RGBA8888 :  faster x7   (4259330 -> 543033)

BGRA8888 -> ABGR8888 :  faster x7   (4110411 -> 529402)
BGRA8888 -> ARGB8888 :  faster x7   (4071906 -> 538393)
BGRA8888 -> RGBA8888 :  faster x6   (4038320 -> 585141)

RGBA8888 -> ABGR8888 :  faster x7   (3937018 -> 534127)
RGBA8888 -> ARGB8888 :  faster x7   (3979577 -> 537810)
RGBA8888 -> BGRA8888 :  faster x7   (3975656 -> 528355)
2019-02-07 15:12:17 +01:00
Sylvain Becker
670f3d3327 Fixed bug 4484 - use SIMD aligned memory for SDL_Surface
Surfaces are allocated using SDL_SIMDAlloc()
They are marked with SDL_SIMD_ALIGNED flag to appropriatly free them with SDL_SIMDFree()
(Flag is cleared when pixels is free'd in RLE, in case user would hijack the pixels ptr)

When providing its own memory pointer (SDL_CreateRGBSurfaceFrom()) and clearing
SDL_PREALLOC  to delegate to SDL the memory free, it's the responsability of the user
to add SDL_SIMD_ALIGNED or not, whether the pointer has been allocated with SDL_malloc() or
SDL_SIMDAlloc().
2019-02-04 09:11:07 +01:00
Sylvain Becker
9292dc7ca1 Fix include path compilation 2019-02-04 08:43:37 +01:00
Sylvain Becker
9a98dcc516 Rename surface aligned memory flag to SDL_SIMD_ALIGNED 2019-02-04 08:34:24 +01:00
Sylvain Becker
e5d194e902 Add SDL_MEMALIGNED flag for SDL_Surface using aligned memory.
If an SDL_Surface has an aligned memory pointers, it should be freed
using SDL_SIMDFree() (will be used by SDL_ttf).
2019-01-31 11:45:31 +01:00
Sylvain Becker
7b8bac5958 Add fast paths in BlitNtoNKey
All following conversions are faster (with colorkey, but no blending).
(ratio isn't very accurate)

ABGR8888 -> BGR888 :  faster x9   (2699035 -> 297425)

ARGB8888 -> RGB888 :  faster x8   (2659266 -> 296137)

BGR24 -> BGR24 :  faster x5   (2232482 -> 445897)
BGR24 -> RGB24 :  faster x4   (2150023 -> 448576)

BGR888 -> ABGR8888 :  faster x8   (2649957 -> 307595)

BGRA8888 -> BGRX8888 :  faster x9   (2696041 -> 297596)

BGRX8888 -> BGRA8888 :  faster x8   (2662011 -> 299463)
BGRX8888 -> BGRX8888 :  faster x9   (2733346 -> 295045)

RGB24 -> BGR24 :  faster x4   (2154551 -> 485262)
RGB24 -> RGB24 :  faster x4   (2149878 -> 484870)

RGB888 -> ARGB8888 :  faster x8   (2762877 -> 324946)

RGBA8888 -> RGBX8888 :  faster x8   (2657855 -> 297753)

RGBX8888 -> RGBA8888 :  faster x8   (2661360 -> 296655)
RGBX8888 -> RGBX8888 :  faster x8   (2649287 -> 308268)
2019-01-30 22:50:20 +01:00
Sylvain Becker
cd25c83aad Fix blit with blending (Blit_A) to RGB332 which has no palette 2019-01-30 17:16:08 +01:00
Sylvain Becker
5b07148f73 Fixed failing SDL_ConvertSurface() when blit has failed.
Some blit combination are not supported (eg ARGB8888 -> SDL_PIXELFORMAT_INDEX1MSB)
So prevent SDL_ConvertSurface from creating a broken surface, which cannot be blitted
2019-01-30 16:36:47 +01:00
Sylvain Becker
a052d81bdf Add explicit unsigned int and char types in (for bug 4290) 2019-01-30 15:31:07 +01:00
Sylvain Becker
1128d57316 Fixed bug 4290 - add fastpaths for format conversion in BlitNtoN
All following conversion are faster (no colorkey, no blending).
(ratio isn't very accurate)

ABGR8888 -> ARGB8888 :  faster x6   (2655837 -> 416607)
ABGR8888 -> BGR24 :  faster x7   (2470117 -> 325693)
ABGR8888 -> RGB24 :  faster x7   (2478107 -> 335445)
ABGR8888 -> RGB888 :  faster x9   (3178524 -> 333859)

ARGB8888 -> ABGR8888 :  faster x6   (2648366 -> 406977)
ARGB8888 -> BGR24 :  faster x7   (2474978 -> 327819)
ARGB8888 -> BGR888 :  faster x9   (3189072 -> 326710)
ARGB8888 -> RGB24 :  faster x7   (2473689 -> 324729)

BGR24 -> ABGR8888 :  faster x6   (2268763 -> 359946)
BGR24 -> ARGB8888 :  faster x6   (2306393 -> 359213)
BGR24 -> BGR888 :  faster x6   (2231141 -> 324195)
BGR24 -> RGB24 :  faster x4   (1557835 -> 322033)
BGR24 -> RGB888 :  faster x6   (2229854 -> 323849)

BGR888 -> ARGB8888 :  faster x8   (3215202 -> 363137)
BGR888 -> BGR24 :  faster x7   (2474775 -> 347916)
BGR888 -> RGB24 :  faster x7   (2532783 -> 327354)
BGR888 -> RGB888 :  faster x9   (3134634 -> 344987)

RGB24 -> ABGR8888 :  faster x6   (2229486 -> 358919)
RGB24 -> ARGB8888 :  faster x6   (2271587 -> 358521)
RGB24 -> BGR24 :  faster x4   (1530913 -> 321149)
RGB24 -> BGR888 :  faster x6   (2227284 -> 327453)
RGB24 -> RGB888 :  faster x6   (2227125 -> 329061)

RGB888 -> ABGR8888 :  faster x8   (3163292 -> 362445)
RGB888 -> BGR24 :  faster x7   (2469489 -> 327127)
RGB888 -> BGR888 :  faster x9   (3190526 -> 326022)
RGB888 -> RGB24 :  faster x7   (2479084 -> 324982)
2019-01-30 15:23:33 +01:00
Charlie Birks
6d89a7bc71 Emscripten: remove GLES_DeleteContext implementation
It was calling glClear without a context. The issue it was trying to
solve was actually that after destroying a window and creating a new one
, the contents of the old window were preserved. This no longer happens
since we resize the window to nothing on destroy.
2019-01-29 12:19:32 +00:00
Charlie Birks
04b1494cf8 Emscripten: resize canvas to 0x0 in DestroyWindow
Closest we can get to actually destroying it
2019-01-29 12:19:23 +00:00
Charlie Birks
d60546aaa8 Emscripten: don't zero the display mode before adding it 2019-01-29 12:19:06 +00:00
Charlie Birks
4a2888af10 Emscripten: use UTF8ToString instead of Pointer_stringify 2019-01-29 12:19:03 +00:00
Charlie Birks
8dab9c956f Emscripten: Use set_canvas_element_size
This will be needed for supporting multiple canvases and set_canvas_size
is deprecated anyway.
2019-01-29 12:18:56 +00:00
kichikuou
ed66a430c9 Emscripten: Do not consume mouseup event outside of the canvas 2019-01-29 12:14:54 +00:00
Sylvain Beucler
2838abb5b2 Emscripten: fix duplicate mousebuttonup/mousebuttondown events when touch events are disabled 2019-01-29 12:14:44 +00:00
Charlie Birks
1767d09187 Emscripten: use a fake size for external sizing check
The check would fail if the canvas happened to be the correct size
already. (#66, mentioned in #58)
2019-01-29 12:14:41 +00:00
Charlie Birks
80d690a2a0 Emscripten: reset fullscreen_window when leaving fullscreen
If the browser left fullscreen mode by the user pressing ESC, the next
call to SDL_SetWindowFullscreen(1) will fail as it thinks the window is
already fullscreen. (#65)
2019-01-29 12:14:33 +00:00
Sylvain Becker
d984f323fc Fixed bug 3827 - issue with MapRGB, palette and colorkey
For palette surface, SDL_MapRGB() returns different values whether colorkey is
set or not.
2019-01-21 19:53:06 +01:00
Sylvain Becker
2bd26b8da8 Fixed bug 3827 - issue with MapRGB, palette and colorkey
For a palettized surface, prevent SDL_MapRGB() value to change whether colorkey is set or not.
2019-01-21 18:45:15 +01:00
Sam Lantinga
61827c6d1a Fixed compiler warning on Android 2019-01-20 12:02:12 -08:00
Sylvain Becker
e5f8801f55 Android: prevent concurrency in Android_SetScreenResolution() when exiting
by checking Android_Window validity

- SDLThread: user application is exiting:
    SDL_VideoQuit() and clearing SDL_GetVideoDevice()

- ActivityThread is changing orientation/size
    surfaceChanged() > Android_SetScreenResolution() > SDL_GetVideoDevice()

- Separate function into Android_SetScreenResolution() and Android_SendResize(),
    formating, and mark Android_DeviceWidth/Heigh as static
2019-01-17 11:05:05 +01:00
Sylvain Becker
e994be5833 Android: move static variable isPaused/isPausing to SDL_VideoData structure
- remove unneed check to Android_Window->driverdata
- add window check into context_backup/restore
2019-01-16 10:31:51 +01:00
Sylvain Becker
dc263450ff Android: create Pause/ResumeSem semaphore at higher level than CreateWindow()
- If you call onPause() before CreateWindow(), SDLThread will run in infinite loop in background.

- If you call onPause() between a DestroyWindow() and a new CreateWindow(), semaphores are invalids.

SDLActivity.java: the first resume() starts the SDLThread, don't call
nativeResume() as it would post ResumeSem. And the first pause would
automatically be resumed.
2019-01-14 23:33:48 +01:00
Sylvain Becker
955d87894b Android/openslES: set audio in paused/resumed state for Android event loop
And also in "stopped" state before closing the device.
2019-01-14 12:33:29 +01:00
Sam Lantinga
fb8cb95fbc Fixed compiler warning 2019-01-12 12:12:43 -08:00
Sylvain Becker
7a1d1baefc Android: add name for Touch devices and simplification, from bug 3958 2019-01-10 21:40:57 +01:00
Sylvain Becker
02f292eb13 Android: add some SetError for Android_SetWindowFullscreen
First error could happen if Android_SetWindowFullscreen somehow gets
called between SurfaceDestroyed() and SurfaceCreated()

Second error should not happen has native_window validity is guaranteed.
(It would happens previously with error -19)
2019-01-09 22:49:49 +01:00
Sylvain Becker
1803944bb2 Android: concurrency issue for Android_SetWindowFullscreen()
It accesses data->native_window, which can be changed by onNativeSurfacedChanged().

Currently, Android_SetWindowFullscreen() may access data->native_window after it
has been released, and before a new reference is acquired.

(can be reproduced by adding some SDL_Delay() in onNativeSurfacedChanged and
Android_SetWindowFullscreen() ).
2019-01-09 15:18:41 +01:00
Sylvain Becker
462e62e154 Android: better fix for bug 3186. Run those commands from SDL thread. 2019-01-06 20:25:54 +01:00
Sylvain Becker
e4f558a50c Android: un-needed check of "isPausing" and minor typos 2019-01-05 22:46:52 +01:00
Sylvain Becker
35722b6423 Android: fix wrong state after immediate sequence pause() / resume() / pause()
It may happen to have the sequence pause()/resume()/pause(), before polling
any events.

Before, it ends in 'resumed' state because as the check is greedy.
Now, always increase the Pause semaphore, and stop at each pause.
It ends in 'paused' state.

Related to bug 3250: set up a reconfiguration of SurfaceView holder.
Turn the screen off manually before the app starts
(repro rate is not 100%..)
2019-01-05 22:27:25 +01:00
Sam Lantinga
d4c0f498db Fixed bug 4255 - SDL_GetGlobalMouseState() returns incorrect Y on secondary display
Julian Raschke

I use an open Mac laptop with an additional external monitor. The coordinate spaces from SDL_GetGlobalMouseState() and SDL_GetWindowPosition() match on the primary display, but not on the secondary display.

Cocoa window coordinates are vertically flipped in relation to the primary display:

https://github.com/spurious/SDL-mirror/blob/release-2.0.8/src/video/cocoa/SDL_cocoawindow.m#L219-L222

However, Cocoa_GetGlobalMouseState inverts the cursor Y coordinate per-display:

https://github.com/spurious/SDL-mirror/blob/release-2.0.8/src/video/cocoa/SDL_cocoamouse.m#L320-L323

Suggested fix: Replace the for-loop with this simpler calculation:

    *x = (int) cocoaLocation.x;
    *y = (int) (CGDisplayPixelsHigh(kCGDirectMainDisplay) - cocoaLocation.y);
2019-01-04 22:09:38 -08:00
Sam Lantinga
5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Sylvain Becker
2a885eb036 Android: fixed immediate transition to pause and resume.
"Pause" transition will add events:
 SDL_WINDOWEVENT_ENTER
 SDL_WINDOWEVENT_FOCUS_LOST
 SDL_WINDOWEVENT_MINIMIZED
 SDL_APP_WILL ENTER BACKGROUND
 SDL_APP_DID ENTER BACKGROUND

"Resume" transition will add events:
 SDL_APP_WILL ENTER FOREGROUND
 SDL_APP_DID ENTER FOREGROUND
 SDL_WINDOWEVENT_FOCUS_GAINED
 SDL_WINDOWEVENT_RESTORED

If Android application doesn't empty the event loop in between, it enters in
"paused" state when SDL_WINDOWEVENT_RESTORED is fetched.

See bug 3250 for pratical case.
2019-01-04 23:39:27 +01:00
Sylvain Becker
cf12234454 Android: make Android_PumpEvents() more readable
No behavior change in this commit.
2019-01-04 23:11:21 +01:00
Sylvain Becker
ca184ac386 Android: concurrency issue with egl_surface EGL_BAD_SURFACE - (bug 4142)
Occurs when application goes to background:
- Java activity is destroying SurfaceView holder and "egl_surface" (in onNativeSurfaceDestroyed())
- While native thread is in Android_GLES_SwapWindow(), prepared to call SDL_EGL_SwapBuffers()

The error is "call to eglSwapBuffers failed, reporting an error of EGL_BAD_SURFACE"

It an be reproduced easily by adding a SDL_Delay(100) at the begining of SDL_EGL_SwapBuffers(),
and putting the application into background.
2019-01-03 23:22:50 +01:00
Sylvain Becker
2e19343df6 Android: use Mutex instead of Semphore for bug 4142 2019-01-03 20:18:29 +01:00
Sylvain Becker
23478642bd Android: prevent the error message from SDL_EGL_CreateSurface() to be masked. 2019-01-03 16:22:33 +01:00
Sylvain Becker
cc8f1136b6 Fixed bug 4142 - Concurrency issues in Android backend
Use a semaphore to prevent concurrency issues between Java Activity and Native thread code, when using 'Android_Window'.
(Eg. Java sending Touch events, while native code is destroying the main SDL_Window. )
2019-01-03 14:18:06 +01:00
Sylvain Becker
d11f7615fa Android: minor preparation for bug 4142 (concurrency issues) 2019-01-03 13:38:33 +01:00
Sylvain Becker
5dc25fef3b Android: preparation bug 4142, reduce usage of global variable Android_Window 2019-01-03 13:14:16 +01:00
Sylvain Becker
a95f91bcea Fixed bug 3250 - Wrong backbuffer pixel format on Android, keep getting RGB_565
Use the egl format to reconfigure java SurfaceView holder format.
If there is a change, it triggers a surfaceDestroyed/Created/Change sequence.
2019-01-02 18:06:33 +01:00
Ryan C. Gordon
13869f194c cocoa: Implement OpenGL swap interval support with CVDisplayLink.
Not only does this fix macOS 10.14 ("Mojave")'s broken NSOpenGLCPSwapInterval
support, it also lets us implement "adaptive vsync" on macOS!

CVDisplayLink is supported back to macOS 10.4 ("Tiger"), so we just use it
universally without version checks and dump NSOpenGLCPSwapInterval, Mojave or
not.
2018-12-16 01:03:17 -05:00
Sylvain Becker
1ed6021960 Fixed bug 4426 - allows re-creation of software renderer
Switching between renderers "software -> opengl -> opengles2 -> software" fails.

"opengl -> opengles2" calls SDL_RecreateWindow() and frees "window->surface"
without marking it as "surface_invalid".
2018-12-15 16:21:24 +01:00
Sam Lantinga
bd08d72dec Fixed building with the 10.10 SDK 2018-12-11 20:04:10 -08:00
Sam Lantinga
1c9595b16f Fixed bug 4415 - SDL menu bar is nonstandard on Mac
foo.null

I'm on macOS 10.14 and I think I'm using or around SDL 2.0.9. This is about the menu bar that SDL sets up which looks like:

<App Name> <Window> <View>

1. View menu never proceeds after the Window menu in any Mac application (it is always before).
2. For SDL, the only purpose of the View menu is for a single fullscreen menu item, which is not justifiable enough to reserve space for a menu. The View menu should thus be removed, and the full screen menu item should be added at the end inside of Window's menu. See built in apps like Dictionary, Chess, App Store (on 10.14) that do this.
3. SDL should add a "Close" menu item to the Window's submenu, and it should be the first item. Its key equivalent should map to command w. Without this, you cannot close the game window via this shortcut, and you cannot close the app's About window via this shortcut.
4. Apps typically use "Enter Full Screen" or "Exit Full Screen" depending on context, not "Toggle Full Screen" which is less user friendly -- I personally care about this point the least.
2018-12-08 11:06:40 -08:00
Brandon Schaefer
f9192ab8fc wayland: Do not try to lock on an invalid pointer
This happens if you try to lock the pointer and (caps & WL_SEAT_CAPABILITY_POINTER) is false
Leading to input->pointer being NULL which ends up bringing the wayland client down (at lease on weston)
2018-12-06 10:39:33 -05:00
Sylvain Becker
252dc85e95 Fix warnings detected on Android build 2018-12-06 09:22:00 +01:00
Ryan C. Gordon
2878d4f80c egl: Don't force X11 support when testing for EGL.
Fixes building Wayland support on embedded systems without X11.

(TODO: maybe move the EGL test out of the X11 tests at some point, too.)
2018-12-05 16:53:15 -05:00
Ryan C. Gordon
bd3ee07c83 wayland: Send SDL_TOUCH_MOUSEID mouse events for touches. 2018-12-05 16:49:38 -05:00
Ryan C. Gordon
65a7c98c6f directfb: Updated render backend to new internal API.
Totally untested, beyond it now compiles again. Probably needs some fixes.

Fixes Bugzilla #4405.
2018-12-02 02:33:06 -05:00
Sergey Zhuravlevich
583f61b202 kmsdrm: Check for resources when validating KMSDRM device in check_modesetting.
Fixes Bugzilla #4403.
2018-12-01 16:31:56 -05:00
Sergey Zhuravlevich
b3ac87d559 kmsdrm: uninitialized KMSDRM fixes
* Search for valid encoder in connector when it doesn't have an
   encoder ID set.

 * Search for valid CRTC in resources and encoder's possible CRTCs
   when encoder doesn't have one set.

 * Select default mode if CRTC doesn't have a valid one.

 * Pick current_mode's W/H/Refresh Rate basing on current and
   valid CRTC mode, not the saved one.
2018-12-01 13:09:00 -05:00
Ryan C. Gordon
c4bc59a50e Patched to compile on Linux with --disable-threads.
Fixes Bugzilla #4393.
2018-12-01 10:36:26 -05:00
Sam Lantinga
a95291c9c8 Fixed the hotspot for cursors on Raspberry Pi 2018-11-27 11:16:04 -08:00
Sam Lantinga
aea483577a Fixed bug changing cursors on Raspberry Pi 2018-11-27 10:20:29 -08:00
Sebastian Krzyszkowiak
5f98051457 wayland: ask xdg-decoration protocol extension to use server-side decorations if possible. 2018-11-04 21:08:40 +01:00
Sam Lantinga
5c5ba0e331 Fixed bug 4394 - Crash in SDL_PumpEvents() after SDL_DestroyWindow()
Cameron Gutman

After updating to SDL 2.0.9, I got a user report that my app was crashing when closing a SDL_WINDOW_FULLSCREEN window to return to my Qt-based UI. It looks like the dead SDL window is getting a spurious updateLayer call which is causing SDL to dereference a null SDL_WindowData pointer.

For some reason, this only happens when using SDL_WINDOW_FULLSCREEN and not windowed or SDL_WINDOW_FULLSCREEN_DESKTOP. I was also unsuccessful in my attempt to get a simple reproducer for this crash. The Session.cpp code is available 688c4a90d9/app/streaming/session.cpp but I slightly modified it (adding a SDL_PumpEvents() call at 1179 to immediately trigger the issue, otherwise it happened when Qt next pumped the event loop).

The crashing line is:

    NSMutableArray *contexts = data->nscontexts;
2018-11-19 21:35:59 -08:00
Alex Szpakowski
c525ff354d cocoa: fix building with the macOS 10.7 SDK (thanks Riccardo!)
Fixes bug #4368
2018-11-10 20:56:23 -04:00
Alex Szpakowski
5029d50ea8 Add SDL_TouchDeviceType enum and SDL_GetTouchDeviceType(SDL_TouchID id).
Touch device types include SDL_TOUCH_DEVICE_DIRECT (a touch screen with window-relative coordinates for touches), SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE (a trackpad-style device with absolute device coordinates), and SDL_TOUCH_DEVICE_INDIRECT_RELATIVE (a trackpad-style device with screen cursor-relative coordinates).

Phone screens are an example of a direct device type. Mac trackpads are the indirect-absolute touch device type. The Apple TV remote is an indirect-relative touch device type.
2018-11-10 16:15:48 -04:00
Sam Lantinga
9665a50891 Added Vulkan headers version 1.1.91
Downloaded from https://github.com/KhronosGroup/Vulkan-Headers
2018-11-06 16:57:07 -08:00
Sebastian Krzyszkowiak
48917e0e70 wayland: fix resizing and fullscreen toggling
For starters, we need to correctly respond to 0,0 configure after unsetting
fullscreen. Also, turns out that there should be no drawing calls at all
in between eglSwapBuffers and wl_egl_window_resize, as otherwise EGL can
already allocate a wrongly sized buffer for a next frame, so handle those
together.
2018-11-07 01:08:35 +01:00
Ryan C. Gordon
bc57ac27f9 mir: Removed mir client support.
Fixes Bugzilla #4288.
2018-11-02 21:34:17 -04:00
Ryan C. Gordon
4659e73892 merge fallout: Patched to compile, fixed some compiler warnings, etc. 2018-11-01 12:31:45 -04:00
Ryan C. Gordon
62494a2e27 Merge SDL-ryan-batching-renderer branch to default. 2018-10-31 15:03:41 -04:00
Ryan C. Gordon
a5ebd4d775 wayland: ask KDE protocol extension to use server-side decorations if possible. 2018-10-29 10:14:59 -04:00
Sam Lantinga
aeee424f65 Fixed bug 4349 - SDL_CreateWindow fails with KMS/DRM after upgrading Mesa to 18.2.3
Rainer Sabelka

After I did an upgrade of my arch Linux installation (resulting in an update of Mesa to version 18.2.3), all my SDL2 applications which use the KMS/DRM driver stopped working.
Reason: Creating a Window with SDL_CreateWindow failed because the call to EGL
eglCreateWindowSurface() returns an error "EGL_BAD_MATCH".
After investigating with the debugger I figured, that the configuration, which has been selected from the output of eglChooseConfig(), has an "EGL_NATIVE_VISUAL_ID" which does not match the "format" of the underlying gbm surface.

The attached patch fixes the problem. It does so, by mimicking Weston's behavior.
All configurations returned from eglChooseConfig() which have an visual_id different from the gbm format are discarded, and only from the remaining ones the "best" match is selected.
2018-10-31 15:16:51 -07:00
Micha? Janiszewski
91820998fc Add and update include guards
Include guards in most changed files were missing, I added them keeping
the same style as other SDL files. In some cases I moved the include
guards around to be the first thing the header has to take advantage of
any possible improvements compiler may have for inclusion guards.
2018-10-28 21:36:48 +01:00
Ryan C. Gordon
1ec56f7302 x11: Fixed incorrect function signature for XkbSetDetectableAutoRepeat.
It needs to use Bool (which is an int) and not BOOL (which is CARD8), which
causes problems on platforms with different byte order and alignment, etc.

Fixes Bugzilla #4326.
2018-10-20 21:35:48 -04:00
Ryan C. Gordon
1fb20f0ab9 cocoa: Put a mutex around GL_SwapBuffers.
Prevents deadlock when swapping two different GL contexts on two different
threads at the same time on macOS 10.14 ("Mojave").

Fixes Bugzilla #4278.
2018-10-18 23:38:27 -04:00
Ryan C. Gordon
cad0a2f730 cocoa: Fix OpenGL rendering on macOS 10.14 ("Mojave").
Fixes Bugzilla #4272.
(transplanted from 54729119b348e8a4a916192d1d6cb8d115656255)
2018-10-18 12:05:05 -04:00
Ryan C. Gordon
072e17bf98 cocoa: GL_GetDrawableSize only uses -[NSView convertRectToBacking] for highDPI.
On Mojave, this will report large numbers for retina displays in fullscreen
mode, which isn't how it works on previous versions.
(transplanted from c6c1731780e2bef94f944a4795e2dfbba46d9500)
2018-10-18 11:59:48 -04:00
Ryan C. Gordon
b262b0ebc9 Small stack allocations fall back to malloc if they're unexpectedly large. 2018-10-22 20:50:32 -04:00
Ryan C. Gordon
22475bf3f0 cocoa: Force an OpenGL context update when the window becomes key.
Fixes missing rendering on macOS 10.14 ("Mojave").

Fixes Bugzilla #4272.
(transplanted from aee4797c84ef90464e270b1f6095a6dd7ce280c1)
2018-09-26 20:10:32 -04:00
Sam Lantinga
404ba5eea8 Fixed bug 4229 - Add support for ABGR format in DirectFB renderer
Alexandre

DirectFB supports 32-bit ABGR pixel format via DSPF_ABGR, but SDL doesn't map SDL_PIXELFORMAT_ABGR8888 to DSPF_ABGR.

A patch is attached and should add support for ABGR pixel format devices.
2018-08-28 13:37:11 -07:00
Sam Lantinga
a1ca84411e Update the cursor clipping each frame, in case it was stolen by another application. 2018-08-26 20:37:23 -07:00
Sam Lantinga
15b3794f11 Only reset the clip rect if it's currently the rect we previously clipped.
This prevents us from clearing the clip rect globally when another application has set it.

There's also an experimental change to regularly update the clip rect for a window defensively, in case someone else has reset it. It works well, but I don't know if it's cheap enough to call as frequently as it would be called now, and might have other undesirable side effects.

Also fixed whitespace and SDL coding style
2018-08-26 10:34:23 -07:00
Jeremy Ong
a794126d56 vulkan: SDL_Vulkan_GetInstanceExtensions should accept a NULL window.
Fixes Bugzilla #4235.
2018-08-24 09:49:48 -04:00
Thomas Perl
84e7832018 Fix "unresponsible application" issues in Wayland
Polling without wl_display_flush() never responds to ping requests.
In that case ping-pong works only on other events, such as user input
or on frame swapped.

From https://git.merproject.org/mer-core/libsdl/merge_requests/3
Original author: Alexander Akulich <a.akulich@omprussia.ru>
2018-08-23 14:47:38 +02:00
Ryan C. Gordon
f677377339 cocoa: Fix OpenGL rendering on macOS 10.14 ("Mojave").
Fixes Bugzilla #4272.
2018-10-18 12:05:05 -04:00
Ryan C. Gordon
eac3fd28d8 cocoa: GL_GetDrawableSize only uses -[NSView convertRectToBacking] for highDPI.
On Mojave, this will report large numbers for retina displays in fullscreen
mode, which isn't how it works on previous versions.
2018-10-18 11:59:48 -04:00
Ryan C. Gordon
dae4a01361 x11: Don't hardcode limit on lines of text in message boxes.
Plus other text parsing fixes.

Fixes Bugzilla #4306.
2018-10-15 00:46:43 -04:00
Alex Szpakowski
e2ad654f2e iOS: Don't ignore the requested alpha bit size when determining whether to use an RGBA8 backbuffer. 2018-10-14 17:26:10 -03:00
Charlie Birks
cd63709ed8 Emscripten: Load eglQueryString and eglGetError
This prevents an assertion on context creation failure (calling a null
function pointer).
2018-10-13 17:18:59 +01:00
Alex Szpakowski
d8022d19b4 macOS: Fixed MoltenVK dynamic library loading code. 2018-10-12 23:23:52 -03:00
Alex Szpakowski
d9094421e1 metal: Fix high dpi and resizing on macOS, and clean up iOS code. Fixes bug #4250. 2018-10-12 17:55:42 -03:00
Cameron Gutman
eff5f65096 Implement SuspendScreenSaver for Win32
Creating a full-screen SDL renderer on Windows will keep the screensaver
suspended by DirectX, as is default for full-screen DX applications. However,
for applications that render in windowed-mode, the screensaver will
still kick in, even if SDL_DisableScreenSaver() is called or
SDL_HINT_VIDEO_ALLOW_SCREENSAVER is set to 0 (default). Implementing
a SuspendScreenSaver() function for Win32 fixes this behavior.
2018-10-09 23:01:43 -07:00
Ryan C. Gordon
88b3252555 kmsdrm: find available card if called without index.
This work was done by Michael Grzeschik, I just cleaned up the patch a little.

Fixes Bugzilla #4241.
2018-10-09 00:27:55 -04:00