Backend_Blit always uses a colour key

This commit is contained in:
Clownacy 2019-08-10 19:31:45 +01:00
parent 64f2a78279
commit 2b86db32a0
6 changed files with 23 additions and 13 deletions

View file

@ -22,7 +22,7 @@ Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height);
void Backend_FreeSurface(Backend_Surface *surface); void Backend_FreeSurface(Backend_Surface *surface);
unsigned char* Backend_Lock(Backend_Surface *surface, unsigned int *pitch); unsigned char* Backend_Lock(Backend_Surface *surface, unsigned int *pitch);
void Backend_Unlock(Backend_Surface *surface); void Backend_Unlock(Backend_Surface *surface);
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key); void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y);
void Backend_BlitToScreen(Backend_Surface *source_surface, const RECT *rect, long x, long y, BOOL colour_key); void Backend_BlitToScreen(Backend_Surface *source_surface, const RECT *rect, long x, long y, BOOL colour_key);
void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue); void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue);
void Backend_ColourFillToScreen(const RECT *rect, unsigned char red, unsigned char green, unsigned char blue); void Backend_ColourFillToScreen(const RECT *rect, unsigned char red, unsigned char green, unsigned char blue);

View file

@ -565,9 +565,9 @@ static void BlitCommon(Backend_Surface *source_surface, const RECT *rect, Backen
vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom; vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom;
} }
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key) void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
{ {
BlitCommon(source_surface, rect, destination_surface, x, y, colour_key); BlitCommon(source_surface, rect, destination_surface, x, y, TRUE);
} }
void Backend_BlitToScreen(Backend_Surface *source_surface, const RECT *rect, long x, long y, BOOL colour_key) void Backend_BlitToScreen(Backend_Surface *source_surface, const RECT *rect, long x, long y, BOOL colour_key)

View file

@ -109,7 +109,7 @@ void Backend_Unlock(Backend_Surface *surface)
(void)surface; (void)surface;
} }
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key) static void BlitCommon(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
{ {
if (source_surface == NULL || destination_surface == NULL) if (source_surface == NULL || destination_surface == NULL)
return; return;
@ -128,9 +128,14 @@ void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Sur
SDL_BlitSurface(source_surface->sdl_surface, &source_rect, destination_surface->sdl_surface, &destination_rect); SDL_BlitSurface(source_surface->sdl_surface, &source_rect, destination_surface->sdl_surface, &destination_rect);
} }
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
{
BlitCommon(source_surface, rect, &framebuffer, x, y, TRUE);
}
void Backend_BlitToScreen(Backend_Surface *source_surface, const RECT *rect, long x, long y, BOOL colour_key) void Backend_BlitToScreen(Backend_Surface *source_surface, const RECT *rect, long x, long y, BOOL colour_key)
{ {
Backend_Blit(source_surface, rect, &framebuffer, x, y, colour_key); BlitCommon(source_surface, rect, &framebuffer, x, y, colour_key);
} }
void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue) void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
@ -151,7 +156,7 @@ void Backend_ColourFillToScreen(const RECT *rect, unsigned char red, unsigned ch
void Backend_ScreenToSurface(Backend_Surface *surface, const RECT *rect) void Backend_ScreenToSurface(Backend_Surface *surface, const RECT *rect)
{ {
Backend_Blit(&framebuffer, rect, surface, rect->left, rect->top, FALSE); BlitCommon(&framebuffer, rect, surface, rect->left, rect->top, FALSE);
} }
BOOL Backend_SupportsSubpixelGlyph(void) BOOL Backend_SupportsSubpixelGlyph(void)

View file

@ -193,7 +193,7 @@ void Backend_Unlock(Backend_Surface *surface)
surface->needs_syncing = TRUE; surface->needs_syncing = TRUE;
} }
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key) void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
{ {
if (source_surface == NULL || destination_surface == NULL) if (source_surface == NULL || destination_surface == NULL)
return; return;
@ -210,11 +210,11 @@ void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Sur
SDL_Rect destination_rect = {(int)x, (int)y, source_rect.w, source_rect.h}; SDL_Rect destination_rect = {(int)x, (int)y, source_rect.w, source_rect.h};
// Blit the surface // Blit the surface
SDL_SetSurfaceBlendMode(source_surface->sdl_surface, colour_key ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE); SDL_SetSurfaceBlendMode(source_surface->sdl_surface, SDL_BLENDMODE_BLEND);
SDL_BlitSurface(source_surface->sdl_surface, &source_rect, destination_surface->sdl_surface, &destination_rect); SDL_BlitSurface(source_surface->sdl_surface, &source_rect, destination_surface->sdl_surface, &destination_rect);
// Now blit the texture // Now blit the texture
SDL_SetTextureBlendMode(source_surface->texture, colour_key ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE); SDL_SetTextureBlendMode(source_surface->texture, SDL_BLENDMODE_BLEND);
SDL_SetRenderTarget(renderer, destination_surface->texture); SDL_SetRenderTarget(renderer, destination_surface->texture);
SDL_RenderCopy(renderer, source_surface->texture, &source_rect, &destination_rect); SDL_RenderCopy(renderer, source_surface->texture, &source_rect, &destination_rect);
SDL_SetRenderTarget(renderer, screen_texture); SDL_SetRenderTarget(renderer, screen_texture);

View file

@ -115,7 +115,7 @@ void Backend_Unlock(Backend_Surface *surface)
(void)surface; (void)surface;
} }
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key) static void BlitCommon(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
{ {
if (source_surface == NULL || destination_surface == NULL) if (source_surface == NULL || destination_surface == NULL)
return; return;
@ -198,9 +198,14 @@ void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Sur
} }
} }
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y)
{
BlitCommon(source_surface, rect, &framebuffer, x, y, TRUE);
}
void Backend_BlitToScreen(Backend_Surface *source_surface, const RECT *rect, long x, long y, BOOL colour_key) void Backend_BlitToScreen(Backend_Surface *source_surface, const RECT *rect, long x, long y, BOOL colour_key)
{ {
Backend_Blit(source_surface, rect, &framebuffer, x, y, colour_key); BlitCommon(source_surface, rect, &framebuffer, x, y, colour_key);
} }
void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue) void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
@ -268,7 +273,7 @@ void Backend_ColourFillToScreen(const RECT *rect, unsigned char red, unsigned ch
void Backend_ScreenToSurface(Backend_Surface *surface, const RECT *rect) void Backend_ScreenToSurface(Backend_Surface *surface, const RECT *rect)
{ {
Backend_Blit(&framebuffer, rect, surface, rect->left, rect->top, FALSE); BlitCommon(&framebuffer, rect, surface, rect->left, rect->top, FALSE);
} }
BOOL Backend_SupportsSubpixelGlyph(void) BOOL Backend_SupportsSubpixelGlyph(void)

View file

@ -421,7 +421,7 @@ void Surface2Surface(int x, int y, const RECT *rect, int to, int from)
RECT frameRect; RECT frameRect;
ScaleRect(rect, &frameRect); ScaleRect(rect, &frameRect);
Backend_Blit(surf[from].backend, &frameRect, surf[to].backend, x * magnification, y * magnification, TRUE); Backend_Blit(surf[from].backend, &frameRect, surf[to].backend, x * magnification, y * magnification);
} }
unsigned long GetCortBoxColor(unsigned long col) unsigned long GetCortBoxColor(unsigned long col)