diff options
-rw-r--r-- | indra/newview/gltfscenemanager.cpp | 18 | ||||
-rw-r--r-- | indra/newview/llviewertexture.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llviewertexture.h | 6 | ||||
-rw-r--r-- | indra/newview/llviewertexturelist.cpp | 19 | ||||
-rw-r--r-- | indra/newview/llviewertexturelist.h | 3 |
5 files changed, 45 insertions, 7 deletions
diff --git a/indra/newview/gltfscenemanager.cpp b/indra/newview/gltfscenemanager.cpp index a20954d7d1..df922b8f3d 100644 --- a/indra/newview/gltfscenemanager.cpp +++ b/indra/newview/gltfscenemanager.cpp @@ -131,7 +131,21 @@ void GLTFSceneManager::uploadSelection() { mPendingImageUploads++; - LLPointer<LLImageRaw> raw = image.mTexture->getCachedRawImage(); + LLPointer<LLImageRaw> raw; + + if (image.mBufferView != INVALID_INDEX) + { + BufferView& view = asset.mBufferViews[image.mBufferView]; + Buffer& buffer = asset.mBuffers[view.mBuffer]; + + raw = LLViewerTextureManager::getRawImageFromMemory(buffer.mData.data() + view.mByteOffset, view.mByteLength, image.mMimeType); + + image.clearData(asset); + } + else + { + raw = image.mTexture->getCachedRawImage(); + } if (raw.notNull()) { @@ -192,8 +206,6 @@ void GLTFSceneManager::uploadSelection() failure)); upload_new_resource(uploadInfo); - - image.clearData(asset); } } } diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 7f913e4153..545bfeaafa 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -335,6 +335,12 @@ LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromUrl(const s return gTextureList.getImageFromUrl(url, f_type, usemipmaps, boost_priority, texture_type, internal_format, primary_format, force_id); } +//static +LLImageRaw* LLViewerTextureManager::getRawImageFromMemory(const U8* data, U32 size, std::string_view mimetype) +{ + return gTextureList.getRawImageFromMemory(data, size, mimetype); +} + //static LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromMemory(const U8* data, U32 size, std::string_view mimetype) { diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index 3c4a5c18ac..dc9182bf1b 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -690,6 +690,12 @@ public: static LLViewerFetchedTexture* getFetchedTextureFromHost(const LLUUID& image_id, FTType f_type, LLHost host) ; + // decode a given image data according to given mime type + // WARNING: caller is responsible for deleting the returned raw image + static LLImageRaw* getRawImageFromMemory(const U8* data, U32 size, std::string_view mimetype); + + // decode given image data according to given mime type + // WARNING: caller is responsible for deleting the returned image static LLViewerFetchedTexture* getFetchedTextureFromMemory(const U8* data, U32 size, std::string_view mimetype); static void init() ; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 37ff5038cd..930bf4230e 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -518,15 +518,28 @@ LLViewerFetchedTexture* LLViewerTextureList::getImageFromUrl(const std::string& return imagep; } -LLViewerFetchedTexture* LLViewerTextureList::getImageFromMemory(const U8* data, U32 size, std::string_view mimetype) +LLImageRaw* LLViewerTextureList::getRawImageFromMemory(const U8* data, U32 size, std::string_view mimetype) { LLPointer<LLImageFormatted> image = LLImageFormatted::loadFromMemory(data, size, mimetype); if (image) { - LLPointer<LLImageRaw> raw_image = new LLImageRaw(); + LLImageRaw* raw_image = new LLImageRaw(); image->decode(raw_image, 0.f); - LLPointer<LLViewerFetchedTexture> imagep = new LLViewerFetchedTexture(raw_image, FTT_LOCAL_FILE, true); + return raw_image; + } + else + { + return nullptr; + } +} + +LLViewerFetchedTexture* LLViewerTextureList::getImageFromMemory(const U8* data, U32 size, std::string_view mimetype) +{ + LLPointer<LLImageRaw> raw_image = getRawImageFromMemory(data, size, mimetype); + if (raw_image.notNull()) + { + LLViewerFetchedTexture* imagep = new LLViewerFetchedTexture(raw_image, FTT_LOCAL_FILE, true); addImage(imagep, TEX_LIST_STANDARD); imagep->dontDiscard(); diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index ba468bab7e..a2cbc85c60 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -191,7 +191,8 @@ private: LLGLenum primary_format = 0, const LLUUID& force_id = LLUUID::null ); - + + LLImageRaw* getRawImageFromMemory(const U8* data, U32 size, std::string_view mimetype); LLViewerFetchedTexture* getImageFromMemory(const U8* data, U32 size, std::string_view mimetype); LLViewerFetchedTexture* createImage(const LLUUID &image_id, |