mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-20 20:46:02 +08:00
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.
In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.
The script I ran for the src directory is added as build-scripts/clang-format-src.sh
This fixes:
#6592
#6593
#6594
(cherry picked from commit 5750bcb174)
This commit is contained in:
@@ -128,7 +128,6 @@ Float4X4 MatrixRotationZ(float r)
|
||||
m.v._33 = 1.0f;
|
||||
m.v._44 = 1.0f;
|
||||
return m;
|
||||
|
||||
}
|
||||
|
||||
#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) && !SDL_RENDER_DISABLED */
|
||||
|
||||
@@ -52,8 +52,10 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
float _11, _12, _13, _14;
|
||||
float _21, _22, _23, _24;
|
||||
float _31, _32, _33, _34;
|
||||
@@ -63,7 +65,6 @@ typedef struct
|
||||
};
|
||||
} Float4X4;
|
||||
|
||||
|
||||
Float4X4 MatrixIdentity();
|
||||
Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2);
|
||||
Float4X4 MatrixScaling(float x, float y, float z);
|
||||
|
||||
+417
-521
File diff suppressed because it is too large
Load Diff
+72
-71
@@ -44,7 +44,6 @@ typedef struct SDL_DRect
|
||||
double h;
|
||||
} SDL_DRect;
|
||||
|
||||
|
||||
/* The SDL 2D rendering system */
|
||||
|
||||
typedef struct SDL_RenderDriver SDL_RenderDriver;
|
||||
@@ -53,14 +52,14 @@ typedef struct SDL_RenderDriver SDL_RenderDriver;
|
||||
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 */
|
||||
SDL_Color color; /**< Texture modulation values */
|
||||
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 */
|
||||
SDL_Color color; /**< Texture modulation values */
|
||||
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
@@ -70,11 +69,11 @@ struct SDL_Texture
|
||||
void *pixels;
|
||||
int pitch;
|
||||
SDL_Rect locked_rect;
|
||||
SDL_Surface *locked_surface; /**< Locked region exposed as a SDL surface */
|
||||
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 */
|
||||
void *driverdata; /**< Driver specific texture representation */
|
||||
void *userdata;
|
||||
|
||||
SDL_Texture *prev;
|
||||
@@ -99,23 +98,28 @@ typedef enum
|
||||
typedef struct SDL_RenderCommand
|
||||
{
|
||||
SDL_RenderCommandType command;
|
||||
union {
|
||||
struct {
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
size_t first;
|
||||
SDL_Rect rect;
|
||||
} viewport;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
SDL_bool enabled;
|
||||
SDL_Rect rect;
|
||||
} cliprect;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
size_t first;
|
||||
size_t count;
|
||||
Uint8 r, g, b, a;
|
||||
SDL_BlendMode blend;
|
||||
SDL_Texture *texture;
|
||||
} draw;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
size_t first;
|
||||
Uint8 r, g, b, a;
|
||||
} color;
|
||||
@@ -123,14 +127,12 @@ typedef struct SDL_RenderCommand
|
||||
struct SDL_RenderCommand *next;
|
||||
} SDL_RenderCommand;
|
||||
|
||||
|
||||
typedef struct SDL_VertexSolid
|
||||
{
|
||||
SDL_FPoint position;
|
||||
SDL_Color color;
|
||||
SDL_Color color;
|
||||
} SDL_VertexSolid;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDL_RENDERLINEMETHOD_POINTS,
|
||||
@@ -138,68 +140,67 @@ typedef enum
|
||||
SDL_RENDERLINEMETHOD_GEOMETRY,
|
||||
} SDL_RenderLineMethod;
|
||||
|
||||
|
||||
/* 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, float scale_x, float scale_y);
|
||||
int (*QueueGeometry) (SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y);
|
||||
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, float scale_x, float scale_y);
|
||||
int (*QueueGeometry)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
|
||||
const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
|
||||
int num_vertices, const void *indices, int num_indices, int size_indices,
|
||||
float scale_x, float scale_y);
|
||||
|
||||
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 (*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);
|
||||
#if SDL_HAVE_YUV
|
||||
int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
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 (*UpdateTextureNV) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
int (*UpdateTextureNV)(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
#endif
|
||||
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);
|
||||
int (*RenderPresent) (SDL_Renderer * renderer);
|
||||
void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
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);
|
||||
int (*RenderPresent)(SDL_Renderer *renderer);
|
||||
void (*DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture);
|
||||
|
||||
void (*DestroyRenderer) (SDL_Renderer * renderer);
|
||||
void (*DestroyRenderer)(SDL_Renderer *renderer);
|
||||
|
||||
int (*SetVSync) (SDL_Renderer * renderer, int vsync);
|
||||
int (*SetVSync)(SDL_Renderer *renderer, int vsync);
|
||||
|
||||
int (*GL_BindTexture) (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh);
|
||||
int (*GL_UnbindTexture) (SDL_Renderer * renderer, SDL_Texture *texture);
|
||||
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);
|
||||
void *(*GetMetalLayer)(SDL_Renderer *renderer);
|
||||
void *(*GetMetalCommandEncoder)(SDL_Renderer *renderer);
|
||||
|
||||
/* The current renderer info */
|
||||
SDL_RendererInfo info;
|
||||
@@ -260,8 +261,8 @@ struct SDL_Renderer
|
||||
SDL_Texture *target;
|
||||
SDL_mutex *target_mutex;
|
||||
|
||||
SDL_Color color; /**< Color for drawing operations values */
|
||||
SDL_BlendMode blendMode; /**< The drawing blend mode */
|
||||
SDL_Color color; /**< Color for drawing operations values */
|
||||
SDL_BlendMode blendMode; /**< The drawing blend mode */
|
||||
|
||||
SDL_bool always_batch;
|
||||
SDL_bool batching;
|
||||
@@ -287,7 +288,7 @@ struct SDL_Renderer
|
||||
/* Define the SDL render driver structure */
|
||||
struct SDL_RenderDriver
|
||||
{
|
||||
SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
|
||||
SDL_Renderer *(*CreateRenderer)(SDL_Window *window, Uint32 flags);
|
||||
|
||||
/* Info about the renderer capabilities */
|
||||
SDL_RendererInfo info;
|
||||
@@ -320,8 +321,8 @@ extern SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode
|
||||
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);
|
||||
|
||||
extern int SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode);
|
||||
extern int SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode);
|
||||
extern int SDL_PrivateLowerBlitScaled(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
|
||||
extern int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
||||
+108
-121
@@ -24,11 +24,9 @@
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
|
||||
|
||||
#include "SDL_yuv_sw_c.h"
|
||||
#include "SDL_cpuinfo.h"
|
||||
|
||||
|
||||
SDL_SW_YUVTexture *
|
||||
SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
||||
{
|
||||
@@ -48,7 +46,7 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
swdata = (SDL_SW_YUVTexture *) SDL_calloc(1, sizeof(*swdata));
|
||||
swdata = (SDL_SW_YUVTexture *)SDL_calloc(1, sizeof(*swdata));
|
||||
if (swdata == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -59,33 +57,32 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
||||
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;
|
||||
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_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;
|
||||
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;
|
||||
default:
|
||||
SDL_assert(0 && "We should never get here (caught above)");
|
||||
break;
|
||||
}
|
||||
swdata->pixels = (Uint8 *) SDL_SIMDAlloc(dst_size);
|
||||
swdata->pixels = (Uint8 *)SDL_SIMDAlloc(dst_size);
|
||||
if (!swdata->pixels) {
|
||||
SDL_SW_DestroyYUVTexture(swdata);
|
||||
SDL_OutOfMemory();
|
||||
@@ -128,33 +125,31 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
||||
return swdata;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels,
|
||||
int *pitch)
|
||||
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)
|
||||
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));
|
||||
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;
|
||||
src = (Uint8 *)pixels;
|
||||
dst = swdata->pixels + rect->y * swdata->w + rect->x;
|
||||
length = rect->w;
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
@@ -162,94 +157,92 @@ SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
src += pitch;
|
||||
dst += swdata->w;
|
||||
}
|
||||
|
||||
|
||||
/* Copy the next plane */
|
||||
src = (Uint8 *) pixels + rect->h * pitch;
|
||||
src = (Uint8 *)pixels + rect->h * pitch;
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
dst += rect->y/2 * ((swdata->w + 1) / 2) + rect->x/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) {
|
||||
for (row = 0; row < (rect->h + 1) / 2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += (pitch + 1)/2;
|
||||
dst += (swdata->w + 1)/2;
|
||||
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);
|
||||
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;
|
||||
((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) {
|
||||
for (row = 0; row < (rect->h + 1) / 2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += (pitch + 1)/2;
|
||||
dst += (swdata->w + 1)/2;
|
||||
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;
|
||||
|
||||
src = (Uint8 *) pixels;
|
||||
dst =
|
||||
swdata->planes[0] + rect->y * swdata->pitches[0] +
|
||||
rect->x * 2;
|
||||
length = 4 * ((rect->w + 1) / 2);
|
||||
/* 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->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);
|
||||
}
|
||||
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)
|
||||
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;
|
||||
@@ -274,12 +267,12 @@ SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
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;
|
||||
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) {
|
||||
for (row = 0; row < (rect->h + 1) / 2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += Upitch;
|
||||
dst += (swdata->w + 1)/2;
|
||||
dst += (swdata->w + 1) / 2;
|
||||
}
|
||||
|
||||
/* Copy the V plane */
|
||||
@@ -290,19 +283,19 @@ SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
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;
|
||||
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) {
|
||||
for (row = 0; row < (rect->h + 1) / 2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += Vpitch;
|
||||
dst += (swdata->w + 1)/2;
|
||||
dst += (swdata->w + 1) / 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch)
|
||||
{
|
||||
const Uint8 *src;
|
||||
Uint8 *dst;
|
||||
@@ -322,30 +315,27 @@ int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * re
|
||||
/* Copy the UV or VU plane */
|
||||
src = UVplane;
|
||||
dst = swdata->pixels + swdata->h * swdata->w;
|
||||
dst += rect->y * ((swdata->w + 1)/2) + rect->x;
|
||||
dst += rect->y * ((swdata->w + 1) / 2) + rect->x;
|
||||
length = (rect->w + 1) / 2;
|
||||
length *= 2;
|
||||
for (row = 0; row < (rect->h + 1)/2; ++row) {
|
||||
for (row = 0; row < (rect->h + 1) / 2; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += UVpitch;
|
||||
dst += 2 * ((swdata->w + 1)/2);
|
||||
dst += 2 * ((swdata->w + 1) / 2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
void **pixels, int *pitch)
|
||||
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)) {
|
||||
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;
|
||||
@@ -360,15 +350,13 @@ SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata)
|
||||
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 SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
|
||||
Uint32 target_format, int w, int h, void *pixels,
|
||||
int pitch)
|
||||
{
|
||||
int stretch;
|
||||
|
||||
@@ -424,7 +412,7 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
||||
pitch = swdata->stretch->pitch;
|
||||
}
|
||||
if (SDL_ConvertPixels(swdata->w, swdata->h, swdata->format,
|
||||
swdata->planes[0], swdata->pitches[0],
|
||||
swdata->planes[0], swdata->pitches[0],
|
||||
target_format, pixels, pitch) < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -435,8 +423,7 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata)
|
||||
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata)
|
||||
{
|
||||
if (swdata) {
|
||||
SDL_SIMDFree(swdata->pixels);
|
||||
|
||||
+10
-10
@@ -47,24 +47,24 @@ struct SDL_SW_YUVTexture
|
||||
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 SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels,
|
||||
int *pitch);
|
||||
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
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,
|
||||
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_UpdateNVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *UVplane, int UVpitch);
|
||||
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,
|
||||
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);
|
||||
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata);
|
||||
|
||||
#endif /* SDL_yuv_sw_c_h_ */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -257,7 +257,6 @@ static const DWORD D3D9_PixelShader_YUV_BT709[] = {
|
||||
0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff
|
||||
};
|
||||
|
||||
|
||||
static const DWORD *D3D9_shaders[] = {
|
||||
D3D9_PixelShader_YUV_JPEG,
|
||||
D3D9_PixelShader_YUV_BT601,
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
/* D3D9 shader implementation */
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
SHADER_YUV_JPEG,
|
||||
SHADER_YUV_BT601,
|
||||
SHADER_YUV_BT709,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -42,11 +42,10 @@ using namespace Windows::Graphics::Display;
|
||||
|
||||
#include "SDL_render_winrt.h"
|
||||
|
||||
|
||||
extern "C" void *
|
||||
D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer)
|
||||
D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_Window * sdlWindow = renderer->window;
|
||||
SDL_Window *sdlWindow = renderer->window;
|
||||
if (renderer->window == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -110,7 +109,6 @@ D3D11_GetCurrentRotation()
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer);
|
||||
void *D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer);
|
||||
DXGI_MODE_ROTATION D3D11_GetCurrentRotation();
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
|
||||
|
||||
|
||||
/* Direct3D 11.x shaders
|
||||
|
||||
SDL's shaders are compiled into SDL itself, to simplify distribution.
|
||||
@@ -52,7 +51,7 @@
|
||||
- vs_4_0_level_9_1: Vertex shader for Windows 8+, including Windows RT
|
||||
- ps_4_0_level_9_3: Pixel shader for Windows Phone 8
|
||||
- vs_4_0_level_9_3: Vertex shader for Windows Phone 8
|
||||
|
||||
|
||||
|
||||
Shader object code was converted to a list of DWORDs via the following
|
||||
*nix style command (available separately from Windows + MSVC):
|
||||
@@ -1905,8 +1904,7 @@ static struct
|
||||
int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout)
|
||||
{
|
||||
/* Declare how the input layout for SDL's vertex shader will be setup: */
|
||||
const D3D11_INPUT_ELEMENT_DESC vertexDesc[] =
|
||||
{
|
||||
const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = {
|
||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
@@ -1915,23 +1913,21 @@ int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vert
|
||||
|
||||
/* Load in SDL's one and only vertex shader: */
|
||||
result = ID3D11Device_CreateVertexShader(d3dDevice,
|
||||
D3D11_VertexShader,
|
||||
sizeof(D3D11_VertexShader),
|
||||
NULL,
|
||||
vertexShader
|
||||
);
|
||||
D3D11_VertexShader,
|
||||
sizeof(D3D11_VertexShader),
|
||||
NULL,
|
||||
vertexShader);
|
||||
if (FAILED(result)) {
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateVertexShader"), result);
|
||||
}
|
||||
|
||||
/* Create an input layout for SDL's vertex shader: */
|
||||
result = ID3D11Device_CreateInputLayout(d3dDevice,
|
||||
vertexDesc,
|
||||
ARRAYSIZE(vertexDesc),
|
||||
D3D11_VertexShader,
|
||||
sizeof(D3D11_VertexShader),
|
||||
inputLayout
|
||||
);
|
||||
vertexDesc,
|
||||
ARRAYSIZE(vertexDesc),
|
||||
D3D11_VertexShader,
|
||||
sizeof(D3D11_VertexShader),
|
||||
inputLayout);
|
||||
if (FAILED(result)) {
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateInputLayout"), result);
|
||||
}
|
||||
@@ -1943,11 +1939,10 @@ int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D1
|
||||
HRESULT result;
|
||||
|
||||
result = ID3D11Device_CreatePixelShader(d3dDevice,
|
||||
D3D11_shaders[shader].shader_data,
|
||||
D3D11_shaders[shader].shader_size,
|
||||
NULL,
|
||||
pixelShader
|
||||
);
|
||||
D3D11_shaders[shader].shader_data,
|
||||
D3D11_shaders[shader].shader_size,
|
||||
NULL,
|
||||
pixelShader);
|
||||
if (FAILED(result)) {
|
||||
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader"), result);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
/* D3D11 shader implementation */
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
SHADER_SOLID,
|
||||
SHADER_RGB,
|
||||
#if SDL_HAVE_YUV
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,6 @@
|
||||
|
||||
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
|
||||
|
||||
|
||||
/* Direct3D 12 shaders
|
||||
|
||||
SDL's shaders are compiled into SDL itself, to simplify distribution.
|
||||
@@ -51,7 +50,7 @@
|
||||
Shader types:
|
||||
- ps_6_0: Pixel shader
|
||||
- vs_6_0: Vertex shader
|
||||
|
||||
|
||||
|
||||
Shader object code was converted to unsigned chars via the following
|
||||
*nix style command (available separately from Windows + MSVC):
|
||||
@@ -1729,7 +1728,7 @@ static unsigned char D3D12_PixelShader_YUV_BT601[] = {
|
||||
float2 tex : TEXCOORD0;
|
||||
float4 color : COLOR0;
|
||||
};
|
||||
|
||||
|
||||
#define YUVRS \
|
||||
"RootFlags ( ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT |" \
|
||||
" DENY_DOMAIN_SHADER_ROOT_ACCESS |" \
|
||||
@@ -6770,7 +6769,7 @@ static unsigned char D3D12_VertexShader_NV[] = {
|
||||
/* Root signature blobs extracted from Vertex Shader
|
||||
dxc command line is:
|
||||
dxc -E <RS> -T rootsig_1_1 -rootsig-define <RS> -Fo <OUTFILE> D3D12_VertexShader.hlsl
|
||||
|
||||
|
||||
Variables:
|
||||
- <RS>: the root signature define
|
||||
- <OUTFILE>: the output file name.
|
||||
@@ -6858,78 +6857,57 @@ static struct
|
||||
{
|
||||
const void *ps_shader_data;
|
||||
SIZE_T ps_shader_size;
|
||||
const void* vs_shader_data;
|
||||
const void *vs_shader_data;
|
||||
SIZE_T vs_shader_size;
|
||||
D3D12_RootSignature root_sig;
|
||||
} D3D12_shaders[NUM_SHADERS] = {
|
||||
{
|
||||
D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors),
|
||||
D3D12_VertexShader_Colors, sizeof(D3D12_VertexShader_Colors),
|
||||
ROOTSIG_COLOR
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures),
|
||||
D3D12_VertexShader_Textures, sizeof(D3D12_VertexShader_Textures),
|
||||
ROOTSIG_TEXTURE
|
||||
},
|
||||
{ D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors),
|
||||
D3D12_VertexShader_Colors, sizeof(D3D12_VertexShader_Colors),
|
||||
ROOTSIG_COLOR },
|
||||
{ D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures),
|
||||
D3D12_VertexShader_Textures, sizeof(D3D12_VertexShader_Textures),
|
||||
ROOTSIG_TEXTURE },
|
||||
#if SDL_HAVE_YUV
|
||||
{
|
||||
D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV
|
||||
},
|
||||
{
|
||||
D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV
|
||||
},
|
||||
{ D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV },
|
||||
{ D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV },
|
||||
{ D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709),
|
||||
D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV),
|
||||
ROOTSIG_YUV },
|
||||
{ D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
{ D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709),
|
||||
D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV),
|
||||
ROOTSIG_NV },
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct {
|
||||
const void* rs_shader_data;
|
||||
static struct
|
||||
{
|
||||
const void *rs_shader_data;
|
||||
SIZE_T rs_shader_size;
|
||||
} D3D12_rootsigs[NUM_ROOTSIGS] = {
|
||||
{D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color)},
|
||||
{D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture)},
|
||||
{ D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color) },
|
||||
{ D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture) },
|
||||
#if SDL_HAVE_YUV
|
||||
{D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV)},
|
||||
{D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV)},
|
||||
{ D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV) },
|
||||
{ D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV) },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
SHADER_SOLID,
|
||||
SHADER_RGB,
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -44,7 +45,8 @@ typedef enum {
|
||||
NUM_SHADERS
|
||||
} D3D12_Shader;
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
ROOTSIG_COLOR,
|
||||
ROOTSIG_TEXTURE,
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -57,7 +59,7 @@ typedef enum {
|
||||
extern void D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode);
|
||||
extern void D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode);
|
||||
extern D3D12_RootSignature D3D12_GetRootSignatureType(D3D12_Shader shader);
|
||||
extern void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE* outBytecode);
|
||||
extern void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
||||
+915
-864
File diff suppressed because it is too large
Load Diff
+142
-142
File diff suppressed because it is too large
Load Diff
+380
-413
File diff suppressed because it is too large
Load Diff
@@ -61,6 +61,8 @@ struct GL_ShaderContext
|
||||
GL_ShaderData shaders[NUM_SHADERS];
|
||||
};
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
||||
#define COLOR_VERTEX_SHADER \
|
||||
"varying vec4 v_color;\n" \
|
||||
"\n" \
|
||||
@@ -235,8 +237,7 @@ struct GL_ShaderContext
|
||||
* 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] =
|
||||
{
|
||||
static const char *shader_source[NUM_SHADERS][2] = {
|
||||
/* SHADER_NONE */
|
||||
{ NULL, NULL },
|
||||
|
||||
@@ -387,8 +388,9 @@ static const char *shader_source[NUM_SHADERS][2] =
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
};
|
||||
|
||||
static SDL_bool
|
||||
CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source)
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
static SDL_bool CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source)
|
||||
{
|
||||
GLint status;
|
||||
const char *sources[2];
|
||||
@@ -405,13 +407,13 @@ CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, co
|
||||
char *info;
|
||||
|
||||
ctx->glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
|
||||
info = SDL_small_alloc(char, length+1, &isstack);
|
||||
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);
|
||||
"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);
|
||||
"Failed to compile shader:\n%s%s\n%s", defines, source, info);
|
||||
#endif
|
||||
SDL_small_free(info, isstack);
|
||||
|
||||
@@ -421,8 +423,7 @@ CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, co
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
|
||||
static SDL_bool CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
|
||||
{
|
||||
const int num_tmus_bound = 4;
|
||||
const char *vert_defines = "";
|
||||
@@ -439,12 +440,12 @@ CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
|
||||
/* 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";
|
||||
"#define sampler2D sampler2DRect\n"
|
||||
"#define texture2D texture2DRect\n"
|
||||
"#define UVCoordScale 0.5\n";
|
||||
} else {
|
||||
frag_defines =
|
||||
"#define UVCoordScale 1.0\n";
|
||||
frag_defines =
|
||||
"#define UVCoordScale 1.0\n";
|
||||
}
|
||||
|
||||
/* Create one program object to rule them all */
|
||||
@@ -482,8 +483,7 @@ CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
|
||||
return ctx->glGetError() == GL_NO_ERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyShaderProgram(GL_ShaderContext *ctx, GL_ShaderData *data)
|
||||
static void DestroyShaderProgram(GL_ShaderContext *ctx, GL_ShaderData *data)
|
||||
{
|
||||
ctx->glDeleteObjectARB(data->vert_shader);
|
||||
ctx->glDeleteObjectARB(data->frag_shader);
|
||||
@@ -514,20 +514,20 @@ GL_CreateShaderContext(void)
|
||||
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");
|
||||
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 &&
|
||||
@@ -563,14 +563,12 @@ GL_CreateShaderContext(void)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void
|
||||
GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader)
|
||||
void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader)
|
||||
{
|
||||
ctx->glUseProgramObjectARB(ctx->shaders[shader].program);
|
||||
}
|
||||
|
||||
void
|
||||
GL_DestroyShaderContext(GL_ShaderContext *ctx)
|
||||
void GL_DestroyShaderContext(GL_ShaderContext *ctx)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
|
||||
/* OpenGL shader implementation */
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
SHADER_INVALID = -1,
|
||||
SHADER_NONE,
|
||||
SHADER_SOLID,
|
||||
@@ -50,7 +51,7 @@ typedef enum {
|
||||
|
||||
typedef struct GL_ShaderContext GL_ShaderContext;
|
||||
|
||||
extern GL_ShaderContext * GL_CreateShaderContext(void);
|
||||
extern GL_ShaderContext *GL_CreateShaderContext(void);
|
||||
extern void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader);
|
||||
extern void GL_DestroyShaderContext(GL_ShaderContext *ctx);
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ 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, 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))
|
||||
@@ -57,6 +57,6 @@ 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_OES(void, glDeleteFramebuffersOES, (GLsizei, const GLuint*))
|
||||
SDL_PROC_OES(void, glDeleteFramebuffersOES, (GLsizei, const GLuint *))
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -50,7 +50,7 @@ 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, 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__
|
||||
@@ -72,7 +72,7 @@ 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, glGetProgramInfoLog, (GLuint, GLsizei, GLsizei *, GLchar *))
|
||||
SDL_PROC(void, glGenBuffers, (GLsizei, GLuint *))
|
||||
SDL_PROC(void, glDeleteBuffers, (GLsizei, const GLuint *))
|
||||
SDL_PROC(void, glBindBuffer, (GLenum, GLuint))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,8 @@
|
||||
#include "SDL_shaders_gles2.h"
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
||||
/*************************************************************************************************
|
||||
* Vertex/fragment shader source *
|
||||
*************************************************************************************************/
|
||||
@@ -346,6 +348,7 @@ static const char GLES2_Fragment_TextureExternalOES[] = \
|
||||
"}\n" \
|
||||
;
|
||||
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
/*************************************************************************************************
|
||||
* Shader selector *
|
||||
@@ -444,4 +447,3 @@ const char *GLES2_GetShader(GLES2_ShaderType type)
|
||||
#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
|
||||
+185
-206
File diff suppressed because it is too large
Load Diff
+374
-421
File diff suppressed because it is too large
Load Diff
@@ -25,10 +25,8 @@
|
||||
#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)
|
||||
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;
|
||||
|
||||
@@ -52,9 +50,8 @@ SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -78,9 +75,8 @@ SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -104,9 +100,8 @@ SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -130,9 +125,8 @@ SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
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)
|
||||
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;
|
||||
@@ -181,9 +175,8 @@ SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
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;
|
||||
@@ -213,9 +206,8 @@ SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_Rect clipped;
|
||||
|
||||
@@ -280,13 +272,12 @@ SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 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,
|
||||
int (*func)(SDL_Surface * dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
int status = 0;
|
||||
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#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);
|
||||
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_ */
|
||||
|
||||
|
||||
@@ -26,11 +26,9 @@
|
||||
#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)
|
||||
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;
|
||||
@@ -133,10 +131,9 @@ SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -238,10 +235,9 @@ SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -343,10 +339,9 @@ SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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;
|
||||
@@ -449,10 +444,9 @@ SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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;
|
||||
@@ -555,10 +549,9 @@ SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -660,10 +653,9 @@ SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -765,14 +757,13 @@ SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
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)
|
||||
static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormat *fmt)
|
||||
{
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 2:
|
||||
@@ -802,9 +793,8 @@ SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt)
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -827,9 +817,8 @@ SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
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 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;
|
||||
@@ -847,8 +836,8 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
x1 = points[i-1].x;
|
||||
y1 = points[i-1].y;
|
||||
x1 = points[i - 1].x;
|
||||
y1 = points[i - 1].y;
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
@@ -863,8 +852,8 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
|
||||
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,
|
||||
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;
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#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);
|
||||
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_ */
|
||||
|
||||
|
||||
@@ -25,10 +25,8 @@
|
||||
#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)
|
||||
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;
|
||||
|
||||
@@ -52,9 +50,8 @@ SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -78,9 +75,8 @@ SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -104,9 +100,8 @@ SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -130,9 +125,8 @@ SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode
|
||||
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)
|
||||
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;
|
||||
@@ -181,9 +175,8 @@ SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uin
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
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;
|
||||
@@ -213,9 +206,8 @@ SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Ui
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_BlendPoint(): dst");
|
||||
@@ -274,9 +266,8 @@ SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 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;
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#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);
|
||||
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_ */
|
||||
|
||||
|
||||
+366
-334
File diff suppressed because it is too large
Load Diff
@@ -26,10 +26,8 @@
|
||||
#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)
|
||||
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;
|
||||
@@ -37,13 +35,13 @@ SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
Uint8 *pixel;
|
||||
if (x1 <= x2) {
|
||||
pixel = (Uint8 *)dst->pixels + y1 * pitch + x1;
|
||||
length = draw_end ? (x2-x1+1) : (x2-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);
|
||||
length = draw_end ? (x1 - x2 + 1) : (x1 - x2);
|
||||
}
|
||||
SDL_memset(pixel, color, length);
|
||||
} else if (x1 == x2) {
|
||||
@@ -55,9 +53,8 @@ SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool 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);
|
||||
@@ -67,7 +64,7 @@ SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
DLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
||||
} else {
|
||||
Uint8 _r, _g, _b, _a;
|
||||
const SDL_PixelFormat * fmt = dst->format;
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
|
||||
if (fmt->Rmask == 0x7C00) {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
@@ -85,9 +82,8 @@ SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool 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);
|
||||
@@ -97,7 +93,7 @@ SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
DLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
||||
} else {
|
||||
Uint8 _r, _g, _b, _a;
|
||||
const SDL_PixelFormat * fmt = dst->format;
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
|
||||
if (fmt->Rmask == 0x00FF0000) {
|
||||
if (!fmt->Amask) {
|
||||
@@ -117,12 +113,11 @@ SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*DrawLineFunc) (SDL_Surface * dst,
|
||||
int x1, int y1, int x2, int y2,
|
||||
Uint32 color, SDL_bool 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)
|
||||
static DrawLineFunc SDL_CalculateDrawLineFunc(const SDL_PixelFormat *fmt)
|
||||
{
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 1:
|
||||
@@ -138,8 +133,7 @@ SDL_CalculateDrawLineFunc(const SDL_PixelFormat * fmt)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
{
|
||||
DrawLineFunc func;
|
||||
|
||||
@@ -162,9 +156,8 @@ SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
Uint32 color)
|
||||
int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
Uint32 color)
|
||||
{
|
||||
int i;
|
||||
int x1, y1;
|
||||
@@ -182,8 +175,8 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
x1 = points[i-1].x;
|
||||
y1 = points[i-1].y;
|
||||
x1 = points[i - 1].x;
|
||||
y1 = points[i - 1].y;
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
@@ -198,8 +191,8 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#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);
|
||||
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_ */
|
||||
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_drawpoint.h"
|
||||
|
||||
|
||||
int
|
||||
SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
|
||||
int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
|
||||
{
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_DrawPoint(): dst");
|
||||
@@ -61,9 +59,8 @@ SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
Uint32 color)
|
||||
int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
Uint32 color)
|
||||
{
|
||||
int minx, miny;
|
||||
int maxx, maxy;
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
|
||||
#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);
|
||||
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_ */
|
||||
|
||||
|
||||
+340
-207
File diff suppressed because it is too large
Load Diff
@@ -22,7 +22,7 @@
|
||||
#ifndef SDL_render_sw_c_h_
|
||||
#define SDL_render_sw_c_h_
|
||||
|
||||
extern SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface * surface);
|
||||
extern SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface);
|
||||
|
||||
#endif /* SDL_render_sw_c_h_ */
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
/* !
|
||||
\brief A 32 bit RGBA pixel.
|
||||
*/
|
||||
typedef struct tColorRGBA {
|
||||
typedef struct tColorRGBA
|
||||
{
|
||||
Uint8 r;
|
||||
Uint8 g;
|
||||
Uint8 b;
|
||||
@@ -57,7 +58,8 @@ typedef struct tColorRGBA {
|
||||
/* !
|
||||
\brief A 8bit Y/palette pixel.
|
||||
*/
|
||||
typedef struct tColorY {
|
||||
typedef struct tColorY
|
||||
{
|
||||
Uint8 y;
|
||||
} tColorY;
|
||||
|
||||
@@ -76,8 +78,7 @@ to a situation where the program can segfault.
|
||||
/* !
|
||||
\brief Returns colorkey info for a surface
|
||||
*/
|
||||
static Uint32
|
||||
get_colorkey(SDL_Surface *src)
|
||||
static Uint32 get_colorkey(SDL_Surface *src)
|
||||
{
|
||||
Uint32 key = 0;
|
||||
if (SDL_HasColorKey(src)) {
|
||||
@@ -87,8 +88,8 @@ get_colorkey(SDL_Surface *src)
|
||||
}
|
||||
|
||||
/* rotate (sx, sy) by (angle, center) into (dx, dy) */
|
||||
static void
|
||||
rotate(double sx, double sy, double sinangle, double cosangle, const SDL_FPoint *center, double *dx, double *dy) {
|
||||
static void rotate(double sx, double sy, double sinangle, double cosangle, const SDL_FPoint *center, double *dx, double *dy)
|
||||
{
|
||||
sx -= center->x;
|
||||
sy -= center->y;
|
||||
|
||||
@@ -111,9 +112,8 @@ rotate(double sx, double sy, double sinangle, double cosangle, const SDL_FPoint
|
||||
\param sangle The cosine of the angle
|
||||
|
||||
*/
|
||||
void
|
||||
SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center,
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle)
|
||||
void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center,
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle)
|
||||
{
|
||||
int minx, maxx, miny, maxy;
|
||||
double radangle;
|
||||
@@ -129,16 +129,16 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP
|
||||
/*
|
||||
* Determine destination width and height by rotating a source box, at pixel center
|
||||
*/
|
||||
rotate(0.5, 0.5, sinangle, cosangle, center, &x0, &y0);
|
||||
rotate(width - 0.5, 0.5, sinangle, cosangle, center, &x1, &y1);
|
||||
rotate(0.5, height - 0.5, sinangle, cosangle, center, &x2, &y2);
|
||||
rotate(0.5, 0.5, sinangle, cosangle, center, &x0, &y0);
|
||||
rotate(width - 0.5, 0.5, sinangle, cosangle, center, &x1, &y1);
|
||||
rotate(0.5, height - 0.5, sinangle, cosangle, center, &x2, &y2);
|
||||
rotate(width - 0.5, height - 0.5, sinangle, cosangle, center, &x3, &y3);
|
||||
|
||||
minx = (int)SDL_floor( SDL_min( SDL_min(x0, x1), SDL_min(x2, x3) ) );
|
||||
maxx = (int)SDL_ceil( SDL_max( SDL_max(x0, x1), SDL_max(x2, x3) ) );
|
||||
minx = (int)SDL_floor(SDL_min(SDL_min(x0, x1), SDL_min(x2, x3)));
|
||||
maxx = (int)SDL_ceil(SDL_max(SDL_max(x0, x1), SDL_max(x2, x3)));
|
||||
|
||||
miny = (int)SDL_floor( SDL_min( SDL_min(y0, y1), SDL_min(y2, y3) ) );
|
||||
maxy = (int)SDL_ceil( SDL_max( SDL_max(y0, y1), SDL_max(y2, y3) ) );
|
||||
miny = (int)SDL_floor(SDL_min(SDL_min(y0, y1), SDL_min(y2, y3)));
|
||||
maxy = (int)SDL_ceil(SDL_max(SDL_max(y0, y1), SDL_max(y2, y3)));
|
||||
|
||||
rect_dest->w = maxx - minx;
|
||||
rect_dest->h = maxy - miny;
|
||||
@@ -151,20 +151,20 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP
|
||||
|
||||
{
|
||||
/* 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 */
|
||||
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) {
|
||||
rect_dest->w = height;
|
||||
rect_dest->w = height;
|
||||
rect_dest->h = width;
|
||||
*cangle = 0;
|
||||
*sangle = angle90 == 1 ? -1 : 1; /* reversed because our rotations are clockwise */
|
||||
} else {
|
||||
rect_dest->w = width;
|
||||
rect_dest->w = width;
|
||||
rect_dest->h = height;
|
||||
*cangle = angle90 == 0 ? 1 : -1;
|
||||
*sangle = 0;
|
||||
@@ -174,19 +174,37 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP
|
||||
}
|
||||
|
||||
/* 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)
|
||||
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;
|
||||
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;
|
||||
@@ -197,34 +215,34 @@ computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int
|
||||
}
|
||||
|
||||
/* 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; \
|
||||
#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; \
|
||||
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 SDL_memcpy */ \
|
||||
SDL_memcpy(dp, sp, dst->w*sizeof(pixelType)); \
|
||||
sp += dst->w*sizeof(pixelType); \
|
||||
dp += dst->w*sizeof(pixelType); \
|
||||
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; \
|
||||
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)
|
||||
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)
|
||||
static void transformSurfaceY90(SDL_Surface *src, SDL_Surface *dst, int angle, int flipx, int flipy)
|
||||
{
|
||||
TRANSFORM_SURFACE_90(tColorY);
|
||||
}
|
||||
@@ -250,32 +268,31 @@ Assumes dst surface was allocated with the correct dimensions.
|
||||
\param dst_rect destination coordinates
|
||||
\param center true center.
|
||||
*/
|
||||
static void
|
||||
transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
int flipx, int flipy, int smooth,
|
||||
const SDL_Rect *rect_dest,
|
||||
const SDL_FPoint *center)
|
||||
static void transformSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst, int isin, int icos,
|
||||
int flipx, int flipy, int smooth,
|
||||
const SDL_Rect *rect_dest,
|
||||
const SDL_FPoint *center)
|
||||
{
|
||||
int sw, sh;
|
||||
int cx, cy;
|
||||
tColorRGBA c00, c01, c10, c11, cswap;
|
||||
tColorRGBA *pc, *sp;
|
||||
int gap;
|
||||
const int fp_half = (1<<15);
|
||||
const int fp_half = (1 << 15);
|
||||
|
||||
/*
|
||||
* Variable setup
|
||||
*/
|
||||
* Variable setup
|
||||
*/
|
||||
sw = src->w - 1;
|
||||
sh = src->h - 1;
|
||||
pc = (tColorRGBA*) dst->pixels;
|
||||
pc = (tColorRGBA *)dst->pixels;
|
||||
gap = dst->pitch - dst->w * 4;
|
||||
cx = (int)(center->x * 65536.0);
|
||||
cy = (int)(center->y * 65536.0);
|
||||
|
||||
/*
|
||||
* Switch between interpolating and non-interpolating code
|
||||
*/
|
||||
* Switch between interpolating and non-interpolating code
|
||||
*/
|
||||
if (smooth) {
|
||||
int y;
|
||||
for (y = 0; y < dst->h; y++) {
|
||||
@@ -293,28 +310,36 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
if (flipy) {
|
||||
dy = sh - dy;
|
||||
}
|
||||
if ((dx > -1) && (dy > -1) && (dx < (src->w-1)) && (dy < (src->h-1))) {
|
||||
if ((dx > -1) && (dy > -1) && (dx < (src->w - 1)) && (dy < (src->h - 1))) {
|
||||
int ex, ey;
|
||||
int t1, t2;
|
||||
sp = (tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy) + dx;
|
||||
sp = (tColorRGBA *)((Uint8 *)src->pixels + src->pitch * dy) + dx;
|
||||
c00 = *sp;
|
||||
sp += 1;
|
||||
c01 = *sp;
|
||||
sp += (src->pitch/4);
|
||||
sp += (src->pitch / 4);
|
||||
c11 = *sp;
|
||||
sp -= 1;
|
||||
c10 = *sp;
|
||||
if (flipx) {
|
||||
cswap = c00; c00=c01; c01=cswap;
|
||||
cswap = c10; c10=c11; c11=cswap;
|
||||
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;
|
||||
cswap = c00;
|
||||
c00 = c10;
|
||||
c10 = cswap;
|
||||
cswap = c01;
|
||||
c01 = c11;
|
||||
c11 = cswap;
|
||||
}
|
||||
/*
|
||||
* Interpolate colors
|
||||
*/
|
||||
* Interpolate colors
|
||||
*/
|
||||
ex = (sdx & 0xffff);
|
||||
ey = (sdy & 0xffff);
|
||||
t1 = ((((c01.r - c00.r) * ex) >> 16) + c00.r) & 0xff;
|
||||
@@ -334,7 +359,7 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
sdy += isin;
|
||||
pc++;
|
||||
}
|
||||
pc = (tColorRGBA *) ((Uint8 *) pc + gap);
|
||||
pc = (tColorRGBA *)((Uint8 *)pc + gap);
|
||||
}
|
||||
} else {
|
||||
int y;
|
||||
@@ -360,7 +385,7 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
sdy += isin;
|
||||
pc++;
|
||||
}
|
||||
pc = (tColorRGBA *) ((Uint8 *) pc + gap);
|
||||
pc = (tColorRGBA *)((Uint8 *)pc + gap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -383,35 +408,34 @@ Assumes dst surface was allocated with the correct dimensions.
|
||||
\param dst_rect destination coordinates
|
||||
\param center true center.
|
||||
*/
|
||||
static void
|
||||
transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int isin, int icos, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest,
|
||||
const SDL_FPoint *center)
|
||||
static void transformSurfaceY(SDL_Surface *src, SDL_Surface *dst, int isin, int icos, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest,
|
||||
const SDL_FPoint *center)
|
||||
{
|
||||
int sw, sh;
|
||||
int cx, cy;
|
||||
tColorY *pc;
|
||||
int gap;
|
||||
const int fp_half = (1<<15);
|
||||
const int fp_half = (1 << 15);
|
||||
int y;
|
||||
|
||||
/*
|
||||
* Variable setup
|
||||
*/
|
||||
* Variable setup
|
||||
*/
|
||||
sw = src->w - 1;
|
||||
sh = src->h - 1;
|
||||
pc = (tColorY*) dst->pixels;
|
||||
pc = (tColorY *)dst->pixels;
|
||||
gap = dst->pitch - dst->w;
|
||||
cx = (int)(center->x * 65536.0);
|
||||
cy = (int)(center->y * 65536.0);
|
||||
|
||||
/*
|
||||
* Clear surface to colorkey
|
||||
*/
|
||||
* Clear surface to colorkey
|
||||
*/
|
||||
SDL_memset(pc, (int)(get_colorkey(src) & 0xff), dst->pitch * dst->h);
|
||||
/*
|
||||
* Iterate through destination surface
|
||||
*/
|
||||
* Iterate through destination surface
|
||||
*/
|
||||
for (y = 0; y < dst->h; y++) {
|
||||
int x;
|
||||
double src_x = (rect_dest->x + 0 + 0.5 - center->x);
|
||||
@@ -438,7 +462,6 @@ transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int isin, int icos, int
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* !
|
||||
\brief Rotates and zooms a surface with different horizontal and vertival scaling factors and optional anti-aliasing.
|
||||
|
||||
@@ -466,8 +489,8 @@ When using the NONE and MOD modes, color and alpha modulation must be applied be
|
||||
*/
|
||||
|
||||
SDL_Surface *
|
||||
SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center)
|
||||
SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center)
|
||||
{
|
||||
SDL_Surface *rz_dst;
|
||||
int is8bit, angle90;
|
||||
@@ -494,8 +517,8 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
|
||||
}
|
||||
|
||||
/* Calculate target factors from sine/cosine and zoom */
|
||||
sangleinv = sangle*65536.0;
|
||||
cangleinv = cangle*65536.0;
|
||||
sangleinv = sangle * 65536.0;
|
||||
cangleinv = cangle * 65536.0;
|
||||
|
||||
/* Alloc space to completely contain the rotated surface */
|
||||
rz_dst = NULL;
|
||||
@@ -557,8 +580,8 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
|
||||
* 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 = (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 */
|
||||
@@ -582,7 +605,7 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
|
||||
transformSurfaceRGBA90(src, rz_dst, angle90, flipx, flipy);
|
||||
} else {
|
||||
transformSurfaceRGBA(src, rz_dst, (int)sangleinv, (int)cangleinv,
|
||||
flipx, flipy, smooth, rect_dest, center);
|
||||
flipx, flipy, smooth, rect_dest, center);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
#ifndef SDL_rotate_h_
|
||||
#define SDL_rotate_h_
|
||||
|
||||
extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center);
|
||||
extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, int flipx, int flipy,
|
||||
const SDL_Rect *rect_dest, double cangle, double sangle, const SDL_FPoint *center);
|
||||
extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FPoint *center,
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle);
|
||||
SDL_Rect *rect_dest, double *cangle, double *sangle);
|
||||
|
||||
#endif /* SDL_rotate_h_ */
|
||||
|
||||
@@ -33,16 +33,15 @@
|
||||
* But, if increased too much, it overflows (srcx, srcy) coordinates used for filling with texture.
|
||||
* (which could be turned to int64).
|
||||
*/
|
||||
#define FP_BITS 1
|
||||
#define FP_BITS 1
|
||||
|
||||
#define COLOR_EQ(c1, c2) ((c1).r == (c2).r && (c1).g == (c2).g && (c1).b == (c2).b && (c1).a == (c2).a)
|
||||
|
||||
#define COLOR_EQ(c1, c2) ((c1).r == (c2).r && (c1).g == (c2).g && (c1).b == (c2).b && (c1).a == (c2).a)
|
||||
|
||||
static void SDL_BlitTriangle_Slow(SDL_BlitInfo * info,
|
||||
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
|
||||
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
|
||||
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform);
|
||||
static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
|
||||
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
|
||||
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform);
|
||||
|
||||
#if 0
|
||||
int SDL_BlitTriangle(SDL_Surface *src, const SDL_Point srcpoints[3], SDL_Surface *dst, const SDL_Point dstpoints[3])
|
||||
@@ -114,7 +113,8 @@ static int is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void trianglepoint_2_fixedpoint(SDL_Point *a) {
|
||||
void trianglepoint_2_fixedpoint(SDL_Point *a)
|
||||
{
|
||||
a->x <<= FP_BITS;
|
||||
a->y <<= FP_BITS;
|
||||
}
|
||||
@@ -146,7 +146,6 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin
|
||||
r->h = (max_y - min_y);
|
||||
}
|
||||
|
||||
|
||||
/* Triangle rendering, using Barycentric coordinates (w0, w1, w2)
|
||||
*
|
||||
* The cross product isn't computed from scratch at each iteration,
|
||||
@@ -154,53 +153,51 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin
|
||||
*
|
||||
*/
|
||||
|
||||
#define TRIANGLE_BEGIN_LOOP \
|
||||
{ \
|
||||
int x, y; \
|
||||
for (y = 0; y < dstrect.h; y++) { \
|
||||
/* y start */ \
|
||||
int w0 = w0_row; \
|
||||
int w1 = w1_row; \
|
||||
int w2 = w2_row; \
|
||||
for (x = 0; x < dstrect.w; x++) { \
|
||||
/* In triangle */ \
|
||||
if (w0 + bias_w0 >= 0 && w1 + bias_w1 >= 0 && w2 + bias_w2 >= 0) { \
|
||||
Uint8 *dptr = (Uint8 *) dst_ptr + x * dstbpp; \
|
||||
|
||||
#define TRIANGLE_BEGIN_LOOP \
|
||||
{ \
|
||||
int x, y; \
|
||||
for (y = 0; y < dstrect.h; y++) { \
|
||||
/* y start */ \
|
||||
int w0 = w0_row; \
|
||||
int w1 = w1_row; \
|
||||
int w2 = w2_row; \
|
||||
for (x = 0; x < dstrect.w; x++) { \
|
||||
/* In triangle */ \
|
||||
if (w0 + bias_w0 >= 0 && w1 + bias_w1 >= 0 && w2 + bias_w2 >= 0) { \
|
||||
Uint8 *dptr = (Uint8 *)dst_ptr + x * dstbpp;
|
||||
|
||||
/* Use 64 bits precision to prevent overflow when interpolating color / texture with wide triangles */
|
||||
#define TRIANGLE_GET_TEXTCOORD \
|
||||
int srcx = (int)(((Sint64)w0 * s2s0_x + (Sint64)w1 * s2s1_x + s2_x_area.x) / area); \
|
||||
int srcy = (int)(((Sint64)w0 * s2s0_y + (Sint64)w1 * s2s1_y + s2_x_area.y) / area); \
|
||||
#define TRIANGLE_GET_TEXTCOORD \
|
||||
int srcx = (int)(((Sint64)w0 * s2s0_x + (Sint64)w1 * s2s1_x + s2_x_area.x) / area); \
|
||||
int srcy = (int)(((Sint64)w0 * s2s0_y + (Sint64)w1 * s2s1_y + s2_x_area.y) / area);
|
||||
|
||||
#define TRIANGLE_GET_MAPPED_COLOR \
|
||||
int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \
|
||||
int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \
|
||||
int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \
|
||||
int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); \
|
||||
int color = SDL_MapRGBA(format, r, g, b, a); \
|
||||
#define TRIANGLE_GET_MAPPED_COLOR \
|
||||
int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \
|
||||
int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \
|
||||
int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \
|
||||
int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); \
|
||||
int color = SDL_MapRGBA(format, r, g, b, a);
|
||||
|
||||
#define TRIANGLE_GET_COLOR \
|
||||
int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \
|
||||
int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \
|
||||
int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \
|
||||
int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); \
|
||||
#define TRIANGLE_GET_COLOR \
|
||||
int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \
|
||||
int g = (int)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \
|
||||
int b = (int)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \
|
||||
int a = (int)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area);
|
||||
|
||||
|
||||
#define TRIANGLE_END_LOOP \
|
||||
} \
|
||||
/* x += 1 */ \
|
||||
w0 += d2d1_y; \
|
||||
w1 += d0d2_y; \
|
||||
w2 += d1d0_y; \
|
||||
} \
|
||||
/* y += 1 */ \
|
||||
w0_row += d1d2_x; \
|
||||
w1_row += d2d0_x; \
|
||||
w2_row += d0d1_x; \
|
||||
dst_ptr += dst_pitch; \
|
||||
} \
|
||||
} \
|
||||
#define TRIANGLE_END_LOOP \
|
||||
} \
|
||||
/* x += 1 */ \
|
||||
w0 += d2d1_y; \
|
||||
w1 += d0d2_y; \
|
||||
w2 += d1d0_y; \
|
||||
} \
|
||||
/* y += 1 */ \
|
||||
w0_row += d1d2_x; \
|
||||
w1_row += d2d0_x; \
|
||||
w2_row += d0d1_x; \
|
||||
dst_ptr += dst_pitch; \
|
||||
} \
|
||||
}
|
||||
|
||||
int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2)
|
||||
{
|
||||
@@ -265,12 +262,11 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
SDL_IntersectRect(&dstrect, &rect, &dstrect);
|
||||
}
|
||||
|
||||
|
||||
if (blend != SDL_BLENDMODE_NONE) {
|
||||
int format = dst->format->format;
|
||||
|
||||
/* need an alpha format */
|
||||
if (! dst->format->Amask) {
|
||||
if (!dst->format->Amask) {
|
||||
format = SDL_PIXELFORMAT_ARGB8888;
|
||||
}
|
||||
|
||||
@@ -323,7 +319,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
}
|
||||
|
||||
/* Handle anti-clockwise triangles */
|
||||
if (! is_clockwise) {
|
||||
if (!is_clockwise) {
|
||||
d2d1_y *= -1;
|
||||
d0d2_y *= -1;
|
||||
d1d0_y *= -1;
|
||||
@@ -346,7 +342,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
if (dst->format->Amask) {
|
||||
color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a);
|
||||
} else {
|
||||
//color = SDL_MapRGB(tmp->format, c0.r, c0.g, c0.b);
|
||||
// color = SDL_MapRGB(tmp->format, c0.r, c0.g, c0.b);
|
||||
color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a);
|
||||
}
|
||||
} else {
|
||||
@@ -362,7 +358,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
} else if (dstbpp == 3) {
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
Uint8 *s = (Uint8*)&color;
|
||||
Uint8 *s = (Uint8 *)&color;
|
||||
dptr[0] = s[0];
|
||||
dptr[1] = s[1];
|
||||
dptr[2] = s[2];
|
||||
@@ -397,7 +393,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_MAPPED_COLOR
|
||||
Uint8 *s = (Uint8*)&color;
|
||||
Uint8 *s = (Uint8 *)&color;
|
||||
dptr[0] = s[0];
|
||||
dptr[1] = s[1];
|
||||
dptr[2] = s[2];
|
||||
@@ -433,18 +429,12 @@ end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int SDL_SW_BlitTriangle(
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2)
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2)
|
||||
{
|
||||
int ret = 0;
|
||||
int src_locked = 0;
|
||||
@@ -584,7 +574,6 @@ int SDL_SW_BlitTriangle(
|
||||
d0d2_y = (d2->y - d0->y) << FP_BITS;
|
||||
d1d0_y = (d0->y - d1->y) << FP_BITS;
|
||||
|
||||
|
||||
d1d2_x = (d2->x - d1->x) << FP_BITS;
|
||||
d2d0_x = (d0->x - d2->x) << FP_BITS;
|
||||
d0d1_x = (d1->x - d0->x) << FP_BITS;
|
||||
@@ -608,7 +597,7 @@ int SDL_SW_BlitTriangle(
|
||||
}
|
||||
|
||||
/* Handle anti-clockwise triangles */
|
||||
if (! is_clockwise) {
|
||||
if (!is_clockwise) {
|
||||
d2d1_y *= -1;
|
||||
d0d2_y *= -1;
|
||||
d1d0_y *= -1;
|
||||
@@ -629,7 +618,7 @@ int SDL_SW_BlitTriangle(
|
||||
s2_x_area.x = s2->x * area;
|
||||
s2_x_area.y = s2->y * area;
|
||||
|
||||
if (blend != SDL_BLENDMODE_NONE || src->format->format != dst->format->format || has_modulation || ! is_uniform) {
|
||||
if (blend != SDL_BLENDMODE_NONE || src->format->format != dst->format->format || has_modulation || !is_uniform) {
|
||||
/* Use SDL_BlitTriangle_Slow */
|
||||
|
||||
SDL_BlitInfo *info = &src->map->info;
|
||||
@@ -651,12 +640,11 @@ int SDL_SW_BlitTriangle(
|
||||
tmp_info.b = c0.b;
|
||||
tmp_info.a = c0.a;
|
||||
|
||||
|
||||
tmp_info.flags &= ~(SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA);
|
||||
|
||||
if (c0.r != 255 || c1.r != 255 || c2.r != 255 ||
|
||||
c0.g != 255 || c1.g != 255 || c2.g != 255 ||
|
||||
c0.b != 255 || c1.b != 255 || c2.b != 255) {
|
||||
if (c0.r != 255 || c1.r != 255 || c2.r != 255 ||
|
||||
c0.g != 255 || c1.g != 255 || c2.g != 255 ||
|
||||
c0.b != 255 || c1.b != 255 || c2.b != 255) {
|
||||
tmp_info.flags |= SDL_COPY_MODULATE_COLOR;
|
||||
}
|
||||
|
||||
@@ -667,17 +655,17 @@ int SDL_SW_BlitTriangle(
|
||||
tmp_info.colorkey = info->colorkey;
|
||||
|
||||
/* src */
|
||||
tmp_info.src = (Uint8 *) src_ptr;
|
||||
tmp_info.src = (Uint8 *)src_ptr;
|
||||
tmp_info.src_pitch = src_pitch;
|
||||
|
||||
/* dst */
|
||||
tmp_info.dst = (Uint8 *) dst_ptr;
|
||||
tmp_info.dst = (Uint8 *)dst_ptr;
|
||||
tmp_info.dst_pitch = dst_pitch;
|
||||
|
||||
SDL_BlitTriangle_Slow(&tmp_info, s2_x_area, dstrect, area, bias_w0, bias_w1, bias_w2,
|
||||
d2d1_y, d1d2_x, d0d2_y, d2d0_x, d1d0_y, d0d1_x,
|
||||
s2s0_x, s2s1_x, s2s0_y, s2s1_y, w0_row, w1_row, w2_row,
|
||||
c0, c1, c2, is_uniform);
|
||||
d2d1_y, d1d2_x, d0d2_y, d2d0_x, d1d0_y, d0d1_x,
|
||||
s2s0_x, s2s1_x, s2s0_y, s2s1_y, w0_row, w1_row, w2_row,
|
||||
c0, c1, c2, is_uniform);
|
||||
|
||||
goto end;
|
||||
}
|
||||
@@ -686,7 +674,7 @@ int SDL_SW_BlitTriangle(
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_TEXTCOORD
|
||||
Uint32 *sptr = (Uint32 *)((Uint8 *) src_ptr + srcy * src_pitch);
|
||||
Uint32 *sptr = (Uint32 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
||||
*(Uint32 *)dptr = sptr[srcx];
|
||||
}
|
||||
TRIANGLE_END_LOOP
|
||||
@@ -694,7 +682,7 @@ int SDL_SW_BlitTriangle(
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_TEXTCOORD
|
||||
Uint8 *sptr = (Uint8 *)((Uint8 *) src_ptr + srcy * src_pitch);
|
||||
Uint8 *sptr = (Uint8 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
||||
dptr[0] = sptr[3 * srcx];
|
||||
dptr[1] = sptr[3 * srcx + 1];
|
||||
dptr[2] = sptr[3 * srcx + 2];
|
||||
@@ -704,7 +692,7 @@ int SDL_SW_BlitTriangle(
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_TEXTCOORD
|
||||
Uint16 *sptr = (Uint16 *)((Uint8 *) src_ptr + srcy * src_pitch);
|
||||
Uint16 *sptr = (Uint16 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
||||
*(Uint16 *)dptr = sptr[srcx];
|
||||
}
|
||||
TRIANGLE_END_LOOP
|
||||
@@ -712,7 +700,7 @@ int SDL_SW_BlitTriangle(
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
{
|
||||
TRIANGLE_GET_TEXTCOORD
|
||||
Uint8 *sptr = (Uint8 *)((Uint8 *) src_ptr + srcy * src_pitch);
|
||||
Uint8 *sptr = (Uint8 *)((Uint8 *)src_ptr + srcy * src_pitch);
|
||||
*dptr = sptr[srcx];
|
||||
}
|
||||
TRIANGLE_END_LOOP
|
||||
@@ -729,13 +717,13 @@ end:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#define FORMAT_ALPHA 0
|
||||
#define FORMAT_NO_ALPHA -1
|
||||
#define FORMAT_2101010 1
|
||||
#define FORMAT_HAS_ALPHA(format) format == 0
|
||||
#define FORMAT_HAS_NO_ALPHA(format) format < 0
|
||||
static int SDL_INLINE detect_format(SDL_PixelFormat *pf) {
|
||||
#define FORMAT_ALPHA 0
|
||||
#define FORMAT_NO_ALPHA -1
|
||||
#define FORMAT_2101010 1
|
||||
#define FORMAT_HAS_ALPHA(format) format == 0
|
||||
#define FORMAT_HAS_NO_ALPHA(format) format < 0
|
||||
static int SDL_INLINE detect_format(SDL_PixelFormat *pf)
|
||||
{
|
||||
if (pf->format == SDL_PIXELFORMAT_ARGB2101010) {
|
||||
return FORMAT_2101010;
|
||||
} else if (pf->Amask) {
|
||||
@@ -745,12 +733,11 @@ static int SDL_INLINE detect_format(SDL_PixelFormat *pf) {
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
|
||||
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
|
||||
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform)
|
||||
static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
SDL_Point s2_x_area, SDL_Rect dstrect, int area, int bias_w0, int bias_w1, int bias_w2,
|
||||
int d2d1_y, int d1d2_x, int d0d2_y, int d2d0_x, int d1d0_y, int d0d1_x,
|
||||
int s2s0_x, int s2s1_x, int s2s0_y, int s2s1_y, int w0_row, int w1_row, int w2_row,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2, int is_uniform)
|
||||
{
|
||||
const int flags = info->flags;
|
||||
Uint32 modulateR = info->r;
|
||||
@@ -796,7 +783,7 @@ SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
/* srcpixel isn't set for 24 bpp */
|
||||
if (srcbpp == 3) {
|
||||
srcpixel = (srcR << src_fmt->Rshift) |
|
||||
(srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift);
|
||||
(srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift);
|
||||
}
|
||||
if ((srcpixel & rgbmask) == ckey) {
|
||||
continue;
|
||||
@@ -813,7 +800,7 @@ SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
||||
RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA);
|
||||
}
|
||||
|
||||
if (! is_uniform) {
|
||||
if (!is_uniform) {
|
||||
TRIANGLE_GET_COLOR
|
||||
modulateR = r;
|
||||
modulateG = g;
|
||||
|
||||
@@ -25,15 +25,15 @@
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
extern int SDL_SW_FillTriangle(SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
|
||||
extern int SDL_SW_BlitTriangle(
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
SDL_Surface *src,
|
||||
SDL_Point *s0, SDL_Point *s1, SDL_Point *s2,
|
||||
SDL_Surface *dst,
|
||||
SDL_Point *d0, SDL_Point *d1, SDL_Point *d2,
|
||||
SDL_Color c0, SDL_Color c1, SDL_Color c2);
|
||||
|
||||
extern void trianglepoint_2_fixedpoint(SDL_Point *a);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31,9 +31,9 @@ vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignment, uns
|
||||
void *mem;
|
||||
|
||||
if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) {
|
||||
size = ALIGN(size, 256*1024);
|
||||
size = ALIGN(size, 256 * 1024);
|
||||
} else {
|
||||
size = ALIGN(size, 4*1024);
|
||||
size = ALIGN(size, 4 * 1024);
|
||||
}
|
||||
|
||||
*uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL);
|
||||
@@ -53,8 +53,7 @@ vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignment, uns
|
||||
return mem;
|
||||
}
|
||||
|
||||
void
|
||||
vita_mem_free(SceUID uid)
|
||||
void vita_mem_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
@@ -76,9 +75,9 @@ vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size)
|
||||
info.size = sizeof(SceKernelFreeMemorySizeInfo);
|
||||
sceKernelGetFreeMemorySize(&info);
|
||||
|
||||
poolsize = ALIGN(info.size_cdram, 256*1024);
|
||||
poolsize = ALIGN(info.size_cdram, 256 * 1024);
|
||||
if (poolsize > info.size_cdram) {
|
||||
poolsize = ALIGN(info.size_cdram - 256*1024, 256*1024);
|
||||
poolsize = ALIGN(info.size_cdram - 256 * 1024, 256 * 1024);
|
||||
}
|
||||
data->texturePoolUID = sceKernelAllocMemBlock("gpu_texture_pool", SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, poolsize, NULL);
|
||||
if (data->texturePoolUID < 0) {
|
||||
@@ -86,7 +85,7 @@ vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size)
|
||||
}
|
||||
|
||||
ret = sceKernelGetMemBlockBase(data->texturePoolUID, &mem);
|
||||
if ( ret < 0) {
|
||||
if (ret < 0) {
|
||||
return NULL;
|
||||
}
|
||||
data->texturePool = sceClibMspaceCreate(mem, poolsize);
|
||||
@@ -102,16 +101,14 @@ vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size)
|
||||
return sceClibMspaceMemalign(data->texturePool, SCE_GXM_TEXTURE_ALIGNMENT, size);
|
||||
}
|
||||
|
||||
void
|
||||
vita_gpu_mem_free(VITA_GXM_RenderData *data, void* ptr)
|
||||
void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr)
|
||||
{
|
||||
if (data->texturePool != NULL) {
|
||||
sceClibMspaceFree(data->texturePool, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
vita_gpu_mem_destroy(VITA_GXM_RenderData *data)
|
||||
void vita_gpu_mem_destroy(VITA_GXM_RenderData *data)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (data->texturePool != NULL) {
|
||||
@@ -143,8 +140,7 @@ vita_mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_of
|
||||
return mem;
|
||||
}
|
||||
|
||||
void
|
||||
vita_mem_vertex_usse_free(SceUID uid)
|
||||
void vita_mem_vertex_usse_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
@@ -172,8 +168,7 @@ vita_mem_fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_
|
||||
return mem;
|
||||
}
|
||||
|
||||
void
|
||||
vita_mem_fragment_usse_free(SceUID uid)
|
||||
void vita_mem_fragment_usse_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
#include <psp2/kernel/sysmem.h>
|
||||
#include "SDL_render_vita_gxm_types.h"
|
||||
|
||||
#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
|
||||
#define ALIGN(x, a) (((x) + ((a)-1)) & ~((a)-1))
|
||||
|
||||
void *vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignment, unsigned int attribs, SceUID *uid);
|
||||
void vita_mem_free(SceUID uid);
|
||||
void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size);
|
||||
void vita_gpu_mem_free(VITA_GXM_RenderData *data, void* ptr);
|
||||
void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr);
|
||||
void vita_gpu_mem_destroy(VITA_GXM_RenderData *data);
|
||||
void *vita_mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset);
|
||||
void vita_mem_vertex_usse_free(SceUID uid);
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include <psp2/gxm.h>
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
||||
#define gxm_shader_clear_f_size 232
|
||||
static const unsigned char gxm_shader_clear_f[gxm_shader_clear_f_size] = {
|
||||
0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03,
|
||||
@@ -268,12 +270,14 @@ static const unsigned char gxm_shader_texture_v[gxm_shader_texture_v_size] = {
|
||||
0x6f, 0x72, 0x00, 0x77, 0x76, 0x70, 0x00, 0x00,
|
||||
};
|
||||
|
||||
static const SceGxmProgram *const clearVertexProgramGxp = (const SceGxmProgram *)gxm_shader_clear_v;
|
||||
static const SceGxmProgram *const clearFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_clear_f;
|
||||
static const SceGxmProgram *const colorVertexProgramGxp = (const SceGxmProgram *)gxm_shader_color_v;
|
||||
static const SceGxmProgram *const colorFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_color_f;
|
||||
static const SceGxmProgram *const textureVertexProgramGxp = (const SceGxmProgram *)gxm_shader_texture_v;
|
||||
static const SceGxmProgram *const textureFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_f;
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
static const SceGxmProgram *const clearVertexProgramGxp = (const SceGxmProgram *)gxm_shader_clear_v;
|
||||
static const SceGxmProgram *const clearFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_clear_f;
|
||||
static const SceGxmProgram *const colorVertexProgramGxp = (const SceGxmProgram *)gxm_shader_color_v;
|
||||
static const SceGxmProgram *const colorFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_color_f;
|
||||
static const SceGxmProgram *const textureVertexProgramGxp = (const SceGxmProgram *)gxm_shader_texture_v;
|
||||
static const SceGxmProgram *const textureFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_f;
|
||||
|
||||
#endif // SDL_RENDER_VITA_GXM_SHADERS_H
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user