summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorAlexander Gavriliuk <alexandrgproductengine@lindenlab.com>2023-12-15 18:26:14 +0100
committerGuru <alexandrgproductengine@lindenlab.com>2023-12-21 19:12:52 +0100
commit74c8b028d42a8c5b080bb861e427f38cedd4ad7c (patch)
tree067f8e85fd7b4f91903ad2aa32630b7dd0364099 /indra/newview
parente104f7ce0291ed1f7ab170714e319408bf076221 (diff)
SL-20743 Use LLMutex in LLImageBase for internal data thread-safety
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/lldrawpoolbump.cpp8
-rw-r--r--indra/newview/llfasttimerview.cpp2
-rw-r--r--indra/newview/llfloater360capture.cpp4
-rw-r--r--indra/newview/llfloaterauction.cpp2
-rw-r--r--indra/newview/llfloatercolorpicker.cpp2
-rw-r--r--indra/newview/llfloaterimagepreview.cpp1
-rw-r--r--indra/newview/llinventorygallerymenu.cpp2
-rw-r--r--indra/newview/llmaterialeditor.cpp2
-rw-r--r--indra/newview/llmeshrepository.cpp20
-rw-r--r--indra/newview/llnetmap.cpp2
-rw-r--r--indra/newview/llsnapshotlivepreview.cpp10
-rw-r--r--indra/newview/lltexturecache.cpp11
-rw-r--r--indra/newview/lltexturecache.h2
-rw-r--r--indra/newview/lltexturefetch.cpp7
-rw-r--r--indra/newview/lltinygltfhelper.cpp9
-rw-r--r--indra/newview/llviewerassetupload.cpp2
-rwxr-xr-xindra/newview/llviewerparceloverlay.cpp2
-rw-r--r--indra/newview/llviewertexture.cpp3
-rw-r--r--indra/newview/llviewertexturelist.cpp4
-rw-r--r--indra/newview/llviewerwindow.cpp6
-rw-r--r--indra/newview/llvoavatar.cpp4
-rw-r--r--indra/newview/llvoavatar.h2
-rw-r--r--indra/newview/llvosky.cpp4
-rw-r--r--indra/newview/llvosky.h2
-rw-r--r--indra/newview/llvovolume.cpp6
-rw-r--r--indra/newview/llwebprofile.cpp4
26 files changed, 95 insertions, 28 deletions
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index a0ce0ef6cf..77a196380b 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -849,11 +849,14 @@ void LLBumpImageList::onSourceStandardLoaded( BOOL success, LLViewerFetchedTextu
void LLBumpImageList::generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nrm_image)
{
+ LLImageDataSharedLock lockIn(src);
+ LLImageDataLock lockOut(nrm_image);
+
U8* nrm_data = nrm_image->getData();
S32 resX = src->getWidth();
S32 resY = src->getHeight();
- U8* src_data = src->getData();
+ const U8* src_data = src->getData();
S32 src_cmp = src->getComponents();
@@ -911,6 +914,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL;
+ LLImageDataSharedLock lock(src);
bump_image_map_t& entries_list(bump_code == BE_BRIGHTNESS ? gBumpImageList.mBrightnessEntries : gBumpImageList.mDarknessEntries );
bump_image_map_t::iterator iter = entries_list.find(source_asset_id);
@@ -933,7 +937,7 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
U8* dst_data = dst_image->getData();
S32 dst_data_size = dst_image->getDataSize();
- U8* src_data = src->getData();
+ const U8* src_data = src->getData();
S32 src_data_size = src->getDataSize();
S32 src_components = src->getComponents();
diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp
index 5b8ca6c49c..9cf9f45bfb 100644
--- a/indra/newview/llfasttimerview.cpp
+++ b/indra/newview/llfasttimerview.cpp
@@ -448,6 +448,8 @@ void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch
// disable use of glReadPixels which messes up nVidia nSight graphics debugging
if (!LLRender::sNsightDebugSupport)
{
+ LLImageDataSharedLock lock(scratch);
+
//read result back into raw image
glReadPixels(0, 0, 1024, 512, GL_RGB, GL_UNSIGNED_BYTE, scratch->getData());
diff --git a/indra/newview/llfloater360capture.cpp b/indra/newview/llfloater360capture.cpp
index 2c638fa959..a0890b7f9d 100644
--- a/indra/newview/llfloater360capture.cpp
+++ b/indra/newview/llfloater360capture.cpp
@@ -360,6 +360,8 @@ void LLFloater360Capture::encodeAndSave(LLPointer<LLImageRaw> raw_image, const s
int jpeg_encode_quality = gSavedSettings.getU32("360CaptureJPEGEncodeQuality");
LLPointer<LLImageJPEG> jpeg_image = new LLImageJPEG(jpeg_encode_quality);
+ LLImageDataSharedLock lock(raw_image);
+
// Actually encode the JPEG image. This is where a lot of time
// is spent now that the snapshot capture process has been
// optimized. The encode_time parameter doesn't appear to be
@@ -410,6 +412,8 @@ void LLFloater360Capture::suspendForAFrame()
// Probably not needed anymore but saving here just in case.
void LLFloater360Capture::mockSnapShot(LLImageRaw* raw)
{
+ LLImageDataLock lock(raw);
+
unsigned int width = raw->getWidth();
unsigned int height = raw->getHeight();
unsigned int depth = raw->getComponents();
diff --git a/indra/newview/llfloaterauction.cpp b/indra/newview/llfloaterauction.cpp
index 9813156bf2..6996224dcb 100644
--- a/indra/newview/llfloaterauction.cpp
+++ b/indra/newview/llfloaterauction.cpp
@@ -190,6 +190,8 @@ void LLFloaterAuction::onClickSnapshot(void* data)
if (success)
{
+ LLImageDataLock lock(raw);
+
self->mTransactionID.generate();
self->mImageID = self->mTransactionID.makeAssetID(gAgent.getSecureSessionID());
diff --git a/indra/newview/llfloatercolorpicker.cpp b/indra/newview/llfloatercolorpicker.cpp
index ba91277c79..af96fdbcfd 100644
--- a/indra/newview/llfloatercolorpicker.cpp
+++ b/indra/newview/llfloatercolorpicker.cpp
@@ -135,6 +135,8 @@ void LLFloaterColorPicker::createUI ()
// create RGB type area (not really RGB but it's got R,G & B in it.,..
LLPointer<LLImageRaw> raw = new LLImageRaw ( mRGBViewerImageWidth, mRGBViewerImageHeight, mComponents );
+ LLImageDataLock lock(raw);
+
U8* bits = raw->getData();
S32 linesize = mRGBViewerImageWidth * mComponents;
for ( S32 y = 0; y < mRGBViewerImageHeight; ++y )
diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp
index ba0f97e2e1..5e7978e224 100644
--- a/indra/newview/llfloaterimagepreview.cpp
+++ b/indra/newview/llfloaterimagepreview.cpp
@@ -789,6 +789,7 @@ void LLImagePreviewSculpted::setPreviewTarget(LLImageRaw* imagep, F32 distance)
if (imagep)
{
+ LLImageDataSharedLock lock(imagep);
mVolume->sculpt(imagep->getWidth(), imagep->getHeight(), imagep->getComponents(), imagep->getData(), 0, false);
}
diff --git a/indra/newview/llinventorygallerymenu.cpp b/indra/newview/llinventorygallerymenu.cpp
index c8ac73b838..e966514955 100644
--- a/indra/newview/llinventorygallerymenu.cpp
+++ b/indra/newview/llinventorygallerymenu.cpp
@@ -70,7 +70,7 @@ void modify_outfit(BOOL append, const LLUUID& cat_id, LLInventoryModel* model)
if (items.size() > max_items())
{
LLSD args;
- args["AMOUNT"] = llformat("%d", static_cast<U32>(max_items));
+ args["AMOUNT"] = llformat("%u", max_items());
LLNotificationsUtil::add("TooManyWearables", args);
return;
}
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 5e78e15c72..415543eb37 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -3424,6 +3424,8 @@ void LLMaterialEditor::inventoryChanged(LLViewerObject* object,
void LLMaterialEditor::saveTexture(LLImageJ2C* img, const std::string& name, const LLUUID& asset_id, upload_callback_f cb)
{
+ LLImageDataSharedLock lock(img);
+
if (asset_id.isNull()
|| img == nullptr
|| img->getDataSize() == 0)
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp
index 01d6469010..2622c23314 100644
--- a/indra/newview/llmeshrepository.cpp
+++ b/indra/newview/llmeshrepository.cpp
@@ -2360,17 +2360,19 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
std::stringstream texture_str;
if (texture != NULL && include_textures && mUploadTextures)
{
- if(texture->hasSavedRawImage())
- {
+ if (texture->hasSavedRawImage())
+ {
+ LLImageDataLock lock(texture->getSavedRawImage());
+
LLPointer<LLImageJ2C> upload_file =
LLViewerTextureList::convertToUploadFile(texture->getSavedRawImage());
if (!upload_file.isNull() && upload_file->getDataSize())
{
- texture_str.write((const char*) upload_file->getData(), upload_file->getDataSize());
+ texture_str.write((const char*) upload_file->getData(), upload_file->getDataSize());
+ }
}
}
- }
if (texture != NULL &&
mUploadTextures &&
@@ -2514,17 +2516,19 @@ void LLMeshUploadThread::wholeModelToLLSD(LLSD& dest, bool include_textures)
std::stringstream texture_str;
if (texture != NULL && include_textures && mUploadTextures)
{
- if(texture->hasSavedRawImage())
- {
+ if (texture->hasSavedRawImage())
+ {
+ LLImageDataLock lock(texture->getSavedRawImage());
+
LLPointer<LLImageJ2C> upload_file =
LLViewerTextureList::convertToUploadFile(texture->getSavedRawImage());
if (!upload_file.isNull() && upload_file->getDataSize())
{
- texture_str.write((const char*) upload_file->getData(), upload_file->getDataSize());
+ texture_str.write((const char*) upload_file->getData(), upload_file->getDataSize());
+ }
}
}
- }
if (texture != NULL &&
mUploadTextures &&
diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp
index 0ba3c3d691..e7f9d0e5df 100644
--- a/indra/newview/llnetmap.cpp
+++ b/indra/newview/llnetmap.cpp
@@ -345,6 +345,7 @@ void LLNetMap::draw()
mObjectImageCenterGlobal = viewPosToGlobal(llfloor(new_center.mV[VX]), llfloor(new_center.mV[VY]));
// Create the base texture.
+ LLImageDataLock lock(mObjectRawImagep);
U8 *default_texture = mObjectRawImagep->getData();
memset( default_texture, 0, mObjectImagep->getWidth() * mObjectImagep->getHeight() * mObjectImagep->getComponents() );
@@ -915,6 +916,7 @@ void LLNetMap::renderPoint(const LLVector3 &pos_local, const LLColor4U &color,
return;
}
+ LLImageDataLock lock(mObjectRawImagep);
U8 *datap = mObjectRawImagep->getData();
S32 neg_radius = diameter / 2;
diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp
index b7a1832b17..bb7c73b59f 100644
--- a/indra/newview/llsnapshotlivepreview.cpp
+++ b/indra/newview/llsnapshotlivepreview.cpp
@@ -766,6 +766,8 @@ void LLSnapshotLivePreview::prepareFreezeFrame()
// Get the decoded version of the formatted image
getEncodedImage();
+ LLImageDataSharedLock lock(mPreviewImageEncoded);
+
// We need to scale that a bit for display...
LLPointer<LLImageRaw> scaled = new LLImageRaw(
mPreviewImageEncoded->getData(),
@@ -825,13 +827,15 @@ LLPointer<LLImageRaw> LLSnapshotLivePreview::getEncodedImage()
{
if (!mPreviewImageEncoded)
{
+ LLImageDataSharedLock lock(mPreviewImage);
+
mPreviewImageEncoded = new LLImageRaw;
-
+
mPreviewImageEncoded->resize(
mPreviewImage->getWidth(),
mPreviewImage->getHeight(),
mPreviewImage->getComponents());
-
+
if (getSnapshotType() == LLSnapshotModel::SNAPSHOT_TEXTURE)
{
// We don't store the intermediate formatted image in mFormattedImage in the J2C case
@@ -978,6 +982,8 @@ void LLSnapshotLivePreview::getSize(S32& w, S32& h) const
void LLSnapshotLivePreview::saveTexture(BOOL outfit_snapshot, std::string name)
{
+ LLImageDataSharedLock lock(mPreviewImage);
+
LL_DEBUGS("Snapshot") << "saving texture: " << mPreviewImage->getWidth() << "x" << mPreviewImage->getHeight() << LL_ENDL;
// gen a new uuid for this asset
LLTransactionID tid;
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp
index a14d4f7a30..dfaeeaab62 100644
--- a/indra/newview/lltexturecache.cpp
+++ b/indra/newview/lltexturecache.cpp
@@ -96,7 +96,7 @@ private:
public:
LLTextureCacheWorker(LLTextureCache* cache, const LLUUID& id,
- U8* data, S32 datasize, S32 offset,
+ const U8* data, S32 datasize, S32 offset,
S32 imagesize, // for writes
LLTextureCache::Responder* responder)
: LLWorkerClass(cache, "LLTextureCacheWorker"),
@@ -145,7 +145,7 @@ protected:
LLUUID mID;
U8* mReadData;
- U8* mWriteData;
+ const U8* mWriteData;
S32 mDataSize;
S32 mOffset;
S32 mImageSize;
@@ -239,7 +239,7 @@ class LLTextureCacheRemoteWorker : public LLTextureCacheWorker
{
public:
LLTextureCacheRemoteWorker(LLTextureCache* cache, const LLUUID& id,
- U8* data, S32 datasize, S32 offset,
+ const U8* data, S32 datasize, S32 offset,
S32 imagesize, // for writes
LLPointer<LLImageRaw> raw, S32 discardlevel,
LLTextureCache::Responder* responder)
@@ -1961,7 +1961,7 @@ bool LLTextureCache::readComplete(handle_t handle, bool abort)
}
LLTextureCache::handle_t LLTextureCache::writeToCache(const LLUUID& id,
- U8* data, S32 datasize, S32 imagesize,
+ const U8* data, S32 datasize, S32 imagesize,
LLPointer<LLImageRaw> rawimage, S32 discardlevel,
WriteResponder* responder)
{
@@ -2047,6 +2047,9 @@ LLPointer<LLImageRaw> LLTextureCache::readFromFastCache(const LLUUID& id, S32& d
bool LLTextureCache::writeToFastCache(LLUUID image_id, S32 id, LLPointer<LLImageRaw> raw, S32 discardlevel)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
+
+ LLImageDataSharedLock lock(raw);
+
//rescale image if needed
if (raw.isNull() || raw->isBufferInvalid() || !raw->getData())
{
diff --git a/indra/newview/lltexturecache.h b/indra/newview/lltexturecache.h
index 43e91b3e4c..cba45393f9 100644
--- a/indra/newview/lltexturecache.h
+++ b/indra/newview/lltexturecache.h
@@ -125,7 +125,7 @@ public:
handle_t readFromCache(const LLUUID& id, S32 offset, S32 size,
ReadResponder* responder);
bool readComplete(handle_t handle, bool abort);
- handle_t writeToCache(const LLUUID& id, U8* data, S32 datasize, S32 imagesize, LLPointer<LLImageRaw> rawimage, S32 discardlevel,
+ handle_t writeToCache(const LLUUID& id, const U8* data, S32 datasize, S32 imagesize, LLPointer<LLImageRaw> rawimage, S32 discardlevel,
WriteResponder* responder);
LLPointer<LLImageRaw> readFromFastCache(const LLUUID& id, S32& discardlevel);
bool writeComplete(handle_t handle, bool abort = false);
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index 38c9b3717d..4ecabf666b 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -1699,7 +1699,9 @@ bool LLTextureFetchWorker::doWork(S32 param)
mFormattedImage = new LLImageJ2C; // default
}
}
-
+
+ LLImageDataLock lock(mFormattedImage);
+
if (mHaveAllData) //the image file is fully loaded.
{
mFileSize = total_size;
@@ -1857,6 +1859,9 @@ bool LLTextureFetchWorker::doWork(S32 param)
//return false;
return doWork(param);
}
+
+ LLImageDataSharedLock lock(mFormattedImage);
+
S32 datasize = mFormattedImage->getDataSize();
if(mFileSize < datasize)//This could happen when http fetching and sim fetching mixed.
{
diff --git a/indra/newview/lltinygltfhelper.cpp b/indra/newview/lltinygltfhelper.cpp
index 999be07dba..cee18489f0 100644
--- a/indra/newview/lltinygltfhelper.cpp
+++ b/indra/newview/lltinygltfhelper.cpp
@@ -31,7 +31,7 @@
#include "llviewertexture.h"
#include "llviewertexturelist.h"
-void strip_alpha_channel(LLPointer<LLImageRaw>& img)
+static void strip_alpha_channel(LLPointer<LLImageRaw>& img)
{
if (img->getComponents() == 4)
{
@@ -45,13 +45,13 @@ void strip_alpha_channel(LLPointer<LLImageRaw>& img)
// PRECONDITIONS:
// dst_img must be 3 component
// src_img and dst_image must have the same dimensions
-void copy_red_channel(LLPointer<LLImageRaw>& src_img, LLPointer<LLImageRaw>& dst_img)
+static void copy_red_channel(const LLPointer<LLImageRaw>& src_img, LLPointer<LLImageRaw>& dst_img)
{
llassert(src_img->getWidth() == dst_img->getWidth() && src_img->getHeight() == dst_img->getHeight());
llassert(dst_img->getComponents() == 3);
U32 pixel_count = dst_img->getWidth() * dst_img->getHeight();
- U8* src = src_img->getData();
+ const U8* src = src_img->getData();
U8* dst = dst_img->getData();
S8 src_components = src_img->getComponents();
@@ -95,6 +95,8 @@ void LLTinyGLTFHelper::initFetchedTextures(tinygltf::Material& material,
int mr_idx = material.pbrMetallicRoughness.metallicRoughnessTexture.index;
if (occlusion_idx != mr_idx)
{
+ LLImageDataLock lockIn(occlusion_img);
+ LLImageDataLock lockOut(mr_img);
//scale occlusion image to match resolution of mr image
occlusion_img->scale(mr_img->getWidth(), mr_img->getHeight());
@@ -104,6 +106,7 @@ void LLTinyGLTFHelper::initFetchedTextures(tinygltf::Material& material,
}
else if (occlusion_img)
{
+ LLImageDataSharedLock lock(occlusion_img);
//no mr but occlusion exists, make a white mr_img and copy occlusion red channel over
mr_img = new LLImageRaw(occlusion_img->getWidth(), occlusion_img->getHeight(), 3);
mr_img->clear(255, 255, 255);
diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp
index a2b0b04092..dcb14eb383 100644
--- a/indra/newview/llviewerassetupload.cpp
+++ b/indra/newview/llviewerassetupload.cpp
@@ -654,6 +654,8 @@ LLBufferedAssetUploadInfo::LLBufferedAssetUploadInfo(LLUUID itemId, LLPointer<LL
{
setItemId(itemId);
+ LLImageDataSharedLock lock(image);
+
EImageCodec codec = static_cast<EImageCodec>(image->getCodec());
switch (codec)
diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp
index 785c84c38d..e1f372d396 100755
--- a/indra/newview/llviewerparceloverlay.cpp
+++ b/indra/newview/llviewerparceloverlay.cpp
@@ -344,6 +344,8 @@ void LLViewerParcelOverlay::updateOverlayTexture()
const LLColor4U for_sale = LLUIColorTable::instance().getColor("PropertyColorForSale").get();
const LLColor4U auction = LLUIColorTable::instance().getColor("PropertyColorAuction").get();
+ LLImageDataLock lock(mImageRaw);
+
// Create the base texture.
U8 *raw = mImageRaw->getData();
const S32 COUNT = mParcelGridsPerEdge * mParcelGridsPerEdge;
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
index ec6f2c848f..820a051782 100644
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -285,6 +285,7 @@ LLPointer<LLViewerTexture> LLViewerTextureManager::getLocalTexture(const U32 wid
LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTexture(const LLImageRaw* raw, FTType type, bool usemipmaps)
{
+ LLImageDataSharedLock lock(raw);
LLViewerFetchedTexture* ret = new LLViewerFetchedTexture(raw, type, usemipmaps);
gTextureList.addImage(ret, TEX_LIST_STANDARD);
return ret;
@@ -2905,6 +2906,8 @@ void LLViewerFetchedTexture::saveRawImage()
return;
}
+ LLImageDataSharedLock lock(mRawImage);
+
mSavedRawDiscardLevel = mRawDiscardLevel;
if (mBoostLevel == LLGLTexture::BOOST_ICON)
{
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index f898fb7142..7931b74b11 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -1252,6 +1252,8 @@ bool LLViewerTextureList::createUploadFile(LLPointer<LLImageRaw> raw_image,
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
+ LLImageDataSharedLock lock(raw_image);
+
// make a copy, since convertToUploadFile scales raw image
LLPointer<LLImageRaw> scale_image = new LLImageRaw(
raw_image->getData(),
@@ -1357,6 +1359,8 @@ BOOL LLViewerTextureList::createUploadFile(const std::string& filename,
LLPointer<LLImageJ2C> LLViewerTextureList::convertToUploadFile(LLPointer<LLImageRaw> raw_image, const S32 max_image_dimentions, bool force_square, bool force_lossless)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE;
+ LLImageDataLock lock(raw_image);
+
if (force_square)
{
S32 biggest_side = llmax(raw_image->getWidth(), raw_image->getHeight());
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index ba2b6e1c7c..27ec8d9376 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -4890,6 +4890,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
{
return FALSE;
}
+
//check if there is enough memory for the snapshot image
if(image_width * image_height > (1 << 22)) //if snapshot image is larger than 2K by 2K
{
@@ -5008,6 +5009,9 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
image_buffer_x = llfloor(snapshot_width * scale_factor) ;
image_buffer_y = llfloor(snapshot_height * scale_factor) ;
}
+
+ LLImageDataLock lock(raw);
+
if ((image_buffer_x > 0) && (image_buffer_y > 0))
{
raw->resize(image_buffer_x, image_buffer_y, 3);
@@ -5266,6 +5270,8 @@ BOOL LLViewerWindow::simpleSnapshot(LLImageRaw* raw, S32 image_width, S32 image_
display(do_rebuild, zoom, subfield, for_snapshot);
}
+ LLImageDataSharedLock lock(raw);
+
glReadPixels(
0, 0,
image_width,
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index fee00eb6f4..8ab7cda28c 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -8894,7 +8894,7 @@ void LLVOAvatar::clearChat()
}
-void LLVOAvatar::applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, LLAvatarAppearanceDefines::EBakedTextureIndex index)
+void LLVOAvatar::applyMorphMask(const U8* tex_data, S32 width, S32 height, S32 num_components, LLAvatarAppearanceDefines::EBakedTextureIndex index)
{
if (index >= BAKED_NUM_INDICES)
{
@@ -9770,6 +9770,8 @@ void LLVOAvatar::onBakedTextureMasksLoaded( BOOL success, LLViewerFetchedTexture
{
if(aux_src && aux_src->getComponents() == 1)
{
+ LLImageDataSharedLock lock(aux_src);
+
if (!aux_src->getData())
{
LL_ERRS() << "No auxiliary source (morph mask) data for image id " << id << LL_ENDL;
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 48bfd5293a..759d02959c 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -590,7 +590,7 @@ public:
// Morph masks
//--------------------------------------------------------------------
public:
- /*virtual*/ void applyMorphMask(U8* tex_data, S32 width, S32 height, S32 num_components, LLAvatarAppearanceDefines::EBakedTextureIndex index = LLAvatarAppearanceDefines::BAKED_NUM_INDICES);
+ /*virtual*/ void applyMorphMask(const U8* tex_data, S32 width, S32 height, S32 num_components, LLAvatarAppearanceDefines::EBakedTextureIndex index = LLAvatarAppearanceDefines::BAKED_NUM_INDICES);
BOOL morphMaskNeedsUpdate(LLAvatarAppearanceDefines::EBakedTextureIndex index = LLAvatarAppearanceDefines::BAKED_NUM_INDICES);
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 20621665fa..db197335f2 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -166,6 +166,7 @@ S32 LLSkyTex::getWhich(const BOOL curr)
void LLSkyTex::initEmpty(const S32 tex)
{
+ LLImageDataLock lock(mImageRaw[tex]);
U8* data = mImageRaw[tex]->getData();
for (S32 i = 0; i < SKYTEX_RESOLUTION; ++i)
{
@@ -187,7 +188,8 @@ void LLSkyTex::initEmpty(const S32 tex)
void LLSkyTex::create()
{
- U8* data = mImageRaw[sCurrent]->getData();
+ LLImageDataSharedLock lock(mImageRaw[sCurrent]);
+ const U8* data = mImageRaw[sCurrent]->getData();
for (S32 i = 0; i < SKYTEX_RESOLUTION; ++i)
{
for (S32 j = 0; j < SKYTEX_RESOLUTION; ++j)
diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h
index 5941ab6e3b..509ad97786 100644
--- a/indra/newview/llvosky.h
+++ b/indra/newview/llvosky.h
@@ -101,6 +101,7 @@ protected:
void setPixel(const LLColor4U &col, const S32 i, const S32 j)
{
+ LLImageDataSharedLock lock(mImageRaw[sCurrent]);
S32 offset = (i * SKYTEX_RESOLUTION + j) * SKYTEX_COMPONENTS;
U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]);
*pix = col.asRGBA();
@@ -109,6 +110,7 @@ protected:
LLColor4U getPixel(const S32 i, const S32 j)
{
LLColor4U col;
+ LLImageDataSharedLock lock(mImageRaw[sCurrent]);
S32 offset = (i * SKYTEX_RESOLUTION + j) * SKYTEX_COMPONENTS;
U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]);
col.fromRGBA( *pix );
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index ec2f490742..8846e30145 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -1311,11 +1311,13 @@ void LLVOVolume::sculpt()
}
}
else
- {
+ {
+ LLImageDataSharedLock lock(raw_image);
+
sculpt_height = raw_image->getHeight();
sculpt_width = raw_image->getWidth();
sculpt_components = raw_image->getComponents();
-
+
sculpt_data = raw_image->getData();
if(LLViewerTextureManager::sTesterp)
diff --git a/indra/newview/llwebprofile.cpp b/indra/newview/llwebprofile.cpp
index f2d7e4585a..ade9bbd847 100644
--- a/indra/newview/llwebprofile.cpp
+++ b/indra/newview/llwebprofile.cpp
@@ -239,10 +239,12 @@ LLCore::BufferArray::ptr_t LLWebProfile::buildPostData(const LLSD &data, LLPoint
<< "Content-Disposition: form-data; name=\"file\"; filename=\"snapshot.png\"\r\n"
<< "Content-Type: image/png\r\n\r\n";
+ LLImageDataSharedLock lock(image);
+
// Insert the image data.
//char *datap = (char *)(image->getData());
//bas.write(datap, image->getDataSize());
- U8* image_data = image->getData();
+ const U8* image_data = image->getData();
for (S32 i = 0; i < image->getDataSize(); ++i)
{
bas << image_data[i];