implement bright window dimming

This commit is contained in:
Rytis Karpuska
2019-11-06 01:34:57 +02:00
parent 310b66d519
commit e510814b7c
4 changed files with 245 additions and 0 deletions

View File

@@ -32,4 +32,20 @@ void report_allocation_failure(const char *func, const char *file, unsigned int
unreachable;
}
///
/// Calculates next closest power of two of 32bit integer n
/// ref: https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
///
int next_power_of_two(int n)
{
n--;
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
n++;
return n;
}
// vim: set noet sw=8 ts=8 :