diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 66217f902..4f6950a7d 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -206,6 +206,19 @@ U8* LLImageBase::allocateData(S32 size)
// virtual
U8* LLImageBase::reallocateData(S32 size)
{
+ if (size == -1)
+ {
+ size = mWidth * mHeight * mComponents;
+ if (size <= 0)
+ {
+ llerrs << llformat("LLImageBase::reallocateData called with bad dimensions: %dx%dx%d", mWidth, mHeight, (S32)mComponents) << llendl;
+ }
+ }
+ else if (size <= 0 || (size > 4096 * 4096 * 16 && !mAllowOverSize))
+ {
+ llerrs << "LLImageBase::reallocateData: bad size: " << size << llendl;
+ }
+
if(mData && (mDataSize == size))
return mData;
@@ -943,76 +956,66 @@ BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data )
return TRUE; // Nothing to do.
}
- // Reallocate the data buffer.
+ U8* old_buffer = NULL;
+ U8* new_buffer;
+ S32 const old_width_bytes = old_width * getComponents();
+ S32 const new_width_bytes = new_width * getComponents();
+ S32 const min_height = llmin(old_height, new_height);
+ S32 const min_width_bytes = llmin(old_width_bytes, new_width_bytes);
if (scale_image_data)
{
- // Vertical
- S32 temp_data_size = old_width * new_height * getComponents();
- llassert_always(temp_data_size > 0);
- U8* temp_buffer = new (std::nothrow) U8[ temp_data_size ];
- if (!temp_buffer )
+ if (new_height != old_height)
{
- llerrs << "Out of memory in LLImageRaw::scale()" << llendl;
- return FALSE;
+ // Resize vertically.
+ old_buffer = LLImageBase::release();
+ new_buffer = allocateDataSize(old_width, new_height, getComponents());
+ for (S32 col = 0; col < old_width; ++col)
+ {
+ copyLineScaled(old_buffer + getComponents() * col, new_buffer + getComponents() * col, old_height, new_height, old_width, old_width);
+ }
+ LLImageBase::deleteData(old_buffer);
}
- for( S32 col = 0; col < old_width; col++ )
+ if (new_width != old_width)
{
- copyLineScaled( getData() + (getComponents() * col), temp_buffer + (getComponents() * col), old_height, new_height, old_width, old_width );
+ // Resize horizontally.
+ old_buffer = LLImageBase::release();
+ new_buffer = allocateDataSize(new_width, new_height, getComponents());
+ for (S32 row = 0; row < new_height; ++row)
+ {
+ copyLineScaled(old_buffer + old_width_bytes * row, new_buffer + new_width_bytes * row, old_width, new_width, 1, 1);
+ }
+ LLImageBase::deleteData(old_buffer);
}
-
- deleteData();
-
- U8* new_buffer = allocateDataSize(new_width, new_height, getComponents());
-
- // Horizontal
- for( S32 row = 0; row < new_height; row++ )
- {
- copyLineScaled( temp_buffer + (getComponents() * old_width * row), new_buffer + (getComponents() * new_width * row), old_width, new_width, 1, 1 );
- }
-
- // Clean up
- delete[] temp_buffer;
}
else
{
- // copy out existing image data
- S32 temp_data_size = old_width * old_height * getComponents();
- U8* temp_buffer = new (std::nothrow) U8[ temp_data_size ];
- if (!temp_buffer)
+ if (new_width == old_width)
{
- llwarns << "Out of memory in LLImageRaw::scale: old (w, h, c) = (" << old_width << ", " << old_height << ", " << (S32)getComponents() <<
- ") ; new (w, h, c) = (" << new_width << ", " << new_height << ", " << (S32)getComponents() << ")" << llendl;
-
- return FALSE ;
+ setSize(new_width, new_height, getComponents());
+ new_buffer = reallocateData();
}
- memcpy(temp_buffer, getData(), temp_data_size); /* Flawfinder: ignore */
-
- // allocate new image data, will delete old data
- U8* new_buffer = allocateDataSize(new_width, new_height, getComponents());
-
- for( S32 row = 0; row < new_height; row++ )
+ else
{
- if (row < old_height)
+ old_buffer = LLImageBase::release();
+ new_buffer = allocateDataSize(new_width, new_height, getComponents());
+ for (S32 row = 0; row < min_height; ++row)
{
- memcpy(new_buffer + (new_width * row * getComponents()), temp_buffer + (old_width * row * getComponents()), getComponents() * llmin(old_width, new_width)); /* Flawfinder: ignore */
- if (old_width < new_width)
+ memcpy(new_buffer + row * new_width_bytes, old_buffer + row * old_width_bytes, min_width_bytes);
+ if (new_width_bytes > old_width_bytes)
{
- // pad out rest of row with black
- memset(new_buffer + (getComponents() * ((new_width * row) + old_width)), 0, getComponents() * (new_width - old_width));
+ // Pad out rest of row with black.
+ memset(new_buffer + new_width_bytes * row + old_width_bytes, 0, new_width_bytes - old_width_bytes);
}
}
- else
- {
- // pad remaining rows with black
- memset(new_buffer + (new_width * row * getComponents()), 0, new_width * getComponents());
- }
+ LLImageBase::deleteData(old_buffer);
+ }
+ if (new_height > old_height)
+ {
+ // Pad remaining rows with black.
+ memset(new_buffer + new_width_bytes * min_height, 0, new_width_bytes * (new_height - old_height));
}
-
- // Clean up
- delete[] temp_buffer;
}
-
return TRUE ;
}
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index 3782ff1cf..a5fcea97d 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -114,6 +114,8 @@ public:
virtual void deleteData();
virtual U8* allocateData(S32 size = -1);
virtual U8* reallocateData(S32 size = -1);
+ static void deleteData(U8* data) { FREE_MEM(sPrivatePoolp, data); }
+ U8* release() { U8* data = mData; mData = NULL; mDataSize = 0; return data; } // Same as deleteData(), but returns old data. Call deleteData(old_data) to free it.
virtual void dump();
virtual void sanityCheck();
@@ -180,7 +182,7 @@ public:
/*virtual*/ void deleteData();
/*virtual*/ U8* allocateData(S32 size = -1);
- /*virtual*/ U8* reallocateData(S32 size);
+ /*virtual*/ U8* reallocateData(S32 size = -1);
BOOL resize(U16 width, U16 height, S8 components);
@@ -287,7 +289,7 @@ public:
// LLImageBase
/*virtual*/ void deleteData();
/*virtual*/ U8* allocateData(S32 size = -1);
- /*virtual*/ U8* reallocateData(S32 size);
+ /*virtual*/ U8* reallocateData(S32 size = -1);
/*virtual*/ void dump();
/*virtual*/ void sanityCheck();
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index c5cf582e5..e34d1a852 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -201,15 +201,13 @@ void gl_rect_2d(S32 left, S32 top, S32 right, S32 bottom, BOOL filled )
gGL.begin( LLRender::LINES );
// Verticals
- gGL.vertex2i(left + 1, top);
- gGL.vertex2i(left + 1, bottom);
+ gGL.vertex2i(left + 1, top + 1);
+ gGL.vertex2i(left + 1, bottom + 1);
- gGL.vertex2i(right, bottom);
- gGL.vertex2i(right, top);
+ gGL.vertex2i(right + 1, bottom + 1);
+ gGL.vertex2i(right + 1, top + 1);
// Horizontals
- top--;
- right--;
gGL.vertex2i(left, bottom);
gGL.vertex2i(right, bottom);
@@ -219,8 +217,6 @@ void gl_rect_2d(S32 left, S32 top, S32 right, S32 bottom, BOOL filled )
}
else
{
- top--;
- right--;
gGL.begin( LLRender::LINE_STRIP );
gGL.vertex2i(left, top);
gGL.vertex2i(left, bottom);
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 6ad0c7bdf..1bd830a96 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -7865,17 +7865,6 @@ Found in Advanced->Rendering->Info Displays
Value
64
- KeepAspectForSnapshot
-
LandBrushSize
+ LastSnapshotToFeedAspect
+
LastSnapshotToFeedHeight
+ LastSnapshotToEmailAspect
+
LastSnapshotToEmailHeight
+ LastSnapshotToDiskAspect
+
LastSnapshotToDiskHeight
+ LastSnapshotToInventoryAspect
+
LastSnapshotToInventoryHeight
+ SnapshotFeedLastAspect
+
SnapshotFeedLastResolution
+ SnapshotLocalLastAspect
+
SnapshotLocalLastResolution
+ SnapshotPostcardLastAspect
+
SnapshotPostcardLastResolution
+ SnapshotTextureLastAspect
+
SnapshotTextureLastResolution