Skip to content

Commit

Permalink
Rename compression format enum
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Jul 10, 2024
1 parent b53ba3e commit 05d5089
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion source/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ target_sources(tactile-base
"${PROJECT_SOURCE_DIR}/inc/tactile/base/container/variant.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/container/vector.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/engine/engine_app.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/io/compress/compression_format.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/io/compress/compressor.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/io/compress/compression_type.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/io/save/save_format_id.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/io/byte_stream.hpp"
"${PROJECT_SOURCE_DIR}/inc/tactile/base/layer/layer_type.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
#pragma once

#include "tactile/base/int.hpp"
#include "tactile/base/prelude.hpp"

namespace tactile {

/**
* Represents different compression modes.
* Represents known compression formats.
*/
enum class CompressionType : uint8 {
kNone,
enum class CompressionFormat : uint8
{
kZlib,
kZstd
};
Expand Down
4 changes: 2 additions & 2 deletions source/core/inc/tactile/core/io/save/ir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "tactile/base/container/string.hpp"
#include "tactile/base/container/vector.hpp"
#include "tactile/base/id.hpp"
#include "tactile/base/io/compress/compression_type.hpp"
#include "tactile/base/io/compress/compression_format.hpp"
#include "tactile/base/layer/layer_type.hpp"
#include "tactile/base/layer/object_type.hpp"
#include "tactile/base/layer/tile_encoding.hpp"
Expand Down Expand Up @@ -264,7 +264,7 @@ struct TileFormat final
TileEncoding encoding;

/** The tile compression strategy. */
CompressionType compression;
CompressionFormat compression;

/** The compression level. */
Maybe<int32> compression_level;
Expand Down
4 changes: 2 additions & 2 deletions source/core/inc/tactile/core/map/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "tactile/base/container/vector.hpp"
#include "tactile/base/id.hpp"
#include "tactile/base/int.hpp"
#include "tactile/base/io/compress/compression_type.hpp"
#include "tactile/base/io/compress/compression_format.hpp"
#include "tactile/base/layer/tile_encoding.hpp"
#include "tactile/base/layer/tile_orientation.hpp"
#include "tactile/base/prelude.hpp"
Expand Down Expand Up @@ -57,7 +57,7 @@ struct CTileFormat final
TileEncoding encoding;

/** The compression strategy. */
CompressionType compression;
Optional<CompressionFormat> compression;

/** The compression level, if any. */
Maybe<int> comp_level;
Expand Down
2 changes: 1 addition & 1 deletion source/core/src/tactile/core/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ auto make_map(Registry& registry, const MapSpec& spec) -> EntityID

auto& format = registry.add<CTileFormat>(map_entity);
format.encoding = TileEncoding::kPlainText;
format.compression = CompressionType::kNone;
format.compression = kNone;
format.comp_level = kNone;

auto& id_cache = registry.add<CMapIdCache>(map_entity);
Expand Down
2 changes: 1 addition & 1 deletion source/core/test/src/map/map_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ TEST_F(MapTest, MakeMap)
EXPECT_TRUE(is_group_layer(mRegistry, map.root_layer));

EXPECT_EQ(format.encoding, TileEncoding::kPlainText);
EXPECT_EQ(format.compression, CompressionType::kNone);
EXPECT_EQ(format.compression, kNone);
EXPECT_EQ(format.comp_level, kNone);

EXPECT_EQ(id_cache.next_tile_id, TileID {1});
Expand Down
2 changes: 1 addition & 1 deletion source/lib/core/layer/tile_format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#pragma once

#include "tactile/base/io/compress/compression_type.hpp"
#include "tactile/base/io/compress/compression_format.hpp"
#include "tactile/base/layer/tile_encoding.hpp"

namespace tactile {
Expand Down
4 changes: 2 additions & 2 deletions source/runtime/lib/inc/tactile/runtime/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "tactile/base/container/smart_ptr.hpp"
#include "tactile/base/container/string.hpp"
#include "tactile/base/int.hpp"
#include "tactile/base/io/compress/compression_type.hpp"
#include "tactile/base/io/compress/compression_format.hpp"
#include "tactile/base/log/log_level.hpp"
#include "tactile/base/prelude.hpp"
#include "tactile/runtime/api.hpp"
Expand Down Expand Up @@ -91,7 +91,7 @@ class TACTILE_RUNTIME_API Runtime final
* compressor is unregistered for the given format if this
* is null.
*/
void set_compression_provider(CompressionType format,
void set_compression_provider(CompressionFormat format,
ICompressor* compressor);

/**
Expand Down
4 changes: 2 additions & 2 deletions source/runtime/lib/src/tactile/runtime/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct Runtime::Data final
runtime_impl::UniqueImGuiContext imgui_context {};
Optional<Window> window {};
IRenderer* renderer {};
HashMap<CompressionType, ICompressor*> compressors {};
HashMap<CompressionFormat, ICompressor*> compressors {};

Data()
: protobuf_context {},
Expand Down Expand Up @@ -126,7 +126,7 @@ void Runtime::set_renderer(IRenderer* renderer)
mData->renderer = renderer;
}

void Runtime::set_compression_provider(const CompressionType format,
void Runtime::set_compression_provider(const CompressionFormat format,
ICompressor* provider)
{
if (provider != nullptr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ void ZlibCompressionPlugin::load(Runtime& runtime)
Runtime::log(LogLevel::kTrace, "Loading Zlib compression plugin");

mCompressor = std::make_unique<ZlibCompressor>();
runtime.set_compression_provider(CompressionType::kZlib, mCompressor.get());
runtime.set_compression_provider(CompressionFormat::kZlib, mCompressor.get());
}

void ZlibCompressionPlugin::unload(Runtime& runtime)
{
Runtime::log(LogLevel::kTrace, "Unloading Zlib compression plugin");

runtime.set_compression_provider(CompressionType::kZlib, nullptr);
runtime.set_compression_provider(CompressionFormat::kZlib, nullptr);
mCompressor.reset();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ void ZstdCompressionPlugin::load(Runtime& runtime)
Runtime::log(LogLevel::kTrace, "Loading Zstd compression plugin");

mCompressor = std::make_unique<ZstdCompressor>();
runtime.set_compression_provider(CompressionType::kZstd, mCompressor.get());
runtime.set_compression_provider(CompressionFormat::kZstd, mCompressor.get());
}

void ZstdCompressionPlugin::unload(Runtime& runtime)
{
Runtime::log(LogLevel::kTrace, "Unloading Zstd compression plugin");

runtime.set_compression_provider(CompressionType::kZstd, nullptr);
runtime.set_compression_provider(CompressionFormat::kZstd, nullptr);
mCompressor.reset();
}

Expand Down

0 comments on commit 05d5089

Please sign in to comment.