1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-05 19:31:35 +00:00

Rename StreamTexture* to CompressedTexture*

* Its not and will not be used for streaming.
* Streaming will be implemented in 4.1 and it will work different.
* It makes more sense to be called CompressedTexture since it imports and compresses texture files.
This commit is contained in:
reduz
2022-03-05 16:43:38 +01:00
parent ff65d33e8c
commit ccd4cdfd8b
24 changed files with 239 additions and 239 deletions

View File

@@ -104,16 +104,16 @@ String ResourceImporterLayeredTexture::get_save_extension() const {
String ResourceImporterLayeredTexture::get_resource_type() const {
switch (mode) {
case MODE_CUBEMAP: {
return "StreamCubemap";
return "CompressedCubemap";
} break;
case MODE_2D_ARRAY: {
return "StreamTexture2DArray";
return "CompressedTexture2DArray";
} break;
case MODE_CUBEMAP_ARRAY: {
return "StreamCubemapArray";
return "CompressedCubemapArray";
} break;
case MODE_3D: {
return "StreamTexture3D";
return "CompressedTexture3D";
} break;
}
ERR_FAIL_V(String());
@@ -263,7 +263,7 @@ void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, cons
f->store_8('T');
f->store_8('L');
f->store_32(StreamTextureLayered::FORMAT_VERSION);
f->store_32(CompressedTextureLayered::FORMAT_VERSION);
f->store_32(p_images.size()); // For 2d layers or 3d depth.
f->store_32(mode);
f->store_32(0);

View File

@@ -35,7 +35,7 @@
#include "core/io/resource_importer.h"
#include "core/object/ref_counted.h"
class StreamTexture2D;
class CompressedTexture2D;
class LayeredTextureImport : public RefCounted {
GDCLASS(LayeredTextureImport, RefCounted);

View File

@@ -37,7 +37,7 @@
#include "editor/editor_file_system.h"
#include "editor/editor_node.h"
void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTexture2D> &p_tex, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_channel) {
void ResourceImporterTexture::_texture_reimport_roughness(const Ref<CompressedTexture2D> &p_tex, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_channel) {
ERR_FAIL_COND(p_tex.is_null());
MutexLock lock(singleton->mutex);
@@ -53,7 +53,7 @@ void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTextur
singleton->make_flags[path].normal_path_for_roughness = p_normal_path;
}
void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture2D> &p_tex) {
void ResourceImporterTexture::_texture_reimport_3d(const Ref<CompressedTexture2D> &p_tex) {
ERR_FAIL_COND(p_tex.is_null());
MutexLock lock(singleton->mutex);
@@ -67,7 +67,7 @@ void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture2D> &p
singleton->make_flags[path].flags |= MAKE_3D_FLAG;
}
void ResourceImporterTexture::_texture_reimport_normal(const Ref<StreamTexture2D> &p_tex) {
void ResourceImporterTexture::_texture_reimport_normal(const Ref<CompressedTexture2D> &p_tex) {
ERR_FAIL_COND(p_tex.is_null());
MutexLock lock(singleton->mutex);
@@ -153,11 +153,11 @@ void ResourceImporterTexture::get_recognized_extensions(List<String> *p_extensio
}
String ResourceImporterTexture::get_save_extension() const {
return "stex";
return "ctex";
}
String ResourceImporterTexture::get_resource_type() const {
return "StreamTexture2D";
return "CompressedTexture2D";
}
bool ResourceImporterTexture::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const {
@@ -231,7 +231,7 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
bool lossless_force_png = ProjectSettings::get_singleton()->get("rendering/textures/lossless_compression/force_png") ||
!Image::_webp_mem_loader_func; // WebP module disabled.
bool use_webp = !lossless_force_png && p_image->get_width() <= 16383 && p_image->get_height() <= 16383; // WebP has a size limit
f->store_32(use_webp ? StreamTexture2D::DATA_FORMAT_WEBP : StreamTexture2D::DATA_FORMAT_PNG);
f->store_32(use_webp ? CompressedTexture2D::DATA_FORMAT_WEBP : CompressedTexture2D::DATA_FORMAT_PNG);
f->store_16(p_image->get_width());
f->store_16(p_image->get_height());
f->store_32(p_image->get_mipmap_count());
@@ -253,7 +253,7 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
} break;
case COMPRESS_LOSSY: {
f->store_32(StreamTexture2D::DATA_FORMAT_WEBP);
f->store_32(CompressedTexture2D::DATA_FORMAT_WEBP);
f->store_16(p_image->get_width());
f->store_16(p_image->get_height());
f->store_32(p_image->get_mipmap_count());
@@ -273,7 +273,7 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
image->compress_from_channels(p_compress_format, p_channels, p_lossy_quality);
f->store_32(StreamTexture2D::DATA_FORMAT_IMAGE);
f->store_32(CompressedTexture2D::DATA_FORMAT_IMAGE);
f->store_16(image->get_width());
f->store_16(image->get_height());
f->store_32(image->get_mipmap_count());
@@ -285,7 +285,7 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
f->store_buffer(r, dl);
} break;
case COMPRESS_VRAM_UNCOMPRESSED: {
f->store_32(StreamTexture2D::DATA_FORMAT_IMAGE);
f->store_32(CompressedTexture2D::DATA_FORMAT_IMAGE);
f->store_16(p_image->get_width());
f->store_16(p_image->get_height());
f->store_32(p_image->get_mipmap_count());
@@ -299,7 +299,7 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image
} break;
case COMPRESS_BASIS_UNIVERSAL: {
f->store_32(StreamTexture2D::DATA_FORMAT_BASIS_UNIVERSAL);
f->store_32(CompressedTexture2D::DATA_FORMAT_BASIS_UNIVERSAL);
f->store_16(p_image->get_width());
f->store_16(p_image->get_height());
f->store_32(p_image->get_mipmap_count());
@@ -326,26 +326,26 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String
f->store_8('2'); //godot streamable texture 2D
//format version
f->store_32(StreamTexture2D::FORMAT_VERSION);
f->store_32(CompressedTexture2D::FORMAT_VERSION);
//texture may be resized later, so original size must be saved first
f->store_32(p_image->get_width());
f->store_32(p_image->get_height());
uint32_t flags = 0;
if (p_streamable) {
flags |= StreamTexture2D::FORMAT_BIT_STREAM;
flags |= CompressedTexture2D::FORMAT_BIT_STREAM;
}
if (p_mipmaps) {
flags |= StreamTexture2D::FORMAT_BIT_HAS_MIPMAPS; //mipmaps bit
flags |= CompressedTexture2D::FORMAT_BIT_HAS_MIPMAPS; //mipmaps bit
}
if (p_detect_3d) {
flags |= StreamTexture2D::FORMAT_BIT_DETECT_3D;
flags |= CompressedTexture2D::FORMAT_BIT_DETECT_3D;
}
if (p_detect_roughness) {
flags |= StreamTexture2D::FORMAT_BIT_DETECT_ROUGNESS;
flags |= CompressedTexture2D::FORMAT_BIT_DETECT_ROUGNESS;
}
if (p_detect_normal) {
flags |= StreamTexture2D::FORMAT_BIT_DETECT_NORMAL;
flags |= CompressedTexture2D::FORMAT_BIT_DETECT_NORMAL;
}
f->store_32(flags);
@@ -540,19 +540,19 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
if (!bptc_ldr && can_s3tc && is_ldr) {
image_compress_mode = Image::COMPRESS_S3TC;
}
_save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, image_compress_mode, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel);
_save_stex(image, p_save_path + ".s3tc.ctex", compress_mode, lossy, image_compress_mode, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel);
r_platform_variants->push_back("s3tc");
formats_imported.push_back("s3tc");
}
if (ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2")) {
_save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel);
_save_stex(image, p_save_path + ".etc2.ctex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel);
r_platform_variants->push_back("etc2");
formats_imported.push_back("etc2");
}
if (ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc")) {
_save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel);
_save_stex(image, p_save_path + ".etc.ctex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel);
r_platform_variants->push_back("etc");
formats_imported.push_back("etc");
}
@@ -562,7 +562,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
}
} else {
//import normally
_save_stex(image, p_save_path + ".stex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel);
_save_stex(image, p_save_path + ".ctex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel);
}
if (r_metadata) {
@@ -638,9 +638,9 @@ ResourceImporterTexture *ResourceImporterTexture::singleton = nullptr;
ResourceImporterTexture::ResourceImporterTexture() {
singleton = this;
StreamTexture2D::request_3d_callback = _texture_reimport_3d;
StreamTexture2D::request_roughness_callback = _texture_reimport_roughness;
StreamTexture2D::request_normal_callback = _texture_reimport_normal;
CompressedTexture2D::request_3d_callback = _texture_reimport_3d;
CompressedTexture2D::request_roughness_callback = _texture_reimport_roughness;
CompressedTexture2D::request_normal_callback = _texture_reimport_normal;
}
ResourceImporterTexture::~ResourceImporterTexture() {

View File

@@ -37,7 +37,7 @@
#include "scene/resources/texture.h"
#include "servers/rendering_server.h"
class StreamTexture2D;
class CompressedTexture2D;
class ResourceImporterTexture : public ResourceImporter {
GDCLASS(ResourceImporterTexture, ResourceImporter);
@@ -67,9 +67,9 @@ protected:
Map<StringName, MakeInfo> make_flags;
static void _texture_reimport_roughness(const Ref<StreamTexture2D> &p_tex, const String &p_normal_path, RenderingServer::TextureDetectRoughnessChannel p_channel);
static void _texture_reimport_3d(const Ref<StreamTexture2D> &p_tex);
static void _texture_reimport_normal(const Ref<StreamTexture2D> &p_tex);
static void _texture_reimport_roughness(const Ref<CompressedTexture2D> &p_tex, const String &p_normal_path, RenderingServer::TextureDetectRoughnessChannel p_channel);
static void _texture_reimport_3d(const Ref<CompressedTexture2D> &p_tex);
static void _texture_reimport_normal(const Ref<CompressedTexture2D> &p_tex);
static ResourceImporterTexture *singleton;
static const char *compression_formats[];