Browse Source

Updated size index after the new dimension restriction.

David Piuva 5 years ago
parent
commit
37a69735f8
2 changed files with 24 additions and 3 deletions
  1. 1 3
      Source/DFPSR/image/ImageRgbaU8.cpp
  2. 23 0
      Source/test/tests/ImageTest.cpp

+ 1 - 3
Source/DFPSR/image/ImageRgbaU8.cpp

@@ -135,9 +135,7 @@ static int32_t getSizeGroup(int32_t size) {
 		group = 13;
 		group = 13;
 	} else if (size == 16384) {
 	} else if (size == 16384) {
 		group = 14; // Largest allowed texture dimension
 		group = 14; // Largest allowed texture dimension
-	} else if (size == 32768) {
-		group = 15; // May exceed the the address space of 32-bit pointers! Not allowed for textures.
-	}
+	} // Higher dimensions should return -1, so that initializeRgbaImage avoids initializing the image as a texture and isTexture returns false
 	return group;
 	return group;
 }
 }
 
 

+ 23 - 0
Source/test/tests/ImageTest.cpp

@@ -55,5 +55,28 @@ START_TEST(Image)
 		image_generatePyramid(image);
 		image_generatePyramid(image);
 		ASSERT_EQUAL(image_hasPyramid(image), true);
 		ASSERT_EQUAL(image_hasPyramid(image), true);
 	}
 	}
+	{ // Texture criterias
+		ImageRgbaU8 image;
+		image = image_create_RgbaU8(2, 2);
+		ASSERT_EQUAL(image_isTexture(image), false); // Too small
+		image = image_create_RgbaU8(13, 8);
+		ASSERT_EQUAL(image_isTexture(image), false); // Not power-of-two width
+		image = image_create_RgbaU8(4, 7);
+		ASSERT_EQUAL(image_isTexture(image), false); // Not power-of-two height
+		image = image_create_RgbaU8(4, 4);
+		ASSERT_EQUAL(image_isTexture(image), true); // Okay
+		image = image_create_RgbaU8(4, 16384);
+		ASSERT_EQUAL(image_isTexture(image), true); // Okay
+		image = image_create_RgbaU8(16384, 4);
+		ASSERT_EQUAL(image_isTexture(image), true); // Okay
+		image = image_create_RgbaU8(16384 + 1, 4);
+		ASSERT_EQUAL(image_isTexture(image), false); // Too wide and not power-of-two width
+		image = image_create_RgbaU8(32768, 4);
+		ASSERT_EQUAL(image_isTexture(image), false); // Too wide
+		image = image_create_RgbaU8(4, 16384 + 1);
+		ASSERT_EQUAL(image_isTexture(image), false); // Too high and not power-of-two height
+		image = image_create_RgbaU8(4, 32768);
+		ASSERT_EQUAL(image_isTexture(image), false); // Too high
+	}
 END_TEST
 END_TEST