mirror of https://github.com/encounter/SDL.git
merged SDL 2.0.4 rc2
This commit is contained in:
commit
d77a55738b
14
.hgignore
14
.hgignore
|
@ -9,8 +9,6 @@ sdl-config
|
||||||
SDL2.spec
|
SDL2.spec
|
||||||
build
|
build
|
||||||
Build
|
Build
|
||||||
*xcuserdata*
|
|
||||||
*xcworkspacedata*
|
|
||||||
|
|
||||||
# for Xcode
|
# for Xcode
|
||||||
*.orig
|
*.orig
|
||||||
|
@ -20,20 +18,12 @@ Build
|
||||||
*~
|
*~
|
||||||
*.o
|
*.o
|
||||||
*.mode1*
|
*.mode1*
|
||||||
*.model*
|
|
||||||
*.perspective*
|
|
||||||
*.perspective*
|
*.perspective*
|
||||||
*.pbxuser
|
*.pbxuser
|
||||||
(^|/)build($|/)
|
(^|/)build($|/)
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Xcode/SDL/SDL.xcodeproj/xcuserdata
|
xcuserdata
|
||||||
Xcode/SDL/SDL.xcodeproj/project.xcworkspace
|
*.xcworkspace
|
||||||
Xcode/SDLTest/SDLTest.xcodeproj/xcuserdata
|
|
||||||
Xcode/SDLTest/SDLTest.xcodeproj/project.xcworkspace
|
|
||||||
Xcode-iOS/SDL/SDL.xcodeproj/xcuserdata
|
|
||||||
Xcode-iOS/SDL/SDL.xcodeproj/project.xcworkspace
|
|
||||||
Xcode-iOS/Demos/Demos.xcodeproj/xcuserdata
|
|
||||||
Xcode-iOS/Demos/Demos.xcodeproj/project.xcworkspace
|
|
||||||
|
|
||||||
# for Visual C++
|
# for Visual C++
|
||||||
Debug
|
Debug
|
||||||
|
|
|
@ -900,10 +900,12 @@ elseif(WINDOWS)
|
||||||
|
|
||||||
# Check for DirectX
|
# Check for DirectX
|
||||||
if(DIRECTX)
|
if(DIRECTX)
|
||||||
if("$ENV{DXSDK_DIR}" STREQUAL "")
|
if(NOT CMAKE_COMPILER_IS_MINGW)
|
||||||
message_error("DIRECTX requires the \$DXSDK_DIR environment variable to be set")
|
if("$ENV{DXSDK_DIR}" STREQUAL "")
|
||||||
|
message_error("DIRECTX requires the \$DXSDK_DIR environment variable to be set")
|
||||||
|
endif()
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
|
|
||||||
check_include_file(d3d9.h HAVE_D3D_H)
|
check_include_file(d3d9.h HAVE_D3D_H)
|
||||||
check_include_file(d3d11_1.h HAVE_D3D11_H)
|
check_include_file(d3d11_1.h HAVE_D3D11_H)
|
||||||
check_include_file(ddraw.h HAVE_DDRAW_H)
|
check_include_file(ddraw.h HAVE_DDRAW_H)
|
||||||
|
@ -914,9 +916,11 @@ elseif(WINDOWS)
|
||||||
check_include_file(dxgi.h HAVE_DXGI_H)
|
check_include_file(dxgi.h HAVE_DXGI_H)
|
||||||
if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
|
if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
|
||||||
set(HAVE_DIRECTX TRUE)
|
set(HAVE_DIRECTX TRUE)
|
||||||
|
if(NOT CMAKE_COMPILER_IS_MINGW)
|
||||||
# TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
|
# TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
|
||||||
link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
|
link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
|
||||||
include_directories($ENV{DXSDK_DIR}\\Include)
|
include_directories($ENV{DXSDK_DIR}\\Include)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||||
endif()
|
endif()
|
||||||
|
@ -1020,7 +1024,12 @@ elseif(WINDOWS)
|
||||||
set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
|
set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
|
||||||
if(HAVE_DINPUT_H)
|
if(HAVE_DINPUT_H)
|
||||||
set(SDL_JOYSTICK_DINPUT 1)
|
set(SDL_JOYSTICK_DINPUT 1)
|
||||||
list(APPEND EXTRA_LIBS dinput8 dxguid dxerr)
|
list(APPEND EXTRA_LIBS dinput8 dxguid)
|
||||||
|
if(CMAKE_COMPILER_IS_MINGW)
|
||||||
|
list(APPEND EXTRA_LIBS dxerr8)
|
||||||
|
else()
|
||||||
|
list(APPEND EXTRA_LIBS dxerr)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(HAVE_XINPUT_H)
|
if(HAVE_XINPUT_H)
|
||||||
set(SDL_JOYSTICK_XINPUT 1)
|
set(SDL_JOYSTICK_XINPUT 1)
|
||||||
|
|
|
@ -39,7 +39,7 @@ SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
|
||||||
SDLTEST_TARGET = libSDL2_test.a
|
SDLTEST_TARGET = libSDL2_test.a
|
||||||
SDLTEST_OBJECTS = @SDLTEST_OBJECTS@
|
SDLTEST_OBJECTS = @SDLTEST_OBJECTS@
|
||||||
|
|
||||||
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
|
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
|
||||||
GEN_DIST = SDL2.spec
|
GEN_DIST = SDL2.spec
|
||||||
|
|
||||||
ifneq ($V,1)
|
ifneq ($V,1)
|
||||||
|
|
15
WhatsNew.txt
15
WhatsNew.txt
|
@ -27,7 +27,10 @@ General:
|
||||||
* Added a Vivante video driver that is used on various SoC platforms
|
* Added a Vivante video driver that is used on various SoC platforms
|
||||||
* 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
|
* 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
|
||||||
* Added a hint SDL_HINT_NO_SIGNAL_HANDLERS to disable SDL's built in signal handling
|
* Added a hint SDL_HINT_NO_SIGNAL_HANDLERS to disable SDL's built in signal handling
|
||||||
|
* Added a hint SDL_HINT_THREAD_STACK_SIZE to set the stack size of SDL's threads
|
||||||
|
* Added SDL_sqrtf(), SDL_tan(), and SDL_tanf() to the stdlib routines
|
||||||
* Improved support for WAV and BMP files with unusual chunks in them
|
* Improved support for WAV and BMP files with unusual chunks in them
|
||||||
|
* Renamed SDL_assert_data to SDL_AssertData and SDL_assert_state to SDL_AssertState
|
||||||
|
|
||||||
Windows:
|
Windows:
|
||||||
* Added support for Windows Phone 8.1
|
* Added support for Windows Phone 8.1
|
||||||
|
@ -39,11 +42,15 @@ Windows:
|
||||||
* SDL_SysWMinfo now contains the window HDC
|
* SDL_SysWMinfo now contains the window HDC
|
||||||
* Added support for Unicode command line options
|
* Added support for Unicode command line options
|
||||||
* Prevent beeping when Alt-key combos are pressed
|
* Prevent beeping when Alt-key combos are pressed
|
||||||
|
* SDL_SetTextInputRect() re-positions the OS-rendered IME
|
||||||
|
|
||||||
Mac OS X:
|
Mac OS X:
|
||||||
* Implemented drag-and-drop support
|
* Implemented drag-and-drop support
|
||||||
* Improved joystick hot-plug detection
|
* Improved joystick hot-plug detection
|
||||||
|
* The SDL_WINDOWEVENT_EXPOSED window event is triggered in the appropriate situations
|
||||||
* Fixed relative mouse mode when the application loses/regains focus
|
* Fixed relative mouse mode when the application loses/regains focus
|
||||||
|
* Fixed bugs related to transitioning to and from Spaces-aware fullscreen-desktop mode
|
||||||
|
* Fixed the refresh rate of display modes
|
||||||
* SDL_SysWMInfo is now ARC-compatible
|
* SDL_SysWMInfo is now ARC-compatible
|
||||||
|
|
||||||
Linux:
|
Linux:
|
||||||
|
@ -55,6 +62,14 @@ Linux:
|
||||||
|
|
||||||
iOS:
|
iOS:
|
||||||
* Added support for iOS 8
|
* Added support for iOS 8
|
||||||
|
* Added support for the hint SDL_HINT_ACCELEROMETER_AS_JOYSTICK
|
||||||
|
* Added sRGB OpenGL ES context support on iOS 7+
|
||||||
|
* Added native resolution support for the iPhone 6 Plus
|
||||||
|
* 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
|
||||||
|
* SDL_GetWindowSize() and display mode sizes are in the "DPI-independent points" coordinate space rather than pixels (matches OS X behavior)
|
||||||
|
* SDL_SysWMinfo now contains the OpenGL ES framebuffer and color renderbuffer objects used by the window's active GLES view
|
||||||
|
* Fixed various rotation and orientation issues
|
||||||
|
* Fixed memory leaks
|
||||||
|
|
||||||
Android:
|
Android:
|
||||||
* Added a hint SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH to prevent mouse events from being registered as touch events
|
* Added a hint SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH to prevent mouse events from being registered as touch events
|
||||||
|
|
|
@ -18701,43 +18701,6 @@ $as_echo "$need_gcc_Wno_multichar" >&6; }
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckWarnShadow()
|
|
||||||
{
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -Wshadow option" >&5
|
|
||||||
$as_echo_n "checking for GCC -Wshadow option... " >&6; }
|
|
||||||
have_gcc_Wshadow=no
|
|
||||||
|
|
||||||
save_CFLAGS="$CFLAGS"
|
|
||||||
CFLAGS="$save_CFLAGS -Wshadow"
|
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
||||||
/* end confdefs.h. */
|
|
||||||
|
|
||||||
int x = 0;
|
|
||||||
|
|
||||||
int
|
|
||||||
main ()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_ACEOF
|
|
||||||
if ac_fn_c_try_compile "$LINENO"; then :
|
|
||||||
|
|
||||||
have_gcc_Wshadow=yes
|
|
||||||
|
|
||||||
fi
|
|
||||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
|
||||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_Wshadow" >&5
|
|
||||||
$as_echo "$have_gcc_Wshadow" >&6; }
|
|
||||||
CFLAGS="$save_CFLAGS"
|
|
||||||
|
|
||||||
if test x$have_gcc_Wshadow = xyes; then
|
|
||||||
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wshadow"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckWayland()
|
CheckWayland()
|
||||||
{
|
{
|
||||||
# Check whether --enable-video-wayland was given.
|
# Check whether --enable-video-wayland was given.
|
||||||
|
@ -23652,7 +23615,6 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CheckWarnAll
|
CheckWarnAll
|
||||||
CheckWarnShadow
|
|
||||||
|
|
||||||
# Verify that we have all the platform specific files we need
|
# Verify that we have all the platform specific files we need
|
||||||
|
|
||||||
|
|
23
configure.in
23
configure.in
|
@ -1159,28 +1159,6 @@ CheckWarnAll()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
dnl See if GCC's -Wshadow is supported.
|
|
||||||
CheckWarnShadow()
|
|
||||||
{
|
|
||||||
AC_MSG_CHECKING(for GCC -Wshadow option)
|
|
||||||
have_gcc_Wshadow=no
|
|
||||||
|
|
||||||
save_CFLAGS="$CFLAGS"
|
|
||||||
CFLAGS="$save_CFLAGS -Wshadow"
|
|
||||||
AC_TRY_COMPILE([
|
|
||||||
int x = 0;
|
|
||||||
],[
|
|
||||||
],[
|
|
||||||
have_gcc_Wshadow=yes
|
|
||||||
])
|
|
||||||
AC_MSG_RESULT($have_gcc_Wshadow)
|
|
||||||
CFLAGS="$save_CFLAGS"
|
|
||||||
|
|
||||||
if test x$have_gcc_Wshadow = xyes; then
|
|
||||||
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wshadow"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
dnl Check for Wayland
|
dnl Check for Wayland
|
||||||
CheckWayland()
|
CheckWayland()
|
||||||
{
|
{
|
||||||
|
@ -3415,7 +3393,6 @@ esac
|
||||||
|
|
||||||
dnl Do this on all platforms, after everything else.
|
dnl Do this on all platforms, after everything else.
|
||||||
CheckWarnAll
|
CheckWarnAll
|
||||||
CheckWarnShadow
|
|
||||||
|
|
||||||
# Verify that we have all the platform specific files we need
|
# Verify that we have all the platform specific files we need
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
Dynamic API
|
Dynamic API
|
||||||
================================================================================
|
================================================================================
|
||||||
Originally posted by Ryan at https://plus.google.com/103391075724026391227/posts/TB8UfnDYu4U
|
Originally posted by Ryan at:
|
||||||
|
https://plus.google.com/103391075724026391227/posts/TB8UfnDYu4U
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,7 @@
|
||||||
#define HAVE_SETJMP 1
|
#define HAVE_SETJMP 1
|
||||||
#define HAVE_NANOSLEEP 1
|
#define HAVE_NANOSLEEP 1
|
||||||
#define HAVE_SYSCONF 1
|
#define HAVE_SYSCONF 1
|
||||||
|
#define HAVE_CLOCK_GETTIME 1
|
||||||
|
|
||||||
#define SIZEOF_VOIDP 4
|
#define SIZEOF_VOIDP 4
|
||||||
|
|
||||||
|
|
|
@ -1771,6 +1771,10 @@ SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
SDL_FRect frect;
|
SDL_FRect frect;
|
||||||
SDL_FPoint fcenter;
|
SDL_FPoint fcenter;
|
||||||
|
|
||||||
|
if (flip == SDL_FLIP_NONE && angle == 0) { /* fast path when we don't need rotation or flipping */
|
||||||
|
return SDL_RenderCopy(renderer, texture, srcrect, dstrect);
|
||||||
|
}
|
||||||
|
|
||||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||||
|
|
||||||
|
|
|
@ -253,6 +253,12 @@ static int
|
||||||
SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
|
SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||||
{
|
{
|
||||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||||
|
/* If the color mod is ever enabled (non-white), permanently disable RLE (which doesn't support
|
||||||
|
* color mod) to avoid potentially frequent RLE encoding/decoding.
|
||||||
|
*/
|
||||||
|
if ((texture->r & texture->g & texture->b) != 255) {
|
||||||
|
SDL_SetSurfaceRLE(surface, 0);
|
||||||
|
}
|
||||||
return SDL_SetSurfaceColorMod(surface, texture->r, texture->g,
|
return SDL_SetSurfaceColorMod(surface, texture->r, texture->g,
|
||||||
texture->b);
|
texture->b);
|
||||||
}
|
}
|
||||||
|
@ -261,6 +267,12 @@ static int
|
||||||
SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
|
SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||||
{
|
{
|
||||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||||
|
/* If the texture ever has multiple alpha values (surface alpha plus alpha channel), permanently
|
||||||
|
* disable RLE (which doesn't support this) to avoid potentially frequent RLE encoding/decoding.
|
||||||
|
*/
|
||||||
|
if (texture->a != 255 && surface->format->Amask) {
|
||||||
|
SDL_SetSurfaceRLE(surface, 0);
|
||||||
|
}
|
||||||
return SDL_SetSurfaceAlphaMod(surface, texture->a);
|
return SDL_SetSurfaceAlphaMod(surface, texture->a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,6 +280,12 @@ static int
|
||||||
SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
|
SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||||
{
|
{
|
||||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||||
|
/* If add or mod blending are ever enabled, permanently disable RLE (which doesn't support
|
||||||
|
* them) to avoid potentially frequent RLE encoding/decoding.
|
||||||
|
*/
|
||||||
|
if ((texture->blendMode == SDL_BLENDMODE_ADD || texture->blendMode == SDL_BLENDMODE_MOD)) {
|
||||||
|
SDL_SetSurfaceRLE(surface, 0);
|
||||||
|
}
|
||||||
return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
|
return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,6 +571,10 @@ SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
if ( srcrect->w == final_rect.w && srcrect->h == final_rect.h ) {
|
if ( srcrect->w == final_rect.w && srcrect->h == final_rect.h ) {
|
||||||
return SDL_BlitSurface(src, srcrect, surface, &final_rect);
|
return SDL_BlitSurface(src, srcrect, surface, &final_rect);
|
||||||
} else {
|
} else {
|
||||||
|
/* If scaling is ever done, permanently disable RLE (which doesn't support scaling)
|
||||||
|
* to avoid potentially frequent RLE encoding/decoding.
|
||||||
|
*/
|
||||||
|
SDL_SetSurfaceRLE(surface, 0);
|
||||||
return SDL_BlitScaled(src, srcrect, surface, &final_rect);
|
return SDL_BlitScaled(src, srcrect, surface, &final_rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,7 +600,6 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
SDL_Surface *src = (SDL_Surface *) texture->driverdata;
|
SDL_Surface *src = (SDL_Surface *) texture->driverdata;
|
||||||
SDL_Rect final_rect, tmp_rect;
|
SDL_Rect final_rect, tmp_rect;
|
||||||
SDL_Surface *surface_rotated, *surface_scaled;
|
SDL_Surface *surface_rotated, *surface_scaled;
|
||||||
Uint32 colorkey;
|
|
||||||
int retval, dstwidth, dstheight, abscenterx, abscentery;
|
int retval, dstwidth, dstheight, abscenterx, abscentery;
|
||||||
double cangle, sangle, px, py, p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y;
|
double cangle, sangle, px, py, p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y;
|
||||||
|
|
||||||
|
@ -596,66 +617,113 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
final_rect.w = (int)dstrect->w;
|
final_rect.w = (int)dstrect->w;
|
||||||
final_rect.h = (int)dstrect->h;
|
final_rect.h = (int)dstrect->h;
|
||||||
|
|
||||||
surface_scaled = SDL_CreateRGBSurface(SDL_SWSURFACE, final_rect.w, final_rect.h, src->format->BitsPerPixel,
|
/* SDLgfx_rotateSurface doesn't accept a source rectangle, so crop and scale if we need to */
|
||||||
src->format->Rmask, src->format->Gmask,
|
tmp_rect = final_rect;
|
||||||
src->format->Bmask, src->format->Amask );
|
tmp_rect.x = 0;
|
||||||
if (surface_scaled) {
|
tmp_rect.y = 0;
|
||||||
SDL_GetColorKey(src, &colorkey);
|
if (srcrect->w == final_rect.w && srcrect->h == final_rect.h && srcrect->x == 0 && srcrect->y == 0) {
|
||||||
SDL_SetColorKey(surface_scaled, SDL_TRUE, colorkey);
|
surface_scaled = src; /* but if we don't need to, just use the original */
|
||||||
tmp_rect = final_rect;
|
retval = 0;
|
||||||
tmp_rect.x = 0;
|
} else {
|
||||||
tmp_rect.y = 0;
|
SDL_Surface *blit_src = src;
|
||||||
|
Uint32 colorkey;
|
||||||
|
SDL_BlendMode blendMode;
|
||||||
|
Uint8 alphaMod, r, g, b;
|
||||||
|
SDL_bool cloneSource = SDL_FALSE;
|
||||||
|
|
||||||
retval = SDL_BlitScaled(src, srcrect, surface_scaled, &tmp_rect);
|
surface_scaled = SDL_CreateRGBSurface(SDL_SWSURFACE, final_rect.w, final_rect.h, src->format->BitsPerPixel,
|
||||||
if (!retval) {
|
src->format->Rmask, src->format->Gmask,
|
||||||
SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, -angle, &dstwidth, &dstheight, &cangle, &sangle);
|
src->format->Bmask, src->format->Amask );
|
||||||
surface_rotated = SDLgfx_rotateSurface(surface_scaled, -angle, dstwidth/2, dstheight/2, GetScaleQuality(), flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle);
|
if (!surface_scaled) {
|
||||||
if(surface_rotated) {
|
return -1;
|
||||||
/* Find out where the new origin is by rotating the four final_rect points around the center and then taking the extremes */
|
}
|
||||||
abscenterx = final_rect.x + (int)center->x;
|
|
||||||
abscentery = final_rect.y + (int)center->y;
|
/* copy the color key, alpha mod, blend mode, and color mod so the scaled surface behaves like the source */
|
||||||
/* Compensate the angle inversion to match the behaviour of the other backends */
|
if (SDL_GetColorKey(src, &colorkey) == 0) {
|
||||||
sangle = -sangle;
|
SDL_SetColorKey(surface_scaled, SDL_TRUE, colorkey);
|
||||||
|
cloneSource = SDL_TRUE;
|
||||||
/* Top Left */
|
}
|
||||||
px = final_rect.x - abscenterx;
|
SDL_GetSurfaceAlphaMod(src, &alphaMod); /* these will be copied to surface_scaled below if necessary */
|
||||||
py = final_rect.y - abscentery;
|
SDL_GetSurfaceBlendMode(src, &blendMode);
|
||||||
p1x = px * cangle - py * sangle + abscenterx;
|
SDL_GetSurfaceColorMod(src, &r, &g, &b);
|
||||||
p1y = px * sangle + py * cangle + abscentery;
|
|
||||||
|
/* now we need to blit the src into surface_scaled. since we want to copy the colors from the source to
|
||||||
/* Top Right */
|
* surface_scaled rather than blend them, etc. we'll need to disable the blend mode, alpha mod, etc.
|
||||||
px = final_rect.x + final_rect.w - abscenterx;
|
* but we don't want to modify src (in case it's being used on other threads), so we'll need to clone it
|
||||||
py = final_rect.y - abscentery;
|
* before changing the blend options
|
||||||
p2x = px * cangle - py * sangle + abscenterx;
|
*/
|
||||||
p2y = px * sangle + py * cangle + abscentery;
|
cloneSource |= blendMode != SDL_BLENDMODE_NONE || (alphaMod & r & g & b) != 255;
|
||||||
|
if (cloneSource) {
|
||||||
/* Bottom Left */
|
blit_src = SDL_ConvertSurface(src, src->format, src->flags); /* clone src */
|
||||||
px = final_rect.x - abscenterx;
|
if (!blit_src) {
|
||||||
py = final_rect.y + final_rect.h - abscentery;
|
SDL_FreeSurface(surface_scaled);
|
||||||
p3x = px * cangle - py * sangle + abscenterx;
|
return -1;
|
||||||
p3y = px * sangle + py * cangle + abscentery;
|
}
|
||||||
|
SDL_SetSurfaceAlphaMod(blit_src, 255); /* disable all blending options in blit_src */
|
||||||
/* Bottom Right */
|
SDL_SetSurfaceBlendMode(blit_src, SDL_BLENDMODE_NONE);
|
||||||
px = final_rect.x + final_rect.w - abscenterx;
|
SDL_SetColorKey(blit_src, 0, 0);
|
||||||
py = final_rect.y + final_rect.h - abscentery;
|
SDL_SetSurfaceColorMod(blit_src, 255, 255, 255);
|
||||||
p4x = px * cangle - py * sangle + abscenterx;
|
SDL_SetSurfaceRLE(blit_src, 0); /* don't RLE encode a surface we'll only use once */
|
||||||
p4y = px * sangle + py * cangle + abscentery;
|
|
||||||
|
SDL_SetSurfaceAlphaMod(surface_scaled, alphaMod); /* copy blending options to surface_scaled */
|
||||||
tmp_rect.x = (int)MIN(MIN(p1x, p2x), MIN(p3x, p4x));
|
SDL_SetSurfaceBlendMode(surface_scaled, blendMode);
|
||||||
tmp_rect.y = (int)MIN(MIN(p1y, p2y), MIN(p3y, p4y));
|
SDL_SetSurfaceColorMod(surface_scaled, r, g, b);
|
||||||
tmp_rect.w = dstwidth;
|
}
|
||||||
tmp_rect.h = dstheight;
|
|
||||||
|
retval = SDL_BlitScaled(blit_src, srcrect, surface_scaled, &tmp_rect);
|
||||||
retval = SDL_BlitSurface(surface_rotated, NULL, surface, &tmp_rect);
|
if (blit_src != src) {
|
||||||
SDL_FreeSurface(surface_scaled);
|
SDL_FreeSurface(blit_src);
|
||||||
SDL_FreeSurface(surface_rotated);
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
if (!retval) {
|
||||||
|
SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, -angle, &dstwidth, &dstheight, &cangle, &sangle);
|
||||||
|
surface_rotated = SDLgfx_rotateSurface(surface_scaled, -angle, dstwidth/2, dstheight/2, GetScaleQuality(), flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle);
|
||||||
|
if(surface_rotated) {
|
||||||
|
/* Find out where the new origin is by rotating the four final_rect points around the center and then taking the extremes */
|
||||||
|
abscenterx = final_rect.x + (int)center->x;
|
||||||
|
abscentery = final_rect.y + (int)center->y;
|
||||||
|
/* Compensate the angle inversion to match the behaviour of the other backends */
|
||||||
|
sangle = -sangle;
|
||||||
|
|
||||||
|
/* Top Left */
|
||||||
|
px = final_rect.x - abscenterx;
|
||||||
|
py = final_rect.y - abscentery;
|
||||||
|
p1x = px * cangle - py * sangle + abscenterx;
|
||||||
|
p1y = px * sangle + py * cangle + abscentery;
|
||||||
|
|
||||||
|
/* Top Right */
|
||||||
|
px = final_rect.x + final_rect.w - abscenterx;
|
||||||
|
py = final_rect.y - abscentery;
|
||||||
|
p2x = px * cangle - py * sangle + abscenterx;
|
||||||
|
p2y = px * sangle + py * cangle + abscentery;
|
||||||
|
|
||||||
|
/* Bottom Left */
|
||||||
|
px = final_rect.x - abscenterx;
|
||||||
|
py = final_rect.y + final_rect.h - abscentery;
|
||||||
|
p3x = px * cangle - py * sangle + abscenterx;
|
||||||
|
p3y = px * sangle + py * cangle + abscentery;
|
||||||
|
|
||||||
|
/* Bottom Right */
|
||||||
|
px = final_rect.x + final_rect.w - abscenterx;
|
||||||
|
py = final_rect.y + final_rect.h - abscentery;
|
||||||
|
p4x = px * cangle - py * sangle + abscenterx;
|
||||||
|
p4y = px * sangle + py * cangle + abscentery;
|
||||||
|
|
||||||
|
tmp_rect.x = (int)MIN(MIN(p1x, p2x), MIN(p3x, p4x));
|
||||||
|
tmp_rect.y = (int)MIN(MIN(p1y, p2y), MIN(p3y, p4y));
|
||||||
|
tmp_rect.w = dstwidth;
|
||||||
|
tmp_rect.h = dstheight;
|
||||||
|
|
||||||
|
retval = SDL_BlitSurface(surface_rotated, NULL, surface, &tmp_rect);
|
||||||
|
SDL_FreeSurface(surface_rotated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (surface_scaled != src) {
|
||||||
|
SDL_FreeSurface(surface_scaled);
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -188,10 +188,8 @@ _transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int
|
||||||
dy = (sdy >> 16);
|
dy = (sdy >> 16);
|
||||||
if (flipx) dx = sw - dx;
|
if (flipx) dx = sw - dx;
|
||||||
if (flipy) dy = sh - dy;
|
if (flipy) dy = sh - dy;
|
||||||
if ((dx > -1) && (dy > -1) && (dx < (src->w-1)) && (dy < (src->h-1))) {
|
if ((unsigned)dx < (unsigned)sw && (unsigned)dy < (unsigned)sh) {
|
||||||
sp = (tColorRGBA *)src->pixels;
|
sp = (tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy) + dx;
|
||||||
sp += ((src->pitch/4) * dy);
|
|
||||||
sp += dx;
|
|
||||||
c00 = *sp;
|
c00 = *sp;
|
||||||
sp += 1;
|
sp += 1;
|
||||||
c01 = *sp;
|
c01 = *sp;
|
||||||
|
@ -237,14 +235,12 @@ _transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int
|
||||||
sdx = (ax + (isin * dy)) + xd;
|
sdx = (ax + (isin * dy)) + xd;
|
||||||
sdy = (ay - (icos * dy)) + yd;
|
sdy = (ay - (icos * dy)) + yd;
|
||||||
for (x = 0; x < dst->w; x++) {
|
for (x = 0; x < dst->w; x++) {
|
||||||
dx = (short) (sdx >> 16);
|
dx = (sdx >> 16);
|
||||||
dy = (short) (sdy >> 16);
|
dy = (sdy >> 16);
|
||||||
if (flipx) dx = (src->w-1)-dx;
|
if ((unsigned)dx < (unsigned)src->w && (unsigned)dy < (unsigned)src->h) {
|
||||||
if (flipy) dy = (src->h-1)-dy;
|
if(flipx) dx = sw - dx;
|
||||||
if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h)) {
|
if(flipy) dy = sh - dy;
|
||||||
sp = (tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy);
|
*pc = *((tColorRGBA *)((Uint8 *)src->pixels + src->pitch * dy) + dx);
|
||||||
sp += dx;
|
|
||||||
*pc = *sp;
|
|
||||||
}
|
}
|
||||||
sdx += icos;
|
sdx += icos;
|
||||||
sdy += isin;
|
sdy += isin;
|
||||||
|
@ -277,7 +273,7 @@ static void
|
||||||
transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy)
|
transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy)
|
||||||
{
|
{
|
||||||
int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay;
|
int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay;
|
||||||
tColorY *pc, *sp;
|
tColorY *pc;
|
||||||
int gap;
|
int gap;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -301,14 +297,12 @@ transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin
|
||||||
sdx = (ax + (isin * dy)) + xd;
|
sdx = (ax + (isin * dy)) + xd;
|
||||||
sdy = (ay - (icos * dy)) + yd;
|
sdy = (ay - (icos * dy)) + yd;
|
||||||
for (x = 0; x < dst->w; x++) {
|
for (x = 0; x < dst->w; x++) {
|
||||||
dx = (short) (sdx >> 16);
|
dx = (sdx >> 16);
|
||||||
dy = (short) (sdy >> 16);
|
dy = (sdy >> 16);
|
||||||
if (flipx) dx = (src->w-1)-dx;
|
if ((unsigned)dx < (unsigned)src->w && (unsigned)dy < (unsigned)src->h) {
|
||||||
if (flipy) dy = (src->h-1)-dy;
|
if (flipx) dx = (src->w-1)-dx;
|
||||||
if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h)) {
|
if (flipy) dy = (src->h-1)-dy;
|
||||||
sp = (tColorY *) (src->pixels);
|
*pc = *((tColorY *)src->pixels + src->pitch * dy + dx);
|
||||||
sp += (src->pitch * dy + dx);
|
|
||||||
*pc = *sp;
|
|
||||||
}
|
}
|
||||||
sdx += icos;
|
sdx += icos;
|
||||||
sdy += isin;
|
sdy += isin;
|
||||||
|
@ -348,7 +342,7 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
|
||||||
SDL_Surface *rz_src;
|
SDL_Surface *rz_src;
|
||||||
SDL_Surface *rz_dst;
|
SDL_Surface *rz_dst;
|
||||||
int is32bit;
|
int is32bit;
|
||||||
int i, src_converted;
|
int i;
|
||||||
Uint8 r,g,b;
|
Uint8 r,g,b;
|
||||||
Uint32 colorkey = 0;
|
Uint32 colorkey = 0;
|
||||||
int colorKeyAvailable = 0;
|
int colorKeyAvailable = 0;
|
||||||
|
@ -375,27 +369,15 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
|
||||||
* Use source surface 'as is'
|
* Use source surface 'as is'
|
||||||
*/
|
*/
|
||||||
rz_src = src;
|
rz_src = src;
|
||||||
src_converted = 0;
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
Uint32 format = SDL_MasksToPixelFormatEnum(32,
|
||||||
* New source surface is 32bit with a defined RGBA ordering
|
|
||||||
*/
|
|
||||||
rz_src =
|
|
||||||
SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
|
|
||||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||||
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
|
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
|
||||||
#else
|
#else
|
||||||
0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
|
0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
if(colorKeyAvailable)
|
rz_src = SDL_ConvertSurfaceFormat(src, format, src->flags);
|
||||||
SDL_SetColorKey(src, 0, 0);
|
|
||||||
|
|
||||||
SDL_BlitSurface(src, NULL, rz_src, NULL);
|
|
||||||
|
|
||||||
if(colorKeyAvailable)
|
|
||||||
SDL_SetColorKey(src, SDL_TRUE /* SDL_SRCCOLORKEY */, colorkey);
|
|
||||||
src_converted = 1;
|
|
||||||
is32bit = 1;
|
is32bit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,6 +462,19 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
|
||||||
flipx, flipy);
|
flipx, flipy);
|
||||||
SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
|
SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* copy alpha mod, color mod, and blend mode */
|
||||||
|
{
|
||||||
|
SDL_BlendMode blendMode;
|
||||||
|
Uint8 alphaMod, r, g, b;
|
||||||
|
SDL_GetSurfaceAlphaMod(src, &alphaMod);
|
||||||
|
SDL_GetSurfaceBlendMode(src, &blendMode);
|
||||||
|
SDL_GetSurfaceColorMod(src, &r, &g, &b);
|
||||||
|
SDL_SetSurfaceAlphaMod(rz_dst, alphaMod);
|
||||||
|
SDL_SetSurfaceBlendMode(rz_dst, blendMode);
|
||||||
|
SDL_SetSurfaceColorMod(rz_dst, r, g, b);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unlock source surface
|
* Unlock source surface
|
||||||
*/
|
*/
|
||||||
|
@ -490,7 +485,7 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
|
||||||
/*
|
/*
|
||||||
* Cleanup temp surface
|
* Cleanup temp surface
|
||||||
*/
|
*/
|
||||||
if (src_converted) {
|
if (rz_src != src) {
|
||||||
SDL_FreeSurface(rz_src);
|
SDL_FreeSurface(rz_src);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,15 @@
|
||||||
#include <mach/mach_time.h>
|
#include <mach/mach_time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Use CLOCK_MONOTONIC_RAW, if available, which is not subject to adjustment by NTP */
|
||||||
|
#if HAVE_CLOCK_GETTIME
|
||||||
|
#ifdef CLOCK_MONOTONIC_RAW
|
||||||
|
#define SDL_MONOTONIC_CLOCK CLOCK_MONOTONIC_RAW
|
||||||
|
#else
|
||||||
|
#define SDL_MONOTONIC_CLOCK CLOCK_MONOTONIC
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The first ticks value of the application */
|
/* The first ticks value of the application */
|
||||||
#if HAVE_CLOCK_GETTIME
|
#if HAVE_CLOCK_GETTIME
|
||||||
static struct timespec start_ts;
|
static struct timespec start_ts;
|
||||||
|
@ -69,7 +78,7 @@ SDL_TicksInit(void)
|
||||||
|
|
||||||
/* Set first ticks value */
|
/* Set first ticks value */
|
||||||
#if HAVE_CLOCK_GETTIME
|
#if HAVE_CLOCK_GETTIME
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &start_ts) == 0) {
|
if (clock_gettime(SDL_MONOTONIC_CLOCK, &start_ts) == 0) {
|
||||||
has_monotonic_time = SDL_TRUE;
|
has_monotonic_time = SDL_TRUE;
|
||||||
} else
|
} else
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
|
@ -101,7 +110,7 @@ SDL_GetTicks(void)
|
||||||
if (has_monotonic_time) {
|
if (has_monotonic_time) {
|
||||||
#if HAVE_CLOCK_GETTIME
|
#if HAVE_CLOCK_GETTIME
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(SDL_MONOTONIC_CLOCK, &now);
|
||||||
ticks = (now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec -
|
ticks = (now.tv_sec - start_ts.tv_sec) * 1000 + (now.tv_nsec -
|
||||||
start_ts.tv_nsec) / 1000000;
|
start_ts.tv_nsec) / 1000000;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
|
@ -132,7 +141,7 @@ SDL_GetPerformanceCounter(void)
|
||||||
#if HAVE_CLOCK_GETTIME
|
#if HAVE_CLOCK_GETTIME
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(SDL_MONOTONIC_CLOCK, &now);
|
||||||
ticks = now.tv_sec;
|
ticks = now.tv_sec;
|
||||||
ticks *= 1000000000;
|
ticks *= 1000000000;
|
||||||
ticks += now.tv_nsec;
|
ticks += now.tv_nsec;
|
||||||
|
|
|
@ -373,6 +373,18 @@
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set a pixel value using the given format, except that the alpha value is
|
||||||
|
* placed in the top byte. This is the format used for RLE with alpha.
|
||||||
|
*/
|
||||||
|
#define RLEPIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \
|
||||||
|
{ \
|
||||||
|
Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
|
||||||
|
((g>>fmt->Gloss)<<fmt->Gshift)| \
|
||||||
|
((b>>fmt->Bloss)<<fmt->Bshift)| \
|
||||||
|
(a<<24); \
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This takes care of the case when the surface is clipped on the left and/or
|
* This takes care of the case when the surface is clipped on the left and/or
|
||||||
* right. Top clipping has already been taken care of.
|
* right. Top clipping has already been taken care of.
|
||||||
|
@ -982,7 +994,7 @@ copy_32(void *dst, Uint32 * src, int n,
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
unsigned r, g, b, a;
|
unsigned r, g, b, a;
|
||||||
RGBA_FROM_8888(*src, sfmt, r, g, b, a);
|
RGBA_FROM_8888(*src, sfmt, r, g, b, a);
|
||||||
PIXEL_FROM_RGBA(*d, dfmt, r, g, b, a);
|
RLEPIXEL_FROM_RGBA(*d, dfmt, r, g, b, a);
|
||||||
d++;
|
d++;
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue