summaryrefslogtreecommitdiff
path: root/indra/llimage
diff options
context:
space:
mode:
authorRye <rye@alchemyviewer.org>2025-12-31 13:07:22 -0500
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2026-01-07 02:15:43 +0200
commite440c0e47958ae9adeb775de6a4f033010b82414 (patch)
treee9eaa3ca811501a012b22443fc8a37673a52044f /indra/llimage
parent25dc8660efedecfd9f021142ac1e4ff3639e80d4 (diff)
Reduce temporary allocations and repeated utf8->utf16 in LLTextureCache with new LLFile IO code
Add non-allocating to_chars and to_wchars string creation functions to LLUUID Signed-off-by: Rye <rye@alchemyviewer.org>
Diffstat (limited to 'indra/llimage')
-rw-r--r--indra/llimage/llimage.cpp36
-rw-r--r--indra/llimage/llimage.h3
2 files changed, 37 insertions, 2 deletions
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index ca8a4199e8..bea33c04ed 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -2036,6 +2036,25 @@ file_extensions[] =
{ "dxt", IMG_CODEC_DXT },
{ "png", IMG_CODEC_PNG }
};
+
+static struct
+{
+ const wchar_t* exten;
+ EImageCodec codec;
+}
+wide_file_extensions[] =
+{
+ { L"bmp", IMG_CODEC_BMP },
+ { L"tga", IMG_CODEC_TGA },
+ { L"j2c", IMG_CODEC_J2C },
+ { L"jp2", IMG_CODEC_J2C },
+ { L"texture", IMG_CODEC_J2C },
+ { L"jpg", IMG_CODEC_JPEG },
+ { L"jpeg", IMG_CODEC_JPEG },
+ { L"mip", IMG_CODEC_DXT },
+ { L"dxt", IMG_CODEC_DXT },
+ { L"png", IMG_CODEC_PNG }
+};
#define NUM_FILE_EXTENSIONS LL_ARRAY_SIZE(file_extensions)
#if 0
static std::string find_file(std::string &name, S8 *codec)
@@ -2056,7 +2075,8 @@ static std::string find_file(std::string &name, S8 *codec)
return std::string("");
}
#endif
-EImageCodec LLImageBase::getCodecFromExtension(const std::string& exten)
+
+EImageCodec LLImageBase::getCodecFromExtension(std::string_view exten)
{
if (!exten.empty())
{
@@ -2068,6 +2088,20 @@ EImageCodec LLImageBase::getCodecFromExtension(const std::string& exten)
}
return IMG_CODEC_INVALID;
}
+
+EImageCodec LLImageBase::getCodecFromExtension(std::wstring_view exten)
+{
+ if (!exten.empty())
+ {
+ for (int i = 0; i < (int)(NUM_FILE_EXTENSIONS); i++)
+ {
+ if (exten == wide_file_extensions[i].exten)
+ return wide_file_extensions[i].codec;
+ }
+ }
+ return IMG_CODEC_INVALID;
+}
+
#if 0
bool LLImageRaw::createFromFile(const std::string &filename, bool j2c_lowest_mip_only)
{
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index 6b14b68c78..16042e573a 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -158,7 +158,8 @@ public:
// <= 0 priority means that there's no need for more data.
static F32 calc_download_priority(F32 virtual_size, F32 visible_area, S32 bytes_sent);
- static EImageCodec getCodecFromExtension(const std::string& exten);
+ static EImageCodec getCodecFromExtension(std::string_view exten);
+ static EImageCodec getCodecFromExtension(std::wstring_view exten);
//static LLTrace::MemStatHandle sMemStat;