ref: d57b2c66ba189f5bb32dcee6c24942f99e62788e
parent: b821d86c911e230575d3d3d9e45f1690de5636a1
author: Jacob Moody <moody@posixcafe.org>
date: Thu Dec 21 17:51:26 EST 2023
stop checking for screen channel on each mask calcuation Also RGBA32 aint worth the hassle. If someone runs in to it then we can revist this.
--- a/src/Backends/Rendering/9front.cpp
+++ b/src/Backends/Rendering/9front.cpp
@@ -75,6 +75,16 @@
memimageinit();
if(initdraw(nil, nil, "cstory") < 0)
sysfatal("initdraw: %r");
+ switch(screen->chan){
+ case XRGB32:
+ case ARGB32:
+ break;
+ default:
+ /* TODO? */
+ sysfatal("unsupported screen color channel");
+ return;
+ }
+
resizec = chancreate(sizeof(int), 1);
mctl = initmouse(nil, screen);
if(mctl == nil)
@@ -187,6 +197,10 @@
surface->dirty = 1;
}
+enum {
+ maskmask = 0xFFFFFF,
+};
+
void RenderBackend_CalcMask(RenderBackend_Surface *s)
{
Memimage *m;
@@ -193,23 +207,7 @@
Rectangle r;
int x, y, w, h;
ulong *lp;
- ulong mask;
- switch(s->i->chan){
- case XRGB32:
- case ARGB32:
- case XBGR32:
- case ABGR32:
- mask = 0xFFFFFF;
- break;
- case RGBA32:
- mask = 0xFFFFFF00;
- break;
- default:
- /* TODO? */
- sysfatal("< 32 bit screen color channel");
- return;
- }
r = s->i->r;
w = Dx(r);
h = Dy(r);
@@ -218,7 +216,7 @@
for(y = 0; y < h; y++)
for(x = 0; x < w; x++){
lp = m->data->base + y*w + x;
- if((*lp & mask) == 0)
+ if((*lp & maskmask) == 0)
*lp = 0x00;
else
*lp = 0xFFFFFFFF;