@@ -79,12 +79,6 @@ struct StringMaker<TextureAtlasTiles::TileHandle> {
79
79
80
80
auto tileData (TileData::Padding padding = {}) { return TileData (TileData::Size (4 ), padding); }
81
81
82
- auto mipmappedTileData (TileData::Padding padding = {})
83
- {
84
- auto mipmapper = [](const TileData& tile_data) { return TileData (dgl::nextMipmapSize (tile_data.size ())); };
85
- return MipmapLevels (tileData (padding), mipmapper);
86
- }
87
-
88
82
auto atlasTiles () { return TextureAtlasTiles ({16 , 4 }); }
89
83
90
84
auto atlasTilesWithTileHandle (const TileData::Padding& padding = {})
@@ -109,6 +103,12 @@ auto frozenTilesWithTileHandle()
109
103
return std::pair{freeze (std::move (atlas_tiles)), tile_handle};
110
104
}
111
105
106
+ auto applyMipmap (const TileData& tile_data)
107
+ {
108
+ auto mipmapper = [](const TileData& tile_data) { return TileData (dgl::nextMipmapSize (tile_data.size ())); };
109
+ return MipmapLevels (tile_data, mipmapper);
110
+ }
111
+
112
112
TEST_CASE (" TextureAtlasTiles can be constructed and moved." , " [texturing][texture-atlas-tiles]" )
113
113
{
114
114
SECTION (" Constructing TextureAtlasTiles." )
@@ -279,6 +279,7 @@ TEST_CASE("TextureAtlasTiles can be filled with tiles of the same size, spanning
279
279
auto tile_height = GENERATE (range<std::size_t >(1 , 5 ));
280
280
281
281
auto tile_size = TileData::Size (tile_width, tile_height);
282
+ auto tile_data = GENERATE_COPY (MipmapLevels (TileData (tile_size)), applyMipmap (TileData (tile_size)));
282
283
283
284
// Tiles are aligned on powers of two:
284
285
auto tile_width_log2 = dutils::ilog2ceil (tile_width);
@@ -297,7 +298,7 @@ TEST_CASE("TextureAtlasTiles can be filled with tiles of the same size, spanning
297
298
DYNAMIC_SECTION (" Atlas of size " << max_texture_size << " cannot fit any tile of size " << tile_size
298
299
<< " .\n Adding a single tile should throw an invalid_argument exception." )
299
300
{
300
- CHECK_THROWS_AS (atlas_tiles.add (TileData (tile_size) ), std::invalid_argument);
301
+ CHECK_THROWS_AS (atlas_tiles.add (tile_data ), std::invalid_argument);
301
302
}
302
303
}
303
304
else {
@@ -309,7 +310,7 @@ TEST_CASE("TextureAtlasTiles can be filled with tiles of the same size, spanning
309
310
for (std::size_t layer = 0 ; layer < max_layer_count; layer++) {
310
311
std::set<dmath::svec2> tile_positions;
311
312
for (std::size_t i = 0 ; i < tiles_per_layer; i++) {
312
- auto tile = atlas_tiles.add (TileData (tile_size) );
313
+ auto tile = atlas_tiles.add (tile_data );
313
314
auto tile_pos = tile.pixelPos ();
314
315
auto [_, position_is_unique] = tile_positions.insert (tile_pos);
315
316
@@ -327,7 +328,7 @@ TEST_CASE("TextureAtlasTiles can be filled with tiles of the same size, spanning
327
328
328
329
SECTION (" Adding one more tile should throw a length_error exception." )
329
330
{
330
- CHECK_THROWS_AS (atlas_tiles.add (TileData (tile_size) ), std::length_error);
331
+ CHECK_THROWS_AS (atlas_tiles.add (tile_data ), std::length_error);
331
332
}
332
333
}
333
334
}
@@ -345,12 +346,13 @@ TEST_CASE("TextureAtlasTiles can be used to update a texture.", "[texturing]")
345
346
auto mipmap_levels = dgl::maxMipmapLevels (size);
346
347
auto tile_size = GENERATE (as<std::size_t >{}, 1 , 2 , 4 );
347
348
auto layers = GENERATE (as<std::size_t >{}, 1 , 2 , 4 );
349
+ auto tile_data = GENERATE_COPY (MipmapLevels (TileData (tile_size)), applyMipmap (TileData (tile_size)));
348
350
349
351
auto tile_count = dutils::sqr (size) / dutils::sqr (tile_size) * layers;
350
352
351
353
auto atlas_tiles = TextureAtlasTiles ({size, layers});
352
354
for (std::size_t i = 0 ; i < tile_count; i++)
353
- (void )atlas_tiles.add (TileData ( TileData::Size (tile_size)) );
355
+ (void )atlas_tiles.add (tile_data );
354
356
355
357
SECTION (" Using the updateTexture method, which allows further modifications." )
356
358
{
@@ -362,7 +364,7 @@ TEST_CASE("TextureAtlasTiles can be used to update a texture.", "[texturing]")
362
364
}
363
365
364
366
CHECK_THAT (resize, CalledWith (resize, size, layers, mipmap_levels));
365
- CHECK_THAT (modify, Called (modify, tile_count));
367
+ CHECK_THAT (modify, Called (modify, tile_count * tile_data. count () ));
366
368
367
369
std::set<std::pair<dmath::svec3, std::size_t >> positions_and_mipmap_levels;
368
370
for (const auto & [tile_data, offset, mipmap_level] : modify.invocations ()) {
0 commit comments