diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/io/SCsub | 1 | ||||
| -rw-r--r-- | core/io/compression.cpp | 20 | ||||
| -rw-r--r-- | core/io/compression.h | 2 | ||||
| -rw-r--r-- | core/io/http_client.cpp | 12 | ||||
| -rw-r--r-- | core/io/http_client.h | 2 | ||||
| -rw-r--r-- | core/project_settings.cpp | 6 |
6 files changed, 25 insertions, 18 deletions
diff --git a/core/io/SCsub b/core/io/SCsub index 4efc902717..79b56cb716 100644 --- a/core/io/SCsub +++ b/core/io/SCsub @@ -5,3 +5,4 @@ Import('env') env.add_source_files(env.core_sources, "*.cpp") Export('env') + diff --git a/core/io/compression.cpp b/core/io/compression.cpp index fbe97e54c7..51d48901cf 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -78,9 +78,16 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, } break; case MODE_ZSTD: { - + ZSTD_CCtx *cctx = ZSTD_createCCtx(); + ZSTD_CCtx_setParameter(cctx, ZSTD_p_compressionLevel, zstd_level); + if (zstd_long_distance_matching) { + ZSTD_CCtx_setParameter(cctx, ZSTD_p_enableLongDistanceMatching, 1); + ZSTD_CCtx_setParameter(cctx, ZSTD_p_windowLog, zstd_window_log_size); + } int max_dst_size = get_max_compressed_buffer_size(p_src_size, MODE_ZSTD); - return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, zstd_level); + int ret = ZSTD_compressCCtx(cctx, p_dst, max_dst_size, p_src, p_src_size, zstd_level); + ZSTD_freeCCtx(cctx); + return ret; } break; } @@ -165,8 +172,11 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p return total; } break; case MODE_ZSTD: { - - return ZSTD_decompress(p_dst, p_dst_max_size, p_src, p_src_size); + ZSTD_DCtx *dctx = ZSTD_createDCtx(); + if (zstd_long_distance_matching) ZSTD_DCtx_setMaxWindowSize(dctx, 1 << zstd_window_log_size); + int ret = ZSTD_decompressDCtx(dctx, p_dst, p_dst_max_size, p_src, p_src_size); + ZSTD_freeDCtx(dctx); + return ret; } break; } @@ -176,3 +186,5 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p int Compression::zlib_level = Z_DEFAULT_COMPRESSION; int Compression::gzip_level = Z_DEFAULT_COMPRESSION; int Compression::zstd_level = 3; +bool Compression::zstd_long_distance_matching = false; +int Compression::zstd_window_log_size = 27; diff --git a/core/io/compression.h b/core/io/compression.h index 22d8109d4f..5a9aedec31 100644 --- a/core/io/compression.h +++ b/core/io/compression.h @@ -38,6 +38,8 @@ public: static int zlib_level; static int gzip_level; static int zstd_level; + static bool zstd_long_distance_matching; + static int zstd_window_log_size; enum Mode { MODE_FASTLZ, diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index b8c0a2b616..46d52384e5 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -189,16 +189,6 @@ Error HTTPClient::request(Method p_method, const String &p_url, const Vector<Str return OK; } -Error HTTPClient::send_body_text(const String &p_body) { - - return OK; -} - -Error HTTPClient::send_body_data(const PoolByteArray &p_body) { - - return OK; -} - bool HTTPClient::has_response() const { return response_headers.size() != 0; @@ -629,8 +619,6 @@ void HTTPClient::_bind_methods() { ClassDB::bind_method(D_METHOD("get_connection"), &HTTPClient::get_connection); ClassDB::bind_method(D_METHOD("request_raw", "method", "url", "headers", "body"), &HTTPClient::request_raw); ClassDB::bind_method(D_METHOD("request", "method", "url", "headers", "body"), &HTTPClient::request, DEFVAL(String())); - ClassDB::bind_method(D_METHOD("send_body_text", "body"), &HTTPClient::send_body_text); - ClassDB::bind_method(D_METHOD("send_body_data", "body"), &HTTPClient::send_body_data); ClassDB::bind_method(D_METHOD("close"), &HTTPClient::close); ClassDB::bind_method(D_METHOD("has_response"), &HTTPClient::has_response); diff --git a/core/io/http_client.h b/core/io/http_client.h index 023370ae81..f8a3349e6e 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -169,8 +169,6 @@ public: Error request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const PoolVector<uint8_t> &p_body); Error request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body = String()); - Error send_body_text(const String &p_body); - Error send_body_data(const PoolByteArray &p_body); void close(); diff --git a/core/project_settings.cpp b/core/project_settings.cpp index c4d1b199a0..2e4fc26784 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -1036,10 +1036,16 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF("debug/settings/profiler/max_functions", 16384); //assigning here, because using GLOBAL_GET on every block for compressing can be slow + Compression::zstd_long_distance_matching = GLOBAL_DEF("compression/formats/zstd/long_distance_matching", false); + custom_prop_info["compression/formats/zstd/long_distance_matching"] = PropertyInfo(Variant::BOOL, "compression/formats/zstd/long_distance_matching"); Compression::zstd_level = GLOBAL_DEF("compression/formats/zstd/compression_level", 3); custom_prop_info["compression/formats/zstd/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/zstd/compression_level", PROPERTY_HINT_RANGE, "1,22,1"); + Compression::zstd_window_log_size = GLOBAL_DEF("compression/formats/zstd/window_log_size", 27); + custom_prop_info["compression/formats/zstd/window_log_size"] = PropertyInfo(Variant::INT, "compression/formats/zstd/window_log_size", PROPERTY_HINT_RANGE, "10,30,1"); + Compression::zlib_level = GLOBAL_DEF("compression/formats/zlib/compression_level", Z_DEFAULT_COMPRESSION); custom_prop_info["compression/formats/zlib/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/zlib/compression_level", PROPERTY_HINT_RANGE, "-1,9,1"); + Compression::gzip_level = GLOBAL_DEF("compression/formats/gzip/compression_level", Z_DEFAULT_COMPRESSION); custom_prop_info["compression/formats/gzip/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/gzip/compression_level", PROPERTY_HINT_RANGE, "-1,9,1"); |