Renderer backends use SDL_Color instead of int for geometry colors.

This commit is contained in:
Alex Szpakowski 2021-12-14 11:02:07 -04:00 committed by Sam Lantinga
parent 086c74556d
commit 3a5e148b13
14 changed files with 106 additions and 83 deletions

View file

@ -545,7 +545,6 @@ QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int cou
const int num_indices = 6 * count; const int num_indices = 6 * count;
const int size_indices = 4; const int size_indices = 4;
int cur_indice = 0; int cur_indice = 0;
int color = (renderer->color.r << 0) | (renderer->color.g << 8) | (renderer->color.b << 16) | ((Uint32)renderer->color.a << 24);
for (i = 0; i < count; ++i) { for (i = 0; i < count; ++i) {
float minx, miny, maxx, maxy; float minx, miny, maxx, maxy;
@ -574,7 +573,7 @@ QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int cou
} }
retval = renderer->QueueGeometry(renderer, cmd, NULL, retval = renderer->QueueGeometry(renderer, cmd, NULL,
xy, xy_stride, &color, 0 /* color_stride */, NULL, 0, xy, xy_stride, &renderer->color, 0 /* color_stride */, NULL, 0,
num_vertices, indices, num_indices, size_indices, num_vertices, indices, num_indices, size_indices,
1.0f, 1.0f); 1.0f, 1.0f);
@ -640,7 +639,7 @@ QueueCmdGeometry(SDL_Renderer *renderer, SDL_Texture *texture,
if (cmd != NULL) { if (cmd != NULL) {
retval = renderer->QueueGeometry(renderer, cmd, texture, retval = renderer->QueueGeometry(renderer, cmd, texture,
xy, xy_stride, xy, xy_stride,
(const int *)color, color_stride, uv, uv_stride, color, color_stride, uv, uv_stride,
num_vertices, indices, num_indices, size_indices, num_vertices, indices, num_indices, size_indices,
scale_x, scale_y); scale_x, scale_y);
if (retval < 0) { if (retval < 0) {

View file

@ -130,7 +130,7 @@ struct SDL_Renderer
const SDL_Rect * srcquad, const SDL_FRect * dstrect, const SDL_Rect * srcquad, const SDL_FRect * dstrect,
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip); const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
int (*QueueGeometry) (SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, int (*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, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices, int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y); float scale_x, float scale_y);

View file

@ -833,7 +833,7 @@ D3D_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F
static int static int
D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, 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, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices, int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y) float scale_x, float scale_y)
{ {

View file

@ -1615,12 +1615,11 @@ D3D11_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL
{ {
VertexPositionColor *verts = (VertexPositionColor *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertexPositionColor), 0, &cmd->data.draw.first); VertexPositionColor *verts = (VertexPositionColor *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertexPositionColor), 0, &cmd->data.draw.first);
int i; int i;
const SDL_Color color = { SDL_Color color;
.r = cmd->data.draw.r, color.r = cmd->data.draw.r;
.g = cmd->data.draw.g, color.g = cmd->data.draw.g;
.b = cmd->data.draw.b, color.b = cmd->data.draw.b;
.a = cmd->data.draw.a color.a = cmd->data.draw.a;
};
if (!verts) { if (!verts) {
return -1; return -1;
@ -1642,7 +1641,7 @@ D3D11_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL
static int static int
D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, D3D11_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, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices, int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y) float scale_x, float scale_y)
{ {

View file

@ -1084,8 +1084,14 @@ METAL_QueueSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
static int static int
METAL_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) METAL_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
{ {
const int color = (cmd->data.draw.r << 0) | (cmd->data.draw.g << 8) | (cmd->data.draw.b << 16) | ((Uint32)cmd->data.draw.a << 24); const SDL_Color color = {
const size_t vertlen = (2 * sizeof (float) + sizeof (int)) * count; cmd->data.draw.r,
cmd->data.draw.g,
cmd->data.draw.b,
cmd->data.draw.a
};
const size_t vertlen = (2 * sizeof (float) + sizeof (SDL_Color)) * count;
float *verts = (float *) SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first); float *verts = (float *) SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first);
if (!verts) { if (!verts) {
return -1; return -1;
@ -1095,7 +1101,7 @@ METAL_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL
for (int i = 0; i < count; i++, points++) { for (int i = 0; i < count; i++, points++) {
*(verts++) = points->x; *(verts++) = points->x;
*(verts++) = points->y; *(verts++) = points->y;
*((int *)verts++) = color; *((SDL_Color *)verts++) = color;
} }
return 0; return 0;
} }
@ -1103,12 +1109,16 @@ METAL_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL
static int static int
METAL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) METAL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
{ {
const SDL_Color color = {
const int color = (cmd->data.draw.r << 0) | (cmd->data.draw.g << 8) | (cmd->data.draw.b << 16) | ((Uint32)cmd->data.draw.a << 24); cmd->data.draw.r,
cmd->data.draw.g,
cmd->data.draw.b,
cmd->data.draw.a
};
SDL_assert(count >= 2); /* should have been checked at the higher level. */ SDL_assert(count >= 2); /* should have been checked at the higher level. */
const size_t vertlen = (2 * sizeof (float) + sizeof (int)) * count; const size_t vertlen = (2 * sizeof (float) + sizeof (SDL_Color)) * count;
float *verts = (float *) SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first); float *verts = (float *) SDL_AllocateRenderVertices(renderer, vertlen, DEVICE_ALIGN(8), &cmd->data.draw.first);
if (!verts) { if (!verts) {
return -1; return -1;
@ -1118,7 +1128,7 @@ METAL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_
for (int i = 0; i < count; i++, points++) { for (int i = 0; i < count; i++, points++) {
*(verts++) = points->x; *(verts++) = points->x;
*(verts++) = points->y; *(verts++) = points->y;
*((int *)verts++) = color; *((SDL_Color *)verts++) = color;
} }
/* If the line segment is completely horizontal or vertical, /* If the line segment is completely horizontal or vertical,
@ -1148,7 +1158,7 @@ METAL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_
static int static int
METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, METAL_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, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices, int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y) float scale_x, float scale_y)
{ {
@ -1175,12 +1185,11 @@ METAL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture
} }
float *xy_ = (float *)((char*)xy + j * xy_stride); float *xy_ = (float *)((char*)xy + j * xy_stride);
int col_ = *(int *)((char*)color + j * color_stride);
*(verts++) = xy_[0] * scale_x; *(verts++) = xy_[0] * scale_x;
*(verts++) = xy_[1] * scale_y; *(verts++) = xy_[1] * scale_y;
*((int *)verts++) = col_; *((SDL_Color *)verts++) = *(SDL_Color *)((char*)color + j * color_stride);
if (texture) { if (texture) {
float *uv_ = (float *)((char*)uv + j * uv_stride); float *uv_ = (float *)((char*)uv + j * uv_stride);

View file

@ -981,7 +981,7 @@ GL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPo
static int static int
GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, GL_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, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices, int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y) float scale_x, float scale_y)
{ {

View file

@ -603,7 +603,7 @@ GLES_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F
static int static int
GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, GLES_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, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices, int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y) float scale_x, float scale_y)
{ {

View file

@ -663,26 +663,30 @@ static int
GLES2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) GLES2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
{ {
const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)); const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888));
int color;
const size_t vertlen = (2 * sizeof (float) + sizeof (int)) * count; const size_t vertlen = (2 * sizeof (float) + sizeof (int)) * count;
GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first); GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first);
int i; int i;
SDL_Color color;
color.r = cmd->data.draw.r;
color.g = cmd->data.draw.g;
color.b = cmd->data.draw.b;
color.a = cmd->data.draw.a;
if (!verts) { if (!verts) {
return -1; return -1;
} }
if (colorswap == 0) { if (colorswap) {
color = (cmd->data.draw.r << 0) | (cmd->data.draw.g << 8) | (cmd->data.draw.b << 16) | ((Uint32)cmd->data.draw.a << 24); Uint8 r = color.r;
} else { color.r = color.b;
color = (cmd->data.draw.r << 16) | (cmd->data.draw.g << 8) | (cmd->data.draw.b << 0) | ((Uint32)cmd->data.draw.a << 24); color.b = r;
} }
cmd->data.draw.count = count; cmd->data.draw.count = count;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
*(verts++) = 0.5f + points[i].x; *(verts++) = 0.5f + points[i].x;
*(verts++) = 0.5f + points[i].y; *(verts++) = 0.5f + points[i].y;
*((int *)verts++) = color; *((SDL_Color *)verts++) = color;
} }
return 0; return 0;
@ -692,19 +696,24 @@ static int
GLES2_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) GLES2_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
{ {
const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)); const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888));
int color;
int i; int i;
GLfloat prevx, prevy; GLfloat prevx, prevy;
const size_t vertlen = ((2 * sizeof (float)) + sizeof (int)) * count; const size_t vertlen = ((2 * sizeof (float)) + sizeof (int)) * count;
GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first); GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first);
SDL_Color color;
color.r = cmd->data.draw.r;
color.g = cmd->data.draw.g;
color.b = cmd->data.draw.b;
color.a = cmd->data.draw.a;
if (!verts) { if (!verts) {
return -1; return -1;
} }
if (colorswap == 0) { if (colorswap) {
color = (cmd->data.draw.r << 0) | (cmd->data.draw.g << 8) | (cmd->data.draw.b << 16) | ((Uint32)cmd->data.draw.a << 24); Uint8 r = color.r;
} else { color.r = color.b;
color = (cmd->data.draw.r << 16) | (cmd->data.draw.g << 8) | (cmd->data.draw.b << 0) | ((Uint32)cmd->data.draw.a << 24); color.b = r;
} }
cmd->data.draw.count = count; cmd->data.draw.count = count;
@ -714,7 +723,7 @@ GLES2_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_
prevy = 0.5f + points->y; prevy = 0.5f + points->y;
*(verts++) = prevx; *(verts++) = prevx;
*(verts++) = prevy; *(verts++) = prevy;
*((int *)verts++) = color; *((SDL_Color*)verts++) = color;
/* bump the end of each line segment out a quarter of a pixel, to provoke /* bump the end of each line segment out a quarter of a pixel, to provoke
the diamond-exit rule. Without this, you won't just drop the last the diamond-exit rule. Without this, you won't just drop the last
@ -733,7 +742,7 @@ GLES2_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_
prevy = yend + (SDL_sinf(angle) * 0.25f); prevy = yend + (SDL_sinf(angle) * 0.25f);
*(verts++) = prevx; *(verts++) = prevx;
*(verts++) = prevy; *(verts++) = prevy;
*((int *)verts++) = color; *((SDL_Color*)verts++) = color;
} }
return 0; return 0;
@ -741,7 +750,7 @@ GLES2_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_
static int static int
GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, GLES2_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, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices, int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y) float scale_x, float scale_y)
{ {
@ -761,7 +770,7 @@ GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
int j; int j;
float *xy_; float *xy_;
int col_; SDL_Color col_;
if (size_indices == 4) { if (size_indices == 4) {
j = ((const Uint32 *)indices)[i]; j = ((const Uint32 *)indices)[i];
} else if (size_indices == 2) { } else if (size_indices == 2) {
@ -773,23 +782,19 @@ GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture
} }
xy_ = (float *)((char*)xy + j * xy_stride); xy_ = (float *)((char*)xy + j * xy_stride);
col_ = *(int *)((char*)color + j * color_stride); col_ = *(SDL_Color *)((char*)color + j * color_stride);
*(verts++) = xy_[0] * scale_x; *(verts++) = xy_[0] * scale_x;
*(verts++) = xy_[1] * scale_y; *(verts++) = xy_[1] * scale_y;
if (colorswap == 0) { if (colorswap) {
*((int *)verts++) = col_; Uint8 r = col_.r;
} else { col_.r = col_.b;
Uint8 r, g, b, a; col_.b = r;
r = (col_ >> 0) & 0xff;
g = (col_ >> 8) & 0xff;
b = (col_ >> 16) & 0xff;
a = (col_ >> 24) & 0xff;
col_ = (r << 16) | (g << 8) | (b << 0) | ((Uint32)a << 24);
*((int *)verts++) = col_;
} }
*((SDL_Color *)verts++) = col_;
if (texture) { if (texture) {
float *uv_ = (float *)((char*)uv + j * uv_stride); float *uv_ = (float *)((char*)uv + j * uv_stride);
*(verts++) = uv_[0]; *(verts++) = uv_[0];

View file

@ -112,7 +112,7 @@ typedef struct
typedef struct typedef struct
{ {
int col; SDL_Color col;
float x, y, z; float x, y, z;
} VertCV; } VertCV;
@ -120,7 +120,7 @@ typedef struct
typedef struct typedef struct
{ {
float u, v; float u, v;
int col; SDL_Color col;
float x, y, z; float x, y, z;
} VertTCV; } VertTCV;
@ -492,7 +492,7 @@ PSP_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F
static int static int
PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, PSP_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, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices, int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y) float scale_x, float scale_y)
{ {
@ -512,7 +512,7 @@ PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
int j; int j;
float *xy_; float *xy_;
int col_; SDL_Color col_;
if (size_indices == 4) { if (size_indices == 4) {
j = ((const Uint32 *)indices)[i]; j = ((const Uint32 *)indices)[i];
} else if (size_indices == 2) { } else if (size_indices == 2) {
@ -524,7 +524,7 @@ PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
} }
xy_ = (float *)((char*)xy + j * xy_stride); xy_ = (float *)((char*)xy + j * xy_stride);
col_ = *(int *)((char*)color + j * color_stride); col_ = *(SDL_Color *)((char*)color + j * color_stride);
verts->x = xy_[0] * scale_x; verts->x = xy_[0] * scale_x;
verts->y = xy_[1] * scale_y; verts->y = xy_[1] * scale_y;
@ -545,7 +545,7 @@ PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
int j; int j;
float *xy_; float *xy_;
int col_; SDL_Color col_;
float *uv_; float *uv_;
if (size_indices == 4) { if (size_indices == 4) {
@ -559,7 +559,7 @@ PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
} }
xy_ = (float *)((char*)xy + j * xy_stride); xy_ = (float *)((char*)xy + j * xy_stride);
col_ = *(int *)((char*)color + j * color_stride); col_ = *(SDL_Color *)((char*)color + j * color_stride);
uv_ = (float *)((char*)uv + j * uv_stride); uv_ = (float *)((char*)uv + j * uv_stride);
verts->x = xy_[0] * scale_x; verts->x = xy_[0] * scale_x;

View file

@ -545,7 +545,7 @@ typedef struct GeometryCopyData
static int static int
SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, SW_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, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices, int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y) float scale_x, float scale_y)
{ {

View file

@ -83,7 +83,7 @@ static int VITA_GXM_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *c
static int static int
VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, VITA_GXM_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, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices, int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y); float scale_x, float scale_y);
@ -442,11 +442,10 @@ VITA_GXM_QueueSetDrawColor(SDL_Renderer * renderer, SDL_RenderCommand *cmd)
{ {
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
const Uint8 r = cmd->data.color.r; data->drawstate.color.r = cmd->data.color.r;
const Uint8 g = cmd->data.color.g; data->drawstate.color.g = cmd->data.color.g;
const Uint8 b = cmd->data.color.b; data->drawstate.color.b = cmd->data.color.b;
const Uint8 a = cmd->data.color.a; data->drawstate.color.a = cmd->data.color.a;
data->drawstate.color = (((Uint32)a << 24) | (b << 16) | (g << 8) | r);
return 0; return 0;
} }
@ -456,7 +455,7 @@ VITA_GXM_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const
{ {
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
int color = data->drawstate.color; SDL_Color color = data->drawstate.color;
color_vertex *vertex = (color_vertex *)pool_malloc( color_vertex *vertex = (color_vertex *)pool_malloc(
data, data,
@ -480,7 +479,7 @@ static int
VITA_GXM_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) VITA_GXM_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count)
{ {
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
int color = data->drawstate.color; SDL_Color color = data->drawstate.color;
color_vertex *vertex = (color_vertex *)pool_malloc( color_vertex *vertex = (color_vertex *)pool_malloc(
data, data,
@ -506,7 +505,7 @@ VITA_GXM_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const S
static int static int
VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, VITA_GXM_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, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices, int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y) float scale_x, float scale_y)
{ {
@ -533,7 +532,7 @@ VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Textu
int j; int j;
float *xy_; float *xy_;
float *uv_; float *uv_;
int col_; SDL_Color col_;
if (size_indices == 4) { if (size_indices == 4) {
j = ((const Uint32 *)indices)[i]; j = ((const Uint32 *)indices)[i];
} else if (size_indices == 2) { } else if (size_indices == 2) {
@ -545,7 +544,7 @@ VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Textu
} }
xy_ = (float *)((char*)xy + j * xy_stride); xy_ = (float *)((char*)xy + j * xy_stride);
col_ = *(int *)((char*)color + j * color_stride); col_ = *(SDL_Color *)((char*)color + j * color_stride);
uv_ = (float *)((char*)uv + j * uv_stride); uv_ = (float *)((char*)uv + j * uv_stride);
vertices[i].x = xy_[0] * scale_x; vertices[i].x = xy_[0] * scale_x;
@ -572,7 +571,7 @@ VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Textu
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
int j; int j;
float *xy_; float *xy_;
int col_; SDL_Color col_;
if (size_indices == 4) { if (size_indices == 4) {
j = ((const Uint32 *)indices)[i]; j = ((const Uint32 *)indices)[i];
} else if (size_indices == 2) { } else if (size_indices == 2) {
@ -584,7 +583,7 @@ VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Textu
} }
xy_ = (float *)((char*)xy + j * xy_stride); xy_ = (float *)((char*)xy + j * xy_stride);
col_ = *(int *)((char*)color + j * color_stride); col_ = *(SDL_Color *)((char*)color + j * color_stride);
vertices[i].x = xy_[0] * scale_x; vertices[i].x = xy_[0] * scale_x;
vertices[i].y = xy_[1] * scale_y; vertices[i].y = xy_[1] * scale_y;

View file

@ -216,19 +216,31 @@ set_stencil_mask(VITA_GXM_RenderData *data, float x, float y, float w, float h)
vertices[0].x = x; vertices[0].x = x;
vertices[0].y = y; vertices[0].y = y;
vertices[0].color = 0; vertices[0].color.r = 0;
vertices[0].color.g = 0;
vertices[0].color.b = 0;
vertices[0].color.a = 0;
vertices[1].x = x + w; vertices[1].x = x + w;
vertices[1].y = y; vertices[1].y = y;
vertices[1].color = 0; vertices[1].color.r = 0;
vertices[1].color.g = 0;
vertices[1].color.b = 0;
vertices[1].color.a = 0;
vertices[2].x = x; vertices[2].x = x;
vertices[2].y = y + h; vertices[2].y = y + h;
vertices[2].color = 0; vertices[2].color.r = 0;
vertices[2].color.g = 0;
vertices[2].color.b = 0;
vertices[2].color.a = 0;
vertices[3].x = x + w; vertices[3].x = x + w;
vertices[3].y = y + h; vertices[3].y = y + h;
vertices[3].color = 0; vertices[3].color.r = 0;
vertices[3].color.g = 0;
vertices[3].color.b = 0;
vertices[3].color.a = 0;
data->drawstate.fragment_program = data->colorFragmentProgram; data->drawstate.fragment_program = data->colorFragmentProgram;
data->drawstate.vertex_program = data->colorVertexProgram; data->drawstate.vertex_program = data->colorVertexProgram;

View file

@ -61,7 +61,7 @@ typedef struct clear_vertex {
typedef struct color_vertex { typedef struct color_vertex {
float x; float x;
float y; float y;
unsigned int color; SDL_Color color;
} color_vertex; } color_vertex;
typedef struct texture_vertex { typedef struct texture_vertex {
@ -69,7 +69,7 @@ typedef struct texture_vertex {
float y; float y;
float u; float u;
float v; float v;
unsigned int color; SDL_Color color;
} texture_vertex; } texture_vertex;
typedef struct gxm_texture { typedef struct gxm_texture {
@ -100,7 +100,7 @@ typedef struct
SDL_bool viewport_dirty; SDL_bool viewport_dirty;
SDL_Texture *texture; SDL_Texture *texture;
SDL_Texture *target; SDL_Texture *target;
Uint32 color; SDL_Color color;
SceGxmFragmentProgram *fragment_program; SceGxmFragmentProgram *fragment_program;
SceGxmVertexProgram *vertex_program; SceGxmVertexProgram *vertex_program;
int last_command; int last_command;
@ -110,7 +110,7 @@ typedef struct
SDL_bool cliprect_dirty; SDL_bool cliprect_dirty;
SDL_Rect cliprect; SDL_Rect cliprect;
SDL_bool texturing; SDL_bool texturing;
Uint32 clear_color; SDL_Color clear_color;
int drawablew; int drawablew;
int drawableh; int drawableh;
} gxm_drawstate_cache; } gxm_drawstate_cache;

View file

@ -633,7 +633,7 @@ DirectFB_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const
static int static int
DirectFB_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, DirectFB_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, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride,
int num_vertices, const void *indices, int num_indices, int size_indices, int num_vertices, const void *indices, int num_indices, int size_indices,
float scale_x, float scale_y) float scale_x, float scale_y)
{ {