early-access version 1611
This commit is contained in:
136
externals/SDL/src/render/SDL_d3dmath.c
vendored
Executable file
136
externals/SDL/src/render/SDL_d3dmath.c
vendored
Executable file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "SDL_d3dmath.h"
|
||||
|
||||
/* Direct3D matrix math functions */
|
||||
|
||||
Float4X4 MatrixIdentity()
|
||||
{
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = 1.0f;
|
||||
m.v._22 = 1.0f;
|
||||
m.v._33 = 1.0f;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2)
|
||||
{
|
||||
Float4X4 m;
|
||||
m.v._11 = M1.v._11 * M2.v._11 + M1.v._12 * M2.v._21 + M1.v._13 * M2.v._31 + M1.v._14 * M2.v._41;
|
||||
m.v._12 = M1.v._11 * M2.v._12 + M1.v._12 * M2.v._22 + M1.v._13 * M2.v._32 + M1.v._14 * M2.v._42;
|
||||
m.v._13 = M1.v._11 * M2.v._13 + M1.v._12 * M2.v._23 + M1.v._13 * M2.v._33 + M1.v._14 * M2.v._43;
|
||||
m.v._14 = M1.v._11 * M2.v._14 + M1.v._12 * M2.v._24 + M1.v._13 * M2.v._34 + M1.v._14 * M2.v._44;
|
||||
m.v._21 = M1.v._21 * M2.v._11 + M1.v._22 * M2.v._21 + M1.v._23 * M2.v._31 + M1.v._24 * M2.v._41;
|
||||
m.v._22 = M1.v._21 * M2.v._12 + M1.v._22 * M2.v._22 + M1.v._23 * M2.v._32 + M1.v._24 * M2.v._42;
|
||||
m.v._23 = M1.v._21 * M2.v._13 + M1.v._22 * M2.v._23 + M1.v._23 * M2.v._33 + M1.v._24 * M2.v._43;
|
||||
m.v._24 = M1.v._21 * M2.v._14 + M1.v._22 * M2.v._24 + M1.v._23 * M2.v._34 + M1.v._24 * M2.v._44;
|
||||
m.v._31 = M1.v._31 * M2.v._11 + M1.v._32 * M2.v._21 + M1.v._33 * M2.v._31 + M1.v._34 * M2.v._41;
|
||||
m.v._32 = M1.v._31 * M2.v._12 + M1.v._32 * M2.v._22 + M1.v._33 * M2.v._32 + M1.v._34 * M2.v._42;
|
||||
m.v._33 = M1.v._31 * M2.v._13 + M1.v._32 * M2.v._23 + M1.v._33 * M2.v._33 + M1.v._34 * M2.v._43;
|
||||
m.v._34 = M1.v._31 * M2.v._14 + M1.v._32 * M2.v._24 + M1.v._33 * M2.v._34 + M1.v._34 * M2.v._44;
|
||||
m.v._41 = M1.v._41 * M2.v._11 + M1.v._42 * M2.v._21 + M1.v._43 * M2.v._31 + M1.v._44 * M2.v._41;
|
||||
m.v._42 = M1.v._41 * M2.v._12 + M1.v._42 * M2.v._22 + M1.v._43 * M2.v._32 + M1.v._44 * M2.v._42;
|
||||
m.v._43 = M1.v._41 * M2.v._13 + M1.v._42 * M2.v._23 + M1.v._43 * M2.v._33 + M1.v._44 * M2.v._43;
|
||||
m.v._44 = M1.v._41 * M2.v._14 + M1.v._42 * M2.v._24 + M1.v._43 * M2.v._34 + M1.v._44 * M2.v._44;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixScaling(float x, float y, float z)
|
||||
{
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = x;
|
||||
m.v._22 = y;
|
||||
m.v._33 = z;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixTranslation(float x, float y, float z)
|
||||
{
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = 1.0f;
|
||||
m.v._22 = 1.0f;
|
||||
m.v._33 = 1.0f;
|
||||
m.v._44 = 1.0f;
|
||||
m.v._41 = x;
|
||||
m.v._42 = y;
|
||||
m.v._43 = z;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixRotationX(float r)
|
||||
{
|
||||
float sinR = SDL_sinf(r);
|
||||
float cosR = SDL_cosf(r);
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = 1.0f;
|
||||
m.v._22 = cosR;
|
||||
m.v._23 = sinR;
|
||||
m.v._32 = -sinR;
|
||||
m.v._33 = cosR;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixRotationY(float r)
|
||||
{
|
||||
float sinR = SDL_sinf(r);
|
||||
float cosR = SDL_cosf(r);
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = cosR;
|
||||
m.v._13 = -sinR;
|
||||
m.v._22 = 1.0f;
|
||||
m.v._31 = sinR;
|
||||
m.v._33 = cosR;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixRotationZ(float r)
|
||||
{
|
||||
float sinR = SDL_sinf(r);
|
||||
float cosR = SDL_cosf(r);
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m.v._11 = cosR;
|
||||
m.v._12 = sinR;
|
||||
m.v._21 = -sinR;
|
||||
m.v._22 = cosR;
|
||||
m.v._33 = 1.0f;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
|
||||
}
|
||||
|
||||
#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
72
externals/SDL/src/render/SDL_d3dmath.h
vendored
Executable file
72
externals/SDL/src/render/SDL_d3dmath.h
vendored
Executable file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED
|
||||
|
||||
/* Direct3D matrix math functions */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
} Float2;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} Float3;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float w;
|
||||
} Float4;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union {
|
||||
struct {
|
||||
float _11, _12, _13, _14;
|
||||
float _21, _22, _23, _24;
|
||||
float _31, _32, _33, _34;
|
||||
float _41, _42, _43, _44;
|
||||
} v;
|
||||
float m[4][4];
|
||||
};
|
||||
} Float4X4;
|
||||
|
||||
|
||||
Float4X4 MatrixIdentity();
|
||||
Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2);
|
||||
Float4X4 MatrixScaling(float x, float y, float z);
|
||||
Float4X4 MatrixTranslation(float x, float y, float z);
|
||||
Float4X4 MatrixRotationX(float r);
|
||||
Float4X4 MatrixRotationY(float r);
|
||||
Float4X4 MatrixRotationZ(float r);
|
||||
|
||||
#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
3404
externals/SDL/src/render/SDL_render.c
vendored
Executable file
3404
externals/SDL/src/render/SDL_render.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
256
externals/SDL/src/render/SDL_sysrender.h
vendored
Executable file
256
externals/SDL/src/render/SDL_sysrender.h
vendored
Executable file
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_sysrender_h_
|
||||
#define SDL_sysrender_h_
|
||||
|
||||
#include "SDL_render.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_mutex.h"
|
||||
#include "SDL_yuv_sw_c.h"
|
||||
|
||||
/* The SDL 2D rendering system */
|
||||
|
||||
typedef struct SDL_RenderDriver SDL_RenderDriver;
|
||||
|
||||
/* Define the SDL texture structure */
|
||||
struct SDL_Texture
|
||||
{
|
||||
const void *magic;
|
||||
Uint32 format; /**< The pixel format of the texture */
|
||||
int access; /**< SDL_TextureAccess */
|
||||
int w; /**< The width of the texture */
|
||||
int h; /**< The height of the texture */
|
||||
int modMode; /**< The texture modulation mode */
|
||||
SDL_BlendMode blendMode; /**< The texture blend mode */
|
||||
SDL_ScaleMode scaleMode; /**< The texture scale mode */
|
||||
Uint8 r, g, b, a; /**< Texture modulation values */
|
||||
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
/* Support for formats not supported directly by the renderer */
|
||||
SDL_Texture *native;
|
||||
SDL_SW_YUVTexture *yuv;
|
||||
void *pixels;
|
||||
int pitch;
|
||||
SDL_Rect locked_rect;
|
||||
SDL_Surface *locked_surface; /**< Locked region exposed as a SDL surface */
|
||||
|
||||
Uint32 last_command_generation; /* last command queue generation this texture was in. */
|
||||
|
||||
void *driverdata; /**< Driver specific texture representation */
|
||||
|
||||
SDL_Texture *prev;
|
||||
SDL_Texture *next;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDL_RENDERCMD_NO_OP,
|
||||
SDL_RENDERCMD_SETVIEWPORT,
|
||||
SDL_RENDERCMD_SETCLIPRECT,
|
||||
SDL_RENDERCMD_SETDRAWCOLOR,
|
||||
SDL_RENDERCMD_CLEAR,
|
||||
SDL_RENDERCMD_DRAW_POINTS,
|
||||
SDL_RENDERCMD_DRAW_LINES,
|
||||
SDL_RENDERCMD_FILL_RECTS,
|
||||
SDL_RENDERCMD_COPY,
|
||||
SDL_RENDERCMD_COPY_EX
|
||||
} SDL_RenderCommandType;
|
||||
|
||||
typedef struct SDL_RenderCommand
|
||||
{
|
||||
SDL_RenderCommandType command;
|
||||
union {
|
||||
struct {
|
||||
size_t first;
|
||||
SDL_Rect rect;
|
||||
} viewport;
|
||||
struct {
|
||||
SDL_bool enabled;
|
||||
SDL_Rect rect;
|
||||
} cliprect;
|
||||
struct {
|
||||
size_t first;
|
||||
size_t count;
|
||||
Uint8 r, g, b, a;
|
||||
SDL_BlendMode blend;
|
||||
SDL_Texture *texture;
|
||||
} draw;
|
||||
struct {
|
||||
size_t first;
|
||||
Uint8 r, g, b, a;
|
||||
} color;
|
||||
} data;
|
||||
struct SDL_RenderCommand *next;
|
||||
} SDL_RenderCommand;
|
||||
|
||||
|
||||
/* Define the SDL renderer structure */
|
||||
struct SDL_Renderer
|
||||
{
|
||||
const void *magic;
|
||||
|
||||
void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event);
|
||||
int (*GetOutputSize) (SDL_Renderer * renderer, int *w, int *h);
|
||||
SDL_bool (*SupportsBlendMode)(SDL_Renderer * renderer, SDL_BlendMode blendMode);
|
||||
int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
int (*QueueSetViewport) (SDL_Renderer * renderer, SDL_RenderCommand *cmd);
|
||||
int (*QueueSetDrawColor) (SDL_Renderer * renderer, SDL_RenderCommand *cmd);
|
||||
int (*QueueDrawPoints) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points,
|
||||
int count);
|
||||
int (*QueueDrawLines) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points,
|
||||
int count);
|
||||
int (*QueueFillRects) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects,
|
||||
int count);
|
||||
int (*QueueCopy) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect);
|
||||
int (*QueueCopyEx) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
|
||||
const SDL_Rect * srcquad, const SDL_FRect * dstrect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
|
||||
int (*RunCommandQueue) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize);
|
||||
int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels,
|
||||
int pitch);
|
||||
int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch);
|
||||
int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch);
|
||||
void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
void (*SetTextureScaleMode) (SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode);
|
||||
int (*SetRenderTarget) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch);
|
||||
void (*RenderPresent) (SDL_Renderer * renderer);
|
||||
void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
|
||||
void (*DestroyRenderer) (SDL_Renderer * renderer);
|
||||
|
||||
int (*GL_BindTexture) (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh);
|
||||
int (*GL_UnbindTexture) (SDL_Renderer * renderer, SDL_Texture *texture);
|
||||
|
||||
void *(*GetMetalLayer) (SDL_Renderer * renderer);
|
||||
void *(*GetMetalCommandEncoder) (SDL_Renderer * renderer);
|
||||
|
||||
/* The current renderer info */
|
||||
SDL_RendererInfo info;
|
||||
|
||||
/* The window associated with the renderer */
|
||||
SDL_Window *window;
|
||||
SDL_bool hidden;
|
||||
|
||||
/* The logical resolution for rendering */
|
||||
int logical_w;
|
||||
int logical_h;
|
||||
int logical_w_backup;
|
||||
int logical_h_backup;
|
||||
|
||||
/* Whether or not to force the viewport to even integer intervals */
|
||||
SDL_bool integer_scale;
|
||||
|
||||
/* The drawable area within the window */
|
||||
SDL_Rect viewport;
|
||||
SDL_Rect viewport_backup;
|
||||
|
||||
/* The clip rectangle within the window */
|
||||
SDL_Rect clip_rect;
|
||||
SDL_Rect clip_rect_backup;
|
||||
|
||||
/* Wether or not the clipping rectangle is used. */
|
||||
SDL_bool clipping_enabled;
|
||||
SDL_bool clipping_enabled_backup;
|
||||
|
||||
/* The render output coordinate scale */
|
||||
SDL_FPoint scale;
|
||||
SDL_FPoint scale_backup;
|
||||
|
||||
/* The pixel to point coordinate scale */
|
||||
SDL_FPoint dpi_scale;
|
||||
|
||||
/* The list of textures */
|
||||
SDL_Texture *textures;
|
||||
SDL_Texture *target;
|
||||
SDL_mutex *target_mutex;
|
||||
|
||||
Uint8 r, g, b, a; /**< Color for drawing operations values */
|
||||
SDL_BlendMode blendMode; /**< The drawing blend mode */
|
||||
|
||||
SDL_bool always_batch;
|
||||
SDL_bool batching;
|
||||
SDL_RenderCommand *render_commands;
|
||||
SDL_RenderCommand *render_commands_tail;
|
||||
SDL_RenderCommand *render_commands_pool;
|
||||
Uint32 render_command_generation;
|
||||
Uint32 last_queued_color;
|
||||
SDL_Rect last_queued_viewport;
|
||||
SDL_Rect last_queued_cliprect;
|
||||
SDL_bool last_queued_cliprect_enabled;
|
||||
SDL_bool color_queued;
|
||||
SDL_bool viewport_queued;
|
||||
SDL_bool cliprect_queued;
|
||||
|
||||
void *vertex_data;
|
||||
size_t vertex_data_used;
|
||||
size_t vertex_data_allocation;
|
||||
|
||||
void *driverdata;
|
||||
};
|
||||
|
||||
/* Define the SDL render driver structure */
|
||||
struct SDL_RenderDriver
|
||||
{
|
||||
SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
|
||||
|
||||
/* Info about the renderer capabilities */
|
||||
SDL_RendererInfo info;
|
||||
};
|
||||
|
||||
/* Not all of these are available in a given build. Use #ifdefs, etc. */
|
||||
extern SDL_RenderDriver D3D_RenderDriver;
|
||||
extern SDL_RenderDriver D3D11_RenderDriver;
|
||||
extern SDL_RenderDriver GL_RenderDriver;
|
||||
extern SDL_RenderDriver GLES2_RenderDriver;
|
||||
extern SDL_RenderDriver GLES_RenderDriver;
|
||||
extern SDL_RenderDriver DirectFB_RenderDriver;
|
||||
extern SDL_RenderDriver METAL_RenderDriver;
|
||||
extern SDL_RenderDriver PSP_RenderDriver;
|
||||
extern SDL_RenderDriver SW_RenderDriver;
|
||||
|
||||
/* Blend mode functions */
|
||||
extern SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode);
|
||||
extern SDL_BlendFactor SDL_GetBlendModeDstColorFactor(SDL_BlendMode blendMode);
|
||||
extern SDL_BlendOperation SDL_GetBlendModeColorOperation(SDL_BlendMode blendMode);
|
||||
extern SDL_BlendFactor SDL_GetBlendModeSrcAlphaFactor(SDL_BlendMode blendMode);
|
||||
extern SDL_BlendFactor SDL_GetBlendModeDstAlphaFactor(SDL_BlendMode blendMode);
|
||||
extern SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode);
|
||||
|
||||
/* drivers call this during their Queue*() methods to make space in a array that are used
|
||||
for a vertex buffer during RunCommandQueue(). Pointers returned here are only valid until
|
||||
the next call, because it might be in an array that gets realloc()'d. */
|
||||
extern void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset);
|
||||
|
||||
#endif /* SDL_sysrender_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
418
externals/SDL/src/render/SDL_yuv_sw.c
vendored
Executable file
418
externals/SDL/src/render/SDL_yuv_sw.c
vendored
Executable file
@@ -0,0 +1,418 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
/* This is the software implementation of the YUV texture support */
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
|
||||
#include "SDL_assert.h"
|
||||
|
||||
#include "SDL_yuv_sw_c.h"
|
||||
|
||||
|
||||
SDL_SW_YUVTexture *
|
||||
SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
||||
{
|
||||
SDL_SW_YUVTexture *swdata;
|
||||
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
case SDL_PIXELFORMAT_YUY2:
|
||||
case SDL_PIXELFORMAT_UYVY:
|
||||
case SDL_PIXELFORMAT_YVYU:
|
||||
case SDL_PIXELFORMAT_NV12:
|
||||
case SDL_PIXELFORMAT_NV21:
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unsupported YUV format");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
swdata = (SDL_SW_YUVTexture *) SDL_calloc(1, sizeof(*swdata));
|
||||
if (!swdata) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
swdata->format = format;
|
||||
swdata->target_format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
swdata->w = w;
|
||||
swdata->h = h;
|
||||
{
|
||||
const int sz_plane = w * h;
|
||||
const int sz_plane_chroma = ((w + 1) / 2) * ((h + 1) / 2);
|
||||
const int sz_plane_packed = ((w + 1) / 2) * h;
|
||||
int dst_size = 0;
|
||||
switch(format)
|
||||
{
|
||||
case SDL_PIXELFORMAT_YV12: /**< Planar mode: Y + V + U (3 planes) */
|
||||
case SDL_PIXELFORMAT_IYUV: /**< Planar mode: Y + U + V (3 planes) */
|
||||
dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma;
|
||||
break;
|
||||
|
||||
case SDL_PIXELFORMAT_YUY2: /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
|
||||
case SDL_PIXELFORMAT_UYVY: /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
|
||||
case SDL_PIXELFORMAT_YVYU: /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
|
||||
dst_size = 4 * sz_plane_packed;
|
||||
break;
|
||||
|
||||
case SDL_PIXELFORMAT_NV12: /**< Planar mode: Y + U/V interleaved (2 planes) */
|
||||
case SDL_PIXELFORMAT_NV21: /**< Planar mode: Y + V/U interleaved (2 planes) */
|
||||
dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma;
|
||||
break;
|
||||
|
||||
default:
|
||||
SDL_assert(0 && "We should never get here (caught above)");
|
||||
break;
|
||||
}
|
||||
swdata->pixels = (Uint8 *) SDL_malloc(dst_size);
|
||||
if (!swdata->pixels) {
|
||||
SDL_SW_DestroyYUVTexture(swdata);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the pitch and offset values for the texture */
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
swdata->pitches[0] = w;
|
||||
swdata->pitches[1] = (swdata->pitches[0] + 1) / 2;
|
||||
swdata->pitches[2] = (swdata->pitches[0] + 1) / 2;
|
||||
swdata->planes[0] = swdata->pixels;
|
||||
swdata->planes[1] = swdata->planes[0] + swdata->pitches[0] * h;
|
||||
swdata->planes[2] = swdata->planes[1] + swdata->pitches[1] * ((h + 1) / 2);
|
||||
break;
|
||||
case SDL_PIXELFORMAT_YUY2:
|
||||
case SDL_PIXELFORMAT_UYVY:
|
||||
case SDL_PIXELFORMAT_YVYU:
|
||||
swdata->pitches[0] = ((w + 1) / 2) * 4;
|
||||
swdata->planes[0] = swdata->pixels;
|
||||
break;
|
||||
|
||||
case SDL_PIXELFORMAT_NV12:
|
||||
case SDL_PIXELFORMAT_NV21:
|
||||
swdata->pitches[0] = w;
|
||||
swdata->pitches[1] = 2 * ((swdata->pitches[0] + 1) / 2);
|
||||
swdata->planes[0] = swdata->pixels;
|
||||
swdata->planes[1] = swdata->planes[0] + swdata->pitches[0] * h;
|
||||
break;
|
||||
|
||||
default:
|
||||
SDL_assert(0 && "We should never get here (caught above)");
|
||||
break;
|
||||
}
|
||||
|
||||
/* We're all done.. */
|
||||
return (swdata);
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels,
|
||||
int *pitch)
|
||||
{
|
||||
*pixels = swdata->planes[0];
|
||||
*pitch = swdata->pitches[0];
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const void *pixels, int pitch)
|
||||
{
|
||||
switch (swdata->format) {
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
if (rect->x == 0 && rect->y == 0 &&
|
||||
rect->w == swdata->w && rect->h == swdata->h) {
|
||||
SDL_memcpy(swdata->pixels, pixels,
|
||||
(swdata->h * swdata->w) + 2* ((swdata->h + 1) /2) * ((swdata->w + 1) / 2));
|
||||
} else {
|
||||
Uint8 *src, *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
/* Copy the Y plane */
|
||||
src = (Uint8 *) pixels;
|
||||
dst = swdata->pixels + rect->y * swdata->w + rect->x;
|
||||
length = rect->w;
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += pitch;
|
||||
dst += swdata->w;
|
||||
}
|
||||
|
||||
/* Copy the next plane */
|
||||
src = (Uint8 *) pixels + rect->h * pitch;
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
dst += rect->y/2 * ((swdata->w + 1) / 2) + rect->x/2;
|
||||
length = (rect->w + 1) / 2;
|
||||
for (row = 0; row < (rect->h + 1)/2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += (pitch + 1)/2;
|
||||
dst += (swdata->w + 1)/2;
|
||||
}
|
||||
|
||||
/* Copy the next plane */
|
||||
src = (Uint8 *) pixels + rect->h * pitch + ((rect->h + 1) / 2) * ((pitch + 1) / 2);
|
||||
dst = swdata->pixels + swdata->h * swdata->w +
|
||||
((swdata->h + 1)/2) * ((swdata->w+1) / 2);
|
||||
dst += rect->y/2 * ((swdata->w + 1)/2) + rect->x/2;
|
||||
length = (rect->w + 1) / 2;
|
||||
for (row = 0; row < (rect->h + 1)/2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += (pitch + 1)/2;
|
||||
dst += (swdata->w + 1)/2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_PIXELFORMAT_YUY2:
|
||||
case SDL_PIXELFORMAT_UYVY:
|
||||
case SDL_PIXELFORMAT_YVYU:
|
||||
{
|
||||
Uint8 *src, *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
src = (Uint8 *) pixels;
|
||||
dst =
|
||||
swdata->planes[0] + rect->y * swdata->pitches[0] +
|
||||
rect->x * 2;
|
||||
length = 4 * ((rect->w + 1) / 2);
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += pitch;
|
||||
dst += swdata->pitches[0];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_PIXELFORMAT_NV12:
|
||||
case SDL_PIXELFORMAT_NV21:
|
||||
{
|
||||
if (rect->x == 0 && rect->y == 0 && rect->w == swdata->w && rect->h == swdata->h) {
|
||||
SDL_memcpy(swdata->pixels, pixels,
|
||||
(swdata->h * swdata->w) + 2* ((swdata->h + 1) /2) * ((swdata->w + 1) / 2));
|
||||
} else {
|
||||
|
||||
Uint8 *src, *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
/* Copy the Y plane */
|
||||
src = (Uint8 *) pixels;
|
||||
dst = swdata->pixels + rect->y * swdata->w + rect->x;
|
||||
length = rect->w;
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += pitch;
|
||||
dst += swdata->w;
|
||||
}
|
||||
|
||||
/* Copy the next plane */
|
||||
src = (Uint8 *) pixels + rect->h * pitch;
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
dst += 2 * ((rect->y + 1)/2) * ((swdata->w + 1) / 2) + 2 * (rect->x/2);
|
||||
length = 2 * ((rect->w + 1) / 2);
|
||||
for (row = 0; row < (rect->h + 1)/2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += 2 * ((pitch + 1)/2);
|
||||
dst += 2 * ((swdata->w + 1)/2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch)
|
||||
{
|
||||
const Uint8 *src;
|
||||
Uint8 *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
/* Copy the Y plane */
|
||||
src = Yplane;
|
||||
dst = swdata->pixels + rect->y * swdata->w + rect->x;
|
||||
length = rect->w;
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += Ypitch;
|
||||
dst += swdata->w;
|
||||
}
|
||||
|
||||
/* Copy the U plane */
|
||||
src = Uplane;
|
||||
if (swdata->format == SDL_PIXELFORMAT_IYUV) {
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
} else {
|
||||
dst = swdata->pixels + swdata->h * swdata->w +
|
||||
((swdata->h + 1) / 2) * ((swdata->w + 1) / 2);
|
||||
}
|
||||
dst += rect->y/2 * ((swdata->w + 1)/2) + rect->x/2;
|
||||
length = (rect->w + 1) / 2;
|
||||
for (row = 0; row < (rect->h + 1)/2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += Upitch;
|
||||
dst += (swdata->w + 1)/2;
|
||||
}
|
||||
|
||||
/* Copy the V plane */
|
||||
src = Vplane;
|
||||
if (swdata->format == SDL_PIXELFORMAT_YV12) {
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
} else {
|
||||
dst = swdata->pixels + swdata->h * swdata->w +
|
||||
((swdata->h + 1) / 2) * ((swdata->w + 1) / 2);
|
||||
}
|
||||
dst += rect->y/2 * ((swdata->w + 1)/2) + rect->x/2;
|
||||
length = (rect->w + 1) / 2;
|
||||
for (row = 0; row < (rect->h + 1)/2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += Vpitch;
|
||||
dst += (swdata->w + 1)/2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
void **pixels, int *pitch)
|
||||
{
|
||||
switch (swdata->format) {
|
||||
case SDL_PIXELFORMAT_YV12:
|
||||
case SDL_PIXELFORMAT_IYUV:
|
||||
case SDL_PIXELFORMAT_NV12:
|
||||
case SDL_PIXELFORMAT_NV21:
|
||||
if (rect
|
||||
&& (rect->x != 0 || rect->y != 0 || rect->w != swdata->w
|
||||
|| rect->h != swdata->h)) {
|
||||
return SDL_SetError
|
||||
("YV12, IYUV, NV12, NV21 textures only support full surface locks");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (rect) {
|
||||
*pixels = swdata->planes[0] + rect->y * swdata->pitches[0] + rect->x * 2;
|
||||
} else {
|
||||
*pixels = swdata->planes[0];
|
||||
}
|
||||
*pitch = swdata->pitches[0];
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
||||
Uint32 target_format, int w, int h, void *pixels,
|
||||
int pitch)
|
||||
{
|
||||
int stretch;
|
||||
|
||||
/* Make sure we're set up to display in the desired format */
|
||||
if (target_format != swdata->target_format && swdata->display) {
|
||||
SDL_FreeSurface(swdata->display);
|
||||
swdata->display = NULL;
|
||||
}
|
||||
|
||||
stretch = 0;
|
||||
if (srcrect->x || srcrect->y || srcrect->w < swdata->w || srcrect->h < swdata->h) {
|
||||
/* The source rectangle has been clipped.
|
||||
Using a scratch surface is easier than adding clipped
|
||||
source support to all the blitters, plus that would
|
||||
slow them down in the general unclipped case.
|
||||
*/
|
||||
stretch = 1;
|
||||
} else if ((srcrect->w != w) || (srcrect->h != h)) {
|
||||
stretch = 1;
|
||||
}
|
||||
if (stretch) {
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
if (swdata->display) {
|
||||
swdata->display->w = w;
|
||||
swdata->display->h = h;
|
||||
swdata->display->pixels = pixels;
|
||||
swdata->display->pitch = pitch;
|
||||
} else {
|
||||
/* This must have succeeded in SDL_SW_SetupYUVDisplay() earlier */
|
||||
SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask,
|
||||
&Bmask, &Amask);
|
||||
swdata->display =
|
||||
SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask,
|
||||
Gmask, Bmask, Amask);
|
||||
if (!swdata->display) {
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
if (!swdata->stretch) {
|
||||
/* This must have succeeded in SDL_SW_SetupYUVDisplay() earlier */
|
||||
SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask,
|
||||
&Bmask, &Amask);
|
||||
swdata->stretch =
|
||||
SDL_CreateRGBSurface(0, swdata->w, swdata->h, bpp, Rmask,
|
||||
Gmask, Bmask, Amask);
|
||||
if (!swdata->stretch) {
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
pixels = swdata->stretch->pixels;
|
||||
pitch = swdata->stretch->pitch;
|
||||
}
|
||||
if (SDL_ConvertPixels(swdata->w, swdata->h, swdata->format,
|
||||
swdata->planes[0], swdata->pitches[0],
|
||||
target_format, pixels, pitch) < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (stretch) {
|
||||
SDL_Rect rect = *srcrect;
|
||||
SDL_SoftStretch(swdata->stretch, &rect, swdata->display, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata)
|
||||
{
|
||||
if (swdata) {
|
||||
SDL_free(swdata->pixels);
|
||||
SDL_FreeSurface(swdata->stretch);
|
||||
SDL_FreeSurface(swdata->display);
|
||||
SDL_free(swdata);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
73
externals/SDL/src/render/SDL_yuv_sw_c.h
vendored
Executable file
73
externals/SDL/src/render/SDL_yuv_sw_c.h
vendored
Executable file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
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"
|
||||
|
||||
/* This is the software implementation of the YUV texture support */
|
||||
|
||||
struct SDL_SW_YUVTexture
|
||||
{
|
||||
Uint32 format;
|
||||
Uint32 target_format;
|
||||
int w, h;
|
||||
Uint8 *pixels;
|
||||
|
||||
/* These are just so we don't have to allocate them separately */
|
||||
Uint16 pitches[3];
|
||||
Uint8 *planes[3];
|
||||
|
||||
/* This is a temporary surface in case we have to stretch copy */
|
||||
SDL_Surface *stretch;
|
||||
SDL_Surface *display;
|
||||
};
|
||||
|
||||
typedef struct SDL_SW_YUVTexture SDL_SW_YUVTexture;
|
||||
|
||||
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h);
|
||||
int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels,
|
||||
int *pitch);
|
||||
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const void *pixels, int pitch);
|
||||
int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch);
|
||||
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
void **pixels, int *pitch);
|
||||
void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata);
|
||||
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
||||
Uint32 target_format, int w, int h, void *pixels,
|
||||
int pitch);
|
||||
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata);
|
||||
|
||||
/* FIXME: This breaks on various versions of GCC and should be rewritten using intrinsics */
|
||||
#if 0 /* (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES && !defined(__clang__) */
|
||||
#define USE_MMX_ASSEMBLY 1
|
||||
#endif
|
||||
|
||||
#endif /* SDL_yuv_sw_c_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1888
externals/SDL/src/render/direct3d/SDL_render_d3d.c
vendored
Executable file
1888
externals/SDL/src/render/direct3d/SDL_render_d3d.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
274
externals/SDL/src/render/direct3d/SDL_shaders_d3d.c
vendored
Executable file
274
externals/SDL/src/render/direct3d/SDL_shaders_d3d.c
vendored
Executable file
@@ -0,0 +1,274 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#include "SDL_render.h"
|
||||
#include "SDL_system.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
|
||||
#include <d3d9.h>
|
||||
|
||||
#include "SDL_shaders_d3d.h"
|
||||
|
||||
/* The shaders here were compiled with:
|
||||
|
||||
fxc /T ps_2_0 /Fo"<OUTPUT FILE>" "<INPUT FILE>"
|
||||
|
||||
Shader object code was converted to a list of DWORDs via the following
|
||||
*nix style command (available separately from Windows + MSVC):
|
||||
|
||||
hexdump -v -e '6/4 "0x%08.8x, " "\n"' <FILE>
|
||||
*/
|
||||
|
||||
/* --- D3D9_PixelShader_YUV_JPEG.hlsl ---
|
||||
Texture2D theTextureY : register(t0);
|
||||
Texture2D theTextureU : register(t1);
|
||||
Texture2D theTextureV : register(t2);
|
||||
SamplerState theSampler = sampler_state
|
||||
{
|
||||
addressU = Clamp;
|
||||
addressV = Clamp;
|
||||
mipfilter = NONE;
|
||||
minfilter = LINEAR;
|
||||
magfilter = LINEAR;
|
||||
};
|
||||
|
||||
struct PixelShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
float4 main(PixelShaderInput input) : SV_TARGET
|
||||
{
|
||||
const float3 offset = {0.0, -0.501960814, -0.501960814};
|
||||
const float3 Rcoeff = {1.0000, 0.0000, 1.4020};
|
||||
const float3 Gcoeff = {1.0000, -0.3441, -0.7141};
|
||||
const float3 Bcoeff = {1.0000, 1.7720, 0.0000};
|
||||
|
||||
float4 Output;
|
||||
|
||||
float3 yuv;
|
||||
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
|
||||
yuv.y = theTextureU.Sample(theSampler, input.tex).r;
|
||||
yuv.z = theTextureV.Sample(theSampler, input.tex).r;
|
||||
|
||||
yuv += offset;
|
||||
Output.r = dot(yuv, Rcoeff);
|
||||
Output.g = dot(yuv, Gcoeff);
|
||||
Output.b = dot(yuv, Bcoeff);
|
||||
Output.a = 1.0f;
|
||||
|
||||
return Output * input.color;
|
||||
}
|
||||
*/
|
||||
static const DWORD D3D9_PixelShader_YUV_JPEG[] = {
|
||||
0xffff0200, 0x0044fffe, 0x42415443, 0x0000001c, 0x000000d7, 0xffff0200,
|
||||
0x00000003, 0x0000001c, 0x00000100, 0x000000d0, 0x00000058, 0x00010003,
|
||||
0x00000001, 0x00000070, 0x00000000, 0x00000080, 0x00020003, 0x00000001,
|
||||
0x00000098, 0x00000000, 0x000000a8, 0x00000003, 0x00000001, 0x000000c0,
|
||||
0x00000000, 0x53656874, 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478,
|
||||
0xab005565, 0x00070004, 0x00040001, 0x00000001, 0x00000000, 0x53656874,
|
||||
0x6c706d61, 0x742b7265, 0x65546568, 0x72757478, 0xab005665, 0x00070004,
|
||||
0x00040001, 0x00000001, 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265,
|
||||
0x65546568, 0x72757478, 0xab005965, 0x00070004, 0x00040001, 0x00000001,
|
||||
0x00000000, 0x325f7370, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820,
|
||||
0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072,
|
||||
0x36392e33, 0x312e3030, 0x34383336, 0xababab00, 0x05000051, 0xa00f0000,
|
||||
0x00000000, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001,
|
||||
0x3f800000, 0x00000000, 0x3fb374bc, 0x00000000, 0x05000051, 0xa00f0002,
|
||||
0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051, 0xa00f0003,
|
||||
0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
|
||||
0xb0030000, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f, 0x90000000,
|
||||
0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, 0x90000000,
|
||||
0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000042,
|
||||
0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002, 0xb0e40000,
|
||||
0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001, 0x80040000,
|
||||
0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000008,
|
||||
0x80010001, 0x80e40000, 0xa0e40001, 0x03000008, 0x80020001, 0x80e40000,
|
||||
0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
|
||||
0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
|
||||
0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff
|
||||
};
|
||||
|
||||
/* --- D3D9_PixelShader_YUV_BT601.hlsl ---
|
||||
Texture2D theTextureY : register(t0);
|
||||
Texture2D theTextureU : register(t1);
|
||||
Texture2D theTextureV : register(t2);
|
||||
SamplerState theSampler = sampler_state
|
||||
{
|
||||
addressU = Clamp;
|
||||
addressV = Clamp;
|
||||
mipfilter = NONE;
|
||||
minfilter = LINEAR;
|
||||
magfilter = LINEAR;
|
||||
};
|
||||
|
||||
struct PixelShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
float4 main(PixelShaderInput input) : SV_TARGET
|
||||
{
|
||||
const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
|
||||
const float3 Rcoeff = {1.1644, 0.0000, 1.5960};
|
||||
const float3 Gcoeff = {1.1644, -0.3918, -0.8130};
|
||||
const float3 Bcoeff = {1.1644, 2.0172, 0.0000};
|
||||
|
||||
float4 Output;
|
||||
|
||||
float3 yuv;
|
||||
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
|
||||
yuv.y = theTextureU.Sample(theSampler, input.tex).r;
|
||||
yuv.z = theTextureV.Sample(theSampler, input.tex).r;
|
||||
|
||||
yuv += offset;
|
||||
Output.r = dot(yuv, Rcoeff);
|
||||
Output.g = dot(yuv, Gcoeff);
|
||||
Output.b = dot(yuv, Bcoeff);
|
||||
Output.a = 1.0f;
|
||||
|
||||
return Output * input.color;
|
||||
}
|
||||
*/
|
||||
static const DWORD D3D9_PixelShader_YUV_BT601[] = {
|
||||
0xffff0200, 0x0044fffe, 0x42415443, 0x0000001c, 0x000000d7, 0xffff0200,
|
||||
0x00000003, 0x0000001c, 0x00000100, 0x000000d0, 0x00000058, 0x00010003,
|
||||
0x00000001, 0x00000070, 0x00000000, 0x00000080, 0x00020003, 0x00000001,
|
||||
0x00000098, 0x00000000, 0x000000a8, 0x00000003, 0x00000001, 0x000000c0,
|
||||
0x00000000, 0x53656874, 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478,
|
||||
0xab005565, 0x00070004, 0x00040001, 0x00000001, 0x00000000, 0x53656874,
|
||||
0x6c706d61, 0x742b7265, 0x65546568, 0x72757478, 0xab005665, 0x00070004,
|
||||
0x00040001, 0x00000001, 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265,
|
||||
0x65546568, 0x72757478, 0xab005965, 0x00070004, 0x00040001, 0x00000001,
|
||||
0x00000000, 0x325f7370, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820,
|
||||
0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072,
|
||||
0x36392e33, 0x312e3030, 0x34383336, 0xababab00, 0x05000051, 0xa00f0000,
|
||||
0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001,
|
||||
0x3f950b0f, 0x00000000, 0x3fcc49ba, 0x00000000, 0x05000051, 0xa00f0002,
|
||||
0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x05000051, 0xa00f0003,
|
||||
0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
|
||||
0xb0030000, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f, 0x90000000,
|
||||
0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, 0x90000000,
|
||||
0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000042,
|
||||
0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002, 0xb0e40000,
|
||||
0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001, 0x80040000,
|
||||
0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000008,
|
||||
0x80010001, 0x80e40000, 0xa0e40001, 0x03000008, 0x80020001, 0x80e40000,
|
||||
0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
|
||||
0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
|
||||
0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff
|
||||
};
|
||||
|
||||
/* --- D3D9_PixelShader_YUV_BT709.hlsl ---
|
||||
Texture2D theTextureY : register(t0);
|
||||
Texture2D theTextureU : register(t1);
|
||||
Texture2D theTextureV : register(t2);
|
||||
SamplerState theSampler = sampler_state
|
||||
{
|
||||
addressU = Clamp;
|
||||
addressV = Clamp;
|
||||
mipfilter = NONE;
|
||||
minfilter = LINEAR;
|
||||
magfilter = LINEAR;
|
||||
};
|
||||
|
||||
struct PixelShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
float4 main(PixelShaderInput input) : SV_TARGET
|
||||
{
|
||||
const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
|
||||
const float3 Rcoeff = {1.1644, 0.0000, 1.7927};
|
||||
const float3 Gcoeff = {1.1644, -0.2132, -0.5329};
|
||||
const float3 Bcoeff = {1.1644, 2.1124, 0.0000};
|
||||
|
||||
float4 Output;
|
||||
|
||||
float3 yuv;
|
||||
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
|
||||
yuv.y = theTextureU.Sample(theSampler, input.tex).r;
|
||||
yuv.z = theTextureV.Sample(theSampler, input.tex).r;
|
||||
|
||||
yuv += offset;
|
||||
Output.r = dot(yuv, Rcoeff);
|
||||
Output.g = dot(yuv, Gcoeff);
|
||||
Output.b = dot(yuv, Bcoeff);
|
||||
Output.a = 1.0f;
|
||||
|
||||
return Output * input.color;
|
||||
}
|
||||
*/
|
||||
static const DWORD D3D9_PixelShader_YUV_BT709[] = {
|
||||
0xffff0200, 0x0044fffe, 0x42415443, 0x0000001c, 0x000000d7, 0xffff0200,
|
||||
0x00000003, 0x0000001c, 0x00000100, 0x000000d0, 0x00000058, 0x00010003,
|
||||
0x00000001, 0x00000070, 0x00000000, 0x00000080, 0x00020003, 0x00000001,
|
||||
0x00000098, 0x00000000, 0x000000a8, 0x00000003, 0x00000001, 0x000000c0,
|
||||
0x00000000, 0x53656874, 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478,
|
||||
0xab005565, 0x00070004, 0x00040001, 0x00000001, 0x00000000, 0x53656874,
|
||||
0x6c706d61, 0x742b7265, 0x65546568, 0x72757478, 0xab005665, 0x00070004,
|
||||
0x00040001, 0x00000001, 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265,
|
||||
0x65546568, 0x72757478, 0xab005965, 0x00070004, 0x00040001, 0x00000001,
|
||||
0x00000000, 0x325f7370, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820,
|
||||
0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072,
|
||||
0x36392e33, 0x312e3030, 0x34383336, 0xababab00, 0x05000051, 0xa00f0000,
|
||||
0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001,
|
||||
0x3f950b0f, 0x00000000, 0x3fe57732, 0x00000000, 0x05000051, 0xa00f0002,
|
||||
0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x05000051, 0xa00f0003,
|
||||
0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
|
||||
0xb0030000, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f, 0x90000000,
|
||||
0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, 0x90000000,
|
||||
0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000042,
|
||||
0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002, 0xb0e40000,
|
||||
0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001, 0x80040000,
|
||||
0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000008,
|
||||
0x80010001, 0x80e40000, 0xa0e40001, 0x03000008, 0x80020001, 0x80e40000,
|
||||
0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
|
||||
0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
|
||||
0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff
|
||||
};
|
||||
|
||||
|
||||
static const DWORD *D3D9_shaders[] = {
|
||||
D3D9_PixelShader_YUV_JPEG,
|
||||
D3D9_PixelShader_YUV_BT601,
|
||||
D3D9_PixelShader_YUV_BT709,
|
||||
};
|
||||
|
||||
HRESULT D3D9_CreatePixelShader(IDirect3DDevice9 *d3dDevice, D3D9_Shader shader, IDirect3DPixelShader9 **pixelShader)
|
||||
{
|
||||
return IDirect3DDevice9_CreatePixelShader(d3dDevice, D3D9_shaders[shader], pixelShader);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
34
externals/SDL/src/render/direct3d/SDL_shaders_d3d.h
vendored
Executable file
34
externals/SDL/src/render/direct3d/SDL_shaders_d3d.h
vendored
Executable file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
/* D3D9 shader implementation */
|
||||
|
||||
typedef enum {
|
||||
SHADER_YUV_JPEG,
|
||||
SHADER_YUV_BT601,
|
||||
SHADER_YUV_BT709,
|
||||
NUM_SHADERS
|
||||
} D3D9_Shader;
|
||||
|
||||
extern HRESULT D3D9_CreatePixelShader(IDirect3DDevice9 *d3dDevice, D3D9_Shader shader, IDirect3DPixelShader9 **pixelShader);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
2594
externals/SDL/src/render/direct3d11/SDL_render_d3d11.c
vendored
Executable file
2594
externals/SDL/src/render/direct3d11/SDL_render_d3d11.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
116
externals/SDL/src/render/direct3d11/SDL_render_winrt.cpp
vendored
Executable file
116
externals/SDL/src/render/direct3d11/SDL_render_winrt.cpp
vendored
Executable file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_syswm.h"
|
||||
#include "../../video/winrt/SDL_winrtvideo_cpp.h"
|
||||
extern "C" {
|
||||
#include "../SDL_sysrender.h"
|
||||
}
|
||||
|
||||
#include <windows.ui.core.h>
|
||||
#include <windows.graphics.display.h>
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
|
||||
#include <windows.ui.xaml.media.dxinterop.h>
|
||||
#endif
|
||||
|
||||
using namespace Windows::UI::Core;
|
||||
using namespace Windows::Graphics::Display;
|
||||
|
||||
#include <DXGI.h>
|
||||
|
||||
#include "SDL_render_winrt.h"
|
||||
|
||||
|
||||
extern "C" void *
|
||||
D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
SDL_Window * sdlWindow = renderer->window;
|
||||
if ( ! renderer->window ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_SysWMinfo sdlWindowInfo;
|
||||
SDL_VERSION(&sdlWindowInfo.version);
|
||||
if ( ! SDL_GetWindowWMInfo(sdlWindow, &sdlWindowInfo) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sdlWindowInfo.subsystem != SDL_SYSWM_WINRT) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!sdlWindowInfo.info.winrt.window) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ABI::Windows::UI::Core::ICoreWindow *coreWindow = NULL;
|
||||
if (FAILED(sdlWindowInfo.info.winrt.window->QueryInterface(&coreWindow))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IUnknown *coreWindowAsIUnknown = NULL;
|
||||
coreWindow->QueryInterface(&coreWindowAsIUnknown);
|
||||
coreWindow->Release();
|
||||
|
||||
return coreWindowAsIUnknown;
|
||||
}
|
||||
|
||||
extern "C" DXGI_MODE_ROTATION
|
||||
D3D11_GetCurrentRotation()
|
||||
{
|
||||
const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation);
|
||||
|
||||
switch (currentOrientation) {
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
/* Windows Phone rotations */
|
||||
case DisplayOrientations::Landscape:
|
||||
return DXGI_MODE_ROTATION_ROTATE90;
|
||||
case DisplayOrientations::Portrait:
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
case DisplayOrientations::LandscapeFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE270;
|
||||
case DisplayOrientations::PortraitFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE180;
|
||||
#else
|
||||
/* Non-Windows-Phone rotations (ex: Windows 8, Windows RT) */
|
||||
case DisplayOrientations::Landscape:
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
case DisplayOrientations::Portrait:
|
||||
return DXGI_MODE_ROTATION_ROTATE270;
|
||||
case DisplayOrientations::LandscapeFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE180;
|
||||
case DisplayOrientations::PortraitFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE90;
|
||||
#endif /* WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP */
|
||||
}
|
||||
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
40
externals/SDL/src/render/direct3d11/SDL_render_winrt.h
vendored
Executable file
40
externals/SDL/src/render/direct3d11/SDL_render_winrt.h
vendored
Executable file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_render.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer);
|
||||
DXGI_MODE_ROTATION D3D11_GetCurrentRotation();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1957
externals/SDL/src/render/direct3d11/SDL_shaders_d3d11.c
vendored
Executable file
1957
externals/SDL/src/render/direct3d11/SDL_shaders_d3d11.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
43
externals/SDL/src/render/direct3d11/SDL_shaders_d3d11.h
vendored
Executable file
43
externals/SDL/src/render/direct3d11/SDL_shaders_d3d11.h
vendored
Executable file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
/* D3D11 shader implementation */
|
||||
|
||||
typedef enum {
|
||||
SHADER_SOLID,
|
||||
SHADER_RGB,
|
||||
SHADER_YUV_JPEG,
|
||||
SHADER_YUV_BT601,
|
||||
SHADER_YUV_BT709,
|
||||
SHADER_NV12_JPEG,
|
||||
SHADER_NV12_BT601,
|
||||
SHADER_NV12_BT709,
|
||||
SHADER_NV21_JPEG,
|
||||
SHADER_NV21_BT601,
|
||||
SHADER_NV21_BT709,
|
||||
NUM_SHADERS
|
||||
} D3D11_Shader;
|
||||
|
||||
extern int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout);
|
||||
extern int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D11PixelShader **pixelShader);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1887
externals/SDL/src/render/metal/SDL_render_metal.m
vendored
Executable file
1887
externals/SDL/src/render/metal/SDL_render_metal.m
vendored
Executable file
File diff suppressed because it is too large
Load Diff
117
externals/SDL/src/render/metal/SDL_shaders_metal.metal
vendored
Executable file
117
externals/SDL/src/render/metal/SDL_shaders_metal.metal
vendored
Executable file
@@ -0,0 +1,117 @@
|
||||
#include <metal_texture>
|
||||
#include <metal_matrix>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct SolidVertexInput
|
||||
{
|
||||
float2 position [[attribute(0)]];
|
||||
};
|
||||
|
||||
struct SolidVertexOutput
|
||||
{
|
||||
float4 position [[position]];
|
||||
float pointSize [[point_size]];
|
||||
};
|
||||
|
||||
vertex SolidVertexOutput SDL_Solid_vertex(SolidVertexInput in [[stage_in]],
|
||||
constant float4x4 &projection [[buffer(2)]],
|
||||
constant float4x4 &transform [[buffer(3)]])
|
||||
{
|
||||
SolidVertexOutput v;
|
||||
v.position = (projection * transform) * float4(in.position, 0.0f, 1.0f);
|
||||
v.pointSize = 1.0f;
|
||||
return v;
|
||||
}
|
||||
|
||||
fragment float4 SDL_Solid_fragment(const device float4 &col [[buffer(0)]])
|
||||
{
|
||||
return col;
|
||||
}
|
||||
|
||||
struct CopyVertexInput
|
||||
{
|
||||
float2 position [[attribute(0)]];
|
||||
float2 texcoord [[attribute(1)]];
|
||||
};
|
||||
|
||||
struct CopyVertexOutput
|
||||
{
|
||||
float4 position [[position]];
|
||||
float2 texcoord;
|
||||
};
|
||||
|
||||
vertex CopyVertexOutput SDL_Copy_vertex(CopyVertexInput in [[stage_in]],
|
||||
constant float4x4 &projection [[buffer(2)]],
|
||||
constant float4x4 &transform [[buffer(3)]])
|
||||
{
|
||||
CopyVertexOutput v;
|
||||
v.position = (projection * transform) * float4(in.position, 0.0f, 1.0f);
|
||||
v.texcoord = in.texcoord;
|
||||
return v;
|
||||
}
|
||||
|
||||
fragment float4 SDL_Copy_fragment(CopyVertexOutput vert [[stage_in]],
|
||||
const device float4 &col [[buffer(0)]],
|
||||
texture2d<float> tex [[texture(0)]],
|
||||
sampler s [[sampler(0)]])
|
||||
{
|
||||
return tex.sample(s, vert.texcoord) * col;
|
||||
}
|
||||
|
||||
struct YUVDecode
|
||||
{
|
||||
float3 offset;
|
||||
float3 Rcoeff;
|
||||
float3 Gcoeff;
|
||||
float3 Bcoeff;
|
||||
};
|
||||
|
||||
fragment float4 SDL_YUV_fragment(CopyVertexOutput vert [[stage_in]],
|
||||
const device float4 &col [[buffer(0)]],
|
||||
constant YUVDecode &decode [[buffer(1)]],
|
||||
texture2d<float> texY [[texture(0)]],
|
||||
texture2d_array<float> texUV [[texture(1)]],
|
||||
sampler s [[sampler(0)]])
|
||||
{
|
||||
float3 yuv;
|
||||
yuv.x = texY.sample(s, vert.texcoord).r;
|
||||
yuv.y = texUV.sample(s, vert.texcoord, 0).r;
|
||||
yuv.z = texUV.sample(s, vert.texcoord, 1).r;
|
||||
|
||||
yuv += decode.offset;
|
||||
|
||||
return col * float4(dot(yuv, decode.Rcoeff), dot(yuv, decode.Gcoeff), dot(yuv, decode.Bcoeff), 1.0);
|
||||
}
|
||||
|
||||
fragment float4 SDL_NV12_fragment(CopyVertexOutput vert [[stage_in]],
|
||||
const device float4 &col [[buffer(0)]],
|
||||
constant YUVDecode &decode [[buffer(1)]],
|
||||
texture2d<float> texY [[texture(0)]],
|
||||
texture2d<float> texUV [[texture(1)]],
|
||||
sampler s [[sampler(0)]])
|
||||
{
|
||||
float3 yuv;
|
||||
yuv.x = texY.sample(s, vert.texcoord).r;
|
||||
yuv.yz = texUV.sample(s, vert.texcoord).rg;
|
||||
|
||||
yuv += decode.offset;
|
||||
|
||||
return col * float4(dot(yuv, decode.Rcoeff), dot(yuv, decode.Gcoeff), dot(yuv, decode.Bcoeff), 1.0);
|
||||
}
|
||||
|
||||
fragment float4 SDL_NV21_fragment(CopyVertexOutput vert [[stage_in]],
|
||||
const device float4 &col [[buffer(0)]],
|
||||
constant YUVDecode &decode [[buffer(1)]],
|
||||
texture2d<float> texY [[texture(0)]],
|
||||
texture2d<float> texUV [[texture(1)]],
|
||||
sampler s [[sampler(0)]])
|
||||
{
|
||||
float3 yuv;
|
||||
yuv.x = texY.sample(s, vert.texcoord).r;
|
||||
yuv.yz = texUV.sample(s, vert.texcoord).gr;
|
||||
|
||||
yuv += decode.offset;
|
||||
|
||||
return col * float4(dot(yuv, decode.Rcoeff), dot(yuv, decode.Gcoeff), dot(yuv, decode.Bcoeff), 1.0);
|
||||
}
|
1854
externals/SDL/src/render/metal/SDL_shaders_metal_ios.h
vendored
Executable file
1854
externals/SDL/src/render/metal/SDL_shaders_metal_ios.h
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1858
externals/SDL/src/render/metal/SDL_shaders_metal_osx.h
vendored
Executable file
1858
externals/SDL/src/render/metal/SDL_shaders_metal_osx.h
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1854
externals/SDL/src/render/metal/SDL_shaders_metal_tvos.h
vendored
Executable file
1854
externals/SDL/src/render/metal/SDL_shaders_metal_tvos.h
vendored
Executable file
File diff suppressed because it is too large
Load Diff
22
externals/SDL/src/render/metal/build-metal-shaders.sh
vendored
Executable file
22
externals/SDL/src/render/metal/build-metal-shaders.sh
vendored
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
set -e
|
||||
cd `dirname "$0"`
|
||||
|
||||
generate_shaders()
|
||||
{
|
||||
fileplatform=$1
|
||||
compileplatform=$2
|
||||
sdkplatform=$3
|
||||
minversion=$4
|
||||
xcrun -sdk $sdkplatform metal -c -std=$compileplatform-metal1.1 -m$sdkplatform-version-min=$minversion -Wall -O3 -o ./sdl.air ./SDL_shaders_metal.metal || exit $?
|
||||
xcrun -sdk $sdkplatform metal-ar rc sdl.metalar sdl.air || exit $?
|
||||
xcrun -sdk $sdkplatform metallib -o sdl.metallib sdl.metalar || exit $?
|
||||
xxd -i sdl.metallib | perl -w -p -e 's/\Aunsigned /const unsigned /;' >./SDL_shaders_metal_$fileplatform.h
|
||||
rm -f sdl.air sdl.metalar sdl.metallib
|
||||
}
|
||||
|
||||
generate_shaders osx osx macosx 10.11
|
||||
generate_shaders ios ios iphoneos 8.0
|
||||
generate_shaders tvos ios appletvos 9.0
|
478
externals/SDL/src/render/opengl/SDL_glfuncs.h
vendored
Executable file
478
externals/SDL/src/render/opengl/SDL_glfuncs.h
vendored
Executable file
@@ -0,0 +1,478 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* list of OpenGL functions sorted alphabetically
|
||||
If you need to use a GL function from the SDL video subsystem,
|
||||
change its entry from SDL_PROC_UNUSED to SDL_PROC and rebuild.
|
||||
*/
|
||||
#define SDL_PROC_UNUSED(ret,func,params)
|
||||
|
||||
SDL_PROC_UNUSED(void, glAccum, (GLenum, GLfloat))
|
||||
SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum, GLclampf))
|
||||
SDL_PROC_UNUSED(GLboolean, glAreTexturesResident,
|
||||
(GLsizei, const GLuint *, GLboolean *))
|
||||
SDL_PROC_UNUSED(void, glArrayElement, (GLint))
|
||||
SDL_PROC(void, glBegin, (GLenum))
|
||||
SDL_PROC(void, glBindTexture, (GLenum, GLuint))
|
||||
SDL_PROC_UNUSED(void, glBitmap,
|
||||
(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat,
|
||||
const GLubyte *))
|
||||
SDL_PROC(void, glBlendEquation, (GLenum))
|
||||
SDL_PROC_UNUSED(void, glBlendFunc, (GLenum, GLenum))
|
||||
SDL_PROC(void, glBlendFuncSeparate, (GLenum, GLenum, GLenum, GLenum))
|
||||
SDL_PROC_UNUSED(void, glCallList, (GLuint))
|
||||
SDL_PROC_UNUSED(void, glCallLists, (GLsizei, GLenum, const GLvoid *))
|
||||
SDL_PROC(void, glClear, (GLbitfield))
|
||||
SDL_PROC_UNUSED(void, glClearAccum, (GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
|
||||
SDL_PROC_UNUSED(void, glClearDepth, (GLclampd))
|
||||
SDL_PROC_UNUSED(void, glClearIndex, (GLfloat))
|
||||
SDL_PROC_UNUSED(void, glClearStencil, (GLint))
|
||||
SDL_PROC_UNUSED(void, glClipPlane, (GLenum, const GLdouble *))
|
||||
SDL_PROC_UNUSED(void, glColor3b, (GLbyte, GLbyte, GLbyte))
|
||||
SDL_PROC_UNUSED(void, glColor3bv, (const GLbyte *))
|
||||
SDL_PROC_UNUSED(void, glColor3d, (GLdouble, GLdouble, GLdouble))
|
||||
SDL_PROC_UNUSED(void, glColor3dv, (const GLdouble *))
|
||||
SDL_PROC_UNUSED(void, glColor3f, (GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glColor3fv, (const GLfloat *))
|
||||
SDL_PROC_UNUSED(void, glColor3i, (GLint, GLint, GLint))
|
||||
SDL_PROC_UNUSED(void, glColor3iv, (const GLint *))
|
||||
SDL_PROC_UNUSED(void, glColor3s, (GLshort, GLshort, GLshort))
|
||||
SDL_PROC_UNUSED(void, glColor3sv, (const GLshort *))
|
||||
SDL_PROC_UNUSED(void, glColor3ub, (GLubyte, GLubyte, GLubyte))
|
||||
SDL_PROC_UNUSED(void, glColor3ubv, (const GLubyte *))
|
||||
SDL_PROC_UNUSED(void, glColor3ui, (GLuint, GLuint, GLuint))
|
||||
SDL_PROC_UNUSED(void, glColor3uiv, (const GLuint *))
|
||||
SDL_PROC_UNUSED(void, glColor3us, (GLushort, GLushort, GLushort))
|
||||
SDL_PROC_UNUSED(void, glColor3usv, (const GLushort *))
|
||||
SDL_PROC_UNUSED(void, glColor4b, (GLbyte, GLbyte, GLbyte, GLbyte))
|
||||
SDL_PROC_UNUSED(void, glColor4bv, (const GLbyte *))
|
||||
SDL_PROC_UNUSED(void, glColor4d, (GLdouble, GLdouble, GLdouble, GLdouble))
|
||||
SDL_PROC_UNUSED(void, glColor4dv, (const GLdouble *))
|
||||
SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC_UNUSED(void, glColor4fv, (const GLfloat *))
|
||||
SDL_PROC_UNUSED(void, glColor4i, (GLint, GLint, GLint, GLint))
|
||||
SDL_PROC_UNUSED(void, glColor4iv, (const GLint *))
|
||||
SDL_PROC_UNUSED(void, glColor4s, (GLshort, GLshort, GLshort, GLshort))
|
||||
SDL_PROC_UNUSED(void, glColor4sv, (const GLshort *))
|
||||
SDL_PROC_UNUSED(void, glColor4ub,
|
||||
(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
|
||||
SDL_PROC_UNUSED(void, glColor4ubv, (const GLubyte * v))
|
||||
SDL_PROC_UNUSED(void, glColor4ui,
|
||||
(GLuint red, GLuint green, GLuint blue, GLuint alpha))
|
||||
SDL_PROC_UNUSED(void, glColor4uiv, (const GLuint * v))
|
||||
SDL_PROC_UNUSED(void, glColor4us,
|
||||
(GLushort red, GLushort green, GLushort blue, GLushort alpha))
|
||||
SDL_PROC_UNUSED(void, glColor4usv, (const GLushort * v))
|
||||
SDL_PROC_UNUSED(void, glColorMask,
|
||||
(GLboolean red, GLboolean green, GLboolean blue,
|
||||
GLboolean alpha))
|
||||
SDL_PROC_UNUSED(void, glColorMaterial, (GLenum face, GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glColorPointer,
|
||||
(GLint size, GLenum type, GLsizei stride,
|
||||
const GLvoid * pointer))
|
||||
SDL_PROC_UNUSED(void, glCopyPixels,
|
||||
(GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLenum type))
|
||||
SDL_PROC_UNUSED(void, glCopyTexImage1D,
|
||||
(GLenum target, GLint level, GLenum internalFormat, GLint x,
|
||||
GLint y, GLsizei width, GLint border))
|
||||
SDL_PROC_UNUSED(void, glCopyTexImage2D,
|
||||
(GLenum target, GLint level, GLenum internalFormat, GLint x,
|
||||
GLint y, GLsizei width, GLsizei height, GLint border))
|
||||
SDL_PROC_UNUSED(void, glCopyTexSubImage1D,
|
||||
(GLenum target, GLint level, GLint xoffset, GLint x, GLint y,
|
||||
GLsizei width))
|
||||
SDL_PROC_UNUSED(void, glCopyTexSubImage2D,
|
||||
(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height))
|
||||
SDL_PROC_UNUSED(void, glCullFace, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glDeleteLists, (GLuint list, GLsizei range))
|
||||
SDL_PROC(void, glDeleteTextures, (GLsizei n, const GLuint * textures))
|
||||
SDL_PROC(void, glDepthFunc, (GLenum func))
|
||||
SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag))
|
||||
SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar))
|
||||
SDL_PROC(void, glDisable, (GLenum cap))
|
||||
SDL_PROC_UNUSED(void, glDisableClientState, (GLenum array))
|
||||
SDL_PROC_UNUSED(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count))
|
||||
SDL_PROC_UNUSED(void, glDrawBuffer, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glDrawElements,
|
||||
(GLenum mode, GLsizei count, GLenum type,
|
||||
const GLvoid * indices))
|
||||
SDL_PROC(void, glDrawPixels,
|
||||
(GLsizei width, GLsizei height, GLenum format, GLenum type,
|
||||
const GLvoid * pixels))
|
||||
SDL_PROC_UNUSED(void, glEdgeFlag, (GLboolean flag))
|
||||
SDL_PROC_UNUSED(void, glEdgeFlagPointer,
|
||||
(GLsizei stride, const GLvoid * pointer))
|
||||
SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean * flag))
|
||||
SDL_PROC(void, glEnable, (GLenum cap))
|
||||
SDL_PROC_UNUSED(void, glEnableClientState, (GLenum array))
|
||||
SDL_PROC(void, glEnd, (void))
|
||||
SDL_PROC_UNUSED(void, glEndList, (void))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1d, (GLdouble u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1dv, (const GLdouble * u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1f, (GLfloat u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1fv, (const GLfloat * u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2d, (GLdouble u, GLdouble v))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2dv, (const GLdouble * u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2f, (GLfloat u, GLfloat v))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2fv, (const GLfloat * u))
|
||||
SDL_PROC_UNUSED(void, glEvalMesh1, (GLenum mode, GLint i1, GLint i2))
|
||||
SDL_PROC_UNUSED(void, glEvalMesh2,
|
||||
(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2))
|
||||
SDL_PROC_UNUSED(void, glEvalPoint1, (GLint i))
|
||||
SDL_PROC_UNUSED(void, glEvalPoint2, (GLint i, GLint j))
|
||||
SDL_PROC_UNUSED(void, glFeedbackBuffer,
|
||||
(GLsizei size, GLenum type, GLfloat * buffer))
|
||||
SDL_PROC_UNUSED(void, glFinish, (void))
|
||||
SDL_PROC_UNUSED(void, glFlush, (void))
|
||||
SDL_PROC_UNUSED(void, glFogf, (GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glFogi, (GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glFogiv, (GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glFrontFace, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glFrustum,
|
||||
(GLdouble left, GLdouble right, GLdouble bottom,
|
||||
GLdouble top, GLdouble zNear, GLdouble zFar))
|
||||
SDL_PROC_UNUSED(GLuint, glGenLists, (GLsizei range))
|
||||
SDL_PROC(void, glGenTextures, (GLsizei n, GLuint * textures))
|
||||
SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean * params))
|
||||
SDL_PROC_UNUSED(void, glGetClipPlane, (GLenum plane, GLdouble * equation))
|
||||
SDL_PROC_UNUSED(void, glGetDoublev, (GLenum pname, GLdouble * params))
|
||||
SDL_PROC(GLenum, glGetError, (void))
|
||||
SDL_PROC_UNUSED(void, glGetFloatv, (GLenum pname, GLfloat * params))
|
||||
SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetLightfv,
|
||||
(GLenum light, GLenum pname, GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glGetLightiv,
|
||||
(GLenum light, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetMapdv, (GLenum target, GLenum query, GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glGetMapfv, (GLenum target, GLenum query, GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glGetMapiv, (GLenum target, GLenum query, GLint * v))
|
||||
SDL_PROC_UNUSED(void, glGetMaterialfv,
|
||||
(GLenum face, GLenum pname, GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glGetMaterialiv,
|
||||
(GLenum face, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetPixelMapfv, (GLenum map, GLfloat * values))
|
||||
SDL_PROC_UNUSED(void, glGetPixelMapuiv, (GLenum map, GLuint * values))
|
||||
SDL_PROC_UNUSED(void, glGetPixelMapusv, (GLenum map, GLushort * values))
|
||||
SDL_PROC(void, glGetPointerv, (GLenum pname, GLvoid * *params))
|
||||
SDL_PROC_UNUSED(void, glGetPolygonStipple, (GLubyte * mask))
|
||||
SDL_PROC(const GLubyte *, glGetString, (GLenum name))
|
||||
SDL_PROC_UNUSED(void, glGetTexEnvfv,
|
||||
(GLenum target, GLenum pname, GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexEnviv,
|
||||
(GLenum target, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexGendv,
|
||||
(GLenum coord, GLenum pname, GLdouble * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexGenfv,
|
||||
(GLenum coord, GLenum pname, GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexGeniv,
|
||||
(GLenum coord, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexImage,
|
||||
(GLenum target, GLint level, GLenum format, GLenum type,
|
||||
GLvoid * pixels))
|
||||
SDL_PROC_UNUSED(void, glGetTexLevelParameterfv,
|
||||
(GLenum target, GLint level, GLenum pname, GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexLevelParameteriv,
|
||||
(GLenum target, GLint level, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexParameterfv,
|
||||
(GLenum target, GLenum pname, GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexParameteriv,
|
||||
(GLenum target, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glHint, (GLenum target, GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glIndexMask, (GLuint mask))
|
||||
SDL_PROC_UNUSED(void, glIndexPointer,
|
||||
(GLenum type, GLsizei stride, const GLvoid * pointer))
|
||||
SDL_PROC_UNUSED(void, glIndexd, (GLdouble c))
|
||||
SDL_PROC_UNUSED(void, glIndexdv, (const GLdouble * c))
|
||||
SDL_PROC_UNUSED(void, glIndexf, (GLfloat c))
|
||||
SDL_PROC_UNUSED(void, glIndexfv, (const GLfloat * c))
|
||||
SDL_PROC_UNUSED(void, glIndexi, (GLint c))
|
||||
SDL_PROC_UNUSED(void, glIndexiv, (const GLint * c))
|
||||
SDL_PROC_UNUSED(void, glIndexs, (GLshort c))
|
||||
SDL_PROC_UNUSED(void, glIndexsv, (const GLshort * c))
|
||||
SDL_PROC_UNUSED(void, glIndexub, (GLubyte c))
|
||||
SDL_PROC_UNUSED(void, glIndexubv, (const GLubyte * c))
|
||||
SDL_PROC_UNUSED(void, glInitNames, (void))
|
||||
SDL_PROC_UNUSED(void, glInterleavedArrays,
|
||||
(GLenum format, GLsizei stride, const GLvoid * pointer))
|
||||
SDL_PROC_UNUSED(GLboolean, glIsEnabled, (GLenum cap))
|
||||
SDL_PROC_UNUSED(GLboolean, glIsList, (GLuint list))
|
||||
SDL_PROC_UNUSED(GLboolean, glIsTexture, (GLuint texture))
|
||||
SDL_PROC_UNUSED(void, glLightModelf, (GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glLightModeli, (GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glLightModeliv, (GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glLightf, (GLenum light, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glLightfv,
|
||||
(GLenum light, GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glLighti, (GLenum light, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glLightiv,
|
||||
(GLenum light, GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glLineStipple, (GLint factor, GLushort pattern))
|
||||
SDL_PROC(void, glLineWidth, (GLfloat width))
|
||||
SDL_PROC_UNUSED(void, glListBase, (GLuint base))
|
||||
SDL_PROC(void, glLoadIdentity, (void))
|
||||
SDL_PROC_UNUSED(void, glLoadMatrixd, (const GLdouble * m))
|
||||
SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat * m))
|
||||
SDL_PROC_UNUSED(void, glLoadName, (GLuint name))
|
||||
SDL_PROC_UNUSED(void, glLogicOp, (GLenum opcode))
|
||||
SDL_PROC_UNUSED(void, glMap1d,
|
||||
(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
|
||||
GLint order, const GLdouble * points))
|
||||
SDL_PROC_UNUSED(void, glMap1f,
|
||||
(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
|
||||
GLint order, const GLfloat * points))
|
||||
SDL_PROC_UNUSED(void, glMap2d,
|
||||
(GLenum target, GLdouble u1, GLdouble u2, GLint ustride,
|
||||
GLint uorder, GLdouble v1, GLdouble v2, GLint vstride,
|
||||
GLint vorder, const GLdouble * points))
|
||||
SDL_PROC_UNUSED(void, glMap2f,
|
||||
(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
|
||||
GLint uorder, GLfloat v1, GLfloat v2, GLint vstride,
|
||||
GLint vorder, const GLfloat * points))
|
||||
SDL_PROC_UNUSED(void, glMapGrid1d, (GLint un, GLdouble u1, GLdouble u2))
|
||||
SDL_PROC_UNUSED(void, glMapGrid1f, (GLint un, GLfloat u1, GLfloat u2))
|
||||
SDL_PROC_UNUSED(void, glMapGrid2d,
|
||||
(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1,
|
||||
GLdouble v2))
|
||||
SDL_PROC_UNUSED(void, glMapGrid2f,
|
||||
(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1,
|
||||
GLfloat v2))
|
||||
SDL_PROC_UNUSED(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glMaterialfv,
|
||||
(GLenum face, GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glMateriali, (GLenum face, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glMaterialiv,
|
||||
(GLenum face, GLenum pname, const GLint * params))
|
||||
SDL_PROC(void, glMatrixMode, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glMultMatrixd, (const GLdouble * m))
|
||||
SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat * m))
|
||||
SDL_PROC_UNUSED(void, glNewList, (GLuint list, GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glNormal3b, (GLbyte nx, GLbyte ny, GLbyte nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3bv, (const GLbyte * v))
|
||||
SDL_PROC_UNUSED(void, glNormal3d, (GLdouble nx, GLdouble ny, GLdouble nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glNormal3i, (GLint nx, GLint ny, GLint nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glNormal3s, (GLshort nx, GLshort ny, GLshort nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glNormalPointer,
|
||||
(GLenum type, GLsizei stride, const GLvoid * pointer))
|
||||
SDL_PROC(void, glOrtho,
|
||||
(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
|
||||
GLdouble zNear, GLdouble zFar))
|
||||
SDL_PROC_UNUSED(void, glPassThrough, (GLfloat token))
|
||||
SDL_PROC_UNUSED(void, glPixelMapfv,
|
||||
(GLenum map, GLsizei mapsize, const GLfloat * values))
|
||||
SDL_PROC_UNUSED(void, glPixelMapuiv,
|
||||
(GLenum map, GLsizei mapsize, const GLuint * values))
|
||||
SDL_PROC_UNUSED(void, glPixelMapusv,
|
||||
(GLenum map, GLsizei mapsize, const GLushort * values))
|
||||
SDL_PROC_UNUSED(void, glPixelStoref, (GLenum pname, GLfloat param))
|
||||
SDL_PROC(void, glPixelStorei, (GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glPixelTransferf, (GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glPixelTransferi, (GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glPixelZoom, (GLfloat xfactor, GLfloat yfactor))
|
||||
SDL_PROC(void, glPointSize, (GLfloat size))
|
||||
SDL_PROC_UNUSED(void, glPolygonMode, (GLenum face, GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units))
|
||||
SDL_PROC_UNUSED(void, glPolygonStipple, (const GLubyte * mask))
|
||||
SDL_PROC_UNUSED(void, glPopAttrib, (void))
|
||||
SDL_PROC_UNUSED(void, glPopClientAttrib, (void))
|
||||
SDL_PROC(void, glPopMatrix, (void))
|
||||
SDL_PROC_UNUSED(void, glPopName, (void))
|
||||
SDL_PROC_UNUSED(void, glPrioritizeTextures,
|
||||
(GLsizei n, const GLuint * textures,
|
||||
const GLclampf * priorities))
|
||||
SDL_PROC_UNUSED(void, glPushAttrib, (GLbitfield mask))
|
||||
SDL_PROC_UNUSED(void, glPushClientAttrib, (GLbitfield mask))
|
||||
SDL_PROC(void, glPushMatrix, (void))
|
||||
SDL_PROC_UNUSED(void, glPushName, (GLuint name))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2d, (GLdouble x, GLdouble y))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2f, (GLfloat x, GLfloat y))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2fv, (const GLfloat * v))
|
||||
SDL_PROC(void, glRasterPos2i, (GLint x, GLint y))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2s, (GLshort x, GLshort y))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3d, (GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3f, (GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3i, (GLint x, GLint y, GLint z))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3s, (GLshort x, GLshort y, GLshort z))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4d,
|
||||
(GLdouble x, GLdouble y, GLdouble z, GLdouble w))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4f,
|
||||
(GLfloat x, GLfloat y, GLfloat z, GLfloat w))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4i, (GLint x, GLint y, GLint z, GLint w))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4s,
|
||||
(GLshort x, GLshort y, GLshort z, GLshort w))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4sv, (const GLshort * v))
|
||||
SDL_PROC(void, glReadBuffer, (GLenum mode))
|
||||
SDL_PROC(void, glReadPixels,
|
||||
(GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type, GLvoid * pixels))
|
||||
SDL_PROC_UNUSED(void, glRectd,
|
||||
(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2))
|
||||
SDL_PROC_UNUSED(void, glRectdv, (const GLdouble * v1, const GLdouble * v2))
|
||||
SDL_PROC(void, glRectf,
|
||||
(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2))
|
||||
SDL_PROC_UNUSED(void, glRectfv, (const GLfloat * v1, const GLfloat * v2))
|
||||
SDL_PROC_UNUSED(void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2))
|
||||
SDL_PROC_UNUSED(void, glRectiv, (const GLint * v1, const GLint * v2))
|
||||
SDL_PROC_UNUSED(void, glRects,
|
||||
(GLshort x1, GLshort y1, GLshort x2, GLshort y2))
|
||||
SDL_PROC_UNUSED(void, glRectsv, (const GLshort * v1, const GLshort * v2))
|
||||
SDL_PROC_UNUSED(GLint, glRenderMode, (GLenum mode))
|
||||
SDL_PROC(void, glRotated,
|
||||
(GLdouble angle, GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC(void, glRotatef,
|
||||
(GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC_UNUSED(void, glScaled, (GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height))
|
||||
SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint * buffer))
|
||||
SDL_PROC(void, glShadeModel, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask))
|
||||
SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask))
|
||||
SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1d, (GLdouble s))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1f, (GLfloat s))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1i, (GLint s))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1s, (GLshort s))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2d, (GLdouble s, GLdouble t))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2dv, (const GLdouble * v))
|
||||
SDL_PROC(void, glTexCoord2f, (GLfloat s, GLfloat t))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2i, (GLint s, GLint t))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2s, (GLshort s, GLshort t))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3d, (GLdouble s, GLdouble t, GLdouble r))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3f, (GLfloat s, GLfloat t, GLfloat r))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3i, (GLint s, GLint t, GLint r))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3s, (GLshort s, GLshort t, GLshort r))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4d,
|
||||
(GLdouble s, GLdouble t, GLdouble r, GLdouble q))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4f,
|
||||
(GLfloat s, GLfloat t, GLfloat r, GLfloat q))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4i, (GLint s, GLint t, GLint r, GLint q))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4s,
|
||||
(GLshort s, GLshort t, GLshort r, GLshort q))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoordPointer,
|
||||
(GLint size, GLenum type, GLsizei stride,
|
||||
const GLvoid * pointer))
|
||||
SDL_PROC(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glTexEnvfv,
|
||||
(GLenum target, GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glTexEnvi, (GLenum target, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glTexEnviv,
|
||||
(GLenum target, GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glTexGend, (GLenum coord, GLenum pname, GLdouble param))
|
||||
SDL_PROC_UNUSED(void, glTexGendv,
|
||||
(GLenum coord, GLenum pname, const GLdouble * params))
|
||||
SDL_PROC_UNUSED(void, glTexGenf, (GLenum coord, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glTexGenfv,
|
||||
(GLenum coord, GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glTexGeni, (GLenum coord, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glTexGeniv,
|
||||
(GLenum coord, GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glTexImage1D,
|
||||
(GLenum target, GLint level, GLint internalformat,
|
||||
GLsizei width, GLint border, GLenum format, GLenum type,
|
||||
const GLvoid * pixels))
|
||||
SDL_PROC(void, glTexImage2D,
|
||||
(GLenum target, GLint level, GLint internalformat, GLsizei width,
|
||||
GLsizei height, GLint border, GLenum format, GLenum type,
|
||||
const GLvoid * pixels))
|
||||
SDL_PROC_UNUSED(void, glTexParameterf,
|
||||
(GLenum target, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glTexParameterfv,
|
||||
(GLenum target, GLenum pname, const GLfloat * params))
|
||||
SDL_PROC(void, glTexParameteri, (GLenum target, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glTexParameteriv,
|
||||
(GLenum target, GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glTexSubImage1D,
|
||||
(GLenum target, GLint level, GLint xoffset, GLsizei width,
|
||||
GLenum format, GLenum type, const GLvoid * pixels))
|
||||
SDL_PROC(void, glTexSubImage2D,
|
||||
(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
||||
GLsizei width, GLsizei height, GLenum format, GLenum type,
|
||||
const GLvoid * pixels))
|
||||
SDL_PROC_UNUSED(void, glTranslated, (GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC_UNUSED(void, glVertex2d, (GLdouble x, GLdouble y))
|
||||
SDL_PROC_UNUSED(void, glVertex2dv, (const GLdouble * v))
|
||||
SDL_PROC(void, glVertex2f, (GLfloat x, GLfloat y))
|
||||
SDL_PROC_UNUSED(void, glVertex2fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glVertex2i, (GLint x, GLint y))
|
||||
SDL_PROC_UNUSED(void, glVertex2iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glVertex2s, (GLshort x, GLshort y))
|
||||
SDL_PROC_UNUSED(void, glVertex2sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glVertex3d, (GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC_UNUSED(void, glVertex3dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glVertex3f, (GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC(void, glVertex3fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glVertex3i, (GLint x, GLint y, GLint z))
|
||||
SDL_PROC_UNUSED(void, glVertex3iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glVertex3s, (GLshort x, GLshort y, GLshort z))
|
||||
SDL_PROC_UNUSED(void, glVertex3sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glVertex4d,
|
||||
(GLdouble x, GLdouble y, GLdouble z, GLdouble w))
|
||||
SDL_PROC_UNUSED(void, glVertex4dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glVertex4f,
|
||||
(GLfloat x, GLfloat y, GLfloat z, GLfloat w))
|
||||
SDL_PROC_UNUSED(void, glVertex4fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glVertex4i, (GLint x, GLint y, GLint z, GLint w))
|
||||
SDL_PROC_UNUSED(void, glVertex4iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glVertex4s,
|
||||
(GLshort x, GLshort y, GLshort z, GLshort w))
|
||||
SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glVertexPointer,
|
||||
(GLint size, GLenum type, GLsizei stride,
|
||||
const GLvoid * pointer))
|
||||
SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height))
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1803
externals/SDL/src/render/opengl/SDL_render_gl.c
vendored
Executable file
1803
externals/SDL/src/render/opengl/SDL_render_gl.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
542
externals/SDL/src/render/opengl/SDL_shaders_gl.c
vendored
Executable file
542
externals/SDL/src/render/opengl/SDL_shaders_gl.c
vendored
Executable file
@@ -0,0 +1,542 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_opengl.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_shaders_gl.h"
|
||||
|
||||
/* OpenGL shader implementation */
|
||||
|
||||
/* #define DEBUG_SHADERS */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLhandleARB program;
|
||||
GLhandleARB vert_shader;
|
||||
GLhandleARB frag_shader;
|
||||
} GL_ShaderData;
|
||||
|
||||
struct GL_ShaderContext
|
||||
{
|
||||
GLenum (*glGetError)(void);
|
||||
|
||||
PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
|
||||
PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
|
||||
PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
|
||||
PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
|
||||
PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
|
||||
PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
|
||||
PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
|
||||
PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
|
||||
PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
|
||||
PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
|
||||
PFNGLUNIFORM1IARBPROC glUniform1iARB;
|
||||
PFNGLUNIFORM1FARBPROC glUniform1fARB;
|
||||
PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
|
||||
|
||||
SDL_bool GL_ARB_texture_rectangle_supported;
|
||||
|
||||
GL_ShaderData shaders[NUM_SHADERS];
|
||||
};
|
||||
|
||||
#define COLOR_VERTEX_SHADER \
|
||||
"varying vec4 v_color;\n" \
|
||||
"\n" \
|
||||
"void main()\n" \
|
||||
"{\n" \
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" \
|
||||
" v_color = gl_Color;\n" \
|
||||
"}" \
|
||||
|
||||
#define TEXTURE_VERTEX_SHADER \
|
||||
"varying vec4 v_color;\n" \
|
||||
"varying vec2 v_texCoord;\n" \
|
||||
"\n" \
|
||||
"void main()\n" \
|
||||
"{\n" \
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" \
|
||||
" v_color = gl_Color;\n" \
|
||||
" v_texCoord = vec2(gl_MultiTexCoord0);\n" \
|
||||
"}" \
|
||||
|
||||
#define JPEG_SHADER_CONSTANTS \
|
||||
"// YUV offset \n" \
|
||||
"const vec3 offset = vec3(0, -0.501960814, -0.501960814);\n" \
|
||||
"\n" \
|
||||
"// RGB coefficients \n" \
|
||||
"const vec3 Rcoeff = vec3(1, 0.000, 1.402);\n" \
|
||||
"const vec3 Gcoeff = vec3(1, -0.3441, -0.7141);\n" \
|
||||
"const vec3 Bcoeff = vec3(1, 1.772, 0.000);\n" \
|
||||
|
||||
#define BT601_SHADER_CONSTANTS \
|
||||
"// YUV offset \n" \
|
||||
"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \
|
||||
"\n" \
|
||||
"// RGB coefficients \n" \
|
||||
"const vec3 Rcoeff = vec3(1.1644, 0.000, 1.596);\n" \
|
||||
"const vec3 Gcoeff = vec3(1.1644, -0.3918, -0.813);\n" \
|
||||
"const vec3 Bcoeff = vec3(1.1644, 2.0172, 0.000);\n" \
|
||||
|
||||
#define BT709_SHADER_CONSTANTS \
|
||||
"// YUV offset \n" \
|
||||
"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \
|
||||
"\n" \
|
||||
"// RGB coefficients \n" \
|
||||
"const vec3 Rcoeff = vec3(1.1644, 0.000, 1.7927);\n" \
|
||||
"const vec3 Gcoeff = vec3(1.1644, -0.2132, -0.5329);\n" \
|
||||
"const vec3 Bcoeff = vec3(1.1644, 2.1124, 0.000);\n" \
|
||||
|
||||
#define YUV_SHADER_PROLOGUE \
|
||||
"varying vec4 v_color;\n" \
|
||||
"varying vec2 v_texCoord;\n" \
|
||||
"uniform sampler2D tex0; // Y \n" \
|
||||
"uniform sampler2D tex1; // U \n" \
|
||||
"uniform sampler2D tex2; // V \n" \
|
||||
"\n" \
|
||||
|
||||
#define YUV_SHADER_BODY \
|
||||
"\n" \
|
||||
"void main()\n" \
|
||||
"{\n" \
|
||||
" vec2 tcoord;\n" \
|
||||
" vec3 yuv, rgb;\n" \
|
||||
"\n" \
|
||||
" // Get the Y value \n" \
|
||||
" tcoord = v_texCoord;\n" \
|
||||
" yuv.x = texture2D(tex0, tcoord).r;\n" \
|
||||
"\n" \
|
||||
" // Get the U and V values \n" \
|
||||
" tcoord *= UVCoordScale;\n" \
|
||||
" yuv.y = texture2D(tex1, tcoord).r;\n" \
|
||||
" yuv.z = texture2D(tex2, tcoord).r;\n" \
|
||||
"\n" \
|
||||
" // Do the color transform \n" \
|
||||
" yuv += offset;\n" \
|
||||
" rgb.r = dot(yuv, Rcoeff);\n" \
|
||||
" rgb.g = dot(yuv, Gcoeff);\n" \
|
||||
" rgb.b = dot(yuv, Bcoeff);\n" \
|
||||
"\n" \
|
||||
" // That was easy. :) \n" \
|
||||
" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \
|
||||
"}" \
|
||||
|
||||
#define NV12_SHADER_PROLOGUE \
|
||||
"varying vec4 v_color;\n" \
|
||||
"varying vec2 v_texCoord;\n" \
|
||||
"uniform sampler2D tex0; // Y \n" \
|
||||
"uniform sampler2D tex1; // U/V \n" \
|
||||
"\n" \
|
||||
|
||||
#define NV12_SHADER_BODY \
|
||||
"\n" \
|
||||
"void main()\n" \
|
||||
"{\n" \
|
||||
" vec2 tcoord;\n" \
|
||||
" vec3 yuv, rgb;\n" \
|
||||
"\n" \
|
||||
" // Get the Y value \n" \
|
||||
" tcoord = v_texCoord;\n" \
|
||||
" yuv.x = texture2D(tex0, tcoord).r;\n" \
|
||||
"\n" \
|
||||
" // Get the U and V values \n" \
|
||||
" tcoord *= UVCoordScale;\n" \
|
||||
" yuv.yz = texture2D(tex1, tcoord).ra;\n" \
|
||||
"\n" \
|
||||
" // Do the color transform \n" \
|
||||
" yuv += offset;\n" \
|
||||
" rgb.r = dot(yuv, Rcoeff);\n" \
|
||||
" rgb.g = dot(yuv, Gcoeff);\n" \
|
||||
" rgb.b = dot(yuv, Bcoeff);\n" \
|
||||
"\n" \
|
||||
" // That was easy. :) \n" \
|
||||
" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \
|
||||
"}" \
|
||||
|
||||
#define NV21_SHADER_PROLOGUE \
|
||||
"varying vec4 v_color;\n" \
|
||||
"varying vec2 v_texCoord;\n" \
|
||||
"uniform sampler2D tex0; // Y \n" \
|
||||
"uniform sampler2D tex1; // U/V \n" \
|
||||
"\n" \
|
||||
|
||||
#define NV21_SHADER_BODY \
|
||||
"\n" \
|
||||
"void main()\n" \
|
||||
"{\n" \
|
||||
" vec2 tcoord;\n" \
|
||||
" vec3 yuv, rgb;\n" \
|
||||
"\n" \
|
||||
" // Get the Y value \n" \
|
||||
" tcoord = v_texCoord;\n" \
|
||||
" yuv.x = texture2D(tex0, tcoord).r;\n" \
|
||||
"\n" \
|
||||
" // Get the U and V values \n" \
|
||||
" tcoord *= UVCoordScale;\n" \
|
||||
" yuv.yz = texture2D(tex1, tcoord).ar;\n" \
|
||||
"\n" \
|
||||
" // Do the color transform \n" \
|
||||
" yuv += offset;\n" \
|
||||
" rgb.r = dot(yuv, Rcoeff);\n" \
|
||||
" rgb.g = dot(yuv, Gcoeff);\n" \
|
||||
" rgb.b = dot(yuv, Bcoeff);\n" \
|
||||
"\n" \
|
||||
" // That was easy. :) \n" \
|
||||
" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \
|
||||
"}" \
|
||||
|
||||
/*
|
||||
* NOTE: Always use sampler2D, etc here. We'll #define them to the
|
||||
* texture_rectangle versions if we choose to use that extension.
|
||||
*/
|
||||
static const char *shader_source[NUM_SHADERS][2] =
|
||||
{
|
||||
/* SHADER_NONE */
|
||||
{ NULL, NULL },
|
||||
|
||||
/* SHADER_SOLID */
|
||||
{
|
||||
/* vertex shader */
|
||||
COLOR_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
"varying vec4 v_color;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = v_color;\n"
|
||||
"}"
|
||||
},
|
||||
|
||||
/* SHADER_RGB */
|
||||
{
|
||||
/* vertex shader */
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"uniform sampler2D tex0;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = texture2D(tex0, v_texCoord);\n"
|
||||
" gl_FragColor.a = 1.0;\n"
|
||||
" gl_FragColor *= v_color;\n"
|
||||
"}"
|
||||
},
|
||||
|
||||
/* SHADER_RGBA */
|
||||
{
|
||||
/* vertex shader */
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"uniform sampler2D tex0;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = texture2D(tex0, v_texCoord) * v_color;\n"
|
||||
"}"
|
||||
},
|
||||
|
||||
/* SHADER_YUV_JPEG */
|
||||
{
|
||||
/* vertex shader */
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
YUV_SHADER_PROLOGUE
|
||||
JPEG_SHADER_CONSTANTS
|
||||
YUV_SHADER_BODY
|
||||
},
|
||||
/* SHADER_YUV_BT601 */
|
||||
{
|
||||
/* vertex shader */
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
YUV_SHADER_PROLOGUE
|
||||
BT601_SHADER_CONSTANTS
|
||||
YUV_SHADER_BODY
|
||||
},
|
||||
/* SHADER_YUV_BT709 */
|
||||
{
|
||||
/* vertex shader */
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
YUV_SHADER_PROLOGUE
|
||||
BT709_SHADER_CONSTANTS
|
||||
YUV_SHADER_BODY
|
||||
},
|
||||
/* SHADER_NV12_JPEG */
|
||||
{
|
||||
/* vertex shader */
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
NV12_SHADER_PROLOGUE
|
||||
JPEG_SHADER_CONSTANTS
|
||||
NV12_SHADER_BODY
|
||||
},
|
||||
/* SHADER_NV12_BT601 */
|
||||
{
|
||||
/* vertex shader */
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
NV12_SHADER_PROLOGUE
|
||||
BT601_SHADER_CONSTANTS
|
||||
NV12_SHADER_BODY
|
||||
},
|
||||
/* SHADER_NV12_BT709 */
|
||||
{
|
||||
/* vertex shader */
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
NV12_SHADER_PROLOGUE
|
||||
BT709_SHADER_CONSTANTS
|
||||
NV12_SHADER_BODY
|
||||
},
|
||||
/* SHADER_NV21_JPEG */
|
||||
{
|
||||
/* vertex shader */
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
NV21_SHADER_PROLOGUE
|
||||
JPEG_SHADER_CONSTANTS
|
||||
NV21_SHADER_BODY
|
||||
},
|
||||
/* SHADER_NV21_BT601 */
|
||||
{
|
||||
/* vertex shader */
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
NV21_SHADER_PROLOGUE
|
||||
BT601_SHADER_CONSTANTS
|
||||
NV21_SHADER_BODY
|
||||
},
|
||||
/* SHADER_NV21_BT709 */
|
||||
{
|
||||
/* vertex shader */
|
||||
TEXTURE_VERTEX_SHADER,
|
||||
/* fragment shader */
|
||||
NV21_SHADER_PROLOGUE
|
||||
BT709_SHADER_CONSTANTS
|
||||
NV21_SHADER_BODY
|
||||
},
|
||||
};
|
||||
|
||||
static SDL_bool
|
||||
CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source)
|
||||
{
|
||||
GLint status;
|
||||
const char *sources[2];
|
||||
|
||||
sources[0] = defines;
|
||||
sources[1] = source;
|
||||
|
||||
ctx->glShaderSourceARB(shader, SDL_arraysize(sources), sources, NULL);
|
||||
ctx->glCompileShaderARB(shader);
|
||||
ctx->glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status);
|
||||
if (status == 0) {
|
||||
SDL_bool isstack;
|
||||
GLint length;
|
||||
char *info;
|
||||
|
||||
ctx->glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
|
||||
info = SDL_small_alloc(char, length+1, &isstack);
|
||||
ctx->glGetInfoLogARB(shader, length, NULL, info);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER,
|
||||
"Failed to compile shader:\n%s%s\n%s", defines, source, info);
|
||||
#ifdef DEBUG_SHADERS
|
||||
fprintf(stderr,
|
||||
"Failed to compile shader:\n%s%s\n%s", defines, source, info);
|
||||
#endif
|
||||
SDL_small_free(info, isstack);
|
||||
|
||||
return SDL_FALSE;
|
||||
} else {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
|
||||
{
|
||||
const int num_tmus_bound = 4;
|
||||
const char *vert_defines = "";
|
||||
const char *frag_defines = "";
|
||||
int i;
|
||||
GLint location;
|
||||
|
||||
if (index == SHADER_NONE) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
ctx->glGetError();
|
||||
|
||||
/* Make sure we use the correct sampler type for our texture type */
|
||||
if (ctx->GL_ARB_texture_rectangle_supported) {
|
||||
frag_defines =
|
||||
"#define sampler2D sampler2DRect\n"
|
||||
"#define texture2D texture2DRect\n"
|
||||
"#define UVCoordScale 0.5\n";
|
||||
} else {
|
||||
frag_defines =
|
||||
"#define UVCoordScale 1.0\n";
|
||||
}
|
||||
|
||||
/* Create one program object to rule them all */
|
||||
data->program = ctx->glCreateProgramObjectARB();
|
||||
|
||||
/* Create the vertex shader */
|
||||
data->vert_shader = ctx->glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
|
||||
if (!CompileShader(ctx, data->vert_shader, vert_defines, shader_source[index][0])) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Create the fragment shader */
|
||||
data->frag_shader = ctx->glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
|
||||
if (!CompileShader(ctx, data->frag_shader, frag_defines, shader_source[index][1])) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* ... and in the darkness bind them */
|
||||
ctx->glAttachObjectARB(data->program, data->vert_shader);
|
||||
ctx->glAttachObjectARB(data->program, data->frag_shader);
|
||||
ctx->glLinkProgramARB(data->program);
|
||||
|
||||
/* Set up some uniform variables */
|
||||
ctx->glUseProgramObjectARB(data->program);
|
||||
for (i = 0; i < num_tmus_bound; ++i) {
|
||||
char tex_name[10];
|
||||
SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i);
|
||||
location = ctx->glGetUniformLocationARB(data->program, tex_name);
|
||||
if (location >= 0) {
|
||||
ctx->glUniform1iARB(location, i);
|
||||
}
|
||||
}
|
||||
ctx->glUseProgramObjectARB(0);
|
||||
|
||||
return (ctx->glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyShaderProgram(GL_ShaderContext *ctx, GL_ShaderData *data)
|
||||
{
|
||||
ctx->glDeleteObjectARB(data->vert_shader);
|
||||
ctx->glDeleteObjectARB(data->frag_shader);
|
||||
ctx->glDeleteObjectARB(data->program);
|
||||
}
|
||||
|
||||
GL_ShaderContext *
|
||||
GL_CreateShaderContext(void)
|
||||
{
|
||||
GL_ShaderContext *ctx;
|
||||
SDL_bool shaders_supported;
|
||||
int i;
|
||||
|
||||
ctx = (GL_ShaderContext *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (!ctx) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!SDL_GL_ExtensionSupported("GL_ARB_texture_non_power_of_two") &&
|
||||
(SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") ||
|
||||
SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle"))) {
|
||||
ctx->GL_ARB_texture_rectangle_supported = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Check for shader support */
|
||||
shaders_supported = SDL_FALSE;
|
||||
if (SDL_GL_ExtensionSupported("GL_ARB_shader_objects") &&
|
||||
SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") &&
|
||||
SDL_GL_ExtensionSupported("GL_ARB_vertex_shader") &&
|
||||
SDL_GL_ExtensionSupported("GL_ARB_fragment_shader")) {
|
||||
ctx->glGetError = (GLenum (*)(void)) SDL_GL_GetProcAddress("glGetError");
|
||||
ctx->glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) SDL_GL_GetProcAddress("glAttachObjectARB");
|
||||
ctx->glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) SDL_GL_GetProcAddress("glCompileShaderARB");
|
||||
ctx->glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glCreateProgramObjectARB");
|
||||
ctx->glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) SDL_GL_GetProcAddress("glCreateShaderObjectARB");
|
||||
ctx->glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) SDL_GL_GetProcAddress("glDeleteObjectARB");
|
||||
ctx->glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) SDL_GL_GetProcAddress("glGetInfoLogARB");
|
||||
ctx->glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB");
|
||||
ctx->glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetUniformLocationARB");
|
||||
ctx->glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) SDL_GL_GetProcAddress("glLinkProgramARB");
|
||||
ctx->glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glShaderSourceARB");
|
||||
ctx->glUniform1iARB = (PFNGLUNIFORM1IARBPROC) SDL_GL_GetProcAddress("glUniform1iARB");
|
||||
ctx->glUniform1fARB = (PFNGLUNIFORM1FARBPROC) SDL_GL_GetProcAddress("glUniform1fARB");
|
||||
ctx->glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glUseProgramObjectARB");
|
||||
if (ctx->glGetError &&
|
||||
ctx->glAttachObjectARB &&
|
||||
ctx->glCompileShaderARB &&
|
||||
ctx->glCreateProgramObjectARB &&
|
||||
ctx->glCreateShaderObjectARB &&
|
||||
ctx->glDeleteObjectARB &&
|
||||
ctx->glGetInfoLogARB &&
|
||||
ctx->glGetObjectParameterivARB &&
|
||||
ctx->glGetUniformLocationARB &&
|
||||
ctx->glLinkProgramARB &&
|
||||
ctx->glShaderSourceARB &&
|
||||
ctx->glUniform1iARB &&
|
||||
ctx->glUniform1fARB &&
|
||||
ctx->glUseProgramObjectARB) {
|
||||
shaders_supported = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!shaders_supported) {
|
||||
SDL_free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Compile all the shaders */
|
||||
for (i = 0; i < NUM_SHADERS; ++i) {
|
||||
if (!CompileShaderProgram(ctx, i, &ctx->shaders[i])) {
|
||||
GL_DestroyShaderContext(ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* We're done! */
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void
|
||||
GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader)
|
||||
{
|
||||
ctx->glUseProgramObjectARB(ctx->shaders[shader].program);
|
||||
}
|
||||
|
||||
void
|
||||
GL_DestroyShaderContext(GL_ShaderContext *ctx)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_SHADERS; ++i) {
|
||||
DestroyShaderProgram(ctx, &ctx->shaders[i]);
|
||||
}
|
||||
SDL_free(ctx);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
55
externals/SDL/src/render/opengl/SDL_shaders_gl.h
vendored
Executable file
55
externals/SDL/src/render/opengl/SDL_shaders_gl.h
vendored
Executable file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
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 */
|
||||
|
||||
typedef enum {
|
||||
SHADER_INVALID = -1,
|
||||
SHADER_NONE,
|
||||
SHADER_SOLID,
|
||||
SHADER_RGB,
|
||||
SHADER_RGBA,
|
||||
SHADER_YUV_JPEG,
|
||||
SHADER_YUV_BT601,
|
||||
SHADER_YUV_BT709,
|
||||
SHADER_NV12_JPEG,
|
||||
SHADER_NV12_BT601,
|
||||
SHADER_NV12_BT709,
|
||||
SHADER_NV21_JPEG,
|
||||
SHADER_NV21_BT601,
|
||||
SHADER_NV21_BT709,
|
||||
NUM_SHADERS
|
||||
} GL_Shader;
|
||||
|
||||
typedef struct GL_ShaderContext GL_ShaderContext;
|
||||
|
||||
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: */
|
65
externals/SDL/src/render/opengles/SDL_glesfuncs.h
vendored
Executable file
65
externals/SDL/src/render/opengles/SDL_glesfuncs.h
vendored
Executable file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
SDL_PROC(void, glBindTexture, (GLenum, GLuint))
|
||||
SDL_PROC(void, glBlendFunc, (GLenum, GLenum))
|
||||
SDL_PROC_OES(void, glBlendEquationOES, (GLenum))
|
||||
SDL_PROC_OES(void, glBlendEquationSeparateOES, (GLenum, GLenum))
|
||||
SDL_PROC_OES(void, glBlendFuncSeparateOES, (GLenum, GLenum, GLenum, GLenum))
|
||||
SDL_PROC(void, glClear, (GLbitfield))
|
||||
SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
|
||||
SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glDeleteTextures, (GLsizei, const GLuint *))
|
||||
SDL_PROC(void, glDisable, (GLenum))
|
||||
SDL_PROC(void, glDisableClientState, (GLenum array))
|
||||
SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei))
|
||||
SDL_PROC_OES(void, glDrawTexfOES, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glEnable, (GLenum))
|
||||
SDL_PROC(void, glEnableClientState, (GLenum))
|
||||
SDL_PROC(void, glFinish, (void))
|
||||
SDL_PROC_OES(void, glGenFramebuffersOES, (GLsizei, GLuint *))
|
||||
SDL_PROC(void, glGenTextures, (GLsizei, GLuint *))
|
||||
SDL_PROC(GLenum, glGetError, (void))
|
||||
SDL_PROC(void, glGetIntegerv, (GLenum, GLint *))
|
||||
SDL_PROC(void, glLoadIdentity, (void))
|
||||
SDL_PROC(void, glMatrixMode, (GLenum))
|
||||
SDL_PROC(void, glOrthof, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glPixelStorei, (GLenum, GLint))
|
||||
SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
|
||||
SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
|
||||
SDL_PROC(void, glTexCoordPointer, (GLint, GLenum, GLsizei, const GLvoid *))
|
||||
SDL_PROC(void, glTexEnvf, (GLenum, GLenum, GLfloat))
|
||||
SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))
|
||||
SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint))
|
||||
SDL_PROC(void, glTexParameteriv, (GLenum, GLenum, const GLint *))
|
||||
SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))
|
||||
SDL_PROC(void, glVertexPointer, (GLint, GLenum, GLsizei, const GLvoid *))
|
||||
SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei))
|
||||
SDL_PROC_OES(void, glBindFramebufferOES, (GLenum, GLuint))
|
||||
SDL_PROC_OES(void, glFramebufferTexture2DOES, (GLenum, GLenum, GLenum, GLuint, GLint))
|
||||
SDL_PROC_OES(GLenum, glCheckFramebufferStatusOES, (GLenum))
|
||||
SDL_PROC(void, glPushMatrix, (void))
|
||||
SDL_PROC(void, glTranslatef, (GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glRotatef, (GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glPopMatrix, (void))
|
||||
SDL_PROC_OES(void, glDeleteFramebuffersOES, (GLsizei, const GLuint*))
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1273
externals/SDL/src/render/opengles/SDL_render_gles.c
vendored
Executable file
1273
externals/SDL/src/render/opengles/SDL_render_gles.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
81
externals/SDL/src/render/opengles2/SDL_gles2funcs.h
vendored
Executable file
81
externals/SDL/src/render/opengles2/SDL_gles2funcs.h
vendored
Executable file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
SDL_PROC(void, glActiveTexture, (GLenum))
|
||||
SDL_PROC(void, glAttachShader, (GLuint, GLuint))
|
||||
SDL_PROC(void, glBindAttribLocation, (GLuint, GLuint, const char *))
|
||||
SDL_PROC(void, glBindTexture, (GLenum, GLuint))
|
||||
SDL_PROC(void, glBlendEquationSeparate, (GLenum, GLenum))
|
||||
SDL_PROC(void, glBlendFuncSeparate, (GLenum, GLenum, GLenum, GLenum))
|
||||
SDL_PROC(void, glClear, (GLbitfield))
|
||||
SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
|
||||
SDL_PROC(void, glCompileShader, (GLuint))
|
||||
SDL_PROC(GLuint, glCreateProgram, (void))
|
||||
SDL_PROC(GLuint, glCreateShader, (GLenum))
|
||||
SDL_PROC(void, glDeleteProgram, (GLuint))
|
||||
SDL_PROC(void, glDeleteShader, (GLuint))
|
||||
SDL_PROC(void, glDeleteTextures, (GLsizei, const GLuint *))
|
||||
SDL_PROC(void, glDisable, (GLenum))
|
||||
SDL_PROC(void, glDisableVertexAttribArray, (GLuint))
|
||||
SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei))
|
||||
SDL_PROC(void, glEnable, (GLenum))
|
||||
SDL_PROC(void, glEnableVertexAttribArray, (GLuint))
|
||||
SDL_PROC(void, glFinish, (void))
|
||||
SDL_PROC(void, glGenFramebuffers, (GLsizei, GLuint *))
|
||||
SDL_PROC(void, glGenTextures, (GLsizei, GLuint *))
|
||||
SDL_PROC(void, glGetBooleanv, (GLenum, GLboolean *))
|
||||
SDL_PROC(const GLubyte *, glGetString, (GLenum))
|
||||
SDL_PROC(GLenum, glGetError, (void))
|
||||
SDL_PROC(void, glGetIntegerv, (GLenum, GLint *))
|
||||
SDL_PROC(void, glGetProgramiv, (GLuint, GLenum, GLint *))
|
||||
SDL_PROC(void, glGetShaderInfoLog, (GLuint, GLsizei, GLsizei *, char *))
|
||||
SDL_PROC(void, glGetShaderiv, (GLuint, GLenum, GLint *))
|
||||
SDL_PROC(GLint, glGetUniformLocation, (GLuint, const char *))
|
||||
SDL_PROC(void, glLinkProgram, (GLuint))
|
||||
SDL_PROC(void, glPixelStorei, (GLenum, GLint))
|
||||
SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
|
||||
SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
|
||||
SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei))
|
||||
#if __NACL__
|
||||
SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar **, const GLint *))
|
||||
#else
|
||||
SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar* const*, const GLint *))
|
||||
#endif
|
||||
SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))
|
||||
SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint))
|
||||
SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))
|
||||
SDL_PROC(void, glUniform1i, (GLint, GLint))
|
||||
SDL_PROC(void, glUniform4f, (GLint, GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glUniformMatrix4fv, (GLint, GLsizei, GLboolean, const GLfloat *))
|
||||
SDL_PROC(void, glUseProgram, (GLuint))
|
||||
SDL_PROC(void, glVertexAttribPointer, (GLuint, GLint, GLenum, GLboolean, GLsizei, const void *))
|
||||
SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei))
|
||||
SDL_PROC(void, glBindFramebuffer, (GLenum, GLuint))
|
||||
SDL_PROC(void, glFramebufferTexture2D, (GLenum, GLenum, GLenum, GLuint, GLint))
|
||||
SDL_PROC(GLenum, glCheckFramebufferStatus, (GLenum))
|
||||
SDL_PROC(void, glDeleteFramebuffers, (GLsizei, const GLuint *))
|
||||
SDL_PROC(GLint, glGetAttribLocation, (GLuint, const GLchar *))
|
||||
SDL_PROC(void, glGetProgramInfoLog, (GLuint, GLsizei, GLsizei*, GLchar*))
|
||||
SDL_PROC(void, glGenBuffers, (GLsizei, GLuint *))
|
||||
SDL_PROC(void, glDeleteBuffers, (GLsizei, const GLuint *))
|
||||
SDL_PROC(void, glBindBuffer, (GLenum, GLuint))
|
||||
SDL_PROC(void, glBufferData, (GLenum, GLsizeiptr, const GLvoid *, GLenum))
|
||||
SDL_PROC(void, glBufferSubData, (GLenum, GLintptr, GLsizeiptr, const GLvoid *))
|
2172
externals/SDL/src/render/opengles2/SDL_render_gles2.c
vendored
Executable file
2172
externals/SDL/src/render/opengles2/SDL_render_gles2.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
573
externals/SDL/src/render/opengles2/SDL_shaders_gles2.c
vendored
Executable file
573
externals/SDL/src/render/opengles2/SDL_shaders_gles2.c
vendored
Executable file
@@ -0,0 +1,573 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_opengles2.h"
|
||||
#include "SDL_shaders_gles2.h"
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
/*************************************************************************************************
|
||||
* Vertex/fragment shader source *
|
||||
*************************************************************************************************/
|
||||
/* Notes on a_angle:
|
||||
* It is a vector containing sin and cos for rotation matrix
|
||||
* To get correct rotation for most cases when a_angle is disabled cos
|
||||
value is decremented by 1.0 to get proper output with 0.0 which is
|
||||
default value
|
||||
*/
|
||||
static const Uint8 GLES2_VertexSrc_Default_[] = " \
|
||||
uniform mat4 u_projection; \
|
||||
attribute vec2 a_position; \
|
||||
attribute vec2 a_texCoord; \
|
||||
attribute vec2 a_angle; \
|
||||
attribute vec2 a_center; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
float s = a_angle[0]; \
|
||||
float c = a_angle[1] + 1.0; \
|
||||
mat2 rotationMatrix = mat2(c, -s, s, c); \
|
||||
vec2 position = rotationMatrix * (a_position - a_center) + a_center; \
|
||||
v_texCoord = a_texCoord; \
|
||||
gl_Position = u_projection * vec4(position, 0.0, 1.0);\
|
||||
gl_PointSize = 1.0; \
|
||||
} \
|
||||
";
|
||||
|
||||
static const Uint8 GLES2_FragmentSrc_SolidSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform vec4 u_color; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
gl_FragColor = u_color; \
|
||||
} \
|
||||
";
|
||||
|
||||
static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_color; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
gl_FragColor = texture2D(u_texture, v_texCoord); \
|
||||
gl_FragColor *= u_color; \
|
||||
} \
|
||||
";
|
||||
|
||||
/* ARGB to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_color; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
vec4 abgr = texture2D(u_texture, v_texCoord); \
|
||||
gl_FragColor = abgr; \
|
||||
gl_FragColor.r = abgr.b; \
|
||||
gl_FragColor.b = abgr.r; \
|
||||
gl_FragColor *= u_color; \
|
||||
} \
|
||||
";
|
||||
|
||||
/* RGB to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_color; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
vec4 abgr = texture2D(u_texture, v_texCoord); \
|
||||
gl_FragColor = abgr; \
|
||||
gl_FragColor.r = abgr.b; \
|
||||
gl_FragColor.b = abgr.r; \
|
||||
gl_FragColor.a = 1.0; \
|
||||
gl_FragColor *= u_color; \
|
||||
} \
|
||||
";
|
||||
|
||||
/* BGR to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_color; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
vec4 abgr = texture2D(u_texture, v_texCoord); \
|
||||
gl_FragColor = abgr; \
|
||||
gl_FragColor.a = 1.0; \
|
||||
gl_FragColor *= u_color; \
|
||||
} \
|
||||
";
|
||||
|
||||
#define JPEG_SHADER_CONSTANTS \
|
||||
"// YUV offset \n" \
|
||||
"const vec3 offset = vec3(0, -0.501960814, -0.501960814);\n" \
|
||||
"\n" \
|
||||
"// RGB coefficients \n" \
|
||||
"const mat3 matrix = mat3( 1, 1, 1,\n" \
|
||||
" 0, -0.3441, 1.772,\n" \
|
||||
" 1.402, -0.7141, 0);\n" \
|
||||
|
||||
#define BT601_SHADER_CONSTANTS \
|
||||
"// YUV offset \n" \
|
||||
"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \
|
||||
"\n" \
|
||||
"// RGB coefficients \n" \
|
||||
"const mat3 matrix = mat3( 1.1644, 1.1644, 1.1644,\n" \
|
||||
" 0, -0.3918, 2.0172,\n" \
|
||||
" 1.596, -0.813, 0);\n" \
|
||||
|
||||
#define BT709_SHADER_CONSTANTS \
|
||||
"// YUV offset \n" \
|
||||
"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \
|
||||
"\n" \
|
||||
"// RGB coefficients \n" \
|
||||
"const mat3 matrix = mat3( 1.1644, 1.1644, 1.1644,\n" \
|
||||
" 0, -0.2132, 2.1124,\n" \
|
||||
" 1.7927, -0.5329, 0);\n" \
|
||||
|
||||
|
||||
#define YUV_SHADER_PROLOGUE \
|
||||
"precision mediump float;\n" \
|
||||
"uniform sampler2D u_texture;\n" \
|
||||
"uniform sampler2D u_texture_u;\n" \
|
||||
"uniform sampler2D u_texture_v;\n" \
|
||||
"uniform vec4 u_color;\n" \
|
||||
"varying vec2 v_texCoord;\n" \
|
||||
"\n" \
|
||||
|
||||
#define YUV_SHADER_BODY \
|
||||
"\n" \
|
||||
"void main()\n" \
|
||||
"{\n" \
|
||||
" mediump vec3 yuv;\n" \
|
||||
" lowp vec3 rgb;\n" \
|
||||
"\n" \
|
||||
" // Get the YUV values \n" \
|
||||
" yuv.x = texture2D(u_texture, v_texCoord).r;\n" \
|
||||
" yuv.y = texture2D(u_texture_u, v_texCoord).r;\n" \
|
||||
" yuv.z = texture2D(u_texture_v, v_texCoord).r;\n" \
|
||||
"\n" \
|
||||
" // Do the color transform \n" \
|
||||
" yuv += offset;\n" \
|
||||
" rgb = matrix * yuv;\n" \
|
||||
"\n" \
|
||||
" // That was easy. :) \n" \
|
||||
" gl_FragColor = vec4(rgb, 1);\n" \
|
||||
" gl_FragColor *= u_color;\n" \
|
||||
"}" \
|
||||
|
||||
#define NV12_SHADER_BODY \
|
||||
"\n" \
|
||||
"void main()\n" \
|
||||
"{\n" \
|
||||
" mediump vec3 yuv;\n" \
|
||||
" lowp vec3 rgb;\n" \
|
||||
"\n" \
|
||||
" // Get the YUV values \n" \
|
||||
" yuv.x = texture2D(u_texture, v_texCoord).r;\n" \
|
||||
" yuv.yz = texture2D(u_texture_u, v_texCoord).ra;\n" \
|
||||
"\n" \
|
||||
" // Do the color transform \n" \
|
||||
" yuv += offset;\n" \
|
||||
" rgb = matrix * yuv;\n" \
|
||||
"\n" \
|
||||
" // That was easy. :) \n" \
|
||||
" gl_FragColor = vec4(rgb, 1);\n" \
|
||||
" gl_FragColor *= u_color;\n" \
|
||||
"}" \
|
||||
|
||||
#define NV21_SHADER_BODY \
|
||||
"\n" \
|
||||
"void main()\n" \
|
||||
"{\n" \
|
||||
" mediump vec3 yuv;\n" \
|
||||
" lowp vec3 rgb;\n" \
|
||||
"\n" \
|
||||
" // Get the YUV values \n" \
|
||||
" yuv.x = texture2D(u_texture, v_texCoord).r;\n" \
|
||||
" yuv.yz = texture2D(u_texture_u, v_texCoord).ar;\n" \
|
||||
"\n" \
|
||||
" // Do the color transform \n" \
|
||||
" yuv += offset;\n" \
|
||||
" rgb = matrix * yuv;\n" \
|
||||
"\n" \
|
||||
" // That was easy. :) \n" \
|
||||
" gl_FragColor = vec4(rgb, 1);\n" \
|
||||
" gl_FragColor *= u_color;\n" \
|
||||
"}" \
|
||||
|
||||
/* YUV to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureYUVJPEGSrc_[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
JPEG_SHADER_CONSTANTS \
|
||||
YUV_SHADER_BODY \
|
||||
;
|
||||
static const Uint8 GLES2_FragmentSrc_TextureYUVBT601Src_[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
BT601_SHADER_CONSTANTS \
|
||||
YUV_SHADER_BODY \
|
||||
;
|
||||
static const Uint8 GLES2_FragmentSrc_TextureYUVBT709Src_[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
BT709_SHADER_CONSTANTS \
|
||||
YUV_SHADER_BODY \
|
||||
;
|
||||
|
||||
/* NV12 to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV12JPEGSrc_[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
JPEG_SHADER_CONSTANTS \
|
||||
NV12_SHADER_BODY \
|
||||
;
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV12BT601Src_[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
BT601_SHADER_CONSTANTS \
|
||||
NV12_SHADER_BODY \
|
||||
;
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV12BT709Src_[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
BT709_SHADER_CONSTANTS \
|
||||
NV12_SHADER_BODY \
|
||||
;
|
||||
|
||||
/* NV21 to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV21JPEGSrc_[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
JPEG_SHADER_CONSTANTS \
|
||||
NV21_SHADER_BODY \
|
||||
;
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV21BT601Src_[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
BT601_SHADER_CONSTANTS \
|
||||
NV21_SHADER_BODY \
|
||||
;
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV21BT709Src_[] = \
|
||||
YUV_SHADER_PROLOGUE \
|
||||
BT709_SHADER_CONSTANTS \
|
||||
NV21_SHADER_BODY \
|
||||
;
|
||||
|
||||
/* Custom Android video format texture */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureExternalOESSrc_[] = " \
|
||||
#extension GL_OES_EGL_image_external : require\n\
|
||||
precision mediump float; \
|
||||
uniform samplerExternalOES u_texture; \
|
||||
uniform vec4 u_color; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
gl_FragColor = texture2D(u_texture, v_texCoord); \
|
||||
gl_FragColor *= u_color; \
|
||||
} \
|
||||
";
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_VertexSrc_Default = {
|
||||
GL_VERTEX_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_VertexSrc_Default_),
|
||||
GLES2_VertexSrc_Default_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_SolidSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_SolidSrc_),
|
||||
GLES2_FragmentSrc_SolidSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureABGRSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureABGRSrc_),
|
||||
GLES2_FragmentSrc_TextureABGRSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureARGBSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureARGBSrc_),
|
||||
GLES2_FragmentSrc_TextureARGBSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureRGBSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureRGBSrc_),
|
||||
GLES2_FragmentSrc_TextureRGBSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureBGRSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureBGRSrc_),
|
||||
GLES2_FragmentSrc_TextureBGRSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVJPEGSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureYUVJPEGSrc_),
|
||||
GLES2_FragmentSrc_TextureYUVJPEGSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVBT601Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureYUVBT601Src_),
|
||||
GLES2_FragmentSrc_TextureYUVBT601Src_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVBT709Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureYUVBT709Src_),
|
||||
GLES2_FragmentSrc_TextureYUVBT709Src_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12JPEGSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV12JPEGSrc_),
|
||||
GLES2_FragmentSrc_TextureNV12JPEGSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12BT601Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV12BT601Src_),
|
||||
GLES2_FragmentSrc_TextureNV12BT601Src_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21BT709Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV21BT709Src_),
|
||||
GLES2_FragmentSrc_TextureNV21BT709Src_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21JPEGSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV21JPEGSrc_),
|
||||
GLES2_FragmentSrc_TextureNV21JPEGSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21BT601Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV21BT601Src_),
|
||||
GLES2_FragmentSrc_TextureNV21BT601Src_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12BT709Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV12BT709Src_),
|
||||
GLES2_FragmentSrc_TextureNV12BT709Src_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureExternalOESSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureExternalOESSrc_),
|
||||
GLES2_FragmentSrc_TextureExternalOESSrc_
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************************************
|
||||
* Vertex/fragment shader definitions *
|
||||
*************************************************************************************************/
|
||||
|
||||
static GLES2_Shader GLES2_VertexShader_Default = {
|
||||
1,
|
||||
{
|
||||
&GLES2_VertexSrc_Default
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_SolidSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_SolidSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureABGRSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureABGRSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureARGBSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureARGBSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureRGBSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureRGBSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureBGRSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureBGRSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureYUVJPEGSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureYUVJPEGSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureYUVBT601Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureYUVBT601Src
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureYUVBT709Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureYUVBT709Src
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV12JPEGSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV12JPEGSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV12BT601Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV12BT601Src
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV12BT709Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV12BT709Src
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV21JPEGSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV21JPEGSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV21BT601Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV21BT601Src
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV21BT709Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV21BT709Src
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureExternalOESSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureExternalOESSrc
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************************************
|
||||
* Shader selector *
|
||||
*************************************************************************************************/
|
||||
|
||||
const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type)
|
||||
{
|
||||
switch (type) {
|
||||
case GLES2_SHADER_VERTEX_DEFAULT:
|
||||
return &GLES2_VertexShader_Default;
|
||||
case GLES2_SHADER_FRAGMENT_SOLID_SRC:
|
||||
return &GLES2_FragmentShader_SolidSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC:
|
||||
return &GLES2_FragmentShader_TextureABGRSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC:
|
||||
return &GLES2_FragmentShader_TextureARGBSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC:
|
||||
return &GLES2_FragmentShader_TextureRGBSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC:
|
||||
return &GLES2_FragmentShader_TextureBGRSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC:
|
||||
return &GLES2_FragmentShader_TextureYUVJPEGSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC:
|
||||
return &GLES2_FragmentShader_TextureYUVBT601Src;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC:
|
||||
return &GLES2_FragmentShader_TextureYUVBT709Src;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC:
|
||||
return &GLES2_FragmentShader_TextureNV12JPEGSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC:
|
||||
return &GLES2_FragmentShader_TextureNV12BT601Src;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC:
|
||||
return &GLES2_FragmentShader_TextureNV12BT709Src;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC:
|
||||
return &GLES2_FragmentShader_TextureNV21JPEGSrc;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC:
|
||||
return &GLES2_FragmentShader_TextureNV21BT601Src;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC:
|
||||
return &GLES2_FragmentShader_TextureNV21BT709Src;
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC:
|
||||
return &GLES2_FragmentShader_TextureExternalOESSrc;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
70
externals/SDL/src/render/opengles2/SDL_shaders_gles2.h
vendored
Executable file
70
externals/SDL/src/render/opengles2/SDL_shaders_gles2.h
vendored
Executable file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#ifndef SDL_shaders_gles2_h_
|
||||
#define SDL_shaders_gles2_h_
|
||||
|
||||
#if SDL_VIDEO_RENDER_OGL_ES2
|
||||
|
||||
typedef struct GLES2_ShaderInstance
|
||||
{
|
||||
GLenum type;
|
||||
GLenum format;
|
||||
int length;
|
||||
const void *data;
|
||||
} GLES2_ShaderInstance;
|
||||
|
||||
typedef struct GLES2_Shader
|
||||
{
|
||||
int instance_count;
|
||||
const GLES2_ShaderInstance *instances[4];
|
||||
} GLES2_Shader;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GLES2_SHADER_VERTEX_DEFAULT,
|
||||
GLES2_SHADER_FRAGMENT_SOLID_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC
|
||||
} GLES2_ShaderType;
|
||||
|
||||
#define GLES2_SOURCE_SHADER (GLenum)-1
|
||||
|
||||
const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type);
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL_ES2 */
|
||||
|
||||
#endif /* SDL_shaders_gles2_h_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1059
externals/SDL/src/render/psp/SDL_render_psp.c
vendored
Executable file
1059
externals/SDL/src/render/psp/SDL_render_psp.c
vendored
Executable file
File diff suppressed because it is too large
Load Diff
357
externals/SDL/src/render/software/SDL_blendfillrect.c
vendored
Executable file
357
externals/SDL/src/render/software/SDL_blendfillrect.c
vendored
Executable file
@@ -0,0 +1,357 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendfillrect.h"
|
||||
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB555);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB555);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_MUL_RGB555);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_RGB555);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB565);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB565);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_MUL_RGB565);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_RGB565);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB888);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB888);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_MUL_RGB888);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_RGB888);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_MUL_ARGB8888);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_ARGB8888);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 2:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_MUL_RGB);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_RGB);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
case 4:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_MUL_RGB);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_RGB);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 4:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGBA);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGBA);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_MUL_RGBA);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_RGBA);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_Rect clipped;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
return SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* If 'rect' == NULL, then fill the whole surface */
|
||||
if (rect) {
|
||||
/* Perform clipping */
|
||||
if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) {
|
||||
return 0;
|
||||
}
|
||||
rect = &clipped;
|
||||
} else {
|
||||
rect = &dst->clip_rect;
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(r, a);
|
||||
g = DRAW_MUL(g, a);
|
||||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
switch (dst->format->BitsPerPixel) {
|
||||
case 15:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x7C00:
|
||||
return SDL_BlendFillRect_RGB555(dst, rect, blendMode, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0xF800:
|
||||
return SDL_BlendFillRect_RGB565(dst, rect, blendMode, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x00FF0000:
|
||||
if (!dst->format->Amask) {
|
||||
return SDL_BlendFillRect_RGB888(dst, rect, blendMode, r, g, b, a);
|
||||
} else {
|
||||
return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a);
|
||||
}
|
||||
/* break; -Wunreachable-code-break */
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!dst->format->Amask) {
|
||||
return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a);
|
||||
} else {
|
||||
return SDL_BlendFillRect_RGBA(dst, rect, blendMode, r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_Rect rect;
|
||||
int i;
|
||||
int (*func)(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
int status = 0;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(r, a);
|
||||
g = DRAW_MUL(g, a);
|
||||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
/* FIXME: Does this function pointer slow things down significantly? */
|
||||
switch (dst->format->BitsPerPixel) {
|
||||
case 15:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x7C00:
|
||||
func = SDL_BlendFillRect_RGB555;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0xF800:
|
||||
func = SDL_BlendFillRect_RGB565;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x00FF0000:
|
||||
if (!dst->format->Amask) {
|
||||
func = SDL_BlendFillRect_RGB888;
|
||||
} else {
|
||||
func = SDL_BlendFillRect_ARGB8888;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!func) {
|
||||
if (!dst->format->Amask) {
|
||||
func = SDL_BlendFillRect_RGB;
|
||||
} else {
|
||||
func = SDL_BlendFillRect_RGBA;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
/* Perform clipping */
|
||||
if (!SDL_IntersectRect(&rects[i], &dst->clip_rect, &rect)) {
|
||||
continue;
|
||||
}
|
||||
status = func(dst, &rect, blendMode, r, g, b, a);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
33
externals/SDL/src/render/software/SDL_blendfillrect.h
vendored
Executable file
33
externals/SDL/src/render/software/SDL_blendfillrect.h
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
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: */
|
875
externals/SDL/src/render/software/SDL_blendline.c
vendored
Executable file
875
externals/SDL/src/render/software/SDL_blendline.c
vendored
Executable file
@@ -0,0 +1,875 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendline.h"
|
||||
#include "SDL_blendpoint.h"
|
||||
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_MUL_RGB, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_MUL_RGB, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_MUL_RGB, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY2_BLEND_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY2_ADD_RGB, DRAW_SETPIXELXY2_ADD_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY2_MOD_RGB, DRAW_SETPIXELXY2_MOD_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY2_MUL_RGB, DRAW_SETPIXELXY2_MUL_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY2_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_MUL_RGB555, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_MUL_RGB555, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_MUL_RGB555, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_BLEND_RGB555, DRAW_SETPIXELXY_BLEND_RGB555,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_ADD_RGB555, DRAW_SETPIXELXY_ADD_RGB555,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_MOD_RGB555, DRAW_SETPIXELXY_MOD_RGB555,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_MUL_RGB555, DRAW_SETPIXELXY_MUL_RGB555,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_RGB555, DRAW_SETPIXELXY_BLEND_RGB555,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_MUL_RGB565, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_MUL_RGB565, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_MUL_RGB565, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_BLEND_RGB565, DRAW_SETPIXELXY_BLEND_RGB565,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_ADD_RGB565, DRAW_SETPIXELXY_ADD_RGB565,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_MOD_RGB565, DRAW_SETPIXELXY_MOD_RGB565,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_MUL_RGB565, DRAW_SETPIXELXY_MUL_RGB565,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_RGB565, DRAW_SETPIXELXY_BLEND_RGB565,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_MUL_RGB, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_MUL_RGB, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_MUL_RGB, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_BLEND_RGB, DRAW_SETPIXELXY4_BLEND_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_ADD_RGB, DRAW_SETPIXELXY4_ADD_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_MOD_RGB, DRAW_SETPIXELXY4_MOD_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_MUL_RGB, DRAW_SETPIXELXY4_MUL_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_RGB, DRAW_SETPIXELXY4_BLEND_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_MUL_RGBA, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_MUL_RGBA, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_MUL_RGBA, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_BLEND_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_ADD_RGBA, DRAW_SETPIXELXY4_ADD_RGBA,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_MOD_RGBA, DRAW_SETPIXELXY4_MOD_RGBA,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_MUL_RGBA, DRAW_SETPIXELXY4_MUL_RGBA,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_MUL_RGB888, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_MUL_RGB888, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_MUL_RGB888, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_BLEND_RGB888, DRAW_SETPIXELXY_BLEND_RGB888,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_ADD_RGB888, DRAW_SETPIXELXY_ADD_RGB888,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_MOD_RGB888, DRAW_SETPIXELXY_MOD_RGB888,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_MUL_RGB888, DRAW_SETPIXELXY_MUL_RGB888,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_RGB888, DRAW_SETPIXELXY_BLEND_RGB888,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_MUL_ARGB8888, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_MUL_ARGB8888, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_MUL_ARGB8888, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_BLEND_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_ADD_ARGB8888, DRAW_SETPIXELXY_ADD_ARGB8888,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_MOD_ARGB8888, DRAW_SETPIXELXY_MOD_ARGB8888,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_MUL_ARGB8888, DRAW_SETPIXELXY_MUL_ARGB8888,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*BlendLineFunc) (SDL_Surface * dst,
|
||||
int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
|
||||
SDL_bool draw_end);
|
||||
|
||||
static BlendLineFunc
|
||||
SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt)
|
||||
{
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 2:
|
||||
if (fmt->Rmask == 0x7C00) {
|
||||
return SDL_BlendLine_RGB555;
|
||||
} else if (fmt->Rmask == 0xF800) {
|
||||
return SDL_BlendLine_RGB565;
|
||||
} else {
|
||||
return SDL_BlendLine_RGB2;
|
||||
}
|
||||
/* break; -Wunreachable-code-break */
|
||||
case 4:
|
||||
if (fmt->Rmask == 0x00FF0000) {
|
||||
if (fmt->Amask) {
|
||||
return SDL_BlendLine_ARGB8888;
|
||||
} else {
|
||||
return SDL_BlendLine_RGB888;
|
||||
}
|
||||
} else {
|
||||
if (fmt->Amask) {
|
||||
return SDL_BlendLine_RGBA4;
|
||||
} else {
|
||||
return SDL_BlendLine_RGB4;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
BlendLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("SDL_BlendLine(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, SDL_TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
int i;
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
SDL_bool draw_end;
|
||||
BlendLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_BlendLines(): Unsupported surface format");
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
x1 = points[i-1].x;
|
||||
y1 = points[i-1].y;
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Draw the end if it was clipped */
|
||||
draw_end = (x2 != points[i].x || y2 != points[i].y);
|
||||
|
||||
func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end);
|
||||
}
|
||||
if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
|
||||
SDL_BlendPoint(dst, points[count-1].x, points[count-1].y,
|
||||
blendMode, r, g, b, a);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
33
externals/SDL/src/render/software/SDL_blendline.h
vendored
Executable file
33
externals/SDL/src/render/software/SDL_blendline.h
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
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: */
|
362
externals/SDL/src/render/software/SDL_blendpoint.c
vendored
Executable file
362
externals/SDL/src/render/software/SDL_blendpoint.c
vendored
Executable file
@@ -0,0 +1,362 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendpoint.h"
|
||||
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY_BLEND_RGB555(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY_ADD_RGB555(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY_MOD_RGB555(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DRAW_SETPIXELXY_MUL_RGB555(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY_RGB555(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY_BLEND_RGB565(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY_ADD_RGB565(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY_MOD_RGB565(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DRAW_SETPIXELXY_MUL_RGB565(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY_RGB565(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY_BLEND_RGB888(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY_ADD_RGB888(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY_MOD_RGB888(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DRAW_SETPIXELXY_MUL_RGB888(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY_RGB888(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY_BLEND_ARGB8888(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY_ADD_ARGB8888(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY_MOD_ARGB8888(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DRAW_SETPIXELXY_MUL_ARGB8888(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY_ARGB8888(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 2:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY2_BLEND_RGB(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY2_ADD_RGB(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY2_MOD_RGB(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DRAW_SETPIXELXY2_MUL_RGB(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY2_RGB(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
case 4:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY4_BLEND_RGB(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY4_ADD_RGB(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY4_MOD_RGB(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DRAW_SETPIXELXY4_MUL_RGB(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY4_RGB(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 4:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY4_BLEND_RGBA(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY4_ADD_RGBA(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY4_MOD_RGBA(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MUL:
|
||||
DRAW_SETPIXELXY4_MUL_RGBA(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY4_RGBA(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
if (!dst) {
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
return SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
|
||||
x >= (dst->clip_rect.x + dst->clip_rect.w) ||
|
||||
y >= (dst->clip_rect.y + dst->clip_rect.h)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(r, a);
|
||||
g = DRAW_MUL(g, a);
|
||||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
switch (dst->format->BitsPerPixel) {
|
||||
case 15:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x7C00:
|
||||
return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0xF800:
|
||||
return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x00FF0000:
|
||||
if (!dst->format->Amask) {
|
||||
return SDL_BlendPoint_RGB888(dst, x, y, blendMode, r, g, b, a);
|
||||
} else {
|
||||
return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
/* break; -Wunreachable-code-break */
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!dst->format->Amask) {
|
||||
return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a);
|
||||
} else {
|
||||
return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
int minx, miny;
|
||||
int maxx, maxy;
|
||||
int i;
|
||||
int x, y;
|
||||
int (*func)(SDL_Surface * dst, int x, int y,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
int status = 0;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
return SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(r, a);
|
||||
g = DRAW_MUL(g, a);
|
||||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
/* FIXME: Does this function pointer slow things down significantly? */
|
||||
switch (dst->format->BitsPerPixel) {
|
||||
case 15:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x7C00:
|
||||
func = SDL_BlendPoint_RGB555;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0xF800:
|
||||
func = SDL_BlendPoint_RGB565;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x00FF0000:
|
||||
if (!dst->format->Amask) {
|
||||
func = SDL_BlendPoint_RGB888;
|
||||
} else {
|
||||
func = SDL_BlendPoint_ARGB8888;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!func) {
|
||||
if (!dst->format->Amask) {
|
||||
func = SDL_BlendPoint_RGB;
|
||||
} else {
|
||||
func = SDL_BlendPoint_RGBA;
|
||||
}
|
||||
}
|
||||
|
||||
minx = dst->clip_rect.x;
|
||||
maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
|
||||
miny = dst->clip_rect.y;
|
||||
maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
x = points[i].x;
|
||||
y = points[i].y;
|
||||
|
||||
if (x < minx || x > maxx || y < miny || y > maxy) {
|
||||
continue;
|
||||
}
|
||||
status = func(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
33
externals/SDL/src/render/software/SDL_blendpoint.h
vendored
Executable file
33
externals/SDL/src/render/software/SDL_blendpoint.h
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
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: */
|
632
externals/SDL/src/render/software/SDL_draw.h
vendored
Executable file
632
externals/SDL/src/render/software/SDL_draw.h
vendored
Executable file
@@ -0,0 +1,632 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#include "../../video/SDL_blit.h"
|
||||
|
||||
/* This code assumes that r, g, b, a are the source color,
|
||||
* and in the blend and add case, the RGB values are premultiplied by a.
|
||||
*/
|
||||
|
||||
#define DRAW_MUL(_a, _b) (((unsigned)(_a)*(_b))/255)
|
||||
|
||||
#define DRAW_FASTSETPIXEL(type) \
|
||||
*pixel = (type) color
|
||||
|
||||
#define DRAW_FASTSETPIXEL1 DRAW_FASTSETPIXEL(Uint8)
|
||||
#define DRAW_FASTSETPIXEL2 DRAW_FASTSETPIXEL(Uint16)
|
||||
#define DRAW_FASTSETPIXEL4 DRAW_FASTSETPIXEL(Uint32)
|
||||
|
||||
#define DRAW_FASTSETPIXELXY(x, y, type, bpp, color) \
|
||||
*(type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
|
||||
+ (x) * bpp) = (type) color
|
||||
|
||||
#define DRAW_FASTSETPIXELXY1(x, y) DRAW_FASTSETPIXELXY(x, y, Uint8, 1, color)
|
||||
#define DRAW_FASTSETPIXELXY2(x, y) DRAW_FASTSETPIXELXY(x, y, Uint16, 2, color)
|
||||
#define DRAW_FASTSETPIXELXY4(x, y) DRAW_FASTSETPIXELXY(x, y, Uint32, 4, color)
|
||||
|
||||
#define DRAW_SETPIXEL(setpixel) \
|
||||
do { \
|
||||
unsigned sr = r, sg = g, sb = b, sa = a; (void) sa; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa = 0xFF; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(inva, sr) + r; \
|
||||
sg = DRAW_MUL(inva, sg) + g; \
|
||||
sb = DRAW_MUL(inva, sb) + b; \
|
||||
sa = DRAW_MUL(inva, sa) + a; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_ADD(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; (void) sa; \
|
||||
getpixel; \
|
||||
sr += r; if (sr > 0xff) sr = 0xff; \
|
||||
sg += g; if (sg > 0xff) sg = 0xff; \
|
||||
sb += b; if (sb > 0xff) sb = 0xff; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_MOD(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; (void) sa; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(sr, r); \
|
||||
sg = DRAW_MUL(sg, g); \
|
||||
sb = DRAW_MUL(sb, b); \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_MUL(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; sa = 0xFF; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(sr, r) + DRAW_MUL(inva, sr); if (sr > 0xff) sr = 0xff; \
|
||||
sg = DRAW_MUL(sg, g) + DRAW_MUL(inva, sg); if (sg > 0xff) sg = 0xff; \
|
||||
sb = DRAW_MUL(sb, b) + DRAW_MUL(inva, sb); if (sb > 0xff) sb = 0xff; \
|
||||
sa = DRAW_MUL(sa, a) + DRAW_MUL(inva, sa); if (sa > 0xff) sa = 0xff; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXELXY(x, y, type, bpp, op) \
|
||||
do { \
|
||||
type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
|
||||
+ (x) * bpp); \
|
||||
op; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Define draw operators for RGB555
|
||||
*/
|
||||
|
||||
#define DRAW_SETPIXEL_RGB555 \
|
||||
DRAW_SETPIXEL(RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB555 \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB555 \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB555 \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGB555 \
|
||||
DRAW_SETPIXEL_MUL(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXELXY_RGB555(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB555)
|
||||
|
||||
#define DRAW_SETPIXELXY_BLEND_RGB555(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB555)
|
||||
|
||||
#define DRAW_SETPIXELXY_ADD_RGB555(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB555)
|
||||
|
||||
#define DRAW_SETPIXELXY_MOD_RGB555(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB555)
|
||||
|
||||
#define DRAW_SETPIXELXY_MUL_RGB555(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MUL_RGB555)
|
||||
|
||||
/*
|
||||
* Define draw operators for RGB565
|
||||
*/
|
||||
|
||||
#define DRAW_SETPIXEL_RGB565 \
|
||||
DRAW_SETPIXEL(RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB565 \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB565 \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB565 \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGB565 \
|
||||
DRAW_SETPIXEL_MUL(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXELXY_RGB565(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB565)
|
||||
|
||||
#define DRAW_SETPIXELXY_BLEND_RGB565(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB565)
|
||||
|
||||
#define DRAW_SETPIXELXY_ADD_RGB565(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB565)
|
||||
|
||||
#define DRAW_SETPIXELXY_MOD_RGB565(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB565)
|
||||
|
||||
#define DRAW_SETPIXELXY_MUL_RGB565(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MUL_RGB565)
|
||||
|
||||
/*
|
||||
* Define draw operators for RGB888
|
||||
*/
|
||||
|
||||
#define DRAW_SETPIXEL_RGB888 \
|
||||
DRAW_SETPIXEL(RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB888 \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB888 \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB888 \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGB888 \
|
||||
DRAW_SETPIXEL_MUL(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXELXY_RGB888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB888)
|
||||
|
||||
#define DRAW_SETPIXELXY_BLEND_RGB888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB888)
|
||||
|
||||
#define DRAW_SETPIXELXY_ADD_RGB888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB888)
|
||||
|
||||
#define DRAW_SETPIXELXY_MOD_RGB888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB888)
|
||||
|
||||
#define DRAW_SETPIXELXY_MUL_RGB888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MUL_RGB888)
|
||||
|
||||
/*
|
||||
* Define draw operators for ARGB8888
|
||||
*/
|
||||
|
||||
#define DRAW_SETPIXEL_ARGB8888 \
|
||||
DRAW_SETPIXEL(ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_ARGB8888 \
|
||||
DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_ARGB8888 \
|
||||
DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_ARGB8888 \
|
||||
DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_ARGB8888 \
|
||||
DRAW_SETPIXEL_MUL(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXELXY_ARGB8888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888)
|
||||
|
||||
#define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_ARGB8888)
|
||||
|
||||
#define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888)
|
||||
|
||||
#define DRAW_SETPIXELXY_MOD_ARGB8888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_ARGB8888)
|
||||
|
||||
#define DRAW_SETPIXELXY_MUL_ARGB8888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MUL_ARGB8888)
|
||||
|
||||
/*
|
||||
* Define draw operators for general RGB
|
||||
*/
|
||||
|
||||
#define DRAW_SETPIXEL_RGB \
|
||||
DRAW_SETPIXEL(PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGB \
|
||||
DRAW_SETPIXEL_MUL(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXELXY2_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY4_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY2_BLEND_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY4_BLEND_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY2_ADD_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY4_ADD_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY2_MOD_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY4_MOD_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY2_MUL_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MUL_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY4_MUL_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MUL_RGB)
|
||||
|
||||
|
||||
/*
|
||||
* Define draw operators for general RGBA
|
||||
*/
|
||||
|
||||
#define DRAW_SETPIXEL_RGBA \
|
||||
DRAW_SETPIXEL(PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGBA \
|
||||
DRAW_SETPIXEL_BLEND(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGBA \
|
||||
DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGBA \
|
||||
DRAW_SETPIXEL_MOD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MUL_RGBA \
|
||||
DRAW_SETPIXEL_MUL(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXELXY4_RGBA(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGBA)
|
||||
|
||||
#define DRAW_SETPIXELXY4_BLEND_RGBA(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGBA)
|
||||
|
||||
#define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGBA)
|
||||
|
||||
#define DRAW_SETPIXELXY4_MOD_RGBA(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGBA)
|
||||
|
||||
#define DRAW_SETPIXELXY4_MUL_RGBA(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MUL_RGBA)
|
||||
|
||||
/*
|
||||
* Define line drawing macro
|
||||
*/
|
||||
|
||||
#define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
|
||||
|
||||
/* Horizontal line */
|
||||
#define HLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (x1 <= x2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
length = draw_end ? (x2-x1+1) : (x2-x1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x2; \
|
||||
if (!draw_end) { \
|
||||
++pixel; \
|
||||
} \
|
||||
length = draw_end ? (x1-x2+1) : (x1-x2); \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
++pixel; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Vertical line */
|
||||
#define VLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
length = draw_end ? (y2-y1+1) : (y2-y1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y2 * pitch + x1; \
|
||||
if (!draw_end) { \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
length = draw_end ? (y1-y2+1) : (y1-y2); \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Diagonal line */
|
||||
#define DLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
if (x1 <= x2) { \
|
||||
++pitch; \
|
||||
} else { \
|
||||
--pitch; \
|
||||
} \
|
||||
length = (y2-y1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y2 * pitch + x2; \
|
||||
if (x2 <= x1) { \
|
||||
++pitch; \
|
||||
} else { \
|
||||
--pitch; \
|
||||
} \
|
||||
if (!draw_end) { \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
length = (y1-y2); \
|
||||
} \
|
||||
if (draw_end) { \
|
||||
++length; \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Bresenham's line algorithm */
|
||||
#define BLINE(x1, y1, x2, y2, op, draw_end) \
|
||||
{ \
|
||||
int i, deltax, deltay, numpixels; \
|
||||
int d, dinc1, dinc2; \
|
||||
int x, xinc1, xinc2; \
|
||||
int y, yinc1, yinc2; \
|
||||
\
|
||||
deltax = ABS(x2 - x1); \
|
||||
deltay = ABS(y2 - y1); \
|
||||
\
|
||||
if (deltax >= deltay) { \
|
||||
numpixels = deltax + 1; \
|
||||
d = (2 * deltay) - deltax; \
|
||||
dinc1 = deltay * 2; \
|
||||
dinc2 = (deltay - deltax) * 2; \
|
||||
xinc1 = 1; \
|
||||
xinc2 = 1; \
|
||||
yinc1 = 0; \
|
||||
yinc2 = 1; \
|
||||
} else { \
|
||||
numpixels = deltay + 1; \
|
||||
d = (2 * deltax) - deltay; \
|
||||
dinc1 = deltax * 2; \
|
||||
dinc2 = (deltax - deltay) * 2; \
|
||||
xinc1 = 0; \
|
||||
xinc2 = 1; \
|
||||
yinc1 = 1; \
|
||||
yinc2 = 1; \
|
||||
} \
|
||||
\
|
||||
if (x1 > x2) { \
|
||||
xinc1 = -xinc1; \
|
||||
xinc2 = -xinc2; \
|
||||
} \
|
||||
if (y1 > y2) { \
|
||||
yinc1 = -yinc1; \
|
||||
yinc2 = -yinc2; \
|
||||
} \
|
||||
\
|
||||
x = x1; \
|
||||
y = y1; \
|
||||
\
|
||||
if (!draw_end) { \
|
||||
--numpixels; \
|
||||
} \
|
||||
for (i = 0; i < numpixels; ++i) { \
|
||||
op(x, y); \
|
||||
if (d < 0) { \
|
||||
d += dinc1; \
|
||||
x += xinc1; \
|
||||
y += yinc1; \
|
||||
} else { \
|
||||
d += dinc2; \
|
||||
x += xinc2; \
|
||||
y += yinc2; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Xiaolin Wu's line algorithm, based on Michael Abrash's implementation */
|
||||
#define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
{ \
|
||||
Uint16 ErrorAdj, ErrorAcc; \
|
||||
Uint16 ErrorAccTemp, Weighting; \
|
||||
int DeltaX, DeltaY, Temp, XDir; \
|
||||
unsigned r, g, b, a, inva; \
|
||||
\
|
||||
/* Draw the initial pixel, which is always exactly intersected by \
|
||||
the line and so needs no weighting */ \
|
||||
opaque_op(x1, y1); \
|
||||
\
|
||||
/* Draw the final pixel, which is always exactly intersected by the line \
|
||||
and so needs no weighting */ \
|
||||
if (draw_end) { \
|
||||
opaque_op(x2, y2); \
|
||||
} \
|
||||
\
|
||||
/* Make sure the line runs top to bottom */ \
|
||||
if (y1 > y2) { \
|
||||
Temp = y1; y1 = y2; y2 = Temp; \
|
||||
Temp = x1; x1 = x2; x2 = Temp; \
|
||||
} \
|
||||
DeltaY = y2 - y1; \
|
||||
\
|
||||
if ((DeltaX = x2 - x1) >= 0) { \
|
||||
XDir = 1; \
|
||||
} else { \
|
||||
XDir = -1; \
|
||||
DeltaX = -DeltaX; /* make DeltaX positive */ \
|
||||
} \
|
||||
\
|
||||
/* line is not horizontal, diagonal, or vertical */ \
|
||||
ErrorAcc = 0; /* initialize the line error accumulator to 0 */ \
|
||||
\
|
||||
/* Is this an X-major or Y-major line? */ \
|
||||
if (DeltaY > DeltaX) { \
|
||||
/* Y-major line; calculate 16-bit fixed-point fractional part of a \
|
||||
pixel that X advances each time Y advances 1 pixel, truncating the \
|
||||
result so that we won't overrun the endpoint along the X axis */ \
|
||||
ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY; \
|
||||
/* Draw all pixels other than the first and last */ \
|
||||
while (--DeltaY) { \
|
||||
ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
|
||||
ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
|
||||
if (ErrorAcc <= ErrorAccTemp) { \
|
||||
/* The error accumulator turned over, so advance the X coord */ \
|
||||
x1 += XDir; \
|
||||
} \
|
||||
y1++; /* Y-major, so always advance Y */ \
|
||||
/* The IntensityBits most significant bits of ErrorAcc give us the \
|
||||
intensity weighting for this pixel, and the complement of the \
|
||||
weighting for the paired pixel */ \
|
||||
Weighting = ErrorAcc >> 8; \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, (Weighting ^ 255)); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1); \
|
||||
} \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, Weighting); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1 + XDir, y1); \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
/* X-major line; calculate 16-bit fixed-point fractional part of a \
|
||||
pixel that Y advances each time X advances 1 pixel, truncating the \
|
||||
result to avoid overrunning the endpoint along the X axis */ \
|
||||
ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX; \
|
||||
/* Draw all pixels other than the first and last */ \
|
||||
while (--DeltaX) { \
|
||||
ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
|
||||
ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
|
||||
if (ErrorAcc <= ErrorAccTemp) { \
|
||||
/* The error accumulator turned over, so advance the Y coord */ \
|
||||
y1++; \
|
||||
} \
|
||||
x1 += XDir; /* X-major, so always advance X */ \
|
||||
/* The IntensityBits most significant bits of ErrorAcc give us the \
|
||||
intensity weighting for this pixel, and the complement of the \
|
||||
weighting for the paired pixel */ \
|
||||
Weighting = ErrorAcc >> 8; \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, (Weighting ^ 255)); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1); \
|
||||
} \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, Weighting); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1 + 1); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifdef AA_LINES
|
||||
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
|
||||
#else
|
||||
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
BLINE(x1, y1, x2, y2, opaque_op, draw_end)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define fill rect macro
|
||||
*/
|
||||
|
||||
#define FILLRECT(type, op) \
|
||||
do { \
|
||||
int width = rect->w; \
|
||||
int height = rect->h; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
int skip = pitch - width; \
|
||||
type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
|
||||
while (height--) { \
|
||||
{ int n = (width+3)/4; \
|
||||
switch (width & 3) { \
|
||||
case 0: do { op; pixel++; /* fallthrough */ \
|
||||
case 3: op; pixel++; /* fallthrough */ \
|
||||
case 2: op; pixel++; /* fallthrough */ \
|
||||
case 1: op; pixel++; /* fallthrough */ \
|
||||
} while ( --n > 0 ); \
|
||||
} \
|
||||
} \
|
||||
pixel += skip; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
209
externals/SDL/src/render/software/SDL_drawline.c
vendored
Executable file
209
externals/SDL/src/render/software/SDL_drawline.c
vendored
Executable file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_drawline.h"
|
||||
#include "SDL_drawpoint.h"
|
||||
|
||||
|
||||
static void
|
||||
SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
if (y1 == y2) {
|
||||
int length;
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel);
|
||||
Uint8 *pixel;
|
||||
if (x1 <= x2) {
|
||||
pixel = (Uint8 *)dst->pixels + y1 * pitch + x1;
|
||||
length = draw_end ? (x2-x1+1) : (x2-x1);
|
||||
} else {
|
||||
pixel = (Uint8 *)dst->pixels + y1 * pitch + x2;
|
||||
if (!draw_end) {
|
||||
++pixel;
|
||||
}
|
||||
length = draw_end ? (x1-x2+1) : (x1-x2);
|
||||
}
|
||||
SDL_memset(pixel, color, length);
|
||||
} else if (x1 == x2) {
|
||||
VLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end);
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
DLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end);
|
||||
} else {
|
||||
BLINE(x1, y1, x2, y2, DRAW_FASTSETPIXELXY1, draw_end);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
if (y1 == y2) {
|
||||
HLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
||||
} else if (x1 == x2) {
|
||||
VLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
DLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
||||
} else {
|
||||
Uint8 _r, _g, _b, _a;
|
||||
const SDL_PixelFormat * fmt = dst->format;
|
||||
SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
|
||||
if (fmt->Rmask == 0x7C00) {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB555,
|
||||
draw_end);
|
||||
} else if (fmt->Rmask == 0xF800) {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB565,
|
||||
draw_end);
|
||||
} else {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY2_BLEND_RGB,
|
||||
draw_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
if (y1 == y2) {
|
||||
HLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
||||
} else if (x1 == x2) {
|
||||
VLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
DLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
||||
} else {
|
||||
Uint8 _r, _g, _b, _a;
|
||||
const SDL_PixelFormat * fmt = dst->format;
|
||||
SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
|
||||
if (fmt->Rmask == 0x00FF0000) {
|
||||
if (!fmt->Amask) {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY_BLEND_RGB888,
|
||||
draw_end);
|
||||
} else {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY_BLEND_ARGB8888,
|
||||
draw_end);
|
||||
}
|
||||
} else {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY4_BLEND_RGB,
|
||||
draw_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*DrawLineFunc) (SDL_Surface * dst,
|
||||
int x1, int y1, int x2, int y2,
|
||||
Uint32 color, SDL_bool draw_end);
|
||||
|
||||
static DrawLineFunc
|
||||
SDL_CalculateDrawLineFunc(const SDL_PixelFormat * fmt)
|
||||
{
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 1:
|
||||
if (fmt->BitsPerPixel < 8) {
|
||||
break;
|
||||
}
|
||||
return SDL_DrawLine1;
|
||||
case 2:
|
||||
return SDL_DrawLine2;
|
||||
case 4:
|
||||
return SDL_DrawLine4;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
{
|
||||
DrawLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("SDL_DrawLine(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
func(dst, x1, y1, x2, y2, color, SDL_TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
Uint32 color)
|
||||
{
|
||||
int i;
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
SDL_bool draw_end;
|
||||
DrawLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("SDL_DrawLines(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_DrawLines(): Unsupported surface format");
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
x1 = points[i-1].x;
|
||||
y1 = points[i-1].y;
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Draw the end if it was clipped */
|
||||
draw_end = (x2 != points[i].x || y2 != points[i].y);
|
||||
|
||||
func(dst, x1, y1, x2, y2, color, draw_end);
|
||||
}
|
||||
if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
|
||||
SDL_DrawPoint(dst, points[count-1].x, points[count-1].y, color);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
33
externals/SDL/src/render/software/SDL_drawline.h
vendored
Executable file
33
externals/SDL/src/render/software/SDL_drawline.h
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
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: */
|
114
externals/SDL/src/render/software/SDL_drawpoint.c
vendored
Executable file
114
externals/SDL/src/render/software/SDL_drawpoint.c
vendored
Executable file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_drawpoint.h"
|
||||
|
||||
|
||||
int
|
||||
SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
|
||||
{
|
||||
if (!dst) {
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
return SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
|
||||
x >= (dst->clip_rect.x + dst->clip_rect.w) ||
|
||||
y >= (dst->clip_rect.y + dst->clip_rect.h)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (dst->format->BytesPerPixel) {
|
||||
case 1:
|
||||
DRAW_FASTSETPIXELXY1(x, y);
|
||||
break;
|
||||
case 2:
|
||||
DRAW_FASTSETPIXELXY2(x, y);
|
||||
break;
|
||||
case 3:
|
||||
return SDL_Unsupported();
|
||||
case 4:
|
||||
DRAW_FASTSETPIXELXY4(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
Uint32 color)
|
||||
{
|
||||
int minx, miny;
|
||||
int maxx, maxy;
|
||||
int i;
|
||||
int x, y;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
return SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
|
||||
}
|
||||
|
||||
minx = dst->clip_rect.x;
|
||||
maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
|
||||
miny = dst->clip_rect.y;
|
||||
maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
x = points[i].x;
|
||||
y = points[i].y;
|
||||
|
||||
if (x < minx || x > maxx || y < miny || y > maxy) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (dst->format->BytesPerPixel) {
|
||||
case 1:
|
||||
DRAW_FASTSETPIXELXY1(x, y);
|
||||
break;
|
||||
case 2:
|
||||
DRAW_FASTSETPIXELXY2(x, y);
|
||||
break;
|
||||
case 3:
|
||||
return SDL_Unsupported();
|
||||
case 4:
|
||||
DRAW_FASTSETPIXELXY4(x, y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
33
externals/SDL/src/render/software/SDL_drawpoint.h
vendored
Executable file
33
externals/SDL/src/render/software/SDL_drawpoint.h
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
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: */
|
894
externals/SDL/src/render/software/SDL_render_sw.c
vendored
Executable file
894
externals/SDL/src/render/software/SDL_render_sw.c
vendored
Executable file
@@ -0,0 +1,894 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "../SDL_sysrender.h"
|
||||
#include "SDL_render_sw_c.h"
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_assert.h"
|
||||
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendfillrect.h"
|
||||
#include "SDL_blendline.h"
|
||||
#include "SDL_blendpoint.h"
|
||||
#include "SDL_drawline.h"
|
||||
#include "SDL_drawpoint.h"
|
||||
#include "SDL_rotate.h"
|
||||
|
||||
/* SDL surface based renderer implementation */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const SDL_Rect *viewport;
|
||||
const SDL_Rect *cliprect;
|
||||
SDL_bool surface_cliprect_dirty;
|
||||
} SW_DrawStateCache;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
SDL_Surface *window;
|
||||
} SW_RenderData;
|
||||
|
||||
|
||||
static SDL_Surface *
|
||||
SW_ActivateRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
|
||||
if (!data->surface) {
|
||||
data->surface = data->window;
|
||||
}
|
||||
if (!data->surface) {
|
||||
SDL_Surface *surface = SDL_GetWindowSurface(renderer->window);
|
||||
if (surface) {
|
||||
data->surface = data->window = surface;
|
||||
}
|
||||
}
|
||||
return data->surface;
|
||||
}
|
||||
|
||||
static void
|
||||
SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
|
||||
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||
data->surface = NULL;
|
||||
data->window = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
|
||||
if (data->surface) {
|
||||
if (w) {
|
||||
*w = data->surface->w;
|
||||
}
|
||||
if (h) {
|
||||
*h = data->surface->h;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (renderer->window) {
|
||||
SDL_GetWindowSize(renderer->window, w, h);
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_SetError("Software renderer doesn't have an output surface");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
if (!SDL_PixelFormatEnumToMasks
|
||||
(texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
|
||||
return SDL_SetError("Unknown texture format");
|
||||
}
|
||||
|
||||
texture->driverdata =
|
||||
SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask,
|
||||
Bmask, Amask);
|
||||
SDL_SetSurfaceColorMod(texture->driverdata, texture->r, texture->g,
|
||||
texture->b);
|
||||
SDL_SetSurfaceAlphaMod(texture->driverdata, texture->a);
|
||||
SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode);
|
||||
|
||||
/* Only RLE encode textures without an alpha channel since the RLE coder
|
||||
* discards the color values of pixels with an alpha value of zero.
|
||||
*/
|
||||
if (texture->access == SDL_TEXTUREACCESS_STATIC && !Amask) {
|
||||
SDL_SetSurfaceRLE(texture->driverdata, 1);
|
||||
}
|
||||
|
||||
if (!texture->driverdata) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
Uint8 *src, *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
if(SDL_MUSTLOCK(surface))
|
||||
SDL_LockSurface(surface);
|
||||
src = (Uint8 *) pixels;
|
||||
dst = (Uint8 *) surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel;
|
||||
length = rect->w * surface->format->BytesPerPixel;
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += pitch;
|
||||
dst += surface->pitch;
|
||||
}
|
||||
if(SDL_MUSTLOCK(surface))
|
||||
SDL_UnlockSurface(surface);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
|
||||
*pixels =
|
||||
(void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel);
|
||||
*pitch = surface->pitch;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
SW_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
SW_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
|
||||
if (texture) {
|
||||
data->surface = (SDL_Surface *) texture->driverdata;
|
||||
} else {
|
||||
data->surface = data->window;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd)
|
||||
{
|
||||
return 0; /* nothing to do in this backend. */
|
||||
}
|
||||
|
||||
static int
|
||||
SW_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
|
||||
{
|
||||
SDL_Point *verts = (SDL_Point *) SDL_AllocateRenderVertices(renderer, count * sizeof (SDL_Point), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
const int x = renderer->viewport.x;
|
||||
const int y = renderer->viewport.y;
|
||||
for (i = 0; i < count; i++, verts++, points++) {
|
||||
verts->x = (int)(x + points->x);
|
||||
verts->y = (int)(y + points->y);
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < count; i++, verts++, points++) {
|
||||
verts->x = (int)points->x;
|
||||
verts->y = (int)points->y;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count)
|
||||
{
|
||||
SDL_Rect *verts = (SDL_Rect *) SDL_AllocateRenderVertices(renderer, count * sizeof (SDL_Rect), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
const int x = renderer->viewport.x;
|
||||
const int y = renderer->viewport.y;
|
||||
|
||||
for (i = 0; i < count; i++, verts++, rects++) {
|
||||
verts->x = (int)(x + rects->x);
|
||||
verts->y = (int)(y + rects->y);
|
||||
verts->w = SDL_max((int)rects->w, 1);
|
||||
verts->h = SDL_max((int)rects->h, 1);
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < count; i++, verts++, rects++) {
|
||||
verts->x = (int)rects->x;
|
||||
verts->y = (int)rects->y;
|
||||
verts->w = SDL_max((int)rects->w, 1);
|
||||
verts->h = SDL_max((int)rects->h, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect)
|
||||
{
|
||||
SDL_Rect *verts = (SDL_Rect *) SDL_AllocateRenderVertices(renderer, 2 * sizeof (SDL_Rect), 0, &cmd->data.draw.first);
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = 1;
|
||||
|
||||
SDL_memcpy(verts, srcrect, sizeof (SDL_Rect));
|
||||
verts++;
|
||||
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
verts->x = (int)(renderer->viewport.x + dstrect->x);
|
||||
verts->y = (int)(renderer->viewport.y + dstrect->y);
|
||||
} else {
|
||||
verts->x = (int)dstrect->x;
|
||||
verts->y = (int)dstrect->y;
|
||||
}
|
||||
verts->w = (int)dstrect->w;
|
||||
verts->h = (int)dstrect->h;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef struct CopyExData
|
||||
{
|
||||
SDL_Rect srcrect;
|
||||
SDL_Rect dstrect;
|
||||
double angle;
|
||||
SDL_FPoint center;
|
||||
SDL_RendererFlip flip;
|
||||
} CopyExData;
|
||||
|
||||
static int
|
||||
SW_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
|
||||
{
|
||||
CopyExData *verts = (CopyExData *) SDL_AllocateRenderVertices(renderer, sizeof (CopyExData), 0, &cmd->data.draw.first);
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = 1;
|
||||
|
||||
SDL_memcpy(&verts->srcrect, srcrect, sizeof (SDL_Rect));
|
||||
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
verts->dstrect.x = (int)(renderer->viewport.x + dstrect->x);
|
||||
verts->dstrect.y = (int)(renderer->viewport.y + dstrect->y);
|
||||
} else {
|
||||
verts->dstrect.x = (int)dstrect->x;
|
||||
verts->dstrect.y = (int)dstrect->y;
|
||||
}
|
||||
verts->dstrect.w = (int)dstrect->w;
|
||||
verts->dstrect.h = (int)dstrect->h;
|
||||
verts->angle = angle;
|
||||
SDL_memcpy(&verts->center, center, sizeof (SDL_FPoint));
|
||||
verts->flip = flip;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_Rect * final_rect,
|
||||
const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip)
|
||||
{
|
||||
SDL_Surface *src = (SDL_Surface *) texture->driverdata;
|
||||
SDL_Rect tmp_rect;
|
||||
SDL_Surface *src_clone, *src_rotated, *src_scaled;
|
||||
SDL_Surface *mask = NULL, *mask_rotated = NULL;
|
||||
int retval = 0, dstwidth, dstheight, abscenterx, abscentery;
|
||||
double cangle, sangle, px, py, p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y;
|
||||
SDL_BlendMode blendmode;
|
||||
Uint8 alphaMod, rMod, gMod, bMod;
|
||||
int applyModulation = SDL_FALSE;
|
||||
int blitRequired = SDL_FALSE;
|
||||
int isOpaque = SDL_FALSE;
|
||||
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
tmp_rect.x = 0;
|
||||
tmp_rect.y = 0;
|
||||
tmp_rect.w = final_rect->w;
|
||||
tmp_rect.h = final_rect->h;
|
||||
|
||||
/* It is possible to encounter an RLE encoded surface here and locking it is
|
||||
* necessary because this code is going to access the pixel buffer directly.
|
||||
*/
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
SDL_LockSurface(src);
|
||||
}
|
||||
|
||||
/* Clone the source surface but use its pixel buffer directly.
|
||||
* The original source surface must be treated as read-only.
|
||||
*/
|
||||
src_clone = SDL_CreateRGBSurfaceFrom(src->pixels, src->w, src->h, src->format->BitsPerPixel, src->pitch,
|
||||
src->format->Rmask, src->format->Gmask,
|
||||
src->format->Bmask, src->format->Amask);
|
||||
if (src_clone == NULL) {
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_GetSurfaceBlendMode(src, &blendmode);
|
||||
SDL_GetSurfaceAlphaMod(src, &alphaMod);
|
||||
SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod);
|
||||
|
||||
/* SDLgfx_rotateSurface only accepts 32-bit surfaces with a 8888 layout. Everything else has to be converted. */
|
||||
if (src->format->BitsPerPixel != 32 || SDL_PIXELLAYOUT(src->format->format) != SDL_PACKEDLAYOUT_8888 || !src->format->Amask) {
|
||||
blitRequired = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* If scaling and cropping is necessary, it has to be taken care of before the rotation. */
|
||||
if (!(srcrect->w == final_rect->w && srcrect->h == final_rect->h && srcrect->x == 0 && srcrect->y == 0)) {
|
||||
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, MOD or MUL blend modes. */
|
||||
if ((blendmode == SDL_BLENDMODE_NONE || blendmode == SDL_BLENDMODE_MOD || blendmode == SDL_BLENDMODE_MUL) && (alphaMod & rMod & gMod & bMod) != 255) {
|
||||
applyModulation = SDL_TRUE;
|
||||
SDL_SetSurfaceAlphaMod(src_clone, alphaMod);
|
||||
SDL_SetSurfaceColorMod(src_clone, rMod, gMod, bMod);
|
||||
}
|
||||
|
||||
/* Opaque surfaces are much easier to handle with the NONE blend mode. */
|
||||
if (blendmode == SDL_BLENDMODE_NONE && !src->format->Amask && alphaMod == 255) {
|
||||
isOpaque = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* The NONE blend mode requires a mask for non-opaque surfaces. This mask will be used
|
||||
* to clear the pixels in the destination surface. The other steps are explained below.
|
||||
*/
|
||||
if (blendmode == SDL_BLENDMODE_NONE && !isOpaque) {
|
||||
mask = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32,
|
||||
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
|
||||
if (mask == NULL) {
|
||||
retval = -1;
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(mask, SDL_BLENDMODE_MOD);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a new surface should there be a format mismatch or if scaling, cropping,
|
||||
* or modulation is required. It's possible to use the source surface directly otherwise.
|
||||
*/
|
||||
if (!retval && (blitRequired || applyModulation)) {
|
||||
SDL_Rect scale_rect = tmp_rect;
|
||||
src_scaled = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32,
|
||||
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
|
||||
if (src_scaled == NULL) {
|
||||
retval = -1;
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(src_clone, SDL_BLENDMODE_NONE);
|
||||
retval = SDL_BlitScaled(src_clone, srcrect, src_scaled, &scale_rect);
|
||||
SDL_FreeSurface(src_clone);
|
||||
src_clone = src_scaled;
|
||||
src_scaled = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* SDLgfx_rotateSurface is going to make decisions depending on the blend mode. */
|
||||
SDL_SetSurfaceBlendMode(src_clone, blendmode);
|
||||
|
||||
if (!retval) {
|
||||
SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, angle, &dstwidth, &dstheight, &cangle, &sangle);
|
||||
src_rotated = SDLgfx_rotateSurface(src_clone, angle, dstwidth/2, dstheight/2, (texture->scaleMode == SDL_ScaleModeNearest) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle);
|
||||
if (src_rotated == NULL) {
|
||||
retval = -1;
|
||||
}
|
||||
if (!retval && mask != NULL) {
|
||||
/* The mask needed for the NONE blend mode gets rotated with the same parameters. */
|
||||
mask_rotated = SDLgfx_rotateSurface(mask, angle, dstwidth/2, dstheight/2, SDL_FALSE, 0, 0, dstwidth, dstheight, cangle, sangle);
|
||||
if (mask_rotated == NULL) {
|
||||
retval = -1;
|
||||
}
|
||||
}
|
||||
if (!retval) {
|
||||
/* 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;
|
||||
|
||||
/* The NONE blend mode needs some special care with non-opaque surfaces.
|
||||
* Other blend modes or opaque surfaces can be blitted directly.
|
||||
*/
|
||||
if (blendmode != SDL_BLENDMODE_NONE || isOpaque) {
|
||||
if (applyModulation == SDL_FALSE) {
|
||||
/* If the modulation wasn't already applied, make it happen now. */
|
||||
SDL_SetSurfaceAlphaMod(src_rotated, alphaMod);
|
||||
SDL_SetSurfaceColorMod(src_rotated, rMod, gMod, bMod);
|
||||
}
|
||||
retval = SDL_BlitSurface(src_rotated, NULL, surface, &tmp_rect);
|
||||
} else {
|
||||
/* The NONE blend mode requires three steps to get the pixels onto the destination surface.
|
||||
* First, the area where the rotated pixels will be blitted to get set to zero.
|
||||
* This is accomplished by simply blitting a mask with the NONE blend mode.
|
||||
* The colorkey set by the rotate function will discard the correct pixels.
|
||||
*/
|
||||
SDL_Rect mask_rect = tmp_rect;
|
||||
SDL_SetSurfaceBlendMode(mask_rotated, SDL_BLENDMODE_NONE);
|
||||
retval = SDL_BlitSurface(mask_rotated, NULL, surface, &mask_rect);
|
||||
if (!retval) {
|
||||
/* The next step copies the alpha value. This is done with the BLEND blend mode and
|
||||
* by modulating the source colors with 0. Since the destination is all zeros, this
|
||||
* will effectively set the destination alpha to the source alpha.
|
||||
*/
|
||||
SDL_SetSurfaceColorMod(src_rotated, 0, 0, 0);
|
||||
mask_rect = tmp_rect;
|
||||
retval = SDL_BlitSurface(src_rotated, NULL, surface, &mask_rect);
|
||||
if (!retval) {
|
||||
/* The last step gets the color values in place. The ADD blend mode simply adds them to
|
||||
* the destination (where the color values are all zero). However, because the ADD blend
|
||||
* mode modulates the colors with the alpha channel, a surface without an alpha mask needs
|
||||
* to be created. This makes all source pixels opaque and the colors get copied correctly.
|
||||
*/
|
||||
SDL_Surface *src_rotated_rgb;
|
||||
src_rotated_rgb = SDL_CreateRGBSurfaceFrom(src_rotated->pixels, src_rotated->w, src_rotated->h,
|
||||
src_rotated->format->BitsPerPixel, src_rotated->pitch,
|
||||
src_rotated->format->Rmask, src_rotated->format->Gmask,
|
||||
src_rotated->format->Bmask, 0);
|
||||
if (src_rotated_rgb == NULL) {
|
||||
retval = -1;
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(src_rotated_rgb, SDL_BLENDMODE_ADD);
|
||||
retval = SDL_BlitSurface(src_rotated_rgb, NULL, surface, &tmp_rect);
|
||||
SDL_FreeSurface(src_rotated_rgb);
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_FreeSurface(mask_rotated);
|
||||
}
|
||||
if (src_rotated != NULL) {
|
||||
SDL_FreeSurface(src_rotated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
if (mask != NULL) {
|
||||
SDL_FreeSurface(mask);
|
||||
}
|
||||
if (src_clone != NULL) {
|
||||
SDL_FreeSurface(src_clone);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
PrepTextureForCopy(const SDL_RenderCommand *cmd)
|
||||
{
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
const Uint8 b = cmd->data.draw.b;
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
const SDL_bool colormod = ((r & g & b) != 0xFF);
|
||||
const SDL_bool alphamod = (a != 0xFF);
|
||||
const SDL_bool blending = ((blend == SDL_BLENDMODE_ADD) || (blend == SDL_BLENDMODE_MOD) || (blend == SDL_BLENDMODE_MUL));
|
||||
|
||||
if (colormod || alphamod || blending) {
|
||||
SDL_SetSurfaceRLE(surface, 0);
|
||||
}
|
||||
|
||||
/* !!! FIXME: we can probably avoid some of these calls. */
|
||||
SDL_SetSurfaceColorMod(surface, r, g, b);
|
||||
SDL_SetSurfaceAlphaMod(surface, a);
|
||||
SDL_SetSurfaceBlendMode(surface, blend);
|
||||
}
|
||||
|
||||
static void
|
||||
SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
|
||||
{
|
||||
if (drawstate->surface_cliprect_dirty) {
|
||||
const SDL_Rect *viewport = drawstate->viewport;
|
||||
const SDL_Rect *cliprect = drawstate->cliprect;
|
||||
SDL_assert(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */
|
||||
|
||||
if (cliprect != NULL) {
|
||||
SDL_Rect clip_rect;
|
||||
clip_rect.x = cliprect->x + viewport->x;
|
||||
clip_rect.y = cliprect->y + viewport->y;
|
||||
clip_rect.w = cliprect->w;
|
||||
clip_rect.h = cliprect->h;
|
||||
SDL_IntersectRect(viewport, &clip_rect, &clip_rect);
|
||||
SDL_SetClipRect(surface, &clip_rect);
|
||||
} else {
|
||||
SDL_SetClipRect(surface, drawstate->viewport);
|
||||
}
|
||||
drawstate->surface_cliprect_dirty = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
SW_DrawStateCache drawstate;
|
||||
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
drawstate.viewport = NULL;
|
||||
drawstate.cliprect = NULL;
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
|
||||
while (cmd) {
|
||||
switch (cmd->command) {
|
||||
case SDL_RENDERCMD_SETDRAWCOLOR: {
|
||||
break; /* Not used in this backend. */
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETVIEWPORT: {
|
||||
drawstate.viewport = &cmd->data.viewport.rect;
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_SETCLIPRECT: {
|
||||
drawstate.cliprect = cmd->data.cliprect.enabled ? &cmd->data.cliprect.rect : NULL;
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_CLEAR: {
|
||||
const Uint8 r = cmd->data.color.r;
|
||||
const Uint8 g = cmd->data.color.g;
|
||||
const Uint8 b = cmd->data.color.b;
|
||||
const Uint8 a = cmd->data.color.a;
|
||||
/* By definition the clear ignores the clip rect */
|
||||
SDL_SetClipRect(surface, NULL);
|
||||
SDL_FillRect(surface, NULL, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_DRAW_POINTS: {
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
const Uint8 b = cmd->data.draw.b;
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const int count = (int) cmd->data.draw.count;
|
||||
const SDL_Point *verts = (SDL_Point *) (((Uint8 *) vertices) + cmd->data.draw.first);
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
if (blend == SDL_BLENDMODE_NONE) {
|
||||
SDL_DrawPoints(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
} else {
|
||||
SDL_BlendPoints(surface, verts, count, blend, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_DRAW_LINES: {
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
const Uint8 b = cmd->data.draw.b;
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const int count = (int) cmd->data.draw.count;
|
||||
const SDL_Point *verts = (SDL_Point *) (((Uint8 *) vertices) + cmd->data.draw.first);
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
if (blend == SDL_BLENDMODE_NONE) {
|
||||
SDL_DrawLines(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
} else {
|
||||
SDL_BlendLines(surface, verts, count, blend, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_FILL_RECTS: {
|
||||
const Uint8 r = cmd->data.draw.r;
|
||||
const Uint8 g = cmd->data.draw.g;
|
||||
const Uint8 b = cmd->data.draw.b;
|
||||
const Uint8 a = cmd->data.draw.a;
|
||||
const int count = (int) cmd->data.draw.count;
|
||||
const SDL_Rect *verts = (SDL_Rect *) (((Uint8 *) vertices) + cmd->data.draw.first);
|
||||
const SDL_BlendMode blend = cmd->data.draw.blend;
|
||||
SetDrawState(surface, &drawstate);
|
||||
if (blend == SDL_BLENDMODE_NONE) {
|
||||
SDL_FillRects(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
} else {
|
||||
SDL_BlendFillRects(surface, verts, count, blend, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_COPY: {
|
||||
SDL_Rect *verts = (SDL_Rect *) (((Uint8 *) vertices) + cmd->data.draw.first);
|
||||
const SDL_Rect *srcrect = verts;
|
||||
SDL_Rect *dstrect = verts + 1;
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
SDL_Surface *src = (SDL_Surface *) texture->driverdata;
|
||||
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
PrepTextureForCopy(cmd);
|
||||
|
||||
if ( srcrect->w == dstrect->w && srcrect->h == dstrect->h ) {
|
||||
SDL_BlitSurface(src, srcrect, surface, dstrect);
|
||||
} 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);
|
||||
SDL_BlitScaled(src, srcrect, surface, dstrect);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_COPY_EX: {
|
||||
const CopyExData *copydata = (CopyExData *) (((Uint8 *) vertices) + cmd->data.draw.first);
|
||||
SetDrawState(surface, &drawstate);
|
||||
PrepTextureForCopy(cmd);
|
||||
SW_RenderCopyEx(renderer, surface, cmd->data.draw.texture, ©data->srcrect,
|
||||
©data->dstrect, copydata->angle, ©data->center, copydata->flip);
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_RENDERCMD_NO_OP:
|
||||
break;
|
||||
}
|
||||
|
||||
cmd = cmd->next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
Uint32 src_format;
|
||||
void *src_pixels;
|
||||
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* NOTE: The rect is already adjusted according to the viewport by
|
||||
* SDL_RenderReadPixels.
|
||||
*/
|
||||
|
||||
if (rect->x < 0 || rect->x+rect->w > surface->w ||
|
||||
rect->y < 0 || rect->y+rect->h > surface->h) {
|
||||
return SDL_SetError("Tried to read outside of surface bounds");
|
||||
}
|
||||
|
||||
src_format = surface->format->format;
|
||||
src_pixels = (void*)((Uint8 *) surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel);
|
||||
|
||||
return SDL_ConvertPixels(rect->w, rect->h,
|
||||
src_format, src_pixels, surface->pitch,
|
||||
format, pixels, pitch);
|
||||
}
|
||||
|
||||
static void
|
||||
SW_RenderPresent(SDL_Renderer * renderer)
|
||||
{
|
||||
SDL_Window *window = renderer->window;
|
||||
|
||||
if (window) {
|
||||
SDL_UpdateWindowSurface(window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
|
||||
static void
|
||||
SW_DestroyRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
|
||||
SDL_free(data);
|
||||
SDL_free(renderer);
|
||||
}
|
||||
|
||||
SDL_Renderer *
|
||||
SW_CreateRendererForSurface(SDL_Surface * surface)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
SW_RenderData *data;
|
||||
|
||||
if (!surface) {
|
||||
SDL_SetError("Can't create renderer for NULL surface");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (SW_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
SW_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
data->surface = surface;
|
||||
data->window = surface;
|
||||
|
||||
renderer->WindowEvent = SW_WindowEvent;
|
||||
renderer->GetOutputSize = SW_GetOutputSize;
|
||||
renderer->CreateTexture = SW_CreateTexture;
|
||||
renderer->UpdateTexture = SW_UpdateTexture;
|
||||
renderer->LockTexture = SW_LockTexture;
|
||||
renderer->UnlockTexture = SW_UnlockTexture;
|
||||
renderer->SetTextureScaleMode = SW_SetTextureScaleMode;
|
||||
renderer->SetRenderTarget = SW_SetRenderTarget;
|
||||
renderer->QueueSetViewport = SW_QueueSetViewport;
|
||||
renderer->QueueSetDrawColor = SW_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
|
||||
renderer->QueueDrawPoints = SW_QueueDrawPoints;
|
||||
renderer->QueueDrawLines = SW_QueueDrawPoints; /* lines and points queue vertices the same way. */
|
||||
renderer->QueueFillRects = SW_QueueFillRects;
|
||||
renderer->QueueCopy = SW_QueueCopy;
|
||||
renderer->QueueCopyEx = SW_QueueCopyEx;
|
||||
renderer->RunCommandQueue = SW_RunCommandQueue;
|
||||
renderer->RenderReadPixels = SW_RenderReadPixels;
|
||||
renderer->RenderPresent = SW_RenderPresent;
|
||||
renderer->DestroyTexture = SW_DestroyTexture;
|
||||
renderer->DestroyRenderer = SW_DestroyRenderer;
|
||||
renderer->info = SW_RenderDriver.info;
|
||||
renderer->driverdata = data;
|
||||
|
||||
SW_ActivateRenderer(renderer);
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
||||
static SDL_Renderer *
|
||||
SW_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
|
||||
surface = SDL_GetWindowSurface(window);
|
||||
if (!surface) {
|
||||
return NULL;
|
||||
}
|
||||
return SW_CreateRendererForSurface(surface);
|
||||
}
|
||||
|
||||
SDL_RenderDriver SW_RenderDriver = {
|
||||
SW_CreateRenderer,
|
||||
{
|
||||
"software",
|
||||
SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE,
|
||||
8,
|
||||
{
|
||||
SDL_PIXELFORMAT_ARGB8888,
|
||||
SDL_PIXELFORMAT_ABGR8888,
|
||||
SDL_PIXELFORMAT_RGBA8888,
|
||||
SDL_PIXELFORMAT_BGRA8888,
|
||||
SDL_PIXELFORMAT_RGB888,
|
||||
SDL_PIXELFORMAT_BGR888,
|
||||
SDL_PIXELFORMAT_RGB565,
|
||||
SDL_PIXELFORMAT_RGB555
|
||||
},
|
||||
0,
|
||||
0}
|
||||
};
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
29
externals/SDL/src/render/software/SDL_render_sw_c.h
vendored
Executable file
29
externals/SDL/src/render/software/SDL_render_sw_c.h
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
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: */
|
538
externals/SDL/src/render/software/SDL_rotate.c
vendored
Executable file
538
externals/SDL/src/render/software/SDL_rotate.c
vendored
Executable file
@@ -0,0 +1,538 @@
|
||||
/*
|
||||
|
||||
SDL_rotate.c: rotates 32bit or 8bit surfaces
|
||||
|
||||
Shamelessly stolen from SDL_gfx by Andreas Schiffler. Original copyright follows:
|
||||
|
||||
Copyright (C) 2001-2011 Andreas Schiffler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_rotate.h"
|
||||
|
||||
/* ---- Internally used structures */
|
||||
|
||||
/* !
|
||||
\brief A 32 bit RGBA pixel.
|
||||
*/
|
||||
typedef struct tColorRGBA {
|
||||
Uint8 r;
|
||||
Uint8 g;
|
||||
Uint8 b;
|
||||
Uint8 a;
|
||||
} tColorRGBA;
|
||||
|
||||
/* !
|
||||
\brief A 8bit Y/palette pixel.
|
||||
*/
|
||||
typedef struct tColorY {
|
||||
Uint8 y;
|
||||
} tColorY;
|
||||
|
||||
/* !
|
||||
\brief Returns maximum of two numbers a and b.
|
||||
*/
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
/* !
|
||||
\brief Number of guard rows added to destination surfaces.
|
||||
|
||||
This is a simple but effective workaround for observed issues.
|
||||
These rows allocate extra memory and are then hidden from the surface.
|
||||
Rows are added to the end of destination surfaces when they are allocated.
|
||||
This catches any potential overflows which seem to happen with
|
||||
just the right src image dimensions and scale/rotation and can lead
|
||||
to a situation where the program can segfault.
|
||||
*/
|
||||
#define GUARD_ROWS (2)
|
||||
|
||||
/* !
|
||||
\brief Returns colorkey info for a surface
|
||||
*/
|
||||
static Uint32
|
||||
_colorkey(SDL_Surface *src)
|
||||
{
|
||||
Uint32 key = 0;
|
||||
if (SDL_HasColorKey(src)) {
|
||||
SDL_GetColorKey(src, &key);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
/* !
|
||||
\brief Internal target surface sizing function for rotations with trig result return.
|
||||
|
||||
\param width The source surface width.
|
||||
\param height The source surface height.
|
||||
\param angle The angle to rotate in degrees.
|
||||
\param dstwidth The calculated width of the destination surface.
|
||||
\param dstheight The calculated height of the destination surface.
|
||||
\param cangle The sine of the angle
|
||||
\param sangle The cosine of the angle
|
||||
|
||||
*/
|
||||
void
|
||||
SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle,
|
||||
int *dstwidth, int *dstheight,
|
||||
double *cangle, double *sangle)
|
||||
{
|
||||
/* The trig code below gets the wrong size (due to FP inaccuracy?) when angle is a multiple of 90 degrees */
|
||||
int angle90 = (int)(angle/90);
|
||||
if(angle90 == angle/90) { /* if the angle is a multiple of 90 degrees */
|
||||
angle90 %= 4;
|
||||
if(angle90 < 0) angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
if(angle90 & 1) {
|
||||
*dstwidth = height;
|
||||
*dstheight = width;
|
||||
*cangle = 0;
|
||||
*sangle = angle90 == 1 ? -1 : 1; /* reversed because our rotations are clockwise */
|
||||
} else {
|
||||
*dstwidth = width;
|
||||
*dstheight = height;
|
||||
*cangle = angle90 == 0 ? 1 : -1;
|
||||
*sangle = 0;
|
||||
}
|
||||
} else {
|
||||
double x, y, cx, cy, sx, sy;
|
||||
double radangle;
|
||||
int dstwidthhalf, dstheighthalf;
|
||||
/*
|
||||
* Determine destination width and height by rotating a centered source box
|
||||
*/
|
||||
radangle = angle * (M_PI / -180.0); /* reverse the angle because our rotations are clockwise */
|
||||
*sangle = SDL_sin(radangle);
|
||||
*cangle = SDL_cos(radangle);
|
||||
x = (double)(width / 2);
|
||||
y = (double)(height / 2);
|
||||
cx = *cangle * x;
|
||||
cy = *cangle * y;
|
||||
sx = *sangle * x;
|
||||
sy = *sangle * y;
|
||||
|
||||
dstwidthhalf = MAX((int)
|
||||
SDL_ceil(MAX(MAX(MAX(SDL_fabs(cx + sy), SDL_fabs(cx - sy)), SDL_fabs(-cx + sy)), SDL_fabs(-cx - sy))), 1);
|
||||
dstheighthalf = MAX((int)
|
||||
SDL_ceil(MAX(MAX(MAX(SDL_fabs(sx + cy), SDL_fabs(sx - cy)), SDL_fabs(-sx + cy)), SDL_fabs(-sx - cy))), 1);
|
||||
*dstwidth = 2 * dstwidthhalf;
|
||||
*dstheight = 2 * dstheighthalf;
|
||||
}
|
||||
}
|
||||
|
||||
/* Computes source pointer X/Y increments for a rotation that's a multiple of 90 degrees. */
|
||||
static void
|
||||
computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int flipy,
|
||||
int *sincx, int *sincy, int *signx, int *signy)
|
||||
{
|
||||
int pitch = flipy ? -src->pitch : src->pitch;
|
||||
if (flipx) {
|
||||
bpp = -bpp;
|
||||
}
|
||||
switch (angle) { /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
case 0: *sincx = bpp; *sincy = pitch - src->w * *sincx; *signx = *signy = 1; break;
|
||||
case 1: *sincx = -pitch; *sincy = bpp - *sincx * src->h; *signx = 1; *signy = -1; break;
|
||||
case 2: *sincx = -bpp; *sincy = -src->w * *sincx - pitch; *signx = *signy = -1; break;
|
||||
case 3: default: *sincx = pitch; *sincy = -*sincx * src->h - bpp; *signx = -1; *signy = 1; break;
|
||||
}
|
||||
if (flipx) {
|
||||
*signx = -*signx;
|
||||
}
|
||||
if (flipy) {
|
||||
*signy = -*signy;
|
||||
}
|
||||
}
|
||||
|
||||
/* Performs a relatively fast rotation/flip when the angle is a multiple of 90 degrees. */
|
||||
#define TRANSFORM_SURFACE_90(pixelType) \
|
||||
int dy, dincy = dst->pitch - dst->w*sizeof(pixelType), sincx, sincy, signx, signy; \
|
||||
Uint8 *sp = (Uint8*)src->pixels, *dp = (Uint8*)dst->pixels, *de; \
|
||||
\
|
||||
computeSourceIncrements90(src, sizeof(pixelType), angle, flipx, flipy, &sincx, &sincy, &signx, &signy); \
|
||||
if (signx < 0) sp += (src->w-1)*sizeof(pixelType); \
|
||||
if (signy < 0) sp += (src->h-1)*src->pitch; \
|
||||
\
|
||||
for (dy = 0; dy < dst->h; sp += sincy, dp += dincy, dy++) { \
|
||||
if (sincx == sizeof(pixelType)) { /* if advancing src and dest equally, use memcpy */ \
|
||||
SDL_memcpy(dp, sp, dst->w*sizeof(pixelType)); \
|
||||
sp += dst->w*sizeof(pixelType); \
|
||||
dp += dst->w*sizeof(pixelType); \
|
||||
} else { \
|
||||
for (de = dp + dst->w*sizeof(pixelType); dp != de; sp += sincx, dp += sizeof(pixelType)) { \
|
||||
*(pixelType*)dp = *(pixelType*)sp; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
static void
|
||||
transformSurfaceRGBA90(SDL_Surface * src, SDL_Surface * dst, int angle, int flipx, int flipy)
|
||||
{
|
||||
TRANSFORM_SURFACE_90(tColorRGBA);
|
||||
}
|
||||
|
||||
static void
|
||||
transformSurfaceY90(SDL_Surface * src, SDL_Surface * dst, int angle, int flipx, int flipy)
|
||||
{
|
||||
TRANSFORM_SURFACE_90(tColorY);
|
||||
}
|
||||
|
||||
#undef TRANSFORM_SURFACE_90
|
||||
|
||||
/* !
|
||||
\brief Internal 32 bit rotozoomer with optional anti-aliasing.
|
||||
|
||||
Rotates and zooms 32 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control
|
||||
parameters by scanning the destination surface and applying optionally anti-aliasing
|
||||
by bilinear interpolation.
|
||||
Assumes src and dst surfaces are of 32 bit depth.
|
||||
Assumes dst surface was allocated with the correct dimensions.
|
||||
|
||||
\param src Source surface.
|
||||
\param dst Destination surface.
|
||||
\param cx Horizontal center coordinate.
|
||||
\param cy Vertical center coordinate.
|
||||
\param isin Integer version of sine of angle.
|
||||
\param icos Integer version of cosine of angle.
|
||||
\param flipx Flag indicating horizontal mirroring should be applied.
|
||||
\param flipy Flag indicating vertical mirroring should be applied.
|
||||
\param smooth Flag indicating anti-aliasing should be used.
|
||||
*/
|
||||
static void
|
||||
_transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth)
|
||||
{
|
||||
int x, y, t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh;
|
||||
tColorRGBA c00, c01, c10, c11, cswap;
|
||||
tColorRGBA *pc, *sp;
|
||||
int gap;
|
||||
|
||||
/*
|
||||
* Variable setup
|
||||
*/
|
||||
xd = ((src->w - dst->w) << 15);
|
||||
yd = ((src->h - dst->h) << 15);
|
||||
ax = (cx << 16) - (icos * cx);
|
||||
ay = (cy << 16) - (isin * cx);
|
||||
sw = src->w - 1;
|
||||
sh = src->h - 1;
|
||||
pc = (tColorRGBA*) dst->pixels;
|
||||
gap = dst->pitch - dst->w * 4;
|
||||
|
||||
/*
|
||||
* Switch between interpolating and non-interpolating code
|
||||
*/
|
||||
if (smooth) {
|
||||
for (y = 0; y < dst->h; y++) {
|
||||
dy = cy - y;
|
||||
sdx = (ax + (isin * dy)) + xd;
|
||||
sdy = (ay - (icos * dy)) + yd;
|
||||
for (x = 0; x < dst->w; x++) {
|
||||
dx = (sdx >> 16);
|
||||
dy = (sdy >> 16);
|
||||
if (flipx) dx = sw - dx;
|
||||
if (flipy) dy = sh - dy;
|
||||
if ((dx > -1) && (dy > -1) && (dx < (src->w-1)) && (dy < (src->h-1))) {
|
||||
sp = (tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy) + dx;
|
||||
c00 = *sp;
|
||||
sp += 1;
|
||||
c01 = *sp;
|
||||
sp += (src->pitch/4);
|
||||
c11 = *sp;
|
||||
sp -= 1;
|
||||
c10 = *sp;
|
||||
if (flipx) {
|
||||
cswap = c00; c00=c01; c01=cswap;
|
||||
cswap = c10; c10=c11; c11=cswap;
|
||||
}
|
||||
if (flipy) {
|
||||
cswap = c00; c00=c10; c10=cswap;
|
||||
cswap = c01; c01=c11; c11=cswap;
|
||||
}
|
||||
/*
|
||||
* Interpolate colors
|
||||
*/
|
||||
ex = (sdx & 0xffff);
|
||||
ey = (sdy & 0xffff);
|
||||
t1 = ((((c01.r - c00.r) * ex) >> 16) + c00.r) & 0xff;
|
||||
t2 = ((((c11.r - c10.r) * ex) >> 16) + c10.r) & 0xff;
|
||||
pc->r = (((t2 - t1) * ey) >> 16) + t1;
|
||||
t1 = ((((c01.g - c00.g) * ex) >> 16) + c00.g) & 0xff;
|
||||
t2 = ((((c11.g - c10.g) * ex) >> 16) + c10.g) & 0xff;
|
||||
pc->g = (((t2 - t1) * ey) >> 16) + t1;
|
||||
t1 = ((((c01.b - c00.b) * ex) >> 16) + c00.b) & 0xff;
|
||||
t2 = ((((c11.b - c10.b) * ex) >> 16) + c10.b) & 0xff;
|
||||
pc->b = (((t2 - t1) * ey) >> 16) + t1;
|
||||
t1 = ((((c01.a - c00.a) * ex) >> 16) + c00.a) & 0xff;
|
||||
t2 = ((((c11.a - c10.a) * ex) >> 16) + c10.a) & 0xff;
|
||||
pc->a = (((t2 - t1) * ey) >> 16) + t1;
|
||||
}
|
||||
sdx += icos;
|
||||
sdy += isin;
|
||||
pc++;
|
||||
}
|
||||
pc = (tColorRGBA *) ((Uint8 *) pc + gap);
|
||||
}
|
||||
} else {
|
||||
for (y = 0; y < dst->h; y++) {
|
||||
dy = cy - y;
|
||||
sdx = (ax + (isin * dy)) + xd;
|
||||
sdy = (ay - (icos * dy)) + yd;
|
||||
for (x = 0; x < dst->w; x++) {
|
||||
dx = (sdx >> 16);
|
||||
dy = (sdy >> 16);
|
||||
if ((unsigned)dx < (unsigned)src->w && (unsigned)dy < (unsigned)src->h) {
|
||||
if(flipx) dx = sw - dx;
|
||||
if(flipy) dy = sh - dy;
|
||||
*pc = *((tColorRGBA *)((Uint8 *)src->pixels + src->pitch * dy) + dx);
|
||||
}
|
||||
sdx += icos;
|
||||
sdy += isin;
|
||||
pc++;
|
||||
}
|
||||
pc = (tColorRGBA *) ((Uint8 *) pc + gap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* !
|
||||
|
||||
\brief Rotates and zooms 8 bit palette/Y 'src' surface to 'dst' surface without smoothing.
|
||||
|
||||
Rotates and zooms 8 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control
|
||||
parameters by scanning the destination surface.
|
||||
Assumes src and dst surfaces are of 8 bit depth.
|
||||
Assumes dst surface was allocated with the correct dimensions.
|
||||
|
||||
\param src Source surface.
|
||||
\param dst Destination surface.
|
||||
\param cx Horizontal center coordinate.
|
||||
\param cy Vertical center coordinate.
|
||||
\param isin Integer version of sine of angle.
|
||||
\param icos Integer version of cosine of angle.
|
||||
\param flipx Flag indicating horizontal mirroring should be applied.
|
||||
\param flipy Flag indicating vertical mirroring should be applied.
|
||||
*/
|
||||
static void
|
||||
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;
|
||||
tColorY *pc;
|
||||
int gap;
|
||||
|
||||
/*
|
||||
* Variable setup
|
||||
*/
|
||||
xd = ((src->w - dst->w) << 15);
|
||||
yd = ((src->h - dst->h) << 15);
|
||||
ax = (cx << 16) - (icos * cx);
|
||||
ay = (cy << 16) - (isin * cx);
|
||||
pc = (tColorY*) dst->pixels;
|
||||
gap = dst->pitch - dst->w;
|
||||
/*
|
||||
* Clear surface to colorkey
|
||||
*/
|
||||
SDL_memset(pc, (int)(_colorkey(src) & 0xff), dst->pitch * dst->h);
|
||||
/*
|
||||
* Iterate through destination surface
|
||||
*/
|
||||
for (y = 0; y < dst->h; y++) {
|
||||
dy = cy - y;
|
||||
sdx = (ax + (isin * dy)) + xd;
|
||||
sdy = (ay - (icos * dy)) + yd;
|
||||
for (x = 0; x < dst->w; x++) {
|
||||
dx = (sdx >> 16);
|
||||
dy = (sdy >> 16);
|
||||
if ((unsigned)dx < (unsigned)src->w && (unsigned)dy < (unsigned)src->h) {
|
||||
if (flipx) dx = (src->w-1)-dx;
|
||||
if (flipy) dy = (src->h-1)-dy;
|
||||
*pc = *((tColorY *)src->pixels + src->pitch * dy + dx);
|
||||
}
|
||||
sdx += icos;
|
||||
sdy += isin;
|
||||
pc++;
|
||||
}
|
||||
pc += gap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* !
|
||||
\brief Rotates and zooms a surface with different horizontal and vertival scaling factors and optional anti-aliasing.
|
||||
|
||||
Rotates a 32-bit or 8-bit 'src' surface to newly created 'dst' surface.
|
||||
'angle' is the rotation in degrees, 'centerx' and 'centery' the rotation center. If 'smooth' is set
|
||||
then the destination 32-bit surface is anti-aliased. 8-bit surfaces must have a colorkey. 32-bit
|
||||
surfaces must have a 8888 layout with red, green, blue and alpha masks (any ordering goes).
|
||||
The blend mode of the 'src' surface has some effects on generation of the 'dst' surface: The NONE
|
||||
mode will set the BLEND mode on the 'dst' surface. The MOD mode either generates a white 'dst'
|
||||
surface and sets the colorkey or fills the it with the colorkey before copying the pixels.
|
||||
When using the NONE and MOD modes, color and alpha modulation must be applied before using this function.
|
||||
|
||||
\param src The surface to rotozoom.
|
||||
\param angle The angle to rotate in degrees.
|
||||
\param centerx The horizontal coordinate of the center of rotation
|
||||
\param zoomy The vertical coordinate of the center of rotation
|
||||
\param smooth Antialiasing flag; set to SMOOTHING_ON to enable.
|
||||
\param flipx Set to 1 to flip the image horizontally
|
||||
\param flipy Set to 1 to flip the image vertically
|
||||
\param dstwidth The destination surface width
|
||||
\param dstheight The destination surface height
|
||||
\param cangle The angle cosine
|
||||
\param sangle The angle sine
|
||||
\return The new rotated surface.
|
||||
|
||||
*/
|
||||
|
||||
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)
|
||||
{
|
||||
SDL_Surface *rz_dst;
|
||||
int is8bit, angle90;
|
||||
int i;
|
||||
SDL_BlendMode blendmode;
|
||||
Uint32 colorkey = 0;
|
||||
int colorKeyAvailable = SDL_FALSE;
|
||||
double sangleinv, cangleinv;
|
||||
|
||||
/* Sanity check */
|
||||
if (src == NULL)
|
||||
return NULL;
|
||||
|
||||
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 */
|
||||
is8bit = src->format->BitsPerPixel == 8 && colorKeyAvailable;
|
||||
if (!(is8bit || (src->format->BitsPerPixel == 32 && src->format->Amask)))
|
||||
return NULL;
|
||||
|
||||
/* Calculate target factors from sin/cos and zoom */
|
||||
sangleinv = sangle*65536.0;
|
||||
cangleinv = cangle*65536.0;
|
||||
|
||||
/* Alloc space to completely contain the rotated surface */
|
||||
rz_dst = NULL;
|
||||
if (is8bit) {
|
||||
/* Target surface is 8 bit */
|
||||
rz_dst = SDL_CreateRGBSurface(0, dstwidth, dstheight + GUARD_ROWS, 8, 0, 0, 0, 0);
|
||||
if (rz_dst != NULL) {
|
||||
for (i = 0; i < src->format->palette->ncolors; i++) {
|
||||
rz_dst->format->palette->colors[i] = src->format->palette->colors[i];
|
||||
}
|
||||
rz_dst->format->palette->ncolors = src->format->palette->ncolors;
|
||||
}
|
||||
} else {
|
||||
/* Target surface is 32 bit with source RGBA ordering */
|
||||
rz_dst = SDL_CreateRGBSurface(0, dstwidth, dstheight + GUARD_ROWS, 32,
|
||||
src->format->Rmask, src->format->Gmask,
|
||||
src->format->Bmask, src->format->Amask);
|
||||
}
|
||||
|
||||
/* Check target */
|
||||
if (rz_dst == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Adjust for guard rows */
|
||||
rz_dst->h = dstheight;
|
||||
|
||||
SDL_GetSurfaceBlendMode(src, &blendmode);
|
||||
|
||||
if (colorKeyAvailable == SDL_TRUE) {
|
||||
/* If available, the colorkey will be used to discard the pixels that are outside of the rotated area. */
|
||||
SDL_SetColorKey(rz_dst, SDL_TRUE, colorkey);
|
||||
SDL_FillRect(rz_dst, NULL, colorkey);
|
||||
} else if (blendmode == SDL_BLENDMODE_NONE) {
|
||||
blendmode = SDL_BLENDMODE_BLEND;
|
||||
} else if (blendmode == SDL_BLENDMODE_MOD || blendmode == SDL_BLENDMODE_MUL) {
|
||||
/* Without a colorkey, the target texture has to be white for the MOD and MUL blend mode so
|
||||
* that the pixels outside the rotated area don't affect the destination surface.
|
||||
*/
|
||||
colorkey = SDL_MapRGBA(rz_dst->format, 255, 255, 255, 0);
|
||||
SDL_FillRect(rz_dst, NULL, colorkey);
|
||||
/* Setting a white colorkey for the destination surface makes the final blit discard
|
||||
* all pixels outside of the rotated area. This doesn't interfere with anything because
|
||||
* white pixels are already a no-op and the MOD blend mode does not interact with alpha.
|
||||
*/
|
||||
SDL_SetColorKey(rz_dst, SDL_TRUE, colorkey);
|
||||
}
|
||||
|
||||
SDL_SetSurfaceBlendMode(rz_dst, blendmode);
|
||||
|
||||
/* Lock source surface */
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
SDL_LockSurface(src);
|
||||
}
|
||||
|
||||
/* check if the rotation is a multiple of 90 degrees so we can take a fast path and also somewhat reduce
|
||||
* the off-by-one problem in _transformSurfaceRGBA that expresses itself when the rotation is near
|
||||
* multiples of 90 degrees.
|
||||
*/
|
||||
angle90 = (int)(angle/90);
|
||||
if (angle90 == angle/90) {
|
||||
angle90 %= 4;
|
||||
if (angle90 < 0) angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
} else {
|
||||
angle90 = -1;
|
||||
}
|
||||
|
||||
if (is8bit) {
|
||||
/* Call the 8-bit transformation routine to do the rotation */
|
||||
if(angle90 >= 0) {
|
||||
transformSurfaceY90(src, rz_dst, angle90, flipx, flipy);
|
||||
} else {
|
||||
transformSurfaceY(src, rz_dst, centerx, centery, (int)sangleinv, (int)cangleinv,
|
||||
flipx, flipy);
|
||||
}
|
||||
} else {
|
||||
/* Call the 32-bit transformation routine to do the rotation */
|
||||
if (angle90 >= 0) {
|
||||
transformSurfaceRGBA90(src, rz_dst, angle90, flipx, flipy);
|
||||
} else {
|
||||
_transformSurfaceRGBA(src, rz_dst, centerx, centery, (int)sangleinv, (int)cangleinv,
|
||||
flipx, flipy, smooth);
|
||||
}
|
||||
}
|
||||
|
||||
/* Unlock source surface */
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
|
||||
/* Return rotated surface */
|
||||
return rz_dst;
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */
|
32
externals/SDL/src/render/software/SDL_rotate.h
vendored
Executable file
32
externals/SDL/src/render/software/SDL_rotate.h
vendored
Executable file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
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
|
||||
|
||||
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