merged SDL 2.0.4 rc2
authorEric Wing <ewing . public |-at-| gmail . com>
Sun, 21 Jun 2015 04:04:14 -0700
changeset 110756a683bf1446c
parent 11074 3d681a44723a
parent 9770 2d9b36c5e49d
child 11076 d772a4dbeff5
merged SDL 2.0.4 rc2
src/render/SDL_render.c
     1.1 --- a/.hgignore	Wed Jun 17 20:03:08 2015 -0700
     1.2 +++ b/.hgignore	Sun Jun 21 04:04:14 2015 -0700
     1.3 @@ -9,8 +9,6 @@
     1.4  SDL2.spec
     1.5  build
     1.6  Build
     1.7 -*xcuserdata*
     1.8 -*xcworkspacedata*
     1.9  
    1.10  # for Xcode
    1.11  *.orig
    1.12 @@ -20,20 +18,12 @@
    1.13  *~
    1.14  *.o
    1.15  *.mode1*
    1.16 -*.model*
    1.17 -*.perspective*
    1.18  *.perspective*
    1.19  *.pbxuser
    1.20  (^|/)build($|/)
    1.21  .DS_Store
    1.22 -Xcode/SDL/SDL.xcodeproj/xcuserdata
    1.23 -Xcode/SDL/SDL.xcodeproj/project.xcworkspace
    1.24 -Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata
    1.25 -Xcode/SDLTest/SDLTest.xcodeproj/project.xcworkspace
    1.26 -Xcode-iOS/SDL/SDL.xcodeproj/xcuserdata
    1.27 -Xcode-iOS/SDL/SDL.xcodeproj/project.xcworkspace
    1.28 -Xcode-iOS/Demos/Demos.xcodeproj/xcuserdata
    1.29 -Xcode-iOS/Demos/Demos.xcodeproj/project.xcworkspace
    1.30 +xcuserdata
    1.31 +*.xcworkspace
    1.32  
    1.33  # for Visual C++
    1.34  Debug
     2.1 --- a/CMakeLists.txt	Wed Jun 17 20:03:08 2015 -0700
     2.2 +++ b/CMakeLists.txt	Sun Jun 21 04:04:14 2015 -0700
     2.3 @@ -900,10 +900,12 @@
     2.4  
     2.5    # Check for DirectX
     2.6    if(DIRECTX)
     2.7 -    if("$ENV{DXSDK_DIR}" STREQUAL "")
     2.8 -      message_error("DIRECTX requires the \$DXSDK_DIR environment variable to be set")
     2.9 +    if(NOT CMAKE_COMPILER_IS_MINGW)
    2.10 +      if("$ENV{DXSDK_DIR}" STREQUAL "")
    2.11 +        message_error("DIRECTX requires the \$DXSDK_DIR environment variable to be set")
    2.12 +      endif()
    2.13 +      set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
    2.14      endif()
    2.15 -    set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
    2.16      check_include_file(d3d9.h HAVE_D3D_H)
    2.17      check_include_file(d3d11_1.h HAVE_D3D11_H)
    2.18      check_include_file(ddraw.h HAVE_DDRAW_H)
    2.19 @@ -914,9 +916,11 @@
    2.20      check_include_file(dxgi.h HAVE_DXGI_H)
    2.21      if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
    2.22        set(HAVE_DIRECTX TRUE)
    2.23 +      if(NOT CMAKE_COMPILER_IS_MINGW)
    2.24        # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
    2.25 -      link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
    2.26 -      include_directories($ENV{DXSDK_DIR}\\Include)
    2.27 +        link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
    2.28 +        include_directories($ENV{DXSDK_DIR}\\Include)
    2.29 +      endif()
    2.30      endif()
    2.31      set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
    2.32    endif()
    2.33 @@ -1020,7 +1024,12 @@
    2.34      set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
    2.35      if(HAVE_DINPUT_H)
    2.36        set(SDL_JOYSTICK_DINPUT 1)
    2.37 -      list(APPEND EXTRA_LIBS dinput8 dxguid dxerr)
    2.38 +      list(APPEND EXTRA_LIBS dinput8 dxguid)
    2.39 +      if(CMAKE_COMPILER_IS_MINGW)
    2.40 +        list(APPEND EXTRA_LIBS dxerr8)
    2.41 +      else()
    2.42 +        list(APPEND EXTRA_LIBS dxerr)
    2.43 +      endif()
    2.44      endif()
    2.45      if(HAVE_XINPUT_H)
    2.46        set(SDL_JOYSTICK_XINPUT 1)
     3.1 --- a/Makefile.in	Wed Jun 17 20:03:08 2015 -0700
     3.2 +++ b/Makefile.in	Sun Jun 21 04:04:14 2015 -0700
     3.3 @@ -39,7 +39,7 @@
     3.4  SDLTEST_TARGET = libSDL2_test.a
     3.5  SDLTEST_OBJECTS = @SDLTEST_OBJECTS@
     3.6  
     3.7 -SRC_DIST = *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake configure configure.in debian include Makefile.* sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in src test VisualC.html VisualC Xcode Xcode-iOS
     3.8 +SRC_DIST = *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake cmake_uninstall.cmake.in configure configure.in debian docs include Makefile.* sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in src test VisualC.html VisualC VisualC-WinRT Xcode Xcode-iOS
     3.9  GEN_DIST = SDL2.spec
    3.10  
    3.11  ifneq ($V,1)
     4.1 --- a/WhatsNew.txt	Wed Jun 17 20:03:08 2015 -0700
     4.2 +++ b/WhatsNew.txt	Sun Jun 21 04:04:14 2015 -0700
     4.3 @@ -27,7 +27,10 @@
     4.4  * Added a Vivante video driver that is used on various SoC platforms
     4.5  * Added an event SDL_RENDER_DEVICE_RESET that is sent from the D3D renderers when the D3D device is lost, and from Android's event loop when the GLES context had to be recreated
     4.6  * Added a hint SDL_HINT_NO_SIGNAL_HANDLERS to disable SDL's built in signal handling
     4.7 +* Added a hint SDL_HINT_THREAD_STACK_SIZE to set the stack size of SDL's threads
     4.8 +* Added SDL_sqrtf(), SDL_tan(), and SDL_tanf() to the stdlib routines
     4.9  * Improved support for WAV and BMP files with unusual chunks in them
    4.10 +* Renamed SDL_assert_data to SDL_AssertData and SDL_assert_state to SDL_AssertState
    4.11  
    4.12  Windows:
    4.13  * Added support for Windows Phone 8.1
    4.14 @@ -39,11 +42,15 @@
    4.15  * SDL_SysWMinfo now contains the window HDC
    4.16  * Added support for Unicode command line options
    4.17  * Prevent beeping when Alt-key combos are pressed
    4.18 +* SDL_SetTextInputRect() re-positions the OS-rendered IME
    4.19  
    4.20  Mac OS X:
    4.21  * Implemented drag-and-drop support
    4.22  * Improved joystick hot-plug detection
    4.23 +* The SDL_WINDOWEVENT_EXPOSED window event is triggered in the appropriate situations
    4.24  * Fixed relative mouse mode when the application loses/regains focus
    4.25 +* Fixed bugs related to transitioning to and from Spaces-aware fullscreen-desktop mode
    4.26 +* Fixed the refresh rate of display modes
    4.27  * SDL_SysWMInfo is now ARC-compatible
    4.28  
    4.29  Linux:
    4.30 @@ -55,6 +62,14 @@
    4.31  
    4.32  iOS:
    4.33  * Added support for iOS 8
    4.34 +* Added support for the hint SDL_HINT_ACCELEROMETER_AS_JOYSTICK
    4.35 +* Added sRGB OpenGL ES context support on iOS 7+
    4.36 +* Added native resolution support for the iPhone 6 Plus
    4.37 +* The SDL_WINDOW_ALLOW_HIGHDPI window flag now enables high-dpi support, and SDL_GL_GetDrawableSize() or SDL_GetRendererOutputSize() gets the window resolution in pixels
    4.38 +* SDL_GetWindowSize() and display mode sizes are in the "DPI-independent points" coordinate space rather than pixels (matches OS X behavior)
    4.39 +* SDL_SysWMinfo now contains the OpenGL ES framebuffer and color renderbuffer objects used by the window's active GLES view
    4.40 +* Fixed various rotation and orientation issues
    4.41 +* Fixed memory leaks
    4.42  
    4.43  Android:
    4.44  * Added a hint SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH to prevent mouse events from being registered as touch events
     5.1 --- a/configure	Wed Jun 17 20:03:08 2015 -0700
     5.2 +++ b/configure	Sun Jun 21 04:04:14 2015 -0700
     5.3 @@ -18701,43 +18701,6 @@
     5.4      fi
     5.5  }
     5.6  
     5.7 -CheckWarnShadow()
     5.8 -{
     5.9 -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -Wshadow option" >&5
    5.10 -$as_echo_n "checking for GCC -Wshadow option... " >&6; }
    5.11 -    have_gcc_Wshadow=no
    5.12 -
    5.13 -    save_CFLAGS="$CFLAGS"
    5.14 -    CFLAGS="$save_CFLAGS -Wshadow"
    5.15 -    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    5.16 -/* end confdefs.h.  */
    5.17 -
    5.18 -    int x = 0;
    5.19 -
    5.20 -int
    5.21 -main ()
    5.22 -{
    5.23 -
    5.24 -
    5.25 -  ;
    5.26 -  return 0;
    5.27 -}
    5.28 -_ACEOF
    5.29 -if ac_fn_c_try_compile "$LINENO"; then :
    5.30 -
    5.31 -    have_gcc_Wshadow=yes
    5.32 -
    5.33 -fi
    5.34 -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
    5.35 -    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_Wshadow" >&5
    5.36 -$as_echo "$have_gcc_Wshadow" >&6; }
    5.37 -    CFLAGS="$save_CFLAGS"
    5.38 -
    5.39 -    if test x$have_gcc_Wshadow = xyes; then
    5.40 -        EXTRA_CFLAGS="$EXTRA_CFLAGS -Wshadow"
    5.41 -    fi
    5.42 -}
    5.43 -
    5.44  CheckWayland()
    5.45  {
    5.46      # Check whether --enable-video-wayland was given.
    5.47 @@ -23652,7 +23615,6 @@
    5.48  esac
    5.49  
    5.50  CheckWarnAll
    5.51 -CheckWarnShadow
    5.52  
    5.53  # Verify that we have all the platform specific files we need
    5.54  
     6.1 --- a/configure.in	Wed Jun 17 20:03:08 2015 -0700
     6.2 +++ b/configure.in	Sun Jun 21 04:04:14 2015 -0700
     6.3 @@ -1159,28 +1159,6 @@
     6.4      fi
     6.5  }
     6.6  
     6.7 -dnl See if GCC's -Wshadow is supported.
     6.8 -CheckWarnShadow()
     6.9 -{
    6.10 -    AC_MSG_CHECKING(for GCC -Wshadow option)
    6.11 -    have_gcc_Wshadow=no
    6.12 -
    6.13 -    save_CFLAGS="$CFLAGS"
    6.14 -    CFLAGS="$save_CFLAGS -Wshadow"
    6.15 -    AC_TRY_COMPILE([
    6.16 -    int x = 0;
    6.17 -    ],[
    6.18 -    ],[
    6.19 -    have_gcc_Wshadow=yes
    6.20 -    ])
    6.21 -    AC_MSG_RESULT($have_gcc_Wshadow)
    6.22 -    CFLAGS="$save_CFLAGS"
    6.23 -
    6.24 -    if test x$have_gcc_Wshadow = xyes; then
    6.25 -        EXTRA_CFLAGS="$EXTRA_CFLAGS -Wshadow"
    6.26 -    fi
    6.27 -}
    6.28 -
    6.29  dnl Check for Wayland
    6.30  CheckWayland()
    6.31  {
    6.32 @@ -3415,7 +3393,6 @@
    6.33  
    6.34  dnl Do this on all platforms, after everything else.
    6.35  CheckWarnAll
    6.36 -CheckWarnShadow
    6.37  
    6.38  # Verify that we have all the platform specific files we need
    6.39  
     7.1 --- a/docs/README-dynapi.md	Wed Jun 17 20:03:08 2015 -0700
     7.2 +++ b/docs/README-dynapi.md	Sun Jun 21 04:04:14 2015 -0700
     7.3 @@ -1,6 +1,7 @@
     7.4  Dynamic API
     7.5  ================================================================================
     7.6 -Originally posted by Ryan at https://plus.google.com/103391075724026391227/posts/TB8UfnDYu4U
     7.7 +Originally posted by Ryan at:
     7.8 +  https://plus.google.com/103391075724026391227/posts/TB8UfnDYu4U
     7.9  
    7.10  Background:
    7.11  
     8.1 --- a/include/SDL_config_android.h	Wed Jun 17 20:03:08 2015 -0700
     8.2 +++ b/include/SDL_config_android.h	Sun Jun 21 04:04:14 2015 -0700
     8.3 @@ -104,6 +104,7 @@
     8.4  #define HAVE_SETJMP 1
     8.5  #define HAVE_NANOSLEEP  1
     8.6  #define HAVE_SYSCONF    1
     8.7 +#define HAVE_CLOCK_GETTIME	1
     8.8  
     8.9  #define SIZEOF_VOIDP 4
    8.10  
     9.1 --- a/src/render/SDL_render.c	Wed Jun 17 20:03:08 2015 -0700
     9.2 +++ b/src/render/SDL_render.c	Sun Jun 21 04:04:14 2015 -0700
     9.3 @@ -1771,6 +1771,10 @@
     9.4      SDL_FRect frect;
     9.5      SDL_FPoint fcenter;
     9.6  
     9.7 +    if (flip == SDL_FLIP_NONE && angle == 0) { /* fast path when we don't need rotation or flipping */
     9.8 +        return SDL_RenderCopy(renderer, texture, srcrect, dstrect);
     9.9 +    }
    9.10 +
    9.11      CHECK_RENDERER_MAGIC(renderer, -1);
    9.12      CHECK_TEXTURE_MAGIC(texture, -1);
    9.13  
    10.1 --- a/src/render/software/SDL_render_sw.c	Wed Jun 17 20:03:08 2015 -0700
    10.2 +++ b/src/render/software/SDL_render_sw.c	Sun Jun 21 04:04:14 2015 -0700
    10.3 @@ -253,6 +253,12 @@
    10.4  SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
    10.5  {
    10.6      SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
    10.7 +    /* If the color mod is ever enabled (non-white), permanently disable RLE (which doesn't support
    10.8 +     * color mod) to avoid potentially frequent RLE encoding/decoding.
    10.9 +     */
   10.10 +    if ((texture->r & texture->g & texture->b) != 255) {
   10.11 +        SDL_SetSurfaceRLE(surface, 0);
   10.12 +    }
   10.13      return SDL_SetSurfaceColorMod(surface, texture->r, texture->g,
   10.14                                    texture->b);
   10.15  }
   10.16 @@ -261,6 +267,12 @@
   10.17  SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
   10.18  {
   10.19      SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
   10.20 +    /* If the texture ever has multiple alpha values (surface alpha plus alpha channel), permanently
   10.21 +     * disable RLE (which doesn't support this) to avoid potentially frequent RLE encoding/decoding.
   10.22 +     */
   10.23 +    if (texture->a != 255 && surface->format->Amask) {
   10.24 +        SDL_SetSurfaceRLE(surface, 0);
   10.25 +    }
   10.26      return SDL_SetSurfaceAlphaMod(surface, texture->a);
   10.27  }
   10.28  
   10.29 @@ -268,6 +280,12 @@
   10.30  SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
   10.31  {
   10.32      SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
   10.33 +    /* If add or mod blending are ever enabled, permanently disable RLE (which doesn't support
   10.34 +     * them) to avoid potentially frequent RLE encoding/decoding.
   10.35 +     */
   10.36 +    if ((texture->blendMode == SDL_BLENDMODE_ADD || texture->blendMode == SDL_BLENDMODE_MOD)) {
   10.37 +        SDL_SetSurfaceRLE(surface, 0);
   10.38 +    }
   10.39      return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
   10.40  }
   10.41  
   10.42 @@ -553,6 +571,10 @@
   10.43      if ( srcrect->w == final_rect.w && srcrect->h == final_rect.h ) {
   10.44          return SDL_BlitSurface(src, srcrect, surface, &final_rect);
   10.45      } else {
   10.46 +        /* If scaling is ever done, permanently disable RLE (which doesn't support scaling)
   10.47 +         * to avoid potentially frequent RLE encoding/decoding.
   10.48 +         */
   10.49 +        SDL_SetSurfaceRLE(surface, 0);
   10.50          return SDL_BlitScaled(src, srcrect, surface, &final_rect);
   10.51      }
   10.52  }
   10.53 @@ -578,7 +600,6 @@
   10.54      SDL_Surface *src = (SDL_Surface *) texture->driverdata;
   10.55      SDL_Rect final_rect, tmp_rect;
   10.56      SDL_Surface *surface_rotated, *surface_scaled;
   10.57 -    Uint32 colorkey;
   10.58      int retval, dstwidth, dstheight, abscenterx, abscentery;
   10.59      double cangle, sangle, px, py, p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y;
   10.60  
   10.61 @@ -596,66 +617,113 @@
   10.62      final_rect.w = (int)dstrect->w;
   10.63      final_rect.h = (int)dstrect->h;
   10.64  
   10.65 -    surface_scaled = SDL_CreateRGBSurface(SDL_SWSURFACE, final_rect.w, final_rect.h, src->format->BitsPerPixel,
   10.66 -                                          src->format->Rmask, src->format->Gmask,
   10.67 -                                          src->format->Bmask, src->format->Amask );
   10.68 -    if (surface_scaled) {
   10.69 -        SDL_GetColorKey(src, &colorkey);
   10.70 -        SDL_SetColorKey(surface_scaled, SDL_TRUE, colorkey);
   10.71 -        tmp_rect = final_rect;
   10.72 -        tmp_rect.x = 0;
   10.73 -        tmp_rect.y = 0;
   10.74 +    /* SDLgfx_rotateSurface doesn't accept a source rectangle, so crop and scale if we need to */
   10.75 +    tmp_rect = final_rect;
   10.76 +    tmp_rect.x = 0;
   10.77 +    tmp_rect.y = 0;
   10.78 +    if (srcrect->w == final_rect.w && srcrect->h == final_rect.h && srcrect->x == 0 && srcrect->y == 0) {
   10.79 +        surface_scaled = src; /* but if we don't need to, just use the original */
   10.80 +        retval = 0;
   10.81 +    } else {
   10.82 +        SDL_Surface *blit_src = src;
   10.83 +        Uint32 colorkey;
   10.84 +        SDL_BlendMode blendMode;
   10.85 +        Uint8 alphaMod, r, g, b;
   10.86 +        SDL_bool cloneSource = SDL_FALSE;
   10.87  
   10.88 -        retval = SDL_BlitScaled(src, srcrect, surface_scaled, &tmp_rect);
   10.89 -        if (!retval) {
   10.90 -            SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, -angle, &dstwidth, &dstheight, &cangle, &sangle);
   10.91 -            surface_rotated = SDLgfx_rotateSurface(surface_scaled, -angle, dstwidth/2, dstheight/2, GetScaleQuality(), flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle);
   10.92 -            if(surface_rotated) {
   10.93 -                /* Find out where the new origin is by rotating the four final_rect points around the center and then taking the extremes */
   10.94 -                abscenterx = final_rect.x + (int)center->x;
   10.95 -                abscentery = final_rect.y + (int)center->y;
   10.96 -                /* Compensate the angle inversion to match the behaviour of the other backends */
   10.97 -                sangle = -sangle;
   10.98 +        surface_scaled = SDL_CreateRGBSurface(SDL_SWSURFACE, final_rect.w, final_rect.h, src->format->BitsPerPixel,
   10.99 +                                              src->format->Rmask, src->format->Gmask,
  10.100 +                                              src->format->Bmask, src->format->Amask );
  10.101 +        if (!surface_scaled) {
  10.102 +            return -1;
  10.103 +        }
  10.104  
  10.105 -                /* Top Left */
  10.106 -                px = final_rect.x - abscenterx;
  10.107 -                py = final_rect.y - abscentery;
  10.108 -                p1x = px * cangle - py * sangle + abscenterx;
  10.109 -                p1y = px * sangle + py * cangle + abscentery;
  10.110 +        /* copy the color key, alpha mod, blend mode, and color mod so the scaled surface behaves like the source */
  10.111 +        if (SDL_GetColorKey(src, &colorkey) == 0) {
  10.112 +            SDL_SetColorKey(surface_scaled, SDL_TRUE, colorkey);
  10.113 +            cloneSource = SDL_TRUE;
  10.114 +        }
  10.115 +        SDL_GetSurfaceAlphaMod(src, &alphaMod); /* these will be copied to surface_scaled below if necessary */
  10.116 +        SDL_GetSurfaceBlendMode(src, &blendMode);
  10.117 +        SDL_GetSurfaceColorMod(src, &r, &g, &b);
  10.118  
  10.119 -                /* Top Right */
  10.120 -                px = final_rect.x + final_rect.w - abscenterx;
  10.121 -                py = final_rect.y - abscentery;
  10.122 -                p2x = px * cangle - py * sangle + abscenterx;
  10.123 -                p2y = px * sangle + py * cangle + abscentery;
  10.124 +        /* now we need to blit the src into surface_scaled. since we want to copy the colors from the source to
  10.125 +         * surface_scaled rather than blend them, etc. we'll need to disable the blend mode, alpha mod, etc.
  10.126 +         * but we don't want to modify src (in case it's being used on other threads), so we'll need to clone it
  10.127 +         * before changing the blend options
  10.128 +         */
  10.129 +        cloneSource |= blendMode != SDL_BLENDMODE_NONE || (alphaMod & r & g & b) != 255;
  10.130 +        if (cloneSource) {
  10.131 +            blit_src = SDL_ConvertSurface(src, src->format, src->flags); /* clone src */
  10.132 +            if (!blit_src) {
  10.133 +                SDL_FreeSurface(surface_scaled);
  10.134 +                return -1;
  10.135 +            }
  10.136 +            SDL_SetSurfaceAlphaMod(blit_src, 255); /* disable all blending options in blit_src */
  10.137 +            SDL_SetSurfaceBlendMode(blit_src, SDL_BLENDMODE_NONE);
  10.138 +            SDL_SetColorKey(blit_src, 0, 0);
  10.139 +            SDL_SetSurfaceColorMod(blit_src, 255, 255, 255);
  10.140 +            SDL_SetSurfaceRLE(blit_src, 0); /* don't RLE encode a surface we'll only use once */
  10.141  
  10.142 -                /* Bottom Left */
  10.143 -                px = final_rect.x - abscenterx;
  10.144 -                py = final_rect.y + final_rect.h - abscentery;
  10.145 -                p3x = px * cangle - py * sangle + abscenterx;
  10.146 -                p3y = px * sangle + py * cangle + abscentery;
  10.147 +            SDL_SetSurfaceAlphaMod(surface_scaled, alphaMod); /* copy blending options to surface_scaled */
  10.148 +            SDL_SetSurfaceBlendMode(surface_scaled, blendMode);
  10.149 +            SDL_SetSurfaceColorMod(surface_scaled, r, g, b);
  10.150 +        }
  10.151  
  10.152 -                /* Bottom Right */
  10.153 -                px = final_rect.x + final_rect.w - abscenterx;
  10.154 -                py = final_rect.y + final_rect.h - abscentery;
  10.155 -                p4x = px * cangle - py * sangle + abscenterx;
  10.156 -                p4y = px * sangle + py * cangle + abscentery;
  10.157 -
  10.158 -                tmp_rect.x = (int)MIN(MIN(p1x, p2x), MIN(p3x, p4x));
  10.159 -                tmp_rect.y = (int)MIN(MIN(p1y, p2y), MIN(p3y, p4y));
  10.160 -                tmp_rect.w = dstwidth;
  10.161 -                tmp_rect.h = dstheight;
  10.162 -
  10.163 -                retval = SDL_BlitSurface(surface_rotated, NULL, surface, &tmp_rect);
  10.164 -                SDL_FreeSurface(surface_scaled);
  10.165 -                SDL_FreeSurface(surface_rotated);
  10.166 -                return retval;
  10.167 -            }
  10.168 +        retval = SDL_BlitScaled(blit_src, srcrect, surface_scaled, &tmp_rect);
  10.169 +        if (blit_src != src) {
  10.170 +            SDL_FreeSurface(blit_src);
  10.171          }
  10.172 -        return retval;
  10.173      }
  10.174  
  10.175 -    return -1;
  10.176 +    if (!retval) {
  10.177 +        SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, -angle, &dstwidth, &dstheight, &cangle, &sangle);
  10.178 +        surface_rotated = SDLgfx_rotateSurface(surface_scaled, -angle, dstwidth/2, dstheight/2, GetScaleQuality(), flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle);
  10.179 +        if(surface_rotated) {
  10.180 +            /* Find out where the new origin is by rotating the four final_rect points around the center and then taking the extremes */
  10.181 +            abscenterx = final_rect.x + (int)center->x;
  10.182 +            abscentery = final_rect.y + (int)center->y;
  10.183 +            /* Compensate the angle inversion to match the behaviour of the other backends */
  10.184 +            sangle = -sangle;
  10.185 +
  10.186 +            /* Top Left */
  10.187 +            px = final_rect.x - abscenterx;
  10.188 +            py = final_rect.y - abscentery;
  10.189 +            p1x = px * cangle - py * sangle + abscenterx;
  10.190 +            p1y = px * sangle + py * cangle + abscentery;
  10.191 +
  10.192 +            /* Top Right */
  10.193 +            px = final_rect.x + final_rect.w - abscenterx;
  10.194 +            py = final_rect.y - abscentery;
  10.195 +            p2x = px * cangle - py * sangle + abscenterx;
  10.196 +            p2y = px * sangle + py * cangle + abscentery;
  10.197 +
  10.198 +            /* Bottom Left */
  10.199 +            px = final_rect.x - abscenterx;
  10.200 +            py = final_rect.y + final_rect.h - abscentery;
  10.201 +            p3x = px * cangle - py * sangle + abscenterx;
  10.202 +            p3y = px * sangle + py * cangle + abscentery;
  10.203 +
  10.204 +            /* Bottom Right */
  10.205 +            px = final_rect.x + final_rect.w - abscenterx;
  10.206 +            py = final_rect.y + final_rect.h - abscentery;
  10.207 +            p4x = px * cangle - py * sangle + abscenterx;
  10.208 +            p4y = px * sangle + py * cangle + abscentery;
  10.209 +
  10.210 +            tmp_rect.x = (int)MIN(MIN(p1x, p2x), MIN(p3x, p4x));
  10.211 +            tmp_rect.y = (int)MIN(MIN(p1y, p2y), MIN(p3y, p4y));
  10.212 +            tmp_rect.w = dstwidth;
  10.213 +            tmp_rect.h = dstheight;
  10.214 +
  10.215 +            retval = SDL_BlitSurface(surface_rotated, NULL, surface, &tmp_rect);
  10.216 +            SDL_FreeSurface(surface_rotated);
  10.217 +        }
  10.218 +    }
  10.219 +
  10.220 +    if (surface_scaled != src) {
  10.221 +        SDL_FreeSurface(surface_scaled);
  10.222 +    }
  10.223 +    return retval;
  10.224  }
  10.225  
  10.226  static int
    11.1 --- a/src/render/software/SDL_rotate.c	Wed Jun 17 20:03:08 2015 -0700
    11.2 +++ b/src/render/software/SDL_rotate.c	Sun Jun 21 04:04:14 2015 -0700
    11.3 @@ -188,10 +188,8 @@
    11.4                  dy = (sdy >> 16);
    11.5                  if (flipx) dx = sw - dx;
    11.6                  if (flipy) dy = sh - dy;
    11.7 -                if ((dx > -1) && (dy > -1) && (dx < (src->w-1)) && (dy < (src->h-1))) {
    11.8 -                    sp = (tColorRGBA *)src->pixels;
    11.9 -                    sp += ((src->pitch/4) * dy);
   11.10 -                    sp += dx;
   11.11 +                if ((unsigned)dx < (unsigned)sw && (unsigned)dy < (unsigned)sh) {
   11.12 +                    sp = (tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy) + dx;
   11.13                      c00 = *sp;
   11.14                      sp += 1;
   11.15                      c01 = *sp;
   11.16 @@ -237,14 +235,12 @@
   11.17              sdx = (ax + (isin * dy)) + xd;
   11.18              sdy = (ay - (icos * dy)) + yd;
   11.19              for (x = 0; x < dst->w; x++) {
   11.20 -                dx = (short) (sdx >> 16);
   11.21 -                dy = (short) (sdy >> 16);
   11.22 -                if (flipx) dx = (src->w-1)-dx;
   11.23 -                if (flipy) dy = (src->h-1)-dy;
   11.24 -                if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h)) {
   11.25 -                    sp = (tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy);
   11.26 -                    sp += dx;
   11.27 -                    *pc = *sp;
   11.28 +                dx = (sdx >> 16);
   11.29 +                dy = (sdy >> 16);
   11.30 +                if ((unsigned)dx < (unsigned)src->w && (unsigned)dy < (unsigned)src->h) {
   11.31 +                    if(flipx) dx = sw - dx;
   11.32 +                    if(flipy) dy = sh - dy;
   11.33 +                    *pc = *((tColorRGBA *)((Uint8 *)src->pixels + src->pitch * dy) + dx);
   11.34                  }
   11.35                  sdx += icos;
   11.36                  sdy += isin;
   11.37 @@ -277,7 +273,7 @@
   11.38  transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy)
   11.39  {
   11.40      int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay;
   11.41 -    tColorY *pc, *sp;
   11.42 +    tColorY *pc;
   11.43      int gap;
   11.44  
   11.45      /*
   11.46 @@ -301,14 +297,12 @@
   11.47          sdx = (ax + (isin * dy)) + xd;
   11.48          sdy = (ay - (icos * dy)) + yd;
   11.49          for (x = 0; x < dst->w; x++) {
   11.50 -            dx = (short) (sdx >> 16);
   11.51 -            dy = (short) (sdy >> 16);
   11.52 -            if (flipx) dx = (src->w-1)-dx;
   11.53 -            if (flipy) dy = (src->h-1)-dy;
   11.54 -            if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h)) {
   11.55 -                sp = (tColorY *) (src->pixels);
   11.56 -                sp += (src->pitch * dy + dx);
   11.57 -                *pc = *sp;
   11.58 +            dx = (sdx >> 16);
   11.59 +            dy = (sdy >> 16);
   11.60 +            if ((unsigned)dx < (unsigned)src->w && (unsigned)dy < (unsigned)src->h) {
   11.61 +                if (flipx) dx = (src->w-1)-dx;
   11.62 +                if (flipy) dy = (src->h-1)-dy;
   11.63 +                *pc = *((tColorY *)src->pixels + src->pitch * dy + dx);
   11.64              }
   11.65              sdx += icos;
   11.66              sdy += isin;
   11.67 @@ -348,7 +342,7 @@
   11.68      SDL_Surface *rz_src;
   11.69      SDL_Surface *rz_dst;
   11.70      int is32bit;
   11.71 -    int i, src_converted;
   11.72 +    int i;
   11.73      Uint8 r,g,b;
   11.74      Uint32 colorkey = 0;
   11.75      int colorKeyAvailable = 0;
   11.76 @@ -375,27 +369,15 @@
   11.77          * Use source surface 'as is'
   11.78          */
   11.79          rz_src = src;
   11.80 -        src_converted = 0;
   11.81      } else {
   11.82 -        /*
   11.83 -        * New source surface is 32bit with a defined RGBA ordering
   11.84 -        */
   11.85 -        rz_src =
   11.86 -            SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
   11.87 +        Uint32 format = SDL_MasksToPixelFormatEnum(32,
   11.88  #if SDL_BYTEORDER == SDL_LIL_ENDIAN
   11.89              0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
   11.90  #else
   11.91              0xff000000,  0x00ff0000, 0x0000ff00, 0x000000ff
   11.92  #endif
   11.93 -            );
   11.94 -        if(colorKeyAvailable)
   11.95 -            SDL_SetColorKey(src, 0, 0);
   11.96 -
   11.97 -        SDL_BlitSurface(src, NULL, rz_src, NULL);
   11.98 -
   11.99 -        if(colorKeyAvailable)
  11.100 -            SDL_SetColorKey(src, SDL_TRUE /* SDL_SRCCOLORKEY */, colorkey);
  11.101 -        src_converted = 1;
  11.102 +        );
  11.103 +        rz_src = SDL_ConvertSurfaceFormat(src, format, src->flags);
  11.104          is32bit = 1;
  11.105      }
  11.106  
  11.107 @@ -480,6 +462,19 @@
  11.108              flipx, flipy);
  11.109          SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
  11.110      }
  11.111 +
  11.112 +    /* copy alpha mod, color mod, and blend mode */
  11.113 +    {
  11.114 +      SDL_BlendMode blendMode;
  11.115 +      Uint8 alphaMod, r, g, b;
  11.116 +      SDL_GetSurfaceAlphaMod(src, &alphaMod);
  11.117 +      SDL_GetSurfaceBlendMode(src, &blendMode);
  11.118 +      SDL_GetSurfaceColorMod(src, &r, &g, &b);
  11.119 +      SDL_SetSurfaceAlphaMod(rz_dst, alphaMod);
  11.120 +      SDL_SetSurfaceBlendMode(rz_dst, blendMode);
  11.121 +      SDL_SetSurfaceColorMod(rz_dst, r, g, b);
  11.122 +    }
  11.123 +
  11.124      /*
  11.125      * Unlock source surface
  11.126      */
  11.127 @@ -490,7 +485,7 @@
  11.128      /*
  11.129      * Cleanup temp surface
  11.130      */
  11.131 -    if (src_converted) {
  11.132 +    if (rz_src != src) {
  11.133          SDL_FreeSurface(rz_src);
  11.134      }
  11.135  
    12.1 --- a/src/timer/unix/SDL_systimer.c	Wed Jun 17 20:03:08 2015 -0700
    12.2 +++ b/src/timer/unix/SDL_systimer.c	Sun Jun 21 04:04:14 2015 -0700
    12.3 @@ -48,6 +48,15 @@
    12.4  #include <mach/mach_time.h>
    12.5  #endif
    12.6  
    12.7 +/* Use CLOCK_MONOTONIC_RAW, if available, which is not subject to adjustment by NTP */
    12.8 +#if HAVE_CLOCK_GETTIME
    12.9 +#ifdef CLOCK_MONOTONIC_RAW
   12.10 +#define SDL_MONOTONIC_CLOCK CLOCK_MONOTONIC_RAW
   12.11 +#else
   12.12 +#define SDL_MONOTONIC_CLOCK CLOCK_MONOTONIC
   12.13 +#endif
   12.14 +#endif
   12.15 +
   12.16  /* The first ticks value of the application */
   12.17  #if HAVE_CLOCK_GETTIME
   12.18  static struct timespec start_ts;
   12.19 @@ -69,7 +78,7 @@
   12.20  
   12.21      /* Set first ticks value */
   12.22  #if HAVE_CLOCK_GETTIME
   12.23 -    if (clock_gettime(CLOCK_MONOTONIC, &start_ts) == 0) {
   12.24 +    if (clock_gettime(SDL_MONOTONIC_CLOCK, &start_ts) == 0) {
   12.25          has_monotonic_time = SDL_TRUE;
   12.26      } else
   12.27  #elif defined(__APPLE__)
   12.28 @@ -101,7 +110,7 @@
   12.29      if (has_monotonic_time) {
   12.30  #if HAVE_CLOCK_GETTIME
   12.31          struct timespec now;
   12.32 -        clock_gettime(CLOCK_MONOTONIC, &now);
   12.33 +        clock_gettime(SDL_MONOTONIC_CLOCK, &now);
   12.34          ticks = (now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec -
   12.35                                                   start_ts.tv_nsec) / 1000000;
   12.36  #elif defined(__APPLE__)
   12.37 @@ -132,7 +141,7 @@
   12.38  #if HAVE_CLOCK_GETTIME
   12.39          struct timespec now;
   12.40  
   12.41 -        clock_gettime(CLOCK_MONOTONIC, &now);
   12.42 +        clock_gettime(SDL_MONOTONIC_CLOCK, &now);
   12.43          ticks = now.tv_sec;
   12.44          ticks *= 1000000000;
   12.45          ticks += now.tv_nsec;
    13.1 --- a/src/video/SDL_RLEaccel.c	Wed Jun 17 20:03:08 2015 -0700
    13.2 +++ b/src/video/SDL_RLEaccel.c	Sun Jun 21 04:04:14 2015 -0700
    13.3 @@ -374,6 +374,18 @@
    13.4      } while(0)
    13.5  
    13.6  /*
    13.7 + * Set a pixel value using the given format, except that the alpha value is
    13.8 + * placed in the top byte. This is the format used for RLE with alpha.
    13.9 + */
   13.10 +#define RLEPIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a)                      \
   13.11 +{                                                                       \
   13.12 +    Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)|                             \
   13.13 +        ((g>>fmt->Gloss)<<fmt->Gshift)|                                 \
   13.14 +        ((b>>fmt->Bloss)<<fmt->Bshift)|                                 \
   13.15 +        (a<<24);                                                        \
   13.16 +}
   13.17 +
   13.18 +/*
   13.19   * This takes care of the case when the surface is clipped on the left and/or
   13.20   * right. Top clipping has already been taken care of.
   13.21   */
   13.22 @@ -982,7 +994,7 @@
   13.23      for (i = 0; i < n; i++) {
   13.24          unsigned r, g, b, a;
   13.25          RGBA_FROM_8888(*src, sfmt, r, g, b, a);
   13.26 -        PIXEL_FROM_RGBA(*d, dfmt, r, g, b, a);
   13.27 +        RLEPIXEL_FROM_RGBA(*d, dfmt, r, g, b, a);
   13.28          d++;
   13.29          src++;
   13.30      }