src/render/SDL_render.c


Log

Author Commit Date CI Message
Sam Lantinga 7df0f4fd 2018-09-27T14:56:29 Fixed bug 4277 - warnings patch Sylvain Patch a few warnings when using: -Wmissing-prototypes -Wdocumentation -Wdocumentation-unknown-command They are automatically enabled with -Wall
Sam Lantinga 60afec79 2018-09-25T19:53:16 Removed redundant SDL_GetColorKey() call. (thanks Sylvain!)
Sam Lantinga ef347048 2018-09-24T16:41:55 Fixed bug 4264 - SDL_CreateTextureFromSurface generates error message but returns ok Anthony @ POW Games SDL_CreateTextureFromSurface makes an internal call to SDL_GetColorKey which can return an error and spams the error log with "Surface doesn't have a colorkey" even though the original function didn't return an error.
Sam Lantinga 74ec7cab 2018-06-18T13:13:56 Fixed race condition where Android touch events could get scaled by a render target's viewport
Ozkan Sezer fe032ff4 2018-05-10T08:25:23 do the direct3d tap dance for overscan hint only if SDL_VIDEO_RENDER_D3D == 1
Sam Lantinga eb14b635 2018-05-07T19:52:25 Fixed bug 4134 - Render targets lose scale quality after minimizing a fullscreen window Olli-Samuli Lehmus If one creates a window with the SDL_WINDOW_FULLSCREEN_DESKTOP flag, and creates a render target with SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"), and afterwards sets SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest"), after minimizing the window, the scale quality hint is lost on the render target. Textures however do keep their interpolation modes.
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Sam Lantinga 87894224 2017-12-12T16:34:16 Fixed bug 3981 - Inverted logic bug in SDL_renderer "overscan" feature Eric wing There is a tiny bug in the new overscan code for the SDL_renderer. In SDL_renderer.c, line 1265, the if check for SDL_strcasecmp with "direct3d" needs to be inverted. Instead of: if(SDL_strcasecmp("direct3d", SDL_GetCurrentVideoDriver())) { It should be: if(0 == SDL_strcasecmp("direct3d", SDL_GetCurrentVideoDriver())) { This bug causes the "overscan" mode to pretty much be completely ignored in all cases and all things remain letterboxed (as before the feature).
Sam Lantinga cf3d4503 2017-12-08T14:30:10 Added SDL_RenderGetMetalLayer() and SDL_RenderGetMetalCommandEncoder()
Sam Lantinga a7c79c5e 2017-10-12T08:37:55 Normalize touch events to the render viewport (thanks Sylvain!)
Sam Lantinga 04e76499 2017-08-14T20:37:07 Fixed build warning
Sam Lantinga 9451cd81 2017-08-14T20:07:30 Fixed compiler warnings
Sam Lantinga aebe17d3 2017-08-14T16:34:54 Fixed bug 2344 - CHECK_WINDOW_MAGIC should include __FILE__ and __LINE__ Martin Gerhardy just for easier debugging issues in the own code... SDL_CreateRenderer should maybe also use this macro Ryan C. Gordon I'll go one better: it should have an SDL_assert().
Sam Lantinga c59d9923 2017-08-14T05:51:44 Implemented more flexible blending modes for accelerated renderers This fixes bug 2594 - Propose new blend mode, SDL_BLENDMODE_BLEND_DSTA blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD); This fixes bug 2828 - Subtractive Blending blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT, SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT); This goes partway to fixing bug 3684 - Add support for a pre-multiplied alpha blending mode blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, SDL_BLENDFACTOR_ONE, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD);
Sam Lantinga ca5c3048 2017-08-13T21:06:52 Fixed bug 3744 - missing SDLCALL in several functions Ozkan Sezer The attached patch adds missing SDLCALL to several functions, so that they properly match the headers as intended.
Sam Lantinga af9ec8f6 2017-08-13T20:13:11 Fixed copy-paste error, thanks Alen!
Philipp Wiesemann 8aa147fa 2017-08-04T23:00:30 Fixed compiler warnings about type conversions. Found by buildbot.
Sam Lantinga 9dbe5a96 2017-08-02T13:38:46 Fixed bug 3311 - Broken touch positions with SDL_RenderSetLogicalSize & HIGHDPI on iOS Eric wing Hi, I think I found a bug when using SDL_WINDOW_ALLOW_HIGHDPI with SDL_RenderSetLogicalSize on iOS. I use SDL_RenderSetLogicalSize for all my stuff. I just tried turning on SDL_WINDOW_ALLOW_HIGHDPI on iOS and suddenly all my touch/mouse positions are really broken/far-off-the-mark. I actually don't have a real retina device (still) so I'm seeing this using the iOS simulator with a 6plus template. Attached is a simple test program that can reproduce the problem. It uses RenderSetLogicalSize and draws some moving happy faces (to show the boundaries/space of the LogicalSize and that it is working correctly for that part). When you click/touch, it will draw one more happy face where your button point is. If you comment out SDL_WINDOW_ALLOW_HIGHDPI, everything works as expected. But if you compile with it in, the mouse coordinates seem really far off the mark. (Face appears far up and to the left.) Alex Szpakowski on the mailing list suggests the problem is "I believe this is a bug in SDL_Render?s platform-agnostic mouse coordinate scaling code. It assumes the units of the mouse coordinates are always in pixels, which isn?t the case where high-DPI is involved (regardless of whether iOS is used) ? they?re actually in ?DPI independent? coordinates (which matches the window size, but not the renderer output size)." Additionally, if this is correct, the Mac under Retina is also probably affected too and "as well as any other platform SDL adds high-dpi support for in the future".
Ryan C. Gordon 92889836 2017-06-06T14:06:40 Merged Eric Wing's overscan patch. Fixes Bugzilla #2799.
Ryan C. Gordon ca0bf151 2017-03-03T16:38:17 Fix some more compiler warnings on armcc.
Ryan C. Gordon c1ac4c68 2017-01-06T21:17:33 Better fix for static analysis issue in SDL_DestroyRenderer(). Follow up fix for Bugzilla #3544.
Sam Lantinga 3df77ced 2017-01-06T00:40:22 Just roll back the entire portion of the commit from a8253d439914 which caused bug 3544 until we figure out what the right static analysis fix is.
Sam Lantinga 356c2ead 2017-01-06T00:32:06 Fixed bug 3544 - Memory freeing bug in SDL_DestroyRenderer/SDL_DestroyTexture felix Here's a snippet of SDL_DestroyRenderer from hg revision 10746:7540ff5d0e0e: SDL_Texture *texture = NULL; SDL_Texture *nexttexture = NULL; /* ... */ for (texture = renderer->textures; texture; texture = nexttexture) { nexttexture = texture->next; SDL_DestroyTexture(texture); } SDL_DestroyTexture removes the texture from the linked list pointed to by the renderer and ends up calling SDL_DestroyTextureInternal, which contains this: if (texture->native) { SDL_DestroyTexture(texture->native); } If it happens that texture->native is an alias of nexttexture two stack frames up, SDL_DestroyRenderer will end up trying to destroy an already freed texture. I've had this very situation happen in dosemu2. Bug introduced in revision 10650:a8253d439914, which has a somewhat ironic description of "Fixed all known static analysis bugs"...
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Ryan C. Gordon fb5fd67c 2016-11-24T21:41:09 Fixed all known static analysis bugs, with checker-279 on macOS.
Sam Lantinga 8e2634eb 2016-10-14T00:51:57 Fixed divide by zero if setting integer scale without setting logical width and height
Sam Lantinga 27d4f099 2016-10-07T23:40:44 Implemented SDL_GetHintBoolean() to make it easier to check boolean hints
Sam Lantinga 9c483655 2016-10-07T18:00:30 Fixed bug 3029 - software renderer cuts off edges when rotate-blitting with a multiple of 90 degrees Adam M. When doing a rotated texture copy with the software renderer, where the angle is a multiple of 90 degrees, one or two edges of the image get cut off. This is because of the following line in sw_rotate.c: if ((unsigned)dx < (unsigned)sw && (unsigned)dy < (unsigned)sh) { which is effectively saying: if (dx >= 0 && dx < src->w-1 && dy >= 0 && dy < src->h-1) { As a result, it doesn't process pixels in the right column or bottom row of the source image (except when they're accessed as part of the bilinear filtering for nearby pixels). This causes it to look like the edges are cut off, and it's especially obvious with an exact multiple of 90 degrees.
Sam Lantinga c8cfccc2 2016-10-01T14:31:00 Fixed bug 3116 - renderer->hidden in SDL_RenderCopy(Ex) Daniel Seems like check of the visibility of renderer (renderer->hidden) is missing in SDL_RenderCopyEx. In SDL_RenderCopy it should be done much earlier (after checking support for RenderCopyEx, line 1750).
Sam Lantinga 67901f53 2016-10-01T13:29:30 Fixed bug 3174 - SDL_SetRenderTarget clip rect Marcel Bakker In SDL_SetRenderTarget(), i think the intended behavior was to clear the clip rect when a new target is set.
Ryan C. Gordon 2a2c8d42 2016-04-21T03:16:44 Initial shot at a renderer target for Apple's Metal API. This isn't complete, but is enough to run testsprite2. It's currently Mac-only; with a little work to figure out how to properly glue in a Metal layer to a UIView, this will likely work on iOS, too. This is only wired up to the configure script right now, and disabled by default. CMake and Xcode still need their bits filled in as appropriate.
Eric Wing bb3cb4f4 2016-04-04T19:25:24 overscan (feature for SDL_RenderSetLogicalSize): Fix to ignore overscan hint when using the Direct3D 9 backend. D39 does not support negative viewport values which the current implementation relies on. D3D11 does support negative viewport values so that will continue working. Refer to Bug 2799.
Philipp Wiesemann 0a1999df 2016-01-16T21:25:10 Fixed compile warnings about type conversion. Found by buildbot.
Ethan Lee 167cf14c 2016-01-05T16:39:18 SDL_RenderSetIntegerScale
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
David Ludwig 9e9ef5ad 2015-12-27T17:55:45 Fixed bug 3202 - Fix renderer visibility on a window maximized directly from the minimized state Many thanks to id.zeta for details on the bug, and for the fix!
Philipp Wiesemann 0856a7ef 2015-08-21T23:50:37 Changed an error return value from 0 to NULL for consistency.
Philipp Wiesemann 0e45984f 2015-06-21T17:33:46 Fixed crash if initialization of EGL failed but was tried again later. The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly uninitialized data structure if loading the library first failed. A later try to use EGL then skipped initialization and assumed it was previously successful because the data structure now already existed. This led to at least one crash in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was dereferenced to make a call to eglBindAPI().
Eric Wing d77a5573 2015-06-21T04:04:14 merged SDL 2.0.4 rc2
Sam Lantinga b7ede6cc 2015-06-19T23:20:43 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.
Eric Wing 27fab8f4 2015-06-17T20:03:08 merged SDL 2.0.4rc1+
Sam Lantinga 6a3ad8a9 2015-05-28T12:18:05 Fixed bug 2367 - Bad mouse motion coordinates with two windows where one has changed logical size Andreas Ragnerstam I have two windows where one has a renderer where the logical size has been changed with SDL_RenderSetLogicalSize. When I get SDL_MOUSEMOTION events belonging to the non-scaled window these will have been scaled with the factor of the scaled window, which is not expected. Adding some printf debugging to SDL_RendererEventWatch of SDL_render.c, where (event->type == SDL_MOUSEMOTION), I found that for every mouse motion SDL_RendererEventWatch is called twice and the event->motion.x and event.motion.y are set twice for the event, once for each renderer where only the last one set will be saved to the event struct. This will work fine if both renderers have the same scale, but otherwise the motion coordinates will be scaled for the renderer belonging to another window than the mouse was moved in. I guess one solution would be to check that window == renderer->window for SDL_MOUSEMOTION events, similar to what is done for when SDL_WINDOWEVENT events. I get the same error on both X11 and Windows. The same problem also exists for SDL_MOUSEBUTTONDOWN and SDL_MOUSEBUTTONUP events.
Ryan C. Gordon d5a57853 2015-05-26T16:42:36 Drop out of SDL_UpdateTexture() early if the rectangle is zero pixels. Hopefully makes static analysis happy about a zero-byte malloc elsewhere.
Sam Lantinga 2c4a6ea0 2015-05-26T06:27:46 Updated the copyright year to 2015
Ryan C. Gordon b72938c8 2015-04-20T12:22:44 Windows: Always set the system timer resolution to 1ms by default. An existing hint lets apps that don't need the timer resolution changed avoid this, to save battery, etc, but this fixes several problems in timing, audio callbacks not firing fast enough, etc. Fixes Bugzilla #2944.
Alex Szpakowski fe6c797c 2015-04-10T23:30:31 Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
Edward Rudd b88ca1b4 2015-02-10T16:28:56 the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here. Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here. Not 5 or 10 depending on the architecture. More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
Philipp Wiesemann b48e54aa 2015-01-26T22:00:29 Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation Jonas Kulla The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c. I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
David Ludwig 70438be2 2014-12-03T10:55:23 WinRT: fixed bug whereby SDL would override an app's default orientation WinRT apps can set a default, preferred orientation via a .appxmanifest file. SDL was overriding this on app startup, and making the app use all possible orientations (landscape and portrait). Thanks to Eric Wing for the heads up on this!
Eric Wing 31388117 2014-12-03T04:41:26 Adds support to control the scaling policy/mode of SDL_RenderSetLogicalSize for both letterbox (current behavior) and a new overscan mode (expand to fill the entire screen, even if some parts draw off the screen). The expected use case is for games that are designed with multiple aspect ratios already in mind and leave optional margins on the edges of the game which won't hurt if they are cut off. An example use case is a game is designed for wide-screen/16:9, but then wants to deploy on an iPad which is 4:3. Normally, SDL will letterbox, which will shrink things and result in wasted space. But the designer already thought about 4:3 and designed the edges of the game so they could be cut off without any functional loss. So rather than wasting space with letterboxing, "overscan" mode will zoom the rendering to fill up the entire screen. Parts on the edges will be drawn offscreen, but since the game was already designed with this in mind, it is fine. The end result is the iPad (4:3) experience is much better since it feels like a game designed for that screen aspect ratio. This patch introduces a new SDL_hint: SDL_HINT_RENDER_LOGICAL_SIZE_MODE. Valid values are "letterbox" or "0" for letterboxing and "overscan" or "1" for overscan. The default mode is letterbox to preserve existing behavior. // Example usage: SDL_SetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE, "overscan"); SDL_RenderSetLogicalSize(renderer, SCREEN_WIDTH, SCREEN_HEIGHT);
Philipp Wiesemann 9c398852 2014-11-22T22:20:40 Corrected header file documentation comment.
Pierre-Loup A. Griffais 24c86b55 2014-09-11T19:24:42 [X11] Reconcile logical keyboard state with physical state on FocusIn since the window system doesn't do it for us like other platforms. This prevents sticky keys and missed keys when going in and out of focus, for example Alt would appear to stick if switching away from an SDL app with Alt-Tab and had to be pressed again. CR: Sam
Sam Lantinga 2e3c778e 2014-08-17T14:34:41 Fixed bug where the render target is updated instead of the default output when the window is resized.
Sam Lantinga 529ed53b 2014-08-16T23:30:44 Fixed bug 2681 - dereference a NULL pointer dst_fmt in SDL_CreateTextureFromSurface function Nitz In SDL_CreateTextureFromSurface: SDL_PixelFormat *dst_fmt; /* Set up a destination surface for the texture update */ dst_fmt = SDL_AllocFormat(format); temp = SDL_ConvertSurface(surface, dst_fmt, 0); Here is need of NULL check for dst_fmt because there are chances of NULL return from SDL_AllocFormat(format);
J?rgen P. Tjern? defd90b6 2014-04-19T13:15:41 Render: Allow empty cliprect. This fixes an issue where an empty cliprect is treated the same as a NULL cliprect, causing the render backends to disable clipping. Also adds a new API, SDL_RenderIsClipEnabled(render) that allows you to differentiate between: - SDL_RenderSetClipRect(render, NULL) - SDL_Rect r = {0,0,0,0}; SDL_RenderSetClipRect(render, &r); Fixes https://bugzilla.libsdl.org/show_bug.cgi?id=2504
David Ludwig 3dcb451f 2014-04-09T21:29:19 Added a README file regarding WinRT support To note, this file is currently formatted with CRLF line endings, rather than LF, to allow the file to be viewed with Notepad.
Ryan C. Gordon 93ba5bd8 2014-03-20T16:23:18 Static analysis fix: uninitialized value. (A false positive: clang doesn't know SDL_SetError() always returns -1.)
Ryan C. Gordon 415675be 2014-03-20T11:14:44 Static analysis fix: division by zero.
Ryan C. Gordon b659c700 2014-03-20T10:41:47 Static analysis fix: uninitialized variables. This is actually a false-positive, in this case, since Clang doesn't know that SDL_SetError() only ever returns -1. Feature request to improve that, with explanation about these specific SDL patches, is here: http://llvm.org/bugs/show_bug.cgi?id=19208
Sam Lantinga 2c558ca2 2014-03-10T17:19:19 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX
Sam Lantinga 1a35f32b 2014-03-10T01:51:03 Converted David Ludwig's D3D11 renderer to C and optimized it. The D3D11 renderer is now slightly faster than D3D9 on my Windows 8 machine (testsprite2 runs at 3400 FPS vs 3100 FPS) This will need tweaking to fix the Windows RT build.
Sam Lantinga 1367bf87 2014-03-09T11:36:47 Integrated David Ludwig's support for Windows RT
Gabriel Jacobo 6ee12d6c 2014-02-24T18:57:22 Fixes #2296 - SDL_GL_UnbindTexture segfaults (thanks Daniel B?nzli)
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
Gabriel Jacobo f848adff 2013-11-29T10:06:08 Improve Android pause/resume behavior.
David Ludwig 46740a5a 2013-11-28T22:09:21 WinRT: merged with latest SDL 2.x/HG code SDL 2.x recently accepted patches to enable OpenGL ES 2 support via Google's ANGLE library. The thought is to try to eventually merge SDL/WinRT's OpenGL code with SDL-official's.
Ryan C. Gordon 7e1289af 2013-11-24T23:56:17 Make internal SDL sources include SDL_internal.h instead of SDL_config.h The new header will include SDL_config.h, but allows for other global stuff.
Philipp Wiesemann 4e270de1 2013-11-02T11:46:43 Changed function to return -1 through SDL_Error() instead of plain -1.
David Ludwig 69c5d21d 2013-10-27T21:26:46 WinRT: merged with SDL 2.0.1 codebase
Sam Lantinga 22a972a4 2013-09-30T22:16:14 Fixed bug 2122 - SDL_CreateTexture allows illegal texture sizes Lloyd Bryant SDL_CreateTexture() is succeeding (i.e. returning a valid pointer) when the requested horizontal or vertical size of the texture exceeds the maximum allowed by the render. This results in hard-to-understand errors showing up when later attempting to use that texture (such as with SDL_SetRenderTarget()).
Sam Lantinga 89c31bb4 2013-09-28T14:06:55 Implemented SDL_UpdateYUVTexture() for Direct3D
Sam Lantinga 17c9ff85 2013-09-28T14:06:51 Added missing SDL_assert.h
Sam Lantinga 57bd5147 2013-09-28T14:06:47 Added optimized YUV texture upload path with SDL_UpdateYUVTexture()
Edward Rudd 869a7076 2013-09-20T13:43:00 add in High DPI support (aka Retina) - based on J?rgen's patch with a few bug fixes
Sam Lantinga f79fc33a 2013-08-29T08:29:21 Christoph Mallon: Remove pointless if (x) before SDL_free(x)
David Ludwig d41fdc94 2013-08-13T20:09:52 WinRT: build fixes and additional WinRT-related integrations with SDL 2.0.0
Gabriel Jacobo dad42067 2013-08-12T11:13:50 Fixes #2022, do not resume on Android when surfaceChanged If the app is in landscape mode and the user presses the power button, a pause is followed immediately by a surfaceChanged event because the lock screen is shown in portrait mode. This triggers a "false" resume. So, we just pause and resume following the onWindowFocusChanged events. Also, wait for SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND before blocking the event pump.
Sam Lantinga 1ad936eb 2013-08-11T19:56:43 Fixed bug 2027 - Full-screen appears to be broken - hang in SDL_DestroyWindow() Rainer Deyke I'm running Linux Mint 15 with the Cinnamon window manager. SDL_DestroyWindow consistently locks up for me when the window if fullscreen.