ref: ceb1c5733da57a554d3e06098eb0d26dc631f684
parent: bce6ff4b8b16c32cbfced092983823acf3c7deb1
author: Jacob Moody <moody@posixcafe.org>
date: Sat Feb 11 09:31:15 EST 2023
use screen channel instead of hardcoded values gives a consistent 2-3 more fps over drawterm
--- a/libnpe_sdl2/sdl2.c
+++ b/libnpe_sdl2/sdl2.c
@@ -341,7 +341,7 @@
werrstr("SDL_CreateRGBSurface: memory");
return nil;
}
- s->i = i = allocmemimage(Rect(0,0,w,h), ARGB32);
+ s->i = i = allocmemimage(Rect(0,0,w,h), screen->chan);
s->format = calloc(1, sizeof(SDL_PixelFormat));
switch(bpp){
case 32:
@@ -712,6 +712,7 @@
{
Rectangle sr, dr;
int logiw, logih;
+ ulong chan;
if(rend->logiw > 0 && rend->logih > 0){
logiw = rend->logiw;
@@ -735,7 +736,11 @@
if(back == nil || Dx(back->r) != logiw || Dy(back->r) != logih){
freememimage(back);
- back = allocmemimage(Rect(0, 0, logiw, logih), ARGB32);
+ if(screen)
+ chan = screen->chan;
+ else
+ chan = ARGB32;
+ back = allocmemimage(Rect(0, 0, logiw, logih), chan);
if(back == nil){
werrstr("SDL_RenderCopy: %r");
return -1;