[Scummvm-git-logs] scummvm master -> 7a8cf33d812571778b36e31bfd60ac93718f534d

Helco noreply at scummvm.org
Tue Oct 21 16:25:16 UTC 2025


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
7a8cf33d81 ALCACHOFA: Replace nextPowerOfTwo with Common::nextHigher2


Commit: 7a8cf33d812571778b36e31bfd60ac93718f534d
    https://github.com/scummvm/scummvm/commit/7a8cf33d812571778b36e31bfd60ac93718f534d
Author: Helco (hermann.noll at hotmail.com)
Date: 2025-10-21T18:25:05+02:00

Commit Message:
ALCACHOFA: Replace nextPowerOfTwo with Common::nextHigher2

Changed paths:
    engines/alcachofa/alcachofa.cpp
    engines/alcachofa/common.cpp
    engines/alcachofa/common.h
    engines/alcachofa/graphics.cpp


diff --git a/engines/alcachofa/alcachofa.cpp b/engines/alcachofa/alcachofa.cpp
index a7f387871c6..e578559bcea 100644
--- a/engines/alcachofa/alcachofa.cpp
+++ b/engines/alcachofa/alcachofa.cpp
@@ -170,8 +170,8 @@ void AlcachofaEngine::playVideo(int32 videoId) {
 	ManagedSurface tmpSurface;
 	if (_renderer->requiresPoTTextures() &&
 		(!isPowerOfTwo(texWidth) || !isPowerOfTwo(texHeight))) {
-		texWidth = nextPowerOfTwo(texWidth);
-		texHeight = nextPowerOfTwo(texHeight);
+		texWidth = nextHigher2(texWidth);
+		texHeight = nextHigher2(texHeight);
 		texMax = {
 			decoder->getWidth() / (float)texWidth,
 			decoder->getHeight() / (float)texHeight,
diff --git a/engines/alcachofa/common.cpp b/engines/alcachofa/common.cpp
index e2f62482cbf..771dd1605ea 100644
--- a/engines/alcachofa/common.cpp
+++ b/engines/alcachofa/common.cpp
@@ -31,19 +31,6 @@ bool isPowerOfTwo(int16 x) {
 	return (x & (x - 1)) == 0;
 }
 
-int16 nextPowerOfTwo(int16 v) {
-	// adapted from https://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
-	assert(v >= 0);
-	if (v == 0)
-		return 0;
-	v--;
-	v |= v >> 1;
-	v |= v >> 2;
-	v |= v >> 4;
-	v |= v >> 8;
-	return v + 1;
-}
-
 float ease(float t, EasingType type) {
 	switch (type) {
 	case EasingType::Linear:
diff --git a/engines/alcachofa/common.h b/engines/alcachofa/common.h
index 1bd5b5f7bff..8cb8adad5b3 100644
--- a/engines/alcachofa/common.h
+++ b/engines/alcachofa/common.h
@@ -115,7 +115,6 @@ private:
 };
 
 bool isPowerOfTwo(int16 x);
-int16 nextPowerOfTwo(int16 v);
 
 float ease(float t, EasingType type);
 
diff --git a/engines/alcachofa/graphics.cpp b/engines/alcachofa/graphics.cpp
index b0fcb5c39d8..45e2d3ce8b1 100644
--- a/engines/alcachofa/graphics.cpp
+++ b/engines/alcachofa/graphics.cpp
@@ -258,8 +258,8 @@ void Animation::load() {
 	Rect maxBounds = maxFrameBounds();
 	int16 texWidth = maxBounds.width(), texHeight = maxBounds.height();
 	if (g_engine->renderer().requiresPoTTextures()) {
-		texWidth = nextPowerOfTwo(maxBounds.width());
-		texHeight = nextPowerOfTwo(maxBounds.height());
+		texWidth = nextHigher2(maxBounds.width());
+		texHeight = nextHigher2(maxBounds.height());
 	}
 	_renderedSurface.create(texWidth, texHeight, g_engine->renderer().getPixelFormat());
 	_renderedTexture = g_engine->renderer().createTexture(texWidth, texHeight, true);
@@ -334,8 +334,8 @@ int32 Animation::frameAtTime(uint32 time) const {
 void Animation::overrideTexture(const ManagedSurface &surface) {
 	int16 texWidth = surface.w, texHeight = surface.h;
 	if (g_engine->renderer().requiresPoTTextures()) {
-		texWidth = nextPowerOfTwo(texWidth);
-		texHeight = nextPowerOfTwo(texHeight);
+		texWidth = nextHigher2(texWidth);
+		texHeight = nextHigher2(texHeight);
 	}
 
 	// In order to really use the overridden surface we have to override all
@@ -468,7 +468,7 @@ void Font::load() {
 
 	_texMins.resize(_images.size());
 	_texMaxs.resize(_images.size());
-	ManagedSurface atlasSurface(nextPowerOfTwo(cellSize.x * 16), nextPowerOfTwo(cellSize.y * 16), g_engine->renderer().getPixelFormat());
+	ManagedSurface atlasSurface(nextHigher2(cellSize.x * 16), nextHigher2(cellSize.y * 16), g_engine->renderer().getPixelFormat());
 	cellSize.x = atlasSurface.w / 16;
 	cellSize.y = atlasSurface.h / 16;
 	const float invWidth = 1.0f / atlasSurface.w;




More information about the Scummvm-git-logs mailing list