mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-03 16:36:25 +00:00
Merge SDL-ryan-batching-renderer branch to default.
This commit is contained in:
@@ -1071,7 +1071,8 @@ GetClosestSupportedFormat(SDL_Renderer * renderer, Uint32 format)
|
||||
return renderer->info.texture_formats[0];
|
||||
}
|
||||
|
||||
SDL_ScaleMode SDL_GetScaleMode(void)
|
||||
|
||||
static SDL_ScaleMode SDL_GetScaleMode(void)
|
||||
{
|
||||
const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
|
||||
|
||||
@@ -1199,7 +1200,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
|
||||
|
||||
/* See what the best texture format is */
|
||||
fmt = surface->format;
|
||||
if (fmt->Amask || SDL_GetColorKey(surface, NULL) == 0) {
|
||||
if (fmt->Amask || SDL_HasColorKey(surface)) {
|
||||
needAlpha = SDL_TRUE;
|
||||
} else {
|
||||
needAlpha = SDL_FALSE;
|
||||
@@ -1258,7 +1259,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
|
||||
SDL_GetSurfaceAlphaMod(surface, &a);
|
||||
SDL_SetTextureAlphaMod(texture, a);
|
||||
|
||||
if (SDL_GetColorKey(surface, NULL) == 0) {
|
||||
if (SDL_HasColorKey(surface)) {
|
||||
/* We converted to a texture with alpha format */
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||
} else {
|
||||
|
@@ -18,6 +18,10 @@
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_yuv_sw_c_h_
|
||||
#define SDL_yuv_sw_c_h_
|
||||
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#include "SDL_video.h"
|
||||
@@ -64,4 +68,6 @@ void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata);
|
||||
#define USE_MMX_ASSEMBLY 1
|
||||
#endif
|
||||
|
||||
#endif /* SDL_yuv_sw_c_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -456,11 +456,6 @@ METAL_ActivateRenderCommandEncoder(SDL_Renderer * renderer, MTLLoadAction load,
|
||||
static void
|
||||
METAL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
{
|
||||
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||
METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata;
|
||||
data.mtllayer.drawableSize = CGSizeMake(event->data1, event->data2);
|
||||
}
|
||||
|
||||
if (event->event == SDL_WINDOWEVENT_SHOWN ||
|
||||
event->event == SDL_WINDOWEVENT_HIDDEN) {
|
||||
// !!! FIXME: write me
|
||||
@@ -552,12 +547,20 @@ METAL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
mtltexdesc.height = (texture->h + 1) / 2;
|
||||
mtltexdesc.textureType = MTLTextureType2DArray;
|
||||
mtltexdesc.arrayLength = 2;
|
||||
mtltexture_uv = [data.mtldevice newTextureWithDescriptor:mtltexdesc];
|
||||
} else if (nv12) {
|
||||
mtltexdesc.pixelFormat = MTLPixelFormatRG8Unorm;
|
||||
mtltexdesc.width = (texture->w + 1) / 2;
|
||||
mtltexdesc.height = (texture->h + 1) / 2;
|
||||
}
|
||||
|
||||
if (yuv || nc12) {
|
||||
mtltexture_uv = [data.mtldevice newTextureWithDescriptor:mtltexdesc];
|
||||
if (mtltexture_uv == nil) {
|
||||
#if !__has_feature(objc_arc)
|
||||
[mtltexture release];
|
||||
#endif
|
||||
return SDL_SetError("Texture allocation failed");
|
||||
}
|
||||
}
|
||||
|
||||
METAL_TextureData *texturedata = [[METAL_TextureData alloc] init];
|
||||
|
@@ -1529,7 +1529,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
|
||||
data = (GL_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
GL_DestroyRenderer(renderer);
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
@@ -1563,16 +1563,21 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
|
||||
data->context = SDL_GL_CreateContext(window);
|
||||
if (!data->context) {
|
||||
GL_DestroyRenderer(renderer);
|
||||
SDL_free(renderer);
|
||||
SDL_free(data);
|
||||
goto error;
|
||||
}
|
||||
if (SDL_GL_MakeCurrent(window, data->context) < 0) {
|
||||
GL_DestroyRenderer(renderer);
|
||||
SDL_GL_DeleteContext(data->context);
|
||||
SDL_free(renderer);
|
||||
SDL_free(data);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (GL_LoadFunctions(data) < 0) {
|
||||
GL_DestroyRenderer(renderer);
|
||||
SDL_GL_DeleteContext(data->context);
|
||||
SDL_free(renderer);
|
||||
SDL_free(data);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,10 @@
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_shaders_gl_h_
|
||||
#define SDL_shaders_gl_h_
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
/* OpenGL shader implementation */
|
||||
@@ -45,4 +49,6 @@ extern GL_ShaderContext * GL_CreateShaderContext(void);
|
||||
extern void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader);
|
||||
extern void GL_DestroyShaderContext(GL_ShaderContext *ctx);
|
||||
|
||||
#endif /* SDL_shaders_gl_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -1942,7 +1942,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
|
||||
data = (GLES2_RenderData *)SDL_calloc(1, sizeof(GLES2_RenderData));
|
||||
if (!data) {
|
||||
GLES2_DestroyRenderer(renderer);
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
@@ -1954,16 +1954,21 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
/* Create an OpenGL ES 2.0 context */
|
||||
data->context = SDL_GL_CreateContext(window);
|
||||
if (!data->context) {
|
||||
GLES2_DestroyRenderer(renderer);
|
||||
SDL_free(renderer);
|
||||
SDL_free(data);
|
||||
goto error;
|
||||
}
|
||||
if (SDL_GL_MakeCurrent(window, data->context) < 0) {
|
||||
GLES2_DestroyRenderer(renderer);
|
||||
SDL_GL_DeleteContext(data->context);
|
||||
SDL_free(renderer);
|
||||
SDL_free(data);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (GLES2_LoadFunctions(data) < 0) {
|
||||
GLES2_DestroyRenderer(renderer);
|
||||
SDL_GL_DeleteContext(data->context);
|
||||
SDL_free(renderer);
|
||||
SDL_free(data);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@@ -18,10 +18,16 @@
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_blendfillrect_h_
|
||||
#define SDL_blendfillrect_h_
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
#endif /* SDL_blendfillrect_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -18,10 +18,16 @@
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_blendline_h_
|
||||
#define SDL_blendline_h_
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
#endif /* SDL_blendline_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -18,10 +18,16 @@
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_blendpoint_h_
|
||||
#define SDL_blendpoint_h_
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern int SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
#endif /* SDL_blendpoint_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -18,10 +18,16 @@
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_drawline_h_
|
||||
#define SDL_drawline_h_
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color);
|
||||
extern int SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color);
|
||||
|
||||
#endif /* SDL_drawline_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -18,10 +18,16 @@
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_drawpoint_h_
|
||||
#define SDL_drawpoint_h_
|
||||
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
extern int SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color);
|
||||
extern int SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color);
|
||||
|
||||
#endif /* SDL_drawpoint_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -377,6 +377,11 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
|
||||
blitRequired = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* srcrect is not selecting the whole src surface, so cropping is needed */
|
||||
if (!(srcrect->w == src->w && srcrect->h == src->h && srcrect->x == 0 && srcrect->y == 0)) {
|
||||
blitRequired = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* The color and alpha modulation has to be applied before the rotation when using the NONE and MOD blend modes. */
|
||||
if ((blendmode == SDL_BLENDMODE_NONE || blendmode == SDL_BLENDMODE_MOD) && (alphaMod & rMod & gMod & bMod) != 255) {
|
||||
applyModulation = SDL_TRUE;
|
||||
|
@@ -19,6 +19,11 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_render_sw_c_h_
|
||||
#define SDL_render_sw_c_h_
|
||||
|
||||
extern SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface * surface);
|
||||
|
||||
#endif /* SDL_render_sw_c_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
@@ -83,7 +83,9 @@ static Uint32
|
||||
_colorkey(SDL_Surface *src)
|
||||
{
|
||||
Uint32 key = 0;
|
||||
SDL_GetColorKey(src, &key);
|
||||
if (SDL_HasColorKey(src)) {
|
||||
SDL_GetColorKey(src, &key);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
@@ -424,8 +426,10 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
|
||||
if (src == NULL)
|
||||
return NULL;
|
||||
|
||||
if (SDL_GetColorKey(src, &colorkey) == 0) {
|
||||
colorKeyAvailable = SDL_TRUE;
|
||||
if (SDL_HasColorKey(src)) {
|
||||
if (SDL_GetColorKey(src, &colorkey) == 0) {
|
||||
colorKeyAvailable = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* This function requires a 32-bit surface or 8-bit surface with a colorkey */
|
||||
|
@@ -19,6 +19,9 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef SDL_rotate_h_
|
||||
#define SDL_rotate_h_
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
@@ -26,3 +29,4 @@
|
||||
extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle);
|
||||
extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle);
|
||||
|
||||
#endif /* SDL_rotate_h_ */
|
||||
|
Reference in New Issue
Block a user