Commit Graph

12898 Commits (6c2472d459602eb3c3ee109d6e8f255336109673)

Author SHA1 Message Date
Alex Szpakowski 87ea39be84 Removed dead code (caught by Clang's static analyzer). 2016-01-09 17:41:09 -04:00
Ryan C. Gordon 1615b2e29d CMake: only set "-O3 -g" defaults if CMAKE_BUILD_TYPE wasn't set at all. 2016-01-08 07:32:51 -05:00
Ryan C. Gordon 06129f6de9 Fixed buildbot's static analysis script to enable assertions.
This removes false positives. Apparently someone forced the default CMake
builds to use -O3, turning these off by default.  :/
2016-01-08 07:21:15 -05:00
Ryan C. Gordon ed62033366 x11: make last mouse coords sane upon window entry (thanks, Cengiz!).
(and thanks to Cengiz for many of the previous Unreal-related
patches! They were generically credited to Epic Games, but a large
amount of that work was his contribution.)

Fixes Bugzilla #3067.
2016-01-07 19:58:00 -05:00
Sam Lantinga 757e994eaa Fixed --enable-new-dtags check with cmake 2016-01-07 17:21:50 -08:00
Sam Lantinga dc5f05bb99 Use --enable-new-dtags to set RUNPATH rather than RPATH so that LD_LIBRARY_PATH is not overridden by the application. 2016-01-07 16:42:30 -08:00
Ryan C. Gordon 73680ab374 Fixed NULL dereference on drop events with no window associated.
(such as when dropping a file onto an app's icon to launch.)

This bug caught by Clang's static analyzer.
2016-01-07 16:01:24 -05:00
Sam Lantinga 1c4c3f505f Updated debian packaging files 2016-01-07 12:01:51 -08:00
Ryan C. Gordon 5dcf6bcc32 Updated dynamic API table. 2016-01-07 14:51:22 -05:00
Ethan Lee 167cf14c1f SDL_RenderSetIntegerScale 2016-01-05 16:39:18 -05:00
Ryan C. Gordon 416d046663 Mac: Implemented SDL_GetDisplayDPI (thanks, Kirill!).
Fixes Bugzilla #3223.
2016-01-07 14:02:37 -05:00
Philipp Wiesemann 1d1ba58f28 Fixed compile warnings about uninitialized variables in test library.
Found by buildbot.
2016-01-06 22:39:29 +01:00
Philipp Wiesemann a4ce22fbf3 Fixed outdated information in a README for iOS.
Four of the listed programs do not exist anymore.
2016-01-06 22:39:04 +01:00
Philipp Wiesemann 1a26c0c838 Fixed doxygen warnings. 2016-01-06 22:38:35 +01:00
Ryan C. Gordon bb1e2bd0b5 CMake: Turned off Mac OS X rpath warning kludge.
Apparently CMake errors out if it doesn't know this policy, and we don't
otherwise require CMake 3.0 yet. Sigh.
2016-01-05 05:44:32 -05:00
Ryan C. Gordon 49e47688b4 Patched to compile on iOS. 2016-01-05 05:38:55 -05:00
Ryan C. Gordon 881ccccbcf Android: Fixed up drop events for new interface. 2016-01-05 05:31:33 -05:00
Ryan C. Gordon eeb899999f Patched to compile. 2016-01-05 05:22:35 -05:00
Ryan C. Gordon 7605ccf68a Use SDL's stdinc functions instead of C runtime calls. 2016-01-05 02:29:16 -05:00
Ryan C. Gordon dc532c70e8 Added SDL_WINDOWEVENT_TAKE_FOCUS.
This is for corner cases where a multi-window app is activated and wants to
make a decision about where focus should go.

This patch came from Unreal Engine 4's fork of SDL, compliments of Epic Games.
2016-01-05 02:27:50 -05:00
Eric Wing d77a55738b merged SDL 2.0.4 rc2 2015-06-21 04:04:14 -07:00
Philipp Wiesemann 4393a71110 Added missing file and folder to the release archive. 2015-06-20 11:15:37 +02:00
Sam Lantinga 36af63f0c0 Added the docs directory to the release archive 2015-06-20 00:25:28 -07:00
Sam Lantinga fb5732dc5c GCC is warning about global functions with the same name as variables in the code, when using -Wshadow.
This is a little ridiculous because we have no idea what functions a given platform will provide, so we'll disable -Wshadow for now.
2015-06-19 23:53:33 -07:00
Sam Lantinga 903df4afbd Use CLOCK_MONOTONIC_RAW, if available, which is not subject to adjustment by NTP 2015-06-19 23:49:00 -07:00
Sam Lantinga f71fa2f402 Android has clock_gettime() - thanks Michael Labbe! 2015-06-19 23:40:23 -07:00
Sam Lantinga 3426c99acf Cleaned up Xcode rules a little more 2015-06-19 23:32:37 -07:00
Sam Lantinga f6b788f095 Simplified Mercurial ignore rules for Xcode build products 2015-06-19 23:27:35 -07:00
Sam Lantinga d763a9f64d Fixed bug 2538 - SDL_SetTextureAlphaMod does not work with SDL_FlipMode or rotation in the software renderer
Adam M.

When setting a texture alpha mod other than 255 and also specifying a flip mode in the software renderer, the rendering fails. When the texture has an alpha channel, it becomes invisible when flipped. When the texture does not have an alpha channel, it is flipped but the colors are wrong: the alpha mod makes the texture darker rather than more translucent.

0) Initialize a software renderer.
1) Load 16-bit 565 or 32-bit texture.
2) Set texture blend mode to BLEND.
3) Set texture alpha mod to 150.
4) Draw the texture flipped horizontally and/or vertically.
2015-06-19 23:22:53 -07:00
Sam Lantinga b7ede6cc47 Fixed bug 1550 - SDL_RenderCopy/CopyEx in software should optionally render 8bit alpha
Adam M.

There are three problems in the code that I see.
1. SW_RenderCopyEx enables a color key on surface_scaled even if the source surface didn't have a color key.
2. SW_RenderCopyEx doesn't copy blend mode, color mod, or alpha mod from src to surface_scaled.
3. When SDL_BlitScaled(src, srcrect, surface_scaled, &tmp_rect) is called, it blends the src pixels into surface_scaled instead of overwriting them (if src has blending, etc. enabled).

I've attached a patch that 1) fixes the three problems that I mentioned, 2) adds the requested performance improvement of using the regular blit function if no rotation or flipping is needed, 3) avoids cloning the source surface if no stretching is required, and simplifies the rotation code slightly.
2015-06-19 23:20:43 -07:00
Sam Lantinga e589cdba2f Fixed bug 3023 - setting a white and then non-white texture color mod breaks the texture with software renderer
Adam M.

Okay, here is the problem, I think.

During the first blit, RLEAlphaSurface is called to do RLE conversion of the RGBA source into a format allowing it "to be quickly alpha-blittable onto dest". Since the destination is the screen, it has no alpha channel. RLEAlphaSurface calls copy_opaque(dst, src + runstart, len, sf, df) (where copy_opaque is copy_32), which has this code:

SDL_RLEaccel.c:984:
  RGBA_FROM_8888(*src, sfmt, r, g, b, a);
  PIXEL_FROM_RGBA(*d, dfmt, r, g, b, a);

On the first line, it reads the source pixel 0xFFFFFFFF. The second line drops the alpha value (because dfmt for the screen has no alpha channel) and writes 0x00FFFFFF. Later, when the RLE conversion is being undone, uncopy_32 is called, which has the following code:

SDL_RLEaccel.c:1001:
  Uint32 pixel = *s++;
  RGB_FROM_PIXEL(pixel, sfmt, r, g, b);
  a = pixel >> 24;
  PIXEL_FROM_RGBA(*dst, dfmt, r, g, b, a);

However, the the alpha channel has already been dropped by copy_opaque (= copy_32), so pixel = 0x00FFFFFF and 'a' becomes 0. Thus, all opaque pixels lose their alpha channel when being unRLE'd. (I don't know what happens to pixels with alpha from 1-254, but they should be checked too.)

So, that seems to be the problem, but I'm not sure what the solution should be. Since opaque pixels have alpha == 255, I'm thinking to create another uncopy function for opaque pixels that simply uses 255 for alpha.

However, there may be other problems here. For translucent pixels, uncopy_32 assumes the alpha channel is stored in the upper 8 bits, but copy_32 doesn't store it there. Instead, it stores it in whatever location is appropriate for the destination surface. Isn't one of their behaviors incorrect, given the other? I'm not sure which to change, however.

For translucent pixels, it seems that the blit function uses do_blend, which is the BLIT_TRANSL_888 macro, which also assumes alpha is in top 8 bits. It has the comment "we have made sure the alpha is stored in the top 8 bits...", but it seems that's not true (copy_32 doesn't make sure the alpha goes there).

Perhaps the correct fix is to make copy_32 put the alpha there, but then that seems to require that RLE conversion be limited to destination surfaces that don't use the upper 8 bits. However, looking further, it seems that has already been done: if (masksum != 0x00ffffff) return -1; /* requires unused high byte */
2015-06-19 23:12:13 -07:00
Sam Lantinga 82ae4f6fc5 [mq]: 3027_rleperf.diff 2015-06-19 22:12:47 -07:00
Philipp Wiesemann 21935b0313 Added more entries and brackets to WhatsNew.txt for 2.0.4. 2015-06-19 21:17:00 +02:00
Ryan C. Gordon 3a84f7b520 CMake fixes for MingW (thanks, Ozkan!).
- ignore DXSDK_DIR for mingw environment
- use dxerr8 instead of dxerr for mingw.

Partially fixes Bugzilla #3016.
2015-06-18 22:34:39 -04:00
Alex Szpakowski dd8c64779b Updated WhatsNew.txt's 2.0.4 list to include a more detailed set of changes for iOS, and added a couple missing items to the OS X and Windows sections. 2015-06-18 12:20:46 -03:00
Ryan C. Gordon 604932ea84 Moving some whitespace around to test something on the Mercurial server. 2015-06-18 00:44:57 -04:00
Eric Wing 27fab8f4bb merged SDL 2.0.4rc1+ 2015-06-17 20:03:08 -07:00
Philipp Wiesemann 1a348aac4f Android: Fixed two warnings. 2015-06-17 21:05:25 +02:00
Ryan C. Gordon 40244dc1a9 Whitespace fix. 2015-06-17 13:02:41 -04:00
Ryan C. Gordon d002d6bf9f Removed Edgar's name from SDL_haptic.h at his request. 2015-06-17 12:59:12 -04:00
Sam Lantinga 4598903548 Partial fix for bug 2758 - Android issues with NDK r10c and API-21
Sylvain

When using API 21 and running on an old device (android < 5.0 ?) some function are missing.

functions are (at least) : signal, sigemptyset, atof, stpcpy (strcat and strcpy), srand, rand.


Very few modifications on SDL to get this working :

on SDL
======

Undefine android configuration :

HAVE_SIGNAL
HAVE_SIGACTION
HAVE_ATOF

In "SDL_systrhead.c", comment out the few block of lines with "sigemptyset".

Android.mk:
remove the compilation of "test" directory because it contains a few rand/srand calls

Also, there are more discussions about this in internet :
https://groups.google.com/forum/#!topic/android-ndk/RjO9WmG9pfE
http://stackoverflow.com/questions/25475055/android-ndk-load-library-cannot-locate-srand
2015-06-17 00:07:45 -07:00
Sam Lantinga 3779bf3845 Fixed bug 2948 - [Android] Arrow keys from external keyboard are not received
Sylvain

http://developer.android.com/reference/android/view/InputDevice.html
 int SOURCE_CLASS_JOYSTICK   Constant Value: 16       (0x00000010)

 int SOURCE_JOYSTICK         Constant Value: 16777232 (0x01000010)
 int SOURCE_KEYBOARD         Constant Value: 257      (0x00000101)
 int SOURCE_GAMEPAD          Constant Value: 1025     (0x00000401)
 int SOURCE_DPAD             Constant Value:  513     (0x00000201)


I have an a PC keyboard that I connect to an android device.
The issue is that "arrow" keys gets lost.

More explanation:

This device gets detected twice by the java "pollInputDevices()" both as SOURCE_KEYBOARD and as a composite (0x1000311 == SOURCE_JOYSTICK | SOURCE_KEYBOARD | SOURCE_DPAD).
Because of being a SOURCE_CLASS_JOYSTICK, only the second entry is registered, and I opened it.


When I press one arrow key, the java method "onKey(...)" is called.
The Source "event.getSource()" is "SOURCE_KEYBOARD", so it enters this conditions :

   if ( (event.getSource() & InputDevice.SOURCE_GAMEPAD) != 0 ||
      (event.getSource() & InputDevice.SOURCE_DPAD) != 0 ) {


And then, it enters :

   SDLActivity.onNativePadDown() (native code in "SDL_sysjoystick.c")


Since the "arrows" are viewed as "D-PAD", it gets translated :

   int button = keycode_to_SDL(keycode);


But the android-java "event.getDeviceId()" is wrong: this is the one from the Keyboard, and not the one from the Joystick that I have opened.
So I don't get them through the Joystick interface.


And since, the keycode has been translated, it returns 0 and assume it was consumed.
So I lost the key in the function "Android_OnPadDown()"


Notice, It won't happen with other normal "letters" keys because they does not get translated by "keycode_to_SDL", so "Android_OnPadDown()" returns -1.
And then java code send the keys to "SDLActivity.onNativeKeyDown()".




Possible patch on "Android_OnPadDown" and also "Android_OnPadUp" (and maybe other functons):

85 int
186 Android_OnPadDown(int device_id, int keycode)
187 {
188     SDL_joylist_item *item;
189     int button = keycode_to_SDL(keycode);
190     if (button >= 0) {
191         item = JoystickByDeviceId(device_id);
192         if (item && item->joystick) {
193             SDL_PrivateJoystickButton(item->joystick, button , SDL_PRESSED);
194         }
+           else return -1;
195         return 0;
196     }
197
198     return -1;
199 }

It would allow the java caller function to send the key to "SDLActivity.onNativeKeyDown();"



Another solution, would be to replace:

 if ( (event.getSource() & InputDevice.SOURCE_GAMEPAD) != 0 ||
      (event.getSource() & InputDevice.SOURCE_DPAD) != 0 ) {

by

 if ( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0)

Because only "SOURCE_CLASS_JOYSTICK" devices are registered/opened.
2015-06-17 00:00:53 -07:00
Sam Lantinga 5db002bb1e Fixed bug 2949 - [Android] Virtual DPAD remote not registered
Sylvain

I have an android device to which I try to connect the google virtual remote application.
https://play.google.com/store/apps/details?id=com.google.android.tv.remote

The java method "pollInputDevices()" detects it as an input source 0x701 which is (SOURCE_KEYBOARD | SOURCE_GAMEPAD | SOURCE_DPAD).

It it not added because it does not AND-bitwise with "SOURCE_CLASS_JOYSTICK".
It's only a virtual DPAD and it works when checking also with SOURCE_CLASS_BUTTON
2015-06-16 23:58:09 -07:00
Sam Lantinga 33ed20fafa Fixed bug 2774 - Android: screen distorted in Landscape after background/foreground
Sylvain

With a Landscape application.
Going to background with Home Key, then foreground.
The screen is distorted.

This has been reported by Samsung. It happens on S5 and Samsung Alpha, see the video attached.

I have captured the following logcat:

V/SDL     (20549): onResume()
V/SDL     (20549): surfaceCreated()
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1920x1080
I/SDL     (20549): SDL_Android_Init()
I/SDL     (20549): SDL_Android_Init() finished!
V/SDL     (20549): SDL audio: opening device
V/SDL     (20549): SDL audio: wanted stereo 16-bit 22.05kHz, 256 frames buffer
V/SDL     (20549): SDL audio: got stereo 16-bit 22.05kHz, 1764 frames buffer
V/SDL     (20549): onWindowFocusChanged(): true
V/SDL     (20549): onWindowFocusChanged(): false
V/SDL     (20549): onPause()
V/SDL     (20549): nativePause()
V/SDL     (20549): surfaceDestroyed()

Background / Foreground

V/SDL     (20549): onResume()
V/SDL     (20549): surfaceCreated()
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1080x1920
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1920x1080
V/SDL     (20549): onWindowFocusChanged(): true
V/SDL     (20549): nativeResume()



This seems to be related to the fact that I have in "AndroidManifest.xml":
android:configChanges="..."
Because of the fields: "orientation" and also "screenSize".


I have looked for another way to solve the issue. Discarding the "surfaceChanged" call, based on the "requestedOrientation" and the new Orientation. It seems to be better.


On my failing test case, the first "surfaceChanged()" is discarded. Sometimes the "focusChanged()" might appear between the two "surfaceChanged()", while the surface is not yet ready. Thus, discarding also the "nativeResume()".

So, for robustness, a call to "nativeResume()" is added at the end of "surfaceChanged()".

Some update:

1/ First I tried, to discard the surface using the current orientation (rather than width / heigh). -> that solve the issue sometimes, but not always.

2/ Samsung Certification now accepts my application that were previously failing.

3/ I personally now owns a Samsung S5, and was able to solve the issue on my side.

4/ I now use the patch and get no complaints from my users. (but I admit, nobody seemed to be complaining before neither...).

5/ I have added a v2 because of a new smart-phone called "Black Berry Passport" that has a square screen of 1440x1440. This screen has a "status bar" so the resolution is in fact : 1440x1308. (as reported by "surfaceChanged").

Problem is: the portrait resolution is in fact a Landscape!

So the "v1" patch is always discarding the "surface" of BlackBerry Passport. Which is terribly bad.


Hence, I added the "v2" patch not to discard the surface when aspect ratio is < 1.20. (BB 1440/1308 is : 1.1009). Which seems fair.
2015-06-16 22:16:35 -07:00
Philipp Wiesemann d29812d092 Moved entry in WhatsNew.txt because it was already in 2.0.0 for Android and iOS. 2015-06-16 20:28:21 +02:00
Philipp Wiesemann 58efd8e547 Fixed comment in test program. 2015-06-16 20:27:01 +02:00
Philipp Wiesemann ae60afce16 Excluded SDL_egl.h from doxygen input. 2015-06-16 20:25:53 +02:00
Sam Lantinga 59d34bc35d Fixed bug 3015 - grab mouse inconsistent state
Martin Gerhardy

Not sure - but I think there might be a logic flaw in SDL_SetWindowGrab.

The problem here is that this modifies the window flags and e.g. sets
SDL_WINDOW_INPUT_GRABBED - but the _this->grabbed_window pointer is not
yet set.

Then in SDL_UpdateWindowGrab the _this->grabbed_window pointer is only
set if the function pointer _this->SetWindowGrab is not NULL. But if
this is NULL, the _this->grabbed_window pointer is never set, but every
future call to any of the grab functions include an assert for:
SDL_assert(!_this->grabbed_window || ((_this->grabbed_window->flags &
SDL_WINDOW_INPUT_GRABBED) != 0));

That means the first call works, the second always fails and triggers
the assert.
2015-06-15 23:44:08 -07:00
Colby Klein ccc12a3632 Implement repositioning the OS-rendered IME with SDL_SetTextInputRect on Windows. 2015-06-15 20:24:51 -07:00
Ryan C. Gordon 0c3830a9a9 Haptic/Linux: Keep track of device numbers properly to track duplicates.
Fixes Bugzilla #3014.
2015-06-16 00:57:45 -04:00