Implement FillRect
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
diff --git a/src/render/ps2/SDL_render_ps2.c b/src/render/ps2/SDL_render_ps2.c
index 8eb5f23..7d10080 100644
--- a/src/render/ps2/SDL_render_ps2.c
+++ b/src/render/ps2/SDL_render_ps2.c
@@ -35,6 +35,11 @@
/* turn black GS Screen */
#define GS_BLACK GS_SETREG_RGBA(0x00, 0x00, 0x00, 0x80)
+typedef struct clear_vertex {
+ float x;
+ float y;
+} clear_vertex;
+
typedef struct texture_vertex {
float x;
float y;
@@ -209,6 +214,22 @@ PS2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F
static int
PS2_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count)
{
+ SDL_Rect *verts = (SDL_Rect *) SDL_AllocateRenderVertices(renderer, count * sizeof (SDL_Rect), 4, &cmd->data.draw.first);
+ int i;
+
+ if (!verts) {
+ return -1;
+ }
+
+ cmd->data.draw.count = count;
+
+ for (i = 0; i < count; i++, verts++, rects++) {
+ verts->x = (int)rects->x;
+ verts->y = (int)rects->y;
+ verts->w = rects->w + 0.5f;
+ verts->h = rects->h + 0.5f;
+ }
+
return 0;
}
@@ -424,6 +445,35 @@ PS2_RenderGeometry(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cm
return 0;
}
+int
+PS2_FillRects(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand * cmd)
+{
+ PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
+ const SDL_Rect* rect;
+ uint64_t color;
+ int i;
+
+ const size_t count = cmd->data.draw.count;
+
+ const uint8_t ColorR = cmd->data.draw.r >> 1;
+ const uint8_t ColorG = cmd->data.draw.g >> 1;
+ const uint8_t ColorB = cmd->data.draw.b >> 1;
+ const uint8_t ColorA = cmd->data.draw.a >> 1;
+
+ color = GS_SETREG_RGBAQ(ColorR, ColorG, ColorB, ColorA, 0x00);
+
+ SDL_Rect *rects = (SDL_Rect *) (vertices + cmd->data.draw.first);
+
+ for (i = 0; i < count; i++) {
+ rect = &rects[i];
+ gsKit_prim_sprite(data->gsGlobal, rect->x, rect->y, rect->w, rect->h, 0, color);
+
+ }
+
+ /* We're done! */
+ return 0;
+}
+
static int
PS2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
{
@@ -437,8 +487,10 @@ PS2_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
PS2_RenderClear(renderer, cmd);
break;
}
- case SDL_RENDERCMD_FILL_RECTS: /* unused */
+ case SDL_RENDERCMD_FILL_RECTS: {
+ PS2_FillRects(renderer, vertices, cmd);
break;
+ }
case SDL_RENDERCMD_COPY: /* unused */
break;