screen usage counter

This commit is contained in:
2026-05-23 01:41:08 +02:00
parent 2275cbf47d
commit 5c905e6f77

View File

@@ -521,6 +521,7 @@ struct ncl_ScreenState {
nn_Context *ctx; nn_Context *ctx;
nn_Lock *lock; nn_Lock *lock;
nn_ScreenConfig conf; nn_ScreenConfig conf;
size_t usage;
int width; int width;
int height; int height;
int viewportWidth; int viewportWidth;
@@ -2142,9 +2143,11 @@ static void ncl_setRealScreenPixel(ncl_ScreenState *state, int x, int y, ncl_Scr
y--; y--;
state->pixels[x + y * state->conf.maxWidth] = pixel; state->pixels[x + y * state->conf.maxWidth] = pixel;
state->usage++;
} }
static void ncl_recomputeScreen(const ncl_ScreenState *state) { static void ncl_recomputeScreen(ncl_ScreenState *state) {
state->usage++;
for(int y = 1; y <= state->height; y++) { for(int y = 1; y <= state->height; y++) {
for(int x = 1; x <= state->width; x++) { for(int x = 1; x <= state->width; x++) {
ncl_ScreenPixel *pixel = ncl_getRealScreenPixelPointer(state, x, y); ncl_ScreenPixel *pixel = ncl_getRealScreenPixelPointer(state, x, y);
@@ -2313,6 +2316,7 @@ nn_Component *ncl_createScreen(nn_Universe *universe, const char *address, const
screen->viewportHeight = screen->height; screen->viewportHeight = screen->height;
screen->keyboardCount = 0; screen->keyboardCount = 0;
screen->brightness = 1; screen->brightness = 1;
screen->usage = 0;
ncl_resetScreen(screen); ncl_resetScreen(screen);
@@ -2566,6 +2570,7 @@ static nn_Exit ncl_gpuHandler(nn_GPURequest *req) {
scr->palette[idx] = req->palette.color; scr->palette[idx] = req->palette.color;
scr->resolvedPalette[idx] = scr->resolvedPalette[idx] =
nn_mapDepth(req->palette.color, scr->depth); nn_mapDepth(req->palette.color, scr->depth);
scr->usage++;
ncl_unlockScreen(scr); ncl_unlockScreen(scr);
return NN_OK; return NN_OK;
} }
@@ -3519,6 +3524,7 @@ void ncl_statComponent(nn_Component *component, ncl_ComponentStat *stat) {
if(strcmp(ty, NCL_SCREEN) == 0) { if(strcmp(ty, NCL_SCREEN) == 0) {
ncl_ScreenState *screen = state; ncl_ScreenState *screen = state;
nn_lock(screen->ctx, screen->lock); nn_lock(screen->ctx, screen->lock);
stat->usageCounter = screen->usage;
stat->screen.conf = &screen->conf; stat->screen.conf = &screen->conf;
stat->screen.depth = screen->depth; stat->screen.depth = screen->depth;
stat->screen.flags = screen->flags; stat->screen.flags = screen->flags;