Direct3D: remove RenderCopy and RenderCopyEx from back-end
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index 00a0255..6fea41c 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -51,7 +51,6 @@ typedef struct
SDL_bool cliprect_enabled_dirty;
SDL_Rect cliprect;
SDL_bool cliprect_dirty;
- SDL_bool is_copy_ex;
LPDIRECT3DPIXELSHADER9 shader;
} D3D_DrawStateCache;
@@ -879,149 +878,6 @@ D3D_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FR
}
static int
-D3D_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
- const SDL_Rect * srcrect, const SDL_FRect * dstrect)
-{
- const DWORD color = D3DCOLOR_ARGB(cmd->data.draw.a, cmd->data.draw.r, cmd->data.draw.g, cmd->data.draw.b);
- float minx, miny, maxx, maxy;
- float minu, maxu, minv, maxv;
- const size_t vertslen = sizeof (Vertex) * 4;
- Vertex *verts = (Vertex *) SDL_AllocateRenderVertices(renderer, vertslen, 0, &cmd->data.draw.first);
-
- if (!verts) {
- return -1;
- }
-
- cmd->data.draw.count = 1;
-
- minx = dstrect->x - 0.5f;
- miny = dstrect->y - 0.5f;
- maxx = dstrect->x + dstrect->w - 0.5f;
- maxy = dstrect->y + dstrect->h - 0.5f;
-
- minu = (float) srcrect->x / texture->w;
- maxu = (float) (srcrect->x + srcrect->w) / texture->w;
- minv = (float) srcrect->y / texture->h;
- maxv = (float) (srcrect->y + srcrect->h) / texture->h;
-
- verts->x = minx;
- verts->y = miny;
- verts->z = 0.0f;
- verts->color = color;
- verts->u = minu;
- verts->v = minv;
- verts++;
-
- verts->x = maxx;
- verts->y = miny;
- verts->z = 0.0f;
- verts->color = color;
- verts->u = maxu;
- verts->v = minv;
- verts++;
-
- verts->x = maxx;
- verts->y = maxy;
- verts->z = 0.0f;
- verts->color = color;
- verts->u = maxu;
- verts->v = maxv;
- verts++;
-
- verts->x = minx;
- verts->y = maxy;
- verts->z = 0.0f;
- verts->color = color;
- verts->u = minu;
- verts->v = maxv;
- verts++;
-
- return 0;
-}
-
-static int
-D3D_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
- const SDL_Rect * srcquad, const SDL_FRect * dstrect,
- const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
-{
- const DWORD color = D3DCOLOR_ARGB(cmd->data.draw.a, cmd->data.draw.r, cmd->data.draw.g, cmd->data.draw.b);
- float minx, miny, maxx, maxy;
- float minu, maxu, minv, maxv;
- const size_t vertslen = sizeof (Vertex) * 5;
- Vertex *verts = (Vertex *) SDL_AllocateRenderVertices(renderer, vertslen, 0, &cmd->data.draw.first);
-
- if (!verts) {
- return -1;
- }
-
- cmd->data.draw.count = 1;
-
- minx = -center->x;
- maxx = dstrect->w - center->x;
- miny = -center->y;
- maxy = dstrect->h - center->y;
-
- if (flip & SDL_FLIP_HORIZONTAL) {
- minu = (float) (srcquad->x + srcquad->w) / texture->w;
- maxu = (float) srcquad->x / texture->w;
- } else {
- minu = (float) srcquad->x / texture->w;
- maxu = (float) (srcquad->x + srcquad->w) / texture->w;
- }
-
- if (flip & SDL_FLIP_VERTICAL) {
- minv = (float) (srcquad->y + srcquad->h) / texture->h;
- maxv = (float) srcquad->y / texture->h;
- } else {
- minv = (float) srcquad->y / texture->h;
- maxv = (float) (srcquad->y + srcquad->h) / texture->h;
- }
-
- verts->x = minx;
- verts->y = miny;
- verts->z = 0.0f;
- verts->color = color;
- verts->u = minu;
- verts->v = minv;
- verts++;
-
- verts->x = maxx;
- verts->y = miny;
- verts->z = 0.0f;
- verts->color = color;
- verts->u = maxu;
- verts->v = minv;
- verts++;
-
- verts->x = maxx;
- verts->y = maxy;
- verts->z = 0.0f;
- verts->color = color;
- verts->u = maxu;
- verts->v = maxv;
- verts++;
-
- verts->x = minx;
- verts->y = maxy;
- verts->z = 0.0f;
- verts->color = color;
- verts->u = minu;
- verts->v = maxv;
- verts++;
-
- verts->x = dstrect->x + center->x - 0.5f; /* X translation */
- verts->y = dstrect->y + center->y - 0.5f; /* Y translation */
- verts->z = (float)(M_PI * (float) angle / 180.0f); /* rotation */
- verts->color = 0;
- verts->u = 0.0f;
- verts->v = 0.0f;
- verts++;
-
- return 0;
-}
-
-#if SDL_HAVE_RENDER_GEOMETRY
-static int
D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture,
const float *xy, int xy_stride, const int *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices,
@@ -1073,7 +929,6 @@ D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
}
return 0;
}
-#endif
static int
UpdateDirtyTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
@@ -1174,8 +1029,6 @@ SetupTextureState(D3D_RenderData *data, SDL_Texture * texture, LPDIRECT3DPIXELSH
static int
SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
{
- const SDL_bool was_copy_ex = data->drawstate.is_copy_ex;
- const SDL_bool is_copy_ex = (cmd->command == SDL_RENDERCMD_COPY_EX);
SDL_Texture *texture = cmd->data.draw.texture;
const SDL_BlendMode blend = cmd->data.draw.blend;
@@ -1234,14 +1087,6 @@ SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
data->drawstate.blend = blend;
}
- if (is_copy_ex != was_copy_ex) {
- if (!is_copy_ex) { /* SDL_RENDERCMD_COPY_EX will set this, we only want to reset it here if necessary. */
- const Float4X4 d3dmatrix = MatrixIdentity();
- IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*) &d3dmatrix);
- }
- data->drawstate.is_copy_ex = is_copy_ex;
- }
-
if (data->drawstate.viewport_dirty) {
const SDL_Rect *viewport = &data->drawstate.viewport;
const D3DVIEWPORT9 d3dviewport = { viewport->x, viewport->y, viewport->w, viewport->h, 0.0f, 1.0f };
@@ -1450,46 +1295,13 @@ D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
break;
}
- case SDL_RENDERCMD_COPY: {
- const size_t count = cmd->data.draw.count;
- const size_t first = cmd->data.draw.first;
- SetDrawState(data, cmd);
- if (vbo) {
- size_t offset = 0;
- for (i = 0; i < count; ++i, offset += 4) {
- IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_TRIANGLEFAN, (UINT) ((first / sizeof (Vertex)) + offset), 2);
- }
- } else {
- const Vertex *verts = (Vertex *) (((Uint8 *) vertices) + first);
- for (i = 0; i < count; ++i, verts += 4) {
- IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2, verts, sizeof (Vertex));
- }
- }
+ case SDL_RENDERCMD_COPY: /* unused */
break;
- }
-
- case SDL_RENDERCMD_COPY_EX: {
- const size_t first = cmd->data.draw.first;
- const Vertex *verts = (Vertex *) (((Uint8 *) vertices) + first);
- const Vertex *transvert = verts + 4;
- const float translatex = transvert->x;
- const float translatey = transvert->y;
- const float rotation = transvert->z;
- const Float4X4 d3dmatrix = MatrixMultiply(MatrixRotationZ(rotation), MatrixTranslation(translatex, translatey, 0));
- SetDrawState(data, cmd);
- IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&d3dmatrix);
-
- if (vbo) {
- IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_TRIANGLEFAN, (UINT) (first / sizeof (Vertex)), 2);
- } else {
- IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2, verts, sizeof (Vertex));
- }
+ case SDL_RENDERCMD_COPY_EX: /* unused */
break;
- }
case SDL_RENDERCMD_GEOMETRY: {
-#if SDL_HAVE_RENDER_GEOMETRY
const size_t count = cmd->data.draw.count;
const size_t first = cmd->data.draw.first;
SetDrawState(data, cmd);
@@ -1499,7 +1311,6 @@ D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
const Vertex* verts = (Vertex*)(((Uint8*)vertices) + first);
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLELIST, (UINT) count / 3, verts, sizeof(Vertex));
}
-#endif
break;
}
@@ -1730,7 +1541,6 @@ D3D_Reset(SDL_Renderer * renderer)
data->drawstate.texture = NULL;
data->drawstate.shader = NULL;
data->drawstate.blend = SDL_BLENDMODE_INVALID;
- data->drawstate.is_copy_ex = SDL_FALSE;
IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&d3dmatrix);
/* Let the application know that render targets were reset */
@@ -1813,11 +1623,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->QueueDrawPoints = D3D_QueueDrawPoints;
renderer->QueueDrawLines = D3D_QueueDrawPoints; /* lines and points queue vertices the same way. */
renderer->QueueFillRects = D3D_QueueFillRects;
- renderer->QueueCopy = D3D_QueueCopy;
- renderer->QueueCopyEx = D3D_QueueCopyEx;
-#if SDL_HAVE_RENDER_GEOMETRY
renderer->QueueGeometry = D3D_QueueGeometry;
-#endif
renderer->RunCommandQueue = D3D_RunCommandQueue;
renderer->RenderReadPixels = D3D_RenderReadPixels;
renderer->RenderPresent = D3D_RenderPresent;