mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-03 08:28:29 +00:00
Corrected header file documentation comment.
This commit is contained in:
136
src/render/SDL_d3dmath.c
Normal file
136
src/render/SDL_d3dmath.c
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "SDL_d3dmath.h"
|
||||
|
||||
/* Direct3D matrix math functions */
|
||||
|
||||
Float4X4 MatrixIdentity()
|
||||
{
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m._11 = 1.0f;
|
||||
m._22 = 1.0f;
|
||||
m._33 = 1.0f;
|
||||
m._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2)
|
||||
{
|
||||
Float4X4 m;
|
||||
m._11 = M1._11 * M2._11 + M1._12 * M2._21 + M1._13 * M2._31 + M1._14 * M2._41;
|
||||
m._12 = M1._11 * M2._12 + M1._12 * M2._22 + M1._13 * M2._32 + M1._14 * M2._42;
|
||||
m._13 = M1._11 * M2._13 + M1._12 * M2._23 + M1._13 * M2._33 + M1._14 * M2._43;
|
||||
m._14 = M1._11 * M2._14 + M1._12 * M2._24 + M1._13 * M2._34 + M1._14 * M2._44;
|
||||
m._21 = M1._21 * M2._11 + M1._22 * M2._21 + M1._23 * M2._31 + M1._24 * M2._41;
|
||||
m._22 = M1._21 * M2._12 + M1._22 * M2._22 + M1._23 * M2._32 + M1._24 * M2._42;
|
||||
m._23 = M1._21 * M2._13 + M1._22 * M2._23 + M1._23 * M2._33 + M1._24 * M2._43;
|
||||
m._24 = M1._21 * M2._14 + M1._22 * M2._24 + M1._23 * M2._34 + M1._24 * M2._44;
|
||||
m._31 = M1._31 * M2._11 + M1._32 * M2._21 + M1._33 * M2._31 + M1._34 * M2._41;
|
||||
m._32 = M1._31 * M2._12 + M1._32 * M2._22 + M1._33 * M2._32 + M1._34 * M2._42;
|
||||
m._33 = M1._31 * M2._13 + M1._32 * M2._23 + M1._33 * M2._33 + M1._34 * M2._43;
|
||||
m._34 = M1._31 * M2._14 + M1._32 * M2._24 + M1._33 * M2._34 + M1._34 * M2._44;
|
||||
m._41 = M1._41 * M2._11 + M1._42 * M2._21 + M1._43 * M2._31 + M1._44 * M2._41;
|
||||
m._42 = M1._41 * M2._12 + M1._42 * M2._22 + M1._43 * M2._32 + M1._44 * M2._42;
|
||||
m._43 = M1._41 * M2._13 + M1._42 * M2._23 + M1._43 * M2._33 + M1._44 * M2._43;
|
||||
m._44 = M1._41 * M2._14 + M1._42 * M2._24 + M1._43 * M2._34 + M1._44 * M2._44;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixScaling(float x, float y, float z)
|
||||
{
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m._11 = x;
|
||||
m._22 = y;
|
||||
m._33 = z;
|
||||
m._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixTranslation(float x, float y, float z)
|
||||
{
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m._11 = 1.0f;
|
||||
m._22 = 1.0f;
|
||||
m._33 = 1.0f;
|
||||
m._44 = 1.0f;
|
||||
m._41 = x;
|
||||
m._42 = y;
|
||||
m._43 = z;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixRotationX(float r)
|
||||
{
|
||||
float sinR = SDL_sinf(r);
|
||||
float cosR = SDL_cosf(r);
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m._11 = 1.0f;
|
||||
m._22 = cosR;
|
||||
m._23 = sinR;
|
||||
m._32 = -sinR;
|
||||
m._33 = cosR;
|
||||
m._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixRotationY(float r)
|
||||
{
|
||||
float sinR = SDL_sinf(r);
|
||||
float cosR = SDL_cosf(r);
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m._11 = cosR;
|
||||
m._13 = -sinR;
|
||||
m._22 = 1.0f;
|
||||
m._31 = sinR;
|
||||
m._33 = cosR;
|
||||
m._44 = 1.0f;
|
||||
return m;
|
||||
}
|
||||
|
||||
Float4X4 MatrixRotationZ(float r)
|
||||
{
|
||||
float sinR = SDL_sinf(r);
|
||||
float cosR = SDL_cosf(r);
|
||||
Float4X4 m;
|
||||
SDL_zero(m);
|
||||
m._11 = cosR;
|
||||
m._12 = sinR;
|
||||
m._21 = -sinR;
|
||||
m._22 = cosR;
|
||||
m._33 = 1.0f;
|
||||
m._44 = 1.0f;
|
||||
return m;
|
||||
|
||||
}
|
||||
|
||||
#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
72
src/render/SDL_d3dmath.h
Normal file
72
src/render/SDL_d3dmath.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED
|
||||
|
||||
/* Direct3D matrix math functions */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
} Float2;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
} Float3;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float w;
|
||||
} Float4;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union {
|
||||
struct {
|
||||
float _11, _12, _13, _14;
|
||||
float _21, _22, _23, _24;
|
||||
float _31, _32, _33, _34;
|
||||
float _41, _42, _43, _44;
|
||||
};
|
||||
float m[4][4];
|
||||
};
|
||||
} Float4X4;
|
||||
|
||||
|
||||
Float4X4 MatrixIdentity();
|
||||
Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2);
|
||||
Float4X4 MatrixScaling(float x, float y, float z);
|
||||
Float4X4 MatrixTranslation(float x, float y, float z);
|
||||
Float4X4 MatrixRotationX(float r);
|
||||
Float4X4 MatrixRotationY(float r);
|
||||
Float4X4 MatrixRotationZ(float r);
|
||||
|
||||
#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11) && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1920
src/render/SDL_render.c
Normal file
1920
src/render/SDL_render.c
Normal file
File diff suppressed because it is too large
Load Diff
202
src/render/SDL_sysrender.h
Normal file
202
src/render/SDL_sysrender.h
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#ifndef _SDL_sysrender_h
|
||||
#define _SDL_sysrender_h
|
||||
|
||||
#include "SDL_render.h"
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_yuv_sw_c.h"
|
||||
|
||||
/* The SDL 2D rendering system */
|
||||
|
||||
typedef struct SDL_RenderDriver SDL_RenderDriver;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
} SDL_FPoint;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float w;
|
||||
float h;
|
||||
} SDL_FRect;
|
||||
|
||||
/* Define the SDL texture structure */
|
||||
struct SDL_Texture
|
||||
{
|
||||
const void *magic;
|
||||
Uint32 format; /**< The pixel format of the texture */
|
||||
int access; /**< SDL_TextureAccess */
|
||||
int w; /**< The width of the texture */
|
||||
int h; /**< The height of the texture */
|
||||
int modMode; /**< The texture modulation mode */
|
||||
SDL_BlendMode blendMode; /**< The texture blend mode */
|
||||
Uint8 r, g, b, a; /**< Texture modulation values */
|
||||
|
||||
SDL_Renderer *renderer;
|
||||
|
||||
/* Support for formats not supported directly by the renderer */
|
||||
SDL_Texture *native;
|
||||
SDL_SW_YUVTexture *yuv;
|
||||
void *pixels;
|
||||
int pitch;
|
||||
SDL_Rect locked_rect;
|
||||
|
||||
void *driverdata; /**< Driver specific texture representation */
|
||||
|
||||
SDL_Texture *prev;
|
||||
SDL_Texture *next;
|
||||
};
|
||||
|
||||
/* 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);
|
||||
int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
int (*SetTextureColorMod) (SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
int (*SetTextureAlphaMod) (SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
int (*SetTextureBlendMode) (SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels,
|
||||
int pitch);
|
||||
int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch);
|
||||
int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch);
|
||||
void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
int (*SetRenderTarget) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
int (*UpdateViewport) (SDL_Renderer * renderer);
|
||||
int (*UpdateClipRect) (SDL_Renderer * renderer);
|
||||
int (*RenderClear) (SDL_Renderer * renderer);
|
||||
int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_FPoint * points,
|
||||
int count);
|
||||
int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_FPoint * points,
|
||||
int count);
|
||||
int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_FRect * rects,
|
||||
int count);
|
||||
int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect);
|
||||
int (*RenderCopyEx) (SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcquad, const SDL_FRect * dstrect,
|
||||
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
|
||||
int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch);
|
||||
void (*RenderPresent) (SDL_Renderer * renderer);
|
||||
void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
|
||||
void (*DestroyRenderer) (SDL_Renderer * renderer);
|
||||
|
||||
int (*GL_BindTexture) (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh);
|
||||
int (*GL_UnbindTexture) (SDL_Renderer * renderer, SDL_Texture *texture);
|
||||
|
||||
/* The current renderer info */
|
||||
SDL_RendererInfo info;
|
||||
|
||||
/* The window associated with the renderer */
|
||||
SDL_Window *window;
|
||||
SDL_bool hidden;
|
||||
|
||||
/* The logical resolution for rendering */
|
||||
int logical_w;
|
||||
int logical_h;
|
||||
int logical_w_backup;
|
||||
int logical_h_backup;
|
||||
|
||||
/* The drawable area within the window */
|
||||
SDL_Rect viewport;
|
||||
SDL_Rect viewport_backup;
|
||||
|
||||
/* The clip rectangle within the window */
|
||||
SDL_Rect clip_rect;
|
||||
SDL_Rect clip_rect_backup;
|
||||
|
||||
/* Wether or not the clipping rectangle is used. */
|
||||
SDL_bool clipping_enabled;
|
||||
SDL_bool clipping_enabled_backup;
|
||||
|
||||
/* The render output coordinate scale */
|
||||
SDL_FPoint scale;
|
||||
SDL_FPoint scale_backup;
|
||||
|
||||
/* The list of textures */
|
||||
SDL_Texture *textures;
|
||||
SDL_Texture *target;
|
||||
|
||||
Uint8 r, g, b, a; /**< Color for drawing operations values */
|
||||
SDL_BlendMode blendMode; /**< The drawing blend mode */
|
||||
|
||||
void *driverdata;
|
||||
};
|
||||
|
||||
/* Define the SDL render driver structure */
|
||||
struct SDL_RenderDriver
|
||||
{
|
||||
SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
|
||||
|
||||
/* Info about the renderer capabilities */
|
||||
SDL_RendererInfo info;
|
||||
};
|
||||
|
||||
#if !SDL_RENDER_DISABLED
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D
|
||||
extern SDL_RenderDriver D3D_RenderDriver;
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_D3D11
|
||||
extern SDL_RenderDriver D3D11_RenderDriver;
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_OGL
|
||||
extern SDL_RenderDriver GL_RenderDriver;
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_OGL_ES2
|
||||
extern SDL_RenderDriver GLES2_RenderDriver;
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_OGL_ES
|
||||
extern SDL_RenderDriver GLES_RenderDriver;
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_DIRECTFB
|
||||
extern SDL_RenderDriver DirectFB_RenderDriver;
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_PSP
|
||||
extern SDL_RenderDriver PSP_RenderDriver;
|
||||
#endif
|
||||
extern SDL_RenderDriver SW_RenderDriver;
|
||||
|
||||
#endif /* !SDL_RENDER_DISABLED */
|
||||
|
||||
#endif /* _SDL_sysrender_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
431
src/render/SDL_yuv_mmx.c
Normal file
431
src/render/SDL_yuv_mmx.c
Normal file
@@ -0,0 +1,431 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#if (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#include "mmx.h"
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
static mmx_t MMX_0080w = { .ud = {0x00800080, 0x00800080} };
|
||||
static mmx_t MMX_00FFw = { .ud = {0x00ff00ff, 0x00ff00ff} };
|
||||
static mmx_t MMX_FF00w = { .ud = {0xff00ff00, 0xff00ff00} };
|
||||
|
||||
static mmx_t MMX_Ycoeff = { .uw = {0x004a, 0x004a, 0x004a, 0x004a} };
|
||||
|
||||
static mmx_t MMX_UbluRGB = { .uw = {0x0072, 0x0072, 0x0072, 0x0072} };
|
||||
static mmx_t MMX_VredRGB = { .uw = {0x0059, 0x0059, 0x0059, 0x0059} };
|
||||
static mmx_t MMX_UgrnRGB = { .uw = {0xffea, 0xffea, 0xffea, 0xffea} };
|
||||
static mmx_t MMX_VgrnRGB = { .uw = {0xffd2, 0xffd2, 0xffd2, 0xffd2} };
|
||||
|
||||
static mmx_t MMX_Ublu5x5 = { .uw = {0x0081, 0x0081, 0x0081, 0x0081} };
|
||||
static mmx_t MMX_Vred5x5 = { .uw = {0x0066, 0x0066, 0x0066, 0x0066} };
|
||||
static mmx_t MMX_Ugrn565 = { .uw = {0xffe8, 0xffe8, 0xffe8, 0xffe8} };
|
||||
static mmx_t MMX_Vgrn565 = { .uw = {0xffcd, 0xffcd, 0xffcd, 0xffcd} };
|
||||
|
||||
static mmx_t MMX_red565 = { .uw = {0xf800, 0xf800, 0xf800, 0xf800} };
|
||||
static mmx_t MMX_grn565 = { .uw = {0x07e0, 0x07e0, 0x07e0, 0x07e0} };
|
||||
|
||||
/**
|
||||
This MMX assembler is my first assembler/MMX program ever.
|
||||
Thus it maybe buggy.
|
||||
Send patches to:
|
||||
mvogt@rhrk.uni-kl.de
|
||||
|
||||
After it worked fine I have "obfuscated" the code a bit to have
|
||||
more parallism in the MMX units. This means I moved
|
||||
initilisation around and delayed other instruction.
|
||||
Performance measurement did not show that this brought any advantage
|
||||
but in theory it _should_ be faster this way.
|
||||
|
||||
The overall performanve gain to the C based dither was 30%-40%.
|
||||
The MMX routine calculates 256bit=8RGB values in each cycle
|
||||
(4 for row1 & 4 for row2)
|
||||
|
||||
The red/green/blue.. coefficents are taken from the mpeg_play
|
||||
player. They look nice, but I dont know if you can have
|
||||
better values, to avoid integer rounding errors.
|
||||
|
||||
|
||||
IMPORTANT:
|
||||
==========
|
||||
|
||||
It is a requirement that the cr/cb/lum are 8 byte aligned and
|
||||
the out are 16byte aligned or you will/may get segfaults
|
||||
|
||||
*/
|
||||
|
||||
void ColorRGBDitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
|
||||
unsigned char *lum, unsigned char *cr,
|
||||
unsigned char *cb, unsigned char *out,
|
||||
int rows, int cols, int mod )
|
||||
{
|
||||
Uint32 *row1;
|
||||
Uint32 *row2;
|
||||
|
||||
unsigned char* y = lum +cols*rows; /* Pointer to the end */
|
||||
int x = 0;
|
||||
row1 = (Uint32 *)out; /* 32 bit target */
|
||||
row2 = (Uint32 *)out+cols+mod; /* start of second row */
|
||||
mod = (mod+cols+mod)*4; /* increment for row1 in byte */
|
||||
|
||||
__asm__ __volatile__ (
|
||||
/* tap dance to workaround the inability to use %%ebx at will... */
|
||||
/* move one thing to the stack... */
|
||||
"pushl $0\n" /* save a slot on the stack. */
|
||||
"pushl %%ebx\n" /* save %%ebx. */
|
||||
"movl %0, %%ebx\n" /* put the thing in ebx. */
|
||||
"movl %%ebx,4(%%esp)\n" /* put the thing in the stack slot. */
|
||||
"popl %%ebx\n" /* get back %%ebx (the PIC register). */
|
||||
|
||||
".align 8\n"
|
||||
"1:\n"
|
||||
|
||||
/* create Cr (result in mm1) */
|
||||
"pushl %%ebx\n"
|
||||
"movl 4(%%esp),%%ebx\n"
|
||||
"movd (%%ebx),%%mm1\n" /* 0 0 0 0 v3 v2 v1 v0 */
|
||||
"popl %%ebx\n"
|
||||
"pxor %%mm7,%%mm7\n" /* 00 00 00 00 00 00 00 00 */
|
||||
"movd (%2), %%mm2\n" /* 0 0 0 0 l3 l2 l1 l0 */
|
||||
"punpcklbw %%mm7,%%mm1\n" /* 0 v3 0 v2 00 v1 00 v0 */
|
||||
"punpckldq %%mm1,%%mm1\n" /* 00 v1 00 v0 00 v1 00 v0 */
|
||||
"psubw %9,%%mm1\n" /* mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 */
|
||||
|
||||
/* create Cr_g (result in mm0) */
|
||||
"movq %%mm1,%%mm0\n" /* r1 r1 r0 r0 r1 r1 r0 r0 */
|
||||
"pmullw %10,%%mm0\n" /* red*-46dec=0.7136*64 */
|
||||
"pmullw %11,%%mm1\n" /* red*89dec=1.4013*64 */
|
||||
"psraw $6, %%mm0\n" /* red=red/64 */
|
||||
"psraw $6, %%mm1\n" /* red=red/64 */
|
||||
|
||||
/* create L1 L2 (result in mm2,mm4) */
|
||||
/* L2=lum+cols */
|
||||
"movq (%2,%4),%%mm3\n" /* 0 0 0 0 L3 L2 L1 L0 */
|
||||
"punpckldq %%mm3,%%mm2\n" /* L3 L2 L1 L0 l3 l2 l1 l0 */
|
||||
"movq %%mm2,%%mm4\n" /* L3 L2 L1 L0 l3 l2 l1 l0 */
|
||||
"pand %12,%%mm2\n" /* L3 0 L1 0 l3 0 l1 0 */
|
||||
"pand %13,%%mm4\n" /* 0 L2 0 L0 0 l2 0 l0 */
|
||||
"psrlw $8,%%mm2\n" /* 0 L3 0 L1 0 l3 0 l1 */
|
||||
|
||||
/* create R (result in mm6) */
|
||||
"movq %%mm2,%%mm5\n" /* 0 L3 0 L1 0 l3 0 l1 */
|
||||
"movq %%mm4,%%mm6\n" /* 0 L2 0 L0 0 l2 0 l0 */
|
||||
"paddsw %%mm1, %%mm5\n" /* lum1+red:x R3 x R1 x r3 x r1 */
|
||||
"paddsw %%mm1, %%mm6\n" /* lum1+red:x R2 x R0 x r2 x r0 */
|
||||
"packuswb %%mm5,%%mm5\n" /* R3 R1 r3 r1 R3 R1 r3 r1 */
|
||||
"packuswb %%mm6,%%mm6\n" /* R2 R0 r2 r0 R2 R0 r2 r0 */
|
||||
"pxor %%mm7,%%mm7\n" /* 00 00 00 00 00 00 00 00 */
|
||||
"punpcklbw %%mm5,%%mm6\n" /* R3 R2 R1 R0 r3 r2 r1 r0 */
|
||||
|
||||
/* create Cb (result in mm1) */
|
||||
"movd (%1), %%mm1\n" /* 0 0 0 0 u3 u2 u1 u0 */
|
||||
"punpcklbw %%mm7,%%mm1\n" /* 0 u3 0 u2 00 u1 00 u0 */
|
||||
"punpckldq %%mm1,%%mm1\n" /* 00 u1 00 u0 00 u1 00 u0 */
|
||||
"psubw %9,%%mm1\n" /* mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 */
|
||||
|
||||
/* create Cb_g (result in mm5) */
|
||||
"movq %%mm1,%%mm5\n" /* u1 u1 u0 u0 u1 u1 u0 u0 */
|
||||
"pmullw %14,%%mm5\n" /* blue*-109dec=1.7129*64 */
|
||||
"pmullw %15,%%mm1\n" /* blue*114dec=1.78125*64 */
|
||||
"psraw $6, %%mm5\n" /* blue=red/64 */
|
||||
"psraw $6, %%mm1\n" /* blue=blue/64 */
|
||||
|
||||
/* create G (result in mm7) */
|
||||
"movq %%mm2,%%mm3\n" /* 0 L3 0 L1 0 l3 0 l1 */
|
||||
"movq %%mm4,%%mm7\n" /* 0 L2 0 L0 0 l2 0 l1 */
|
||||
"paddsw %%mm5, %%mm3\n" /* lum1+Cb_g:x G3t x G1t x g3t x g1t */
|
||||
"paddsw %%mm5, %%mm7\n" /* lum1+Cb_g:x G2t x G0t x g2t x g0t */
|
||||
"paddsw %%mm0, %%mm3\n" /* lum1+Cr_g:x G3 x G1 x g3 x g1 */
|
||||
"paddsw %%mm0, %%mm7\n" /* lum1+blue:x G2 x G0 x g2 x g0 */
|
||||
"packuswb %%mm3,%%mm3\n" /* G3 G1 g3 g1 G3 G1 g3 g1 */
|
||||
"packuswb %%mm7,%%mm7\n" /* G2 G0 g2 g0 G2 G0 g2 g0 */
|
||||
"punpcklbw %%mm3,%%mm7\n" /* G3 G2 G1 G0 g3 g2 g1 g0 */
|
||||
|
||||
/* create B (result in mm5) */
|
||||
"movq %%mm2,%%mm3\n" /* 0 L3 0 L1 0 l3 0 l1 */
|
||||
"movq %%mm4,%%mm5\n" /* 0 L2 0 L0 0 l2 0 l1 */
|
||||
"paddsw %%mm1, %%mm3\n" /* lum1+blue:x B3 x B1 x b3 x b1 */
|
||||
"paddsw %%mm1, %%mm5\n" /* lum1+blue:x B2 x B0 x b2 x b0 */
|
||||
"packuswb %%mm3,%%mm3\n" /* B3 B1 b3 b1 B3 B1 b3 b1 */
|
||||
"packuswb %%mm5,%%mm5\n" /* B2 B0 b2 b0 B2 B0 b2 b0 */
|
||||
"punpcklbw %%mm3,%%mm5\n" /* B3 B2 B1 B0 b3 b2 b1 b0 */
|
||||
|
||||
/* fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb) */
|
||||
|
||||
"pxor %%mm2,%%mm2\n" /* 0 0 0 0 0 0 0 0 */
|
||||
"pxor %%mm4,%%mm4\n" /* 0 0 0 0 0 0 0 0 */
|
||||
"movq %%mm6,%%mm1\n" /* R3 R2 R1 R0 r3 r2 r1 r0 */
|
||||
"movq %%mm5,%%mm3\n" /* B3 B2 B1 B0 b3 b2 b1 b0 */
|
||||
|
||||
/* process lower lum */
|
||||
"punpcklbw %%mm4,%%mm1\n" /* 0 r3 0 r2 0 r1 0 r0 */
|
||||
"punpcklbw %%mm4,%%mm3\n" /* 0 b3 0 b2 0 b1 0 b0 */
|
||||
"movq %%mm1,%%mm2\n" /* 0 r3 0 r2 0 r1 0 r0 */
|
||||
"movq %%mm3,%%mm0\n" /* 0 b3 0 b2 0 b1 0 b0 */
|
||||
"punpcklwd %%mm1,%%mm3\n" /* 0 r1 0 b1 0 r0 0 b0 */
|
||||
"punpckhwd %%mm2,%%mm0\n" /* 0 r3 0 b3 0 r2 0 b2 */
|
||||
|
||||
"pxor %%mm2,%%mm2\n" /* 0 0 0 0 0 0 0 0 */
|
||||
"movq %%mm7,%%mm1\n" /* G3 G2 G1 G0 g3 g2 g1 g0 */
|
||||
"punpcklbw %%mm1,%%mm2\n" /* g3 0 g2 0 g1 0 g0 0 */
|
||||
"punpcklwd %%mm4,%%mm2\n" /* 0 0 g1 0 0 0 g0 0 */
|
||||
"por %%mm3, %%mm2\n" /* 0 r1 g1 b1 0 r0 g0 b0 */
|
||||
"movq %%mm2,(%3)\n" /* wrote out ! row1 */
|
||||
|
||||
"pxor %%mm2,%%mm2\n" /* 0 0 0 0 0 0 0 0 */
|
||||
"punpcklbw %%mm1,%%mm4\n" /* g3 0 g2 0 g1 0 g0 0 */
|
||||
"punpckhwd %%mm2,%%mm4\n" /* 0 0 g3 0 0 0 g2 0 */
|
||||
"por %%mm0, %%mm4\n" /* 0 r3 g3 b3 0 r2 g2 b2 */
|
||||
"movq %%mm4,8(%3)\n" /* wrote out ! row1 */
|
||||
|
||||
/* fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb) */
|
||||
/* this can be done "destructive" */
|
||||
"pxor %%mm2,%%mm2\n" /* 0 0 0 0 0 0 0 0 */
|
||||
"punpckhbw %%mm2,%%mm6\n" /* 0 R3 0 R2 0 R1 0 R0 */
|
||||
"punpckhbw %%mm1,%%mm5\n" /* G3 B3 G2 B2 G1 B1 G0 B0 */
|
||||
"movq %%mm5,%%mm1\n" /* G3 B3 G2 B2 G1 B1 G0 B0 */
|
||||
"punpcklwd %%mm6,%%mm1\n" /* 0 R1 G1 B1 0 R0 G0 B0 */
|
||||
"movq %%mm1,(%5)\n" /* wrote out ! row2 */
|
||||
"punpckhwd %%mm6,%%mm5\n" /* 0 R3 G3 B3 0 R2 G2 B2 */
|
||||
"movq %%mm5,8(%5)\n" /* wrote out ! row2 */
|
||||
|
||||
"addl $4,%2\n" /* lum+4 */
|
||||
"leal 16(%3),%3\n" /* row1+16 */
|
||||
"leal 16(%5),%5\n" /* row2+16 */
|
||||
"addl $2,(%%esp)\n" /* cr+2 */
|
||||
"addl $2,%1\n" /* cb+2 */
|
||||
|
||||
"addl $4,%6\n" /* x+4 */
|
||||
"cmpl %4,%6\n"
|
||||
|
||||
"jl 1b\n"
|
||||
"addl %4,%2\n" /* lum += cols */
|
||||
"addl %8,%3\n" /* row1+= mod */
|
||||
"addl %8,%5\n" /* row2+= mod */
|
||||
"movl $0,%6\n" /* x=0 */
|
||||
"cmpl %7,%2\n"
|
||||
"jl 1b\n"
|
||||
|
||||
"addl $4,%%esp\n" /* get rid of the stack slot we reserved. */
|
||||
"emms\n" /* reset MMX registers. */
|
||||
:
|
||||
: "m" (cr), "r"(cb),"r"(lum),
|
||||
"r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod),
|
||||
"m"(MMX_0080w),"m"(MMX_VgrnRGB),"m"(MMX_VredRGB),
|
||||
"m"(MMX_FF00w),"m"(MMX_00FFw),"m"(MMX_UgrnRGB),
|
||||
"m"(MMX_UbluRGB)
|
||||
);
|
||||
}
|
||||
|
||||
void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
|
||||
unsigned char *lum, unsigned char *cr,
|
||||
unsigned char *cb, unsigned char *out,
|
||||
int rows, int cols, int mod )
|
||||
{
|
||||
Uint16 *row1;
|
||||
Uint16 *row2;
|
||||
|
||||
unsigned char* y = lum +cols*rows; /* Pointer to the end */
|
||||
int x = 0;
|
||||
row1 = (Uint16 *)out; /* 16 bit target */
|
||||
row2 = (Uint16 *)out+cols+mod; /* start of second row */
|
||||
mod = (mod+cols+mod)*2; /* increment for row1 in byte */
|
||||
|
||||
__asm__ __volatile__(
|
||||
/* tap dance to workaround the inability to use %%ebx at will... */
|
||||
/* move one thing to the stack... */
|
||||
"pushl $0\n" /* save a slot on the stack. */
|
||||
"pushl %%ebx\n" /* save %%ebx. */
|
||||
"movl %0, %%ebx\n" /* put the thing in ebx. */
|
||||
"movl %%ebx, 4(%%esp)\n" /* put the thing in the stack slot. */
|
||||
"popl %%ebx\n" /* get back %%ebx (the PIC register). */
|
||||
|
||||
".align 8\n"
|
||||
"1:\n"
|
||||
|
||||
"movd (%1), %%mm0\n" /* 4 Cb 0 0 0 0 u3 u2 u1 u0 */
|
||||
"pxor %%mm7, %%mm7\n"
|
||||
"pushl %%ebx\n"
|
||||
"movl 4(%%esp), %%ebx\n"
|
||||
"movd (%%ebx), %%mm1\n" /* 4 Cr 0 0 0 0 v3 v2 v1 v0 */
|
||||
"popl %%ebx\n"
|
||||
|
||||
"punpcklbw %%mm7, %%mm0\n" /* 4 W cb 0 u3 0 u2 0 u1 0 u0 */
|
||||
"punpcklbw %%mm7, %%mm1\n" /* 4 W cr 0 v3 0 v2 0 v1 0 v0 */
|
||||
"psubw %9, %%mm0\n"
|
||||
"psubw %9, %%mm1\n"
|
||||
"movq %%mm0, %%mm2\n" /* Cb 0 u3 0 u2 0 u1 0 u0 */
|
||||
"movq %%mm1, %%mm3\n" /* Cr */
|
||||
"pmullw %10, %%mm2\n" /* Cb2green 0 R3 0 R2 0 R1 0 R0 */
|
||||
"movq (%2), %%mm6\n" /* L1 l7 L6 L5 L4 L3 L2 L1 L0 */
|
||||
"pmullw %11, %%mm0\n" /* Cb2blue */
|
||||
"pand %12, %%mm6\n" /* L1 00 L6 00 L4 00 L2 00 L0 */
|
||||
"pmullw %13, %%mm3\n" /* Cr2green */
|
||||
"movq (%2), %%mm7\n" /* L2 */
|
||||
"pmullw %14, %%mm1\n" /* Cr2red */
|
||||
"psrlw $8, %%mm7\n" /* L2 00 L7 00 L5 00 L3 00 L1 */
|
||||
"pmullw %15, %%mm6\n" /* lum1 */
|
||||
"paddw %%mm3, %%mm2\n" /* Cb2green + Cr2green == green */
|
||||
"pmullw %15, %%mm7\n" /* lum2 */
|
||||
|
||||
"movq %%mm6, %%mm4\n" /* lum1 */
|
||||
"paddw %%mm0, %%mm6\n" /* lum1 +blue 00 B6 00 B4 00 B2 00 B0 */
|
||||
"movq %%mm4, %%mm5\n" /* lum1 */
|
||||
"paddw %%mm1, %%mm4\n" /* lum1 +red 00 R6 00 R4 00 R2 00 R0 */
|
||||
"paddw %%mm2, %%mm5\n" /* lum1 +green 00 G6 00 G4 00 G2 00 G0 */
|
||||
"psraw $6, %%mm4\n" /* R1 0 .. 64 */
|
||||
"movq %%mm7, %%mm3\n" /* lum2 00 L7 00 L5 00 L3 00 L1 */
|
||||
"psraw $6, %%mm5\n" /* G1 - .. + */
|
||||
"paddw %%mm0, %%mm7\n" /* Lum2 +blue 00 B7 00 B5 00 B3 00 B1 */
|
||||
"psraw $6, %%mm6\n" /* B1 0 .. 64 */
|
||||
"packuswb %%mm4, %%mm4\n" /* R1 R1 */
|
||||
"packuswb %%mm5, %%mm5\n" /* G1 G1 */
|
||||
"packuswb %%mm6, %%mm6\n" /* B1 B1 */
|
||||
"punpcklbw %%mm4, %%mm4\n"
|
||||
"punpcklbw %%mm5, %%mm5\n"
|
||||
|
||||
"pand %16, %%mm4\n"
|
||||
"psllw $3, %%mm5\n" /* GREEN 1 */
|
||||
"punpcklbw %%mm6, %%mm6\n"
|
||||
"pand %17, %%mm5\n"
|
||||
"pand %16, %%mm6\n"
|
||||
"por %%mm5, %%mm4\n" /* */
|
||||
"psrlw $11, %%mm6\n" /* BLUE 1 */
|
||||
"movq %%mm3, %%mm5\n" /* lum2 */
|
||||
"paddw %%mm1, %%mm3\n" /* lum2 +red 00 R7 00 R5 00 R3 00 R1 */
|
||||
"paddw %%mm2, %%mm5\n" /* lum2 +green 00 G7 00 G5 00 G3 00 G1 */
|
||||
"psraw $6, %%mm3\n" /* R2 */
|
||||
"por %%mm6, %%mm4\n" /* MM4 */
|
||||
"psraw $6, %%mm5\n" /* G2 */
|
||||
"movq (%2, %4), %%mm6\n" /* L3 load lum2 */
|
||||
"psraw $6, %%mm7\n"
|
||||
"packuswb %%mm3, %%mm3\n"
|
||||
"packuswb %%mm5, %%mm5\n"
|
||||
"packuswb %%mm7, %%mm7\n"
|
||||
"pand %12, %%mm6\n" /* L3 */
|
||||
"punpcklbw %%mm3, %%mm3\n"
|
||||
"punpcklbw %%mm5, %%mm5\n"
|
||||
"pmullw %15, %%mm6\n" /* lum3 */
|
||||
"punpcklbw %%mm7, %%mm7\n"
|
||||
"psllw $3, %%mm5\n" /* GREEN 2 */
|
||||
"pand %16, %%mm7\n"
|
||||
"pand %16, %%mm3\n"
|
||||
"psrlw $11, %%mm7\n" /* BLUE 2 */
|
||||
"pand %17, %%mm5\n"
|
||||
"por %%mm7, %%mm3\n"
|
||||
"movq (%2,%4), %%mm7\n" /* L4 load lum2 */
|
||||
"por %%mm5, %%mm3\n"
|
||||
"psrlw $8, %%mm7\n" /* L4 */
|
||||
"movq %%mm4, %%mm5\n"
|
||||
"punpcklwd %%mm3, %%mm4\n"
|
||||
"pmullw %15, %%mm7\n" /* lum4 */
|
||||
"punpckhwd %%mm3, %%mm5\n"
|
||||
|
||||
"movq %%mm4, (%3)\n" /* write row1 */
|
||||
"movq %%mm5, 8(%3)\n" /* write row1 */
|
||||
|
||||
"movq %%mm6, %%mm4\n" /* Lum3 */
|
||||
"paddw %%mm0, %%mm6\n" /* Lum3 +blue */
|
||||
|
||||
"movq %%mm4, %%mm5\n" /* Lum3 */
|
||||
"paddw %%mm1, %%mm4\n" /* Lum3 +red */
|
||||
"paddw %%mm2, %%mm5\n" /* Lum3 +green */
|
||||
"psraw $6, %%mm4\n"
|
||||
"movq %%mm7, %%mm3\n" /* Lum4 */
|
||||
"psraw $6, %%mm5\n"
|
||||
"paddw %%mm0, %%mm7\n" /* Lum4 +blue */
|
||||
"psraw $6, %%mm6\n" /* Lum3 +blue */
|
||||
"movq %%mm3, %%mm0\n" /* Lum4 */
|
||||
"packuswb %%mm4, %%mm4\n"
|
||||
"paddw %%mm1, %%mm3\n" /* Lum4 +red */
|
||||
"packuswb %%mm5, %%mm5\n"
|
||||
"paddw %%mm2, %%mm0\n" /* Lum4 +green */
|
||||
"packuswb %%mm6, %%mm6\n"
|
||||
"punpcklbw %%mm4, %%mm4\n"
|
||||
"punpcklbw %%mm5, %%mm5\n"
|
||||
"punpcklbw %%mm6, %%mm6\n"
|
||||
"psllw $3, %%mm5\n" /* GREEN 3 */
|
||||
"pand %16, %%mm4\n"
|
||||
"psraw $6, %%mm3\n" /* psr 6 */
|
||||
"psraw $6, %%mm0\n"
|
||||
"pand %16, %%mm6\n" /* BLUE */
|
||||
"pand %17, %%mm5\n"
|
||||
"psrlw $11, %%mm6\n" /* BLUE 3 */
|
||||
"por %%mm5, %%mm4\n"
|
||||
"psraw $6, %%mm7\n"
|
||||
"por %%mm6, %%mm4\n"
|
||||
"packuswb %%mm3, %%mm3\n"
|
||||
"packuswb %%mm0, %%mm0\n"
|
||||
"packuswb %%mm7, %%mm7\n"
|
||||
"punpcklbw %%mm3, %%mm3\n"
|
||||
"punpcklbw %%mm0, %%mm0\n"
|
||||
"punpcklbw %%mm7, %%mm7\n"
|
||||
"pand %16, %%mm3\n"
|
||||
"pand %16, %%mm7\n" /* BLUE */
|
||||
"psllw $3, %%mm0\n" /* GREEN 4 */
|
||||
"psrlw $11, %%mm7\n"
|
||||
"pand %17, %%mm0\n"
|
||||
"por %%mm7, %%mm3\n"
|
||||
"por %%mm0, %%mm3\n"
|
||||
|
||||
"movq %%mm4, %%mm5\n"
|
||||
|
||||
"punpcklwd %%mm3, %%mm4\n"
|
||||
"punpckhwd %%mm3, %%mm5\n"
|
||||
|
||||
"movq %%mm4, (%5)\n"
|
||||
"movq %%mm5, 8(%5)\n"
|
||||
|
||||
"addl $8, %6\n"
|
||||
"addl $8, %2\n"
|
||||
"addl $4, (%%esp)\n"
|
||||
"addl $4, %1\n"
|
||||
"cmpl %4, %6\n"
|
||||
"leal 16(%3), %3\n"
|
||||
"leal 16(%5),%5\n" /* row2+16 */
|
||||
|
||||
"jl 1b\n"
|
||||
"addl %4, %2\n" /* lum += cols */
|
||||
"addl %8, %3\n" /* row1+= mod */
|
||||
"addl %8, %5\n" /* row2+= mod */
|
||||
"movl $0, %6\n" /* x=0 */
|
||||
"cmpl %7, %2\n"
|
||||
"jl 1b\n"
|
||||
"addl $4, %%esp\n" /* get rid of the stack slot we reserved. */
|
||||
"emms\n"
|
||||
:
|
||||
: "m" (cr), "r"(cb),"r"(lum),
|
||||
"r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod),
|
||||
"m"(MMX_0080w),"m"(MMX_Ugrn565),"m"(MMX_Ublu5x5),
|
||||
"m"(MMX_00FFw),"m"(MMX_Vgrn565),"m"(MMX_Vred5x5),
|
||||
"m"(MMX_Ycoeff),"m"(MMX_red565),"m"(MMX_grn565)
|
||||
);
|
||||
}
|
||||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
#endif /* GCC3 i386 inline assembly */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1405
src/render/SDL_yuv_sw.c
Normal file
1405
src/render/SDL_yuv_sw.c
Normal file
File diff suppressed because it is too large
Load Diff
72
src/render/SDL_yuv_sw_c.h
Normal file
72
src/render/SDL_yuv_sw_c.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
#include "SDL_video.h"
|
||||
|
||||
/* This is the software implementation of the YUV texture support */
|
||||
|
||||
struct SDL_SW_YUVTexture
|
||||
{
|
||||
Uint32 format;
|
||||
Uint32 target_format;
|
||||
int w, h;
|
||||
Uint8 *pixels;
|
||||
int *colortab;
|
||||
Uint32 *rgb_2_pix;
|
||||
void (*Display1X) (int *colortab, Uint32 * rgb_2_pix,
|
||||
unsigned char *lum, unsigned char *cr,
|
||||
unsigned char *cb, unsigned char *out,
|
||||
int rows, int cols, int mod);
|
||||
void (*Display2X) (int *colortab, Uint32 * rgb_2_pix,
|
||||
unsigned char *lum, unsigned char *cr,
|
||||
unsigned char *cb, unsigned char *out,
|
||||
int rows, int cols, int mod);
|
||||
|
||||
/* These are just so we don't have to allocate them separately */
|
||||
Uint16 pitches[3];
|
||||
Uint8 *planes[3];
|
||||
|
||||
/* This is a temporary surface in case we have to stretch copy */
|
||||
SDL_Surface *stretch;
|
||||
SDL_Surface *display;
|
||||
};
|
||||
|
||||
typedef struct SDL_SW_YUVTexture SDL_SW_YUVTexture;
|
||||
|
||||
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h);
|
||||
int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels,
|
||||
int *pitch);
|
||||
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const void *pixels, int pitch);
|
||||
int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
const Uint8 *Yplane, int Ypitch,
|
||||
const Uint8 *Uplane, int Upitch,
|
||||
const Uint8 *Vplane, int Vpitch);
|
||||
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
void **pixels, int *pitch);
|
||||
void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata);
|
||||
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
||||
Uint32 target_format, int w, int h, void *pixels,
|
||||
int pitch);
|
||||
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1980
src/render/direct3d/SDL_render_d3d.c
Normal file
1980
src/render/direct3d/SDL_render_d3d.c
Normal file
File diff suppressed because it is too large
Load Diff
2980
src/render/direct3d11/SDL_render_d3d11.c
Normal file
2980
src/render/direct3d11/SDL_render_d3d11.c
Normal file
File diff suppressed because it is too large
Load Diff
116
src/render/direct3d11/SDL_render_winrt.cpp
Normal file
116
src/render/direct3d11/SDL_render_winrt.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_syswm.h"
|
||||
#include "../../video/winrt/SDL_winrtvideo_cpp.h"
|
||||
extern "C" {
|
||||
#include "../SDL_sysrender.h"
|
||||
}
|
||||
|
||||
#include <windows.ui.core.h>
|
||||
#include <windows.graphics.display.h>
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
|
||||
#include <windows.ui.xaml.media.dxinterop.h>
|
||||
#endif
|
||||
|
||||
using namespace Windows::UI::Core;
|
||||
using namespace Windows::Graphics::Display;
|
||||
|
||||
#include <DXGI.h>
|
||||
|
||||
#include "SDL_render_winrt.h"
|
||||
|
||||
|
||||
extern "C" void *
|
||||
D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
SDL_Window * sdlWindow = renderer->window;
|
||||
if ( ! renderer->window ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_SysWMinfo sdlWindowInfo;
|
||||
SDL_VERSION(&sdlWindowInfo.version);
|
||||
if ( ! SDL_GetWindowWMInfo(sdlWindow, &sdlWindowInfo) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sdlWindowInfo.subsystem != SDL_SYSWM_WINRT) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!sdlWindowInfo.info.winrt.window) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ABI::Windows::UI::Core::ICoreWindow *coreWindow = NULL;
|
||||
if (FAILED(sdlWindowInfo.info.winrt.window->QueryInterface(&coreWindow))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IUnknown *coreWindowAsIUnknown = NULL;
|
||||
coreWindow->QueryInterface(&coreWindowAsIUnknown);
|
||||
coreWindow->Release();
|
||||
|
||||
return coreWindowAsIUnknown;
|
||||
}
|
||||
|
||||
extern "C" DXGI_MODE_ROTATION
|
||||
D3D11_GetCurrentRotation()
|
||||
{
|
||||
const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation);
|
||||
|
||||
switch (currentOrientation) {
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
/* Windows Phone rotations */
|
||||
case DisplayOrientations::Landscape:
|
||||
return DXGI_MODE_ROTATION_ROTATE90;
|
||||
case DisplayOrientations::Portrait:
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
case DisplayOrientations::LandscapeFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE270;
|
||||
case DisplayOrientations::PortraitFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE180;
|
||||
#else
|
||||
/* Non-Windows-Phone rotations (ex: Windows 8, Windows RT) */
|
||||
case DisplayOrientations::Landscape:
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
case DisplayOrientations::Portrait:
|
||||
return DXGI_MODE_ROTATION_ROTATE270;
|
||||
case DisplayOrientations::LandscapeFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE180;
|
||||
case DisplayOrientations::PortraitFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE90;
|
||||
#endif /* WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP */
|
||||
}
|
||||
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
40
src/render/direct3d11/SDL_render_winrt.h
Normal file
40
src/render/direct3d11/SDL_render_winrt.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_render.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer);
|
||||
DXGI_MODE_ROTATION D3D11_GetCurrentRotation();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
642
src/render/mmx.h
Normal file
642
src/render/mmx.h
Normal file
@@ -0,0 +1,642 @@
|
||||
/* mmx.h
|
||||
|
||||
MultiMedia eXtensions GCC interface library for IA32.
|
||||
|
||||
To use this library, simply include this header file
|
||||
and compile with GCC. You MUST have inlining enabled
|
||||
in order for mmx_ok() to work; this can be done by
|
||||
simply using -O on the GCC command line.
|
||||
|
||||
Compiling with -DMMX_TRACE will cause detailed trace
|
||||
output to be sent to stderr for each mmx operation.
|
||||
This adds lots of code, and obviously slows execution to
|
||||
a crawl, but can be very useful for debugging.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
|
||||
LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR ANY PARTICULAR PURPOSE.
|
||||
|
||||
1997-99 by H. Dietz and R. Fisher
|
||||
|
||||
Notes:
|
||||
It appears that the latest gas has the pand problem fixed, therefore
|
||||
I'll undefine BROKEN_PAND by default.
|
||||
*/
|
||||
|
||||
#ifndef _MMX_H
|
||||
#define _MMX_H
|
||||
|
||||
|
||||
/* Warning: at this writing, the version of GAS packaged
|
||||
with most Linux distributions does not handle the
|
||||
parallel AND operation mnemonic correctly. If the
|
||||
symbol BROKEN_PAND is defined, a slower alternative
|
||||
coding will be used. If execution of mmxtest results
|
||||
in an illegal instruction fault, define this symbol.
|
||||
*/
|
||||
#undef BROKEN_PAND
|
||||
|
||||
|
||||
/* The type of an value that fits in an MMX register
|
||||
(note that long long constant values MUST be suffixed
|
||||
by LL and unsigned long long values by ULL, lest
|
||||
they be truncated by the compiler)
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
long long q; /* Quadword (64-bit) value */
|
||||
unsigned long long uq; /* Unsigned Quadword */
|
||||
int d[2]; /* 2 Doubleword (32-bit) values */
|
||||
unsigned int ud[2]; /* 2 Unsigned Doubleword */
|
||||
short w[4]; /* 4 Word (16-bit) values */
|
||||
unsigned short uw[4]; /* 4 Unsigned Word */
|
||||
char b[8]; /* 8 Byte (8-bit) values */
|
||||
unsigned char ub[8]; /* 8 Unsigned Byte */
|
||||
float s[2]; /* Single-precision (32-bit) value */
|
||||
} __attribute__ ((aligned(8))) mmx_t; /* On an 8-byte (64-bit) boundary */
|
||||
|
||||
|
||||
#if 0
|
||||
/* Function to test if multimedia instructions are supported...
|
||||
*/
|
||||
inline extern int
|
||||
mm_support(void)
|
||||
{
|
||||
/* Returns 1 if MMX instructions are supported,
|
||||
3 if Cyrix MMX and Extended MMX instructions are supported
|
||||
5 if AMD MMX and 3DNow! instructions are supported
|
||||
0 if hardware does not support any of these
|
||||
*/
|
||||
register int rval = 0;
|
||||
|
||||
__asm__ __volatile__(
|
||||
/* See if CPUID instruction is supported ... */
|
||||
/* ... Get copies of EFLAGS into eax and ecx */
|
||||
"pushf\n\t"
|
||||
"popl %%eax\n\t" "movl %%eax, %%ecx\n\t"
|
||||
/* ... Toggle the ID bit in one copy and store */
|
||||
/* to the EFLAGS reg */
|
||||
"xorl $0x200000, %%eax\n\t"
|
||||
"push %%eax\n\t" "popf\n\t"
|
||||
/* ... Get the (hopefully modified) EFLAGS */
|
||||
"pushf\n\t" "popl %%eax\n\t"
|
||||
/* ... Compare and test result */
|
||||
"xorl %%eax, %%ecx\n\t" "testl $0x200000, %%ecx\n\t" "jz NotSupported1\n\t" /* CPUID not supported */
|
||||
/* Get standard CPUID information, and
|
||||
go to a specific vendor section */
|
||||
"movl $0, %%eax\n\t" "cpuid\n\t"
|
||||
/* Check for Intel */
|
||||
"cmpl $0x756e6547, %%ebx\n\t"
|
||||
"jne TryAMD\n\t"
|
||||
"cmpl $0x49656e69, %%edx\n\t"
|
||||
"jne TryAMD\n\t"
|
||||
"cmpl $0x6c65746e, %%ecx\n"
|
||||
"jne TryAMD\n\t" "jmp Intel\n\t"
|
||||
/* Check for AMD */
|
||||
"\nTryAMD:\n\t"
|
||||
"cmpl $0x68747541, %%ebx\n\t"
|
||||
"jne TryCyrix\n\t"
|
||||
"cmpl $0x69746e65, %%edx\n\t"
|
||||
"jne TryCyrix\n\t"
|
||||
"cmpl $0x444d4163, %%ecx\n"
|
||||
"jne TryCyrix\n\t" "jmp AMD\n\t"
|
||||
/* Check for Cyrix */
|
||||
"\nTryCyrix:\n\t"
|
||||
"cmpl $0x69727943, %%ebx\n\t"
|
||||
"jne NotSupported2\n\t"
|
||||
"cmpl $0x736e4978, %%edx\n\t"
|
||||
"jne NotSupported3\n\t"
|
||||
"cmpl $0x64616574, %%ecx\n\t"
|
||||
"jne NotSupported4\n\t"
|
||||
/* Drop through to Cyrix... */
|
||||
/* Cyrix Section */
|
||||
/* See if extended CPUID level 80000001 is supported */
|
||||
/* The value of CPUID/80000001 for the 6x86MX is undefined
|
||||
according to the Cyrix CPU Detection Guide (Preliminary
|
||||
Rev. 1.01 table 1), so we'll check the value of eax for
|
||||
CPUID/0 to see if standard CPUID level 2 is supported.
|
||||
According to the table, the only CPU which supports level
|
||||
2 is also the only one which supports extended CPUID levels.
|
||||
*/
|
||||
"cmpl $0x2, %%eax\n\t" "jne MMXtest\n\t" /* Use standard CPUID instead */
|
||||
/* Extended CPUID supported (in theory), so get extended
|
||||
features */
|
||||
"movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%eax\n\t" /* Test for MMX */
|
||||
"jz NotSupported5\n\t" /* MMX not supported */
|
||||
"testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */
|
||||
"jnz EMMXSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */
|
||||
"jmp Return\n\n" "EMMXSupported:\n\t" "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */
|
||||
"jmp Return\n\t"
|
||||
/* AMD Section */
|
||||
"AMD:\n\t"
|
||||
/* See if extended CPUID is supported */
|
||||
"movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t" /* Use standard CPUID instead */
|
||||
/* Extended CPUID supported, so get extended features */
|
||||
"movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */
|
||||
"jz NotSupported6\n\t" /* MMX not supported */
|
||||
"testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */
|
||||
"jnz ThreeDNowSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */
|
||||
"jmp Return\n\n" "ThreeDNowSupported:\n\t" "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */
|
||||
"jmp Return\n\t"
|
||||
/* Intel Section */
|
||||
"Intel:\n\t"
|
||||
/* Check for MMX */
|
||||
"MMXtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */
|
||||
"jz NotSupported7\n\t" /* MMX Not supported */
|
||||
"movl $1, %0:\n\n\t" /* MMX Supported */
|
||||
"jmp Return\n\t"
|
||||
/* Nothing supported */
|
||||
"\nNotSupported1:\n\t" "#movl $101, %0:\n\n\t" "\nNotSupported2:\n\t" "#movl $102, %0:\n\n\t" "\nNotSupported3:\n\t" "#movl $103, %0:\n\n\t" "\nNotSupported4:\n\t" "#movl $104, %0:\n\n\t" "\nNotSupported5:\n\t" "#movl $105, %0:\n\n\t" "\nNotSupported6:\n\t" "#movl $106, %0:\n\n\t" "\nNotSupported7:\n\t" "#movl $107, %0:\n\n\t" "movl $0, %0:\n\n\t" "Return:\n\t":"=a"(rval): /* no input */
|
||||
:"eax", "ebx", "ecx", "edx");
|
||||
|
||||
/* Return */
|
||||
return (rval);
|
||||
}
|
||||
|
||||
/* Function to test if mmx instructions are supported...
|
||||
*/
|
||||
inline extern int
|
||||
mmx_ok(void)
|
||||
{
|
||||
/* Returns 1 if MMX instructions are supported, 0 otherwise */
|
||||
return (mm_support() & 0x1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Helper functions for the instruction macros that follow...
|
||||
(note that memory-to-register, m2r, instructions are nearly
|
||||
as efficient as register-to-register, r2r, instructions;
|
||||
however, memory-to-memory instructions are really simulated
|
||||
as a convenience, and are only 1/3 as efficient)
|
||||
*/
|
||||
#ifdef MMX_TRACE
|
||||
|
||||
/* Include the stuff for printing a trace to stderr...
|
||||
*/
|
||||
|
||||
#define mmx_i2r(op, imm, reg) \
|
||||
{ \
|
||||
mmx_t mmx_trace; \
|
||||
mmx_trace.uq = (imm); \
|
||||
printf(#op "_i2r(" #imm "=0x%08x%08x, ", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
__asm__ __volatile__ ("movq %%" #reg ", %0" \
|
||||
: "=X" (mmx_trace) \
|
||||
: /* nothing */ ); \
|
||||
printf(#reg "=0x%08x%08x) => ", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
__asm__ __volatile__ (#op " %0, %%" #reg \
|
||||
: /* nothing */ \
|
||||
: "X" (imm)); \
|
||||
__asm__ __volatile__ ("movq %%" #reg ", %0" \
|
||||
: "=X" (mmx_trace) \
|
||||
: /* nothing */ ); \
|
||||
printf(#reg "=0x%08x%08x\n", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
}
|
||||
|
||||
#define mmx_m2r(op, mem, reg) \
|
||||
{ \
|
||||
mmx_t mmx_trace; \
|
||||
mmx_trace = (mem); \
|
||||
printf(#op "_m2r(" #mem "=0x%08x%08x, ", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
__asm__ __volatile__ ("movq %%" #reg ", %0" \
|
||||
: "=X" (mmx_trace) \
|
||||
: /* nothing */ ); \
|
||||
printf(#reg "=0x%08x%08x) => ", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
__asm__ __volatile__ (#op " %0, %%" #reg \
|
||||
: /* nothing */ \
|
||||
: "X" (mem)); \
|
||||
__asm__ __volatile__ ("movq %%" #reg ", %0" \
|
||||
: "=X" (mmx_trace) \
|
||||
: /* nothing */ ); \
|
||||
printf(#reg "=0x%08x%08x\n", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
}
|
||||
|
||||
#define mmx_r2m(op, reg, mem) \
|
||||
{ \
|
||||
mmx_t mmx_trace; \
|
||||
__asm__ __volatile__ ("movq %%" #reg ", %0" \
|
||||
: "=X" (mmx_trace) \
|
||||
: /* nothing */ ); \
|
||||
printf(#op "_r2m(" #reg "=0x%08x%08x, ", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
mmx_trace = (mem); \
|
||||
printf(#mem "=0x%08x%08x) => ", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
__asm__ __volatile__ (#op " %%" #reg ", %0" \
|
||||
: "=X" (mem) \
|
||||
: /* nothing */ ); \
|
||||
mmx_trace = (mem); \
|
||||
printf(#mem "=0x%08x%08x\n", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
}
|
||||
|
||||
#define mmx_r2r(op, regs, regd) \
|
||||
{ \
|
||||
mmx_t mmx_trace; \
|
||||
__asm__ __volatile__ ("movq %%" #regs ", %0" \
|
||||
: "=X" (mmx_trace) \
|
||||
: /* nothing */ ); \
|
||||
printf(#op "_r2r(" #regs "=0x%08x%08x, ", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
__asm__ __volatile__ ("movq %%" #regd ", %0" \
|
||||
: "=X" (mmx_trace) \
|
||||
: /* nothing */ ); \
|
||||
printf(#regd "=0x%08x%08x) => ", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
__asm__ __volatile__ (#op " %" #regs ", %" #regd); \
|
||||
__asm__ __volatile__ ("movq %%" #regd ", %0" \
|
||||
: "=X" (mmx_trace) \
|
||||
: /* nothing */ ); \
|
||||
printf(#regd "=0x%08x%08x\n", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
}
|
||||
|
||||
#define mmx_m2m(op, mems, memd) \
|
||||
{ \
|
||||
mmx_t mmx_trace; \
|
||||
mmx_trace = (mems); \
|
||||
printf(#op "_m2m(" #mems "=0x%08x%08x, ", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
mmx_trace = (memd); \
|
||||
printf(#memd "=0x%08x%08x) => ", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
__asm__ __volatile__ ("movq %0, %%mm0\n\t" \
|
||||
#op " %1, %%mm0\n\t" \
|
||||
"movq %%mm0, %0" \
|
||||
: "=X" (memd) \
|
||||
: "X" (mems)); \
|
||||
mmx_trace = (memd); \
|
||||
printf(#memd "=0x%08x%08x\n", \
|
||||
mmx_trace.d[1], mmx_trace.d[0]); \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* These macros are a lot simpler without the tracing...
|
||||
*/
|
||||
|
||||
#define mmx_i2r(op, imm, reg) \
|
||||
__asm__ __volatile__ (#op " %0, %%" #reg \
|
||||
: /* nothing */ \
|
||||
: "X" (imm) )
|
||||
|
||||
#define mmx_m2r(op, mem, reg) \
|
||||
__asm__ __volatile__ (#op " %0, %%" #reg \
|
||||
: /* nothing */ \
|
||||
: "m" (mem))
|
||||
|
||||
#define mmx_r2m(op, reg, mem) \
|
||||
__asm__ __volatile__ (#op " %%" #reg ", %0" \
|
||||
: "=m" (mem) \
|
||||
: /* nothing */ )
|
||||
|
||||
#define mmx_r2r(op, regs, regd) \
|
||||
__asm__ __volatile__ (#op " %" #regs ", %" #regd)
|
||||
|
||||
#define mmx_m2m(op, mems, memd) \
|
||||
__asm__ __volatile__ ("movq %0, %%mm0\n\t" \
|
||||
#op " %1, %%mm0\n\t" \
|
||||
"movq %%mm0, %0" \
|
||||
: "=X" (memd) \
|
||||
: "X" (mems))
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* 1x64 MOVe Quadword
|
||||
(this is both a load and a store...
|
||||
in fact, it is the only way to store)
|
||||
*/
|
||||
#define movq_m2r(var, reg) mmx_m2r(movq, var, reg)
|
||||
#define movq_r2m(reg, var) mmx_r2m(movq, reg, var)
|
||||
#define movq_r2r(regs, regd) mmx_r2r(movq, regs, regd)
|
||||
#define movq(vars, vard) \
|
||||
__asm__ __volatile__ ("movq %1, %%mm0\n\t" \
|
||||
"movq %%mm0, %0" \
|
||||
: "=X" (vard) \
|
||||
: "X" (vars))
|
||||
|
||||
|
||||
/* 1x32 MOVe Doubleword
|
||||
(like movq, this is both load and store...
|
||||
but is most useful for moving things between
|
||||
mmx registers and ordinary registers)
|
||||
*/
|
||||
#define movd_m2r(var, reg) mmx_m2r(movd, var, reg)
|
||||
#define movd_r2m(reg, var) mmx_r2m(movd, reg, var)
|
||||
#define movd_r2r(regs, regd) mmx_r2r(movd, regs, regd)
|
||||
#define movd(vars, vard) \
|
||||
__asm__ __volatile__ ("movd %1, %%mm0\n\t" \
|
||||
"movd %%mm0, %0" \
|
||||
: "=X" (vard) \
|
||||
: "X" (vars))
|
||||
|
||||
|
||||
/* 2x32, 4x16, and 8x8 Parallel ADDs
|
||||
*/
|
||||
#define paddd_m2r(var, reg) mmx_m2r(paddd, var, reg)
|
||||
#define paddd_r2r(regs, regd) mmx_r2r(paddd, regs, regd)
|
||||
#define paddd(vars, vard) mmx_m2m(paddd, vars, vard)
|
||||
|
||||
#define paddw_m2r(var, reg) mmx_m2r(paddw, var, reg)
|
||||
#define paddw_r2r(regs, regd) mmx_r2r(paddw, regs, regd)
|
||||
#define paddw(vars, vard) mmx_m2m(paddw, vars, vard)
|
||||
|
||||
#define paddb_m2r(var, reg) mmx_m2r(paddb, var, reg)
|
||||
#define paddb_r2r(regs, regd) mmx_r2r(paddb, regs, regd)
|
||||
#define paddb(vars, vard) mmx_m2m(paddb, vars, vard)
|
||||
|
||||
|
||||
/* 4x16 and 8x8 Parallel ADDs using Saturation arithmetic
|
||||
*/
|
||||
#define paddsw_m2r(var, reg) mmx_m2r(paddsw, var, reg)
|
||||
#define paddsw_r2r(regs, regd) mmx_r2r(paddsw, regs, regd)
|
||||
#define paddsw(vars, vard) mmx_m2m(paddsw, vars, vard)
|
||||
|
||||
#define paddsb_m2r(var, reg) mmx_m2r(paddsb, var, reg)
|
||||
#define paddsb_r2r(regs, regd) mmx_r2r(paddsb, regs, regd)
|
||||
#define paddsb(vars, vard) mmx_m2m(paddsb, vars, vard)
|
||||
|
||||
|
||||
/* 4x16 and 8x8 Parallel ADDs using Unsigned Saturation arithmetic
|
||||
*/
|
||||
#define paddusw_m2r(var, reg) mmx_m2r(paddusw, var, reg)
|
||||
#define paddusw_r2r(regs, regd) mmx_r2r(paddusw, regs, regd)
|
||||
#define paddusw(vars, vard) mmx_m2m(paddusw, vars, vard)
|
||||
|
||||
#define paddusb_m2r(var, reg) mmx_m2r(paddusb, var, reg)
|
||||
#define paddusb_r2r(regs, regd) mmx_r2r(paddusb, regs, regd)
|
||||
#define paddusb(vars, vard) mmx_m2m(paddusb, vars, vard)
|
||||
|
||||
|
||||
/* 2x32, 4x16, and 8x8 Parallel SUBs
|
||||
*/
|
||||
#define psubd_m2r(var, reg) mmx_m2r(psubd, var, reg)
|
||||
#define psubd_r2r(regs, regd) mmx_r2r(psubd, regs, regd)
|
||||
#define psubd(vars, vard) mmx_m2m(psubd, vars, vard)
|
||||
|
||||
#define psubw_m2r(var, reg) mmx_m2r(psubw, var, reg)
|
||||
#define psubw_r2r(regs, regd) mmx_r2r(psubw, regs, regd)
|
||||
#define psubw(vars, vard) mmx_m2m(psubw, vars, vard)
|
||||
|
||||
#define psubb_m2r(var, reg) mmx_m2r(psubb, var, reg)
|
||||
#define psubb_r2r(regs, regd) mmx_r2r(psubb, regs, regd)
|
||||
#define psubb(vars, vard) mmx_m2m(psubb, vars, vard)
|
||||
|
||||
|
||||
/* 4x16 and 8x8 Parallel SUBs using Saturation arithmetic
|
||||
*/
|
||||
#define psubsw_m2r(var, reg) mmx_m2r(psubsw, var, reg)
|
||||
#define psubsw_r2r(regs, regd) mmx_r2r(psubsw, regs, regd)
|
||||
#define psubsw(vars, vard) mmx_m2m(psubsw, vars, vard)
|
||||
|
||||
#define psubsb_m2r(var, reg) mmx_m2r(psubsb, var, reg)
|
||||
#define psubsb_r2r(regs, regd) mmx_r2r(psubsb, regs, regd)
|
||||
#define psubsb(vars, vard) mmx_m2m(psubsb, vars, vard)
|
||||
|
||||
|
||||
/* 4x16 and 8x8 Parallel SUBs using Unsigned Saturation arithmetic
|
||||
*/
|
||||
#define psubusw_m2r(var, reg) mmx_m2r(psubusw, var, reg)
|
||||
#define psubusw_r2r(regs, regd) mmx_r2r(psubusw, regs, regd)
|
||||
#define psubusw(vars, vard) mmx_m2m(psubusw, vars, vard)
|
||||
|
||||
#define psubusb_m2r(var, reg) mmx_m2r(psubusb, var, reg)
|
||||
#define psubusb_r2r(regs, regd) mmx_r2r(psubusb, regs, regd)
|
||||
#define psubusb(vars, vard) mmx_m2m(psubusb, vars, vard)
|
||||
|
||||
|
||||
/* 4x16 Parallel MULs giving Low 4x16 portions of results
|
||||
*/
|
||||
#define pmullw_m2r(var, reg) mmx_m2r(pmullw, var, reg)
|
||||
#define pmullw_r2r(regs, regd) mmx_r2r(pmullw, regs, regd)
|
||||
#define pmullw(vars, vard) mmx_m2m(pmullw, vars, vard)
|
||||
|
||||
|
||||
/* 4x16 Parallel MULs giving High 4x16 portions of results
|
||||
*/
|
||||
#define pmulhw_m2r(var, reg) mmx_m2r(pmulhw, var, reg)
|
||||
#define pmulhw_r2r(regs, regd) mmx_r2r(pmulhw, regs, regd)
|
||||
#define pmulhw(vars, vard) mmx_m2m(pmulhw, vars, vard)
|
||||
|
||||
|
||||
/* 4x16->2x32 Parallel Mul-ADD
|
||||
(muls like pmullw, then adds adjacent 16-bit fields
|
||||
in the multiply result to make the final 2x32 result)
|
||||
*/
|
||||
#define pmaddwd_m2r(var, reg) mmx_m2r(pmaddwd, var, reg)
|
||||
#define pmaddwd_r2r(regs, regd) mmx_r2r(pmaddwd, regs, regd)
|
||||
#define pmaddwd(vars, vard) mmx_m2m(pmaddwd, vars, vard)
|
||||
|
||||
|
||||
/* 1x64 bitwise AND
|
||||
*/
|
||||
#ifdef BROKEN_PAND
|
||||
#define pand_m2r(var, reg) \
|
||||
{ \
|
||||
mmx_m2r(pandn, (mmx_t) -1LL, reg); \
|
||||
mmx_m2r(pandn, var, reg); \
|
||||
}
|
||||
#define pand_r2r(regs, regd) \
|
||||
{ \
|
||||
mmx_m2r(pandn, (mmx_t) -1LL, regd); \
|
||||
mmx_r2r(pandn, regs, regd) \
|
||||
}
|
||||
#define pand(vars, vard) \
|
||||
{ \
|
||||
movq_m2r(vard, mm0); \
|
||||
mmx_m2r(pandn, (mmx_t) -1LL, mm0); \
|
||||
mmx_m2r(pandn, vars, mm0); \
|
||||
movq_r2m(mm0, vard); \
|
||||
}
|
||||
#else
|
||||
#define pand_m2r(var, reg) mmx_m2r(pand, var, reg)
|
||||
#define pand_r2r(regs, regd) mmx_r2r(pand, regs, regd)
|
||||
#define pand(vars, vard) mmx_m2m(pand, vars, vard)
|
||||
#endif
|
||||
|
||||
|
||||
/* 1x64 bitwise AND with Not the destination
|
||||
*/
|
||||
#define pandn_m2r(var, reg) mmx_m2r(pandn, var, reg)
|
||||
#define pandn_r2r(regs, regd) mmx_r2r(pandn, regs, regd)
|
||||
#define pandn(vars, vard) mmx_m2m(pandn, vars, vard)
|
||||
|
||||
|
||||
/* 1x64 bitwise OR
|
||||
*/
|
||||
#define por_m2r(var, reg) mmx_m2r(por, var, reg)
|
||||
#define por_r2r(regs, regd) mmx_r2r(por, regs, regd)
|
||||
#define por(vars, vard) mmx_m2m(por, vars, vard)
|
||||
|
||||
|
||||
/* 1x64 bitwise eXclusive OR
|
||||
*/
|
||||
#define pxor_m2r(var, reg) mmx_m2r(pxor, var, reg)
|
||||
#define pxor_r2r(regs, regd) mmx_r2r(pxor, regs, regd)
|
||||
#define pxor(vars, vard) mmx_m2m(pxor, vars, vard)
|
||||
|
||||
|
||||
/* 2x32, 4x16, and 8x8 Parallel CoMPare for EQuality
|
||||
(resulting fields are either 0 or -1)
|
||||
*/
|
||||
#define pcmpeqd_m2r(var, reg) mmx_m2r(pcmpeqd, var, reg)
|
||||
#define pcmpeqd_r2r(regs, regd) mmx_r2r(pcmpeqd, regs, regd)
|
||||
#define pcmpeqd(vars, vard) mmx_m2m(pcmpeqd, vars, vard)
|
||||
|
||||
#define pcmpeqw_m2r(var, reg) mmx_m2r(pcmpeqw, var, reg)
|
||||
#define pcmpeqw_r2r(regs, regd) mmx_r2r(pcmpeqw, regs, regd)
|
||||
#define pcmpeqw(vars, vard) mmx_m2m(pcmpeqw, vars, vard)
|
||||
|
||||
#define pcmpeqb_m2r(var, reg) mmx_m2r(pcmpeqb, var, reg)
|
||||
#define pcmpeqb_r2r(regs, regd) mmx_r2r(pcmpeqb, regs, regd)
|
||||
#define pcmpeqb(vars, vard) mmx_m2m(pcmpeqb, vars, vard)
|
||||
|
||||
|
||||
/* 2x32, 4x16, and 8x8 Parallel CoMPare for Greater Than
|
||||
(resulting fields are either 0 or -1)
|
||||
*/
|
||||
#define pcmpgtd_m2r(var, reg) mmx_m2r(pcmpgtd, var, reg)
|
||||
#define pcmpgtd_r2r(regs, regd) mmx_r2r(pcmpgtd, regs, regd)
|
||||
#define pcmpgtd(vars, vard) mmx_m2m(pcmpgtd, vars, vard)
|
||||
|
||||
#define pcmpgtw_m2r(var, reg) mmx_m2r(pcmpgtw, var, reg)
|
||||
#define pcmpgtw_r2r(regs, regd) mmx_r2r(pcmpgtw, regs, regd)
|
||||
#define pcmpgtw(vars, vard) mmx_m2m(pcmpgtw, vars, vard)
|
||||
|
||||
#define pcmpgtb_m2r(var, reg) mmx_m2r(pcmpgtb, var, reg)
|
||||
#define pcmpgtb_r2r(regs, regd) mmx_r2r(pcmpgtb, regs, regd)
|
||||
#define pcmpgtb(vars, vard) mmx_m2m(pcmpgtb, vars, vard)
|
||||
|
||||
|
||||
/* 1x64, 2x32, and 4x16 Parallel Shift Left Logical
|
||||
*/
|
||||
#define psllq_i2r(imm, reg) mmx_i2r(psllq, imm, reg)
|
||||
#define psllq_m2r(var, reg) mmx_m2r(psllq, var, reg)
|
||||
#define psllq_r2r(regs, regd) mmx_r2r(psllq, regs, regd)
|
||||
#define psllq(vars, vard) mmx_m2m(psllq, vars, vard)
|
||||
|
||||
#define pslld_i2r(imm, reg) mmx_i2r(pslld, imm, reg)
|
||||
#define pslld_m2r(var, reg) mmx_m2r(pslld, var, reg)
|
||||
#define pslld_r2r(regs, regd) mmx_r2r(pslld, regs, regd)
|
||||
#define pslld(vars, vard) mmx_m2m(pslld, vars, vard)
|
||||
|
||||
#define psllw_i2r(imm, reg) mmx_i2r(psllw, imm, reg)
|
||||
#define psllw_m2r(var, reg) mmx_m2r(psllw, var, reg)
|
||||
#define psllw_r2r(regs, regd) mmx_r2r(psllw, regs, regd)
|
||||
#define psllw(vars, vard) mmx_m2m(psllw, vars, vard)
|
||||
|
||||
|
||||
/* 1x64, 2x32, and 4x16 Parallel Shift Right Logical
|
||||
*/
|
||||
#define psrlq_i2r(imm, reg) mmx_i2r(psrlq, imm, reg)
|
||||
#define psrlq_m2r(var, reg) mmx_m2r(psrlq, var, reg)
|
||||
#define psrlq_r2r(regs, regd) mmx_r2r(psrlq, regs, regd)
|
||||
#define psrlq(vars, vard) mmx_m2m(psrlq, vars, vard)
|
||||
|
||||
#define psrld_i2r(imm, reg) mmx_i2r(psrld, imm, reg)
|
||||
#define psrld_m2r(var, reg) mmx_m2r(psrld, var, reg)
|
||||
#define psrld_r2r(regs, regd) mmx_r2r(psrld, regs, regd)
|
||||
#define psrld(vars, vard) mmx_m2m(psrld, vars, vard)
|
||||
|
||||
#define psrlw_i2r(imm, reg) mmx_i2r(psrlw, imm, reg)
|
||||
#define psrlw_m2r(var, reg) mmx_m2r(psrlw, var, reg)
|
||||
#define psrlw_r2r(regs, regd) mmx_r2r(psrlw, regs, regd)
|
||||
#define psrlw(vars, vard) mmx_m2m(psrlw, vars, vard)
|
||||
|
||||
|
||||
/* 2x32 and 4x16 Parallel Shift Right Arithmetic
|
||||
*/
|
||||
#define psrad_i2r(imm, reg) mmx_i2r(psrad, imm, reg)
|
||||
#define psrad_m2r(var, reg) mmx_m2r(psrad, var, reg)
|
||||
#define psrad_r2r(regs, regd) mmx_r2r(psrad, regs, regd)
|
||||
#define psrad(vars, vard) mmx_m2m(psrad, vars, vard)
|
||||
|
||||
#define psraw_i2r(imm, reg) mmx_i2r(psraw, imm, reg)
|
||||
#define psraw_m2r(var, reg) mmx_m2r(psraw, var, reg)
|
||||
#define psraw_r2r(regs, regd) mmx_r2r(psraw, regs, regd)
|
||||
#define psraw(vars, vard) mmx_m2m(psraw, vars, vard)
|
||||
|
||||
|
||||
/* 2x32->4x16 and 4x16->8x8 PACK and Signed Saturate
|
||||
(packs source and dest fields into dest in that order)
|
||||
*/
|
||||
#define packssdw_m2r(var, reg) mmx_m2r(packssdw, var, reg)
|
||||
#define packssdw_r2r(regs, regd) mmx_r2r(packssdw, regs, regd)
|
||||
#define packssdw(vars, vard) mmx_m2m(packssdw, vars, vard)
|
||||
|
||||
#define packsswb_m2r(var, reg) mmx_m2r(packsswb, var, reg)
|
||||
#define packsswb_r2r(regs, regd) mmx_r2r(packsswb, regs, regd)
|
||||
#define packsswb(vars, vard) mmx_m2m(packsswb, vars, vard)
|
||||
|
||||
|
||||
/* 4x16->8x8 PACK and Unsigned Saturate
|
||||
(packs source and dest fields into dest in that order)
|
||||
*/
|
||||
#define packuswb_m2r(var, reg) mmx_m2r(packuswb, var, reg)
|
||||
#define packuswb_r2r(regs, regd) mmx_r2r(packuswb, regs, regd)
|
||||
#define packuswb(vars, vard) mmx_m2m(packuswb, vars, vard)
|
||||
|
||||
|
||||
/* 2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK Low
|
||||
(interleaves low half of dest with low half of source
|
||||
as padding in each result field)
|
||||
*/
|
||||
#define punpckldq_m2r(var, reg) mmx_m2r(punpckldq, var, reg)
|
||||
#define punpckldq_r2r(regs, regd) mmx_r2r(punpckldq, regs, regd)
|
||||
#define punpckldq(vars, vard) mmx_m2m(punpckldq, vars, vard)
|
||||
|
||||
#define punpcklwd_m2r(var, reg) mmx_m2r(punpcklwd, var, reg)
|
||||
#define punpcklwd_r2r(regs, regd) mmx_r2r(punpcklwd, regs, regd)
|
||||
#define punpcklwd(vars, vard) mmx_m2m(punpcklwd, vars, vard)
|
||||
|
||||
#define punpcklbw_m2r(var, reg) mmx_m2r(punpcklbw, var, reg)
|
||||
#define punpcklbw_r2r(regs, regd) mmx_r2r(punpcklbw, regs, regd)
|
||||
#define punpcklbw(vars, vard) mmx_m2m(punpcklbw, vars, vard)
|
||||
|
||||
|
||||
/* 2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK High
|
||||
(interleaves high half of dest with high half of source
|
||||
as padding in each result field)
|
||||
*/
|
||||
#define punpckhdq_m2r(var, reg) mmx_m2r(punpckhdq, var, reg)
|
||||
#define punpckhdq_r2r(regs, regd) mmx_r2r(punpckhdq, regs, regd)
|
||||
#define punpckhdq(vars, vard) mmx_m2m(punpckhdq, vars, vard)
|
||||
|
||||
#define punpckhwd_m2r(var, reg) mmx_m2r(punpckhwd, var, reg)
|
||||
#define punpckhwd_r2r(regs, regd) mmx_r2r(punpckhwd, regs, regd)
|
||||
#define punpckhwd(vars, vard) mmx_m2m(punpckhwd, vars, vard)
|
||||
|
||||
#define punpckhbw_m2r(var, reg) mmx_m2r(punpckhbw, var, reg)
|
||||
#define punpckhbw_r2r(regs, regd) mmx_r2r(punpckhbw, regs, regd)
|
||||
#define punpckhbw(vars, vard) mmx_m2m(punpckhbw, vars, vard)
|
||||
|
||||
|
||||
/* Empty MMx State
|
||||
(used to clean-up when going from mmx to float use
|
||||
of the registers that are shared by both; note that
|
||||
there is no float-to-mmx operation needed, because
|
||||
only the float tag word info is corruptible)
|
||||
*/
|
||||
#ifdef MMX_TRACE
|
||||
|
||||
#define emms() \
|
||||
{ \
|
||||
printf("emms()\n"); \
|
||||
__asm__ __volatile__ ("emms"); \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define emms() __asm__ __volatile__ ("emms")
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
477
src/render/opengl/SDL_glfuncs.h
Normal file
477
src/render/opengl/SDL_glfuncs.h
Normal file
@@ -0,0 +1,477 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* list of OpenGL functions sorted alphabetically
|
||||
If you need to use a GL function from the SDL video subsystem,
|
||||
change its entry from SDL_PROC_UNUSED to SDL_PROC and rebuild.
|
||||
*/
|
||||
#define SDL_PROC_UNUSED(ret,func,params)
|
||||
|
||||
SDL_PROC_UNUSED(void, glAccum, (GLenum, GLfloat))
|
||||
SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum, GLclampf))
|
||||
SDL_PROC_UNUSED(GLboolean, glAreTexturesResident,
|
||||
(GLsizei, const GLuint *, GLboolean *))
|
||||
SDL_PROC_UNUSED(void, glArrayElement, (GLint))
|
||||
SDL_PROC(void, glBegin, (GLenum))
|
||||
SDL_PROC(void, glBindTexture, (GLenum, GLuint))
|
||||
SDL_PROC_UNUSED(void, glBitmap,
|
||||
(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat,
|
||||
const GLubyte *))
|
||||
SDL_PROC(void, glBlendFunc, (GLenum, GLenum))
|
||||
SDL_PROC(void, glBlendFuncSeparate, (GLenum, GLenum, GLenum, GLenum))
|
||||
SDL_PROC_UNUSED(void, glCallList, (GLuint))
|
||||
SDL_PROC_UNUSED(void, glCallLists, (GLsizei, GLenum, const GLvoid *))
|
||||
SDL_PROC(void, glClear, (GLbitfield))
|
||||
SDL_PROC_UNUSED(void, glClearAccum, (GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
|
||||
SDL_PROC_UNUSED(void, glClearDepth, (GLclampd))
|
||||
SDL_PROC_UNUSED(void, glClearIndex, (GLfloat))
|
||||
SDL_PROC_UNUSED(void, glClearStencil, (GLint))
|
||||
SDL_PROC_UNUSED(void, glClipPlane, (GLenum, const GLdouble *))
|
||||
SDL_PROC_UNUSED(void, glColor3b, (GLbyte, GLbyte, GLbyte))
|
||||
SDL_PROC_UNUSED(void, glColor3bv, (const GLbyte *))
|
||||
SDL_PROC_UNUSED(void, glColor3d, (GLdouble, GLdouble, GLdouble))
|
||||
SDL_PROC_UNUSED(void, glColor3dv, (const GLdouble *))
|
||||
SDL_PROC_UNUSED(void, glColor3f, (GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glColor3fv, (const GLfloat *))
|
||||
SDL_PROC_UNUSED(void, glColor3i, (GLint, GLint, GLint))
|
||||
SDL_PROC_UNUSED(void, glColor3iv, (const GLint *))
|
||||
SDL_PROC_UNUSED(void, glColor3s, (GLshort, GLshort, GLshort))
|
||||
SDL_PROC_UNUSED(void, glColor3sv, (const GLshort *))
|
||||
SDL_PROC_UNUSED(void, glColor3ub, (GLubyte, GLubyte, GLubyte))
|
||||
SDL_PROC_UNUSED(void, glColor3ubv, (const GLubyte *))
|
||||
SDL_PROC_UNUSED(void, glColor3ui, (GLuint, GLuint, GLuint))
|
||||
SDL_PROC_UNUSED(void, glColor3uiv, (const GLuint *))
|
||||
SDL_PROC_UNUSED(void, glColor3us, (GLushort, GLushort, GLushort))
|
||||
SDL_PROC_UNUSED(void, glColor3usv, (const GLushort *))
|
||||
SDL_PROC_UNUSED(void, glColor4b, (GLbyte, GLbyte, GLbyte, GLbyte))
|
||||
SDL_PROC_UNUSED(void, glColor4bv, (const GLbyte *))
|
||||
SDL_PROC_UNUSED(void, glColor4d, (GLdouble, GLdouble, GLdouble, GLdouble))
|
||||
SDL_PROC_UNUSED(void, glColor4dv, (const GLdouble *))
|
||||
SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC_UNUSED(void, glColor4fv, (const GLfloat *))
|
||||
SDL_PROC_UNUSED(void, glColor4i, (GLint, GLint, GLint, GLint))
|
||||
SDL_PROC_UNUSED(void, glColor4iv, (const GLint *))
|
||||
SDL_PROC_UNUSED(void, glColor4s, (GLshort, GLshort, GLshort, GLshort))
|
||||
SDL_PROC_UNUSED(void, glColor4sv, (const GLshort *))
|
||||
SDL_PROC_UNUSED(void, glColor4ub,
|
||||
(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
|
||||
SDL_PROC_UNUSED(void, glColor4ubv, (const GLubyte * v))
|
||||
SDL_PROC_UNUSED(void, glColor4ui,
|
||||
(GLuint red, GLuint green, GLuint blue, GLuint alpha))
|
||||
SDL_PROC_UNUSED(void, glColor4uiv, (const GLuint * v))
|
||||
SDL_PROC_UNUSED(void, glColor4us,
|
||||
(GLushort red, GLushort green, GLushort blue, GLushort alpha))
|
||||
SDL_PROC_UNUSED(void, glColor4usv, (const GLushort * v))
|
||||
SDL_PROC_UNUSED(void, glColorMask,
|
||||
(GLboolean red, GLboolean green, GLboolean blue,
|
||||
GLboolean alpha))
|
||||
SDL_PROC_UNUSED(void, glColorMaterial, (GLenum face, GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glColorPointer,
|
||||
(GLint size, GLenum type, GLsizei stride,
|
||||
const GLvoid * pointer))
|
||||
SDL_PROC_UNUSED(void, glCopyPixels,
|
||||
(GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLenum type))
|
||||
SDL_PROC_UNUSED(void, glCopyTexImage1D,
|
||||
(GLenum target, GLint level, GLenum internalFormat, GLint x,
|
||||
GLint y, GLsizei width, GLint border))
|
||||
SDL_PROC_UNUSED(void, glCopyTexImage2D,
|
||||
(GLenum target, GLint level, GLenum internalFormat, GLint x,
|
||||
GLint y, GLsizei width, GLsizei height, GLint border))
|
||||
SDL_PROC_UNUSED(void, glCopyTexSubImage1D,
|
||||
(GLenum target, GLint level, GLint xoffset, GLint x, GLint y,
|
||||
GLsizei width))
|
||||
SDL_PROC_UNUSED(void, glCopyTexSubImage2D,
|
||||
(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height))
|
||||
SDL_PROC_UNUSED(void, glCullFace, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glDeleteLists, (GLuint list, GLsizei range))
|
||||
SDL_PROC(void, glDeleteTextures, (GLsizei n, const GLuint * textures))
|
||||
SDL_PROC(void, glDepthFunc, (GLenum func))
|
||||
SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag))
|
||||
SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar))
|
||||
SDL_PROC(void, glDisable, (GLenum cap))
|
||||
SDL_PROC_UNUSED(void, glDisableClientState, (GLenum array))
|
||||
SDL_PROC_UNUSED(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count))
|
||||
SDL_PROC_UNUSED(void, glDrawBuffer, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glDrawElements,
|
||||
(GLenum mode, GLsizei count, GLenum type,
|
||||
const GLvoid * indices))
|
||||
SDL_PROC(void, glDrawPixels,
|
||||
(GLsizei width, GLsizei height, GLenum format, GLenum type,
|
||||
const GLvoid * pixels))
|
||||
SDL_PROC_UNUSED(void, glEdgeFlag, (GLboolean flag))
|
||||
SDL_PROC_UNUSED(void, glEdgeFlagPointer,
|
||||
(GLsizei stride, const GLvoid * pointer))
|
||||
SDL_PROC_UNUSED(void, glEdgeFlagv, (const GLboolean * flag))
|
||||
SDL_PROC(void, glEnable, (GLenum cap))
|
||||
SDL_PROC_UNUSED(void, glEnableClientState, (GLenum array))
|
||||
SDL_PROC(void, glEnd, (void))
|
||||
SDL_PROC_UNUSED(void, glEndList, (void))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1d, (GLdouble u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1dv, (const GLdouble * u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1f, (GLfloat u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord1fv, (const GLfloat * u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2d, (GLdouble u, GLdouble v))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2dv, (const GLdouble * u))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2f, (GLfloat u, GLfloat v))
|
||||
SDL_PROC_UNUSED(void, glEvalCoord2fv, (const GLfloat * u))
|
||||
SDL_PROC_UNUSED(void, glEvalMesh1, (GLenum mode, GLint i1, GLint i2))
|
||||
SDL_PROC_UNUSED(void, glEvalMesh2,
|
||||
(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2))
|
||||
SDL_PROC_UNUSED(void, glEvalPoint1, (GLint i))
|
||||
SDL_PROC_UNUSED(void, glEvalPoint2, (GLint i, GLint j))
|
||||
SDL_PROC_UNUSED(void, glFeedbackBuffer,
|
||||
(GLsizei size, GLenum type, GLfloat * buffer))
|
||||
SDL_PROC_UNUSED(void, glFinish, (void))
|
||||
SDL_PROC_UNUSED(void, glFlush, (void))
|
||||
SDL_PROC_UNUSED(void, glFogf, (GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glFogi, (GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glFogiv, (GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glFrontFace, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glFrustum,
|
||||
(GLdouble left, GLdouble right, GLdouble bottom,
|
||||
GLdouble top, GLdouble zNear, GLdouble zFar))
|
||||
SDL_PROC_UNUSED(GLuint, glGenLists, (GLsizei range))
|
||||
SDL_PROC(void, glGenTextures, (GLsizei n, GLuint * textures))
|
||||
SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean * params))
|
||||
SDL_PROC_UNUSED(void, glGetClipPlane, (GLenum plane, GLdouble * equation))
|
||||
SDL_PROC_UNUSED(void, glGetDoublev, (GLenum pname, GLdouble * params))
|
||||
SDL_PROC(GLenum, glGetError, (void))
|
||||
SDL_PROC_UNUSED(void, glGetFloatv, (GLenum pname, GLfloat * params))
|
||||
SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetLightfv,
|
||||
(GLenum light, GLenum pname, GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glGetLightiv,
|
||||
(GLenum light, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetMapdv, (GLenum target, GLenum query, GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glGetMapfv, (GLenum target, GLenum query, GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glGetMapiv, (GLenum target, GLenum query, GLint * v))
|
||||
SDL_PROC_UNUSED(void, glGetMaterialfv,
|
||||
(GLenum face, GLenum pname, GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glGetMaterialiv,
|
||||
(GLenum face, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetPixelMapfv, (GLenum map, GLfloat * values))
|
||||
SDL_PROC_UNUSED(void, glGetPixelMapuiv, (GLenum map, GLuint * values))
|
||||
SDL_PROC_UNUSED(void, glGetPixelMapusv, (GLenum map, GLushort * values))
|
||||
SDL_PROC(void, glGetPointerv, (GLenum pname, GLvoid * *params))
|
||||
SDL_PROC_UNUSED(void, glGetPolygonStipple, (GLubyte * mask))
|
||||
SDL_PROC(const GLubyte *, glGetString, (GLenum name))
|
||||
SDL_PROC_UNUSED(void, glGetTexEnvfv,
|
||||
(GLenum target, GLenum pname, GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexEnviv,
|
||||
(GLenum target, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexGendv,
|
||||
(GLenum coord, GLenum pname, GLdouble * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexGenfv,
|
||||
(GLenum coord, GLenum pname, GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexGeniv,
|
||||
(GLenum coord, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexImage,
|
||||
(GLenum target, GLint level, GLenum format, GLenum type,
|
||||
GLvoid * pixels))
|
||||
SDL_PROC_UNUSED(void, glGetTexLevelParameterfv,
|
||||
(GLenum target, GLint level, GLenum pname, GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexLevelParameteriv,
|
||||
(GLenum target, GLint level, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexParameterfv,
|
||||
(GLenum target, GLenum pname, GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glGetTexParameteriv,
|
||||
(GLenum target, GLenum pname, GLint * params))
|
||||
SDL_PROC_UNUSED(void, glHint, (GLenum target, GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glIndexMask, (GLuint mask))
|
||||
SDL_PROC_UNUSED(void, glIndexPointer,
|
||||
(GLenum type, GLsizei stride, const GLvoid * pointer))
|
||||
SDL_PROC_UNUSED(void, glIndexd, (GLdouble c))
|
||||
SDL_PROC_UNUSED(void, glIndexdv, (const GLdouble * c))
|
||||
SDL_PROC_UNUSED(void, glIndexf, (GLfloat c))
|
||||
SDL_PROC_UNUSED(void, glIndexfv, (const GLfloat * c))
|
||||
SDL_PROC_UNUSED(void, glIndexi, (GLint c))
|
||||
SDL_PROC_UNUSED(void, glIndexiv, (const GLint * c))
|
||||
SDL_PROC_UNUSED(void, glIndexs, (GLshort c))
|
||||
SDL_PROC_UNUSED(void, glIndexsv, (const GLshort * c))
|
||||
SDL_PROC_UNUSED(void, glIndexub, (GLubyte c))
|
||||
SDL_PROC_UNUSED(void, glIndexubv, (const GLubyte * c))
|
||||
SDL_PROC_UNUSED(void, glInitNames, (void))
|
||||
SDL_PROC_UNUSED(void, glInterleavedArrays,
|
||||
(GLenum format, GLsizei stride, const GLvoid * pointer))
|
||||
SDL_PROC_UNUSED(GLboolean, glIsEnabled, (GLenum cap))
|
||||
SDL_PROC_UNUSED(GLboolean, glIsList, (GLuint list))
|
||||
SDL_PROC_UNUSED(GLboolean, glIsTexture, (GLuint texture))
|
||||
SDL_PROC_UNUSED(void, glLightModelf, (GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glLightModeli, (GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glLightModeliv, (GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glLightf, (GLenum light, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glLightfv,
|
||||
(GLenum light, GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glLighti, (GLenum light, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glLightiv,
|
||||
(GLenum light, GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glLineStipple, (GLint factor, GLushort pattern))
|
||||
SDL_PROC(void, glLineWidth, (GLfloat width))
|
||||
SDL_PROC_UNUSED(void, glListBase, (GLuint base))
|
||||
SDL_PROC(void, glLoadIdentity, (void))
|
||||
SDL_PROC_UNUSED(void, glLoadMatrixd, (const GLdouble * m))
|
||||
SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat * m))
|
||||
SDL_PROC_UNUSED(void, glLoadName, (GLuint name))
|
||||
SDL_PROC_UNUSED(void, glLogicOp, (GLenum opcode))
|
||||
SDL_PROC_UNUSED(void, glMap1d,
|
||||
(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
|
||||
GLint order, const GLdouble * points))
|
||||
SDL_PROC_UNUSED(void, glMap1f,
|
||||
(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
|
||||
GLint order, const GLfloat * points))
|
||||
SDL_PROC_UNUSED(void, glMap2d,
|
||||
(GLenum target, GLdouble u1, GLdouble u2, GLint ustride,
|
||||
GLint uorder, GLdouble v1, GLdouble v2, GLint vstride,
|
||||
GLint vorder, const GLdouble * points))
|
||||
SDL_PROC_UNUSED(void, glMap2f,
|
||||
(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
|
||||
GLint uorder, GLfloat v1, GLfloat v2, GLint vstride,
|
||||
GLint vorder, const GLfloat * points))
|
||||
SDL_PROC_UNUSED(void, glMapGrid1d, (GLint un, GLdouble u1, GLdouble u2))
|
||||
SDL_PROC_UNUSED(void, glMapGrid1f, (GLint un, GLfloat u1, GLfloat u2))
|
||||
SDL_PROC_UNUSED(void, glMapGrid2d,
|
||||
(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1,
|
||||
GLdouble v2))
|
||||
SDL_PROC_UNUSED(void, glMapGrid2f,
|
||||
(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1,
|
||||
GLfloat v2))
|
||||
SDL_PROC_UNUSED(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glMaterialfv,
|
||||
(GLenum face, GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glMateriali, (GLenum face, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glMaterialiv,
|
||||
(GLenum face, GLenum pname, const GLint * params))
|
||||
SDL_PROC(void, glMatrixMode, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glMultMatrixd, (const GLdouble * m))
|
||||
SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat * m))
|
||||
SDL_PROC_UNUSED(void, glNewList, (GLuint list, GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glNormal3b, (GLbyte nx, GLbyte ny, GLbyte nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3bv, (const GLbyte * v))
|
||||
SDL_PROC_UNUSED(void, glNormal3d, (GLdouble nx, GLdouble ny, GLdouble nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glNormal3i, (GLint nx, GLint ny, GLint nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glNormal3s, (GLshort nx, GLshort ny, GLshort nz))
|
||||
SDL_PROC_UNUSED(void, glNormal3sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glNormalPointer,
|
||||
(GLenum type, GLsizei stride, const GLvoid * pointer))
|
||||
SDL_PROC(void, glOrtho,
|
||||
(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
|
||||
GLdouble zNear, GLdouble zFar))
|
||||
SDL_PROC_UNUSED(void, glPassThrough, (GLfloat token))
|
||||
SDL_PROC_UNUSED(void, glPixelMapfv,
|
||||
(GLenum map, GLsizei mapsize, const GLfloat * values))
|
||||
SDL_PROC_UNUSED(void, glPixelMapuiv,
|
||||
(GLenum map, GLsizei mapsize, const GLuint * values))
|
||||
SDL_PROC_UNUSED(void, glPixelMapusv,
|
||||
(GLenum map, GLsizei mapsize, const GLushort * values))
|
||||
SDL_PROC_UNUSED(void, glPixelStoref, (GLenum pname, GLfloat param))
|
||||
SDL_PROC(void, glPixelStorei, (GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glPixelTransferf, (GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glPixelTransferi, (GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glPixelZoom, (GLfloat xfactor, GLfloat yfactor))
|
||||
SDL_PROC(void, glPointSize, (GLfloat size))
|
||||
SDL_PROC_UNUSED(void, glPolygonMode, (GLenum face, GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units))
|
||||
SDL_PROC_UNUSED(void, glPolygonStipple, (const GLubyte * mask))
|
||||
SDL_PROC_UNUSED(void, glPopAttrib, (void))
|
||||
SDL_PROC_UNUSED(void, glPopClientAttrib, (void))
|
||||
SDL_PROC(void, glPopMatrix, (void))
|
||||
SDL_PROC_UNUSED(void, glPopName, (void))
|
||||
SDL_PROC_UNUSED(void, glPrioritizeTextures,
|
||||
(GLsizei n, const GLuint * textures,
|
||||
const GLclampf * priorities))
|
||||
SDL_PROC_UNUSED(void, glPushAttrib, (GLbitfield mask))
|
||||
SDL_PROC_UNUSED(void, glPushClientAttrib, (GLbitfield mask))
|
||||
SDL_PROC(void, glPushMatrix, (void))
|
||||
SDL_PROC_UNUSED(void, glPushName, (GLuint name))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2d, (GLdouble x, GLdouble y))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2f, (GLfloat x, GLfloat y))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2fv, (const GLfloat * v))
|
||||
SDL_PROC(void, glRasterPos2i, (GLint x, GLint y))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2s, (GLshort x, GLshort y))
|
||||
SDL_PROC_UNUSED(void, glRasterPos2sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3d, (GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3f, (GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3i, (GLint x, GLint y, GLint z))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3s, (GLshort x, GLshort y, GLshort z))
|
||||
SDL_PROC_UNUSED(void, glRasterPos3sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4d,
|
||||
(GLdouble x, GLdouble y, GLdouble z, GLdouble w))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4f,
|
||||
(GLfloat x, GLfloat y, GLfloat z, GLfloat w))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4i, (GLint x, GLint y, GLint z, GLint w))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4s,
|
||||
(GLshort x, GLshort y, GLshort z, GLshort w))
|
||||
SDL_PROC_UNUSED(void, glRasterPos4sv, (const GLshort * v))
|
||||
SDL_PROC(void, glReadBuffer, (GLenum mode))
|
||||
SDL_PROC(void, glReadPixels,
|
||||
(GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type, GLvoid * pixels))
|
||||
SDL_PROC_UNUSED(void, glRectd,
|
||||
(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2))
|
||||
SDL_PROC_UNUSED(void, glRectdv, (const GLdouble * v1, const GLdouble * v2))
|
||||
SDL_PROC(void, glRectf,
|
||||
(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2))
|
||||
SDL_PROC_UNUSED(void, glRectfv, (const GLfloat * v1, const GLfloat * v2))
|
||||
SDL_PROC_UNUSED(void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2))
|
||||
SDL_PROC_UNUSED(void, glRectiv, (const GLint * v1, const GLint * v2))
|
||||
SDL_PROC_UNUSED(void, glRects,
|
||||
(GLshort x1, GLshort y1, GLshort x2, GLshort y2))
|
||||
SDL_PROC_UNUSED(void, glRectsv, (const GLshort * v1, const GLshort * v2))
|
||||
SDL_PROC_UNUSED(GLint, glRenderMode, (GLenum mode))
|
||||
SDL_PROC(void, glRotated,
|
||||
(GLdouble angle, GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC(void, glRotatef,
|
||||
(GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC_UNUSED(void, glScaled, (GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height))
|
||||
SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint * buffer))
|
||||
SDL_PROC(void, glShadeModel, (GLenum mode))
|
||||
SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask))
|
||||
SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask))
|
||||
SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1d, (GLdouble s))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1f, (GLfloat s))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1i, (GLint s))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1s, (GLshort s))
|
||||
SDL_PROC_UNUSED(void, glTexCoord1sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2d, (GLdouble s, GLdouble t))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2dv, (const GLdouble * v))
|
||||
SDL_PROC(void, glTexCoord2f, (GLfloat s, GLfloat t))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2i, (GLint s, GLint t))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2s, (GLshort s, GLshort t))
|
||||
SDL_PROC_UNUSED(void, glTexCoord2sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3d, (GLdouble s, GLdouble t, GLdouble r))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3f, (GLfloat s, GLfloat t, GLfloat r))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3i, (GLint s, GLint t, GLint r))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3s, (GLshort s, GLshort t, GLshort r))
|
||||
SDL_PROC_UNUSED(void, glTexCoord3sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4d,
|
||||
(GLdouble s, GLdouble t, GLdouble r, GLdouble q))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4f,
|
||||
(GLfloat s, GLfloat t, GLfloat r, GLfloat q))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4i, (GLint s, GLint t, GLint r, GLint q))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4s,
|
||||
(GLshort s, GLshort t, GLshort r, GLshort q))
|
||||
SDL_PROC_UNUSED(void, glTexCoord4sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glTexCoordPointer,
|
||||
(GLint size, GLenum type, GLsizei stride,
|
||||
const GLvoid * pointer))
|
||||
SDL_PROC(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glTexEnvfv,
|
||||
(GLenum target, GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glTexEnvi, (GLenum target, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glTexEnviv,
|
||||
(GLenum target, GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glTexGend, (GLenum coord, GLenum pname, GLdouble param))
|
||||
SDL_PROC_UNUSED(void, glTexGendv,
|
||||
(GLenum coord, GLenum pname, const GLdouble * params))
|
||||
SDL_PROC_UNUSED(void, glTexGenf, (GLenum coord, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glTexGenfv,
|
||||
(GLenum coord, GLenum pname, const GLfloat * params))
|
||||
SDL_PROC_UNUSED(void, glTexGeni, (GLenum coord, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glTexGeniv,
|
||||
(GLenum coord, GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glTexImage1D,
|
||||
(GLenum target, GLint level, GLint internalformat,
|
||||
GLsizei width, GLint border, GLenum format, GLenum type,
|
||||
const GLvoid * pixels))
|
||||
SDL_PROC(void, glTexImage2D,
|
||||
(GLenum target, GLint level, GLint internalformat, GLsizei width,
|
||||
GLsizei height, GLint border, GLenum format, GLenum type,
|
||||
const GLvoid * pixels))
|
||||
SDL_PROC_UNUSED(void, glTexParameterf,
|
||||
(GLenum target, GLenum pname, GLfloat param))
|
||||
SDL_PROC_UNUSED(void, glTexParameterfv,
|
||||
(GLenum target, GLenum pname, const GLfloat * params))
|
||||
SDL_PROC(void, glTexParameteri, (GLenum target, GLenum pname, GLint param))
|
||||
SDL_PROC_UNUSED(void, glTexParameteriv,
|
||||
(GLenum target, GLenum pname, const GLint * params))
|
||||
SDL_PROC_UNUSED(void, glTexSubImage1D,
|
||||
(GLenum target, GLint level, GLint xoffset, GLsizei width,
|
||||
GLenum format, GLenum type, const GLvoid * pixels))
|
||||
SDL_PROC(void, glTexSubImage2D,
|
||||
(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
||||
GLsizei width, GLsizei height, GLenum format, GLenum type,
|
||||
const GLvoid * pixels))
|
||||
SDL_PROC_UNUSED(void, glTranslated, (GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC_UNUSED(void, glVertex2d, (GLdouble x, GLdouble y))
|
||||
SDL_PROC_UNUSED(void, glVertex2dv, (const GLdouble * v))
|
||||
SDL_PROC(void, glVertex2f, (GLfloat x, GLfloat y))
|
||||
SDL_PROC_UNUSED(void, glVertex2fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glVertex2i, (GLint x, GLint y))
|
||||
SDL_PROC_UNUSED(void, glVertex2iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glVertex2s, (GLshort x, GLshort y))
|
||||
SDL_PROC_UNUSED(void, glVertex2sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glVertex3d, (GLdouble x, GLdouble y, GLdouble z))
|
||||
SDL_PROC_UNUSED(void, glVertex3dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glVertex3f, (GLfloat x, GLfloat y, GLfloat z))
|
||||
SDL_PROC(void, glVertex3fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glVertex3i, (GLint x, GLint y, GLint z))
|
||||
SDL_PROC_UNUSED(void, glVertex3iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glVertex3s, (GLshort x, GLshort y, GLshort z))
|
||||
SDL_PROC_UNUSED(void, glVertex3sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glVertex4d,
|
||||
(GLdouble x, GLdouble y, GLdouble z, GLdouble w))
|
||||
SDL_PROC_UNUSED(void, glVertex4dv, (const GLdouble * v))
|
||||
SDL_PROC_UNUSED(void, glVertex4f,
|
||||
(GLfloat x, GLfloat y, GLfloat z, GLfloat w))
|
||||
SDL_PROC_UNUSED(void, glVertex4fv, (const GLfloat * v))
|
||||
SDL_PROC_UNUSED(void, glVertex4i, (GLint x, GLint y, GLint z, GLint w))
|
||||
SDL_PROC_UNUSED(void, glVertex4iv, (const GLint * v))
|
||||
SDL_PROC_UNUSED(void, glVertex4s,
|
||||
(GLshort x, GLshort y, GLshort z, GLshort w))
|
||||
SDL_PROC_UNUSED(void, glVertex4sv, (const GLshort * v))
|
||||
SDL_PROC_UNUSED(void, glVertexPointer,
|
||||
(GLint size, GLenum type, GLsizei stride,
|
||||
const GLvoid * pointer))
|
||||
SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height))
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1572
src/render/opengl/SDL_render_gl.c
Normal file
1572
src/render/opengl/SDL_render_gl.c
Normal file
File diff suppressed because it is too large
Load Diff
463
src/render/opengl/SDL_shaders_gl.c
Normal file
463
src/render/opengl/SDL_shaders_gl.c
Normal file
@@ -0,0 +1,463 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_opengl.h"
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_shaders_gl.h"
|
||||
|
||||
/* OpenGL shader implementation */
|
||||
|
||||
/* #define DEBUG_SHADERS */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLhandleARB program;
|
||||
GLhandleARB vert_shader;
|
||||
GLhandleARB frag_shader;
|
||||
} GL_ShaderData;
|
||||
|
||||
struct GL_ShaderContext
|
||||
{
|
||||
GLenum (*glGetError)(void);
|
||||
|
||||
PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
|
||||
PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
|
||||
PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
|
||||
PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
|
||||
PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
|
||||
PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
|
||||
PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
|
||||
PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
|
||||
PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
|
||||
PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
|
||||
PFNGLUNIFORM1IARBPROC glUniform1iARB;
|
||||
PFNGLUNIFORM1FARBPROC glUniform1fARB;
|
||||
PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
|
||||
|
||||
SDL_bool GL_ARB_texture_rectangle_supported;
|
||||
|
||||
GL_ShaderData shaders[NUM_SHADERS];
|
||||
};
|
||||
|
||||
/*
|
||||
* NOTE: Always use sampler2D, etc here. We'll #define them to the
|
||||
* texture_rectangle versions if we choose to use that extension.
|
||||
*/
|
||||
static const char *shader_source[NUM_SHADERS][2] =
|
||||
{
|
||||
/* SHADER_NONE */
|
||||
{ NULL, NULL },
|
||||
|
||||
/* SHADER_SOLID */
|
||||
{
|
||||
/* vertex shader */
|
||||
"varying vec4 v_color;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||
" v_color = gl_Color;\n"
|
||||
"}",
|
||||
/* fragment shader */
|
||||
"varying vec4 v_color;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = v_color;\n"
|
||||
"}"
|
||||
},
|
||||
|
||||
/* SHADER_RGB */
|
||||
{
|
||||
/* vertex shader */
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||
" v_color = gl_Color;\n"
|
||||
" v_texCoord = vec2(gl_MultiTexCoord0);\n"
|
||||
"}",
|
||||
/* fragment shader */
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"uniform sampler2D tex0;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = texture2D(tex0, v_texCoord) * v_color;\n"
|
||||
"}"
|
||||
},
|
||||
|
||||
/* SHADER_YUV */
|
||||
{
|
||||
/* vertex shader */
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||
" v_color = gl_Color;\n"
|
||||
" v_texCoord = vec2(gl_MultiTexCoord0);\n"
|
||||
"}",
|
||||
/* fragment shader */
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"uniform sampler2D tex0; // Y \n"
|
||||
"uniform sampler2D tex1; // U \n"
|
||||
"uniform sampler2D tex2; // V \n"
|
||||
"\n"
|
||||
"// YUV offset \n"
|
||||
"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n"
|
||||
"\n"
|
||||
"// RGB coefficients \n"
|
||||
"const vec3 Rcoeff = vec3(1.164, 0.000, 1.596);\n"
|
||||
"const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);\n"
|
||||
"const vec3 Bcoeff = vec3(1.164, 2.018, 0.000);\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec2 tcoord;\n"
|
||||
" vec3 yuv, rgb;\n"
|
||||
"\n"
|
||||
" // Get the Y value \n"
|
||||
" tcoord = v_texCoord;\n"
|
||||
" yuv.x = texture2D(tex0, tcoord).r;\n"
|
||||
"\n"
|
||||
" // Get the U and V values \n"
|
||||
" tcoord *= UVCoordScale;\n"
|
||||
" yuv.y = texture2D(tex1, tcoord).r;\n"
|
||||
" yuv.z = texture2D(tex2, tcoord).r;\n"
|
||||
"\n"
|
||||
" // Do the color transform \n"
|
||||
" yuv += offset;\n"
|
||||
" rgb.r = dot(yuv, Rcoeff);\n"
|
||||
" rgb.g = dot(yuv, Gcoeff);\n"
|
||||
" rgb.b = dot(yuv, Bcoeff);\n"
|
||||
"\n"
|
||||
" // That was easy. :) \n"
|
||||
" gl_FragColor = vec4(rgb, 1.0) * v_color;\n"
|
||||
"}"
|
||||
},
|
||||
|
||||
/* SHADER_NV12 */
|
||||
{
|
||||
/* vertex shader */
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||
" v_color = gl_Color;\n"
|
||||
" v_texCoord = vec2(gl_MultiTexCoord0);\n"
|
||||
"}",
|
||||
/* fragment shader */
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"uniform sampler2D tex0; // Y \n"
|
||||
"uniform sampler2D tex1; // U/V \n"
|
||||
"\n"
|
||||
"// YUV offset \n"
|
||||
"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n"
|
||||
"\n"
|
||||
"// RGB coefficients \n"
|
||||
"const vec3 Rcoeff = vec3(1.164, 0.000, 1.596);\n"
|
||||
"const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);\n"
|
||||
"const vec3 Bcoeff = vec3(1.164, 2.018, 0.000);\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec2 tcoord;\n"
|
||||
" vec3 yuv, rgb;\n"
|
||||
"\n"
|
||||
" // Get the Y value \n"
|
||||
" tcoord = v_texCoord;\n"
|
||||
" yuv.x = texture2D(tex0, tcoord).r;\n"
|
||||
"\n"
|
||||
" // Get the U and V values \n"
|
||||
" tcoord *= UVCoordScale;\n"
|
||||
" yuv.yz = texture2D(tex1, tcoord).ra;\n"
|
||||
"\n"
|
||||
" // Do the color transform \n"
|
||||
" yuv += offset;\n"
|
||||
" rgb.r = dot(yuv, Rcoeff);\n"
|
||||
" rgb.g = dot(yuv, Gcoeff);\n"
|
||||
" rgb.b = dot(yuv, Bcoeff);\n"
|
||||
"\n"
|
||||
" // That was easy. :) \n"
|
||||
" gl_FragColor = vec4(rgb, 1.0) * v_color;\n"
|
||||
"}"
|
||||
},
|
||||
|
||||
/* SHADER_NV21 */
|
||||
{
|
||||
/* vertex shader */
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
|
||||
" v_color = gl_Color;\n"
|
||||
" v_texCoord = vec2(gl_MultiTexCoord0);\n"
|
||||
"}",
|
||||
/* fragment shader */
|
||||
"varying vec4 v_color;\n"
|
||||
"varying vec2 v_texCoord;\n"
|
||||
"uniform sampler2D tex0; // Y \n"
|
||||
"uniform sampler2D tex1; // U/V \n"
|
||||
"\n"
|
||||
"// YUV offset \n"
|
||||
"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n"
|
||||
"\n"
|
||||
"// RGB coefficients \n"
|
||||
"const vec3 Rcoeff = vec3(1.164, 0.000, 1.596);\n"
|
||||
"const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);\n"
|
||||
"const vec3 Bcoeff = vec3(1.164, 2.018, 0.000);\n"
|
||||
"\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec2 tcoord;\n"
|
||||
" vec3 yuv, rgb;\n"
|
||||
"\n"
|
||||
" // Get the Y value \n"
|
||||
" tcoord = v_texCoord;\n"
|
||||
" yuv.x = texture2D(tex0, tcoord).r;\n"
|
||||
"\n"
|
||||
" // Get the U and V values \n"
|
||||
" tcoord *= UVCoordScale;\n"
|
||||
" yuv.yz = texture2D(tex1, tcoord).ar;\n"
|
||||
"\n"
|
||||
" // Do the color transform \n"
|
||||
" yuv += offset;\n"
|
||||
" rgb.r = dot(yuv, Rcoeff);\n"
|
||||
" rgb.g = dot(yuv, Gcoeff);\n"
|
||||
" rgb.b = dot(yuv, Bcoeff);\n"
|
||||
"\n"
|
||||
" // That was easy. :) \n"
|
||||
" gl_FragColor = vec4(rgb, 1.0) * v_color;\n"
|
||||
"}"
|
||||
},
|
||||
};
|
||||
|
||||
static SDL_bool
|
||||
CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source)
|
||||
{
|
||||
GLint status;
|
||||
const char *sources[2];
|
||||
|
||||
sources[0] = defines;
|
||||
sources[1] = source;
|
||||
|
||||
ctx->glShaderSourceARB(shader, SDL_arraysize(sources), sources, NULL);
|
||||
ctx->glCompileShaderARB(shader);
|
||||
ctx->glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status);
|
||||
if (status == 0) {
|
||||
GLint length;
|
||||
char *info;
|
||||
|
||||
ctx->glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
|
||||
info = SDL_stack_alloc(char, length+1);
|
||||
ctx->glGetInfoLogARB(shader, length, NULL, info);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_RENDER,
|
||||
"Failed to compile shader:\n%s%s\n%s", defines, source, info);
|
||||
#ifdef DEBUG_SHADERS
|
||||
fprintf(stderr,
|
||||
"Failed to compile shader:\n%s%s\n%s", defines, source, info);
|
||||
#endif
|
||||
SDL_stack_free(info);
|
||||
|
||||
return SDL_FALSE;
|
||||
} else {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
|
||||
{
|
||||
const int num_tmus_bound = 4;
|
||||
const char *vert_defines = "";
|
||||
const char *frag_defines = "";
|
||||
int i;
|
||||
GLint location;
|
||||
|
||||
if (index == SHADER_NONE) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
ctx->glGetError();
|
||||
|
||||
/* Make sure we use the correct sampler type for our texture type */
|
||||
if (ctx->GL_ARB_texture_rectangle_supported) {
|
||||
frag_defines =
|
||||
"#define sampler2D sampler2DRect\n"
|
||||
"#define texture2D texture2DRect\n"
|
||||
"#define UVCoordScale 0.5\n";
|
||||
} else {
|
||||
frag_defines =
|
||||
"#define UVCoordScale 1.0\n";
|
||||
}
|
||||
|
||||
/* Create one program object to rule them all */
|
||||
data->program = ctx->glCreateProgramObjectARB();
|
||||
|
||||
/* Create the vertex shader */
|
||||
data->vert_shader = ctx->glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
|
||||
if (!CompileShader(ctx, data->vert_shader, vert_defines, shader_source[index][0])) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Create the fragment shader */
|
||||
data->frag_shader = ctx->glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
|
||||
if (!CompileShader(ctx, data->frag_shader, frag_defines, shader_source[index][1])) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* ... and in the darkness bind them */
|
||||
ctx->glAttachObjectARB(data->program, data->vert_shader);
|
||||
ctx->glAttachObjectARB(data->program, data->frag_shader);
|
||||
ctx->glLinkProgramARB(data->program);
|
||||
|
||||
/* Set up some uniform variables */
|
||||
ctx->glUseProgramObjectARB(data->program);
|
||||
for (i = 0; i < num_tmus_bound; ++i) {
|
||||
char tex_name[10];
|
||||
SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i);
|
||||
location = ctx->glGetUniformLocationARB(data->program, tex_name);
|
||||
if (location >= 0) {
|
||||
ctx->glUniform1iARB(location, i);
|
||||
}
|
||||
}
|
||||
ctx->glUseProgramObjectARB(0);
|
||||
|
||||
return (ctx->glGetError() == GL_NO_ERROR);
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyShaderProgram(GL_ShaderContext *ctx, GL_ShaderData *data)
|
||||
{
|
||||
ctx->glDeleteObjectARB(data->vert_shader);
|
||||
ctx->glDeleteObjectARB(data->frag_shader);
|
||||
ctx->glDeleteObjectARB(data->program);
|
||||
}
|
||||
|
||||
GL_ShaderContext *
|
||||
GL_CreateShaderContext()
|
||||
{
|
||||
GL_ShaderContext *ctx;
|
||||
SDL_bool shaders_supported;
|
||||
int i;
|
||||
|
||||
ctx = (GL_ShaderContext *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (!ctx) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!SDL_GL_ExtensionSupported("GL_ARB_texture_non_power_of_two") &&
|
||||
(SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") ||
|
||||
SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle"))) {
|
||||
ctx->GL_ARB_texture_rectangle_supported = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Check for shader support */
|
||||
shaders_supported = SDL_FALSE;
|
||||
if (SDL_GL_ExtensionSupported("GL_ARB_shader_objects") &&
|
||||
SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") &&
|
||||
SDL_GL_ExtensionSupported("GL_ARB_vertex_shader") &&
|
||||
SDL_GL_ExtensionSupported("GL_ARB_fragment_shader")) {
|
||||
ctx->glGetError = (GLenum (*)(void)) SDL_GL_GetProcAddress("glGetError");
|
||||
ctx->glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) SDL_GL_GetProcAddress("glAttachObjectARB");
|
||||
ctx->glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) SDL_GL_GetProcAddress("glCompileShaderARB");
|
||||
ctx->glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glCreateProgramObjectARB");
|
||||
ctx->glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) SDL_GL_GetProcAddress("glCreateShaderObjectARB");
|
||||
ctx->glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) SDL_GL_GetProcAddress("glDeleteObjectARB");
|
||||
ctx->glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) SDL_GL_GetProcAddress("glGetInfoLogARB");
|
||||
ctx->glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB");
|
||||
ctx->glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetUniformLocationARB");
|
||||
ctx->glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) SDL_GL_GetProcAddress("glLinkProgramARB");
|
||||
ctx->glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glShaderSourceARB");
|
||||
ctx->glUniform1iARB = (PFNGLUNIFORM1IARBPROC) SDL_GL_GetProcAddress("glUniform1iARB");
|
||||
ctx->glUniform1fARB = (PFNGLUNIFORM1FARBPROC) SDL_GL_GetProcAddress("glUniform1fARB");
|
||||
ctx->glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glUseProgramObjectARB");
|
||||
if (ctx->glGetError &&
|
||||
ctx->glAttachObjectARB &&
|
||||
ctx->glCompileShaderARB &&
|
||||
ctx->glCreateProgramObjectARB &&
|
||||
ctx->glCreateShaderObjectARB &&
|
||||
ctx->glDeleteObjectARB &&
|
||||
ctx->glGetInfoLogARB &&
|
||||
ctx->glGetObjectParameterivARB &&
|
||||
ctx->glGetUniformLocationARB &&
|
||||
ctx->glLinkProgramARB &&
|
||||
ctx->glShaderSourceARB &&
|
||||
ctx->glUniform1iARB &&
|
||||
ctx->glUniform1fARB &&
|
||||
ctx->glUseProgramObjectARB) {
|
||||
shaders_supported = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!shaders_supported) {
|
||||
SDL_free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Compile all the shaders */
|
||||
for (i = 0; i < NUM_SHADERS; ++i) {
|
||||
if (!CompileShaderProgram(ctx, i, &ctx->shaders[i])) {
|
||||
GL_DestroyShaderContext(ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* We're done! */
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void
|
||||
GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader)
|
||||
{
|
||||
ctx->glUseProgramObjectARB(ctx->shaders[shader].program);
|
||||
}
|
||||
|
||||
void
|
||||
GL_DestroyShaderContext(GL_ShaderContext *ctx)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_SHADERS; ++i) {
|
||||
DestroyShaderProgram(ctx, &ctx->shaders[i]);
|
||||
}
|
||||
SDL_free(ctx);
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
41
src/render/opengl/SDL_shaders_gl.h
Normal file
41
src/render/opengl/SDL_shaders_gl.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
/* OpenGL shader implementation */
|
||||
|
||||
typedef enum {
|
||||
SHADER_NONE,
|
||||
SHADER_SOLID,
|
||||
SHADER_RGB,
|
||||
SHADER_YUV,
|
||||
SHADER_NV12,
|
||||
SHADER_NV21,
|
||||
NUM_SHADERS
|
||||
} GL_Shader;
|
||||
|
||||
typedef struct GL_ShaderContext GL_ShaderContext;
|
||||
|
||||
extern GL_ShaderContext * GL_CreateShaderContext();
|
||||
extern void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader);
|
||||
extern void GL_DestroyShaderContext(GL_ShaderContext *ctx);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
63
src/render/opengles/SDL_glesfuncs.h
Normal file
63
src/render/opengles/SDL_glesfuncs.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
SDL_PROC(void, glBindTexture, (GLenum, GLuint))
|
||||
SDL_PROC(void, glBlendFunc, (GLenum, GLenum))
|
||||
SDL_PROC_OES(void, glBlendFuncSeparateOES, (GLenum, GLenum, GLenum, GLenum))
|
||||
SDL_PROC(void, glClear, (GLbitfield))
|
||||
SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
|
||||
SDL_PROC(void, glColor4f, (GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glDeleteTextures, (GLsizei, const GLuint *))
|
||||
SDL_PROC(void, glDisable, (GLenum))
|
||||
SDL_PROC(void, glDisableClientState, (GLenum array))
|
||||
SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei))
|
||||
SDL_PROC_OES(void, glDrawTexfOES, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glEnable, (GLenum))
|
||||
SDL_PROC(void, glEnableClientState, (GLenum))
|
||||
SDL_PROC(void, glFinish, (void))
|
||||
SDL_PROC_OES(void, glGenFramebuffersOES, (GLsizei, GLuint *))
|
||||
SDL_PROC(void, glGenTextures, (GLsizei, GLuint *))
|
||||
SDL_PROC(GLenum, glGetError, (void))
|
||||
SDL_PROC(void, glGetIntegerv, (GLenum, GLint *))
|
||||
SDL_PROC(void, glLoadIdentity, (void))
|
||||
SDL_PROC(void, glMatrixMode, (GLenum))
|
||||
SDL_PROC(void, glOrthof, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glPixelStorei, (GLenum, GLint))
|
||||
SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
|
||||
SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
|
||||
SDL_PROC(void, glTexCoordPointer, (GLint, GLenum, GLsizei, const GLvoid *))
|
||||
SDL_PROC(void, glTexEnvf, (GLenum, GLenum, GLfloat))
|
||||
SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))
|
||||
SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint))
|
||||
SDL_PROC(void, glTexParameteriv, (GLenum, GLenum, const GLint *))
|
||||
SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))
|
||||
SDL_PROC(void, glVertexPointer, (GLint, GLenum, GLsizei, const GLvoid *))
|
||||
SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei))
|
||||
SDL_PROC_OES(void, glBindFramebufferOES, (GLenum, GLuint))
|
||||
SDL_PROC_OES(void, glFramebufferTexture2DOES, (GLenum, GLenum, GLenum, GLuint, GLint))
|
||||
SDL_PROC_OES(GLenum, glCheckFramebufferStatusOES, (GLenum))
|
||||
SDL_PROC(void, glPushMatrix, (void))
|
||||
SDL_PROC(void, glTranslatef, (GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glRotatef, (GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glPopMatrix, (void))
|
||||
SDL_PROC_OES(void, glDeleteFramebuffersOES, (GLsizei, const GLuint*))
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1218
src/render/opengles/SDL_render_gles.c
Normal file
1218
src/render/opengles/SDL_render_gles.c
Normal file
File diff suppressed because it is too large
Load Diff
71
src/render/opengles2/SDL_gles2funcs.h
Normal file
71
src/render/opengles2/SDL_gles2funcs.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
SDL_PROC(void, glActiveTexture, (GLenum))
|
||||
SDL_PROC(void, glAttachShader, (GLuint, GLuint))
|
||||
SDL_PROC(void, glBindAttribLocation, (GLuint, GLuint, const char *))
|
||||
SDL_PROC(void, glBindTexture, (GLenum, GLuint))
|
||||
SDL_PROC(void, glBlendFuncSeparate, (GLenum, GLenum, GLenum, GLenum))
|
||||
SDL_PROC(void, glClear, (GLbitfield))
|
||||
SDL_PROC(void, glClearColor, (GLclampf, GLclampf, GLclampf, GLclampf))
|
||||
SDL_PROC(void, glCompileShader, (GLuint))
|
||||
SDL_PROC(GLuint, glCreateProgram, (void))
|
||||
SDL_PROC(GLuint, glCreateShader, (GLenum))
|
||||
SDL_PROC(void, glDeleteProgram, (GLuint))
|
||||
SDL_PROC(void, glDeleteShader, (GLuint))
|
||||
SDL_PROC(void, glDeleteTextures, (GLsizei, const GLuint *))
|
||||
SDL_PROC(void, glDisable, (GLenum))
|
||||
SDL_PROC(void, glDisableVertexAttribArray, (GLuint))
|
||||
SDL_PROC(void, glDrawArrays, (GLenum, GLint, GLsizei))
|
||||
SDL_PROC(void, glEnable, (GLenum))
|
||||
SDL_PROC(void, glEnableVertexAttribArray, (GLuint))
|
||||
SDL_PROC(void, glFinish, (void))
|
||||
SDL_PROC(void, glGenFramebuffers, (GLsizei, GLuint *))
|
||||
SDL_PROC(void, glGenTextures, (GLsizei, GLuint *))
|
||||
SDL_PROC(void, glGetBooleanv, (GLenum, GLboolean *))
|
||||
SDL_PROC(const GLubyte *, glGetString, (GLenum))
|
||||
SDL_PROC(GLenum, glGetError, (void))
|
||||
SDL_PROC(void, glGetIntegerv, (GLenum, GLint *))
|
||||
SDL_PROC(void, glGetProgramiv, (GLuint, GLenum, GLint *))
|
||||
SDL_PROC(void, glGetShaderInfoLog, (GLuint, GLsizei, GLsizei *, char *))
|
||||
SDL_PROC(void, glGetShaderiv, (GLuint, GLenum, GLint *))
|
||||
SDL_PROC(GLint, glGetUniformLocation, (GLuint, const char *))
|
||||
SDL_PROC(void, glLinkProgram, (GLuint))
|
||||
SDL_PROC(void, glPixelStorei, (GLenum, GLint))
|
||||
SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
|
||||
SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
|
||||
SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei))
|
||||
SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar* const*, const GLint *))
|
||||
SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))
|
||||
SDL_PROC(void, glTexParameteri, (GLenum, GLenum, GLint))
|
||||
SDL_PROC(void, glTexSubImage2D, (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))
|
||||
SDL_PROC(void, glUniform1i, (GLint, GLint))
|
||||
SDL_PROC(void, glUniform4f, (GLint, GLfloat, GLfloat, GLfloat, GLfloat))
|
||||
SDL_PROC(void, glUniformMatrix4fv, (GLint, GLsizei, GLboolean, const GLfloat *))
|
||||
SDL_PROC(void, glUseProgram, (GLuint))
|
||||
SDL_PROC(void, glVertexAttribPointer, (GLuint, GLint, GLenum, GLboolean, GLsizei, const void *))
|
||||
SDL_PROC(void, glViewport, (GLint, GLint, GLsizei, GLsizei))
|
||||
SDL_PROC(void, glBindFramebuffer, (GLenum, GLuint))
|
||||
SDL_PROC(void, glFramebufferTexture2D, (GLenum, GLenum, GLenum, GLuint, GLint))
|
||||
SDL_PROC(GLenum, glCheckFramebufferStatus, (GLenum))
|
||||
SDL_PROC(void, glDeleteFramebuffers, (GLsizei, const GLuint *))
|
||||
SDL_PROC(GLint, glGetAttribLocation, (GLuint, const GLchar *))
|
||||
SDL_PROC(void, glGetProgramInfoLog, (GLuint, GLsizei, GLsizei*, GLchar*))
|
2050
src/render/opengles2/SDL_render_gles2.c
Normal file
2050
src/render/opengles2/SDL_render_gles2.c
Normal file
File diff suppressed because it is too large
Load Diff
912
src/render/opengles2/SDL_shaders_gles2.c
Normal file
912
src/render/opengles2/SDL_shaders_gles2.c
Normal file
@@ -0,0 +1,912 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_opengles2.h"
|
||||
#include "SDL_shaders_gles2.h"
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
/*************************************************************************************************
|
||||
* Vertex/fragment shader source *
|
||||
*************************************************************************************************/
|
||||
|
||||
static const Uint8 GLES2_VertexSrc_Default_[] = " \
|
||||
uniform mat4 u_projection; \
|
||||
attribute vec2 a_position; \
|
||||
attribute vec2 a_texCoord; \
|
||||
attribute float a_angle; \
|
||||
attribute vec2 a_center; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
float angle = radians(a_angle); \
|
||||
float c = cos(angle); \
|
||||
float s = sin(angle); \
|
||||
mat2 rotationMatrix = mat2(c, -s, s, c); \
|
||||
vec2 position = rotationMatrix * (a_position - a_center) + a_center; \
|
||||
v_texCoord = a_texCoord; \
|
||||
gl_Position = u_projection * vec4(position, 0.0, 1.0);\
|
||||
gl_PointSize = 1.0; \
|
||||
} \
|
||||
";
|
||||
|
||||
static const Uint8 GLES2_FragmentSrc_SolidSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform vec4 u_color; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
gl_FragColor = u_color; \
|
||||
} \
|
||||
";
|
||||
|
||||
static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_modulation; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
gl_FragColor = texture2D(u_texture, v_texCoord); \
|
||||
gl_FragColor *= u_modulation; \
|
||||
} \
|
||||
";
|
||||
|
||||
/* ARGB to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_modulation; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
vec4 abgr = texture2D(u_texture, v_texCoord); \
|
||||
gl_FragColor = abgr; \
|
||||
gl_FragColor.r = abgr.b; \
|
||||
gl_FragColor.b = abgr.r; \
|
||||
gl_FragColor *= u_modulation; \
|
||||
} \
|
||||
";
|
||||
|
||||
/* RGB to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_modulation; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
vec4 abgr = texture2D(u_texture, v_texCoord); \
|
||||
gl_FragColor = abgr; \
|
||||
gl_FragColor.r = abgr.b; \
|
||||
gl_FragColor.b = abgr.r; \
|
||||
gl_FragColor.a = 1.0; \
|
||||
gl_FragColor *= u_modulation; \
|
||||
} \
|
||||
";
|
||||
|
||||
/* BGR to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform vec4 u_modulation; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
vec4 abgr = texture2D(u_texture, v_texCoord); \
|
||||
gl_FragColor = abgr; \
|
||||
gl_FragColor.a = 1.0; \
|
||||
gl_FragColor *= u_modulation; \
|
||||
} \
|
||||
";
|
||||
|
||||
/* YUV to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureYUVSrc_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform sampler2D u_texture_u; \
|
||||
uniform sampler2D u_texture_v; \
|
||||
uniform vec4 u_modulation; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
mediump vec3 yuv; \
|
||||
lowp vec3 rgb; \
|
||||
yuv.x = texture2D(u_texture, v_texCoord).r; \
|
||||
yuv.y = texture2D(u_texture_u, v_texCoord).r - 0.5; \
|
||||
yuv.z = texture2D(u_texture_v, v_texCoord).r - 0.5; \
|
||||
rgb = mat3( 1, 1, 1, \
|
||||
0, -0.39465, 2.03211, \
|
||||
1.13983, -0.58060, 0) * yuv; \
|
||||
gl_FragColor = vec4(rgb, 1); \
|
||||
gl_FragColor *= u_modulation; \
|
||||
} \
|
||||
";
|
||||
|
||||
/* NV12 to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV12Src_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform sampler2D u_texture_u; \
|
||||
uniform vec4 u_modulation; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
mediump vec3 yuv; \
|
||||
lowp vec3 rgb; \
|
||||
yuv.x = texture2D(u_texture, v_texCoord).r; \
|
||||
yuv.yz = texture2D(u_texture_u, v_texCoord).ra - 0.5; \
|
||||
rgb = mat3( 1, 1, 1, \
|
||||
0, -0.39465, 2.03211, \
|
||||
1.13983, -0.58060, 0) * yuv; \
|
||||
gl_FragColor = vec4(rgb, 1); \
|
||||
gl_FragColor *= u_modulation; \
|
||||
} \
|
||||
";
|
||||
|
||||
/* NV21 to ABGR conversion */
|
||||
static const Uint8 GLES2_FragmentSrc_TextureNV21Src_[] = " \
|
||||
precision mediump float; \
|
||||
uniform sampler2D u_texture; \
|
||||
uniform sampler2D u_texture_u; \
|
||||
uniform vec4 u_modulation; \
|
||||
varying vec2 v_texCoord; \
|
||||
\
|
||||
void main() \
|
||||
{ \
|
||||
mediump vec3 yuv; \
|
||||
lowp vec3 rgb; \
|
||||
yuv.x = texture2D(u_texture, v_texCoord).r; \
|
||||
yuv.yz = texture2D(u_texture_u, v_texCoord).ar - 0.5; \
|
||||
rgb = mat3( 1, 1, 1, \
|
||||
0, -0.39465, 2.03211, \
|
||||
1.13983, -0.58060, 0) * yuv; \
|
||||
gl_FragColor = vec4(rgb, 1); \
|
||||
gl_FragColor *= u_modulation; \
|
||||
} \
|
||||
";
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_VertexSrc_Default = {
|
||||
GL_VERTEX_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_VertexSrc_Default_),
|
||||
GLES2_VertexSrc_Default_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_SolidSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_SolidSrc_),
|
||||
GLES2_FragmentSrc_SolidSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureABGRSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureABGRSrc_),
|
||||
GLES2_FragmentSrc_TextureABGRSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureARGBSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureARGBSrc_),
|
||||
GLES2_FragmentSrc_TextureARGBSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureRGBSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureRGBSrc_),
|
||||
GLES2_FragmentSrc_TextureRGBSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureBGRSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureBGRSrc_),
|
||||
GLES2_FragmentSrc_TextureBGRSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureYUVSrc_),
|
||||
GLES2_FragmentSrc_TextureYUVSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV12Src_),
|
||||
GLES2_FragmentSrc_TextureNV12Src_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21Src = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GLES2_SOURCE_SHADER,
|
||||
sizeof(GLES2_FragmentSrc_TextureNV21Src_),
|
||||
GLES2_FragmentSrc_TextureNV21Src_
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************************************
|
||||
* Vertex/fragment shader binaries (NVIDIA Tegra 1/2) *
|
||||
*************************************************************************************************/
|
||||
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
|
||||
#define GL_NVIDIA_PLATFORM_BINARY_NV 0x890B
|
||||
|
||||
static const Uint8 GLES2_VertexTegra_Default_[] = {
|
||||
243, 193, 1, 142, 31, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
|
||||
0, 0, 46, 0, 0, 0, 48, 0, 0, 0, 2, 0, 0, 0, 85, 0, 0, 0, 2, 0, 0, 0, 24, 0, 0, 0, 3, 0, 0, 0,
|
||||
91, 0, 0, 0, 1, 0, 0, 0, 16, 0, 0, 0, 5, 0, 0, 0, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 95, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0,
|
||||
13, 0, 0, 0, 102, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 16, 0, 0, 0, 104, 0, 0, 0, 1, 0, 0, 0, 32, 0, 0, 0, 17, 0, 0, 0, 112, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 112, 0, 0, 0, 80, 0, 0, 0, 80, 0, 0, 0, 19, 0, 0, 0, 132, 0,
|
||||
0, 0, 104, 0, 0, 0, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 97,
|
||||
95, 112, 111, 115, 105, 116, 105, 111, 110, 0, 97, 95, 116, 101, 120, 67, 111, 111, 114, 100,
|
||||
0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 112, 114, 111, 106, 101, 99,
|
||||
116, 105, 111, 110, 0, 0, 0, 0, 0, 0, 0, 82, 139, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 80, 139, 0,
|
||||
0, 1, 0, 0, 0, 22, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 33, 0, 0, 0, 92, 139, 0, 0,
|
||||
1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 240, 0, 0, 0, 0, 0, 0, 1, 0,
|
||||
0, 0, 64, 0, 0, 0, 80, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 193, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 66, 24, 0, 6, 34, 108, 28,
|
||||
0, 0, 42, 16, 128, 0, 195, 192, 6, 129, 252, 255, 65, 96, 108, 28, 0, 0, 0, 0, 0, 1, 195, 192,
|
||||
6, 1, 252, 255, 33, 96, 108, 156, 31, 64, 8, 1, 64, 0, 131, 192, 6, 1, 156, 159, 65, 96, 108,
|
||||
28, 0, 0, 85, 32, 0, 1, 195, 192, 6, 1, 252, 255, 33, 96, 108, 156, 31, 64, 0, 64, 64, 0, 131,
|
||||
192, 134, 1, 152, 31, 65, 96, 108, 156, 31, 64, 127, 48, 0, 1, 195, 192, 6, 129, 129, 255, 33,
|
||||
96
|
||||
};
|
||||
|
||||
static const Uint8 GLES2_FragmentTegra_None_SolidSrc_[] = {
|
||||
155, 191, 159, 1, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
|
||||
0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
|
||||
75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0,
|
||||
0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4,
|
||||
0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0,
|
||||
0, 108, 0, 0, 0, 108, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0,
|
||||
0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 241, 0, 0, 0, 240, 0, 0,
|
||||
0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1,
|
||||
0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 0, 0, 0, 0, 1, 0, 0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 0, 0, 0,
|
||||
0, 1, 0, 1, 39, 0, 0, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 0, 40, 0, 0, 0, 242, 65, 63,
|
||||
192, 200, 0, 0, 0, 242, 65, 63, 128, 168, 0, 0, 0, 242, 65, 63, 64, 72, 0, 0, 0, 242, 65, 63,
|
||||
1, 0, 6, 40, 0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0
|
||||
};
|
||||
|
||||
static const Uint8 GLES2_FragmentTegra_Alpha_SolidSrc_[] = {
|
||||
169, 153, 195, 28, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
|
||||
0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
|
||||
75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0,
|
||||
0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4,
|
||||
0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0,
|
||||
0, 220, 0, 0, 0, 220, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0,
|
||||
0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 118, 118, 17, 241, 0, 0, 0, 240, 0,
|
||||
0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 21, 32, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78,
|
||||
1, 0, 0, 0, 3, 0, 0, 0, 3, 0, 65, 37, 8, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 21, 0,
|
||||
0, 0, 0, 3, 0, 1, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 39, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 3, 0, 1, 40, 1, 0, 0, 0, 5, 0, 0, 0, 9, 0, 0, 0, 24, 0, 4, 40, 232, 231, 15,
|
||||
0, 0, 242, 65, 62, 194, 72, 1, 0, 0, 250, 65, 63, 194, 40, 1, 0, 0, 250, 65, 63, 192, 168, 1,
|
||||
0, 0, 242, 1, 64, 192, 168, 1, 0, 0, 242, 1, 68, 168, 32, 0, 0, 0, 50, 64, 0, 192, 168, 15,
|
||||
0, 0, 242, 1, 66, 168, 64, 0, 16, 0, 242, 65, 1, 232, 231, 15, 0, 0, 242, 65, 62, 168, 160,
|
||||
0, 0, 0, 50, 64, 2, 104, 192, 0, 0, 36, 48, 66, 4, 232, 231, 15, 0, 0, 242, 65, 62, 3, 0, 6,
|
||||
40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 41, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 2, 0
|
||||
};
|
||||
|
||||
static const Uint8 GLES2_FragmentTegra_Additive_SolidSrc_[] = {
|
||||
59, 71, 42, 17, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, 0,
|
||||
0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
|
||||
75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0,
|
||||
0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4,
|
||||
0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0,
|
||||
0, 108, 0, 0, 0, 108, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0,
|
||||
0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 22, 22, 17, 241, 0, 0, 0, 240, 0,
|
||||
0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78,
|
||||
1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 8, 0, 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 0,
|
||||
0, 0, 0, 1, 0, 1, 39, 0, 0, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 192, 200, 0, 0, 0, 26,
|
||||
0, 70, 192, 40, 0, 0, 0, 2, 0, 64, 192, 72, 0, 0, 0, 10, 0, 66, 192, 168, 0, 0, 0, 18, 0, 68,
|
||||
1, 0, 6, 40, 0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0
|
||||
};
|
||||
|
||||
static const Uint8 GLES2_FragmentTegra_Modulated_SolidSrc_[] = {
|
||||
37, 191, 49, 17, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, 0,
|
||||
0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0,
|
||||
75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0,
|
||||
0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4,
|
||||
0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0,
|
||||
0, 108, 0, 0, 0, 108, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0,
|
||||
0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 32, 32, 17, 241, 0, 0, 0, 240, 0,
|
||||
0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78,
|
||||
1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 8, 0, 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 0,
|
||||
0, 0, 0, 1, 0, 1, 39, 0, 0, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 104, 192, 0, 0, 0, 242,
|
||||
1, 70, 8, 32, 0, 0, 0, 242, 1, 64, 40, 64, 0, 0, 0, 242, 1, 66, 72, 160, 0, 0, 0, 242, 1, 68,
|
||||
1, 0, 6, 40, 0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0
|
||||
};
|
||||
|
||||
static const Uint8 GLES2_FragmentTegra_None_TextureSrc_[] = {
|
||||
220, 217, 41, 211, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
|
||||
0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
|
||||
82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
|
||||
0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0,
|
||||
13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4,
|
||||
0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0,
|
||||
0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135,
|
||||
0, 0, 0, 120, 0, 0, 0, 120, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
|
||||
0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108,
|
||||
97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0,
|
||||
0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 1, 0, 0, 0, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240,
|
||||
0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 1, 0,
|
||||
0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0,
|
||||
0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 0, 0, 0, 0, 1, 0,
|
||||
0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 1, 0, 0, 0, 2, 0, 4, 38, 186, 81, 78, 16, 2, 1, 0, 0, 1, 0,
|
||||
1, 39, 0, 4, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 104, 192, 0, 0, 0, 242, 1, 70, 8, 32,
|
||||
0, 0, 0, 242, 1, 64, 40, 64, 0, 0, 0, 242, 1, 66, 72, 160, 0, 0, 0, 242, 1, 68, 1, 0, 6, 40,
|
||||
0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0
|
||||
};
|
||||
|
||||
static const Uint8 GLES2_FragmentTegra_Alpha_TextureSrc_[] = {
|
||||
71, 202, 114, 229, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
|
||||
0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
|
||||
82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
|
||||
0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0,
|
||||
13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4,
|
||||
0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0,
|
||||
0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135,
|
||||
0, 0, 0, 176, 0, 0, 0, 176, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
|
||||
0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108,
|
||||
97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0,
|
||||
0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 1, 118, 118, 17, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0,
|
||||
240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0,
|
||||
1, 0, 0, 0, 2, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16,
|
||||
0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 65, 37, 0, 0, 0, 0,
|
||||
8, 0, 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 2, 0, 1, 38, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 38, 186,
|
||||
81, 78, 16, 2, 1, 0, 0, 2, 0, 1, 39, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 1, 40, 1, 0, 0, 0, 5, 0,
|
||||
0, 0, 16, 0, 4, 40, 40, 160, 1, 0, 0, 242, 1, 66, 8, 192, 1, 0, 0, 242, 1, 64, 104, 32, 1, 0,
|
||||
0, 242, 1, 70, 72, 64, 1, 0, 0, 242, 1, 68, 154, 192, 0, 0, 37, 34, 64, 3, 8, 32, 0, 0, 5, 58,
|
||||
208, 4, 40, 64, 0, 0, 5, 50, 208, 4, 72, 160, 0, 0, 37, 42, 208, 4, 2, 0, 6, 40, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 2, 0, 1, 41, 0, 0, 0, 0, 5, 0, 2, 0
|
||||
};
|
||||
|
||||
static const Uint8 GLES2_FragmentTegra_Additive_TextureSrc_[] = {
|
||||
161, 234, 193, 234, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
|
||||
0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
|
||||
82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
|
||||
0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0,
|
||||
13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4,
|
||||
0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0,
|
||||
0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135,
|
||||
0, 0, 0, 176, 0, 0, 0, 176, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
|
||||
0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108,
|
||||
97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0,
|
||||
0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 1, 22, 22, 17, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240,
|
||||
0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0,
|
||||
0, 0, 2, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0,
|
||||
0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 65, 37, 0, 0, 0, 0, 8, 0,
|
||||
129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 2, 0, 1, 38, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 38, 186, 81,
|
||||
78, 16, 2, 1, 0, 0, 2, 0, 1, 39, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 1, 40, 1, 0, 0, 0, 5, 0, 0, 0,
|
||||
16, 0, 4, 40, 40, 160, 1, 0, 0, 242, 1, 66, 104, 32, 1, 0, 0, 242, 1, 70, 8, 192, 1, 0, 0, 242,
|
||||
1, 64, 72, 64, 1, 0, 0, 242, 1, 68, 136, 192, 0, 0, 0, 26, 64, 4, 136, 32, 0, 0, 0, 2, 64, 7,
|
||||
136, 64, 0, 0, 0, 10, 64, 6, 136, 160, 0, 0, 0, 18, 64, 5, 2, 0, 6, 40, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 2, 0, 1, 41, 0, 0, 0, 0, 5, 0, 2, 0
|
||||
};
|
||||
|
||||
static const Uint8 GLES2_FragmentTegra_Modulated_TextureSrc_[] = {
|
||||
75, 132, 201, 227, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0,
|
||||
0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0,
|
||||
82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0,
|
||||
0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0,
|
||||
13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4,
|
||||
0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0,
|
||||
0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135,
|
||||
0, 0, 0, 176, 0, 0, 0, 176, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21,
|
||||
0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108,
|
||||
97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0,
|
||||
0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 1, 32, 32, 17, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240,
|
||||
0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0,
|
||||
0, 0, 2, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0,
|
||||
0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 65, 37, 0, 0, 0, 0, 8, 0,
|
||||
129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 2, 0, 1, 38, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 38, 186, 81,
|
||||
78, 16, 2, 1, 0, 0, 2, 0, 1, 39, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 1, 40, 1, 0, 0, 0, 5, 0, 0, 0,
|
||||
16, 0, 4, 40, 40, 160, 1, 0, 0, 242, 1, 66, 8, 192, 1, 0, 0, 242, 1, 64, 104, 32, 1, 0, 0, 242,
|
||||
1, 70, 72, 64, 1, 0, 0, 242, 1, 68, 104, 192, 0, 0, 0, 242, 65, 4, 232, 32, 0, 0, 0, 242, 65,
|
||||
0, 40, 64, 0, 0, 0, 242, 65, 6, 72, 160, 0, 0, 0, 242, 65, 5, 2, 0, 6, 40, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 2, 0, 1, 41, 0, 0, 0, 0, 5, 0, 2, 0
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_VertexTegra_Default = {
|
||||
GL_VERTEX_SHADER,
|
||||
GL_NVIDIA_PLATFORM_BINARY_NV,
|
||||
sizeof(GLES2_VertexTegra_Default_),
|
||||
GLES2_VertexTegra_Default_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentTegra_None_SolidSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GL_NVIDIA_PLATFORM_BINARY_NV,
|
||||
sizeof(GLES2_FragmentTegra_None_SolidSrc_),
|
||||
GLES2_FragmentTegra_None_SolidSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentTegra_Alpha_SolidSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GL_NVIDIA_PLATFORM_BINARY_NV,
|
||||
sizeof(GLES2_FragmentTegra_Alpha_SolidSrc_),
|
||||
GLES2_FragmentTegra_Alpha_SolidSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentTegra_Additive_SolidSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GL_NVIDIA_PLATFORM_BINARY_NV,
|
||||
sizeof(GLES2_FragmentTegra_Additive_SolidSrc_),
|
||||
GLES2_FragmentTegra_Additive_SolidSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentTegra_Modulated_SolidSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GL_NVIDIA_PLATFORM_BINARY_NV,
|
||||
sizeof(GLES2_FragmentTegra_Modulated_SolidSrc_),
|
||||
GLES2_FragmentTegra_Modulated_SolidSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentTegra_None_TextureSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GL_NVIDIA_PLATFORM_BINARY_NV,
|
||||
sizeof(GLES2_FragmentTegra_None_TextureSrc_),
|
||||
GLES2_FragmentTegra_None_TextureSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentTegra_Alpha_TextureSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GL_NVIDIA_PLATFORM_BINARY_NV,
|
||||
sizeof(GLES2_FragmentTegra_Alpha_TextureSrc_),
|
||||
GLES2_FragmentTegra_Alpha_TextureSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentTegra_Additive_TextureSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GL_NVIDIA_PLATFORM_BINARY_NV,
|
||||
sizeof(GLES2_FragmentTegra_Additive_TextureSrc_),
|
||||
GLES2_FragmentTegra_Additive_TextureSrc_
|
||||
};
|
||||
|
||||
static const GLES2_ShaderInstance GLES2_FragmentTegra_Modulated_TextureSrc = {
|
||||
GL_FRAGMENT_SHADER,
|
||||
GL_NVIDIA_PLATFORM_BINARY_NV,
|
||||
sizeof(GLES2_FragmentTegra_Modulated_TextureSrc_),
|
||||
GLES2_FragmentTegra_Modulated_TextureSrc_
|
||||
};
|
||||
|
||||
#endif /* GLES2_INCLUDE_NVIDIA_SHADERS */
|
||||
|
||||
/*************************************************************************************************
|
||||
* Vertex/fragment shader definitions *
|
||||
*************************************************************************************************/
|
||||
|
||||
static GLES2_Shader GLES2_VertexShader_Default = {
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
2,
|
||||
#else
|
||||
1,
|
||||
#endif
|
||||
{
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
&GLES2_VertexTegra_Default,
|
||||
#endif
|
||||
&GLES2_VertexSrc_Default
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_None_SolidSrc = {
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
2,
|
||||
#else
|
||||
1,
|
||||
#endif
|
||||
{
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
&GLES2_FragmentTegra_None_SolidSrc,
|
||||
#endif
|
||||
&GLES2_FragmentSrc_SolidSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Alpha_SolidSrc = {
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
2,
|
||||
#else
|
||||
1,
|
||||
#endif
|
||||
{
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
&GLES2_FragmentTegra_Alpha_SolidSrc,
|
||||
#endif
|
||||
&GLES2_FragmentSrc_SolidSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Additive_SolidSrc = {
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
2,
|
||||
#else
|
||||
1,
|
||||
#endif
|
||||
{
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
&GLES2_FragmentTegra_Additive_SolidSrc,
|
||||
#endif
|
||||
&GLES2_FragmentSrc_SolidSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Modulated_SolidSrc = {
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
2,
|
||||
#else
|
||||
1,
|
||||
#endif
|
||||
{
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
&GLES2_FragmentTegra_Modulated_SolidSrc,
|
||||
#endif
|
||||
&GLES2_FragmentSrc_SolidSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_None_TextureABGRSrc = {
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
2,
|
||||
#else
|
||||
1,
|
||||
#endif
|
||||
{
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
&GLES2_FragmentTegra_None_TextureSrc,
|
||||
#endif
|
||||
&GLES2_FragmentSrc_TextureABGRSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Alpha_TextureABGRSrc = {
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
2,
|
||||
#else
|
||||
1,
|
||||
#endif
|
||||
{
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
&GLES2_FragmentTegra_Alpha_TextureSrc,
|
||||
#endif
|
||||
&GLES2_FragmentSrc_TextureABGRSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Additive_TextureABGRSrc = {
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
2,
|
||||
#else
|
||||
1,
|
||||
#endif
|
||||
{
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
&GLES2_FragmentTegra_Additive_TextureSrc,
|
||||
#endif
|
||||
&GLES2_FragmentSrc_TextureABGRSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Modulated_TextureABGRSrc = {
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
2,
|
||||
#else
|
||||
1,
|
||||
#endif
|
||||
{
|
||||
#if GLES2_INCLUDE_NVIDIA_SHADERS
|
||||
&GLES2_FragmentTegra_Modulated_TextureSrc,
|
||||
#endif
|
||||
&GLES2_FragmentSrc_TextureABGRSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_None_TextureARGBSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureARGBSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Alpha_TextureARGBSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureARGBSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Additive_TextureARGBSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureARGBSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Modulated_TextureARGBSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureARGBSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_None_TextureRGBSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureRGBSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Alpha_TextureRGBSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureRGBSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Additive_TextureRGBSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureRGBSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Modulated_TextureRGBSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureRGBSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_None_TextureBGRSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureBGRSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Alpha_TextureBGRSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureBGRSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Additive_TextureBGRSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureBGRSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_Modulated_TextureBGRSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureBGRSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureYUVSrc = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureYUVSrc
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV12Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV12Src
|
||||
}
|
||||
};
|
||||
|
||||
static GLES2_Shader GLES2_FragmentShader_TextureNV21Src = {
|
||||
1,
|
||||
{
|
||||
&GLES2_FragmentSrc_TextureNV21Src
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************************************
|
||||
* Shader selector *
|
||||
*************************************************************************************************/
|
||||
|
||||
const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMode)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GLES2_SHADER_VERTEX_DEFAULT:
|
||||
return &GLES2_VertexShader_Default;
|
||||
case GLES2_SHADER_FRAGMENT_SOLID_SRC:
|
||||
switch (blendMode)
|
||||
{
|
||||
case SDL_BLENDMODE_NONE:
|
||||
return &GLES2_FragmentShader_None_SolidSrc;
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
return &GLES2_FragmentShader_Alpha_SolidSrc;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
return &GLES2_FragmentShader_Additive_SolidSrc;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
return &GLES2_FragmentShader_Modulated_SolidSrc;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC:
|
||||
switch (blendMode)
|
||||
{
|
||||
case SDL_BLENDMODE_NONE:
|
||||
return &GLES2_FragmentShader_None_TextureABGRSrc;
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
return &GLES2_FragmentShader_Alpha_TextureABGRSrc;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
return &GLES2_FragmentShader_Additive_TextureABGRSrc;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
return &GLES2_FragmentShader_Modulated_TextureABGRSrc;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC:
|
||||
switch (blendMode)
|
||||
{
|
||||
case SDL_BLENDMODE_NONE:
|
||||
return &GLES2_FragmentShader_None_TextureARGBSrc;
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
return &GLES2_FragmentShader_Alpha_TextureARGBSrc;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
return &GLES2_FragmentShader_Additive_TextureARGBSrc;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
return &GLES2_FragmentShader_Modulated_TextureARGBSrc;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC:
|
||||
switch (blendMode)
|
||||
{
|
||||
case SDL_BLENDMODE_NONE:
|
||||
return &GLES2_FragmentShader_None_TextureRGBSrc;
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
return &GLES2_FragmentShader_Alpha_TextureRGBSrc;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
return &GLES2_FragmentShader_Additive_TextureRGBSrc;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
return &GLES2_FragmentShader_Modulated_TextureRGBSrc;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC:
|
||||
switch (blendMode)
|
||||
{
|
||||
case SDL_BLENDMODE_NONE:
|
||||
return &GLES2_FragmentShader_None_TextureBGRSrc;
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
return &GLES2_FragmentShader_Alpha_TextureBGRSrc;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
return &GLES2_FragmentShader_Additive_TextureBGRSrc;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
return &GLES2_FragmentShader_Modulated_TextureBGRSrc;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_SRC:
|
||||
{
|
||||
return &GLES2_FragmentShader_TextureYUVSrc;
|
||||
}
|
||||
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_SRC:
|
||||
{
|
||||
return &GLES2_FragmentShader_TextureNV12Src;
|
||||
}
|
||||
|
||||
case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_SRC:
|
||||
{
|
||||
return &GLES2_FragmentShader_TextureNV21Src;
|
||||
}
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
63
src/render/opengles2/SDL_shaders_gles2.h
Normal file
63
src/render/opengles2/SDL_shaders_gles2.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if SDL_VIDEO_RENDER_OGL_ES2
|
||||
|
||||
#ifndef SDL_shaderdata_h_
|
||||
#define SDL_shaderdata_h_
|
||||
|
||||
typedef struct GLES2_ShaderInstance
|
||||
{
|
||||
GLenum type;
|
||||
GLenum format;
|
||||
int length;
|
||||
const void *data;
|
||||
} GLES2_ShaderInstance;
|
||||
|
||||
typedef struct GLES2_Shader
|
||||
{
|
||||
int instance_count;
|
||||
const GLES2_ShaderInstance *instances[4];
|
||||
} GLES2_Shader;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GLES2_SHADER_VERTEX_DEFAULT,
|
||||
GLES2_SHADER_FRAGMENT_SOLID_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_YUV_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV12_SRC,
|
||||
GLES2_SHADER_FRAGMENT_TEXTURE_NV21_SRC
|
||||
} GLES2_ShaderType;
|
||||
|
||||
#define GLES2_SOURCE_SHADER (GLenum)-1
|
||||
|
||||
const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMode);
|
||||
|
||||
#endif /* SDL_shaderdata_h_ */
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_OGL_ES2 */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
1020
src/render/psp/SDL_render_psp.c
Normal file
1020
src/render/psp/SDL_render_psp.c
Normal file
File diff suppressed because it is too large
Load Diff
336
src/render/software/SDL_blendfillrect.c
Normal file
336
src/render/software/SDL_blendfillrect.c
Normal file
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendfillrect.h"
|
||||
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB555);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB555);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_RGB555);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB565);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB565);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_RGB565);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB888);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB888);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_RGB888);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_ARGB8888);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 2:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint16, DRAW_SETPIXEL_RGB);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
case 4:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_RGB);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 4:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGBA);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGBA);
|
||||
break;
|
||||
default:
|
||||
FILLRECT(Uint32, DRAW_SETPIXEL_RGBA);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_Rect clipped;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
return SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* If 'rect' == NULL, then fill the whole surface */
|
||||
if (rect) {
|
||||
/* Perform clipping */
|
||||
if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) {
|
||||
return 0;
|
||||
}
|
||||
rect = &clipped;
|
||||
} else {
|
||||
rect = &dst->clip_rect;
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(r, a);
|
||||
g = DRAW_MUL(g, a);
|
||||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
switch (dst->format->BitsPerPixel) {
|
||||
case 15:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x7C00:
|
||||
return SDL_BlendFillRect_RGB555(dst, rect, blendMode, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0xF800:
|
||||
return SDL_BlendFillRect_RGB565(dst, rect, blendMode, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x00FF0000:
|
||||
if (!dst->format->Amask) {
|
||||
return SDL_BlendFillRect_RGB888(dst, rect, blendMode, r, g, b, a);
|
||||
} else {
|
||||
return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!dst->format->Amask) {
|
||||
return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a);
|
||||
} else {
|
||||
return SDL_BlendFillRect_RGBA(dst, rect, blendMode, r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_Rect rect;
|
||||
int i;
|
||||
int (*func)(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
int status = 0;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(r, a);
|
||||
g = DRAW_MUL(g, a);
|
||||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
/* FIXME: Does this function pointer slow things down significantly? */
|
||||
switch (dst->format->BitsPerPixel) {
|
||||
case 15:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x7C00:
|
||||
func = SDL_BlendFillRect_RGB555;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0xF800:
|
||||
func = SDL_BlendFillRect_RGB565;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x00FF0000:
|
||||
if (!dst->format->Amask) {
|
||||
func = SDL_BlendFillRect_RGB888;
|
||||
} else {
|
||||
func = SDL_BlendFillRect_ARGB8888;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!func) {
|
||||
if (!dst->format->Amask) {
|
||||
func = SDL_BlendFillRect_RGB;
|
||||
} else {
|
||||
func = SDL_BlendFillRect_RGBA;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
/* Perform clipping */
|
||||
if (!SDL_IntersectRect(&rects[i], &dst->clip_rect, &rect)) {
|
||||
continue;
|
||||
}
|
||||
status = func(dst, &rect, blendMode, r, g, b, a);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif /* !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
27
src/render/software/SDL_blendfillrect.h
Normal file
27
src/render/software/SDL_blendfillrect.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
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);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
777
src/render/software/SDL_blendline.c
Normal file
777
src/render/software/SDL_blendline.c
Normal file
@@ -0,0 +1,777 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendline.h"
|
||||
#include "SDL_blendpoint.h"
|
||||
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY2_BLEND_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY2_ADD_RGB, DRAW_SETPIXELXY2_ADD_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY2_MOD_RGB, DRAW_SETPIXELXY2_MOD_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY2_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_BLEND_RGB555, DRAW_SETPIXELXY_BLEND_RGB555,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_ADD_RGB555, DRAW_SETPIXELXY_ADD_RGB555,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_MOD_RGB555, DRAW_SETPIXELXY_MOD_RGB555,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_RGB555, DRAW_SETPIXELXY_BLEND_RGB555,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_BLEND_RGB565, DRAW_SETPIXELXY_BLEND_RGB565,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_ADD_RGB565, DRAW_SETPIXELXY_ADD_RGB565,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_MOD_RGB565, DRAW_SETPIXELXY_MOD_RGB565,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_RGB565, DRAW_SETPIXELXY_BLEND_RGB565,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_BLEND_RGB, DRAW_SETPIXELXY4_BLEND_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_ADD_RGB, DRAW_SETPIXELXY4_ADD_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_MOD_RGB, DRAW_SETPIXELXY4_MOD_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_RGB, DRAW_SETPIXELXY4_BLEND_RGB,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_BLEND_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_ADD_RGBA, DRAW_SETPIXELXY4_ADD_RGBA,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_MOD_RGBA, DRAW_SETPIXELXY4_MOD_RGBA,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY4_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_BLEND_RGB888, DRAW_SETPIXELXY_BLEND_RGB888,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_ADD_RGB888, DRAW_SETPIXELXY_ADD_RGB888,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_MOD_RGB888, DRAW_SETPIXELXY_MOD_RGB888,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_RGB888, DRAW_SETPIXELXY_BLEND_RGB888,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(_r, _a);
|
||||
g = DRAW_MUL(_g, _a);
|
||||
b = DRAW_MUL(_b, _a);
|
||||
a = _a;
|
||||
} else {
|
||||
r = _r;
|
||||
g = _g;
|
||||
b = _b;
|
||||
a = _a;
|
||||
}
|
||||
inva = (a ^ 0xff);
|
||||
|
||||
if (y1 == y2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
|
||||
break;
|
||||
default:
|
||||
HLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (x1 == x2) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
|
||||
break;
|
||||
default:
|
||||
VLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
|
||||
break;
|
||||
}
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
|
||||
break;
|
||||
default:
|
||||
DLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_BLEND_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_ADD_ARGB8888, DRAW_SETPIXELXY_ADD_ARGB8888,
|
||||
draw_end);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_MOD_ARGB8888, DRAW_SETPIXELXY_MOD_ARGB8888,
|
||||
draw_end);
|
||||
break;
|
||||
default:
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_SETPIXELXY_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888,
|
||||
draw_end);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*BlendLineFunc) (SDL_Surface * dst,
|
||||
int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
|
||||
SDL_bool draw_end);
|
||||
|
||||
static BlendLineFunc
|
||||
SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt)
|
||||
{
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 2:
|
||||
if (fmt->Rmask == 0x7C00) {
|
||||
return SDL_BlendLine_RGB555;
|
||||
} else if (fmt->Rmask == 0xF800) {
|
||||
return SDL_BlendLine_RGB565;
|
||||
} else {
|
||||
return SDL_BlendLine_RGB2;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (fmt->Rmask == 0x00FF0000) {
|
||||
if (fmt->Amask) {
|
||||
return SDL_BlendLine_ARGB8888;
|
||||
} else {
|
||||
return SDL_BlendLine_RGB888;
|
||||
}
|
||||
} else {
|
||||
if (fmt->Amask) {
|
||||
return SDL_BlendLine_RGBA4;
|
||||
} else {
|
||||
return SDL_BlendLine_RGB4;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
BlendLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("SDL_BlendLine(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, SDL_TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
int i;
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
SDL_bool draw_end;
|
||||
BlendLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_BlendLines(): Unsupported surface format");
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
x1 = points[i-1].x;
|
||||
y1 = points[i-1].y;
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Draw the end if it was clipped */
|
||||
draw_end = (x2 != points[i].x || y2 != points[i].y);
|
||||
|
||||
func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end);
|
||||
}
|
||||
if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
|
||||
SDL_BlendPoint(dst, points[count-1].x, points[count-1].y,
|
||||
blendMode, r, g, b, a);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
27
src/render/software/SDL_blendline.h
Normal file
27
src/render/software/SDL_blendline.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
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);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
343
src/render/software/SDL_blendpoint.c
Normal file
343
src/render/software/SDL_blendpoint.c
Normal file
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendpoint.h"
|
||||
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY_BLEND_RGB555(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY_ADD_RGB555(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY_MOD_RGB555(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY_RGB555(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY_BLEND_RGB565(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY_ADD_RGB565(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY_MOD_RGB565(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY_RGB565(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY_BLEND_RGB888(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY_ADD_RGB888(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY_MOD_RGB888(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY_RGB888(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY_BLEND_ARGB8888(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY_ADD_ARGB8888(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY_MOD_ARGB8888(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY_ARGB8888(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 2:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY2_BLEND_RGB(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY2_ADD_RGB(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY2_MOD_RGB(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY2_RGB(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
case 4:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY4_BLEND_RGB(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY4_ADD_RGB(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY4_MOD_RGB(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY4_RGB(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 4:
|
||||
switch (blendMode) {
|
||||
case SDL_BLENDMODE_BLEND:
|
||||
DRAW_SETPIXELXY4_BLEND_RGBA(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_ADD:
|
||||
DRAW_SETPIXELXY4_ADD_RGBA(x, y);
|
||||
break;
|
||||
case SDL_BLENDMODE_MOD:
|
||||
DRAW_SETPIXELXY4_MOD_RGBA(x, y);
|
||||
break;
|
||||
default:
|
||||
DRAW_SETPIXELXY4_RGBA(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
if (!dst) {
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
return SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
|
||||
x >= (dst->clip_rect.x + dst->clip_rect.w) ||
|
||||
y >= (dst->clip_rect.y + dst->clip_rect.h)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(r, a);
|
||||
g = DRAW_MUL(g, a);
|
||||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
switch (dst->format->BitsPerPixel) {
|
||||
case 15:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x7C00:
|
||||
return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0xF800:
|
||||
return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x00FF0000:
|
||||
if (!dst->format->Amask) {
|
||||
return SDL_BlendPoint_RGB888(dst, x, y, blendMode, r, g, b,
|
||||
a);
|
||||
} else {
|
||||
return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b,
|
||||
a);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!dst->format->Amask) {
|
||||
return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a);
|
||||
} else {
|
||||
return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
int minx, miny;
|
||||
int maxx, maxy;
|
||||
int i;
|
||||
int x, y;
|
||||
int (*func)(SDL_Surface * dst, int x, int y,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
int status = 0;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
return SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
r = DRAW_MUL(r, a);
|
||||
g = DRAW_MUL(g, a);
|
||||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
/* FIXME: Does this function pointer slow things down significantly? */
|
||||
switch (dst->format->BitsPerPixel) {
|
||||
case 15:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x7C00:
|
||||
func = SDL_BlendPoint_RGB555;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0xF800:
|
||||
func = SDL_BlendPoint_RGB565;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
switch (dst->format->Rmask) {
|
||||
case 0x00FF0000:
|
||||
if (!dst->format->Amask) {
|
||||
func = SDL_BlendPoint_RGB888;
|
||||
} else {
|
||||
func = SDL_BlendPoint_ARGB8888;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!func) {
|
||||
if (!dst->format->Amask) {
|
||||
func = SDL_BlendPoint_RGB;
|
||||
} else {
|
||||
func = SDL_BlendPoint_RGBA;
|
||||
}
|
||||
}
|
||||
|
||||
minx = dst->clip_rect.x;
|
||||
maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
|
||||
miny = dst->clip_rect.y;
|
||||
maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
x = points[i].x;
|
||||
y = points[i].y;
|
||||
|
||||
if (x < minx || x > maxx || y < miny || y > maxy) {
|
||||
continue;
|
||||
}
|
||||
status = func(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif /* !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
27
src/render/software/SDL_blendpoint.h
Normal file
27
src/render/software/SDL_blendpoint.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
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);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
576
src/render/software/SDL_draw.h
Normal file
576
src/render/software/SDL_draw.h
Normal file
@@ -0,0 +1,576 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#include "../../video/SDL_blit.h"
|
||||
|
||||
/* This code assumes that r, g, b, a are the source color,
|
||||
* and in the blend and add case, the RGB values are premultiplied by a.
|
||||
*/
|
||||
|
||||
#define DRAW_MUL(_a, _b) (((unsigned)(_a)*(_b))/255)
|
||||
|
||||
#define DRAW_FASTSETPIXEL(type) \
|
||||
*pixel = (type) color
|
||||
|
||||
#define DRAW_FASTSETPIXEL1 DRAW_FASTSETPIXEL(Uint8)
|
||||
#define DRAW_FASTSETPIXEL2 DRAW_FASTSETPIXEL(Uint16)
|
||||
#define DRAW_FASTSETPIXEL4 DRAW_FASTSETPIXEL(Uint32)
|
||||
|
||||
#define DRAW_FASTSETPIXELXY(x, y, type, bpp, color) \
|
||||
*(type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
|
||||
+ (x) * bpp) = (type) color
|
||||
|
||||
#define DRAW_FASTSETPIXELXY1(x, y) DRAW_FASTSETPIXELXY(x, y, Uint8, 1, color)
|
||||
#define DRAW_FASTSETPIXELXY2(x, y) DRAW_FASTSETPIXELXY(x, y, Uint16, 2, color)
|
||||
#define DRAW_FASTSETPIXELXY4(x, y) DRAW_FASTSETPIXELXY(x, y, Uint32, 4, color)
|
||||
|
||||
#define DRAW_SETPIXEL(setpixel) \
|
||||
do { \
|
||||
unsigned sr = r, sg = g, sb = b, sa = a; (void) sa; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa = 0xFF; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(inva, sr) + r; \
|
||||
sg = DRAW_MUL(inva, sg) + g; \
|
||||
sb = DRAW_MUL(inva, sb) + b; \
|
||||
sa = DRAW_MUL(inva, sa) + a; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_ADD(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; (void) sa; \
|
||||
getpixel; \
|
||||
sr += r; if (sr > 0xff) sr = 0xff; \
|
||||
sg += g; if (sg > 0xff) sg = 0xff; \
|
||||
sb += b; if (sb > 0xff) sb = 0xff; \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXEL_MOD(getpixel, setpixel) \
|
||||
do { \
|
||||
unsigned sr, sg, sb, sa; (void) sa; \
|
||||
getpixel; \
|
||||
sr = DRAW_MUL(sr, r); \
|
||||
sg = DRAW_MUL(sg, g); \
|
||||
sb = DRAW_MUL(sb, b); \
|
||||
setpixel; \
|
||||
} while (0)
|
||||
|
||||
#define DRAW_SETPIXELXY(x, y, type, bpp, op) \
|
||||
do { \
|
||||
type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
|
||||
+ (x) * bpp); \
|
||||
op; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Define draw operators for RGB555
|
||||
*/
|
||||
|
||||
#define DRAW_SETPIXEL_RGB555 \
|
||||
DRAW_SETPIXEL(RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB555 \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB555 \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB555 \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
|
||||
RGB555_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXELXY_RGB555(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB555)
|
||||
|
||||
#define DRAW_SETPIXELXY_BLEND_RGB555(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB555)
|
||||
|
||||
#define DRAW_SETPIXELXY_ADD_RGB555(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB555)
|
||||
|
||||
#define DRAW_SETPIXELXY_MOD_RGB555(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB555)
|
||||
|
||||
/*
|
||||
* Define draw operators for RGB565
|
||||
*/
|
||||
|
||||
#define DRAW_SETPIXEL_RGB565 \
|
||||
DRAW_SETPIXEL(RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB565 \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB565 \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB565 \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
|
||||
RGB565_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXELXY_RGB565(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB565)
|
||||
|
||||
#define DRAW_SETPIXELXY_BLEND_RGB565(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB565)
|
||||
|
||||
#define DRAW_SETPIXELXY_ADD_RGB565(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB565)
|
||||
|
||||
#define DRAW_SETPIXELXY_MOD_RGB565(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB565)
|
||||
|
||||
/*
|
||||
* Define draw operators for RGB888
|
||||
*/
|
||||
|
||||
#define DRAW_SETPIXEL_RGB888 \
|
||||
DRAW_SETPIXEL(RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB888 \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB888 \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB888 \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
|
||||
RGB888_FROM_RGB(*pixel, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXELXY_RGB888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB888)
|
||||
|
||||
#define DRAW_SETPIXELXY_BLEND_RGB888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB888)
|
||||
|
||||
#define DRAW_SETPIXELXY_ADD_RGB888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB888)
|
||||
|
||||
#define DRAW_SETPIXELXY_MOD_RGB888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB888)
|
||||
|
||||
/*
|
||||
* Define draw operators for ARGB8888
|
||||
*/
|
||||
|
||||
#define DRAW_SETPIXEL_ARGB8888 \
|
||||
DRAW_SETPIXEL(ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_ARGB8888 \
|
||||
DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_ARGB8888 \
|
||||
DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_ARGB8888 \
|
||||
DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
|
||||
ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXELXY_ARGB8888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888)
|
||||
|
||||
#define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_ARGB8888)
|
||||
|
||||
#define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888)
|
||||
|
||||
#define DRAW_SETPIXELXY_MOD_ARGB8888(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_ARGB8888)
|
||||
|
||||
/*
|
||||
* Define draw operators for general RGB
|
||||
*/
|
||||
|
||||
#define DRAW_SETPIXEL_RGB \
|
||||
DRAW_SETPIXEL(PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGB \
|
||||
DRAW_SETPIXEL_BLEND(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGB \
|
||||
DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGB \
|
||||
DRAW_SETPIXEL_MOD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
|
||||
PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
|
||||
|
||||
#define DRAW_SETPIXELXY2_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY4_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY2_BLEND_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY4_BLEND_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY2_ADD_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY4_ADD_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY2_MOD_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB)
|
||||
|
||||
#define DRAW_SETPIXELXY4_MOD_RGB(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB)
|
||||
|
||||
|
||||
/*
|
||||
* Define draw operators for general RGBA
|
||||
*/
|
||||
|
||||
#define DRAW_SETPIXEL_RGBA \
|
||||
DRAW_SETPIXEL(PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_BLEND_RGBA \
|
||||
DRAW_SETPIXEL_BLEND(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_ADD_RGBA \
|
||||
DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXEL_MOD_RGBA \
|
||||
DRAW_SETPIXEL_MOD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
|
||||
PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
|
||||
|
||||
#define DRAW_SETPIXELXY4_RGBA(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGBA)
|
||||
|
||||
#define DRAW_SETPIXELXY4_BLEND_RGBA(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGBA)
|
||||
|
||||
#define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGBA)
|
||||
|
||||
#define DRAW_SETPIXELXY4_MOD_RGBA(x, y) \
|
||||
DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGBA)
|
||||
|
||||
/*
|
||||
* Define line drawing macro
|
||||
*/
|
||||
|
||||
#define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
|
||||
|
||||
/* Horizontal line */
|
||||
#define HLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (x1 <= x2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
length = draw_end ? (x2-x1+1) : (x2-x1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x2; \
|
||||
if (!draw_end) { \
|
||||
++pixel; \
|
||||
} \
|
||||
length = draw_end ? (x1-x2+1) : (x1-x2); \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
++pixel; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Vertical line */
|
||||
#define VLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
length = draw_end ? (y2-y1+1) : (y2-y1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y2 * pitch + x1; \
|
||||
if (!draw_end) { \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
length = draw_end ? (y1-y2+1) : (y1-y2); \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Diagonal line */
|
||||
#define DLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
if (x1 <= x2) { \
|
||||
++pitch; \
|
||||
} else { \
|
||||
--pitch; \
|
||||
} \
|
||||
length = (y2-y1); \
|
||||
} else { \
|
||||
pixel = (type *)dst->pixels + y2 * pitch + x2; \
|
||||
if (x2 <= x1) { \
|
||||
++pitch; \
|
||||
} else { \
|
||||
--pitch; \
|
||||
} \
|
||||
if (!draw_end) { \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
length = (y1-y2); \
|
||||
} \
|
||||
if (draw_end) { \
|
||||
++length; \
|
||||
} \
|
||||
while (length--) { \
|
||||
op; \
|
||||
pixel += pitch; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Bresenham's line algorithm */
|
||||
#define BLINE(x1, y1, x2, y2, op, draw_end) \
|
||||
{ \
|
||||
int i, deltax, deltay, numpixels; \
|
||||
int d, dinc1, dinc2; \
|
||||
int x, xinc1, xinc2; \
|
||||
int y, yinc1, yinc2; \
|
||||
\
|
||||
deltax = ABS(x2 - x1); \
|
||||
deltay = ABS(y2 - y1); \
|
||||
\
|
||||
if (deltax >= deltay) { \
|
||||
numpixels = deltax + 1; \
|
||||
d = (2 * deltay) - deltax; \
|
||||
dinc1 = deltay * 2; \
|
||||
dinc2 = (deltay - deltax) * 2; \
|
||||
xinc1 = 1; \
|
||||
xinc2 = 1; \
|
||||
yinc1 = 0; \
|
||||
yinc2 = 1; \
|
||||
} else { \
|
||||
numpixels = deltay + 1; \
|
||||
d = (2 * deltax) - deltay; \
|
||||
dinc1 = deltax * 2; \
|
||||
dinc2 = (deltax - deltay) * 2; \
|
||||
xinc1 = 0; \
|
||||
xinc2 = 1; \
|
||||
yinc1 = 1; \
|
||||
yinc2 = 1; \
|
||||
} \
|
||||
\
|
||||
if (x1 > x2) { \
|
||||
xinc1 = -xinc1; \
|
||||
xinc2 = -xinc2; \
|
||||
} \
|
||||
if (y1 > y2) { \
|
||||
yinc1 = -yinc1; \
|
||||
yinc2 = -yinc2; \
|
||||
} \
|
||||
\
|
||||
x = x1; \
|
||||
y = y1; \
|
||||
\
|
||||
if (!draw_end) { \
|
||||
--numpixels; \
|
||||
} \
|
||||
for (i = 0; i < numpixels; ++i) { \
|
||||
op(x, y); \
|
||||
if (d < 0) { \
|
||||
d += dinc1; \
|
||||
x += xinc1; \
|
||||
y += yinc1; \
|
||||
} else { \
|
||||
d += dinc2; \
|
||||
x += xinc2; \
|
||||
y += yinc2; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Xiaolin Wu's line algorithm, based on Michael Abrash's implementation */
|
||||
#define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
{ \
|
||||
Uint16 ErrorAdj, ErrorAcc; \
|
||||
Uint16 ErrorAccTemp, Weighting; \
|
||||
int DeltaX, DeltaY, Temp, XDir; \
|
||||
unsigned r, g, b, a, inva; \
|
||||
\
|
||||
/* Draw the initial pixel, which is always exactly intersected by \
|
||||
the line and so needs no weighting */ \
|
||||
opaque_op(x1, y1); \
|
||||
\
|
||||
/* Draw the final pixel, which is always exactly intersected by the line \
|
||||
and so needs no weighting */ \
|
||||
if (draw_end) { \
|
||||
opaque_op(x2, y2); \
|
||||
} \
|
||||
\
|
||||
/* Make sure the line runs top to bottom */ \
|
||||
if (y1 > y2) { \
|
||||
Temp = y1; y1 = y2; y2 = Temp; \
|
||||
Temp = x1; x1 = x2; x2 = Temp; \
|
||||
} \
|
||||
DeltaY = y2 - y1; \
|
||||
\
|
||||
if ((DeltaX = x2 - x1) >= 0) { \
|
||||
XDir = 1; \
|
||||
} else { \
|
||||
XDir = -1; \
|
||||
DeltaX = -DeltaX; /* make DeltaX positive */ \
|
||||
} \
|
||||
\
|
||||
/* line is not horizontal, diagonal, or vertical */ \
|
||||
ErrorAcc = 0; /* initialize the line error accumulator to 0 */ \
|
||||
\
|
||||
/* Is this an X-major or Y-major line? */ \
|
||||
if (DeltaY > DeltaX) { \
|
||||
/* Y-major line; calculate 16-bit fixed-point fractional part of a \
|
||||
pixel that X advances each time Y advances 1 pixel, truncating the \
|
||||
result so that we won't overrun the endpoint along the X axis */ \
|
||||
ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY; \
|
||||
/* Draw all pixels other than the first and last */ \
|
||||
while (--DeltaY) { \
|
||||
ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
|
||||
ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
|
||||
if (ErrorAcc <= ErrorAccTemp) { \
|
||||
/* The error accumulator turned over, so advance the X coord */ \
|
||||
x1 += XDir; \
|
||||
} \
|
||||
y1++; /* Y-major, so always advance Y */ \
|
||||
/* The IntensityBits most significant bits of ErrorAcc give us the \
|
||||
intensity weighting for this pixel, and the complement of the \
|
||||
weighting for the paired pixel */ \
|
||||
Weighting = ErrorAcc >> 8; \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, (Weighting ^ 255)); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1); \
|
||||
} \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, Weighting); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1 + XDir, y1); \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
/* X-major line; calculate 16-bit fixed-point fractional part of a \
|
||||
pixel that Y advances each time X advances 1 pixel, truncating the \
|
||||
result to avoid overrunning the endpoint along the X axis */ \
|
||||
ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX; \
|
||||
/* Draw all pixels other than the first and last */ \
|
||||
while (--DeltaX) { \
|
||||
ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
|
||||
ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
|
||||
if (ErrorAcc <= ErrorAccTemp) { \
|
||||
/* The error accumulator turned over, so advance the Y coord */ \
|
||||
y1++; \
|
||||
} \
|
||||
x1 += XDir; /* X-major, so always advance X */ \
|
||||
/* The IntensityBits most significant bits of ErrorAcc give us the \
|
||||
intensity weighting for this pixel, and the complement of the \
|
||||
weighting for the paired pixel */ \
|
||||
Weighting = ErrorAcc >> 8; \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, (Weighting ^ 255)); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1); \
|
||||
} \
|
||||
{ \
|
||||
a = DRAW_MUL(_a, Weighting); \
|
||||
r = DRAW_MUL(_r, a); \
|
||||
g = DRAW_MUL(_g, a); \
|
||||
b = DRAW_MUL(_b, a); \
|
||||
inva = (a ^ 0xFF); \
|
||||
blend_op(x1, y1 + 1); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifdef AA_LINES
|
||||
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
|
||||
#else
|
||||
#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
|
||||
BLINE(x1, y1, x2, y2, opaque_op, draw_end)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define fill rect macro
|
||||
*/
|
||||
|
||||
#define FILLRECT(type, op) \
|
||||
do { \
|
||||
int width = rect->w; \
|
||||
int height = rect->h; \
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel); \
|
||||
int skip = pitch - width; \
|
||||
type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
|
||||
while (height--) { \
|
||||
{ int n = (width+3)/4; \
|
||||
switch (width & 3) { \
|
||||
case 0: do { op; pixel++; \
|
||||
case 3: op; pixel++; \
|
||||
case 2: op; pixel++; \
|
||||
case 1: op; pixel++; \
|
||||
} while ( --n > 0 ); \
|
||||
} \
|
||||
} \
|
||||
pixel += skip; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
209
src/render/software/SDL_drawline.c
Normal file
209
src/render/software/SDL_drawline.c
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_drawline.h"
|
||||
#include "SDL_drawpoint.h"
|
||||
|
||||
|
||||
static void
|
||||
SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
if (y1 == y2) {
|
||||
int length;
|
||||
int pitch = (dst->pitch / dst->format->BytesPerPixel);
|
||||
Uint8 *pixel;
|
||||
if (x1 <= x2) {
|
||||
pixel = (Uint8 *)dst->pixels + y1 * pitch + x1;
|
||||
length = draw_end ? (x2-x1+1) : (x2-x1);
|
||||
} else {
|
||||
pixel = (Uint8 *)dst->pixels + y1 * pitch + x2;
|
||||
if (!draw_end) {
|
||||
++pixel;
|
||||
}
|
||||
length = draw_end ? (x1-x2+1) : (x1-x2);
|
||||
}
|
||||
SDL_memset(pixel, color, length);
|
||||
} else if (x1 == x2) {
|
||||
VLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end);
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
DLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end);
|
||||
} else {
|
||||
BLINE(x1, y1, x2, y2, DRAW_FASTSETPIXELXY1, draw_end);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
if (y1 == y2) {
|
||||
HLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
||||
} else if (x1 == x2) {
|
||||
VLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
DLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
||||
} else {
|
||||
Uint8 _r, _g, _b, _a;
|
||||
const SDL_PixelFormat * fmt = dst->format;
|
||||
SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
|
||||
if (fmt->Rmask == 0x7C00) {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB555,
|
||||
draw_end);
|
||||
} else if (fmt->Rmask == 0xF800) {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB565,
|
||||
draw_end);
|
||||
} else {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY2_BLEND_RGB,
|
||||
draw_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
if (y1 == y2) {
|
||||
HLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
||||
} else if (x1 == x2) {
|
||||
VLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
||||
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
|
||||
DLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
||||
} else {
|
||||
Uint8 _r, _g, _b, _a;
|
||||
const SDL_PixelFormat * fmt = dst->format;
|
||||
SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
|
||||
if (fmt->Rmask == 0x00FF0000) {
|
||||
if (!fmt->Amask) {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY_BLEND_RGB888,
|
||||
draw_end);
|
||||
} else {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY_BLEND_ARGB8888,
|
||||
draw_end);
|
||||
}
|
||||
} else {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY4_BLEND_RGB,
|
||||
draw_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*DrawLineFunc) (SDL_Surface * dst,
|
||||
int x1, int y1, int x2, int y2,
|
||||
Uint32 color, SDL_bool draw_end);
|
||||
|
||||
static DrawLineFunc
|
||||
SDL_CalculateDrawLineFunc(const SDL_PixelFormat * fmt)
|
||||
{
|
||||
switch (fmt->BytesPerPixel) {
|
||||
case 1:
|
||||
if (fmt->BitsPerPixel < 8) {
|
||||
break;
|
||||
}
|
||||
return SDL_DrawLine1;
|
||||
case 2:
|
||||
return SDL_DrawLine2;
|
||||
case 4:
|
||||
return SDL_DrawLine4;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
{
|
||||
DrawLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("SDL_DrawLine(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
func(dst, x1, y1, x2, y2, color, SDL_TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
Uint32 color)
|
||||
{
|
||||
int i;
|
||||
int x1, y1;
|
||||
int x2, y2;
|
||||
SDL_bool draw_end;
|
||||
DrawLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("SDL_DrawLines(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_DrawLines(): Unsupported surface format");
|
||||
}
|
||||
|
||||
for (i = 1; i < count; ++i) {
|
||||
x1 = points[i-1].x;
|
||||
y1 = points[i-1].y;
|
||||
x2 = points[i].x;
|
||||
y2 = points[i].y;
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Draw the end if it was clipped */
|
||||
draw_end = (x2 != points[i].x || y2 != points[i].y);
|
||||
|
||||
func(dst, x1, y1, x2, y2, color, draw_end);
|
||||
}
|
||||
if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
|
||||
SDL_DrawPoint(dst, points[count-1].x, points[count-1].y, color);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
27
src/render/software/SDL_drawline.h
Normal file
27
src/render/software/SDL_drawline.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
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);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
114
src/render/software/SDL_drawpoint.c
Normal file
114
src/render/software/SDL_drawpoint.c
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_drawpoint.h"
|
||||
|
||||
|
||||
int
|
||||
SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
|
||||
{
|
||||
if (!dst) {
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
return SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
|
||||
x >= (dst->clip_rect.x + dst->clip_rect.w) ||
|
||||
y >= (dst->clip_rect.y + dst->clip_rect.h)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (dst->format->BytesPerPixel) {
|
||||
case 1:
|
||||
DRAW_FASTSETPIXELXY1(x, y);
|
||||
break;
|
||||
case 2:
|
||||
DRAW_FASTSETPIXELXY2(x, y);
|
||||
break;
|
||||
case 3:
|
||||
return SDL_Unsupported();
|
||||
case 4:
|
||||
DRAW_FASTSETPIXELXY4(x, y);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
Uint32 color)
|
||||
{
|
||||
int minx, miny;
|
||||
int maxx, maxy;
|
||||
int i;
|
||||
int x, y;
|
||||
|
||||
if (!dst) {
|
||||
return SDL_SetError("Passed NULL destination surface");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->BitsPerPixel < 8) {
|
||||
return SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
|
||||
}
|
||||
|
||||
minx = dst->clip_rect.x;
|
||||
maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
|
||||
miny = dst->clip_rect.y;
|
||||
maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
x = points[i].x;
|
||||
y = points[i].y;
|
||||
|
||||
if (x < minx || x > maxx || y < miny || y > maxy) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (dst->format->BytesPerPixel) {
|
||||
case 1:
|
||||
DRAW_FASTSETPIXELXY1(x, y);
|
||||
break;
|
||||
case 2:
|
||||
DRAW_FASTSETPIXELXY2(x, y);
|
||||
break;
|
||||
case 3:
|
||||
return SDL_Unsupported();
|
||||
case 4:
|
||||
DRAW_FASTSETPIXELXY4(x, y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
27
src/render/software/SDL_drawpoint.h
Normal file
27
src/render/software/SDL_drawpoint.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
|
||||
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);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
726
src/render/software/SDL_render_sw.c
Normal file
726
src/render/software/SDL_render_sw.c
Normal file
@@ -0,0 +1,726 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if !SDL_RENDER_DISABLED
|
||||
|
||||
#include "../SDL_sysrender.h"
|
||||
#include "SDL_render_sw_c.h"
|
||||
#include "SDL_hints.h"
|
||||
|
||||
#include "SDL_draw.h"
|
||||
#include "SDL_blendfillrect.h"
|
||||
#include "SDL_blendline.h"
|
||||
#include "SDL_blendpoint.h"
|
||||
#include "SDL_drawline.h"
|
||||
#include "SDL_drawpoint.h"
|
||||
#include "SDL_rotate.h"
|
||||
|
||||
/* SDL surface based renderer implementation */
|
||||
|
||||
static SDL_Renderer *SW_CreateRenderer(SDL_Window * window, Uint32 flags);
|
||||
static void SW_WindowEvent(SDL_Renderer * renderer,
|
||||
const SDL_WindowEvent *event);
|
||||
static int SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h);
|
||||
static int SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
static int SW_SetTextureColorMod(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
static int SW_SetTextureAlphaMod(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
static int SW_SetTextureBlendMode(SDL_Renderer * renderer,
|
||||
SDL_Texture * texture);
|
||||
static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels,
|
||||
int pitch);
|
||||
static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch);
|
||||
static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
static int SW_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
static int SW_UpdateViewport(SDL_Renderer * renderer);
|
||||
static int SW_UpdateClipRect(SDL_Renderer * renderer);
|
||||
static int SW_RenderClear(SDL_Renderer * renderer);
|
||||
static int SW_RenderDrawPoints(SDL_Renderer * renderer,
|
||||
const SDL_FPoint * points, int count);
|
||||
static int SW_RenderDrawLines(SDL_Renderer * renderer,
|
||||
const SDL_FPoint * points, int count);
|
||||
static int SW_RenderFillRects(SDL_Renderer * renderer,
|
||||
const SDL_FRect * rects, int count);
|
||||
static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect);
|
||||
static int SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect,
|
||||
const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip);
|
||||
static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch);
|
||||
static void SW_RenderPresent(SDL_Renderer * renderer);
|
||||
static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
|
||||
static void SW_DestroyRenderer(SDL_Renderer * renderer);
|
||||
|
||||
|
||||
SDL_RenderDriver SW_RenderDriver = {
|
||||
SW_CreateRenderer,
|
||||
{
|
||||
"software",
|
||||
SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE,
|
||||
8,
|
||||
{
|
||||
SDL_PIXELFORMAT_ARGB8888,
|
||||
SDL_PIXELFORMAT_ABGR8888,
|
||||
SDL_PIXELFORMAT_RGBA8888,
|
||||
SDL_PIXELFORMAT_BGRA8888,
|
||||
SDL_PIXELFORMAT_RGB888,
|
||||
SDL_PIXELFORMAT_BGR888,
|
||||
SDL_PIXELFORMAT_RGB565,
|
||||
SDL_PIXELFORMAT_RGB555
|
||||
},
|
||||
0,
|
||||
0}
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
SDL_Surface *window;
|
||||
} SW_RenderData;
|
||||
|
||||
|
||||
static SDL_Surface *
|
||||
SW_ActivateRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
|
||||
if (!data->surface) {
|
||||
data->surface = data->window;
|
||||
}
|
||||
if (!data->surface) {
|
||||
SDL_Surface *surface = SDL_GetWindowSurface(renderer->window);
|
||||
if (surface) {
|
||||
data->surface = data->window = surface;
|
||||
|
||||
SW_UpdateViewport(renderer);
|
||||
SW_UpdateClipRect(renderer);
|
||||
}
|
||||
}
|
||||
return data->surface;
|
||||
}
|
||||
|
||||
SDL_Renderer *
|
||||
SW_CreateRendererForSurface(SDL_Surface * surface)
|
||||
{
|
||||
SDL_Renderer *renderer;
|
||||
SW_RenderData *data;
|
||||
|
||||
if (!surface) {
|
||||
SDL_SetError("Can't create renderer for NULL surface");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (SW_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
SW_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
data->surface = surface;
|
||||
data->window = surface;
|
||||
|
||||
renderer->WindowEvent = SW_WindowEvent;
|
||||
renderer->GetOutputSize = SW_GetOutputSize;
|
||||
renderer->CreateTexture = SW_CreateTexture;
|
||||
renderer->SetTextureColorMod = SW_SetTextureColorMod;
|
||||
renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod;
|
||||
renderer->SetTextureBlendMode = SW_SetTextureBlendMode;
|
||||
renderer->UpdateTexture = SW_UpdateTexture;
|
||||
renderer->LockTexture = SW_LockTexture;
|
||||
renderer->UnlockTexture = SW_UnlockTexture;
|
||||
renderer->SetRenderTarget = SW_SetRenderTarget;
|
||||
renderer->UpdateViewport = SW_UpdateViewport;
|
||||
renderer->UpdateClipRect = SW_UpdateClipRect;
|
||||
renderer->RenderClear = SW_RenderClear;
|
||||
renderer->RenderDrawPoints = SW_RenderDrawPoints;
|
||||
renderer->RenderDrawLines = SW_RenderDrawLines;
|
||||
renderer->RenderFillRects = SW_RenderFillRects;
|
||||
renderer->RenderCopy = SW_RenderCopy;
|
||||
renderer->RenderCopyEx = SW_RenderCopyEx;
|
||||
renderer->RenderReadPixels = SW_RenderReadPixels;
|
||||
renderer->RenderPresent = SW_RenderPresent;
|
||||
renderer->DestroyTexture = SW_DestroyTexture;
|
||||
renderer->DestroyRenderer = SW_DestroyRenderer;
|
||||
renderer->info = SW_RenderDriver.info;
|
||||
renderer->driverdata = data;
|
||||
|
||||
SW_ActivateRenderer(renderer);
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
||||
SDL_Renderer *
|
||||
SW_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
|
||||
surface = SDL_GetWindowSurface(window);
|
||||
if (!surface) {
|
||||
return NULL;
|
||||
}
|
||||
return SW_CreateRendererForSurface(surface);
|
||||
}
|
||||
|
||||
static void
|
||||
SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
|
||||
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||
data->surface = NULL;
|
||||
data->window = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
|
||||
if (surface) {
|
||||
if (w) {
|
||||
*w = surface->w;
|
||||
}
|
||||
if (h) {
|
||||
*h = surface->h;
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
SDL_SetError("Software renderer doesn't have an output surface");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
||||
if (!SDL_PixelFormatEnumToMasks
|
||||
(texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
|
||||
return SDL_SetError("Unknown texture format");
|
||||
}
|
||||
|
||||
texture->driverdata =
|
||||
SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask,
|
||||
Bmask, Amask);
|
||||
SDL_SetSurfaceColorMod(texture->driverdata, texture->r, texture->g,
|
||||
texture->b);
|
||||
SDL_SetSurfaceAlphaMod(texture->driverdata, texture->a);
|
||||
SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode);
|
||||
|
||||
if (texture->access == SDL_TEXTUREACCESS_STATIC) {
|
||||
SDL_SetSurfaceRLE(texture->driverdata, 1);
|
||||
}
|
||||
|
||||
if (!texture->driverdata) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
return SDL_SetSurfaceColorMod(surface, texture->r, texture->g,
|
||||
texture->b);
|
||||
}
|
||||
|
||||
static int
|
||||
SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
return SDL_SetSurfaceAlphaMod(surface, texture->a);
|
||||
}
|
||||
|
||||
static int
|
||||
SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
|
||||
}
|
||||
|
||||
static int
|
||||
SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, const void *pixels, int pitch)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
Uint8 *src, *dst;
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
if(SDL_MUSTLOCK(surface))
|
||||
SDL_LockSurface(surface);
|
||||
src = (Uint8 *) pixels;
|
||||
dst = (Uint8 *) surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel;
|
||||
length = rect->w * surface->format->BytesPerPixel;
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += pitch;
|
||||
dst += surface->pitch;
|
||||
}
|
||||
if(SDL_MUSTLOCK(surface))
|
||||
SDL_UnlockSurface(surface);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * rect, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
|
||||
*pixels =
|
||||
(void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel);
|
||||
*pitch = surface->pitch;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
SW_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
|
||||
if (texture ) {
|
||||
data->surface = (SDL_Surface *) texture->driverdata;
|
||||
} else {
|
||||
data->surface = data->window;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_UpdateViewport(SDL_Renderer * renderer)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
SDL_Surface *surface = data->surface;
|
||||
|
||||
if (!surface) {
|
||||
/* We'll update the viewport after we recreate the surface */
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_SetClipRect(data->surface, &renderer->viewport);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_UpdateClipRect(SDL_Renderer * renderer)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
SDL_Surface *surface = data->surface;
|
||||
if (surface) {
|
||||
if (renderer->clipping_enabled) {
|
||||
SDL_SetClipRect(surface, &renderer->clip_rect);
|
||||
} else {
|
||||
SDL_SetClipRect(surface, NULL);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderClear(SDL_Renderer * renderer)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
Uint32 color;
|
||||
SDL_Rect clip_rect;
|
||||
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
color = SDL_MapRGBA(surface->format,
|
||||
renderer->r, renderer->g, renderer->b, renderer->a);
|
||||
|
||||
/* By definition the clear ignores the clip rect */
|
||||
clip_rect = surface->clip_rect;
|
||||
SDL_SetClipRect(surface, NULL);
|
||||
SDL_FillRect(surface, NULL, color);
|
||||
SDL_SetClipRect(surface, &clip_rect);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points,
|
||||
int count)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
SDL_Point *final_points;
|
||||
int i, status;
|
||||
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
final_points = SDL_stack_alloc(SDL_Point, count);
|
||||
if (!final_points) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
int x = renderer->viewport.x;
|
||||
int y = renderer->viewport.y;
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
final_points[i].x = (int)(x + points[i].x);
|
||||
final_points[i].y = (int)(y + points[i].y);
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < count; ++i) {
|
||||
final_points[i].x = (int)points[i].x;
|
||||
final_points[i].y = (int)points[i].y;
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw the points! */
|
||||
if (renderer->blendMode == SDL_BLENDMODE_NONE) {
|
||||
Uint32 color = SDL_MapRGBA(surface->format,
|
||||
renderer->r, renderer->g, renderer->b,
|
||||
renderer->a);
|
||||
|
||||
status = SDL_DrawPoints(surface, final_points, count, color);
|
||||
} else {
|
||||
status = SDL_BlendPoints(surface, final_points, count,
|
||||
renderer->blendMode,
|
||||
renderer->r, renderer->g, renderer->b,
|
||||
renderer->a);
|
||||
}
|
||||
SDL_stack_free(final_points);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points,
|
||||
int count)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
SDL_Point *final_points;
|
||||
int i, status;
|
||||
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
final_points = SDL_stack_alloc(SDL_Point, count);
|
||||
if (!final_points) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
int x = renderer->viewport.x;
|
||||
int y = renderer->viewport.y;
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
final_points[i].x = (int)(x + points[i].x);
|
||||
final_points[i].y = (int)(y + points[i].y);
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < count; ++i) {
|
||||
final_points[i].x = (int)points[i].x;
|
||||
final_points[i].y = (int)points[i].y;
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw the lines! */
|
||||
if (renderer->blendMode == SDL_BLENDMODE_NONE) {
|
||||
Uint32 color = SDL_MapRGBA(surface->format,
|
||||
renderer->r, renderer->g, renderer->b,
|
||||
renderer->a);
|
||||
|
||||
status = SDL_DrawLines(surface, final_points, count, color);
|
||||
} else {
|
||||
status = SDL_BlendLines(surface, final_points, count,
|
||||
renderer->blendMode,
|
||||
renderer->r, renderer->g, renderer->b,
|
||||
renderer->a);
|
||||
}
|
||||
SDL_stack_free(final_points);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
SDL_Rect *final_rects;
|
||||
int i, status;
|
||||
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
final_rects = SDL_stack_alloc(SDL_Rect, count);
|
||||
if (!final_rects) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
int x = renderer->viewport.x;
|
||||
int y = renderer->viewport.y;
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
final_rects[i].x = (int)(x + rects[i].x);
|
||||
final_rects[i].y = (int)(y + rects[i].y);
|
||||
final_rects[i].w = SDL_max((int)rects[i].w, 1);
|
||||
final_rects[i].h = SDL_max((int)rects[i].h, 1);
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < count; ++i) {
|
||||
final_rects[i].x = (int)rects[i].x;
|
||||
final_rects[i].y = (int)rects[i].y;
|
||||
final_rects[i].w = SDL_max((int)rects[i].w, 1);
|
||||
final_rects[i].h = SDL_max((int)rects[i].h, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (renderer->blendMode == SDL_BLENDMODE_NONE) {
|
||||
Uint32 color = SDL_MapRGBA(surface->format,
|
||||
renderer->r, renderer->g, renderer->b,
|
||||
renderer->a);
|
||||
status = SDL_FillRects(surface, final_rects, count, color);
|
||||
} else {
|
||||
status = SDL_BlendFillRects(surface, final_rects, count,
|
||||
renderer->blendMode,
|
||||
renderer->r, renderer->g, renderer->b,
|
||||
renderer->a);
|
||||
}
|
||||
SDL_stack_free(final_rects);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
SDL_Surface *src = (SDL_Surface *) texture->driverdata;
|
||||
SDL_Rect final_rect;
|
||||
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
final_rect.x = (int)(renderer->viewport.x + dstrect->x);
|
||||
final_rect.y = (int)(renderer->viewport.y + dstrect->y);
|
||||
} else {
|
||||
final_rect.x = (int)dstrect->x;
|
||||
final_rect.y = (int)dstrect->y;
|
||||
}
|
||||
final_rect.w = (int)dstrect->w;
|
||||
final_rect.h = (int)dstrect->h;
|
||||
|
||||
if ( srcrect->w == final_rect.w && srcrect->h == final_rect.h ) {
|
||||
return SDL_BlitSurface(src, srcrect, surface, &final_rect);
|
||||
} else {
|
||||
return SDL_BlitScaled(src, srcrect, surface, &final_rect);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
GetScaleQuality(void)
|
||||
{
|
||||
const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
|
||||
|
||||
if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_FRect * dstrect,
|
||||
const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
SDL_Surface *src = (SDL_Surface *) texture->driverdata;
|
||||
SDL_Rect final_rect, tmp_rect;
|
||||
SDL_Surface *surface_rotated, *surface_scaled;
|
||||
Uint32 colorkey;
|
||||
int retval, dstwidth, dstheight, abscenterx, abscentery;
|
||||
double cangle, sangle, px, py, p1x, p1y, p2x, p2y, p3x, p3y, p4x, p4y;
|
||||
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
final_rect.x = (int)(renderer->viewport.x + dstrect->x);
|
||||
final_rect.y = (int)(renderer->viewport.y + dstrect->y);
|
||||
} else {
|
||||
final_rect.x = (int)dstrect->x;
|
||||
final_rect.y = (int)dstrect->y;
|
||||
}
|
||||
final_rect.w = (int)dstrect->w;
|
||||
final_rect.h = (int)dstrect->h;
|
||||
|
||||
surface_scaled = SDL_CreateRGBSurface(SDL_SWSURFACE, final_rect.w, final_rect.h, src->format->BitsPerPixel,
|
||||
src->format->Rmask, src->format->Gmask,
|
||||
src->format->Bmask, src->format->Amask );
|
||||
if (surface_scaled) {
|
||||
SDL_GetColorKey(src, &colorkey);
|
||||
SDL_SetColorKey(surface_scaled, SDL_TRUE, colorkey);
|
||||
tmp_rect = final_rect;
|
||||
tmp_rect.x = 0;
|
||||
tmp_rect.y = 0;
|
||||
|
||||
retval = SDL_BlitScaled(src, srcrect, surface_scaled, &tmp_rect);
|
||||
if (!retval) {
|
||||
SDLgfx_rotozoomSurfaceSizeTrig(tmp_rect.w, tmp_rect.h, -angle, &dstwidth, &dstheight, &cangle, &sangle);
|
||||
surface_rotated = SDLgfx_rotateSurface(surface_scaled, -angle, dstwidth/2, dstheight/2, GetScaleQuality(), flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, dstwidth, dstheight, cangle, sangle);
|
||||
if(surface_rotated) {
|
||||
/* Find out where the new origin is by rotating the four final_rect points around the center and then taking the extremes */
|
||||
abscenterx = final_rect.x + (int)center->x;
|
||||
abscentery = final_rect.y + (int)center->y;
|
||||
/* Compensate the angle inversion to match the behaviour of the other backends */
|
||||
sangle = -sangle;
|
||||
|
||||
/* Top Left */
|
||||
px = final_rect.x - abscenterx;
|
||||
py = final_rect.y - abscentery;
|
||||
p1x = px * cangle - py * sangle + abscenterx;
|
||||
p1y = px * sangle + py * cangle + abscentery;
|
||||
|
||||
/* Top Right */
|
||||
px = final_rect.x + final_rect.w - abscenterx;
|
||||
py = final_rect.y - abscentery;
|
||||
p2x = px * cangle - py * sangle + abscenterx;
|
||||
p2y = px * sangle + py * cangle + abscentery;
|
||||
|
||||
/* Bottom Left */
|
||||
px = final_rect.x - abscenterx;
|
||||
py = final_rect.y + final_rect.h - abscentery;
|
||||
p3x = px * cangle - py * sangle + abscenterx;
|
||||
p3y = px * sangle + py * cangle + abscentery;
|
||||
|
||||
/* Bottom Right */
|
||||
px = final_rect.x + final_rect.w - abscenterx;
|
||||
py = final_rect.y + final_rect.h - abscentery;
|
||||
p4x = px * cangle - py * sangle + abscenterx;
|
||||
p4y = px * sangle + py * cangle + abscentery;
|
||||
|
||||
tmp_rect.x = (int)MIN(MIN(p1x, p2x), MIN(p3x, p4x));
|
||||
tmp_rect.y = (int)MIN(MIN(p1y, p2y), MIN(p3y, p4y));
|
||||
tmp_rect.w = dstwidth;
|
||||
tmp_rect.h = dstheight;
|
||||
|
||||
retval = SDL_BlitSurface(surface_rotated, NULL, surface, &tmp_rect);
|
||||
SDL_FreeSurface(surface_scaled);
|
||||
SDL_FreeSurface(surface_rotated);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 format, void * pixels, int pitch)
|
||||
{
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
Uint32 src_format;
|
||||
void *src_pixels;
|
||||
SDL_Rect final_rect;
|
||||
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (renderer->viewport.x || renderer->viewport.y) {
|
||||
final_rect.x = renderer->viewport.x + rect->x;
|
||||
final_rect.y = renderer->viewport.y + rect->y;
|
||||
final_rect.w = rect->w;
|
||||
final_rect.h = rect->h;
|
||||
rect = &final_rect;
|
||||
}
|
||||
|
||||
if (rect->x < 0 || rect->x+rect->w > surface->w ||
|
||||
rect->y < 0 || rect->y+rect->h > surface->h) {
|
||||
return SDL_SetError("Tried to read outside of surface bounds");
|
||||
}
|
||||
|
||||
src_format = surface->format->format;
|
||||
src_pixels = (void*)((Uint8 *) surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->BytesPerPixel);
|
||||
|
||||
return SDL_ConvertPixels(rect->w, rect->h,
|
||||
src_format, src_pixels, surface->pitch,
|
||||
format, pixels, pitch);
|
||||
}
|
||||
|
||||
static void
|
||||
SW_RenderPresent(SDL_Renderer * renderer)
|
||||
{
|
||||
SDL_Window *window = renderer->window;
|
||||
|
||||
if (window) {
|
||||
SDL_UpdateWindowSurface(window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
|
||||
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
|
||||
static void
|
||||
SW_DestroyRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
|
||||
SDL_free(data);
|
||||
SDL_free(renderer);
|
||||
}
|
||||
|
||||
#endif /* !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
24
src/render/software/SDL_render_sw_c.h
Normal file
24
src/render/software/SDL_render_sw_c.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
extern SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface * surface);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
501
src/render/software/SDL_rotate.c
Normal file
501
src/render/software/SDL_rotate.c
Normal file
@@ -0,0 +1,501 @@
|
||||
/*
|
||||
|
||||
SDL_rotate.c: rotates 32bit or 8bit surfaces
|
||||
|
||||
Shamelessly stolen from SDL_gfx by Andreas Schiffler. Original copyright follows:
|
||||
|
||||
Copyright (C) 2001-2011 Andreas Schiffler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
|
||||
*/
|
||||
#include "../../SDL_internal.h"
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#include "../../core/windows/SDL_windows.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_rotate.h"
|
||||
|
||||
/* ---- Internally used structures */
|
||||
|
||||
/* !
|
||||
\brief A 32 bit RGBA pixel.
|
||||
*/
|
||||
typedef struct tColorRGBA {
|
||||
Uint8 r;
|
||||
Uint8 g;
|
||||
Uint8 b;
|
||||
Uint8 a;
|
||||
} tColorRGBA;
|
||||
|
||||
/* !
|
||||
\brief A 8bit Y/palette pixel.
|
||||
*/
|
||||
typedef struct tColorY {
|
||||
Uint8 y;
|
||||
} tColorY;
|
||||
|
||||
/* !
|
||||
\brief Returns maximum of two numbers a and b.
|
||||
*/
|
||||
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
/* !
|
||||
\brief Number of guard rows added to destination surfaces.
|
||||
|
||||
This is a simple but effective workaround for observed issues.
|
||||
These rows allocate extra memory and are then hidden from the surface.
|
||||
Rows are added to the end of destination surfaces when they are allocated.
|
||||
This catches any potential overflows which seem to happen with
|
||||
just the right src image dimensions and scale/rotation and can lead
|
||||
to a situation where the program can segfault.
|
||||
*/
|
||||
#define GUARD_ROWS (2)
|
||||
|
||||
/* !
|
||||
\brief Lower limit of absolute zoom factor or rotation degrees.
|
||||
*/
|
||||
#define VALUE_LIMIT 0.001
|
||||
|
||||
/* !
|
||||
\brief Returns colorkey info for a surface
|
||||
*/
|
||||
static Uint32
|
||||
_colorkey(SDL_Surface *src)
|
||||
{
|
||||
Uint32 key = 0;
|
||||
SDL_GetColorKey(src, &key);
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
/* !
|
||||
\brief Internal target surface sizing function for rotations with trig result return.
|
||||
|
||||
\param width The source surface width.
|
||||
\param height The source surface height.
|
||||
\param angle The angle to rotate in degrees.
|
||||
\param dstwidth The calculated width of the destination surface.
|
||||
\param dstheight The calculated height of the destination surface.
|
||||
\param cangle The sine of the angle
|
||||
\param sangle The cosine of the angle
|
||||
|
||||
*/
|
||||
void
|
||||
SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle,
|
||||
int *dstwidth, int *dstheight,
|
||||
double *cangle, double *sangle)
|
||||
{
|
||||
double x, y, cx, cy, sx, sy;
|
||||
double radangle;
|
||||
int dstwidthhalf, dstheighthalf;
|
||||
|
||||
/*
|
||||
* Determine destination width and height by rotating a centered source box
|
||||
*/
|
||||
radangle = angle * (M_PI / 180.0);
|
||||
*sangle = SDL_sin(radangle);
|
||||
*cangle = SDL_cos(radangle);
|
||||
x = (double)(width / 2);
|
||||
y = (double)(height / 2);
|
||||
cx = *cangle * x;
|
||||
cy = *cangle * y;
|
||||
sx = *sangle * x;
|
||||
sy = *sangle * y;
|
||||
|
||||
dstwidthhalf = MAX((int)
|
||||
SDL_ceil(MAX(MAX(MAX(SDL_fabs(cx + sy), SDL_fabs(cx - sy)), SDL_fabs(-cx + sy)), SDL_fabs(-cx - sy))), 1);
|
||||
dstheighthalf = MAX((int)
|
||||
SDL_ceil(MAX(MAX(MAX(SDL_fabs(sx + cy), SDL_fabs(sx - cy)), SDL_fabs(-sx + cy)), SDL_fabs(-sx - cy))), 1);
|
||||
*dstwidth = 2 * dstwidthhalf;
|
||||
*dstheight = 2 * dstheighthalf;
|
||||
}
|
||||
|
||||
|
||||
/* !
|
||||
\brief Internal 32 bit rotozoomer with optional anti-aliasing.
|
||||
|
||||
Rotates and zooms 32 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control
|
||||
parameters by scanning the destination surface and applying optionally anti-aliasing
|
||||
by bilinear interpolation.
|
||||
Assumes src and dst surfaces are of 32 bit depth.
|
||||
Assumes dst surface was allocated with the correct dimensions.
|
||||
|
||||
\param src Source surface.
|
||||
\param dst Destination surface.
|
||||
\param cx Horizontal center coordinate.
|
||||
\param cy Vertical center coordinate.
|
||||
\param isin Integer version of sine of angle.
|
||||
\param icos Integer version of cosine of angle.
|
||||
\param flipx Flag indicating horizontal mirroring should be applied.
|
||||
\param flipy Flag indicating vertical mirroring should be applied.
|
||||
\param smooth Flag indicating anti-aliasing should be used.
|
||||
*/
|
||||
static void
|
||||
_transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy, int smooth)
|
||||
{
|
||||
int x, y, t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh;
|
||||
tColorRGBA c00, c01, c10, c11, cswap;
|
||||
tColorRGBA *pc, *sp;
|
||||
int gap;
|
||||
|
||||
/*
|
||||
* Variable setup
|
||||
*/
|
||||
xd = ((src->w - dst->w) << 15);
|
||||
yd = ((src->h - dst->h) << 15);
|
||||
ax = (cx << 16) - (icos * cx);
|
||||
ay = (cy << 16) - (isin * cx);
|
||||
sw = src->w - 1;
|
||||
sh = src->h - 1;
|
||||
pc = (tColorRGBA*) dst->pixels;
|
||||
gap = dst->pitch - dst->w * 4;
|
||||
|
||||
/*
|
||||
* Switch between interpolating and non-interpolating code
|
||||
*/
|
||||
if (smooth) {
|
||||
for (y = 0; y < dst->h; y++) {
|
||||
dy = cy - y;
|
||||
sdx = (ax + (isin * dy)) + xd;
|
||||
sdy = (ay - (icos * dy)) + yd;
|
||||
for (x = 0; x < dst->w; x++) {
|
||||
dx = (sdx >> 16);
|
||||
dy = (sdy >> 16);
|
||||
if (flipx) dx = sw - dx;
|
||||
if (flipy) dy = sh - dy;
|
||||
if ((dx > -1) && (dy > -1) && (dx < (src->w-1)) && (dy < (src->h-1))) {
|
||||
sp = (tColorRGBA *)src->pixels;
|
||||
sp += ((src->pitch/4) * dy);
|
||||
sp += dx;
|
||||
c00 = *sp;
|
||||
sp += 1;
|
||||
c01 = *sp;
|
||||
sp += (src->pitch/4);
|
||||
c11 = *sp;
|
||||
sp -= 1;
|
||||
c10 = *sp;
|
||||
if (flipx) {
|
||||
cswap = c00; c00=c01; c01=cswap;
|
||||
cswap = c10; c10=c11; c11=cswap;
|
||||
}
|
||||
if (flipy) {
|
||||
cswap = c00; c00=c10; c10=cswap;
|
||||
cswap = c01; c01=c11; c11=cswap;
|
||||
}
|
||||
/*
|
||||
* Interpolate colors
|
||||
*/
|
||||
ex = (sdx & 0xffff);
|
||||
ey = (sdy & 0xffff);
|
||||
t1 = ((((c01.r - c00.r) * ex) >> 16) + c00.r) & 0xff;
|
||||
t2 = ((((c11.r - c10.r) * ex) >> 16) + c10.r) & 0xff;
|
||||
pc->r = (((t2 - t1) * ey) >> 16) + t1;
|
||||
t1 = ((((c01.g - c00.g) * ex) >> 16) + c00.g) & 0xff;
|
||||
t2 = ((((c11.g - c10.g) * ex) >> 16) + c10.g) & 0xff;
|
||||
pc->g = (((t2 - t1) * ey) >> 16) + t1;
|
||||
t1 = ((((c01.b - c00.b) * ex) >> 16) + c00.b) & 0xff;
|
||||
t2 = ((((c11.b - c10.b) * ex) >> 16) + c10.b) & 0xff;
|
||||
pc->b = (((t2 - t1) * ey) >> 16) + t1;
|
||||
t1 = ((((c01.a - c00.a) * ex) >> 16) + c00.a) & 0xff;
|
||||
t2 = ((((c11.a - c10.a) * ex) >> 16) + c10.a) & 0xff;
|
||||
pc->a = (((t2 - t1) * ey) >> 16) + t1;
|
||||
}
|
||||
sdx += icos;
|
||||
sdy += isin;
|
||||
pc++;
|
||||
}
|
||||
pc = (tColorRGBA *) ((Uint8 *) pc + gap);
|
||||
}
|
||||
} else {
|
||||
for (y = 0; y < dst->h; y++) {
|
||||
dy = cy - y;
|
||||
sdx = (ax + (isin * dy)) + xd;
|
||||
sdy = (ay - (icos * dy)) + yd;
|
||||
for (x = 0; x < dst->w; x++) {
|
||||
dx = (short) (sdx >> 16);
|
||||
dy = (short) (sdy >> 16);
|
||||
if (flipx) dx = (src->w-1)-dx;
|
||||
if (flipy) dy = (src->h-1)-dy;
|
||||
if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h)) {
|
||||
sp = (tColorRGBA *) ((Uint8 *) src->pixels + src->pitch * dy);
|
||||
sp += dx;
|
||||
*pc = *sp;
|
||||
}
|
||||
sdx += icos;
|
||||
sdy += isin;
|
||||
pc++;
|
||||
}
|
||||
pc = (tColorRGBA *) ((Uint8 *) pc + gap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* !
|
||||
|
||||
\brief Rotates and zooms 8 bit palette/Y 'src' surface to 'dst' surface without smoothing.
|
||||
|
||||
Rotates and zooms 8 bit RGBA/ABGR 'src' surface to 'dst' surface based on the control
|
||||
parameters by scanning the destination surface.
|
||||
Assumes src and dst surfaces are of 8 bit depth.
|
||||
Assumes dst surface was allocated with the correct dimensions.
|
||||
|
||||
\param src Source surface.
|
||||
\param dst Destination surface.
|
||||
\param cx Horizontal center coordinate.
|
||||
\param cy Vertical center coordinate.
|
||||
\param isin Integer version of sine of angle.
|
||||
\param icos Integer version of cosine of angle.
|
||||
\param flipx Flag indicating horizontal mirroring should be applied.
|
||||
\param flipy Flag indicating vertical mirroring should be applied.
|
||||
*/
|
||||
static void
|
||||
transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int cx, int cy, int isin, int icos, int flipx, int flipy)
|
||||
{
|
||||
int x, y, dx, dy, xd, yd, sdx, sdy, ax, ay;
|
||||
tColorY *pc, *sp;
|
||||
int gap;
|
||||
|
||||
/*
|
||||
* Variable setup
|
||||
*/
|
||||
xd = ((src->w - dst->w) << 15);
|
||||
yd = ((src->h - dst->h) << 15);
|
||||
ax = (cx << 16) - (icos * cx);
|
||||
ay = (cy << 16) - (isin * cx);
|
||||
pc = (tColorY*) dst->pixels;
|
||||
gap = dst->pitch - dst->w;
|
||||
/*
|
||||
* Clear surface to colorkey
|
||||
*/
|
||||
SDL_memset(pc, (int)(_colorkey(src) & 0xff), dst->pitch * dst->h);
|
||||
/*
|
||||
* Iterate through destination surface
|
||||
*/
|
||||
for (y = 0; y < dst->h; y++) {
|
||||
dy = cy - y;
|
||||
sdx = (ax + (isin * dy)) + xd;
|
||||
sdy = (ay - (icos * dy)) + yd;
|
||||
for (x = 0; x < dst->w; x++) {
|
||||
dx = (short) (sdx >> 16);
|
||||
dy = (short) (sdy >> 16);
|
||||
if (flipx) dx = (src->w-1)-dx;
|
||||
if (flipy) dy = (src->h-1)-dy;
|
||||
if ((dx >= 0) && (dy >= 0) && (dx < src->w) && (dy < src->h)) {
|
||||
sp = (tColorY *) (src->pixels);
|
||||
sp += (src->pitch * dy + dx);
|
||||
*pc = *sp;
|
||||
}
|
||||
sdx += icos;
|
||||
sdy += isin;
|
||||
pc++;
|
||||
}
|
||||
pc += gap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* !
|
||||
\brief Rotates and zooms a surface with different horizontal and vertival scaling factors and optional anti-aliasing.
|
||||
|
||||
Rotates a 32bit or 8bit 'src' surface to newly created 'dst' surface.
|
||||
'angle' is the rotation in degrees, 'centerx' and 'centery' the rotation center. If 'smooth' is set
|
||||
then the destination 32bit surface is anti-aliased. If the surface is not 8bit
|
||||
or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
|
||||
|
||||
\param src The surface to rotozoom.
|
||||
\param angle The angle to rotate in degrees.
|
||||
\param centerx The horizontal coordinate of the center of rotation
|
||||
\param zoomy The vertical coordinate of the center of rotation
|
||||
\param smooth Antialiasing flag; set to SMOOTHING_ON to enable.
|
||||
\param flipx Set to 1 to flip the image horizontally
|
||||
\param flipy Set to 1 to flip the image vertically
|
||||
\param dstwidth The destination surface width
|
||||
\param dstheight The destination surface height
|
||||
\param cangle The angle cosine
|
||||
\param sangle The angle sine
|
||||
\return The new rotated surface.
|
||||
|
||||
*/
|
||||
|
||||
SDL_Surface *
|
||||
SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle)
|
||||
{
|
||||
SDL_Surface *rz_src;
|
||||
SDL_Surface *rz_dst;
|
||||
int is32bit;
|
||||
int i, src_converted;
|
||||
Uint8 r,g,b;
|
||||
Uint32 colorkey = 0;
|
||||
int colorKeyAvailable = 0;
|
||||
double sangleinv, cangleinv;
|
||||
|
||||
/*
|
||||
* Sanity check
|
||||
*/
|
||||
if (src == NULL)
|
||||
return (NULL);
|
||||
|
||||
if (src->flags & SDL_TRUE/* SDL_SRCCOLORKEY */)
|
||||
{
|
||||
colorkey = _colorkey(src);
|
||||
SDL_GetRGB(colorkey, src->format, &r, &g, &b);
|
||||
colorKeyAvailable = 1;
|
||||
}
|
||||
/*
|
||||
* Determine if source surface is 32bit or 8bit
|
||||
*/
|
||||
is32bit = (src->format->BitsPerPixel == 32);
|
||||
if ((is32bit) || (src->format->BitsPerPixel == 8)) {
|
||||
/*
|
||||
* Use source surface 'as is'
|
||||
*/
|
||||
rz_src = src;
|
||||
src_converted = 0;
|
||||
} else {
|
||||
/*
|
||||
* New source surface is 32bit with a defined RGBA ordering
|
||||
*/
|
||||
rz_src =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, src->w, src->h, 32,
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000
|
||||
#else
|
||||
0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff
|
||||
#endif
|
||||
);
|
||||
if(colorKeyAvailable)
|
||||
SDL_SetColorKey(src, 0, 0);
|
||||
|
||||
SDL_BlitSurface(src, NULL, rz_src, NULL);
|
||||
|
||||
if(colorKeyAvailable)
|
||||
SDL_SetColorKey(src, SDL_TRUE /* SDL_SRCCOLORKEY */, colorkey);
|
||||
src_converted = 1;
|
||||
is32bit = 1;
|
||||
}
|
||||
|
||||
|
||||
/* Determine target size */
|
||||
/* _rotozoomSurfaceSizeTrig(rz_src->w, rz_src->h, angle, &dstwidth, &dstheight, &cangle, &sangle); */
|
||||
|
||||
/*
|
||||
* Calculate target factors from sin/cos and zoom
|
||||
*/
|
||||
sangleinv = sangle*65536.0;
|
||||
cangleinv = cangle*65536.0;
|
||||
|
||||
/*
|
||||
* Alloc space to completely contain the rotated surface
|
||||
*/
|
||||
rz_dst = NULL;
|
||||
if (is32bit) {
|
||||
/*
|
||||
* Target surface is 32bit with source RGBA/ABGR ordering
|
||||
*/
|
||||
rz_dst =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS, 32,
|
||||
rz_src->format->Rmask, rz_src->format->Gmask,
|
||||
rz_src->format->Bmask, rz_src->format->Amask);
|
||||
} else {
|
||||
/*
|
||||
* Target surface is 8bit
|
||||
*/
|
||||
rz_dst = SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS, 8, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/* Check target */
|
||||
if (rz_dst == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Adjust for guard rows */
|
||||
rz_dst->h = dstheight;
|
||||
|
||||
if (colorKeyAvailable == 1){
|
||||
colorkey = SDL_MapRGB(rz_dst->format, r, g, b);
|
||||
|
||||
SDL_FillRect(rz_dst, NULL, colorkey );
|
||||
}
|
||||
|
||||
/*
|
||||
* Lock source surface
|
||||
*/
|
||||
if (SDL_MUSTLOCK(rz_src)) {
|
||||
SDL_LockSurface(rz_src);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check which kind of surface we have
|
||||
*/
|
||||
if (is32bit) {
|
||||
/*
|
||||
* Call the 32bit transformation routine to do the rotation (using alpha)
|
||||
*/
|
||||
_transformSurfaceRGBA(rz_src, rz_dst, centerx, centery,
|
||||
(int) (sangleinv), (int) (cangleinv),
|
||||
flipx, flipy,
|
||||
smooth);
|
||||
/*
|
||||
* Turn on source-alpha support
|
||||
*/
|
||||
/* SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255); */
|
||||
SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
|
||||
} else {
|
||||
/*
|
||||
* Copy palette and colorkey info
|
||||
*/
|
||||
for (i = 0; i < rz_src->format->palette->ncolors; i++) {
|
||||
rz_dst->format->palette->colors[i] = rz_src->format->palette->colors[i];
|
||||
}
|
||||
rz_dst->format->palette->ncolors = rz_src->format->palette->ncolors;
|
||||
/*
|
||||
* Call the 8bit transformation routine to do the rotation
|
||||
*/
|
||||
transformSurfaceY(rz_src, rz_dst, centerx, centery,
|
||||
(int) (sangleinv), (int) (cangleinv),
|
||||
flipx, flipy);
|
||||
SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
|
||||
}
|
||||
/*
|
||||
* Unlock source surface
|
||||
*/
|
||||
if (SDL_MUSTLOCK(rz_src)) {
|
||||
SDL_UnlockSurface(rz_src);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleanup temp surface
|
||||
*/
|
||||
if (src_converted) {
|
||||
SDL_FreeSurface(rz_src);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return destination surface
|
||||
*/
|
||||
return (rz_dst);
|
||||
}
|
28
src/render/software/SDL_rotate.h
Normal file
28
src/render/software/SDL_rotate.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle);
|
||||
extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle);
|
||||
|
Reference in New Issue
Block a user