Ansariel 2023-03-28 18:02:32 +02:00
commit 62a57b441a
8 changed files with 187 additions and 18 deletions

View File

@ -5,6 +5,7 @@ env:
EXTRA_ARGS: -DFMODSTUDIO=ON -DUSE_KDU=ON --crashreporting
build_secrets_checkout: ${{github.workspace}}/signing
jobs:
build_matrix:
strategy:
@ -31,6 +32,18 @@ jobs:
- name: Check python version
run: python -V
- name: Free Disk Space (Ubuntu)
if: runner.os == 'Linux'
uses: jlumbroso/free-disk-space@main
with:
swap-storage: false
- name: Set gcc version on Linux
if: runner.os == 'Linux'
run: |
echo "CC=gcc-10" >> $GITHUB_ENV
echo "CXX=g++-10" >> $GITHUB_ENV
- name: Install Bash 4 and GNU sed on Mac
if: runner.os == 'macOS'
run: |
@ -117,12 +130,14 @@ jobs:
security set-key-partition-list -S apple-tool:,apple:, -s -k "$FS_KEYCHAIN_PASS" -t private ~/Library/Keychains/viewer.keychain
security list-keychain -d user -s ~/Library/Keychains/viewer.keychain
- name: Install required Ubuntu packages
- name: Install required Ubuntu packages and release some space.
if: runner.os == 'Linux'
run: |
dependencies=("python3-setuptools" "mesa-common-dev" "libgl1-mesa-dev" "libxinerama-dev" "libxrandr-dev" "libpulse-dev" "libglu1-mesa-dev" "libfreetype6-dev" "libfontconfig1")
sudo apt-get update
sudo apt-get install -y "${dependencies[@]}"
sudo apt-get autoremove --purge
sudo apt-get clean
- name: test macOS bundles are present
if: runner.os == 'MacOS'
@ -168,7 +183,9 @@ jobs:
fi
done
shell: bash
- name: Clean up packages to give more space
run: rm *${{ env.fallback_platform }}*bz2
shell: bash
- name: Configure
run: autobuild configure --debug -c ReleaseFS -A${{matrix.addrsize}} -- --package --chan ${{env.FS_RELEASE_CHAN}} ${{env.EXTRA_ARGS}} ${{env.FS_GRID}}
shell: bash

View File

@ -1098,11 +1098,11 @@
<key>archive</key>
<map>
<key>hash</key>
<string>e610f49fa7ed5b10b0cc6409b9bf4afc</string>
<string>5fee0f9587f50531211ff9e1e860692f</string>
<key>hash_algorithm</key>
<string>md5</string>
<key>url</key>
<string>file:///opt/firestorm/fmodstudio-2.02.11-linux64-230190114.tar.bz2</string>
<string>file:///opt/firestorm/fmodstudio-2.02.13-linux64-230861132.tar.bz2</string>
</map>
<key>name</key>
<string>linux64</string>
@ -1112,11 +1112,11 @@
<key>archive</key>
<map>
<key>hash</key>
<string>8b2fff1a0a7e057da99fdade1f9e82ff</string>
<string>99c928b18a0d2f08b0ee33fca90c4118</string>
<key>hash_algorithm</key>
<string>md5</string>
<key>url</key>
<string>file:///c:/cygwin/opt/firestorm/fmodstudio-2.02.11-windows-230181802.tar.bz2</string>
<string>file:///c:/cygwin/opt/firestorm/fmodstudio-2.02.13-windows-230860911.tar.bz2</string>
</map>
<key>name</key>
<string>windows</string>
@ -1126,18 +1126,18 @@
<key>archive</key>
<map>
<key>hash</key>
<string>6cf457e2268ed83326c6d77f3475e8f5</string>
<string>01946a6427d126570607c02b75560f02</string>
<key>hash_algorithm</key>
<string>md5</string>
<key>url</key>
<string>file:///c:/cygwin/opt/firestorm/fmodstudio-2.02.11-windows64-230181820.tar.bz2</string>
<string>file:///c:/cygwin/opt/firestorm/fmodstudio-2.02.13-windows64-230860913.tar.bz2</string>
</map>
<key>name</key>
<string>windows64</string>
</map>
</map>
<key>version</key>
<string>2.02.11</string>
<string>2.02.13</string>
</map>
<key>fontconfig</key>
<map>

View File

@ -257,7 +257,11 @@ if (LINUX OR DARWIN)
if(LINUX)
set(GCC_CXX_WARNINGS "${GCC_WARNINGS} -Wno-reorder -Wno-non-virtual-dtor -Wno-unused-variable -Wno-unused-but-set-variable -Wno-pragmas -Wno-deprecated")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)
set(GCC_CXX_WARNINGS "${GCC_CXX_WARNINGS} -Wno-c++20-compat")
endif()
set(CMAKE_C_FLAGS "${GCC_WARNINGS} ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${GCC_CXX_WARNINGS} ${CMAKE_CXX_FLAGS}")

View File

@ -65,6 +65,8 @@
#include "llcheckboxctrl.h"
#include "llagentbenefits.h"
#include "llnotificationsutil.h" // <FS:Zi> detect and strip empty alpha layers from images on upload
const S32 PREVIEW_BORDER_WIDTH = 2;
const S32 PREVIEW_RESIZE_HANDLE_SIZE = S32(RESIZE_HANDLE_WIDTH * OO_SQRT2) + PREVIEW_BORDER_WIDTH;
const S32 PREVIEW_HPAD = PREVIEW_RESIZE_HANDLE_SIZE;
@ -72,6 +74,10 @@ const S32 PREVIEW_VPAD = -24 + 35; // yuk, hard coded
const S32 PREF_BUTTON_HEIGHT = 16 + 7 + 16 + 35;
const S32 PREVIEW_TEXTURE_HEIGHT = 320;
// <FS:Zi> detect and strip empty alpha layers from images on upload
const U8 ALPHA_EMPTY_THRESHOLD = 253;
const F32 ALPHA_EMPTY_THRESHOLD_RATIO = 0.999f;
// </FS:Zi>
//-----------------------------------------------------------------------------
// LLFloaterImagePreview()
//-----------------------------------------------------------------------------
@ -168,16 +174,99 @@ BOOL LLFloaterImagePreview::postBuild()
}
}
getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this));
// <FS:Zi> detect and strip empty alpha layers from images on upload
// getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterNameDesc::onBtnOK, this));
getChild<LLUICtrl>("ok_btn")->setCommitCallback(boost::bind(&LLFloaterImagePreview::onBtnUpload, this));
if (mRawImagep->getComponents() != 4)
{
return TRUE;
}
U32 imageBytes = mRawImagep->getWidth() * mRawImagep->getHeight() * 4;
U32 emptyAlphaCount = 0;
U8* data = mRawImagep->getData();
for (U32 i = 3; i < imageBytes; i += 4)
{
if (data[i] > ALPHA_EMPTY_THRESHOLD)
{
emptyAlphaCount++;
}
}
mEmptyAlphaCheck = getChild<LLCheckBoxCtrl>("strip_alpha_check");
if (emptyAlphaCount > (imageBytes / 4 * ALPHA_EMPTY_THRESHOLD_RATIO))
{
getChild<LLUICtrl>("image_alpha_warning")->setVisible(true);
mEmptyAlphaCheck->setCommitCallback(boost::bind(&LLFloaterImagePreview::emptyAlphaCheckboxCallback, this));
mEmptyAlphaCheck->setValue(true);
}
else
{
getChild<LLUICtrl>("image_alpha_warning")->setVisible(false);
mEmptyAlphaCheck->setValue(false);
}
// </FS:Zi>
return TRUE;
}
// <FS:Zi> detect and strip empty alpha layers from images on upload
void LLFloaterImagePreview::emptyAlphaCheckboxCallback()
{
if (!mEmptyAlphaCheck->getValue())
{
LLNotificationsUtil::add("ImageEmptyAlphaLayer", LLSD(), LLSD(), boost::bind(&LLFloaterImagePreview::imageEmptyAlphaCallback, this, _1, _2));
}
}
bool LLFloaterImagePreview::imageEmptyAlphaCallback(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
// 0 = strip alpha
if (option == 0)
{
mEmptyAlphaCheck->setValue(true);
}
return true;
}
void LLFloaterImagePreview::onBtnUpload()
{
if(mEmptyAlphaCheck->getValue())
{
LLPointer<LLImageRaw> stripped_image = new LLImageRaw(mRawImagep->getWidth(), mRawImagep->getHeight(), 3);
stripped_image->copyUnscaled4onto3(mRawImagep);
LLPointer<LLImageFormatted> stripped_png = new LLImagePNG;
// 0.0 = encode time, apparently not used in the encode() function
stripped_png->encode(stripped_image, 0.0f);
mFilenameAndPath = gDirUtilp->getTempFilename() + "." + stripped_png->getExtension();
stripped_png->save(mFilenameAndPath);
mDeleteTempFile = mFilenameAndPath;
}
onBtnOK();
}
// </FS:Zi>
//-----------------------------------------------------------------------------
// LLFloaterImagePreview()
//-----------------------------------------------------------------------------
LLFloaterImagePreview::~LLFloaterImagePreview()
{
// <FS:Zi> detect and strip empty alpha layers from images on upload
if (!mDeleteTempFile.empty())
{
LLFile::remove(mDeleteTempFile);
}
// </FS:Zi>
clearAllPreviewTextures();
mRawImagep = NULL;

View File

@ -39,6 +39,7 @@ class LLVOAvatar;
class LLTextBox;
class LLVertexBuffer;
class LLVolume;
class LLCheckBoxCtrl; // <FS:Zi> detect and strip empty alpha layers from images on upload
class LLImagePreviewSculpted : public LLViewerDynamicTexture
{
@ -129,6 +130,11 @@ protected:
void draw();
bool loadImage(const std::string& filename);
// <FS:Zi> detect and strip empty alpha layers from images on upload
void onBtnUpload();
void emptyAlphaCheckboxCallback();
bool imageEmptyAlphaCallback(const LLSD& notification, const LLSD& response);
// </FS:Zi>
LLPointer<LLImageRaw> mRawImagep;
LLPointer<LLImagePreviewAvatar> mAvatarPreview;
LLPointer<LLImagePreviewSculpted> mSculptedPreview;
@ -139,6 +145,10 @@ protected:
LLPointer<LLViewerTexture> mImagep ;
std::string mImageLoadError;
// <FS:Zi> detect and strip empty alpha layers from images on upload
std::string mDeleteTempFile;
LLCheckBoxCtrl* mEmptyAlphaCheck;
// </FS:Zi>
};
#endif // LL_LLFLOATERIMAGEPREVIEW_H

View File

@ -47,9 +47,9 @@
<text
type="string"
length="1"
bottom_delta="30"
top_pad="8"
follows="top|left"
height="25"
height="16"
width="105"
word_wrap="true"
layout="topleft"
@ -105,6 +105,38 @@
value="Sculpted Prim"
name="SculptedPrim" />
</combo_box>
<panel
follows="left|right"
height="32"
layout="topleft"
left="10"
name="image_alpha_warning"
right="-10"
top_pad="4"
visible="false">
<icon
height="24"
image_name="Popup_Caution"
left="0"
top="0"
width="24"
/>
<check_box
follows="top|left|right"
height="12"
label="Empty alpha channel will be removed"
layout="topleft"
left_pad="8"
name="strip_alpha_check"
right="-1"
top_delta="10"
/>
</panel>
<text
type="string"
length="1"

View File

@ -13944,4 +13944,26 @@ Camera reset might be inhibited by the following objects:
yestext="Okay"/>
</notification>
<!-- <FS:Zi> detect and strip empty alpha layers from images on upload -->
<notification
icon="alertmodal.tga"
label="Image Contains Empty Alpha Channel"
name="ImageEmptyAlphaLayer"
type="alertmodal">
The image you are trying to upload contains an empty, or almost empty alpha channel (transparency information). This is almost always not desired and should be stripped off. Adding an alpha channel to an image will lead to textures flipping on top of each other at different camera angles, and it makes rendering slower. So, unless you really need this texture to have an empty / almost empty alpha channel, consider stripping it out.
<tag>confirm_strip</tag>
<form name="form">
<button
default="true"
index="0"
name="strip"
text="Strip Alpha"/>
<button
index="1"
name="use_as_is"
text="Use As Is"/>
</form>
</notification>
<!-- </FS:Zi> -->
</notifications>

View File

@ -26,11 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
$/LicenseInfo$
"""
#<FS:TS> Remove this line if Python 2 compatibility is not needed.
# Note that, as is, the script works under both versions, so no
# matter what version "/usr/bin/env python" returns, it'll run.
from __future__ import print_function, division
import errno
import glob
import itertools