diff options
Diffstat (limited to 'indra/newview/lltinygltfhelper.cpp')
-rw-r--r-- | indra/newview/lltinygltfhelper.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/indra/newview/lltinygltfhelper.cpp b/indra/newview/lltinygltfhelper.cpp index f71c9dd14a..7b4f47e567 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(); @@ -91,6 +91,8 @@ void LLTinyGLTFHelper::initFetchedTextures(tinygltf::Material& material, { if (material.pbrMetallicRoughness.metallicRoughnessTexture.index != material.occlusionTexture.index) { + LLImageDataLock lockIn(occlusion_img); + LLImageDataLock lockOut(mr_img); // occlusion is a distinct texture from pbrMetallicRoughness // pack into mr red channel int occlusion_idx = material.occlusionTexture.index; @@ -114,6 +116,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); @@ -336,7 +339,7 @@ bool LLTinyGLTFHelper::getMaterialFromModel( if (base_color_tex) { - base_color_tex->addTextureStats(64.f * 64.f, TRUE); + base_color_tex->addTextureStats(64.f * 64.f, true); material->mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR] = base_color_tex->getID(); material->mBaseColorTexture = base_color_tex; } @@ -348,7 +351,7 @@ bool LLTinyGLTFHelper::getMaterialFromModel( if (normal_tex) { - normal_tex->addTextureStats(64.f * 64.f, TRUE); + normal_tex->addTextureStats(64.f * 64.f, true); material->mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_NORMAL] = normal_tex->getID(); material->mNormalTexture = normal_tex; } @@ -360,7 +363,7 @@ bool LLTinyGLTFHelper::getMaterialFromModel( if (mr_tex) { - mr_tex->addTextureStats(64.f * 64.f, TRUE); + mr_tex->addTextureStats(64.f * 64.f, true); material->mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS] = mr_tex->getID(); material->mMetallicRoughnessTexture = mr_tex; } @@ -372,7 +375,7 @@ bool LLTinyGLTFHelper::getMaterialFromModel( if (emissive_tex) { - emissive_tex->addTextureStats(64.f * 64.f, TRUE); + emissive_tex->addTextureStats(64.f * 64.f, true); material->mTextureId[LLGLTFMaterial::GLTF_TEXTURE_INFO_EMISSIVE] = emissive_tex->getID(); material->mEmissiveTexture = emissive_tex; } |