diff options
author | Morris Tabor <80684659+mortarroad@users.noreply.github.com> | 2021-04-12 18:56:50 +0200 |
---|---|---|
committer | Morris Tabor <80684659+mortarroad@users.noreply.github.com> | 2021-06-11 18:46:04 +0200 |
commit | 1bc1e942089043418cc4415af313b86e4155bff6 (patch) | |
tree | 5f4401ee3515d991ee905d46639c37310b3776fa /scene | |
parent | 9990f28d8414e27843eb0626fbf7f0277e6c9130 (diff) |
Implement lossless WebP encoding
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/texture.cpp | 8 | ||||
-rw-r--r-- | scene/resources/texture.h | 21 |
2 files changed, 10 insertions, 19 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 4475179431..064563d4b5 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -327,7 +327,7 @@ Ref<Image> StreamTexture2D::load_image_from_file(FileAccess *f, int p_size_limit uint32_t mipmaps = f->get_32(); Image::Format format = Image::Format(f->get_32()); - if (data_format == DATA_FORMAT_LOSSLESS || data_format == DATA_FORMAT_LOSSY || data_format == DATA_FORMAT_BASIS_UNIVERSAL) { + if (data_format == DATA_FORMAT_PNG || data_format == DATA_FORMAT_WEBP || data_format == DATA_FORMAT_BASIS_UNIVERSAL) { //look for a PNG or WEBP file inside int sw = w; @@ -360,10 +360,10 @@ Ref<Image> StreamTexture2D::load_image_from_file(FileAccess *f, int p_size_limit Ref<Image> img; if (data_format == DATA_FORMAT_BASIS_UNIVERSAL) { img = Image::basis_universal_unpacker(pv); - } else if (data_format == DATA_FORMAT_LOSSLESS) { - img = Image::lossless_unpacker(pv); + } else if (data_format == DATA_FORMAT_PNG) { + img = Image::png_unpacker(pv); } else { - img = Image::lossy_unpacker(pv); + img = Image::webp_unpacker(pv); } if (img.is_null() || img->is_empty()) { diff --git a/scene/resources/texture.h b/scene/resources/texture.h index df8c00f8ff..95e960b5a5 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -136,8 +136,8 @@ class StreamTexture2D : public Texture2D { public: enum DataFormat { DATA_FORMAT_IMAGE, - DATA_FORMAT_LOSSLESS, - DATA_FORMAT_LOSSY, + DATA_FORMAT_PNG, + DATA_FORMAT_WEBP, DATA_FORMAT_BASIS_UNIVERSAL, }; @@ -146,9 +146,6 @@ public: }; enum FormatBits { - FORMAT_MASK_IMAGE_FORMAT = (1 << 20) - 1, - FORMAT_BIT_LOSSLESS = 1 << 20, - FORMAT_BIT_LOSSY = 1 << 21, FORMAT_BIT_STREAM = 1 << 22, FORMAT_BIT_HAS_MIPMAPS = 1 << 23, FORMAT_BIT_DETECT_3D = 1 << 24, @@ -389,8 +386,8 @@ class StreamTextureLayered : public TextureLayered { public: enum DataFormat { DATA_FORMAT_IMAGE, - DATA_FORMAT_LOSSLESS, - DATA_FORMAT_LOSSY, + DATA_FORMAT_PNG, + DATA_FORMAT_WEBP, DATA_FORMAT_BASIS_UNIVERSAL, }; @@ -399,9 +396,6 @@ public: }; enum FormatBits { - FORMAT_MASK_IMAGE_FORMAT = (1 << 20) - 1, - FORMAT_BIT_LOSSLESS = 1 << 20, - FORMAT_BIT_LOSSY = 1 << 21, FORMAT_BIT_STREAM = 1 << 22, FORMAT_BIT_HAS_MIPMAPS = 1 << 23, }; @@ -532,8 +526,8 @@ class StreamTexture3D : public Texture3D { public: enum DataFormat { DATA_FORMAT_IMAGE, - DATA_FORMAT_LOSSLESS, - DATA_FORMAT_LOSSY, + DATA_FORMAT_PNG, + DATA_FORMAT_WEBP, DATA_FORMAT_BASIS_UNIVERSAL, }; @@ -542,9 +536,6 @@ public: }; enum FormatBits { - FORMAT_MASK_IMAGE_FORMAT = (1 << 20) - 1, - FORMAT_BIT_LOSSLESS = 1 << 20, - FORMAT_BIT_LOSSY = 1 << 21, FORMAT_BIT_STREAM = 1 << 22, FORMAT_BIT_HAS_MIPMAPS = 1 << 23, }; |