Skip to content

Commit 0560f71

Browse files
committed
Disable texture check in the Copy method
1 parent a2b5203 commit 0560f71

File tree

1 file changed

+23
-43
lines changed

1 file changed

+23
-43
lines changed

src/render/psp/SDL_render_psp.c

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -545,39 +545,23 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex
545545
const float u1 = srcrect->x + srcrect->w;
546546
const float v1 = srcrect->y + srcrect->h;
547547

548-
// We need to split in slices because we have a texture bigger than 64 pixel width
549-
if (texture) {
550-
SliceSize sliceSize, sliceDimension, uvSize;
551-
uvSize.width = abs(u1 - u0);
552-
uvSize.height = abs(v1 - v0);
553-
if (calculateBestSliceSizeForTexture(texture, &uvSize, &sliceSize, &sliceDimension))
554-
return -1;
555-
556-
verticesCount = sliceDimension.width * sliceDimension.height * 2;
557-
verts = (VertTV *)SDL_AllocateRenderVertices(renderer, verticesCount * sizeof(VertTV), 4, &cmd->data.draw.first);
558-
if (verts == NULL)
559-
return -1;
560-
561-
fillSpriteVertices(verts, &sliceDimension, &sliceSize, srcrect, dstrect);
562-
} else {
563-
// We don't need to split in slices because we don't have a texture
564-
verticesCount = 2;
565-
verts = (VertTV *)SDL_AllocateRenderVertices(renderer, verticesCount * sizeof(VertTV), 4, &cmd->data.draw.first);
566-
if (verts == NULL)
567-
return -1;
548+
SliceSize sliceSize, sliceDimension, uvSize;
568549

569-
verts[0].u = u0;
570-
verts[0].v = v0;
571-
verts[0].x = x;
572-
verts[0].y = y;
573-
verts[0].z = 0;
574-
575-
verts[1].u = u1;
576-
verts[1].v = v1;
577-
verts[1].x = x + width;
578-
verts[1].y = y + height;
579-
verts[1].z = 0;
580-
}
550+
// In this function texture must be created
551+
if (!texture)
552+
return -1;
553+
554+
uvSize.width = abs(u1 - u0);
555+
uvSize.height = abs(v1 - v0);
556+
if (calculateBestSliceSizeForTexture(texture, &uvSize, &sliceSize, &sliceDimension))
557+
return -1;
558+
559+
verticesCount = sliceDimension.width * sliceDimension.height * 2;
560+
verts = (VertTV *)SDL_AllocateRenderVertices(renderer, verticesCount * sizeof(VertTV), 4, &cmd->data.draw.first);
561+
if (verts == NULL)
562+
return -1;
563+
564+
fillSpriteVertices(verts, &sliceDimension, &sliceSize, srcrect, dstrect);
581565

582566
cmd->data.draw.count = verticesCount;
583567

@@ -788,18 +772,14 @@ int PSP_RenderCopy(SDL_Renderer *renderer, void *vertices, SDL_RenderCommand *cm
788772

789773
PSP_SetBlendMode(data, blendInfo);
790774

791-
if (cmd->data.draw.texture) {
792-
PSP_Texture *psp_tex = (PSP_Texture *)cmd->data.draw.texture->driverdata;
775+
PSP_Texture *psp_tex = (PSP_Texture *)cmd->data.draw.texture->driverdata;
793776

794-
sceGuTexMode(psp_tex->format, 0, 0, GU_FALSE);
795-
sceGuTexImage(0, psp_tex->textureWidth, psp_tex->textureHeight, psp_tex->width, psp_tex->data);
796-
sceGuTexFilter(psp_tex->filter, psp_tex->filter);
797-
sceGuEnable(GU_TEXTURE_2D);
798-
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, count, 0, verts);
799-
sceGuDisable(GU_TEXTURE_2D);
800-
} else {
801-
sceGuDrawArray(GU_SPRITES, GU_VERTEX_32BITF | GU_TRANSFORM_2D, count, 0, verts);
802-
}
777+
sceGuTexMode(psp_tex->format, 0, 0, GU_FALSE);
778+
sceGuTexImage(0, psp_tex->textureWidth, psp_tex->textureHeight, psp_tex->width, psp_tex->data);
779+
sceGuTexFilter(psp_tex->filter, psp_tex->filter);
780+
sceGuEnable(GU_TEXTURE_2D);
781+
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, count, 0, verts);
782+
sceGuDisable(GU_TEXTURE_2D);
803783

804784
return 0;
805785
}

0 commit comments

Comments
 (0)