summaryrefslogtreecommitdiff
path: root/indra/llimage/llpngwrapper.cpp
diff options
context:
space:
mode:
authorBrad Linden <46733234+brad-linden@users.noreply.github.com>2024-05-06 15:44:19 -0700
committerGitHub <noreply@github.com>2024-05-06 15:44:19 -0700
commit84827a7cb8d4b7a58309f98c7d4df4cfeb173935 (patch)
treeb91494298eab93bbd8dd9b00722b7a30714a1b9c /indra/llimage/llpngwrapper.cpp
parent76101843c0d390c25a783f212eb1ea75e508ada4 (diff)
parent8b747cee182cd8e95063fa152d9b5d7383cb1c74 (diff)
Merge pull request #1413 from secondlife/gltf-dev-maint-a-merge
Merge Maint A to development
Diffstat (limited to 'indra/llimage/llpngwrapper.cpp')
-rw-r--r--indra/llimage/llpngwrapper.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/indra/llimage/llpngwrapper.cpp b/indra/llimage/llpngwrapper.cpp
index cad7c00042..baf1330011 100644
--- a/indra/llimage/llpngwrapper.cpp
+++ b/indra/llimage/llpngwrapper.cpp
@@ -70,7 +70,7 @@ LLPngWrapper::~LLPngWrapper()
}
// Checks the src for a valid PNG header
-BOOL LLPngWrapper::isValidPng(U8* src)
+bool LLPngWrapper::isValidPng(U8* src)
{
const int PNG_BYTES_TO_CHECK = 8;
@@ -78,10 +78,10 @@ BOOL LLPngWrapper::isValidPng(U8* src)
if (sig != 0)
{
mErrorMessage = "Invalid or corrupt PNG file";
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
// Called by the libpng library when a fatal encoding or decoding error
@@ -134,7 +134,7 @@ void LLPngWrapper::writeFlush(png_structp png_ptr)
// The scanline also begins at the bottom of
// the image (per SecondLife conventions) instead of at the top, so we
// must assign row-pointers in "reverse" order.
-BOOL LLPngWrapper::readPng(U8* src, S32 dataSize, LLImageRaw* rawImage, ImageInfo *infop)
+bool LLPngWrapper::readPng(U8* src, S32 dataSize, LLImageRaw* rawImage, ImageInfo *infop)
{
try
{
@@ -173,6 +173,8 @@ BOOL LLPngWrapper::readPng(U8* src, S32 dataSize, LLImageRaw* rawImage, ImageInf
// data space
if (rawImage != NULL)
{
+ LLImageDataLock lock(rawImage);
+
if (!rawImage->resize(static_cast<U16>(mWidth),
static_cast<U16>(mHeight), mChannels))
{
@@ -208,18 +210,18 @@ BOOL LLPngWrapper::readPng(U8* src, S32 dataSize, LLImageRaw* rawImage, ImageInf
{
mErrorMessage = msg.what();
releaseResources();
- return (FALSE);
+ return (false);
}
catch (std::bad_alloc&)
{
mErrorMessage = "LLPngWrapper";
releaseResources();
- return (FALSE);
+ return (false);
}
// Clean up and return
releaseResources();
- return (TRUE);
+ return (true);
}
// Do transformations to normalize the input to 8-bpp RGBA
@@ -281,7 +283,7 @@ void LLPngWrapper::updateMetaData()
// Method to write raw image into PNG at dest. The raw scanline begins
// at the bottom of the image per SecondLife conventions.
-BOOL LLPngWrapper::writePng(const LLImageRaw* rawImage, U8* dest, size_t destSize)
+bool LLPngWrapper::writePng(const LLImageRaw* rawImage, U8* dest, size_t destSize)
{
try
{
@@ -362,11 +364,11 @@ BOOL LLPngWrapper::writePng(const LLImageRaw* rawImage, U8* dest, size_t destSiz
{
mErrorMessage = msg.what();
releaseResources();
- return (FALSE);
+ return (false);
}
releaseResources();
- return TRUE;
+ return true;
}
// Cleanup various internal structures