diff options
Diffstat (limited to 'indra')
456 files changed, 7264 insertions, 6785 deletions
diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 07deaa56b0..5a1fb72eca 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -32,6 +32,10 @@ add_compile_definitions( ADDRESS_SIZE=${ADDRESS_SIZE}) # -- which we do. Without one or the other, we get a ton of Boost warnings. add_compile_definitions(BOOST_BIND_GLOBAL_PLACEHOLDERS) +# Force enable SSE2 instructions in GLM per the manual +# https://github.com/g-truc/glm/blob/master/manual.md#section2_10 +add_compile_definitions(GLM_FORCE_DEFAULT_ALIGNED_GENTYPES=1 GLM_FORCE_SSE2=1) + # Configure crash reporting set(RELEASE_CRASH_REPORTING OFF CACHE BOOL "Enable use of crash reporting in release builds") set(NON_RELEASE_CRASH_REPORTING OFF CACHE BOOL "Enable use of crash reporting in developer builds") diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt index 0f338931c0..c067105f68 100644 --- a/indra/cmake/CMakeLists.txt +++ b/indra/cmake/CMakeLists.txt @@ -63,7 +63,6 @@ set(cmake_SOURCE_FILES VisualLeakDetector.cmake LibVLCPlugin.cmake WebRTC.cmake - XmlRpcEpi.cmake xxHash.cmake ZLIBNG.cmake ) diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake index 30dee3c6c1..3f43ec6729 100644 --- a/indra/cmake/Copy3rdPartyLibs.cmake +++ b/indra/cmake/Copy3rdPartyLibs.cmake @@ -137,9 +137,14 @@ if(WINDOWS) # Check each of them. foreach(release_msvc_file msvcp${MSVC_VER}.dll + msvcp${MSVC_VER}_1.dll + msvcp${MSVC_VER}_2.dll + msvcp${MSVC_VER}_atomic_wait.dll + msvcp${MSVC_VER}_codecvt_ids.dll msvcr${MSVC_VER}.dll vcruntime${MSVC_VER}.dll vcruntime${MSVC_VER}_1.dll + vcruntime${MSVC_VER}_threads.dll ) if(redist_path AND EXISTS "${redist_path}/${release_msvc_file}") MESSAGE(STATUS "Copying redist file from ${redist_path}/${release_msvc_file}") diff --git a/indra/cmake/LLCommon.cmake b/indra/cmake/LLCommon.cmake index 9e3707ff17..dd43ca4916 100644 --- a/indra/cmake/LLCommon.cmake +++ b/indra/cmake/LLCommon.cmake @@ -6,5 +6,3 @@ include(EXPAT) include(Tracy) include(xxHash) include(ZLIBNG) - -include(XmlRpcEpi) diff --git a/indra/cmake/XmlRpcEpi.cmake b/indra/cmake/XmlRpcEpi.cmake deleted file mode 100644 index 6409f9d6e2..0000000000 --- a/indra/cmake/XmlRpcEpi.cmake +++ /dev/null @@ -1,11 +0,0 @@ -# -*- cmake -*- -include(Prebuilt) - -include_guard() -add_library( ll::xmlrpc-epi INTERFACE IMPORTED ) - -use_system_binary( xmlrpc-epi ) - -use_prebuilt_binary(xmlrpc-epi) -target_link_libraries(ll::xmlrpc-epi INTERFACE xmlrpc-epi ) -target_include_directories( ll::xmlrpc-epi SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include) diff --git a/indra/llappearance/llpolymorph.cpp b/indra/llappearance/llpolymorph.cpp index 7ae760d312..8df8a9726f 100644 --- a/indra/llappearance/llpolymorph.cpp +++ b/indra/llappearance/llpolymorph.cpp @@ -557,7 +557,7 @@ void LLPolyMorphTarget::apply( ESex avatar_sex ) } if (mLastWeight != mLastWeight) { - mLastWeight = mCurWeight+.001; + mLastWeight = mCurWeight+.001f; } // perform differential update of morph diff --git a/indra/llappearance/lltexlayer.cpp b/indra/llappearance/lltexlayer.cpp index d376c68c7f..aa48a2d621 100644 --- a/indra/llappearance/lltexlayer.cpp +++ b/indra/llappearance/lltexlayer.cpp @@ -106,7 +106,7 @@ void LLTexLayerSetBuffer::pushProjection() const gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); gGL.loadIdentity(); - gGL.ortho(0.0f, getCompositeWidth(), 0.0f, getCompositeHeight(), -1.0f, 1.0f); + gGL.ortho(0.0f, (F32)getCompositeWidth(), 0.0f, (F32)getCompositeHeight(), -1.0f, 1.0f); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); diff --git a/indra/llcharacter/llkeyframewalkmotion.cpp b/indra/llcharacter/llkeyframewalkmotion.cpp index 605e15f442..f8691b5f59 100644 --- a/indra/llcharacter/llkeyframewalkmotion.cpp +++ b/indra/llcharacter/llkeyframewalkmotion.cpp @@ -383,7 +383,7 @@ bool LLFlyAdjustMotion::onUpdate(F32 time, U8* joint_mask) F32 target_roll = llclamp(ang_vel.mV[VZ], -4.f, 4.f) * roll_factor; // roll is critically damped interpolation between current roll and angular velocity-derived target roll - mRoll = LLSmoothInterpolation::lerp(mRoll, target_roll, U32Milliseconds(100)); + mRoll = LLSmoothInterpolation::lerp(mRoll, target_roll, F32Milliseconds(100.f)); LLQuaternion roll(mRoll, LLVector3(0.f, 0.f, 1.f)); mPelvisState->setRotation(roll); diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index b85bd2573b..6da764f94c 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -90,7 +90,7 @@ bool LLApp::sDisableCrashlogger = false; // Local flag for whether or not to do logging in signal handlers. //static -bool LLApp::sLogInSignal = false; +bool LLApp::sLogInSignal = true; // static // Keeps track of application status @@ -373,6 +373,9 @@ static std::map<LLApp::EAppStatus, const char*> statusDesc // static void LLApp::setStatus(EAppStatus status) { + auto status_it = statusDesc.find(status); + std::string status_text = status_it != statusDesc.end() ? std::string(status_it->second) : std::to_string(status); + LL_INFOS() << "status: " << status_text << LL_ENDL; // notify everyone waiting on sStatus any time its value changes sStatus.set_all(status); @@ -381,18 +384,7 @@ void LLApp::setStatus(EAppStatus status) if (! LLEventPumps::wasDeleted()) { // notify interested parties of status change - LLSD statsd; - auto found = statusDesc.find(status); - if (found != statusDesc.end()) - { - statsd = found->second; - } - else - { - // unknown status? at least report value - statsd = LLSD::Integer(status); - } - LLEventPumps::instance().obtain("LLApp").post(llsd::map("status", statsd)); + LLEventPumps::instance().obtain("LLApp").post(llsd::map("status", status_text)); } } @@ -487,6 +479,33 @@ int LLApp::getPid() #endif } +// static +void LLApp::notifyOutOfDiskSpace() +{ + static const U32Seconds min_interval = U32Seconds(60); + static U32Seconds min_time_to_send = U32Seconds(0); + U32Seconds now = LLTimer::getTotalTime(); + if (now < min_time_to_send) + return; + + min_time_to_send = now + min_interval; + + if (LLApp* app = instance()) + { + app->sendOutOfDiskSpaceNotification(); + } + else + { + LL_WARNS() << "No app instance" << LL_ENDL; + } +} + +// virtual +void LLApp::sendOutOfDiskSpaceNotification() +{ + LL_WARNS() << "Should never be called" << LL_ENDL; // Should be overridden +} + #ifndef LL_WINDOWS void setup_signals() { @@ -654,6 +673,7 @@ void default_unix_signal_handler(int signum, siginfo_t *info, void *) { LL_WARNS() << "Signal handler - Handling fatal signal!" << LL_ENDL; } + if (LLApp::isError()) { // Received second fatal signal while handling first, just die right now @@ -691,11 +711,11 @@ void default_unix_signal_handler(int signum, siginfo_t *info, void *) clear_signals(); raise(signum); return; - } else { - if (LLApp::sLogInSignal) - { - LL_INFOS() << "Signal handler - Unhandled signal " << signum << ", ignoring!" << LL_ENDL; - } + } + + if (LLApp::sLogInSignal) + { + LL_INFOS() << "Signal handler - Unhandled signal " << signum << ", ignoring!" << LL_ENDL; } } } diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h index ad8912ca88..d90ecdf661 100644 --- a/indra/llcommon/llapp.h +++ b/indra/llcommon/llapp.h @@ -202,6 +202,8 @@ public: static bool isExiting(); // Either quitting or error (app is exiting, cleanly or not) static int getPid(); + static void notifyOutOfDiskSpace(); + // // Sleep for specified time while still running // @@ -301,6 +303,8 @@ protected: */ void stepFrame(); + virtual void sendOutOfDiskSpaceNotification(); + private: // Contains the filename of the minidump file after a crash. char mMinidumpPath[MAX_MINDUMP_PATH_LENGTH]; diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index b085f8f5dc..01763c49aa 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -28,6 +28,7 @@ #include "linden_common.h" #include "llapr.h" +#include "llapp.h" #include "llmutex.h" #include "apr_dso.h" @@ -606,7 +607,11 @@ S32 LLAPRFile::writeEx(const std::string& filename, const void *buf, S32 offset, apr_status_t s = apr_file_write(file_handle, buf, &bytes_written); if (s != APR_SUCCESS) { - LL_WARNS("APR") << " Attempting to write filename: " << filename << LL_ENDL; + LL_WARNS("APR") << "Attempting to write filename: " << filename << LL_ENDL; + if (APR_STATUS_IS_ENOSPC(s)) + { + LLApp::notifyOutOfDiskSpace(); + } ll_apr_warn_status(s); bytes_written = 0; } diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h index 369d65407e..c3820ae987 100644 --- a/indra/llcommon/llcoros.h +++ b/indra/llcommon/llcoros.h @@ -31,8 +31,9 @@ #include "llexception.h" #include <boost/fiber/fss.hpp> -#include <boost/fiber/future/promise.hpp> #include <boost/fiber/future/future.hpp> +#include <boost/fiber/future/promise.hpp> +#include <boost/fiber/recursive_mutex.hpp> #include "mutex.h" #include "llsingleton.h" #include "llinstancetracker.h" @@ -307,6 +308,12 @@ public: // use mutex, lock, condition_variable suitable for coroutines using Mutex = boost::fibers::mutex; + using RMutex = boost::fibers::recursive_mutex; + // With C++17, LockType is deprecated: at this point we can directly + // declare 'std::unique_lock lk(some_mutex)' without explicitly stating + // the mutex type. Sadly, making LockType an alias template for + // std::unique_lock doesn't work the same way: Class Template Argument + // Deduction only works for class templates, not alias templates. using LockType = std::unique_lock<Mutex>; using cv_status = boost::fibers::cv_status; using ConditionVariable = boost::fibers::condition_variable; diff --git a/indra/llcommon/lldate.cpp b/indra/llcommon/lldate.cpp index c63c7012d1..b38864688d 100644 --- a/indra/llcommon/lldate.cpp +++ b/indra/llcommon/lldate.cpp @@ -41,20 +41,11 @@ #include "llstring.h" #include "llfasttimer.h" -static const F64 DATE_EPOCH = 0.0; - static const F64 LL_APR_USEC_PER_SEC = 1000000.0; // should be APR_USEC_PER_SEC, but that relies on INT64_C which // isn't defined in glib under our build set up for some reason -LLDate::LLDate() : mSecondsSinceEpoch(DATE_EPOCH) -{} - -LLDate::LLDate(const LLDate& date) : - mSecondsSinceEpoch(date.mSecondsSinceEpoch) -{} - LLDate::LLDate(F64SecondsImplicit seconds_since_epoch) : mSecondsSinceEpoch(seconds_since_epoch.value()) {} diff --git a/indra/llcommon/lldate.h b/indra/llcommon/lldate.h index 81f2dd0d1c..1a69a04232 100644 --- a/indra/llcommon/lldate.h +++ b/indra/llcommon/lldate.h @@ -43,16 +43,13 @@ */ class LL_COMMON_API LLDate { + static constexpr F64 DATE_EPOCH = 0.0; public: /** * @brief Construct a date equal to epoch. */ - LLDate(); - - /** - * @brief Construct a date equal to the source date. - */ - LLDate(const LLDate& date); + constexpr LLDate() : mSecondsSinceEpoch(DATE_EPOCH) + {} /** * @brief Construct a date from a seconds since epoch value. diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index fa24987d1c..6c3b9c9542 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -55,7 +55,6 @@ #include "llsingleton.h" #include "llstl.h" #include "lltimer.h" -#include <boost/fiber/recursive_mutex.hpp> // On Mac, got: // #error "Boost.Stacktrace requires `_Unwind_Backtrace` function. Define @@ -168,7 +167,7 @@ namespace { virtual void recordMessage(LLError::ELevel level, const std::string& message) override { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; if (LLError::getAlwaysFlush()) { mFile << message << std::endl; @@ -235,7 +234,7 @@ namespace { virtual void recordMessage(LLError::ELevel level, const std::string& message) override { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; // The default colors for error, warn and debug are now a bit more pastel // and easier to read on the default (black) terminal background but you // now have the option to set the color of each via an environment variables: @@ -275,7 +274,7 @@ namespace { LL_FORCE_INLINE void writeANSI(const std::string& ansi_code, const std::string& message) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; static std::string s_ansi_bold = createBoldANSI(); // bold text static std::string s_ansi_reset = createResetANSI(); // reset // ANSI color code escape sequence, message, and reset in one fprintf call @@ -312,7 +311,7 @@ namespace { virtual void recordMessage(LLError::ELevel level, const std::string& message) override { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; mBuffer->addLine(message); } @@ -339,7 +338,7 @@ namespace { virtual void recordMessage(LLError::ELevel level, const std::string& message) override { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; debugger_print(message); } }; @@ -507,7 +506,7 @@ namespace LLError::TimeFunction mTimeFunction; Recorders mRecorders; - boost::fibers::recursive_mutex mRecorderMutex; + LLCoros::RMutex mRecorderMutex; int mShouldLogCallCounter; @@ -1216,7 +1215,7 @@ namespace void writeToRecorders(const LLError::CallSite& site, const std::string& message) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; LLError::ELevel level = site.mLevel; SettingsConfigPtr s = Globals::getInstance()->getSettingsConfig(); @@ -1347,7 +1346,7 @@ namespace LLError bool Log::shouldLog(CallSite& site) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; LLMutexTrylock lock(getMutex<LOG_MUTEX>(), 5); if (!lock.isLocked()) { @@ -1392,7 +1391,7 @@ namespace LLError void Log::flush(const std::ostringstream& out, const CallSite& site) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; LLMutexTrylock lock(getMutex<LOG_MUTEX>(),5); if (!lock.isLocked()) { diff --git a/indra/llcommon/llerrorcontrol.h b/indra/llcommon/llerrorcontrol.h index bf5a6df556..2be443ca37 100644 --- a/indra/llcommon/llerrorcontrol.h +++ b/indra/llcommon/llerrorcontrol.h @@ -190,7 +190,7 @@ namespace LLError {} void recordMessage(LLError::ELevel level, const std::string& message) override { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; mCallable(level, message); } private: diff --git a/indra/llcommon/lleventfilter.h b/indra/llcommon/lleventfilter.h index 5c45144fad..d8c7e15a27 100644 --- a/indra/llcommon/lleventfilter.h +++ b/indra/llcommon/lleventfilter.h @@ -429,7 +429,7 @@ public: // path, then stores it to mTarget. virtual bool post(const LLSD& event) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; // Extract the element specified by 'mPath' from 'event'. To perform a // generic type-appropriate store through mTarget, construct an diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp index ddf239f306..9045324bf2 100644 --- a/indra/llcommon/llfile.cpp +++ b/indra/llcommon/llfile.cpp @@ -248,6 +248,24 @@ int LLFile::close(LLFILE * file) return ret_value; } +std::string LLFile::getContents(const std::string& filename) +{ + LLFILE* fp = fopen(filename, "rb"); /* Flawfinder: ignore */ + if (fp) + { + fseek(fp, 0, SEEK_END); + U32 length = ftell(fp); + fseek(fp, 0, SEEK_SET); + + std::vector<char> buffer(length); + size_t nread = fread(buffer.data(), 1, length, fp); + fclose(fp); + + return std::string(buffer.data(), nread); + } + + return LLStringUtil::null; +} int LLFile::remove(const std::string& filename, int supress_error) { diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h index 2564671b13..74110343fc 100644 --- a/indra/llcommon/llfile.h +++ b/indra/llcommon/llfile.h @@ -67,6 +67,8 @@ public: static int close(LLFILE * file); + static std::string getContents(const std::string& filename); + // perms is a permissions mask like 0777 or 0700. In most cases it will // be overridden by the user's umask. It is ignored on Windows. // mkdir() considers "directory already exists" to be SUCCESS. diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index 4b7d60d654..99c803e46f 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -39,6 +39,7 @@ #elif LL_LINUX # include <unistd.h> # include <sys/resource.h> +# include <sys/sysinfo.h> #endif #include "llmemory.h" @@ -50,13 +51,28 @@ //---------------------------------------------------------------------------- //static + +// most important memory metric for texture streaming +// On Windows, this should agree with resource monitor -> performance -> memory -> available +// On OS X, this should be activity monitor -> memory -> (physical memory - memory used) +// NOTE: this number MAY be less than the actual available memory on systems with more than MaxHeapSize64 GB of physical memory (default 16GB) +// In that case, should report min(available, sMaxHeapSizeInKB-sAllocateMemInKB) U32Kilobytes LLMemory::sAvailPhysicalMemInKB(U32_MAX); + +// Installed physical memory U32Kilobytes LLMemory::sMaxPhysicalMemInKB(0); -static LLTrace::SampleStatHandle<F64Megabytes> sAllocatedMem("allocated_mem", "active memory in use by application"); -static LLTrace::SampleStatHandle<F64Megabytes> sVirtualMem("virtual_mem", "virtual memory assigned to application"); + +// Maximimum heap size according to the user's settings (default 16GB) +U32Kilobytes LLMemory::sMaxHeapSizeInKB(U32_MAX); + +// Current memory usage U32Kilobytes LLMemory::sAllocatedMemInKB(0); + U32Kilobytes LLMemory::sAllocatedPageSizeInKB(0); -U32Kilobytes LLMemory::sMaxHeapSizeInKB(U32_MAX); + + +static LLTrace::SampleStatHandle<F64Megabytes> sAllocatedMem("allocated_mem", "active memory in use by application"); +static LLTrace::SampleStatHandle<F64Megabytes> sVirtualMem("virtual_mem", "virtual memory assigned to application"); void ll_assert_aligned_func(uintptr_t ptr,U32 alignment) { @@ -84,7 +100,14 @@ void LLMemory::initMaxHeapSizeGB(F32Gigabytes max_heap_size) //static void LLMemory::updateMemoryInfo() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; + + sMaxPhysicalMemInKB = gSysMemory.getPhysicalMemoryKB(); + + U32Kilobytes avail_mem; + LLMemoryInfo::getAvailableMemoryKB(avail_mem); + sAvailPhysicalMemInKB = avail_mem; + #if LL_WINDOWS PROCESS_MEMORY_COUNTERS counters; @@ -95,23 +118,9 @@ void LLMemory::updateMemoryInfo() } sAllocatedMemInKB = U32Kilobytes::convert(U64Bytes(counters.WorkingSetSize)); - sample(sAllocatedMem, sAllocatedMemInKB); sAllocatedPageSizeInKB = U32Kilobytes::convert(U64Bytes(counters.PagefileUsage)); sample(sVirtualMem, sAllocatedPageSizeInKB); - U32Kilobytes avail_phys, avail_virtual; - LLMemoryInfo::getAvailableMemoryKB(avail_phys, avail_virtual) ; - sMaxPhysicalMemInKB = llmin(avail_phys + sAllocatedMemInKB, sMaxHeapSizeInKB); - - if(sMaxPhysicalMemInKB > sAllocatedMemInKB) - { - sAvailPhysicalMemInKB = sMaxPhysicalMemInKB - sAllocatedMemInKB ; - } - else - { - sAvailPhysicalMemInKB = U32Kilobytes(0); - } - #elif defined(LL_DARWIN) task_vm_info info; mach_msg_type_number_t infoCount = TASK_VM_INFO_COUNT; @@ -136,31 +145,19 @@ void LLMemory::updateMemoryInfo() { LL_WARNS() << "task_info failed" << LL_ENDL; } - - // Total installed and available physical memory are properties of the host, not just our process. - vm_statistics64_data_t vmstat; - mach_msg_type_number_t count = HOST_VM_INFO64_COUNT; - mach_port_t host = mach_host_self(); - vm_size_t page_size; - host_page_size(host, &page_size); - kern_return_t result = host_statistics64(host, HOST_VM_INFO64, reinterpret_cast<host_info_t>(&vmstat), &count); - if (result == KERN_SUCCESS) { - // This is what Chrome reports as 'the "Physical Memory Free" value reported by the Memory Monitor in Instruments.' - // Note though that inactive pages are not included here and not yet free, but could become so under memory pressure. - sAvailPhysicalMemInKB = U32Bytes(vmstat.free_count * page_size); - sMaxPhysicalMemInKB = LLMemoryInfo::getHardwareMemSize(); - } - else - { - LL_WARNS() << "task_info failed" << LL_ENDL; - } - +#elif defined(LL_LINUX) + // Use sysinfo() to get the total physical memory. + struct sysinfo info; + sysinfo(&info); + sAllocatedMemInKB = U32Kilobytes::convert(U64Bytes(LLMemory::getCurrentRSS())); // represents the RAM allocated by this process only (in line with the windows implementation) #else //not valid for other systems for now. + LL_WARNS() << "LLMemory::updateMemoryInfo() not implemented for this platform." << LL_ENDL; sAllocatedMemInKB = U64Bytes(LLMemory::getCurrentRSS()); - sMaxPhysicalMemInKB = U64Bytes(U32_MAX); - sAvailPhysicalMemInKB = U64Bytes(U32_MAX); #endif + sample(sAllocatedMem, sAllocatedMemInKB); + + sAvailPhysicalMemInKB = llmin(sAvailPhysicalMemInKB, sMaxHeapSizeInKB - sAllocatedMemInKB); return ; } @@ -192,16 +189,16 @@ void* LLMemory::tryToAlloc(void* address, U32 size) //static void LLMemory::logMemoryInfo(bool update) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; if(update) { updateMemoryInfo() ; } - LL_INFOS() << "Current allocated physical memory(KB): " << sAllocatedMemInKB << LL_ENDL ; - LL_INFOS() << "Current allocated page size (KB): " << sAllocatedPageSizeInKB << LL_ENDL ; - LL_INFOS() << "Current available physical memory(KB): " << sAvailPhysicalMemInKB << LL_ENDL ; - LL_INFOS() << "Current max usable memory(KB): " << sMaxPhysicalMemInKB << LL_ENDL ; + LL_INFOS() << llformat("Current allocated physical memory: %.2f MB", sAllocatedMemInKB / 1024.0) << LL_ENDL; + LL_INFOS() << llformat("Current allocated page size: %.2f MB", sAllocatedPageSizeInKB / 1024.0) << LL_ENDL; + LL_INFOS() << llformat("Current available physical memory: %.2f MB", sAvailPhysicalMemInKB / 1024.0) << LL_ENDL; + LL_INFOS() << llformat("Current max usable memory: %.2f MB", sMaxPhysicalMemInKB / 1024.0) << LL_ENDL; } //static diff --git a/indra/llcommon/llmutex.cpp b/indra/llcommon/llmutex.cpp index 40c651d9c1..be1ae89a25 100644 --- a/indra/llcommon/llmutex.cpp +++ b/indra/llcommon/llmutex.cpp @@ -100,7 +100,7 @@ void LLMutex::unlock() bool LLMutex::isLocked() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; if (!mMutex.try_lock()) { return true; @@ -124,7 +124,7 @@ LLThread::id_t LLMutex::lockingThread() const bool LLMutex::trylock() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; if (isSelfLocked()) { //redundant lock mCount++; @@ -161,7 +161,7 @@ LLSharedMutex::LLSharedMutex() bool LLSharedMutex::isLocked() const { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; std::lock_guard<std::mutex> lock(mLockMutex); return !mLockingThreads.empty(); @@ -169,7 +169,7 @@ bool LLSharedMutex::isLocked() const bool LLSharedMutex::isThreadLocked() const { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; LLThread::id_t current_thread = LLThread::currentID(); std::lock_guard<std::mutex> lock(mLockMutex); @@ -179,7 +179,7 @@ bool LLSharedMutex::isThreadLocked() const void LLSharedMutex::lockShared() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; LLThread::id_t current_thread = LLThread::currentID(); mLockMutex.lock(); @@ -204,7 +204,7 @@ void LLSharedMutex::lockShared() void LLSharedMutex::lockExclusive() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; LLThread::id_t current_thread = LLThread::currentID(); mLockMutex.lock(); @@ -237,7 +237,7 @@ void LLSharedMutex::lockExclusive() bool LLSharedMutex::trylockShared() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; LLThread::id_t current_thread = LLThread::currentID(); std::lock_guard<std::mutex> lock(mLockMutex); @@ -260,7 +260,7 @@ bool LLSharedMutex::trylockShared() bool LLSharedMutex::trylockExclusive() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; LLThread::id_t current_thread = LLThread::currentID(); std::lock_guard<std::mutex> lock(mLockMutex); @@ -282,7 +282,7 @@ bool LLSharedMutex::trylockExclusive() void LLSharedMutex::unlockShared() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; LLThread::id_t current_thread = LLThread::currentID(); std::lock_guard<std::mutex> lock(mLockMutex); @@ -303,7 +303,7 @@ void LLSharedMutex::unlockShared() void LLSharedMutex::unlockExclusive() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; LLThread::id_t current_thread = LLThread::currentID(); std::lock_guard<std::mutex> lock(mLockMutex); @@ -338,20 +338,20 @@ LLCondition::~LLCondition() void LLCondition::wait() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; std::unique_lock< std::mutex > lock(mMutex); mCond.wait(lock); } void LLCondition::signal() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; mCond.notify_one(); } void LLCondition::broadcast() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; mCond.notify_all(); } @@ -364,7 +364,7 @@ LLMutexTrylock::LLMutexTrylock(LLMutex* mutex) : mMutex(mutex), mLocked(false) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; if (mMutex) mLocked = mMutex->trylock(); } @@ -373,7 +373,7 @@ LLMutexTrylock::LLMutexTrylock(LLMutex* mutex, U32 aTries, U32 delay_ms) : mMutex(mutex), mLocked(false) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; if (!mMutex) return; @@ -388,7 +388,7 @@ LLMutexTrylock::LLMutexTrylock(LLMutex* mutex, U32 aTries, U32 delay_ms) LLMutexTrylock::~LLMutexTrylock() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; if (mMutex && mLocked) mMutex->unlock(); } @@ -400,7 +400,7 @@ LLMutexTrylock::~LLMutexTrylock() // LLScopedLock::LLScopedLock(std::mutex* mutex) : mMutex(mutex) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; if(mutex) { mutex->lock(); @@ -419,7 +419,7 @@ LLScopedLock::~LLScopedLock() void LLScopedLock::unlock() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; if(mLocked) { mMutex->unlock(); diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index f5916f9d58..6edff9fa5e 100644 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -46,8 +46,11 @@ template <class Type> class LLPointer { public: + template<typename Subclass> + friend class LLPointer; + LLPointer() : - mPointer(NULL) + mPointer(nullptr) { } @@ -63,6 +66,12 @@ public: ref(); } + LLPointer(LLPointer<Type>&& ptr) noexcept + { + mPointer = ptr.mPointer; + ptr.mPointer = nullptr; + } + // Support conversion up the type hierarchy. See Item 45 in Effective C++, 3rd Ed. template<typename Subclass> LLPointer(const LLPointer<Subclass>& ptr) : @@ -71,6 +80,13 @@ public: ref(); } + template<typename Subclass> + LLPointer(LLPointer<Subclass>&& ptr) noexcept : + mPointer(ptr.get()) + { + ptr.mPointer = nullptr; + } + ~LLPointer() { unref(); @@ -82,11 +98,11 @@ public: const Type& operator*() const { return *mPointer; } Type& operator*() { return *mPointer; } - operator BOOL() const { return (mPointer != NULL); } - operator bool() const { return (mPointer != NULL); } - bool operator!() const { return (mPointer == NULL); } - bool isNull() const { return (mPointer == NULL); } - bool notNull() const { return (mPointer != NULL); } + operator BOOL() const { return (mPointer != nullptr); } + operator bool() const { return (mPointer != nullptr); } + bool operator!() const { return (mPointer == nullptr); } + bool isNull() const { return (mPointer == nullptr); } + bool notNull() const { return (mPointer != nullptr); } operator Type*() const { return mPointer; } bool operator !=(Type* ptr) const { return (mPointer != ptr); } @@ -107,6 +123,17 @@ public: return *this; } + LLPointer<Type>& operator =(LLPointer<Type>&& ptr) + { + if (mPointer != ptr.mPointer) + { + unref(); + mPointer = ptr.mPointer; + ptr.mPointer = nullptr; + } + return *this; + } + // support assignment up the type hierarchy. See Item 45 in Effective C++, 3rd Ed. template<typename Subclass> LLPointer<Type>& operator =(const LLPointer<Subclass>& ptr) @@ -115,6 +142,18 @@ public: return *this; } + template<typename Subclass> + LLPointer<Type>& operator =(LLPointer<Subclass>&& ptr) + { + if (mPointer != ptr.mPointer) + { + unref(); + mPointer = ptr.mPointer; + ptr.mPointer = nullptr; + } + return *this; + } + // Just exchange the pointers, which will not change the reference counts. static void swap(LLPointer<Type>& a, LLPointer<Type>& b) { @@ -141,9 +180,9 @@ protected: if (mPointer) { Type *temp = mPointer; - mPointer = NULL; + mPointer = nullptr; temp->unref(); - if (mPointer != NULL) + if (mPointer != nullptr) { LL_WARNS() << "Unreference did assignment to non-NULL because of destructor" << LL_ENDL; unref(); @@ -168,9 +207,11 @@ protected: template <class Type> class LLConstPointer { + template<typename Subclass> + friend class LLConstPointer; public: LLConstPointer() : - mPointer(NULL) + mPointer(nullptr) { } @@ -186,6 +227,12 @@ public: ref(); } + LLConstPointer(LLConstPointer<Type>&& ptr) noexcept + { + mPointer = ptr.mPointer; + ptr.mPointer = nullptr; + } + // support conversion up the type hierarchy. See Item 45 in Effective C++, 3rd Ed. template<typename Subclass> LLConstPointer(const LLConstPointer<Subclass>& ptr) : @@ -194,6 +241,13 @@ public: ref(); } + template<typename Subclass> + LLConstPointer(LLConstPointer<Subclass>&& ptr) noexcept : + mPointer(ptr.get()) + { + ptr.mPointer = nullptr; + } + ~LLConstPointer() { unref(); @@ -203,11 +257,11 @@ public: const Type* operator->() const { return mPointer; } const Type& operator*() const { return *mPointer; } - operator BOOL() const { return (mPointer != NULL); } - operator bool() const { return (mPointer != NULL); } - bool operator!() const { return (mPointer == NULL); } - bool isNull() const { return (mPointer == NULL); } - bool notNull() const { return (mPointer != NULL); } + operator BOOL() const { return (mPointer != nullptr); } + operator bool() const { return (mPointer != nullptr); } + bool operator!() const { return (mPointer == nullptr); } + bool isNull() const { return (mPointer == nullptr); } + bool notNull() const { return (mPointer != nullptr); } operator const Type*() const { return mPointer; } bool operator !=(const Type* ptr) const { return (mPointer != ptr); } @@ -239,6 +293,17 @@ public: return *this; } + LLConstPointer<Type>& operator =(LLConstPointer<Type>&& ptr) + { + if (mPointer != ptr.mPointer) + { + unref(); + mPointer = ptr.mPointer; + ptr.mPointer = nullptr; + } + return *this; + } + // support assignment up the type hierarchy. See Item 45 in Effective C++, 3rd Ed. template<typename Subclass> LLConstPointer<Type>& operator =(const LLConstPointer<Subclass>& ptr) @@ -252,6 +317,18 @@ public: return *this; } + template<typename Subclass> + LLConstPointer<Type>& operator =(LLConstPointer<Subclass>&& ptr) + { + if (mPointer != ptr.mPointer) + { + unref(); + mPointer = ptr.mPointer; + ptr.mPointer = nullptr; + } + return *this; + } + // Just exchange the pointers, which will not change the reference counts. static void swap(LLConstPointer<Type>& a, LLConstPointer<Type>& b) { @@ -278,9 +355,9 @@ protected: if (mPointer) { const Type *temp = mPointer; - mPointer = NULL; + mPointer = nullptr; temp->unref(); - if (mPointer != NULL) + if (mPointer != nullptr) { LL_WARNS() << "Unreference did assignment to non-NULL because of destructor" << LL_ENDL; unref(); @@ -313,7 +390,7 @@ public: : LLPointer<Type>(ptr), mStayUnique(false) { - if (ptr.mForceUnique) + if (ptr.mStayUnique) { makeUnique(); } diff --git a/indra/llcommon/llpreprocessor.h b/indra/llcommon/llpreprocessor.h index 0248e8f8b9..a528cc7fd8 100644 --- a/indra/llcommon/llpreprocessor.h +++ b/indra/llcommon/llpreprocessor.h @@ -74,9 +74,6 @@ #ifndef LL_MSVC #define LL_MSVC 1 #endif - #if _MSC_VER < 1400 - #define LL_MSVC7 //Visual C++ 2003 or earlier - #endif #endif // Deal with minor differences on Unixy OSes. @@ -130,8 +127,6 @@ #endif // level 4 warnings that we need to disable: -#pragma warning (disable : 4244) // possible loss of data on conversions -#pragma warning (disable : 4396) // the inline specifier cannot be used when a friend declaration refers to a specialization of a function template #pragma warning (disable : 4251) // member needs to have dll-interface to be used by clients of class #pragma warning (disable : 4275) // non dll-interface class used as base for dll-interface class #endif // LL_MSVC diff --git a/indra/llcommon/llprofiler.h b/indra/llcommon/llprofiler.h index 722d9afca2..732436cc4f 100644 --- a/indra/llcommon/llprofiler.h +++ b/indra/llcommon/llprofiler.h @@ -84,7 +84,7 @@ extern thread_local bool gProfilerEnabled; // #define TRACY_NO_BROADCAST 1 // #define TRACY_ONLY_LOCALHOST 1 #define TRACY_ONLY_IPV4 1 - #include "Tracy.hpp" + #include "tracy/Tracy.hpp" // Enable OpenGL profiling #define LL_PROFILER_ENABLE_TRACY_OPENGL 0 diff --git a/indra/llcommon/llqueuedthread.cpp b/indra/llcommon/llqueuedthread.cpp index 7d77f6f6a9..1c4ac5a7bf 100644 --- a/indra/llcommon/llqueuedthread.cpp +++ b/indra/llcommon/llqueuedthread.cpp @@ -483,7 +483,7 @@ void LLQueuedThread::processRequest(LLQueuedThread::QueuedRequest* req) if (sleep_time.count() > 0) { - ms_sleep(sleep_time.count()); + ms_sleep((U32)sleep_time.count()); } } processRequest(req); diff --git a/indra/llcommon/llrand.cpp b/indra/llcommon/llrand.cpp index 25d75af568..2c51e6f07f 100644 --- a/indra/llcommon/llrand.cpp +++ b/indra/llcommon/llrand.cpp @@ -85,7 +85,7 @@ inline F32 ll_internal_random<F32>() // Per Monty, it's important to clamp using the correct fmodf() rather // than expanding to F64 for fmod() and then truncating back to F32. Prior // to this change, we were getting sporadic ll_frand() == 1.0 results. - F32 rv{ narrow<F32>(gRandomGenerator()) }; + F32 rv{ narrow<F64>(gRandomGenerator()) }; if(!((rv >= 0.0f) && (rv < 1.0f))) return fmodf(rv, 1.0f); return rv; } diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp index 663ceac22b..77fe545c3f 100644 --- a/indra/llcommon/llsd.cpp +++ b/indra/llcommon/llsd.cpp @@ -30,6 +30,7 @@ #include "linden_common.h" #include "llsd.h" +#include "llbase64.h" #include "llerror.h" #include "../llmath/llmath.h" #include "llformat.h" @@ -105,6 +106,9 @@ public: static void reset(Impl*& var, Impl* impl); ///< safely set var to refer to the new impl (possibly shared) + static void move(Impl*& var, Impl*& impl); + ///< safely move impl from one object to another + static Impl& safe( Impl*); static const Impl& safe(const Impl*); ///< since a NULL Impl* is used for undefined, this ensures there is @@ -122,11 +126,17 @@ public: virtual void assign(Impl*& var, LLSD::Boolean); virtual void assign(Impl*& var, LLSD::Integer); virtual void assign(Impl*& var, LLSD::Real); + virtual void assign(Impl*& var, const char*); virtual void assign(Impl*& var, const LLSD::String&); virtual void assign(Impl*& var, const LLSD::UUID&); virtual void assign(Impl*& var, const LLSD::Date&); virtual void assign(Impl*& var, const LLSD::URI&); virtual void assign(Impl*& var, const LLSD::Binary&); + virtual void assign(Impl*& var, LLSD::String&&); + virtual void assign(Impl*& var, LLSD::UUID&&); + virtual void assign(Impl*& var, LLSD::Date&&); + virtual void assign(Impl*& var, LLSD::URI&&); + virtual void assign(Impl*& var, LLSD::Binary&&); ///< If the receiver is the right type and unshared, these are simple // data assignments, othewise the default implementation handless // constructing the proper Impl subclass @@ -142,11 +152,13 @@ public: virtual const String& asStringRef() const { static const std::string empty; return empty; } - virtual bool has(const String&) const { return false; } - virtual LLSD get(const String&) const { return LLSD(); } + virtual String asXMLRPCValue() const { return "<nil/>"; } + + virtual bool has(std::string_view) const { return false; } + virtual LLSD get(std::string_view) const { return LLSD(); } virtual LLSD getKeys() const { return LLSD::emptyArray(); } virtual void erase(const String&) { } - virtual const LLSD& ref(const String&) const{ return undef(); } + virtual const LLSD& ref(std::string_view) const{ return undef(); } virtual size_t size() const { return 0; } virtual LLSD get(size_t) const { return LLSD(); } @@ -182,7 +194,7 @@ namespace LLSDUnnamedNamespace namespace #endif { - template<LLSD::Type T, class Data, class DataRef = Data> + template<LLSD::Type T, class Data, class DataRef = Data, class DataMove = Data> class ImplBase : public LLSD::Impl ///< This class handles most of the work for a subclass of Impl // for a given simple data type. Subclasses of this provide the @@ -195,6 +207,7 @@ namespace public: ImplBase(DataRef value) : mValue(value) { } + ImplBase(DataMove value) : mValue(std::move(value)) { } virtual LLSD::Type type() const { return T; } @@ -209,11 +222,21 @@ namespace mValue = value; } } + virtual void assign(LLSD::Impl*& var, DataMove value) { + if (shared()) + { + Impl::assign(var, std::move(value)); + } + else + { + mValue = std::move(value); + } + } }; - class ImplBoolean - : public ImplBase<LLSD::TypeBoolean, LLSD::Boolean> + class ImplBoolean final + : public ImplBase<LLSD::TypeBoolean, LLSD::Boolean, LLSD::Boolean, LLSD::Boolean&&> { public: ImplBoolean(LLSD::Boolean v) : Base(v) { } @@ -222,6 +245,8 @@ namespace virtual LLSD::Integer asInteger() const { return mValue ? 1 : 0; } virtual LLSD::Real asReal() const { return mValue ? 1 : 0; } virtual LLSD::String asString() const; + + virtual LLSD::String asXMLRPCValue() const { return mValue ? "<boolean>1</boolean>" : "<boolean>0</boolean>"; } }; LLSD::String ImplBoolean::asString() const @@ -233,8 +258,8 @@ namespace { return mValue ? "true" : ""; } - class ImplInteger - : public ImplBase<LLSD::TypeInteger, LLSD::Integer> + class ImplInteger final + : public ImplBase<LLSD::TypeInteger, LLSD::Integer, LLSD::Integer, LLSD::Integer&&> { public: ImplInteger(LLSD::Integer v) : Base(v) { } @@ -243,14 +268,16 @@ namespace virtual LLSD::Integer asInteger() const { return mValue; } virtual LLSD::Real asReal() const { return mValue; } virtual LLSD::String asString() const; + + virtual LLSD::String asXMLRPCValue() const { return "<int>" + std::to_string(mValue) + "</int>"; } }; LLSD::String ImplInteger::asString() const { return llformat("%d", mValue); } - class ImplReal - : public ImplBase<LLSD::TypeReal, LLSD::Real> + class ImplReal final + : public ImplBase<LLSD::TypeReal, LLSD::Real, LLSD::Real, LLSD::Real&&> { public: ImplReal(LLSD::Real v) : Base(v) { } @@ -259,6 +286,8 @@ namespace virtual LLSD::Integer asInteger() const; virtual LLSD::Real asReal() const { return mValue; } virtual LLSD::String asString() const; + + virtual LLSD::String asXMLRPCValue() const { return "<double>" + std::to_string(mValue) + "</double>"; } }; LLSD::Boolean ImplReal::asBoolean() const @@ -271,11 +300,12 @@ namespace { return llformat("%lg", mValue); } - class ImplString - : public ImplBase<LLSD::TypeString, LLSD::String, const LLSD::String&> + class ImplString final + : public ImplBase<LLSD::TypeString, LLSD::String, const LLSD::String&, LLSD::String&&> { public: ImplString(const LLSD::String& v) : Base(v) { } + ImplString(LLSD::String&& v) : Base(std::move(v)) {} virtual LLSD::Boolean asBoolean() const { return !mValue.empty(); } virtual LLSD::Integer asInteger() const; @@ -286,9 +316,24 @@ namespace virtual LLSD::URI asURI() const { return LLURI(mValue); } virtual size_t size() const { return mValue.size(); } virtual const LLSD::String& asStringRef() const { return mValue; } + + virtual LLSD::String asXMLRPCValue() const { return "<string>" + LLStringFn::xml_encode(mValue) + "</string>"; } + + using LLSD::Impl::assign; // Unhiding base class virtuals... + virtual void assign(LLSD::Impl*& var, const char* value) + { + if (shared()) + { + Impl::assign(var, value); + } + else + { + mValue = value; + } + } }; - LLSD::Integer ImplString::asInteger() const + LLSD::Integer ImplString::asInteger() const { // This must treat "1.23" not as an error, but as a number, which is // then truncated down to an integer. Hence, this code doesn't call @@ -298,7 +343,7 @@ namespace return (int)asReal(); } - LLSD::Real ImplString::asReal() const + LLSD::Real ImplString::asReal() const { F64 v = 0.0; std::istringstream i_stream(mValue); @@ -315,25 +360,32 @@ namespace } - class ImplUUID - : public ImplBase<LLSD::TypeUUID, LLSD::UUID, const LLSD::UUID&> + class ImplUUID final + : public ImplBase<LLSD::TypeUUID, LLSD::UUID, const LLSD::UUID&, LLSD::UUID&&> { public: ImplUUID(const LLSD::UUID& v) : Base(v) { } + ImplUUID(LLSD::UUID&& v) : Base(std::move(v)) { } virtual LLSD::String asString() const{ return mValue.asString(); } virtual LLSD::UUID asUUID() const { return mValue; } + + virtual LLSD::String asXMLRPCValue() const { return "<string>" + mValue.asString() + "</string>"; } }; - class ImplDate - : public ImplBase<LLSD::TypeDate, LLSD::Date, const LLSD::Date&> + class ImplDate final + : public ImplBase<LLSD::TypeDate, LLSD::Date, const LLSD::Date&, LLSD::Date&&> { public: ImplDate(const LLSD::Date& v) - : ImplBase<LLSD::TypeDate, LLSD::Date, const LLSD::Date&>(v) + : ImplBase(v) { } + ImplDate(LLSD::Date&& v) + : ImplBase(std::move(v)) + { } + virtual LLSD::Integer asInteger() const { return (LLSD::Integer)(mValue.secondsSinceEpoch()); @@ -344,34 +396,42 @@ namespace } virtual LLSD::String asString() const{ return mValue.asString(); } virtual LLSD::Date asDate() const { return mValue; } + + virtual LLSD::String asXMLRPCValue() const { return "<dateTime.iso8601>" + mValue.toHTTPDateString("%FT%T") + "</dateTime.iso8601>"; } }; - class ImplURI - : public ImplBase<LLSD::TypeURI, LLSD::URI, const LLSD::URI&> + class ImplURI final + : public ImplBase<LLSD::TypeURI, LLSD::URI, const LLSD::URI&, LLSD::URI&&> { public: ImplURI(const LLSD::URI& v) : Base(v) { } + ImplURI(LLSD::URI&& v) : Base(std::move(v)) { } virtual LLSD::String asString() const{ return mValue.asString(); } virtual LLSD::URI asURI() const { return mValue; } + + virtual LLSD::String asXMLRPCValue() const { return "<string>" + LLStringFn::xml_encode(mValue.asString()) + "</string>"; } }; - class ImplBinary - : public ImplBase<LLSD::TypeBinary, LLSD::Binary, const LLSD::Binary&> + class ImplBinary final + : public ImplBase<LLSD::TypeBinary, LLSD::Binary, const LLSD::Binary&, LLSD::Binary&&> { public: ImplBinary(const LLSD::Binary& v) : Base(v) { } + ImplBinary(LLSD::Binary&& v) : Base(std::move(v)) { } virtual const LLSD::Binary& asBinary() const{ return mValue; } + + virtual LLSD::String asXMLRPCValue() const { return "<base64>" + LLBase64::encode(mValue.data(), mValue.size()) + "</base64>"; } }; - class ImplMap : public LLSD::Impl + class ImplMap final : public LLSD::Impl { private: - typedef std::map<LLSD::String, LLSD> DataMap; + typedef std::map<LLSD::String, LLSD, std::less<>> DataMap; DataMap mData; @@ -387,17 +447,30 @@ namespace virtual LLSD::Boolean asBoolean() const { return !mData.empty(); } - virtual bool has(const LLSD::String&) const; + virtual LLSD::String asXMLRPCValue() const + { + std::ostringstream os; + os << "<struct>"; + for (const auto& it : mData) + { + os << "<member><name>" << LLStringFn::xml_encode(it.first) << "</name>" + << it.second.asXMLRPCValue() << "</member>"; + } + os << "</struct>"; + return os.str(); + } + + virtual bool has(std::string_view) const; using LLSD::Impl::get; // Unhiding get(size_t) using LLSD::Impl::erase; // Unhiding erase(size_t) using LLSD::Impl::ref; // Unhiding ref(size_t) - virtual LLSD get(const LLSD::String&) const; + virtual LLSD get(std::string_view) const; virtual LLSD getKeys() const; - void insert(const LLSD::String& k, const LLSD& v); + void insert(std::string_view k, const LLSD& v); virtual void erase(const LLSD::String&); - LLSD& ref(const LLSD::String&); - virtual const LLSD& ref(const LLSD::String&) const; + LLSD& ref(std::string_view); + virtual const LLSD& ref(std::string_view) const; virtual size_t size() const { return mData.size(); } @@ -425,14 +498,14 @@ namespace } } - bool ImplMap::has(const LLSD::String& k) const + bool ImplMap::has(const std::string_view k) const { LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; DataMap::const_iterator i = mData.find(k); return i != mData.end(); } - LLSD ImplMap::get(const LLSD::String& k) const + LLSD ImplMap::get(const std::string_view k) const { LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; DataMap::const_iterator i = mData.find(k); @@ -452,10 +525,10 @@ namespace return keys; } - void ImplMap::insert(const LLSD::String& k, const LLSD& v) + void ImplMap::insert(std::string_view k, const LLSD& v) { LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; - mData.insert(DataMap::value_type(k, v)); + mData.emplace(k, v); } void ImplMap::erase(const LLSD::String& k) @@ -464,15 +537,21 @@ namespace mData.erase(k); } - LLSD& ImplMap::ref(const LLSD::String& k) + LLSD& ImplMap::ref(std::string_view k) { - return mData[k]; + DataMap::iterator i = mData.lower_bound(k); + if (i == mData.end() || mData.key_comp()(k, i->first)) + { + return mData.emplace_hint(i, std::make_pair(k, LLSD()))->second; + } + + return i->second; } - const LLSD& ImplMap::ref(const LLSD::String& k) const + const LLSD& ImplMap::ref(std::string_view k) const { DataMap::const_iterator i = mData.lower_bound(k); - if (i == mData.end() || mData.key_comp()(k, i->first)) + if (i == mData.end() || mData.key_comp()(k, i->first)) { return undef(); } @@ -500,7 +579,7 @@ namespace { //std::cout << " " << (*iter).first << ": " << (*iter).second << std::endl; Impl::calcStats((*iter).second, type_counts, share_counts); - iter++; + ++iter; } // Add in the values for this map @@ -511,7 +590,7 @@ namespace class ImplArray : public LLSD::Impl { private: - typedef std::vector<LLSD> DataVector; + typedef std::vector<LLSD> DataVector; DataVector mData; @@ -527,6 +606,18 @@ namespace virtual LLSD::Boolean asBoolean() const { return !mData.empty(); } + virtual LLSD::String asXMLRPCValue() const + { + std::ostringstream os; + os << "<array><data>"; + for (const auto& it : mData) + { + os << it.asXMLRPCValue(); + } + os << "</data></array>"; + return os.str(); + } + using LLSD::Impl::get; // Unhiding get(LLSD::String) using LLSD::Impl::erase; // Unhiding erase(LLSD::String) using LLSD::Impl::ref; // Unhiding ref(LLSD::String) @@ -647,7 +738,7 @@ namespace while (iter != endArray()) { // Add values for all items held in the array Impl::calcStats((*iter), type_counts, share_counts); - iter++; + ++iter; } // Add in the values for this array @@ -685,6 +776,16 @@ void LLSD::Impl::reset(Impl*& var, Impl* impl) var = impl; } +void LLSD::Impl::move(Impl*& var, Impl*& impl) +{ + if (var && var->mUseCount != STATIC_USAGE_COUNT && --var->mUseCount == 0) + { + delete var; // destroy var if usage falls to 0 and not static + } + var = impl; // Steal impl to var without incrementing use since this is a move + impl = nullptr; // null out old-impl pointer +} + LLSD::Impl& LLSD::Impl::safe(Impl* impl) { static Impl theUndefined(STATIC_USAGE_COUNT); @@ -738,6 +839,11 @@ void LLSD::Impl::assign(Impl*& var, LLSD::Real v) reset(var, new ImplReal(v)); } +void LLSD::Impl::assign(Impl*& var, const char* v) +{ + reset(var, new ImplString(v)); +} + void LLSD::Impl::assign(Impl*& var, const LLSD::String& v) { reset(var, new ImplString(v)); @@ -763,6 +869,31 @@ void LLSD::Impl::assign(Impl*& var, const LLSD::Binary& v) reset(var, new ImplBinary(v)); } +void LLSD::Impl::assign(Impl*& var, LLSD::String&& v) +{ + reset(var, new ImplString(std::move(v))); +} + +void LLSD::Impl::assign(Impl*& var, LLSD::UUID&& v) +{ + reset(var, new ImplUUID(std::move(v))); +} + +void LLSD::Impl::assign(Impl*& var, LLSD::Date&& v) +{ + reset(var, new ImplDate(std::move(v))); +} + +void LLSD::Impl::assign(Impl*& var, LLSD::URI&& v) +{ + reset(var, new ImplURI(std::move(v))); +} + +void LLSD::Impl::assign(Impl*& var, LLSD::Binary&& v) +{ + reset(var, new ImplBinary(std::move(v))); +} + const LLSD& LLSD::Impl::undef() { @@ -835,6 +966,9 @@ LLSD::~LLSD() { FREE_LLSD_OBJECT; Impl::reset(impl, 0) LLSD::LLSD(const LLSD& other) : impl(0) { ALLOC_LLSD_OBJECT; assign(other); } void LLSD::assign(const LLSD& other) { Impl::assign(impl, other.impl); } +LLSD::LLSD(LLSD&& other) noexcept : impl(nullptr) { ALLOC_LLSD_OBJECT; Impl::move(impl, other.impl); } +void LLSD::assign(LLSD&& other) { Impl::move(impl, other.impl); } +LLSD& LLSD::operator=(LLSD&& other) noexcept { Impl::move(impl, other.impl); return *this; } void LLSD::clear() { Impl::assignUndefined(impl); } @@ -849,6 +983,11 @@ LLSD::LLSD(const String& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } LLSD::LLSD(const Date& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } LLSD::LLSD(const URI& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } LLSD::LLSD(const Binary& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } +LLSD::LLSD(UUID&& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(std::move(v)); } +LLSD::LLSD(String&& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(std::move(v)); } +LLSD::LLSD(Date&& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(std::move(v)); } +LLSD::LLSD(URI&& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(std::move(v)); } +LLSD::LLSD(Binary&& v) : impl(0) { ALLOC_LLSD_OBJECT; assign(std::move(v)); } // Scalar Assignment void LLSD::assign(Boolean v) { safe(impl).assign(impl, v); } @@ -859,6 +998,11 @@ void LLSD::assign(const UUID& v) { safe(impl).assign(impl, v); } void LLSD::assign(const Date& v) { safe(impl).assign(impl, v); } void LLSD::assign(const URI& v) { safe(impl).assign(impl, v); } void LLSD::assign(const Binary& v) { safe(impl).assign(impl, v); } +void LLSD::assign(String&& v) { safe(impl).assign(impl, std::move(v)); } +void LLSD::assign(UUID&& v) { safe(impl).assign(impl, std::move(v)); } +void LLSD::assign(Date&& v) { safe(impl).assign(impl, std::move(v)); } +void LLSD::assign(URI&& v) { safe(impl).assign(impl, std::move(v)); } +void LLSD::assign(Binary&& v) { safe(impl).assign(impl, std::move(v)); } // Scalar Accessors LLSD::Boolean LLSD::asBoolean() const { return safe(impl).asBoolean(); } @@ -872,11 +1016,13 @@ const LLSD::Binary& LLSD::asBinary() const { return safe(impl).asBinary(); } const LLSD::String& LLSD::asStringRef() const { return safe(impl).asStringRef(); } +LLSD::String LLSD::asXMLRPCValue() const { return "<value>" + safe(impl).asXMLRPCValue() + "</value>"; } + // const char * helpers LLSD::LLSD(const char* v) : impl(0) { ALLOC_LLSD_OBJECT; assign(v); } void LLSD::assign(const char* v) { - if(v) assign(std::string(v)); + if(v) safe(impl).assign(impl, v); else assign(std::string()); } @@ -888,24 +1034,24 @@ LLSD LLSD::emptyMap() return v; } -bool LLSD::has(const String& k) const { return safe(impl).has(k); } -LLSD LLSD::get(const String& k) const { return safe(impl).get(k); } +bool LLSD::has(const std::string_view k) const { return safe(impl).has(k); } +LLSD LLSD::get(const std::string_view k) const { return safe(impl).get(k); } LLSD LLSD::getKeys() const { return safe(impl).getKeys(); } -void LLSD::insert(const String& k, const LLSD& v) { makeMap(impl).insert(k, v); } +void LLSD::insert(std::string_view k, const LLSD& v) { makeMap(impl).insert(k, v); } -LLSD& LLSD::with(const String& k, const LLSD& v) +LLSD& LLSD::with(std::string_view k, const LLSD& v) { makeMap(impl).insert(k, v); return *this; } void LLSD::erase(const String& k) { makeMap(impl).erase(k); } -LLSD& LLSD::operator[](const String& k) +LLSD& LLSD::operator[](const std::string_view k) { LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; return makeMap(impl).ref(k); } -const LLSD& LLSD::operator[](const String& k) const +const LLSD& LLSD::operator[](const std::string_view k) const { LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; return safe(impl).ref(k); diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index a5e735b561..d2b3548831 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -161,6 +161,13 @@ public: //@} + /** @name Movable */ + //@{ + LLSD(LLSD&& other) noexcept; + void assign(LLSD&& other); + LLSD& operator=(LLSD&& other) noexcept; + //@} + void clear(); ///< resets to Undefined @@ -188,6 +195,11 @@ public: LLSD(const Date&); LLSD(const URI&); LLSD(const Binary&); + LLSD(String&&); + LLSD(UUID&&); + LLSD(Date&&); + LLSD(URI&&); + LLSD(Binary&&); //@} /** @name Convenience Constructors */ @@ -215,6 +227,11 @@ public: void assign(const Date&); void assign(const URI&); void assign(const Binary&); + void assign(String&&); + void assign(UUID&&); + void assign(Date&&); + void assign(URI&&); + void assign(Binary&&); LLSD& operator=(Boolean v) { assign(v); return *this; } LLSD& operator=(Integer v) { assign(v); return *this; } @@ -224,6 +241,11 @@ public: LLSD& operator=(const Date& v) { assign(v); return *this; } LLSD& operator=(const URI& v) { assign(v); return *this; } LLSD& operator=(const Binary& v) { assign(v); return *this; } + LLSD& operator=(String&& v) { assign(std::move(v)); return *this; } + LLSD& operator=(UUID&& v) { assign(std::move(v)); return *this; } + LLSD& operator=(Date&& v) { assign(std::move(v)); return *this; } + LLSD& operator=(URI&& v) { assign(std::move(v)); return *this; } + LLSD& operator=(Binary&& v) { assign(std::move(v)); return *this; } //@} /** @@ -259,10 +281,14 @@ public: UUID asUUID() const; Date asDate() const; URI asURI() const; - const Binary& asBinary() const; + const Binary& asBinary() const; // asStringRef on any non-string type will return a ref to an empty string. - const String& asStringRef() const; + const String& asStringRef() const; + + // Return "<value><((type))>((scalar value or recursive calls))</((type))></value>" + // See http://xmlrpc.com/spec.md + String asXMLRPCValue() const; operator Boolean() const { return asBoolean(); } operator Integer() const { return asInteger(); } @@ -275,7 +301,7 @@ public: // This is needed because most platforms do not automatically // convert the boolean negation as a bool in an if statement. - bool operator!() const {return !asBoolean();} + bool operator!() const { return !asBoolean(); } //@} /** @name Character Pointer Helpers @@ -292,24 +318,22 @@ public: //@{ static LLSD emptyMap(); - bool has(const String&) const; - LLSD get(const String&) const; + bool has(const std::string_view) const; + LLSD get(const std::string_view) const; LLSD getKeys() const; // Return an LLSD array with keys as strings - void insert(const String&, const LLSD&); + void insert(std::string_view, const LLSD&); void erase(const String&); - LLSD& with(const String&, const LLSD&); + LLSD& with(std::string_view, const LLSD&); - LLSD& operator[](const String&); + LLSD& operator[](const std::string_view); LLSD& operator[](const char* c) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; - return (*this)[String(c)]; + return c ? (*this)[std::string_view(c)] : *this; } - const LLSD& operator[](const String&) const; + const LLSD& operator[](const std::string_view) const; const LLSD& operator[](const char* c) const { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; - return (*this)[String(c)]; + return c ? (*this)[std::string_view(c)] : *this; } //@} diff --git a/indra/llcommon/llsdparam.cpp b/indra/llcommon/llsdparam.cpp index b981be4d0a..3ae153a67c 100644 --- a/indra/llcommon/llsdparam.cpp +++ b/indra/llcommon/llsdparam.cpp @@ -149,7 +149,7 @@ bool LLParamSDParser::readF32(Parser& parser, void* val_ptr) { LLParamSDParser& self = static_cast<LLParamSDParser&>(parser); - *((F32*)val_ptr) = self.mCurReadSD->asReal(); + *((F32*)val_ptr) = (F32)self.mCurReadSD->asReal(); return true; } diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp index 15002580c9..37af366a20 100644 --- a/indra/llcommon/llsdserialize.cpp +++ b/indra/llcommon/llsdserialize.cpp @@ -231,7 +231,7 @@ bool LLSDSerialize::deserialize(LLSD& sd, std::istream& str, llssize max_bytes) } // Since we've already read 'inbuf' bytes into 'hdr_buf', prepend that // data to whatever remains in 'str'. - LLMemoryStreamBuf already(reinterpret_cast<const U8*>(hdr_buf), inbuf); + LLMemoryStreamBuf already(reinterpret_cast<const U8*>(hdr_buf), (S32)inbuf); cat_streambuf prebuff(&already, str.rdbuf()); std::istream prepend(&prebuff); #if 1 @@ -475,7 +475,7 @@ LLSDNotationParser::~LLSDNotationParser() // virtual S32 LLSDNotationParser::doParse(std::istream& istr, LLSD& data, S32 max_depth) const { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD + LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; // map: { string:object, string:object } // array: [ object, object, object ] // undef: ! @@ -566,7 +566,7 @@ S32 LLSDNotationParser::doParse(std::istream& istr, LLSD& data, S32 max_depth) c data, NOTATION_FALSE_SERIAL, false); - if(PARSE_FAILURE == cnt) parse_count = cnt; + if(PARSE_FAILURE == cnt) parse_count = (S32)cnt; else account(cnt); } else @@ -592,7 +592,7 @@ S32 LLSDNotationParser::doParse(std::istream& istr, LLSD& data, S32 max_depth) c if(isalpha(c)) { auto cnt = deserialize_boolean(istr,data,NOTATION_TRUE_SERIAL,true); - if(PARSE_FAILURE == cnt) parse_count = cnt; + if(PARSE_FAILURE == cnt) parse_count = (S32)cnt; else account(cnt); } else @@ -735,7 +735,7 @@ S32 LLSDNotationParser::doParse(std::istream& istr, LLSD& data, S32 max_depth) c S32 LLSDNotationParser::parseMap(std::istream& istr, LLSD& map, S32 max_depth) const { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD + LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; // map: { string:object, string:object } map = LLSD::emptyMap(); S32 parse_count = 0; @@ -796,7 +796,7 @@ S32 LLSDNotationParser::parseMap(std::istream& istr, LLSD& map, S32 max_depth) c S32 LLSDNotationParser::parseArray(std::istream& istr, LLSD& array, S32 max_depth) const { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD + LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; // array: [ object, object, object ] array = LLSD::emptyArray(); S32 parse_count = 0; @@ -836,7 +836,7 @@ S32 LLSDNotationParser::parseArray(std::istream& istr, LLSD& array, S32 max_dept bool LLSDNotationParser::parseString(std::istream& istr, LLSD& data) const { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD + LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; std::string value; auto count = deserialize_string(istr, value, mMaxBytesLeft); if(PARSE_FAILURE == count) return false; @@ -847,7 +847,7 @@ bool LLSDNotationParser::parseString(std::istream& istr, LLSD& data) const bool LLSDNotationParser::parseBinary(std::istream& istr, LLSD& data) const { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD + LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; // binary: b##"ff3120ab1" // or: b(len)"..." @@ -950,7 +950,7 @@ LLSDBinaryParser::~LLSDBinaryParser() // virtual S32 LLSDBinaryParser::doParse(std::istream& istr, LLSD& data, S32 max_depth) const { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD + LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; /** * Undefined: '!'<br> * Boolean: '1' for true '0' for false<br> diff --git a/indra/llcommon/llsdserialize_xml.cpp b/indra/llcommon/llsdserialize_xml.cpp index 88cbb3b984..6396caf8d5 100644 --- a/indra/llcommon/llsdserialize_xml.cpp +++ b/indra/llcommon/llsdserialize_xml.cpp @@ -554,7 +554,7 @@ void LLSDXMLParser::Impl::parsePart(const char* buf, llssize len) if ( buf != NULL && len > 0 ) { - XML_Status status = XML_Parse(mParser, buf, len, false); + XML_Status status = XML_Parse(mParser, buf, (int)len, 0); if (status == XML_STATUS_ERROR) { LL_INFOS() << "Unexpected XML parsing error at start" << LL_ENDL; @@ -930,7 +930,7 @@ void LLSDXMLParser::parsePart(const char *buf, llssize len) // virtual S32 LLSDXMLParser::doParse(std::istream& input, LLSD& data, S32 max_depth) const { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD + LL_PROFILE_ZONE_SCOPED_CATEGORY_LLSD; #ifdef XML_PARSER_PERFORMANCE_TESTS XML_Timer timer( &parseTime ); diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp index dd3a58c26d..12f67208c1 100644 --- a/indra/llcommon/llsdutil.cpp +++ b/indra/llcommon/llsdutil.cpp @@ -51,7 +51,7 @@ // U32 LLSD ll_sd_from_U32(const U32 val) { - std::vector<U8> v; + LLSD::Binary v; U32 net_order = htonl(val); v.resize(4); @@ -63,7 +63,7 @@ LLSD ll_sd_from_U32(const U32 val) U32 ll_U32_from_sd(const LLSD& sd) { U32 ret; - std::vector<U8> v = sd.asBinary(); + const LLSD::Binary& v = sd.asBinary(); if (v.size() < 4) { return 0; @@ -76,7 +76,7 @@ U32 ll_U32_from_sd(const LLSD& sd) //U64 LLSD ll_sd_from_U64(const U64 val) { - std::vector<U8> v; + LLSD::Binary v; U32 high, low; high = (U32)(val >> 32); @@ -94,7 +94,7 @@ LLSD ll_sd_from_U64(const U64 val) U64 ll_U64_from_sd(const LLSD& sd) { U32 high, low; - std::vector<U8> v = sd.asBinary(); + const LLSD::Binary& v = sd.asBinary(); if (v.size() < 8) { @@ -112,7 +112,7 @@ U64 ll_U64_from_sd(const LLSD& sd) // IP Address (stored in net order in a U32, so don't need swizzling) LLSD ll_sd_from_ipaddr(const U32 val) { - std::vector<U8> v; + LLSD::Binary v; v.resize(4); memcpy(&(v[0]), &val, 4); /* Flawfinder: ignore */ @@ -123,7 +123,7 @@ LLSD ll_sd_from_ipaddr(const U32 val) U32 ll_ipaddr_from_sd(const LLSD& sd) { U32 ret; - std::vector<U8> v = sd.asBinary(); + const LLSD::Binary& v = sd.asBinary(); if (v.size() < 4) { return 0; @@ -135,17 +135,17 @@ U32 ll_ipaddr_from_sd(const LLSD& sd) // Converts an LLSD binary to an LLSD string LLSD ll_string_from_binary(const LLSD& sd) { - std::vector<U8> value = sd.asBinary(); + const LLSD::Binary& value = sd.asBinary(); std::string str; str.resize(value.size()); - memcpy(&str[0], &value[0], value.size()); + memcpy(&str[0], value.data(), value.size()); return str; } // Converts an LLSD string to an LLSD binary LLSD ll_binary_from_string(const LLSD& sd) { - std::vector<U8> binary_value; + LLSD::Binary binary_value; std::string string_value = sd.asString(); for (const U8 c : string_value) @@ -214,7 +214,7 @@ bool compare_llsd_with_template( const LLSD& template_llsd, LLSD& resultant_llsd) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; if ( llsd_to_test.isUndefined() && @@ -337,7 +337,7 @@ bool filter_llsd_with_template( const LLSD & template_llsd, LLSD & resultant_llsd) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; if (llsd_to_test.isUndefined() && template_llsd.isDefined()) { @@ -533,7 +533,7 @@ class TypeLookup public: TypeLookup() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; for (const Data *di(boost::begin(typedata)), *dend(boost::end(typedata)); di != dend; ++di) { @@ -543,7 +543,7 @@ public: std::string lookup(LLSD::Type type) const { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; MapType::const_iterator found = mMap.find(type); if (found != mMap.end()) @@ -595,7 +595,7 @@ static std::string match_types(LLSD::Type expect, // prototype.type() LLSD::Type actual, // type we're checking const std::string& pfx) // as for llsd_matches { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; // Trivial case: if the actual type is exactly what we expect, we're good. if (actual == expect) @@ -634,7 +634,7 @@ static std::string match_types(LLSD::Type expect, // prototype.type() // see docstring in .h file std::string llsd_matches(const LLSD& prototype, const LLSD& data, const std::string& pfx) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; // An undefined prototype means that any data is valid. // An undefined slot in an array or map prototype means that any data @@ -768,7 +768,7 @@ std::string llsd_matches(const LLSD& prototype, const LLSD& data, const std::str bool llsd_equals(const LLSD& lhs, const LLSD& rhs, int bits) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; // We're comparing strict equality of LLSD representation rather than // performing any conversions. So if the types aren't equal, the LLSD @@ -878,7 +878,7 @@ namespace llsd LLSD& drill_ref(LLSD& blob, const LLSD& rawPath) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; // Treat rawPath uniformly as an array. If it's not already an array, // store it as the only entry in one. (But let's say Undefined means an @@ -905,7 +905,7 @@ LLSD& drill_ref(LLSD& blob, const LLSD& rawPath) // path entry that's bad. for (LLSD::Integer i = 0; i < path.size(); ++i) { - LL_PROFILE_ZONE_NUM( i ) + LL_PROFILE_ZONE_NUM(i); const LLSD& key{path[i]}; if (key.isString()) @@ -935,7 +935,7 @@ LLSD& drill_ref(LLSD& blob, const LLSD& rawPath) LLSD drill(const LLSD& blob, const LLSD& path) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; // drill_ref() does exactly what we want. Temporarily cast away // const-ness and use that. @@ -949,7 +949,7 @@ LLSD drill(const LLSD& blob, const LLSD& path) // filter may be include to exclude/include keys in a map. LLSD llsd_clone(LLSD value, LLSD filter) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; LLSD clone; bool has_filter(filter.isMap()); @@ -990,8 +990,7 @@ LLSD llsd_clone(LLSD value, LLSD filter) case LLSD::TypeBinary: { - LLSD::Binary bin(value.asBinary().begin(), value.asBinary().end()); - clone = LLSD::Binary(bin); + clone = LLSD::Binary(value.asBinary().begin(), value.asBinary().end()); break; } default: diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 7c6be25309..316831cd74 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -37,7 +37,8 @@ #include "llmainthreadtask.h" #ifdef LL_WINDOWS -#pragma warning( disable : 4506 ) // no definition for inline function +#pragma warning(push) +#pragma warning(disable : 4506) // no definition for inline function #endif class LLSingletonBase: private boost::noncopyable @@ -861,4 +862,8 @@ private: template <class T> T* LLSimpleton<T>::sInstance{ nullptr }; +#ifdef LL_WINDOWS +#pragma warning(pop) +#endif + #endif diff --git a/indra/llcommon/llstl.h b/indra/llcommon/llstl.h index 1b52d94258..7d41c42ba7 100644 --- a/indra/llcommon/llstl.h +++ b/indra/llcommon/llstl.h @@ -226,11 +226,11 @@ void delete_and_clear_array(T*& ptr) // foo[2] = "hello"; // const char* bar = get_ptr_in_map(foo, 2); // bar -> "hello" // const char* baz = get_ptr_in_map(foo, 3); // baz == NULL -template <typename K, typename T> -inline T* get_ptr_in_map(const std::map<K,T*>& inmap, const K& key) +template <typename T> +inline typename T::mapped_type get_ptr_in_map(const T& inmap, typename T::key_type const& key) { // Typedef here avoids warnings because of new c++ naming rules. - typedef typename std::map<K,T*>::const_iterator map_iter; + typedef typename T::const_iterator map_iter; map_iter iter = inmap.find(key); if(iter == inmap.end()) { diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index 514d73b24b..c57f8b1e96 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -250,7 +250,7 @@ LLWString utf16str_to_wstring(const U16* utf16str, size_t len) while (i < len) { llwchar cur_char; - i += utf16chars_to_wchar(chars16+i, &cur_char); + i += (S32)utf16chars_to_wchar(chars16+i, &cur_char); wout += cur_char; } return wout; @@ -1208,6 +1208,75 @@ namespace LLStringFn return output; } + using literals_t = std::map<char, std::string>; + static const literals_t xml_elem_literals = + { + { '<', "<" }, + { '>', ">" }, + { '&', "&" } + }; + static const literals_t xml_attr_literals = + { + { '"', """ }, + { '\'', "'" } + }; + + static void literals_encode(std::string& text, const literals_t& literals) + { + for (const std::pair<char, std::string> it : literals) + { + std::string::size_type pos = 0; + while ((pos = text.find(it.first, pos)) != std::string::npos) + { + text.replace(pos, 1, it.second); + pos += it.second.size(); + } + } + } + + static void literals_decode(std::string& text, const literals_t& literals) + { + for (const std::pair<char, std::string> it : literals) + { + std::string::size_type pos = 0; + while ((pos = text.find(it.second, pos)) != std::string::npos) + { + text[pos++] = it.first; + text.erase(pos, it.second.size() - 1); + } + } + } + + /** + * @brief Replace all characters that are not allowed in XML 1.0 + * with corresponding literals: [ < > & ] => [ < > & ] + */ + std::string xml_encode(const std::string& input, bool for_attribute) + { + std::string result(input); + literals_encode(result, xml_elem_literals); + if (for_attribute) + { + literals_encode(result, xml_attr_literals); + } + return result; + } + + /** + * @brief Replace some of XML literals that are defined in XML 1.0 + * with corresponding characters: [ < > & ] => [ < > & ] + */ + std::string xml_decode(const std::string& input, bool for_attribute) + { + std::string result(input); + literals_decode(result, xml_elem_literals); + if (for_attribute) + { + literals_decode(result, xml_attr_literals); + } + return result; + } + /** * @brief Replace all control characters (c < 0x20) with replacement in * string. diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index 123f4184b5..b69a068830 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -890,6 +890,20 @@ namespace LLStringFn /** + * @brief Replace all characters that are not allowed in XML 1.0 + * with corresponding literals: [ < > & ] => [ < > & ] + */ + LL_COMMON_API std::string xml_encode(const std::string& input, bool for_attribute = false); + + + /** + * @brief Replace some of XML literals that are defined in XML 1.0 + * with corresponding characters: [ < > & ] => [ < > & ] + */ + LL_COMMON_API std::string xml_decode(const std::string& input, bool for_attribute = false); + + + /** * @brief Replace all control characters (0 <= c < 0x20) with replacement in * string. This is safe for utf-8 * diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index cfb05873df..79625ad9f8 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -74,6 +74,8 @@ using namespace llsd; # include <mach/mach_host.h> # include <mach/task.h> # include <mach/task_info.h> +# include <sys/types.h> +# include <mach/mach_init.h> #elif LL_LINUX # include <errno.h> # include <sys/utsname.h> @@ -85,6 +87,7 @@ const char MEMINFO_FILE[] = "/proc/meminfo"; #endif LLCPUInfo gSysCPU; +LLMemoryInfo gSysMemory; // Don't log memory info any more often than this. It also serves as our // framerate sample size. @@ -797,33 +800,32 @@ U32Kilobytes LLMemoryInfo::getPhysicalMemoryKB() const } //static -void LLMemoryInfo::getAvailableMemoryKB(U32Kilobytes& avail_physical_mem_kb, U32Kilobytes& avail_virtual_mem_kb) +void LLMemoryInfo::getAvailableMemoryKB(U32Kilobytes& avail_mem_kb) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_MEMORY; #if LL_WINDOWS // Sigh, this shouldn't be a static method, then we wouldn't have to // reload this data separately from refresh() LLSD statsMap(loadStatsMap()); - avail_physical_mem_kb = (U32Kilobytes)statsMap["Avail Physical KB"].asInteger(); - avail_virtual_mem_kb = (U32Kilobytes)statsMap["Avail Virtual KB"].asInteger(); + avail_mem_kb = (U32Kilobytes)statsMap["Avail Physical KB"].asInteger(); #elif LL_DARWIN - // mStatsMap is derived from vm_stat, look for (e.g.) "kb free": - // $ vm_stat - // Mach Virtual Memory Statistics: (page size of 4096 bytes) - // Pages free: 462078. - // Pages active: 142010. - // Pages inactive: 220007. - // Pages wired down: 159552. - // "Translation faults": 220825184. - // Pages copy-on-write: 2104153. - // Pages zero filled: 167034876. - // Pages reactivated: 65153. - // Pageins: 2097212. - // Pageouts: 41759. - // Object cache: 841598 hits of 7629869 lookups (11% hit rate) - avail_physical_mem_kb = (U32Kilobytes)-1 ; - avail_virtual_mem_kb = (U32Kilobytes)-1 ; + // use host_statistics64 to get memory info + vm_statistics64_data_t vmstat; + mach_msg_type_number_t count = HOST_VM_INFO64_COUNT; + mach_port_t host = mach_host_self(); + vm_size_t page_size; + host_page_size(host, &page_size); + kern_return_t result = host_statistics64(host, HOST_VM_INFO64, reinterpret_cast<host_info_t>(&vmstat), &count); + if (result == KERN_SUCCESS) + { + avail_mem_kb = U64Bytes((vmstat.free_count + vmstat.inactive_count) * page_size); + } + else + { + avail_mem_kb = (U32Kilobytes)-1; + } #elif LL_LINUX // mStatsMap is derived from MEMINFO_FILE: @@ -874,15 +876,14 @@ void LLMemoryInfo::getAvailableMemoryKB(U32Kilobytes& avail_physical_mem_kb, U32 // DirectMap4k: 434168 kB // DirectMap2M: 477184 kB // (could also run 'free', but easier to read a file than run a program) - avail_physical_mem_kb = (U32Kilobytes)-1 ; - avail_virtual_mem_kb = (U32Kilobytes)-1 ; + LLSD statsMap(loadStatsMap()); + avail_mem_kb = (U32Kilobytes)statsMap["MemFree"].asInteger(); #else //do not know how to collect available memory info for other systems. //leave it blank here for now. - avail_physical_mem_kb = (U32Kilobytes)-1 ; - avail_virtual_mem_kb = (U32Kilobytes)-1 ; + avail_mem_kb = (U32Kilobytes)-1 ; #endif } @@ -928,7 +929,7 @@ LLSD LLMemoryInfo::getStatsMap() const LLMemoryInfo& LLMemoryInfo::refresh() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; mStatsMap = loadStatsMap(); LL_DEBUGS("LLMemoryInfo") << "Populated mStatsMap:\n"; @@ -977,7 +978,7 @@ LLSD LLMemoryInfo::loadStatsMap() // specifically accepts PROCESS_MEMORY_COUNTERS*, and since this is a // classic-C API, PROCESS_MEMORY_COUNTERS_EX isn't a subclass. Cast the // pointer. - GetProcessMemoryInfo(GetCurrentProcess(), PPROCESS_MEMORY_COUNTERS(&pmem), sizeof(pmem)); + GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*) &pmem, sizeof(pmem)); stats.add("Page Fault Count", pmem.PageFaultCount); stats.add("PeakWorkingSetSize KB", pmem.PeakWorkingSetSize/div); diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h index f97d49eeb1..827b0dc048 100644 --- a/indra/llcommon/llsys.h +++ b/indra/llcommon/llsys.h @@ -134,8 +134,8 @@ public: static U32Kilobytes getHardwareMemSize(); // Because some Mac linkers won't let us reference extern gSysMemory from a different lib. #endif - //get the available memory infomation in KiloBytes. - static void getAvailableMemoryKB(U32Kilobytes& avail_physical_mem_kb, U32Kilobytes& avail_virtual_mem_kb); + //get the available memory in KiloBytes. + static void getAvailableMemoryKB(U32Kilobytes& avail_mem_kb); // Retrieve a map of memory statistics. The keys of the map are platform- // dependent. The values are in kilobytes to try to avoid integer overflow. @@ -169,6 +169,7 @@ bool LL_COMMON_API gunzip_file(const std::string& srcfile, const std::string& ds // gzip srcfile into dstfile. Returns false on error. bool LL_COMMON_API gzip_file(const std::string& srcfile, const std::string& dstfile); +extern LL_COMMON_API LLMemoryInfo gSysMemory; extern LL_COMMON_API LLCPUInfo gSysCPU; #endif // LL_LLSYS_H diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index faaaefd561..9eb92ca6a1 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -344,7 +344,7 @@ bool LLThread::runCondition(void) // Stop thread execution if requested until unpaused. void LLThread::checkPause() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; mDataLock->lock(); // This is in a while loop because the pthread API allows for spurious wakeups. @@ -376,20 +376,20 @@ void LLThread::setQuitting() // static LLThread::id_t LLThread::currentID() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; return std::this_thread::get_id(); } // static void LLThread::yield() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; std::this_thread::yield(); } void LLThread::wake() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; mDataLock->lock(); if(!shouldSleep()) { @@ -400,7 +400,7 @@ void LLThread::wake() void LLThread::wakeLocked() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; if(!shouldSleep()) { mRunCondition->signal(); @@ -409,13 +409,13 @@ void LLThread::wakeLocked() void LLThread::lockData() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; mDataLock->lock(); } void LLThread::unlockData() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD + LL_PROFILE_ZONE_SCOPED_CATEGORY_THREAD; mDataLock->unlock(); } diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index a3e871661c..28d6e4e4cc 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -91,7 +91,7 @@ U32 micro_sleep(U64 us, U32 max_yields) U32 micro_sleep(U64 us, U32 max_yields) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; #if 0 LARGE_INTEGER ft; ft.QuadPart = -static_cast<S64>(us * 10); // '-' using relative time @@ -101,7 +101,7 @@ U32 micro_sleep(U64 us, U32 max_yields) WaitForSingleObject(timer, INFINITE); CloseHandle(timer); #else - Sleep(us / 1000); + Sleep((DWORD)(us / 1000)); #endif return 0; @@ -109,7 +109,7 @@ U32 micro_sleep(U64 us, U32 max_yields) void ms_sleep(U32 ms) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; micro_sleep(ms * 1000, 0); } diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp index 8741087f3a..dc9a87eb80 100644 --- a/indra/llcommon/lltraceaccumulators.cpp +++ b/indra/llcommon/lltraceaccumulators.cpp @@ -100,7 +100,7 @@ bool AccumulatorBufferGroup::isCurrent() const return mCounts.isCurrent(); } -void AccumulatorBufferGroup::append( const AccumulatorBufferGroup& other ) +void AccumulatorBufferGroup::append(const AccumulatorBufferGroup& other) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; mCounts.addSamples(other.mCounts, SEQUENTIAL); @@ -109,7 +109,7 @@ void AccumulatorBufferGroup::append( const AccumulatorBufferGroup& other ) mStackTimers.addSamples(other.mStackTimers, SEQUENTIAL); } -void AccumulatorBufferGroup::merge( const AccumulatorBufferGroup& other) +void AccumulatorBufferGroup::merge(const AccumulatorBufferGroup& other) { LL_PROFILE_ZONE_SCOPED_CATEGORY_STATS; mCounts.addSamples(other.mCounts, NON_SEQUENTIAL); @@ -140,7 +140,7 @@ void AccumulatorBufferGroup::sync() F64 SampleAccumulator::mergeSumsOfSquares(const SampleAccumulator& a, const SampleAccumulator& b) { - const F64 epsilon = 0.0000001; + constexpr F64 epsilon = 0.0000001; if (a.getSamplingTime() > epsilon && b.getSamplingTime() > epsilon) { @@ -170,7 +170,7 @@ F64 SampleAccumulator::mergeSumsOfSquares(const SampleAccumulator& a, const Samp return a.getSumOfSquares(); } -void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppendType append_type ) +void SampleAccumulator::addSamples(const SampleAccumulator& other, EBufferAppendType append_type) { if (append_type == NON_SEQUENTIAL) { @@ -205,7 +205,7 @@ void SampleAccumulator::addSamples( const SampleAccumulator& other, EBufferAppen } } -void SampleAccumulator::reset( const SampleAccumulator* other ) +void SampleAccumulator::reset(const SampleAccumulator* other) { mLastValue = other ? other->mLastValue : NaN; mHasValue = other ? other->mHasValue : false; @@ -243,7 +243,7 @@ F64 EventAccumulator::mergeSumsOfSquares(const EventAccumulator& a, const EventA return a.mSumOfSquares; } -void EventAccumulator::addSamples( const EventAccumulator& other, EBufferAppendType append_type ) +void EventAccumulator::addSamples(const EventAccumulator& other, EBufferAppendType append_type) { if (other.mNumSamples) { @@ -269,12 +269,12 @@ void EventAccumulator::addSamples( const EventAccumulator& other, EBufferAppendT } } -void EventAccumulator::reset( const EventAccumulator* other ) +void EventAccumulator::reset(const EventAccumulator* other) { mNumSamples = 0; mSum = 0; - mMin = F32(NaN); - mMax = F32(NaN); + mMin = NaN; + mMax = NaN; mMean = NaN; mSumOfSquares = 0; mLastValue = other ? other->mLastValue : NaN; diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index ba7acf9547..0a2e2bf997 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -39,7 +39,7 @@ namespace LLTrace { - const F64 NaN = std::numeric_limits<double>::quiet_NaN(); + constexpr F64 NaN = std::numeric_limits<double>::quiet_NaN(); enum EBufferAppendType { @@ -251,8 +251,8 @@ namespace LLTrace EventAccumulator() : mSum(0), - mMin(F32(NaN)), - mMax(F32(NaN)), + mMin(NaN), + mMax(NaN), mMean(NaN), mSumOfSquares(0), mNumSamples(0), @@ -288,11 +288,11 @@ namespace LLTrace void sync(F64SecondsImplicit) {} F64 getSum() const { return mSum; } - F32 getMin() const { return mMin; } - F32 getMax() const { return mMax; } + F64 getMin() const { return mMin; } + F64 getMax() const { return mMax; } F64 getLastValue() const { return mLastValue; } F64 getMean() const { return mMean; } - F64 getStandardDeviation() const { return sqrtf(mSumOfSquares / mNumSamples); } + F64 getStandardDeviation() const { return sqrt(mSumOfSquares / mNumSamples); } F64 getSumOfSquares() const { return mSumOfSquares; } S32 getSampleCount() const { return mNumSamples; } bool hasValue() const { return mNumSamples > 0; } @@ -307,7 +307,7 @@ namespace LLTrace F64 mMean, mSumOfSquares; - F32 mMin, + F64 mMin, mMax; S32 mNumSamples; @@ -322,8 +322,8 @@ namespace LLTrace SampleAccumulator() : mSum(0), - mMin(F32(NaN)), - mMax(F32(NaN)), + mMin(NaN), + mMax(NaN), mMean(NaN), mSumOfSquares(0), mLastSampleTimeStamp(0), @@ -378,11 +378,11 @@ namespace LLTrace } F64 getSum() const { return mSum; } - F32 getMin() const { return mMin; } - F32 getMax() const { return mMax; } + F64 getMin() const { return mMin; } + F64 getMax() const { return mMax; } F64 getLastValue() const { return mLastValue; } F64 getMean() const { return mMean; } - F64 getStandardDeviation() const { return sqrtf(mSumOfSquares / mTotalSamplingTime); } + F64 getStandardDeviation() const { return sqrt(mSumOfSquares / mTotalSamplingTime); } F64 getSumOfSquares() const { return mSumOfSquares; } F64SecondsImplicit getSamplingTime() const { return mTotalSamplingTime; } S32 getSampleCount() const { return mNumSamples; } @@ -402,7 +402,7 @@ namespace LLTrace mLastSampleTimeStamp, mTotalSamplingTime; - F32 mMin, + F64 mMin, mMax; S32 mNumSamples; diff --git a/indra/llcommon/lltracerecording.cpp b/indra/llcommon/lltracerecording.cpp index 1ec83be7cb..c23adca7e8 100644 --- a/indra/llcommon/lltracerecording.cpp +++ b/indra/llcommon/lltracerecording.cpp @@ -229,7 +229,7 @@ F32 Recording::getPerSec(const StatType<TimeBlockAccumulator::CallCountFacet>& s update(); const TimeBlockAccumulator& accumulator = mBuffers->mStackTimers[stat.getIndex()]; const TimeBlockAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mStackTimers[stat.getIndex()] : NULL; - return (F32)(accumulator.mCalls + (active_accumulator ? active_accumulator->mCalls : 0)) / mElapsedSeconds.value(); + return (F32)(accumulator.mCalls + (active_accumulator ? active_accumulator->mCalls : 0)) / (F32)mElapsedSeconds.value(); } bool Recording::hasValue(const StatType<CountAccumulator>& stat) @@ -296,11 +296,11 @@ F64 Recording::getMean( const StatType<SampleAccumulator>& stat ) const SampleAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mSamples[stat.getIndex()] : NULL; if (active_accumulator && active_accumulator->hasValue()) { - F32 t = 0.0f; + F64 t = 0.0; S32 div = accumulator.getSampleCount() + active_accumulator->getSampleCount(); if (div > 0) { - t = active_accumulator->getSampleCount() / div; + t = (F64)active_accumulator->getSampleCount() / (F64)div; } return lerp(accumulator.getMean(), active_accumulator->getMean(), t); } @@ -319,7 +319,7 @@ F64 Recording::getStandardDeviation( const StatType<SampleAccumulator>& stat ) if (active_accumulator && active_accumulator->hasValue()) { F64 sum_of_squares = SampleAccumulator::mergeSumsOfSquares(accumulator, *active_accumulator); - return sqrtf(sum_of_squares / (accumulator.getSamplingTime() + active_accumulator->getSamplingTime())); + return sqrt(sum_of_squares / (F64)(accumulator.getSamplingTime() + active_accumulator->getSamplingTime())); } else { @@ -382,11 +382,11 @@ F64 Recording::getMean( const StatType<EventAccumulator>& stat ) const EventAccumulator* active_accumulator = mActiveBuffers ? &mActiveBuffers->mEvents[stat.getIndex()] : NULL; if (active_accumulator && active_accumulator->hasValue()) { - F32 t = 0.0f; + F64 t = 0.0; S32 div = accumulator.getSampleCount() + active_accumulator->getSampleCount(); if (div > 0) { - t = active_accumulator->getSampleCount() / div; + t = (F64)active_accumulator->getSampleCount() / (F64)div; } return lerp(accumulator.getMean(), active_accumulator->getMean(), t); } @@ -405,7 +405,7 @@ F64 Recording::getStandardDeviation( const StatType<EventAccumulator>& stat ) if (active_accumulator && active_accumulator->hasValue()) { F64 sum_of_squares = EventAccumulator::mergeSumsOfSquares(accumulator, *active_accumulator); - return sqrtf(sum_of_squares / (accumulator.getSampleCount() + active_accumulator->getSampleCount())); + return sqrt(sum_of_squares / (F64)(accumulator.getSampleCount() + active_accumulator->getSampleCount())); } else { diff --git a/indra/llcommon/lltracerecording.h b/indra/llcommon/lltracerecording.h index 985f06cd59..ad4c91d85b 100644 --- a/indra/llcommon/lltracerecording.h +++ b/indra/llcommon/lltracerecording.h @@ -35,6 +35,11 @@ #include "llpointer.h" #include <limits> +#ifdef LL_WINDOWS +#pragma warning(push) +#pragma warning(disable : 4244) // possible loss of data on conversions +#endif + class LLStopWatchControlsMixinCommon { public: @@ -714,4 +719,8 @@ namespace LLTrace }; } +#ifdef LL_WINDOWS +#pragma warning(pop) +#endif + #endif // LL_LLTRACERECORDING_H diff --git a/indra/llcommon/llunittype.h b/indra/llcommon/llunittype.h index 83ce0d05a8..bb1408609a 100644 --- a/indra/llcommon/llunittype.h +++ b/indra/llcommon/llunittype.h @@ -31,6 +31,11 @@ #include "llpreprocessor.h" #include "llerror.h" +#ifdef LL_WINDOWS +#pragma warning(push) +#pragma warning(disable : 4244) // possible loss of data on conversions +#endif + //lightweight replacement of type traits for simple type equality check template<typename S, typename T> struct LLIsSameType @@ -846,4 +851,8 @@ LL_FORCE_INLINE S2 ll_convert_units(LLUnit<S1, base_unit_name> in, LLUnit<S2, un typedef LLUnit<U64, ns::unit_name> U64##unit_name; \ typedef LLUnitImplicit<U64, ns::unit_name> U64##unit_name##Implicit +#ifdef LL_WINDOWS +#pragma warning(pop) +#endif + #endif //LL_UNITTYPE_H diff --git a/indra/llcommon/tests/lleventfilter_test.cpp b/indra/llcommon/tests/lleventfilter_test.cpp index a01d7fe415..d7b80e2545 100644 --- a/indra/llcommon/tests/lleventfilter_test.cpp +++ b/indra/llcommon/tests/lleventfilter_test.cpp @@ -81,13 +81,13 @@ class TestEventThrottle: public LLEventThrottleBase public: TestEventThrottle(F32 interval): LLEventThrottleBase(interval), - mAlarmRemaining(-1), - mTimerRemaining(-1) + mAlarmRemaining(-1.f), + mTimerRemaining(-1.f) {} TestEventThrottle(LLEventPump& source, F32 interval): LLEventThrottleBase(source, interval), - mAlarmRemaining(-1), - mTimerRemaining(-1) + mAlarmRemaining(-1.f), + mTimerRemaining(-1.f) {} /*----- implementation of LLEventThrottleBase timing functionality -----*/ @@ -100,12 +100,12 @@ public: virtual bool alarmRunning() const /*override*/ { // decrementing to exactly 0 should mean the alarm fires - return mAlarmRemaining > 0; + return mAlarmRemaining > 0.f; } virtual void alarmCancel() /*override*/ { - mAlarmRemaining = -1; + mAlarmRemaining = -1.f; } virtual void timerSet(F32 interval) /*override*/ @@ -116,7 +116,7 @@ public: virtual F32 timerGetRemaining() const /*override*/ { // LLTimer.getRemainingTimeF32() never returns negative; 0.0 means expired - return (mTimerRemaining > 0.0)? mTimerRemaining : 0.0; + return (mTimerRemaining > 0.0f)? mTimerRemaining : 0.0f; } /*------------------- methods for manipulating time --------------------*/ diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp index fb2af1d2db..fae9f7023f 100644 --- a/indra/llcommon/tests/llsdserialize_test.cpp +++ b/indra/llcommon/tests/llsdserialize_test.cpp @@ -1809,7 +1809,7 @@ namespace tut std::string q("\""); std::string qPYTHON(q + PYTHON + q); std::string qscript(q + scriptfile.getName() + q); - int rc = _spawnl(_P_WAIT, PYTHON.c_str(), qPYTHON.c_str(), qscript.c_str(), + int rc = (int)_spawnl(_P_WAIT, PYTHON.c_str(), qPYTHON.c_str(), qscript.c_str(), std::forward<ARGS>(args)..., NULL); if (rc == -1) { diff --git a/indra/llcommon/tests/lltrace_test.cpp b/indra/llcommon/tests/lltrace_test.cpp index 8851f87b91..923a67ac8e 100644 --- a/indra/llcommon/tests/lltrace_test.cpp +++ b/indra/llcommon/tests/lltrace_test.cpp @@ -32,6 +32,10 @@ #include "lltracerecording.h" #include "../test/lltut.h" +#ifdef LL_WINDOWS +#pragma warning(disable : 4244) // possible loss of data on conversions +#endif + namespace LLUnits { // using powers of 2 to allow strict floating point equality diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp index 49f2d3085a..98a58eb47e 100644 --- a/indra/llcommon/tests/llunits_test.cpp +++ b/indra/llcommon/tests/llunits_test.cpp @@ -262,7 +262,7 @@ namespace tut F32 float_val = quatloos_implicit; ensure("implicit units convert implicitly to regular values", float_val == 16); - S32 int_val = quatloos_implicit; + S32 int_val = (S32)quatloos_implicit; ensure("implicit units convert implicitly to regular values", int_val == 16); // conversion of implicits diff --git a/indra/llcorehttp/_httpinternal.h b/indra/llcorehttp/_httpinternal.h index 768ef98330..2a191fa550 100644 --- a/indra/llcorehttp/_httpinternal.h +++ b/indra/llcorehttp/_httpinternal.h @@ -106,17 +106,17 @@ namespace LLCore // Maxium number of policy classes that can be defined. // *TODO: Currently limited to the default class + 1, extend. // (TSN: should this be more dynamically sized. Is there a reason to hard limit the number of policies?) -const int HTTP_POLICY_CLASS_LIMIT = 32; +constexpr int HTTP_POLICY_CLASS_LIMIT = 32; // Debug/informational tracing. Used both // as a global option and in per-request traces. -const int HTTP_TRACE_OFF = 0; -const int HTTP_TRACE_LOW = 1; -const int HTTP_TRACE_CURL_HEADERS = 2; -const int HTTP_TRACE_CURL_BODIES = 3; +constexpr int HTTP_TRACE_OFF = 0; +constexpr int HTTP_TRACE_LOW = 1; +constexpr int HTTP_TRACE_CURL_HEADERS = 2; +constexpr int HTTP_TRACE_CURL_BODIES = 3; -const int HTTP_TRACE_MIN = HTTP_TRACE_OFF; -const int HTTP_TRACE_MAX = HTTP_TRACE_CURL_BODIES; +constexpr int HTTP_TRACE_MIN = HTTP_TRACE_OFF; +constexpr int HTTP_TRACE_MAX = HTTP_TRACE_CURL_BODIES; // Request retry limits // @@ -127,41 +127,41 @@ const int HTTP_TRACE_MAX = HTTP_TRACE_CURL_BODIES; // We want to span a few windows to allow transport to slow // after onset of the throttles and then recover without a final // failure. Other systems may need other constants. -const int HTTP_RETRY_COUNT_DEFAULT = 5; -const int HTTP_RETRY_COUNT_MIN = 0; -const int HTTP_RETRY_COUNT_MAX = 100; -const HttpTime HTTP_RETRY_BACKOFF_MIN_DEFAULT = 1E6L; // 1 sec -const HttpTime HTTP_RETRY_BACKOFF_MAX_DEFAULT = 5E6L; // 5 sec -const HttpTime HTTP_RETRY_BACKOFF_MAX = 20E6L; // 20 sec +constexpr int HTTP_RETRY_COUNT_DEFAULT = 5; +constexpr int HTTP_RETRY_COUNT_MIN = 0; +constexpr int HTTP_RETRY_COUNT_MAX = 100; +constexpr HttpTime HTTP_RETRY_BACKOFF_MIN_DEFAULT = 1000000UL; // 1 sec +constexpr HttpTime HTTP_RETRY_BACKOFF_MAX_DEFAULT = 50000006UL; // 5 sec +constexpr HttpTime HTTP_RETRY_BACKOFF_MAX = 20000000UL; // 20 sec -const int HTTP_REDIRECTS_DEFAULT = 10; +constexpr int HTTP_REDIRECTS_DEFAULT = 10; // Timeout value used for both connect and protocol exchange. // Retries and time-on-queue are not included and aren't // accounted for. -const long HTTP_REQUEST_TIMEOUT_DEFAULT = 30L; -const long HTTP_REQUEST_XFER_TIMEOUT_DEFAULT = 0L; -const long HTTP_REQUEST_TIMEOUT_MIN = 0L; -const long HTTP_REQUEST_TIMEOUT_MAX = 3600L; +constexpr long HTTP_REQUEST_TIMEOUT_DEFAULT = 30L; +constexpr long HTTP_REQUEST_XFER_TIMEOUT_DEFAULT = 0L; +constexpr long HTTP_REQUEST_TIMEOUT_MIN = 0L; +constexpr long HTTP_REQUEST_TIMEOUT_MAX = 3600L; // Limits on connection counts -const int HTTP_CONNECTION_LIMIT_DEFAULT = 8; -const int HTTP_CONNECTION_LIMIT_MIN = 1; -const int HTTP_CONNECTION_LIMIT_MAX = 256; +constexpr int HTTP_CONNECTION_LIMIT_DEFAULT = 8; +constexpr int HTTP_CONNECTION_LIMIT_MIN = 1; +constexpr int HTTP_CONNECTION_LIMIT_MAX = 256; // Pipelining limits -const long HTTP_PIPELINING_DEFAULT = 0L; -const long HTTP_PIPELINING_MAX = 20L; +constexpr long HTTP_PIPELINING_DEFAULT = 0L; +constexpr long HTTP_PIPELINING_MAX = 20L; // Miscellaneous defaults -const bool HTTP_USE_RETRY_AFTER_DEFAULT = true; -const long HTTP_THROTTLE_RATE_DEFAULT = 0L; +constexpr bool HTTP_USE_RETRY_AFTER_DEFAULT = true; +constexpr long HTTP_THROTTLE_RATE_DEFAULT = 0L; // Tuning parameters // Time worker thread sleeps after a pass through the // request, ready and active queues. -const int HTTP_SERVICE_LOOP_SLEEP_NORMAL_MS = 2; +constexpr int HTTP_SERVICE_LOOP_SLEEP_NORMAL_MS = 2; // Block allocation size (a tuning parameter) is found // in bufferarray.h. diff --git a/indra/llcorehttp/httpstats.h b/indra/llcorehttp/httpstats.h index e1387d9df5..f12e59da0c 100644 --- a/indra/llcorehttp/httpstats.h +++ b/indra/llcorehttp/httpstats.h @@ -47,12 +47,12 @@ namespace LLCore void recordDataDown(size_t bytes) { - mDataDown.push(bytes); + mDataDown.push((F32)bytes); } void recordDataUp(size_t bytes) { - mDataUp.push(bytes); + mDataUp.push((F32)bytes); } void recordHTTPRequest() { ++mRequests; } diff --git a/indra/llcrashlogger/llcrashlock.cpp b/indra/llcrashlogger/llcrashlock.cpp index 506232ab2a..ecd197b2c1 100644 --- a/indra/llcrashlogger/llcrashlock.cpp +++ b/indra/llcrashlogger/llcrashlock.cpp @@ -45,11 +45,10 @@ bool LLCrashLock::isProcessAlive(U32 pid, const std::string& pname) { - std::wstring wpname; - wpname = std::wstring(pname.begin(), pname.end()); + std::wstring wpname = ll_convert_string_to_wide(pname); HANDLE snapshot; - PROCESSENTRY32 pe32; + PROCESSENTRY32 pe32{}; bool matched = false; @@ -65,7 +64,7 @@ bool LLCrashLock::isProcessAlive(U32 pid, const std::string& pname) { do { std::wstring wexecname = pe32.szExeFile; - std::string execname = std::string(wexecname.begin(), wexecname.end()); + std::string execname = ll_convert_wide_to_string(wexecname); if (!wpname.compare(pe32.szExeFile)) { if (pid == (U32)pe32.th32ProcessID) diff --git a/indra/llfilesystem/lldir.cpp b/indra/llfilesystem/lldir.cpp index 8ee2c309a5..a18dc0a4f1 100644 --- a/indra/llfilesystem/lldir.cpp +++ b/indra/llfilesystem/lldir.cpp @@ -201,15 +201,15 @@ U32 LLDir::deleteDirAndContents(const std::string& dir_name) boost::filesystem::path dir_path(dir_name); #endif - if (boost::filesystem::exists (dir_path)) + if (boost::filesystem::exists(dir_path)) { - if (!boost::filesystem::is_empty (dir_path)) + if (!boost::filesystem::is_empty(dir_path)) { // Directory has content - num_deleted = boost::filesystem::remove_all (dir_path); + num_deleted = (U32)boost::filesystem::remove_all(dir_path); } else { // Directory is empty - boost::filesystem::remove (dir_path); + boost::filesystem::remove(dir_path); } } } diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index da2e960ed3..86b1e2ac81 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -325,8 +325,8 @@ const std::string LLDiskCache::getCacheInfo() { std::ostringstream cache_info; - F32 max_in_mb = (F32)mMaxSizeBytes / (1024.0 * 1024.0); - F32 percent_used = ((F32)dirFileSize(mCacheDir) / (F32)mMaxSizeBytes) * 100.0; + F32 max_in_mb = (F32)mMaxSizeBytes / (1024.0f * 1024.0f); + F32 percent_used = ((F32)dirFileSize(mCacheDir) / (F32)mMaxSizeBytes) * 100.0f; cache_info << std::fixed; cache_info << std::setprecision(1); diff --git a/indra/llfilesystem/llfilesystem.cpp b/indra/llfilesystem/llfilesystem.cpp index 235aae0be3..7d2a6bd6f5 100644 --- a/indra/llfilesystem/llfilesystem.cpp +++ b/indra/llfilesystem/llfilesystem.cpp @@ -79,6 +79,7 @@ LLFileSystem::~LLFileSystem() // static bool LLFileSystem::getExists(const LLUUID& file_id, const LLAssetType::EType file_type) { + LL_PROFILE_ZONE_SCOPED; std::string id_str; file_id.toString(id_str); const std::string extra_info = ""; @@ -147,7 +148,7 @@ S32 LLFileSystem::getFileSize(const LLUUID& file_id, const LLAssetType::EType fi if (file.is_open()) { file.seekg(0, std::ios::end); - file_size = file.tellg(); + file_size = (S32)file.tellg(); } return file_size; @@ -175,7 +176,7 @@ bool LLFileSystem::read(U8* buffer, S32 bytes) } else { - mBytesRead = file.gcount(); + mBytesRead = (S32)file.gcount(); } file.close(); @@ -216,7 +217,7 @@ bool LLFileSystem::write(const U8* buffer, S32 bytes) { ofs.write((const char*)buffer, bytes); - mPosition = ofs.tellp(); // <FS:Ansariel> Fix asset caching + mPosition = (S32)ofs.tellp(); // <FS:Ansariel> Fix asset caching success = true; } diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 42eecbb97c..8b966b8ea3 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -32,37 +32,37 @@ #include "llpointer.h" #include "lltrace.h" -const S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2 -const S32 MAX_IMAGE_MIP = 12; // 4096x4096 +constexpr S32 MIN_IMAGE_MIP = 2; // 4x4, only used for expand/contract power of 2 +constexpr S32 MAX_IMAGE_MIP = 12; // 4096x4096 // *TODO : Use MAX_IMAGE_MIP as max discard level and modify j2c management so that the number // of levels is read from the header's file, not inferred from its size. -const S32 MAX_DISCARD_LEVEL = 5; +constexpr S32 MAX_DISCARD_LEVEL = 5; // JPEG2000 size constraints // Those are declared here as they are germane to other image constraints used in the viewer // and declared right here. Some come from the JPEG2000 spec, some conventions specific to SL. -const S32 MAX_DECOMPOSITION_LEVELS = 32; // Number of decomposition levels cannot exceed 32 according to jpeg2000 spec -const S32 MIN_DECOMPOSITION_LEVELS = 5; // the SL viewer will *crash* trying to decode images with fewer than 5 decomposition levels (unless image is small that is) -const S32 MAX_PRECINCT_SIZE = 4096; // No reason to be bigger than MAX_IMAGE_SIZE -const S32 MIN_PRECINCT_SIZE = 4; // Can't be smaller than MIN_BLOCK_SIZE -const S32 MAX_BLOCK_SIZE = 64; // Max total block size is 4096, hence 64x64 when using square blocks -const S32 MIN_BLOCK_SIZE = 4; // Min block dim is 4 according to jpeg2000 spec -const S32 MIN_LAYER_SIZE = 2000; // Size of the first quality layer (after header). Must be > to FIRST_PACKET_SIZE!! -const S32 MAX_NB_LAYERS = 64; // Max number of layers we'll entertain in SL (practical limit) - -const S32 MIN_IMAGE_SIZE = (1<<MIN_IMAGE_MIP); // 4, only used for expand/contract power of 2 -const S32 MAX_IMAGE_SIZE = (1<<MAX_IMAGE_MIP); // 4096 -const S32 MIN_IMAGE_AREA = MIN_IMAGE_SIZE * MIN_IMAGE_SIZE; -const S32 MAX_IMAGE_AREA = MAX_IMAGE_SIZE * MAX_IMAGE_SIZE; -const S32 MAX_IMAGE_COMPONENTS = 8; -const S32 MAX_IMAGE_DATA_SIZE = MAX_IMAGE_AREA * MAX_IMAGE_COMPONENTS; //4096 * 4096 * 8 = 128 MB +constexpr S32 MAX_DECOMPOSITION_LEVELS = 32; // Number of decomposition levels cannot exceed 32 according to jpeg2000 spec +constexpr S32 MIN_DECOMPOSITION_LEVELS = 5; // the SL viewer will *crash* trying to decode images with fewer than 5 decomposition levels (unless image is small that is) +constexpr S32 MAX_PRECINCT_SIZE = 4096; // No reason to be bigger than MAX_IMAGE_SIZE +constexpr S32 MIN_PRECINCT_SIZE = 4; // Can't be smaller than MIN_BLOCK_SIZE +constexpr S32 MAX_BLOCK_SIZE = 64; // Max total block size is 4096, hence 64x64 when using square blocks +constexpr S32 MIN_BLOCK_SIZE = 4; // Min block dim is 4 according to jpeg2000 spec +constexpr S32 MIN_LAYER_SIZE = 2000; // Size of the first quality layer (after header). Must be > to FIRST_PACKET_SIZE!! +constexpr S32 MAX_NB_LAYERS = 64; // Max number of layers we'll entertain in SL (practical limit) + +constexpr S32 MIN_IMAGE_SIZE = (1<<MIN_IMAGE_MIP); // 4, only used for expand/contract power of 2 +constexpr S32 MAX_IMAGE_SIZE = (1<<MAX_IMAGE_MIP); // 4096 +constexpr S32 MIN_IMAGE_AREA = MIN_IMAGE_SIZE * MIN_IMAGE_SIZE; +constexpr S32 MAX_IMAGE_AREA = MAX_IMAGE_SIZE * MAX_IMAGE_SIZE; +constexpr S32 MAX_IMAGE_COMPONENTS = 8; +constexpr S32 MAX_IMAGE_DATA_SIZE = MAX_IMAGE_AREA * MAX_IMAGE_COMPONENTS; //4096 * 4096 * 8 = 128 MB // Note! These CANNOT be changed without modifying simulator code // *TODO: change both to 1024 when SIM texture fetching is deprecated -const S32 FIRST_PACKET_SIZE = 600; -const S32 MAX_IMG_PACKET_SIZE = 1000; -const S32 HTTP_PACKET_SIZE = 1496; +constexpr S32 FIRST_PACKET_SIZE = 600; +constexpr S32 MAX_IMG_PACKET_SIZE = 1000; +constexpr S32 HTTP_PACKET_SIZE = 1496; // Base classes for images. // There are two major parts for the image: diff --git a/indra/llimage/llimagefilter.cpp b/indra/llimage/llimagefilter.cpp index 0d15906afd..bfcb1f76de 100644 --- a/indra/llimage/llimagefilter.cpp +++ b/indra/llimage/llimagefilter.cpp @@ -253,7 +253,7 @@ void LLImageFilter::executeFilter(LLPointer<LLImageRaw> raw_image) bool abs_value = (mFilterData[i][index++].asReal() > 0.0); for (S32 k = 0; k < NUM_VALUES_IN_MAT3; k++) for (S32 j = 0; j < NUM_VALUES_IN_MAT3; j++) - kernel.mMatrix[k][j] = mFilterData[i][index++].asReal(); + kernel.mMatrix[k][j] = (F32)mFilterData[i][index++].asReal(); convolve(kernel,normalize,abs_value); } else if (filter_name == "colortransform") @@ -262,7 +262,7 @@ void LLImageFilter::executeFilter(LLPointer<LLImageRaw> raw_image) S32 index = 1; for (S32 k = 0; k < NUM_VALUES_IN_MAT3; k++) for (S32 j = 0; j < NUM_VALUES_IN_MAT3; j++) - transform.mMatrix[k][j] = mFilterData[i][index++].asReal(); + transform.mMatrix[k][j] = (F32)mFilterData[i][index++].asReal(); transform.transpose(); colorTransform(transform); } @@ -279,32 +279,32 @@ void LLImageFilter::executeFilter(LLPointer<LLImageRaw> raw_image) void LLImageFilter::blendStencil(F32 alpha, U8* pixel, U8 red, U8 green, U8 blue) { - F32 inv_alpha = 1.0 - alpha; + F32 inv_alpha = 1.0f - alpha; switch (mStencilBlendMode) { case STENCIL_BLEND_MODE_BLEND: // Classic blend of incoming color with the background image - pixel[VRED] = inv_alpha * pixel[VRED] + alpha * red; - pixel[VGREEN] = inv_alpha * pixel[VGREEN] + alpha * green; - pixel[VBLUE] = inv_alpha * pixel[VBLUE] + alpha * blue; + pixel[VRED] = (U8)(inv_alpha * pixel[VRED] + alpha * red); + pixel[VGREEN] = (U8)(inv_alpha * pixel[VGREEN] + alpha * green); + pixel[VBLUE] = (U8)(inv_alpha * pixel[VBLUE] + alpha * blue); break; case STENCIL_BLEND_MODE_ADD: // Add incoming color to the background image - pixel[VRED] = llclampb(pixel[VRED] + alpha * red); - pixel[VGREEN] = llclampb(pixel[VGREEN] + alpha * green); - pixel[VBLUE] = llclampb(pixel[VBLUE] + alpha * blue); + pixel[VRED] = (U8)llclampb(pixel[VRED] + alpha * red); + pixel[VGREEN] = (U8)llclampb(pixel[VGREEN] + alpha * green); + pixel[VBLUE] = (U8)llclampb(pixel[VBLUE] + alpha * blue); break; case STENCIL_BLEND_MODE_ABACK: // Add back background image to the incoming color - pixel[VRED] = llclampb(inv_alpha * pixel[VRED] + red); - pixel[VGREEN] = llclampb(inv_alpha * pixel[VGREEN] + green); - pixel[VBLUE] = llclampb(inv_alpha * pixel[VBLUE] + blue); + pixel[VRED] = (U8)llclampb(inv_alpha * pixel[VRED] + red); + pixel[VGREEN] = (U8)llclampb(inv_alpha * pixel[VGREEN] + green); + pixel[VBLUE] = (U8)llclampb(inv_alpha * pixel[VBLUE] + blue); break; case STENCIL_BLEND_MODE_FADE: // Fade incoming color to black - pixel[VRED] = alpha * red; - pixel[VGREEN] = alpha * green; - pixel[VBLUE] = alpha * blue; + pixel[VRED] = (U8)(alpha * red); + pixel[VGREEN] = (U8)(alpha * green); + pixel[VBLUE] = (U8)(alpha * blue); break; } } @@ -348,7 +348,7 @@ void LLImageFilter::colorTransform(const LLMatrix3 &transform) dst.clamp(0.0f,255.0f); // Blend result - blendStencil(getStencilAlpha(i,j), dst_data, dst.mV[VRED], dst.mV[VGREEN], dst.mV[VBLUE]); + blendStencil(getStencilAlpha(i,j), dst_data, (U8)dst.mV[VRED], (U8)dst.mV[VGREEN], (U8)dst.mV[VBLUE]); dst_data += components; } } @@ -463,7 +463,7 @@ void LLImageFilter::convolve(const LLMatrix3 &kernel, bool normalize, bool abs_v dst.clamp(0.0f,255.0f); // Blend result - blendStencil(getStencilAlpha(i,j), dst_data, dst.mV[VRED], dst.mV[VGREEN], dst.mV[VBLUE]); + blendStencil(getStencilAlpha(i,j), dst_data, (U8)dst.mV[VRED], (U8)dst.mV[VGREEN], (U8)dst.mV[VBLUE]); // Next pixel dst_data += components; @@ -499,7 +499,7 @@ void LLImageFilter::filterScreen(EScreenMode mode, const F32 wave_length, const S32 width = mImage->getWidth(); S32 height = mImage->getHeight(); - F32 wave_length_pixels = wave_length * (F32)(height) / 2.0; + F32 wave_length_pixels = wave_length * (F32)(height) / 2.0f; F32 sin = sinf(angle*DEG_TO_RAD); F32 cos = cosf(angle*DEG_TO_RAD); @@ -507,7 +507,7 @@ void LLImageFilter::filterScreen(EScreenMode mode, const F32 wave_length, const U8 gamma[256]; for (S32 i = 0; i < 256; i++) { - F32 gamma_i = llclampf((float)(powf((float)(i)/255.0,1.0/4.0))); + F32 gamma_i = llclampf((float)(powf((float)(i)/255.0f,1.0f/4.0f))); gamma[i] = (U8)(255.0 * gamma_i); } @@ -525,11 +525,11 @@ void LLImageFilter::filterScreen(EScreenMode mode, const F32 wave_length, const case SCREEN_MODE_2DSINE: di = cos*i + sin*j; dj = -sin*i + cos*j; - value = (sinf(2*F_PI*di/wave_length_pixels)*sinf(2*F_PI*dj/wave_length_pixels)+1.0)*255.0/2.0; + value = (sinf(2*F_PI*di/wave_length_pixels)*sinf(2*F_PI*dj/wave_length_pixels)+1.0f)*255.0f/2.0f; break; case SCREEN_MODE_LINE: dj = sin*i - cos*j; - value = (sinf(2*F_PI*dj/wave_length_pixels)+1.0)*255.0/2.0; + value = (sinf(2*F_PI*dj/wave_length_pixels)+1.0f)*255.0f/2.0f; break; } U8 dst_value = (dst_data[VRED] >= (U8)(value) ? gamma[dst_data[VRED] - (U8)(value)] : 0); @@ -556,16 +556,16 @@ void LLImageFilter::setStencil(EStencilShape shape, EStencilBlendMode mode, F32 mStencilCenterX = (S32)(mImage->getWidth() + params[0] * (F32)(mImage->getHeight()))/2; mStencilCenterY = (S32)(mImage->getHeight() + params[1] * (F32)(mImage->getHeight()))/2; mStencilWidth = (S32)(params[2] * (F32)(mImage->getHeight()))/2; - mStencilGamma = (params[3] <= 0.0 ? 1.0 : params[3]); + mStencilGamma = (params[3] <= 0.0f ? 1.0f : params[3]); - mStencilWavelength = (params[0] <= 0.0 ? 10.0 : params[0] * (F32)(mImage->getHeight()) / 2.0); + mStencilWavelength = (params[0] <= 0.0f ? 10.0f : params[0] * (F32)(mImage->getHeight()) / 2.0f); mStencilSine = sinf(params[1]*DEG_TO_RAD); mStencilCosine = cosf(params[1]*DEG_TO_RAD); - mStencilStartX = ((F32)(mImage->getWidth()) + params[0] * (F32)(mImage->getHeight()))/2.0; - mStencilStartY = ((F32)(mImage->getHeight()) + params[1] * (F32)(mImage->getHeight()))/2.0; - F32 end_x = ((F32)(mImage->getWidth()) + params[2] * (F32)(mImage->getHeight()))/2.0; - F32 end_y = ((F32)(mImage->getHeight()) + params[3] * (F32)(mImage->getHeight()))/2.0; + mStencilStartX = ((F32)(mImage->getWidth()) + params[0] * (F32)(mImage->getHeight()))/2.0f; + mStencilStartY = ((F32)(mImage->getHeight()) + params[1] * (F32)(mImage->getHeight()))/2.0f; + F32 end_x = ((F32)(mImage->getWidth()) + params[2] * (F32)(mImage->getHeight()))/2.0f; + F32 end_y = ((F32)(mImage->getHeight()) + params[3] * (F32)(mImage->getHeight()))/2.0f; mStencilGradX = end_x - mStencilStartX; mStencilGradY = end_y - mStencilStartY; mStencilGradN = mStencilGradX*mStencilGradX + mStencilGradY*mStencilGradY; @@ -578,14 +578,14 @@ F32 LLImageFilter::getStencilAlpha(S32 i, S32 j) { // alpha is a modified gaussian value, with a center and fading in a circular pattern toward the edges // The gamma parameter controls the intensity of the drop down from alpha 1.0 (center) to 0.0 - F32 d_center_square = (i - mStencilCenterX)*(i - mStencilCenterX) + (j - mStencilCenterY)*(j - mStencilCenterY); + F32 d_center_square = (F32)((i - mStencilCenterX)*(i - mStencilCenterX) + (j - mStencilCenterY)*(j - mStencilCenterY)); alpha = powf(F_E, -(powf((d_center_square/(mStencilWidth*mStencilWidth)),mStencilGamma)/2.0f)); } else if (mStencilShape == STENCIL_SHAPE_SCAN_LINES) { // alpha varies according to a squared sine function. F32 d = mStencilSine*i - mStencilCosine*j; - alpha = (sinf(2*F_PI*d/mStencilWavelength) > 0.0 ? 1.0 : 0.0); + alpha = (sinf(2*F_PI*d/mStencilWavelength) > 0.0f ? 1.0f : 0.0f); } else if (mStencilShape == STENCIL_SHAPE_GRADIENT) { @@ -756,11 +756,11 @@ void LLImageFilter::filterGamma(F32 gamma, const LLColor3& alpha) for (S32 i = 0; i < 256; i++) { - F32 gamma_i = llclampf((float)(powf((float)(i)/255.0,1.0/gamma))); + F32 gamma_i = llclampf((float)(powf((float)(i)/255.0f,1.0f/gamma))); // Blend in with alpha values - gamma_red_lut[i] = (U8)((1.0 - alpha.mV[0]) * (float)(i) + alpha.mV[0] * 255.0 * gamma_i); - gamma_green_lut[i] = (U8)((1.0 - alpha.mV[1]) * (float)(i) + alpha.mV[1] * 255.0 * gamma_i); - gamma_blue_lut[i] = (U8)((1.0 - alpha.mV[2]) * (float)(i) + alpha.mV[2] * 255.0 * gamma_i); + gamma_red_lut[i] = (U8)((1.0f - alpha.mV[0]) * (float)(i) + alpha.mV[0] * 255.0f * gamma_i); + gamma_green_lut[i] = (U8)((1.0f - alpha.mV[1]) * (float)(i) + alpha.mV[1] * 255.0f * gamma_i); + gamma_blue_lut[i] = (U8)((1.0f - alpha.mV[2]) * (float)(i) + alpha.mV[2] * 255.0f * gamma_i); } colorCorrect(gamma_red_lut,gamma_green_lut,gamma_blue_lut); @@ -808,23 +808,23 @@ void LLImageFilter::filterLinearize(F32 tail, const LLColor3& alpha) { U8 value_i = (i < min_v ? 0 : 255); // Blend in with alpha values - linear_red_lut[i] = (U8)((1.0 - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); - linear_green_lut[i] = (U8)((1.0 - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); - linear_blue_lut[i] = (U8)((1.0 - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); + linear_red_lut[i] = (U8)((1.0f - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); + linear_green_lut[i] = (U8)((1.0f - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); + linear_blue_lut[i] = (U8)((1.0f - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); } } else { // Linearize between min and max - F32 slope = 255.0 / (F32)(max_v - min_v); + F32 slope = 255.0f / (F32)(max_v - min_v); F32 translate = -min_v * slope; for (S32 i = 0; i < 256; i++) { U8 value_i = (U8)(llclampb((S32)(slope*i + translate))); // Blend in with alpha values - linear_red_lut[i] = (U8)((1.0 - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); - linear_green_lut[i] = (U8)((1.0 - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); - linear_blue_lut[i] = (U8)((1.0 - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); + linear_red_lut[i] = (U8)((1.0f - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); + linear_green_lut[i] = (U8)((1.0f - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); + linear_blue_lut[i] = (U8)((1.0f - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); } } @@ -863,9 +863,9 @@ void LLImageFilter::filterEqualize(S32 nb_classes, const LLColor3& alpha) for (S32 i = 0; i < 256; i++) { // Blend in current_value with alpha values - equalize_red_lut[i] = (U8)((1.0 - alpha.mV[0]) * (float)(i) + alpha.mV[0] * current_value); - equalize_green_lut[i] = (U8)((1.0 - alpha.mV[1]) * (float)(i) + alpha.mV[1] * current_value); - equalize_blue_lut[i] = (U8)((1.0 - alpha.mV[2]) * (float)(i) + alpha.mV[2] * current_value); + equalize_red_lut[i] = (U8)((1.0f - alpha.mV[0]) * (float)(i) + alpha.mV[0] * current_value); + equalize_green_lut[i] = (U8)((1.0f - alpha.mV[1]) * (float)(i) + alpha.mV[1] * current_value); + equalize_blue_lut[i] = (U8)((1.0f - alpha.mV[2]) * (float)(i) + alpha.mV[2] * current_value); if (cumulated_histo[i] >= current_count) { current_count += delta_count; @@ -884,15 +884,15 @@ void LLImageFilter::filterColorize(const LLColor3& color, const LLColor3& alpha) U8 green_lut[256]; U8 blue_lut[256]; - F32 red_composite = 255.0 * alpha.mV[0] * color.mV[0]; - F32 green_composite = 255.0 * alpha.mV[1] * color.mV[1]; - F32 blue_composite = 255.0 * alpha.mV[2] * color.mV[2]; + F32 red_composite = 255.0f * alpha.mV[0] * color.mV[0]; + F32 green_composite = 255.0f * alpha.mV[1] * color.mV[1]; + F32 blue_composite = 255.0f * alpha.mV[2] * color.mV[2]; for (S32 i = 0; i < 256; i++) { - red_lut[i] = (U8)(llclampb((S32)((1.0 - alpha.mV[0]) * (F32)(i) + red_composite))); - green_lut[i] = (U8)(llclampb((S32)((1.0 - alpha.mV[1]) * (F32)(i) + green_composite))); - blue_lut[i] = (U8)(llclampb((S32)((1.0 - alpha.mV[2]) * (F32)(i) + blue_composite))); + red_lut[i] = (U8)(llclampb((S32)((1.0f - alpha.mV[0]) * (F32)(i) + red_composite))); + green_lut[i] = (U8)(llclampb((S32)((1.0f - alpha.mV[1]) * (F32)(i) + green_composite))); + blue_lut[i] = (U8)(llclampb((S32)((1.0f - alpha.mV[2]) * (F32)(i) + blue_composite))); } colorCorrect(red_lut,green_lut,blue_lut); @@ -904,15 +904,15 @@ void LLImageFilter::filterContrast(F32 slope, const LLColor3& alpha) U8 contrast_green_lut[256]; U8 contrast_blue_lut[256]; - F32 translate = 128.0 * (1.0 - slope); + F32 translate = 128.0f * (1.0f - slope); for (S32 i = 0; i < 256; i++) { U8 value_i = (U8)(llclampb((S32)(slope*i + translate))); // Blend in with alpha values - contrast_red_lut[i] = (U8)((1.0 - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); - contrast_green_lut[i] = (U8)((1.0 - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); - contrast_blue_lut[i] = (U8)((1.0 - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); + contrast_red_lut[i] = (U8)((1.0f - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); + contrast_green_lut[i] = (U8)((1.0f - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); + contrast_blue_lut[i] = (U8)((1.0f - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); } colorCorrect(contrast_red_lut,contrast_green_lut,contrast_blue_lut); @@ -924,15 +924,15 @@ void LLImageFilter::filterBrightness(F32 add, const LLColor3& alpha) U8 brightness_green_lut[256]; U8 brightness_blue_lut[256]; - S32 add_value = (S32)(add * 255.0); + S32 add_value = (S32)(add * 255.0f); for (S32 i = 0; i < 256; i++) { U8 value_i = (U8)(llclampb(i + add_value)); // Blend in with alpha values - brightness_red_lut[i] = (U8)((1.0 - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); - brightness_green_lut[i] = (U8)((1.0 - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); - brightness_blue_lut[i] = (U8)((1.0 - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); + brightness_red_lut[i] = (U8)((1.0f - alpha.mV[0]) * (float)(i) + alpha.mV[0] * value_i); + brightness_green_lut[i] = (U8)((1.0f - alpha.mV[1]) * (float)(i) + alpha.mV[1] * value_i); + brightness_blue_lut[i] = (U8)((1.0f - alpha.mV[2]) * (float)(i) + alpha.mV[2] * value_i); } colorCorrect(brightness_red_lut,brightness_green_lut,brightness_blue_lut); diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 0058b91b0f..42f3e92257 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -275,30 +275,24 @@ S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 r // For details about the equation used here, see https://wiki.lindenlab.com/wiki/THX1138_KDU_Improvements#Byte_Range_Study // Estimate the number of layers. This is consistent with what's done for j2c encoding in LLImageJ2CKDU::encodeImpl(). + constexpr S32 precision = 8; // assumed bitrate per component channel, might change in future for HDR support + constexpr S32 max_components = 4; // assumed the file has four components; three color and alpha S32 nb_layers = 1; - S32 surface = w*h; + const S32 surface = w*h; S32 s = 64*64; + S32 totalbytes = (S32)(s * max_components * precision * rate); // first level computed before loop while (surface > s) { + if (nb_layers <= (5 - discard_level)) + totalbytes += (S32)(s * max_components * precision * rate); nb_layers++; s *= 4; } - F32 layer_factor = 3.0f * (7 - llclamp(nb_layers,1,6)); - - // Compute w/pow(2,discard_level) and h/pow(2,discard_level) - w >>= discard_level; - h >>= discard_level; - w = llmax(w, 1); - h = llmax(h, 1); - - // Temporary: compute both new and old range and pick one according to the settings TextureNewByteRange - // *TODO: Take the old code out once we have enough tests done - S32 bytes; - S32 new_bytes = (S32) (sqrt((F32)(w*h))*(F32)(comp)*rate*1000.f/layer_factor); - S32 old_bytes = (S32)((F32)(w*h*comp)*rate); - bytes = (LLImage::useNewByteRange() && (new_bytes < old_bytes) ? new_bytes : old_bytes); - bytes = llmax(bytes, calcHeaderSizeJ2C()); - return bytes; + + totalbytes /= 8; // to bytes + totalbytes += calcHeaderSizeJ2C(); // header + + return totalbytes; } S32 LLImageJ2C::calcHeaderSize() diff --git a/indra/llimagej2coj/llimagej2coj.cpp b/indra/llimagej2coj/llimagej2coj.cpp index 9a4e382183..f4bcb97a5d 100644 --- a/indra/llimagej2coj/llimagej2coj.cpp +++ b/indra/llimagej2coj/llimagej2coj.cpp @@ -431,23 +431,20 @@ public: opj_set_default_encoder_parameters(¶meters); parameters.cod_format = OPJ_CODEC_J2K; parameters.cp_disto_alloc = 1; - parameters.max_cs_size = (1 << 15); if (reversible) { + parameters.max_cs_size = 0; // do not limit size for reversible compression + parameters.irreversible = 0; // should be the default, but, just in case parameters.tcp_numlayers = 1; - parameters.tcp_rates[0] = 1.0f; + /* documentation seems to be wrong, should be 0.0f for lossless, not 1.0f + see https://github.com/uclouvain/openjpeg/blob/39e8c50a2f9bdcf36810ee3d41bcbf1cc78968ae/src/lib/openjp2/j2k.c#L7755 + */ + parameters.tcp_rates[0] = 0.0f; } else { - parameters.tcp_numlayers = 5; - parameters.tcp_rates[0] = 1920.0f; - parameters.tcp_rates[1] = 960.0f; - parameters.tcp_rates[2] = 480.0f; - parameters.tcp_rates[3] = 120.0f; - parameters.tcp_rates[4] = 30.0f; parameters.irreversible = 1; - parameters.tcp_mct = 1; } if (comment_text) @@ -501,6 +498,50 @@ public: parameters.prog_order = OPJ_RLCP; parameters.cp_disto_alloc = 1; + // if not lossless compression, computes tcp_numlayers and max_cs_size depending on the image dimensions + if( parameters.irreversible ) { + + // computes a number of layers + U32 surface = rawImageIn.getWidth() * rawImageIn.getHeight(); + U32 nb_layers = 1; + U32 s = 64*64; + while (surface > s) + { + nb_layers++; + s *= 4; + } + nb_layers = llclamp(nb_layers, 1, 6); + + parameters.tcp_numlayers = nb_layers; + parameters.tcp_rates[nb_layers - 1] = (U32)(1.f / DEFAULT_COMPRESSION_RATE); // 1:8 by default + + // for each subsequent layer, computes its rate and adds surface * numcomps * 1/rate to the max_cs_size + U32 max_cs_size = (U32)(surface * image->numcomps * DEFAULT_COMPRESSION_RATE); + U32 multiplier; + for (int i = nb_layers - 2; i >= 0; i--) + { + if( i == nb_layers - 2 ) + { + multiplier = 15; + } + else if( i == nb_layers - 3 ) + { + multiplier = 4; + } + else + { + multiplier = 2; + } + parameters.tcp_rates[i] = parameters.tcp_rates[i + 1] * multiplier; + max_cs_size += (U32)(surface * image->numcomps * (1 / parameters.tcp_rates[i])); + } + + //ensure that we have at least a minimal size + max_cs_size = llmax(max_cs_size, (U32)FIRST_PACKET_SIZE); + + parameters.max_cs_size = max_cs_size; + } + if (!opj_setup_encoder(encoder, ¶meters, image)) { return false; @@ -557,7 +598,7 @@ public: { // "append" (set) the data we "streamed" (memcopied) for writing to the formatted image // with side-effect of setting the actually encoded size to same - compressedImageOut.allocateData(offset); + compressedImageOut.allocateData((S32)offset); memcpy(compressedImageOut.getData(), buffer, offset); compressedImageOut.updateData(); // update width, height etc from header } diff --git a/indra/llinventory/llparcel.cpp b/indra/llinventory/llparcel.cpp index ef6ddb3cab..71dc8cff34 100644 --- a/indra/llinventory/llparcel.cpp +++ b/indra/llinventory/llparcel.cpp @@ -1268,7 +1268,7 @@ void LLParcel::setExperienceKeyType( const LLUUID& experience_key, U32 type ) U32 LLParcel::countExperienceKeyType( U32 type ) { - return std::count_if( + return (U32)std::count_if( boost::begin(mExperienceKeys | boost::adaptors::map_values), boost::end(mExperienceKeys | boost::adaptors::map_values), [type](U32 key){ return (key == type); }); diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index c1893eff41..7b55fbc9e8 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -278,11 +278,11 @@ LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD { case LLSD::TypeInteger: // lerp between the two values rounding the result to the nearest integer. - new_value = LLSD::Integer(llroundf(lerp(value.asReal(), other_value.asReal(), mix))); + new_value = LLSD::Integer(llroundf(lerp((F32)value.asReal(), (F32)other_value.asReal(), (F32)mix))); break; case LLSD::TypeReal: // lerp between the two values. - new_value = LLSD::Real(lerp(value.asReal(), other_value.asReal(), mix)); + new_value = LLSD::Real(lerp((F32)value.asReal(), (F32)other_value.asReal(), (F32)mix)); break; case LLSD::TypeMap: // deep copy. @@ -297,7 +297,7 @@ LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD { LLQuaternion a(value); LLQuaternion b(other_value); - LLQuaternion q = slerp(mix, a, b); + LLQuaternion q = slerp((F32)mix, a, b); new_array = q.getValue(); } else @@ -308,7 +308,7 @@ LLSD LLSettingsBase::interpolateSDValue(const std::string& key_name, const LLSD for (size_t i = 0; i < len; ++i) { - new_array[i] = lerp(value[i].asReal(), other_value[i].asReal(), mix); + new_array[i] = lerp((F32)value[i].asReal(), (F32)other_value[i].asReal(), (F32)mix); } } @@ -693,7 +693,7 @@ void LLSettingsBlender::update(const LLSettingsBase::BlendFactor& blendf) F64 LLSettingsBlender::setBlendFactor(const LLSettingsBase::BlendFactor& blendf_in) { - LLSettingsBase::TrackPosition blendf = blendf_in; + LLSettingsBase::TrackPosition blendf = (F32)blendf_in; llassert(!isnan(blendf)); if (blendf >= 1.0) { @@ -744,7 +744,7 @@ bool LLSettingsBlenderTimeDelta::applyTimeDelta(const LLSettingsBase::Seconds& t return false; } - LLSettingsBase::BlendFactor blendf = calculateBlend(mTimeSpent, mBlendSpan); + LLSettingsBase::BlendFactor blendf = calculateBlend((F32)mTimeSpent.value(), mBlendSpan); if (fabs(mLastBlendF - blendf) < mBlendFMinDelta) { diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h index a5499c4eb6..9d8d746b7e 100644 --- a/indra/llinventory/llsettingsbase.h +++ b/indra/llinventory/llsettingsbase.h @@ -475,7 +475,7 @@ public: LLSettingsBlenderTimeDelta(const LLSettingsBase::ptr_t &target, const LLSettingsBase::ptr_t &initsetting, const LLSettingsBase::ptr_t &endsetting, const LLSettingsBase::Seconds& blend_span) : LLSettingsBlender(target, initsetting, endsetting), - mBlendSpan(blend_span), + mBlendSpan((F32)blend_span.value()), mLastUpdate(0.0f), mTimeSpent(0.0f), mBlendFMinDelta(MIN_BLEND_DELTA), diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 2ff1cc74c6..abf746ef2c 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -500,7 +500,7 @@ namespace continue; } - LLSettingsBase::TrackPosition frame = elem[LLSettingsDay::SETTING_KEYKFRAME].asReal(); + LLSettingsBase::TrackPosition frame = (F32)elem[LLSettingsDay::SETTING_KEYKFRAME].asReal(); if ((frame < 0.0) || (frame > 1.0)) { frame = llclamp(frame, 0.0f, 1.0f); diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index e14b2f25ed..cbec2f4906 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -480,19 +480,19 @@ void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) // If there is no cloud texture in destination, reduce coverage to imitate disappearance // See LLDrawPoolWLSky::renderSkyClouds... we don't blend present texture with null // Note: Probably can be done by shader - cloud_shadow = lerp(mSettings[SETTING_CLOUD_SHADOW].asReal(), (F64)0.f, blendf); + cloud_shadow = lerp((F32)mSettings[SETTING_CLOUD_SHADOW].asReal(), 0.f, (F32)blendf); cloud_noise_id_next = cloud_noise_id; } else if (cloud_noise_id.isNull() && !cloud_noise_id_next.isNull()) { // Source has no cloud texture, reduce initial coverage to imitate appearance // use same texture as destination - cloud_shadow = lerp((F64)0.f, other->mSettings[SETTING_CLOUD_SHADOW].asReal(), blendf); + cloud_shadow = lerp(0.f, (F32)other->mSettings[SETTING_CLOUD_SHADOW].asReal(), (F32)blendf); setCloudNoiseTextureId(cloud_noise_id_next); } else { - cloud_shadow = lerp(mSettings[SETTING_CLOUD_SHADOW].asReal(), other->mSettings[SETTING_CLOUD_SHADOW].asReal(), blendf); + cloud_shadow = lerp((F32)mSettings[SETTING_CLOUD_SHADOW].asReal(), (F32)other->mSettings[SETTING_CLOUD_SHADOW].asReal(), (F32)blendf); } LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, other->getParameterMap(), blendf); @@ -923,8 +923,8 @@ LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy) if (legacy.has(SETTING_LEGACY_EAST_ANGLE) && legacy.has(SETTING_LEGACY_SUN_ANGLE)) { // get counter-clockwise radian angle from clockwise legacy WL east angle... - F32 azimuth = -legacy[SETTING_LEGACY_EAST_ANGLE].asReal(); - F32 altitude = legacy[SETTING_LEGACY_SUN_ANGLE].asReal(); + F32 azimuth = -(F32)legacy[SETTING_LEGACY_EAST_ANGLE].asReal(); + F32 altitude = (F32)legacy[SETTING_LEGACY_SUN_ANGLE].asReal(); LLQuaternion sunquat = convert_azimuth_and_altitude_to_quat(azimuth, altitude); // original WL moon dir was diametrically opposed to the sun dir @@ -958,7 +958,7 @@ void LLSettingsSky::updateSettings() F32 LLSettingsSky::getSunMoonGlowFactor() const { return getIsSunUp() ? 1.0f : - getIsMoonUp() ? getMoonBrightness() * 0.25 : 0.0f; + getIsMoonUp() ? getMoonBrightness() * 0.25f : 0.0f; } bool LLSettingsSky::getIsSunUp() const @@ -1043,11 +1043,11 @@ F32 LLSettingsSky::getFloat(const std::string& key, F32 default_value) const LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(key)) { - return mSettings[SETTING_LEGACY_HAZE][key].asReal(); + return (F32)mSettings[SETTING_LEGACY_HAZE][key].asReal(); } if (mSettings.has(key)) { - return mSettings[key].asReal(); + return (F32)mSettings[key].asReal(); } return default_value; } @@ -1307,7 +1307,7 @@ void LLSettingsSky::clampColor(LLColor3& color, F32 gamma, F32 scale) const color *= scale/max_color; } LLColor3 linear(color); - linear *= 1.0 / scale; + linear *= 1.0f / scale; linear = smear(1.0f) - linear; linear = componentPow(linear, gamma); linear *= scale; @@ -1353,7 +1353,7 @@ void LLSettingsSky::calculateLightSettings() const F32 haze_horizon = getHazeHorizon(); - sunlight *= 1.0 - cloud_shadow; + sunlight *= 1.0f - cloud_shadow; sunlight += tmpAmbient; mHazeColor = getBlueHorizon() * getBlueDensity() * sunlight; @@ -1415,22 +1415,22 @@ LLUUID LLSettingsSky::GetDefaultHaloTextureId() F32 LLSettingsSky::getPlanetRadius() const { - return mSettings[SETTING_PLANET_RADIUS].asReal(); + return (F32)mSettings[SETTING_PLANET_RADIUS].asReal(); } F32 LLSettingsSky::getSkyMoistureLevel() const { - return mSettings[SETTING_SKY_MOISTURE_LEVEL].asReal(); + return (F32)mSettings[SETTING_SKY_MOISTURE_LEVEL].asReal(); } F32 LLSettingsSky::getSkyDropletRadius() const { - return mSettings[SETTING_SKY_DROPLET_RADIUS].asReal(); + return (F32)mSettings[SETTING_SKY_DROPLET_RADIUS].asReal(); } F32 LLSettingsSky::getSkyIceLevel() const { - return mSettings[SETTING_SKY_ICE_LEVEL].asReal(); + return (F32)mSettings[SETTING_SKY_ICE_LEVEL].asReal(); } F32 LLSettingsSky::getReflectionProbeAmbiance(bool auto_adjust) const @@ -1440,27 +1440,27 @@ F32 LLSettingsSky::getReflectionProbeAmbiance(bool auto_adjust) const return sAutoAdjustProbeAmbiance; } - return mSettings[SETTING_REFLECTION_PROBE_AMBIANCE].asReal(); + return (F32)mSettings[SETTING_REFLECTION_PROBE_AMBIANCE].asReal(); } F32 LLSettingsSky::getSkyBottomRadius() const { - return mSettings[SETTING_SKY_BOTTOM_RADIUS].asReal(); + return (F32)mSettings[SETTING_SKY_BOTTOM_RADIUS].asReal(); } F32 LLSettingsSky::getSkyTopRadius() const { - return mSettings[SETTING_SKY_TOP_RADIUS].asReal(); + return (F32)mSettings[SETTING_SKY_TOP_RADIUS].asReal(); } F32 LLSettingsSky::getSunArcRadians() const { - return mSettings[SETTING_SUN_ARC_RADIANS].asReal(); + return (F32)mSettings[SETTING_SUN_ARC_RADIANS].asReal(); } F32 LLSettingsSky::getMieAnisotropy() const { - return getMieConfig()[SETTING_MIE_ANISOTROPY_FACTOR].asReal(); + return (F32)getMieConfig()[SETTING_MIE_ANISOTROPY_FACTOR].asReal(); } LLSD LLSettingsSky::getRayleighConfig() const @@ -1569,7 +1569,7 @@ void LLSettingsSky::setCloudPosDensity2(const LLColor3 &val) F32 LLSettingsSky::getCloudScale() const { - return mSettings[SETTING_CLOUD_SCALE].asReal(); + return (F32)mSettings[SETTING_CLOUD_SCALE].asReal(); } void LLSettingsSky::setCloudScale(F32 val) @@ -1601,7 +1601,7 @@ void LLSettingsSky::setCloudScrollRateY(F32 val) F32 LLSettingsSky::getCloudShadow() const { - return mSettings[SETTING_CLOUD_SHADOW].asReal(); + return (F32)mSettings[SETTING_CLOUD_SHADOW].asReal(); } void LLSettingsSky::setCloudShadow(F32 val) @@ -1611,7 +1611,7 @@ void LLSettingsSky::setCloudShadow(F32 val) F32 LLSettingsSky::getCloudVariance() const { - return mSettings[SETTING_CLOUD_VARIANCE].asReal(); + return (F32)mSettings[SETTING_CLOUD_VARIANCE].asReal(); } void LLSettingsSky::setCloudVariance(F32 val) @@ -1621,7 +1621,7 @@ void LLSettingsSky::setCloudVariance(F32 val) F32 LLSettingsSky::getDomeOffset() const { - //return mSettings[SETTING_DOME_OFFSET].asReal(); + //return (F32)mSettings[SETTING_DOME_OFFSET].asReal(); return DOME_OFFSET; } @@ -1633,7 +1633,7 @@ F32 LLSettingsSky::getDomeRadius() const F32 LLSettingsSky::getGamma() const { - return mSettings[SETTING_GAMMA].asReal(); + return (F32)mSettings[SETTING_GAMMA].asReal(); } void LLSettingsSky::setGamma(F32 val) @@ -1654,7 +1654,7 @@ void LLSettingsSky::setGlow(const LLColor3 &val) F32 LLSettingsSky::getMaxY() const { - return mSettings[SETTING_MAX_Y].asReal(); + return (F32)mSettings[SETTING_MAX_Y].asReal(); } void LLSettingsSky::setMaxY(F32 val) @@ -1674,7 +1674,7 @@ void LLSettingsSky::setMoonRotation(const LLQuaternion &val) F32 LLSettingsSky::getMoonScale() const { - return mSettings[SETTING_MOON_SCALE].asReal(); + return (F32)mSettings[SETTING_MOON_SCALE].asReal(); } void LLSettingsSky::setMoonScale(F32 val) @@ -1692,9 +1692,9 @@ void LLSettingsSky::setMoonTextureId(LLUUID id) setValue(SETTING_MOON_TEXTUREID, id); } -F32 LLSettingsSky::getMoonBrightness() const +F32 LLSettingsSky::getMoonBrightness() const { - return mSettings[SETTING_MOON_BRIGHTNESS].asReal(); + return (F32)mSettings[SETTING_MOON_BRIGHTNESS].asReal(); } void LLSettingsSky::setMoonBrightness(F32 brightness_factor) @@ -1704,7 +1704,7 @@ void LLSettingsSky::setMoonBrightness(F32 brightness_factor) F32 LLSettingsSky::getStarBrightness() const { - return mSettings[SETTING_STAR_BRIGHTNESS].asReal(); + return (F32)mSettings[SETTING_STAR_BRIGHTNESS].asReal(); } void LLSettingsSky::setStarBrightness(F32 val) @@ -1749,7 +1749,7 @@ void LLSettingsSky::setSunRotation(const LLQuaternion &val) F32 LLSettingsSky::getSunScale() const { - return mSettings[SETTING_SUN_SCALE].asReal(); + return (F32)mSettings[SETTING_SUN_SCALE].asReal(); } void LLSettingsSky::setSunScale(F32 val) diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h index 0b29d8ca19..9e7ff61272 100644 --- a/indra/llinventory/llsettingswater.h +++ b/indra/llinventory/llsettingswater.h @@ -72,7 +72,7 @@ public: //--------------------------------------------------------------------- F32 getBlurMultiplier() const { - return mSettings[SETTING_BLUR_MULTIPLIER].asReal(); + return (F32)mSettings[SETTING_BLUR_MULTIPLIER].asReal(); } void setBlurMultiplier(F32 val) @@ -92,7 +92,7 @@ public: F32 getWaterFogDensity() const { - return mSettings[SETTING_FOG_DENSITY].asReal(); + return (F32)mSettings[SETTING_FOG_DENSITY].asReal(); } F32 getModifiedWaterFogDensity(bool underwater) const; @@ -104,7 +104,7 @@ public: F32 getFogMod() const { - return mSettings[SETTING_FOG_MOD].asReal(); + return (F32)mSettings[SETTING_FOG_MOD].asReal(); } void setFogMod(F32 val) @@ -114,7 +114,7 @@ public: F32 getFresnelOffset() const { - return mSettings[SETTING_FRESNEL_OFFSET].asReal(); + return (F32)mSettings[SETTING_FRESNEL_OFFSET].asReal(); } void setFresnelOffset(F32 val) @@ -124,7 +124,7 @@ public: F32 getFresnelScale() const { - return mSettings[SETTING_FRESNEL_SCALE].asReal(); + return (F32)mSettings[SETTING_FRESNEL_SCALE].asReal(); } void setFresnelScale(F32 val) @@ -164,7 +164,7 @@ public: F32 getScaleAbove() const { - return mSettings[SETTING_SCALE_ABOVE].asReal(); + return (F32)mSettings[SETTING_SCALE_ABOVE].asReal(); } void setScaleAbove(F32 val) @@ -174,7 +174,7 @@ public: F32 getScaleBelow() const { - return mSettings[SETTING_SCALE_BELOW].asReal(); + return (F32)mSettings[SETTING_SCALE_BELOW].asReal(); } void setScaleBelow(F32 val) diff --git a/indra/llinventory/tests/inventorymisc_test.cpp b/indra/llinventory/tests/inventorymisc_test.cpp index bcf6131bd8..9779cb8fbc 100644 --- a/indra/llinventory/tests/inventorymisc_test.cpp +++ b/indra/llinventory/tests/inventorymisc_test.cpp @@ -61,7 +61,7 @@ LLPointer<LLInventoryItem> create_random_inventory_item() S32 price = rand(); LLSaleInfo sale_info(LLSaleInfo::FS_COPY, price); U32 flags = rand(); - S32 creation = time(NULL); + S32 creation = (S32)time(NULL); LLPointer<LLInventoryItem> item = new LLInventoryItem( item_id, @@ -195,7 +195,7 @@ namespace tut src->setSaleInfo(new_sale_info); U32 new_flags = rand(); - S32 new_creation = time(NULL); + S32 new_creation = (S32)time(NULL); LLPermissions new_perm; @@ -266,7 +266,7 @@ namespace tut src->setSaleInfo(new_sale_info); U32 new_flags = rand(); - S32 new_creation = time(NULL); + S32 new_creation = (S32)time(NULL); LLPermissions new_perm; diff --git a/indra/llmath/llcalcparser.h b/indra/llmath/llcalcparser.h index e8fdcc9ae3..ea71752ebc 100644 --- a/indra/llmath/llcalcparser.h +++ b/indra/llmath/llcalcparser.h @@ -175,7 +175,7 @@ private: F32 _exp(const F32& a) const { return exp(a); } F32 _fabs(const F32& a) const { return fabs(a); } F32 _floor(const F32& a) const { return (F32)llfloor(a); } - F32 _ceil(const F32& a) const { return llceil(a); } + F32 _ceil(const F32& a) const { return (F32)llceil(a); } F32 _atan2(const F32& a,const F32& b) const { return atan2(a,b); } LLCalc::calc_map_t* mConstants; diff --git a/indra/llmath/llquaternion.h b/indra/llmath/llquaternion.h index 6136c59ed1..762d13eded 100644 --- a/indra/llmath/llquaternion.h +++ b/indra/llmath/llquaternion.h @@ -186,10 +186,10 @@ inline LLSD LLQuaternion::getValue() const inline void LLQuaternion::setValue(const LLSD& sd) { - mQ[0] = sd[0].asReal(); - mQ[1] = sd[1].asReal(); - mQ[2] = sd[2].asReal(); - mQ[3] = sd[3].asReal(); + mQ[0] = (F32)sd[0].asReal(); + mQ[1] = (F32)sd[1].asReal(); + mQ[2] = (F32)sd[2].asReal(); + mQ[3] = (F32)sd[3].asReal(); } // checker diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index f3db9424d9..56ac22ca18 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -734,7 +734,7 @@ S32 LLProfile::getNumPoints(const LLProfileParams& params, bool path_open,F32 de bool LLProfile::generate(const LLProfileParams& params, bool path_open,F32 detail, S32 split, bool is_sculpted, S32 sculpt_size) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; if ((!mDirty) && (!is_sculpted)) { @@ -1216,7 +1216,7 @@ S32 LLPath::getNumNGonPoints(const LLPathParams& params, S32 sides, F32 startOff void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 end_scale, F32 twist_scale) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; // Generates a circular path, starting at (1, 0, 0), counterclockwise along the xz plane. constexpr F32 tableScale[] = { 1, 1, 1, 0.5f, 0.707107f, 0.53f, 0.525f, 0.5f }; @@ -1452,7 +1452,7 @@ S32 LLPath::getNumPoints(const LLPathParams& params, F32 detail) bool LLPath::generate(const LLPathParams& params, F32 detail, S32 split, bool is_sculpted, S32 sculpt_size) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; if ((!mDirty) && (!is_sculpted)) { @@ -2029,7 +2029,7 @@ LLVolume::~LLVolume() bool LLVolume::generate() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; LL_CHECK_MEMORY llassert_always(mProfilep); @@ -2289,7 +2289,7 @@ bool LLVolumeFace::VertexData::compareNormal(const LLVolumeFace::VertexData& rhs bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; //input stream is now pointing at a zlib compressed block of LLSD //decompress block @@ -2345,11 +2345,11 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl) continue; } - LLSD::Binary pos = mdl[i]["Position"]; - LLSD::Binary norm = mdl[i]["Normal"]; - LLSD::Binary tangent = mdl[i]["Tangent"]; - LLSD::Binary tc = mdl[i]["TexCoord0"]; - LLSD::Binary idx = mdl[i]["TriangleList"]; + const LLSD::Binary& pos = mdl[i]["Position"].asBinary(); + const LLSD::Binary& norm = mdl[i]["Normal"].asBinary(); + const LLSD::Binary& tangent = mdl[i]["Tangent"].asBinary(); + const LLSD::Binary& tc = mdl[i]["TexCoord0"].asBinary(); + const LLSD::Binary& idx = mdl[i]["TriangleList"].asBinary(); //copy out indices auto num_indices = idx.size() / 2; @@ -2538,7 +2538,7 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl) continue; } - LLSD::Binary weights = mdl[i]["Weights"]; + const LLSD::Binary& weights = mdl[i]["Weights"].asBinary(); U32 idx = 0; @@ -2776,7 +2776,7 @@ S32 LLVolume::getNumFaces() const void LLVolume::createVolumeFaces() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; if (mGenerateSingleFace) { @@ -3741,7 +3741,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices, const LLMatrix3& norm_mat_in, S32 face_mask) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; LLMatrix4a mat; mat.loadu(mat_in); @@ -4870,7 +4870,7 @@ void LLVolumeFace::freeData() bool LLVolumeFace::create(LLVolume* volume, bool partial_build) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; //tree for this face is no longer valid destroyOctree(); @@ -5462,7 +5462,11 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents) U32 stream_count = data.w.empty() ? 4 : 5; - S32 vert_count = static_cast<S32>(meshopt_generateVertexRemapMulti(&remap[0], nullptr, data.p.size(), data.p.size(), mos, stream_count)); + S32 vert_count = 0; + if (!data.p.empty()) + { + vert_count = static_cast<S32>(meshopt_generateVertexRemapMulti(&remap[0], nullptr, data.p.size(), data.p.size(), mos, stream_count)); + } if (vert_count < 65535 && vert_count != 0) { @@ -5545,7 +5549,7 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents) void LLVolumeFace::createOctree(F32 scaler, const LLVector4a& center, const LLVector4a& size) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; if (getOctree()) { @@ -6556,7 +6560,7 @@ void LLVolumeFace::fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v, bool LLVolumeFace::createSide(LLVolume* volume, bool partial_build) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; LL_CHECK_MEMORY bool flat = mTypeMask & FLAT_MASK; @@ -7090,7 +7094,7 @@ bool LLVolumeFace::createSide(LLVolume* volume, bool partial_build) void LLCalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVector4a *normal, const LLVector2 *texcoord, U32 triangleCount, const U16* index_array, LLVector4a *tangent) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; //LLVector4a *tan1 = new LLVector4a[vertexCount * 2]; LLVector4a* tan1 = (LLVector4a*) ll_aligned_malloc_16(vertexCount*2*sizeof(LLVector4a)); diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h index 05d45f7b5f..1d74644715 100644 --- a/indra/llmath/llvolumeoctree.h +++ b/indra/llmath/llvolumeoctree.h @@ -143,7 +143,7 @@ public: virtual void visit(const LLOctreeNode<LLVolumeTriangle, LLVolumeTriangle*>* branch) { //this is a depth first traversal, so it's safe to assum all children have complete //bounding data - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; LLVolumeOctreeListener* node = (LLVolumeOctreeListener*)branch->getListener(0); diff --git a/indra/llmath/v3color.h b/indra/llmath/v3color.h index 7b92f85a0c..821c17f03d 100644 --- a/indra/llmath/v3color.h +++ b/indra/llmath/v3color.h @@ -517,9 +517,9 @@ inline const LLVector3 linearColor3v(const T& a) { template<typename T> const LLColor3& LLColor3::set(const std::vector<T>& v) { - for (S32 i = 0; i < llmin((S32)v.size(), 3); ++i) + for (size_t i = 0; i < llmin(v.size(), 3); ++i) { - mV[i] = v[i]; + mV[i] = (F32)v[i]; } return *this; @@ -530,9 +530,9 @@ const LLColor3& LLColor3::set(const std::vector<T>& v) template<typename T> void LLColor3::write(std::vector<T>& v) const { - for (int i = 0; i < llmin((S32)v.size(), 3); ++i) + for (size_t i = 0; i < llmin(v.size(), 3); ++i) { - v[i] = mV[i]; + v[i] = (T)mV[i]; } } diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index e9bb6a07ba..cafdbd9d7c 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -702,9 +702,9 @@ inline const LLColor4 linearColor4(const LLColor4 &a) template<typename T> const LLColor4& LLColor4::set(const std::vector<T>& v) { - for (S32 i = 0; i < llmin((S32)v.size(), 4); ++i) + for (size_t i = 0; i < llmin(v.size(), 4); ++i) { - mV[i] = v[i]; + mV[i] = (F32)v[i]; } return *this; @@ -713,9 +713,9 @@ const LLColor4& LLColor4::set(const std::vector<T>& v) template<typename T> void LLColor4::write(std::vector<T>& v) const { - for (int i = 0; i < llmin((S32)v.size(), 4); ++i) + for (size_t i = 0; i < llmin(v.size(), 4); ++i) { - v[i] = mV[i]; + v[i] = (T)mV[i]; } } diff --git a/indra/llmath/v4math.h b/indra/llmath/v4math.h index 7ed22212d3..a5b6f506d7 100644 --- a/indra/llmath/v4math.h +++ b/indra/llmath/v4math.h @@ -67,10 +67,10 @@ class LLVector4 void setValue(const LLSD& sd) { - mV[0] = sd[0].asReal(); - mV[1] = sd[1].asReal(); - mV[2] = sd[2].asReal(); - mV[3] = sd[3].asReal(); + mV[0] = (F32)sd[0].asReal(); + mV[1] = (F32)sd[1].asReal(); + mV[2] = (F32)sd[2].asReal(); + mV[3] = (F32)sd[3].asReal(); } diff --git a/indra/llmeshoptimizer/llmeshoptimizer.cpp b/indra/llmeshoptimizer/llmeshoptimizer.cpp index 52ed9b9526..7339454367 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.cpp +++ b/indra/llmeshoptimizer/llmeshoptimizer.cpp @@ -291,6 +291,7 @@ U64 LLMeshOptimizer::simplifyU32(U32 *destination, vertex_positions_stride, target_index_count, target_error, + 0, result_error ); } @@ -332,6 +333,7 @@ U64 LLMeshOptimizer::simplify(U16 *destination, vertex_positions_stride, target_index_count, target_error, + 0, result_error ); } diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index 5322139304..b2757a7306 100644 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -27,7 +27,6 @@ set(llmessage_SOURCE_FILES lldatapacker.cpp lldispatcher.cpp llexperiencecache.cpp - llfiltersd2xmlrpc.cpp llgenericstreamingmessage.cpp llhost.cpp llhttpnode.cpp @@ -111,7 +110,6 @@ set(llmessage_HEADER_FILES lleventflags.h llexperiencecache.h llextendedstatus.h - llfiltersd2xmlrpc.h llfollowcamparams.h llgenericstreamingmessage.h llhost.h @@ -193,7 +191,6 @@ target_link_libraries( llfilesystem llmath llcorehttp - ll::xmlrpc-epi ) target_include_directories( llmessage INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp index 70a7a34a70..2de59c1b6a 100644 --- a/indra/llmessage/llassetstorage.cpp +++ b/indra/llmessage/llassetstorage.cpp @@ -484,6 +484,8 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, void *user_data, bool is_priority) { + LL_PROFILE_ZONE_SCOPED; + LL_DEBUGS("AssetStorage") << "LLAssetStorage::getAssetData() - " << uuid << "," << LLAssetType::lookup(type) << LL_ENDL; LL_DEBUGS("AssetStorage") << "ASSET_TRACE requesting " << uuid << " type " << LLAssetType::lookup(type) << LL_ENDL; @@ -529,6 +531,7 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, if (size > 0) { + LL_PROFILE_ZONE_NAMED("gad - file in cache"); // we've already got the file // theoretically, partial files w/o a pending request shouldn't happen // unless there's a weird error @@ -548,7 +551,7 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, } bool duplicate = false; - + LL_PROFILE_ZONE_NAMED("gad - check pending downloads"); // check to see if there's a pending download of this uuid already for (request_list_t::iterator iter = mPendingDownloads.begin(); iter != mPendingDownloads.end(); ++iter ) diff --git a/indra/llmessage/llbuffer.cpp b/indra/llmessage/llbuffer.cpp index dc7115b167..3a4b493b26 100644 --- a/indra/llmessage/llbuffer.cpp +++ b/indra/llmessage/llbuffer.cpp @@ -142,7 +142,7 @@ LLHeapBuffer::~LLHeapBuffer() S32 LLHeapBuffer::bytesLeft() const { - return (mSize - (mNextFree - mBuffer)); + return (mSize - (S32)(mNextFree - mBuffer)); } // virtual @@ -371,11 +371,11 @@ LLBufferArray::segment_iterator_t LLBufferArray::splitAfter(U8* address) return it; } S32 channel = (*it).getChannel(); - LLSegment segment1(channel, base, (address - base) + 1); + LLSegment segment1(channel, base, (S32)((address - base) + 1)); *it = segment1; segment_iterator_t rv = it; ++it; - LLSegment segment2(channel, address + 1, size - (address - base) - 1); + LLSegment segment2(channel, address + 1, (S32)(size - (address - base) - 1)); mSegments.insert(it, segment2); return rv; } @@ -424,7 +424,7 @@ LLBufferArray::segment_iterator_t LLBufferArray::constructSegmentAfter( segment = LLSegment( (*rv).getChannel(), address, - (*rv).size() - (address - (*rv).data())); + (*rv).size() - (S32)(address - (*rv).data())); } else { @@ -533,7 +533,7 @@ S32 LLBufferArray::countAfter(S32 channel, U8* start) const if(++start < ((*it).data() + (*it).size())) { // it's in the same segment - offset = start - (*it).data(); + offset = (S32)(start - (*it).data()); } else if(++it == end) { @@ -586,7 +586,7 @@ U8* LLBufferArray::readAfter( && (*it).isOnChannel(channel)) { // copy the data out of this segment - S32 bytes_in_segment = (*it).size() - (start - (*it).data()); + S32 bytes_in_segment = (*it).size() - (S32)(start - (*it).data()); bytes_to_copy = llmin(bytes_left, bytes_in_segment); memcpy(dest, start, bytes_to_copy); /*Flawfinder: ignore*/ len += bytes_to_copy; @@ -681,7 +681,7 @@ U8* LLBufferArray::seek( { if(delta > 0) { - S32 bytes_in_segment = (*it).size() - (start - (*it).data()); + S32 bytes_in_segment = (*it).size() - (S32)(start - (*it).data()); S32 local_delta = llmin(delta, bytes_in_segment); rv += local_delta; delta -= local_delta; @@ -689,7 +689,7 @@ U8* LLBufferArray::seek( } else { - S32 bytes_in_segment = start - (*it).data(); + S32 bytes_in_segment = (S32)(start - (*it).data()); S32 local_delta = llmin(llabs(delta), bytes_in_segment); rv -= local_delta; delta += local_delta; diff --git a/indra/llmessage/llbufferstream.cpp b/indra/llmessage/llbufferstream.cpp index e51b489813..2c745f6fe4 100644 --- a/indra/llmessage/llbufferstream.cpp +++ b/indra/llmessage/llbufferstream.cpp @@ -273,7 +273,7 @@ streampos LLBufferStreamBuf::seekoff( } LLMutexLock lock(mBuffer->getMutex()); - address = mBuffer->seek(mChannels.in(), base_addr, off); + address = mBuffer->seek(mChannels.in(), base_addr, (S32)off); if(address) { LLBufferArray::segment_iterator_t iter; @@ -306,7 +306,7 @@ streampos LLBufferStreamBuf::seekoff( } LLMutexLock lock(mBuffer->getMutex()); - address = mBuffer->seek(mChannels.out(), base_addr, off); + address = mBuffer->seek(mChannels.out(), base_addr, (S32)off); if(address) { LLBufferArray::segment_iterator_t iter; diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index 63ac46722a..64f660d0ce 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -53,7 +53,6 @@ const U32 PENDING_TIMEOUT_SECS = 5 * 60; // Globals LLCacheName* gCacheName = NULL; -std::map<std::string, std::string> LLCacheName::sCacheName; /// --------------------------------------------------------------------------- /// class LLCacheNameEntry @@ -215,7 +214,7 @@ public: Impl(LLMessageSystem* msg); ~Impl(); - bool getName(const LLUUID& id, std::string& first, std::string& last); + bool getName(const LLUUID& id, std::string& first, std::string& last, std::map<std::string, std::string>& default_names); boost::signals2::connection addPending(const LLUUID& id, const LLCacheNameCallback& callback); void addPending(const LLUUID& id, const LLHost& host); @@ -247,9 +246,9 @@ LLCacheName::LLCacheName(LLMessageSystem* msg) LLCacheName::LLCacheName(LLMessageSystem* msg, const LLHost& upstream_host) : impl(* new Impl(msg)) { - sCacheName["waiting"] = "(Loading...)"; - sCacheName["nobody"] = "(nobody)"; - sCacheName["none"] = "(none)"; + mCacheName["waiting"] = "(Loading...)"; + mCacheName["nobody"] = "(nobody)"; + mCacheName["none"] = "(none)"; setUpstream(upstream_host); } @@ -274,7 +273,7 @@ LLCacheName::Impl::Impl(LLMessageSystem* msg) LLCacheName::Impl::~Impl() { - for_each(mCache.begin(), mCache.end(), DeletePairedPointer()); + std::for_each(mCache.begin(), mCache.end(), DeletePairedPointer()); mCache.clear(); for_each(mReplyQueue.begin(), mReplyQueue.end(), DeletePointer()); mReplyQueue.clear(); @@ -402,11 +401,11 @@ void LLCacheName::exportFile(std::ostream& ostr) } -bool LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::string& last) +bool LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::string& last, std::map<std::string, std::string>& default_names) { if(id.isNull()) { - first = sCacheName["nobody"]; + first = default_names["nobody"]; last.clear(); return true; } @@ -420,7 +419,7 @@ bool LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::strin } else { - first = sCacheName["waiting"]; + first = default_names["waiting"]; last.clear(); if (!isRequestPending(id)) { @@ -434,8 +433,8 @@ bool LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::strin // static void LLCacheName::localizeCacheName(std::string key, std::string value) { - if (key!="" && value!= "" ) - sCacheName[key]=value; + if (!key.empty() && !value.empty()) + mCacheName[key]=value; else LL_WARNS()<< " Error localizing cache key " << key << " To "<< value<<LL_ENDL; } @@ -443,7 +442,7 @@ void LLCacheName::localizeCacheName(std::string key, std::string value) bool LLCacheName::getFullName(const LLUUID& id, std::string& fullname) { std::string first_name, last_name; - bool res = impl.getName(id, first_name, last_name); + bool res = impl.getName(id, first_name, last_name, mCacheName); fullname = buildFullName(first_name, last_name); return res; } @@ -454,7 +453,7 @@ bool LLCacheName::getGroupName(const LLUUID& id, std::string& group) { if(id.isNull()) { - group = sCacheName["none"]; + group = mCacheName["none"]; return true; } @@ -475,7 +474,7 @@ bool LLCacheName::getGroupName(const LLUUID& id, std::string& group) } else { - group = sCacheName["waiting"]; + group = mCacheName["waiting"]; if (!impl.isRequestPending(id)) { impl.mAskGroupQueue.insert(id); @@ -614,7 +613,7 @@ boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, co { LLCacheNameSignal signal; signal.connect(callback); - signal(id, sCacheName["nobody"], is_group); + signal(id, mCacheName["nobody"], is_group); return res; } @@ -754,14 +753,14 @@ void LLCacheName::dumpStats() void LLCacheName::clear() { - for_each(impl.mCache.begin(), impl.mCache.end(), DeletePairedPointer()); + std::for_each(impl.mCache.begin(), impl.mCache.end(), DeletePairedPointer()); impl.mCache.clear(); } //static std::string LLCacheName::getDefaultName() { - return sCacheName["waiting"]; + return mCacheName["waiting"]; } //static diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h index 1df713c7c7..609387b6de 100644 --- a/indra/llmessage/llcachename.h +++ b/indra/llmessage/llcachename.h @@ -127,15 +127,16 @@ public: void dumpStats(); // Dumps the sizes of the cache and associated queues. void clear(); // Deletes all entries from the cache - static std::string getDefaultName(); + std::string getDefaultName(); // Returns "Resident", the default last name for SLID-based accounts // that have no last name. static std::string getDefaultLastName(); - static void localizeCacheName(std::string key, std::string value); - static std::map<std::string, std::string> sCacheName; + void localizeCacheName(std::string key, std::string value); + private: + std::map<std::string, std::string> mCacheName; class Impl; Impl& impl; diff --git a/indra/llmessage/llcircuit.cpp b/indra/llmessage/llcircuit.cpp index bf22f3d3f0..8f9c02bdca 100644 --- a/indra/llmessage/llcircuit.cpp +++ b/indra/llmessage/llcircuit.cpp @@ -525,13 +525,13 @@ void LLCircuitData::checkPeriodTime() F64Seconds period_length = mt_sec - mPeriodTime; if ( period_length > TARGET_PERIOD_LENGTH) { - F32 bps_in = F32Bits(mBytesInThisPeriod).value() / period_length.value(); + F32 bps_in = F32Bits(mBytesInThisPeriod).value() / (F32)period_length.value(); if (bps_in > mPeakBPSIn) { mPeakBPSIn = bps_in; } - F32 bps_out = F32Bits(mBytesOutThisPeriod).value() / period_length.value(); + F32 bps_out = F32Bits(mBytesOutThisPeriod).value() / (F32)period_length.value(); if (bps_out > mPeakBPSOut) { mPeakBPSOut = bps_out; diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 684e96883f..3fdc691141 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -523,7 +523,7 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: bas >> std::noskipws; data.assign(std::istream_iterator<U8>(bas), std::istream_iterator<U8>()); - result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = data; + result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = std::move(data); #else // This is disabled because it's dangerous. See the other case for an diff --git a/indra/llmessage/llfiltersd2xmlrpc.cpp b/indra/llmessage/llfiltersd2xmlrpc.cpp deleted file mode 100644 index 84b56d54bf..0000000000 --- a/indra/llmessage/llfiltersd2xmlrpc.cpp +++ /dev/null @@ -1,778 +0,0 @@ -/** - * @file llfiltersd2xmlrpc.cpp - * @author Phoenix - * @date 2005-04-26 - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -/** - * xml rpc request: - * <code> - * <?xml version="1.0"?> - * <methodCall><methodName>examples.getStateName</methodName> - * <params><param><value><i4>41</i4></value></param></params> - * </methodCall> - * </code> - * - * xml rpc response: - * <code> - * <?xml version="1.0"?> - * <methodResponse> - * <params><param><value><string>South Dakota</string></value></param></params> - * </methodResponse> - * </code> - * - * xml rpc fault: - * </code> - * <?xml version="1.0"?> - * <methodResponse> - * <fault><value><struct> - * <member><name>faultCode</name><value><int>4</int></value></member> - * <member><name>faultString</name><value><string>...</string></value></member> - * </struct></value></fault> - * </methodResponse> - * </code> - * - * llsd rpc request: - * <code> - * { 'method':'...', 'parameter':...]} - * </code> - * - * llsd rpc response: - * <code> - * { 'response':... } - * </code> - * - * llsd rpc fault: - * <code> - * { 'fault': {'code':i..., 'description':'...'} } - * </code> - * - */ - -#include "linden_common.h" -#include "llfiltersd2xmlrpc.h" - -#include <sstream> -#include <iterator> - -#ifdef LL_USESYSTEMLIBS -#include <xmlrpc.h> -#else -#include <xmlrpc-epi/xmlrpc.h> -#endif - -#include "apr_base64.h" - -#include "llbuffer.h" -#include "llbufferstream.h" -#include "llfasttimer.h" -#include "llmemorystream.h" -#include "llsd.h" -#include "llsdserialize.h" -#include "lluuid.h" - -// spammy mode -//#define LL_SPEW_STREAM_OUT_DEBUGGING 1 - -/** - * String constants - */ -static const char XML_HEADER[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; -static const char XMLRPC_REQUEST_HEADER_1[] = "<methodCall><methodName>"; -static const char XMLRPC_REQUEST_HEADER_2[] = "</methodName><params>"; -static const char XMLRPC_REQUEST_FOOTER[] = "</params></methodCall>"; -static const char XMLRPC_METHOD_RESPONSE_HEADER[] = "<methodResponse>"; -static const char XMLRPC_METHOD_RESPONSE_FOOTER[] = "</methodResponse>"; -static const char XMLRPC_RESPONSE_HEADER[] = "<params><param>"; -static const char XMLRPC_RESPONSE_FOOTER[] = "</param></params>"; -static const char XMLRPC_FAULT_1[] = "<fault><value><struct><member><name>faultCode</name><value><int>"; -static const char XMLRPC_FAULT_2[] = "</int></value></member><member><name>faultString</name><value><string>"; -static const char XMLRPC_FAULT_3[] = "</string></value></member></struct></value></fault>"; -static const char LLSDRPC_RESPONSE_HEADER[] = "{'response':"; -static const char LLSDRPC_RESPONSE_FOOTER[] = "}"; -const char LLSDRPC_REQUEST_HEADER_1[] = "{'method':'"; -const char LLSDRPC_REQUEST_HEADER_2[] = "', 'parameter': "; -const char LLSDRPC_REQUEST_FOOTER[] = "}"; -static const char LLSDRPC_FAULT_HADER_1[] = "{ 'fault': {'code':i"; -static const char LLSDRPC_FAULT_HADER_2[] = ", 'description':"; -static const char LLSDRPC_FAULT_FOOTER[] = "} }"; -static const S32 DEFAULT_PRECISION = 20; - -/** - * LLFilterSD2XMLRPC - */ -LLFilterSD2XMLRPC::LLFilterSD2XMLRPC() -{ -} - -LLFilterSD2XMLRPC::~LLFilterSD2XMLRPC() -{ -} - -std::string xml_escape_string(const std::string& in) -{ - std::ostringstream out; - std::string::const_iterator it = in.begin(); - std::string::const_iterator end = in.end(); - for(; it != end; ++it) - { - switch((*it)) - { - case '<': - out << "<"; - break; - case '>': - out << ">"; - break; - case '&': - out << "&"; - break; - case '\'': - out << "'"; - break; - case '"': - out << """; - break; - default: - out << (*it); - break; - } - } - return out.str(); -} - -void LLFilterSD2XMLRPC::streamOut(std::ostream& ostr, const LLSD& sd) -{ - ostr << "<value>"; - switch(sd.type()) - { - case LLSD::TypeMap: - { -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(map) BEGIN" << LL_ENDL; -#endif - ostr << "<struct>"; - if(ostr.fail()) - { - LL_INFOS() << "STREAM FAILURE writing struct" << LL_ENDL; - } - LLSD::map_const_iterator it = sd.beginMap(); - LLSD::map_const_iterator end = sd.endMap(); - for(; it != end; ++it) - { - ostr << "<member><name>" << xml_escape_string((*it).first) - << "</name>"; - streamOut(ostr, (*it).second); - if(ostr.fail()) - { - LL_INFOS() << "STREAM FAILURE writing '" << (*it).first - << "' with sd type " << (*it).second.type() << LL_ENDL; - } - ostr << "</member>"; - } - ostr << "</struct>"; -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(map) END" << LL_ENDL; -#endif - break; - } - case LLSD::TypeArray: - { -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(array) BEGIN" << LL_ENDL; -#endif - ostr << "<array><data>"; - LLSD::array_const_iterator it = sd.beginArray(); - LLSD::array_const_iterator end = sd.endArray(); - for(; it != end; ++it) - { - streamOut(ostr, *it); - if(ostr.fail()) - { - LL_INFOS() << "STREAM FAILURE writing array element sd type " - << (*it).type() << LL_ENDL; - } - } -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(array) END" << LL_ENDL; -#endif - ostr << "</data></array>"; - break; - } - case LLSD::TypeUndefined: - // treat undefined as a bool with a false value. - case LLSD::TypeBoolean: -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(bool)" << LL_ENDL; -#endif - ostr << "<boolean>" << (sd.asBoolean() ? "1" : "0") << "</boolean>"; - break; - case LLSD::TypeInteger: -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(int)" << LL_ENDL; -#endif - ostr << "<i4>" << sd.asInteger() << "</i4>"; - break; - case LLSD::TypeReal: -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(real)" << LL_ENDL; -#endif - ostr << "<double>" << sd.asReal() << "</double>"; - break; - case LLSD::TypeString: -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(string)" << LL_ENDL; -#endif - ostr << "<string>" << xml_escape_string(sd.asString()) << "</string>"; - break; - case LLSD::TypeUUID: -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(uuid)" << LL_ENDL; -#endif - // serialize it as a string - ostr << "<string>" << sd.asString() << "</string>"; - break; - case LLSD::TypeURI: - { -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(uri)" << LL_ENDL; -#endif - // serialize it as a string - ostr << "<string>" << xml_escape_string(sd.asString()) << "</string>"; - break; - } - case LLSD::TypeBinary: - { -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(binary)" << LL_ENDL; -#endif - // this is pretty inefficient, but we'll deal with that - // problem when it becomes one. - ostr << "<base64>"; - LLSD::Binary buffer = sd.asBinary(); - if(!buffer.empty()) - { - // *TODO: convert to LLBase64 - int b64_buffer_length = apr_base64_encode_len(static_cast<int>(buffer.size())); - char* b64_buffer = new char[b64_buffer_length]; - b64_buffer_length = apr_base64_encode_binary( - b64_buffer, - &buffer[0], - static_cast<int>(buffer.size())); - ostr.write(b64_buffer, b64_buffer_length - 1); - delete[] b64_buffer; - } - ostr << "</base64>"; - break; - } - case LLSD::TypeDate: -#if LL_SPEW_STREAM_OUT_DEBUGGING - LL_INFOS() << "streamOut(date)" << LL_ENDL; -#endif - // no need to escape this since it will be alpha-numeric. - ostr << "<dateTime.iso8601>" << sd.asString() << "</dateTime.iso8601>"; - break; - default: - // unhandled type - LL_WARNS() << "Unhandled structured data type: " << sd.type() - << LL_ENDL; - break; - } - ostr << "</value>"; -} - -/** - * LLFilterSD2XMLRPCResponse - */ - -LLFilterSD2XMLRPCResponse::LLFilterSD2XMLRPCResponse() -{ -} - -LLFilterSD2XMLRPCResponse::~LLFilterSD2XMLRPCResponse() -{ -} - - -// virtual -LLIOPipe::EStatus LLFilterSD2XMLRPCResponse::process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump) -{ - LL_PROFILE_ZONE_SCOPED; - - PUMP_DEBUG; - // This pipe does not work if it does not have everyting. This - // could be addressed by making a stream parser for llsd which - // handled partial information. - if(!eos) - { - return STATUS_BREAK; - } - - PUMP_DEBUG; - // we have everyting in the buffer, so turn the structure data rpc - // response into an xml rpc response. - LLBufferStream stream(channels, buffer.get()); - stream << XML_HEADER << XMLRPC_METHOD_RESPONSE_HEADER; - LLSD sd; - LLSDSerialize::fromNotation(sd, stream, buffer->count(channels.in())); - - PUMP_DEBUG; - LLIOPipe::EStatus rv = STATUS_ERROR; - if(sd.has("response")) - { - PUMP_DEBUG; - // it is a normal response. pack it up and ship it out. - stream.precision(DEFAULT_PRECISION); - stream << XMLRPC_RESPONSE_HEADER; - streamOut(stream, sd["response"]); - stream << XMLRPC_RESPONSE_FOOTER << XMLRPC_METHOD_RESPONSE_FOOTER; - rv = STATUS_DONE; - } - else if(sd.has("fault")) - { - PUMP_DEBUG; - // it is a fault. - stream << XMLRPC_FAULT_1 << sd["fault"]["code"].asInteger() - << XMLRPC_FAULT_2 - << xml_escape_string(sd["fault"]["description"].asString()) - << XMLRPC_FAULT_3 << XMLRPC_METHOD_RESPONSE_FOOTER; - rv = STATUS_DONE; - } - else - { - LL_WARNS() << "Unable to determine the type of LLSD response." << LL_ENDL; - } - PUMP_DEBUG; - return rv; -} - -/** - * LLFilterSD2XMLRPCRequest - */ -LLFilterSD2XMLRPCRequest::LLFilterSD2XMLRPCRequest() -{ -} - -LLFilterSD2XMLRPCRequest::LLFilterSD2XMLRPCRequest(const char* method) -{ - if(method) - { - mMethod.assign(method); - } -} - -LLFilterSD2XMLRPCRequest::~LLFilterSD2XMLRPCRequest() -{ -} - -// virtual -LLIOPipe::EStatus LLFilterSD2XMLRPCRequest::process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump) -{ - LL_PROFILE_ZONE_SCOPED; - // This pipe does not work if it does not have everyting. This - // could be addressed by making a stream parser for llsd which - // handled partial information. - PUMP_DEBUG; - if(!eos) - { - LL_INFOS() << "!eos" << LL_ENDL; - return STATUS_BREAK; - } - - // See if we can parse it - LLBufferStream stream(channels, buffer.get()); - LLSD sd; - LLSDSerialize::fromNotation(sd, stream, buffer->count(channels.in())); - if(stream.fail()) - { - LL_INFOS() << "STREAM FAILURE reading structure data." << LL_ENDL; - } - - PUMP_DEBUG; - // We can get the method and parameters from either the member - // function or passed in via the buffer. We prefer the buffer if - // we found a parameter and a method, or fall back to using - // mMethod and putting everyting in the buffer into the parameter. - std::string method; - LLSD param_sd; - if(sd.has("method") && sd.has("parameter")) - { - method = sd["method"].asString(); - param_sd = sd["parameter"]; - } - else - { - method = mMethod; - param_sd = sd; - } - if(method.empty()) - { - LL_WARNS() << "SD -> XML Request no method found." << LL_ENDL; - return STATUS_ERROR; - } - - PUMP_DEBUG; - // We have a method, and some kind of parameter, so package it up - // and send it out. - LLBufferStream ostream(channels, buffer.get()); - ostream.precision(DEFAULT_PRECISION); - if(ostream.fail()) - { - LL_INFOS() << "STREAM FAILURE setting precision" << LL_ENDL; - } - ostream << XML_HEADER << XMLRPC_REQUEST_HEADER_1 - << xml_escape_string(method) << XMLRPC_REQUEST_HEADER_2; - if(ostream.fail()) - { - LL_INFOS() << "STREAM FAILURE writing method headers" << LL_ENDL; - } - switch(param_sd.type()) - { - case LLSD::TypeMap: - // If the params are a map, then we do not want to iterate - // through them since the iterators returned will be map - // ordered un-named values, which will lose the names, and - // only stream the values, turning it into an array. - ostream << "<param>"; - streamOut(ostream, param_sd); - ostream << "</param>"; - break; - case LLSD::TypeArray: - { - - LLSD::array_iterator it = param_sd.beginArray(); - LLSD::array_iterator end = param_sd.endArray(); - for(; it != end; ++it) - { - ostream << "<param>"; - streamOut(ostream, *it); - ostream << "</param>"; - } - break; - } - default: - ostream << "<param>"; - streamOut(ostream, param_sd); - ostream << "</param>"; - break; - } - - stream << XMLRPC_REQUEST_FOOTER; - return STATUS_DONE; -} - -/** - * LLFilterXMLRPCResponse2LLSD - */ -// this is a c function here since it's really an implementation -// detail that requires a header file just get the definition of the -// parameters. -LLIOPipe::EStatus stream_out(std::ostream& ostr, XMLRPC_VALUE value) -{ - XMLRPC_VALUE_TYPE_EASY type = XMLRPC_GetValueTypeEasy(value); - LLIOPipe::EStatus status = LLIOPipe::STATUS_OK; - switch(type) - { - case xmlrpc_type_base64: - { - S32 len = XMLRPC_GetValueStringLen(value); - const char* buf = XMLRPC_GetValueBase64(value); - ostr << " b("; - if((len > 0) && buf) - { - ostr << len << ")\""; - ostr.write(buf, len); - ostr << "\""; - } - else - { - ostr << "0)\"\""; - } - break; - } - case xmlrpc_type_boolean: - //LL_DEBUGS() << "stream_out() bool" << LL_ENDL; - ostr << " " << (XMLRPC_GetValueBoolean(value) ? "true" : "false"); - break; - case xmlrpc_type_datetime: - ostr << " d\"" << XMLRPC_GetValueDateTime_ISO8601(value) << "\""; - break; - case xmlrpc_type_double: - ostr << " r" << XMLRPC_GetValueDouble(value); - //LL_DEBUGS() << "stream_out() double" << XMLRPC_GetValueDouble(value) - // << LL_ENDL; - break; - case xmlrpc_type_int: - ostr << " i" << XMLRPC_GetValueInt(value); - //LL_DEBUGS() << "stream_out() integer:" << XMLRPC_GetValueInt(value) - // << LL_ENDL; - break; - case xmlrpc_type_string: - //LL_DEBUGS() << "stream_out() string: " << str << LL_ENDL; - ostr << " s(" << XMLRPC_GetValueStringLen(value) << ")'" - << XMLRPC_GetValueString(value) << "'"; - break; - case xmlrpc_type_array: // vector - case xmlrpc_type_mixed: // vector - { - //LL_DEBUGS() << "stream_out() array" << LL_ENDL; - ostr << " ["; - U32 needs_comma = 0; - XMLRPC_VALUE current = XMLRPC_VectorRewind(value); - while(current && (LLIOPipe::STATUS_OK == status)) - { - if(needs_comma++) ostr << ","; - status = stream_out(ostr, current); - current = XMLRPC_VectorNext(value); - } - ostr << "]"; - break; - } - case xmlrpc_type_struct: // still vector - { - //LL_DEBUGS() << "stream_out() struct" << LL_ENDL; - ostr << " {"; - std::string name; - U32 needs_comma = 0; - XMLRPC_VALUE current = XMLRPC_VectorRewind(value); - while(current && (LLIOPipe::STATUS_OK == status)) - { - if(needs_comma++) ostr << ","; - name.assign(XMLRPC_GetValueID(current)); - ostr << "'" << LLSDNotationFormatter::escapeString(name) << "':"; - status = stream_out(ostr, current); - current = XMLRPC_VectorNext(value); - } - ostr << "}"; - break; - } - case xmlrpc_type_empty: - case xmlrpc_type_none: - default: - status = LLIOPipe::STATUS_ERROR; - LL_WARNS() << "Found an empty xmlrpc type.." << LL_ENDL; - // not much we can do here... - break; - }; - return status; -} - -LLFilterXMLRPCResponse2LLSD::LLFilterXMLRPCResponse2LLSD() -{ -} - -LLFilterXMLRPCResponse2LLSD::~LLFilterXMLRPCResponse2LLSD() -{ -} - -LLIOPipe::EStatus LLFilterXMLRPCResponse2LLSD::process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump) -{ - LL_PROFILE_ZONE_SCOPED; - - PUMP_DEBUG; - if(!eos) return STATUS_BREAK; - if(!buffer) return STATUS_ERROR; - - PUMP_DEBUG; - // *FIX: This technique for reading data is far from optimal. We - // need to have some kind of istream interface into the xml - // parser... - S32 bytes = buffer->countAfter(channels.in(), NULL); - if(!bytes) return STATUS_ERROR; - char* buf = new char[bytes + 1]; - buf[bytes] = '\0'; - buffer->readAfter(channels.in(), NULL, (U8*)buf, bytes); - - //LL_DEBUGS() << "xmlrpc response: " << buf << LL_ENDL; - - PUMP_DEBUG; - XMLRPC_REQUEST response = XMLRPC_REQUEST_FromXML( - buf, - bytes, - NULL); - if(!response) - { - LL_WARNS() << "XML -> SD Response unable to parse xml." << LL_ENDL; - delete[] buf; - return STATUS_ERROR; - } - - PUMP_DEBUG; - LLBufferStream stream(channels, buffer.get()); - stream.precision(DEFAULT_PRECISION); - if(XMLRPC_ResponseIsFault(response)) - { - PUMP_DEBUG; - stream << LLSDRPC_FAULT_HADER_1 - << XMLRPC_GetResponseFaultCode(response) - << LLSDRPC_FAULT_HADER_2; - const char* fault_str = XMLRPC_GetResponseFaultString(response); - std::string fault_string; - if(fault_str) - { - fault_string.assign(fault_str); - } - stream << "'" << LLSDNotationFormatter::escapeString(fault_string) - << "'" <<LLSDRPC_FAULT_FOOTER; - } - else - { - PUMP_DEBUG; - stream << LLSDRPC_RESPONSE_HEADER; - XMLRPC_VALUE param = XMLRPC_RequestGetData(response); - if(param) - { - stream_out(stream, param); - } - stream << LLSDRPC_RESPONSE_FOOTER; - } - PUMP_DEBUG; - XMLRPC_RequestFree(response, 1); - delete[] buf; - PUMP_DEBUG; - return STATUS_DONE; -} - -/** - * LLFilterXMLRPCRequest2LLSD - */ -LLFilterXMLRPCRequest2LLSD::LLFilterXMLRPCRequest2LLSD() -{ -} - -LLFilterXMLRPCRequest2LLSD::~LLFilterXMLRPCRequest2LLSD() -{ -} - -LLIOPipe::EStatus LLFilterXMLRPCRequest2LLSD::process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump) -{ - LL_PROFILE_ZONE_SCOPED; - PUMP_DEBUG; - if(!eos) return STATUS_BREAK; - if(!buffer) return STATUS_ERROR; - - PUMP_DEBUG; - // *FIX: This technique for reading data is far from optimal. We - // need to have some kind of istream interface into the xml - // parser... - S32 bytes = buffer->countAfter(channels.in(), NULL); - if(!bytes) return STATUS_ERROR; - char* buf = new char[bytes + 1]; - buf[bytes] = '\0'; - buffer->readAfter(channels.in(), NULL, (U8*)buf, bytes); - - //LL_DEBUGS() << "xmlrpc request: " << buf << LL_ENDL; - - // Check the value in the buffer. XMLRPC_REQUEST_FromXML will report a error code 4 if - // values that are less than 0x20 are passed to it, except - // 0x09: Horizontal tab; 0x0a: New Line; 0x0d: Carriage - U8* cur_pBuf = (U8*)buf; - U8 cur_char; - for (S32 i=0; i<bytes; i++) - { - cur_char = *cur_pBuf; - if ( cur_char < 0x20 - && 0x09 != cur_char - && 0x0a != cur_char - && 0x0d != cur_char ) - { - *cur_pBuf = '?'; - } - ++cur_pBuf; - } - - PUMP_DEBUG; - XMLRPC_REQUEST request = XMLRPC_REQUEST_FromXML( - buf, - bytes, - NULL); - if(!request) - { - LL_WARNS() << "XML -> SD Request process parse error." << LL_ENDL; - delete[] buf; - return STATUS_ERROR; - } - - PUMP_DEBUG; - LLBufferStream stream(channels, buffer.get()); - stream.precision(DEFAULT_PRECISION); - const char* name = XMLRPC_RequestGetMethodName(request); - stream << LLSDRPC_REQUEST_HEADER_1 << (name ? name : "") - << LLSDRPC_REQUEST_HEADER_2; - XMLRPC_VALUE param = XMLRPC_RequestGetData(request); - if(param) - { - PUMP_DEBUG; - S32 size = XMLRPC_VectorSize(param); - if(size > 1) - { - // if there are multiple parameters, stuff the values into - // an array so that the next step in the chain can read them. - stream << "["; - } - XMLRPC_VALUE current = XMLRPC_VectorRewind(param); - bool needs_comma = false; - while(current) - { - if(needs_comma) - { - stream << ","; - } - needs_comma = true; - stream_out(stream, current); - current = XMLRPC_VectorNext(param); - } - if(size > 1) - { - // close the array - stream << "]"; - } - } - stream << LLSDRPC_REQUEST_FOOTER; - XMLRPC_RequestFree(request, 1); - delete[] buf; - PUMP_DEBUG; - return STATUS_DONE; -} - diff --git a/indra/llmessage/llfiltersd2xmlrpc.h b/indra/llmessage/llfiltersd2xmlrpc.h deleted file mode 100644 index 55938d3e2b..0000000000 --- a/indra/llmessage/llfiltersd2xmlrpc.h +++ /dev/null @@ -1,271 +0,0 @@ -/** - * @file llfiltersd2xmlrpc.h - * @author Phoenix - * @date 2005-04-26 - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLFILTERSD2XMLRPC_H -#define LL_LLFILTERSD2XMLRPC_H - -/** - * These classes implement the necessary pipes for translating between - * xmlrpc and llsd rpc. The llsd rpcs mechanism was developed as an - * extensible and easy to parse serialization grammer which maintains - * a time efficient in-memory representation. - */ - -#include <iosfwd> -#include "lliopipe.h" - -/** - * @class LLFilterSD2XMLRPC - * @brief Filter from serialized LLSD to an XMLRPC method call - * - * This clas provides common functionality for the LLFilterSD2XMLRPRC - * request and response classes. - */ -class LLFilterSD2XMLRPC : public LLIOPipe -{ -public: - LLFilterSD2XMLRPC(); - virtual ~LLFilterSD2XMLRPC(); - -protected: - /** - * @brief helper method - */ - void streamOut(std::ostream& ostr, const LLSD& sd); -}; - -/** - * @class LLFilterSD2XMLRPCResponse - * @brief Filter from serialized LLSD to an XMLRPC response - * - * This class filters a serialized LLSD object to an xmlrpc - * repsonse. Since resonses are limited to a single param, the xmlrprc - * response only serializes it as one object. - * This class correctly handles normal llsd responses as well as llsd - * rpc faults. - * - * For example, if given: - * <code>{'response':[ i200, r3.4, {"foo":"bar"} ]}</code> - * Would generate: - * <code> - * <?xml version="1.0"?> - * <methodResponse><params><param><array><data> - * <value><int>200</int></value> - * <value><double>3.4</double></value> - * <value><struct><member> - * <name>foo</name><value><string>bar</string></value></member> - * </struct></value> - * </data></array></param></params></methodResponse> - * </code> - */ -class LLFilterSD2XMLRPCResponse : public LLFilterSD2XMLRPC -{ -public: - // constructor - LLFilterSD2XMLRPCResponse(); - - // destructor - virtual ~LLFilterSD2XMLRPCResponse(); - - /* @name LLIOPipe virtual implementations - */ - //@{ -protected: - /** - * @brief Process the data in buffer. - */ - virtual EStatus process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump); - //@} -}; - -/** - * @class LLFilterSD2XMLRPCRequest - * @brief Filter from serialized LLSD to an XMLRPC method call - * - * This class will accept any kind of serialized LLSD object, but you - * probably want to have an array on the outer boundary since this - * object will interpret each element in the top level LLSD as a - * parameter into the xmlrpc spec. - * - * For example, you would represent 3 params as: - * <code> - * {'method'='foo', 'parameter':[i200, r3.4, {"foo":"bar"}]} - * </code> - * To generate: - * <code> - * <?xml version="1.0"?> - * <methodCall><params> - * <param><value><int>200</int></value></param> - * <param><value><double>3.4</double></value></param> - * <param><value><struct><member> - * <name>foo</name><value><string>bar</string></value></member> - * </struct></value></param> - * </params></methodCall> - * - * This class will accept 2 different kinds of encodings. The first - * just an array of params as long as you specify the method in the - * constructor. It will also accept a structured data in the form: - * {'method':'$method_name', 'parameter':[...] } In the latter form, the - * encoded 'method' will be used regardless of the construction of the - * object, and the 'parameter' will be used as parameter to the call. - */ -class LLFilterSD2XMLRPCRequest : public LLFilterSD2XMLRPC -{ -public: - // constructor - LLFilterSD2XMLRPCRequest(); - - // constructor - LLFilterSD2XMLRPCRequest(const char* method); - - // destructor - virtual ~LLFilterSD2XMLRPCRequest(); - - /* @name LLIOPipe virtual implementations - */ - //@{ -protected: - /** - * @brief Process the data in buffer. - */ - virtual EStatus process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump); - //@} - -protected: - // The method name of this request. - std::string mMethod; -}; - -/** - * @class LLFilterXMLRPCResponse2LLSD - * @brief Filter from serialized XMLRPC method response to LLSD - * - * The xmlrpc spec states that responses can only have one element - * which can be of any supported type. - * This takes in xml of the form: - * <code> - * <?xml version=\"1.0\"?><methodResponse><params><param> - * <value><string>ok</string></value></param></params></methodResponse> - * </code> - * And processes it into: - * <code>'ok'</code> - * - */ -class LLFilterXMLRPCResponse2LLSD : public LLIOPipe -{ -public: - // constructor - LLFilterXMLRPCResponse2LLSD(); - - // destructor - virtual ~LLFilterXMLRPCResponse2LLSD(); - - /* @name LLIOPipe virtual implementations - */ - //@{ -protected: - /** - * @brief Process the data in buffer. - */ - virtual EStatus process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump); - //@} - -protected: -}; - -/** - * @class LLFilterXMLRPCRequest2LLSD - * @brief Filter from serialized XMLRPC method call to LLSD - * - * This takes in xml of the form: - * <code> - * <?xml version=\"1.0\"?><methodCall> - * <methodName>repeat</methodName> - * <params> - * <param><value><i4>4</i4></value></param> - * <param><value><string>ok</string></value></param> - * </params></methodCall> - * </code> - * And processes it into: - * <code>{ 'method':'repeat', 'params':[i4, 'ok'] }</code> - */ -class LLFilterXMLRPCRequest2LLSD : public LLIOPipe -{ -public: - // constructor - LLFilterXMLRPCRequest2LLSD(); - - // destructor - virtual ~LLFilterXMLRPCRequest2LLSD(); - - /* @name LLIOPipe virtual implementations - */ - //@{ -protected: - /** - * @brief Process the data in buffer. - */ - virtual EStatus process_impl( - const LLChannelDescriptors& channels, - buffer_ptr_t& buffer, - bool& eos, - LLSD& context, - LLPumpIO* pump); - //@} - -protected: -}; - -/** - * @brief This function takes string, and escapes it appropritately - * for inclusion as xml data. - */ -std::string xml_escape_string(const std::string& in); - -/** - * @brief Externally available constants - */ -extern const char LLSDRPC_REQUEST_HEADER_1[]; -extern const char LLSDRPC_REQUEST_HEADER_2[]; -extern const char LLSDRPC_REQUEST_FOOTER[]; - -#endif // LL_LLFILTERSD2XMLRPC_H diff --git a/indra/llmessage/lliohttpserver.cpp b/indra/llmessage/lliohttpserver.cpp index e562f09844..edc431e538 100644 --- a/indra/llmessage/lliohttpserver.cpp +++ b/indra/llmessage/lliohttpserver.cpp @@ -625,7 +625,7 @@ bool LLHTTPResponder::readHeaderLine( } return false; } - S32 offset = -((len - 1) - (newline - dest)); + S32 offset = -((len - 1) - (S32)(newline - dest)); ++newline; *newline = '\0'; mLastRead = buffer->seek(channels.in(), last, offset); diff --git a/indra/llmessage/lltemplatemessagedispatcher.cpp b/indra/llmessage/lltemplatemessagedispatcher.cpp index 0e709d6c75..edbeb4acc1 100644 --- a/indra/llmessage/lltemplatemessagedispatcher.cpp +++ b/indra/llmessage/lltemplatemessagedispatcher.cpp @@ -43,7 +43,7 @@ void LLTemplateMessageDispatcher::dispatch(const std::string& msg_name, const LLSD& message, LLHTTPNode::ResponsePtr responsep) { - std::vector<U8> data = message["body"]["binary-template-data"].asBinary(); + const LLSD::Binary& data = message["body"]["binary-template-data"].asBinary(); auto size = data.size(); if(size == 0) { @@ -53,11 +53,11 @@ void LLTemplateMessageDispatcher::dispatch(const std::string& msg_name, LLHost host; host = gMessageSystem->getSender(); - bool validate_message = mTemplateMessageReader.validateMessage(&(data[0]), static_cast<S32>(size), host, true); + bool validate_message = mTemplateMessageReader.validateMessage(data.data(), static_cast<S32>(size), host, true); if (validate_message) { - mTemplateMessageReader.readMessage(&(data[0]),host); + mTemplateMessageReader.readMessage(data.data(),host); } else { diff --git a/indra/llplugin/llpluginprocessparent.cpp b/indra/llplugin/llpluginprocessparent.cpp index 00abcf740f..bd1e19c294 100644 --- a/indra/llplugin/llpluginprocessparent.cpp +++ b/indra/llplugin/llpluginprocessparent.cpp @@ -34,6 +34,9 @@ #include "llpluginmessageclasses.h" #include "llsdserialize.h" #include "stringize.h" +#include "threadpool.h" +#include "workqueue.h" + #include "llapr.h" //virtual @@ -79,29 +82,8 @@ protected: }; - -class LLPluginProcessCreationThread : public LLThread -{ -public: - LLPluginProcessCreationThread(LLPluginProcessParent *parent) : - LLThread("LLPluginProcessCreationThread", gAPRPoolp), - pParent(parent) - { - } -protected: - // Inherited from LLThread, should run once - /*virtual*/ void run(void) - { - pParent->createPluginProcess(); - } -private: - LLPluginProcessParent *pParent; - -}; - LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner *owner): - mIncomingQueueMutex(), - pProcessCreationThread(NULL) + mIncomingQueueMutex() { if(!sInstancesMutex) { @@ -130,18 +112,6 @@ LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner *owner): LLPluginProcessParent::~LLPluginProcessParent() { LL_DEBUGS("Plugin") << "destructor" << LL_ENDL; - if (pProcessCreationThread) - { - if (!pProcessCreationThread->isStopped()) - { - // Shouldn't happen at this stage - LL_WARNS("Plugin") << "Shutting down active pProcessCreationThread" << LL_ENDL; - pProcessCreationThread->shutdown(); - ms_sleep(20); - } - delete pProcessCreationThread; - pProcessCreationThread = NULL; - } // Destroy any remaining shared memory regions sharedMemoryRegionsType::iterator iter; @@ -352,35 +322,6 @@ bool LLPluginProcessParent::accept() return result; } -bool LLPluginProcessParent::createPluginProcess() -{ - if (!mProcess) - { - // Only argument to the launcher is the port number we're listening on - mProcessParams.args.add(stringize(mBoundPort)); - mProcess = LLProcess::create(mProcessParams); - return mProcess != NULL; - } - - return false; -} - -void LLPluginProcessParent::clearProcessCreationThread() -{ - if (pProcessCreationThread) - { - if (!pProcessCreationThread->isStopped()) - { - pProcessCreationThread->shutdown(); - } - else - { - delete pProcessCreationThread; - pProcessCreationThread = NULL; - } - } -} - void LLPluginProcessParent::idle(void) { bool idle_again; @@ -542,30 +483,72 @@ void LLPluginProcessParent::idle(void) case STATE_LISTENING: { + // Only argument to the launcher is the port number we're listening on + mProcessParams.args.add(stringize(mBoundPort)); + // Launch the plugin process. - if (mDebug && !pProcessCreationThread) + if (mDebug && !mProcess) { - createPluginProcess(); - if (!mProcess) + if (!(mProcess = LLProcess::create(mProcessParams))) { errorState(); } } - else if (pProcessCreationThread == NULL) - { - // exe plugin process allocation can be hindered by a number - // of factors, don't hold whole viewer because of it, use thread - pProcessCreationThread = new LLPluginProcessCreationThread(this); - pProcessCreationThread->start(); - } - else if (!mProcess && pProcessCreationThread->isStopped()) + else if (!mProcess && !mProcessCreationRequested) { - delete pProcessCreationThread; - pProcessCreationThread = NULL; - errorState(); + mProcessCreationRequested = true; + LL::WorkQueue::ptr_t main_queue = LL::WorkQueue::getInstance("mainloop"); + // *NOTE: main_queue->postTo casts this refcounted smart pointer to a weak + // pointer + LL::WorkQueue::ptr_t general_queue = LL::WorkQueue::getInstance("General"); + llassert_always(main_queue); + llassert_always(general_queue); + + auto process_params = mProcessParams; + + bool posted = main_queue->postTo( + general_queue, + [process_params]() // Work done on general queue + { + return LLProcess::create(process_params); + }, + [this](LLProcessPtr new_process) // Callback to main thread + mutable { + ptr_t that; + { + // this grabs a copy of the smart pointer to ourselves to ensure that we do not + // get destroyed until after this method returns. + LLCoros::LockType lock(*sInstancesMutex); + mapInstances_t::iterator it = sInstances.find(this); + if (it != sInstances.end()) + that = (*it).second; + } + + if (that) + { + if (new_process) + { + that->mProcess = new_process; + } + else + { + that->mProcessCreationRequested = false; + that->errorState(); + } + } + + }); + if (!posted) + { + LL_WARNS("Plugin") << "Failed to dispath process creation to threadpool" << LL_ENDL; + if (!(mProcess = LLProcess::create(mProcessParams))) + { + mProcessCreationRequested = false; + errorState(); + } + } } - if (mProcess) { if(mDebug) @@ -595,15 +578,6 @@ void LLPluginProcessParent::idle(void) // This will allow us to time out if the process never starts. mHeartbeat.start(); mHeartbeat.setTimerExpirySec(mPluginLaunchTimeout); - - // pProcessCreationThread should have stopped by this point, - // but check just in case it paused on statistics sync - if (pProcessCreationThread && pProcessCreationThread->isStopped()) - { - delete pProcessCreationThread; - pProcessCreationThread = NULL; - } - setState(STATE_LAUNCHED); } } @@ -706,7 +680,6 @@ void LLPluginProcessParent::idle(void) killSockets(); setState(STATE_DONE); dirtyPollSet(); - clearProcessCreationThread(); break; case STATE_DONE: diff --git a/indra/llplugin/llpluginprocessparent.h b/indra/llplugin/llpluginprocessparent.h index d1c4933d81..334f1411af 100644 --- a/indra/llplugin/llpluginprocessparent.h +++ b/indra/llplugin/llpluginprocessparent.h @@ -69,11 +69,6 @@ public: const std::string &plugin_filename, bool debug); - // Creates a process - // returns true if process already exists or if created, - // false if failed to create - bool createPluginProcess(); - void idle(void); // returns true if the plugin is on its way to steady state @@ -168,15 +163,13 @@ private: bool accept(); - void clearProcessCreationThread(); - LLSocket::ptr_t mListenSocket; LLSocket::ptr_t mSocket; U32 mBoundPort; LLProcess::Params mProcessParams; LLProcessPtr mProcess; - LLThread *pProcessCreationThread; + bool mProcessCreationRequested = false; std::string mPluginFile; std::string mPluginDir; diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index 1480322935..3e84eeffc2 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -107,7 +107,7 @@ bool get_dom_sources(const domInputLocalOffset_Array& inputs, S32& pos_offset, S { if (strcmp(COMMON_PROFILE_INPUT_POSITION, v_inp[k]->getSemantic()) == 0) { - pos_offset = inputs[j]->getOffset(); + pos_offset = (S32)inputs[j]->getOffset(); const domURIFragmentType& uri = v_inp[k]->getSource(); daeElementRef elem = uri.getElement(); @@ -116,7 +116,7 @@ bool get_dom_sources(const domInputLocalOffset_Array& inputs, S32& pos_offset, S if (strcmp(COMMON_PROFILE_INPUT_NORMAL, v_inp[k]->getSemantic()) == 0) { - norm_offset = inputs[j]->getOffset(); + norm_offset = (S32)inputs[j]->getOffset(); const domURIFragmentType& uri = v_inp[k]->getSource(); daeElementRef elem = uri.getElement(); @@ -128,14 +128,14 @@ bool get_dom_sources(const domInputLocalOffset_Array& inputs, S32& pos_offset, S if (strcmp(COMMON_PROFILE_INPUT_NORMAL, inputs[j]->getSemantic()) == 0) { //found normal array for this triangle list - norm_offset = inputs[j]->getOffset(); + norm_offset = (S32)inputs[j]->getOffset(); const domURIFragmentType& uri = inputs[j]->getSource(); daeElementRef elem = uri.getElement(); norm_source = (domSource*) elem.cast(); } else if (strcmp(COMMON_PROFILE_INPUT_TEXCOORD, inputs[j]->getSemantic()) == 0) { //found texCoords - tc_offset = inputs[j]->getOffset(); + tc_offset = (S32)inputs[j]->getOffset(); const domURIFragmentType& uri = inputs[j]->getSource(); daeElementRef elem = uri.getElement(); tc_source = (domSource*) elem.cast(); @@ -201,8 +201,8 @@ LLModel::EModelStatus load_face_from_dom_triangles( return LLModel::BAD_ELEMENT; } // VFExtents change - face.mExtents[0].set(v[0], v[1], v[2]); - face.mExtents[1].set(v[0], v[1], v[2]); + face.mExtents[0].set((F32)v[0], (F32)v[1], (F32)v[2]); + face.mExtents[1].set((F32)v[0], (F32)v[1], (F32)v[2]); } LLVolumeFace::VertexMapData::PointMap point_map; @@ -223,22 +223,22 @@ LLModel::EModelStatus load_face_from_dom_triangles( LLVolumeFace::VertexData cv; if (pos_source) { - cv.setPosition(LLVector4a(v[idx[i+pos_offset]*3+0], - v[idx[i+pos_offset]*3+1], - v[idx[i+pos_offset]*3+2])); + cv.setPosition(LLVector4a((F32)v[idx[i+pos_offset]*3+0], + (F32)v[idx[i+pos_offset]*3+1], + (F32)v[idx[i+pos_offset]*3+2])); } if (tc_source) { - cv.mTexCoord.setVec(tc[idx[i+tc_offset]*2+0], - tc[idx[i+tc_offset]*2+1]); + cv.mTexCoord.setVec((F32)tc[idx[i+tc_offset]*2+0], + (F32)tc[idx[i+tc_offset]*2+1]); } if (norm_source) { - cv.setNormal(LLVector4a(n[idx[i+norm_offset]*3+0], - n[idx[i+norm_offset]*3+1], - n[idx[i+norm_offset]*3+2])); + cv.setNormal(LLVector4a((F32)n[idx[i+norm_offset]*3+0], + (F32)n[idx[i+norm_offset]*3+1], + (F32)n[idx[i+norm_offset]*3+2])); } bool found = false; @@ -326,8 +326,8 @@ LLModel::EModelStatus load_face_from_dom_triangles( face = LLVolumeFace(); // VFExtents change - face.mExtents[0].set(v[0], v[1], v[2]); - face.mExtents[1].set(v[0], v[1], v[2]); + face.mExtents[0].set((F32)v[0], (F32)v[1], (F32)v[2]); + face.mExtents[1].set((F32)v[0], (F32)v[1], (F32)v[2]); verts.clear(); indices.clear(); @@ -416,8 +416,8 @@ LLModel::EModelStatus load_face_from_dom_polylist( { v = pos_source->getFloat_array()->getValue(); // VFExtents change - face.mExtents[0].set(v[0], v[1], v[2]); - face.mExtents[1].set(v[0], v[1], v[2]); + face.mExtents[0].set((F32)v[0], (F32)v[1], (F32)v[2]); + face.mExtents[1].set((F32)v[0], (F32)v[1], (F32)v[2]); } if (tc_source) @@ -445,9 +445,9 @@ LLModel::EModelStatus load_face_from_dom_polylist( if (pos_source) { - cv.getPosition().set(v[idx[cur_idx+pos_offset]*3+0], - v[idx[cur_idx+pos_offset]*3+1], - v[idx[cur_idx+pos_offset]*3+2]); + cv.getPosition().set((F32)v[idx[cur_idx+pos_offset]*3+0], + (F32)v[idx[cur_idx+pos_offset]*3+1], + (F32)v[idx[cur_idx+pos_offset]*3+2]); if (!cv.getPosition().isFinite3()) { LL_WARNS() << "Found NaN while loading position data from DAE-Model, invalid model." << LL_ENDL; @@ -465,7 +465,7 @@ LLModel::EModelStatus load_face_from_dom_polylist( if (idx_y < tc.getCount()) { - cv.mTexCoord.setVec(tc[idx_x], tc[idx_y]); + cv.mTexCoord.setVec((F32)tc[idx_x], (F32)tc[idx_y]); } else if (log_tc_msg) { @@ -479,9 +479,9 @@ LLModel::EModelStatus load_face_from_dom_polylist( if (norm_source) { - cv.getNormal().set(n[idx[cur_idx+norm_offset]*3+0], - n[idx[cur_idx+norm_offset]*3+1], - n[idx[cur_idx+norm_offset]*3+2]); + cv.getNormal().set((F32)n[idx[cur_idx+norm_offset]*3+0], + (F32)n[idx[cur_idx+norm_offset]*3+1], + (F32)n[idx[cur_idx+norm_offset]*3+2]); if (!cv.getNormal().isFinite3()) { @@ -607,8 +607,8 @@ LLModel::EModelStatus load_face_from_dom_polylist( face = LLVolumeFace(); // VFExtents change - face.mExtents[0].set(v[0], v[1], v[2]); - face.mExtents[1].set(v[0], v[1], v[2]); + face.mExtents[0].set((F32)v[0], (F32)v[1], (F32)v[2]); + face.mExtents[1].set((F32)v[0], (F32)v[1], (F32)v[2]); verts.clear(); indices.clear(); point_map.clear(); @@ -669,7 +669,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac if (strcmp(COMMON_PROFILE_INPUT_VERTEX, inputs[i]->getSemantic()) == 0) { //found vertex array - v_offset = inputs[i]->getOffset(); + v_offset = (S32)inputs[i]->getOffset(); const domURIFragmentType& uri = inputs[i]->getSource(); daeElementRef elem = uri.getElement(); @@ -697,7 +697,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac } else if (strcmp(COMMON_PROFILE_INPUT_NORMAL, inputs[i]->getSemantic()) == 0) { - n_offset = inputs[i]->getOffset(); + n_offset = (S32)inputs[i]->getOffset(); //found normal array for this triangle list const domURIFragmentType& uri = inputs[i]->getSource(); daeElementRef elem = uri.getElement(); @@ -710,7 +710,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac } else if (strcmp(COMMON_PROFILE_INPUT_TEXCOORD, inputs[i]->getSemantic()) == 0 && inputs[i]->getSet() == 0) { //found texCoords - t_offset = inputs[i]->getOffset(); + t_offset = (S32)inputs[i]->getOffset(); const domURIFragmentType& uri = inputs[i]->getSource(); daeElementRef elem = uri.getElement(); domSource* src = (domSource*) elem.cast(); @@ -745,11 +745,11 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac if (v) { - U32 v_idx = idx[j*stride+v_offset]*3; + U32 v_idx = (U32)idx[j*stride+v_offset]*3; v_idx = llclamp(v_idx, (U32) 0, (U32) v->getCount()); - vert.getPosition().set(v->get(v_idx), - v->get(v_idx+1), - v->get(v_idx+2)); + vert.getPosition().set((F32)v->get(v_idx), + (F32)v->get(v_idx+1), + (F32)v->get(v_idx+2)); } //bounds check n and t lookups because some FBX to DAE converters @@ -757,11 +757,11 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac //for a particular channel if (n && n->getCount() > 0) { - U32 n_idx = idx[j*stride+n_offset]*3; + U32 n_idx = (U32)idx[j*stride+n_offset]*3; n_idx = llclamp(n_idx, (U32) 0, (U32) n->getCount()); - vert.getNormal().set(n->get(n_idx), - n->get(n_idx+1), - n->get(n_idx+2)); + vert.getNormal().set((F32)n->get(n_idx), + (F32)n->get(n_idx+1), + (F32)n->get(n_idx+2)); } else { @@ -771,10 +771,10 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac if (t && t->getCount() > 0) { - U32 t_idx = idx[j*stride+t_offset]*2; + U32 t_idx = (U32)idx[j*stride+t_offset]*2; t_idx = llclamp(t_idx, (U32) 0, (U32) t->getCount()); - vert.mTexCoord.setVec(t->get(t_idx), - t->get(t_idx+1)); + vert.mTexCoord.setVec((F32)t->get(t_idx), + (F32)t->get(t_idx+1)); } else { @@ -1026,7 +1026,7 @@ bool LLDAELoader::OpenFile(const std::string& filename) if (unit) { - F32 meter = unit->getMeter(); + F32 meter = (F32)unit->getMeter(); mTransform.mMatrix[0][0] = meter; mTransform.mMatrix[1][1] = meter; mTransform.mMatrix[2][2] = meter; @@ -1241,7 +1241,7 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do { for(int j = 0; j < 4; j++) { - mat.mMatrix[i][j] = dom_value[i + j*4]; + mat.mMatrix[i][j] = (F32)dom_value[i + j*4]; } } @@ -1463,7 +1463,7 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do { for(int j = 0; j < 4; j++) { - mat.mMatrix[i][j] = transform[k*16 + i + j*4]; + mat.mMatrix[i][j] = (F32)transform[k*16 + i + j*4]; } } model->mSkinInfo.mInvBindMatrix.push_back(LLMatrix4a(mat)); @@ -1581,7 +1581,7 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do LL_ERRS() << "Invalid position array size." << LL_ENDL; } - LLVector3 v(pos[j], pos[j+1], pos[j+2]); + LLVector3 v((F32)pos[j], (F32)pos[j+1], (F32)pos[j+2]); //transform from COLLADA space to volume space v = v * inverse_normalized_transformation; @@ -1621,15 +1621,15 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do U32 c_idx = 0; for (size_t vc_idx = 0; vc_idx < vcount.getCount(); ++vc_idx) { //for each vertex - daeUInt count = vcount[vc_idx]; + daeUInt count = (daeUInt)vcount[vc_idx]; //create list of weights that influence this vertex LLModel::weight_list weight_list; for (daeUInt i = 0; i < count; ++i) { //for each weight - daeInt joint_idx = v[c_idx++]; - daeInt weight_idx = v[c_idx++]; + daeInt joint_idx = (daeInt)v[c_idx++]; + daeInt weight_idx = (daeInt)v[c_idx++]; if (joint_idx == -1) { @@ -1637,7 +1637,7 @@ void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, do continue; } - F32 weight_value = w[weight_idx]; + F32 weight_value = (F32)w[weight_idx]; weight_list.push_back(LLModel::JointWeight(joint_idx, weight_value)); } @@ -1807,7 +1807,7 @@ bool LLDAELoader::verifyController( domController* pController ) { //Skin is reference directly by geometry and get the vertex count from skin domSkin::domVertex_weights* pVertexWeights = pSkin->getVertex_weights(); - U32 vertexWeightsCount = pVertexWeights->getCount(); + U32 vertexWeightsCount = (U32)pVertexWeights->getCount(); domGeometry* pGeometry = (domGeometry*) (domElement*) uri.getElement(); domMesh* pMesh = pGeometry->getMesh(); @@ -1825,7 +1825,7 @@ bool LLDAELoader::verifyController( domController* pController ) { xsAnyURI src = pVertices->getInput_array()[0]->getSource(); domSource* pSource = (domSource*) (domElement*) src.getElement(); - U32 verticesCount = pSource->getTechnique_common()->getAccessor()->getCount(); + U32 verticesCount = (U32)pSource->getTechnique_common()->getAccessor()->getCount(); result = verifyCount( verticesCount, vertexWeightsCount ); if ( !result ) { @@ -1845,7 +1845,7 @@ bool LLDAELoader::verifyController( domController* pController ) U32 sum = 0; for (size_t i=0; i<vcountCount; i++) { - sum += pVertexWeights->getVcount()->getValue()[i]; + sum += (U32)pVertexWeights->getVcount()->getValue()[i]; } result = verifyCount( sum * static_cast<U32>(inputs.getCount()), (domInt) static_cast<int>(pVertexWeights->getV()->getValue().getCount()) ); } @@ -1860,7 +1860,7 @@ bool LLDAELoader::verifyController( domController* pController ) void LLDAELoader::extractTranslation( domTranslate* pTranslate, LLMatrix4& transform ) { domFloat3 jointTrans = pTranslate->getValue(); - LLVector3 singleJointTranslation( jointTrans[0], jointTrans[1], jointTrans[2] ); + LLVector3 singleJointTranslation((F32)jointTrans[0], (F32)jointTrans[1], (F32)jointTrans[2]); transform.setTranslation( singleJointTranslation ); } //----------------------------------------------------------------------------- @@ -1872,7 +1872,7 @@ void LLDAELoader::extractTranslationViaElement( daeElement* pTranslateElement, L { domTranslate* pTranslateChild = static_cast<domTranslate*>( pTranslateElement ); domFloat3 translateChild = pTranslateChild->getValue(); - LLVector3 singleJointTranslation( translateChild[0], translateChild[1], translateChild[2] ); + LLVector3 singleJointTranslation((F32)translateChild[0], (F32)translateChild[1], (F32)translateChild[2]); transform.setTranslation( singleJointTranslation ); } } @@ -1894,7 +1894,7 @@ void LLDAELoader::extractTranslationViaSID( daeElement* pElement, LLMatrix4& tra { for( int j = 0; j < 4; j++ ) { - workingTransform.mMatrix[i][j] = domArray[i + j*4]; + workingTransform.mMatrix[i][j] = (F32)domArray[i + j*4]; } } LLVector3 trans = workingTransform.getTranslation(); @@ -1957,7 +1957,7 @@ void LLDAELoader::processJointNode( domNode* pNode, JointTransformMap& jointTran { for (int j = 0; j < 4; j++) { - workingTransform.mMatrix[i][j] = domArray[i + j * 4]; + workingTransform.mMatrix[i][j] = (F32)domArray[i + j * 4]; } } } @@ -2023,7 +2023,7 @@ void LLDAELoader::processElement( daeElement* element, bool& badElement, DAE* da domFloat3 dom_value = translate->getValue(); LLMatrix4 translation; - translation.setTranslation(LLVector3(dom_value[0], dom_value[1], dom_value[2])); + translation.setTranslation(LLVector3((F32)dom_value[0], (F32)dom_value[1], (F32)dom_value[2])); translation *= mTransform; mTransform = translation; @@ -2036,7 +2036,7 @@ void LLDAELoader::processElement( daeElement* element, bool& badElement, DAE* da domFloat4 dom_value = rotate->getValue(); LLMatrix4 rotation; - rotation.initRotTrans(dom_value[3] * DEG_TO_RAD, LLVector3(dom_value[0], dom_value[1], dom_value[2]), LLVector3(0, 0, 0)); + rotation.initRotTrans((F32)dom_value[3] * DEG_TO_RAD, LLVector3((F32)dom_value[0], (F32)dom_value[1], (F32)dom_value[2]), LLVector3(0, 0, 0)); rotation *= mTransform; mTransform = rotation; @@ -2049,7 +2049,7 @@ void LLDAELoader::processElement( daeElement* element, bool& badElement, DAE* da domFloat3 dom_value = scale->getValue(); - LLVector3 scale_vector = LLVector3(dom_value[0], dom_value[1], dom_value[2]); + LLVector3 scale_vector = LLVector3((F32)dom_value[0], (F32)dom_value[1], (F32)dom_value[2]); scale_vector.abs(); // Set all values positive, since we don't currently support mirrored meshes LLMatrix4 scaling; scaling.initScale(scale_vector); @@ -2070,7 +2070,7 @@ void LLDAELoader::processElement( daeElement* element, bool& badElement, DAE* da { for(int j = 0; j < 4; j++) { - matrix_transform.mMatrix[i][j] = dom_value[i + j*4]; + matrix_transform.mMatrix[i][j] = (F32)dom_value[i + j*4]; } } @@ -2338,7 +2338,7 @@ LLImportMaterial LLDAELoader::profileToMaterial(domProfile_COMMON* material, DAE if (color) { domFx_color_common domfx_color = color->getValue(); - LLColor4 value = LLColor4(domfx_color[0], domfx_color[1], domfx_color[2], domfx_color[3]); + LLColor4 value = LLColor4((F32)domfx_color[0], (F32)domfx_color[1], (F32)domfx_color[2], (F32)domfx_color[3]); mat.mDiffuseColor = value; } } @@ -2450,7 +2450,7 @@ LLColor4 LLDAELoader::getDaeColor(daeElement* element) if (color) { domFx_color_common domfx_color = color->getValue(); - value = LLColor4(domfx_color[0], domfx_color[1], domfx_color[2], domfx_color[3]); + value = LLColor4((F32)domfx_color[0], (F32)domfx_color[1], (F32)domfx_color[2], (F32)domfx_color[3]); } return value; diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp index e8c9af5ea3..cc4921416f 100644 --- a/indra/llprimitive/llgltfmaterial.cpp +++ b/indra/llprimitive/llgltfmaterial.cpp @@ -790,7 +790,7 @@ void LLGLTFMaterial::applyOverrideLLSD(const LLSD& data) const LLSD& mf = data["mf"]; if (mf.isReal()) { - mMetallicFactor = mf.asReal(); + mMetallicFactor = (F32)mf.asReal(); if (mMetallicFactor == getDefaultMetallicFactor()) { // HACK -- nudge by epsilon if we receive a default value (indicates override to default) @@ -801,7 +801,7 @@ void LLGLTFMaterial::applyOverrideLLSD(const LLSD& data) const LLSD& rf = data["rf"]; if (rf.isReal()) { - mRoughnessFactor = rf.asReal(); + mRoughnessFactor = (F32)rf.asReal(); if (mRoughnessFactor == getDefaultRoughnessFactor()) { // HACK -- nudge by epsilon if we receive a default value (indicates override to default) @@ -819,7 +819,7 @@ void LLGLTFMaterial::applyOverrideLLSD(const LLSD& data) const LLSD& ac = data["ac"]; if (ac.isReal()) { - mAlphaCutoff = ac.asReal(); + mAlphaCutoff = (F32)ac.asReal(); if (mAlphaCutoff == getDefaultAlphaCutoff()) { // HACK -- nudge by epsilon if we receive a default value (indicates override to default) @@ -854,7 +854,7 @@ void LLGLTFMaterial::applyOverrideLLSD(const LLSD& data) const LLSD& r = ti[i]["r"]; if (r.isReal()) { - mTextureTransform[i].mRotation = r.asReal(); + mTextureTransform[i].mRotation = (F32)r.asReal(); } } } diff --git a/indra/llprimitive/llmaterialid.cpp b/indra/llprimitive/llmaterialid.cpp index 847824d770..4992b282f3 100644 --- a/indra/llprimitive/llmaterialid.cpp +++ b/indra/llprimitive/llmaterialid.cpp @@ -136,7 +136,7 @@ LLSD LLMaterialID::asLLSD() const materialIDBinary.resize(MATERIAL_ID_SIZE * sizeof(U8)); memcpy(materialIDBinary.data(), mID, MATERIAL_ID_SIZE * sizeof(U8)); - LLSD materialID = materialIDBinary; + LLSD materialID = std::move(materialIDBinary); return materialID; } diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index e7152a2291..15087a7255 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -1487,7 +1487,7 @@ void LLMeshSkinInfo::fromLLSD(LLSD& skin) { for (U32 k = 0; k < 4; k++) { - mat.mMatrix[j][k] = skin["inverse_bind_matrix"][i][j*4+k].asReal(); + mat.mMatrix[j][k] = (F32)skin["inverse_bind_matrix"][i][j*4+k].asReal(); } } @@ -1510,7 +1510,7 @@ void LLMeshSkinInfo::fromLLSD(LLSD& skin) { for (U32 k = 0; k < 4; k++) { - mat.mMatrix[j][k] = skin["bind_shape_matrix"][j*4+k].asReal(); + mat.mMatrix[j][k] = (F32)skin["bind_shape_matrix"][j*4+k].asReal(); } } mBindShapeMatrix.loadu(mat); @@ -1525,7 +1525,7 @@ void LLMeshSkinInfo::fromLLSD(LLSD& skin) { for (U32 k = 0; k < 4; k++) { - mat.mMatrix[j][k] = skin["alt_inverse_bind_matrix"][i][j*4+k].asReal(); + mat.mMatrix[j][k] = (F32)skin["alt_inverse_bind_matrix"][i][j*4+k].asReal(); } } @@ -1535,7 +1535,7 @@ void LLMeshSkinInfo::fromLLSD(LLSD& skin) if (skin.has("pelvis_offset")) { - mPelvisOffset = skin["pelvis_offset"].asReal(); + mPelvisOffset = (F32)skin["pelvis_offset"].asReal(); } if (skin.has("lock_scale_if_joint_position")) @@ -1618,7 +1618,7 @@ void LLMeshSkinInfo::updateHash() for (size_t i = 0, count = mInvBindMatrix.size() * 16; i < count; ++i) { - S32 t = llround(src[i] * 10000.f); + S32 t = ll_round(src[i] * 10000.f); hash.update((const void*)&t, sizeof(S32)); } //hash.update((const void*)mInvBindMatrix.data(), sizeof(LLMatrix4a) * mInvBindMatrix.size()); diff --git a/indra/llprimitive/lltreeparams.cpp b/indra/llprimitive/lltreeparams.cpp index b85aa3acf2..b6216c022b 100644 --- a/indra/llprimitive/lltreeparams.cpp +++ b/indra/llprimitive/lltreeparams.cpp @@ -178,7 +178,7 @@ F32 LLTreeParams::ShapeRatio(EShapeRatio shape, F32 ratio) case (SR_SPHERICAL): return (.2f + .8f * sinf(F_PI*ratio)); case (SR_HEMISPHERICAL): - return (.2f + .8f * sinf(.5*F_PI*ratio)); + return (.2f + .8f * sinf(.5f*F_PI*ratio)); case (SR_CYLINDRICAL): return (1); case (SR_TAPERED_CYLINDRICAL): diff --git a/indra/llrender/llfontfreetype.cpp b/indra/llrender/llfontfreetype.cpp index 741ed993b0..6128e03fa7 100644 --- a/indra/llrender/llfontfreetype.cpp +++ b/indra/llrender/llfontfreetype.cpp @@ -178,7 +178,7 @@ unsigned long ft_read_cb(FT_Stream stream, unsigned long offset, unsigned char * llifstream *file_stream = static_cast<llifstream *>(stream->descriptor.pointer); file_stream->seekg(offset, std::ios::beg); file_stream->read((char*)buffer, count); - return file_stream->gcount(); + return (unsigned long)file_stream->gcount(); } void ft_close_cb(FT_Stream stream) { diff --git a/indra/llrender/llfontfreetypesvg.cpp b/indra/llrender/llfontfreetypesvg.cpp index 355e8432aa..71f751329e 100644 --- a/indra/llrender/llfontfreetypesvg.cpp +++ b/indra/llrender/llfontfreetypesvg.cpp @@ -136,18 +136,18 @@ FT_Error LLFontFreeTypeSvgRenderer::OnPresetGlypthSlot(FT_GlyphSlot glyph_slot, float svg_scale = llmin(svg_x_scale, svg_y_scale); datap->Scale = svg_scale; - glyph_slot->bitmap.width = floorf(svg_width) * svg_scale; - glyph_slot->bitmap.rows = floorf(svg_height) * svg_scale; + glyph_slot->bitmap.width = (unsigned int)(floorf(svg_width) * svg_scale); + glyph_slot->bitmap.rows = (unsigned int)(floorf(svg_height) * svg_scale); glyph_slot->bitmap_left = (document->metrics.x_ppem - glyph_slot->bitmap.width) / 2; - glyph_slot->bitmap_top = glyph_slot->face->size->metrics.ascender / 64.f; + glyph_slot->bitmap_top = (FT_Int)(glyph_slot->face->size->metrics.ascender / 64.f); glyph_slot->bitmap.pitch = glyph_slot->bitmap.width * 4; glyph_slot->bitmap.pixel_mode = FT_PIXEL_MODE_BGRA; /* Copied as-is from fcft (MIT license) */ // Compute all the bearings and set them correctly. The outline is scaled already, we just need to use the bounding box. - float horiBearingX = 0.; - float horiBearingY = -glyph_slot->bitmap_top; + float horiBearingX = 0.f; + float horiBearingY = -(float)glyph_slot->bitmap_top; // XXX parentheses correct? float vertBearingX = glyph_slot->metrics.horiBearingX / 64.0f - glyph_slot->metrics.horiAdvance / 64.0f / 2; @@ -156,13 +156,13 @@ FT_Error LLFontFreeTypeSvgRenderer::OnPresetGlypthSlot(FT_GlyphSlot glyph_slot, // Do conversion in two steps to avoid 'bad function cast' warning glyph_slot->metrics.width = glyph_slot->bitmap.width * 64; glyph_slot->metrics.height = glyph_slot->bitmap.rows * 64; - glyph_slot->metrics.horiBearingX = horiBearingX * 64; - glyph_slot->metrics.horiBearingY = horiBearingY * 64; - glyph_slot->metrics.vertBearingX = vertBearingX * 64; - glyph_slot->metrics.vertBearingY = vertBearingY * 64; + glyph_slot->metrics.horiBearingX = (FT_Pos)(horiBearingX * 64); + glyph_slot->metrics.horiBearingY = (FT_Pos)(horiBearingY * 64); + glyph_slot->metrics.vertBearingX = (FT_Pos)(vertBearingX * 64); + glyph_slot->metrics.vertBearingY = (FT_Pos)(vertBearingY * 64); if (glyph_slot->metrics.vertAdvance == 0) { - glyph_slot->metrics.vertAdvance = glyph_slot->bitmap.rows * 1.2f * 64; + glyph_slot->metrics.vertAdvance = (FT_Pos)(glyph_slot->bitmap.rows * 1.2f * 64); } return FT_Err_Ok; diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 59ee8ef84f..b9a4235a4e 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -112,7 +112,7 @@ S32 LLFontGL::getNumFaces(const std::string& filename) S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, const LLRect& rect, const LLColor4 &color, HAlign halign, VAlign valign, U8 style, ShadowType shadow, S32 max_chars, F32* right_x, bool use_ellipses, bool use_color) const { - LLRectf rect_float(rect.mLeft, rect.mTop, rect.mRight, rect.mBottom); + LLRectf rect_float((F32)rect.mLeft, (F32)rect.mTop, (F32)rect.mRight, (F32)rect.mBottom); return render(wstr, begin_offset, rect_float, color, halign, valign, style, shadow, max_chars, right_x, use_ellipses, use_color); } @@ -138,7 +138,7 @@ S32 LLFontGL::render(const LLWString &wstr, S32 begin_offset, const LLRectf& rec y = rect.mBottom; break; } - return render(wstr, begin_offset, x, y, color, halign, valign, style, shadow, max_chars, rect.getWidth(), right_x, use_ellipses, use_color); + return render(wstr, begin_offset, x, y, color, halign, valign, style, shadow, max_chars, (S32)rect.getWidth(), right_x, use_ellipses, use_color); } @@ -560,7 +560,7 @@ F32 LLFontGL::getWidthF32(const llwchar* wchars, S32 begin_offset, S32 max_chars void LLFontGL::generateASCIIglyphs() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_UI + LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; for (U32 i = 32; (i < 127); i++) { mFontFreetype->getGlyphInfo(i, EFontGlyphType::Grayscale); @@ -570,7 +570,7 @@ void LLFontGL::generateASCIIglyphs() // Returns the max number of complete characters from text (up to max_chars) that can be drawn in max_pixels S32 LLFontGL::maxDrawableChars(const llwchar* wchars, F32 max_pixels, S32 max_chars, EWordWrapStyle end_on_word_boundary) const { - LL_PROFILE_ZONE_SCOPED_CATEGORY_UI + LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; if (!wchars || !wchars[0] || max_chars == 0) { return 0; @@ -881,7 +881,7 @@ void LLFontGL::dumpFontTextures() // static bool LLFontGL::loadDefaultFonts() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_UI + LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; bool succ = true; succ &= (NULL != getFontSansSerifSmall()); succ &= (NULL != getFontSansSerif()); @@ -894,7 +894,7 @@ bool LLFontGL::loadDefaultFonts() void LLFontGL::loadCommonFonts() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_UI + LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; getFont(LLFontDescriptor("SansSerif", "Small", BOLD)); getFont(LLFontDescriptor("SansSerif", "Large", BOLD)); getFont(LLFontDescriptor("SansSerif", "Huge", BOLD)); diff --git a/indra/llrender/llfontregistry.cpp b/indra/llrender/llfontregistry.cpp index 62f4f35e3d..c48a389f6a 100644 --- a/indra/llrender/llfontregistry.cpp +++ b/indra/llrender/llfontregistry.cpp @@ -500,7 +500,7 @@ LLFontGL *LLFontRegistry::createFont(const LLFontDescriptor& desc) // *HACK: Fallback fonts don't render, so we can use that to suppress // creation of OpenGL textures for test apps. JC bool is_fallback = !is_first_found || !mCreateGLTextures; - F32 extra_scale = (is_fallback)?fallback_scale:1.0; + F32 extra_scale = (is_fallback) ? fallback_scale : 1.0f; F32 point_size_scale = extra_scale * point_size; bool is_font_loaded = false; for(string_vec_t::iterator font_search_path_it = font_search_paths.begin(); diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 909dad2e85..be1c0a532a 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -102,6 +102,9 @@ public: bool mIsNVIDIA; bool mIsIntel; + // hints to the render pipe + U32 mDownScaleMethod = 0; // see settings.xml RenderDownScaleMethod + #if LL_DARWIN // Needed to distinguish problem cards on older Macs that break with Materials bool mIsMobileGF; diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index 25e4a88f28..e76a30a954 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -190,7 +190,7 @@ void LLGLSLShader::dumpStats() tris_sec /= seconds; F32 pct_samples = (F32)((F64)mSamplesDrawn / (F64)sTotalSamplesDrawn) * 100.f; - F32 samples_sec = (F32)mSamplesDrawn / 1000000000.0; + F32 samples_sec = (F32)(mSamplesDrawn / 1000000000.0); samples_sec /= seconds; F32 pct_binds = (F32)mBinds / (F32)sTotalBinds * 100.f; @@ -1265,7 +1265,7 @@ void LLGLSLShader::uniform1i(U32 index, GLint x) if (iter == mValue.end() || iter->second.mV[0] != x) { glUniform1i(mUniform[index], x); - mValue[mUniform[index]] = LLVector4(x, 0.f, 0.f, 0.f); + mValue[mUniform[index]] = LLVector4((F32)x, 0.f, 0.f, 0.f); } } } @@ -1405,7 +1405,7 @@ void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v) if (mUniform[index] >= 0) { const auto& iter = mValue.find(mUniform[index]); - LLVector4 vec(v[0], 0.f, 0.f, 0.f); + LLVector4 vec((F32)v[0], 0.f, 0.f, 0.f); if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) { glUniform1iv(mUniform[index], count, v); @@ -1432,7 +1432,7 @@ void LLGLSLShader::uniform4iv(U32 index, U32 count, const GLint* v) if (mUniform[index] >= 0) { const auto& iter = mValue.find(mUniform[index]); - LLVector4 vec(v[0], v[1], v[2], v[3]); + LLVector4 vec((F32)v[0], (F32)v[1], (F32)v[2], (F32)v[3]); if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) { glUniform1iv(mUniform[index], count, v); @@ -1702,7 +1702,7 @@ void LLGLSLShader::uniform1i(const LLStaticHashedString& uniform, GLint v) if (location >= 0) { const auto& iter = mValue.find(location); - LLVector4 vec(v, 0.f, 0.f, 0.f); + LLVector4 vec((F32)v, 0.f, 0.f, 0.f); if (iter == mValue.end() || shouldChange(iter->second, vec)) { glUniform1i(location, v); @@ -1718,7 +1718,7 @@ void LLGLSLShader::uniform1iv(const LLStaticHashedString& uniform, U32 count, co if (location >= 0) { - LLVector4 vec(v[0], 0, 0, 0); + LLVector4 vec((F32)v[0], 0.f, 0.f, 0.f); const auto& iter = mValue.find(location); if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) { @@ -1736,7 +1736,7 @@ void LLGLSLShader::uniform4iv(const LLStaticHashedString& uniform, U32 count, co if (location >= 0) { - LLVector4 vec(v[0], v[1], v[2], v[3]); + LLVector4 vec((F32)v[0], (F32)v[1], (F32)v[2], (F32)v[3]); const auto& iter = mValue.find(location); if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) { @@ -1755,7 +1755,7 @@ void LLGLSLShader::uniform2i(const LLStaticHashedString& uniform, GLint i, GLint if (location >= 0) { const auto& iter = mValue.find(location); - LLVector4 vec(i, j, 0.f, 0.f); + LLVector4 vec((F32)i, (F32)j, 0.f, 0.f); if (iter == mValue.end() || shouldChange(iter->second, vec)) { glUniform2i(location, i, j); diff --git a/indra/llrender/llgltexture.cpp b/indra/llrender/llgltexture.cpp index e614f45986..4dcca5a726 100644 --- a/indra/llrender/llgltexture.cpp +++ b/indra/llrender/llgltexture.cpp @@ -351,20 +351,6 @@ void LLGLTexture::forceUpdateBindStats(void) const return mGLTexturep->forceUpdateBindStats() ; } -U32 LLGLTexture::getTexelsInAtlas() const -{ - llassert(mGLTexturep.notNull()) ; - - return mGLTexturep->getTexelsInAtlas() ; -} - -U32 LLGLTexture::getTexelsInGLTexture() const -{ - llassert(mGLTexturep.notNull()) ; - - return mGLTexturep->getTexelsInGLTexture() ; -} - bool LLGLTexture::isGLTextureCreated() const { llassert(mGLTexturep.notNull()) ; @@ -372,13 +358,6 @@ bool LLGLTexture::isGLTextureCreated() const return mGLTexturep->isGLTextureCreated() ; } -S32 LLGLTexture::getDiscardLevelInAtlas() const -{ - llassert(mGLTexturep.notNull()) ; - - return mGLTexturep->getDiscardLevelInAtlas() ; -} - void LLGLTexture::destroyGLTexture() { if(mGLTexturep.notNull() && mGLTexturep->getHasGLTexture()) diff --git a/indra/llrender/llgltexture.h b/indra/llrender/llgltexture.h index 0901243f8f..a7de20dc5c 100644 --- a/indra/llrender/llgltexture.h +++ b/indra/llrender/llgltexture.h @@ -51,10 +51,10 @@ public: BOOST_NONE = 0, BOOST_AVATAR , BOOST_AVATAR_BAKED , - BOOST_SCULPTED , BOOST_TERRAIN , // Needed for minimap generation for now. Lower than BOOST_HIGH so the texture stats don't get forced, i.e. texture stats are manually managed by minimap/terrain instead. BOOST_HIGH = 10, + BOOST_SCULPTED , BOOST_BUMP , BOOST_UNUSED_1 , // Placeholder to avoid disrupting habits around texture debug BOOST_SELECTED , @@ -75,7 +75,6 @@ public: AVATAR_SCRATCH_TEX, DYNAMIC_TEX, MEDIA, - ATLAS, OTHER, MAX_GL_IMAGE_CATEGORY }; @@ -156,10 +155,7 @@ public: bool isJustBound()const ; void forceUpdateBindStats(void) const; - U32 getTexelsInAtlas() const ; - U32 getTexelsInGLTexture() const ; bool isGLTextureCreated() const ; - S32 getDiscardLevelInAtlas() const ; LLGLTextureState getTextureState() const { return mTextureState; } //--------------------------------------------------------------------------------------------- diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 7e5cd628c1..058afa0cf2 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -41,6 +41,7 @@ #include "llrender.h" #include "llwindow.h" #include "llframetimer.h" +#include <unordered_set> extern LL_COMMON_API bool on_main_thread(); @@ -56,6 +57,9 @@ const F32 MIN_TEXTURE_LIFETIME = 10.f; U32 wpo2(U32 i); +U32 LLImageGL::sFrameCount = 0; + + // texture memory accounting (for macOS) static LLMutex sTexMemMutex; static std::unordered_map<U32, U64> sTextureAllocs; @@ -130,10 +134,9 @@ S32 LLImageGL::sCount = 0; bool LLImageGL::sGlobalUseAnisotropic = false; F32 LLImageGL::sLastFrameTime = 0.f; -bool LLImageGL::sAllowReadBackRaw = false ; LLImageGL* LLImageGL::sDefaultGLTexture = NULL ; bool LLImageGL::sCompressTextures = false; -std::set<LLImageGL*> LLImageGL::sImageList; +std::unordered_set<LLImageGL*> LLImageGL::sImageList; bool LLImageGLThread::sEnabledTextures = false; @@ -150,6 +153,9 @@ S32 LLImageGL::sMaxCategories = 1 ; //optimization for when we don't need to calculate mIsMask bool LLImageGL::sSkipAnalyzeAlpha; +U32 LLImageGL::sScratchPBO = 0; +U32 LLImageGL::sScratchPBOSize = 0; + //------------------------ //**************************************************************************************************** @@ -159,20 +165,6 @@ bool LLImageGL::sSkipAnalyzeAlpha; //************************************************************************************** //below are functions for debug use //do not delete them even though they are not currently being used. -void check_all_images() -{ - for (std::set<LLImageGL*>::iterator iter = LLImageGL::sImageList.begin(); - iter != LLImageGL::sImageList.end(); iter++) - { - LLImageGL* glimage = *iter; - if (glimage->getTexName() && glimage->isGLTextureCreated()) - { - gGL.getTexUnit(0)->bind(glimage) ; - glimage->checkTexSize() ; - gGL.getTexUnit(0)->unbind(glimage->getTarget()) ; - } - } -} void LLImageGL::checkTexSize(bool forced) const { @@ -252,6 +244,11 @@ void LLImageGL::initClass(LLWindow* window, S32 num_catagories, bool skip_analyz LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; sSkipAnalyzeAlpha = skip_analyze_alpha; + if (sScratchPBO == 0) + { + glGenBuffers(1, &sScratchPBO); + } + if (thread_texture_loads || thread_media_updates) { LLImageGLThread::createInstance(window); @@ -265,6 +262,12 @@ void LLImageGL::cleanupClass() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; LLImageGLThread::deleteSingleton(); + if (sScratchPBO != 0) + { + glDeleteBuffers(1, &sScratchPBO); + sScratchPBO = 0; + sScratchPBOSize = 0; + } } @@ -360,66 +363,19 @@ void LLImageGL::updateStats(F32 current_time) //---------------------------------------------------------------------------- //static -void LLImageGL::destroyGL(bool save_state) +void LLImageGL::destroyGL() { for (S32 stage = 0; stage < gGLManager.mNumTextureImageUnits; stage++) { gGL.getTexUnit(stage)->unbind(LLTexUnit::TT_TEXTURE); } - - sAllowReadBackRaw = true ; - for (std::set<LLImageGL*>::iterator iter = sImageList.begin(); - iter != sImageList.end(); iter++) - { - LLImageGL* glimage = *iter; - if (glimage->mTexName) - { - if (save_state && glimage->isGLTextureCreated() && glimage->mComponents) - { - glimage->mSaveData = new LLImageRaw; - if(!glimage->readBackRaw(glimage->mCurrentDiscardLevel, glimage->mSaveData, false)) //necessary, keep it. - { - glimage->mSaveData = NULL ; - } - } - - glimage->destroyGLTexture(); - stop_glerror(); - } - } - sAllowReadBackRaw = false ; -} - -//static -void LLImageGL::restoreGL() -{ - for (std::set<LLImageGL*>::iterator iter = sImageList.begin(); - iter != sImageList.end(); iter++) - { - LLImageGL* glimage = *iter; - if(glimage->getTexName()) - { - LL_ERRS() << "tex name is not 0." << LL_ENDL ; - } - if (glimage->mSaveData.notNull()) - { - if (glimage->getComponents() && glimage->mSaveData->getComponents()) - { - glimage->createGLTexture(glimage->mCurrentDiscardLevel, glimage->mSaveData, 0, true, glimage->getCategory()); - stop_glerror(); - } - glimage->mSaveData = NULL; // deletes data - } - } } //static void LLImageGL::dirtyTexOptions() { - for (std::set<LLImageGL*>::iterator iter = sImageList.begin(); - iter != sImageList.end(); iter++) + for (auto& glimage : sImageList) { - LLImageGL* glimage = *iter; glimage->mTexOptionsDirty = true; stop_glerror(); } @@ -542,10 +498,6 @@ void LLImageGL::init(bool usemipmaps) mHeight = 0; mCurrentDiscardLevel = -1; - mDiscardLevelInAtlas = -1 ; - mTexelsInAtlas = 0 ; - mTexelsInGLTexture = 0 ; - mAllowCompression = true; mTarget = GL_TEXTURE_2D; @@ -622,9 +574,6 @@ bool LLImageGL::setSize(S32 width, S32 height, S32 ncomponents, S32 discard_leve return false; } - // pickmask validity depends on old image size, delete it - freePickMask(); - mWidth = width; mHeight = height; mComponents = ncomponents; @@ -789,7 +738,7 @@ bool LLImageGL::setImage(const U8* data_in, bool data_hasmips /* = false */, S32 } if (is_compressed) { - S32 tex_size = dataFormatBytes(mFormatPrimary, w, h); + GLsizei tex_size = (GLsizei)dataFormatBytes(mFormatPrimary, w, h); glCompressedTexImage2D(mTarget, gl_level, mFormatPrimary, w, h, 0, tex_size, (GLvoid *)data_in); stop_glerror(); } @@ -992,7 +941,7 @@ bool LLImageGL::setImage(const U8* data_in, bool data_hasmips /* = false */, S32 S32 h = getHeight(); if (is_compressed) { - S32 tex_size = dataFormatBytes(mFormatPrimary, w, h); + GLsizei tex_size = (GLsizei)dataFormatBytes(mFormatPrimary, w, h); glCompressedTexImage2D(mTarget, 0, mFormatPrimary, w, h, 0, tex_size, (GLvoid *)data_in); stop_glerror(); } @@ -1025,98 +974,6 @@ bool LLImageGL::setImage(const U8* data_in, bool data_hasmips /* = false */, S32 return true; } -bool LLImageGL::preAddToAtlas(S32 discard_level, const LLImageRaw* raw_image) -{ - //not compatible with core GL profile - llassert(!LLRender::sGLCoreProfile); - - if (gGLManager.mIsDisabled) - { - LL_WARNS() << "Trying to create a texture while GL is disabled!" << LL_ENDL; - return false; - } - llassert(gGLManager.mInited); - stop_glerror(); - - if (discard_level < 0) - { - llassert(mCurrentDiscardLevel >= 0); - discard_level = mCurrentDiscardLevel; - } - - // Actual image width/height = raw image width/height * 2^discard_level - S32 w = raw_image->getWidth() << discard_level; - S32 h = raw_image->getHeight() << discard_level; - - // setSize may call destroyGLTexture if the size does not match - if (!setSize(w, h, raw_image->getComponents(), discard_level)) - { - LL_WARNS() << "Trying to create a texture with incorrect dimensions!" << LL_ENDL; - return false; - } - - if (!mHasExplicitFormat) - { - switch (mComponents) - { - case 1: - // Use luminance alpha (for fonts) - mFormatInternal = GL_LUMINANCE8; - mFormatPrimary = GL_LUMINANCE; - mFormatType = GL_UNSIGNED_BYTE; - break; - case 2: - // Use luminance alpha (for fonts) - mFormatInternal = GL_LUMINANCE8_ALPHA8; - mFormatPrimary = GL_LUMINANCE_ALPHA; - mFormatType = GL_UNSIGNED_BYTE; - break; - case 3: - mFormatInternal = GL_RGB8; - mFormatPrimary = GL_RGB; - mFormatType = GL_UNSIGNED_BYTE; - break; - case 4: - mFormatInternal = GL_RGBA8; - mFormatPrimary = GL_RGBA; - mFormatType = GL_UNSIGNED_BYTE; - break; - default: - LL_ERRS() << "Bad number of components for texture: " << (U32) getComponents() << LL_ENDL; - } - } - - mCurrentDiscardLevel = discard_level; - mDiscardLevelInAtlas = discard_level; - mTexelsInAtlas = raw_image->getWidth() * raw_image->getHeight() ; - mLastBindTime = sLastFrameTime; - mGLTextureCreated = false ; - - glPixelStorei(GL_UNPACK_ROW_LENGTH, raw_image->getWidth()); - stop_glerror(); - - if(mFormatSwapBytes) - { - glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); - stop_glerror(); - } - - return true ; -} - -void LLImageGL::postAddToAtlas() -{ - if(mFormatSwapBytes) - { - glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); - stop_glerror(); - } - - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - gGL.getTexUnit(0)->setTextureFilteringOption(mFilterOption); - stop_glerror(); -} - U32 type_width_from_pixtype(U32 pixtype) { U32 type_width = 0; @@ -1149,7 +1006,7 @@ bool should_stagger_image_set(bool compressed) #else // glTexSubImage2D doesn't work with compressed textures on select tested Nvidia GPUs on Windows 10 -Cosmic,2023-03-08 // Setting media textures off-thread seems faster when not using sub_image_lines (Nvidia/Windows 10) -Cosmic,2023-03-31 - return !compressed && on_main_thread(); + return !compressed && on_main_thread() && !gGLManager.mIsIntel; #endif } @@ -1332,12 +1189,36 @@ void LLImageGL::generateTextures(S32 numTextures, U32 *textures) } // static +void LLImageGL::updateClass() +{ + sFrameCount++; +} + +// static void LLImageGL::deleteTextures(S32 numTextures, const U32 *textures) { + // wait a few frames before actually deleting the textures to avoid + // synchronization issues with the GPU + static std::vector<U32> sFreeList[4]; + if (gGLManager.mInited) { - free_tex_images(numTextures, textures); - glDeleteTextures(numTextures, textures); + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + U32 idx = sFrameCount % 4; + + for (S32 i = 0; i < numTextures; ++i) + { + sFreeList[idx].push_back(textures[i]); + } + + idx = (sFrameCount + 3) % 4; + + if (!sFreeList[idx].empty()) + { + glDeleteTextures((GLsizei) sFreeList[idx].size(), sFreeList[idx].data()); + free_tex_images((GLsizei) sFreeList[idx].size(), sFreeList[idx].data()); + sFreeList[idx].resize(0); + } } } @@ -1752,7 +1633,6 @@ bool LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, bool data_ mTextureMemory = (S64Bytes)getMipBytes(mCurrentDiscardLevel); - mTexelsInGLTexture = getWidth() * getHeight(); // mark this as bound at this point, so we don't throw it out immediately mLastBindTime = sLastFrameTime; @@ -1830,8 +1710,7 @@ void LLImageGL::syncTexName(LLGLuint texname) bool LLImageGL::readBackRaw(S32 discard_level, LLImageRaw* imageraw, bool compressed_ok) const { - llassert_always(sAllowReadBackRaw) ; - //LL_ERRS() << "should not call this function!" << LL_ENDL ; + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; if (discard_level < 0) { @@ -2297,6 +2176,8 @@ void LLImageGL::analyzeAlpha(const void* data_in, U32 w, U32 h) //---------------------------------------------------------------------------- U32 LLImageGL::createPickMask(S32 pWidth, S32 pHeight) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + freePickMask(); U32 pick_width = pWidth/2 + 1; U32 pick_height = pHeight/2 + 1; @@ -2314,7 +2195,6 @@ U32 LLImageGL::createPickMask(S32 pWidth, S32 pHeight) //---------------------------------------------------------------------------- void LLImageGL::freePickMask() { - // pickmask validity depends on old image size, delete it if (mPickMask != NULL) { delete [] mPickMask; @@ -2352,16 +2232,16 @@ void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) return ; } - freePickMask(); - if (mFormatType != GL_UNSIGNED_BYTE || ((mFormatPrimary != GL_RGBA) && (mFormatPrimary != GL_SRGB_ALPHA))) { //cannot generate a pick mask for this texture + freePickMask(); return; } + #ifdef SHOW_ASSERT const U32 pickSize = createPickMask(width, height); #else // SHOW_ASSERT @@ -2460,6 +2340,114 @@ void LLImageGL::resetCurTexSizebar() sCurTexSizeBar = -1 ; sCurTexPickSize = -1 ; } + +bool LLImageGL::scaleDown(S32 desired_discard) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + + if (mTarget != GL_TEXTURE_2D) + { + return false; + } + + desired_discard = llmin(desired_discard, mMaxDiscardLevel); + + if (desired_discard <= mCurrentDiscardLevel) + { + return false; + } + + S32 mip = desired_discard - mCurrentDiscardLevel; + + S32 desired_width = getWidth(desired_discard); + S32 desired_height = getHeight(desired_discard); + + if (gGLManager.mDownScaleMethod == 0) + { // use an FBO to downscale the texture + // allocate new texture + U32 temp_texname = 0; + generateTextures(1, &temp_texname); + gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, temp_texname, true); + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glTexImage2D"); + glTexImage2D(mTarget, 0, mFormatPrimary, desired_width, desired_height, 0, mFormatPrimary, mFormatType, NULL); + } + + // account for new texture getting created + alloc_tex_image(desired_width, desired_height, mFormatPrimary); + + // Use render-to-texture to scale down the texture + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glFramebufferTexture2D"); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, mTarget, temp_texname, 0); + } + + glViewport(0, 0, desired_width, desired_height); + + // draw a full screen triangle + gGL.getTexUnit(0)->bind(this); + glDrawArrays(GL_TRIANGLES, 0, 3); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + + // delete old texture and assign new texture name + deleteTextures(1, &mTexName); + mTexName = temp_texname; + + if (mHasMipMaps) + { // generate mipmaps if needed + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glGenerateMipmap"); + gGL.getTexUnit(0)->bind(this); + glGenerateMipmap(mTarget); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } + } + else + { // use a PBO to downscale the texture + U64 size = getBytes(desired_discard); + llassert(size <= 2048 * 2048 * 4); // we shouldn't be using this method to downscale huge textures, but it'll work + gGL.getTexUnit(0)->bind(this); + + if (sScratchPBO == 0) + { + glGenBuffers(1, &sScratchPBO); + sScratchPBOSize = 0; + } + + glBindBuffer(GL_PIXEL_PACK_BUFFER, sScratchPBO); + + if (size > sScratchPBOSize) + { + glBufferData(GL_PIXEL_PACK_BUFFER, size, NULL, GL_STREAM_COPY); + sScratchPBOSize = (U32)size; + } + + glGetTexImage(mTarget, mip, mFormatPrimary, mFormatType, nullptr); + + free_tex_image(mTexName); + + glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); + + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, sScratchPBO); + glTexImage2D(mTarget, 0, mFormatPrimary, desired_width, desired_height, 0, mFormatPrimary, mFormatType, nullptr); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); + + alloc_tex_image(desired_width, desired_height, mFormatPrimary); + + if (mHasMipMaps) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glGenerateMipmap"); + glGenerateMipmap(mTarget); + } + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + } + + mCurrentDiscardLevel = desired_discard; + + return true; +} + + //---------------------------------------------------------------------------- #if LL_IMAGEGL_THREAD_CHECK void LLImageGL::checkActiveThread() diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 5c7a5ce821..5073701c30 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -39,6 +39,7 @@ #include "llrender.h" #include "threadpool.h" #include "workqueue.h" +#include <unordered_set> #define LL_IMAGEGL_THREAD_CHECK 0 //set to 1 to enable thread debugging for ImageGL @@ -61,6 +62,9 @@ class LLImageGL : public LLRefCount friend class LLTexUnit; public: + // call once per frame + static void updateClass(); + // Get an estimate of how many bytes have been allocated in vram for textures. // Does not include mipmaps. // NOTE: multiplying this number by two gives a good estimate for total @@ -83,9 +87,8 @@ public: // needs to be called every frame static void updateStats(F32 current_time); - // Save off / restore GL textures - static void destroyGL(bool save_state = true); - static void restoreGL(); + // cleanup GL state + static void destroyGL(); static void dirtyTexOptions(); static bool checkSize(S32 width, S32 height); @@ -148,6 +151,10 @@ public: S32 getDiscardLevel() const { return mCurrentDiscardLevel; } S32 getMaxDiscardLevel() const { return mMaxDiscardLevel; } + // override the current discard level + // should only be used for local textures where you know exactly what you're doing + void setDiscardLevel(S32 level) { mCurrentDiscardLevel = level; } + S32 getCurrentWidth() const { return mWidth ;} S32 getCurrentHeight() const { return mHeight ;} S32 getWidth(S32 discard_level = -1) const; @@ -194,26 +201,26 @@ public: void setFilteringOption(LLTexUnit::eTextureFilterOptions option); LLTexUnit::eTextureFilterOptions getFilteringOption(void) const { return mFilterOption; } - LLGLenum getTexTarget()const { return mTarget ;} - S8 getDiscardLevelInAtlas()const {return mDiscardLevelInAtlas;} - U32 getTexelsInAtlas()const { return mTexelsInAtlas ;} - U32 getTexelsInGLTexture()const {return mTexelsInGLTexture;} - + LLGLenum getTexTarget()const { return mTarget; } void init(bool usemipmaps); virtual void cleanup(); // Clean up the LLImageGL so it can be reinitialized. Be careful when using this in derived class destructors void setNeedsAlphaAndPickMask(bool need_mask); - bool preAddToAtlas(S32 discard_level, const LLImageRaw* raw_image); - void postAddToAtlas() ; - #if LL_IMAGEGL_THREAD_CHECK // thread debugging std::thread::id mActiveThread; void checkActiveThread(); #endif + // scale down to the desired discard level using GPU + // returns true if texture was scaled down + // desired discard will be clamped to max discard + // if desired discard is less than or equal to current discard, no scaling will occur + // only works for GL_TEXTURE_2D target + bool scaleDown(S32 desired_discard); + public: // Various GL/Rendering options S64Bytes mTextureMemory; @@ -240,15 +247,10 @@ private: bool mGLTextureCreated ; LLGLuint mTexName; - //LLGLuint mNewTexName = 0; // tex name set by background thread to be applied in main thread U16 mWidth; U16 mHeight; S8 mCurrentDiscardLevel; - S8 mDiscardLevelInAtlas; - U32 mTexelsInAtlas ; - U32 mTexelsInGLTexture; - bool mAllowCompression; protected: @@ -275,9 +277,9 @@ protected: // STATICS public: - static std::set<LLImageGL*> sImageList; + static std::unordered_set<LLImageGL*> sImageList; static S32 sCount; - + static U32 sFrameCount; static F32 sLastFrameTime; // Global memory statistics @@ -301,6 +303,8 @@ public: private: static S32 sMaxCategories; static bool sSkipAnalyzeAlpha; + static U32 sScratchPBO; + static U32 sScratchPBOSize; //the flag to allow to call readBackRaw(...). //can be removed if we do not use that function at all. diff --git a/indra/llrender/llpostprocess.cpp b/indra/llrender/llpostprocess.cpp index 8ebd09f20d..eef7193c92 100644 --- a/indra/llrender/llpostprocess.cpp +++ b/indra/llrender/llpostprocess.cpp @@ -343,7 +343,7 @@ void LLPostProcess::viewOrthogonal(unsigned int width, unsigned int height) gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); gGL.loadIdentity(); - gGL.ortho( 0.f, (GLdouble) width , (GLdouble) height , 0.f, -1.f, 1.f ); + gGL.ortho( 0.f, (GLfloat) width , (GLfloat) height , 0.f, -1.f, 1.f ); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); gGL.loadIdentity(); diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index a0209fab43..1301d325a0 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1514,7 +1514,7 @@ LLLightState* LLRender::getLight(U32 index) void LLRender::setAmbientLightColor(const LLColor4& color) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; if (color != mAmbientLightColor) { ++mLightHash; diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index be9f3895e7..e6b4118beb 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -297,7 +297,11 @@ public: ALTERNATE_DIFFUSE_MAP = 1, NORMAL_MAP = 1, SPECULAR_MAP = 2, - NUM_TEXTURE_CHANNELS = 3, + BASECOLOR_MAP = 3, + METALLIC_ROUGHNESS_MAP = 4, + GLTF_NORMAL_MAP = 5, + EMISSIVE_MAP = 6, + NUM_TEXTURE_CHANNELS = 7, }; enum eVolumeTexIndex : U8 diff --git a/indra/llrender/llrender2dutils.cpp b/indra/llrender/llrender2dutils.cpp index ef02fbd071..176c7a5d2c 100644 --- a/indra/llrender/llrender2dutils.cpp +++ b/indra/llrender/llrender2dutils.cpp @@ -364,7 +364,7 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex { // add in offset of current image to current UI translation const LLVector3 ui_scale = gGL.getUIScale(); - const LLVector3 ui_translation = (gGL.getUITranslation() + LLVector3(x, y, 0.f)).scaledVec(ui_scale); + const LLVector3 ui_translation = (gGL.getUITranslation() + LLVector3((F32)x, (F32)y, 0.f)).scaledVec(ui_scale); F32 uv_width = uv_outer_rect.getWidth(); F32 uv_height = uv_outer_rect.getHeight(); @@ -375,8 +375,8 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex uv_outer_rect.mLeft + (center_rect.mRight * uv_width), uv_outer_rect.mBottom + (center_rect.mBottom * uv_height)); - F32 image_width = image->getWidth(0); - F32 image_height = image->getHeight(0); + F32 image_width = (F32)image->getWidth(0); + F32 image_height = (F32)image->getHeight(0); S32 image_natural_width = ll_round(image_width * uv_width); S32 image_natural_height = ll_round(image_height * uv_height); @@ -413,10 +413,10 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex draw_center_rect.setCenterAndSize(uv_center_rect.getCenterX() * width, uv_center_rect.getCenterY() * height, scaled_width, scaled_height); } - draw_center_rect.mLeft = ll_round(ui_translation.mV[VX] + (F32)draw_center_rect.mLeft * ui_scale.mV[VX]); - draw_center_rect.mTop = ll_round(ui_translation.mV[VY] + (F32)draw_center_rect.mTop * ui_scale.mV[VY]); - draw_center_rect.mRight = ll_round(ui_translation.mV[VX] + (F32)draw_center_rect.mRight * ui_scale.mV[VX]); - draw_center_rect.mBottom = ll_round(ui_translation.mV[VY] + (F32)draw_center_rect.mBottom * ui_scale.mV[VY]); + draw_center_rect.mLeft = (F32)ll_round(ui_translation.mV[VX] + (F32)draw_center_rect.mLeft * ui_scale.mV[VX]); + draw_center_rect.mTop = (F32)ll_round(ui_translation.mV[VY] + (F32)draw_center_rect.mTop * ui_scale.mV[VY]); + draw_center_rect.mRight = (F32)ll_round(ui_translation.mV[VX] + (F32)draw_center_rect.mRight * ui_scale.mV[VX]); + draw_center_rect.mBottom = (F32)ll_round(ui_translation.mV[VY] + (F32)draw_center_rect.mBottom * ui_scale.mV[VY]); LLRectf draw_outer_rect(ui_translation.mV[VX], ui_translation.mV[VY] + height * ui_scale.mV[VY], diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index efdde77a32..f700201ace 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -123,7 +123,7 @@ bool LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, LLT if (mGenerateMipMaps != LLTexUnit::TMG_NONE) { // Calculate the number of mip levels based upon resolution that we should have. - mMipLevels = 1 + floor(log10((float)llmax(mResX, mResY))/log10(2.0)); + mMipLevels = 1 + (U32)floor(log10((float)llmax(mResX, mResY)) / log10(2.0)); } if (depth) @@ -426,14 +426,17 @@ void LLRenderTarget::bindTarget() GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3}; - glDrawBuffers(static_cast<GLsizei>(mTex.size()), drawbuffers); if (mTex.empty()) { //no color buffer to draw to glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); } - + else + { + glDrawBuffers(static_cast<GLsizei>(mTex.size()), drawbuffers); + glReadBuffer(GL_COLOR_ATTACHMENT0); + } check_framebuffer_status(); glViewport(0, 0, mResX, mResY); @@ -519,7 +522,8 @@ void LLRenderTarget::flush() llassert(sCurFBO == mFBO); llassert(sBoundTarget == this); - if (mGenerateMipMaps == LLTexUnit::TMG_AUTO) { + if (mGenerateMipMaps == LLTexUnit::TMG_AUTO) + { LL_PROFILE_GPU_ZONE("rt generate mipmaps"); bindTexture(0, 0, LLTexUnit::TFO_TRILINEAR); glGenerateMipmap(GL_TEXTURE_2D); @@ -540,6 +544,8 @@ void LLRenderTarget::flush() glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); sCurResX = gGLViewport[2]; sCurResY = gGLViewport[3]; + glReadBuffer(GL_BACK); + glDrawBuffer(GL_BACK); } } diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h index 340276a752..cd3290cf66 100644 --- a/indra/llrender/llrendertarget.h +++ b/indra/llrender/llrendertarget.h @@ -61,7 +61,7 @@ class LLRenderTarget { public: - //whether or not to use FBO implementation + // Whether or not to use FBO implementation static bool sUseFBO; static U32 sBytesAllocated; static U32 sCurFBO; @@ -172,6 +172,8 @@ public: // *HACK void swapFBORefs(LLRenderTarget& other); + static LLRenderTarget* sBoundTarget; + protected: U32 mResX; U32 mResY; @@ -186,8 +188,6 @@ protected: U32 mMipLevels; LLTexUnit::eTextureType mUsage; - - static LLRenderTarget* sBoundTarget; }; #endif diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index a8e9f20b40..bc542d325e 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -44,7 +44,6 @@ using std::make_pair; using std::string; LLShaderMgr * LLShaderMgr::sInstance = NULL; -bool LLShaderMgr::sMirrorsEnabled = false; LLShaderMgr::LLShaderMgr() { @@ -600,11 +599,6 @@ GLuint LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_lev extra_code_text[extra_code_count++] = strdup("#define FXAA_GLSL_130 1\n"); } - if (sMirrorsEnabled) - { - extra_code_text[extra_code_count++] = strdup("#define HERO_PROBES 1\n"); - } - // Use alpha float to store bit flags // See: C++: addDeferredAttachment(), shader: frag_data[2] extra_code_text[extra_code_count++] = strdup("#define GBUFFER_FLAG_SKIP_ATMOS 0.0 \n"); // atmo kill @@ -1003,7 +997,7 @@ void LLShaderMgr::initShaderCache(bool enabled, const LLUUID& old_cache_version, ProgramBinaryData binary_info = ProgramBinaryData(); binary_info.mBinaryFormat = data_pair.second["binary_format"].asInteger(); binary_info.mBinaryLength = data_pair.second["binary_size"].asInteger(); - binary_info.mLastUsedTime = data_pair.second["last_used"].asReal(); + binary_info.mLastUsedTime = (F32)data_pair.second["last_used"].asReal(); mShaderBinaryCache.insert_or_assign(LLUUID(data_pair.first), binary_info); } } @@ -1034,7 +1028,7 @@ void LLShaderMgr::persistShaderCacheMetadata() LLSD out = LLSD::emptyMap(); static const F32 LRU_TIME = (60.f * 60.f) * 24.f * 7.f; // 14 days - const F32 current_time = LLTimer::getTotalSeconds(); + const F32 current_time = (F32)LLTimer::getTotalSeconds(); for (auto it = mShaderBinaryCache.begin(); it != mShaderBinaryCache.end();) { const ProgramBinaryData& shader_metadata = it->second; @@ -1093,7 +1087,7 @@ bool LLShaderMgr::loadCachedProgramBinary(LLGLSLShader* shader) glGetProgramiv(shader->mProgramObject, GL_LINK_STATUS, &success); if (error == GL_NO_ERROR && success == GL_TRUE) { - binary_iter->second.mLastUsedTime = LLTimer::getTotalSeconds(); + binary_iter->second.mLastUsedTime = (F32)LLTimer::getTotalSeconds(); LL_INFOS() << "Loaded cached binary for shader: " << shader->mName << LL_ENDL; return true; } @@ -1131,7 +1125,7 @@ bool LLShaderMgr::saveCachedProgramBinary(LLGLSLShader* shader) fwrite(program_binary.data(), sizeof(U8), program_binary.size(), outfile); outfile.close(); - binary_info.mLastUsedTime = LLTimer::getTotalSeconds(); + binary_info.mLastUsedTime = (F32)LLTimer::getTotalSeconds(); mShaderBinaryCache.insert_or_assign(shader->mShaderHash, binary_info); return true; diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index fe6137c448..921ef20997 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -378,7 +378,6 @@ public: bool mShaderCacheInitialized = false; bool mShaderCacheEnabled = false; std::string mShaderCacheDir; - static bool sMirrorsEnabled; protected: diff --git a/indra/llrender/lluiimage.cpp b/indra/llrender/lluiimage.cpp index bcf665ca18..d31a91e2af 100644 --- a/indra/llrender/lluiimage.cpp +++ b/indra/llrender/lluiimage.cpp @@ -83,7 +83,7 @@ void LLUIImage::draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, c LLRender2D::getInstance()->pushMatrix(); { - LLVector3 rect_origin = origin_agent + (rect.mLeft * x_axis) + (rect.mBottom * y_axis); + LLVector3 rect_origin = origin_agent + ((F32)rect.mLeft * x_axis) + ((F32)rect.mBottom * y_axis); LLRender2D::getInstance()->translate(rect_origin.mV[VX], rect_origin.mV[VY], rect_origin.mV[VZ]); @@ -100,8 +100,8 @@ void LLUIImage::draw3D(const LLVector3& origin_agent, const LLVector3& x_axis, c (rect.getHeight() - (border_height * border_scale * 0.5f)) / (F32)rect.getHeight(), (rect.getWidth() - (border_width * border_scale * 0.5f)) / (F32)rect.getWidth(), (border_height * border_scale * 0.5f) / (F32)rect.getHeight()), - rect.getWidth() * x_axis, - rect.getHeight() * y_axis); + (F32)rect.getWidth() * x_axis, + (F32)rect.getHeight() * y_axis); } LLRender2D::getInstance()->popMatrix(); } diff --git a/indra/llui/llaccordionctrl.cpp b/indra/llui/llaccordionctrl.cpp index 4682044d6e..06f7a20add 100644 --- a/indra/llui/llaccordionctrl.cpp +++ b/indra/llui/llaccordionctrl.cpp @@ -379,12 +379,10 @@ void LLAccordionCtrl::initNoTabsWidget(const LLTextBox::Params& tb_params) void LLAccordionCtrl::updateNoTabsHelpTextVisibility() { - bool visible_exists = false; - std::vector<LLAccordionCtrlTab*>::const_iterator it = mAccordionTabs.begin(); - const std::vector<LLAccordionCtrlTab*>::const_iterator it_end = mAccordionTabs.end(); - while (it < it_end) + bool visible_exists{ false }; + for (auto accordion_tab : mAccordionTabs) { - if ((*(it++))->getVisible()) + if (accordion_tab->getVisible()) { visible_exists = true; break; diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp index 6d58a2545c..ac66525030 100644 --- a/indra/llui/llaccordionctrltab.cpp +++ b/indra/llui/llaccordionctrltab.cpp @@ -602,15 +602,13 @@ void LLAccordionCtrlTab::setSelected(bool is_selected) LLView* LLAccordionCtrlTab::findContainerView() { - child_list_const_iter_t it = getChildList()->begin(), it_end = getChildList()->end(); - while (it != it_end) + for (auto child : *getChildList()) { - LLView* child = *(it++); if (DD_HEADER_NAME != child->getName() && child->getVisible()) return child; } - return NULL; + return nullptr; } void LLAccordionCtrlTab::selectOnFocusReceived() diff --git a/indra/llui/llbadge.cpp b/indra/llui/llbadge.cpp index 3397c97ee1..3ff0617554 100644 --- a/indra/llui/llbadge.cpp +++ b/indra/llui/llbadge.cpp @@ -36,7 +36,7 @@ static LLDefaultChildRegistry::Register<LLBadge> r("badge"); static const S32 BADGE_OFFSET_NOT_SPECIFIED = 0x7FFFFFFF; // Compiler optimization, generate extern template -template class LLBadge* LLView::getChild<class LLBadge>(const std::string& name, bool recurse) const; +template class LLBadge* LLView::getChild<class LLBadge>(std::string_view name, bool recurse) const; LLBadge::Params::Params() @@ -197,10 +197,10 @@ void renderBadgeBackground(F32 centerX, F32 centerY, F32 width, F32 height, cons F32 x = LLFontGL::sCurOrigin.mX + centerX - width * 0.5f; F32 y = LLFontGL::sCurOrigin.mY + centerY - height * 0.5f; - LLRectf screen_rect(ll_round(x), - ll_round(y), - ll_round(x) + width, - ll_round(y) + height); + LLRectf screen_rect((F32)ll_round(x), + (F32)ll_round(y), + (F32)ll_round(x) + width, + (F32)ll_round(y) + height); LLVector3 vertices[4]; vertices[0] = LLVector3(screen_rect.mRight, screen_rect.mTop, 1.0f); @@ -302,7 +302,7 @@ void LLBadge::draw() } else { - badge_center_x = location_offset_horiz; + badge_center_x = (F32)location_offset_horiz; } // Compute y position @@ -319,7 +319,7 @@ void LLBadge::draw() } else { - badge_center_y = location_offset_vert; + badge_center_y = (F32)location_offset_vert; } // diff --git a/indra/llui/llbadge.h b/indra/llui/llbadge.h index a6d584c6d7..77fe76f0da 100644 --- a/indra/llui/llbadge.h +++ b/indra/llui/llbadge.h @@ -171,7 +171,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLBADGE_CPP -extern template class LLBadge* LLView::getChild<class LLBadge>(const std::string& name, bool recurse) const; +extern template class LLBadge* LLView::getChild<class LLBadge>(std::string_view name, bool recurse) const; #endif #endif // LL_LLBADGE_H diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp index e6c045250e..9e1e3ba120 100644 --- a/indra/llui/llbutton.cpp +++ b/indra/llui/llbutton.cpp @@ -56,7 +56,7 @@ static LLDefaultChildRegistry::Register<LLButton> r("button"); // Compiler optimization, generate extern template template class LLButton* LLView::getChild<class LLButton>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; // globals S32 LLBUTTON_H_PAD = 4; @@ -188,7 +188,7 @@ LLButton::LLButton(const LLButton::Params& p) // Likewise, missing "p.button_flash_rate" is replaced by gSavedSettings.getF32("FlashPeriod"). // Note: flashing should be allowed in settings.xml (boolean key "EnableButtonFlashing"). S32 flash_count = p.button_flash_count.isProvided()? p.button_flash_count : 0; - F32 flash_rate = p.button_flash_rate.isProvided()? p.button_flash_rate : 0.0; + F32 flash_rate = p.button_flash_rate.isProvided()? p.button_flash_rate : 0.0f; mFlashingTimer = new LLFlashTimer ((LLFlashTimer::callback_t)NULL, flash_count, flash_rate); } else @@ -1273,7 +1273,7 @@ void LLButton::setFloaterToggle(LLUICtrl* ctrl, const LLSD& sdname) // Set the button control value (toggle state) to the floater visibility control (Sets the value as well) button->setControlVariable(LLFloater::getControlGroup()->getControl(vis_control_name)); // Set the clicked callback to toggle the floater - button->setClickedCallback(boost::bind(&LLFloaterReg::toggleInstance, sdname, LLSD())); + button->setClickedCallback([=](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::toggleInstance(sdname.asString(), LLSD()); }); } // static diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index fed5cdcc50..80a876393e 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -400,7 +400,7 @@ protected: // Build time optimization, generate once in .cpp file #ifndef LLBUTTON_CPP extern template class LLButton* LLView::getChild<class LLButton>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_LLBUTTON_H diff --git a/indra/llui/llcheckboxctrl.cpp b/indra/llui/llcheckboxctrl.cpp index 3bcf0a6517..dea262942b 100644 --- a/indra/llui/llcheckboxctrl.cpp +++ b/indra/llui/llcheckboxctrl.cpp @@ -45,7 +45,7 @@ static LLDefaultChildRegistry::Register<LLCheckBoxCtrl> r("check_box"); // Compiler optimization, generate extern template template class LLCheckBoxCtrl* LLView::getChild<class LLCheckBoxCtrl>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; void LLCheckBoxCtrl::WordWrap::declareValues() { diff --git a/indra/llui/llcheckboxctrl.h b/indra/llui/llcheckboxctrl.h index 3058e946c3..fc04a8a781 100644 --- a/indra/llui/llcheckboxctrl.h +++ b/indra/llui/llcheckboxctrl.h @@ -151,7 +151,7 @@ protected: // Build time optimization, generate once in .cpp file #ifndef LLCHECKBOXCTRL_CPP extern template class LLCheckBoxCtrl* LLView::getChild<class LLCheckBoxCtrl>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_LLCHECKBOXCTRL_H diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index 79dce1c714..ee1700e009 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -875,6 +875,20 @@ bool LLComboBox::handleUnicodeCharHere(llwchar uni_char) return result; } +// virtual +bool LLComboBox::handleScrollWheel(S32 x, S32 y, S32 clicks) +{ + if (mList->getVisible()) return mList->handleScrollWheel(x, y, clicks); + if (mAllowTextEntry) // We might be editable + if (!mList->getFirstSelected()) // We aren't in the list, don't kill their text + return false; + + setCurrentByIndex(llclamp(getCurrentIndex() + clicks, 0, getItemCount() - 1)); + prearrangeList(); + onCommit(); + return true; +} + void LLComboBox::setTextEntry(const LLStringExplicit& text) { if (mTextEntry) diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index cc1c2885fc..9dc6fa9257 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -114,6 +114,7 @@ public: virtual bool handleToolTip(S32 x, S32 y, MASK mask); virtual bool handleKeyHere(KEY key, MASK mask); virtual bool handleUnicodeCharHere(llwchar uni_char); + virtual bool handleScrollWheel(S32 x, S32 y, S32 clicks); // LLUICtrl interface virtual void clear(); // select nothing diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp index 9fbfb3e5fa..fe4f991921 100644 --- a/indra/llui/llconsole.cpp +++ b/indra/llui/llconsole.cpp @@ -80,7 +80,7 @@ void LLConsole::setLinePersistTime(F32 seconds) void LLConsole::reshape(S32 width, S32 height, bool called_from_parent) { S32 new_width = llmax(50, llmin(getRect().getWidth(), width)); - S32 new_height = llmax(llfloor(mFont->getLineHeight()) + 15, llmin(getRect().getHeight(), height)); + S32 new_height = llmax(mFont->getLineHeight() + 15, llmin(getRect().getHeight(), height)); if ( mConsoleWidth == new_width && mConsoleHeight == new_height ) @@ -186,7 +186,7 @@ void LLConsole::draw() LLColor4 color = LLUIColorTable::instance().getColor("ConsoleBackground"); color.mV[VALPHA] *= console_opacity; - F32 line_height = mFont->getLineHeight(); + F32 line_height = (F32)mFont->getLineHeight(); for(paragraph_it = mParagraphs.rbegin(); paragraph_it != mParagraphs.rend(); paragraph_it++) { diff --git a/indra/llui/llf32uictrl.cpp b/indra/llui/llf32uictrl.cpp index 52954ebbbb..9d041fffb0 100644 --- a/indra/llui/llf32uictrl.cpp +++ b/indra/llui/llf32uictrl.cpp @@ -37,7 +37,7 @@ LLF32UICtrl::LLF32UICtrl(const Params& p) : LLUICtrl(p), - mInitialValue(p.initial_value().asReal()), + mInitialValue((F32)p.initial_value().asReal()), mMinValue(p.min_value), mMaxValue(p.max_value), mIncrement(p.increment) @@ -47,5 +47,5 @@ LLF32UICtrl::LLF32UICtrl(const Params& p) F32 LLF32UICtrl::getValueF32() const { - return mViewModel->getValue().asReal(); + return (F32)mViewModel->getValue().asReal(); } diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp index 1799968afb..53f39766c6 100644 --- a/indra/llui/llflatlistview.cpp +++ b/indra/llui/llflatlistview.cpp @@ -1250,17 +1250,15 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items) detached_items.clear(); // Go through items and detach valid items, remove them from items panel // and add to detached_items. - pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end(); - while (iter != iter_end) + for (auto item_pair : mItemPairs) { - LLPanel* pItem = (*iter)->first; + LLPanel* pItem = item_pair->first; if (1 == pItem->notify(action)) { - selectItemPair((*iter), false); + selectItemPair(item_pair, false); mItemsPanel->removeChild(pItem); - detached_items.push_back(pItem); + detached_items.emplace_back(pItem); } - iter++; } if (!detached_items.empty()) { @@ -1268,12 +1266,10 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items) if (detached_items.size() == mItemPairs.size()) { // This way will be faster if all items were disconnected - pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end(); - while (iter != iter_end) + for (auto item_pair : mItemPairs) { - (*iter)->first = NULL; - delete *iter; - iter++; + item_pair->first = nullptr; + delete item_pair; } mItemPairs.clear(); // Also set items panel height to zero. @@ -1286,26 +1282,16 @@ void LLFlatListView::detachItems(std::vector<LLPanel*>& detached_items) } else { - std::vector<LLPanel*>::const_iterator - detached_iter = detached_items.begin(), - detached_iter_end = detached_items.end(); - while (detached_iter < detached_iter_end) + for (auto detached_item : detached_items) { - LLPanel* pDetachedItem = *detached_iter; - pairs_iterator_t iter = mItemPairs.begin(), iter_end = mItemPairs.end(); - while (iter != iter_end) + auto found_pos = std::find_if(mItemPairs.begin(), mItemPairs.end(), [detached_item](auto item_pair) { return item_pair->first == detached_item; }); + if (found_pos != mItemPairs.end()) { - item_pair_t* item_pair = *iter; - if (item_pair->first == pDetachedItem) - { - mItemPairs.erase(iter); - item_pair->first = NULL; - delete item_pair; - break; - } - iter++; + mItemPairs.erase(found_pos); + auto item_pair = *found_pos; + item_pair->first = nullptr; + delete item_pair; } - detached_iter++; } rearrangeItems(); } @@ -1412,11 +1398,10 @@ void LLFlatListViewEx::filterItems(bool re_sort, bool notify_parent) action.with("match_filter", cur_filter); mHasMatchedItems = false; - bool visibility_changed = false; - pairs_const_iterator_t iter = getItemPairs().begin(), iter_end = getItemPairs().end(); - while (iter != iter_end) + bool visibility_changed{ false }; + for (auto item_pair : getItemPairs()) { - LLPanel* pItem = (*(iter++))->first; + LLPanel* pItem = item_pair->first; visibility_changed |= updateItemVisibility(pItem, action); } diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index e6ecf3c283..12d5c41de1 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -960,8 +960,8 @@ bool LLFloater::applyRectControl() && !x_control->isDefault() && !y_control->isDefault()) { - mPosition.mX = x_control->getValue().asReal(); - mPosition.mY = y_control->getValue().asReal(); + mPosition.mX = (LL_COORD_FLOATER::value_t)x_control->getValue().asReal(); + mPosition.mY = (LL_COORD_FLOATER::value_t)y_control->getValue().asReal(); mPositioning = LLFloaterEnums::POSITIONING_RELATIVE; applyRelativePosition(); @@ -1205,24 +1205,64 @@ void LLFloater::handleReshape(const LLRect& new_rect, bool by_user) { S32 delta_x = 0; S32 delta_y = 0; + + // take translation of dependee floater into account + delta_x += new_rect.mLeft - old_rect.mLeft; + delta_y += new_rect.mBottom - old_rect.mBottom; + // check to see if it snapped to right or top, and move if dependee floater is resizing LLRect dependent_rect = floaterp->getRect(); - if (dependent_rect.mLeft - getRect().mLeft >= old_rect.getWidth() || // dependent on my right? - dependent_rect.mRight == getRect().mLeft + old_rect.getWidth()) // dependent aligned with my right + if ((dependent_rect.mLeft - getRect().mLeft >= old_rect.getWidth() || // dependent on my right? + dependent_rect.mRight == getRect().mLeft + old_rect.getWidth()) // dependent aligned with my right + && dependent_rect.mBottom <= old_rect.mTop + 1) { // was snapped directly onto right side or aligned with it delta_x += new_rect.getWidth() - old_rect.getWidth(); + + // make sure dependent still touches floater and din't go too high, + // it can go over edge, but should't detach completely + if (delta_y > 0 + && dependent_rect.mBottom + delta_y > new_rect.mTop) + { + delta_y = llmax(new_rect.mTop - dependent_rect.mBottom, 0); + } + } + else if (dependent_rect.mRight == old_rect.mLeft) + { + // make sure dependent still touches floater and don't go too high + if (delta_y > 0 + && dependent_rect.mBottom <= old_rect.mTop + && dependent_rect.mBottom + delta_y > new_rect.mTop) + { + delta_y = llmax(new_rect.mTop - dependent_rect.mBottom, 0); + } } - if (dependent_rect.mBottom - getRect().mBottom >= old_rect.getHeight() || - dependent_rect.mTop == getRect().mBottom + old_rect.getHeight()) + + if ((dependent_rect.mBottom - getRect().mBottom >= old_rect.getHeight() || + dependent_rect.mTop == getRect().mBottom + old_rect.getHeight()) + && dependent_rect.mLeft <= old_rect.mRight + 1) { // was snapped directly onto top side or aligned with it delta_y += new_rect.getHeight() - old_rect.getHeight(); - } - // take translation of dependee floater into account as well - delta_x += new_rect.mLeft - old_rect.mLeft; - delta_y += new_rect.mBottom - old_rect.mBottom; + // make sure dependent still touches floater + // and din't go too far to the right + if (delta_x > 0 + && dependent_rect.mLeft + delta_x > new_rect.mRight) + { + delta_x = llmax(new_rect.mRight - dependent_rect.mLeft, 0); + } + } + else if (dependent_rect.mTop == old_rect.mBottom) + { + // make sure dependent still touches floater and don't go too far to the right + if (delta_x > 0 + && dependent_rect.mLeft <= old_rect.mRight + && dependent_rect.mLeft + delta_x > new_rect.mRight) + { + delta_x = llmax(new_rect.mRight - dependent_rect.mLeft, 0); + } + } dependent_rect.translate(delta_x, delta_y); floaterp->setShape(dependent_rect, by_user); @@ -3618,7 +3658,7 @@ void LLFloater::applyRelativePosition() LLCoordFloater::LLCoordFloater(F32 x, F32 y, LLFloater& floater) -: coord_t((S32)x, (S32)y) +: coord_t(x, y) { mFloater = floater.getHandle(); } @@ -3661,28 +3701,28 @@ LLCoordCommon LL_COORD_FLOATER::convertToCommon() const LLCoordCommon out; if (self.mX < -0.5f) { - out.mX = ll_round(rescale(self.mX, -1.f, -0.5f, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft)); + out.mX = ll_round(rescale(self.mX, -1.f, -0.5f, (F32)(snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS)), (F32)snap_rect.mLeft)); } else if (self.mX > 0.5f) { - out.mX = ll_round(rescale(self.mX, 0.5f, 1.f, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS)); + out.mX = ll_round(rescale(self.mX, 0.5f, 1.f, (F32)(snap_rect.mRight - floater_width), (F32)(snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS))); } else { - out.mX = ll_round(rescale(self.mX, -0.5f, 0.5f, snap_rect.mLeft, snap_rect.mRight - floater_width)); + out.mX = ll_round(rescale(self.mX, -0.5f, 0.5f, (F32)snap_rect.mLeft, (F32)(snap_rect.mRight - floater_width))); } if (self.mY < -0.5f) { - out.mY = ll_round(rescale(self.mY, -1.f, -0.5f, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom)); + out.mY = ll_round(rescale(self.mY, -1.f, -0.5f, (F32)(snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS)), (F32)snap_rect.mBottom)); } else if (self.mY > 0.5f) { - out.mY = ll_round(rescale(self.mY, 0.5f, 1.f, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS)); + out.mY = ll_round(rescale(self.mY, 0.5f, 1.f, (F32)(snap_rect.mTop - floater_height), (F32)(snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS))); } else { - out.mY = ll_round(rescale(self.mY, -0.5f, 0.5f, snap_rect.mBottom, snap_rect.mTop - floater_height)); + out.mY = ll_round(rescale(self.mY, -0.5f, 0.5f, (F32)snap_rect.mBottom, (F32)(snap_rect.mTop - floater_height))); } // return center point instead of lower left @@ -3709,27 +3749,27 @@ void LL_COORD_FLOATER::convertFromCommon(const LLCoordCommon& from) if (from_x < snap_rect.mLeft) { - self.mX = rescale(from_x, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft, -1.f, -0.5f); + self.mX = rescale((F32)from_x, (F32)(snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS)), (F32)snap_rect.mLeft, -1.f, -0.5f); } else if (from_x + floater_width > snap_rect.mRight) { - self.mX = rescale(from_x, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f); + self.mX = rescale((F32)from_x, (F32)(snap_rect.mRight - floater_width), (F32)(snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS), 0.5f, 1.f); } else { - self.mX = rescale(from_x, snap_rect.mLeft, snap_rect.mRight - floater_width, -0.5f, 0.5f); + self.mX = rescale((F32)from_x, (F32)snap_rect.mLeft, (F32)(snap_rect.mRight - floater_width), -0.5f, 0.5f); } if (from_y < snap_rect.mBottom) { - self.mY = rescale(from_y, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom, -1.f, -0.5f); + self.mY = rescale((F32)from_y, (F32)(snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS)), (F32)snap_rect.mBottom, -1.f, -0.5f); } else if (from_y + floater_height > snap_rect.mTop) { - self.mY = rescale(from_y, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f); + self.mY = rescale((F32)from_y, (F32)(snap_rect.mTop - floater_height), (F32)(snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS), 0.5f, 1.f); } else { - self.mY = rescale(from_y, snap_rect.mBottom, snap_rect.mTop - floater_height, -0.5f, 0.5f); + self.mY = rescale((F32)from_y, (F32)snap_rect.mBottom, (F32)(snap_rect.mTop - floater_height), -0.5f, 0.5f); } } diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp index fd5a370bc3..a818e72f59 100644 --- a/indra/llui/llfloaterreg.cpp +++ b/indra/llui/llfloaterreg.cpp @@ -40,9 +40,9 @@ LLFloaterReg::instance_list_t LLFloaterReg::sNullInstanceList; LLFloaterReg::instance_map_t LLFloaterReg::sInstanceMap; LLFloaterReg::build_map_t LLFloaterReg::sBuildMap; -std::map<std::string,std::string> LLFloaterReg::sGroupMap; +std::map<std::string, std::string, std::less<>> LLFloaterReg::sGroupMap; bool LLFloaterReg::sBlockShowFloaters = false; -std::set<std::string> LLFloaterReg::sAlwaysShowableList; +std::set<std::string, std::less<>> LLFloaterReg::sAlwaysShowableList; static LLFloaterRegListener sFloaterRegListener; @@ -58,27 +58,31 @@ void LLFloaterReg::add(const std::string& name, const std::string& filename, con } //static -bool LLFloaterReg::isRegistered(const std::string& name) +bool LLFloaterReg::isRegistered(std::string_view name) { return sBuildMap.find(name) != sBuildMap.end(); } //static -LLFloater* LLFloaterReg::getLastFloaterInGroup(const std::string& name) +LLFloater* LLFloaterReg::getLastFloaterInGroup(std::string_view name) { - const std::string& groupname = sGroupMap[name]; - if (!groupname.empty()) + auto it = sGroupMap.find(name); + if (it != sGroupMap.end()) { - instance_list_t& list = sInstanceMap[groupname]; - if (!list.empty()) + const std::string& groupname = it->second; + if (!groupname.empty()) { - for (instance_list_t::reverse_iterator iter = list.rbegin(); iter != list.rend(); ++iter) + instance_list_t& list = sInstanceMap[groupname]; + if (!list.empty()) { - LLFloater* inst = *iter; - - if (inst->getVisible() && !inst->isMinimized()) + for (instance_list_t::reverse_iterator iter = list.rbegin(), end = list.rend(); iter != end; ++iter) { - return inst; + LLFloater* inst = *iter; + + if (inst->getVisible() && !inst->isMinimized()) + { + return inst; + } } } } @@ -99,10 +103,8 @@ LLFloater* LLFloaterReg::getLastFloaterCascading() instance_list_t& instances = sInstanceMap[group_name]; - for (instance_list_t::const_iterator iter = instances.begin(); iter != instances.end(); ++iter) + for (LLFloater* inst : instances) { - LLFloater* inst = *iter; - if (inst->getVisible() && (inst->isPositioning(LLFloaterEnums::POSITIONING_CASCADING) || inst->isPositioning(LLFloaterEnums::POSITIONING_CASCADE_GROUP))) @@ -120,20 +122,23 @@ LLFloater* LLFloaterReg::getLastFloaterCascading() } //static -LLFloater* LLFloaterReg::findInstance(const std::string& name, const LLSD& key) +LLFloater* LLFloaterReg::findInstance(std::string_view name, const LLSD& key) { LLFloater* res = NULL; - const std::string& groupname = sGroupMap[name]; - if (!groupname.empty()) + auto it = sGroupMap.find(name); + if (it != sGroupMap.end()) { - instance_list_t& list = sInstanceMap[groupname]; - for (instance_list_t::iterator iter = list.begin(); iter != list.end(); ++iter) + const std::string& groupname = it->second; + if (!groupname.empty()) { - LLFloater* inst = *iter; - if (inst->matchesKey(key)) + instance_list_t& list = sInstanceMap[groupname]; + for (LLFloater* inst : list) { - res = inst; - break; + if (inst->matchesKey(key)) + { + res = inst; + break; + } } } } @@ -141,47 +146,55 @@ LLFloater* LLFloaterReg::findInstance(const std::string& name, const LLSD& key) } //static -LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) +LLFloater* LLFloaterReg::getInstance(std::string_view name, const LLSD& key) { LLFloater* res = findInstance(name, key); if (!res) { - const LLFloaterBuildFunc& build_func = sBuildMap[name].mFunc; - const std::string& xui_file = sBuildMap[name].mFile; - if (build_func) + auto it = sBuildMap.find(name); + if (it != sBuildMap.end()) { - const std::string& groupname = sGroupMap[name]; - if (!groupname.empty()) + const LLFloaterBuildFunc& build_func = it->second.mFunc; + const std::string& xui_file = it->second.mFile; + if (build_func) { - instance_list_t& list = sInstanceMap[groupname]; - - res = build_func(key); - if (!res) - { - LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; - return NULL; - } - bool success = res->buildFromFile(xui_file); - if (!success) + auto it = sGroupMap.find(name); + if (it != sGroupMap.end()) { - LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; - return NULL; + const std::string& groupname = it->second; + if (!groupname.empty()) + { + instance_list_t& list = sInstanceMap[groupname]; + + res = build_func(key); + if (!res) + { + LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; + return NULL; + } + bool success = res->buildFromFile(xui_file); + if (!success) + { + LL_WARNS() << "Failed to build floater type: '" << name << "'." << LL_ENDL; + return NULL; + } + + // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe + if (res->mKey.isUndefined()) + { + res->mKey = key; + } + res->setInstanceName(std::string(name)); + + LLFloater* last_floater = (list.empty() ? NULL : list.back()); + + res->applyControlsAndPosition(last_floater); + + gFloaterView->adjustToFitScreen(res, false); + + list.push_back(res); + } } - - // Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe - if (res->mKey.isUndefined()) - { - res->mKey = key; - } - res->setInstanceName(name); - - LLFloater *last_floater = (list.empty() ? NULL : list.back()); - - res->applyControlsAndPosition(last_floater); - - gFloaterView->adjustToFitScreen(res, false); - - list.push_back(res); } } if (!res) @@ -193,21 +206,25 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key) } //static -LLFloater* LLFloaterReg::removeInstance(const std::string& name, const LLSD& key) +LLFloater* LLFloaterReg::removeInstance(std::string_view name, const LLSD& key) { LLFloater* res = NULL; - const std::string& groupname = sGroupMap[name]; - if (!groupname.empty()) + auto it = sGroupMap.find(name); + if (it != sGroupMap.end()) { - instance_list_t& list = sInstanceMap[groupname]; - for (instance_list_t::iterator iter = list.begin(); iter != list.end(); ++iter) + const std::string& groupname = it->second; + if (!groupname.empty()) { - LLFloater* inst = *iter; - if (inst->matchesKey(key)) + instance_list_t& list = sInstanceMap[groupname]; + for (instance_list_t::iterator iter = list.begin(); iter != list.end(); ++iter) { - res = inst; - list.erase(iter); - break; + LLFloater* inst = *iter; + if (inst->matchesKey(key)) + { + res = inst; + list.erase(iter); + break; + } } } } @@ -216,7 +233,7 @@ LLFloater* LLFloaterReg::removeInstance(const std::string& name, const LLSD& key //static // returns true if the instance existed -bool LLFloaterReg::destroyInstance(const std::string& name, const LLSD& key) +bool LLFloaterReg::destroyInstance(std::string_view name, const LLSD& key) { LLFloater* inst = removeInstance(name, key); if (inst) @@ -232,7 +249,7 @@ bool LLFloaterReg::destroyInstance(const std::string& name, const LLSD& key) // Iterators //static -LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(const std::string& name) +LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(std::string_view name) { instance_map_t::iterator iter = sInstanceMap.find(name); if (iter != sInstanceMap.end()) @@ -248,7 +265,7 @@ LLFloaterReg::const_instance_list_t& LLFloaterReg::getFloaterList(const std::str // Visibility Management //static -LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key, bool focus) +LLFloater* LLFloaterReg::showInstance(std::string_view name, const LLSD& key, bool focus) { if( sBlockShowFloaters // see EXT-7090 @@ -266,7 +283,7 @@ LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key, //static // returns true if the instance exists -bool LLFloaterReg::hideInstance(const std::string& name, const LLSD& key) +bool LLFloaterReg::hideInstance(std::string_view name, const LLSD& key) { LLFloater* instance = findInstance(name, key); if (instance) @@ -278,7 +295,7 @@ bool LLFloaterReg::hideInstance(const std::string& name, const LLSD& key) //static // returns true if the instance is visible when completed -bool LLFloaterReg::toggleInstance(const std::string& name, const LLSD& key) +bool LLFloaterReg::toggleInstance(std::string_view name, const LLSD& key) { LLFloater* instance = findInstance(name, key); if (instance && instance->isShown()) @@ -294,7 +311,7 @@ bool LLFloaterReg::toggleInstance(const std::string& name, const LLSD& key) //static // returns true if the instance exists and is visible (doesnt matter minimized or not) -bool LLFloaterReg::instanceVisible(const std::string& name, const LLSD& key) +bool LLFloaterReg::instanceVisible(std::string_view name, const LLSD& key) { LLFloater* instance = findInstance(name, key); return LLFloater::isVisible(instance); diff --git a/indra/llui/llfloaterreg.h b/indra/llui/llfloaterreg.h index 6a642cbb27..94a67c8d8b 100644 --- a/indra/llui/llfloaterreg.h +++ b/indra/llui/llfloaterreg.h @@ -51,26 +51,26 @@ public: // 2) We can change the key of a floater without altering the list. typedef std::list<LLFloater*> instance_list_t; typedef const instance_list_t const_instance_list_t; - typedef std::map<std::string, instance_list_t> instance_map_t; + typedef std::map<std::string, instance_list_t, std::less<>> instance_map_t; struct BuildData { LLFloaterBuildFunc mFunc; std::string mFile; }; - typedef std::map<std::string, BuildData> build_map_t; + typedef std::map<std::string, BuildData, std::less<>> build_map_t; private: friend class LLFloaterRegListener; static instance_list_t sNullInstanceList; static instance_map_t sInstanceMap; static build_map_t sBuildMap; - static std::map<std::string,std::string> sGroupMap; + static std::map<std::string, std::string, std::less<>> sGroupMap; static bool sBlockShowFloaters; /** * Defines list of floater names that can be shown despite state of sBlockShowFloaters. */ - static std::set<std::string> sAlwaysShowableList; + static std::set<std::string, std::less<>> sAlwaysShowableList; public: // Registration @@ -85,30 +85,30 @@ public: static void add(const std::string& name, const std::string& file, const LLFloaterBuildFunc& func, const std::string& groupname = LLStringUtil::null); - static bool isRegistered(const std::string& name); + static bool isRegistered(std::string_view name); // Helpers - static LLFloater* getLastFloaterInGroup(const std::string& name); + static LLFloater* getLastFloaterInGroup(std::string_view name); static LLFloater* getLastFloaterCascading(); // Find / get (create) / remove / destroy - static LLFloater* findInstance(const std::string& name, const LLSD& key = LLSD()); - static LLFloater* getInstance(const std::string& name, const LLSD& key = LLSD()); - static LLFloater* removeInstance(const std::string& name, const LLSD& key = LLSD()); - static bool destroyInstance(const std::string& name, const LLSD& key = LLSD()); + static LLFloater* findInstance(std::string_view name, const LLSD& key = LLSD()); + static LLFloater* getInstance(std::string_view name, const LLSD& key = LLSD()); + static LLFloater* removeInstance(std::string_view name, const LLSD& key = LLSD()); + static bool destroyInstance(std::string_view name, const LLSD& key = LLSD()); // Iterators - static const_instance_list_t& getFloaterList(const std::string& name); + static const_instance_list_t& getFloaterList(std::string_view name); // Visibility Management // return NULL if instance not found or can't create instance (no builder) - static LLFloater* showInstance(const std::string& name, const LLSD& key = LLSD(), bool focus = false); + static LLFloater* showInstance(std::string_view name, const LLSD& key = LLSD(), bool focus = false); // Close a floater (may destroy or set invisible) // return false if can't find instance - static bool hideInstance(const std::string& name, const LLSD& key = LLSD()); + static bool hideInstance(std::string_view name, const LLSD& key = LLSD()); // return true if instance is visible: - static bool toggleInstance(const std::string& name, const LLSD& key = LLSD()); - static bool instanceVisible(const std::string& name, const LLSD& key = LLSD()); + static bool toggleInstance(std::string_view name, const LLSD& key = LLSD()); + static bool instanceVisible(std::string_view name, const LLSD& key = LLSD()); static void showInitialVisibleInstances(); static void hideVisibleInstances(const std::set<std::string>& exceptions = std::set<std::string>()); @@ -133,19 +133,19 @@ public: // Typed find / get / show template <class T> - static T* findTypedInstance(const std::string& name, const LLSD& key = LLSD()) + static T* findTypedInstance(std::string_view name, const LLSD& key = LLSD()) { return dynamic_cast<T*>(findInstance(name, key)); } template <class T> - static T* getTypedInstance(const std::string& name, const LLSD& key = LLSD()) + static T* getTypedInstance(std::string_view name, const LLSD& key = LLSD()) { return dynamic_cast<T*>(getInstance(name, key)); } template <class T> - static T* showTypedInstance(const std::string& name, const LLSD& key = LLSD(), bool focus = false) + static T* showTypedInstance(std::string_view name, const LLSD& key = LLSD(), bool focus = false) { return dynamic_cast<T*>(showInstance(name, key, focus)); } diff --git a/indra/llui/llfloaterreglistener.cpp b/indra/llui/llfloaterreglistener.cpp index aa3d1a1171..17641b8375 100644 --- a/indra/llui/llfloaterreglistener.cpp +++ b/indra/llui/llfloaterreglistener.cpp @@ -94,22 +94,22 @@ void LLFloaterRegListener::getBuildMap(const LLSD& event) const void LLFloaterRegListener::showInstance(const LLSD& event) const { - LLFloaterReg::showInstance(event["name"], event["key"], event["focus"]); + LLFloaterReg::showInstance(event["name"].asString(), event["key"], event["focus"]); } void LLFloaterRegListener::hideInstance(const LLSD& event) const { - LLFloaterReg::hideInstance(event["name"], event["key"]); + LLFloaterReg::hideInstance(event["name"].asString(), event["key"]); } void LLFloaterRegListener::toggleInstance(const LLSD& event) const { - LLFloaterReg::toggleInstance(event["name"], event["key"]); + LLFloaterReg::toggleInstance(event["name"].asString(), event["key"]); } void LLFloaterRegListener::instanceVisible(const LLSD& event) const { - sendReply(LLSDMap("visible", LLFloaterReg::instanceVisible(event["name"], event["key"])), + sendReply(LLSDMap("visible", LLFloaterReg::instanceVisible(event["name"].asString(), event["key"])), event); } @@ -119,7 +119,7 @@ void LLFloaterRegListener::clickButton(const LLSD& event) const LLReqID reqID(event); LLSD reply(reqID.makeResponse()); - LLFloater* floater = LLFloaterReg::findInstance(event["name"], event["key"]); + LLFloater* floater = LLFloaterReg::findInstance(event["name"].asString(), event["key"]); if (! LLFloater::isShown(floater)) { reply["type"] = "LLFloater"; @@ -131,7 +131,7 @@ void LLFloaterRegListener::clickButton(const LLSD& event) const { // Here 'floater' points to an LLFloater instance with the specified // name and key which isShown(). - LLButton* button = floater->findChild<LLButton>(event["button"]); + LLButton* button = floater->findChild<LLButton>(event["button"].asString()); if (! LLButton::isAvailable(button)) { reply["type"] = "LLButton"; diff --git a/indra/llui/llfolderviewitem.cpp b/indra/llui/llfolderviewitem.cpp index 82cd2483e8..4c1733506c 100644 --- a/indra/llui/llfolderviewitem.cpp +++ b/indra/llui/llfolderviewitem.cpp @@ -950,7 +950,7 @@ void LLFolderViewItem::draw() S32 filter_offset = static_cast<S32>(mViewModelItem->getFilterStringOffset()); if (filter_string_length > 0) { - S32 bottom = llfloor(getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD); + S32 bottom = getRect().getHeight() - font->getLineHeight() - 3 - TOP_PAD; S32 top = getRect().getHeight() - TOP_PAD; if(mLabelSuffix.empty() || (font == suffix_font)) { @@ -966,8 +966,8 @@ void LLFolderViewItem::draw() S32 label_filter_length = llmin((S32)mLabel.size() - filter_offset, (S32)filter_string_length); if(label_filter_length > 0) { - S32 left = ll_round(text_left) + font->getWidthF32(mLabel, 0, llmin(filter_offset, (S32)mLabel.size())) - 2; - S32 right = left + font->getWidthF32(mLabel, filter_offset, label_filter_length) + 2; + S32 left = (S32)(ll_round(text_left) + font->getWidthF32(mLabel, 0, llmin(filter_offset, (S32)mLabel.size()))) - 2; + S32 right = left + (S32)font->getWidthF32(mLabel, filter_offset, label_filter_length) + 2; LLUIImage* box_image = default_params.selection_image; LLRect box_rect(left, top, right, bottom); box_image->draw(box_rect, sFilterBGColor); @@ -976,8 +976,8 @@ void LLFolderViewItem::draw() if(suffix_filter_length > 0) { S32 suffix_offset = llmax(0, filter_offset - (S32)mLabel.size()); - S32 left = ll_round(text_left) + font->getWidthF32(mLabel, 0, static_cast<S32>(mLabel.size())) + suffix_font->getWidthF32(mLabelSuffix, 0, suffix_offset) - 2; - S32 right = left + suffix_font->getWidthF32(mLabelSuffix, suffix_offset, suffix_filter_length) + 2; + S32 left = (S32)(ll_round(text_left) + font->getWidthF32(mLabel, 0, static_cast<S32>(mLabel.size())) + suffix_font->getWidthF32(mLabelSuffix, 0, suffix_offset))- 2; + S32 right = left + (S32)suffix_font->getWidthF32(mLabelSuffix, suffix_offset, suffix_filter_length) + 2; LLUIImage* box_image = default_params.selection_image; LLRect box_rect(left, top, right, bottom); box_image->draw(box_rect, sFilterBGColor); diff --git a/indra/llui/llkeywords.cpp b/indra/llui/llkeywords.cpp index 5e184b5ddb..cc567adb75 100644 --- a/indra/llui/llkeywords.cpp +++ b/indra/llui/llkeywords.cpp @@ -164,13 +164,13 @@ std::string LLKeywords::getArguments(LLSD& arguments) return argString; } -std::string LLKeywords::getAttribute(const std::string& key) +std::string LLKeywords::getAttribute(std::string_view key) { attribute_iterator_t it = mAttributes.find(key); return (it != mAttributes.end()) ? it->second : ""; } -LLColor4 LLKeywords::getColorGroup(const std::string& key_in) +LLColor4 LLKeywords::getColorGroup(std::string_view key_in) { std::string color_group = "ScriptText"; if (key_in == "functions") @@ -261,7 +261,7 @@ void LLKeywords::processTokens() LL_INFOS("SyntaxLSL") << "Finished processing tokens." << LL_ENDL; } -void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group) +void LLKeywords::processTokensGroup(const LLSD& tokens, std::string_view group) { LLColor4 color; LLColor4 color_group; @@ -333,7 +333,7 @@ void LLKeywords::processTokensGroup(const LLSD& tokens, const std::string& group case LLKeywordToken::TT_CONSTANT: if (getAttribute("type").length() > 0) { - color_group = getColorGroup(group + "-" + getAttribute("type")); + color_group = getColorGroup(std::string(group) + "-" + getAttribute("type")); } else { @@ -501,7 +501,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW { if( *cur == '\n' ) { - LLTextSegmentPtr text_segment = new LLLineBreakTextSegment(style, cur-base); + LLTextSegmentPtr text_segment = new LLLineBreakTextSegment(style, (S32)(cur - base)); text_segment->setToken( 0 ); insertSegment( *seg_list, text_segment, text_len, style, editor); cur++; @@ -532,13 +532,13 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW LLKeywordToken* cur_token = *iter; if( cur_token->isHead( cur ) ) { - S32 seg_start = cur - base; + S32 seg_start = (S32)(cur - base); while( *cur && *cur != '\n' ) { // skip the rest of the line cur++; } - S32 seg_end = cur - base; + S32 seg_end = (S32)(cur - base); //create segments from seg_start to seg_end insertSegments(wtext, *seg_list,cur_token, text_len, seg_start, seg_end, style, editor); @@ -582,7 +582,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW S32 between_delimiters = 0; S32 seg_end = 0; - seg_start = cur - base; + seg_start = (S32)(cur - base); cur += cur_delimiter->getLengthHead(); LLKeywordToken::ETokenType type = cur_delimiter->getType(); @@ -669,7 +669,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW { p++; } - S32 seg_len = p - cur; + S32 seg_len = (S32)(p - cur); if( seg_len > 0 ) { WStringMapIndex word( cur, seg_len ); @@ -677,7 +677,7 @@ void LLKeywords::findSegments(std::vector<LLTextSegmentPtr>* seg_list, const LLW if( map_iter != mWordTokenMap.end() ) { LLKeywordToken* cur_token = map_iter->second; - S32 seg_start = cur - base; + S32 seg_start = (S32)(cur - base); S32 seg_end = seg_start + seg_len; // LL_INFOS("SyntaxLSL") << "Seg: [" << word.c_str() << "]" << LL_ENDL; diff --git a/indra/llui/llkeywords.h b/indra/llui/llkeywords.h index f498b3ddee..6df2da7cd3 100644 --- a/indra/llui/llkeywords.h +++ b/indra/llui/llkeywords.h @@ -111,7 +111,7 @@ public: ~LLKeywords(); void clearLoaded() { mLoaded = false; } - LLColor4 getColorGroup(const std::string& key_in); + LLColor4 getColorGroup(std::string_view key_in); bool isLoaded() const { return mLoaded; } void findSegments(std::vector<LLTextSegmentPtr> *seg_list, @@ -170,7 +170,7 @@ public: #endif protected: - void processTokensGroup(const LLSD& Tokens, const std::string& Group); + void processTokensGroup(const LLSD& Tokens, std::string_view Group); void insertSegment(std::vector<LLTextSegmentPtr>& seg_list, LLTextSegmentPtr new_segment, S32 text_len, @@ -194,10 +194,10 @@ protected: token_list_t mLineTokenList; token_list_t mDelimiterTokenList; - typedef std::map<std::string, std::string> element_attributes_t; + typedef std::map<std::string, std::string, std::less<>> element_attributes_t; typedef element_attributes_t::const_iterator attribute_iterator_t; element_attributes_t mAttributes; - std::string getAttribute(const std::string& key); + std::string getAttribute(std::string_view key); std::string getArguments(LLSD& arguments); }; diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp index 6db9f64a97..3a3aa7e4df 100644 --- a/indra/llui/lllayoutstack.cpp +++ b/indra/llui/lllayoutstack.cpp @@ -131,7 +131,7 @@ void LLLayoutPanel::setTargetDim(S32 value) S32 LLLayoutPanel::getVisibleDim() const { - F32 min_dim = getRelevantMinDim(); + F32 min_dim = (F32)getRelevantMinDim(); return ll_round(mVisibleAmt * (min_dim + (((F32)mTargetDim - min_dim) * (1.f - mCollapseAmt)))); @@ -209,7 +209,7 @@ LLLayoutStack::Params::Params() open_time_constant("open_time_constant", 0.02f), close_time_constant("close_time_constant", 0.03f), resize_bar_overlap("resize_bar_overlap", 1), - border_size("border_size", LLCachedControl<S32>(*LLUI::getInstance()->mSettingGroups["config"], "UIResizeBarHeight", 0)), + border_size("border_size", LLUI::getInstance()->mSettingGroups["config"]->getS32("UIResizeBarHeight")), show_drag_handle("show_drag_handle", false), drag_handle_first_indent("drag_handle_first_indent", 0), drag_handle_second_indent("drag_handle_second_indent", 0), @@ -445,7 +445,7 @@ void LLLayoutStack::updateLayout() for (LLLayoutPanel* panelp : mPanels) { - F32 panel_dim = llmax(panelp->getExpandedMinDim(), panelp->mTargetDim); + F32 panel_dim = (F32)llmax(panelp->getExpandedMinDim(), panelp->mTargetDim); LLRect panel_rect; if (mOrientation == HORIZONTAL) @@ -465,7 +465,7 @@ void LLLayoutStack::updateLayout() LLRect resize_bar_rect(panel_rect); F32 panel_spacing = (F32)mPanelSpacing * panelp->getVisibleAmount(); - F32 panel_visible_dim = panelp->getVisibleDim(); + F32 panel_visible_dim = (F32)panelp->getVisibleDim(); S32 panel_spacing_round = (S32)(ll_round(panel_spacing)); if (mOrientation == HORIZONTAL) @@ -548,7 +548,7 @@ LLLayoutPanel* LLLayoutStack::findEmbeddedPanel(LLPanel* panelp) const return NULL; } -LLLayoutPanel* LLLayoutStack::findEmbeddedPanelByName(const std::string& name) const +LLLayoutPanel* LLLayoutStack::findEmbeddedPanelByName(std::string_view name) const { LLLayoutPanel* result = NULL; diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index 9e5f8048ba..8459921c60 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -111,7 +111,7 @@ private: e_panel_list_t mPanels; LLLayoutPanel* findEmbeddedPanel(LLPanel* panelp) const; - LLLayoutPanel* findEmbeddedPanelByName(const std::string& name) const; + LLLayoutPanel* findEmbeddedPanelByName(std::string_view name) const; void updateFractionalSizes(); void normalizeFractionalSizes(); void updatePanelRect( LLLayoutPanel* param1, const LLRect& new_rect ); diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 50bf3f5877..60b6115b34 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -74,7 +74,7 @@ static LLDefaultChildRegistry::Register<LLLineEditor> r1("line_editor"); // Compiler optimization, generate extern template template class LLLineEditor* LLView::getChild<class LLLineEditor>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; // // Member functions @@ -2109,7 +2109,7 @@ void LLLineEditor::draw() if (0 == mText.length() && (mReadOnly || mShowLabelFocused)) { mGLFont->render(mLabel.getWString(), 0, - mTextLeftEdge, (F32)text_bottom, + (F32)mTextLeftEdge, (F32)text_bottom, label_color, LLFontGL::LEFT, LLFontGL::BOTTOM, @@ -2134,7 +2134,7 @@ void LLLineEditor::draw() if (0 == mText.length()) { mGLFont->render(mLabel.getWString(), 0, - mTextLeftEdge, (F32)text_bottom, + (F32)mTextLeftEdge, (F32)text_bottom, label_color, LLFontGL::LEFT, LLFontGL::BOTTOM, diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index e955cbb17d..1cb7cac854 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -466,7 +466,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLLINEEDITOR_CPP extern template class LLLineEditor* LLView::getChild<class LLLineEditor>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_LINEEDITOR_ diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp index dffaf69a9f..0038a8ae18 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -988,7 +988,7 @@ LLMenuItemBranchGL::~LLMenuItemBranchGL() // virtual -LLView* LLMenuItemBranchGL::getChildView(const std::string& name, bool recurse) const +LLView* LLMenuItemBranchGL::getChildView(std::string_view name, bool recurse) const { LLMenuGL* branch = getBranch(); if (branch) @@ -1005,7 +1005,7 @@ LLView* LLMenuItemBranchGL::getChildView(const std::string& name, bool recurse) return LLView::getChildView(name, recurse); } -LLView* LLMenuItemBranchGL::findChildView(const std::string& name, bool recurse) const +LLView* LLMenuItemBranchGL::findChildView(std::string_view name, bool recurse) const { LLMenuGL* branch = getBranch(); if (branch) @@ -2752,7 +2752,7 @@ void LLMenuGL::setEnabledSubMenus(bool enable) // setItemEnabled() - pass the label and the enable flag for a menu // item. true will make sure it's enabled, false will disable it. -void LLMenuGL::setItemEnabled( const std::string& name, bool enable ) +void LLMenuGL::setItemEnabled(std::string_view name, bool enable ) { item_list_t::iterator item_iter; for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) @@ -2766,7 +2766,7 @@ void LLMenuGL::setItemEnabled( const std::string& name, bool enable ) } } -void LLMenuGL::setItemVisible( const std::string& name, bool visible ) +void LLMenuGL::setItemVisible(std::string_view name, bool visible ) { item_list_t::iterator item_iter; for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) @@ -3277,7 +3277,7 @@ void LLMenuGL::setVisible(bool visible) } } -LLMenuGL* LLMenuGL::findChildMenuByName(const std::string& name, bool recurse) const +LLMenuGL* LLMenuGL::findChildMenuByName(std::string_view name, bool recurse) const { LLView* view = findChildView(name, recurse); if (view) diff --git a/indra/llui/llmenugl.h b/indra/llui/llmenugl.h index 51766afe85..66f84393fe 100644 --- a/indra/llui/llmenugl.h +++ b/indra/llui/llmenugl.h @@ -456,7 +456,7 @@ public: virtual bool hasAccelerator(const KEY &key, const MASK &mask) const; virtual bool handleAcceleratorKey(KEY key, MASK mask); - LLMenuGL* findChildMenuByName(const std::string& name, bool recurse) const; + LLMenuGL* findChildMenuByName(std::string_view name, bool recurse) const; bool clearHoverItem(); @@ -479,12 +479,12 @@ public: // setItemEnabled() - pass the name and the enable flag for a // menu item. true will make sure it's enabled, false will disable // it. - void setItemEnabled( const std::string& name, bool enable ); + void setItemEnabled(std::string_view name, bool enable ); // propagate message to submenus void setEnabledSubMenus(bool enable); - void setItemVisible( const std::string& name, bool visible); + void setItemVisible(std::string_view name, bool visible); void setItemLabel(const std::string &name, const std::string &label); @@ -687,8 +687,8 @@ public: virtual void openMenu(); - virtual LLView* getChildView(const std::string& name, bool recurse = true) const; - virtual LLView* findChildView(const std::string& name, bool recurse = true) const; + virtual LLView* getChildView(std::string_view name, bool recurse = true) const; + virtual LLView* findChildView(std::string_view name, bool recurse = true) const; private: LLHandle<LLView> mBranchHandle; diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index bee7d5bb3f..cd80e7f63f 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -266,7 +266,7 @@ LLSD LLNotificationForm::asLLSD() const return mFormData; } -LLSD LLNotificationForm::getElement(const std::string& element_name) +LLSD LLNotificationForm::getElement(std::string_view element_name) { for (LLSD::array_const_iterator it = mFormData.beginArray(); it != mFormData.endArray(); @@ -278,7 +278,7 @@ LLSD LLNotificationForm::getElement(const std::string& element_name) } -bool LLNotificationForm::hasElement(const std::string& element_name) const +bool LLNotificationForm::hasElement(std::string_view element_name) const { for (LLSD::array_const_iterator it = mFormData.beginArray(); it != mFormData.endArray(); @@ -301,7 +301,7 @@ void LLNotificationForm::getElements(LLSD& elements, S32 offset) } } -bool LLNotificationForm::getElementEnabled(const std::string& element_name) const +bool LLNotificationForm::getElementEnabled(std::string_view element_name) const { for (LLSD::array_const_iterator it = mFormData.beginArray(); it != mFormData.endArray(); @@ -316,7 +316,7 @@ bool LLNotificationForm::getElementEnabled(const std::string& element_name) cons return false; } -void LLNotificationForm::setElementEnabled(const std::string& element_name, bool enabled) +void LLNotificationForm::setElementEnabled(std::string_view element_name, bool enabled) { for (LLSD::array_iterator it = mFormData.beginArray(); it != mFormData.endArray(); @@ -439,7 +439,7 @@ LLNotificationTemplate::LLNotificationTemplate(const LLNotificationTemplate::Par mSoundName("") { if (p.sound.isProvided() - && LLUI::getInstance()->mSettingGroups["config"]->controlExists(p.sound)) + && LLUI::getInstance()->mSettingGroups["config"]->controlExists(p.sound())) { mSoundName = p.sound; } @@ -769,7 +769,7 @@ bool LLNotification::hasUniquenessConstraints() const return (mTemplatep ? mTemplatep->mUnique : false); } -bool LLNotification::matchesTag(const std::string& tag) +bool LLNotification::matchesTag(std::string_view tag) { bool result = false; @@ -861,7 +861,7 @@ void LLNotification::init(const std::string& template_name, const LLSD& form_ele for (LLStringUtil::format_map_t::const_iterator iter = default_args.begin(); iter != default_args.end(); ++iter) { - mSubstitutions[iter->first] = iter->second; + mSubstitutions[std::string(iter->first)] = iter->second; } mSubstitutions["_URL"] = getURL(); mSubstitutions["_NAME"] = template_name; @@ -1443,11 +1443,12 @@ void LLNotifications::createDefaultChannels() } -LLNotificationTemplatePtr LLNotifications::getTemplate(const std::string& name) +LLNotificationTemplatePtr LLNotifications::getTemplate(std::string_view name) { - if (mTemplates.count(name)) + auto it = mTemplates.find(name); + if (it != mTemplates.end()) { - return mTemplates[name]; + return it->second; } else { @@ -1455,7 +1456,7 @@ LLNotificationTemplatePtr LLNotifications::getTemplate(const std::string& name) } } -bool LLNotifications::templateExists(const std::string& name) +bool LLNotifications::templateExists(std::string_view name) { return (mTemplates.count(name) != 0); } @@ -1740,7 +1741,7 @@ void LLNotifications::cancel(LLNotificationPtr pNotif) } } -void LLNotifications::cancelByName(const std::string& name) +void LLNotifications::cancelByName(std::string_view name) { LLMutexLock lock(&mItemsMutex); std::vector<LLNotificationPtr> notifs_to_cancel; @@ -1815,7 +1816,7 @@ LLNotificationPtr LLNotifications::find(LLUUID uuid) } } -std::string LLNotifications::getGlobalString(const std::string& key) const +std::string LLNotifications::getGlobalString(std::string_view key) const { GlobalStringMap::const_iterator it = mGlobalStrings.find(key); if (it != mGlobalStrings.end()) @@ -1826,7 +1827,7 @@ std::string LLNotifications::getGlobalString(const std::string& key) const { // if we don't have the key as a global, return the key itself so that the error // is self-diagnosing. - return key; + return std::string(key); } } @@ -1839,13 +1840,13 @@ bool LLNotifications::getIgnoreAllNotifications() return mIgnoreAllNotifications; } -void LLNotifications::setIgnored(const std::string& name, bool ignored) +void LLNotifications::setIgnored(std::string_view name, bool ignored) { LLNotificationTemplatePtr templatep = getTemplate(name); templatep->mForm->setIgnored(ignored); } -bool LLNotifications::getIgnored(const std::string& name) +bool LLNotifications::getIgnored(std::string_view name) { LLNotificationTemplatePtr templatep = getTemplate(name); return (mIgnoreAllNotifications) || ( (templatep->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO) && (templatep->mForm->getIgnored()) ); diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index d3615b6601..1a197f8a17 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -251,11 +251,11 @@ public: S32 getNumElements() { return static_cast<S32>(mFormData.size()); } LLSD getElement(S32 index) { return mFormData.get(index); } - LLSD getElement(const std::string& element_name); + LLSD getElement(std::string_view element_name); void getElements(LLSD& elements, S32 offset = 0); - bool hasElement(const std::string& element_name) const; - bool getElementEnabled(const std::string& element_name) const; - void setElementEnabled(const std::string& element_name, bool enabled); + bool hasElement(std::string_view element_name) const; + bool getElementEnabled(std::string_view element_name) const; + void setElementEnabled(std::string_view element_name, bool enabled); void addElement(const std::string& type, const std::string& name, const LLSD& value = LLSD(), bool enabled = true); void formatElements(const LLSD& substitutions); // appends form elements from another form serialized as LLSD @@ -641,7 +641,7 @@ public: bool hasUniquenessConstraints() const; - bool matchesTag(const std::string& tag); + bool matchesTag(std::string_view tag); virtual ~LLNotification() {} }; @@ -926,7 +926,7 @@ public: void add(const LLNotificationPtr pNotif); void load(const LLNotificationPtr pNotif); void cancel(LLNotificationPtr pNotif); - void cancelByName(const std::string& name); + void cancelByName(std::string_view name); void cancelByOwner(const LLUUID ownerId); void update(const LLNotificationPtr pNotif); @@ -934,19 +934,19 @@ public: // This is all stuff for managing the templates // take your template out - LLNotificationTemplatePtr getTemplate(const std::string& name); + LLNotificationTemplatePtr getTemplate(std::string_view name); // get the whole collection typedef std::vector<std::string> TemplateNames; TemplateNames getTemplateNames() const; // returns a list of notification names - typedef std::map<std::string, LLNotificationTemplatePtr> TemplateMap; + typedef std::map<std::string, LLNotificationTemplatePtr, std::less<>> TemplateMap; TemplateMap::const_iterator templatesBegin() { return mTemplates.begin(); } TemplateMap::const_iterator templatesEnd() { return mTemplates.end(); } // test for existence - bool templateExists(const std::string& name); + bool templateExists(std::string_view name); typedef std::list<LLNotificationVisibilityRulePtr> VisibilityRuleList; @@ -956,13 +956,13 @@ public: LLNotificationChannelPtr getChannel(const std::string& channelName); - std::string getGlobalString(const std::string& key) const; + std::string getGlobalString(std::string_view key) const; void setIgnoreAllNotifications(bool ignore); bool getIgnoreAllNotifications(); - void setIgnored(const std::string& name, bool ignored); - bool getIgnored(const std::string& name); + void setIgnored(std::string_view name, bool ignored); + bool getIgnored(std::string_view name); bool isVisibleByRules(LLNotificationPtr pNotification); @@ -988,7 +988,7 @@ private: LLNotificationMap mUniqueNotifications; - typedef std::map<std::string, std::string> GlobalStringMap; + typedef std::map<std::string, std::string, std::less<>> GlobalStringMap; GlobalStringMap mGlobalStrings; bool mIgnoreAllNotifications; diff --git a/indra/llui/llnotificationslistener.cpp b/indra/llui/llnotificationslistener.cpp index ace9e37e25..9c1fc27c51 100644 --- a/indra/llui/llnotificationslistener.cpp +++ b/indra/llui/llnotificationslistener.cpp @@ -191,7 +191,7 @@ void LLNotificationsListener::ignore(const LLSD& params) const if (params["name"].isDefined()) { // ["name"] was passed: ignore just that notification - LLNotificationTemplatePtr templatep = mNotifications.getTemplate(params["name"]); + LLNotificationTemplatePtr templatep = mNotifications.getTemplate(params["name"].asStringRef()); if (templatep) { templatep->mForm->setIgnored(ignore); diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp index 468cdb10fb..ab3433af98 100644 --- a/indra/llui/llpanel.cpp +++ b/indra/llui/llpanel.cpp @@ -55,7 +55,7 @@ LLPanel::factory_stack_t LLPanel::sFactoryStack; // Compiler optimization, generate extern template template class LLPanel* LLView::getChild<class LLPanel>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; LLPanel::LocalizedString::LocalizedString() : name("name"), @@ -277,7 +277,7 @@ void LLPanel::setDefaultBtn(LLButton* btn) } } -void LLPanel::setDefaultBtn(const std::string& id) +void LLPanel::setDefaultBtn(std::string_view id) { LLButton *button = getChild<LLButton>(id); if (button) @@ -593,12 +593,12 @@ bool LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu return true; } -bool LLPanel::hasString(const std::string& name) +bool LLPanel::hasString(std::string_view name) { return mUIStrings.find(name) != mUIStrings.end(); } -std::string LLPanel::getString(const std::string& name, const LLStringUtil::format_map_t& args) const +std::string LLPanel::getString(std::string_view name, const LLStringUtil::format_map_t& args) const { ui_string_map_t::const_iterator found_it = mUIStrings.find(name); if (found_it != mUIStrings.end()) @@ -608,7 +608,7 @@ std::string LLPanel::getString(const std::string& name, const LLStringUtil::form formatted_string.setArgList(args); return formatted_string.getString(); } - std::string err_str("Failed to find string " + name + " in panel " + getName()); //*TODO: Translate + std::string err_str("Failed to find string " + std::string(name) + " in panel " + getName()); //*TODO: Translate if(LLUI::getInstance()->mSettingGroups["config"]->getBOOL("QAMode")) { LL_ERRS() << err_str << LL_ENDL; @@ -620,14 +620,14 @@ std::string LLPanel::getString(const std::string& name, const LLStringUtil::form return LLStringUtil::null; } -std::string LLPanel::getString(const std::string& name) const +std::string LLPanel::getString(std::string_view name) const { ui_string_map_t::const_iterator found_it = mUIStrings.find(name); if (found_it != mUIStrings.end()) { return found_it->second; } - std::string err_str("Failed to find string " + name + " in panel " + getName()); //*TODO: Translate + std::string err_str("Failed to find string " + std::string(name) +" in panel " + getName()); //*TODO: Translate if(LLUI::getInstance()->mSettingGroups["config"]->getBOOL("QAMode")) { LL_ERRS() << err_str << LL_ENDL; @@ -640,7 +640,7 @@ std::string LLPanel::getString(const std::string& name) const } -void LLPanel::childSetVisible(const std::string& id, bool visible) +void LLPanel::childSetVisible(std::string_view id, bool visible) { LLView* child = findChild<LLView>(id); if (child) @@ -649,7 +649,7 @@ void LLPanel::childSetVisible(const std::string& id, bool visible) } } -void LLPanel::childSetEnabled(const std::string& id, bool enabled) +void LLPanel::childSetEnabled(std::string_view id, bool enabled) { LLView* child = findChild<LLView>(id); if (child) @@ -658,7 +658,7 @@ void LLPanel::childSetEnabled(const std::string& id, bool enabled) } } -void LLPanel::childSetFocus(const std::string& id, bool focus) +void LLPanel::childSetFocus(std::string_view id, bool focus) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -667,7 +667,7 @@ void LLPanel::childSetFocus(const std::string& id, bool focus) } } -bool LLPanel::childHasFocus(const std::string& id) +bool LLPanel::childHasFocus(std::string_view id) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -684,7 +684,7 @@ bool LLPanel::childHasFocus(const std::string& id) // Prefer getChild<LLUICtrl>("foo")->setCommitCallback(boost:bind(...)), // which takes a generic slot. Or use mCommitCallbackRegistrar.add() with // a named callback and reference it in XML. -void LLPanel::childSetCommitCallback(const std::string& id, boost::function<void (LLUICtrl*,void*)> cb, void* data) +void LLPanel::childSetCommitCallback(std::string_view id, boost::function<void (LLUICtrl*,void*)> cb, void* data) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -693,7 +693,7 @@ void LLPanel::childSetCommitCallback(const std::string& id, boost::function<void } } -void LLPanel::childSetColor(const std::string& id, const LLColor4& color) +void LLPanel::childSetColor(std::string_view id, const LLColor4& color) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -702,7 +702,7 @@ void LLPanel::childSetColor(const std::string& id, const LLColor4& color) } } -LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const std::string& id) const +LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(std::string_view id) const { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -712,7 +712,7 @@ LLCtrlSelectionInterface* LLPanel::childGetSelectionInterface(const std::string& return NULL; } -LLCtrlListInterface* LLPanel::childGetListInterface(const std::string& id) const +LLCtrlListInterface* LLPanel::childGetListInterface(std::string_view id) const { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -722,7 +722,7 @@ LLCtrlListInterface* LLPanel::childGetListInterface(const std::string& id) const return NULL; } -LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const std::string& id) const +LLCtrlScrollInterface* LLPanel::childGetScrollInterface(std::string_view id) const { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -732,7 +732,7 @@ LLCtrlScrollInterface* LLPanel::childGetScrollInterface(const std::string& id) c return NULL; } -void LLPanel::childSetValue(const std::string& id, LLSD value) +void LLPanel::childSetValue(std::string_view id, LLSD value) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -741,7 +741,7 @@ void LLPanel::childSetValue(const std::string& id, LLSD value) } } -LLSD LLPanel::childGetValue(const std::string& id) const +LLSD LLPanel::childGetValue(std::string_view id) const { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -752,7 +752,7 @@ LLSD LLPanel::childGetValue(const std::string& id) const return LLSD(); } -bool LLPanel::childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text) +bool LLPanel::childSetTextArg(std::string_view id, const std::string& key, const LLStringExplicit& text) { LLUICtrl* child = findChild<LLUICtrl>(id); if (child) @@ -762,7 +762,7 @@ bool LLPanel::childSetTextArg(const std::string& id, const std::string& key, con return false; } -bool LLPanel::childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text) +bool LLPanel::childSetLabelArg(std::string_view id, const std::string& key, const LLStringExplicit& text) { LLView* child = findChild<LLView>(id); if (child) @@ -772,7 +772,7 @@ bool LLPanel::childSetLabelArg(const std::string& id, const std::string& key, co return false; } -void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_type& function) +void LLPanel::childSetAction(std::string_view id, const commit_signal_t::slot_type& function) { LLButton* button = findChild<LLButton>(id); if (button) @@ -781,7 +781,7 @@ void LLPanel::childSetAction(const std::string& id, const commit_signal_t::slot_ } } -void LLPanel::childSetAction(const std::string& id, boost::function<void(void*)> function, void* value) +void LLPanel::childSetAction(std::string_view id, boost::function<void(void*)> function, void* value) { LLButton* button = findChild<LLButton>(id); if (button) diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h index 2be5573faf..f6aa91fb30 100644 --- a/indra/llui/llpanel.h +++ b/indra/llui/llpanel.h @@ -149,7 +149,7 @@ public: void setBackgroundOpaque(bool b) { mBgOpaque = b; } bool isBackgroundOpaque() const { return mBgOpaque; } void setDefaultBtn(LLButton* btn = NULL); - void setDefaultBtn(const std::string& id); + void setDefaultBtn(std::string_view id); void updateDefaultBtn(); void setLabel(const LLStringExplicit& label) { mLabel = label; } std::string getLabel() const { return mLabel; } @@ -169,47 +169,47 @@ public: void initFromParams(const Params& p); bool initPanelXML( LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node, const LLPanel::Params& default_params); - bool hasString(const std::string& name); - std::string getString(const std::string& name, const LLStringUtil::format_map_t& args) const; - std::string getString(const std::string& name) const; + bool hasString(std::string_view name); + std::string getString(std::string_view name, const LLStringUtil::format_map_t& args) const; + std::string getString(std::string_view name) const; // ** Wrappers for setting child properties by name ** -TomY // WARNING: These are deprecated, please use getChild<T>("name")->doStuff() idiom instead // LLView - void childSetVisible(const std::string& name, bool visible); + void childSetVisible(std::string_view name, bool visible); - void childSetEnabled(const std::string& name, bool enabled); - void childEnable(const std::string& name) { childSetEnabled(name, true); } - void childDisable(const std::string& name) { childSetEnabled(name, false); }; + void childSetEnabled(std::string_view name, bool enabled); + void childEnable(std::string_view name) { childSetEnabled(name, true); } + void childDisable(std::string_view name) { childSetEnabled(name, false); }; // LLUICtrl - void childSetFocus(const std::string& id, bool focus = true); - bool childHasFocus(const std::string& id); + void childSetFocus(std::string_view id, bool focus = true); + bool childHasFocus(std::string_view id); // *TODO: Deprecate; for backwards compatability only: // Prefer getChild<LLUICtrl>("foo")->setCommitCallback(boost:bind(...)), // which takes a generic slot. Or use mCommitCallbackRegistrar.add() with // a named callback and reference it in XML. - void childSetCommitCallback(const std::string& id, boost::function<void (LLUICtrl*,void*)> cb, void* data); - void childSetColor(const std::string& id, const LLColor4& color); + void childSetCommitCallback(std::string_view id, boost::function<void (LLUICtrl*,void*)> cb, void* data); + void childSetColor(std::string_view id, const LLColor4& color); - LLCtrlSelectionInterface* childGetSelectionInterface(const std::string& id) const; - LLCtrlListInterface* childGetListInterface(const std::string& id) const; - LLCtrlScrollInterface* childGetScrollInterface(const std::string& id) const; + LLCtrlSelectionInterface* childGetSelectionInterface(std::string_view id) const; + LLCtrlListInterface* childGetListInterface(std::string_view id) const; + LLCtrlScrollInterface* childGetScrollInterface(std::string_view id) const; // This is the magic bullet for data-driven UI - void childSetValue(const std::string& id, LLSD value); - LLSD childGetValue(const std::string& id) const; + void childSetValue(std::string_view id, LLSD value); + LLSD childGetValue(std::string_view id) const; // For setting text / label replacement params, e.g. "Hello [NAME]" // Not implemented for all types, defaults to noop, returns false if not applicaple - bool childSetTextArg(const std::string& id, const std::string& key, const LLStringExplicit& text); - bool childSetLabelArg(const std::string& id, const std::string& key, const LLStringExplicit& text); + bool childSetTextArg(std::string_view id, const std::string& key, const LLStringExplicit& text); + bool childSetLabelArg(std::string_view id, const std::string& key, const LLStringExplicit& text); // LLButton - void childSetAction(const std::string& id, boost::function<void(void*)> function, void* value); - void childSetAction(const std::string& id, const commit_signal_t::slot_type& function); + void childSetAction(std::string_view id, boost::function<void(void*)> function, void* value); + void childSetAction(std::string_view id, const commit_signal_t::slot_type& function); static LLView* fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr output_node = NULL); @@ -250,7 +250,7 @@ private: LLButton* mDefaultBtn; LLUIString mLabel; - typedef std::map<std::string, std::string> ui_string_map_t; + typedef std::map<std::string, std::string, std::less<>> ui_string_map_t; ui_string_map_t mUIStrings; @@ -259,7 +259,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLPANEL_CPP extern template class LLPanel* LLView::getChild<class LLPanel>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif typedef boost::function<LLPanel* (void)> LLPanelClassCreatorFunc; @@ -277,7 +277,7 @@ public: mPanelClassesNames[tag] = func; } - LLPanel* createPanelClass(const std::string& tag) + LLPanel* createPanelClass(std::string_view tag) { param_name_map_t::iterator iT = mPanelClassesNames.find(tag); if(iT == mPanelClassesNames.end()) @@ -292,7 +292,7 @@ public: } private: - typedef std::map< std::string, LLPanelClassCreatorFunc> param_name_map_t; + typedef std::map< std::string, LLPanelClassCreatorFunc, std::less<>> param_name_map_t; param_name_map_t mPanelClassesNames; }; diff --git a/indra/llui/llscrollingpanellist.cpp b/indra/llui/llscrollingpanellist.cpp index b158d7b1b7..7696a27320 100644 --- a/indra/llui/llscrollingpanellist.cpp +++ b/indra/llui/llscrollingpanellist.cpp @@ -84,42 +84,35 @@ void LLScrollingPanelList::removePanel(LLScrollingPanel* panel) if (!mPanelList.empty()) { - for (iter = mPanelList.begin(); iter != mPanelList.end(); ++iter, ++index) - { - if (*iter == panel) - { - break; - } - } + LLScrollingPanelList::panel_list_t::const_iterator iter = + std::find(mPanelList.begin(), mPanelList.end(), panel); if (iter != mPanelList.end()) { - removePanel(index); + removeChild(panel); + mPanelList.erase(iter); + rearrange(); } } } -void LLScrollingPanelList::removePanel( U32 panel_index ) +void LLScrollingPanelList::removePanel(U32 panel_index) { - if ( mPanelList.empty() || panel_index >= mPanelList.size() ) + if (panel_index >= mPanelList.size()) { LL_WARNS() << "Panel index " << panel_index << " is out of range!" << LL_ENDL; return; } - else - { - removeChild( mPanelList.at(panel_index) ); - mPanelList.erase( mPanelList.begin() + panel_index ); - } + LLScrollingPanelList::panel_list_t::const_iterator iter = mPanelList.begin() + panel_index; + removeChild(*iter); + mPanelList.erase(iter); rearrange(); } void LLScrollingPanelList::updatePanels(bool allow_modify) { - for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin(); - iter != mPanelList.end(); ++iter) + for (LLScrollingPanel* childp : mPanelList) { - LLScrollingPanel *childp = *iter; childp->updatePanel(allow_modify); } } @@ -131,10 +124,8 @@ void LLScrollingPanelList::rearrange() if (!mPanelList.empty()) { new_width = new_height = mPadding * 2; - for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin(); - iter != mPanelList.end(); ++iter) + for (LLScrollingPanel* childp : mPanelList) { - LLScrollingPanel* childp = *iter; const LLRect& rect = childp->getRect(); if (mIsHorizontal) { @@ -180,10 +171,8 @@ void LLScrollingPanelList::rearrange() // Reposition each of the child views S32 pos = mIsHorizontal ? mPadding : rc.getHeight() - mPadding; - for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin(); - iter != mPanelList.end(); ++iter) + for (LLScrollingPanel* childp : mPanelList) { - LLScrollingPanel* childp = *iter; const LLRect& rect = childp->getRect(); if (mIsHorizontal) { @@ -211,10 +200,11 @@ void LLScrollingPanelList::updatePanelVisiblilty() getParent()->getRect().getHeight() - mPadding, &parent_screen_rect.mRight, &parent_screen_rect.mTop ); - for (std::deque<LLScrollingPanel*>::iterator iter = mPanelList.begin(); - iter != mPanelList.end(); ++iter) + for (LLScrollingPanel* childp : mPanelList) { - LLScrollingPanel *childp = *iter; + if (childp->isDead()) + continue; + const LLRect& local_rect = childp->getRect(); LLRect screen_rect; childp->localPointToScreen( diff --git a/indra/llui/llscrolllistcell.cpp b/indra/llui/llscrolllistcell.cpp index 403879646d..5dccf9a8ba 100644 --- a/indra/llui/llscrolllistcell.cpp +++ b/indra/llui/llscrolllistcell.cpp @@ -209,7 +209,7 @@ void LLScrollListBar::setValue(const LLSD& value) { if (value.has("ratio")) { - mRatio = value["ratio"].asReal(); + mRatio = (F32)value["ratio"].asReal(); } if (value.has("bottom")) { @@ -239,7 +239,7 @@ S32 LLScrollListBar::getWidth() const void LLScrollListBar::draw(const LLColor4& color, const LLColor4& highlight_color) const { S32 bar_width = getWidth() - mLeftPad - mRightPad; - S32 left = bar_width - bar_width * mRatio; + S32 left = (S32)(bar_width - bar_width * mRatio); left = llclamp(left, mLeftPad, getWidth() - mRightPad - 1); gl_rect_2d(left, mBottom, getWidth() - mRightPad, mBottom - 1, mColor); @@ -637,7 +637,7 @@ void LLScrollListIconText::draw(const LLColor4& color, const LLColor4& highlight switch (mFontAlignment) { case LLFontGL::LEFT: - start_text_x = icon_space + 1; + start_text_x = icon_space + 1.f; start_icon_x = 1; break; case LLFontGL::RIGHT: @@ -647,7 +647,7 @@ void LLScrollListIconText::draw(const LLColor4& color, const LLColor4& highlight case LLFontGL::HCENTER: F32 center = (F32)getWidth()* 0.5f; start_text_x = center + ((F32)icon_space * 0.5f); - start_icon_x = center - (((F32)icon_space + mFont->getWidth(mText.getString())) * 0.5f); + start_icon_x = (S32)(center - (((F32)icon_space + mFont->getWidth(mText.getString())) * 0.5f)); break; } mFont->render(mText.getWString(), 0, diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 74a9641836..8512555b49 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -1479,7 +1479,10 @@ const std::string LLScrollListCtrl::getSelectedItemLabel(S32 column) const item = getFirstSelected(); if (item) { - return item->getColumn(column)->getValue().asString(); + if (LLScrollListCell* cell = item->getColumn(column)) + { + return cell->getValue().asString(); + } } return LLStringUtil::null; @@ -2716,7 +2719,8 @@ struct SameSortColumn bool LLScrollListCtrl::setSort(S32 column_idx, bool ascending) { LLScrollListColumn* sort_column = getColumn(column_idx); - if (!sort_column) return false; + if (!sort_column) + return false; sort_column->mSortDirection = ascending ? LLScrollListColumn::ASCENDING : LLScrollListColumn::DESCENDING; @@ -2729,32 +2733,28 @@ bool LLScrollListCtrl::setSort(S32 column_idx, bool ascending) mSortColumns.push_back(new_sort_column); return true; } - else - { - // grab current sort column - sort_column_t cur_sort_column = mSortColumns.back(); - // remove any existing sort criterion referencing this column - // and add the new one - mSortColumns.erase(remove_if(mSortColumns.begin(), mSortColumns.end(), SameSortColumn(column_idx)), mSortColumns.end()); - mSortColumns.push_back(new_sort_column); + // grab current sort column + sort_column_t cur_sort_column = mSortColumns.back(); - // did the sort criteria change? - return (cur_sort_column != new_sort_column); - } + // remove any existing sort criterion referencing this column + // and add the new one + mSortColumns.erase(remove_if(mSortColumns.begin(), mSortColumns.end(), SameSortColumn(column_idx)), mSortColumns.end()); + mSortColumns.push_back(new_sort_column); + + // did the sort criteria change? + return cur_sort_column != new_sort_column; } S32 LLScrollListCtrl::getLinesPerPage() { - //if mPageLines is NOT provided display all item if (mPageLines) { return mPageLines; } - else - { - return mLineHeight ? mItemListRect.getHeight() / mLineHeight : getItemCount(); - } + + // If mPageLines is NOT provided then display all items + return mLineHeight ? mItemListRect.getHeight() / mLineHeight : getItemCount(); } @@ -2770,7 +2770,7 @@ void LLScrollListCtrl::sortByColumn(const std::string& name, bool ascending) column_map_t::iterator itor = mColumns.find(name); if (itor != mColumns.end()) { - sortByColumnIndex((*itor).second->mIndex, ascending); + sortByColumnIndex(itor->second->mIndex, ascending); } } @@ -3089,8 +3089,7 @@ std::string LLScrollListCtrl::getSortColumnName() { LLScrollListColumn* column = mSortColumns.empty() ? NULL : mColumnsIndexed[mSortColumns.back().first]; - if (column) return column->mName; - else return ""; + return column ? column->mName : LLStringUtil::null; } bool LLScrollListCtrl::hasSortOrder() const diff --git a/indra/llui/llspellcheck.cpp b/indra/llui/llspellcheck.cpp index 1615db5b52..9d8eadfd3f 100644 --- a/indra/llui/llspellcheck.cpp +++ b/indra/llui/llspellcheck.cpp @@ -448,7 +448,7 @@ void LLSpellChecker::removeDictionary(const std::string& dict_language) { LLFile::remove(dict_aff); } - dict_map.erase(it - dict_map.beginArray()); + dict_map.erase((LLSD::Integer)(it - dict_map.beginArray())); break; } } diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index adb1d51813..4273fae71e 100644 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -66,7 +66,7 @@ F32 calc_tick_value(F32 min, F32 max) S32 num_whole_digits = llceil(logf(llabs(min + possible_tick_value)) * OO_LN10); for (S32 digit_count = -(num_whole_digits - 1); digit_count < 6; digit_count++) { - F32 test_tick_value = min + (possible_tick_value * pow(10.0, digit_count)); + F32 test_tick_value = min + (possible_tick_value * (F32)pow(10.0, digit_count)); if (is_approx_equal((F32)(S32)test_tick_value, test_tick_value)) { @@ -99,7 +99,7 @@ void calc_auto_scale_range(F32& min, F32& max, F32& tick) : llceil(logf(llabs(min)) * OO_LN10); const S32 num_digits = llmax(num_digits_max, num_digits_min); - const F32 power_of_10 = pow(10.0, num_digits - 1); + const F32 power_of_10 = (F32)pow(10.0, num_digits - 1); const F32 starting_max = power_of_10 * ((max < 0.f) ? -1 : 1); const F32 starting_min = power_of_10 * ((min < 0.f) ? -1 : 1); @@ -313,13 +313,13 @@ void LLStatBar::draw() const LLTrace::StatType<LLTrace::CountAccumulator>& count_stat = *mStat.countStatp; unit_label = std::string(count_stat.getUnitLabel()) + "/s"; - current = last_frame_recording.getPerSec(count_stat); - min = frame_recording.getPeriodMinPerSec(count_stat, num_frames); - max = frame_recording.getPeriodMaxPerSec(count_stat, num_frames); - mean = frame_recording.getPeriodMeanPerSec(count_stat, num_frames); + current = (F32)last_frame_recording.getPerSec(count_stat); + min = (F32)frame_recording.getPeriodMinPerSec(count_stat, num_frames); + max = (F32)frame_recording.getPeriodMaxPerSec(count_stat, num_frames); + mean = (F32)frame_recording.getPeriodMeanPerSec(count_stat, num_frames); if (mShowMedian) { - display_value = frame_recording.getPeriodMedianPerSec(count_stat, num_frames); + display_value = (F32)frame_recording.getPeriodMedianPerSec(count_stat, num_frames); } else { @@ -332,10 +332,10 @@ void LLStatBar::draw() const LLTrace::StatType<LLTrace::EventAccumulator>& event_stat = *mStat.eventStatp; unit_label = mUnitLabel.empty() ? event_stat.getUnitLabel() : mUnitLabel; - current = last_frame_recording.getLastValue(event_stat); - min = frame_recording.getPeriodMin(event_stat, num_frames); - max = frame_recording.getPeriodMax(event_stat, num_frames); - mean = frame_recording.getPeriodMean(event_stat, num_frames); + current = (F32)last_frame_recording.getLastValue(event_stat); + min = (F32)frame_recording.getPeriodMin(event_stat, num_frames); + max = (F32)frame_recording.getPeriodMax(event_stat, num_frames); + mean = (F32)frame_recording.getPeriodMean(event_stat, num_frames); display_value = mean; } break; @@ -344,15 +344,15 @@ void LLStatBar::draw() const LLTrace::StatType<LLTrace::SampleAccumulator>& sample_stat = *mStat.sampleStatp; unit_label = mUnitLabel.empty() ? sample_stat.getUnitLabel() : mUnitLabel; - current = last_frame_recording.getLastValue(sample_stat); - min = frame_recording.getPeriodMin(sample_stat, num_frames); - max = frame_recording.getPeriodMax(sample_stat, num_frames); - mean = frame_recording.getPeriodMean(sample_stat, num_frames); + current = (F32)last_frame_recording.getLastValue(sample_stat); + min = (F32)frame_recording.getPeriodMin(sample_stat, num_frames); + max = (F32)frame_recording.getPeriodMax(sample_stat, num_frames); + mean = (F32)frame_recording.getPeriodMean(sample_stat, num_frames); num_rapid_changes = calc_num_rapid_changes(frame_recording, sample_stat, RAPID_CHANGE_WINDOW); if (mShowMedian) { - display_value = frame_recording.getPeriodMedian(sample_stat, num_frames); + display_value = (F32)frame_recording.getPeriodMedian(sample_stat, num_frames); } else if (num_rapid_changes / RAPID_CHANGE_WINDOW.value() > MAX_RAPID_CHANGES_PER_SEC) { @@ -450,8 +450,8 @@ void LLStatBar::draw() } F32 span = (mOrientation == HORIZONTAL) - ? (bar_rect.getWidth()) - : (bar_rect.getHeight()); + ? (F32)(bar_rect.getWidth()) + : (F32)(bar_rect.getHeight()); if (mDisplayHistory && mStat.valid) { @@ -471,18 +471,18 @@ void LLStatBar::draw() switch(mStatType) { case STAT_COUNT: - min_value = recording.getPerSec(*mStat.countStatp); + min_value = (F32)recording.getPerSec(*mStat.countStatp); max_value = min_value; num_samples = recording.getSampleCount(*mStat.countStatp); break; case STAT_EVENT: - min_value = recording.getMin(*mStat.eventStatp); - max_value = recording.getMax(*mStat.eventStatp); + min_value = (F32)recording.getMin(*mStat.eventStatp); + max_value = (F32)recording.getMax(*mStat.eventStatp); num_samples = recording.getSampleCount(*mStat.eventStatp); break; case STAT_SAMPLE: - min_value = recording.getMin(*mStat.sampleStatp); - max_value = recording.getMax(*mStat.sampleStatp); + min_value = (F32)recording.getMin(*mStat.sampleStatp); + max_value = (F32)recording.getMax(*mStat.sampleStatp); num_samples = recording.getSampleCount(*mStat.sampleStatp); break; default: diff --git a/indra/llui/llstatgraph.cpp b/indra/llui/llstatgraph.cpp index d37f927073..95a9493323 100644 --- a/indra/llui/llstatgraph.cpp +++ b/indra/llui/llstatgraph.cpp @@ -70,11 +70,11 @@ void LLStatGraph::draw() if (mPerSec) { - mValue = recording.getPerSec(*mNewStatFloatp); + mValue = (F32)recording.getPerSec(*mNewStatFloatp); } else { - mValue = recording.getSum(*mNewStatFloatp); + mValue = (F32)recording.getSum(*mNewStatFloatp); } } diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 06f584d372..595ab0bd2b 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -315,7 +315,7 @@ void LLTabContainer::reshape(S32 width, S32 height, bool called_from_parent) } //virtual -LLView* LLTabContainer::getChildView(const std::string& name, bool recurse) const +LLView* LLTabContainer::getChildView(std::string_view name, bool recurse) const { tuple_list_t::const_iterator itor; for (itor = mTabList.begin(); itor != mTabList.end(); ++itor) @@ -343,7 +343,7 @@ LLView* LLTabContainer::getChildView(const std::string& name, bool recurse) cons } //virtual -LLView* LLTabContainer::findChildView(const std::string& name, bool recurse) const +LLView* LLTabContainer::findChildView(std::string_view name, bool recurse) const { tuple_list_t::const_iterator itor; for (itor = mTabList.begin(); itor != mTabList.end(); ++itor) @@ -1401,7 +1401,7 @@ S32 LLTabContainer::getIndexForPanel(LLPanel* panel) return -1; } -S32 LLTabContainer::getPanelIndexByTitle(const std::string& title) +S32 LLTabContainer::getPanelIndexByTitle(std::string_view title) { for (S32 index = 0 ; index < (S32)mTabList.size(); index++) { @@ -1413,7 +1413,7 @@ S32 LLTabContainer::getPanelIndexByTitle(const std::string& title) return -1; } -LLPanel* LLTabContainer::getPanelByName(const std::string& name) +LLPanel* LLTabContainer::getPanelByName(std::string_view name) { for (S32 index = 0 ; index < (S32)mTabList.size(); index++) { @@ -1637,7 +1637,7 @@ bool LLTabContainer::setTab(S32 which) return is_visible; } -bool LLTabContainer::selectTabByName(const std::string& name) +bool LLTabContainer::selectTabByName(std::string_view name) { LLPanel* panel = getPanelByName(name); if (!panel) @@ -2189,7 +2189,7 @@ void LLTabContainer::setTabVisibility( LLPanel const *aPanel, bool aVisible ) LLTabTuple const *pTT = *itr; if( pTT->mVisible ) { - this->selectTab( itr - mTabList.begin() ); + this->selectTab((S32)(itr - mTabList.begin())); foundTab = true; break; } diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h index b22eec2fe5..40f272ffa8 100644 --- a/indra/llui/lltabcontainer.h +++ b/indra/llui/lltabcontainer.h @@ -149,8 +149,8 @@ public: /*virtual*/ bool handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, EDragAndDropType type, void* cargo_data, EAcceptance* accept, std::string& tooltip); - /*virtual*/ LLView* getChildView(const std::string& name, bool recurse = true) const; - /*virtual*/ LLView* findChildView(const std::string& name, bool recurse = true) const; + /*virtual*/ LLView* getChildView(std::string_view name, bool recurse = true) const; + /*virtual*/ LLView* findChildView(std::string_view name, bool recurse = true) const; /*virtual*/ void initFromParams(const LLPanel::Params& p); /*virtual*/ bool addChild(LLView* view, S32 tab_group = 0); /*virtual*/ bool postBuild(); @@ -190,8 +190,8 @@ public: S32 getTabCount(); LLPanel* getPanelByIndex(S32 index); S32 getIndexForPanel(LLPanel* panel); - S32 getPanelIndexByTitle(const std::string& title); - LLPanel* getPanelByName(const std::string& name); + S32 getPanelIndexByTitle(std::string_view title); + LLPanel* getPanelByName(std::string_view name); S32 getTotalTabWidth() const; void setCurrentTabName(const std::string& name); @@ -201,7 +201,7 @@ public: void selectPrevTab(); bool selectTabPanel( LLPanel* child ); bool selectTab(S32 which); - bool selectTabByName(const std::string& title); + bool selectTabByName(std::string_view title); void setCurrentPanelIndex(S32 index) { mCurrentTabIdx = index; } bool getTabPanelFlashing(LLPanel* child); diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 1d358a0e9d..8c3b317838 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -401,8 +401,8 @@ std::vector<LLRect> LLTextBase::getSelectionRects() // Use F32 otherwise a string of multiple segments // will accumulate a large error - F32 left_precise = line_iter->mRect.mLeft; - F32 right_precise = line_iter->mRect.mLeft; + F32 left_precise = (F32)line_iter->mRect.mLeft; + F32 right_precise = (F32)line_iter->mRect.mLeft; for (; segment_iter != mSegments.end(); ++segment_iter, segment_offset = 0) { @@ -448,8 +448,8 @@ std::vector<LLRect> LLTextBase::getSelectionRects() } LLRect selection_rect; - selection_rect.mLeft = left_precise; - selection_rect.mRight = right_precise; + selection_rect.mLeft = (S32)left_precise; + selection_rect.mRight = (S32)right_precise; selection_rect.mBottom = line_iter->mRect.mBottom; selection_rect.mTop = line_iter->mRect.mTop; @@ -598,7 +598,7 @@ void LLTextBase::drawCursor() // Make sure the IME is in the right place LLRect screen_pos = calcScreenRect(); - LLCoordGL ime_pos( screen_pos.mLeft + llfloor(cursor_rect.mLeft), screen_pos.mBottom + llfloor(cursor_rect.mTop) ); + LLCoordGL ime_pos( screen_pos.mLeft + cursor_rect.mLeft, screen_pos.mBottom + cursor_rect.mTop ); ime_pos.mX = (S32) (ime_pos.mX * LLUI::getScaleFactor().mV[VX]); ime_pos.mY = (S32) (ime_pos.mY * LLUI::getScaleFactor().mV[VY]); @@ -755,9 +755,9 @@ void LLTextBase::drawText() line_end = next_start; } - LLRectf text_rect(line.mRect.mLeft, line.mRect.mTop, line.mRect.mRight, line.mRect.mBottom); - text_rect.mRight = mDocumentView->getRect().getWidth(); // clamp right edge to document extents - text_rect.translate(mDocumentView->getRect().mLeft, mDocumentView->getRect().mBottom); // adjust by scroll position + LLRectf text_rect((F32)line.mRect.mLeft, (F32)line.mRect.mTop, (F32)line.mRect.mRight, (F32)line.mRect.mBottom); + text_rect.mRight = (F32)mDocumentView->getRect().getWidth(); // clamp right edge to document extents + text_rect.translate((F32)mDocumentView->getRect().mLeft, (F32)mDocumentView->getRect().mBottom); // adjust by scroll position // draw a single line of text S32 seg_start = line_start; @@ -802,13 +802,13 @@ void LLTextBase::drawText() S32 squiggle_start = 0, squiggle_end = 0, pony = 0; cur_segment->getDimensions(seg_start - cur_segment->getStart(), misspell_start - seg_start, squiggle_start, pony); cur_segment->getDimensions(misspell_start - cur_segment->getStart(), misspell_end - misspell_start, squiggle_end, pony); - squiggle_start += text_rect.mLeft; + squiggle_start += (S32)text_rect.mLeft; pony = (squiggle_end + 3) / 6; squiggle_start += squiggle_end / 2 - pony * 3; squiggle_end = squiggle_start + pony * 6; - S32 squiggle_bottom = text_rect.mBottom + (S32)cur_segment->getStyle()->getFont()->getDescenderHeight(); + S32 squiggle_bottom = (S32)text_rect.mBottom + (S32)cur_segment->getStyle()->getFont()->getDescenderHeight(); gGL.color4ub(255, 0, 0, 200); while (squiggle_start + 1 < squiggle_end) @@ -1674,7 +1674,7 @@ void LLTextBase::reflow() segment_set_t::iterator seg_iter = mSegments.begin(); S32 seg_offset = 0; S32 line_start_index = 0; - const F32 text_available_width = mVisibleTextRect.getWidth() - mHPad; // reserve room for margin + const F32 text_available_width = (F32)(mVisibleTextRect.getWidth() - mHPad); // reserve room for margin F32 remaining_pixels = text_available_width; S32 line_count = 0; @@ -1881,7 +1881,7 @@ S32 LLTextBase::getLineNumFromDocIndex( S32 doc_index, bool include_wordwrap) co line_list_t::const_iterator iter = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), doc_index, line_end_compare()); if (include_wordwrap) { - return iter - mLineInfoList.begin(); + return (S32)(iter - mLineInfoList.begin()); } else { @@ -1918,7 +1918,7 @@ S32 LLTextBase::getFirstVisibleLine() const // binary search for line that starts before top of visible buffer line_list_t::const_iterator iter = std::lower_bound(mLineInfoList.begin(), mLineInfoList.end(), visible_region.mTop, compare_bottom()); - return iter - mLineInfoList.begin(); + return (S32)(iter - mLineInfoList.begin()); } std::pair<S32, S32> LLTextBase::getVisibleLines(bool require_fully_visible) @@ -1940,7 +1940,7 @@ std::pair<S32, S32> LLTextBase::getVisibleLines(bool require_fully_visible) first_iter = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), visible_region.mTop, compare_bottom()); last_iter = std::lower_bound(mLineInfoList.begin(), mLineInfoList.end(), visible_region.mBottom, compare_top()); } - return std::pair<S32, S32>(first_iter - mLineInfoList.begin(), last_iter - mLineInfoList.begin()); + return std::pair<S32, S32>((S32)(first_iter - mLineInfoList.begin()), (S32)(last_iter - mLineInfoList.begin())); } @@ -2608,7 +2608,7 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, bool round, } S32 pos = getLength(); - F32 start_x = line_iter->mRect.mLeft + doc_rect.mLeft; + F32 start_x = (F32)(line_iter->mRect.mLeft + doc_rect.mLeft); segment_set_t::iterator line_seg_iter; S32 line_seg_offset; @@ -2626,7 +2626,7 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, bool round, if(newline) { - pos = segment_line_start + segmentp->getOffset(local_x - start_x, line_seg_offset, segment_line_length, round); + pos = segment_line_start + segmentp->getOffset(local_x - (S32)start_x, line_seg_offset, segment_line_length, round); break; } @@ -2656,7 +2656,7 @@ S32 LLTextBase::getDocIndexFromLocalCoord( S32 local_x, S32 local_y, bool round, } else { - offset = segmentp->getOffset(local_x - start_x, line_seg_offset, segment_line_length, round); + offset = segmentp->getOffset(local_x - (S32)start_x, line_seg_offset, segment_line_length, round); } pos = segment_line_start + offset; break; @@ -2703,7 +2703,7 @@ LLRect LLTextBase::getDocRectFromDocIndex(S32 pos) const getSegmentAndOffset(line_iter->mDocIndexStart, &line_seg_iter, &line_seg_offset); getSegmentAndOffset(pos, &cursor_seg_iter, &cursor_seg_offset); - F32 doc_left_precise = line_iter->mRect.mLeft; + F32 doc_left_precise = (F32)line_iter->mRect.mLeft; while(line_seg_iter != mSegments.end()) { @@ -2734,7 +2734,7 @@ LLRect LLTextBase::getDocRectFromDocIndex(S32 pos) const } LLRect doc_rect; - doc_rect.mLeft = doc_left_precise; + doc_rect.mLeft = (S32)doc_left_precise; doc_rect.mBottom = line_iter->mRect.mBottom; doc_rect.mTop = line_iter->mRect.mTop; @@ -3720,7 +3720,7 @@ bool LLInlineViewSegment::getDimensionsF32(S32 first_char, S32 num_chars, F32& w } else { - width = mLeftPad + mRightPad + mView->getRect().getWidth(); + width = (F32)(mLeftPad + mRightPad + mView->getRect().getWidth()); height = mBottomPad + mTopPad + mView->getRect().getHeight(); } @@ -3871,10 +3871,10 @@ F32 LLImageTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 select S32 style_image_width = image->getWidth(); // Text is drawn from the top of the draw_rect downward - S32 text_center = draw_rect.mTop - (draw_rect.getHeight() / 2); + S32 text_center = (S32)(draw_rect.mTop - (draw_rect.getHeight() / 2.f)); // Align image to center of draw rect S32 image_bottom = text_center - (style_image_height / 2); - image->draw(draw_rect.mLeft, image_bottom, + image->draw((S32)draw_rect.mLeft, image_bottom, style_image_width, style_image_height, color); const S32 IMAGE_HPAD = 3; diff --git a/indra/llui/lltextbox.cpp b/indra/llui/lltextbox.cpp index 92551b682c..05af36b71e 100644 --- a/indra/llui/lltextbox.cpp +++ b/indra/llui/lltextbox.cpp @@ -39,7 +39,7 @@ static LLDefaultChildRegistry::Register<LLTextBox> r("text"); // Compiler optimization, generate extern template template class LLTextBox* LLView::getChild<class LLTextBox>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; LLTextBox::LLTextBox(const LLTextBox::Params& p) : LLTextBase(p), diff --git a/indra/llui/lltextbox.h b/indra/llui/lltextbox.h index c1f829c2b9..a3cde45cd0 100644 --- a/indra/llui/lltextbox.h +++ b/indra/llui/lltextbox.h @@ -81,7 +81,7 @@ protected: // Build time optimization, generate once in .cpp file #ifndef LLTEXTBOX_CPP extern template class LLTextBox* LLView::getChild<class LLTextBox>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index dc3026e14d..3537c764b9 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -71,7 +71,7 @@ static LLDefaultChildRegistry::Register<LLTextEditor> r("simple_text_editor"); // Compiler optimization, generate extern template template class LLTextEditor* LLView::getChild<class LLTextEditor>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; // // Constants @@ -2315,17 +2315,17 @@ void LLTextEditor::drawPreeditMarker() if (mPreeditStandouts[i]) { gl_rect_2d(preedit_left + preedit_standout_gap, - text_rect.mBottom + mFont->getDescenderHeight() - 1, + text_rect.mBottom + (S32)mFont->getDescenderHeight() - 1, preedit_right - preedit_standout_gap - 1, - text_rect.mBottom + mFont->getDescenderHeight() - 1 - preedit_standout_thickness, + text_rect.mBottom + (S32)mFont->getDescenderHeight() - 1 - preedit_standout_thickness, (mCursorColor.get() * preedit_standout_brightness + mWriteableBgColor.get() * (1 - preedit_standout_brightness)).setAlpha(1.0f)); } else { gl_rect_2d(preedit_left + preedit_marker_gap, - text_rect.mBottom + mFont->getDescenderHeight() - 1, + text_rect.mBottom + (S32)mFont->getDescenderHeight() - 1, preedit_right - preedit_marker_gap - 1, - text_rect.mBottom + mFont->getDescenderHeight() - 1 - preedit_marker_thickness, + text_rect.mBottom + (S32)mFont->getDescenderHeight() - 1 - preedit_marker_thickness, (mCursorColor.get() * preedit_marker_brightness + mWriteableBgColor.get() * (1 - preedit_marker_brightness)).setAlpha(1.0f)); } } diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index be7f7cb256..0b5acf19a1 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -345,7 +345,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLTEXTEDITOR_CPP extern template class LLTextEditor* LLView::getChild<class LLTextEditor>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_TEXTEDITOR_H diff --git a/indra/llui/lltrans.cpp b/indra/llui/lltrans.cpp index 6c7e472a87..8410031653 100644 --- a/indra/llui/lltrans.cpp +++ b/indra/llui/lltrans.cpp @@ -65,7 +65,7 @@ bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& defa if (!root->hasName("strings")) { LL_ERRS() << "Invalid root node name in " << xml_filename - << ": was " << root->getName() << ", expected \"strings\"" << LL_ENDL; + << ": was " << root->getName()->mString << ", expected \"strings\"" << LL_ENDL; } StringTable string_table; @@ -113,7 +113,7 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root) if (!root->hasName("strings")) { LL_ERRS() << "Invalid root node name in " << xml_filename - << ": was " << root->getName() << ", expected \"strings\"" << LL_ENDL; + << ": was " << root->getName()->mString << ", expected \"strings\"" << LL_ENDL; } StringTable string_table; @@ -143,7 +143,7 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root) static LLTrace::BlockTimerStatHandle FTM_GET_TRANS("Translate string"); //static -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args, bool def_string) { // Don't care about time as much as call count. Make sure we're not // calling LLTrans::getString() in an inner loop. JC @@ -167,12 +167,12 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil:: else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString("+xml_desc+")"; + return "MissingString(" + std::string(xml_desc) + ")"; } } //static -std::string LLTrans::getDefString(const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args) +std::string LLTrans::getDefString(std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args) { template_map_t::iterator iter = sDefaultStringTemplates.find(xml_desc); if (iter != sDefaultStringTemplates.end()) @@ -187,12 +187,12 @@ std::string LLTrans::getDefString(const std::string &xml_desc, const LLStringUti else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString(" + xml_desc + ")"; + return "MissingString(" + std::string(xml_desc) + ")"; } } //static -std::string LLTrans::getString(const std::string &xml_desc, const LLSD& msg_args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLSD& msg_args, bool def_string) { // Don't care about time as much as call count. Make sure we're not // calling LLTrans::getString() in an inner loop. JC @@ -213,12 +213,12 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLSD& msg_args else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString("+xml_desc+")"; + return "MissingString(" + std::string(xml_desc) + ")"; } } //static -std::string LLTrans::getDefString(const std::string &xml_desc, const LLSD& msg_args) +std::string LLTrans::getDefString(std::string_view xml_desc, const LLSD& msg_args) { template_map_t::iterator iter = sDefaultStringTemplates.find(xml_desc); if (iter != sDefaultStringTemplates.end()) @@ -230,12 +230,12 @@ std::string LLTrans::getDefString(const std::string &xml_desc, const LLSD& msg_a else { LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL; - return "MissingString(" + xml_desc + ")"; + return "MissingString(" + std::string(xml_desc) + ")"; } } //static -bool LLTrans::findString(std::string &result, const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args) +bool LLTrans::findString(std::string &result, std::string_view xml_desc, const LLStringUtil::format_map_t& msg_args) { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; @@ -257,7 +257,7 @@ bool LLTrans::findString(std::string &result, const std::string &xml_desc, const } //static -bool LLTrans::findString(std::string &result, const std::string &xml_desc, const LLSD& msg_args) +bool LLTrans::findString(std::string &result, std::string_view xml_desc, const LLSD& msg_args) { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; diff --git a/indra/llui/lltrans.h b/indra/llui/lltrans.h index 4f38ef9067..3492ed0169 100644 --- a/indra/llui/lltrans.h +++ b/indra/llui/lltrans.h @@ -76,12 +76,12 @@ public: * @param args A list of substrings to replace in the string * @returns Translated string */ - static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); - static std::string getDefString(const std::string &xml_desc, const LLStringUtil::format_map_t& args); - static std::string getString(const std::string &xml_desc, const LLSD& args, bool def_string = false); - static std::string getDefString(const std::string &xml_desc, const LLSD& args); - static bool findString(std::string &result, const std::string &xml_desc, const LLStringUtil::format_map_t& args); - static bool findString(std::string &result, const std::string &xml_desc, const LLSD& args); + static std::string getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); + static std::string getDefString(std::string_view xml_desc, const LLStringUtil::format_map_t& args); + static std::string getString(std::string_view xml_desc, const LLSD& args, bool def_string = false); + static std::string getDefString(std::string_view xml_desc, const LLSD& args); + static bool findString(std::string &result, std::string_view xml_desc, const LLStringUtil::format_map_t& args); + static bool findString(std::string &result, std::string_view xml_desc, const LLSD& args); // Returns translated string with [COUNT] replaced with a number, following // special per-language logic for plural nouns. For example, some languages @@ -94,23 +94,22 @@ public: * @param xml_desc String's description * @returns Translated string */ - static std::string getString(const std::string &xml_desc, bool def_string = false) + static std::string getString(std::string_view xml_desc, bool def_string = false) { LLStringUtil::format_map_t empty; return getString(xml_desc, empty); } - static bool findString(std::string &result, const std::string &xml_desc) + static bool findString(std::string &result, std::string_view xml_desc) { LLStringUtil::format_map_t empty; return findString(result, xml_desc, empty); } - static std::string getKeyboardString(const char* keystring) + static std::string getKeyboardString(const std::string_view keystring) { - std::string key_str(keystring); std::string trans_str; - return findString(trans_str, key_str) ? trans_str : key_str; + return findString(trans_str, keystring) ? trans_str : std::string(keystring); } // get the default args @@ -128,7 +127,7 @@ public: } private: - typedef std::map<std::string, LLTransTemplate > template_map_t; + typedef std::map<std::string, LLTransTemplate, std::less<>> template_map_t; static template_map_t sStringTemplates; static template_map_t sDefaultStringTemplates; static LLStringUtil::format_map_t sDefaultArgs; diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 66ec3ad9bd..e3ddd66b58 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -170,11 +170,11 @@ mHelpImpl(NULL) LLUICtrl::CommitCallbackRegistry::Registrar& reg = LLUICtrl::CommitCallbackRegistry::defaultRegistrar(); // Callbacks for associating controls with floater visibility: - reg.add("Floater.Toggle", boost::bind(&LLFloaterReg::toggleInstance, _2, LLSD())); - reg.add("Floater.ToggleOrBringToFront", boost::bind(&LLFloaterReg::toggleInstanceOrBringToFront, _2, LLSD())); - reg.add("Floater.Show", boost::bind(&LLFloaterReg::showInstance, _2, LLSD(), false)); - reg.add("Floater.ShowOrBringToFront", boost::bind(&LLFloaterReg::showInstanceOrBringToFront, _2, LLSD())); - reg.add("Floater.Hide", boost::bind(&LLFloaterReg::hideInstance, _2, LLSD())); + reg.add("Floater.Toggle", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::toggleInstance(param.asStringRef()); }); + reg.add("Floater.ToggleOrBringToFront", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::toggleInstanceOrBringToFront(param.asStringRef()); }); + reg.add("Floater.Show", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::showInstance(param.asStringRef(), LLSD(), false); }); + reg.add("Floater.ShowOrBringToFront", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::showInstanceOrBringToFront(param.asStringRef(), LLSD()); }); + reg.add("Floater.Hide", [](LLUICtrl* ctrl, const LLSD& param) -> void { LLFloaterReg::hideInstance(param.asStringRef()); }); // Button initialization callback for toggle buttons reg.add("Button.SetFloaterToggle", boost::bind(&LLButton::setFloaterToggle, _1, _2)); @@ -189,8 +189,8 @@ mHelpImpl(NULL) reg.add("Button.ToggleFloater", boost::bind(&LLButton::toggleFloaterAndSetToggleState, _1, _2)); // Used by menus along with Floater.Toggle to display visibility as a check-mark - LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.Visible", boost::bind(&LLFloaterReg::instanceVisible, _2, LLSD())); - LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.IsOpen", boost::bind(&LLFloaterReg::instanceVisible, _2, LLSD())); + LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.Visible", [](LLUICtrl* ctrl, const LLSD& param) -> bool { return LLFloaterReg::instanceVisible(param.asStringRef(), LLSD()); }); + LLUICtrl::EnableCallbackRegistry::defaultRegistrar().add("Floater.IsOpen", [](LLUICtrl* ctrl, const LLSD& param) -> bool { return LLFloaterReg::instanceVisible(param.asStringRef(), LLSD()); }); // Parse the master list of commands LLCommandManager::load(); @@ -367,7 +367,7 @@ void LLUI::glRectToScreen(const LLRect& gl, LLRect *screen) } -LLControlGroup& LLUI::getControlControlGroup (const std::string& controlname) +LLControlGroup& LLUI::getControlControlGroup (std::string_view controlname) { for (settings_map_t::iterator itor = mSettingGroups.begin(); itor != mSettingGroups.end(); ++itor) @@ -529,7 +529,7 @@ namespace LLInitParam { if (control.isProvided() && !control().empty()) { - updateValue(LLUIColorTable::instance().getColor(control)); + updateValue(LLUIColorTable::instance().getColor(control())); } else { diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 373a358544..f33b43f599 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -115,7 +115,7 @@ typedef void (*LLUIAudioCallback)(const LLUUID& uuid); class LLUI : public LLParamSingleton<LLUI> { public: - typedef std::map<std::string, LLControlGroup*> settings_map_t; + typedef std::map<std::string, LLControlGroup*, std::less<> > settings_map_t; private: LLSINGLETON(LLUI , const settings_map_t &settings, @@ -295,7 +295,7 @@ public: void screenRectToGL(const LLRect& screen, LLRect *gl); void glRectToScreen(const LLRect& gl, LLRect *screen); // Returns the control group containing the control name, or the default group - LLControlGroup& getControlControlGroup (const std::string& controlname); + LLControlGroup& getControlControlGroup (std::string_view controlname); F32 getMouseIdleTime() { return mMouseIdleTimer.getElapsedTimeF32(); } void resetMouseIdleTimer() { mMouseIdleTimer.reset(); } LLWindow* getWindow() { return mWindow; } diff --git a/indra/llui/lluicolortable.cpp b/indra/llui/lluicolortable.cpp index 54f8727fa5..3279926786 100644 --- a/indra/llui/lluicolortable.cpp +++ b/indra/llui/lluicolortable.cpp @@ -63,7 +63,7 @@ void LLUIColorTable::insertFromParams(const Params& p, string_color_map_t& table ColorEntryParams color_entry = *it; if(color_entry.color.value.isChosen()) { - setColor(color_entry.name, color_entry.color.value, table); + setColor(color_entry.name(), color_entry.color.value, table); } else { @@ -176,7 +176,7 @@ void LLUIColorTable::clear() clearTable(mUserSetColors); } -LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& default_color) const +LLUIColor LLUIColorTable::getColor(std::string_view name, const LLColor4& default_color) const { string_color_map_t::const_iterator iter = mUserSetColors.find(name); @@ -196,7 +196,7 @@ LLUIColor LLUIColorTable::getColor(const std::string& name, const LLColor4& defa } // update user color, loaded colors are parsed on initialization -void LLUIColorTable::setColor(const std::string& name, const LLColor4& color) +void LLUIColorTable::setColor(std::string_view name, const LLColor4& color) { setColor(name, color, mUserSetColors); } @@ -258,7 +258,7 @@ void LLUIColorTable::saveUserSettings() const } } -bool LLUIColorTable::colorExists(const std::string& color_name) const +bool LLUIColorTable::colorExists(std::string_view color_name) const { return ((mLoadedColors.find(color_name) != mLoadedColors.end()) || (mUserSetColors.find(color_name) != mUserSetColors.end())); @@ -276,7 +276,7 @@ void LLUIColorTable::clearTable(string_color_map_t& table) // this method inserts a color into the table if it does not exist // if the color already exists it changes the color -void LLUIColorTable::setColor(const std::string& name, const LLColor4& color, string_color_map_t& table) +void LLUIColorTable::setColor(std::string_view name, const LLColor4& color, string_color_map_t& table) { string_color_map_t::iterator it = table.lower_bound(name); if(it != table.end() diff --git a/indra/llui/lluicolortable.h b/indra/llui/lluicolortable.h index 7232077cab..ca1ca9eaa7 100644 --- a/indra/llui/lluicolortable.h +++ b/indra/llui/lluicolortable.h @@ -42,7 +42,7 @@ class LLUIColorTable : public LLSingleton<LLUIColorTable> LOG_CLASS(LLUIColorTable); // consider using sorted vector, can be much faster - typedef std::map<std::string, LLUIColor> string_color_map_t; + typedef std::map<std::string, LLUIColor, std::less<>> string_color_map_t; public: struct ColorParams : LLInitParam::ChoiceBlock<ColorParams> @@ -75,13 +75,13 @@ public: void clear(); // color lookup - LLUIColor getColor(const std::string& name, const LLColor4& default_color = LLColor4::magenta) const; + LLUIColor getColor(std::string_view name, const LLColor4& default_color = LLColor4::magenta) const; // if the color is in the table, it's value is changed, otherwise it is added - void setColor(const std::string& name, const LLColor4& color); + void setColor(std::string_view name, const LLColor4& color); // returns true if color_name exists in the table - bool colorExists(const std::string& color_name) const; + bool colorExists(std::string_view color_name) const; // loads colors from settings files bool loadFromSettings(); @@ -95,7 +95,7 @@ private: void insertFromParams(const Params& p, string_color_map_t& table); void clearTable(string_color_map_t& table); - void setColor(const std::string& name, const LLColor4& color, string_color_map_t& table); + void setColor(std::string_view name, const LLColor4& color, string_color_map_t& table); string_color_map_t mLoadedColors; string_color_map_t mUserSetColors; diff --git a/indra/llui/lluictrl.cpp b/indra/llui/lluictrl.cpp index 52c5f72a45..cb86a79407 100644 --- a/indra/llui/lluictrl.cpp +++ b/indra/llui/lluictrl.cpp @@ -44,7 +44,7 @@ F32 LLUICtrl::sInactiveControlTransparency = 1.0f; // Compiler optimization, generate extern template template class LLUICtrl* LLView::getChild<class LLUICtrl>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; LLUICtrl::CallbackParam::CallbackParam() : name("name"), @@ -135,7 +135,7 @@ void LLUICtrl::initFromParams(const Params& p) { if (p.enabled_controls.enabled.isChosen()) { - LLControlVariable* control = findControl(p.enabled_controls.enabled); + LLControlVariable* control = findControl(p.enabled_controls.enabled()); if (control) { setEnabledControlVariable(control); @@ -149,7 +149,7 @@ void LLUICtrl::initFromParams(const Params& p) } else if(p.enabled_controls.disabled.isChosen()) { - LLControlVariable* control = findControl(p.enabled_controls.disabled); + LLControlVariable* control = findControl(p.enabled_controls.disabled()); if (control) { setDisabledControlVariable(control); @@ -166,7 +166,7 @@ void LLUICtrl::initFromParams(const Params& p) { if (p.controls_visibility.visible.isChosen()) { - LLControlVariable* control = findControl(p.controls_visibility.visible); + LLControlVariable* control = findControl(p.controls_visibility.visible()); if (control) { setMakeVisibleControlVariable(control); @@ -180,7 +180,7 @@ void LLUICtrl::initFromParams(const Params& p) } else if (p.controls_visibility.invisible.isChosen()) { - LLControlVariable* control = findControl(p.controls_visibility.invisible); + LLControlVariable* control = findControl(p.controls_visibility.invisible()); if (control) { setMakeInvisibleControlVariable(control); diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index c56c3c43a4..fb8fc0c5ea 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -335,7 +335,7 @@ private: // Build time optimization, generate once in .cpp file #ifndef LLUICTRL_CPP extern template class LLUICtrl* LLView::getChild<class LLUICtrl>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif // LL_LLUICTRL_H diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index a07f9b7dae..75e7e396bc 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -182,10 +182,10 @@ fail: } template<class T> - static T* getDefaultWidget(const std::string& name) + static T* getDefaultWidget(std::string_view name) { typename T::Params widget_params; - widget_params.name = name; + widget_params.name = std::string(name); return create<T>(widget_params); } diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 441b7d6a6c..7d6c937b85 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -85,7 +85,7 @@ bool LLView::sIsDrawing = false; // Compiler optimization, generate extern template template class LLView* LLView::getChild<class LLView>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; static LLDefaultChildRegistry::Register<LLView> r("view"); @@ -729,7 +729,7 @@ void LLView::logMouseEvent() } template <typename METHOD, typename CHARTYPE> -LLView* LLView::childrenHandleCharEvent(const std::string& desc, const METHOD& method, +LLView* LLView::childrenHandleCharEvent(std::string_view desc, const METHOD& method, CHARTYPE c, MASK mask) { if ( getVisible() && getEnabled() ) @@ -1613,7 +1613,7 @@ bool LLView::hasAncestor(const LLView* parentp) const //----------------------------------------------------------------------------- -bool LLView::childHasKeyboardFocus( const std::string& childname ) const +bool LLView::childHasKeyboardFocus(std::string_view childname) const { LLView *focus = dynamic_cast<LLView *>(gFocusMgr.getKeyboardFocus()); @@ -1632,7 +1632,7 @@ bool LLView::childHasKeyboardFocus( const std::string& childname ) const //----------------------------------------------------------------------------- -bool LLView::hasChild(const std::string& childname, bool recurse) const +bool LLView::hasChild(std::string_view childname, bool recurse) const { return findChildView(childname, recurse) != NULL; } @@ -1640,12 +1640,12 @@ bool LLView::hasChild(const std::string& childname, bool recurse) const //----------------------------------------------------------------------------- // getChildView() //----------------------------------------------------------------------------- -LLView* LLView::getChildView(const std::string& name, bool recurse) const +LLView* LLView::getChildView(std::string_view name, bool recurse) const { return getChild<LLView>(name, recurse); } -LLView* LLView::findChildView(const std::string& name, bool recurse) const +LLView* LLView::findChildView(std::string_view name, bool recurse) const { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; @@ -2312,18 +2312,20 @@ LLView* LLView::findSnapEdge(S32& new_edge_val, const LLCoordGL& mouse_dir, ESna //----------------------------------------------------------------------------- -LLControlVariable *LLView::findControl(const std::string& name) +LLControlVariable *LLView::findControl(std::string_view name) { + auto uiInst = LLUI::getInstance(); // parse the name to locate which group it belongs to std::size_t key_pos= name.find("."); - if(key_pos!= std::string::npos ) + if(key_pos != std::string_view::npos ) { - std::string control_group_key = name.substr(0, key_pos); + std::string_view control_group_key = name.substr(0, key_pos); LLControlVariable* control; // check if it's in the control group that name indicated - if(LLUI::getInstance()->mSettingGroups[control_group_key]) + auto it = uiInst->mSettingGroups.find(control_group_key); + if(it != uiInst->mSettingGroups.end() && it->second) { - control = LLUI::getInstance()->mSettingGroups[control_group_key]->getControl(name); + control = it->second->getControl(name); if (control) { return control; @@ -2331,7 +2333,7 @@ LLControlVariable *LLView::findControl(const std::string& name) } } - LLControlGroup& control_group = LLUI::getInstance()->getControlControlGroup(name); + LLControlGroup& control_group = uiInst->getControlControlGroup(name); return control_group.getControl(name); } diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 3ce7243370..710ec3d05e 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -341,8 +341,8 @@ public: S32 getChildCount() const { return (S32)mChildList.size(); } template<class _Pr3> void sortChildren(_Pr3 _Pred) { mChildList.sort(_Pred); } bool hasAncestor(const LLView* parentp) const; - bool hasChild(const std::string& childname, bool recurse = false) const; - bool childHasKeyboardFocus( const std::string& childname ) const; + bool hasChild(std::string_view childname, bool recurse = false) const; + bool childHasKeyboardFocus( std::string_view childname ) const; // these iterators are used for collapsing various tree traversals into for loops typedef LLTreeDFSIter<LLView, child_list_const_iter_t> tree_iterator_t; @@ -416,7 +416,7 @@ public: void screenRectToLocal( const LLRect& screen, LLRect* local ) const; void localRectToScreen( const LLRect& local, LLRect* screen ) const; - LLControlVariable *findControl(const std::string& name); + LLControlVariable *findControl(std::string_view name); const child_list_t* getChildList() const { return &mChildList; } child_list_const_iter_t beginChild() const { return mChildList.begin(); } @@ -452,24 +452,24 @@ public: // static method handles NULL pointer too static std::string getPathname(const LLView*); - template <class T> T* findChild(const std::string& name, bool recurse = true) const + template <class T> T* findChild(std::string_view name, bool recurse = true) const { LLView* child = findChildView(name, recurse); T* result = dynamic_cast<T*>(child); return result; } - template <class T> T* getChild(const std::string& name, bool recurse = true) const; + template <class T> T* getChild(std::string_view name, bool recurse = true) const; - template <class T> T& getChildRef(const std::string& name, bool recurse = true) const + template <class T> T& getChildRef(std::string_view name, bool recurse = true) const { return *getChild<T>(name, recurse); } - virtual LLView* getChildView(const std::string& name, bool recurse = true) const; - virtual LLView* findChildView(const std::string& name, bool recurse = true) const; + virtual LLView* getChildView(std::string_view name, bool recurse = true) const; + virtual LLView* findChildView(std::string_view name, bool recurse = true) const; - template <class T> T* getDefaultWidget(const std::string& name) const + template <class T> T* getDefaultWidget(std::string_view name) const { LLView* widgetp = getDefaultWidgetContainer().findChildView(name); return dynamic_cast<T*>(widgetp); @@ -576,7 +576,7 @@ private: LLView* childrenHandleMouseEvent(const METHOD& method, S32 x, S32 y, XDATA extra, bool allow_mouse_block = true); template <typename METHOD, typename CHARTYPE> - LLView* childrenHandleCharEvent(const std::string& desc, const METHOD& method, + LLView* childrenHandleCharEvent(std::string_view desc, const METHOD& method, CHARTYPE c, MASK mask); // adapter to blur distinction between handleKey() and handleUnicodeChar() @@ -696,7 +696,7 @@ struct TypeValues<LLView::EOrientation> : public LLInitParam::TypeValuesHelper<L }; } -template <class T> T* LLView::getChild(const std::string& name, bool recurse) const +template <class T> T* LLView::getChild(std::string_view name, bool recurse) const { LLView* child = findChildView(name, recurse); T* result = dynamic_cast<T*>(child); @@ -731,7 +731,7 @@ template <class T> T* LLView::getChild(const std::string& name, bool recurse) co // require explicit specialization. See llbutton.cpp for an example. #ifndef LLVIEW_CPP extern template class LLView* LLView::getChild<class LLView>( - const std::string& name, bool recurse) const; + std::string_view name, bool recurse) const; #endif #endif //LL_LLVIEW_H diff --git a/indra/llui/llvirtualtrackball.cpp b/indra/llui/llvirtualtrackball.cpp index 8166afc89b..273a1d7bde 100644 --- a/indra/llui/llvirtualtrackball.cpp +++ b/indra/llui/llvirtualtrackball.cpp @@ -217,19 +217,19 @@ void LLVirtualTrackball::draw() S32 halfwidth = mTouchArea->getRect().getWidth() / 2; S32 halfheight = mTouchArea->getRect().getHeight() / 2; - draw_point.mV[VX] = (draw_point.mV[VX] + 1.0) * halfwidth + mTouchArea->getRect().mLeft; - draw_point.mV[VY] = (draw_point.mV[VY] + 1.0) * halfheight + mTouchArea->getRect().mBottom; + draw_point.mV[VX] = (draw_point.mV[VX] + 1.0f) * halfwidth + mTouchArea->getRect().mLeft; + draw_point.mV[VY] = (draw_point.mV[VY] + 1.0f) * halfheight + mTouchArea->getRect().mBottom; bool upper_hemisphere = (draw_point.mV[VZ] >= 0.f); mImgSphere->draw(mTouchArea->getRect(), upper_hemisphere ? UI_VERTEX_COLOR : UI_VERTEX_COLOR % 0.5f); - drawThumb(draw_point.mV[VX], draw_point.mV[VY], mThumbMode, upper_hemisphere); + drawThumb((S32)draw_point.mV[VX], (S32)draw_point.mV[VY], mThumbMode, upper_hemisphere); if (LLView::sDebugRects) { gGL.color4fv(LLColor4::red.mV); - gl_circle_2d(mTouchArea->getRect().getCenterX(), mTouchArea->getRect().getCenterY(), mImgSphere->getWidth() / 2, 60, false); - gl_circle_2d(draw_point.mV[VX], draw_point.mV[VY], mImgSunFront->getWidth() / 2, 12, false); + gl_circle_2d((F32)mTouchArea->getRect().getCenterX(), (F32)mTouchArea->getRect().getCenterY(), (F32)mImgSphere->getWidth() / 2.f, 60, false); + gl_circle_2d(draw_point.mV[VX], draw_point.mV[VY], (F32)mImgSunFront->getWidth() / 2.f, 12, false); } // hide the direction labels when disabled @@ -392,20 +392,20 @@ bool LLVirtualTrackball::handleHover(S32 x, S32 y, MASK mask) { // trackball (move to roll) mode LLQuaternion delta; - F32 rotX = x - mPrevX; - F32 rotY = y - mPrevY; + F32 rotX = (F32)(x - mPrevX); + F32 rotY = (F32)(y - mPrevY); if (abs(rotX) > 1) { - F32 direction = (rotX < 0) ? -1 : 1; - delta.setAngleAxis(mIncrementMouse * abs(rotX), 0, direction, 0); // changing X - rotate around Y axis + F32 direction = (rotX < 0) ? -1.f : 1.f; + delta.setAngleAxis(mIncrementMouse * abs(rotX), 0.f, direction, 0.f); // changing X - rotate around Y axis mValue *= delta; } if (abs(rotY) > 1) { - F32 direction = (rotY < 0) ? 1 : -1; // reverse for Y (value increases from bottom to top) - delta.setAngleAxis(mIncrementMouse * abs(rotY), direction, 0, 0); // changing Y - rotate around X axis + F32 direction = (rotY < 0) ? 1.f : -1.f; // reverse for Y (value increases from bottom to top) + delta.setAngleAxis(mIncrementMouse * abs(rotY), direction, 0.f, 0.f); // changing Y - rotate around X axis mValue *= delta; } } @@ -416,10 +416,10 @@ bool LLVirtualTrackball::handleHover(S32 x, S32 y, MASK mask) return true; // don't drag outside the circle } - F32 radius = mTouchArea->getRect().getWidth() / 2; - F32 xx = x - mTouchArea->getRect().getCenterX(); - F32 yy = y - mTouchArea->getRect().getCenterY(); - F32 dist = sqrt(pow(xx, 2) + pow(yy, 2)); + F32 radius = (F32)mTouchArea->getRect().getWidth() / 2.f; + F32 xx = (F32)(x - mTouchArea->getRect().getCenterX()); + F32 yy = (F32)(y - mTouchArea->getRect().getCenterY()); + F32 dist = (F32)(sqrt(pow(xx, 2) + pow(yy, 2))); F32 azimuth = llclamp(acosf(xx / dist), 0.0f, F_PI); F32 altitude = llclamp(acosf(dist / radius), 0.0f, F_PI_BY_TWO); diff --git a/indra/llui/llxyvector.cpp b/indra/llui/llxyvector.cpp index 19bd8465b9..1521823ce2 100644 --- a/indra/llui/llxyvector.cpp +++ b/indra/llui/llxyvector.cpp @@ -159,15 +159,15 @@ void drawArrow(S32 tailX, S32 tailY, S32 tipX, S32 tipY, LLColor4 color) S32 arrowLength = (abs(dx) < ARROW_LENGTH_LONG && abs(dy) < ARROW_LENGTH_LONG) ? ARROW_LENGTH_SHORT : ARROW_LENGTH_LONG; - F32 theta = std::atan2(dy, dx); + F32 theta = (F32)std::atan2(dy, dx); - F32 rad = ARROW_ANGLE * std::atan(1) * 4 / 180; + F32 rad = (F32)(ARROW_ANGLE * std::atan(1) * 4 / 180); F32 x = tipX - arrowLength * cos(theta + rad); F32 y = tipY - arrowLength * sin(theta + rad); - F32 rad2 = -1 * ARROW_ANGLE * std::atan(1) * 4 / 180; + F32 rad2 = (F32)(-1 * ARROW_ANGLE * std::atan(1) * 4 / 180); F32 x2 = tipX - arrowLength * cos(theta + rad2); F32 y2 = tipY - arrowLength * sin(theta + rad2); - gl_triangle_2d(tipX, tipY, x, y, x2, y2, color, true); + gl_triangle_2d(tipX, tipY, (S32)x, (S32)y, (S32)x2, (S32)y2, color, true); } void LLXYVector::draw() @@ -179,18 +179,18 @@ void LLXYVector::draw() if (mLogarithmic) { - pointX = (log(llabs(mValueX) + 1)) / mLogScaleX; + pointX = (S32)((log(llabs(mValueX) + 1)) / mLogScaleX); pointX *= (mValueX < 0) ? -1 : 1; pointX += centerX; - pointY = (log(llabs(mValueY) + 1)) / mLogScaleY; + pointY = (S32)((log(llabs(mValueY) + 1)) / mLogScaleY); pointY *= (mValueY < 0) ? -1 : 1; pointY += centerY; } else // linear { - pointX = centerX + (mValueX * mTouchArea->getRect().getWidth() / (2 * mMaxValueX)); - pointY = centerY + (mValueY * mTouchArea->getRect().getHeight() / (2 * mMaxValueY)); + pointX = centerX + (S32)(mValueX * mTouchArea->getRect().getWidth() / (2 * mMaxValueX)); + pointY = centerY + (S32)(mValueY * mTouchArea->getRect().getHeight() / (2 * mMaxValueY)); } // fill @@ -223,7 +223,7 @@ void LLXYVector::draw() } // draw center circle - gl_circle_2d(centerX, centerY, CENTER_CIRCLE_RADIUS, 12, true); + gl_circle_2d((F32)centerX, (F32)centerY, CENTER_CIRCLE_RADIUS, 12, true); LLView::draw(); } @@ -232,7 +232,7 @@ void LLXYVector::onEditChange() { if (getEnabled()) { - setValueAndCommit(mXEntry->getValue().asReal(), mYEntry->getValue().asReal()); + setValueAndCommit((F32)mXEntry->getValue().asReal(), (F32)mYEntry->getValue().asReal()); } } @@ -240,7 +240,7 @@ void LLXYVector::setValue(const LLSD& value) { if (value.isArray()) { - setValue(value[0].asReal(), value[1].asReal()); + setValue((F32)value[0].asReal(), (F32)value[1].asReal()); } } diff --git a/indra/llwebrtc/llwebrtc.cpp b/indra/llwebrtc/llwebrtc.cpp index d5bd913315..6dc632aba4 100644 --- a/indra/llwebrtc/llwebrtc.cpp +++ b/indra/llwebrtc/llwebrtc.cpp @@ -458,7 +458,7 @@ void ll_set_device_module_render_device(rtc::scoped_refptr<webrtc::AudioDeviceMo { device_module->SetPlayoutDevice(webrtc::AudioDeviceModule::kDefaultDevice); } - else + else { device_module->SetPlayoutDevice(device); } @@ -656,7 +656,7 @@ void LLWebRTCImpl::freePeerConnection(LLWebRTCPeerConnectionInterface* peer_conn // Most peer connection (signaling) happens on // the signaling thread. -LLWebRTCPeerConnectionImpl::LLWebRTCPeerConnectionImpl() : +LLWebRTCPeerConnectionImpl::LLWebRTCPeerConnectionImpl() : mWebRTCImpl(nullptr), mPeerConnection(nullptr), mMute(false), @@ -1171,7 +1171,7 @@ void LLWebRTCPeerConnectionImpl::OnSuccess(webrtc::SessionDescriptionInterface * { observer->OnOfferAvailable(mangled_sdp); } - + mPeerConnection->SetLocalDescription(std::unique_ptr<webrtc::SessionDescriptionInterface>( webrtc::CreateSessionDescription(webrtc::SdpType::kOffer, mangled_sdp)), rtc::scoped_refptr<webrtc::SetLocalDescriptionObserverInterface>(this)); diff --git a/indra/llwebrtc/llwebrtc.h b/indra/llwebrtc/llwebrtc.h index f447ea990a..62b40636d2 100644 --- a/indra/llwebrtc/llwebrtc.h +++ b/indra/llwebrtc/llwebrtc.h @@ -129,7 +129,7 @@ class LLWebRTCDeviceInterface }; virtual void setAudioConfig(AudioConfig config) = 0; - + // instructs webrtc to refresh the device list. virtual void refreshDevices() = 0; @@ -230,8 +230,8 @@ class LLWebRTCSignalingObserver // allows for management of this peer connection. class LLWebRTCPeerConnectionInterface { - public: - +public: + struct InitOptions { // equivalent of PeerConnectionInterface::IceServer diff --git a/indra/llwebrtc/llwebrtc_impl.h b/indra/llwebrtc/llwebrtc_impl.h index 6672f8ce90..2fb5525519 100644 --- a/indra/llwebrtc/llwebrtc_impl.h +++ b/indra/llwebrtc/llwebrtc_impl.h @@ -235,7 +235,7 @@ class LLWebRTCImpl : public LLWebRTCDeviceInterface, public webrtc::AudioDeviceS // The factory that allows creation of native webrtc PeerConnections. rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> mPeerConnectionFactory; - + rtc::scoped_refptr<webrtc::AudioProcessing> mAudioProcessingModule; // more native webrtc stuff diff --git a/indra/llwindow/lldxhardware.cpp b/indra/llwindow/lldxhardware.cpp index d916d95713..392a67b5ce 100644 --- a/indra/llwindow/lldxhardware.cpp +++ b/indra/llwindow/lldxhardware.cpp @@ -343,7 +343,7 @@ std::string LLDXHardware::getDriverVersionWMI(EGPUVendor vendor) //convert BSTR to std::string std::wstring ws(caption, SysStringLen(caption)); - std::string caption_str(ws.begin(), ws.end()); + std::string caption_str = ll_convert_wide_to_string(ws); LLStringUtil::toLower(caption_str); bool found = false; @@ -395,7 +395,7 @@ std::string LLDXHardware::getDriverVersionWMI(EGPUVendor vendor) //convert BSTR to std::string std::wstring ws(driverVersion, SysStringLen(driverVersion)); - std::string str(ws.begin(), ws.end()); + std::string str = ll_convert_wide_to_string(ws); LL_INFOS("AppInit") << " DriverVersion : " << str << LL_ENDL; if (mDriverVersion.empty()) diff --git a/indra/llwindow/llkeyboard.cpp b/indra/llwindow/llkeyboard.cpp index 4f29fb0b0a..33eebdadd1 100644 --- a/indra/llwindow/llkeyboard.cpp +++ b/indra/llwindow/llkeyboard.cpp @@ -359,7 +359,7 @@ std::string LLKeyboard::stringFromKey(KEY key, bool translate) LLKeyStringTranslatorFunc *trans = gKeyboard->mStringTranslator; if (trans != NULL) { - res = trans(res.c_str()); + res = trans(res); } } @@ -399,7 +399,7 @@ std::string LLKeyboard::stringFromMouse(EMouseClickType click, bool translate) LLKeyStringTranslatorFunc* trans = gKeyboard->mStringTranslator; if (trans != NULL) { - res = trans(res.c_str()); + res = trans(res); } } return res; diff --git a/indra/llwindow/llkeyboard.h b/indra/llwindow/llkeyboard.h index 7f8d0af155..713eb7aec2 100644 --- a/indra/llwindow/llkeyboard.h +++ b/indra/llwindow/llkeyboard.h @@ -42,7 +42,7 @@ enum EKeystate }; typedef boost::function<bool(EKeystate keystate)> LLKeyFunc; -typedef std::string (LLKeyStringTranslatorFunc)(const char *label); +typedef std::string (LLKeyStringTranslatorFunc)(std::string_view); enum EKeyboardInsertMode { diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index 56c393be0f..378e633cd2 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -71,8 +71,8 @@ S32 OSMessageBox(const std::string& text, const std::string& caption, U32 type) } S32 result = 0; -#if LL_MESA_HEADLESS // !!! *FIX: (?) LL_WARNS() << "OSMessageBox: " << text << LL_ENDL; +#if LL_MESA_HEADLESS // !!! *FIX: (?) return OSBTN_OK; #elif LL_WINDOWS result = OSMessageBoxWin32(text, caption, type); diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index f0f7e03691..94762db5c5 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -187,6 +187,8 @@ DWORD LLWindowWin32::sWinIMEConversionMode = IME_CMODE_NATIVE; DWORD LLWindowWin32::sWinIMESentenceMode = IME_SMODE_AUTOMATIC; LLCoordWindow LLWindowWin32::sWinIMEWindowPosition(-1,-1); +static HWND sWindowHandleForMessageBox = NULL; + // The following class LLWinImm delegates Windows IMM APIs. // It was originally introduced to support US Windows XP, on which we needed // to dynamically load IMM32.DLL and use GetProcAddress to resolve its entry @@ -848,6 +850,11 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks, LLWindowWin32::~LLWindowWin32() { + if (sWindowHandleForMessageBox == mWindowHandle) + { + sWindowHandleForMessageBox = NULL; + } + delete mDragDrop; delete [] mWindowTitle; @@ -970,6 +977,11 @@ void LLWindowWin32::close() LL_DEBUGS("Window") << "Destroying Window" << LL_ENDL; + if (sWindowHandleForMessageBox == mWindowHandle) + { + sWindowHandleForMessageBox = NULL; + } + mhDC = NULL; mWindowHandle = NULL; @@ -1383,7 +1395,7 @@ bool LLWindowWin32::switchContext(bool fullscreen, const LLCoordScreen& size, bo gGLManager.initWGL(); - if (wglChoosePixelFormatARB) + if (wglChoosePixelFormatARB && wglGetPixelFormatAttribivARB) { // OK, at this point, use the ARB wglChoosePixelFormatsARB function to see if we // can get exactly what we want. @@ -1702,10 +1714,15 @@ void LLWindowWin32::recreateWindow(RECT window_rect, DWORD dw_ex_style, DWORD dw auto oldWindowHandle = mWindowHandle; auto oldDCHandle = mhDC; + if (sWindowHandleForMessageBox == mWindowHandle) + { + sWindowHandleForMessageBox = NULL; + } + // zero out mWindowHandle and mhDC before destroying window so window // thread falls back to peekmessage - mWindowHandle = 0; - mhDC = 0; + mWindowHandle = NULL; + mhDC = NULL; std::promise<std::pair<HWND, HDC>> promise; // What follows must be done on the window thread. @@ -1802,6 +1819,8 @@ void LLWindowWin32::recreateWindow(RECT window_rect, DWORD dw_ex_style, DWORD dw auto pair = future.get(); mWindowHandle = pair.first; mhDC = pair.second; + + sWindowHandleForMessageBox = mWindowHandle; } void* LLWindowWin32::createSharedContext() @@ -1809,7 +1828,7 @@ void* LLWindowWin32::createSharedContext() mMaxGLVersion = llclamp(mMaxGLVersion, 3.f, 4.6f); S32 version_major = llfloor(mMaxGLVersion); - S32 version_minor = llround((mMaxGLVersion-version_major)*10); + S32 version_minor = (S32)llround((mMaxGLVersion-version_major)*10); S32 attribs[] = { @@ -2111,7 +2130,7 @@ void LLWindowWin32::initCursors() void LLWindowWin32::updateCursor() { ASSERT_MAIN_THREAD(); - LL_PROFILE_ZONE_SCOPED_CATEGORY_WIN32 + LL_PROFILE_ZONE_SCOPED_CATEGORY_WIN32; if (mNextCursor == UI_CURSOR_ARROW && mBusyCount > 0) { @@ -2155,7 +2174,7 @@ void LLWindowWin32::delayInputProcessing() void LLWindowWin32::gatherInput() { ASSERT_MAIN_THREAD(); - LL_PROFILE_ZONE_SCOPED_CATEGORY_WIN32 + LL_PROFILE_ZONE_SCOPED_CATEGORY_WIN32; MSG msg; { @@ -2464,12 +2483,12 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ { window_imp->mKeyCharCode = 0; // don't know until wm_char comes in next window_imp->mKeyScanCode = (l_param >> 16) & 0xff; - window_imp->mKeyVirtualKey = w_param; + window_imp->mKeyVirtualKey = (U32)w_param; window_imp->mRawMsg = u_msg; - window_imp->mRawWParam = w_param; - window_imp->mRawLParam = l_param; + window_imp->mRawWParam = (U32)w_param; + window_imp->mRawLParam = (U32)l_param; - gKeyboard->handleKeyDown(w_param, mask); + gKeyboard->handleKeyDown((U16)w_param, mask); }); if (eat_keystroke) return 0; // skip DefWindowProc() handling if we're consuming the keypress break; @@ -2484,14 +2503,14 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ window_imp->post([=]() { window_imp->mKeyScanCode = (l_param >> 16) & 0xff; - window_imp->mKeyVirtualKey = w_param; + window_imp->mKeyVirtualKey = (U32)w_param; window_imp->mRawMsg = u_msg; - window_imp->mRawWParam = w_param; - window_imp->mRawLParam = l_param; + window_imp->mRawWParam = (U32)w_param; + window_imp->mRawLParam = (U32)l_param; { LL_PROFILE_ZONE_NAMED_CATEGORY_WIN32("mwp - WM_KEYUP"); - gKeyboard->handleKeyUp(w_param, mask); + gKeyboard->handleKeyUp((U16)w_param, mask); } }); if (eat_keystroke) return 0; // skip DefWindowProc() handling if we're consuming the keypress @@ -2531,7 +2550,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ LL_PROFILE_ZONE_NAMED_CATEGORY_WIN32("mwp - WM_IME_COMPOSITION"); if (LLWinImm::isAvailable() && window_imp->mPreeditor) { - WINDOW_IMP_POST(window_imp->handleCompositionMessage(l_param)); + WINDOW_IMP_POST(window_imp->handleCompositionMessage((U32)l_param)); return 0; } break; @@ -2552,10 +2571,10 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ LL_PROFILE_ZONE_NAMED_CATEGORY_WIN32("mwp - WM_CHAR"); window_imp->post([=]() { - window_imp->mKeyCharCode = w_param; + window_imp->mKeyCharCode = (U32)w_param; window_imp->mRawMsg = u_msg; - window_imp->mRawWParam = w_param; - window_imp->mRawLParam = l_param; + window_imp->mRawWParam = (U32)w_param; + window_imp->mRawLParam = (U32)l_param; // Should really use WM_UNICHAR eventually, but it requires a specific Windows version and I need // to figure out how that works. - Doug @@ -2979,7 +2998,7 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ window_imp->post([=]() { - window_imp->mCallbacks->handleDataCopy(window_imp, myType, data); + window_imp->mCallbacks->handleDataCopy(window_imp, (S32)myType, data); delete[] data; }); }; @@ -3039,8 +3058,8 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ S32 width = GetSystemMetrics(v_desktop ? SM_CXVIRTUALSCREEN : SM_CXSCREEN); S32 height = GetSystemMetrics(v_desktop ? SM_CYVIRTUALSCREEN : SM_CYSCREEN); - absolute_x = (raw->data.mouse.lLastX / 65535.0f) * width; - absolute_y = (raw->data.mouse.lLastY / 65535.0f) * height; + absolute_x = (S32)((raw->data.mouse.lLastX / 65535.0f) * width); + absolute_y = (S32)((raw->data.mouse.lLastY / 65535.0f) * height); } window_imp->mRawMouseDelta.mX += absolute_x - prev_absolute_x; @@ -3061,8 +3080,8 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_ } else { - window_imp->mRawMouseDelta.mX += round((F32)raw->data.mouse.lLastX * (F32)speed / DEFAULT_SPEED); - window_imp->mRawMouseDelta.mY -= round((F32)raw->data.mouse.lLastY * (F32)speed / DEFAULT_SPEED); + window_imp->mRawMouseDelta.mX += (S32)round((F32)raw->data.mouse.lLastX * (F32)speed / DEFAULT_SPEED); + window_imp->mRawMouseDelta.mY -= (S32)round((F32)raw->data.mouse.lLastY * (F32)speed / DEFAULT_SPEED); } } } @@ -3684,7 +3703,14 @@ S32 OSMessageBoxWin32(const std::string& text, const std::string& caption, U32 t break; } - int retval_win = MessageBoxW(NULL, // HWND + // AG: Of course, the using of the static global variable sWindowHandleForMessageBox + // instead of using the field mWindowHandle of the class LLWindowWin32 looks strange. + // But in fact, the function OSMessageBoxWin32() doesn't have access to gViewerWindow + // because the former is implemented in the library llwindow which is abstract enough. + // + // "This is why I'm doing it this way, instead of what you would think would be more obvious..." + // (C) Nat Goodspeed + int retval_win = MessageBoxW(sWindowHandleForMessageBox, // HWND ll_convert_string_to_wide(text).c_str(), ll_convert_string_to_wide(caption).c_str(), uType); @@ -4658,7 +4684,7 @@ void LLWindowWin32::LLWindowWin32Thread::checkDXMem() DXGI_ADAPTER_DESC desc; p_dxgi_adapter->GetDesc(&desc); std::wstring description_w((wchar_t*)desc.Description); - std::string description(description_w.begin(), description_w.end()); + std::string description = ll_convert_wide_to_string(description_w); LL_INFOS("Window") << "Graphics adapter index: " << graphics_adapter_index << ", " << "Description: " << description << ", " << "DeviceId: " << desc.DeviceId << ", " diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp index 82e07e03c9..bb590ebd76 100644 --- a/indra/llxml/llcontrol.cpp +++ b/indra/llxml/llcontrol.cpp @@ -348,7 +348,7 @@ LLPointer<LLControlVariable> LLControlGroup::getControl(std::string_view name) incrCount(name); } - ctrl_name_table_t::iterator iter = mNameTable.find(name.data()); + ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter == mNameTable.end() ? LLPointer<LLControlVariable>() : iter->second; } @@ -657,7 +657,7 @@ LLSD LLControlGroup::asLLSD(bool diffs_only) return result; } -bool LLControlGroup::controlExists(const std::string& name) +bool LLControlGroup::controlExists(std::string_view name) { ctrl_name_table_t::iterator iter = mNameTable.find(name); return iter != mNameTable.end(); diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index 1b04729a82..344352e980 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -189,7 +189,7 @@ class LLControlGroup : public LLInstanceTracker<LLControlGroup, std::string> LOG_CLASS(LLControlGroup); protected: - typedef std::map<std::string, LLControlVariablePtr > ctrl_name_table_t; + typedef std::map<std::string, LLControlVariablePtr, std::less<> > ctrl_name_table_t; ctrl_name_table_t mNameTable; static const std::string mTypeString[TYPE_COUNT]; @@ -295,7 +295,7 @@ public: } } - bool controlExists(const std::string& name); + bool controlExists(std::string_view name); // Returns number of controls loaded, 0 if failed // If require_declaration is false, will auto-declare controls it finds diff --git a/indra/llxml/llxmlnode.cpp b/indra/llxml/llxmlnode.cpp index 0fd4516844..e695035461 100644 --- a/indra/llxml/llxmlnode.cpp +++ b/indra/llxml/llxmlnode.cpp @@ -38,7 +38,9 @@ #include "v3math.h" #include "v3dmath.h" #include "v4math.h" +#include "llbase64.h" #include "llquaternion.h" +#include "llsd.h" #include "llstring.h" #include "lluuid.h" #include "lldir.h" @@ -653,32 +655,24 @@ bool LLXMLNode::updateNode( // static bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXMLNode* defaults_tree) { - // Read file - LL_DEBUGS("XMLNode") << "parsing XML file: " << filename << LL_ENDL; - LLFILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */ - if (fp == NULL) + std::string xml = LLFile::getContents(filename); + if (xml.empty()) { - node = NULL ; - return false; + LL_WARNS("XMLNode") << "no XML file: " << filename << LL_ENDL; + } + else if (parseBuffer(xml.data(), xml.size(), node, defaults_tree)) + { + return true; } - fseek(fp, 0, SEEK_END); - U32 length = ftell(fp); - fseek(fp, 0, SEEK_SET); - - U8* buffer = new U8[length+1]; - size_t nread = fread(buffer, 1, length, fp); - buffer[nread] = 0; - fclose(fp); - bool rv = parseBuffer(buffer, static_cast<U32>(nread), node, defaults_tree); - delete [] buffer; - return rv; + node = nullptr; + return false; } // static bool LLXMLNode::parseBuffer( - U8* buffer, - U32 length, + const char* buffer, + U64 length, LLXMLNodePtr& node, LLXMLNode* defaults) { @@ -693,20 +687,25 @@ bool LLXMLNode::parseBuffer( file_node->mParser = &my_parser; - XML_SetUserData(my_parser, (void *)file_node_ptr); + XML_SetUserData(my_parser, file_node_ptr); // Do the parsing - if (XML_Parse(my_parser, (const char *)buffer, length, true) != XML_STATUS_OK) + bool success = XML_STATUS_OK == XML_Parse(my_parser, buffer, (int)length, true); + if (!success) { LL_WARNS() << "Error parsing xml error code: " << XML_ErrorString(XML_GetErrorCode(my_parser)) << " on line " << XML_GetCurrentLineNumber(my_parser) + << ", column " << XML_GetCurrentColumnNumber(my_parser) << LL_ENDL; } // Deinit XML_ParserFree(my_parser); + if (!success) + return false; + if (!file_node->mChildren || file_node->mChildren->map.size() != 1) { LL_WARNS() << "Parse failure - wrong number of top-level nodes xml." @@ -3266,3 +3265,171 @@ S32 LLXMLNode::getLineNumber() { return mLineNumber; } + +bool LLXMLNode::parseXmlRpcArrayValue(LLSD& target) +{ + LLXMLNode* datap = getFirstChild().get(); + if (!datap) + { + LL_WARNS() << "No inner XML element." << LL_ENDL; + return false; + } + if (!datap->hasName("data")) + { + LL_WARNS() << "No inner XML element (<data> expected, got: " + << datap->mName->mString << ")" << LL_ENDL; + return false; + } + if (datap->getNextSibling().get()) + { + LL_WARNS() << "Multiple inner XML elements (single <data> expected)" + << LL_ENDL; + return false; + } + for (LLXMLNode* itemp = datap->getFirstChild().get(); itemp; + itemp = itemp->getNextSibling().get()) + { + LLSD value; + if (!itemp->fromXMLRPCValue(value)) + { + return false; + } + target.append(value); + } + return true; +} + +bool LLXMLNode::parseXmlRpcStructValue(LLSD& target) +{ + std::string name; + LLSD value; + for (LLXMLNode* itemp = getFirstChild().get(); itemp; + itemp = itemp->getNextSibling().get()) + { + if (!itemp->hasName("member")) + { + LL_WARNS() << "Invalid inner XML element (<member> expected, got: <" + << itemp->mName->mString << ">" << LL_ENDL; + return false; + } + name.clear(); + value.clear(); + for (LLXMLNode* chilp = itemp->getFirstChild().get(); chilp; + chilp = chilp->getNextSibling().get()) + { + if (chilp->hasName("name")) + { + name = LLStringFn::xml_decode(chilp->getTextContents()); + } + else if (!chilp->fromXMLRPCValue(value)) + { + return false; + } + } + if (name.empty()) + { + LL_WARNS() << "Empty struct member name" << LL_ENDL; + return false; + } + target.insert(name, value); + } + return true; +} + +bool LLXMLNode::fromXMLRPCValue(LLSD& target) +{ + target.clear(); + + if (!hasName("value")) + { + LL_WARNS() << "Invalid XML element (<value> expected), got: <" + << mName->mString << ">" << LL_ENDL; + return false; + } + + LLXMLNode* childp = getFirstChild().get(); + if (!childp) + { + LL_WARNS() << "No inner XML element (value type expected)" << LL_ENDL; + // Value with no type qualifier is treated as string + target.assign(LLStringFn::xml_decode(getTextContents())); + return true; + } + + if (childp->getNextSibling()) + { + LL_WARNS() << "Multiple inner XML elements (single expected)" + << LL_ENDL; + return false; + } + + if (childp->hasName("string")) + { + target.assign(LLStringFn::xml_decode(childp->getTextContents())); + return true; + } + + if (childp->hasName("int") || childp->hasName("i4")) + { + target.assign(std::stoi(childp->getTextContents())); + return true; + } + + if (childp->hasName("double")) + { + target.assign(std::stod(childp->getTextContents())); + return true; + } + + if (childp->hasName("boolean")) + { + target.assign(std::stoi(childp->getTextContents()) != 0); + return true; + } + + if (childp->hasName("dateTime.iso8601")) + { + target.assign(LLSD::Date(childp->getTextContents())); + return true; + } + + if (childp->hasName("base64")) + { + std::string decoded = + LLBase64::decodeAsString(childp->getTextContents()); + size_t size = decoded.size(); + LLSD::Binary binary(size); + if (size) + { + memcpy((void*)binary.data(), (void*)decoded.data(), size); + } + target.assign(binary); + return true; + } + + if (childp->hasName("array")) + { + if (!childp->parseXmlRpcArrayValue(target)) + { + target.clear(); + return false; + } + return true; + } + + if (childp->hasName("struct")) + { + if (!childp->parseXmlRpcStructValue(target)) + { + target.clear(); + return false; + } + return true; + } + + LL_WARNS() << "Unknown inner XML element (known value type expected)" + << LL_ENDL; + // Value with unknown type qualifier is treated as string + target.assign(LLStringFn::xml_decode(childp->getTextContents())); + return true; +} diff --git a/indra/llxml/llxmlnode.h b/indra/llxml/llxmlnode.h index b8e29bbfef..3769ec8293 100644 --- a/indra/llxml/llxmlnode.h +++ b/indra/llxml/llxmlnode.h @@ -50,6 +50,7 @@ class LLVector3d; class LLQuaternion; class LLColor4; class LLColor4U; +class LLSD; struct CompareAttributes @@ -129,20 +130,20 @@ public: void addChild(LLXMLNodePtr& new_child); void setParent(LLXMLNodePtr& new_parent); // reparent if necessary - // Serialization + // Deserialization static bool parseFile( const std::string& filename, LLXMLNodePtr& node, - LLXMLNode* defaults_tree); + LLXMLNode* defaults = nullptr); static bool parseBuffer( - U8* buffer, - U32 length, + const char* buffer, + U64 length, LLXMLNodePtr& node, - LLXMLNode* defaults); + LLXMLNode* defaults = nullptr); static bool parseStream( std::istream& str, LLXMLNodePtr& node, - LLXMLNode* defaults); + LLXMLNode* defaults = nullptr); static bool updateNode( LLXMLNodePtr& node, LLXMLNodePtr& update_node); @@ -284,12 +285,18 @@ public: void setAttributes(ValueType type, U32 precision, Encoding encoding, U32 length); // void appendValue(const std::string& value); // Unused + bool fromXMLRPCValue(LLSD& target); + // Unit Testing void createUnitTest(S32 max_num_children); bool performUnitTest(std::string &error_buffer); protected: bool removeChild(LLXMLNode* child); + bool isFullyDefault(); + + bool parseXmlRpcArrayValue(LLSD& target); + bool parseXmlRpcStructValue(LLSD& target); public: std::string mID; // The ID attribute of this node @@ -328,8 +335,6 @@ protected: static const char *skipNonWhitespace(const char *str); static const char *parseInteger(const char *str, U64 *dest, bool *is_negative, U32 precision, Encoding encoding); static const char *parseFloat(const char *str, F64 *dest, U32 precision, Encoding encoding); - - bool isFullyDefault(); }; #endif // LL_LLXMLNODE diff --git a/indra/media_plugins/libvlc/media_plugin_libvlc.cpp b/indra/media_plugins/libvlc/media_plugin_libvlc.cpp index a5d8f885fd..4240613a0c 100644 --- a/indra/media_plugins/libvlc/media_plugin_libvlc.cpp +++ b/indra/media_plugins/libvlc/media_plugin_libvlc.cpp @@ -585,7 +585,7 @@ void MediaPluginLibVLC::receiveMessage(const char* message_string) mTextureWidth = texture_width; mTextureHeight = texture_height; - libvlc_time_t time = 1000.0 * mCurTime; + libvlc_time_t time = (libvlc_time_t)(1000.0 * mCurTime); playMedia(); @@ -655,7 +655,7 @@ void MediaPluginLibVLC::receiveMessage(const char* message_string) { if (mLibVLCMediaPlayer) { - libvlc_time_t time = 1000.0 * message_in.getValueReal("time"); + libvlc_time_t time = (libvlc_time_t)(1000.0 * message_in.getValueReal("time")); libvlc_media_player_set_time(mLibVLCMediaPlayer, time); time = libvlc_media_player_get_time(mLibVLCMediaPlayer); if (time < 0) diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 3aaeb426da..d4c2875c6c 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -189,6 +189,7 @@ set(viewer_SOURCE_FILES llfloaterbigpreview.cpp llfloaterbuildoptions.cpp llfloaterbulkpermission.cpp + llfloaterbulkupload.cpp llfloaterbump.cpp llfloaterbuy.cpp llfloaterbuycontents.cpp @@ -219,6 +220,7 @@ set(viewer_SOURCE_FILES llfloaterfonttest.cpp llfloaterforgetuser.cpp llfloatergesture.cpp + llfloatergltfasseteditor.cpp llfloatergodtools.cpp llfloatergotoline.cpp llfloatergridstatus.cpp @@ -313,6 +315,8 @@ set(viewer_SOURCE_FILES llgesturemgr.cpp llgiveinventory.cpp llglsandbox.cpp + llgltffolderitem.cpp + llgltffoldermodel.cpp llgltfmateriallist.cpp llgltfmaterialpreviewmgr.cpp llgroupactions.cpp @@ -849,6 +853,7 @@ set(viewer_HEADER_FILES llfloaterbigpreview.h llfloaterbuildoptions.h llfloaterbulkpermission.h + llfloaterbulkupload.h llfloaterbump.h llfloaterbuy.h llfloaterbuycontents.h @@ -879,6 +884,7 @@ set(viewer_HEADER_FILES llfloaterfonttest.h llfloaterforgetuser.h llfloatergesture.h + llfloatergltfasseteditor.h llfloatergodtools.h llfloatergotoline.h llfloatergridstatus.h @@ -975,6 +981,8 @@ set(viewer_HEADER_FILES llgesturelistener.h llgesturemgr.h llgiveinventory.h + llgltffolderitem.h + llgltffoldermodel.h llgltfmateriallist.h llgltfmaterialpreviewmgr.h llgroupactions.h diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 50632a7b07..235d294849 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1094,6 +1094,17 @@ <key>Value</key> <integer>0</integer> </map> + <key>BulkUpload2KTextures</key> + <map> + <key>Comment</key> + <string>Bulk upload scales textures to 2K if true, to 1K if false</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> <key>EnableButtonFlashing</key> <map> <key>Comment</key> @@ -7716,6 +7727,28 @@ <key>Value</key> <integer>0</integer> </map> + <key>RenderMinFreeMainMemoryThreshold</key> + <map> + <key>Comment</key> + <string>Minimum of available physical memory in MB before textures get scaled down</string> + <key>Persist</key> + <integer>0</integer> + <key>Type</key> + <string>U32</string> + <key>Value</key> + <integer>512</integer> + </map> + <key>RenderLowMemMinDiscardIncrement</key> + <map> + <key>Comment</key> + <string>Minimum increment of discard level if system memory gets low</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>0.1</real> + </map> <key>RenderMaxTextureIndex</key> <map> <key>Comment</key> @@ -7738,6 +7771,17 @@ <key>Value</key> <integer>2048</integer> </map> + <key>RenderDownScaleMethod</key> + <map> + <key>Comment</key> + <string>Method to use to downscale images. 0 - FBO, 1 - PBO</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>U32</string> + <key>Value</key> + <integer>1</integer> + </map> <key>RenderDebugTextureBind</key> <map> <key>Comment</key> @@ -9245,7 +9289,7 @@ <key>RenderTerrainPBREnabled</key> <map> <key>Comment</key> - <string>EXPERIMENTAL: Enable PBR Terrain features.</string> + <string>Enable PBR Terrain features.</string> <key>Persist</key> <integer>1</integer> <key>Type</key> @@ -11267,6 +11311,19 @@ <key>Value</key> <real>8.0</real> </map> + <key>TextureBiasUnimportantFactor</key> + <map> + <key>Comment</key> + <string>When biasing textures to lower resolution due to lack of vram, the importance threshold below which is considered unimportant and getting an extra bias.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>F32</string> + <key>Value</key> + <real>0.25</real> + <key>Backup</key> + <integer>0</integer> + </map> <key>TextureDecodeDisabled</key> <map> <key>Comment</key> diff --git a/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl b/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl index 902746366d..607a8c6ef6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/normgenF.glsl @@ -25,24 +25,53 @@ /*[EXTRA_CODE_HERE]*/ + + +// generate a normal map using an approximation of the old emboss bump map "brightness/darkness" technique +// srcMap is a source color image, output should be a normal + out vec4 frag_color; -uniform sampler2D alphaMap; +uniform sampler2D srcMap; in vec2 vary_texcoord0; uniform float stepX; uniform float stepY; uniform float norm_scale; +uniform int bump_code; + +#define BE_BRIGHTNESS 1 +#define BE_DARKNESS 2 + +// get luminance or inverse luminance depending on bump_code +float getBumpValue(vec2 texcoord) +{ + vec3 c = texture(srcMap, texcoord).rgb; + + vec3 WEIGHT = vec3(0.2995, 0.5875, 0.1145); + + float l = dot(c, WEIGHT); + + if (bump_code == BE_DARKNESS) + { + l = 1.0 - l; + } + + return l; +} + void main() { - float c = texture(alphaMap, vary_texcoord0).r; + float c = getBumpValue(vary_texcoord0); + + float scaler = 512.0; - vec3 right = vec3(norm_scale, 0, (texture(alphaMap, vary_texcoord0+vec2(stepX, 0)).r-c)*255); - vec3 left = vec3(-norm_scale, 0, (texture(alphaMap, vary_texcoord0-vec2(stepX, 0)).r-c)*255); - vec3 up = vec3(0, -norm_scale, (texture(alphaMap, vary_texcoord0-vec2(0, stepY)).r-c)*255); - vec3 down = vec3(0, norm_scale, (texture(alphaMap, vary_texcoord0+vec2(0, stepY)).r-c)*255); + vec3 right = vec3(norm_scale, 0, (getBumpValue(vary_texcoord0+vec2(stepX, 0))-c)*scaler); + vec3 left = vec3(-norm_scale, 0, (getBumpValue(vary_texcoord0-vec2(stepX, 0))-c)*scaler); + vec3 up = vec3(0, -norm_scale, (getBumpValue(vary_texcoord0-vec2(0, stepY))-c)*scaler); + vec3 down = vec3(0, norm_scale, (getBumpValue(vary_texcoord0+vec2(0, stepY))-c)*scaler); vec3 norm = cross(right, down) + cross(down, left) + cross(left,up) + cross(up, right); diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl index ae179d3f37..66adf50fa9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaV.glsl @@ -69,7 +69,7 @@ flat out float vary_sign; out vec3 vary_normal; vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); -vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); +vec4 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); void main() @@ -103,8 +103,9 @@ void main() n = normalize(n); - vary_tangent = normalize(tangent_space_transform(vec4(t, tangent.w), n, texture_normal_transform, texture_matrix0)); - vary_sign = tangent.w; + vec4 transformed_tangent = tangent_space_transform(vec4(t, tangent.w), n, texture_normal_transform, texture_matrix0); + vary_tangent = normalize(transformed_tangent.xyz); + vary_sign = transformed_tangent.w; vary_normal = n; vertex_color = diffuse_color; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl index fd020afd57..0ad9bf5e4b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueV.glsl @@ -63,7 +63,7 @@ out vec3 vary_normal; out vec3 vary_position; vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); -vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); +vec4 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); void main() { @@ -97,8 +97,9 @@ void main() n = normalize(n); - vary_tangent = normalize(tangent_space_transform(vec4(t, tangent.w), n, texture_normal_transform, texture_matrix0)); - vary_sign = tangent.w; + vec4 transformed_tangent = tangent_space_transform(vec4(t, tangent.w), n, texture_normal_transform, texture_matrix0); + vary_tangent = normalize(transformed_tangent.xyz); + vary_sign = transformed_tangent.w; vary_normal = n; vertex_color = diffuse_color; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl index 2cb7ff196b..6ca35419f2 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl @@ -75,6 +75,9 @@ PBRMix terrain_sample_and_multiply_pbr( #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , sampler2D tex_vNt +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , float transform_sign +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , sampler2D tex_emissive @@ -139,7 +142,7 @@ in vec3 vary_position; in vec3 vary_normal; #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) in vec3 vary_tangents[4]; -flat in float vary_sign; +flat in float vary_signs[4]; #endif in vec4 vary_texcoord0; in vec4 vary_texcoord1; @@ -150,11 +153,11 @@ float terrain_mix(TerrainMix tm, vec4 tms4); #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) // from mikktspace.com -vec3 mikktspace(vec3 vNt, vec3 vT) +vec3 mikktspace(vec3 vNt, vec3 vT, float sign) { vec3 vN = vary_normal; - vec3 vB = vary_sign * cross(vN, vT); + vec3 vB = sign * cross(vN, vT); vec3 tnorm = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN ); tnorm *= gl_FrontFacing ? 1.0 : -1.0; @@ -216,6 +219,9 @@ void main() #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , detail_0_normal +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , vary_signs[0] +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , detail_0_emissive @@ -231,7 +237,7 @@ void main() #endif ); #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) - mix2.vNt = mikktspace(mix2.vNt, vary_tangents[0]); + mix2.vNt = mikktspace(mix2.vNt, vary_tangents[0], vary_signs[0]); #endif pbr_mix = mix_pbr(pbr_mix, mix2, tm.weight.x); break; @@ -258,6 +264,9 @@ void main() #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , detail_1_normal +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , vary_signs[1] +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , detail_1_emissive @@ -273,7 +282,7 @@ void main() #endif ); #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) - mix2.vNt = mikktspace(mix2.vNt, vary_tangents[1]); + mix2.vNt = mikktspace(mix2.vNt, vary_tangents[1], vary_signs[1]); #endif pbr_mix = mix_pbr(pbr_mix, mix2, tm.weight.y); break; @@ -300,6 +309,9 @@ void main() #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , detail_2_normal +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , vary_signs[2] +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , detail_2_emissive @@ -315,7 +327,7 @@ void main() #endif ); #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) - mix2.vNt = mikktspace(mix2.vNt, vary_tangents[2]); + mix2.vNt = mikktspace(mix2.vNt, vary_tangents[2], vary_signs[2]); #endif pbr_mix = mix_pbr(pbr_mix, mix2, tm.weight.z); break; @@ -342,6 +354,9 @@ void main() #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , detail_3_normal +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , vary_signs[3] +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , detail_3_emissive @@ -357,7 +372,7 @@ void main() #endif ); #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) - mix2.vNt = mikktspace(mix2.vNt, vary_tangents[3]); + mix2.vNt = mikktspace(mix2.vNt, vary_tangents[3], vary_signs[3]); #endif pbr_mix = mix_pbr(pbr_mix, mix2, tm.weight.w); break; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl index 1ae9efe544..5098de717e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainUtilF.glsl @@ -256,11 +256,12 @@ vec3 _t_normal_post_1(vec3 vNt0, float sign_or_zero) } // Triplanar-specific normal texture fixes -vec3 _t_normal_post_x(vec3 vNt0) +vec3 _t_normal_post_x(vec3 vNt0, float tangent_sign) { vec3 vNt_x = _t_normal_post_1(vNt0, sign(vary_vertex_normal.x)); // *HACK: Transform normals according to orientation of the UVs vNt_x.xy = vec2(-vNt_x.y, vNt_x.x); + vNt_x.xy *= tangent_sign; return vNt_x; } vec3 _t_normal_post_y(vec3 vNt0) @@ -285,6 +286,7 @@ PBRMix terrain_sample_pbr( #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , sampler2D tex_vNt + , float tangent_sign #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , sampler2D tex_emissive @@ -314,7 +316,7 @@ PBRMix terrain_sample_pbr( ); #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) // Triplanar-specific normal texture fix - mix_x.vNt = _t_normal_post_x(mix_x.vNt); + mix_x.vNt = _t_normal_post_x(mix_x.vNt, tangent_sign); #endif mix = mix_pbr(mix, mix_x, tw.weight.x); break; @@ -420,6 +422,9 @@ PBRMix terrain_sample_and_multiply_pbr( #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , sampler2D tex_vNt +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , float tangent_sign +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , sampler2D tex_emissive @@ -446,6 +451,9 @@ PBRMix terrain_sample_and_multiply_pbr( #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) , tex_vNt +#if TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT == 3 + , tangent_sign +#endif #endif #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_EMISSIVE) , tex_emissive diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl index f8e826bbdb..c90b2b5926 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl @@ -43,7 +43,7 @@ out vec3 vary_vertex_normal; // Used by pbrterrainUtilF.glsl out vec3 vary_normal; #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) out vec3 vary_tangents[4]; -flat out float vary_sign; +flat out float vary_signs[4]; #endif out vec4 vary_texcoord0; out vec4 vary_texcoord1; @@ -60,7 +60,7 @@ out vec3 vary_position; uniform vec4[5] terrain_texture_transforms; vec2 terrain_texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform); -vec3 terrain_tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform); +vec4 terrain_tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform); void main() { @@ -75,28 +75,35 @@ void main() #if (TERRAIN_PBR_DETAIL >= TERRAIN_PBR_DETAIL_NORMAL) { vec4[2] ttt; + vec4 transformed_tangent; // material 1 ttt[0].xyz = terrain_texture_transforms[0].xyz; ttt[1].x = terrain_texture_transforms[0].w; ttt[1].y = terrain_texture_transforms[1].x; - vary_tangents[0] = normalize(terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt)); + transformed_tangent = terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt); + vary_tangents[0] = normalize(transformed_tangent.xyz); + vary_signs[0] = transformed_tangent.w; // material 2 ttt[0].xyz = terrain_texture_transforms[1].yzw; ttt[1].xy = terrain_texture_transforms[2].xy; - vary_tangents[1] = normalize(terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt)); + transformed_tangent = terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt); + vary_tangents[1] = normalize(transformed_tangent.xyz); + vary_signs[1] = transformed_tangent.w; // material 3 ttt[0].xy = terrain_texture_transforms[2].zw; ttt[0].z = terrain_texture_transforms[3].x; ttt[1].xy = terrain_texture_transforms[3].yz; - vary_tangents[2] = normalize(terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt)); + transformed_tangent = terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt); + vary_tangents[2] = normalize(transformed_tangent.xyz); + vary_signs[2] = transformed_tangent.w; // material 4 ttt[0].x = terrain_texture_transforms[3].w; ttt[0].yz = terrain_texture_transforms[4].xy; ttt[1].xy = terrain_texture_transforms[4].zw; - vary_tangents[3] = normalize(terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt)); + transformed_tangent = terrain_tangent_space_transform(vec4(t, tangent.w), n, ttt); + vary_tangents[3] = normalize(transformed_tangent.xyz); + vary_signs[3] = transformed_tangent.w; } - - vary_sign = tangent.w; #endif vary_normal = normalize(n); diff --git a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl index 767416d564..c75a0e0d5d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/textureUtilV.glsl @@ -94,36 +94,48 @@ vec2 terrain_texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform) // Take the rotation only from both transforms and apply to the tangent. This // accounts for the change of the topology of the normal texture when a texture // rotation is applied to it. +// In practice, this applies the inverse of the texture transform to the tangent. +// It is effectively an inverse of the rotation // *HACK: Assume the imported GLTF model did not have both normal texture // transforms and tangent vertices. The use of this function is inconsistent // with the GLTF sample viewer when that is the case. See getNormalInfo in // https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Viewer/47a191931461a6f2e14de48d6da0f0eb6ec2d147/source/Renderer/shaders/material_info.glsl // We may want to account for this case during GLTF model import. // -Cosmic,2023-06-06 -vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform) +vec4 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform, mat4 sl_animation_transform) { - vec2 weights = vec2(0, 1); - - // Apply texture animation first to avoid shearing and other artifacts (rotation only) - mat2 sl_rot_scale; - sl_rot_scale[0][0] = sl_animation_transform[0][0]; - sl_rot_scale[0][1] = sl_animation_transform[0][1]; - sl_rot_scale[1][0] = sl_animation_transform[1][0]; - sl_rot_scale[1][1] = sl_animation_transform[1][1]; - weights = sl_rot_scale * weights; - // Remove scale - weights = normalize(weights); - - // Convert to left-handed coordinate system - weights.y = -weights.y; + // Immediately convert to left-handed coordinate system, but it has no + // effect here because y is 0 ((1,0) -> (1,0)) + vec2 weights = vec2(1, 0); - // Apply KHR_texture_transform (rotation only) - float khr_rotation = khr_gltf_transform[0].z; + // Apply inverse KHR_texture_transform (rotation and scale sign only) + float khr_rotation = -khr_gltf_transform[0].z; mat2 khr_rotation_mat = mat2( cos(khr_rotation),-sin(khr_rotation), sin(khr_rotation), cos(khr_rotation) ); weights = khr_rotation_mat * weights; + vec2 khr_scale_sign = sign(khr_gltf_transform[0].xy); + weights *= khr_scale_sign.xy; + + // *NOTE: Delay conversion to right-handed coordinate system here, to + // remove the need for computing the inverse of the SL texture animation + // matrix. + + // Apply texture animation last to avoid shearing and other artifacts (rotation only) + mat2 inv_sl_rot_scale; + inv_sl_rot_scale[0][0] = sl_animation_transform[0][0]; + inv_sl_rot_scale[0][1] = sl_animation_transform[0][1]; + inv_sl_rot_scale[1][0] = sl_animation_transform[1][0]; + inv_sl_rot_scale[1][1] = sl_animation_transform[1][1]; + weights = inv_sl_rot_scale * weights; + // *NOTE: Scale to be removed later + + // Set weights to default if 0 for some reason + weights.x += 1.0 - abs(sign(sign(weights.x) + (0.5 * sign(weights.y)))); + + // Remove scale from SL texture animation transform + weights = normalize(weights); // Convert back to right-handed coordinate system weights.y = -weights.y; @@ -132,27 +144,41 @@ vec3 tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] kh // from the normal and tangent, as seen in the fragment shader vec3 vertex_binormal = vertex_tangent.w * cross(vertex_normal, vertex_tangent.xyz); - return (weights.x * vertex_binormal.xyz) + (weights.y * vertex_tangent.xyz); + // An additional sign flip prevents the binormal from being flipped as a + // result of a propagation of the tangent sign during the cross product. + float sign_flip = khr_scale_sign.x * khr_scale_sign.y; + return vec4((weights.x * vertex_tangent.xyz) + (weights.y * vertex_binormal.xyz), vertex_tangent.w * sign_flip); } // Similar to tangent_space_transform but no texture animation support. -vec3 terrain_tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform) +vec4 terrain_tangent_space_transform(vec4 vertex_tangent, vec3 vertex_normal, vec4[2] khr_gltf_transform) { - // Immediately convert to left-handed coordinate system ((0,1) -> (0, -1)) - vec2 weights = vec2(0, -1); + // Immediately convert to left-handed coordinate system, but it has no + // effect here because y is 0 ((1,0) -> (1,0)) + vec2 weights = vec2(1, 0); - // Apply KHR_texture_transform (rotation only) - float khr_rotation = khr_gltf_transform[0].z; + // Apply inverse KHR_texture_transform (rotation and scale sign only) + float khr_rotation = -khr_gltf_transform[0].z; mat2 khr_rotation_mat = mat2( cos(khr_rotation),-sin(khr_rotation), sin(khr_rotation), cos(khr_rotation) ); weights = khr_rotation_mat * weights; + vec2 khr_scale_sign = sign(khr_gltf_transform[0].xy); + weights *= khr_scale_sign.xy; + + // Set weights to default if 0 for some reason + weights.x += 1.0 - abs(sign(sign(weights.x) + (0.5 * sign(weights.y)))); // Convert back to right-handed coordinate system weights.y = -weights.y; + // Similar to the MikkTSpace-compatible method of extracting the binormal + // from the normal and tangent, as seen in the fragment shader vec3 vertex_binormal = vertex_tangent.w * cross(vertex_normal, vertex_tangent.xyz); - return (weights.x * vertex_binormal.xyz) + (weights.y * vertex_tangent.xyz); + // An additional sign flip prevents the binormal from being flipped as a + // result of a propagation of the tangent sign during the cross product. + float sign_flip = khr_scale_sign.x * khr_scale_sign.y; + return vec4((weights.x * vertex_tangent.xyz) + (weights.y * vertex_binormal.xyz), vertex_tangent.w * sign_flip); } diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index 03849a0326..358fc2dfc8 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 60 +version 62 // The version number above should be incremented IF AND ONLY IF some // change has been made that is sufficiently important to justify // resetting the graphics preferences of all users to the recommended @@ -28,7 +28,6 @@ version 60 // list all RenderAnisotropic 1 1 -RenderAvatarCloth 0 0 RenderAvatarLODFactor 1 1.0 RenderAvatarPhysicsLODFactor 1 1.0 RenderAvatarMaxNonImpostors 1 16 @@ -65,7 +64,6 @@ RenderShaderLightingMaxLevel 1 3 RenderReflectionProbeLevel 1 3 RenderDeferred 1 1 RenderDeferredSSAO 1 1 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 RenderUseStreamVBO 1 1 RenderFSAASamples 1 16 @@ -76,6 +74,11 @@ RenderGLMultiThreadedMedia 1 1 RenderReflectionProbeResolution 1 128 RenderScreenSpaceReflections 1 1 RenderMirrors 1 1 +RenderHeroProbeResolution 1 2048 +RenderHeroProbeDistance 1 16 +RenderHeroProbeUpdateRate 1 4 +RenderHeroProbeConservativeUpdateMultiplier 1 16 +RenderDownScaleMethod 1 1 // @@ -102,7 +105,6 @@ RenderTerrainPBRPlanarSampleCount 1 1 RenderTreeLODFactor 1 0 RenderVolumeLODFactor 1 1.125 RenderDeferredSSAO 1 0 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 96 RenderFSAASamples 1 0 @@ -138,7 +140,6 @@ RenderTerrainPBRPlanarSampleCount 1 1 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.125 RenderDeferredSSAO 1 0 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 96 RenderFSAASamples 1 0 @@ -172,7 +173,6 @@ RenderTerrainPBRPlanarSampleCount 1 1 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.25 RenderDeferredSSAO 1 0 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 96 RenderFSAASamples 1 2 @@ -208,7 +208,6 @@ RenderTerrainPBRPlanarSampleCount 1 1 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.375 RenderDeferredSSAO 1 0 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 96 RenderFSAASamples 1 2 @@ -244,7 +243,6 @@ RenderTerrainPBRPlanarSampleCount 1 3 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.5 RenderDeferredSSAO 1 1 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 1 WLSkyDetail 1 96 RenderFSAASamples 1 2 @@ -280,7 +278,6 @@ RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.75 RenderDeferredSSAO 1 1 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 WLSkyDetail 1 96 RenderFSAASamples 1 2 @@ -317,7 +314,6 @@ RenderVolumeLODFactor 1 2.0 WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 RenderDeferredSSAO 1 1 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 @@ -336,7 +332,6 @@ RenderHeroProbeConservativeUpdateMultiplier 1 4 list Unknown RenderShadowDetail 1 0 RenderDeferredSSAO 1 0 -RenderUseAdvancedAtmospherics 1 0 RenderMirrors 1 0 // @@ -366,6 +361,7 @@ RenderAnisotropic 1 0 RenderFSAASamples 1 0 RenderGLContextCoreProfile 1 0 RenderGLMultiThreadedMedia 1 0 +RenderDownScaleMethod 1 0 list AMD RenderGLMultiThreadedTextures 1 1 diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 7aa8504eaa..581350d73c 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 57 +version 58 // The version number above should be incremented IF AND ONLY IF some // change has been made that is sufficiently important to justify // resetting the graphics preferences of all users to the recommended @@ -28,7 +28,6 @@ version 57 // list all RenderAnisotropic 1 0 -RenderAvatarCloth 0 0 RenderAvatarLODFactor 1 1.0 RenderAvatarPhysicsLODFactor 1 1.0 RenderAvatarMaxNonImpostors 1 16 @@ -62,7 +61,6 @@ RenderCompressTextures 1 1 RenderShaderLightingMaxLevel 1 3 RenderDeferred 1 1 RenderDeferredSSAO 1 1 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 RenderUseStreamVBO 1 1 RenderFSAASamples 1 16 @@ -75,6 +73,10 @@ RenderReflectionProbeDetail 1 2 RenderScreenSpaceReflections 1 1 RenderReflectionProbeLevel 1 3 RenderMirrors 1 1 +RenderHeroProbeResolution 1 2048 +RenderHeroProbeDistance 1 16 +RenderHeroProbeUpdateRate 1 4 +RenderHeroProbeConservativeUpdateMultiplier 1 16 // // Low Graphics Settings @@ -98,7 +100,6 @@ RenderTransparentWater 1 0 RenderTreeLODFactor 1 0 RenderVolumeLODFactor 1 1.125 RenderDeferredSSAO 1 0 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 96 RenderFSAASamples 1 0 @@ -134,7 +135,6 @@ RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.125 RenderDeferredSSAO 1 0 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 96 RenderFSAASamples 1 0 @@ -170,7 +170,6 @@ RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.25 RenderDeferredSSAO 1 0 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 96 RenderFSAASamples 1 2 @@ -206,7 +205,6 @@ RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.375 RenderDeferredSSAO 1 0 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 96 RenderFSAASamples 1 2 @@ -242,7 +240,6 @@ RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.5 RenderDeferredSSAO 1 1 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 1 WLSkyDetail 1 96 RenderFSAASamples 1 2 @@ -279,7 +276,6 @@ RenderTreeLODFactor 1 0.5 RenderVolumeLODFactor 1 1.75 RenderDeferredSSAO 1 1 RenderShadowDetail 1 2 -RenderUseAdvancedAtmospherics 1 0 WLSkyDetail 1 96 RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 @@ -315,7 +311,6 @@ RenderVolumeLODFactor 1 2.0 WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 RenderDeferredSSAO 1 1 -RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 @@ -334,7 +329,6 @@ RenderHeroProbeConservativeUpdateMultiplier 1 4 list Unknown RenderShadowDetail 1 0 RenderDeferredSSAO 1 0 -RenderUseAdvancedAtmospherics 1 0 RenderMirrors 1 0 @@ -355,7 +349,6 @@ RenderLocalLightCount 1 0 RenderMaxPartCount 1 1024 RenderTerrainDetail 1 0 RenderDeferredSSAO 0 0 -RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 RenderMirrors 0 0 diff --git a/indra/newview/gltf/accessor.cpp b/indra/newview/gltf/accessor.cpp index 2ef9237f2d..d1845605d4 100644 --- a/indra/newview/gltf/accessor.cpp +++ b/indra/newview/gltf/accessor.cpp @@ -104,7 +104,7 @@ namespace LL void Buffer::erase(Asset& asset, S32 offset, S32 length) { - S32 idx = this - &asset.mBuffers[0]; + S32 idx = (S32)(this - &asset.mBuffers[0]); mData.erase(mData.begin() + offset, mData.begin() + offset + length); @@ -197,7 +197,7 @@ bool Buffer::save(Asset& asset, const std::string& folder) { if (mName.empty()) { - S32 idx = this - &asset.mBuffers[0]; + S32 idx = (S32)(this - &asset.mBuffers[0]); mUri = llformat("buffer_%d.bin", idx); } else diff --git a/indra/newview/gltf/accessor.h b/indra/newview/gltf/accessor.h index ec68c5f624..85ea0f2967 100644 --- a/indra/newview/gltf/accessor.h +++ b/indra/newview/gltf/accessor.h @@ -36,8 +36,6 @@ namespace LL { namespace GLTF { - constexpr S32 INVALID_INDEX = -1; - class Buffer { public: diff --git a/indra/newview/gltf/animation.cpp b/indra/newview/gltf/animation.cpp index 3dff67d746..31549986af 100644 --- a/indra/newview/gltf/animation.cpp +++ b/indra/newview/gltf/animation.cpp @@ -127,8 +127,8 @@ void Animation::apply(Asset& asset, float time) bool Animation::Sampler::prep(Asset& asset) { Accessor& accessor = asset.mAccessors[mInput]; - mMinTime = accessor.mMin[0]; - mMaxTime = accessor.mMax[0]; + mMinTime = (F32)accessor.mMin[0]; + mMaxTime = (F32)accessor.mMax[0]; mFrameTimes.resize(accessor.mCount); diff --git a/indra/newview/gltf/asset.cpp b/indra/newview/gltf/asset.cpp index a454e68a92..c210b9c61d 100644 --- a/indra/newview/gltf/asset.cpp +++ b/indra/newview/gltf/asset.cpp @@ -105,7 +105,7 @@ void Node::updateTransforms(Asset& asset, const mat4& parentMatrix) mAssetMatrixInv = glm::inverse(mAssetMatrix); - S32 my_index = this - &asset.mNodes[0]; + S32 my_index = (S32)(this - &asset.mNodes[0]); for (auto& childIndex : mChildren) { @@ -271,11 +271,11 @@ S32 Asset::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, local_end = p; // pointer math to get the node index - node_hit = &node - &mNodes[0]; + node_hit = (S32)(&node - &mNodes[0]); llassert(&mNodes[node_hit] == &node); //pointer math to get the primitive index - primitive_hit = &primitive - &mesh.mPrimitives[0]; + primitive_hit = (S32)(&primitive - &mesh.mPrimitives[0]); llassert(&mesh.mPrimitives[primitive_hit] == &primitive); } } @@ -476,6 +476,7 @@ void Asset::update() { // HACK - force texture to be loaded full rez // TODO: calculate actual vsize image.mTexture->addTextureStats(2048.f * 2048.f); + image.mTexture->setBoostLevel(LLViewerTexture::BOOST_HIGH); } } } @@ -990,6 +991,12 @@ bool Image::prep(Asset& asset) return false; } + if (!asset.mFilename.empty()) + { // local preview, boost image so it doesn't discard and force to save raw image in case we save out or upload + mTexture->setBoostLevel(LLViewerTexture::BOOST_PREVIEW); + mTexture->forceToSaveRawImage(0, F32_MAX); + } + return true; } @@ -1027,7 +1034,7 @@ bool Image::save(Asset& asset, const std::string& folder) const std::string& delim = gDirUtilp->getDirDelimiter(); if (name.empty()) { - S32 idx = this - asset.mImages.data(); + S32 idx = (S32)(this - asset.mImages.data()); name = llformat("image_%d", idx); } diff --git a/indra/newview/gltf/buffer_util.h b/indra/newview/gltf/buffer_util.h index 40f9448aaf..ef9bba8128 100644 --- a/indra/newview/gltf/buffer_util.h +++ b/indra/newview/gltf/buffer_util.h @@ -161,7 +161,7 @@ namespace LL template<> inline void copyVec3<U16, LLColor4U>(U16* src, LLColor4U& dst) { - dst.set(src[0], src[1], src[2], 255); + dst.set((U8)(src[0]), (U8)(src[1]), (U8)(src[2]), 255); } template<> @@ -181,15 +181,25 @@ namespace LL } template<> + inline void copyVec4<U8, U64>(U8* src, U64& dst) + { + U8* data = (U8*)&dst; + data[0] = src[0]; + data[1] = src[1]; + data[2] = src[2]; + data[3] = src[3]; + } + + template<> inline void copyVec4<U16, LLColor4U>(U16* src, LLColor4U& dst) { - dst.set(src[0], src[1], src[2], src[3]); + dst.set((U8)(src[0]), (U8)(src[1]), (U8)(src[2]), ((U8)src[3])); } template<> inline void copyVec4<F32, LLColor4U>(F32* src, LLColor4U& dst) { - dst.set(src[0]*255, src[1]*255, src[2]*255, src[3]*255); + dst.set((U8)(src[0]*255.f), (U8)(src[1]*255.f), (U8)(src[2]*255.f), (U8)(src[3]*255.f)); } template<> @@ -892,7 +902,7 @@ namespace LL { if (src.is_int64()) { - dst = src.get_int64(); + dst = (U32)src.get_int64(); return true; } return false; @@ -947,7 +957,7 @@ namespace LL { if (src.is_int64()) { - dst = src.get_int64(); + dst = (U32)src.get_int64(); return true; } return false; diff --git a/indra/newview/gltf/common.h b/indra/newview/gltf/common.h index b9698d4017..742daff715 100644 --- a/indra/newview/gltf/common.h +++ b/indra/newview/gltf/common.h @@ -43,6 +43,8 @@ namespace LL { namespace GLTF { + constexpr S32 INVALID_INDEX = -1; + using Value = boost::json::value; using mat4 = glm::mat4; diff --git a/indra/newview/gltf/primitive.cpp b/indra/newview/gltf/primitive.cpp index e1579374d4..81caff8ab2 100644 --- a/indra/newview/gltf/primitive.cpp +++ b/indra/newview/gltf/primitive.cpp @@ -109,7 +109,7 @@ struct MikktMesh for (U32 tri_idx = 0; tri_idx < U32(triangle_count); ++tri_idx) { - U32 idx[3]; + U32 idx[3] = {0, 0, 0}; if (prim->mMode == Primitive::Mode::TRIANGLES) { diff --git a/indra/newview/gltfscenemanager.cpp b/indra/newview/gltfscenemanager.cpp index 7b2de4d6de..44564b7926 100644 --- a/indra/newview/gltfscenemanager.cpp +++ b/indra/newview/gltfscenemanager.cpp @@ -42,6 +42,7 @@ #include "llviewertexturelist.h" #include "llimagej2c.h" #include "llfloaterperms.h" +#include "llfloaterreg.h" #include "llagentbenefits.h" #include "llfilesystem.h" #include "boost/json.hpp" @@ -144,7 +145,17 @@ void GLTFSceneManager::uploadSelection() } else { - raw = image.mTexture->getCachedRawImage(); + raw = image.mTexture->getRawImage(); + } + + if (raw.isNull()) + { + raw = image.mTexture->getSavedRawImage(); + } + + if (raw.isNull()) + { + image.mTexture->readbackRawImage(); } if (raw.notNull()) @@ -314,6 +325,7 @@ void GLTFSceneManager::load(const std::string& filename) { mObjects.push_back(obj); } + LLFloaterReg::showInstance("gltf_asset_editor"); } } else @@ -339,9 +351,16 @@ void GLTFSceneManager::renderAlpha() void GLTFSceneManager::addGLTFObject(LLViewerObject* obj, LLUUID gltf_id) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_GLTF; llassert(obj->getVolume()->getParams().getSculptID() == gltf_id); llassert(obj->getVolume()->getParams().getSculptType() == LL_SCULPT_TYPE_GLTF); + if (obj->mGLTFAsset) + { // object already has a GLTF asset, don't reload it + llassert(std::find(mObjects.begin(), mObjects.end(), obj) != mObjects.end()); + return; + } + obj->ref(); gAssetStorage->getAssetData(gltf_id, LLAssetType::AT_GLTF, onGLTFLoadComplete, obj); } @@ -773,7 +792,7 @@ void GLTFSceneManager::bind(Asset& asset, Material& material) bindTexture(asset, TextureType::EMISSIVE, material.mEmissiveTexture, LLViewerFetchedTexture::sWhiteImagep); } - shader->uniform1i(LLShaderMgr::GLTF_MATERIAL_ID, &material - &asset.mMaterials[0]); + shader->uniform1i(LLShaderMgr::GLTF_MATERIAL_ID, (GLint)(&material - &asset.mMaterials[0])); } LLMatrix4a inverse(const LLMatrix4a& mat) diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp index 82124b7412..54d8ceb85a 100644 --- a/indra/newview/llaccountingcostmanager.cpp +++ b/indra/newview/llaccountingcostmanager.cpp @@ -150,9 +150,9 @@ void LLAccountingCostManager::accountingCostCoro(std::string url, F32 networkCost = 0.0f; F32 simulationCost = 0.0f; - physicsCost = selected["physics"].asReal(); - networkCost = selected["streaming"].asReal(); - simulationCost = selected["simulation"].asReal(); + physicsCost = (F32)selected["physics"].asReal(); + networkCost = (F32)selected["streaming"].asReal(); + simulationCost = (F32)selected["simulation"].asReal(); SelectionCost selectionCost( physicsCost, networkCost, simulationCost); diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 2f5b0f04e3..c4336758ac 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -2662,9 +2662,9 @@ void LLAgent::setStartPositionSuccess(const LLSD &result) (!result["HomeLocation"]["LocationPos"].has("Z"))) break; - agent_pos.mV[VX] = result["HomeLocation"]["LocationPos"]["X"].asInteger(); - agent_pos.mV[VY] = result["HomeLocation"]["LocationPos"]["Y"].asInteger(); - agent_pos.mV[VZ] = result["HomeLocation"]["LocationPos"]["Z"].asInteger(); + agent_pos.mV[VX] = (F32)result["HomeLocation"]["LocationPos"]["X"].asInteger(); + agent_pos.mV[VY] = (F32)result["HomeLocation"]["LocationPos"]["Y"].asInteger(); + agent_pos.mV[VZ] = (F32)result["HomeLocation"]["LocationPos"]["Z"].asInteger(); error = false; @@ -2778,7 +2778,7 @@ bool LLAgent::canAccessMaturityInRegion( U64 region_handle ) const bool LLAgent::canAccessMaturityAtGlobal( LLVector3d pos_global ) const { - U64 region_handle = to_region_handle_global( pos_global.mdV[0], pos_global.mdV[1] ); + U64 region_handle = to_region_handle_global((F32)pos_global.mdV[0], (F32)pos_global.mdV[1]); return canAccessMaturityInRegion( region_handle ); } diff --git a/indra/newview/llagentbenefits.cpp b/indra/newview/llagentbenefits.cpp index e9f00f6556..f651b42010 100644 --- a/indra/newview/llagentbenefits.cpp +++ b/indra/newview/llagentbenefits.cpp @@ -195,6 +195,19 @@ S32 LLAgentBenefits::getTextureUploadCost(const LLImageBase* tex) const return getTextureUploadCost(); } +S32 LLAgentBenefits::getTextureUploadCost(S32 w, S32 h) const +{ + if (w > 0 && h > 0) + { + S32 area = w * h; + if (area >= MIN_2K_TEXTURE_AREA) + { + return get2KTextureUploadCost(area); + } + } + return getTextureUploadCost(); +} + S32 LLAgentBenefits::get2KTextureUploadCost(S32 area) const { if (m_2k_texture_upload_cost.empty()) diff --git a/indra/newview/llagentbenefits.h b/indra/newview/llagentbenefits.h index ff23241aa9..c0aa6edd90 100644 --- a/indra/newview/llagentbenefits.h +++ b/indra/newview/llagentbenefits.h @@ -54,6 +54,7 @@ public: S32 getTextureUploadCost() const; S32 getTextureUploadCost(const LLViewerTexture* tex) const; S32 getTextureUploadCost(const LLImageBase* tex) const; + S32 getTextureUploadCost(S32 w, S32 h) const; S32 get2KTextureUploadCost(S32 area) const; bool findUploadCost(LLAssetType::EType& asset_type, S32& cost) const; diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 25e777191f..e7531f963b 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1931,7 +1931,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(bool *hit_limit) } else { - LLCachedControl<F32> dynamic_camera_strength(gSavedSettings, "DynamicCameraStrength"); + static LLCachedControl<F32> dynamic_camera_strength(gSavedSettings, "DynamicCameraStrength"); target_lag = vel * dynamic_camera_strength / 30.f; } @@ -2114,14 +2114,14 @@ void LLAgentCamera::handleScrollWheel(S32 clicks) F32 camera_offset_initial_mag = getCameraOffsetInitial().magVec(); F32 current_zoom_fraction = mTargetCameraDistance / (camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale")); - current_zoom_fraction *= 1.f - pow(ROOT_ROOT_TWO, clicks); + current_zoom_fraction *= 1.f - (F32)pow(ROOT_ROOT_TWO, clicks); cameraOrbitIn(current_zoom_fraction * camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale")); } else { F32 current_zoom_fraction = (F32)mCameraFocusOffsetTarget.magVec(); - cameraOrbitIn(current_zoom_fraction * (1.f - pow(ROOT_ROOT_TWO, clicks))); + cameraOrbitIn(current_zoom_fraction * (1.f - (F32)pow(ROOT_ROOT_TWO, clicks))); } } } diff --git a/indra/newview/llagentlistener.cpp b/indra/newview/llagentlistener.cpp index 005a518910..0c120ae01d 100644 --- a/indra/newview/llagentlistener.cpp +++ b/indra/newview/llagentlistener.cpp @@ -156,9 +156,9 @@ void LLAgentListener::requestTeleport(LLSD const & event_data) const else { std::string url = LLSLURL(event_data["regionname"], - LLVector3(event_data["x"].asReal(), - event_data["y"].asReal(), - event_data["z"].asReal())).getSLURLString(); + LLVector3((F32)event_data["x"].asReal(), + (F32)event_data["y"].asReal(), + (F32)event_data["z"].asReal())).getSLURLString(); LLURLDispatcher::dispatch(url, LLCommandHandler::NAV_TYPE_CLICKED, NULL, false); } } @@ -344,7 +344,7 @@ void LLAgentListener::startAutoPilot(LLSD const & event_data) F32 rotation_threshold = 0.03f; if (event_data.has("rotation_threshold")) { - rotation_threshold = event_data["rotation_threshold"].asReal(); + rotation_threshold = (F32)event_data["rotation_threshold"].asReal(); } bool allow_flying = true; @@ -357,7 +357,7 @@ void LLAgentListener::startAutoPilot(LLSD const & event_data) F32 stop_distance = 0.f; if (event_data.has("stop_distance")) { - stop_distance = event_data["stop_distance"].asReal(); + stop_distance = (F32)event_data["stop_distance"].asReal(); } // Clear follow target, this is doing a path @@ -446,7 +446,7 @@ void LLAgentListener::startFollowPilot(LLSD const & event_data) F32 stop_distance = 0.f; if (event_data.has("stop_distance")) { - stop_distance = event_data["stop_distance"].asReal(); + stop_distance = (F32)event_data["stop_distance"].asReal(); } if (target_id.notNull()) diff --git a/indra/newview/llagentpilot.cpp b/indra/newview/llagentpilot.cpp index 40f1679663..0b5198bbd3 100644 --- a/indra/newview/llagentpilot.cpp +++ b/indra/newview/llagentpilot.cpp @@ -145,7 +145,7 @@ void LLAgentPilot::loadXML(const std::string& filename) Action action; action.mTime = record["time"].asReal(); action.mType = (EActionType)record["type"].asInteger(); - action.mCameraView = record["camera_view"].asReal(); + action.mCameraView = (F32)record["camera_view"].asReal(); action.mTarget = ll_vector3d_from_sd(record["target"]); action.mCameraOrigin = ll_vector3_from_sd(record["camera_origin"]); action.mCameraXAxis = ll_vector3_from_sd(record["camera_xaxis"]); @@ -297,8 +297,8 @@ void LLAgentPilot::moveCamera() S32 start_index = llmax(mCurrentAction-1,0); S32 end_index = mCurrentAction; F32 t = 0.0; - F32 timedelta = mActions[end_index].mTime - mActions[start_index].mTime; - F32 tickelapsed = mTimer.getElapsedTimeF32()-mActions[start_index].mTime; + F32 timedelta = (F32)(mActions[end_index].mTime - mActions[start_index].mTime); + F32 tickelapsed = mTimer.getElapsedTimeF32()-(F32)mActions[start_index].mTime; if (timedelta > 0.0) { t = tickelapsed/timedelta; diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 9dd23a5319..a808c196c7 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -3934,7 +3934,7 @@ void LLAppearanceMgr::serverAppearanceUpdateCoro(LLCoreHttpUtil::HttpCoroutineAd LL_WARNS("Avatar") << "Bake retry count exceeded!" << LL_ENDL; break; } - F32 timeout = pow(BAKE_RETRY_TIMEOUT, static_cast<float>(retryCount)) - 1.0; + F32 timeout = pow(BAKE_RETRY_TIMEOUT, static_cast<float>(retryCount)) - 1.0f; LL_WARNS("Avatar") << "Bake retry #" << retryCount << " in " << timeout << " seconds." << LL_ENDL; @@ -4329,7 +4329,7 @@ LLAppearanceMgr::LLAppearanceMgr(): outfit_observer.addCOFSavedCallback(boost::bind( &LLAppearanceMgr::setOutfitLocked, this, false)); - mUnlockOutfitTimer.reset(new LLOutfitUnLockTimer(gSavedSettings.getS32( + mUnlockOutfitTimer.reset(new LLOutfitUnLockTimer((F32)gSavedSettings.getS32( "OutfitOperationsTimeout"))); gIdleCallbacks.addFunction(&LLAttachmentsMgr::onIdle, NULL); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 85ede793e2..b380b09129 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -340,24 +340,23 @@ F32 gLogoutMaxTime = LOGOUT_REQUEST_TIME; S32 gPendingMetricsUploads = 0; -bool gDisconnected = false; +bool gDisconnected = false; -// used to restore texture state after a mode switch -LLFrameTimer gRestoreGLTimer; -bool gRestoreGL = false; -bool gUseWireframe = false; +// Used to restore texture state after a mode switch +LLFrameTimer gRestoreGLTimer; +bool gRestoreGL = false; +bool gUseWireframe = false; -LLMemoryInfo gSysMemory; U64Bytes gMemoryAllocated(0); // updated in display_stats() in llviewerdisplay.cpp std::string gLastVersionChannel; -LLVector3 gWindVec(3.0, 3.0, 0.0); -LLVector3 gRelativeWindVec(0.0, 0.0, 0.0); +LLVector3 gWindVec(3.0, 3.0, 0.0); +LLVector3 gRelativeWindVec(0.0, 0.0, 0.0); -U32 gPacketsIn = 0; +U32 gPacketsIn = 0; -bool gPrintMessagesThisFrame = false; +bool gPrintMessagesThisFrame = false; bool gRandomizeFramerate = false; bool gPeriodicSlowFrame = false; @@ -456,7 +455,7 @@ void idle_afk_check() { // check idle timers F32 current_idle = gAwayTriggerTimer.getElapsedTimeF32(); - F32 afk_timeout = gSavedSettings.getS32("AFKTimeout"); + F32 afk_timeout = (F32)gSavedSettings.getS32("AFKTimeout"); if (afk_timeout && (current_idle > afk_timeout) && ! gAgent.getAFK()) { LL_INFOS("IdleAway") << "Idle more than " << afk_timeout << " seconds: automatically changing to Away status" << LL_ENDL; @@ -752,7 +751,9 @@ bool LLAppViewer::init() // inits from settings.xml and from strings.xml if (!initConfiguration()) - return false; + { + LL_ERRS("InitInfo") << "initConfiguration() failed." << LL_ENDL; + } LL_INFOS("InitInfo") << "Configuration initialized." << LL_ENDL ; @@ -760,7 +761,6 @@ bool LLAppViewer::init() initMaxHeapSize() ; LLCoros::instance().setStackSize(gSavedSettings.getS32("CoroutineStackSize")); - // Although initLoggingAndGetLastDuration() is the right place to mess with // setFatalFunction(), we can't query gSavedSettings until after // initConfiguration(). @@ -783,14 +783,12 @@ bool LLAppViewer::init() LLMachineID::init(); + if (gSavedSettings.getBOOL("QAModeMetrics")) { - if (gSavedSettings.getBOOL("QAModeMetrics")) - { - app_metrics_qa_mode = true; - app_metrics_interval = METRICS_INTERVAL_QA; - } - LLViewerAssetStatsFF::init(); + app_metrics_qa_mode = true; + app_metrics_interval = METRICS_INTERVAL_QA; } + LLViewerAssetStatsFF::init(); initThreads(); LL_INFOS("InitInfo") << "Threads initialized." << LL_ENDL ; @@ -906,10 +904,10 @@ bool LLAppViewer::init() // do any necessary set-up for accepting incoming SLURLs from apps initSLURLHandler(); - if(false == initHardwareTest()) + if (!initHardwareTest()) { // Early out from user choice. - return false; + LL_ERRS("InitInfo") << "initHardwareTest() failed." << LL_ENDL; } LL_INFOS("InitInfo") << "Hardware test initialization done." << LL_ENDL ; @@ -923,11 +921,9 @@ bool LLAppViewer::init() if (!initCache()) { - LL_WARNS("InitInfo") << "Failed to init cache" << LL_ENDL; - std::ostringstream msg; - msg << LLTrans::getString("MBUnableToAccessFile"); - OSMessageBox(msg.str(),LLStringUtil::null,OSMB_OK); - return 0; + std::string msg = LLTrans::getString("MBUnableToAccessFile"); + OSMessageBox(msg.c_str(), LLStringUtil::null, OSMB_OK); + LL_ERRS("InitInfo") << "Failed to init cache" << LL_ENDL; } LL_INFOS("InitInfo") << "Cache initialization is done." << LL_ENDL ; @@ -956,10 +952,11 @@ bool LLAppViewer::init() gGLManager.printGLInfoString(); // If we don't have the right GL requirements, exit. + // ? AG: It seems we never set mHasRequirements to false if (!gGLManager.mHasRequirements) { - // already handled with a MBVideoDrvErr - return 0; + // Already handled with a MBVideoDrvErr + LL_ERRS("InitInfo") << "gGLManager.mHasRequirements is false." << LL_ENDL; } // Without SSE2 support we will crash almost immediately, warn here. @@ -967,15 +964,13 @@ bool LLAppViewer::init() { // can't use an alert here since we're exiting and // all hell breaks lose. - OSMessageBox( - LLNotifications::instance().getGlobalString("UnsupportedCPUSSE2"), - LLStringUtil::null, - OSMB_OK); - return 0; + std::string msg = LLNotifications::instance().getGlobalString("UnsupportedCPUSSE2"); + OSMessageBox(msg.c_str(), LLStringUtil::null, OSMB_OK); + LL_ERRS("InitInfo") << "SSE2 is not supported" << LL_ENDL; } // alert the user if they are using unsupported hardware - if(!gSavedSettings.getBOOL("AlertedUnsupportedHardware")) + if (!gSavedSettings.getBOOL("AlertedUnsupportedHardware")) { bool unsupported = false; LLSD args; @@ -991,19 +986,21 @@ bool LLAppViewer::init() U64Bytes minRAM; minRAMString >> minRAM; - if(!LLFeatureManager::getInstance()->isGPUSupported() && LLFeatureManager::getInstance()->getGPUClass() != GPU_CLASS_UNKNOWN) + if (!LLFeatureManager::getInstance()->isGPUSupported() && LLFeatureManager::getInstance()->getGPUClass() != GPU_CLASS_UNKNOWN) { minSpecs += LLNotifications::instance().getGlobalString("UnsupportedGPU"); minSpecs += "\n"; unsupported = true; } - if(gSysCPU.getMHz() < minCPU) + + if (gSysCPU.getMHz() < minCPU) { minSpecs += LLNotifications::instance().getGlobalString("UnsupportedCPU"); minSpecs += "\n"; unsupported = true; } - if(gSysMemory.getPhysicalMemoryKB() < minRAM) + + if (gSysMemory.getPhysicalMemoryKB() < minRAM) { minSpecs += LLNotifications::instance().getGlobalString("UnsupportedRAM"); minSpecs += "\n"; @@ -1015,15 +1012,14 @@ bool LLAppViewer::init() LLNotificationsUtil::add("UnknownGPU"); } - if(unsupported) + if (unsupported) { - if(!gSavedSettings.controlExists("WarnUnsupportedHardware") + if (!gSavedSettings.controlExists("WarnUnsupportedHardware") || gSavedSettings.getBOOL("WarnUnsupportedHardware")) { args["MINSPECS"] = minSpecs; LLNotificationsUtil::add("UnsupportedHardware", args ); } - } } @@ -1115,12 +1111,13 @@ bool LLAppViewer::init() LLViewerJoystick::getInstance()->init(false); } - try { + try + { initializeSecHandler(); } catch (LLProtectedDataException&) { - LLNotificationsUtil::add("CorruptedProtectedDataStore"); + LLNotificationsUtil::add("CorruptedProtectedDataStore"); } gGLActive = false; @@ -1227,7 +1224,7 @@ bool LLAppViewer::init() //datetime formatting functions didn't support some parameters such as "weekday". //Names for days and months localized in xml are also useful for Polish locale(STORM-107). std::string language = gSavedSettings.getString("Language"); - if(language == "ja" || language == "pl") + if (language == "ja" || language == "pl") { LLStringOps::setupWeekDaysNames(LLTrans::getString("dateTimeWeekdaysNames")); LLStringOps::setupWeekDaysShortNames(LLTrans::getString("dateTimeWeekdaysShortNames")); @@ -1431,13 +1428,13 @@ bool LLAppViewer::doFrame() } { - LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df mainloop") + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df mainloop"); // canonical per-frame event mainloop.post(newFrame); } { - LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df suspend") + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df suspend"); // give listeners a chance to run llcoro::suspend(); // if one of our coroutines threw an uncaught exception, rethrow it now @@ -1447,7 +1444,7 @@ bool LLAppViewer::doFrame() if (!LLApp::isExiting()) { - LL_PROFILE_ZONE_NAMED_CATEGORY_APP( "df JoystickKeyboard" ) + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df JoystickKeyboard"); pingMainloopTimeout("Main:JoystickKeyboard"); // Scan keyboard for movement keys. Command keys and typing @@ -1470,7 +1467,7 @@ bool LLAppViewer::doFrame() // Update state based on messages, user input, object idle. { { - LL_PROFILE_ZONE_NAMED_CATEGORY_APP( "df pauseMainloopTimeout" ) + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df pauseMainloopTimeout"); pauseMainloopTimeout(); // *TODO: Remove. Messages shouldn't be stalling for 20+ seconds! } @@ -1481,7 +1478,7 @@ bool LLAppViewer::doFrame() } { - LL_PROFILE_ZONE_NAMED_CATEGORY_APP( "df resumeMainloopTimeout" ) + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df resumeMainloopTimeout"); resumeMainloopTimeout(); } } @@ -1528,7 +1525,7 @@ bool LLAppViewer::doFrame() } { - LL_PROFILE_ZONE_NAMED_CATEGORY_APP( "df pauseMainloopTimeout" ) + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df pauseMainloopTimeout"); pingMainloopTimeout("Main:Sleep"); pauseMainloopTimeout(); @@ -1537,14 +1534,14 @@ bool LLAppViewer::doFrame() // Sleep and run background threads { //LL_RECORD_BLOCK_TIME(SLEEP2); - LL_PROFILE_ZONE_WARN( "Sleep2" ) + LL_PROFILE_ZONE_WARN("Sleep2"); // yield some time to the os based on command line option static LLCachedControl<S32> yield_time(gSavedSettings, "YieldTime", -1); if(yield_time >= 0) { LL_PROFILE_ZONE_NAMED_CATEGORY_APP("Yield"); - LL_PROFILE_ZONE_NUM( yield_time ) + LL_PROFILE_ZONE_NUM(yield_time); ms_sleep(yield_time); } @@ -1612,24 +1609,24 @@ bool LLAppViewer::doFrame() } { - LL_PROFILE_ZONE_NAMED_CATEGORY_APP( "df gMeshRepo" ) + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df gMeshRepo"); gMeshRepo.update() ; } if(!total_work_pending) //pause texture fetching threads if nothing to process. { - LL_PROFILE_ZONE_NAMED_CATEGORY_APP( "df getTextureCache" ) + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df getTextureCache"); LLAppViewer::getTextureCache()->pause(); LLAppViewer::getTextureFetch()->pause(); } if(!total_io_pending) //pause file threads if nothing to process. { - LL_PROFILE_ZONE_NAMED_CATEGORY_APP( "df LLVFSThread" ) + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df LLVFSThread"); LLLFSThread::sLocal->pause(); } { - LL_PROFILE_ZONE_NAMED_CATEGORY_APP( "df resumeMainloopTimeout" ) + LL_PROFILE_ZONE_NAMED_CATEGORY_APP("df resumeMainloopTimeout"); resumeMainloopTimeout(); } pingMainloopTimeout("Main:End"); @@ -1657,7 +1654,7 @@ bool LLAppViewer::doFrame() LL_INFOS() << "Exiting main_loop" << LL_ENDL; } }LLPerfStats::StatsRecorder::endFrame(); - LL_PROFILER_FRAME_END + LL_PROFILER_FRAME_END; return ! LLApp::isRunning(); } @@ -1942,7 +1939,7 @@ bool LLAppViewer::cleanup() LL_INFOS() << "Saving Data" << LL_ENDL; // Store the time of our current logoff - gSavedPerAccountSettings.setU32("LastLogoff", time_corrected()); + gSavedPerAccountSettings.setU32("LastLogoff", (U32)time_corrected()); if (LLEnvironment::instanceExists()) { @@ -2210,10 +2207,10 @@ bool LLAppViewer::initThreads() cores = llmin(cores, (S32) max_cores); } - // The only configurable thread count right now is ImageDecode - // The viewer typically starts around 8 threads not including image decode, - // so try to leave at least one core free - S32 image_decode_count = llclamp(cores - 9, 1, 8); + // always use at least 2 threads for image decoding to prevent + // a single texture blocking all other textures from decoding + S32 image_decode_count = llclamp(cores - 6, 2, 16); + threadCounts["ImageDecode"] = image_decode_count; gSavedSettings.setLLSD("ThreadPoolSizes", threadCounts); @@ -2315,7 +2312,7 @@ void LLAppViewer::initLoggingAndGetLastDuration() int log_stat_result = LLFile::stat(log_file, &log_file_stat); if (0 == start_stat_result && 0 == log_stat_result) { - int elapsed_seconds = log_file_stat.st_ctime - start_marker_stat.st_ctime; + int elapsed_seconds = (int)(log_file_stat.st_ctime - start_marker_stat.st_ctime); // only report a last run time if the last viewer was the same version // because this stat will be counted against this version if (markerIsSameVersion(start_marker_file_name)) @@ -2393,7 +2390,7 @@ bool LLAppViewer::loadSettingsFromDirectory(const std::string& location_key, std::string full_settings_path; if (file.file_name_setting.isProvided() - && gSavedSettings.controlExists(file.file_name_setting)) + && gSavedSettings.controlExists(file.file_name_setting())) { // try to find filename stored in file_name_setting control full_settings_path = gSavedSettings.getString(file.file_name_setting()); @@ -2513,7 +2510,7 @@ bool tempSetControl(const std::string& name, const std::string& value) bool LLAppViewer::initConfiguration() { - //Load settings files list + // Load settings files list std::string settings_file_list = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "settings_files.xml"); LLXMLNodePtr root; bool success = LLXMLNode::parseFile(settings_file_list, root, NULL); @@ -2560,7 +2557,7 @@ bool LLAppViewer::initConfiguration() // - load defaults bool set_defaults = true; - if(!loadSettingsFromDirectory("Default", set_defaults)) + if (!loadSettingsFromDirectory("Default", set_defaults)) { OSMessageBox( "Unable to load default settings file. The installation may be corrupted.", @@ -2577,13 +2574,12 @@ bool LLAppViewer::initConfiguration() #ifndef LL_RELEASE_FOR_DOWNLOAD // provide developer build only overrides for these control variables that are not // persisted to settings.xml - LLControlVariable* c = gSavedSettings.getControl("AllowMultipleViewers"); - if (c) + if (LLControlVariable* c = gSavedSettings.getControl("AllowMultipleViewers")) { c->setValue(true, false); } - gSavedSettings.setBOOL("QAMode", true ); + gSavedSettings.setBOOL("QAMode", true); gSavedSettings.setS32("WatchdogEnabled", 0); #endif @@ -2616,7 +2612,7 @@ bool LLAppViewer::initConfiguration() clp.configure(cmd_line_config, &gSavedSettings); - if(!initParseCommandLine(clp)) + if (!initParseCommandLine(clp)) { handleCommandLineError(clp); return false; @@ -2626,7 +2622,7 @@ bool LLAppViewer::initConfiguration() // If the user has specified a alternate settings file name. // Load it now before loading the user_settings/settings.xml - if(clp.hasOption("settings")) + if (clp.hasOption("settings")) { std::string user_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, @@ -2668,7 +2664,7 @@ bool LLAppViewer::initConfiguration() loadSettingsFromDirectory("UserSession"); // - apply command line settings - if (! clp.notify()) + if (!clp.notify()) { handleCommandLineError(clp); return false; @@ -2677,7 +2673,7 @@ bool LLAppViewer::initConfiguration() // Register the core crash option as soon as we can // if we want gdb post-mortem on cores we need to be up and running // ASAP or we might miss init issue etc. - if(gSavedSettings.getBOOL("DisableCrashLogger")) + if (gSavedSettings.getBOOL("DisableCrashLogger")) { LL_WARNS() << "Crashes will be handled by system, stack trace logs and crash logger are both disabled" << LL_ENDL; disableCrashlogger(); @@ -2691,7 +2687,7 @@ bool LLAppViewer::initConfiguration() initConsole(); } - if(clp.hasOption("help")) + if (clp.hasOption("help")) { std::ostringstream msg; msg << LLTrans::getString("MBCmdLineUsg") << "\n" << clp; @@ -2705,17 +2701,17 @@ bool LLAppViewer::initConfiguration() return false; } - if(clp.hasOption("set")) + if (clp.hasOption("set")) { const LLCommandLineParser::token_vector_t& set_values = clp.getOption("set"); - if(0x1 & set_values.size()) + if (0x1 & set_values.size()) { LL_WARNS() << "Invalid '--set' parameter count." << LL_ENDL; } else { LLCommandLineParser::token_vector_t::const_iterator itr = set_values.begin(); - for(; itr != set_values.end(); ++itr) + for (; itr != set_values.end(); ++itr) { const std::string& name = *itr; const std::string& value = *(++itr); @@ -2727,12 +2723,13 @@ bool LLAppViewer::initConfiguration() } } - if (clp.hasOption("logevents")) { + if (clp.hasOption("logevents")) + { LLViewerEventRecorder::instance().setEventLoggingOn(); } std::string CmdLineChannel(gSavedSettings.getString("CmdLineChannel")); - if(! CmdLineChannel.empty()) + if (!CmdLineChannel.empty()) { LLVersionInfo::instance().resetChannel(CmdLineChannel); } @@ -2747,7 +2744,7 @@ bool LLAppViewer::initConfiguration() } std::string test_name(gSavedSettings.getString("LogMetrics")); - if (! test_name.empty()) + if (!test_name.empty()) { LLTrace::BlockTimer::sMetricLog = true; // '--logmetrics' is specified with a named test metric argument so the data gathering is done only on that test @@ -2789,7 +2786,7 @@ bool LLAppViewer::initConfiguration() } const LLControlVariable* skinfolder = gSavedSettings.getControl("SkinCurrent"); - if(skinfolder && LLStringUtil::null != skinfolder->getValue().asString()) + if (skinfolder && LLStringUtil::null != skinfolder->getValue().asString()) { // Examining "Language" may not suffice -- see LLUI::getLanguage() // logic. Unfortunately LLUI::getLanguage() doesn't yet do us much @@ -2823,7 +2820,6 @@ bool LLAppViewer::initConfiguration() llassert_always(!gSavedSettings.getBOOL("SLURLPassToOtherInstance")); } - // Handle slurl use. NOTE: Don't let SL-55321 reappear. // This initial-SLURL logic, up through the call to // sendURLToOtherInstance(), must precede LLSplashScreen::show() -- @@ -2849,21 +2845,21 @@ bool LLAppViewer::initConfiguration() std::string starting_location; std::string cmd_line_login_location(gSavedSettings.getString("CmdLineLoginLocation")); - if(! cmd_line_login_location.empty()) + if (!cmd_line_login_location.empty()) { starting_location = cmd_line_login_location; } else { std::string default_login_location(gSavedSettings.getString("DefaultLoginLocation")); - if (! default_login_location.empty()) + if (!default_login_location.empty()) { starting_location = default_login_location; } } LLSLURL start_slurl; - if (! starting_location.empty()) + if (!starting_location.empty()) { start_slurl = starting_location; LLStartUp::setStartSLURL(start_slurl); @@ -2875,12 +2871,12 @@ bool LLAppViewer::initConfiguration() // NextLoginLocation is set as a side effect of LLStartUp::setStartSLURL() std::string nextLoginLocation = gSavedSettings.getString( "NextLoginLocation" ); - if ( !nextLoginLocation.empty() ) + if (!nextLoginLocation.empty()) { LL_DEBUGS("AppInit")<<"set start from NextLoginLocation: "<<nextLoginLocation<<LL_ENDL; LLStartUp::setStartSLURL(LLSLURL(nextLoginLocation)); } - else if ( ( clp.hasOption("login") || clp.hasOption("autologin")) + else if ((clp.hasOption("login") || clp.hasOption("autologin")) && gSavedSettings.getString("CmdLineLoginLocation").empty()) { // If automatic login from command line with --login switch @@ -2936,7 +2932,7 @@ bool LLAppViewer::initConfiguration() #endif if (!gArgs.empty()) { - gWindowTitle += std::string(" ") + gArgs; + gWindowTitle += std::string(" ") + gArgs; } LLStringUtil::truncate(gWindowTitle, 255); @@ -2960,7 +2956,7 @@ bool LLAppViewer::initConfiguration() // but make sure the setting is *not* persisted. // Also see LLVivoxVoiceClient::voiceEnabled() LLControlVariable* enable_voice = gSavedSettings.getControl("EnableVoiceChat"); - if(enable_voice) + if (enable_voice) { const bool DO_NOT_PERSIST = false; enable_voice->setValue(LLSD(false), DO_NOT_PERSIST); @@ -3071,6 +3067,13 @@ bool LLAppViewer::meetsRequirementsForMaximizedStart() return maximizedOk; } +// virtual +void LLAppViewer::sendOutOfDiskSpaceNotification() +{ + LL_WARNS() << "Out of disk space notification requested" << LL_ENDL; + LLNotificationsUtil::add("OutOfDiskSpace"); +} + bool LLAppViewer::initWindow() { LL_INFOS("AppInit") << "Initializing window..." << LL_ENDL; @@ -3164,8 +3167,8 @@ bool LLAppViewer::initWindow() gSavedSettings.setBOOL("RenderInitError", false); gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), true ); - //If we have a startup crash, it's usually near GL initialization, so simulate that. - if(gCrashOnStartup) + // If we have a startup crash, it's usually near GL initialization, so simulate that. + if (gCrashOnStartup) { LLAppViewer::instance()->forceErrorLLError(); } @@ -3418,7 +3421,7 @@ LLSD LLAppViewer::getViewerInfo() const info["LIBVLC_VERSION"] = "Undefined"; #endif - S32 packets_in = LLViewerStats::instance().getRecording().getSum(LLStatViewer::PACKETS_IN); + S32 packets_in = (S32)LLViewerStats::instance().getRecording().getSum(LLStatViewer::PACKETS_IN); if (packets_in > 0) { info["PACKETS_LOST"] = LLViewerStats::instance().getRecording().getSum(LLStatViewer::PACKETS_LOST); @@ -3990,11 +3993,11 @@ void LLAppViewer::requestQuit() LLViewerRegion* region = gAgent.getRegion(); - if( (LLStartUp::getStartupState() < STATE_STARTED) || !region ) + if ((LLStartUp::getStartupState() < STATE_STARTED) || !region) { // If we have a region, make some attempt to send a logout request first. // This prevents the halfway-logged-in avatar from hanging around inworld for a couple minutes. - if(region) + if (region) { sendLogoutRequest(); } @@ -4609,6 +4612,10 @@ void LLAppViewer::idle() LLGLTFMaterialList::flushUpdates(); + static LLCachedControl<U32> downscale_method(gSavedSettings, "RenderDownScaleMethod"); + gGLManager.mDownScaleMethod = downscale_method; + LLImageGL::updateClass(); + // Service the WorkQueue we use for replies from worker threads. // Use function statics for the timeslice setting so we only have to fetch // and convert MainWorkTime once. @@ -5039,9 +5046,6 @@ void LLAppViewer::idleShutdown() return; } - - - // ProductEngine: Try moving this code to where we shut down sTextureCache in cleanup() // *TODO: ugly static bool saved_teleport_history = false; @@ -5090,7 +5094,7 @@ void LLAppViewer::idleShutdown() } // All floaters are closed. Tell server we want to quit. - if( !logoutRequestSent() ) + if (!logoutRequestSent()) { sendLogoutRequest(); @@ -5102,8 +5106,8 @@ void LLAppViewer::idleShutdown() } // Make sure that we quit if we haven't received a reply from the server. - if( logoutRequestSent() - && gLogoutTimer.getElapsedTimeF32() > gLogoutMaxTime ) + if (logoutRequestSent() + && gLogoutTimer.getElapsedTimeF32() > gLogoutMaxTime) { forceQuit(); return; diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 08fbbaa390..417ab0fa00 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -245,6 +245,8 @@ protected: virtual bool meetsRequirementsForMaximizedStart(); // Used on first login to decide to launch maximized + virtual void sendOutOfDiskSpaceNotification(); + private: bool doFrame(); @@ -338,7 +340,7 @@ private: }; // consts from viewer.h -const S32 AGENT_UPDATES_PER_SECOND = 10; +const S32 AGENT_UPDATES_PER_SECOND = 125; // Value derived experimentally to avoid Input Delays with latest PBR-Capable Viewers when viewer FPS is highly volatile. const S32 AGENT_FORCE_UPDATES_PER_SECOND = 1; // Globals with external linkage. From viewer.h diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index 3cdae041fc..c4c6dd3327 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -197,19 +197,6 @@ LONG WINAPI catchallCrashHandler(EXCEPTION_POINTERS * /*ExceptionInfo*/) return 0; } -// *FIX:Mani - This hack is to fix a linker issue with libndofdev.lib -// The lib was compiled under VS2005 - in VS2003 we need to remap assert -#ifdef LL_DEBUG -#ifdef LL_MSVC7 -extern "C" { - void _wassert(const wchar_t * _Message, const wchar_t *_File, unsigned _Line) - { - LL_ERRS() << _Message << LL_ENDL; - } -} -#endif -#endif - const std::string LLAppViewerWin32::sWindowClass = "Second Life"; /* @@ -240,7 +227,7 @@ bool create_app_mutex() LPCWSTR unique_mutex_name = L"SecondLifeAppMutex"; HANDLE hMutex; hMutex = CreateMutex(NULL, TRUE, unique_mutex_name); - if(GetLastError() == ERROR_ALREADY_EXISTS) + if (GetLastError() == ERROR_ALREADY_EXISTS) { result = false; } @@ -464,7 +451,7 @@ int APIENTRY WINMAIN(HINSTANCE hInstance, gDebugInfo["FoundOtherInstanceAtStartup"] = LLSD::Boolean(found_other_instance); bool ok = viewer_app_ptr->init(); - if(!ok) + if (!ok) { LL_WARNS() << "Application init failed." << LL_ENDL; return -1; diff --git a/indra/newview/llavatarpropertiesprocessor.cpp b/indra/newview/llavatarpropertiesprocessor.cpp index 65e32610c3..299cc5ed64 100644 --- a/indra/newview/llavatarpropertiesprocessor.cpp +++ b/indra/newview/llavatarpropertiesprocessor.cpp @@ -695,7 +695,7 @@ bool LLAvatarPropertiesProcessor::isPendingRequest(const LLUUID& avatar_id, EAva if (it == mRequestTimestamps.end()) return false; // We found a request, check if it has timed out - U32 now = time(nullptr); + U32 now = (U32)time(nullptr); const U32 REQUEST_EXPIRE_SECS = 5; U32 expires = it->second + REQUEST_EXPIRE_SECS; @@ -709,7 +709,7 @@ bool LLAvatarPropertiesProcessor::isPendingRequest(const LLUUID& avatar_id, EAva void LLAvatarPropertiesProcessor::addPendingRequest(const LLUUID& avatar_id, EAvatarProcessorType type) { timestamp_map_t::key_type key = std::make_pair(avatar_id, type); - U32 now = time(nullptr); + U32 now = (U32)time(nullptr); // Add or update existing (expired) request mRequestTimestamps[ key ] = now; } diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index b0befa62e6..3fd2b7fe5d 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -84,7 +84,7 @@ void LLAvatarRenderInfoAccountant::avatarRenderInfoGetCoro(std::string url, U64 // Going to request each 15 seconds either way, so don't wait // too long and don't repeat httpOpts->setRetries(0); - httpOpts->setTimeout(SECS_BETWEEN_REGION_REQUEST); + httpOpts->setTimeout((unsigned int)SECS_BETWEEN_REGION_REQUEST); LLSD result = httpAdapter->getAndSuspend(httpRequest, url, httpOpts); diff --git a/indra/newview/llavatarrendernotifier.cpp b/indra/newview/llavatarrendernotifier.cpp index 07a5c871ae..b40bcadabf 100644 --- a/indra/newview/llavatarrendernotifier.cpp +++ b/indra/newview/llavatarrendernotifier.cpp @@ -172,7 +172,7 @@ void LLAvatarRenderNotifier::updateNotificationRegion(U32 agentcount, U32 overLi // save current values for later use mLatestAgentsCount = agentcount > overLimit ? agentcount - 1 : agentcount; // subtract self mLatestOverLimitAgents = overLimit; - mLatestOverLimitPct = mLatestAgentsCount != 0 ? ((F32)overLimit / (F32)mLatestAgentsCount) * 100.0 : 0; + mLatestOverLimitPct = mLatestAgentsCount != 0 ? ((F32)overLimit / (F32)mLatestAgentsCount) * 100.0f : 0.f; if (mAgentsCount == mLatestAgentsCount && mOverLimitAgents == mLatestOverLimitAgents) @@ -191,7 +191,7 @@ void LLAvatarRenderNotifier::updateNotificationRegion(U32 agentcount, U32 overLi // default timeout before next notification static LLCachedControl<U32> pop_up_delay(gSavedSettings, "ComplexityChangesPopUpDelay", 300); - mPopUpDelayTimer.resetWithExpiry(pop_up_delay); + mPopUpDelayTimer.resetWithExpiry((F32)pop_up_delay); } } @@ -500,6 +500,6 @@ void LLHUDRenderNotifier::displayHUDNotification(EWarnLevel warn_type, LLUUID ob .name("HUDComplexityWarning") .expiry(expire_date) .substitutions(msg_args)); - mHUDPopUpDelayTimer.resetWithExpiry(pop_up_delay); + mHUDPopUpDelayTimer.resetWithExpiry((F32)pop_up_delay); } diff --git a/indra/newview/llcallingcard.cpp b/indra/newview/llcallingcard.cpp index 039164cd6e..214b5f5cde 100644 --- a/indra/newview/llcallingcard.cpp +++ b/indra/newview/llcallingcard.cpp @@ -491,7 +491,7 @@ void LLAvatarTracker::notifyObservers() // new masks and ids will be processed later from idle. return; } - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; mIsNotifyObservers = true; observer_list_t observers(mObservers); @@ -678,7 +678,7 @@ void LLAvatarTracker::processChangeUserRights(LLMessageSystem* msg, void**) void LLAvatarTracker::processNotify(LLMessageSystem* msg, bool online) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; S32 count = msg->getNumberOfBlocksFast(_PREHASH_AgentBlock); bool chat_notify = gSavedSettings.getBOOL("ChatOnlineNotification"); diff --git a/indra/newview/llchannelmanager.cpp b/indra/newview/llchannelmanager.cpp index 060430862b..454991ab83 100644 --- a/indra/newview/llchannelmanager.cpp +++ b/indra/newview/llchannelmanager.cpp @@ -148,7 +148,7 @@ void LLChannelManager::onLoginCompleted() mStartUpChannel->setMouseDownCallback(boost::bind(&LLFloaterNotificationsTabbed::onStartUpToastClick, LLFloaterNotificationsTabbed::getInstance(), _2, _3, _4)); mStartUpChannel->setCommitCallback(boost::bind(&LLChannelManager::onStartUpToastClose, this)); - mStartUpChannel->createStartUpToast(away_notifications, gSavedSettings.getS32("StartUpToastLifeTime")); + mStartUpChannel->createStartUpToast(away_notifications, (F32)gSavedSettings.getS32("StartUpToastLifeTime")); } } diff --git a/indra/newview/llchathistory.cpp b/indra/newview/llchathistory.cpp index fc50691ece..2b02aabc31 100644 --- a/indra/newview/llchathistory.cpp +++ b/indra/newview/llchathistory.cpp @@ -423,7 +423,7 @@ public: if (mTime > 0) // have frame time { time_t current_time = time_corrected(); - time_t message_time = current_time - LLFrameTimer::getElapsedSeconds() + mTime; + time_t message_time = (time_t)(current_time - LLFrameTimer::getElapsedSeconds() + mTime); time_string = "[" + LLTrans::getString("TimeMonth") + "]/[" + LLTrans::getString("TimeDay") + "]/[" diff --git a/indra/newview/llchatitemscontainerctrl.cpp b/indra/newview/llchatitemscontainerctrl.cpp index d517f5a19d..a5c26eff9c 100644 --- a/indra/newview/llchatitemscontainerctrl.cpp +++ b/indra/newview/llchatitemscontainerctrl.cpp @@ -135,7 +135,7 @@ void LLFloaterIMNearbyChatToastPanel::addMessage(LLSD& notification) std::string color_name = notification["text_color"].asString(); LLColor4 textColor = LLUIColorTable::instance().getColor(color_name); - textColor.mV[VALPHA] =notification["color_alpha"].asReal(); + textColor.mV[VALPHA] = (F32)notification["color_alpha"].asReal(); S32 font_size = notification["font_size"].asInteger(); @@ -191,7 +191,7 @@ void LLFloaterIMNearbyChatToastPanel::init(LLSD& notification) std::string color_name = notification["text_color"].asString(); LLColor4 textColor = LLUIColorTable::instance().getColor(color_name); - textColor.mV[VALPHA] =notification["color_alpha"].asReal(); + textColor.mV[VALPHA] = (F32)notification["color_alpha"].asReal(); S32 font_size = notification["font_size"].asInteger(); diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp index 716333b217..2a52b7dde9 100644 --- a/indra/newview/llcontrolavatar.cpp +++ b/indra/newview/llcontrolavatar.cpp @@ -99,19 +99,11 @@ LLVOAvatar *LLControlAvatar::getAttachedAvatar() void LLControlAvatar::getNewConstraintFixups(LLVector3& new_pos_fixup, F32& new_scale_fixup) const { - F32 max_legal_offset = MAX_LEGAL_OFFSET; - if (gSavedSettings.getControl("AnimatedObjectsMaxLegalOffset")) - { - max_legal_offset = gSavedSettings.getF32("AnimatedObjectsMaxLegalOffset"); - } - max_legal_offset = llmax(max_legal_offset,0.f); + static LLCachedControl<F32> anim_max_legal_offset(gSavedSettings, "AnimatedObjectsMaxLegalOffset", MAX_LEGAL_OFFSET); + F32 max_legal_offset = llmax(anim_max_legal_offset(), 0.f); - F32 max_legal_size = MAX_LEGAL_SIZE; - if (gSavedSettings.getControl("AnimatedObjectsMaxLegalSize")) - { - max_legal_size = gSavedSettings.getF32("AnimatedObjectsMaxLegalSize"); - } - max_legal_size = llmax(max_legal_size, 1.f); + static LLCachedControl<F32> anim_max_legal_size(gSavedSettings, "AnimatedObjectsMaxLegalSize", MAX_LEGAL_SIZE); + F32 max_legal_size = llmax(anim_max_legal_size(), 1.f); new_pos_fixup = LLVector3(); new_scale_fixup = 1.0f; @@ -419,7 +411,8 @@ bool LLControlAvatar::updateCharacter(LLAgent &agent) //virtual void LLControlAvatar::updateDebugText() { - if (gSavedSettings.getBOOL("DebugAnimatedObjects")) + static LLCachedControl<bool> debug_animated_objects(gSavedSettings, "DebugAnimatedObjects"); + if (debug_animated_objects) { S32 total_linkset_count = 0; if (mRootVolp) diff --git a/indra/newview/llcurrencyuimanager.cpp b/indra/newview/llcurrencyuimanager.cpp index 06c87343e2..8a4ab091a3 100644 --- a/indra/newview/llcurrencyuimanager.cpp +++ b/indra/newview/llcurrencyuimanager.cpp @@ -111,16 +111,17 @@ public: bool hasEstimate() const; std::string getLocalEstimate() const; - void startTransaction(TransactionType type, - const char* method, LLXMLRPCValue params); + void startTransaction(TransactionType type, const char* method, const LLSD& params); + + // return true if update needed bool checkTransaction(); - // return true if update needed void setError(const std::string& message, const std::string& uri); void clearError(); + // return true if update needed bool considerUpdateCurrency(); - // return true if update needed + void currencyKey(S32); static void onCurrencyKey(LLLineEditor* caller, void* data); @@ -160,32 +161,29 @@ void LLCurrencyUIManager::Impl::updateCurrencyInfo() return; } - LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); - keywordArgs.appendString("agentId", gAgent.getID().asString()); - keywordArgs.appendString( - "secureSessionId", - gAgent.getSecureSessionID().asString()); - keywordArgs.appendString("language", LLUI::getLanguage()); - keywordArgs.appendInt("currencyBuy", mUserCurrencyBuy); - keywordArgs.appendString("viewerChannel", LLVersionInfo::instance().getChannel()); - keywordArgs.appendInt("viewerMajorVersion", LLVersionInfo::instance().getMajor()); - keywordArgs.appendInt("viewerMinorVersion", LLVersionInfo::instance().getMinor()); - keywordArgs.appendInt("viewerPatchVersion", LLVersionInfo::instance().getPatch()); + const LLVersionInfo& vi(LLVersionInfo::instance()); + + LLSD params = LLSD::emptyMap(); + params["agentId"] = gAgent.getID().asString(); + params["secureSessionId"] = gAgent.getSecureSessionID().asString(); + params["language"] = LLUI::getLanguage(); + params["currencyBuy"] = mUserCurrencyBuy; + params["viewerChannel"] = vi.getChannel(); + params["viewerMajorVersion"] = vi.getMajor(); + params["viewerMinorVersion"] = vi.getMinor(); + params["viewerPatchVersion"] = vi.getPatch(); // With GitHub builds, the build number is too big to fit in a 32-bit int, - // and XMLRPC_VALUE doesn't deal with integers wider than int. Use string. - keywordArgs.appendString("viewerBuildVersion", stringize(LLVersionInfo::instance().getBuild())); - - LLXMLRPCValue params = LLXMLRPCValue::createArray(); - params.append(keywordArgs); + // and XMLRPC value doesn't deal with integers wider than int. Use string. + params["viewerBuildVersion"] = std::to_string(vi.getBuild()); startTransaction(TransactionCurrency, "getCurrencyQuote", params); } void LLCurrencyUIManager::Impl::finishCurrencyInfo() { - LLXMLRPCValue result = mTransaction->responseValue(); + const LLSD& result = mTransaction->response(); - bool success = result["success"].asBool(); + bool success = result["success"].asBoolean(); if (!success) { setError( @@ -195,24 +193,24 @@ void LLCurrencyUIManager::Impl::finishCurrencyInfo() return; } - LLXMLRPCValue currency = result["currency"]; + const LLSD& currency = result["currency"]; // old XML-RPC server: estimatedCost = value in US cents - mUSDCurrencyEstimated = currency["estimatedCost"].isValid(); + mUSDCurrencyEstimated = currency.has("estimatedCost"); if (mUSDCurrencyEstimated) { - mUSDCurrencyEstimatedCost = currency["estimatedCost"].asInt(); + mUSDCurrencyEstimatedCost = currency["estimatedCost"].asInteger(); } // newer XML-RPC server: estimatedLocalCost = local currency string - mLocalCurrencyEstimated = currency["estimatedLocalCost"].isValid(); + mLocalCurrencyEstimated = currency.has("estimatedLocalCost"); if (mLocalCurrencyEstimated) { mLocalCurrencyEstimatedCost = currency["estimatedLocalCost"].asString(); mSupportsInternationalBilling = true; } - S32 newCurrencyBuy = currency["currencyBuy"].asInt(); + S32 newCurrencyBuy = currency["currencyBuy"].asInteger(); if (newCurrencyBuy != mUserCurrencyBuy) { mUserCurrencyBuy = newCurrencyBuy; @@ -224,36 +222,36 @@ void LLCurrencyUIManager::Impl::finishCurrencyInfo() void LLCurrencyUIManager::Impl::startCurrencyBuy(const std::string& password) { - LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); - keywordArgs.appendString("agentId", gAgent.getID().asString()); - keywordArgs.appendString( - "secureSessionId", - gAgent.getSecureSessionID().asString()); - keywordArgs.appendString("language", LLUI::getLanguage()); - keywordArgs.appendInt("currencyBuy", mUserCurrencyBuy); + const LLVersionInfo& vi(LLVersionInfo::instance()); + + LLSD params = LLSD::emptyMap(); + params["agentId"] = gAgent.getID().asString(); + params["secureSessionId"] = gAgent.getSecureSessionID().asString(); + params["language"] = LLUI::getLanguage(); + params["currencyBuy"] = mUserCurrencyBuy; + params["confirm"] = mSiteConfirm; + params["viewerChannel"] = vi.getChannel(); + params["viewerMajorVersion"] = vi.getMajor(); + params["viewerMinorVersion"] = vi.getMinor(); + params["viewerPatchVersion"] = vi.getPatch(); + // With GitHub builds, the build number is too big to fit in a 32-bit int, + // and XMLRPC value doesn't deal with integers wider than int. Use string. + params["viewerBuildVersion"] = std::to_string(vi.getBuild()); + if (mUSDCurrencyEstimated) { - keywordArgs.appendInt("estimatedCost", mUSDCurrencyEstimatedCost); + params["estimatedCost"] = mUSDCurrencyEstimatedCost; } + if (mLocalCurrencyEstimated) { - keywordArgs.appendString("estimatedLocalCost", mLocalCurrencyEstimatedCost); + params["estimatedLocalCost"] = mLocalCurrencyEstimatedCost; } - keywordArgs.appendString("confirm", mSiteConfirm); + if (!password.empty()) { - keywordArgs.appendString("password", password); + params["password"] = password; } - keywordArgs.appendString("viewerChannel", LLVersionInfo::instance().getChannel()); - keywordArgs.appendInt("viewerMajorVersion", LLVersionInfo::instance().getMajor()); - keywordArgs.appendInt("viewerMinorVersion", LLVersionInfo::instance().getMinor()); - keywordArgs.appendInt("viewerPatchVersion", LLVersionInfo::instance().getPatch()); - // With GitHub builds, the build number is too big to fit in a 32-bit int, - // and XMLRPC_VALUE doesn't deal with integers wider than int. Use string. - keywordArgs.appendString("viewerBuildVersion", stringize(LLVersionInfo::instance().getBuild())); - - LLXMLRPCValue params = LLXMLRPCValue::createArray(); - params.append(keywordArgs); startTransaction(TransactionBuy, "buyCurrency", params); @@ -263,9 +261,9 @@ void LLCurrencyUIManager::Impl::startCurrencyBuy(const std::string& password) void LLCurrencyUIManager::Impl::finishCurrencyBuy() { - LLXMLRPCValue result = mTransaction->responseValue(); + const LLSD& result = mTransaction->response(); - bool success = result["success"].asBool(); + bool success = result["success"].asBoolean(); if (!success) { setError( @@ -282,7 +280,7 @@ void LLCurrencyUIManager::Impl::finishCurrencyBuy() } void LLCurrencyUIManager::Impl::startTransaction(TransactionType type, - const char* method, LLXMLRPCValue params) + const char* method, const LLSD& params) { static std::string transactionURI; if (transactionURI.empty()) @@ -293,12 +291,7 @@ void LLCurrencyUIManager::Impl::startTransaction(TransactionType type, delete mTransaction; mTransactionType = type; - mTransaction = new LLXMLRPCTransaction( - transactionURI, - method, - params, - false /* don't use gzip */ - ); + mTransaction = new LLXMLRPCTransaction(transactionURI, method, params); clearError(); } @@ -352,12 +345,17 @@ bool LLCurrencyUIManager::Impl::checkTransaction() { setError(mTransaction->statusMessage(), mTransaction->statusURI()); } - else { + else + { switch (mTransactionType) { - case TransactionCurrency: finishCurrencyInfo(); break; - case TransactionBuy: finishCurrencyBuy(); break; - default: ; + case TransactionCurrency: + finishCurrencyInfo(); + break; + case TransactionBuy: + finishCurrencyBuy(); + break; + default:; } } @@ -385,9 +383,8 @@ void LLCurrencyUIManager::Impl::clearError() bool LLCurrencyUIManager::Impl::considerUpdateCurrency() { - if (mCurrencyChanged - && !mTransaction - && mCurrencyKeyTimer.getElapsedTimeF32() >= CURRENCY_ESTIMATE_FREQUENCY) + if (mCurrencyChanged && !mTransaction && + mCurrencyKeyTimer.getElapsedTimeF32() >= CURRENCY_ESTIMATE_FREQUENCY) { updateCurrencyInfo(); return true; @@ -408,7 +405,8 @@ void LLCurrencyUIManager::Impl::currencyKey(S32 value) mUserCurrencyBuy = value; - if (hasEstimate()) { + if (hasEstimate()) + { clearEstimate(); //cannot just simply refresh the whole UI, as the edit field will // get reset and the cursor will change... @@ -421,8 +419,7 @@ void LLCurrencyUIManager::Impl::currencyKey(S32 value) } // static -void LLCurrencyUIManager::Impl::onCurrencyKey( - LLLineEditor* caller, void* data) +void LLCurrencyUIManager::Impl::onCurrencyKey(LLLineEditor* caller, void* data) { S32 value = atoi(caller->getText().c_str()); LLCurrencyUIManager::Impl* self = (LLCurrencyUIManager::Impl*)data; @@ -589,14 +586,12 @@ bool LLCurrencyUIManager::inProcess() bool LLCurrencyUIManager::canCancel() { - return impl.mTransactionType != Impl::TransactionBuy; + return !buying(); } bool LLCurrencyUIManager::canBuy() { - return impl.mTransactionType == Impl::TransactionNone - && impl.hasEstimate() - && impl.mUserCurrencyBuy > 0; + return !inProcess() && impl.hasEstimate() && impl.mUserCurrencyBuy > 0; } bool LLCurrencyUIManager::buying() diff --git a/indra/newview/lldateutil.cpp b/indra/newview/lldateutil.cpp index 246e2099f9..a0fbebb4cb 100644 --- a/indra/newview/lldateutil.cpp +++ b/indra/newview/lldateutil.cpp @@ -211,5 +211,5 @@ S32 LLDateUtil::secondsSinceEpochFromString(const std::string& format, const std // is calculated with no time zone corrections. time_duration diff = time_t_date - time_t_epoch; - return diff.total_seconds(); + return (S32)diff.total_seconds(); } diff --git a/indra/newview/lldebugview.cpp b/indra/newview/lldebugview.cpp index b88d11886a..0596a8fe7d 100644 --- a/indra/newview/lldebugview.cpp +++ b/indra/newview/lldebugview.cpp @@ -105,10 +105,7 @@ void LLDebugView::init() addChild(gSceneMonitorView); gSceneMonitorView->setRect(rect); - r.setLeftTopAndSize(25, rect.getHeight() - 50, (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.75f), - (S32) (gViewerWindow->getWindowRectScaled().getHeight() * 0.75f)); - - r.set(150, rect.getHeight() - 50, 820, 100); + r.set(150, rect.getHeight() - 60, 820, 110); LLTextureView::Params tvp; tvp.name("gTextureView"); tvp.rect(r); @@ -116,7 +113,6 @@ void LLDebugView::init() tvp.visible(false); gTextureView = LLUICtrlFactory::create<LLTextureView>(tvp); addChild(gTextureView); - //gTextureView->reshape(r.getWidth(), r.getHeight(), true); } void LLDebugView::draw() diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 26fdf51485..60e7171004 100644 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -98,7 +98,7 @@ LLDrawable::LLDrawable(LLViewerObject *vobj, bool new_entry) void LLDrawable::init(bool new_entry) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; // mXform mParent = NULL; @@ -305,7 +305,7 @@ S32 LLDrawable::findReferences(LLDrawable *drawablep) LLFace* LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLFace *face; { @@ -333,7 +333,7 @@ LLFace* LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep) LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLFace *face; @@ -356,7 +356,7 @@ LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep) LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLFace *face; face = new LLFace(this, mVObjp); @@ -379,7 +379,7 @@ LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, LLViewerTexture *normalp, LLViewerTexture *specularp) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLFace *face; face = new LLFace(this, mVObjp); @@ -403,7 +403,7 @@ LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep, void LLDrawable::setNumFaces(const S32 newFaces, LLFacePool *poolp, LLViewerTexture *texturep) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (newFaces == (S32)mFaces.size()) { @@ -428,7 +428,7 @@ void LLDrawable::setNumFaces(const S32 newFaces, LLFacePool *poolp, LLViewerText void LLDrawable::setNumFacesFast(const S32 newFaces, LLFacePool *poolp, LLViewerTexture *texturep) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (newFaces <= (S32)mFaces.size() && newFaces >= (S32)mFaces.size()/2) { @@ -453,7 +453,7 @@ void LLDrawable::setNumFacesFast(const S32 newFaces, LLFacePool *poolp, LLViewer void LLDrawable::mergeFaces(LLDrawable* src) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; auto face_count = mFaces.size() + src->mFaces.size(); @@ -488,7 +488,7 @@ void LLDrawable::updateMaterial() void LLDrawable::makeActive() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; #if !LL_RELEASE_FOR_DOWNLOAD if (mVObjp.notNull()) @@ -552,7 +552,7 @@ void LLDrawable::makeActive() void LLDrawable::makeStatic(bool warning_enabled) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (isState(ACTIVE) && !isState(ACTIVE_CHILD) && @@ -600,7 +600,7 @@ void LLDrawable::makeStatic(bool warning_enabled) // Returns "distance" between target destination and resulting xfrom F32 LLDrawable::updateXform(bool undamped) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; bool damped = !undamped; @@ -754,7 +754,7 @@ void LLDrawable::moveUpdatePipeline(bool moved) void LLDrawable::movePartition() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLSpatialPartition* part = getSpatialPartition(); if (part) @@ -800,7 +800,7 @@ bool LLDrawable::updateMoveUndamped() void LLDrawable::updatePartition() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (!getVOVolume()) { @@ -819,7 +819,7 @@ void LLDrawable::updatePartition() bool LLDrawable::updateMoveDamped() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; F32 dist_squared = updateXform(false); @@ -844,7 +844,7 @@ bool LLDrawable::updateMoveDamped() void LLDrawable::updateDistance(LLCamera& camera, bool force_update) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD) { @@ -944,7 +944,7 @@ void LLDrawable::updateTexture() bool LLDrawable::updateGeometry() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; llassert(mVObjp.notNull()); bool res = mVObjp && mVObjp->updateGeometry(this); @@ -1022,7 +1022,7 @@ const LLVector3& LLDrawable::getBounds(LLVector3& min, LLVector3& max) const void LLDrawable::updateSpatialExtents() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (mVObjp) { @@ -1158,7 +1158,7 @@ void LLDrawable::setGroup(LLViewerOctreeGroup *groupp) */ LLSpatialPartition* LLDrawable::getSpatialPartition() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLSpatialPartition* retval = NULL; @@ -1295,7 +1295,7 @@ void LLSpatialBridge::destroyTree() void LLSpatialBridge::updateSpatialExtents() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; LLSpatialGroup* root = (LLSpatialGroup*) mOctree->getListener(0); @@ -1468,7 +1468,7 @@ public: void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>* results, bool for_select) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (!gPipeline.hasRenderType(mDrawableType)) { @@ -1567,7 +1567,7 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>* void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; if (mDrawable == NULL) { diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 34da5b29d4..cb1439b403 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -81,10 +81,6 @@ LLDrawPoolAlpha::~LLDrawPoolAlpha() void LLDrawPoolAlpha::prerender() { mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_OBJECT); - - // TODO: is this even necessay? These are probably set to never discard - LLViewerFetchedTexture::sFlatNormalImagep->addTextureStats(1024.f*1024.f); - LLViewerFetchedTexture::sWhiteImagep->addTextureStats(1024.f * 1024.f); } S32 LLDrawPoolAlpha::getNumPostDeferredPasses() @@ -212,7 +208,7 @@ void LLDrawPoolAlpha::renderPostDeferred(S32 pass) forwardRender(); // final pass, render to depth for depth of field effects - if (!LLPipeline::sImpostorRender && gSavedSettings.getBOOL("RenderDepthOfField") && !gCubeSnapshot && !LLPipeline::sRenderingHUDs && getType() == LLDrawPool::POOL_ALPHA_POST_WATER) + if (!LLPipeline::sImpostorRender && LLPipeline::RenderDepthOfField && !gCubeSnapshot && !LLPipeline::sRenderingHUDs && getType() == LLDrawPool::POOL_ALPHA_POST_WATER) { //update depth buffer sampler simple_shader = fullbright_shader = &gDeferredFullbrightAlphaMaskProgram; diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index 9afc705d3e..ec70c7ebc0 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -117,7 +117,7 @@ LLDrawPoolAvatar::~LLDrawPoolAvatar() // virtual bool LLDrawPoolAvatar::isDead() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; if (!LLFacePool::isDead()) { @@ -129,14 +129,14 @@ bool LLDrawPoolAvatar::isDead() S32 LLDrawPoolAvatar::getShaderLevel() const { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; return (S32) LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_AVATAR); } void LLDrawPoolAvatar::prerender() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; mShaderLevel = LLViewerShaderMgr::instance()->getShaderLevel(LLViewerShaderMgr::SHADER_AVATAR); @@ -145,7 +145,7 @@ void LLDrawPoolAvatar::prerender() LLMatrix4& LLDrawPoolAvatar::getModelView() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; static LLMatrix4 ret; @@ -217,7 +217,7 @@ void LLDrawPoolAvatar::endDeferredPass(S32 pass) void LLDrawPoolAvatar::renderDeferred(S32 pass) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; render(pass); } @@ -229,7 +229,7 @@ S32 LLDrawPoolAvatar::getNumPostDeferredPasses() void LLDrawPoolAvatar::beginPostDeferredPass(S32 pass) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; sSkipOpaque = true; sShaderLevel = mShaderLevel; @@ -245,7 +245,7 @@ void LLDrawPoolAvatar::beginPostDeferredPass(S32 pass) void LLDrawPoolAvatar::endPostDeferredPass(S32 pass) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; // if we're in software-blending, remember to set the fence _after_ we draw so we wait till this rendering is done sRenderingSkinned = false; sSkipOpaque = false; @@ -257,7 +257,7 @@ void LLDrawPoolAvatar::endPostDeferredPass(S32 pass) void LLDrawPoolAvatar::renderPostDeferred(S32 pass) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; is_post_deferred_render = true; if (LLPipeline::sImpostorRender) @@ -489,7 +489,7 @@ void LLDrawPoolAvatar::endRenderPass(S32 pass) void LLDrawPoolAvatar::beginImpostor() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; if (!LLPipeline::sReflectionRender) { @@ -506,7 +506,7 @@ void LLDrawPoolAvatar::beginImpostor() void LLDrawPoolAvatar::endImpostor() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; gImpostorProgram.unbind(); gPipeline.enableLightsDynamic(); @@ -514,7 +514,7 @@ void LLDrawPoolAvatar::endImpostor() void LLDrawPoolAvatar::beginRigid() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; if (gPipeline.shadersLoaded()) { @@ -534,7 +534,7 @@ void LLDrawPoolAvatar::beginRigid() void LLDrawPoolAvatar::endRigid() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; sShaderLevel = mShaderLevel; if (sVertexProgram != NULL) @@ -545,7 +545,7 @@ void LLDrawPoolAvatar::endRigid() void LLDrawPoolAvatar::beginDeferredImpostor() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; if (!LLPipeline::sReflectionRender) { @@ -563,7 +563,7 @@ void LLDrawPoolAvatar::beginDeferredImpostor() void LLDrawPoolAvatar::endDeferredImpostor() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; sShaderLevel = mShaderLevel; sVertexProgram->disableTexture(LLViewerShaderMgr::NORMAL_MAP); @@ -576,7 +576,7 @@ void LLDrawPoolAvatar::endDeferredImpostor() void LLDrawPoolAvatar::beginDeferredRigid() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; sVertexProgram = &gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram; sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP); @@ -586,7 +586,7 @@ void LLDrawPoolAvatar::beginDeferredRigid() void LLDrawPoolAvatar::endDeferredRigid() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; sShaderLevel = mShaderLevel; sVertexProgram->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP); @@ -597,7 +597,7 @@ void LLDrawPoolAvatar::endDeferredRigid() void LLDrawPoolAvatar::beginSkinned() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; // used for preview only @@ -611,7 +611,7 @@ void LLDrawPoolAvatar::beginSkinned() void LLDrawPoolAvatar::endSkinned() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; // if we're in software-blending, remember to set the fence _after_ we draw so we wait till this rendering is done if (sShaderLevel > 0) @@ -637,7 +637,7 @@ void LLDrawPoolAvatar::endSkinned() void LLDrawPoolAvatar::beginDeferredSkinned() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; sShaderLevel = mShaderLevel; sVertexProgram = &gDeferredAvatarProgram; @@ -651,7 +651,7 @@ void LLDrawPoolAvatar::beginDeferredSkinned() void LLDrawPoolAvatar::endDeferredSkinned() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; // if we're in software-blending, remember to set the fence _after_ we draw so we wait till this rendering is done sRenderingSkinned = false; @@ -836,7 +836,7 @@ static LLTrace::BlockTimerStatHandle FTM_RIGGED_VBO("Rigged VBO"); //----------------------------------------------------------------------------- LLViewerTexture *LLDrawPoolAvatar::getDebugTexture() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; if (mReferences.empty()) { diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 055f99d764..7289e95b6e 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -79,11 +79,6 @@ static S32 diffuse_channel = -1; static S32 bump_channel = -1; static bool shiny = false; -// Enabled after changing LLViewerTexture::mNeedsCreateTexture to an -// LLAtomicBool; this should work just fine, now. HB -#define LL_BUMPLIST_MULTITHREADED 1 - - // static void LLStandardBumpmap::shutdown() { @@ -764,24 +759,21 @@ LLViewerTexture* LLBumpImageList::getBrightnessDarknessImage(LLViewerFetchedText LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; llassert( (bump_code == BE_BRIGHTNESS) || (bump_code == BE_DARKNESS) ); - LLViewerTexture* bump = NULL; + LLViewerTexture* bump = nullptr; - bump_image_map_t* entries_list = NULL; - void (*callback_func)( bool success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata ) = NULL; + bump_image_map_t* entries_list = nullptr; switch( bump_code ) { case BE_BRIGHTNESS: entries_list = &mBrightnessEntries; - callback_func = LLBumpImageList::onSourceBrightnessLoaded; break; case BE_DARKNESS: entries_list = &mDarknessEntries; - callback_func = LLBumpImageList::onSourceDarknessLoaded; break; default: llassert(0); - return NULL; + return nullptr; } bump_image_map_t::iterator iter = entries_list->find(src_image->getID()); @@ -789,51 +781,18 @@ LLViewerTexture* LLBumpImageList::getBrightnessDarknessImage(LLViewerFetchedText { bump = iter->second; } - else - { - (*entries_list)[src_image->getID()] = LLViewerTextureManager::getLocalTexture( true ); - bump = (*entries_list)[src_image->getID()]; // In case callback was called immediately and replaced the image - } - - if (!src_image->hasCallbacks()) - { //if image has no callbacks but resolutions don't match, trigger raw image loaded callback again - if (src_image->getWidth() != bump->getWidth() || - src_image->getHeight() != bump->getHeight())// || - //(LLPipeline::sRenderDeferred && bump->getComponents() != 4)) - { - src_image->setBoostLevel(LLGLTexture::BOOST_BUMP) ; - src_image->setLoadedCallback( callback_func, 0, true, false, new LLUUID(src_image->getID()), NULL ); - src_image->forceToSaveRawImage(0) ; - } - } - - return bump; -} - -// static -void LLBumpImageList::onSourceBrightnessLoaded( bool success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata ) -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - LLUUID* source_asset_id = (LLUUID*)userdata; - LLBumpImageList::onSourceLoaded( success, src_vi, src, *source_asset_id, BE_BRIGHTNESS ); - if( final ) + if (bump == nullptr || + src_image->getWidth() != bump->getWidth() || + src_image->getHeight() != bump->getHeight()) { - delete source_asset_id; + onSourceUpdated(src_image, (EBumpEffect) bump_code); } -} -// static -void LLBumpImageList::onSourceDarknessLoaded( bool success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata ) -{ - LLUUID* source_asset_id = (LLUUID*)userdata; - LLBumpImageList::onSourceLoaded( success, src_vi, src, *source_asset_id, BE_DARKNESS ); - if( final ) - { - delete source_asset_id; - } + return (*entries_list)[src_image->getID()]; } + void LLBumpImageList::onSourceStandardLoaded( bool success, LLViewerFetchedTexture* src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata) { if (success && LLPipeline::sRenderDeferred) @@ -909,289 +868,108 @@ void LLBumpImageList::generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nr } // static -void LLBumpImageList::onSourceLoaded( bool success, LLViewerTexture *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump_code ) +void LLBumpImageList::onSourceUpdated(LLViewerTexture* src, EBumpEffect bump_code) { - LL_PROFILE_ZONE_SCOPED; - - if( success ) - { - 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); - - { - if (iter == entries_list.end() || - iter->second.isNull() || - iter->second->getWidth() != src->getWidth() || - iter->second->getHeight() != src->getHeight()) // bump not cached yet or has changed resolution - { //make sure an entry exists for this image - entries_list[src_vi->getID()] = LLViewerTextureManager::getLocalTexture(true); - iter = entries_list.find(src_vi->getID()); - } - } - - if (iter->second->getWidth() != src->getWidth() || - iter->second->getHeight() != src->getHeight()) // bump not cached yet or has changed resolution - { - LLPointer<LLImageRaw> dst_image = new LLImageRaw(src->getWidth(), src->getHeight(), 1); - U8* dst_data = dst_image->getData(); - S32 dst_data_size = dst_image->getDataSize(); - - const U8* src_data = src->getData(); - S32 src_data_size = src->getDataSize(); - - S32 src_components = src->getComponents(); - - // Convert to luminance and then scale and bias that to get ready for - // embossed bump mapping. (0-255 maps to 127-255) - - // Convert to fixed point so we don't have to worry about precision/clamping. - const S32 FIXED_PT = 8; - const S32 R_WEIGHT = S32(0.2995f * (1<<FIXED_PT)); - const S32 G_WEIGHT = S32(0.5875f * (1<<FIXED_PT)); - const S32 B_WEIGHT = S32(0.1145f * (1<<FIXED_PT)); - - S32 minimum = 255; - S32 maximum = 0; - - switch( src_components ) - { - case 1: - case 2: - { - if( src_data_size == dst_data_size * src_components ) - { - for( S32 i = 0, j=0; i < dst_data_size; i++, j+= src_components ) - { - dst_data[i] = src_data[j]; - if( dst_data[i] < minimum ) - { - minimum = dst_data[i]; - } - if( dst_data[i] > maximum ) - { - maximum = dst_data[i]; - } - } - } - else - { - llassert(0); - dst_image->clear(); - } - } - break; - case 3: - case 4: - { - if( src_data_size == dst_data_size * src_components ) - { - for( S32 i = 0, j=0; i < dst_data_size; i++, j+= src_components ) - { - // RGB to luminance - dst_data[i] = (R_WEIGHT * src_data[j] + G_WEIGHT * src_data[j+1] + B_WEIGHT * src_data[j+2]) >> FIXED_PT; - //llassert( dst_data[i] <= 255 );true because it's 8bit - if( dst_data[i] < minimum ) - { - minimum = dst_data[i]; - } - if( dst_data[i] > maximum ) - { - maximum = dst_data[i]; - } - } - } - else - { - llassert(0); - dst_image->clear(); - } - } - break; - default: - llassert(0); - dst_image->clear(); - break; - } - - if( maximum > minimum ) - { - U8 bias_and_scale_lut[256]; - F32 twice_one_over_range = 2.f / (maximum - minimum); - S32 i; - - const F32 ARTIFICIAL_SCALE = 2.f; // Advantage: exaggerates the effect in midrange. Disadvantage: clamps at the extremes. - if (BE_DARKNESS == bump_code) - { - for( i = minimum; i <= maximum; i++ ) - { - F32 minus_one_to_one = F32(maximum - i) * twice_one_over_range - 1.f; - bias_and_scale_lut[i] = llclampb(ll_round(127 * minus_one_to_one * ARTIFICIAL_SCALE + 128)); - } - } - else - { - for( i = minimum; i <= maximum; i++ ) - { - F32 minus_one_to_one = F32(i - minimum) * twice_one_over_range - 1.f; - bias_and_scale_lut[i] = llclampb(ll_round(127 * minus_one_to_one * ARTIFICIAL_SCALE + 128)); - } - } - - for( i = 0; i < dst_data_size; i++ ) - { - dst_data[i] = bias_and_scale_lut[dst_data[i]]; - } - } - - //--------------------------------------------------- - // immediately assign bump to a smart pointer in case some local smart pointer - // accidentally releases it. - LLPointer<LLViewerTexture> bump = iter->second; - - if (!LLPipeline::sRenderDeferred) - { - bump->setExplicitFormat(GL_ALPHA8, GL_ALPHA); - -#if LL_BUMPLIST_MULTITHREADED - auto tex_queue = LLImageGLThread::sEnabledTextures ? sTexUpdateQueue.lock() : nullptr; - - if (tex_queue) - { //dispatch creation to background thread - LLImageRaw* dst_ptr = dst_image; - LLViewerTexture* bump_ptr = bump; - dst_ptr->ref(); - bump_ptr->ref(); - tex_queue->post( - [=]() - { - LL_PROFILE_ZONE_NAMED("bil - create texture"); - bump_ptr->createGLTexture(0, dst_ptr); - bump_ptr->unref(); - dst_ptr->unref(); - }); - - } - else -#endif - { - bump->createGLTexture(0, dst_image); - } - } - else - { //convert to normal map - LL_PROFILE_ZONE_NAMED("bil - create normal map"); - LLImageGL* img = bump->getGLTexture(); - LLImageRaw* dst_ptr = dst_image.get(); - LLGLTexture* bump_ptr = bump.get(); - - dst_ptr->ref(); - img->ref(); - bump_ptr->ref(); - auto create_func = [=]() - { - img->setUseMipMaps(true); - // upload dst_image to GPU (greyscale in red channel) - img->setExplicitFormat(GL_RED, GL_RED); + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; - bump_ptr->createGLTexture(0, dst_ptr); - dst_ptr->unref(); - }; + const LLUUID& src_id = src->getID(); - auto generate_func = [=]() - { - // Allocate an empty RGBA texture at "tex_name" the same size as bump - // Note: bump will still point at GPU copy of dst_image - bump_ptr->setExplicitFormat(GL_RGBA, GL_RGBA); - LLGLuint tex_name; - img->createGLTexture(0, nullptr, false, 0, true, &tex_name); + bump_image_map_t& entries_list(bump_code == BE_BRIGHTNESS ? gBumpImageList.mBrightnessEntries : gBumpImageList.mDarknessEntries); + bump_image_map_t::iterator iter = entries_list.find(src_id); - // point render target at empty buffer - sRenderTarget.setColorAttachment(img, tex_name); + if (iter == entries_list.end()) + { //make sure an entry exists for this image + entries_list[src_id] = LLViewerTextureManager::getLocalTexture(true); + iter = entries_list.find(src_id); + } - // generate normal map in empty texture - { - sRenderTarget.bindTarget(); + //--------------------------------------------------- + // immediately assign bump to a smart pointer in case some local smart pointer + // accidentally releases it. + LLPointer<LLViewerTexture> bump = iter->second; - LLGLDepthTest depth(GL_FALSE); - LLGLDisable cull(GL_CULL_FACE); - LLGLDisable blend(GL_BLEND); - gGL.setColorMask(true, true); + if (bump->getWidth() != src->getWidth() || + bump->getHeight() != src->getHeight()) // bump not cached yet or has changed resolution + { + //convert to normal map + LL_PROFILE_ZONE_NAMED("bil - create normal map"); - gNormalMapGenProgram.bind(); + bump->setExplicitFormat(GL_RGBA, GL_RGBA); - static LLStaticHashedString sNormScale("norm_scale"); - static LLStaticHashedString sStepX("stepX"); - static LLStaticHashedString sStepY("stepY"); + LLImageGL* src_img = src->getGLTexture(); + LLImageGL* dst_img = bump->getGLTexture(); + dst_img->setSize(src->getWidth(), src->getHeight(), 4, 0); + dst_img->setUseMipMaps(true); + dst_img->setDiscardLevel(0); + dst_img->createGLTexture(); - gNormalMapGenProgram.uniform1f(sNormScale, gSavedSettings.getF32("RenderNormalMapScale")); - gNormalMapGenProgram.uniform1f(sStepX, 1.f / bump_ptr->getWidth()); - gNormalMapGenProgram.uniform1f(sStepY, 1.f / bump_ptr->getHeight()); + gGL.getTexUnit(0)->bind(bump); - gGL.getTexUnit(0)->bind(bump_ptr); + LLImageGL::setManualImage(GL_TEXTURE_2D, 0, dst_img->getPrimaryFormat(), dst_img->getWidth(), dst_img->getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, nullptr, false); - gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.texCoord2f(0, 0); - gGL.vertex2f(0, 0); + LLGLuint tex_name = dst_img->getTexName(); + // point render target at empty buffer + sRenderTarget.setColorAttachment(bump->getGLTexture(), tex_name); - gGL.texCoord2f(0, 1); - gGL.vertex2f(0, 1); + // generate normal map in empty texture + { + sRenderTarget.bindTarget(); - gGL.texCoord2f(1, 0); - gGL.vertex2f(1, 0); + LLGLDepthTest depth(GL_FALSE); + LLGLDisable cull(GL_CULL_FACE); + LLGLDisable blend(GL_BLEND); + gGL.setColorMask(true, true); - gGL.texCoord2f(1, 1); - gGL.vertex2f(1, 1); + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + gNormalMapGenProgram.bind(); - gGL.end(); + static LLStaticHashedString sNormScale("norm_scale"); + static LLStaticHashedString sStepX("stepX"); + static LLStaticHashedString sStepY("stepY"); + static LLStaticHashedString sBumpCode("bump_code"); - gGL.flush(); + gNormalMapGenProgram.uniform1f(sNormScale, gSavedSettings.getF32("RenderNormalMapScale")); + gNormalMapGenProgram.uniform1f(sStepX, 1.f / bump->getWidth()); + gNormalMapGenProgram.uniform1f(sStepY, 1.f / bump->getHeight()); + gNormalMapGenProgram.uniform1i(sBumpCode, bump_code); - gNormalMapGenProgram.unbind(); + gGL.getTexUnit(0)->bind(src); - sRenderTarget.flush(); - sRenderTarget.releaseColorAttachment(); - } + gGL.begin(LLRender::TRIANGLE_STRIP); + gGL.texCoord2f(0, 0); + gGL.vertex2f(0, 0); - // point bump at normal map and free gpu copy of dst_image - img->syncTexName(tex_name); + gGL.texCoord2f(0, 1); + gGL.vertex2f(0, 1); - // generate mipmap - gGL.getTexUnit(0)->bind(img); - glGenerateMipmap(GL_TEXTURE_2D); - gGL.getTexUnit(0)->disable(); + gGL.texCoord2f(1, 0); + gGL.vertex2f(1, 0); - bump_ptr->unref(); - img->unref(); - }; + gGL.texCoord2f(1, 1); + gGL.vertex2f(1, 1); -#if LL_BUMPLIST_MULTITHREADED - auto main_queue = LLImageGLThread::sEnabledTextures ? sMainQueue.lock() : nullptr; + gGL.end(); - if (main_queue) - { //dispatch texture upload to background thread, issue GPU commands to generate normal map on main thread - main_queue->postTo( - sTexUpdateQueue, - create_func, - generate_func); - } - else -#endif - { // immediate upload texture and generate normal map - create_func(); - generate_func(); - } + gGL.flush(); + sRenderTarget.flush(); + sRenderTarget.releaseColorAttachment(); + if (shader) + { + shader->bind(); } - - iter->second = bump; // derefs (and deletes) old image - //--------------------------------------------------- } + + // generate mipmap + gGL.getTexUnit(0)->bind(bump); + glGenerateMipmap(GL_TEXTURE_2D); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); } + + iter->second = bump; // derefs (and deletes) old image + //--------------------------------------------------- + } void LLDrawPoolBump::pushBumpBatches(U32 type) diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h index 65cb9af015..15976884ca 100644 --- a/indra/newview/lldrawpoolbump.h +++ b/indra/newview/lldrawpoolbump.h @@ -140,14 +140,13 @@ public: LLViewerTexture* getBrightnessDarknessImage(LLViewerFetchedTexture* src_image, U8 bump_code); void addTextureStats(U8 bump, const LLUUID& base_image_id, F32 virtual_size); - static void onSourceBrightnessLoaded( bool success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata ); - static void onSourceDarknessLoaded( bool success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata ); static void onSourceStandardLoaded( bool success, LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, bool final, void* userdata ); static void generateNormalMapFromAlpha(LLImageRaw* src, LLImageRaw* nrm_image); private: - static void onSourceLoaded( bool success, LLViewerTexture *src_vi, LLImageRaw* src, LLUUID& source_asset_id, EBumpEffect bump ); + // should be called whenever resolution of src_vi changes compared to the current entry + static void onSourceUpdated( LLViewerTexture *src_vi, EBumpEffect bump ); private: typedef std::unordered_map<LLUUID, LLPointer<LLViewerTexture> > bump_image_map_t; diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index afc5cc9d4e..7d2912d81f 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -107,7 +107,8 @@ U32 LLDrawPoolTerrain::getVertexDataMask() void LLDrawPoolTerrain::prerender() { - sPBRDetailMode = gSavedSettings.getS32("RenderTerrainPBRDetail"); + static LLCachedControl<S32> render_terrain_pbr_detail(gSavedSettings, "RenderTerrainPBRDetail"); + sPBRDetailMode = render_terrain_pbr_detail; } void LLDrawPoolTerrain::boostTerrainDetailTextures() diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 71b82b77eb..0d4eaab488 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -215,7 +215,7 @@ void LLDrawPoolWater::renderPostDeferred(S32 pass) LLViewerTexture* tex_a = mWaterNormp[0]; LLViewerTexture* tex_b = mWaterNormp[1]; - F32 blend_factor = pwater->getBlendFactor(); + F32 blend_factor = (F32)pwater->getBlendFactor(); gGL.getTexUnit(bumpTex)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(bumpTex2)->unbind(LLTexUnit::TT_TEXTURE); @@ -256,7 +256,7 @@ void LLDrawPoolWater::renderPostDeferred(S32 pass) if (mShaderLevel == 1) { - fog_color.mV[VALPHA] = log(fog_density) / log(2); + fog_color.mV[VALPHA] = (F32)(log(fog_density) / log(2)); } F32 water_height = environment.getWaterHeight(); diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 047e9a8112..305215f541 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -242,7 +242,7 @@ void LLDrawPoolWLSky::renderStarsDeferred(const LLVector3& camPosLocal) const LLViewerTexture* tex_a = gSky.mVOSkyp->getBloomTex(); LLViewerTexture* tex_b = gSky.mVOSkyp->getBloomTexNext(); - F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor(); + F32 blend_factor = (F32)LLEnvironment::instance().getCurrentSky()->getBlendFactor(); if (tex_a && (!tex_b || (tex_a == tex_b))) { @@ -309,8 +309,8 @@ void LLDrawPoolWLSky::renderSkyCloudsDeferred(const LLVector3& camPosLocal, F32 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); - F32 cloud_variance = psky ? psky->getCloudVariance() : 0.0f; - F32 blend_factor = psky ? psky->getBlendFactor() : 0.0f; + F32 cloud_variance = psky ? (F32)psky->getCloudVariance() : 0.0f; + F32 blend_factor = psky ? (F32)psky->getBlendFactor() : 0.0f; if (psky->getCloudScrollRate().isExactlyZero()) { @@ -364,7 +364,7 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() LLFace * face = gSky.mVOSkyp->mFace[LLVOSky::FACE_SUN]; - F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor(); + F32 blend_factor = (F32)LLEnvironment::instance().getCurrentSky()->getBlendFactor(); bool can_use_vertex_shaders = gPipeline.shadersLoaded(); bool can_use_windlight_shaders = gPipeline.canUseWindLightShaders(); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 8884905cf0..c12546f7eb 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -209,7 +209,7 @@ namespace mInitial = (*initial.first).second; mFinal = (*initial.second).second; - mBlendSpan = getSpanTime(initial); + mBlendSpan = (LLSettingsBase::TrackPosition)getSpanTime(initial); initializeTarget(now); setOnFinished([this](const LLSettingsBlender::ptr_t &){ onFinishedSpan(); }); @@ -237,7 +237,7 @@ namespace LLSettingsBase::BlendFactor blendf = calculateBlend(targetpos, targetspan); pendsetting->blend((*bounds.second).second, blendf); - reset(pstartsetting, pendsetting, LLEnvironment::TRANSITION_ALTITUDE); + reset(pstartsetting, pendsetting, (LLSettingsBase::TrackPosition)LLEnvironment::TRANSITION_ALTITUDE); } protected: @@ -304,7 +304,7 @@ namespace LLSettingsDay::TrackBound_t next = getBoundingEntries(adjusted_now); LLSettingsBase::Seconds nextspan = getSpanTime(next); - reset((*next.first).second, (*next.second).second, nextspan); + reset((*next.first).second, (*next.second).second, (LLSettingsBase::TrackPosition)nextspan); // Recalculate (reinitialize) position. Because: // - 'delta' from applyTimeDelta accumulates errors (probably should be fixed/changed to absolute time) @@ -695,7 +695,7 @@ namespace // Ideally we need to check for texture in injection, but // in this case user is setting value explicitly, potentially // with different transitions, don't ignore it - F64 result = lerp(value, injection->mValue.asReal(), mix); + F64 result = lerp((F32)value, (F32)injection->mValue.asReal(), (F32)mix); injection->mLastValue = LLSD::Real(result); this->mSettings[injection->mKeyName] = injection->mLastValue; } @@ -898,7 +898,7 @@ void LLEnvironment::initSingleton() gSavedSettings.getControl("RenderSkyAutoAdjustProbeAmbiance")->getSignal()->connect( [](LLControlVariable*, const LLSD& new_val, const LLSD& old_val) { - LLSettingsSky::sAutoAdjustProbeAmbiance = new_val.asReal(); + LLSettingsSky::sAutoAdjustProbeAmbiance = (F32)new_val.asReal(); } ); LLSettingsSky::sAutoAdjustProbeAmbiance = gSavedSettings.getF32("RenderSkyAutoAdjustProbeAmbiance"); @@ -967,11 +967,11 @@ LLSettingsWater::ptr_t LLEnvironment::getCurrentWater() const void LayerConfigToDensityLayer(const LLSD& layerConfig, DensityLayer& layerOut) { - layerOut.constant_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); - layerOut.exp_scale = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); - layerOut.exp_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); - layerOut.linear_term = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); - layerOut.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + layerOut.constant_term = (F32)layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); + layerOut.exp_scale = (F32)layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + layerOut.exp_term = (F32)layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + layerOut.linear_term = (F32)layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + layerOut.width = (F32)layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); } void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settingsOut, const LLSettingsSky::ptr_t &psky) @@ -1758,7 +1758,7 @@ void LLEnvironment::updateGLVariablesForSettings(LLShaderUniforms* uniforms, con //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; break; case LLSD::TypeReal: - shader->uniform1f(it.second.getShaderKey(), value.asReal()); + shader->uniform1f(it.second.getShaderKey(), (F32)value.asReal()); //_WARNS("RIDER") << "pushing '" << (*it).first << "' as " << value << LL_ENDL; break; @@ -1928,8 +1928,8 @@ void LLEnvironment::adjustRegionOffset(F32 adjust) if (mEnvironments[ENV_REGION]) { - F32 day_length = mEnvironments[ENV_REGION]->getDayLength(); - F32 day_offset = mEnvironments[ENV_REGION]->getDayOffset(); + F32 day_length = (F32)mEnvironments[ENV_REGION]->getDayLength(); + F32 day_offset = (F32)mEnvironments[ENV_REGION]->getDayOffset(); F32 day_adjustment = adjust * day_length; @@ -2345,7 +2345,7 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL { for (int idx = 0; idx < 3; idx++) { - pinfo->mAltitudes[idx+1] = environment[KEY_TRACKALTS][idx].asReal(); + pinfo->mAltitudes[idx+1] = (F32)environment[KEY_TRACKALTS][idx].asReal(); } pinfo->mAltitudes[0] = 0; } @@ -2569,7 +2569,7 @@ void LLEnvironment::handleEnvironmentPush(LLSD &message) std::string action = message[KEY_ACTION].asString(); LLUUID experience_id = message[KEY_EXPERIENCEID].asUUID(); LLSD action_data = message[KEY_ACTIONDATA]; - F32 transition_time = action_data[KEY_TRANSITIONTIME].asReal(); + F32 transition_time = (F32)action_data[KEY_TRANSITIONTIME].asReal(); //TODO: Check here that the viewer thinks the experience is still valid. @@ -2601,7 +2601,7 @@ void LLEnvironment::handleEnvironmentPushFull(LLUUID experience_id, LLSD &messag { LLUUID asset_id(message[KEY_ASSETID].asUUID()); - setExperienceEnvironment(experience_id, asset_id, LLSettingsBase::Seconds(transition)); + setExperienceEnvironment(experience_id, asset_id, (F32)LLSettingsBase::Seconds(transition)); } void LLEnvironment::handleEnvironmentPushPartial(LLUUID experience_id, LLSD &message, F32 transition) @@ -2611,7 +2611,7 @@ void LLEnvironment::handleEnvironmentPushPartial(LLUUID experience_id, LLSD &mes if (settings.isUndefined()) return; - setExperienceEnvironment(experience_id, settings, LLSettingsBase::Seconds(transition)); + setExperienceEnvironment(experience_id, settings, (F32)LLSettingsBase::Seconds(transition)); } void LLEnvironment::clearExperienceEnvironment(LLUUID experience_id, LLSettingsBase::Seconds transition_time) @@ -2968,7 +2968,7 @@ void LLEnvironment::DayTransition::animate() // pause probe updates and reset reflection maps on sky change - gPipeline.mReflectionMapManager.pause(mTransitionTime); + gPipeline.mReflectionMapManager.pause((F32)mTransitionTime); gPipeline.mReflectionMapManager.reset(); mSky = mStartSky->buildClone(); @@ -3286,7 +3286,7 @@ void LLTrackBlenderLoopingManual::switchTrack(S32 trackno, const LLSettingsBase: { mTrackNo = trackno; - LLSettingsBase::TrackPosition useposition = (position < 0.0) ? mPosition : position; + LLSettingsBase::TrackPosition useposition = (position < 0.0) ? (LLSettingsBase::TrackPosition)mPosition : position; setPosition(useposition); } @@ -3297,7 +3297,7 @@ LLSettingsDay::TrackBound_t LLTrackBlenderLoopingManual::getBoundingEntries(F64 mEndMarker = wtrack.end(); - LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, position); + LLSettingsDay::TrackBound_t bounds = get_bounding_entries(wtrack, (LLSettingsBase::TrackPosition)position); return bounds; } @@ -3571,7 +3571,7 @@ namespace mInjectedSky->setSource(target_sky); // clear reflection probes and pause updates during sky change - gPipeline.mReflectionMapManager.pause(transition); + gPipeline.mReflectionMapManager.pause((F32)transition); gPipeline.mReflectionMapManager.reset(); mBlenderSky = std::make_shared<LLSettingsBlenderTimeDelta>(target_sky, start_sky, psky, transition); diff --git a/indra/newview/llexpandabletextbox.cpp b/indra/newview/llexpandabletextbox.cpp index 4c105176b6..42fe8fc6e6 100644 --- a/indra/newview/llexpandabletextbox.cpp +++ b/indra/newview/llexpandabletextbox.cpp @@ -54,7 +54,7 @@ public: } else { - width = mEditor.getDocumentView()->getRect().getWidth() - mEditor.getHPad(); + width = (F32)(mEditor.getDocumentView()->getRect().getWidth() - mEditor.getHPad()); height = mStyle->getFont()->getLineHeight(); } return true; @@ -86,7 +86,7 @@ public: LLFontGL::RIGHT, LLFontGL::TOP, 0, mStyle->getShadowType(), - end - start, draw_rect.getWidth(), + end - start, (S32)draw_rect.getWidth(), &right_x, mEditor.getUseEllipses(), mEditor.getUseColor()); return right_x; diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp index 0e8e64af69..f73c530ff9 100644 --- a/indra/newview/llface.cpp +++ b/indra/newview/llface.cpp @@ -169,6 +169,8 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp) mImportanceToCamera = 0.f ; mBoundingSphereRadius = 0.0f ; + mTexExtents[0].set(0, 0); + mTexExtents[1].set(1, 1); mHasMedia = false ; mIsMediaAllowed = true; } @@ -234,7 +236,7 @@ void LLFace::setPool(LLFacePool* pool) void LLFace::setPool(LLFacePool* new_pool, LLViewerTexture *texturep) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE + LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE; if (!new_pool) { @@ -315,7 +317,7 @@ void LLFace::setSpecularMap(LLViewerTexture* tex) void LLFace::dirtyTexture() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE + LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE; LLDrawable* drawablep = getDrawable(); @@ -502,7 +504,7 @@ void LLFace::updateCenterAgent() void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE + LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE; if (mDrawablep == NULL || mDrawablep->getSpatialGroup() == NULL) { @@ -576,7 +578,7 @@ void LLFace::renderSelected(LLViewerTexture *imagep, const LLColor4& color) void renderFace(LLDrawable* drawable, LLFace *face) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE + LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE; LLVOVolume* vobj = drawable->getVOVolume(); if (vobj) @@ -803,7 +805,7 @@ bool less_than_max_mag(const LLVector4a& vec) bool LLFace::genVolumeBBoxes(const LLVolume &volume, S32 f, const LLMatrix4& mat_vert_in, bool global_volume) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE + LL_PROFILE_ZONE_SCOPED_CATEGORY_FACE; //get bounding box if (mDrawablep->isState(LLDrawable::REBUILD_VOLUME | LLDrawable::REBUILD_POSITION | LLDrawable::REBUILD_RIGGED)) @@ -2047,10 +2049,12 @@ void LLFace::resetVirtualSize() F32 LLFace::getTextureVirtualSize() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + F32 radius; F32 cos_angle_to_view_dir; bool in_frustum = calcPixelArea(cos_angle_to_view_dir, radius); + if (mPixelArea < F_ALMOST_ZERO || !in_frustum) { setVirtualSize(0.f) ; @@ -2271,7 +2275,7 @@ F32 LLFace::adjustPixelArea(F32 importance, F32 pixel_area) { if(importance < LEAST_IMPORTANCE_FOR_LARGE_IMAGE)//if the face is not important, do not load hi-res. { - pixel_area = LLViewerTexture::sMinLargeImageSize ; + pixel_area = (F32)LLViewerTexture::sMinLargeImageSize ; } } } diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 67d55c53e4..8056983c7c 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -279,9 +279,9 @@ bool LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) // so we can create a new tooltip LLToolTipMgr::instance().unblockToolTips(); mHoverTimer = mHoverID; - mToolTipRect.set(mBarRect.mLeft + (hover_bar->mSelfStart / mTotalTimeDisplay) * mBarRect.getWidth(), + mToolTipRect.set((S32)(mBarRect.mLeft + (hover_bar->mSelfStart / mTotalTimeDisplay) * mBarRect.getWidth()), row.mTop, - mBarRect.mLeft + (hover_bar->mSelfEnd / mTotalTimeDisplay) * mBarRect.getWidth(), + (S32)(mBarRect.mLeft + (hover_bar->mSelfEnd / mTotalTimeDisplay) * mBarRect.getWidth()), row.mBottom); } } @@ -626,7 +626,7 @@ void LLFastTimerView::exportCharts(const std::string& base, const std::string& t gGL.begin(LLRender::TRIANGLE_STRIP); gGL.vertex3fv(last_p.mV); gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - last_p.set((F32)i/(F32) base_times.size(), base_times[i]/max_time, 0.f); + last_p.set((F32)i/(F32) base_times.size(), (F32)(base_times[i]/max_time), 0.f); gGL.vertex3fv(last_p.mV); gGL.vertex3f(last_p.mV[0], 0.f, 0.f); gGL.end(); @@ -645,7 +645,7 @@ void LLFastTimerView::exportCharts(const std::string& base, const std::string& t gGL.begin(LLRender::TRIANGLE_STRIP); gGL.vertex3f(last_p.mV[0], 0.f, 0.f); gGL.vertex3fv(last_p.mV); - last_p.set((F32) i / (F32) cur_times.size(), cur_times[i]/max_time, 0.f); + last_p.set((F32) i / (F32) cur_times.size(), (F32)(cur_times[i]/max_time), 0.f); gGL.vertex3f(last_p.mV[0], 0.f, 0.f); gGL.vertex3fv(last_p.mV); gGL.end(); @@ -715,7 +715,7 @@ void LLFastTimerView::exportCharts(const std::string& base, const std::string& t gGL.begin(LLRender::TRIANGLE_STRIP); gGL.vertex3fv(last_p.mV); gGL.vertex3f(last_p.mV[0], 0.f, 0.f); - last_p.set((F32)count/(F32)total_count, *iter/max_execution, 0.f); + last_p.set((F32)count/(F32)total_count, (F32)(*iter/max_execution), 0.f); gGL.vertex3fv(last_p.mV); gGL.vertex3f(last_p.mV[0], 0.f, 0.f); gGL.end(); @@ -735,7 +735,7 @@ void LLFastTimerView::exportCharts(const std::string& base, const std::string& t gGL.begin(LLRender::TRIANGLE_STRIP); gGL.vertex3f(last_p.mV[0], 0.f, 0.f); gGL.vertex3fv(last_p.mV); - last_p.set((F32)count/(F32)total_count, *iter/max_execution, 0.f); + last_p.set((F32)count/(F32)total_count, (F32)(*iter/max_execution), 0.f); gGL.vertex3f(last_p.mV[0], 0.f, 0.f); gGL.vertex3fv(last_p.mV); gGL.end(); @@ -787,8 +787,8 @@ LLSD LLFastTimerView::analyzePerformanceLogDefault(std::istream& is) { LLSD::Integer samples = iter->second["Calls"].asInteger(); - time_stats[label].push(time); - sample_stats[label].push(samples); + time_stats[label].push((F32)time); + sample_stats[label].push((F32)samples); } } total_frames++; @@ -1112,7 +1112,7 @@ void LLFastTimerView::drawLineGraph() break; } gGL.vertex2f(x,y); - gGL.vertex2f(x,mGraphRect.mBottom); + gGL.vertex2f(x,(GLfloat)mGraphRect.mBottom); } gGL.end(); @@ -1432,7 +1432,7 @@ void LLFastTimerView::updateTotalTime() break; } - mTotalTimeDisplay = LLUnits::Milliseconds::fromValue(llceil(mTotalTimeDisplay.valueInUnits<LLUnits::Milliseconds>() / 20.f) * 20.f); + mTotalTimeDisplay = LLUnits::Milliseconds::fromValue(llceil((F32)mTotalTimeDisplay.valueInUnits<LLUnits::Milliseconds>() / 20.f) * 20.f); } void LLFastTimerView::drawBars() @@ -1491,7 +1491,7 @@ void LLFastTimerView::drawBars() LLRect frame_bar_rect; frame_bar_rect.setLeftTopAndSize(mBarRect.mLeft, bars_top, - ll_round((mAverageTimerRow.mBars[0].mTotalTime / mTotalTimeDisplay) * mBarRect.getWidth()), + (S32)ll_round((mAverageTimerRow.mBars[0].mTotalTime / mTotalTimeDisplay) * mBarRect.getWidth()), bar_height); mAverageTimerRow.mTop = frame_bar_rect.mTop; mAverageTimerRow.mBottom = frame_bar_rect.mBottom; @@ -1505,7 +1505,7 @@ void LLFastTimerView::drawBars() row.mTop = frame_bar_rect.mTop; row.mBottom = frame_bar_rect.mBottom; frame_bar_rect.mRight = frame_bar_rect.mLeft - + ll_round((row.mBars[0].mTotalTime / mTotalTimeDisplay) * mBarRect.getWidth()); + + (S32)ll_round((row.mBars[0].mTotalTime / mTotalTimeDisplay) * mBarRect.getWidth()); drawBar(frame_bar_rect, row, image_width, image_height); frame_bar_rect.translate(0, -(bar_height + vpad)); @@ -1633,8 +1633,8 @@ S32 LLFastTimerView::drawBar(LLRect bar_rect, TimerBarRow& row, S32 image_width, } LLRect children_rect; - children_rect.mLeft = ll_round(timer_bar.mChildrenStart / mTotalTimeDisplay * (F32)mBarRect.getWidth()) + mBarRect.mLeft; - children_rect.mRight = ll_round(timer_bar.mChildrenEnd / mTotalTimeDisplay * (F32)mBarRect.getWidth()) + mBarRect.mLeft; + children_rect.mLeft = (S32)ll_round(timer_bar.mChildrenStart / mTotalTimeDisplay * (F32)mBarRect.getWidth()) + mBarRect.mLeft; + children_rect.mRight = (S32)ll_round(timer_bar.mChildrenEnd / mTotalTimeDisplay * (F32)mBarRect.getWidth()) + mBarRect.mLeft; if (bar_rect.getHeight() > MIN_BAR_HEIGHT) { diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp index 367803b78a..b6f1eea802 100644 --- a/indra/newview/llflexibleobject.cpp +++ b/indra/newview/llflexibleobject.cpp @@ -94,7 +94,7 @@ void LLVolumeImplFlexible::updateClass() { LL_PROFILE_ZONE_SCOPED; - U64 virtual_frame_num = LLTimer::getElapsedSeconds() / SEC_PER_FLEXI_FRAME; + U64 virtual_frame_num = (U64)(LLTimer::getElapsedSeconds() / SEC_PER_FLEXI_FRAME); for (std::vector<LLVolumeImplFlexible*>::iterator iter = sInstanceList.begin(); iter != sInstanceList.end(); ++iter) @@ -362,7 +362,7 @@ void LLVolumeImplFlexible::doIdleUpdate() update_period = llclamp(update_period, 1U, 32U); // We control how fast flexies update, buy splitting updates among frames - U64 virtual_frame_num = LLTimer::getElapsedSeconds() / SEC_PER_FLEXI_FRAME; + U64 virtual_frame_num = (U64)(LLTimer::getElapsedSeconds() / SEC_PER_FLEXI_FRAME); if (visible) { diff --git a/indra/newview/llfloater360capture.cpp b/indra/newview/llfloater360capture.cpp index 66796276a9..01a0525d56 100644 --- a/indra/newview/llfloater360capture.cpp +++ b/indra/newview/llfloater360capture.cpp @@ -488,7 +488,7 @@ void LLFloater360Capture::capture360Images() // 'GPano:InitialViewHeadingDegrees' field. // We need to convert from the angle getYaw() gives us into something // the XMP data field wants (N=0, E=90, S=180, W= 270 etc.) - mInitialHeadingDeg = (360 + 90 - (int)(camera->getYaw() * RAD_TO_DEG)) % 360; + mInitialHeadingDeg = (float)((360 + 90 - (int)(camera->getYaw() * RAD_TO_DEG)) % 360); LL_INFOS("360Capture") << "Recording a heading of " << (int)(mInitialHeadingDeg) << " Image size: " << (S32)mSourceImageSize << LL_ENDL; diff --git a/indra/newview/llfloateravatar.cpp b/indra/newview/llfloateravatar.cpp index 6a38d7549c..404316275d 100644 --- a/indra/newview/llfloateravatar.cpp +++ b/indra/newview/llfloateravatar.cpp @@ -25,11 +25,6 @@ * $/LicenseInfo$ */ -/** - * Floater that appears when buying an object, giving a preview - * of its contents and their permissions. - */ - #include "llviewerprecompiledheaders.h" #include "llfloateravatar.h" diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index 6087e6c0ee..08a54b7369 100644 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -300,7 +300,7 @@ void LLFloaterAvatarPicker::populateNearMe() if (!LLAvatarNameCache::get(av, &av_name)) { element["columns"][0]["column"] = "name"; - element["columns"][0]["value"] = LLCacheName::getDefaultName(); + element["columns"][0]["value"] = gCacheName->getDefaultName(); all_loaded = false; } else diff --git a/indra/newview/llfloaterbanduration.cpp b/indra/newview/llfloaterbanduration.cpp index c9141322e3..eb32e50901 100644 --- a/indra/newview/llfloaterbanduration.cpp +++ b/indra/newview/llfloaterbanduration.cpp @@ -82,7 +82,7 @@ void LLFloaterBanDuration::onClickBan() LLSpinCtrl* hours_spin = getChild<LLSpinCtrl>("ban_hours"); if (hours_spin) { - time = LLDate::now().secondsSinceEpoch() + (hours_spin->getValue().asInteger() * 3600); + time = (S32)(LLDate::now().secondsSinceEpoch() + (hours_spin->getValue().asInteger() * 3600)); } } mSelectionCallback(mAvatar_ids, time); diff --git a/indra/newview/llfloaterbulkupload.cpp b/indra/newview/llfloaterbulkupload.cpp new file mode 100644 index 0000000000..b898cb28b6 --- /dev/null +++ b/indra/newview/llfloaterbulkupload.cpp @@ -0,0 +1,136 @@ +/** + * @file llfloaterbulkupload.cpp + * @author Andrey Kleshchev + * @brief LLFloaterBulkUpload class implementation + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloaterbulkupload.h" + +#include "lltextbox.h" +#include "llviewercontrol.h" +#include "llviewermenufile.h" + +constexpr S32 MAX_HEIGH = 211; + +LLFloaterBulkUpload::LLFloaterBulkUpload(const LLSD& key) +: LLModalDialog(key, true) +{ + mUploadCost = key["upload_cost"].asInteger(); + mUploadCount = key["upload_count"].asInteger(); + mHas2kTextures = key["has_2k_textures"].asBoolean(); + if (key["files"].isArray()) + { + const LLSD& files = key["files"]; + for (LLSD::array_const_iterator it = files.beginArray(); + it != files.endArray(); + ++it) + { + mFiles.push_back(it->asString()); + } + } +} + +LLFloaterBulkUpload::~LLFloaterBulkUpload() +{ +} + +bool LLFloaterBulkUpload::postBuild() +{ + childSetAction("upload_btn", [this](void*) { onClickUpload(); }, this); + childSetAction("cancel_btn", [this](void*) { onClickCancel(); }, this); + + mCountLabel = getChild<LLTextBox>("number_of_items", true); + mCostLabel = getChild<LLTextBox>("upload_cost", true); + + mCheckboxPanel = getChild<LLPanel>("checkbox_panel", true); + mLinkPanel = getChild<LLPanel>("link_panel", true); + mWarningPanel = getChild<LLPanel>("warning_panel", true); + + mCheckboxUpload2K = getChild<LLUICtrl>("upload_2k"); + mCheckboxUpload2K->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& data) { onUpload2KCheckBox(); }); + + mAllow2kTextures = gSavedSettings.getBOOL("BulkUpload2KTextures"); + mCheckboxUpload2K->setValue(!mAllow2kTextures); + + if (!mAllow2kTextures && mHas2kTextures) + { + // provided cost is for 2K textures, recalculate cost + S32 bvh_count; + S32 textures_2k_count; + get_bulk_upload_expected_cost(mFiles, mAllow2kTextures, mUploadCost, mUploadCount, bvh_count, textures_2k_count); + + update(); + } + + + update(); + + return LLModalDialog::postBuild(); +} + +void LLFloaterBulkUpload::update() +{ + mCountLabel->setTextArg("[COUNT]", llformat("%d", mUploadCount)); + mCostLabel->setTextArg("[COST]", llformat("%d", mUploadCost)); + + mCheckboxPanel->setVisible(mHas2kTextures); + mLinkPanel->setVisible(mHas2kTextures); + mWarningPanel->setVisible(mHas2kTextures); + + S32 new_height = MAX_HEIGH; + if (!mHas2kTextures) + { + new_height -= mCheckboxPanel->getRect().getHeight(); + new_height -= mLinkPanel->getRect().getHeight(); + new_height -= mWarningPanel->getRect().getHeight(); + } + reshape(getRect().getWidth(), new_height, false); +} + +void LLFloaterBulkUpload::onUpload2KCheckBox() +{ + mAllow2kTextures = !mCheckboxUpload2K->getValue().asBoolean(); + gSavedSettings.setBOOL("BulkUpload2KTextures", mAllow2kTextures); + + S32 bvh_count; + S32 textures_2k_count; + get_bulk_upload_expected_cost(mFiles, mAllow2kTextures, mUploadCost, mUploadCount, bvh_count, textures_2k_count); + // keep old value of mHas2kTextures to show checkbox + + update(); +} + +void LLFloaterBulkUpload::onClickUpload() +{ + do_bulk_upload(mFiles, mAllow2kTextures); + closeFloater(); +} + + +void LLFloaterBulkUpload::onClickCancel() +{ + closeFloater(); +} diff --git a/indra/newview/llfloaterbulkupload.h b/indra/newview/llfloaterbulkupload.h new file mode 100644 index 0000000000..d07dc8eabe --- /dev/null +++ b/indra/newview/llfloaterbulkupload.h @@ -0,0 +1,66 @@ +/** + * @file llfloaterbulkupload.h + * @author Andrey Kleshchev + * @brief LLFloaterBulkUpload class definition + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATERBULKUPLOAD_H +#define LL_LLFLOATERBULKUPLOAD_H + +#include "llmodaldialog.h" + +class LLTextBox; + +class LLFloaterBulkUpload : public LLModalDialog +{ +public: + LLFloaterBulkUpload(const LLSD& key); + ~LLFloaterBulkUpload(); + + bool postBuild() override; + + void update(); + +protected: + void onUpload2KCheckBox(); + + void onClickUpload(); + void onClickCancel(); + +private: + LLUICtrl* mCheckboxUpload2K = nullptr; + LLTextBox* mCountLabel = nullptr; + LLTextBox* mCostLabel = nullptr; + LLPanel* mCheckboxPanel = nullptr; + LLPanel* mLinkPanel = nullptr; + LLPanel* mWarningPanel = nullptr; + + std::vector<std::string> mFiles; + bool mAllow2kTextures = true; + bool mHas2kTextures = false; + S32 mUploadCost = 0; + S32 mUploadCount = 0; +}; + +#endif diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp index 570a223908..11505e3047 100644 --- a/indra/newview/llfloaterbuyland.cpp +++ b/indra/newview/llfloaterbuyland.cpp @@ -182,7 +182,7 @@ public: void refreshUI(); - void startTransaction(TransactionType type, const LLXMLRPCValue& params); + void startTransaction(TransactionType type, const LLSD& params); bool checkTransaction(); void tellUserError(const std::string& message, const std::string& uri); @@ -396,11 +396,10 @@ void LLFloaterBuyLandUI::updateParcelInfo() // Can't have more than region max tasks, regardless of parcel // object bonus factor. LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion(); - if(region) + if (region) { S32 max_tasks_per_region = (S32)region->getMaxTasks(); - mParcelSupportedObjects = llmin( - mParcelSupportedObjects, max_tasks_per_region); + mParcelSupportedObjects = llmin(mParcelSupportedObjects, max_tasks_per_region); } mParcelSoldWithObjects = parcel->getSellWithObjects(); @@ -423,7 +422,7 @@ void LLFloaterBuyLandUI::updateParcelInfo() // checks that we can buy the land - if(mIsForGroup && !gAgent.hasPowerInActiveGroup(GP_LAND_DEED)) + if (mIsForGroup && !gAgent.hasPowerInActiveGroup(GP_LAND_DEED)) { mCannotBuyReason = getString("cant_buy_for_group"); return; @@ -492,85 +491,56 @@ void LLFloaterBuyLandUI::updateParcelInfo() void LLFloaterBuyLandUI::updateCovenantInfo() { LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion(); - if(!region) return; + if (!region) + return; U8 sim_access = region->getSimAccess(); std::string rating = LLViewerRegion::accessToString(sim_access); LLTextBox* region_name = getChild<LLTextBox>("region_name_text"); - if (region_name) - { - std::string region_name_txt = region->getName() + " ("+rating +")"; - region_name->setText(region_name_txt); + std::string region_name_txt = region->getName() + " ("+rating +")"; + region_name->setText(region_name_txt); - LLIconCtrl* rating_icon = getChild<LLIconCtrl>("rating_icon"); - LLRect rect = rating_icon->getRect(); - S32 region_name_width = llmin(region_name->getRect().getWidth(), region_name->getTextBoundingRect().getWidth()); - S32 icon_left_pad = region_name->getRect().mLeft + region_name_width + ICON_PAD; - region_name->setToolTip(region_name->getText()); - rating_icon->setRect(rect.setOriginAndSize(icon_left_pad, rect.mBottom, rect.getWidth(), rect.getHeight())); + LLIconCtrl* rating_icon = getChild<LLIconCtrl>("rating_icon"); + LLRect rect = rating_icon->getRect(); + S32 region_name_width = llmin(region_name->getRect().getWidth(), region_name->getTextBoundingRect().getWidth()); + S32 icon_left_pad = region_name->getRect().mLeft + region_name_width + ICON_PAD; + region_name->setToolTip(region_name->getText()); + rating_icon->setRect(rect.setOriginAndSize(icon_left_pad, rect.mBottom, rect.getWidth(), rect.getHeight())); - switch(sim_access) - { - case SIM_ACCESS_PG: - rating_icon->setValue(getString("icon_PG")); - break; + switch (sim_access) + { + case SIM_ACCESS_PG: + rating_icon->setValue(getString("icon_PG")); + break; - case SIM_ACCESS_ADULT: - rating_icon->setValue(getString("icon_R")); - break; + case SIM_ACCESS_ADULT: + rating_icon->setValue(getString("icon_R")); + break; - default: - rating_icon->setValue(getString("icon_M")); - } + default: + rating_icon->setValue(getString("icon_M")); } LLTextBox* region_type = getChild<LLTextBox>("region_type_text"); - if (region_type) - { - region_type->setText(region->getLocalizedSimProductName()); - region_type->setToolTip(region->getLocalizedSimProductName()); - } + region_type->setText(region->getLocalizedSimProductName()); + region_type->setToolTip(region->getLocalizedSimProductName()); LLTextBox* resellable_clause = getChild<LLTextBox>("resellable_clause"); - if (resellable_clause) - { - if (region->getRegionFlag(REGION_FLAGS_BLOCK_LAND_RESELL)) - { - resellable_clause->setText(getString("can_not_resell")); - } - else - { - resellable_clause->setText(getString("can_resell")); - } - } + const char* can_resell = region->getRegionFlag(REGION_FLAGS_BLOCK_LAND_RESELL) ? "can_not_resell" : "can_resell"; + resellable_clause->setText(getString(can_resell)); LLTextBox* changeable_clause = getChild<LLTextBox>("changeable_clause"); - if (changeable_clause) - { - if (region->getRegionFlag(REGION_FLAGS_ALLOW_PARCEL_CHANGES)) - { - changeable_clause->setText(getString("can_change")); - } - else - { - changeable_clause->setText(getString("can_not_change")); - } - } + const char* can_change = region->getRegionFlag(REGION_FLAGS_ALLOW_PARCEL_CHANGES) ? "can_change" : "can_not_change"; + changeable_clause->setText(getString(can_change)); LLCheckBoxCtrl* check = getChild<LLCheckBoxCtrl>("agree_covenant"); - if(check) - { - check->set(false); - check->setEnabled(true); - check->setCommitCallback(onChangeAgreeCovenant, this); - } + check->set(false); + check->setEnabled(true); + check->setCommitCallback(onChangeAgreeCovenant, this); LLTextBox* box = getChild<LLTextBox>("covenant_text"); - if(box) - { - box->setVisible(false); - } + box->setVisible(false); // send EstateCovenantInfo message LLMessageSystem *msg = gMessageSystem; @@ -584,10 +554,9 @@ void LLFloaterBuyLandUI::updateCovenantInfo() // static void LLFloaterBuyLandUI::onChangeAgreeCovenant(LLUICtrl* ctrl, void* user_data) { - LLFloaterBuyLandUI* self = (LLFloaterBuyLandUI*)user_data; - if(self) + if (user_data) { - self->refreshUI(); + ((LLFloaterBuyLandUI*)user_data)->refreshUI(); } } @@ -626,13 +595,13 @@ void LLFloaterBuyLandUI::updateFloaterEstateName(const std::string& name) void LLFloaterBuyLandUI::updateFloaterLastModified(const std::string& text) { LLTextBox* editor = getChild<LLTextBox>("covenant_timestamp_text"); - if (editor) editor->setText(text); + editor->setText(text); } void LLFloaterBuyLandUI::updateFloaterEstateOwnerName(const std::string& name) { LLTextBox* box = getChild<LLTextBox>("estate_owner_text"); - if (box) box->setText(name); + box->setText(name); } void LLFloaterBuyLandUI::updateWebSiteInfo() @@ -640,9 +609,10 @@ void LLFloaterBuyLandUI::updateWebSiteInfo() S32 askBillableArea = mIsForGroup ? 0 : mParcelBillableArea; S32 askCurrencyBuy = mCurrency.getAmount(); - if (mTransaction && mTransactionType == TransactionPreflight - && mPreflightAskBillableArea == askBillableArea - && mPreflightAskCurrencyBuy == askCurrencyBuy) + if (mTransaction && + mTransactionType == TransactionPreflight && + mPreflightAskBillableArea == askBillableArea && + mPreflightAskCurrencyBuy == askCurrencyBuy) { return; } @@ -664,27 +634,21 @@ void LLFloaterBuyLandUI::updateWebSiteInfo() mSiteCurrencyEstimatedCost = 0; #endif - LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); - keywordArgs.appendString("agentId", gAgent.getID().asString()); - keywordArgs.appendString( - "secureSessionId", - gAgent.getSecureSessionID().asString()); - keywordArgs.appendString("language", LLUI::getLanguage()); - keywordArgs.appendInt("billableArea", mPreflightAskBillableArea); - keywordArgs.appendInt("currencyBuy", mPreflightAskCurrencyBuy); - - LLXMLRPCValue params = LLXMLRPCValue::createArray(); - params.append(keywordArgs); + LLSD params = LLSD::emptyMap(); + params["agentId"] = gAgent.getID().asString(); + params["secureSessionId"] = gAgent.getSecureSessionID().asString(); + params["language"] = LLUI::getLanguage(); + params["billableArea"] = mPreflightAskBillableArea; + params["currencyBuy"] = mPreflightAskCurrencyBuy; startTransaction(TransactionPreflight, params); } void LLFloaterBuyLandUI::finishWebSiteInfo() { + const LLSD& result = mTransaction->response(); - LLXMLRPCValue result = mTransaction->responseValue(); - - mSiteValid = result["success"].asBool(); + mSiteValid = result["success"].asBoolean(); if (!mSiteValid) { tellUserError( @@ -694,31 +658,30 @@ void LLFloaterBuyLandUI::finishWebSiteInfo() return; } - LLXMLRPCValue membership = result["membership"]; - mSiteMembershipUpgrade = membership["upgrade"].asBool(); + const LLSD& membership = result["membership"]; + mSiteMembershipUpgrade = membership["upgrade"].asBoolean(); mSiteMembershipAction = membership["action"].asString(); mSiteMembershipPlanIDs.clear(); mSiteMembershipPlanNames.clear(); - LLXMLRPCValue levels = membership["levels"]; - for (LLXMLRPCValue level = levels.rewind(); - level.isValid(); - level = levels.next()) + const LLSD& levels = membership["levels"]; + for (auto it = levels.beginArray(); it != levels.endArray(); ++it) { + const LLSD& level = *it; mSiteMembershipPlanIDs.push_back(level["id"].asString()); mSiteMembershipPlanNames.push_back(level["description"].asString()); } mUserPlanChoice = 0; - LLXMLRPCValue landUse = result["landUse"]; - mSiteLandUseUpgrade = landUse["upgrade"].asBool(); + const LLSD& landUse = result["landUse"]; + mSiteLandUseUpgrade = landUse["upgrade"].asBoolean(); mSiteLandUseAction = landUse["action"].asString(); - LLXMLRPCValue currency = result["currency"]; - if (currency["estimatedCost"].isValid()) + const LLSD& currency = result["currency"]; + if (currency.has("estimatedCost")) { - mCurrency.setUSDEstimate(currency["estimatedCost"].asInt()); + mCurrency.setUSDEstimate(currency["estimatedCost"].asInteger()); } - if (currency["estimatedLocalCost"].isValid()) + if (currency.has("estimatedLocalCost")) { mCurrency.setLocalEstimate(currency["estimatedLocalCost"].asString()); } @@ -760,35 +723,30 @@ void LLFloaterBuyLandUI::runWebSitePrep(const std::string& password) } } - LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct(); - keywordArgs.appendString("agentId", gAgent.getID().asString()); - keywordArgs.appendString( - "secureSessionId", - gAgent.getSecureSessionID().asString()); - keywordArgs.appendString("language", LLUI::getLanguage()); - keywordArgs.appendString("levelId", newLevel); - keywordArgs.appendInt("billableArea", - mIsForGroup ? 0 : mParcelBillableArea); - keywordArgs.appendInt("currencyBuy", mCurrency.getAmount()); - keywordArgs.appendInt("estimatedCost", mCurrency.getUSDEstimate()); - keywordArgs.appendString("estimatedLocalCost", mCurrency.getLocalEstimate()); - keywordArgs.appendString("confirm", mSiteConfirm); + LLSD params = LLSD::emptyMap(); + params["agentId"] = gAgent.getID().asString(); + params["secureSessionId"] = gAgent.getSecureSessionID().asString(); + params["language"] = LLUI::getLanguage(); + params["levelId"] = newLevel; + params["billableArea"] = mIsForGroup ? 0 : mParcelBillableArea; + params["currencyBuy"] = mCurrency.getAmount(); + params["estimatedCost"] = mCurrency.getUSDEstimate(); + params["estimatedLocalCost"] = mCurrency.getLocalEstimate(); + params["confirm"] = mSiteConfirm; + if (!password.empty()) { - keywordArgs.appendString("password", password); + params["password"] = password; } - LLXMLRPCValue params = LLXMLRPCValue::createArray(); - params.append(keywordArgs); - startTransaction(TransactionBuy, params); } void LLFloaterBuyLandUI::finishWebSitePrep() { - LLXMLRPCValue result = mTransaction->responseValue(); + const LLSD& result = mTransaction->response(); - bool success = result["success"].asBool(); + bool success = result["success"].asBoolean(); if (!success) { tellUserError( @@ -850,7 +808,7 @@ void LLFloaterBuyLandUI::updateGroupName(const LLUUID& id, } } -void LLFloaterBuyLandUI::startTransaction(TransactionType type, const LLXMLRPCValue& params) +void LLFloaterBuyLandUI::startTransaction(TransactionType type, const LLSD& params) { delete mTransaction; mTransaction = NULL; @@ -878,12 +836,7 @@ void LLFloaterBuyLandUI::startTransaction(TransactionType type, const LLXMLRPCVa return; } - mTransaction = new LLXMLRPCTransaction( - transaction_uri, - method, - params, - false /* don't use gzip */ - ); + mTransaction = new LLXMLRPCTransaction(transaction_uri, method, params); } bool LLFloaterBuyLandUI::checkTransaction() diff --git a/indra/newview/llfloaterbvhpreview.cpp b/indra/newview/llfloaterbvhpreview.cpp index 5330518ba5..2cb930922a 100644 --- a/indra/newview/llfloaterbvhpreview.cpp +++ b/indra/newview/llfloaterbvhpreview.cpp @@ -1086,7 +1086,7 @@ bool LLPreviewAnimation::render() gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); gGL.loadIdentity(); - gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); + gGL.ortho(0.0f, (F32)mFullWidth, 0.0f, (F32)mFullHeight, -1.0f, 1.0f); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); diff --git a/indra/newview/llfloaterchangeitemthumbnail.cpp b/indra/newview/llfloaterchangeitemthumbnail.cpp index 3e2e7cb7a3..fb31361fd9 100644 --- a/indra/newview/llfloaterchangeitemthumbnail.cpp +++ b/indra/newview/llfloaterchangeitemthumbnail.cpp @@ -951,8 +951,8 @@ void LLFloaterChangeItemThumbnail::onTexturePickerCommit() || texturep->getFullWidth() == 0) { if (texturep->isFullyLoaded() - && (texturep->getCachedRawImageLevel() == 0 || texturep->getRawImageLevel() == 0) - && (texturep->isCachedRawImageReady() || texturep->isRawImageValid())) + && (texturep->getRawImageLevel() == 0) + && (texturep->isRawImageValid())) { LLUUID task_id = mTaskId; uuid_set_t inventory_ids = mItemList; @@ -962,20 +962,10 @@ void LLFloaterChangeItemThumbnail::onTexturePickerCommit() { onUploadComplete(asset_id, task_id, inventory_ids, handle); }; - if (texturep->isRawImageValid()) - { - LLFloaterSimpleSnapshot::uploadThumbnail(texturep->getRawImage(), - *mItemList.begin(), - mTaskId, - callback); - } - else - { - LLFloaterSimpleSnapshot::uploadThumbnail(texturep->getCachedRawImage(), - *mItemList.begin(), - mTaskId, - callback); - } + LLFloaterSimpleSnapshot::uploadThumbnail(texturep->getRawImage(), + *mItemList.begin(), + mTaskId, + callback); } else { diff --git a/indra/newview/llfloaterconversationpreview.cpp b/indra/newview/llfloaterconversationpreview.cpp index 837aa858f5..6f5d81eda3 100644 --- a/indra/newview/llfloaterconversationpreview.cpp +++ b/indra/newview/llfloaterconversationpreview.cpp @@ -111,8 +111,8 @@ void LLFloaterConversationPreview::setPages(std::list<LLSD>* messages, const std mCurrentPage = (mMessages->size() ? (static_cast<int>(mMessages->size()) - 1) / mPageSize : 0); mPageSpinner->setEnabled(true); - mPageSpinner->setMaxValue(mCurrentPage+1); - mPageSpinner->set(mCurrentPage+1); + mPageSpinner->setMaxValue((F32)(mCurrentPage+1)); + mPageSpinner->set((F32)(mCurrentPage+1)); std::string total_page_num = llformat("/ %d", mCurrentPage+1); getChild<LLTextBox>("page_num_label")->setValue(total_page_num); diff --git a/indra/newview/llfloaterdestinations.cpp b/indra/newview/llfloaterdestinations.cpp index 93cf02e835..fad9693e8f 100644 --- a/indra/newview/llfloaterdestinations.cpp +++ b/indra/newview/llfloaterdestinations.cpp @@ -25,11 +25,6 @@ * $/LicenseInfo$ */ -/** - * Floater that appears when buying an object, giving a preview - * of its contents and their permissions. - */ - #include "llviewerprecompiledheaders.h" #include "llfloaterdestinations.h" diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index ebccb2214c..60343a4e2a 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -313,7 +313,7 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) mDayLength.value(0); if (key.has(KEY_DAY_LENGTH)) { - mDayLength.value(key[KEY_DAY_LENGTH].asReal()); + mDayLength.value(key[KEY_DAY_LENGTH].asInteger()); } // Time&Percentage labels @@ -352,7 +352,7 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key) // Adjust Time&Percentage labels' location according to length LLRect label_rect = getChild<LLTextBox>("p0", true)->getRect(); - F32 slider_width = mFramesSlider->getRect().getWidth(); + F32 slider_width = (F32)mFramesSlider->getRect().getWidth(); for (int i = 1; i < max_elm; i++) { LLTextBox *pcnt_label = getChild<LLTextBox>("p" + llformat("%d", i), true); @@ -705,7 +705,7 @@ void LLFloaterEditExtDayCycle::onAddFrame() LL_WARNS("ENVDAYEDIT") << "Attempt to add new frame while waiting for day(asset) to load." << LL_ENDL; return; } - if ((mEditDay->getSettingsNearKeyframe(frame, mCurrentTrack, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)).second) + if ((mEditDay->getSettingsNearKeyframe((LLSettingsBase::TrackPosition)frame, mCurrentTrack, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)).second) { LL_WARNS("ENVDAYEDIT") << "Attempt to add new frame too close to existing frame." << LL_ENDL; return; @@ -722,17 +722,17 @@ void LLFloaterEditExtDayCycle::onAddFrame() // scratch water should always have the current water settings. LLSettingsWater::ptr_t water(mScratchWater->buildClone()); setting = water; - mEditDay->setWaterAtKeyframe( std::static_pointer_cast<LLSettingsWater>(setting), frame); + mEditDay->setWaterAtKeyframe( std::static_pointer_cast<LLSettingsWater>(setting), (LLSettingsBase::TrackPosition)frame); } else { // scratch sky should always have the current sky settings. LLSettingsSky::ptr_t sky(mScratchSky->buildClone()); setting = sky; - mEditDay->setSkyAtKeyframe(sky, frame, mCurrentTrack); + mEditDay->setSkyAtKeyframe(sky, (LLSettingsBase::TrackPosition)frame, mCurrentTrack); } setDirtyFlag(); - addSliderFrame(frame, setting); + addSliderFrame((F32)frame, setting); updateTabs(); } @@ -1316,7 +1316,7 @@ void LLFloaterEditExtDayCycle::removeCurrentSliderFrame() { LL_DEBUGS("ENVDAYEDIT") << "Removing frame from " << iter->second.mFrame << LL_ENDL; LLSettingsBase::Seconds seconds(iter->second.mFrame); - mEditDay->removeTrackKeyframe(mCurrentTrack, seconds); + mEditDay->removeTrackKeyframe(mCurrentTrack, (LLSettingsBase::TrackPosition)seconds); mSliderKeyMap.erase(iter); } @@ -1474,17 +1474,17 @@ void LLFloaterEditExtDayCycle::reblendSettings() { if ((mSkyBlender->getTrack() != mCurrentTrack) && (mCurrentTrack != LLSettingsDay::TRACK_WATER)) { - mSkyBlender->switchTrack(mCurrentTrack, position); + mSkyBlender->switchTrack(mCurrentTrack, (LLSettingsBase::TrackPosition)position); } else { - mSkyBlender->setPosition(position); + mSkyBlender->setPosition((LLSettingsBase::TrackPosition)position); } } if (mWaterBlender) { - mWaterBlender->setPosition(position); + mWaterBlender->setPosition((LLSettingsBase::TrackPosition)position); } } @@ -1517,7 +1517,7 @@ bool LLFloaterEditExtDayCycle::isAddingFrameAllowed() if (!mFramesSlider->getCurSlider().empty() || !mEditDay) return false; LLSettingsBase::Seconds frame(mTimeSlider->getCurSliderValue()); - if ((mEditDay->getSettingsNearKeyframe(frame, mCurrentTrack, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)).second) + if ((mEditDay->getSettingsNearKeyframe((LLSettingsBase::TrackPosition)frame, mCurrentTrack, LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR)).second) { return false; } diff --git a/indra/newview/llfloateremojipicker.cpp b/indra/newview/llfloateremojipicker.cpp index d38f53eed6..30f58aaeec 100644 --- a/indra/newview/llfloateremojipicker.cpp +++ b/indra/newview/llfloateremojipicker.cpp @@ -101,7 +101,7 @@ public: LLScrollingPanel::draw(); F32 x = 4; // padding-left - F32 y = getRect().getHeight() / 2; + F32 y = (F32)(getRect().getHeight() / 2); LLFontGL::getFontSansSerif()->render( mText, // wstr 0, // begin_offset @@ -137,8 +137,8 @@ public: { LLScrollingPanel::draw(); - F32 x = getRect().getWidth() / 2; - F32 y = getRect().getHeight() / 2; + F32 x = (F32)(getRect().getWidth() / 2); + F32 y = (F32)(getRect().getHeight() / 2); LLFontGL::getFontEmojiLarge()->render( mChar, // wstr 0, // begin_offset @@ -206,7 +206,7 @@ public: static LLColor4 defaultColor(0.75f, 0.75f, 0.75f, 1.0f); LLColor4 textColor = LLUIColorTable::instance().getColor("MenuItemEnabledColor", defaultColor); S32 max_pixels = clientWidth - iconWidth; - drawName(iconWidth, centerY, max_pixels, textColor); + drawName((F32)iconWidth, centerY, max_pixels, textColor); } protected: @@ -229,7 +229,7 @@ protected: void drawName(F32 x, F32 y, S32 max_pixels, LLColor4& color) { F32 x0 = x; - F32 x1 = max_pixels; + F32 x1 = (F32)max_pixels; LLFontGL* font = LLFontGL::getFontEmojiLarge(); if (mBegin) { @@ -245,7 +245,7 @@ protected: LLFontGL::NORMAL, // style LLFontGL::DROP_SHADOW_SOFT, // shadow static_cast<S32>(text.size()), // max_chars - x1); // max_pixels + (S32)x1); // max_pixels F32 dx = font->getWidthF32(text); x0 += dx; x1 -= dx; @@ -264,7 +264,7 @@ protected: LLFontGL::NORMAL, // style LLFontGL::DROP_SHADOW_SOFT, // shadow static_cast<S32>(text.size()), // max_chars - x1); // max_pixels + (S32)x1); // max_pixels F32 dx = font->getWidthF32(text); x0 += dx; x1 -= dx; @@ -283,7 +283,7 @@ protected: LLFontGL::NORMAL, // style LLFontGL::DROP_SHADOW_SOFT, // shadow static_cast<S32>(text.size()), // max_chars - x1); // max_pixels + (S32)x1); // max_pixels } } @@ -849,8 +849,7 @@ void LLFloaterEmojiPicker::createEmojiIcon(const LLEmojiSearchResult& emoji, void LLFloaterEmojiPicker::showPreview(bool show) { - //mPreview->setIcon(nullptr); - mDummy->setVisible(show); + mDummy->setVisible(!show); mPreview->setVisible(show); } @@ -865,7 +864,7 @@ void LLFloaterEmojiPicker::onGroupButtonClick(LLUICtrl* ctrl) if (it == mGroupButtons.end()) return; - selectEmojiGroup(it - mGroupButtons.begin()); + selectEmojiGroup((U32)(it - mGroupButtons.begin())); } } diff --git a/indra/newview/llfloaterenvironmentadjust.cpp b/indra/newview/llfloaterenvironmentadjust.cpp index 32c4f6205d..3b8a25b3a6 100644 --- a/indra/newview/llfloaterenvironmentadjust.cpp +++ b/indra/newview/llfloaterenvironmentadjust.cpp @@ -292,7 +292,7 @@ void LLFloaterEnvironmentAdjust::onHazeHorizonChanged() { if (!mLiveSky) return; - mLiveSky->setHazeHorizon(getChild<LLUICtrl>(FIELD_SKY_HAZE_HORIZON)->getValue().asReal()); + mLiveSky->setHazeHorizon((F32)getChild<LLUICtrl>(FIELD_SKY_HAZE_HORIZON)->getValue().asReal()); mLiveSky->update(); } @@ -300,7 +300,7 @@ void LLFloaterEnvironmentAdjust::onHazeDensityChanged() { if (!mLiveSky) return; - mLiveSky->setHazeDensity(getChild<LLUICtrl>(FIELD_SKY_HAZE_DENSITY)->getValue().asReal()); + mLiveSky->setHazeDensity((F32)getChild<LLUICtrl>(FIELD_SKY_HAZE_DENSITY)->getValue().asReal()); mLiveSky->update(); } @@ -308,7 +308,7 @@ void LLFloaterEnvironmentAdjust::onSceneGammaChanged() { if (!mLiveSky) return; - mLiveSky->setGamma(getChild<LLUICtrl>(FIELD_SKY_SCENE_GAMMA)->getValue().asReal()); + mLiveSky->setGamma((F32)getChild<LLUICtrl>(FIELD_SKY_SCENE_GAMMA)->getValue().asReal()); mLiveSky->update(); } @@ -324,7 +324,7 @@ void LLFloaterEnvironmentAdjust::onCloudCoverageChanged() { if (!mLiveSky) return; - mLiveSky->setCloudShadow(getChild<LLUICtrl>(FIELD_SKY_CLOUD_COVERAGE)->getValue().asReal()); + mLiveSky->setCloudShadow((F32)getChild<LLUICtrl>(FIELD_SKY_CLOUD_COVERAGE)->getValue().asReal()); mLiveSky->update(); } @@ -332,7 +332,7 @@ void LLFloaterEnvironmentAdjust::onCloudScaleChanged() { if (!mLiveSky) return; - mLiveSky->setCloudScale(getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCALE)->getValue().asReal()); + mLiveSky->setCloudScale((F32)getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCALE)->getValue().asReal()); mLiveSky->update(); } @@ -340,7 +340,7 @@ void LLFloaterEnvironmentAdjust::onGlowChanged() { if (!mLiveSky) return; - LLColor3 glow(getChild<LLUICtrl>(FIELD_SKY_GLOW_SIZE)->getValue().asReal(), 0.0f, getChild<LLUICtrl>(FIELD_SKY_GLOW_FOCUS)->getValue().asReal()); + LLColor3 glow((F32)getChild<LLUICtrl>(FIELD_SKY_GLOW_SIZE)->getValue().asReal(), 0.0f, (F32)getChild<LLUICtrl>(FIELD_SKY_GLOW_FOCUS)->getValue().asReal()); // takes 0 - 1.99 UI range -> 40 -> 0.2 range glow.mV[0] = (2.0f - glow.mV[0]) * SLIDER_SCALE_GLOW_R; @@ -354,7 +354,7 @@ void LLFloaterEnvironmentAdjust::onStarBrightnessChanged() { if (!mLiveSky) return; - mLiveSky->setStarBrightness(getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->getValue().asReal()); + mLiveSky->setStarBrightness((F32)getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->getValue().asReal()); mLiveSky->update(); } @@ -375,8 +375,8 @@ void LLFloaterEnvironmentAdjust::onSunRotationChanged() void LLFloaterEnvironmentAdjust::onSunAzimElevChanged() { - F32 azimuth = getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->getValue().asReal(); - F32 elevation = getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->getValue().asReal(); + F32 azimuth = (F32)getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->getValue().asReal(); + F32 elevation = (F32)getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->getValue().asReal(); LLQuaternion quat; azimuth *= DEG_TO_RAD; @@ -405,7 +405,7 @@ void LLFloaterEnvironmentAdjust::onSunScaleChanged() { if (!mLiveSky) return; - mLiveSky->setSunScale((getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->getValue().asReal())); + mLiveSky->setSunScale((F32)(getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->getValue().asReal())); mLiveSky->update(); } @@ -426,8 +426,8 @@ void LLFloaterEnvironmentAdjust::onMoonRotationChanged() void LLFloaterEnvironmentAdjust::onMoonAzimElevChanged() { - F32 azimuth = getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->getValue().asReal(); - F32 elevation = getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->getValue().asReal(); + F32 azimuth = (F32)getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->getValue().asReal(); + F32 elevation = (F32)getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->getValue().asReal(); LLQuaternion quat; azimuth *= DEG_TO_RAD; @@ -483,7 +483,7 @@ void LLFloaterEnvironmentAdjust::onSunColorChanged() void LLFloaterEnvironmentAdjust::onReflectionProbeAmbianceChanged() { if (!mLiveSky) return; - F32 ambiance = getChild<LLUICtrl>(FIELD_REFLECTION_PROBE_AMBIANCE)->getValue().asReal(); + F32 ambiance = (F32)getChild<LLUICtrl>(FIELD_REFLECTION_PROBE_AMBIANCE)->getValue().asReal(); mLiveSky->setReflectionProbeAmbiance(ambiance); updateGammaLabel(); diff --git a/indra/newview/llfloaterfonttest.cpp b/indra/newview/llfloaterfonttest.cpp index 95d08cb9ce..d39b061d40 100644 --- a/indra/newview/llfloaterfonttest.cpp +++ b/indra/newview/llfloaterfonttest.cpp @@ -25,11 +25,6 @@ * $/LicenseInfo$ */ -/** - * Floater that appears when buying an object, giving a preview - * of its contents and their permissions. - */ - #include "llviewerprecompiledheaders.h" #include "llfloaterfonttest.h" diff --git a/indra/newview/llfloatergltfasseteditor.cpp b/indra/newview/llfloatergltfasseteditor.cpp new file mode 100644 index 0000000000..d2cf24f1dd --- /dev/null +++ b/indra/newview/llfloatergltfasseteditor.cpp @@ -0,0 +1,622 @@ +/** + * @file llfloatergltfasseteditor.cpp + * @author Andrii Kleshchev + * @brief LLFloaterGltfAssetEditor class implementation + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloatergltfasseteditor.h" + +#include "gltf/asset.h" +#include "llcallbacklist.h" +#include "llmenubutton.h" +#include "llselectmgr.h" +#include "llspinctrl.h" +#include "llviewerobject.h" + +const LLColor4U DEFAULT_WHITE(255, 255, 255); + +/// LLFloaterGLTFAssetEditor + +LLFloaterGLTFAssetEditor::LLFloaterGLTFAssetEditor(const LLSD& key) + : LLFloater(key) + , mUIColor(LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE)) +{ + setTitle("GLTF Asset Editor (WIP)"); + + mCommitCallbackRegistrar.add("PanelObject.menuDoToSelected", [this](LLUICtrl* ctrl, const LLSD& data) { onMenuDoToSelected(data); }); + mEnableCallbackRegistrar.add("PanelObject.menuEnable", [this](LLUICtrl* ctrl, const LLSD& data) { return onMenuEnableItem(data); }); +} + +LLFloaterGLTFAssetEditor::~LLFloaterGLTFAssetEditor() +{ + if (mScroller) + { + mItemListPanel->removeChild(mScroller); + delete mScroller; + mScroller = NULL; + } +} + +bool LLFloaterGLTFAssetEditor::postBuild() +{ + // Position + mMenuClipboardPos = getChild<LLMenuButton>("clipboard_pos_btn"); + mCtrlPosX = getChild<LLSpinCtrl>("Pos X", true); + mCtrlPosX->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + mCtrlPosY = getChild<LLSpinCtrl>("Pos Y", true); + mCtrlPosY->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + mCtrlPosZ = getChild<LLSpinCtrl>("Pos Z", true); + mCtrlPosZ->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + + // Scale + mMenuClipboardScale = getChild<LLMenuButton>("clipboard_size_btn"); + mCtrlScaleX = getChild<LLSpinCtrl>("Scale X", true); + mCtrlScaleX->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + mCtrlScaleY = getChild<LLSpinCtrl>("Scale Y", true); + mCtrlScaleY->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + mCtrlScaleZ = getChild<LLSpinCtrl>("Scale Z", true); + mCtrlScaleZ->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + + // Rotation + mMenuClipboardRot = getChild<LLMenuButton>("clipboard_rot_btn"); + mCtrlRotX = getChild<LLSpinCtrl>("Rot X", true); + mCtrlRotX->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + mCtrlRotY = getChild<LLSpinCtrl>("Rot Y", true); + mCtrlRotY->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + mCtrlRotZ = getChild<LLSpinCtrl>("Rot Z", true); + mCtrlPosZ->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& param) { onCommitTransform(); }); + setTransformsEnabled(false); + // todo: do multiple panels based on selected element. + mTransformsPanel = getChild<LLPanel>("transform_panel", true); + mTransformsPanel->setVisible(false); + + mItemListPanel = getChild<LLPanel>("item_list_panel", true); + initFolderRoot(); + + return true; +} + +void LLFloaterGLTFAssetEditor::initFolderRoot() +{ + if (mScroller || mFolderRoot) + { + LL_ERRS() << "Folder root already initialized" << LL_ENDL; + return; + } + + LLRect scroller_view_rect = mItemListPanel->getRect(); + scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom); + LLScrollContainer::Params scroller_params(LLUICtrlFactory::getDefaultParams<LLFolderViewScrollContainer>()); + scroller_params.rect(scroller_view_rect); + scroller_params.name("folder_scroller"); + mScroller = LLUICtrlFactory::create<LLFolderViewScrollContainer>(scroller_params); + mScroller->setFollowsAll(); + + // Insert that scroller into the panel widgets hierarchy + mItemListPanel->addChild(mScroller); + + // Create the root model + LLGLTFFolderItem* base_item = new LLGLTFFolderItem(mGLTFViewModel); + + LLFolderView::Params p(LLUICtrlFactory::getDefaultParams<LLFolderView>()); + p.name = "Root"; + p.title = "Root"; + p.rect = LLRect(0, 0, getRect().getWidth(), 0); + p.parent_panel = mItemListPanel; + p.tool_tip = p.name; + p.listener = base_item; + p.view_model = &mGLTFViewModel; + p.root = NULL; + p.use_ellipses = true; + p.options_menu = "menu_gltf.xml"; // *TODO : create this or fix to be optional + mFolderRoot = LLUICtrlFactory::create<LLFolderView>(p); + mFolderRoot->setCallbackRegistrar(&mCommitCallbackRegistrar); + mFolderRoot->setEnableRegistrar(&mEnableCallbackRegistrar); + // Attach root to the scroller + mScroller->addChild(mFolderRoot); + mFolderRoot->setScrollContainer(mScroller); + mFolderRoot->setFollowsAll(); + mFolderRoot->setOpen(true); + mFolderRoot->setSelectCallback([this](const std::deque<LLFolderViewItem*>& items, bool user_action) { onFolderSelectionChanged(items, user_action); }); + mScroller->setVisible(true); +} + +void LLFloaterGLTFAssetEditor::onOpen(const LLSD& key) +{ + gIdleCallbacks.addFunction(idle, this); + loadFromSelection(); +} + +void LLFloaterGLTFAssetEditor::onClose(bool app_quitting) +{ + gIdleCallbacks.deleteFunction(idle, this); + mAsset = nullptr; + mObject = nullptr; +} + +void LLFloaterGLTFAssetEditor::clearRoot() +{ + LLFolderViewFolder::folders_t::iterator folders_it = mFolderRoot->getFoldersBegin(); + while (folders_it != mFolderRoot->getFoldersEnd()) + { + (*folders_it)->destroyView(); + folders_it = mFolderRoot->getFoldersBegin(); + } + mNodeToItemMap.clear(); +} + +void LLFloaterGLTFAssetEditor::idle(void* user_data) +{ + LLFloaterGLTFAssetEditor* floater = (LLFloaterGLTFAssetEditor*)user_data; + + if (floater->mFolderRoot) + { + floater->mFolderRoot->update(); + } +} + +void LLFloaterGLTFAssetEditor::loadItem(S32 id, const std::string& name, LLGLTFFolderItem::EType type, LLFolderViewFolder* parent) +{ + LLGLTFFolderItem* listener = new LLGLTFFolderItem(id, name, type, mGLTFViewModel); + + LLFolderViewItem::Params params; + params.name(name); + params.creation_date(0); + params.root(mFolderRoot); + params.listener(listener); + params.rect(LLRect()); + params.tool_tip = params.name; + params.font_color = mUIColor; + params.font_highlight_color = mUIColor; + LLFolderViewItem* view = LLUICtrlFactory::create<LLFolderViewItem>(params); + + view->addToFolder(parent); + view->setVisible(true); +} + +void LLFloaterGLTFAssetEditor::loadFromNode(S32 node_id, LLFolderViewFolder* parent) +{ + if (mAsset->mNodes.size() <= node_id) + { + return; + } + + LL::GLTF::Node& node = mAsset->mNodes[node_id]; + + std::string name = node.mName; + if (node.mName.empty()) + { + name = getString("node_tittle"); + } + else + { + name = node.mName; + } + + LLGLTFFolderItem* listener = new LLGLTFFolderItem(node_id, name, LLGLTFFolderItem::TYPE_NODE, mGLTFViewModel); + + LLFolderViewFolder::Params p; + p.root = mFolderRoot; + p.listener = listener; + p.name = name; + p.tool_tip = name; + p.font_color = mUIColor; + p.font_highlight_color = mUIColor; + LLFolderViewFolder* view = LLUICtrlFactory::create<LLFolderViewFolder>(p); + + view->addToFolder(parent); + view->setVisible(true); + view->setOpen(true); + + mNodeToItemMap[node_id] = view; + + for (S32& node_id : node.mChildren) + { + loadFromNode(node_id, view); + } + + if (node.mMesh != LL::GLTF::INVALID_INDEX && mAsset->mMeshes.size() > node.mMesh) + { + std::string name = mAsset->mMeshes[node.mMesh].mName; + if (name.empty()) + { + name = getString("mesh_tittle"); + } + loadItem(node.mMesh, name, LLGLTFFolderItem::TYPE_MESH, view); + } + + if (node.mSkin != LL::GLTF::INVALID_INDEX && mAsset->mSkins.size() > node.mSkin) + { + std::string name = mAsset->mSkins[node.mSkin].mName; + if (name.empty()) + { + name = getString("skin_tittle"); + } + loadItem(node.mSkin, name, LLGLTFFolderItem::TYPE_SKIN, view); + } + + view->setChildrenInited(true); +} + +void LLFloaterGLTFAssetEditor::loadFromSelection() +{ + clearRoot(); + + if (LLSelectMgr::getInstance()->getSelection()->getObjectCount() != 1) + { + mAsset = nullptr; + mObject = nullptr; + return; + } + + LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(NULL); + LLViewerObject* objectp = node->getObject(); + if (!objectp) + { + mAsset = nullptr; + mObject = nullptr; + return; + } + + if (!objectp->mGLTFAsset) + { + mAsset = nullptr; + mObject = nullptr; + return; + } + mAsset = objectp->mGLTFAsset; + mObject = objectp; + + if (node->mName.empty()) + { + setTitle(getString("floater_title")); + } + else + { + setTitle(node->mName); + } + + LLUIColor item_color = LLUIColorTable::instance().getColor("MenuItemEnabledColor", DEFAULT_WHITE); + for (S32 i = 0; i < mAsset->mScenes.size(); i++) + { + LL::GLTF::Scene& scene = mAsset->mScenes[i]; + std::string name = scene.mName; + if (scene.mName.empty()) + { + name = getString("scene_tittle"); + } + else + { + name = scene.mName; + } + + LLGLTFFolderItem* listener = new LLGLTFFolderItem(i, name, LLGLTFFolderItem::TYPE_SCENE, mGLTFViewModel); + + LLFolderViewFolder::Params p; + p.name = name; + p.root = mFolderRoot; + p.listener = listener; + p.tool_tip = name; + p.font_color = mUIColor; + p.font_highlight_color = mUIColor; + LLFolderViewFolder* view = LLUICtrlFactory::create<LLFolderViewFolder>(p); + + view->addToFolder(mFolderRoot); + view->setVisible(true); + view->setOpen(true); + + for (S32& node_id : scene.mNodes) + { + loadFromNode(node_id, view); + } + view->setChildrenInited(true); + } + + mGLTFViewModel.requestSortAll(); + mFolderRoot->setChildrenInited(true); + mFolderRoot->arrangeAll(); + mFolderRoot->update(); +} + +void LLFloaterGLTFAssetEditor::dirty() +{ + if (!mObject || !mAsset || !mFolderRoot) + { + return; + } + + if (LLSelectMgr::getInstance()->getSelection()->getObjectCount() > 1) + { + if (getVisible()) + { + closeFloater(); + } + return; + } + + LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(NULL); + if (!node) + { + // not yet updated? + // Todo: Subscribe to deletion in some way + return; + } + + LLViewerObject* objectp = node->getObject(); + if (mObject != objectp || !objectp->mGLTFAsset) + { + if (getVisible()) + { + closeFloater(); + } + return; + } + + if (mAsset != objectp->mGLTFAsset) + { + loadFromSelection(); + return; + } + + auto found = mNodeToItemMap.find(node->mSelectedGLTFNode); + if (found != mNodeToItemMap.end()) + { + LLFolderViewItem* itemp = found->second; + itemp->arrangeAndSet(true, false); + loadNodeTransforms(node->mSelectedGLTFNode); + } +} + +void LLFloaterGLTFAssetEditor::onFolderSelectionChanged(const std::deque<LLFolderViewItem*>& items, bool user_action) +{ + if (items.empty()) + { + setTransformsEnabled(false); + return; + } + + LLFolderViewItem* item = items.front(); + LLGLTFFolderItem* vmi = static_cast<LLGLTFFolderItem*>(item->getViewModelItem()); + + switch (vmi->getType()) + { + case LLGLTFFolderItem::TYPE_SCENE: + { + setTransformsEnabled(false); + LLSelectMgr::getInstance()->selectObjectOnly(mObject, SELECT_ALL_TES, -1, -1); + break; + } + case LLGLTFFolderItem::TYPE_NODE: + { + setTransformsEnabled(true); + loadNodeTransforms(vmi->getItemId()); + LLSelectMgr::getInstance()->selectObjectOnly(mObject, SELECT_ALL_TES, vmi->getItemId(), 0); + break; + } + case LLGLTFFolderItem::TYPE_MESH: + case LLGLTFFolderItem::TYPE_SKIN: + { + if (item->getParent()) // should be a node + { + LLFolderViewFolder* parent = item->getParentFolder(); + LLGLTFFolderItem* parent_vmi = static_cast<LLGLTFFolderItem*>(parent->getViewModelItem()); + LLSelectMgr::getInstance()->selectObjectOnly(mObject, SELECT_ALL_TES, parent_vmi->getItemId(), 0); + } + + setTransformsEnabled(false); + break; + } + default: + { + setTransformsEnabled(false); + break; + } + } +} + +void LLFloaterGLTFAssetEditor::setTransformsEnabled(bool val) +{ + mMenuClipboardPos->setEnabled(val); + mCtrlPosX->setEnabled(val); + mCtrlPosY->setEnabled(val); + mCtrlPosZ->setEnabled(val); + mMenuClipboardScale->setEnabled(val); + mCtrlScaleX->setEnabled(val); + mCtrlScaleY->setEnabled(val); + mCtrlScaleZ->setEnabled(val); + mMenuClipboardRot->setEnabled(val); + mCtrlRotX->setEnabled(val); + mCtrlRotY->setEnabled(val); + mCtrlRotZ->setEnabled(val); +} + +void LLFloaterGLTFAssetEditor::loadNodeTransforms(S32 node_id) +{ + if (node_id < 0 || node_id >= mAsset->mNodes.size()) + { + LL_ERRS() << "Node id out of range: " << node_id << LL_ENDL; + return; + } + + LL::GLTF::Node& node = mAsset->mNodes[node_id]; + node.makeTRSValid(); + + mCtrlPosX->set(node.mTranslation[0]); + mCtrlPosY->set(node.mTranslation[1]); + mCtrlPosZ->set(node.mTranslation[2]); + + mCtrlScaleX->set(node.mScale[0]); + mCtrlScaleY->set(node.mScale[1]); + mCtrlScaleZ->set(node.mScale[2]); + + LLQuaternion object_rot = LLQuaternion(node.mRotation[0], node.mRotation[1], node.mRotation[2], node.mRotation[3]); + object_rot.getEulerAngles(&(mLastEulerDegrees.mV[VX]), &(mLastEulerDegrees.mV[VY]), &(mLastEulerDegrees.mV[VZ])); + mLastEulerDegrees *= RAD_TO_DEG; + mLastEulerDegrees.mV[VX] = fmod(ll_round(mLastEulerDegrees.mV[VX], OBJECT_ROTATION_PRECISION) + 360.f, 360.f); + mLastEulerDegrees.mV[VY] = fmod(ll_round(mLastEulerDegrees.mV[VY], OBJECT_ROTATION_PRECISION) + 360.f, 360.f); + mLastEulerDegrees.mV[VZ] = fmod(ll_round(mLastEulerDegrees.mV[VZ], OBJECT_ROTATION_PRECISION) + 360.f, 360.f); + + mCtrlRotX->set(mLastEulerDegrees.mV[VX]); + mCtrlRotY->set(mLastEulerDegrees.mV[VY]); + mCtrlRotZ->set(mLastEulerDegrees.mV[VZ]); +} + +void LLFloaterGLTFAssetEditor::onCommitTransform() +{ + if (!mFolderRoot) + { + LL_ERRS() << "Folder root not initialized" << LL_ENDL; + return; + } + + LLFolderViewItem* item = mFolderRoot->getCurSelectedItem(); + if (!item) + { + LL_ERRS() << "Nothing selected" << LL_ENDL; + return; + } + + LLGLTFFolderItem* vmi = static_cast<LLGLTFFolderItem*>(item->getViewModelItem()); + + if (!vmi || vmi->getType() != LLGLTFFolderItem::TYPE_NODE) + { + LL_ERRS() << "Only nodes implemented" << LL_ENDL; + return; + } + S32 node_id = vmi->getItemId(); + LL::GLTF::Node& node = mAsset->mNodes[node_id]; + + LL::GLTF::vec3 tr(mCtrlPosX->get(), mCtrlPosY->get(), mCtrlPosZ->get()); + node.setTranslation(tr); + + LL::GLTF::vec3 scale(mCtrlScaleX->get(), mCtrlScaleY->get(), mCtrlScaleZ->get()); + node.setScale(scale); + + LLVector3 new_rot(mCtrlRotX->get(), mCtrlRotY->get(), mCtrlRotZ->get()); + new_rot.mV[VX] = ll_round(new_rot.mV[VX], OBJECT_ROTATION_PRECISION); + new_rot.mV[VY] = ll_round(new_rot.mV[VY], OBJECT_ROTATION_PRECISION); + new_rot.mV[VZ] = ll_round(new_rot.mV[VZ], OBJECT_ROTATION_PRECISION); + + // Note: must compare before conversion to radians, some value can go 'around' 360 + LLVector3 delta = new_rot - mLastEulerDegrees; + + if (delta.magVec() >= 0.0005f) + { + mLastEulerDegrees = new_rot; + new_rot *= DEG_TO_RAD; + + LLQuaternion rotation; + rotation.setQuat(new_rot.mV[VX], new_rot.mV[VY], new_rot.mV[VZ]); + LL::GLTF::quat q; + q[0] = rotation.mQ[VX]; + q[1] = rotation.mQ[VY]; + q[2] = rotation.mQ[VZ]; + q[3] = rotation.mQ[VW]; + + node.setRotation(q); + } + + mAsset->updateTransforms(); +} + +void LLFloaterGLTFAssetEditor::onMenuDoToSelected(const LLSD& userdata) +{ + std::string command = userdata.asString(); + + if (command == "psr_paste") + { + // todo: implement + // onPastePos(); + // onPasteSize(); + // onPasteRot(); + } + else if (command == "pos_paste") + { + // todo: implement + } + else if (command == "size_paste") + { + // todo: implement + } + else if (command == "rot_paste") + { + // todo: implement + } + else if (command == "psr_copy") + { + // onCopyPos(); + // onCopySize(); + // onCopyRot(); + } + else if (command == "pos_copy") + { + // todo: implement + } + else if (command == "size_copy") + { + // todo: implement + } + else if (command == "rot_copy") + { + // todo: implement + } +} + +bool LLFloaterGLTFAssetEditor::onMenuEnableItem(const LLSD& userdata) +{ + if (!mFolderRoot) + { + return false; + } + + LLFolderViewItem* item = mFolderRoot->getCurSelectedItem(); + if (!item) + { + return false; + } + + LLGLTFFolderItem* vmi = static_cast<LLGLTFFolderItem*>(item->getViewModelItem()); + + if (!vmi || vmi->getType() != LLGLTFFolderItem::TYPE_NODE) + { + return false; + } + + std::string command = userdata.asString(); + if (command == "pos_paste" || command == "size_paste" || command == "rot_paste") + { + // todo: implement + return true; + } + if (command == "psr_copy") + { + // todo: implement + return true; + } + + return false; +} + diff --git a/indra/newview/llfloatergltfasseteditor.h b/indra/newview/llfloatergltfasseteditor.h new file mode 100644 index 0000000000..b0ba8941b9 --- /dev/null +++ b/indra/newview/llfloatergltfasseteditor.h @@ -0,0 +1,109 @@ +/** + * @file llfloatergltfasseteditor.h + * @author Andrii Kleshchev + * @brief LLFloaterGltfAssetEditor header file + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATERGLTFASSETEDITOR_H +#define LL_LLFLOATERGLTFASSETEDITOR_H + +#include "llfloater.h" + +#include "llgltffoldermodel.h" + +namespace LL +{ + namespace GLTF + { + class Asset; + } +} + +class LLSpinCtrl; +class LLMenuButton; +class LLViewerObject; + +class LLFloaterGLTFAssetEditor : public LLFloater +{ +public: + LLFloaterGLTFAssetEditor(const LLSD& key); + ~LLFloaterGLTFAssetEditor(); + + bool postBuild() override; + void onOpen(const LLSD& key) override; + void onClose(bool app_quitting) override; + void initFolderRoot(); + + LLGLTFViewModel& getRootViewModel() { return mGLTFViewModel; } + + static void idle(void* user_data); + void loadItem(S32 id, const std::string& name, LLGLTFFolderItem::EType type, LLFolderViewFolder* parent); + void loadFromNode(S32 node, LLFolderViewFolder* parent); + void loadFromSelection(); + + void dirty(); + +protected: + void onFolderSelectionChanged(const std::deque<LLFolderViewItem*>& items, bool user_action); + void onCommitTransform(); + void onMenuDoToSelected(const LLSD& userdata); + bool onMenuEnableItem(const LLSD& userdata); + + void setTransformsEnabled(bool val); + void loadNodeTransforms(S32 id); + + void clearRoot(); + +private: + + LLPointer<LLViewerObject> mObject; + std::shared_ptr<LL::GLTF::Asset> mAsset; + + // Folder view related + LLUIColor mUIColor; + LLGLTFViewModel mGLTFViewModel; + LLPanel* mItemListPanel = nullptr; + LLFolderView* mFolderRoot = nullptr; + LLScrollContainer* mScroller = nullptr; + std::map<S32, LLFolderViewItem*> mNodeToItemMap; + + // Transforms panel + LLVector3 mLastEulerDegrees; + + LLPanel* mTransformsPanel = nullptr; + LLMenuButton* mMenuClipboardPos = nullptr; + LLSpinCtrl* mCtrlPosX = nullptr; + LLSpinCtrl* mCtrlPosY = nullptr; + LLSpinCtrl* mCtrlPosZ = nullptr; + LLMenuButton* mMenuClipboardScale = nullptr; + LLSpinCtrl* mCtrlScaleX = nullptr; + LLSpinCtrl* mCtrlScaleY = nullptr; + LLSpinCtrl* mCtrlScaleZ = nullptr; + LLMenuButton* mMenuClipboardRot = nullptr; + LLSpinCtrl* mCtrlRotX = nullptr; + LLSpinCtrl* mCtrlRotY = nullptr; + LLSpinCtrl* mCtrlRotZ = nullptr; +}; + +#endif diff --git a/indra/newview/llfloaterimagepreview.cpp b/indra/newview/llfloaterimagepreview.cpp index ea49c88755..a900e04707 100644 --- a/indra/newview/llfloaterimagepreview.cpp +++ b/indra/newview/llfloaterimagepreview.cpp @@ -671,7 +671,7 @@ bool LLImagePreviewAvatar::render() gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); gGL.loadIdentity(); - gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); + gGL.ortho(0.0f, (F32)mFullWidth, 0.0f, (F32)mFullHeight, -1.0f, 1.0f); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); @@ -875,7 +875,7 @@ bool LLImagePreviewSculpted::render() gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); gGL.loadIdentity(); - gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); + gGL.ortho(0.0f, (F32)mFullWidth, 0.0f, (F32)mFullHeight, -1.0f, 1.0f); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp index add389748f..08e13276b3 100644 --- a/indra/newview/llfloaterimcontainer.cpp +++ b/indra/newview/llfloaterimcontainer.cpp @@ -988,11 +988,14 @@ void LLFloaterIMContainer::onAddButtonClicked() { LLView * button = findChild<LLView>("conversations_pane_buttons_expanded")->findChild<LLButton>("add_btn"); LLFloater* root_floater = gFloaterView->getParentFloater(this); - LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show(boost::bind(&LLFloaterIMContainer::onAvatarPicked, this, _1), true, true, true, root_floater->getName(), button); - - if (picker && root_floater) + if (button && root_floater) { - root_floater->addDependentFloater(picker); + LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show(boost::bind(&LLFloaterIMContainer::onAvatarPicked, this, _1), true, true, true, root_floater->getName(), button); + + if (picker) + { + root_floater->addDependentFloater(picker); + } } } diff --git a/indra/newview/llfloaterimnearbychathandler.cpp b/indra/newview/llfloaterimnearbychathandler.cpp index ef7ec9e950..5cf02d1ec0 100644 --- a/indra/newview/llfloaterimnearbychathandler.cpp +++ b/indra/newview/llfloaterimnearbychathandler.cpp @@ -263,8 +263,8 @@ bool LLFloaterIMNearbyChatScreenChannel::createPoolToast() LLToast::Params p; p.panel = panel; - p.lifetime_secs = gSavedSettings.getS32("NearbyToastLifeTime"); - p.fading_time_secs = gSavedSettings.getS32("NearbyToastFadingTime"); + p.lifetime_secs = (F32)gSavedSettings.getS32("NearbyToastLifeTime"); + p.fading_time_secs = (F32)gSavedSettings.getS32("NearbyToastFadingTime"); LLToast* toast = new LLFloaterIMNearbyChatToast(p, this); @@ -643,8 +643,18 @@ void LLFloaterIMNearbyChatHandler::processChat(const LLChat& chat_msg, } } + std::string user_preferences; + if (chat_msg.mSourceType == CHAT_SOURCE_OBJECT) + { + user_preferences = gSavedSettings.getString("NotificationObjectIMOptions"); + } + else + { + user_preferences = gSavedSettings.getString("NotificationNearbyChatOptions"); + } + //Will show toast when chat preference is set - if((gSavedSettings.getString("NotificationNearbyChatOptions") == "toast") || !nearby_chat->isMessagePaneExpanded()) + if((user_preferences == "toast") || !nearby_chat->isMessagePaneExpanded()) { // Add a nearby chat toast. LLUUID id; diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 9a794d1775..41b6025e0f 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -1706,7 +1706,7 @@ void LLPanelLandObjects::processParcelObjectOwnersReply(LLMessageSystem *msg, vo object_count_str = llformat("%d", object_count); item_params.columns.add().value(object_count_str).font(FONT).column("count"); - item_params.columns.add().value(LLDate((time_t)most_recent_time)).font(FONT).column("mostrecent").type("date"); + item_params.columns.add().value(LLDate((double)most_recent_time)).font(FONT).column("mostrecent").type("date"); self->mOwnerList->addNameItemRow(item_params); LL_DEBUGS() << "object owner " << owner_id << " (" << (is_group_owned ? "group" : "agent") @@ -2527,7 +2527,7 @@ void LLPanelLandAccess::refresh() if (entry.mTime != 0) { LLStringUtil::format_map_t args; - S32 now = time(NULL); + S32 now = (S32)time(NULL); S32 seconds = entry.mTime - now; if (seconds < 0) seconds = 0; prefix.assign(" ("); @@ -2576,7 +2576,7 @@ void LLPanelLandAccess::refresh() if (entry.mTime != 0) { LLStringUtil::format_map_t args; - S32 now = time(NULL); + S32 now = (S32)time(NULL); seconds = entry.mTime - now; if (seconds < 0) seconds = 0; diff --git a/indra/newview/llfloatermemleak.cpp b/indra/newview/llfloatermemleak.cpp index cd5bea1be4..b4bb45c864 100644 --- a/indra/newview/llfloatermemleak.cpp +++ b/indra/newview/llfloatermemleak.cpp @@ -60,7 +60,7 @@ LLFloaterMemLeak::LLFloaterMemLeak(const LLSD& key) bool LLFloaterMemLeak::postBuild(void) { F32 a, b ; - a = getChild<LLUICtrl>("leak_speed")->getValue().asReal(); + a = (F32)getChild<LLUICtrl>("leak_speed")->getValue().asReal(); if(a > (F32)(0xFFFFFFFF)) { sMemLeakingSpeed = 0xFFFFFFFF ; @@ -69,7 +69,7 @@ bool LLFloaterMemLeak::postBuild(void) { sMemLeakingSpeed = (U32)a ; } - b = getChild<LLUICtrl>("max_leak")->getValue().asReal(); + b = (F32)getChild<LLUICtrl>("max_leak")->getValue().asReal(); if(b > (F32)0xFFF) { sMaxLeakedMem = 0xFFFFFFFF ; @@ -150,8 +150,7 @@ void LLFloaterMemLeak::idle() //---------------------- void LLFloaterMemLeak::onChangeLeakingSpeed() { - F32 tmp ; - tmp =getChild<LLUICtrl>("leak_speed")->getValue().asReal(); + F32 tmp = (F32)getChild<LLUICtrl>("leak_speed")->getValue().asReal(); if(tmp > (F32)0xFFFFFFFF) { @@ -161,14 +160,11 @@ void LLFloaterMemLeak::onChangeLeakingSpeed() { sMemLeakingSpeed = (U32)tmp ; } - } void LLFloaterMemLeak::onChangeMaxMemLeaking() { - - F32 tmp ; - tmp =getChild<LLUICtrl>("max_leak")->getValue().asReal(); + F32 tmp = (F32)getChild<LLUICtrl>("max_leak")->getValue().asReal(); if(tmp > (F32)0xFFF) { sMaxLeakedMem = 0xFFFFFFFF ; @@ -177,7 +173,6 @@ void LLFloaterMemLeak::onChangeMaxMemLeaking() { sMaxLeakedMem = ((U32)tmp) << 20 ; } - } void LLFloaterMemLeak::onClickStart() diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index a91cdba5c0..5ca727cf66 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -1198,7 +1198,7 @@ void LLFloaterModelPreview::initDecompControls() else if (LLSpinCtrl* spinner = dynamic_cast<LLSpinCtrl*>(ctrl)) { bool is_retain_ctrl = "Retain%" == name; - double coefficient = is_retain_ctrl ? RETAIN_COEFFICIENT : 1.f; + float coefficient = is_retain_ctrl ? (F32)RETAIN_COEFFICIENT : 1.f; spinner->setMinValue(param[i].mDetails.mRange.mLow.mFloat * coefficient); spinner->setMaxValue(param[i].mDetails.mRange.mHigh.mFloat * coefficient); @@ -1238,10 +1238,10 @@ void LLFloaterModelPreview::initDecompControls() LLUICtrl* ctrl = getChild<LLUICtrl>(name); if (LLSliderCtrl* slider = dynamic_cast<LLSliderCtrl*>(ctrl)) { - slider->setMinValue(param[i].mDetails.mRange.mLow.mIntOrEnumValue); - slider->setMaxValue(param[i].mDetails.mRange.mHigh.mIntOrEnumValue); - slider->setIncrement(param[i].mDetails.mRange.mDelta.mIntOrEnumValue); - slider->setValue(param[i].mDefault.mIntOrEnumValue); + slider->setMinValue((F32)param[i].mDetails.mRange.mLow.mIntOrEnumValue); + slider->setMaxValue((F32)param[i].mDetails.mRange.mHigh.mIntOrEnumValue); + slider->setIncrement((F32)param[i].mDetails.mRange.mDelta.mIntOrEnumValue); + slider->setValue((F32)param[i].mDefault.mIntOrEnumValue); slider->setCommitCallback(onPhysicsParamCommit, (void*) ¶m[i]); } else if (LLComboBox* combo_box = dynamic_cast<LLComboBox*>(ctrl)) diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 85a07f23a4..5e5cfcecbf 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1101,7 +1101,7 @@ void LLFloaterPreference::onNameTagOpacityChange(const LLSD& newvalue) if (color_swatch) { LLColor4 new_color = color_swatch->get(); - color_swatch->set( new_color.setAlpha(newvalue.asReal()) ); + color_swatch->set(new_color.setAlpha((F32)newvalue.asReal())); } } @@ -1910,7 +1910,7 @@ void LLFloaterPreference::setCacheLocation(const LLStringExplicit& location) void LLFloaterPreference::selectPanel(const LLSD& name) { LLTabContainer * tab_containerp = getChild<LLTabContainer>("pref core"); - LLPanel * panel = tab_containerp->getPanelByName(name); + LLPanel * panel = tab_containerp->getPanelByName(name.asStringRef()); if (NULL != panel) { tab_containerp->selectTabPanel(panel); diff --git a/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp b/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp index 082a77d741..d66c303c65 100644 --- a/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp +++ b/indra/newview/llfloaterpreferencesgraphicsadvanced.cpp @@ -270,8 +270,6 @@ void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings() { LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections"); LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText"); - LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram"); - LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth"); LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders"); LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders"); LLComboBox* ctrl_shadows = getChild<LLComboBox>("ShadowDetail"); @@ -336,45 +334,6 @@ void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings() ctrl_shadows->setValue(0); shadows_text->setEnabled(false); } - - // disabled reflections - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail")) - { - ctrl_reflections->setEnabled(false); - ctrl_reflections->setValue(false); - reflections_text->setEnabled(false); - } - - // disabled av - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP")) - { - ctrl_avatar_vp->setEnabled(false); - ctrl_avatar_vp->setValue(false); - - ctrl_avatar_cloth->setEnabled(false); - ctrl_avatar_cloth->setValue(false); - - //deferred needs AvatarVP, disable deferred - ctrl_shadows->setEnabled(false); - ctrl_shadows->setValue(0); - shadows_text->setEnabled(false); - - ctrl_ssao->setEnabled(false); - ctrl_ssao->setValue(false); - - ctrl_dof->setEnabled(false); - ctrl_dof->setValue(false); - - ctrl_deferred->setEnabled(false); - ctrl_deferred->setValue(false); - } - - // disabled cloth - if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarCloth")) - { - ctrl_avatar_cloth->setEnabled(false); - ctrl_avatar_cloth->setValue(false); - } } void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() @@ -392,23 +351,6 @@ void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() bool bumpshiny = LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump"); bumpshiny_ctrl->setEnabled(bumpshiny); - // Avatar Mode - // Enable Avatar Shaders - LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram"); - // Avatar Render Mode - LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth"); - - bool avatar_vp_enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP"); - if (LLViewerShaderMgr::sInitialized) - { - S32 max_avatar_shader = LLViewerShaderMgr::instance()->mMaxAvatarShaderLevel; - avatar_vp_enabled = max_avatar_shader > 0; - } - - ctrl_avatar_vp->setEnabled(avatar_vp_enabled); - - ctrl_avatar_cloth->setEnabled(gSavedSettings.getBOOL("RenderAvatarVP")); - // Vertex Shaders, Global Shader Enable // SL-12594 Basic shaders are always enabled. DJH TODO clean up now-orphaned state handling code LLSliderCtrl* terrain_detail = getChild<LLSliderCtrl>("TerrainDetail"); // can be linked with control var diff --git a/indra/newview/llfloaterprofiletexture.cpp b/indra/newview/llfloaterprofiletexture.cpp index 47b3aa015b..8cb941cb12 100644 --- a/indra/newview/llfloaterprofiletexture.cpp +++ b/indra/newview/llfloaterprofiletexture.cpp @@ -244,8 +244,8 @@ void LLFloaterProfileTexture::updateDimensions() if (biggest_dim > MAX_DIMENTIONS) { F32 scale_down = MAX_DIMENTIONS / (F32)biggest_dim; - width *= scale_down; - height *= scale_down; + width = (S32)(width * scale_down); + height = (S32)(height * scale_down); } //reshape floater diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 8807509a2e..52eddcfc67 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -519,7 +519,7 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) panel->getChild<LLUICtrl>("object_bonus_spin")->setValue(LLSD(object_bonus_factor)); panel->getChild<LLUICtrl>("access_combo")->setValue(LLSD(sim_access)); - panel->getChild<LLSpinCtrl>("agent_limit_spin")->setMaxValue(hard_agent_limit); + panel->getChild<LLSpinCtrl>("agent_limit_spin")->setMaxValue((F32)hard_agent_limit); LLPanelRegionGeneralInfo* panel_general = LLFloaterRegionInfo::getPanelGeneral(); if (panel) @@ -1561,7 +1561,7 @@ bool LLPanelRegionTerrainInfo::postBuild() { mTextureDetailCtrl[i]->setBakeTextureEnabled(false); } - initAndSetCtrl(mMaterialDetailCtrl[i], llformat("material_detail_%d", i)); + initMaterialCtrl(mMaterialDetailCtrl[i], llformat("material_detail_%d", i), i); initAndSetCtrl(mMaterialScaleUCtrl[i], llformat("terrain%dScaleU", i)); initAndSetCtrl(mMaterialScaleVCtrl[i], llformat("terrain%dScaleV", i)); @@ -1931,11 +1931,11 @@ bool LLPanelRegionTerrainInfo::sendUpdate() for (U32 tt = 0; tt < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++tt) { LLGLTFMaterial::TextureTransform& transform = mat_override->mTextureTransform[tt]; - transform.mScale.mV[VX] = mMaterialScaleUCtrl[i]->getValue().asReal(); - transform.mScale.mV[VY] = mMaterialScaleVCtrl[i]->getValue().asReal(); - transform.mRotation = mMaterialRotationCtrl[i]->getValue().asReal() * DEG_TO_RAD; - transform.mOffset.mV[VX] = mMaterialOffsetUCtrl[i]->getValue().asReal(); - transform.mOffset.mV[VY] = mMaterialOffsetVCtrl[i]->getValue().asReal(); + transform.mScale.mV[VX] = (F32)mMaterialScaleUCtrl[i]->getValue().asReal(); + transform.mScale.mV[VY] = (F32)mMaterialScaleVCtrl[i]->getValue().asReal(); + transform.mRotation = (F32)mMaterialRotationCtrl[i]->getValue().asReal() * DEG_TO_RAD; + transform.mOffset.mV[VX] = (F32)mMaterialOffsetUCtrl[i]->getValue().asReal(); + transform.mOffset.mV[VY] = (F32)mMaterialOffsetVCtrl[i]->getValue().asReal(); } } @@ -1958,6 +1958,31 @@ bool LLPanelRegionTerrainInfo::sendUpdate() return true; } +void LLPanelRegionTerrainInfo::initMaterialCtrl(LLTextureCtrl*& ctrl, const std::string& name, S32 index) +{ + ctrl = findChild<LLTextureCtrl>(name, true); + if (!ctrl) return; + + // consume cancel events, otherwise they will trigger commit callbacks + ctrl->setOnCancelCallback([](LLUICtrl* ctrl, const LLSD& param) {}); + ctrl->setCommitCallback( + [this, index](LLUICtrl* ctrl, const LLSD& param) + { + if (!mMaterialScaleUCtrl[index] + || !mMaterialScaleVCtrl[index] + || !mMaterialRotationCtrl[index] + || !mMaterialOffsetUCtrl[index] + || !mMaterialOffsetVCtrl[index]) return; + + mMaterialScaleUCtrl[index]->setValue(1.f); + mMaterialScaleVCtrl[index]->setValue(1.f); + mMaterialRotationCtrl[index]->setValue(0.f); + mMaterialOffsetUCtrl[index]->setValue(0.f); + mMaterialOffsetVCtrl[index]->setValue(0.f); + onChangeAnything(); + }); +} + bool LLPanelRegionTerrainInfo::callbackTextureHeights(const LLSD& notification, const LLSD& response) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 5623bc20cb..60564435d7 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -273,6 +273,8 @@ public: protected: bool sendUpdate() override; + void initMaterialCtrl(LLTextureCtrl*& ctrl, const std::string& name, S32 index); + private: bool mConfirmedTextureHeights; bool mAskedTextureHeights; diff --git a/indra/newview/llfloatersettingsdebug.cpp b/indra/newview/llfloatersettingsdebug.cpp index 17707e808e..525317304d 100644 --- a/indra/newview/llfloatersettingsdebug.cpp +++ b/indra/newview/llfloatersettingsdebug.cpp @@ -131,10 +131,10 @@ void LLFloaterSettingsDebug::onCommitSettings() controlp->set(vectord.getValue()); break; case TYPE_QUAT: - quat.mQ[VX] = getChild<LLUICtrl>("val_spinner_1")->getValue().asReal(); - quat.mQ[VY] = getChild<LLUICtrl>("val_spinner_2")->getValue().asReal(); - quat.mQ[VZ] = getChild<LLUICtrl>("val_spinner_3")->getValue().asReal(); - quat.mQ[VS] = getChild<LLUICtrl>("val_spinner_4")->getValue().asReal();; + quat.mQ[VX] = (F32)getChild<LLUICtrl>("val_spinner_1")->getValue().asReal(); + quat.mQ[VY] = (F32)getChild<LLUICtrl>("val_spinner_2")->getValue().asReal(); + quat.mQ[VZ] = (F32)getChild<LLUICtrl>("val_spinner_3")->getValue().asReal(); + quat.mQ[VS] = (F32)getChild<LLUICtrl>("val_spinner_4")->getValue().asReal();; controlp->set(quat.getValue()); break; case TYPE_RECT: diff --git a/indra/newview/llfloatersidepanelcontainer.cpp b/indra/newview/llfloatersidepanelcontainer.cpp index 2f6d14d6b5..6c5d2570f2 100644 --- a/indra/newview/llfloatersidepanelcontainer.cpp +++ b/indra/newview/llfloatersidepanelcontainer.cpp @@ -28,6 +28,7 @@ #include "llfloaterreg.h" #include "llfloatersidepanelcontainer.h" +#include "llnotificationsutil.h" #include "llpaneleditwearable.h" // newview includes @@ -90,6 +91,46 @@ void LLFloaterSidePanelContainer::closeFloater(bool app_quitting) } } +void LLFloaterSidePanelContainer::onClickCloseBtn(bool app_quitting) +{ + if (!app_quitting) + { + LLPanelOutfitEdit* panel_outfit_edit = + dynamic_cast<LLPanelOutfitEdit*>(LLFloaterSidePanelContainer::findPanel("appearance", "panel_outfit_edit")); + if (panel_outfit_edit) + { + LLFloater* parent = gFloaterView->getParentFloater(panel_outfit_edit); + if (parent == this) + { + LLSidepanelAppearance* panel_appearance = dynamic_cast<LLSidepanelAppearance*>(getPanel("appearance")); + if (panel_appearance) + { + LLPanelEditWearable* edit_wearable_ptr = panel_appearance->getWearable(); + if (edit_wearable_ptr && edit_wearable_ptr->getVisible() && edit_wearable_ptr->isDirty()) + { + LLNotificationsUtil::add("UsavedWearableChanges", LLSD(), LLSD(), [this](const LLSD& notification, const LLSD& response) + { + onCloseMsgCallback(notification, response); + }); + return; + } + } + } + } + } + + closeFloater(); +} + +void LLFloaterSidePanelContainer::onCloseMsgCallback(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (0 == option) + { + closeFloater(); + } +} + LLFloater* LLFloaterSidePanelContainer::getTopmostInventoryFloater() { LLFloater* topmost_floater = NULL; @@ -113,7 +154,7 @@ LLFloater* LLFloaterSidePanelContainer::getTopmostInventoryFloater() return topmost_floater; } -LLPanel* LLFloaterSidePanelContainer::openChildPanel(const std::string& panel_name, const LLSD& params) +LLPanel* LLFloaterSidePanelContainer::openChildPanel(std::string_view panel_name, const LLSD& params) { LLView* view = findChildView(panel_name, true); if (!view) @@ -144,7 +185,7 @@ LLPanel* LLFloaterSidePanelContainer::openChildPanel(const std::string& panel_na return panel; } -void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const LLSD& key) +void LLFloaterSidePanelContainer::showPanel(std::string_view floater_name, const LLSD& key) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name); if (floaterp) @@ -153,7 +194,7 @@ void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, con } } -void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key) +void LLFloaterSidePanelContainer::showPanel(std::string_view floater_name, std::string_view panel_name, const LLSD& key) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name); if (floaterp) @@ -162,7 +203,7 @@ void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, con } } -LLPanel* LLFloaterSidePanelContainer::getPanel(const std::string& floater_name, const std::string& panel_name) +LLPanel* LLFloaterSidePanelContainer::getPanel(std::string_view floater_name, std::string_view panel_name) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name); @@ -174,7 +215,7 @@ LLPanel* LLFloaterSidePanelContainer::getPanel(const std::string& floater_name, return NULL; } -LLPanel* LLFloaterSidePanelContainer::findPanel(const std::string& floater_name, const std::string& panel_name) +LLPanel* LLFloaterSidePanelContainer::findPanel(std::string_view floater_name, std::string_view panel_name) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::findTypedInstance<LLFloaterSidePanelContainer>(floater_name); diff --git a/indra/newview/llfloatersidepanelcontainer.h b/indra/newview/llfloatersidepanelcontainer.h index d5d0c43cae..d7f6c309c4 100644 --- a/indra/newview/llfloatersidepanelcontainer.h +++ b/indra/newview/llfloatersidepanelcontainer.h @@ -49,23 +49,25 @@ public: LLFloaterSidePanelContainer(const LLSD& key, const Params& params = getDefaultParams()); ~LLFloaterSidePanelContainer(); - /*virtual*/ void onOpen(const LLSD& key); + void onOpen(const LLSD& key) override; - /*virtual*/ void closeFloater(bool app_quitting = false); + void closeFloater(bool app_quitting = false) override; + + void onClickCloseBtn(bool app_qutting) override; void cleanup() { destroy(); } - LLPanel* openChildPanel(const std::string& panel_name, const LLSD& params); + LLPanel* openChildPanel(std::string_view panel_name, const LLSD& params); static LLFloater* getTopmostInventoryFloater(); - static void showPanel(const std::string& floater_name, const LLSD& key); + static void showPanel(std::string_view floater_name, const LLSD& key); - static void showPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key); + static void showPanel(std::string_view floater_name, std::string_view panel_name, const LLSD& key); - static LLPanel* getPanel(const std::string& floater_name, const std::string& panel_name = sMainPanelName); + static LLPanel* getPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName); - static LLPanel* findPanel(const std::string& floater_name, const std::string& panel_name = sMainPanelName); + static LLPanel* findPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName); /** * Gets the panel of given type T (doesn't show it or do anything else with it). @@ -75,7 +77,7 @@ public: * @returns a pointer to the panel of given type T. */ template <typename T> - static T* getPanel(const std::string& floater_name, const std::string& panel_name = sMainPanelName) + static T* getPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName) { T* panel = dynamic_cast<T*>(getPanel(floater_name, panel_name)); if (!panel) @@ -84,6 +86,9 @@ public: } return panel; } + +protected: + void onCloseMsgCallback(const LLSD& notification, const LLSD& response); }; #endif // LL_LLFLOATERSIDEPANELCONTAINER_H diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 2bac7d6360..e03b11e572 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -46,12 +46,12 @@ ///---------------------------------------------------------------------------- /// Local function declarations, constants, enums, and typedefs ///---------------------------------------------------------------------------- -LLSnapshotFloaterView* gSnapshotFloaterView = NULL; +LLSnapshotFloaterView* gSnapshotFloaterView = nullptr; -const F32 AUTO_SNAPSHOT_TIME_DELAY = 1.f; +constexpr F32 AUTO_SNAPSHOT_TIME_DELAY = 1.f; -const S32 MAX_POSTCARD_DATASIZE = 1572864; // 1.5 megabyte, similar to simulator limit -const S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512 +constexpr S32 MAX_POSTCARD_DATASIZE = 1572864; // 1.5 megabyte, similar to simulator limit +constexpr S32 MAX_TEXTURE_SIZE = 2048 ; //max upload texture size 2048 * 2048 static LLDefaultChildRegistry::Register<LLSnapshotFloaterView> r("snapshot_floater_view"); @@ -168,10 +168,10 @@ void LLFloaterSnapshotBase::ImplBase::updateLayout(LLFloaterSnapshotBase* floate panel_width = 700.f; } - S32 floater_width = 224.f; + S32 floater_width{ 224 }; if(mAdvanced) { - floater_width = floater_width + panel_width; + floater_width = floater_width + (S32)panel_width; } LLUICtrl* thumbnail_placeholder = floaterp->getChild<LLUICtrl>("thumbnail_placeholder"); @@ -185,7 +185,7 @@ void LLFloaterSnapshotBase::ImplBase::updateLayout(LLFloaterSnapshotBase* floate } if (!mSkipReshaping) { - thumbnail_placeholder->reshape(panel_width, thumbnail_placeholder->getRect().getHeight()); + thumbnail_placeholder->reshape((S32)panel_width, thumbnail_placeholder->getRect().getHeight()); if (!floaterp->isMinimized()) { floaterp->reshape(floater_width, floaterp->getRect().getHeight()); @@ -283,7 +283,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshotBase* floater) width_ctrl->setValue(w); if (getActiveSnapshotType(floater) == LLSnapshotModel::SNAPSHOT_TEXTURE) { - width_ctrl->setIncrement(w >> 1); + width_ctrl->setIncrement((F32)(w >> 1)); } } if (height_ctrl->getValue().asInteger() == 0) @@ -293,7 +293,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshotBase* floater) height_ctrl->setValue(h); if (getActiveSnapshotType(floater) == LLSnapshotModel::SNAPSHOT_TEXTURE) { - height_ctrl->setIncrement(h >> 1); + height_ctrl->setIncrement((F32)(h >> 1)); } } @@ -303,9 +303,9 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshotBase* floater) S32 width = gViewerWindow->getWindowWidthRaw(); S32 height = gViewerWindow->getWindowHeightRaw(); - width_ctrl->setMaxValue(width); + width_ctrl->setMaxValue((F32)width); - height_ctrl->setMaxValue(height); + height_ctrl->setMaxValue((F32)height); if (width_ctrl->getValue().asInteger() > width) { @@ -761,8 +761,8 @@ void LLFloaterSnapshot::Impl::updateResolution(LLUICtrl* ctrl, void* data, bool getHeightSpinner(view)->setValue(height); if (getActiveSnapshotType(view) == LLSnapshotModel::SNAPSHOT_TEXTURE) { - getWidthSpinner(view)->setIncrement(width >> 1); - getHeightSpinner(view)->setIncrement(height >> 1); + getWidthSpinner(view)->setIncrement((F32)(width >> 1)); + getHeightSpinner(view)->setIncrement((F32)(height >> 1)); } } @@ -882,8 +882,8 @@ void LLFloaterSnapshot::Impl::setImageSizeSpinnersValues(LLFloaterSnapshotBase* getHeightSpinner(view)->forceSetValue(height); if (getActiveSnapshotType(view) == LLSnapshotModel::SNAPSHOT_TEXTURE) { - getWidthSpinner(view)->setIncrement(width >> 1); - getHeightSpinner(view)->setIncrement(height >> 1); + getWidthSpinner(view)->setIncrement((F32)(width >> 1)); + getHeightSpinner(view)->setIncrement((F32)(height >> 1)); } } diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index 735776f7e5..e58e819345 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -67,7 +67,11 @@ bool LLFloaterSpellCheckerSettings::postBuild(void) LLSpellChecker::setSettingsChangeCallback(boost::bind(&LLFloaterSpellCheckerSettings::onSpellCheckSettingsChange, this)); getChild<LLUICtrl>("spellcheck_remove_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnRemove, this)); getChild<LLUICtrl>("spellcheck_import_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnImport, this)); - getChild<LLUICtrl>("spellcheck_main_combo")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaries, this, false)); + getChild<LLUICtrl>("spellcheck_main_combo")->setCommitCallback([this](LLUICtrl* ctrl, const LLSD& data) + { + mMainSelectionChanged = true; + refreshDictionaries(false); + }); getChild<LLUICtrl>("spellcheck_moveleft_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_active_list", "spellcheck_available_list")); getChild<LLUICtrl>("spellcheck_moveright_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_available_list", "spellcheck_active_list")); center(); @@ -146,7 +150,7 @@ void LLFloaterSpellCheckerSettings::onBtnRemove() void LLFloaterSpellCheckerSettings::onSpellCheckSettingsChange() { - refreshDictionaries(true); + refreshDictionaries(!mMainSelectionChanged); } void LLFloaterSpellCheckerSettings::refreshDictionaries(bool from_settings) diff --git a/indra/newview/llfloaterspellchecksettings.h b/indra/newview/llfloaterspellchecksettings.h index f05bf68040..ff76ff6ba5 100644 --- a/indra/newview/llfloaterspellchecksettings.h +++ b/indra/newview/llfloaterspellchecksettings.h @@ -45,6 +45,8 @@ protected: void onBtnRemove(); void onSpellCheckSettingsChange(); void refreshDictionaries(bool from_settings); + + bool mMainSelectionChanged{ false }; }; class LLFloaterSpellCheckerImport : public LLFloater diff --git a/indra/newview/llfloatertopobjects.cpp b/indra/newview/llfloatertopobjects.cpp index 64b22c4bb1..9bc8c63fa0 100644 --- a/indra/newview/llfloatertopobjects.cpp +++ b/indra/newview/llfloatertopobjects.cpp @@ -195,7 +195,7 @@ void LLFloaterTopObjects::handleReply(LLMessageSystem *msg, void** data) { parcel_buf = parcel_name; script_memory = script_size; - total_memory += script_size; + total_memory += (U64)script_size; } } @@ -233,7 +233,7 @@ void LLFloaterTopObjects::handleReply(LLMessageSystem *msg, void** data) columns[column_num]["column"] = "time"; columns[column_num]["type"] = "date"; - columns[column_num]["value"] = LLDate((time_t)time_stamp); + columns[column_num]["value"] = LLDate((double)time_stamp); columns[column_num++]["font"] = "SANSSERIF"; if (mCurrentMode == STAT_REPORT_TOP_SCRIPTS diff --git a/indra/newview/llfloateruipreview.cpp b/indra/newview/llfloateruipreview.cpp index 6f526e1905..7c49db9c54 100644 --- a/indra/newview/llfloateruipreview.cpp +++ b/indra/newview/llfloateruipreview.cpp @@ -1598,7 +1598,7 @@ void LLOverlapPanel::draw() if(!LLView::sPreviewClickedElement) { - LLUI::translate(5,getRect().getHeight()-20); // translate to top-5,left-5 + LLUI::translate(5.f, (F32)getRect().getHeight() - 20.f); // translate to top-5,left-5 LLView::sDrawPreviewHighlights = false; LLFontGL::getFontSansSerifSmall()->renderUTF8(current_selection_text, 0, 0, 0, text_color, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW); @@ -1614,7 +1614,7 @@ void LLOverlapPanel::draw() std::list<LLView*> overlappers = mOverlapMap[LLView::sPreviewClickedElement]; if(overlappers.size() == 0) { - LLUI::translate(5,getRect().getHeight()-20); // translate to top-5,left-5 + LLUI::translate(5.f, (F32)getRect().getHeight() - 20.f); // translate to top-5,left-5 LLView::sDrawPreviewHighlights = false; std::string current_selection = std::string(current_selection_text + LLView::sPreviewClickedElement->getName() + " (no elements overlap)"); S32 text_width = LLFontGL::getFontSansSerifSmall()->getWidth(current_selection) + 10; @@ -1679,14 +1679,14 @@ void LLOverlapPanel::draw() setRect(LLRect(rect.mLeft,rect.mTop,rect.mRight,rect.mTop-height_sum)); } - LLUI::translate(5,getRect().getHeight()-10); // translate to top left + LLUI::translate(5.f, (F32)getRect().getHeight() - 10.f); // translate to top left LLView::sDrawPreviewHighlights = false; // draw currently-selected element at top of overlappers - LLUI::translate(0,-mSpacing); + LLUI::translate(0.f, -(F32)mSpacing); LLFontGL::getFontSansSerifSmall()->renderUTF8(current_selection_text + LLView::sPreviewClickedElement->getName(), 0, 0, 0, text_color, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW); - LLUI::translate(0,-mSpacing-LLView::sPreviewClickedElement->getRect().getHeight()); // skip spacing distance + height + LLUI::translate(0.f, -(F32)mSpacing - (F32)LLView::sPreviewClickedElement->getRect().getHeight()); // skip spacing distance + height LLView::sPreviewClickedElement->draw(); for(std::list<LLView*>::iterator overlap_it = overlappers.begin(); overlap_it != overlappers.end(); ++overlap_it) @@ -1694,16 +1694,16 @@ void LLOverlapPanel::draw() LLView* viewp = *overlap_it; // draw separating line - LLUI::translate(0,-mSpacing); + LLUI::translate(0.f, -(F32)mSpacing); gl_line_2d(0,0,getRect().getWidth()-10,0,LLColor4(192.0f/255.0f,192.0f/255.0f,192.0f/255.0f)); // draw name - LLUI::translate(0,-mSpacing); + LLUI::translate(0.f, -(F32)mSpacing); LLFontGL::getFontSansSerifSmall()->renderUTF8(overlapper_text + viewp->getName(), 0, 0, 0, text_color, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW); // draw element - LLUI::translate(0,-mSpacing-viewp->getRect().getHeight()); // skip spacing distance + height + LLUI::translate(0.f, -(F32)mSpacing - (F32)viewp->getRect().getHeight()); // skip spacing distance + height viewp->draw(); } mLastClickedElement = LLView::sPreviewClickedElement; diff --git a/indra/newview/llfloaterwebcontent.cpp b/indra/newview/llfloaterwebcontent.cpp index f5b5b8293f..e1b6df6072 100644 --- a/indra/newview/llfloaterwebcontent.cpp +++ b/indra/newview/llfloaterwebcontent.cpp @@ -220,7 +220,7 @@ void LLFloaterWebContent::preCreate(LLFloaterWebContent::Params& p) // showInstance will open a new window. Figure out how many web browsers are already open, // and close the least recently opened one if this will put us over the limit. - LLFloaterReg::const_instance_list_t &instances = LLFloaterReg::getFloaterList(p.window_class); + LLFloaterReg::const_instance_list_t &instances = LLFloaterReg::getFloaterList(p.window_class()); if(instances.size() >= (size_t)browser_window_limit) { diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 08f8918e5d..19cb4d04e2 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -893,7 +893,7 @@ void LLSky::renderSunMoonBeacons(const LLVector3& pos_agent, const LLVector3& di { pos_end.mV[i] = pos_agent.mV[i] + (50 * direction.mV[i]); } - glLineWidth(LLPipeline::DebugBeaconLineWidth); + glLineWidth((GLfloat)LLPipeline::DebugBeaconLineWidth); gGL.begin(LLRender::LINES); color.mV[3] *= 0.5f; gGL.color4fv(color.mV); @@ -1190,8 +1190,8 @@ F32 gpu_benchmark() F32 ms = gBenchmarkProgram.mTimeElapsed/1000000.f; F32 seconds = ms/1000.f; - F64 samples_drawn = gBenchmarkProgram.mSamplesDrawn; - F32 samples_sec = (samples_drawn/1000000000.0)/seconds; + F64 samples_drawn = (F64)gBenchmarkProgram.mSamplesDrawn; + F32 samples_sec = (F32)((samples_drawn/1000000000.0)/seconds); gbps = samples_sec*4; // 4 bytes per sample LL_INFOS("Benchmark") << "Memory bandwidth is " << llformat("%.3f", gbps) << " GB/sec according to ARB_timer_query, total time " << seconds << " seconds" << LL_ENDL; diff --git a/indra/newview/llgltffolderitem.cpp b/indra/newview/llgltffolderitem.cpp new file mode 100644 index 0000000000..77a19c060d --- /dev/null +++ b/indra/newview/llgltffolderitem.cpp @@ -0,0 +1,164 @@ +/** + * @file llgltffolderitem.cpp + * @author Andrey Kleshchev + * @brief LLGLTFFolderItem class implementation + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llgltffolderitem.h" + +#include "llinventoryicon.h" + +/// LLGLTFItem + +LLGLTFFolderItem::LLGLTFFolderItem(S32 id, const std::string &display_name, EType type, LLFolderViewModelInterface& root_view_model) + : LLFolderViewModelItemCommon(root_view_model) + , mName(display_name) + , mItemType(type) + , mItemId(id) +{ + init(); +} + +LLGLTFFolderItem::LLGLTFFolderItem(LLFolderViewModelInterface& root_view_model) + : LLFolderViewModelItemCommon(root_view_model) +{ + init(); +} + +LLGLTFFolderItem::~LLGLTFFolderItem() +{ + +} + +void LLGLTFFolderItem::init() +{ + // using inventory icons as a placeholder. + // Todo: GLTF needs to have own icons + switch (mItemType) + { + case TYPE_SCENE: + pIcon = LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_OBJECT_MULTI); + break; + case TYPE_NODE: + pIcon = LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_OBJECT); + break; + case TYPE_MESH: + pIcon = LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_MESH); + break; + case TYPE_SKIN: + pIcon = LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_BODYPART_SKIN); + break; + default: + pIcon = LLInventoryIcon::getIcon(LLInventoryType::ICONNAME_OBJECT); + break; + } +} + + +bool LLGLTFFolderItem::filterChildItem(LLFolderViewModelItem* item, LLFolderViewFilter& filter) +{ + S32 filter_generation = filter.getCurrentGeneration(); + + bool continue_filtering = true; + if (item) + { + if (item->getLastFilterGeneration() < filter_generation) + { + // Recursive application of the filter for child items (CHUI-849) + continue_filtering = item->filter(filter); + } + + // Update latest generation to pass filter in parent and propagate up to root + if (item->passedFilter()) + { + LLGLTFFolderItem* view_model = this; + + while (view_model && view_model->mMostFilteredDescendantGeneration < filter_generation) + { + view_model->mMostFilteredDescendantGeneration = filter_generation; + view_model = static_cast<LLGLTFFolderItem*>(view_model->mParent); + } + } + } + return continue_filtering; +} + +bool LLGLTFFolderItem::filter(LLFolderViewFilter& filter) +{ + const S32 filter_generation = filter.getCurrentGeneration(); + const S32 must_pass_generation = filter.getFirstRequiredGeneration(); + + if (getLastFilterGeneration() >= must_pass_generation + && getLastFolderFilterGeneration() >= must_pass_generation + && !passedFilter(must_pass_generation)) + { + // failed to pass an earlier filter that was a subset of the current one + // go ahead and flag this item as not pass + setPassedFilter(false, filter_generation); + setPassedFolderFilter(false, filter_generation); + return true; + } + + bool is_folder = true; + const bool passed_filter_folder = is_folder ? filter.checkFolder(this) : true; + setPassedFolderFilter(passed_filter_folder, filter_generation); + + bool continue_filtering = true; + + if (!mChildren.empty() + && (getLastFilterGeneration() < must_pass_generation // haven't checked descendants against minimum required generation to pass + || descendantsPassedFilter(must_pass_generation))) // or at least one descendant has passed the minimum requirement + { + // now query children + for (child_list_t::iterator iter = mChildren.begin(), end_iter = mChildren.end(); iter != end_iter; ++iter) + { + continue_filtering = filterChildItem((*iter), filter); + if (!continue_filtering) + { + break; + } + } + } + + // If we didn't use all the filter time that means we filtered all of our descendants so we can filter ourselves now + if (continue_filtering) + { + // This is where filter check on the item done (CHUI-849) + const bool passed_filter = filter.check(this); + if (passed_filter && mChildren.empty() && is_folder) // Update the latest filter generation for empty folders + { + LLGLTFFolderItem* view_model = this; + while (view_model && view_model->mMostFilteredDescendantGeneration < filter_generation) + { + view_model->mMostFilteredDescendantGeneration = filter_generation; + view_model = static_cast<LLGLTFFolderItem*>(view_model->mParent); + } + } + setPassedFilter(passed_filter, filter_generation, filter.getStringMatchOffset(this), filter.getFilterStringSize()); + continue_filtering = !filter.isTimedOut(); + } + return continue_filtering; +} diff --git a/indra/newview/llgltffolderitem.h b/indra/newview/llgltffolderitem.h new file mode 100644 index 0000000000..89d90c81cc --- /dev/null +++ b/indra/newview/llgltffolderitem.h @@ -0,0 +1,128 @@ +/** + * @file llgltffolderitem.h + * @author Andrey Kleshchev + * @brief LLGLTFFolderItem header file + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLGLTFFOLDERITEM_H +#define LL_LLGLTFFOLDERITEM_H + +#include "llfloater.h" + +#include "llfolderviewmodel.h" + +class LLGLTFFolderItem : public LLFolderViewModelItemCommon +{ +public: + enum EType + { + TYPE_ROOT, + TYPE_SCENE, + TYPE_NODE, + TYPE_MESH, + TYPE_SKIN, + }; + + LLGLTFFolderItem(S32 id, const std::string &display_name, EType type, LLFolderViewModelInterface& root_view_model); + LLGLTFFolderItem(LLFolderViewModelInterface& root_view_model); + virtual ~LLGLTFFolderItem(); + + void init(); + + const std::string& getName() const override { return mName; } + const std::string& getDisplayName() const override { return mName; } + const std::string& getSearchableName() const override { return mName; } + + std::string getSearchableDescription() const override { return std::string(); } + std::string getSearchableCreatorName()const override { return std::string(); } + std::string getSearchableUUIDString() const override { return std::string(); } + + LLPointer<LLUIImage> getIcon() const override { return pIcon; } + LLPointer<LLUIImage> getIconOpen() const override { return getIcon(); } + LLPointer<LLUIImage> getIconOverlay() const override { return NULL; } + + LLFontGL::StyleFlags getLabelStyle() const override { return LLFontGL::NORMAL; } + std::string getLabelSuffix() const override { return std::string(); } + + void openItem(void) override {} + void closeItem(void) override {} + void selectItem(void) override {} + + void navigateToFolder(bool new_window = false, bool change_mode = false) override {} + + bool isItemWearable() const override { return false; } + + bool isItemRenameable() const override { return false; } + bool renameItem(const std::string& new_name) override { return false; } + + bool isItemMovable(void) const override { return false; } // Can be moved to another folder + void move(LLFolderViewModelItem* parent_listener) override {} + + bool isItemRemovable(bool check_worn = true) const override { return false; } + bool removeItem() override { return false; } + void removeBatch(std::vector<LLFolderViewModelItem*>& batch) override {} + + bool isItemCopyable(bool can_copy_as_link = true) const override { return false; } + bool copyToClipboard() const override { return false; } + bool cutToClipboard() override { return false; } + bool isCutToClipboard() override { return false; } + + bool isClipboardPasteable() const override { return false; } + void pasteFromClipboard() override {} + void pasteLinkFromClipboard() override {} + + void buildContextMenu(LLMenuGL& menu, U32 flags) override {}; + + bool potentiallyVisible() override { return true; }; // is the item definitely visible or we haven't made up our minds yet? + + bool hasChildren() const override { return mChildren.size() > 0; } + + bool dragOrDrop( + MASK mask, + bool drop, + EDragAndDropType cargo_type, + void* cargo_data, + std::string& tooltip_msg) override + { + return false; + } + + bool filterChildItem(LLFolderViewModelItem* item, LLFolderViewFilter& filter); + bool filter(LLFolderViewFilter& filter) override; + + EType getType() const { return mItemType; } + S32 getItemId() const { return mItemId; } + +private: + LLUIImagePtr pIcon; + std::string mName; + EType mItemType = TYPE_ROOT; + + // mItemId can be an id in a mesh vector, node vector or any other vector. + // mItemId is not nessesarily unique, ex: some nodes can reuse the same + // mesh or skin, so mesh-items can have the same id. + S32 mItemId = -1; +}; + +#endif diff --git a/indra/newview/llgltffoldermodel.cpp b/indra/newview/llgltffoldermodel.cpp new file mode 100644 index 0000000000..de2510dc4a --- /dev/null +++ b/indra/newview/llgltffoldermodel.cpp @@ -0,0 +1,73 @@ +/** + * @file llgltffoldermodel.cpp + * @author Andrey Kleshchev + * @brief gltf model's folder structure related classes + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llgltffoldermodel.h" + +#include "llfolderviewitem.h" + +bool LLGLTFSort::operator()(const LLGLTFFolderItem* const& a, const LLGLTFFolderItem* const& b) const +{ + // Comparison operator: returns "true" is a comes before b, "false" otherwise + S32 compare = LLStringUtil::compareDict(a->getName(), b->getName()); + return (compare < 0); +} + +/// LLGLTFViewModel + +LLGLTFViewModel::LLGLTFViewModel() + : base_t(new LLGLTFSort(), new LLGLTFFilter()) +{} + +void LLGLTFViewModel::sort(LLFolderViewFolder* folder) +{ + base_t::sort(folder); +} + + /// LLGLTFNode +// LLUICtrlFactory::create<LLGLTFNode>(params); +class LLGLTFNode : public LLFolderViewItem +{ +public: + struct Params : public LLInitParam::Block<Params, LLFolderViewItem::Params> + { + Params(); + }; + ~LLGLTFNode(); +protected: + LLGLTFNode(const Params& p); +}; + +LLGLTFNode::LLGLTFNode(const LLGLTFNode::Params& p) + : LLFolderViewItem(p) +{ +} + +LLGLTFNode::~LLGLTFNode() +{ +} diff --git a/indra/newview/llgltffoldermodel.h b/indra/newview/llgltffoldermodel.h new file mode 100644 index 0000000000..69b284aa31 --- /dev/null +++ b/indra/newview/llgltffoldermodel.h @@ -0,0 +1,91 @@ +/** + * @file llfloatergltfasseteditor.h + * @author Andrey Kleshchev + * @brief gltf model's folder structure related classes + * + * $LicenseInfo:firstyear=2024&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2024, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLGLTFFOLDERMODEL_H +#define LL_LLGLTFFOLDERMODEL_H + +#include "llfolderviewmodel.h" +#include "llgltffolderitem.h" + +class LLGLTFSort +{ +public: + LLGLTFSort() { } + bool operator()(const LLGLTFFolderItem* const& a, const LLGLTFFolderItem* const& b) const; +private: +}; + +class LLGLTFFilter : public LLFolderViewFilter +{ +public: + LLGLTFFilter() { mEmpty = ""; } + ~LLGLTFFilter() {} + + bool check(const LLFolderViewModelItem* item) { return true; } + bool checkFolder(const LLFolderViewModelItem* folder) const { return true; } + void setEmptyLookupMessage(const std::string& message) { } + std::string getEmptyLookupMessage(bool is_empty_folder = false) const { return mEmpty; } + bool showAllResults() const { return true; } + std::string::size_type getStringMatchOffset(LLFolderViewModelItem* item) const { return std::string::npos; } + std::string::size_type getFilterStringSize() const { return 0; } + + bool isActive() const { return false; } + bool isModified() const { return false; } + void clearModified() { } + const std::string& getName() const { return mEmpty; } + const std::string& getFilterText() { return mEmpty; } + void setModified(EFilterModified behavior = FILTER_RESTART) { } + + void resetTime(S32 timeout) { } + bool isTimedOut() { return false; } + + bool isDefault() const { return true; } + bool isNotDefault() const { return false; } + void markDefault() { } + void resetDefault() { } + + S32 getCurrentGeneration() const { return 0; } + S32 getFirstSuccessGeneration() const { return 0; } + S32 getFirstRequiredGeneration() const { return 0; } +private: + std::string mEmpty; +}; + +class LLGLTFViewModel + : public LLFolderViewModel<LLGLTFSort, LLGLTFFolderItem, LLGLTFFolderItem, LLGLTFFilter> +{ +public: + typedef LLFolderViewModel< LLGLTFSort, LLGLTFFolderItem, LLGLTFFolderItem, LLGLTFFilter> base_t; + LLGLTFViewModel(); + + void sort(LLFolderViewFolder* folder); + bool startDrag(std::vector<LLFolderViewModelItem*>& items) { return false; } + +private: +}; + +#endif diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index 215f3dd3a7..25438eae5e 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -55,6 +55,8 @@ LLGLTFMaterialList::modify_queue_t LLGLTFMaterialList::sModifyQueue; LLGLTFMaterialList::apply_queue_t LLGLTFMaterialList::sApplyQueue; LLSD LLGLTFMaterialList::sUpdates; +const size_t MAX_TASK_UPDATES = 255; + #ifdef SHOW_ASSERT // return true if given data is (probably) valid update message for ModifyMaterialParams capability static bool is_valid_update(const LLSD& data) @@ -362,6 +364,17 @@ void LLGLTFMaterialList::queueApply(const LLViewerObject* obj, S32 side, const L LLGLTFMaterial* material = new LLGLTFMaterial(*material_override); sApplyQueue.push_back({ obj->getID(), side, asset_id, material }); } + + if (sUpdates.size() >= MAX_TASK_UPDATES) + { + LLCoros::instance().launch("modifyMaterialCoro", + std::bind(&LLGLTFMaterialList::modifyMaterialCoro, + gAgent.getRegionCapability("ModifyMaterialParams"), + sUpdates, + std::shared_ptr<CallbackHolder>(nullptr))); + + sUpdates = LLSD::emptyArray(); + } } void LLGLTFMaterialList::queueUpdate(const LLSD& data) @@ -374,16 +387,41 @@ void LLGLTFMaterialList::queueUpdate(const LLSD& data) } sUpdates[sUpdates.size()] = data; + + if (sUpdates.size() >= MAX_TASK_UPDATES) + { + LLCoros::instance().launch("modifyMaterialCoro", + std::bind(&LLGLTFMaterialList::modifyMaterialCoro, + gAgent.getRegionCapability("ModifyMaterialParams"), + sUpdates, + std::shared_ptr<CallbackHolder>(nullptr))); + + sUpdates = LLSD::emptyArray(); + } } void LLGLTFMaterialList::flushUpdates(void(*done_callback)(bool)) { + std::shared_ptr<CallbackHolder> callback_holder; + if (done_callback) + { + callback_holder = std::make_shared<CallbackHolder>(done_callback); + } + while (!sModifyQueue.empty() || !sApplyQueue.empty()) + { + flushUpdatesOnce(callback_holder); + } +} + +void LLGLTFMaterialList::flushUpdatesOnce(std::shared_ptr<CallbackHolder> callback_holder) +{ LLSD& data = sUpdates; - auto i = data.size(); + size_t i = data.size(); - for (ModifyMaterialData& e : sModifyQueue) + while (!sModifyQueue.empty() && i < MAX_TASK_UPDATES) { + ModifyMaterialData& e = sModifyQueue.front(); #ifdef SHOW_ASSERT // validate object has a material id LLViewerObject* obj = gObjectList.findObject(e.object_id); @@ -405,11 +443,12 @@ void LLGLTFMaterialList::flushUpdates(void(*done_callback)(bool)) llassert(is_valid_update(data[i])); ++i; + sModifyQueue.pop_front(); } - sModifyQueue.clear(); - for (ApplyMaterialAssetData& e : sApplyQueue) + while (!sApplyQueue.empty() && i < MAX_TASK_UPDATES) { + ApplyMaterialAssetData& e = sApplyQueue.front(); data[i]["object_id"] = e.object_id; data[i]["side"] = e.side; data[i]["asset_id"] = e.asset_id; @@ -425,8 +464,8 @@ void LLGLTFMaterialList::flushUpdates(void(*done_callback)(bool)) llassert(is_valid_update(data[i])); ++i; + sApplyQueue.pop_front(); } - sApplyQueue.clear(); #if 0 // debug output of data being sent to capability std::stringstream str; @@ -440,7 +479,7 @@ void LLGLTFMaterialList::flushUpdates(void(*done_callback)(bool)) std::bind(&LLGLTFMaterialList::modifyMaterialCoro, gAgent.getRegionCapability("ModifyMaterialParams"), sUpdates, - done_callback)); + callback_holder)); sUpdates = LLSD::emptyArray(); } @@ -661,7 +700,7 @@ void LLGLTFMaterialList::flushMaterials() } // static -void LLGLTFMaterialList::modifyMaterialCoro(std::string cap_url, LLSD overrides, void(*done_callback)(bool) ) +void LLGLTFMaterialList::modifyMaterialCoro(std::string cap_url, LLSD overrides, std::shared_ptr<CallbackHolder> callback_holder) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -691,9 +730,12 @@ void LLGLTFMaterialList::modifyMaterialCoro(std::string cap_url, LLSD overrides, success = false; } - if (done_callback) + if (callback_holder) { - done_callback(success); + // Set to false even if something went through + // since at the moment it get used to refresh UI + // if update failed + callback_holder->mSuccess &= success; } } diff --git a/indra/newview/llgltfmateriallist.h b/indra/newview/llgltfmateriallist.h index 982538f106..e79da3592a 100644 --- a/indra/newview/llgltfmateriallist.h +++ b/indra/newview/llgltfmateriallist.h @@ -58,7 +58,9 @@ public: // NOTE: do not use to revert to asset when applying a new asset id, use queueApply below static void queueModify(const LLViewerObject* obj, S32 side, const LLGLTFMaterial* mat); - // Queue an application of a material asset we want to send to the simulator. Call "flushUpdates" to flush pending updates. + // Queue an application of a material asset we want to send to the simulator. + // Call "flushUpdates" to flush pending updates immediately. + // Will be flushed automatically if queue is full. // object_id - ID of object to apply material asset to // side - TextureEntry index to apply material to, or -1 for all sides // asset_id - ID of material asset to apply, or LLUUID::null to disassociate current material asset @@ -66,7 +68,9 @@ public: // NOTE: Implicitly clears most override data if present static void queueApply(const LLViewerObject* obj, S32 side, const LLUUID& asset_id); - // Queue an application of a material asset we want to send to the simulator. Call "flushUpdates" to flush pending updates. + // Queue an application of a material asset we want to send to the simulator. + // Call "flushUpdates" to flush pending updates immediately. + // Will be flushed automatically if queue is full. // object_id - ID of object to apply material asset to // side - TextureEntry index to apply material to, or -1 for all sides // asset_id - ID of material asset to apply, or LLUUID::null to disassociate current material asset @@ -104,7 +108,22 @@ private: // NOTE: this is NOT for applying overrides from the UI, see queueModifyMaterial above void queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFMaterial* override_data); - static void modifyMaterialCoro(std::string cap_url, LLSD overrides, void(*done_callback)(bool)); + + class CallbackHolder + { + public: + CallbackHolder(void(*done_callback)(bool)) + : mCallback(done_callback) + {} + ~CallbackHolder() + { + if (mCallback) mCallback(mSuccess); + } + std::function<void(bool)> mCallback = nullptr; + bool mSuccess = true; + }; + static void flushUpdatesOnce(std::shared_ptr<CallbackHolder> callback_holder); + static void modifyMaterialCoro(std::string cap_url, LLSD overrides, std::shared_ptr<CallbackHolder> callback_holder); protected: static void onAssetLoadComplete( diff --git a/indra/newview/llgltfmaterialpreviewmgr.cpp b/indra/newview/llgltfmaterialpreviewmgr.cpp index a198d1bdf4..06920734fe 100644 --- a/indra/newview/llgltfmaterialpreviewmgr.cpp +++ b/indra/newview/llgltfmaterialpreviewmgr.cpp @@ -462,7 +462,7 @@ bool LLGLTFPreviewTexture::render() // Set up camera and viewport const LLVector3 origin(0.0, 0.0, 0.0); camera.lookAt(origin, object_position); - camera.setAspect(mFullHeight / mFullWidth); + camera.setAspect((F32)(mFullHeight / mFullWidth)); const LLRect texture_rect(0, mFullHeight, mFullWidth, 0); camera.setPerspective(NOT_FOR_SELECTION, texture_rect.mLeft, texture_rect.mBottom, texture_rect.getWidth(), texture_rect.getHeight(), false, camera.getNear(), MAX_FAR_CLIP*2.f); diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp index 100aacb8ac..090ed7b0e2 100644 --- a/indra/newview/llgroupmgr.cpp +++ b/indra/newview/llgroupmgr.cpp @@ -190,7 +190,7 @@ S32 LLGroupRoleData::getMembersInRole(uuid_vec_t members, in_role_end = std::set_intersection(mMemberIDs.begin(), mMemberIDs.end(), members.begin(), members.end(), in_role.begin()); - return in_role_end - in_role.begin(); + return (S32)(in_role_end - in_role.begin()); } void LLGroupRoleData::addMember(const LLUUID& member) @@ -806,7 +806,7 @@ void LLGroupMgrGroupData::banMemberById(const LLUUID& participant_uuid) mPendingBanRequest = false; - LLGroupMemberData* member_data = (*mi).second; + LLGroupMemberData* member_data = mi->second; if (member_data && member_data->isInRole(mOwnerRole)) { return; // can't ban group owner @@ -832,8 +832,7 @@ void LLGroupMgrGroupData::banMemberById(const LLUUID& participant_uuid) // LLGroupMgr // -LLGroupMgr::LLGroupMgr(): - mMemberRequestInFlight(false) +LLGroupMgr::LLGroupMgr() { } @@ -968,11 +967,11 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data) LLGroupMgrGroupData* group_datap = LLGroupMgr::getInstance()->getGroupData(group_id); if (!group_datap || (group_datap->mMemberRequestID != request_id)) { - LL_WARNS() << "processGroupMembersReply: Received incorrect (stale?) group or request id" << LL_ENDL; + LL_WARNS() << "Received incorrect (stale?) group or request id" << LL_ENDL; return; } - msg->getS32(_PREHASH_GroupData, "MemberCount", group_datap->mMemberCount ); + msg->getS32Fast(_PREHASH_GroupData, _PREHASH_MemberCount, group_datap->mMemberCount); if (group_datap->mMemberCount > 0) { @@ -987,12 +986,12 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data) { LLUUID member_id; - msg->getUUIDFast(_PREHASH_MemberData, _PREHASH_AgentID, member_id, i ); - msg->getS32(_PREHASH_MemberData, _PREHASH_Contribution, contribution, i); - msg->getU64(_PREHASH_MemberData, "AgentPowers", agent_powers, i); + msg->getUUIDFast(_PREHASH_MemberData, _PREHASH_AgentID, member_id, i); + msg->getS32Fast(_PREHASH_MemberData, _PREHASH_Contribution, contribution, i); + msg->getU64Fast(_PREHASH_MemberData, _PREHASH_AgentPowers, agent_powers, i); msg->getStringFast(_PREHASH_MemberData, _PREHASH_OnlineStatus, online_status, i); - msg->getString(_PREHASH_MemberData, "Title", title, i); - msg->getBOOL(_PREHASH_MemberData,"IsOwner",is_owner,i); + msg->getStringFast(_PREHASH_MemberData, _PREHASH_Title, title, i); + msg->getBOOLFast(_PREHASH_MemberData, _PREHASH_IsOwner, is_owner, i); if (member_id.notNull()) { @@ -1037,7 +1036,7 @@ void LLGroupMgr::processGroupMembersReply(LLMessageSystem* msg, void** data) group_datap->mMemberVersion.generate(); - if (group_datap->mMembers.size() == (U32)group_datap->mMemberCount) + if (group_datap->mMembers.size() == (U32)group_datap->mMemberCount) { group_datap->mMemberDataComplete = true; group_datap->mMemberRequestID.setNull(); @@ -1569,7 +1568,7 @@ void LLGroupMgr::addGroup(LLGroupMgrGroupData* group_datap) { // LRU: Remove the oldest un-observed group from cache until group size is small enough - F32 oldest_access = LLFrameTimer::getTotalSeconds(); + F32 oldest_access = (F32)LLFrameTimer::getTotalSeconds(); group_map_t::iterator oldest_gi = mGroups.end(); for (group_map_t::iterator gi = mGroups.begin(); gi != mGroups.end(); ++gi ) @@ -1678,13 +1677,12 @@ void LLGroupMgr::sendGroupRoleMembersRequest(const LLUUID& group_id) if (group_datap->mRoleMembersRequestID.isNull()) { // Don't send the request if we don't have all the member or role data - if (!group_datap->isMemberDataComplete() - || !group_datap->isRoleDataComplete()) + if (!group_datap->isMemberDataComplete() || !group_datap->isRoleDataComplete()) { // *TODO: KLW FIXME: Should we start a member or role data request? LL_INFOS("GrpMgr") << " Pending: " << (group_datap->mPendingRoleMemberRequest ? "Y" : "N") - << " MemberDataComplete: " << (group_datap->mMemberDataComplete ? "Y" : "N") - << " RoleDataComplete: " << (group_datap->mRoleDataComplete ? "Y" : "N") << LL_ENDL; + << ", MemberDataComplete: " << (group_datap->mMemberDataComplete ? "Y" : "N") + << ", RoleDataComplete: " << (group_datap->mRoleDataComplete ? "Y" : "N") << LL_ENDL; group_datap->mPendingRoleMemberRequest = true; return; } @@ -1984,14 +1982,14 @@ void LLGroupMgr::sendGroupMemberEjects(const LLUUID& group_id, group_datap->mMemberVersion.generate(); } -void LLGroupMgr::getGroupBanRequestCoro(std::string url, LLUUID groupId) +void LLGroupMgr::getGroupBanRequestCoro(std::string url, LLUUID group_id) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - std::string finalUrl = url + "?group_id=" + groupId.asString(); + std::string finalUrl = url + "?group_id=" + group_id.asString(); LLSD result = httpAdapter->getAndSuspend(httpRequest, finalUrl); @@ -2012,8 +2010,8 @@ void LLGroupMgr::getGroupBanRequestCoro(std::string url, LLUUID groupId) } } -void LLGroupMgr::postGroupBanRequestCoro(std::string url, LLUUID groupId, - U32 action, uuid_vec_t banList, bool update) +void LLGroupMgr::postGroupBanRequestCoro(std::string url, LLUUID group_id, + U32 action, uuid_vec_t ban_list, bool update) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -2026,20 +2024,16 @@ void LLGroupMgr::postGroupBanRequestCoro(std::string url, LLUUID groupId, httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); - - std::string finalUrl = url + "?group_id=" + groupId.asString(); + std::string finalUrl = url + "?group_id=" + group_id.asString(); LLSD postData = LLSD::emptyMap(); postData["ban_action"] = (LLSD::Integer)action; // Add our list of potential banned residents to the list postData["ban_ids"] = LLSD::emptyArray(); - LLSD banEntry; - uuid_vec_t::const_iterator it = banList.begin(); - for (; it != banList.end(); ++it) + for (const LLUUID& ban_id : ban_list) { - banEntry = (*it); - postData["ban_ids"].append(banEntry); + postData["ban_ids"].append(ban_id); } LL_WARNS() << "post: " << ll_pretty_print_sd(postData) << LL_ENDL; @@ -2064,7 +2058,7 @@ void LLGroupMgr::postGroupBanRequestCoro(std::string url, LLUUID groupId, if (update) { - getGroupBanRequestCoro(url, groupId); + getGroupBanRequestCoro(url, group_id); } } @@ -2151,55 +2145,66 @@ void LLGroupMgr::processGroupBanRequest(const LLSD& content) LLGroupMgr::getInstance()->notifyObservers(GC_BANLIST); } -void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID groupId) +void LLGroupMgr::groupMembersRequestCoro(std::string url, LLUUID group_id, U32 page_size, U32 page_start, std::string sort_column) { + LL_INFOS("GrpMgr") << "group_id: '" << group_id << "', sort_column: '" << sort_column << "', page_size: " << page_size << ", page_start: " << page_start << LL_ENDL; LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); - - mMemberRequestInFlight = true; + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); LLSD postData = LLSD::emptyMap(); - postData["group_id"] = groupId; + postData["group_id"] = group_id; + if (page_size) + { + postData["page_size"] = LLSD::Integer(page_size); + if (page_start) + { + postData["page_start"] = LLSD::Integer(page_start); + } + if (!sort_column.empty()) + { + postData["sort_column"] = sort_column; + } + } - LLSD result = httpAdapter->postAndSuspend(httpRequest, url, postData, httpOpts); + LLSD response = httpAdapter->postAndSuspend(httpRequest, url, postData, httpOpts); - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + mMemberRequestInFlight = false; + + LLSD httpResults = response.get(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { LL_WARNS("GrpMgr") << "Error receiving group member data " << LL_ENDL; - mMemberRequestInFlight = false; return; } - result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); - LLGroupMgr::processCapGroupMembersRequest(result); - mMemberRequestInFlight = false; + response.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + processCapGroupMembersResponse(response, page_size, page_start, sort_column); } -void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) +void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id, U32 page_size, U32 page_start, const std::string& sort_column) { static U32 lastGroupMemberRequestFrame = 0; // Have we requested the information already this frame? // Todo: make this per group, we can invite to one group and simultaneously be checking another one - if ((lastGroupMemberRequestFrame == gFrameCount) || (mMemberRequestInFlight)) + if ((lastGroupMemberRequestFrame == gFrameCount) || mMemberRequestInFlight) return; LLViewerRegion* currentRegion = gAgent.getRegion(); // Thank you FS:Ansariel! - if(!currentRegion) + if (!currentRegion) { LL_WARNS("GrpMgr") << "Agent does not have a current region. Uh-oh!" << LL_ENDL; return; } // Check to make sure we have our capabilities - if(!currentRegion->capabilitiesReceived()) + if (!currentRegion->capabilitiesReceived()) { LL_WARNS("GrpMgr") << " Capabilities not received!" << LL_ENDL; return; @@ -2209,9 +2214,9 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) std::string cap_url = currentRegion->getCapability("GroupMemberData"); // Thank you FS:Ansariel! - if(cap_url.empty()) + if (cap_url.empty()) { - LL_INFOS("GrpMgr") << "Region has no GroupMemberData capability. Falling back to UDP fetch." << LL_ENDL; + LL_INFOS("GrpMgr") << "Region has no GroupMemberData capability. Falling back to UDP fetch." << LL_ENDL; sendGroupMembersRequest(group_id); return; } @@ -2221,120 +2226,121 @@ void LLGroupMgr::sendCapGroupMembersRequest(const LLUUID& group_id) lastGroupMemberRequestFrame = gFrameCount; - LLCoros::instance().launch("LLGroupMgr::groupMembersRequestCoro", - boost::bind(&LLGroupMgr::groupMembersRequestCoro, this, cap_url, group_id)); -} + mMemberRequestInFlight = true; + LLCoros::instance().launch("LLGroupMgr::groupMembersRequestCoro", [&]() + { + groupMembersRequestCoro(cap_url, group_id, page_size, page_start, sort_column); + }); +} -void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) +void LLGroupMgr::processCapGroupMembersResponse(const LLSD& response, U32 page_size, U32 page_start, const std::string& sort_column) { + LLUUID group_id = response["group_id"].asUUID(); + LL_INFOS("GrpMgr") << "group_id: '" << group_id << "', sort_column: '" << sort_column << "', page_size: " << page_size << ", page_start: " << page_start << LL_ENDL; + // Did we get anything in content? - if(!content.size()) + if (!response.size()) { - LL_DEBUGS("GrpMgr") << "No group member data received." << LL_ENDL; + LL_INFOS("GrpMgr") << "No group member data received." << LL_ENDL; return; } - LLUUID group_id = content["group_id"].asUUID(); - LLGroupMgrGroupData* group_datap = getGroupData(group_id); - if(!group_datap) + if (!group_datap) { LL_WARNS("GrpMgr") << "Received incorrect, possibly stale, group or request id" << LL_ENDL; return; } - // If we have no members, there's no reason to do anything else - S32 num_members = content["member_count"]; - if (num_members < 1) - { - LL_INFOS("GrpMgr") << "Received empty group members list for group id: " << group_id.asString() << LL_ENDL; - // Set mMemberDataComplete for correct handling of empty responses. See MAINT-5237 - group_datap->mMemberDataComplete = true; - group_datap->mChanged = true; - LLGroupMgr::getInstance()->notifyObservers(GC_MEMBER_DATA); - return; - } - - group_datap->mMemberCount = num_members; + LLSD members = response["members"]; + LLSD titles = response["titles"]; + LLSD defaults = response["defaults"]; - LLSD member_list = content["members"]; - LLSD titles = content["titles"]; - LLSD defaults = content["defaults"]; - - std::string online_status; - std::string title; - S32 contribution; - U64 member_powers; - // If this is changed to a bool, make sure to change the LLGroupMemberData constructor - bool is_owner; + size_t members_before = group_datap->mMembers.size(); + size_t members_loaded = members.size(); // Compute this once, rather than every time. - U64 default_powers = llstrtou64(defaults["default_powers"].asString().c_str(), NULL, 16); + std::string default_title = titles.size() ? titles[0].asString() : LLStringUtil::null; + U64 default_powers = llstrtou64(defaults["default_powers"].asString().c_str(), NULL, 16); - LLSD::map_const_iterator member_iter_start = member_list.beginMap(); - LLSD::map_const_iterator member_iter_end = member_list.endMap(); - for( ; member_iter_start != member_iter_end; ++member_iter_start) + auto members_end = members.endMap(); + for (auto it = members.beginMap(); it != members_end; ++it) { // Reset defaults - online_status = "unknown"; - title = titles[0].asString(); - contribution = 0; - member_powers = default_powers; - is_owner = false; + std::string online_status = "unknown"; + std::string title = default_title; + U64 member_powers = default_powers; + S32 donated_square_meters = 0; + bool is_owner = false; - const LLUUID member_id(member_iter_start->first); - LLSD member_info = member_iter_start->second; + const LLUUID member_id(it->first); + LLSD member_info = it->second; - if(member_info.has("last_login")) + if (member_info.has("last_login")) { online_status = member_info["last_login"].asString(); - if(online_status == "Online") + if (online_status == "Online") + { online_status = LLTrans::getString("group_member_status_online"); + } else + { formatDateString(online_status); + } } - if(member_info.has("title")) + if (member_info.has("title")) + { title = titles[member_info["title"].asInteger()].asString(); + } - if(member_info.has("powers")) + if (member_info.has("powers")) + { member_powers = llstrtou64(member_info["powers"].asString().c_str(), NULL, 16); + } - if(member_info.has("donated_square_meters")) - contribution = member_info["donated_square_meters"]; + if (member_info.has("donated_square_meters")) + { + donated_square_meters = member_info["donated_square_meters"]; + } - if(member_info.has("owner")) + if (member_info.has("owner")) + { is_owner = true; + } LLGroupMemberData* data = new LLGroupMemberData(member_id, - contribution, - member_powers, - title, - online_status, - is_owner); - - LLGroupMemberData* member_old = group_datap->mMembers[member_id]; - if (member_old && group_datap->mRoleMemberDataComplete) - { - LLGroupMemberData::role_list_t::iterator rit = member_old->roleBegin(); - LLGroupMemberData::role_list_t::iterator end = member_old->roleEnd(); + donated_square_meters, member_powers, title, online_status, is_owner); - for ( ; rit != end; ++rit) + if (group_datap->mRoleMemberDataComplete) + { + if (LLGroupMemberData* member_old = group_datap->mMembers[member_id]) { - data->addRole((*rit).first,(*rit).second); + auto role_end = member_old->roleEnd(); + for (auto role_it = member_old->roleBegin(); role_it != role_end; ++role_it) + { + data->addRole(role_it->first, role_it->second); + } + } + else + { + group_datap->mRoleMemberDataComplete = false; } - } - else - { - group_datap->mRoleMemberDataComplete = false; } group_datap->mMembers[member_id] = data; } + group_datap->mMemberCount = (S32)group_datap->mMembers.size(); + group_datap->mMemberDataComplete = true; + group_datap->mMemberRequestID.setNull(); group_datap->mMemberVersion.generate(); + LL_INFOS("GrpMgr") << "members before: " << members_before + << ", members loaded: " << members_loaded + << ", members now: " << group_datap->mMemberCount << LL_ENDL; + // Technically, we have this data, but to prevent completely overhauling // this entire system (it would be nice, but I don't have the time), // I'm going to be dumb and just call services I most likely don't need @@ -2342,12 +2348,16 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) // // TODO: // Refactor to reduce multiple calls for data we already have. - if(group_datap->mTitles.size() < 1) + if (group_datap->mTitles.size() < 1) + { sendGroupTitlesRequest(group_id); + } + if (page_size && members_loaded >= page_size) + { + sendCapGroupMembersRequest(group_id, page_size, (U32)group_datap->mMemberCount, sort_column); + } - group_datap->mMemberDataComplete = true; - group_datap->mMemberRequestID.setNull(); // Make the role-member data request if (group_datap->mPendingRoleMemberRequest || !group_datap->mRoleMemberDataComplete) { @@ -2357,10 +2367,8 @@ void LLGroupMgr::processCapGroupMembersRequest(const LLSD& content) group_datap->mChanged = true; notifyObservers(GC_MEMBER_DATA); - } - void LLGroupMgr::sendGroupRoleChanges(const LLUUID& group_id) { LL_DEBUGS("GrpMgr") << "LLGroupMgr::sendGroupRoleChanges" << LL_ENDL; @@ -2379,9 +2387,11 @@ void LLGroupMgr::sendGroupRoleChanges(const LLUUID& group_id) void LLGroupMgr::cancelGroupRoleChanges(const LLUUID& group_id) { LL_DEBUGS("GrpMgr") << "LLGroupMgr::cancelGroupRoleChanges" << LL_ENDL; - LLGroupMgrGroupData* group_datap = getGroupData(group_id); - if (group_datap) group_datap->cancelRoleChanges(); + if (LLGroupMgrGroupData* group_datap = getGroupData(group_id)) + { + group_datap->cancelRoleChanges(); + } } //static @@ -2503,5 +2513,3 @@ void LLGroupMgr::debugClearAllGroups(void*) LLGroupMgr::getInstance()->clearGroups(); LLGroupMgr::parseRoleActions("role_actions.xml"); } - - diff --git a/indra/newview/llgroupmgr.h b/indra/newview/llgroupmgr.h index 18efae7654..f96c5ccc14 100644 --- a/indra/newview/llgroupmgr.h +++ b/indra/newview/llgroupmgr.h @@ -403,7 +403,7 @@ public: bool mature_publish); static void sendGroupMemberJoin(const LLUUID& group_id); - static void sendGroupMemberInvites(const LLUUID& group_id, std::map<LLUUID,LLUUID>& role_member_pairs); + static void sendGroupMemberInvites(const LLUUID& group_id, std::map<LLUUID, LLUUID>& role_member_pairs); static void sendGroupMemberEjects(const LLUUID& group_id, uuid_vec_t& member_ids); @@ -413,7 +413,8 @@ public: const uuid_vec_t &ban_list = uuid_vec_t()); - void sendCapGroupMembersRequest(const LLUUID& group_id); + void sendCapGroupMembersRequest(const LLUUID& group_id, + U32 page_size = 0, U32 page_start = 0, const std::string& sort_column = LLStringUtil::null); void cancelGroupRoleChanges(const LLUUID& group_id); @@ -436,16 +437,15 @@ public: void clearGroupData(const LLUUID& group_id); private: - void groupMembersRequestCoro(std::string url, LLUUID groupId); - void processCapGroupMembersRequest(const LLSD& content); + void groupMembersRequestCoro(std::string url, LLUUID group_id, U32 page_size, U32 page_start, std::string sort_column); + void processCapGroupMembersResponse(const LLSD& response, U32 page_size, U32 page_start, const std::string& sort_column); - void getGroupBanRequestCoro(std::string url, LLUUID groupId); - void postGroupBanRequestCoro(std::string url, LLUUID groupId, U32 action, uuid_vec_t banList, bool update); + void getGroupBanRequestCoro(std::string url, LLUUID group_id); + void postGroupBanRequestCoro(std::string url, LLUUID group_id, U32 action, uuid_vec_t ban_list, bool update); static void processGroupBanRequest(const LLSD& content); void notifyObservers(LLGroupChange gc); - void notifyObserver(const LLUUID& group_id, LLGroupChange gc); void addGroup(LLGroupMgrGroupData* group_datap); LLGroupMgrGroupData* createGroupData(const LLUUID &id); bool hasPendingPropertyRequest(const LLUUID& id); @@ -465,7 +465,7 @@ private: typedef std::map<LLUUID,observer_set_t> observer_map_t; observer_map_t mParticularObservers; - bool mMemberRequestInFlight; + bool mMemberRequestInFlight { false }; }; diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index 66ccdd2b32..91051f8235 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -98,7 +98,7 @@ void LLHeroProbeManager::update() if (mMipChain.empty()) { U32 res = mProbeResolution; - U32 count = log2((F32)res) + 0.5f; + U32 count = (U32)(log2((F32)res) + 0.5f); mMipChain.resize(count); for (U32 i = 0; i < count; ++i) @@ -121,6 +121,7 @@ void LLHeroProbeManager::update() // Find our nearest hero candidate. float last_distance = 99999.f; float camera_center_distance = 99999.f; + mNearestHero = nullptr; for (auto vo : mHeroVOList) { if (vo && !vo->isDead() && vo->mDrawable.notNull() && vo->isReflectionProbe() && vo->getReflectionProbeIsBox()) @@ -194,11 +195,17 @@ void LLHeroProbeManager::update() else { mNearestHero = nullptr; + mDefaultProbe->mViewerObject = nullptr; } mHeroProbeStrength = 1; } + else + { + mNearestHero = nullptr; + mDefaultProbe->mViewerObject = nullptr; } +} void LLHeroProbeManager::renderProbes() { @@ -334,7 +341,7 @@ void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face, bool gGaussianProgram.unbind(); } - S32 mips = log2((F32)mProbeResolution) + 0.5f; + S32 mips = (S32)(log2((F32)mProbeResolution) + 0.5f); gReflectionMipProgram.bind(); S32 diffuseChannel = gReflectionMipProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_TEXTURE); @@ -424,7 +431,7 @@ void LLHeroProbeManager::generateRadiance(LLReflectionMap* probe) static LLStaticHashedString sStrength("probe_strength"); gHeroRadianceGenProgram.uniform1f(sRoughness, (F32) i / (F32) (mMipChain.size() - 1)); - gHeroRadianceGenProgram.uniform1f(sMipLevel, i); + gHeroRadianceGenProgram.uniform1f(sMipLevel, (GLfloat)i); gHeroRadianceGenProgram.uniform1i(sWidth, mProbeResolution); gHeroRadianceGenProgram.uniform1f(sStrength, 1); @@ -526,7 +533,7 @@ void LLHeroProbeManager::initReflectionMaps() mReset = false; mReflectionProbeCount = count; mProbeResolution = gSavedSettings.getS32("RenderHeroProbeResolution"); - mMaxProbeLOD = log2f(mProbeResolution) - 1.f; // number of mips - 1 + mMaxProbeLOD = log2f((F32)mProbeResolution) - 1.f; // number of mips - 1 mTexture = new LLCubeMapArray(); diff --git a/indra/newview/llhttpretrypolicy.cpp b/indra/newview/llhttpretrypolicy.cpp index 44d33eec93..3e55030610 100644 --- a/indra/newview/llhttpretrypolicy.cpp +++ b/indra/newview/llhttpretrypolicy.cpp @@ -180,7 +180,7 @@ bool LLAdaptiveRetryPolicy::getSecondsUntilRetryAfter(const std::string& retry_a time_t date = curl_getdate(retry_after.c_str(), NULL); if (-1 == date) return false; - seconds_to_wait = (F64)date - LLTimer::getTotalSeconds(); + seconds_to_wait = (F32)((F64)date - LLTimer::getTotalSeconds()); return true; } diff --git a/indra/newview/llhudnametag.cpp b/indra/newview/llhudnametag.cpp index e1bf6c2077..4011a857e5 100644 --- a/indra/newview/llhudnametag.cpp +++ b/indra/newview/llhudnametag.cpp @@ -449,7 +449,7 @@ void LLHUDNameTag::addLine(const std::string &text_utf8, // token does does not fit into signle line, need to draw "...". // Use four dots for ellipsis width to generate padding const LLWString dots_pad(utf8str_to_wstring(std::string("...."))); - S32 elipses_width = font->getWidthF32(dots_pad.c_str()); + S32 elipses_width = (S32)font->getWidthF32(dots_pad.c_str()); // truncated string length segment_length = font->maxDrawableChars(iter->substr(line_length).c_str(), max_pixels - elipses_width, static_cast<S32>(wline.length()), LLFontGL::ANYWHERE); const LLWString dots(utf8str_to_wstring(std::string("..."))); @@ -780,7 +780,7 @@ void LLHUDNameTag::updateAll() } LLTrace::CountStatHandle<>* camera_vel_stat = LLViewerCamera::getVelocityStat(); - F32 camera_vel = LLTrace::get_frame_recording().getLastRecording().getPerSec(*camera_vel_stat); + F32 camera_vel = (F32)LLTrace::get_frame_recording().getLastRecording().getPerSec(*camera_vel_stat); if (camera_vel > MAX_STABLE_CAMERA_VELOCITY) { return; diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp index e2e83ef42b..e24274650d 100644 --- a/indra/newview/llimprocessing.cpp +++ b/indra/newview/llimprocessing.cpp @@ -1607,7 +1607,7 @@ void LLIMProcessing::requestOfflineMessagesCoro(std::string url) } else { - position.set(message_data["local_x"].asReal(), message_data["local_y"].asReal(), message_data["local_z"].asReal()); + position.set((F32)message_data["local_x"].asReal(), (F32)message_data["local_y"].asReal(), (F32)message_data["local_z"].asReal()); } std::vector<U8> bin_bucket; diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp index 05b1fec8e5..33e6d2d1b2 100644 --- a/indra/newview/llimview.cpp +++ b/indra/newview/llimview.cpp @@ -372,8 +372,10 @@ void notify_of_message(const LLSD& msg, bool is_dnd_msg) // 4. Toast if ((("toast" == user_preferences) && (ON_TOP_AND_ITEM_IS_SELECTED != conversations_floater_status) && - (!session_floater->isTornOff() || !LLFloater::isVisible(session_floater))) - || !session_floater->isMessagePaneExpanded()) + (!session_floater->isTornOff() + || session_floater->isMinimized() + || !LLFloater::isVisible(session_floater))) + || !session_floater->isMessagePaneExpanded()) { //Show IM toasts (upper right toasts) @@ -3040,13 +3042,16 @@ void LLIncomingCallDialog::processCallResponse(S32 response, const LLSD &payload gIMMgr->addSession(correct_session_name, type, session_id, payload["voice_channel_info"]); - std::string url = gAgent.getRegion()->getCapability( + std::string url = gAgent.getRegionCapability( "ChatSessionRequest"); if (voice) { - LLCoros::instance().launch("chatterBoxInvitationCoro", - boost::bind(&chatterBoxInvitationCoro, url, session_id, inv_type, payload["voice_channel_info"])); + if(!url.empty()) + { + LLCoros::instance().launch("chatterBoxInvitationCoro", + boost::bind(&chatterBoxInvitationCoro, url, session_id, inv_type, payload["voice_channel_info"])); + } // send notification message to the corresponding chat if (payload["notify_box_type"].asString() == "VoiceInviteGroup" || payload["notify_box_type"].asString() == "VoiceInviteAdHoc") @@ -4061,9 +4066,12 @@ public: // Send request for chat history, if enabled. if (gSavedPerAccountSettings.getBOOL("FetchGroupChatHistory")) { - std::string url = gAgent.getRegion()->getCapability("ChatSessionRequest"); - LLCoros::instance().launch("chatterBoxHistoryCoro", - boost::bind(&chatterBoxHistoryCoro, url, session_id, "", "", 0)); + std::string url = gAgent.getRegionCapability("ChatSessionRequest"); + if (!url.empty()) + { + LLCoros::instance().launch("chatterBoxHistoryCoro", + boost::bind(&chatterBoxHistoryCoro, url, session_id, "", "", 0)); + } } } } @@ -4242,7 +4250,7 @@ public: message_params["region_id"].asUUID(), ll_vector3_from_sd(message_params["position"]), false, // is_region_message - timestamp); + (U32)timestamp); if (LLMuteList::getInstance()->isMuted(from_id, name, LLMute::flagTextChat)) { diff --git a/indra/newview/llinspecttexture.cpp b/indra/newview/llinspecttexture.cpp index 75366c4831..24dbe61bad 100644 --- a/indra/newview/llinspecttexture.cpp +++ b/indra/newview/llinspecttexture.cpp @@ -152,7 +152,7 @@ void LLTexturePreviewView::draw() bool isLoading = (!m_Image->isFullyLoaded()) && (m_Image->getDiscardLevel() > 0); if (isLoading) - LLFontGL::getFontSansSerif()->renderUTF8(mLoadingText, 0, llfloor(rctClient.mLeft + 3), llfloor(rctClient.mTop - 25), LLColor4::white, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::DROP_SHADOW); + LLFontGL::getFontSansSerif()->renderUTF8(mLoadingText, 0, rctClient.mLeft + 3, rctClient.mTop - 25, LLColor4::white, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::DROP_SHADOW); m_Image->addTextureStats((isLoading) ? MAX_IMAGE_AREA : (F32)(rctClient.getWidth() * rctClient.getHeight())); } } diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 81d738cf42..8f3dc3ce16 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -961,7 +961,7 @@ void LLInvFVBridge::getClipboardEntries(bool show_asset_id, } } - if (obj->getType() != LLAssetType::AT_CATEGORY) + if (obj && obj->getType() != LLAssetType::AT_CATEGORY) { items.push_back(std::string("Paste Separator")); } @@ -1190,6 +1190,7 @@ void LLInvFVBridge::addMarketplaceContextMenuOptions(U32 flags, || (U32)depth > (max_depth + 1)) { disabled_items.push_back(std::string("New Folder")); + disabled_items.push_back(std::string("New Listing Folder")); } } @@ -4268,6 +4269,7 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items if (LLMarketplaceData::instance().isUpdating(mUUID)) { disabled_items.push_back(std::string("New Folder")); + disabled_items.push_back(std::string("New Listing Folder")); disabled_items.push_back(std::string("Rename")); disabled_items.push_back(std::string("Cut")); disabled_items.push_back(std::string("Copy")); @@ -4278,12 +4280,14 @@ void LLFolderBridge::buildContextMenuOptions(U32 flags, menuentry_vec_t& items if (getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK) { disabled_items.push_back(std::string("New Folder")); + disabled_items.push_back(std::string("New Listing Folder")); disabled_items.push_back(std::string("upload_def")); disabled_items.push_back(std::string("create_new")); } if (marketplace_listings_id == mUUID) { disabled_items.push_back(std::string("New Folder")); + disabled_items.push_back(std::string("New Listing Folder")); disabled_items.push_back(std::string("Rename")); disabled_items.push_back(std::string("Cut")); disabled_items.push_back(std::string("Delete")); @@ -6289,7 +6293,7 @@ void LLCallingCardBridge::performAction(LLInventoryModel* model, std::string act if (item && (item->getCreatorUUID() != gAgent.getID()) && (!item->getCreatorUUID().isNull())) { - std::string callingcard_name = LLCacheName::getDefaultName(); + std::string callingcard_name = gCacheName->getDefaultName(); LLAvatarName av_name; if (LLAvatarNameCache::get(item->getCreatorUUID(), &av_name)) { diff --git a/indra/newview/llinventoryfilter.cpp b/indra/newview/llinventoryfilter.cpp index 114ccfdd3f..e3d4645701 100644 --- a/indra/newview/llinventoryfilter.cpp +++ b/indra/newview/llinventoryfilter.cpp @@ -1519,7 +1519,7 @@ LLInventoryFilter& LLInventoryFilter::operator=( const LLInventoryFilter& othe void LLInventoryFilter::toParams(Params& params) const { - params.filter_ops.types = getFilterObjectTypes(); + params.filter_ops.types = (U32)getFilterObjectTypes(); params.filter_ops.category_types = getFilterCategoryTypes(); if (getFilterObjectTypes() & FILTERTYPE_WEARABLE) { @@ -1532,7 +1532,7 @@ void LLInventoryFilter::toParams(Params& params) const params.filter_ops.show_folder_state = getShowFolderState(); params.filter_ops.creator_type = getFilterCreatorType(); params.filter_ops.permissions = getFilterPermissions(); - params.filter_ops.search_visibility = getSearchVisibilityTypes(); + params.filter_ops.search_visibility = (U32)getSearchVisibilityTypes(); params.substring = getFilterSubString(); params.since_logoff = isSinceLogoff(); } @@ -1646,7 +1646,7 @@ bool LLInventoryFilter::isTimedOut() void LLInventoryFilter::resetTime(S32 timeout) { mFilterTime.reset(); - F32 time_in_sec = (F32)(timeout)/1000.0; + F32 time_in_sec = (F32)(timeout)/1000.0f; mFilterTime.setTimerExpirySec(time_in_sec); } diff --git a/indra/newview/llinventorygallery.cpp b/indra/newview/llinventorygallery.cpp index c69f797868..98b3707457 100644 --- a/indra/newview/llinventorygallery.cpp +++ b/indra/newview/llinventorygallery.cpp @@ -2641,7 +2641,7 @@ bool LLInventoryGallery::checkAgainstFilterType(const LLUUID& object_id) { object_type = inv_item->getInventoryType(); } - const U32 filterTypes = mFilter->getFilterTypes(); + const U32 filterTypes = (U32)mFilter->getFilterTypes(); if ((filterTypes & LLInventoryFilter::FILTERTYPE_OBJECT) && inv_item) { diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp index 9dc13bcf09..9e4f4c0adc 100644 --- a/indra/newview/llinventorypanel.cpp +++ b/indra/newview/llinventorypanel.cpp @@ -425,7 +425,7 @@ void LLInventoryPanel::setFilterWorn() U32 LLInventoryPanel::getFilterObjectTypes() const { - return getFilter().getFilterObjectTypes(); + return (U32)getFilter().getFilterObjectTypes(); } U32 LLInventoryPanel::getFilterPermMask() const @@ -643,7 +643,7 @@ void LLInventoryPanel::itemChanged(const LLUUID& item_id, U32 mask, const LLInve } // Select any newly created object that has the auto rename at top of folder root set. - if(mFolderRoot.get()->getRoot()->needsAutoRename()) + if(mFolderRoot.get() && mFolderRoot.get()->getRoot()->needsAutoRename()) { setSelection(item_id, false); } @@ -2334,14 +2334,14 @@ void LLInventorySingleFolderPanel::clearNavigationHistory() mBackwardFolders.clear(); } -bool LLInventorySingleFolderPanel::isBackwardAvailable() +bool LLInventorySingleFolderPanel::isBackwardAvailable() const { - return (!mBackwardFolders.empty() && (mFolderID != mBackwardFolders.back())); + return !mBackwardFolders.empty() && (mFolderID != mBackwardFolders.back()); } -bool LLInventorySingleFolderPanel::isForwardAvailable() +bool LLInventorySingleFolderPanel::isForwardAvailable() const { - return (!mForwardFolders.empty() && (mFolderID != mForwardFolders.back())); + return !mForwardFolders.empty() && (mFolderID != mForwardFolders.back()); } boost::signals2::connection LLInventorySingleFolderPanel::setRootChangedCallback(root_changed_callback_t cb) @@ -2406,9 +2406,14 @@ void LLInventorySingleFolderPanel::updateSingleFolderRoot() } } -bool LLInventorySingleFolderPanel::hasVisibleItems() +bool LLInventorySingleFolderPanel::hasVisibleItems() const { - return mFolderRoot.get()->hasVisibleChildren(); + if (const LLFolderView* root = mFolderRoot.get()) + { + return root->hasVisibleChildren(); + } + + return false; } void LLInventorySingleFolderPanel::doCreate(const LLSD& userdata) diff --git a/indra/newview/llinventorypanel.h b/indra/newview/llinventorypanel.h index 6dead2cf6d..56909c8d98 100644 --- a/indra/newview/llinventorypanel.h +++ b/indra/newview/llinventorypanel.h @@ -420,10 +420,10 @@ public: void doToSelected(const LLSD& userdata); void doShare(); - bool isBackwardAvailable(); - bool isForwardAvailable(); + bool isBackwardAvailable() const; + bool isForwardAvailable() const; - bool hasVisibleItems(); + bool hasVisibleItems() const; void setNavBackwardList(std::list<LLUUID> backward_list) { mBackwardFolders = backward_list; } void setNavForwardList(std::list<LLUUID> forward_list) { mForwardFolders = forward_list; } diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index 00dbf9a9f8..4eaf69c39d 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -732,8 +732,8 @@ LLJoystickQuaternion::LLJoystickQuaternion(const LLJoystickQuaternion::Params &p { for (int i = 0; i < 3; ++i) { - mLfRtAxis.mV[i] = (mXAxisIndex == i) ? 1.0 : 0.0; - mUpDnAxis.mV[i] = (mYAxisIndex == i) ? 1.0 : 0.0; + mLfRtAxis.mV[i] = (mXAxisIndex == i) ? 1.0f : 0.0f; + mUpDnAxis.mV[i] = (mYAxisIndex == i) ? 1.0f : 0.0f; } } @@ -864,8 +864,8 @@ void LLJoystickQuaternion::draw() LLVector3 draw_point = mVectorZero * mRotation; S32 halfwidth = getRect().getWidth() / 2; S32 halfheight = getRect().getHeight() / 2; - draw_point.mV[mXAxisIndex] = (draw_point.mV[mXAxisIndex] + 1.0) * halfwidth; - draw_point.mV[mYAxisIndex] = (draw_point.mV[mYAxisIndex] + 1.0) * halfheight; + draw_point.mV[mXAxisIndex] = (draw_point.mV[mXAxisIndex] + 1.0f) * halfwidth; + draw_point.mV[mYAxisIndex] = (draw_point.mV[mYAxisIndex] + 1.0f) * halfheight; gl_circle_2d(draw_point.mV[mXAxisIndex], draw_point.mV[mYAxisIndex], 4, 8, draw_point.mV[mZAxisIndex] >= 0.f); diff --git a/indra/newview/lllocalbitmaps.cpp b/indra/newview/lllocalbitmaps.cpp index 6ab5e05b7d..0e2b3cb409 100644 --- a/indra/newview/lllocalbitmaps.cpp +++ b/indra/newview/lllocalbitmaps.cpp @@ -215,7 +215,6 @@ bool LLLocalBitmap::updateSelf(EUpdateType optional_firstupdate) ("file://"+mFilename, FTT_LOCAL_FILE, mWorldID, LL_LOCAL_USE_MIPMAPS); texture->createGLTexture(LL_LOCAL_DISCARD_LEVEL, raw_image); - texture->setCachedRawImage(LL_LOCAL_DISCARD_LEVEL, raw_image); texture->ref(); gTextureList.addImage(texture, TEX_LIST_STANDARD); diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 282a273be6..f37926a938 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -33,9 +33,6 @@ #include "stringize.h" #include "llsdserialize.h" -// llmessage (!) -#include "llfiltersd2xmlrpc.h" // for xml_escape_string() - // login #include "lllogin.h" @@ -450,7 +447,7 @@ void LLLoginInstance::handleLoginFailure(const LLSD& event) gViewerWindow->setShowProgress(false); } - showMFAChallange(LLTrans::getString(response["message_id"])); + showMFAChallange(LLTrans::getString(response["message_id"].asString())); } else if( reason_response == "key" || reason_response == "presence" @@ -612,7 +609,7 @@ std::string construct_start_string() << position[VX] << "&" << position[VY] << "&" << position[VZ]); - start = xml_escape_string(unescaped_start); + start = LLStringFn::xml_encode(unescaped_start, true); break; } case LLSLURL::HOME_LOCATION: diff --git a/indra/newview/llmachineid.cpp b/indra/newview/llmachineid.cpp index d572605635..aa03001389 100644 --- a/indra/newview/llmachineid.cpp +++ b/indra/newview/llmachineid.cpp @@ -293,7 +293,7 @@ bool LLWMIMethods::getGenericSerialNumber(const BSTR &select, const LPCWSTR &var if (validate_as_uuid) { std::wstring ws(serialNumber, serial_size); - std::string str(ws.begin(), ws.end()); + std::string str = ll_convert_wide_to_string(ws); if (!LLUUID::validate(str)) { diff --git a/indra/newview/llmanip.cpp b/indra/newview/llmanip.cpp index 2adb506c0f..0c82db1011 100644 --- a/indra/newview/llmanip.cpp +++ b/indra/newview/llmanip.cpp @@ -450,10 +450,10 @@ void LLManip::renderXYZ(const LLVector3 &vec) gGL.color4f(0.f, 0.f, 0.f, 0.7f); imagep->draw( - (window_center_x - 115) * display_scale.mV[VX], - (window_center_y + vertical_offset - PAD) * display_scale.mV[VY], - 235 * display_scale.mV[VX], - (PAD * 2 + 10) * display_scale.mV[VY], + (S32)((window_center_x - 115) * display_scale.mV[VX]), + (S32)((window_center_y + vertical_offset - PAD) * display_scale.mV[VY]), + (S32)(235 * display_scale.mV[VX]), + (S32)((PAD * 2 + 10) * display_scale.mV[VY]), LLColor4(0.f, 0.f, 0.f, 0.7f) ); LLFontGL* font = LLFontGL::getFontSansSerif(); @@ -463,33 +463,33 @@ void LLManip::renderXYZ(const LLVector3 &vec) // render drop shadowed text (manually because of bigger 'distance') F32 right_x; feedback_string = llformat("X: %.3f", vec.mV[VX]); - font->render(utf8str_to_wstring(feedback_string), 0, window_center_x - 102.f + 1.f, window_center_y + vertical_offset - 2.f, LLColor4::black, + font->render(utf8str_to_wstring(feedback_string), 0, window_center_x - 102.f + 1.f, (F32)(window_center_y + vertical_offset) - 2.f, LLColor4::black, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, 1000, &right_x); feedback_string = llformat("Y: %.3f", vec.mV[VY]); - font->render(utf8str_to_wstring(feedback_string), 0, window_center_x - 27.f + 1.f, window_center_y + vertical_offset - 2.f, LLColor4::black, + font->render(utf8str_to_wstring(feedback_string), 0, window_center_x - 27.f + 1.f, (F32)(window_center_y + vertical_offset) - 2.f, LLColor4::black, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, 1000, &right_x); feedback_string = llformat("Z: %.3f", vec.mV[VZ]); - font->render(utf8str_to_wstring(feedback_string), 0, window_center_x + 48.f + 1.f, window_center_y + vertical_offset - 2.f, LLColor4::black, + font->render(utf8str_to_wstring(feedback_string), 0, window_center_x + 48.f + 1.f, (F32)(window_center_y + vertical_offset) - 2.f, LLColor4::black, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, 1000, &right_x); // render text on top feedback_string = llformat("X: %.3f", vec.mV[VX]); - font->render(utf8str_to_wstring(feedback_string), 0, window_center_x - 102.f, window_center_y + vertical_offset, LLColor4(1.f, 0.5f, 0.5f, 1.f), + font->render(utf8str_to_wstring(feedback_string), 0, window_center_x - 102.f, (F32)(window_center_y + vertical_offset), LLColor4(1.f, 0.5f, 0.5f, 1.f), LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, 1000, &right_x); feedback_string = llformat("Y: %.3f", vec.mV[VY]); - font->render(utf8str_to_wstring(feedback_string), 0, window_center_x - 27.f, window_center_y + vertical_offset, LLColor4(0.5f, 1.f, 0.5f, 1.f), + font->render(utf8str_to_wstring(feedback_string), 0, window_center_x - 27.f, (F32)(window_center_y + vertical_offset), LLColor4(0.5f, 1.f, 0.5f, 1.f), LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, 1000, &right_x); feedback_string = llformat("Z: %.3f", vec.mV[VZ]); - font->render(utf8str_to_wstring(feedback_string), 0, window_center_x + 48.f, window_center_y + vertical_offset, LLColor4(0.5f, 0.5f, 1.f, 1.f), + font->render(utf8str_to_wstring(feedback_string), 0, window_center_x + 48.f, (F32)(window_center_y + vertical_offset), LLColor4(0.5f, 0.5f, 1.f, 1.f), LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, 1000, &right_x); } diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp index c4f3f01ea1..ffb66dc6cc 100644 --- a/indra/newview/llmanipscale.cpp +++ b/indra/newview/llmanipscale.cpp @@ -884,7 +884,7 @@ void LLManipScale::dragCorner( S32 x, S32 y ) { F32 drag_dist = mScaleDir * projected_drag_pos1; // Projecting the drag position allows for negative results, vs using the length which will result in a "reverse scaling" bug. - F32 cur_subdivisions = llclamp(getSubdivisionLevel(mScaleCenter + projected_drag_pos1, mScaleDir, mScaleSnapUnit1, mTickPixelSpacing1), sGridMinSubdivisionLevel, sGridMaxSubdivisionLevel); + F32 cur_subdivisions = llclamp(getSubdivisionLevel(mScaleCenter + projected_drag_pos1, mScaleDir, mScaleSnapUnit1, (S32)mTickPixelSpacing1), sGridMinSubdivisionLevel, sGridMaxSubdivisionLevel); F32 snap_dist = mScaleSnapUnit1 / (2.f * cur_subdivisions); F32 relative_snap_dist = fmodf(drag_dist + snap_dist, mScaleSnapUnit1 / cur_subdivisions); @@ -902,7 +902,7 @@ void LLManipScale::dragCorner( S32 x, S32 y ) { F32 drag_dist = mScaleDir * projected_drag_pos2; // Projecting the drag position allows for negative results, vs using the length which will result in a "reverse scaling" bug. - F32 cur_subdivisions = llclamp(getSubdivisionLevel(mScaleCenter + projected_drag_pos2, mScaleDir, mScaleSnapUnit2, mTickPixelSpacing2), sGridMinSubdivisionLevel, sGridMaxSubdivisionLevel); + F32 cur_subdivisions = llclamp(getSubdivisionLevel(mScaleCenter + projected_drag_pos2, mScaleDir, mScaleSnapUnit2, (S32)mTickPixelSpacing2), sGridMinSubdivisionLevel, sGridMaxSubdivisionLevel); F32 snap_dist = mScaleSnapUnit2 / (2.f * cur_subdivisions); F32 relative_snap_dist = fmodf(drag_dist + snap_dist, mScaleSnapUnit2 / cur_subdivisions); @@ -1113,7 +1113,7 @@ void LLManipScale::dragFace( S32 x, S32 y ) else { F32 drag_dist = scale_center_to_mouse * mScaleDir; - F32 cur_subdivisions = llclamp(getSubdivisionLevel(mScaleCenter + mScaleDir * drag_dist, mScaleDir, mScaleSnapUnit1, mTickPixelSpacing1), sGridMinSubdivisionLevel, sGridMaxSubdivisionLevel); + F32 cur_subdivisions = llclamp(getSubdivisionLevel(mScaleCenter + mScaleDir * drag_dist, mScaleDir, mScaleSnapUnit1, (S32)mTickPixelSpacing1), sGridMinSubdivisionLevel, sGridMaxSubdivisionLevel); F32 snap_dist = mScaleSnapUnit1 / (2.f * cur_subdivisions); F32 relative_snap_dist = fmodf(drag_dist + snap_dist, mScaleSnapUnit1 / cur_subdivisions); relative_snap_dist -= snap_dist; @@ -1542,8 +1542,8 @@ void LLManipScale::updateSnapGuides(const LLBBox& bbox) mScaleSnapUnit1 = mScaleSnapUnit1 / (mSnapDir1 * mScaleDir); mScaleSnapUnit2 = mScaleSnapUnit2 / (mSnapDir2 * mScaleDir); - mTickPixelSpacing1 = ll_round((F32)MIN_DIVISION_PIXEL_WIDTH / (mScaleDir % mSnapGuideDir1).length()); - mTickPixelSpacing2 = ll_round((F32)MIN_DIVISION_PIXEL_WIDTH / (mScaleDir % mSnapGuideDir2).length()); + mTickPixelSpacing1 = (F32)ll_round((F32)MIN_DIVISION_PIXEL_WIDTH / (mScaleDir % mSnapGuideDir1).length()); + mTickPixelSpacing2 = (F32)ll_round((F32)MIN_DIVISION_PIXEL_WIDTH / (mScaleDir % mSnapGuideDir2).length()); if (uniform) { @@ -1608,8 +1608,8 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox) F32 dist_scale_units_2 = dist_grid_axis / smallest_subdivision2; // find distance to nearest smallest grid unit - F32 grid_multiple1 = llfloor(dist_scale_units_1); - F32 grid_multiple2 = llfloor(dist_scale_units_2); + F32 grid_multiple1 = (F32)llfloor(dist_scale_units_1); + F32 grid_multiple2 = (F32)llfloor(dist_scale_units_2); F32 grid_offset1 = fmodf(dist_grid_axis, smallest_subdivision1); F32 grid_offset2 = fmodf(dist_grid_axis, smallest_subdivision2); diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 92f8ed949e..dde238eddb 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -648,7 +648,7 @@ void LLMaterialEditor::setBaseColor(const LLColor4& color) F32 LLMaterialEditor::getTransparency() { - return childGetValue("transparency").asReal(); + return (F32)childGetValue("transparency").asReal(); } void LLMaterialEditor::setTransparency(F32 transparency) @@ -668,7 +668,7 @@ void LLMaterialEditor::setAlphaMode(const std::string& alpha_mode) F32 LLMaterialEditor::getAlphaCutoff() { - return childGetValue("alpha cutoff").asReal(); + return (F32)childGetValue("alpha cutoff").asReal(); } void LLMaterialEditor::setAlphaCutoff(F32 alpha_cutoff) @@ -708,7 +708,7 @@ void LLMaterialEditor::setMetallicRoughnessUploadId(const LLUUID& id) F32 LLMaterialEditor::getMetalnessFactor() { - return childGetValue("metalness factor").asReal(); + return (F32)childGetValue("metalness factor").asReal(); } void LLMaterialEditor::setMetalnessFactor(F32 factor) @@ -718,7 +718,7 @@ void LLMaterialEditor::setMetalnessFactor(F32 factor) F32 LLMaterialEditor::getRoughnessFactor() { - return childGetValue("roughness factor").asReal(); + return (F32)childGetValue("roughness factor").asReal(); } void LLMaterialEditor::setRoughnessFactor(F32 factor) @@ -2430,14 +2430,14 @@ void LLMaterialEditor::onSaveObjectsMaterialAsMsgCallback(const LLSD& notificati createInventoryItem(str.str(), new_name, std::string(), permissions); } -const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter type); +const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter type, bool allow_2k); void LLMaterialEditor::loadMaterial(const tinygltf::Model &model_in, const std::string &filename, S32 index, bool open_floater) { if (index == model_in.materials.size()) { // bulk upload all the things - upload_bulk({ filename }, LLFilePicker::FFLOAD_MATERIAL); + upload_bulk({ filename }, LLFilePicker::FFLOAD_MATERIAL, true); return; } @@ -2618,13 +2618,13 @@ bool LLMaterialEditor::setFromGltfModel(const tinygltf::Model& model, S32 index, } setAlphaMode(material_in.alphaMode); - setAlphaCutoff(material_in.alphaCutoff); + setAlphaCutoff((F32)material_in.alphaCutoff); setBaseColor(LLTinyGLTFHelper::getColor(material_in.pbrMetallicRoughness.baseColorFactor)); setEmissiveColor(LLTinyGLTFHelper::getColor(material_in.emissiveFactor)); - setMetalnessFactor(material_in.pbrMetallicRoughness.metallicFactor); - setRoughnessFactor(material_in.pbrMetallicRoughness.roughnessFactor); + setMetalnessFactor((F32)material_in.pbrMetallicRoughness.metallicFactor); + setRoughnessFactor((F32)material_in.pbrMetallicRoughness.roughnessFactor); setDoubleSided(material_in.doubleSided); } diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 01c922df16..c02a12e6b2 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1685,9 +1685,7 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, bool c file.read(buffer, bytes); if (headerReceived(mesh_params, buffer, bytes) == MESH_OK) { - std::string mid; - mesh_params.getSculptID().toString(mid); - LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh header for ID " << mid << " - was retrieved from the cache." << LL_ENDL; + LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh header for ID " << mesh_params.getSculptID() << " - was retrieved from the cache." << LL_ENDL; // Found mesh in cache return true; @@ -1703,9 +1701,7 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, bool c if (!http_url.empty()) { - std::string mid; - mesh_params.getSculptID().toString(mid); - LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh header for ID " << mid << " - was retrieved from the simulator." << LL_ENDL; + LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh header for ID " << mesh_params.getSculptID() << " - was retrieved from the simulator." << LL_ENDL; //grab first 4KB if we're going to bother with a fetch. Cache will prevent future fetches if a full mesh fits //within the first 4KB @@ -1793,9 +1789,7 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod, { delete[] buffer; - std::string mid; - mesh_id.toString(mid); - LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh body for ID " << mid << " - was retrieved from the cache." << LL_ENDL; + LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh body for ID " << mesh_id << " - was retrieved from the cache." << LL_ENDL; return true; } @@ -1810,9 +1804,7 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod, if (!http_url.empty()) { - std::string mid; - mesh_id.toString(mid); - LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh body for ID " << mid << " - was retrieved from the simulator." << LL_ENDL; + LL_DEBUGS(LOG_MESH) << "Mesh/Cache: Mesh body for ID " << mesh_id << " - was retrieved from the simulator." << LL_ENDL; LLMeshHandlerBase::ptr_t handler(new LLMeshLODHandler(mesh_params, lod, offset, size)); LLCore::HttpHandle handle = getByteRange(http_url, offset, size, handler); @@ -1869,7 +1861,7 @@ EMeshProcessingResult LLMeshRepoThread::headerReceived(const LLVolumeParams& mes llssize dsize = data_size; char* result_ptr = strip_deprecated_header((char*)data, dsize, &header_size); - data_size = dsize; + data_size = (S32)dsize; boost::iostreams::stream<boost::iostreams::array_source> stream(result_ptr, data_size); @@ -1910,8 +1902,8 @@ EMeshProcessingResult LLMeshRepoThread::headerReceived(const LLVolumeParams& mes { LLMutexLock lock(mHeaderMutex); - mMeshHeader[mesh_id] = { header_size, header }; - LLMeshRepository::sCacheBytesHeaders += header_size; + mMeshHeader[mesh_id] = { (U32)header_size, header }; + LLMeshRepository::sCacheBytesHeaders += (U32)header_size; } LLMutexLock lock(mMutex); // make sure only one thread access mPendingLOD at the same time. @@ -4607,7 +4599,8 @@ F32 LLMeshRepository::getStreamingCostLegacy(LLMeshHeader& header, F32 radius, S *unscaled_value = weighted_avg; } - return weighted_avg/gSavedSettings.getU32("MeshTriangleBudget")*15000.f; + static LLCachedControl<U32> mesh_triangle_budget(gSavedSettings, "MeshTriangleBudget"); + return weighted_avg / mesh_triangle_budget * 15000.f; } LLMeshCostData::LLMeshCostData() @@ -4758,12 +4751,13 @@ F32 LLMeshCostData::getEstTrisForStreamingCost() F32 LLMeshCostData::getRadiusBasedStreamingCost(F32 radius) { - return getRadiusWeightedTris(radius)/gSavedSettings.getU32("MeshTriangleBudget")*15000.f; + static LLCachedControl<U32> mesh_triangle_budget(gSavedSettings, "MeshTriangleBudget"); + return getRadiusWeightedTris(radius)/mesh_triangle_budget*15000.f; } F32 LLMeshCostData::getTriangleBasedStreamingCost() { - F32 result = ANIMATED_OBJECT_COST_PER_KTRI * 0.001 * getEstTrisForStreamingCost(); + F32 result = ANIMATED_OBJECT_COST_PER_KTRI * 0.001f * getEstTrisForStreamingCost(); return result; } @@ -5334,8 +5328,9 @@ bool LLMeshRepository::meshUploadEnabled() bool LLMeshRepository::meshRezEnabled() { + static LLCachedControl<bool> mesh_enabled(gSavedSettings, "MeshEnabled"); LLViewerRegion *region = gAgent.getRegion(); - if(gSavedSettings.getBOOL("MeshEnabled") && + if(mesh_enabled && region) { return region->meshRezEnabled(); @@ -5473,7 +5468,7 @@ void on_new_single_inventory_upload_complete( LL_INFOS() << "inventory_item_flags " << inventory_item_flags << LL_ENDL; } } - S32 creation_date_now = time_corrected(); + S32 creation_date_now = (S32)time_corrected(); LLPointer<LLViewerInventoryItem> item = new LLViewerInventoryItem( server_response["new_inventory_item"].asUUID(), item_folder_id, diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index b1a48db0ee..df573bd785 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -242,7 +242,7 @@ void LLModelPreview::updateDimentionsAndOffsets() std::set<LLModel*> accounted; - mPelvisZOffset = mFMP ? mFMP->childGetValue("pelvis_offset").asReal() : 3.0f; + mPelvisZOffset = mFMP ? (F32)mFMP->childGetValue("pelvis_offset").asReal() : 3.0f; if (mFMP && mFMP->childGetValue("upload_joints").asBoolean()) { @@ -272,7 +272,7 @@ void LLModelPreview::updateDimentionsAndOffsets() } } - F32 scale = mFMP ? mFMP->childGetValue("import_scale").asReal()*2.f : 2.f; + F32 scale = mFMP ? (F32)mFMP->childGetValue("import_scale").asReal()*2.f : 2.f; mDetailsSignal((F32)(mPreviewScale[0] * scale), (F32)(mPreviewScale[1] * scale), (F32)(mPreviewScale[2] * scale)); @@ -293,7 +293,7 @@ void LLModelPreview::rebuildUploadData() LLSpinCtrl* scale_spinner = mFMP->getChild<LLSpinCtrl>("import_scale"); - F32 scale = scale_spinner->getValue().asReal(); + F32 scale = (F32)scale_spinner->getValue().asReal(); LLMatrix4 scale_mat; scale_mat.initScale(LLVector3(scale, scale, scale)); @@ -1290,7 +1290,7 @@ void LLModelPreview::generateNormals() return; } - F32 angle_cutoff = mFMP->childGetValue("crease_angle").asReal(); + F32 angle_cutoff = (F32)mFMP->childGetValue("crease_angle").asReal(); mRequestedCreaseAngle[which_lod] = angle_cutoff; @@ -1489,7 +1489,7 @@ F32 LLModelPreview::genMeshOptimizerPerModel(LLModel *base_model, LLModel *targe target_indices = 3; } - size_new_indices = LLMeshOptimizer::simplifyU32( + size_new_indices = (S32)LLMeshOptimizer::simplifyU32( output_indices, source_indices, size_indices, @@ -1730,7 +1730,7 @@ F32 LLModelPreview::genMeshOptimizerPerFace(LLModel *base_model, LLModel *target target_indices = 3; } - size_new_indices = LLMeshOptimizer::simplify( + size_new_indices = (S32)LLMeshOptimizer::simplify( output_indices, source_indices, size_indices, @@ -1851,7 +1851,7 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d { if (!enforce_tri_limit) { - triangle_limit = base_triangle_count; + triangle_limit = (F32)base_triangle_count; // reset to default value for this lod F32 pw = pow((F32)decimation, (F32)(LLModel::LOD_HIGH - which_lod)); @@ -1861,7 +1861,7 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d { // UI spacifies limit for all models of single lod - triangle_limit = mFMP->childGetValue("lod_triangle_limit_" + lod_name[which_lod]).asInteger(); + triangle_limit = (F32)mFMP->childGetValue("lod_triangle_limit_" + lod_name[which_lod]).asReal(); } // meshoptimizer doesn't use triangle limit, it uses indices limit, so convert it to aproximate ratio @@ -1871,14 +1871,14 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d else { // UI shows 0 to 100%, but meshoptimizer works with 0 to 1 - lod_error_threshold = mFMP->childGetValue("lod_error_threshold_" + lod_name[which_lod]).asReal() / 100.f; + lod_error_threshold = (F32)mFMP->childGetValue("lod_error_threshold_" + lod_name[which_lod]).asReal() / 100.f; } } else { // we are genrating all lods and each lod will get own indices_decimator indices_decimator = 1; - triangle_limit = base_triangle_count; + triangle_limit = (F32)base_triangle_count; } mMaxTriangleLimit = base_triangle_count; @@ -1906,7 +1906,7 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d } } - mRequestedTriangleCount[lod] = triangle_limit; + mRequestedTriangleCount[lod] = (S32)triangle_limit; mRequestedErrorThreshold[lod] = lod_error_threshold * 100; mRequestedLoDMode[lod] = lod_mode; @@ -2748,7 +2748,7 @@ void LLModelPreview::updateLodControls(S32 lod) LLSpinCtrl* threshold = mFMP->getChild<LLSpinCtrl>("lod_error_threshold_" + lod_name[lod]); LLSpinCtrl* limit = mFMP->getChild<LLSpinCtrl>("lod_triangle_limit_" + lod_name[lod]); - limit->setMaxValue(mMaxTriangleLimit); + limit->setMaxValue((F32)mMaxTriangleLimit); limit->forceSetValue(mRequestedTriangleCount[lod]); threshold->forceSetValue(mRequestedErrorThreshold[lod]); @@ -2760,8 +2760,8 @@ void LLModelPreview::updateLodControls(S32 lod) limit->setVisible(true); threshold->setVisible(false); - limit->setMaxValue(mMaxTriangleLimit); - limit->setIncrement(llmax((U32)1, mMaxTriangleLimit / 32)); + limit->setMaxValue((F32)mMaxTriangleLimit); + limit->setIncrement((F32)llmax((U32)1, mMaxTriangleLimit / 32)); } else { @@ -3134,6 +3134,13 @@ U32 LLModelPreview::loadTextures(LLImportMaterial& material, void* opaque) LLPointer< LLViewerFetchedTexture >& tex = (*reinterpret_cast< LLPointer< LLViewerFetchedTexture > * >(material.mOpaqueData)); tex = LLViewerTextureManager::getFetchedTextureFromUrl("file://" + LLURI::unescape(material.mDiffuseMapFilename), FTT_LOCAL_FILE, true, LLGLTexture::BOOST_PREVIEW); + if (tex->getDiscardLevel() < tex->getMaxDiscardLevel()) + { + // file was loaded previosly, reload image to get potential changes + tex->clearFetchedResults(); + } + // Todo: might cause a crash if preview gets closed before we get the callback. + // Use a callback list or guard callback in some way tex->setLoadedCallback(LLModelPreview::textureLoadedCallback, 0, true, false, opaque, NULL, false); tex->forceToSaveRawImage(0, F32_MAX); material.setDiffuseMap(tex->getID()); // record tex ID @@ -3215,7 +3222,7 @@ bool LLModelPreview::render() gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); gGL.loadIdentity(); - gGL.ortho(0.0f, width, 0.0f, height, -1.0f, 1.0f); + gGL.ortho(0.0f, (F32)width, 0.0f, (F32)height, -1.0f, 1.0f); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); @@ -3353,7 +3360,7 @@ bool LLModelPreview::render() mFMP->childSetEnabled("upload_joints", upload_skin); } - F32 explode = mFMP->childGetValue("physics_explode").asReal(); + F32 explode = (F32)mFMP->childGetValue("physics_explode").asReal(); LLGLDepthTest gls_depth(GL_TRUE); // SL-12781 re-enable z-buffer for 3D model preview diff --git a/indra/newview/llnavigationbar.cpp b/indra/newview/llnavigationbar.cpp index da5bc4b05d..dfead5ee8a 100644 --- a/indra/newview/llnavigationbar.cpp +++ b/indra/newview/llnavigationbar.cpp @@ -705,7 +705,7 @@ void LLNavigationBar::resizeLayoutPanel() { LLRect nav_bar_rect = mNavigationPanel->getRect(); - S32 nav_panel_width = (nav_bar_rect.getWidth() + mFavoritePanel->getRect().getWidth()) * gSavedPerAccountSettings.getF32("NavigationBarRatio"); + S32 nav_panel_width = (S32)((nav_bar_rect.getWidth() + mFavoritePanel->getRect().getWidth()) * gSavedPerAccountSettings.getF32("NavigationBarRatio")); nav_bar_rect.setLeftTopAndSize(nav_bar_rect.mLeft, nav_bar_rect.mTop, nav_panel_width, nav_bar_rect.getHeight()); mNavigationPanel->handleReshape(nav_bar_rect,true); diff --git a/indra/newview/llnetmap.cpp b/indra/newview/llnetmap.cpp index 1410232a0f..3f370b1ab5 100644 --- a/indra/newview/llnetmap.cpp +++ b/indra/newview/llnetmap.cpp @@ -296,8 +296,6 @@ void LLNetMap::draw() gGL.color4f(1.f, 0.5f, 0.5f, 1.f); } - - // Draw using texture. gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture()); gGL.begin(LLRender::QUADS); @@ -311,24 +309,6 @@ void LLNetMap::draw() gGL.vertex2f(right, top); gGL.end(); - // Draw water - gGL.flush(); - { - if (regionp->getLand().getWaterTexture()) - { - gGL.getTexUnit(0)->bind(regionp->getLand().getWaterTexture()); - gGL.begin(LLRender::QUADS); - gGL.texCoord2f(0.f, 1.f); - gGL.vertex2f(left, top); - gGL.texCoord2f(0.f, 0.f); - gGL.vertex2f(left, bottom); - gGL.texCoord2f(1.f, 0.f); - gGL.vertex2f(right, bottom); - gGL.texCoord2f(1.f, 1.f); - gGL.vertex2f(right, top); - gGL.end(); - } - } gGL.flush(); } @@ -455,7 +435,7 @@ void LLNetMap::draw() } F32 dist_to_cursor_squared = dist_vec_squared(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), - LLVector2(local_mouse_x,local_mouse_y)); + LLVector2((F32)local_mouse_x, (F32)local_mouse_y)); if(dist_to_cursor_squared < min_pick_dist_squared && dist_to_cursor_squared < closest_dist_squared) { closest_dist_squared = dist_to_cursor_squared; @@ -495,7 +475,7 @@ void LLNetMap::draw() dot_width); F32 dist_to_cursor_squared = dist_vec_squared(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), - LLVector2(local_mouse_x,local_mouse_y)); + LLVector2((F32)local_mouse_x, (F32)local_mouse_y)); if(dist_to_cursor_squared < min_pick_dist_squared && dist_to_cursor_squared < closest_dist_squared) { mClosestAgentToCursor = gAgent.getID(); @@ -691,7 +671,7 @@ LLVector3d LLNetMap::viewPosToGlobal( S32 x, S32 y ) bool LLNetMap::handleScrollWheel(S32 x, S32 y, S32 clicks) { // note that clicks are reversed from what you'd think: i.e. > 0 means zoom out, < 0 means zoom in - F32 new_scale = mScale * pow(MAP_SCALE_ZOOM_FACTOR, -clicks); + F32 new_scale = mScale * (F32)pow(MAP_SCALE_ZOOM_FACTOR, -clicks); F32 old_scale = mScale; setScale(new_scale); @@ -701,8 +681,8 @@ bool LLNetMap::handleScrollWheel(S32 x, S32 y, S32 clicks) { // Adjust pan to center the zoom on the mouse pointer LLVector2 zoom_offset; - zoom_offset.mV[VX] = x - getRect().getWidth() / 2; - zoom_offset.mV[VY] = y - getRect().getHeight() / 2; + zoom_offset.mV[VX] = (F32)(x - getRect().getWidth() / 2); + zoom_offset.mV[VY] = (F32)(y - getRect().getHeight() / 2); mCurPan -= zoom_offset * mScale / old_scale - zoom_offset; } diff --git a/indra/newview/llnotificationscripthandler.cpp b/indra/newview/llnotificationscripthandler.cpp index 842c24db8a..f0bbaddfb2 100644 --- a/indra/newview/llnotificationscripthandler.cpp +++ b/indra/newview/llnotificationscripthandler.cpp @@ -68,7 +68,7 @@ void LLScriptHandler::initChannel() //-------------------------------------------------------------------------- void LLScriptHandler::addToastWithNotification(const LLNotificationPtr& notification) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; LLToastPanel* notify_box = LLToastPanel::buidPanelFromNotification(notification); LLToast::Params p; diff --git a/indra/newview/llnotificationtiphandler.cpp b/indra/newview/llnotificationtiphandler.cpp index c7fa96edca..0c4ef6f943 100644 --- a/indra/newview/llnotificationtiphandler.cpp +++ b/indra/newview/llnotificationtiphandler.cpp @@ -121,12 +121,12 @@ bool LLTipHandler::processNotification(const LLNotificationPtr& notification, bo if (exp_time > cur_time) { // we have non-default expiration time - keep visible until expires - p.lifetime_secs = exp_time.secondsSinceEpoch() - cur_time.secondsSinceEpoch(); + p.lifetime_secs = (F32)(exp_time.secondsSinceEpoch() - cur_time.secondsSinceEpoch()); } else { // use default time - p.lifetime_secs = gSavedSettings.getS32("NotificationTipToastLifeTime"); + p.lifetime_secs = (F32)gSavedSettings.getS32("NotificationTipToastLifeTime"); } LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>(mChannel.get()); diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp index 9fe8f39bd6..1faf241aaa 100644 --- a/indra/newview/llpanelclassified.cpp +++ b/indra/newview/llpanelclassified.cpp @@ -479,8 +479,8 @@ void LLPanelClassifiedInfo::stretchSnapshot() // Lets increase texture height to force texture look as expected. rc.mBottom -= BTN_HEIGHT_SMALL; - F32 t_width = texture->getFullWidth(); - F32 t_height = texture->getFullHeight(); + F32 t_width = (F32)texture->getFullWidth(); + F32 t_height = (F32)texture->getFullHeight(); F32 ratio = llmin<F32>( (rc.getWidth() / t_width), (rc.getHeight() / t_height) ); diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index 5255b3763c..ea2b2ba944 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -248,7 +248,7 @@ void LLPanelSettingsSkyAtmosTab::onBlueDensityChanged() void LLPanelSettingsSkyAtmosTab::onHazeHorizonChanged() { if (!mSkySettings) return; - mSkySettings->setHazeHorizon(getChild<LLUICtrl>(FIELD_SKY_HAZE_HORIZON)->getValue().asReal()); + mSkySettings->setHazeHorizon((F32)getChild<LLUICtrl>(FIELD_SKY_HAZE_HORIZON)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } @@ -256,7 +256,7 @@ void LLPanelSettingsSkyAtmosTab::onHazeHorizonChanged() void LLPanelSettingsSkyAtmosTab::onHazeDensityChanged() { if (!mSkySettings) return; - mSkySettings->setHazeDensity(getChild<LLUICtrl>(FIELD_SKY_HAZE_DENSITY)->getValue().asReal()); + mSkySettings->setHazeDensity((F32)getChild<LLUICtrl>(FIELD_SKY_HAZE_DENSITY)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } @@ -264,7 +264,7 @@ void LLPanelSettingsSkyAtmosTab::onHazeDensityChanged() void LLPanelSettingsSkyAtmosTab::onSceneGammaChanged() { if (!mSkySettings) return; - mSkySettings->setGamma(getChild<LLUICtrl>(FIELD_SKY_SCENE_GAMMA)->getValue().asReal()); + mSkySettings->setGamma((F32)getChild<LLUICtrl>(FIELD_SKY_SCENE_GAMMA)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } @@ -272,7 +272,7 @@ void LLPanelSettingsSkyAtmosTab::onSceneGammaChanged() void LLPanelSettingsSkyAtmosTab::onDensityMultipChanged() { if (!mSkySettings) return; - F32 density_mult = getChild<LLUICtrl>(FIELD_SKY_DENSITY_MULTIP)->getValue().asReal(); + F32 density_mult = (F32)getChild<LLUICtrl>(FIELD_SKY_DENSITY_MULTIP)->getValue().asReal(); density_mult *= SLIDER_SCALE_DENSITY_MULTIPLIER; mSkySettings->setDensityMultiplier(density_mult); mSkySettings->update(); @@ -282,7 +282,7 @@ void LLPanelSettingsSkyAtmosTab::onDensityMultipChanged() void LLPanelSettingsSkyAtmosTab::onDistanceMultipChanged() { if (!mSkySettings) return; - mSkySettings->setDistanceMultiplier(getChild<LLUICtrl>(FIELD_SKY_DISTANCE_MULTIP)->getValue().asReal()); + mSkySettings->setDistanceMultiplier((F32)getChild<LLUICtrl>(FIELD_SKY_DISTANCE_MULTIP)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } @@ -290,7 +290,7 @@ void LLPanelSettingsSkyAtmosTab::onDistanceMultipChanged() void LLPanelSettingsSkyAtmosTab::onMaxAltChanged() { if (!mSkySettings) return; - mSkySettings->setMaxY(getChild<LLUICtrl>(FIELD_SKY_MAX_ALT)->getValue().asReal()); + mSkySettings->setMaxY((F32)getChild<LLUICtrl>(FIELD_SKY_MAX_ALT)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } @@ -298,7 +298,7 @@ void LLPanelSettingsSkyAtmosTab::onMaxAltChanged() void LLPanelSettingsSkyAtmosTab::onMoistureLevelChanged() { if (!mSkySettings) return; - F32 moisture_level = getChild<LLUICtrl>(FIELD_SKY_DENSITY_MOISTURE_LEVEL)->getValue().asReal(); + F32 moisture_level = (F32)getChild<LLUICtrl>(FIELD_SKY_DENSITY_MOISTURE_LEVEL)->getValue().asReal(); mSkySettings->setSkyMoistureLevel(moisture_level); mSkySettings->update(); setIsDirty(); @@ -307,7 +307,7 @@ void LLPanelSettingsSkyAtmosTab::onMoistureLevelChanged() void LLPanelSettingsSkyAtmosTab::onDropletRadiusChanged() { if (!mSkySettings) return; - F32 droplet_radius = getChild<LLUICtrl>(FIELD_SKY_DENSITY_DROPLET_RADIUS)->getValue().asReal(); + F32 droplet_radius = (F32)getChild<LLUICtrl>(FIELD_SKY_DENSITY_DROPLET_RADIUS)->getValue().asReal(); mSkySettings->setSkyDropletRadius(droplet_radius); mSkySettings->update(); setIsDirty(); @@ -316,7 +316,7 @@ void LLPanelSettingsSkyAtmosTab::onDropletRadiusChanged() void LLPanelSettingsSkyAtmosTab::onIceLevelChanged() { if (!mSkySettings) return; - F32 ice_level = getChild<LLUICtrl>(FIELD_SKY_DENSITY_ICE_LEVEL)->getValue().asReal(); + F32 ice_level = (F32)getChild<LLUICtrl>(FIELD_SKY_DENSITY_ICE_LEVEL)->getValue().asReal(); mSkySettings->setSkyIceLevel(ice_level); mSkySettings->update(); setIsDirty(); @@ -325,7 +325,7 @@ void LLPanelSettingsSkyAtmosTab::onIceLevelChanged() void LLPanelSettingsSkyAtmosTab::onReflectionProbeAmbianceChanged() { if (!mSkySettings) return; - F32 ambiance = getChild<LLUICtrl>(FIELD_REFLECTION_PROBE_AMBIANCE)->getValue().asReal(); + F32 ambiance = (F32)getChild<LLUICtrl>(FIELD_REFLECTION_PROBE_AMBIANCE)->getValue().asReal(); mSkySettings->setReflectionProbeAmbiance(ambiance); mSkySettings->update(); @@ -446,7 +446,7 @@ void LLPanelSettingsSkyCloudTab::onCloudColorChanged() void LLPanelSettingsSkyCloudTab::onCloudCoverageChanged() { if (!mSkySettings) return; - mSkySettings->setCloudShadow(getChild<LLUICtrl>(FIELD_SKY_CLOUD_COVERAGE)->getValue().asReal()); + mSkySettings->setCloudShadow((F32)getChild<LLUICtrl>(FIELD_SKY_CLOUD_COVERAGE)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } @@ -454,14 +454,14 @@ void LLPanelSettingsSkyCloudTab::onCloudCoverageChanged() void LLPanelSettingsSkyCloudTab::onCloudScaleChanged() { if (!mSkySettings) return; - mSkySettings->setCloudScale(getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCALE)->getValue().asReal()); + mSkySettings->setCloudScale((F32)getChild<LLUICtrl>(FIELD_SKY_CLOUD_SCALE)->getValue().asReal()); setIsDirty(); } void LLPanelSettingsSkyCloudTab::onCloudVarianceChanged() { if (!mSkySettings) return; - mSkySettings->setCloudVariance(getChild<LLUICtrl>(FIELD_SKY_CLOUD_VARIANCE)->getValue().asReal()); + mSkySettings->setCloudVariance((F32)getChild<LLUICtrl>(FIELD_SKY_CLOUD_VARIANCE)->getValue().asReal()); setIsDirty(); } @@ -484,9 +484,9 @@ void LLPanelSettingsSkyCloudTab::onCloudMapChanged() void LLPanelSettingsSkyCloudTab::onCloudDensityChanged() { if (!mSkySettings) return; - LLColor3 density(getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_X)->getValue().asReal(), - getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_Y)->getValue().asReal(), - getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_D)->getValue().asReal()); + LLColor3 density((F32)getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_X)->getValue().asReal(), + (F32)getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_Y)->getValue().asReal(), + (F32)getChild<LLUICtrl>(FIELD_SKY_CLOUD_DENSITY_D)->getValue().asReal()); mSkySettings->setCloudPosDensity1(density); setIsDirty(); @@ -495,9 +495,9 @@ void LLPanelSettingsSkyCloudTab::onCloudDensityChanged() void LLPanelSettingsSkyCloudTab::onCloudDetailChanged() { if (!mSkySettings) return; - LLColor3 detail(getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_X)->getValue().asReal(), - getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_Y)->getValue().asReal(), - getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_D)->getValue().asReal()); + LLColor3 detail((F32)getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_X)->getValue().asReal(), + (F32)getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_Y)->getValue().asReal(), + (F32)getChild<LLUICtrl>(FIELD_SKY_CLOUD_DETAIL_D)->getValue().asReal()); mSkySettings->setCloudPosDensity2(detail); setIsDirty(); @@ -626,7 +626,7 @@ void LLPanelSettingsSkySunMoonTab::onSunMoonColorChanged() void LLPanelSettingsSkySunMoonTab::onGlowChanged() { if (!mSkySettings) return; - LLColor3 glow(getChild<LLUICtrl>(FIELD_SKY_GLOW_SIZE)->getValue().asReal(), 0.0f, getChild<LLUICtrl>(FIELD_SKY_GLOW_FOCUS)->getValue().asReal()); + LLColor3 glow((F32)getChild<LLUICtrl>(FIELD_SKY_GLOW_SIZE)->getValue().asReal(), 0.0f, (F32)getChild<LLUICtrl>(FIELD_SKY_GLOW_FOCUS)->getValue().asReal()); // takes 0 - 1.99 UI range -> 40 -> 0.2 range glow.mV[0] = (2.0f - glow.mV[0]) * SLIDER_SCALE_GLOW_R; @@ -640,7 +640,7 @@ void LLPanelSettingsSkySunMoonTab::onGlowChanged() void LLPanelSettingsSkySunMoonTab::onStarBrightnessChanged() { if (!mSkySettings) return; - mSkySettings->setStarBrightness(getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->getValue().asReal()); + mSkySettings->setStarBrightness((F32)getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->getValue().asReal()); mSkySettings->update(); setIsDirty(); } @@ -663,8 +663,8 @@ void LLPanelSettingsSkySunMoonTab::onSunRotationChanged() void LLPanelSettingsSkySunMoonTab::onSunAzimElevChanged() { - F32 azimuth = getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->getValue().asReal(); - F32 elevation = getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->getValue().asReal(); + F32 azimuth = (F32)getChild<LLUICtrl>(FIELD_SKY_SUN_AZIMUTH)->getValue().asReal(); + F32 elevation = (F32)getChild<LLUICtrl>(FIELD_SKY_SUN_ELEVATION)->getValue().asReal(); LLQuaternion quat; azimuth *= DEG_TO_RAD; @@ -693,7 +693,7 @@ void LLPanelSettingsSkySunMoonTab::onSunAzimElevChanged() void LLPanelSettingsSkySunMoonTab::onSunScaleChanged() { if (!mSkySettings) return; - mSkySettings->setSunScale((getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->getValue().asReal())); + mSkySettings->setSunScale((F32)(getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->getValue().asReal())); mSkySettings->update(); setIsDirty(); } @@ -725,8 +725,8 @@ void LLPanelSettingsSkySunMoonTab::onMoonRotationChanged() void LLPanelSettingsSkySunMoonTab::onMoonAzimElevChanged() { - F32 azimuth = getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->getValue().asReal(); - F32 elevation = getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->getValue().asReal(); + F32 azimuth = (F32)getChild<LLUICtrl>(FIELD_SKY_MOON_AZIMUTH)->getValue().asReal(); + F32 elevation = (F32)getChild<LLUICtrl>(FIELD_SKY_MOON_ELEVATION)->getValue().asReal(); LLQuaternion quat; azimuth *= DEG_TO_RAD; @@ -763,7 +763,7 @@ void LLPanelSettingsSkySunMoonTab::onMoonImageChanged() void LLPanelSettingsSkySunMoonTab::onMoonScaleChanged() { if (!mSkySettings) return; - mSkySettings->setMoonScale((getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->getValue().asReal())); + mSkySettings->setMoonScale((F32)(getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->getValue().asReal())); mSkySettings->update(); setIsDirty(); } @@ -771,7 +771,7 @@ void LLPanelSettingsSkySunMoonTab::onMoonScaleChanged() void LLPanelSettingsSkySunMoonTab::onMoonBrightnessChanged() { if (!mSkySettings) return; - mSkySettings->setMoonBrightness((getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->getValue().asReal())); + mSkySettings->setMoonBrightness((F32)(getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->getValue().asReal())); mSkySettings->update(); setIsDirty(); } @@ -851,24 +851,24 @@ void LLPanelSettingsSkyDensityTab::refresh() LLSD mie_config = mSkySettings->getMieConfig(); LLSD absorption_config = mSkySettings->getAbsorptionConfig(); - F32 rayleigh_exponential_term = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); - F32 rayleigh_exponential_scale = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); - F32 rayleigh_linear_term = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); - F32 rayleigh_constant_term = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); - F32 rayleigh_max_alt = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); - - F32 mie_exponential_term = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); - F32 mie_exponential_scale = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); - F32 mie_linear_term = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); - F32 mie_constant_term = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); - F32 mie_aniso_factor = mie_config[LLSettingsSky::SETTING_MIE_ANISOTROPY_FACTOR].asReal(); - F32 mie_max_alt = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); - - F32 absorption_exponential_term = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); - F32 absorption_exponential_scale = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); - F32 absorption_linear_term = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); - F32 absorption_constant_term = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); - F32 absorption_max_alt = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + F32 rayleigh_exponential_term = (F32)rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + F32 rayleigh_exponential_scale = (F32)rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + F32 rayleigh_linear_term = (F32)rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + F32 rayleigh_constant_term = (F32)rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); + F32 rayleigh_max_alt = (F32)rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + + F32 mie_exponential_term = (F32)mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + F32 mie_exponential_scale = (F32)mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + F32 mie_linear_term = (F32)mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + F32 mie_constant_term = (F32)mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); + F32 mie_aniso_factor = (F32)mie_config[LLSettingsSky::SETTING_MIE_ANISOTROPY_FACTOR].asReal(); + F32 mie_max_alt = (F32)mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + + F32 absorption_exponential_term = (F32)absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + F32 absorption_exponential_scale = (F32)absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + F32 absorption_linear_term = (F32)absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + F32 absorption_constant_term = (F32)absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + F32 absorption_max_alt = (F32)absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->setValue(rayleigh_exponential_term); getChild<LLUICtrl>(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->setValue(rayleigh_exponential_scale); diff --git a/indra/newview/llpaneleditwater.cpp b/indra/newview/llpaneleditwater.cpp index 236cb6b97c..174a416fb4 100644 --- a/indra/newview/llpaneleditwater.cpp +++ b/indra/newview/llpaneleditwater.cpp @@ -170,14 +170,14 @@ void LLPanelSettingsWaterMainTab::onFogColorChanged() void LLPanelSettingsWaterMainTab::onFogDensityChanged() { if (!mWaterSettings) return; - mWaterSettings->setWaterFogDensity(getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->getValue().asReal()); + mWaterSettings->setWaterFogDensity((F32)getChild<LLUICtrl>(FIELD_WATER_FOG_DENSITY)->getValue().asReal()); setIsDirty(); } void LLPanelSettingsWaterMainTab::onFogUnderWaterChanged() { if (!mWaterSettings) return; - mWaterSettings->setFogMod(getChild<LLUICtrl>(FIELD_WATER_UNDERWATER_MOD)->getValue().asReal()); + mWaterSettings->setFogMod((F32)getChild<LLUICtrl>(FIELD_WATER_UNDERWATER_MOD)->getValue().asReal()); setIsDirty(); } @@ -210,7 +210,7 @@ void LLPanelSettingsWaterMainTab::onSmallWaveChanged() void LLPanelSettingsWaterMainTab::onNormalScaleChanged() { if (!mWaterSettings) return; - LLVector3 vect(getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_X)->getValue().asReal(), getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Y)->getValue().asReal(), getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Z)->getValue().asReal()); + LLVector3 vect((F32)getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_X)->getValue().asReal(), (F32)getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Y)->getValue().asReal(), (F32)getChild<LLUICtrl>(FIELD_WATER_NORMAL_SCALE_Z)->getValue().asReal()); mWaterSettings->setNormalScale(vect); setIsDirty(); } @@ -218,34 +218,34 @@ void LLPanelSettingsWaterMainTab::onNormalScaleChanged() void LLPanelSettingsWaterMainTab::onFresnelScaleChanged() { if (!mWaterSettings) return; - mWaterSettings->setFresnelScale(getChild<LLUICtrl>(FIELD_WATER_FRESNEL_SCALE)->getValue().asReal()); + mWaterSettings->setFresnelScale((F32)getChild<LLUICtrl>(FIELD_WATER_FRESNEL_SCALE)->getValue().asReal()); setIsDirty(); } void LLPanelSettingsWaterMainTab::onFresnelOffsetChanged() { if (!mWaterSettings) return; - mWaterSettings->setFresnelOffset(getChild<LLUICtrl>(FIELD_WATER_FRESNEL_OFFSET)->getValue().asReal()); + mWaterSettings->setFresnelOffset((F32)getChild<LLUICtrl>(FIELD_WATER_FRESNEL_OFFSET)->getValue().asReal()); setIsDirty(); } void LLPanelSettingsWaterMainTab::onScaleAboveChanged() { if (!mWaterSettings) return; - mWaterSettings->setScaleAbove(getChild<LLUICtrl>(FIELD_WATER_SCALE_ABOVE)->getValue().asReal()); + mWaterSettings->setScaleAbove((F32)getChild<LLUICtrl>(FIELD_WATER_SCALE_ABOVE)->getValue().asReal()); setIsDirty(); } void LLPanelSettingsWaterMainTab::onScaleBelowChanged() { if (!mWaterSettings) return; - mWaterSettings->setScaleBelow(getChild<LLUICtrl>(FIELD_WATER_SCALE_BELOW)->getValue().asReal()); + mWaterSettings->setScaleBelow((F32)getChild<LLUICtrl>(FIELD_WATER_SCALE_BELOW)->getValue().asReal()); setIsDirty(); } void LLPanelSettingsWaterMainTab::onBlurMultipChanged() { if (!mWaterSettings) return; - mWaterSettings->setBlurMultiplier(getChild<LLUICtrl>(FIELD_WATER_BLUR_MULTIP)->getValue().asReal()); + mWaterSettings->setBlurMultiplier((F32)getChild<LLUICtrl>(FIELD_WATER_BLUR_MULTIP)->getValue().asReal()); setIsDirty(); } diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index a14f1d54a2..e88f6c0470 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -299,9 +299,9 @@ LLEditWearableDictionary::Subparts::Subparts() addEntry(SUBPART_UNDERSHIRT, new SubpartEntry(SUBPART_UNDERSHIRT, "mTorso", "undershirt", "undershirt_main_param_list", "undershirt_main_tab", LLVector3d(0.f, 0.f, 0.3f), LLVector3d(-1.f, 0.15f, 0.3f),SEX_BOTH)); addEntry(SUBPART_UNDERPANTS, new SubpartEntry(SUBPART_UNDERPANTS, "mPelvis", "underpants", "underpants_main_param_list", "underpants_main_tab", LLVector3d(0.f, 0.f, -0.5f), LLVector3d(-1.6f, 0.15f, -0.5f),SEX_BOTH)); addEntry(SUBPART_SKIRT, new SubpartEntry(SUBPART_SKIRT, "mPelvis", "skirt", "skirt_main_param_list", "skirt_main_tab", LLVector3d(0.f, 0.f, -0.5f), LLVector3d(-1.6f, 0.15f, -0.5f),SEX_BOTH)); - addEntry(SUBPART_ALPHA, new SubpartEntry(SUBPART_ALPHA, "mPelvis", "alpha", "alpha_main_param_list", "alpha_main_tab", LLVector3d(0.f, 0.f, 0.1f), LLVector3d(-2.5f, 0.5f, 0.8f),SEX_BOTH)); - addEntry(SUBPART_TATTOO, new SubpartEntry(SUBPART_TATTOO, "mPelvis", "tattoo", "tattoo_main_param_list", "tattoo_main_tab", LLVector3d(0.f, 0.f, 0.1f), LLVector3d(-2.5f, 0.5f, 0.8f),SEX_BOTH)); - addEntry(SUBPART_UNIVERSAL, new SubpartEntry(SUBPART_UNIVERSAL, "mPelvis", "universal", "universal_main_param_list", "universal_main_tab", LLVector3d(0.f, 0.f, 0.1f), LLVector3d(-2.5f, 0.5f, 0.8f), SEX_BOTH)); + addEntry(SUBPART_ALPHA, new SubpartEntry(SUBPART_ALPHA, "mPelvis", "alpha", "", "", LLVector3d(0.f, 0.f, 0.1f), LLVector3d(-2.5f, 0.5f, 0.8f),SEX_BOTH)); + addEntry(SUBPART_TATTOO, new SubpartEntry(SUBPART_TATTOO, "mPelvis", "tattoo", "", "", LLVector3d(0.f, 0.f, 0.1f), LLVector3d(-2.5f, 0.5f, 0.8f),SEX_BOTH)); + addEntry(SUBPART_UNIVERSAL, new SubpartEntry(SUBPART_UNIVERSAL, "mPelvis", "universal", "", "", LLVector3d(0.f, 0.f, 0.1f), LLVector3d(-2.5f, 0.5f, 0.8f), SEX_BOTH)); // WT_PHYSICS addEntry(SUBPART_PHYSICS_BREASTS_UPDOWN, new SubpartEntry(SUBPART_PHYSICS_BREASTS_UPDOWN, "mTorso", "physics_breasts_updown", "physics_breasts_updown_param_list", "physics_breasts_updown_tab", LLVector3d(0.f, 0.f, 0.3f), LLVector3d(0.f, 0.f, 0.f), SEX_FEMALE)); @@ -794,8 +794,12 @@ bool LLPanelEditWearable::postBuild() continue; } - const std::string accordion_tab = subpart_entry->mAccordionTab; - LLAccordionCtrlTab *tab = getChild<LLAccordionCtrlTab>(accordion_tab); + const std::string& accordion_tab = subpart_entry->mAccordionTab; + if (accordion_tab.empty()) + { + continue; + } + LLAccordionCtrlTab *tab = findChild<LLAccordionCtrlTab>(accordion_tab); if (!tab) { LL_WARNS() << "could not get llaccordionctrltab from UI with name: " << accordion_tab << LL_ENDL; @@ -1199,12 +1203,16 @@ void LLPanelEditWearable::showWearable(LLViewerWearable* wearable, bool show, bo continue; } - const std::string scrolling_panel = subpart_entry->mParamList; - const std::string accordion_tab = subpart_entry->mAccordionTab; + const std::string& scrolling_panel = subpart_entry->mParamList; + const std::string& accordion_tab = subpart_entry->mAccordionTab; - LLScrollingPanelList *panel_list = getChild<LLScrollingPanelList>(scrolling_panel); - LLAccordionCtrlTab *tab = getChild<LLAccordionCtrlTab>(accordion_tab); + if (scrolling_panel.empty() || accordion_tab.empty()) + { + continue; + } + LLScrollingPanelList *panel_list = findChild<LLScrollingPanelList>(scrolling_panel); + LLAccordionCtrlTab *tab = findChild<LLAccordionCtrlTab>(accordion_tab); if (!panel_list) { LL_WARNS() << "could not get scrolling panel list: " << scrolling_panel << LL_ENDL; diff --git a/indra/newview/llpanelemojicomplete.cpp b/indra/newview/llpanelemojicomplete.cpp index 3faa01ae0c..cb89a5910e 100644 --- a/indra/newview/llpanelemojicomplete.cpp +++ b/indra/newview/llpanelemojicomplete.cpp @@ -110,8 +110,8 @@ void LLPanelEmojiComplete::draw() F32 iconCenterX = mRenderRect.mLeft + (F32)mEmojiWidth / 2; F32 iconCenterY = mRenderRect.mTop - (F32)mEmojiHeight / 2; - F32 textLeft = mVertical ? mRenderRect.mLeft + mEmojiWidth + mPadding : 0; - F32 textWidth = mVertical ? getRect().getWidth() - textLeft - mPadding : 0; + F32 textLeft = mVertical ? (F32)(mRenderRect.mLeft + mEmojiWidth + mPadding) : 0.f; + F32 textWidth = mVertical ? (F32)(getRect().getWidth() - textLeft - mPadding) : 0.f; for (size_t curIdx = firstVisibleIdx; curIdx < lastVisibleIdx; curIdx++) { @@ -129,7 +129,7 @@ void LLPanelEmojiComplete::draw() std::string text = shortCode.substr(0, mEmojis[curIdx].Begin); mTextFont->renderUTF8(text, 0, x0, iconCenterY, LLColor4::white, LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - static_cast<S32>(text.size()), x1); + static_cast<S32>(text.size()), (S32)x1); x0 += mTextFont->getWidthF32(text); x1 = textLeft + textWidth - x0; } @@ -138,7 +138,7 @@ void LLPanelEmojiComplete::draw() std::string text = shortCode.substr(mEmojis[curIdx].Begin, mEmojis[curIdx].End - mEmojis[curIdx].Begin); mTextFont->renderUTF8(text, 0, x0, iconCenterY, LLColor4::yellow6, LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - static_cast<S32>(text.size()), x1); + static_cast<S32>(text.size()), (S32)x1); x0 += mTextFont->getWidthF32(text); x1 = textLeft + textWidth - x0; } @@ -147,7 +147,7 @@ void LLPanelEmojiComplete::draw() std::string text = shortCode.substr(mEmojis[curIdx].End); mTextFont->renderUTF8(text, 0, x0, iconCenterY, LLColor4::white, LLFontGL::LEFT, LLFontGL::VCENTER, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, - static_cast<S32>(text.size()), x1); + static_cast<S32>(text.size()), (S32)x1); } iconCenterY -= mEmojiHeight; } @@ -163,7 +163,7 @@ bool LLPanelEmojiComplete::handleHover(S32 x, S32 y, MASK mask) if (mScrollbar && mScrollbar->getVisible() && childrenHandleHover(x, y, mask)) return true; - LLVector2 curHover(x, y); + LLVector2 curHover((F32)x, (F32)y); if ((mLastHover - curHover).lengthSquared() > MIN_MOUSE_MOVE_DELTA) { size_t index = posToIndex(x, y); @@ -235,7 +235,7 @@ bool LLPanelEmojiComplete::handleMouseDown(S32 x, S32 y, MASK mask) return true; mCurSelected = posToIndex(x, y); - mLastHover = LLVector2(x, y); + mLastHover = LLVector2((F32)x, (F32)y); return true; } @@ -438,7 +438,7 @@ void LLPanelEmojiComplete::updateConstraints() { mRenderRect = getLocalRect(); - mEmojiWidth = mIconFont->getWidthF32(u8"\U0001F431") + mPadding * 2; + mEmojiWidth = (U16)(mIconFont->getWidthF32(u8"\U0001F431") + mPadding * 2); if (mVertical) { mEmojiHeight = mIconFont->getLineHeight() + mPadding * 2; @@ -481,7 +481,7 @@ void LLPanelEmojiComplete::updateScrollPos() } else { - mScrollPos = mCurSelected - ((float)mCurSelected / (mTotalEmojis - 2) * (mVisibleEmojis - 2)); + mScrollPos = (size_t)(mCurSelected - ((float)mCurSelected / (mTotalEmojis - 2) * (mVisibleEmojis - 2))); } if (mScrollbar && mScrollbar->getVisible()) diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp index 43612865fc..a706e339ea 100644 --- a/indra/newview/llpanelenvironment.cpp +++ b/indra/newview/llpanelenvironment.cpp @@ -173,10 +173,10 @@ bool LLPanelEnvironmentInfo::postBuild() getChild<LLUICtrl>(BTN_EDIT)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnEdit(); }); getChild<LLUICtrl>(BTN_RST_ALTITUDES)->setCommitCallback([this](LLUICtrl *, const LLSD &){ onBtnRstAltitudes(); }); - getChild<LLUICtrl>(SLD_DAYLENGTH)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayLengthChanged(value.asReal()); }); + getChild<LLUICtrl>(SLD_DAYLENGTH)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayLengthChanged((F32)value.asReal()); }); getChild<LLSliderCtrl>(SLD_DAYLENGTH)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); }); getChild<LLSliderCtrl>(SLD_DAYLENGTH)->setSliderEditorCommitCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); }); - getChild<LLUICtrl>(SLD_DAYOFFSET)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayOffsetChanged(value.asReal()); }); + getChild<LLUICtrl>(SLD_DAYOFFSET)->setCommitCallback([this](LLUICtrl *, const LLSD &value) { onSldDayOffsetChanged((F32)value.asReal()); }); getChild<LLSliderCtrl>(SLD_DAYOFFSET)->setSliderMouseUpCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); }); getChild<LLSliderCtrl>(SLD_DAYOFFSET)->setSliderEditorCommitCallback([this](LLUICtrl *, const LLSD &) { onDayLenOffsetMouseUp(); }); @@ -193,7 +193,7 @@ bool LLPanelEnvironmentInfo::postBuild() drop_target->setPanel(this, alt_sliders[idx]); } // set initial values to prevent [ALTITUDE] from displaying - updateAltLabel(alt_prefixes[idx], idx + 2, idx * 1000); + updateAltLabel(alt_prefixes[idx], idx + 2, (F32)(idx * 1000)); } getChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[3])->setPanel(this, alt_prefixes[3]); getChild<LLSettingsDropTarget>("sdt_" + alt_prefixes[4])->setPanel(this, alt_prefixes[4]); @@ -554,7 +554,7 @@ void LLPanelEnvironmentInfo::updateAltLabel(const std::string &alt_prefix, U32 s S32 sld_range = sld_rect.getHeight(); S32 sld_bottom = sld_rect.mBottom; S32 sld_offset = sld_rect.getWidth(); // Roughly identical to thumb's width in slider. - S32 pos = (sld_range - sld_offset) * ((alt_value - 100) / (4000 - 100)); + S32 pos = (S32)((sld_range - sld_offset) * ((alt_value - 100) / (4000 - 100))); // get related views LLTextBox* text = findChild<LLTextBox>("txt_" + alt_prefix); @@ -647,15 +647,15 @@ void LLPanelEnvironmentInfo::readjustAltLabels() // Account for edges LLRect midle_rect = view_midle->getRect(); F32 factor = 0.5f; - S32 edge_zone_height = midle_rect.getHeight() * 1.5f; + S32 edge_zone_height = (S32)(midle_rect.getHeight() * 1.5f); if (midle_rect.mBottom - sld_rect.mBottom < edge_zone_height) { - factor = 1 - ((midle_rect.mBottom - sld_rect.mBottom) / (edge_zone_height * 2)); + factor = 1.f - (F32)((midle_rect.mBottom - sld_rect.mBottom) / (edge_zone_height * 2)); } else if (sld_rect.mTop - midle_rect.mTop < edge_zone_height ) { - factor = ((sld_rect.mTop - midle_rect.mTop) / (edge_zone_height * 2)); + factor = (F32)((sld_rect.mTop - midle_rect.mTop) / (edge_zone_height * 2)); } S32 shift_middle = (S32)(((F32)shift_down * factor) + ((F32)shift_up * (1.f - factor))); @@ -739,8 +739,8 @@ void LLPanelEnvironmentInfo::commitDayLenOffsetChanges(bool need_callback) { LLEnvironment::instance().updateParcel(getParcelId(), LLSettingsDay::ptr_t(), - mCurrentEnvironment->mDayLength.value(), - mCurrentEnvironment->mDayOffset.value(), + (S32)mCurrentEnvironment->mDayLength.value(), + (S32)mCurrentEnvironment->mDayOffset.value(), LLEnvironment::altitudes_vect_t(), [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); } @@ -748,8 +748,8 @@ void LLPanelEnvironmentInfo::commitDayLenOffsetChanges(bool need_callback) { LLEnvironment::instance().updateParcel(getParcelId(), LLSettingsDay::ptr_t(), - mCurrentEnvironment->mDayLength.value(), - mCurrentEnvironment->mDayOffset.value(), + (S32)mCurrentEnvironment->mDayLength.value(), + (S32)mCurrentEnvironment->mDayOffset.value(), LLEnvironment::altitudes_vect_t()); } @@ -813,8 +813,8 @@ void LLPanelEnvironmentInfo::onAltSliderMouseUp() setControlsEnabled(false); LLEnvironment::instance().updateParcel(getParcelId(), LLSettingsDay::ptr_t(), - mCurrentEnvironment ? mCurrentEnvironment->mDayLength.value() : -1, - mCurrentEnvironment ? mCurrentEnvironment->mDayOffset.value() : -1, + mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayLength.value() : -1, + mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayOffset.value() : -1, alts); } } @@ -894,8 +894,8 @@ void LLPanelEnvironmentInfo::onBtnRstAltitudes() LLEnvironment::instance().updateParcel(getParcelId(), LLSettingsDay::ptr_t(), - mCurrentEnvironment ? mCurrentEnvironment->mDayLength.value() : -1, - mCurrentEnvironment ? mCurrentEnvironment->mDayOffset.value() : -1, + mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayLength.value() : -1, + mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayOffset.value() : -1, alts, [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); } @@ -912,7 +912,7 @@ void LLPanelEnvironmentInfo::udpateApparentTimeOfDay() } getChild<LLUICtrl>(LBL_TIMEOFDAY)->setVisible(true); - S32Seconds now(LLDate::now().secondsSinceEpoch()); + S32Seconds now((S32)LLDate::now().secondsSinceEpoch()); now += mCurrentEnvironment->mDayOffset; @@ -984,8 +984,8 @@ void LLPanelEnvironmentInfo::onPickerCommitted(LLUUID item_id, S32 track_num) itemp->getAssetUUID(), itemp->getName(), track_num, - mCurrentEnvironment ? mCurrentEnvironment->mDayLength.value() : -1, - mCurrentEnvironment ? mCurrentEnvironment->mDayOffset.value() : -1, + mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayLength.value() : -1, + mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayOffset.value() : -1, flags, LLEnvironment::altitudes_vect_t(), [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); @@ -1018,8 +1018,8 @@ void LLPanelEnvironmentInfo::onEditCommitted(LLSettingsDay::ptr_t newday) LLEnvironment::instance().updateParcel(getParcelId(), newday, - mCurrentEnvironment ? mCurrentEnvironment->mDayLength.value() : -1, - mCurrentEnvironment ? mCurrentEnvironment->mDayOffset.value() : -1, + mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayLength.value() : -1, + mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayOffset.value() : -1, LLEnvironment::altitudes_vect_t(), [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); }); } diff --git a/indra/newview/llpanelexperiencelog.cpp b/indra/newview/llpanelexperiencelog.cpp index 24c9d7dced..5380565ace 100644 --- a/indra/newview/llpanelexperiencelog.cpp +++ b/indra/newview/llpanelexperiencelog.cpp @@ -76,7 +76,7 @@ bool LLPanelExperienceLog::postBuild() LLSpinCtrl* spin = getChild<LLSpinCtrl>("logsizespinner"); - spin->set(log->getMaxDays()); + spin->set((F32)log->getMaxDays()); spin->setCommitCallback(boost::bind(&LLPanelExperienceLog::logSizeChanged, this)); mPageSize = log->getPageSize(); diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 89af765bb7..00338d3125 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -245,19 +245,19 @@ LLUUID LLPanelFace::getCurrentSpecularMap() { return getChild<LLTextureC U32 LLPanelFace::getCurrentShininess() { return getChild<LLComboBox>("combobox shininess")->getCurrentIndex(); } U32 LLPanelFace::getCurrentBumpiness() { return getChild<LLComboBox>("combobox bumpiness")->getCurrentIndex(); } U8 LLPanelFace::getCurrentDiffuseAlphaMode() { return (U8)getChild<LLComboBox>("combobox alphamode")->getCurrentIndex(); } -U8 LLPanelFace::getCurrentAlphaMaskCutoff() { return (U8)getChild<LLUICtrl>("maskcutoff")->getValue().asInteger(); } -U8 LLPanelFace::getCurrentEnvIntensity() { return (U8)getChild<LLUICtrl>("environment")->getValue().asInteger(); } -U8 LLPanelFace::getCurrentGlossiness() { return (U8)getChild<LLUICtrl>("glossiness")->getValue().asInteger(); } -F32 LLPanelFace::getCurrentBumpyRot() { return getChild<LLUICtrl>("bumpyRot")->getValue().asReal(); } -F32 LLPanelFace::getCurrentBumpyScaleU() { return getChild<LLUICtrl>("bumpyScaleU")->getValue().asReal(); } -F32 LLPanelFace::getCurrentBumpyScaleV() { return getChild<LLUICtrl>("bumpyScaleV")->getValue().asReal(); } -F32 LLPanelFace::getCurrentBumpyOffsetU() { return getChild<LLUICtrl>("bumpyOffsetU")->getValue().asReal(); } -F32 LLPanelFace::getCurrentBumpyOffsetV() { return getChild<LLUICtrl>("bumpyOffsetV")->getValue().asReal(); } -F32 LLPanelFace::getCurrentShinyRot() { return getChild<LLUICtrl>("shinyRot")->getValue().asReal(); } -F32 LLPanelFace::getCurrentShinyScaleU() { return getChild<LLUICtrl>("shinyScaleU")->getValue().asReal(); } -F32 LLPanelFace::getCurrentShinyScaleV() { return getChild<LLUICtrl>("shinyScaleV")->getValue().asReal(); } -F32 LLPanelFace::getCurrentShinyOffsetU() { return getChild<LLUICtrl>("shinyOffsetU")->getValue().asReal(); } -F32 LLPanelFace::getCurrentShinyOffsetV() { return getChild<LLUICtrl>("shinyOffsetV")->getValue().asReal(); } +U8 LLPanelFace::getCurrentAlphaMaskCutoff() { return (U8)getChild<LLUICtrl>("maskcutoff")->getValue().asInteger(); } +U8 LLPanelFace::getCurrentEnvIntensity() { return (U8)getChild<LLUICtrl>("environment")->getValue().asInteger(); } +U8 LLPanelFace::getCurrentGlossiness() { return (U8)getChild<LLUICtrl>("glossiness")->getValue().asInteger(); } +F32 LLPanelFace::getCurrentBumpyRot() { return (F32)getChild<LLUICtrl>("bumpyRot")->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyScaleU() { return (F32)getChild<LLUICtrl>("bumpyScaleU")->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyScaleV() { return (F32)getChild<LLUICtrl>("bumpyScaleV")->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyOffsetU() { return (F32)getChild<LLUICtrl>("bumpyOffsetU")->getValue().asReal(); } +F32 LLPanelFace::getCurrentBumpyOffsetV() { return (F32)getChild<LLUICtrl>("bumpyOffsetV")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyRot() { return (F32)getChild<LLUICtrl>("shinyRot")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyScaleU() { return (F32)getChild<LLUICtrl>("shinyScaleU")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyScaleV() { return (F32)getChild<LLUICtrl>("shinyScaleV")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyOffsetU() { return (F32)getChild<LLUICtrl>("shinyOffsetU")->getValue().asReal(); } +F32 LLPanelFace::getCurrentShinyOffsetV() { return (F32)getChild<LLUICtrl>("shinyOffsetV")->getValue().asReal(); } // // Methods @@ -1854,13 +1854,13 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) // Set variable values for numeric expressions LLCalc* calcp = LLCalc::getInstance(); - calcp->setVar(LLCalc::TEX_U_SCALE, childGetValue("TexScaleU").asReal()); - calcp->setVar(LLCalc::TEX_V_SCALE, childGetValue("TexScaleV").asReal()); - calcp->setVar(LLCalc::TEX_U_OFFSET, childGetValue("TexOffsetU").asReal()); - calcp->setVar(LLCalc::TEX_V_OFFSET, childGetValue("TexOffsetV").asReal()); - calcp->setVar(LLCalc::TEX_ROTATION, childGetValue("TexRot").asReal()); - calcp->setVar(LLCalc::TEX_TRANSPARENCY, childGetValue("ColorTrans").asReal()); - calcp->setVar(LLCalc::TEX_GLOW, childGetValue("glow").asReal()); + calcp->setVar(LLCalc::TEX_U_SCALE, (F32)childGetValue("TexScaleU").asReal()); + calcp->setVar(LLCalc::TEX_V_SCALE, (F32)childGetValue("TexScaleV").asReal()); + calcp->setVar(LLCalc::TEX_U_OFFSET, (F32)childGetValue("TexOffsetU").asReal()); + calcp->setVar(LLCalc::TEX_V_OFFSET, (F32)childGetValue("TexOffsetV").asReal()); + calcp->setVar(LLCalc::TEX_ROTATION, (F32)childGetValue("TexRot").asReal()); + calcp->setVar(LLCalc::TEX_TRANSPARENCY, (F32)childGetValue("ColorTrans").asReal()); + calcp->setVar(LLCalc::TEX_GLOW, (F32)childGetValue("glow").asReal()); } else { @@ -3777,7 +3777,7 @@ void LLPanelFace::onCommitTextureScaleX( LLUICtrl* ctrl, void* userdata ) LLPanelFace* self = (LLPanelFace*) userdata; if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - F32 bumpy_scale_u = self->getChild<LLUICtrl>("TexScaleU")->getValue().asReal(); + F32 bumpy_scale_u = (F32)self->getChild<LLUICtrl>("TexScaleU")->getValue().asReal(); if (self->isIdenticalPlanarTexgen()) { bumpy_scale_u *= 0.5f; @@ -3797,7 +3797,7 @@ void LLPanelFace::onCommitTextureScaleY( LLUICtrl* ctrl, void* userdata ) LLPanelFace* self = (LLPanelFace*) userdata; if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - F32 bumpy_scale_v = self->getChild<LLUICtrl>("TexScaleV")->getValue().asReal(); + F32 bumpy_scale_v = (F32)self->getChild<LLUICtrl>("TexScaleV")->getValue().asReal(); if (self->isIdenticalPlanarTexgen()) { bumpy_scale_v *= 0.5f; @@ -3818,7 +3818,7 @@ void LLPanelFace::onCommitTextureRot( LLUICtrl* ctrl, void* userdata ) if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - syncMaterialRot(self, self->getChild<LLUICtrl>("TexRot")->getValue().asReal()); + syncMaterialRot(self, (F32)self->getChild<LLUICtrl>("TexRot")->getValue().asReal()); } else { @@ -3833,7 +3833,7 @@ void LLPanelFace::onCommitTextureOffsetX( LLUICtrl* ctrl, void* userdata ) LLPanelFace* self = (LLPanelFace*) userdata; if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - syncOffsetX(self, self->getChild<LLUICtrl>("TexOffsetU")->getValue().asReal()); + syncOffsetX(self, (F32)self->getChild<LLUICtrl>("TexOffsetU")->getValue().asReal()); } else { @@ -3848,7 +3848,7 @@ void LLPanelFace::onCommitTextureOffsetY( LLUICtrl* ctrl, void* userdata ) LLPanelFace* self = (LLPanelFace*) userdata; if (gSavedSettings.getBOOL("SyncMaterialSettings")) { - syncOffsetY(self, self->getChild<LLUICtrl>("TexOffsetV")->getValue().asReal()); + syncOffsetY(self, (F32)self->getChild<LLUICtrl>("TexOffsetV")->getValue().asReal()); } else { @@ -3861,27 +3861,27 @@ void LLPanelFace::onCommitTextureOffsetY( LLUICtrl* ctrl, void* userdata ) // static void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) { - LLPanelFace* self = (LLPanelFace*) userdata; + LLPanelFace *self = (LLPanelFace *) userdata; - LLUICtrl* repeats_ctrl = self->getChild<LLUICtrl>("rptctrl"); + LLUICtrl *repeats_ctrl = self->getChild<LLUICtrl>("rptctrl"); U32 materials_media = self->mComboMatMedia->getCurrentIndex(); - U32 material_type = 0; + U32 material_type = 0; if (materials_media == MATMEDIA_PBR) { - LLRadioGroup* radio_mat_type = self->getChild<LLRadioGroup>("radio_pbr_type"); - material_type = radio_mat_type->getSelectedIndex(); + LLRadioGroup *radio_mat_type = self->getChild<LLRadioGroup>("radio_pbr_type"); + material_type = radio_mat_type->getSelectedIndex(); } if (materials_media == MATMEDIA_MATERIAL) { - LLRadioGroup* radio_mat_type = self->getChild<LLRadioGroup>("radio_material_type"); - material_type = radio_mat_type->getSelectedIndex(); + LLRadioGroup *radio_mat_type = self->getChild<LLRadioGroup>("radio_material_type"); + material_type = radio_mat_type->getSelectedIndex(); } - F32 repeats_per_meter = repeats_ctrl->getValue().asReal(); + F32 repeats_per_meter = (F32) repeats_ctrl->getValue().asReal(); - F32 obj_scale_s = 1.0f; - F32 obj_scale_t = 1.0f; + F32 obj_scale_s = 1.0f; + F32 obj_scale_t = 1.0f; bool identical_scale_s = false; bool identical_scale_t = false; @@ -3889,10 +3889,10 @@ void LLPanelFace::onCommitRepeatsPerMeter(LLUICtrl* ctrl, void* userdata) LLSelectedTE::getObjectScaleS(obj_scale_s, identical_scale_s); LLSelectedTE::getObjectScaleS(obj_scale_t, identical_scale_t); - LLUICtrl* bumpy_scale_u = self->getChild<LLUICtrl>("bumpyScaleU"); - LLUICtrl* bumpy_scale_v = self->getChild<LLUICtrl>("bumpyScaleV"); - LLUICtrl* shiny_scale_u = self->getChild<LLUICtrl>("shinyScaleU"); - LLUICtrl* shiny_scale_v = self->getChild<LLUICtrl>("shinyScaleV"); + LLUICtrl *bumpy_scale_u = self->getChild<LLUICtrl>("bumpyScaleU"); + LLUICtrl *bumpy_scale_v = self->getChild<LLUICtrl>("bumpyScaleV"); + LLUICtrl *shiny_scale_u = self->getChild<LLUICtrl>("shinyScaleU"); + LLUICtrl *shiny_scale_v = self->getChild<LLUICtrl>("shinyScaleV"); if (gSavedSettings.getBOOL("SyncMaterialSettings")) { @@ -5085,7 +5085,7 @@ bool LLPanelFace::Selection::compareSelection() void LLPanelFace::onCommitGLTFTextureScaleU(LLUICtrl* ctrl) { - const float value = ctrl->getValue().asReal(); + const float value = (F32)ctrl->getValue().asReal(); const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex(); updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) { @@ -5095,7 +5095,7 @@ void LLPanelFace::onCommitGLTFTextureScaleU(LLUICtrl* ctrl) void LLPanelFace::onCommitGLTFTextureScaleV(LLUICtrl* ctrl) { - const float value = ctrl->getValue().asReal(); + const float value = (F32)ctrl->getValue().asReal(); const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex(); updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) { @@ -5105,7 +5105,7 @@ void LLPanelFace::onCommitGLTFTextureScaleV(LLUICtrl* ctrl) void LLPanelFace::onCommitGLTFRotation(LLUICtrl* ctrl) { - const float value = ctrl->getValue().asReal() * DEG_TO_RAD; + const float value = (F32)ctrl->getValue().asReal() * DEG_TO_RAD; const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex(); updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) { @@ -5115,7 +5115,7 @@ void LLPanelFace::onCommitGLTFRotation(LLUICtrl* ctrl) void LLPanelFace::onCommitGLTFTextureOffsetU(LLUICtrl* ctrl) { - const float value = ctrl->getValue().asReal(); + const float value = (F32)ctrl->getValue().asReal(); const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex(); updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) { @@ -5125,7 +5125,7 @@ void LLPanelFace::onCommitGLTFTextureOffsetU(LLUICtrl* ctrl) void LLPanelFace::onCommitGLTFTextureOffsetV(LLUICtrl* ctrl) { - const float value = ctrl->getValue().asReal(); + const float value = (F32)ctrl->getValue().asReal(); const U32 pbr_type = findChild<LLRadioGroup>("radio_pbr_type")->getSelectedIndex(); updateGLTFTextureTransform(value, pbr_type, [&](LLGLTFMaterial::TextureTransform* new_transform) { diff --git a/indra/newview/llpanelgroupbulk.cpp b/indra/newview/llpanelgroupbulk.cpp index f54ec45a3c..433db74cda 100644 --- a/indra/newview/llpanelgroupbulk.cpp +++ b/indra/newview/llpanelgroupbulk.cpp @@ -68,33 +68,36 @@ LLPanelGroupBulkImpl::LLPanelGroupBulkImpl(const LLUUID& group_id) : mAlreadyInGroup(), mConfirmedOwnerInvite(false), mListFullNotificationSent(false) -{} +{ +} LLPanelGroupBulkImpl::~LLPanelGroupBulkImpl() { - if(mAvatarNameCacheConnection.connected()) + if (mAvatarNameCacheConnection.connected()) { mAvatarNameCacheConnection.disconnect(); } } +// static void LLPanelGroupBulkImpl::callbackClickAdd(void* userdata) { - LLPanelGroupBulk* panelp = (LLPanelGroupBulk*)userdata; - - if(panelp) + if (LLPanelGroupBulk* panelp = (LLPanelGroupBulk*)userdata) { - //Right now this is hard coded with some knowledge that it is part - //of a floater since the avatar picker needs to be added as a dependent - //floater to the parent floater. - //Soon the avatar picker will be embedded into this panel - //instead of being it's own separate floater. But that is next week. - //This will do for now. -jwolk May 10, 2006 + // Right now this is hard coded with some knowledge that it is part + // of a floater since the avatar picker needs to be added as a dependent + // floater to the parent floater. + // Soon the avatar picker will be embedded into this panel + // instead of being it's own separate floater. But that is next week. + // This will do for now. -jwolk May 10, 2006 LLView* button = panelp->findChild<LLButton>("add_button"); LLFloater* root_floater = gFloaterView->getParentFloater(panelp); LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show( - boost::bind(callbackAddUsers, _1, panelp->mImplementation), true, false, false, root_floater->getName(), button); - if(picker) + [&](const uuid_vec_t& agent_ids, const std::vector<LLAvatarName>&) + { + panelp->mImplementation->addUsers(agent_ids); + }, true, false, false, root_floater->getName(), button); + if (picker) { root_floater->addDependentFloater(picker); LLGroupMgr::getInstance()->sendCapGroupMembersRequest(panelp->mImplementation->mGroupID); @@ -102,70 +105,72 @@ void LLPanelGroupBulkImpl::callbackClickAdd(void* userdata) } } +// static void LLPanelGroupBulkImpl::callbackClickRemove(void* userdata) { - LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*)userdata; - if (selfp) + if (LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*)userdata) + { selfp->handleRemove(); + } } +// static void LLPanelGroupBulkImpl::callbackClickCancel(void* userdata) { - LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*)userdata; - if(selfp) + if (LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*)userdata) + { (*(selfp->mCloseCallback))(selfp->mCloseCallbackUserData); + } } +// static void LLPanelGroupBulkImpl::callbackSelect(LLUICtrl* ctrl, void* userdata) { - LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*)userdata; - if (selfp) + if (LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*)userdata) + { selfp->handleSelection(); + } } -void LLPanelGroupBulkImpl::callbackAddUsers(const uuid_vec_t& agent_ids, void* user_data) +void LLPanelGroupBulkImpl::addUsers(const uuid_vec_t& agent_ids) { std::vector<std::string> names; - for (S32 i = 0; i < (S32)agent_ids.size(); i++) + for (const LLUUID& agent_id : agent_ids) { LLAvatarName av_name; - if (LLAvatarNameCache::get(agent_ids[i], &av_name)) + if (LLAvatarNameCache::get(agent_id, &av_name)) { - onAvatarNameCache(agent_ids[i], av_name, user_data); + onAvatarNameCache(agent_id, av_name); } else { - LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*) user_data; - if (selfp) + if (mAvatarNameCacheConnection.connected()) { - if (selfp->mAvatarNameCacheConnection.connected()) - { - selfp->mAvatarNameCacheConnection.disconnect(); - } - // *TODO : Add a callback per avatar name being fetched. - selfp->mAvatarNameCacheConnection = LLAvatarNameCache::get(agent_ids[i],boost::bind(onAvatarNameCache, _1, _2, user_data)); + mAvatarNameCacheConnection.disconnect(); } + // *TODO : Add a callback per avatar name being fetched. + mAvatarNameCacheConnection = LLAvatarNameCache::get(agent_id, + [&](const LLUUID& agent_id, const LLAvatarName& av_name) + { + onAvatarNameCache(agent_id, av_name); + }); } } } -void LLPanelGroupBulkImpl::onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name, void* user_data) +void LLPanelGroupBulkImpl::onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name) { - LLPanelGroupBulkImpl* selfp = (LLPanelGroupBulkImpl*) user_data; - - if (selfp) + if (mAvatarNameCacheConnection.connected()) { - if (selfp->mAvatarNameCacheConnection.connected()) - { - selfp->mAvatarNameCacheConnection.disconnect(); - } - std::vector<std::string> names; - uuid_vec_t agent_ids; - agent_ids.push_back(agent_id); - names.push_back(av_name.getCompleteName()); - - selfp->addUsers(names, agent_ids); + mAvatarNameCacheConnection.disconnect(); } + + std::vector<std::string> names; + uuid_vec_t agent_ids; + agent_ids.push_back(agent_id); + names.push_back(av_name.getCompleteName()); + + addUsers(names, agent_ids); } void LLPanelGroupBulkImpl::handleRemove() @@ -174,17 +179,15 @@ void LLPanelGroupBulkImpl::handleRemove() if (selection.empty()) return; - std::vector<LLScrollListItem*>::iterator iter; - for(iter = selection.begin(); iter != selection.end(); ++iter) + for (const LLScrollListItem* item : selection) { - mInviteeIDs.erase((*iter)->getUUID()); + mInviteeIDs.erase(item->getUUID()); } mBulkAgentList->deleteSelectedItems(); mRemoveButton->setEnabled(false); - if( mOKButton && mOKButton->getEnabled() && - mBulkAgentList->isEmpty()) + if (mOKButton && mOKButton->getEnabled() && mBulkAgentList->isEmpty()) { mOKButton->setEnabled(false); } @@ -192,24 +195,17 @@ void LLPanelGroupBulkImpl::handleRemove() void LLPanelGroupBulkImpl::handleSelection() { - std::vector<LLScrollListItem*> selection = mBulkAgentList->getAllSelected(); - if (selection.empty()) - mRemoveButton->setEnabled(false); - else - mRemoveButton->setEnabled(true); + mRemoveButton->setEnabled(mBulkAgentList->getFirstSelected()); } void LLPanelGroupBulkImpl::addUsers(const std::vector<std::string>& names, const uuid_vec_t& agent_ids) { - std::string name; - LLUUID id; - - if(mListFullNotificationSent) + if (mListFullNotificationSent) { return; } - if( !mListFullNotificationSent && + if (!mListFullNotificationSent && (names.size() + mInviteeIDs.size() > MAX_GROUP_INVITES)) { mListFullNotificationSent = true; @@ -223,32 +219,35 @@ void LLPanelGroupBulkImpl::addUsers(const std::vector<std::string>& names, const for (S32 i = 0; i < (S32)names.size(); ++i) { - name = names[i]; - id = agent_ids[i]; + const LLUUID& id = agent_ids[i]; - if(mInviteeIDs.find(id) != mInviteeIDs.end()) + if (mInviteeIDs.find(id) != mInviteeIDs.end()) { continue; } - //add the name to the names list + // Add the name to the name list LLSD row; row["id"] = id; - row["columns"][0]["value"] = name; + row["columns"][0]["value"] = names[i]; mBulkAgentList->addElement(row); mInviteeIDs.insert(id); // We've successfully added someone to the list. - if(mOKButton && !mOKButton->getEnabled()) + if (mOKButton && !mOKButton->getEnabled()) + { mOKButton->setEnabled(true); + } } } void LLPanelGroupBulkImpl::setGroupName(std::string name) { - if(mGroupName) + if (mGroupName) + { mGroupName->setText(name); + } } @@ -258,7 +257,8 @@ LLPanelGroupBulk::LLPanelGroupBulk(const LLUUID& group_id) : mPendingGroupPropertiesUpdate(false), mPendingRoleDataUpdate(false), mPendingMemberDataUpdate(false) -{} +{ +} LLPanelGroupBulk::~LLPanelGroupBulk() { @@ -269,11 +269,15 @@ void LLPanelGroupBulk::clear() { mImplementation->mInviteeIDs.clear(); - if(mImplementation->mBulkAgentList) + if (mImplementation->mBulkAgentList) + { mImplementation->mBulkAgentList->deleteAllItems(); + } - if(mImplementation->mOKButton) + if (mImplementation->mOKButton) + { mImplementation->mOKButton->setEnabled(false); + } } void LLPanelGroupBulk::update() @@ -292,12 +296,14 @@ void LLPanelGroupBulk::updateGroupName() { LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); - if( gdatap && + if (gdatap && gdatap->isGroupPropertiesDataComplete()) { // Only do work if the current group name differs - if(mImplementation->mGroupName->getText().compare(gdatap->mName) != 0) + if (mImplementation->mGroupName->getText().compare(gdatap->mName) != 0) + { mImplementation->setGroupName(gdatap->mName); + } } else { @@ -308,43 +314,34 @@ void LLPanelGroupBulk::updateGroupName() void LLPanelGroupBulk::updateGroupData() { LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mImplementation->mGroupID); - if(gdatap && gdatap->isGroupPropertiesDataComplete()) + if (gdatap && gdatap->isGroupPropertiesDataComplete()) { mPendingGroupPropertiesUpdate = false; } - else + else if (!mPendingGroupPropertiesUpdate) { - if(!mPendingGroupPropertiesUpdate) - { - mPendingGroupPropertiesUpdate = true; - LLGroupMgr::getInstance()->sendGroupPropertiesRequest(mImplementation->mGroupID); - } + mPendingGroupPropertiesUpdate = true; + LLGroupMgr::getInstance()->sendGroupPropertiesRequest(mImplementation->mGroupID); } - if(gdatap && gdatap->isRoleDataComplete()) + if (gdatap && gdatap->isRoleDataComplete()) { mPendingRoleDataUpdate = false; } - else + else if (!mPendingRoleDataUpdate) { - if(!mPendingRoleDataUpdate) - { - mPendingRoleDataUpdate = true; - LLGroupMgr::getInstance()->sendGroupRoleDataRequest(mImplementation->mGroupID); - } + mPendingRoleDataUpdate = true; + LLGroupMgr::getInstance()->sendGroupRoleDataRequest(mImplementation->mGroupID); } - if(gdatap && gdatap->isMemberDataComplete()) + if (gdatap && gdatap->isMemberDataComplete()) { mPendingMemberDataUpdate = false; } - else + else if (!mPendingMemberDataUpdate) { - if(!mPendingMemberDataUpdate) - { - mPendingMemberDataUpdate = true; - LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mImplementation->mGroupID); - } + mPendingMemberDataUpdate = true; + LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mImplementation->mGroupID); } } @@ -367,21 +364,20 @@ void LLPanelGroupBulk::setCloseCallback(void (*close_callback)(void*), void* dat void LLPanelGroupBulk::addUsers(uuid_vec_t& agent_ids) { std::vector<std::string> names; - for (S32 i = 0; i < (S32)agent_ids.size(); i++) + for (size_t i = 0; i < agent_ids.size(); i++) { std::string fullname; - LLUUID agent_id = agent_ids[i]; + const LLUUID& agent_id = agent_ids[i]; LLViewerObject* dest = gObjectList.findObject(agent_id); - if(dest && dest->isAvatar()) + if (dest && dest->isAvatar()) { LLNameValue* nvfirst = dest->getNVPair("FirstName"); LLNameValue* nvlast = dest->getNVPair("LastName"); - if(nvfirst && nvlast) + if (nvfirst && nvlast) { - fullname = LLCacheName::buildFullName( - nvfirst->getString(), nvlast->getString()); - + fullname = LLCacheName::buildFullName(nvfirst->getString(), nvlast->getString()); } + if (!fullname.empty()) { names.push_back(fullname); @@ -394,20 +390,25 @@ void LLPanelGroupBulk::addUsers(uuid_vec_t& agent_ids) } else { - //looks like user try to invite offline friend - //for offline avatar_id gObjectList.findObject() will return null - //so we need to do this additional search in avatar tracker, see EXT-4732 + // Looks like the user tries to invite a friend which is offline. + // For offline avatar_id gObjectList.findObject() will return null + // so we need to do this additional search in avatar tracker, see EXT-4732 if (LLAvatarTracker::instance().isBuddy(agent_id)) { LLAvatarName av_name; if (!LLAvatarNameCache::get(agent_id, &av_name)) { - // actually it should happen, just in case - LLAvatarNameCache::get(LLUUID(agent_id), boost::bind(&LLPanelGroupBulk::addUserCallback, this, _1, _2)); + // Actually it shouldn't happen, just in case + LLAvatarNameCache::get(LLUUID(agent_id), + [&](const LLUUID& agent_id, const LLAvatarName& av_name) + { + addUserCallback(agent_id, av_name); + }); // for this special case! - //when there is no cached name we should remove resident from agent_ids list to avoid breaking of sequence + // when there is no cached name we should remove resident from agent_ids list to avoid breaking of sequence // removed id will be added in callback agent_ids.erase(agent_ids.begin() + i); + i--; // To process the next agent_id with the same index } else { diff --git a/indra/newview/llpanelgroupbulkimpl.h b/indra/newview/llpanelgroupbulkimpl.h index 963780200a..5a479f8117 100644 --- a/indra/newview/llpanelgroupbulkimpl.h +++ b/indra/newview/llpanelgroupbulkimpl.h @@ -50,9 +50,10 @@ public: static void callbackClickCancel(void* userdata); static void callbackSelect(LLUICtrl* ctrl, void* userdata); - static void callbackAddUsers(const uuid_vec_t& agent_ids, void* user_data); - static void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name, void* user_data); + void addUsers(const uuid_vec_t& agent_ids); + + void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name); void handleRemove(); void handleSelection(); diff --git a/indra/newview/llpanelgrouproles.cpp b/indra/newview/llpanelgrouproles.cpp index bc56b49e5d..864d73683e 100644 --- a/indra/newview/llpanelgrouproles.cpp +++ b/indra/newview/llpanelgrouproles.cpp @@ -812,20 +812,14 @@ bool LLPanelGroupMembersSubTab::postBuildSubTab(LLView* root) { LLPanelGroupSubTab::postBuildSubTab(root); - // Upcast parent so we can ask it for sibling controls. - LLPanelGroupRoles* parent = (LLPanelGroupRoles*) root; - // Look recursively from the parent to find all our widgets. - bool recurse = true; - mHeader = parent->findChild<LLPanel>("members_header", recurse); - mFooter = parent->findChild<LLPanel>("members_footer", recurse); - - mMembersList = parent->getChild<LLNameListCtrl>("member_list", recurse); - mAssignedRolesList = parent->getChild<LLScrollListCtrl>("member_assigned_roles", recurse); - mAllowedActionsList = parent->getChild<LLScrollListCtrl>("member_allowed_actions", recurse); - mActionDescription = parent->getChild<LLTextEditor>("member_action_description", recurse); + mHeader = root->findChild<LLPanel>("members_header"); + mFooter = root->findChild<LLPanel>("members_footer"); - if (!mMembersList || !mAssignedRolesList || !mAllowedActionsList || !mActionDescription) return false; + mMembersList = root->getChild<LLNameListCtrl>("member_list"); + mAssignedRolesList = root->getChild<LLScrollListCtrl>("member_assigned_roles"); + mAllowedActionsList = root->getChild<LLScrollListCtrl>("member_allowed_actions"); + mActionDescription = root->getChild<LLTextEditor>("member_action_description"); mAllowedActionsList->setCommitOnSelectionChange(true); mAllowedActionsList->setCommitCallback(boost::bind(&LLPanelGroupMembersSubTab::updateActionDescription, this)); @@ -844,31 +838,22 @@ bool LLPanelGroupMembersSubTab::postBuildSubTab(LLView* root) row["columns"][2]["column"] = "online"; mMembersList->addElement(row); std::string order_by = gSavedSettings.getString("GroupMembersSortOrder"); - if(!order_by.empty()) + if (!order_by.empty()) { mMembersList->sortByColumn(order_by, true); } - LLButton* button = parent->getChild<LLButton>("member_invite", recurse); - if ( button ) - { - button->setClickedCallback(onInviteMember, this); - button->setEnabled(gAgent.hasPowerInGroup(mGroupID, GP_MEMBER_INVITE)); - } + LLButton* button = root->getChild<LLButton>("member_invite"); + button->setClickedCallback(onInviteMember, this); + button->setEnabled(gAgent.hasPowerInGroup(mGroupID, GP_MEMBER_INVITE)); - mEjectBtn = parent->getChild<LLButton>("member_eject", recurse); - if ( mEjectBtn ) - { - mEjectBtn->setClickedCallback(onEjectMembers, this); - mEjectBtn->setEnabled(false); - } + mEjectBtn = root->getChild<LLButton>("member_eject"); + mEjectBtn->setClickedCallback(onEjectMembers, this); + mEjectBtn->setEnabled(false); - mBanBtn = parent->getChild<LLButton>("member_ban", recurse); - if(mBanBtn) - { - mBanBtn->setClickedCallback(onBanMember, this); - mBanBtn->setEnabled(false); - } + mBanBtn = root->getChild<LLButton>("member_ban"); + mBanBtn->setClickedCallback(onBanMember, this); + mBanBtn->setEnabled(false); return true; } @@ -1371,11 +1356,13 @@ void LLPanelGroupMembersSubTab::activate() LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); LLPanelGroupSubTab::activate(); - if(!mActivated) + if (!mActivated) { if (!gdatap || !gdatap->isMemberDataComplete()) { - LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mGroupID); + const U32 page_size = 50; + std::string sort_column = mMembersList->getSortColumnName(); + LLGroupMgr::getInstance()->sendCapGroupMembersRequest(mGroupID, page_size, 0, sort_column); } if (!gdatap || !gdatap->isRoleMemberDataComplete()) @@ -1483,8 +1470,7 @@ bool LLPanelGroupMembersSubTab::addOwnerCB(const LLSD& notification, const LLSD& void LLPanelGroupMembersSubTab::applyMemberChanges() { - //sucks to do a find again here, but it is in constant time, so, could - //be worse + // Sucks to do a find again here, but it is in constant time, so, could be worse LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); if (!gdatap) { @@ -1492,8 +1478,7 @@ void LLPanelGroupMembersSubTab::applyMemberChanges() return; } - //we need to add all of the changed roles data - //for each member whose role changed + // We need to add all of the changed roles data for each member whose role changed for (member_role_changes_map_t::iterator member = mMemberRoleChangeData.begin(); member != mMemberRoleChangeData.end(); ++member) { @@ -1511,7 +1496,7 @@ void LLPanelGroupMembersSubTab::applyMemberChanges() mMemberRoleChangeData.clear(); LLGroupMgr::getInstance()->sendGroupRoleMemberChanges(mGroupID); - //force a UI update + // Force an UI update handleMemberSelect(); mChanged = false; @@ -1522,32 +1507,23 @@ void LLPanelGroupMembersSubTab::applyMemberChanges() bool LLPanelGroupMembersSubTab::matchesSearchFilter(const std::string& fullname) { // If the search filter is empty, everything passes. - if (mSearchFilter.empty()) return true; + if (mSearchFilter.empty()) + return true; // Create a full name, and compare it to the search filter. std::string fullname_lc(fullname); LLStringUtil::toLower(fullname_lc); std::string::size_type match = fullname_lc.find(mSearchFilter); - - if (std::string::npos == match) - { - // not found - return false; - } - else - { - return true; - } + return match != std::string::npos; } U64 LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges(const LLUUID& agent_id) { - //we loop over all of the changes - //if we are adding a role, then we simply add the role's powers - //if we are removing a role, we store that role id away - //and then we have to build the powers up bases on the roles the agent - //is in + // We loop over all of the changes + // If we are adding a role, then we simply add the role's powers + // If we are removing a role, we store that role id away + // and then we have to build the powers up bases on the roles the agent is in LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); if (!gdatap) @@ -1557,7 +1533,7 @@ U64 LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges(const LLUUID& ag } LLGroupMgrGroupData::member_list_t::iterator iter = gdatap->mMembers.find(agent_id); - if ( iter == gdatap->mMembers.end() ) + if (iter == gdatap->mMembers.end()) { LL_WARNS() << "LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges() -- No member data for member with UUID " << agent_id << LL_ENDL; return GP_NO_POWERS; @@ -1570,37 +1546,36 @@ U64 LLPanelGroupMembersSubTab::getAgentPowersBasedOnRoleChanges(const LLUUID& ag return GP_NO_POWERS; } - //see if there are unsaved role changes for this agent + // See if there are unsaved role changes for this agent role_change_data_map_t* role_change_datap = NULL; member_role_changes_map_t::iterator member = mMemberRoleChangeData.find(agent_id); - if ( member != mMemberRoleChangeData.end() ) + if (member != mMemberRoleChangeData.end()) { - //this member has unsaved role changes - //so grab them - role_change_datap = (*member).second; + // This member has unsaved role changes + // so grab them + role_change_datap = member->second; } U64 new_powers = GP_NO_POWERS; - if ( role_change_datap ) + if (role_change_datap) { uuid_vec_t roles_to_be_removed; - for (role_change_data_map_t::iterator role = role_change_datap->begin(); - role != role_change_datap->end(); ++ role) + for (const auto& role : *role_change_datap) { - if ( role->second == RMC_ADD ) + if (role.second == RMC_ADD) { - new_powers |= gdatap->getRolePowers(role->first); + new_powers |= gdatap->getRolePowers(role.first); } else { - roles_to_be_removed.push_back(role->first); + roles_to_be_removed.push_back(role.first); } } - //loop over the member's current roles, summing up - //the powers (not including the role we are removing) + // loop over the member's current roles, summing up + // the powers (not including the role we are removing) for (LLGroupMemberData::role_list_t::iterator current_role = member_data->roleBegin(); current_role != member_data->roleEnd(); ++current_role) { @@ -1661,9 +1636,10 @@ void LLPanelGroupMembersSubTab::draw() void LLPanelGroupMembersSubTab::update(LLGroupChange gc) { - if (mGroupID.isNull()) return; + if (mGroupID.isNull()) + return; - if ( GC_TITLES == gc || GC_PROPERTIES == gc ) + if (GC_TITLES == gc || GC_PROPERTIES == gc) { // Don't care about title or general group properties updates. return; @@ -1677,9 +1653,9 @@ void LLPanelGroupMembersSubTab::update(LLGroupChange gc) } // Wait for both all data to be retrieved before displaying anything. - if ( gdatap->isMemberDataComplete() - && gdatap->isRoleDataComplete() - && gdatap->isRoleMemberDataComplete()) + if (gdatap->isMemberDataComplete() && + gdatap->isRoleDataComplete() && + gdatap->isRoleMemberDataComplete()) { mMemberProgress = gdatap->mMembers.begin(); mPendingMemberUpdate = true; @@ -1690,18 +1666,18 @@ void LLPanelGroupMembersSubTab::update(LLGroupChange gc) // Build a string with info on retrieval progress. std::ostringstream retrieved; - if ( gdatap->isRoleDataComplete() && gdatap->isMemberDataComplete() && !gdatap->mMembers.size() ) + if (gdatap->isRoleDataComplete() && gdatap->isMemberDataComplete() && !gdatap->mMembers.size()) { // MAINT-5237 retrieved << "Member list not available."; } - else if ( !gdatap->isMemberDataComplete() ) + else if (!gdatap->isMemberDataComplete()) { // Still busy retreiving member list. retrieved << "Retrieving member list (" << gdatap->mMembers.size() << " / " << gdatap->mMemberCount << ")..."; } - else if( !gdatap->isRoleDataComplete() ) + else if (!gdatap->isRoleDataComplete()) { // Still busy retreiving role list. retrieved << "Retrieving role list (" << gdatap->mRoles.size() @@ -1719,7 +1695,9 @@ void LLPanelGroupMembersSubTab::update(LLGroupChange gc) void LLPanelGroupMembersSubTab::addMemberToList(LLGroupMemberData* data) { - if (!data) return; + if (!data) + return; + LLUIString donated = getString("donation_area"); donated.setArg("[AREA]", llformat("%d", data->getContribution())); @@ -1765,7 +1743,7 @@ void LLPanelGroupMembersSubTab::onNameCache(const LLUUID& update_id, LLGroupMemb if (matchesSearchFilter(av_name.getAccountName())) { addMemberToList(member); - if(!mMembersList->getEnabled()) + if (!mMembersList->getEnabled()) { mMembersList->setEnabled(true); } @@ -1788,15 +1766,15 @@ void LLPanelGroupMembersSubTab::updateMembers() // Make sure all data is still complete. Incomplete data // may occur if we refresh. - if ( !gdatap->isMemberDataComplete() - || !gdatap->isRoleDataComplete() - || !gdatap->isRoleMemberDataComplete()) + if (!gdatap->isMemberDataComplete() || + !gdatap->isRoleDataComplete() || + !gdatap->isRoleMemberDataComplete()) { return; } - //cleanup list only for first iteration - if(mMemberProgress == gdatap->mMembers.begin()) + // Cleanup list only for first iteration + if (mMemberProgress == gdatap->mMembers.begin()) { mMembersList->deleteAllItems(); } @@ -1806,7 +1784,7 @@ void LLPanelGroupMembersSubTab::updateMembers() LLTimer update_time; update_time.setTimerExpirySec(UPDATE_MEMBERS_SECONDS_PER_FRAME); - for( ; mMemberProgress != end && !update_time.hasExpired(); ++mMemberProgress) + for (; mMemberProgress != end && !update_time.hasExpired(); ++mMemberProgress) { if (!mMemberProgress->second) continue; @@ -1866,7 +1844,8 @@ void LLPanelGroupMembersSubTab::onBanMember(void* user_data) void LLPanelGroupMembersSubTab::confirmBanMembers() { std::vector<LLScrollListItem*> selection = mMembersList->getAllSelected(); - if (selection.empty()) return; + if (selection.empty()) + return; auto selection_count = selection.size(); if (selection_count == 1) @@ -1912,8 +1891,7 @@ void LLPanelGroupMembersSubTab::updateActionDescription() return; } - LLRoleAction* rap = (LLRoleAction*)action_item->getUserdata(); - if (rap) + if (LLRoleAction* rap = (LLRoleAction*)action_item->getUserdata()) { std::string desc = rap->mLongDescription.empty() ? rap->mDescription : rap->mLongDescription; mActionDescription->setText(desc); @@ -1923,23 +1901,22 @@ void LLPanelGroupMembersSubTab::updateActionDescription() void LLPanelGroupMembersSubTab::handleBanMember() { LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); - if(!gdatap) + if (!gdatap) { LL_WARNS("Groups") << "Unable to get group data for group " << mGroupID << LL_ENDL; return; } std::vector<LLScrollListItem*> selection = mMembersList->getAllSelected(); - if(selection.empty()) + if (selection.empty()) { return; } uuid_vec_t ban_ids; - std::vector<LLScrollListItem*>::iterator itor; - for(itor = selection.begin(); itor != selection.end(); ++itor) + for (const LLScrollListItem* item : selection) { - LLUUID ban_id = (*itor)->getUUID(); + LLUUID ban_id = item->getUUID(); ban_ids.push_back(ban_id); LLGroupBanData ban_data; @@ -1983,54 +1960,33 @@ bool LLPanelGroupRolesSubTab::postBuildSubTab(LLView* root) LLPanelGroupRoles* parent = (LLPanelGroupRoles*) root; // Look recursively from the parent to find all our widgets. - bool recurse = true; - mHeader = parent->findChild<LLPanel>("roles_header", recurse); - mFooter = parent->findChild<LLPanel>("roles_footer", recurse); - - - mRolesList = parent->getChild<LLScrollListCtrl>("role_list", recurse); - mAssignedMembersList = parent->getChild<LLNameListCtrl>("role_assigned_members", recurse); - mAllowedActionsList = parent->getChild<LLScrollListCtrl>("role_allowed_actions", recurse); - mActionDescription = parent->getChild<LLTextEditor>("role_action_description", recurse); + mHeader = parent->findChild<LLPanel>("roles_header"); + mFooter = parent->findChild<LLPanel>("roles_footer"); - mRoleName = parent->getChild<LLLineEditor>("role_name", recurse); - mRoleTitle = parent->getChild<LLLineEditor>("role_title", recurse); - mRoleDescription = parent->getChild<LLTextEditor>("role_description", recurse); + mRolesList = parent->getChild<LLScrollListCtrl>("role_list"); + mAssignedMembersList = parent->getChild<LLNameListCtrl>("role_assigned_members"); + mAllowedActionsList = parent->getChild<LLScrollListCtrl>("role_allowed_actions"); + mActionDescription = parent->getChild<LLTextEditor>("role_action_description"); - mMemberVisibleCheck = parent->getChild<LLCheckBoxCtrl>("role_visible_in_list", recurse); + mRoleName = parent->getChild<LLLineEditor>("role_name"); + mRoleTitle = parent->getChild<LLLineEditor>("role_title"); + mRoleDescription = parent->getChild<LLTextEditor>("role_description"); - if (!mRolesList || !mAssignedMembersList || !mAllowedActionsList || !mActionDescription - || !mRoleName || !mRoleTitle || !mRoleDescription || !mMemberVisibleCheck) - { - LL_WARNS() << "ARG! element not found." << LL_ENDL; - return false; - } + mMemberVisibleCheck = parent->getChild<LLCheckBoxCtrl>("role_visible_in_list"); mRemoveEveryoneTxt = getString("cant_delete_role"); - mCreateRoleButton = - parent->getChild<LLButton>("role_create", recurse); - if ( mCreateRoleButton ) - { - mCreateRoleButton->setClickedCallback(onCreateRole, this); - mCreateRoleButton->setEnabled(false); - } + mCreateRoleButton = parent->getChild<LLButton>("role_create"); + mCreateRoleButton->setClickedCallback(onCreateRole, this); + mCreateRoleButton->setEnabled(false); - mCopyRoleButton = - parent->getChild<LLButton>("role_copy", recurse); - if ( mCopyRoleButton ) - { - mCopyRoleButton->setClickedCallback(onCopyRole, this); - mCopyRoleButton->setEnabled(false); - } + mCopyRoleButton = parent->getChild<LLButton>("role_copy"); + mCopyRoleButton->setClickedCallback(onCopyRole, this); + mCopyRoleButton->setEnabled(false); - mDeleteRoleButton = - parent->getChild<LLButton>("role_delete", recurse); - if ( mDeleteRoleButton ) - { - mDeleteRoleButton->setClickedCallback(onDeleteRole, this); - mDeleteRoleButton->setEnabled(false); - } + mDeleteRoleButton = parent->getChild<LLButton>("role_delete"); + mDeleteRoleButton->setClickedCallback(onDeleteRole, this); + mDeleteRoleButton->setEnabled(false); mRolesList->setCommitOnSelectionChange(true); mRolesList->setCommitCallback(onRoleSelect, this); @@ -2949,26 +2905,19 @@ void LLPanelGroupActionsSubTab::handleActionSelect() mActionMembers->deleteAllItems(); mActionRoles->deleteAllItems(); - U64 power_mask = GP_NO_POWERS; - std::vector<LLScrollListItem*> selection = - mActionList->getAllSelected(); - if (selection.empty()) return; - - LLRoleAction* rap; + std::vector<LLScrollListItem*> selection = mActionList->getAllSelected(); + if (selection.empty()) + return; - std::vector<LLScrollListItem*>::iterator itor; - for (itor = selection.begin() ; - itor != selection.end(); ++itor) + U64 power_mask = GP_NO_POWERS; + for (const LLScrollListItem* item : selection) { - rap = (LLRoleAction*)( (*itor)->getUserdata() ); - power_mask |= rap->mPowerBit; + power_mask |= ((LLRoleAction*)item->getUserdata())->mPowerBit; } if (selection.size() == 1) { - LLScrollListItem* item = selection[0]; - rap = (LLRoleAction*)(item->getUserdata()); - + LLRoleAction* rap = (LLRoleAction*)selection.front()->getUserdata(); if (rap->mLongDescription.empty()) { mActionDescription->setText(rap->mDescription); @@ -2985,21 +2934,19 @@ void LLPanelGroupActionsSubTab::handleActionSelect() LLGroupMgrGroupData* gdatap = LLGroupMgr::getInstance()->getGroupData(mGroupID); - if (!gdatap) return; + if (!gdatap) + return; if (gdatap->isMemberDataComplete()) { - LLGroupMgrGroupData::member_list_t::iterator it = gdatap->mMembers.begin(); - LLGroupMgrGroupData::member_list_t::iterator end = gdatap->mMembers.end(); - LLGroupMemberData* gmd; - - for ( ; it != end; ++it) + for (const auto& it : gdatap->mMembers) { - gmd = (*it).second; - if (!gmd) continue; - if ((gmd->getAgentPowers() & power_mask) == power_mask) + if (LLGroupMemberData* gmd = it.second) { - mActionMembers->addNameItem(gmd->getID()); + if ((gmd->getAgentPowers() & power_mask) == power_mask) + { + mActionMembers->addNameItem(gmd->getID()); + } } } } diff --git a/indra/newview/llpanellandmarks.cpp b/indra/newview/llpanellandmarks.cpp index 99133d1fb3..fb7ccbfe4c 100644 --- a/indra/newview/llpanellandmarks.cpp +++ b/indra/newview/llpanellandmarks.cpp @@ -647,10 +647,18 @@ bool LLLandmarksPanel::isActionEnabled(const LLSD& userdata) const if ("collapse_all" == command_name) { + if (!mCurrentSelectedList) + { + return false; + } return has_expanded_folders(mCurrentSelectedList->getRootFolder()); } else if ("expand_all" == command_name) { + if (!mCurrentSelectedList) + { + return false; + } return has_collapsed_folders(mCurrentSelectedList->getRootFolder()); } else if ("sort_by_date" == command_name) @@ -959,12 +967,12 @@ bool LLLandmarksPanel::canItemBeModified(const std::string& command_name, LLFold // then ask LLFolderView permissions - LLFolderView* root_folder = mCurrentSelectedList->getRootFolder(); + LLFolderView* root_folder = mCurrentSelectedList ? mCurrentSelectedList->getRootFolder() : nullptr; if ("copy" == command_name) { // we shouldn't be able to copy folders from My Inventory Panel - return can_be_modified && root_folder->canCopy(); + return can_be_modified && root_folder && root_folder->canCopy(); } else if ("collapse" == command_name) { @@ -981,7 +989,7 @@ bool LLLandmarksPanel::canItemBeModified(const std::string& command_name, LLFold if ("cut" == command_name) { - can_be_modified = root_folder->canCut(); + can_be_modified = root_folder && root_folder->canCut(); } else if ("rename" == command_name) { @@ -993,7 +1001,7 @@ bool LLLandmarksPanel::canItemBeModified(const std::string& command_name, LLFold } else if("paste" == command_name) { - can_be_modified = root_folder->canPaste(); + can_be_modified = root_folder && root_folder->canPaste(); } else { diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index ba52da0760..bbf533b694 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -1177,7 +1177,7 @@ void LLFloaterInventoryFinder::updateElementsFromFilter() return; // Get data needed for filter display - U32 filter_types = mFilter->getFilterObjectTypes(); + U32 filter_types = (U32)mFilter->getFilterObjectTypes(); LLInventoryFilter::EFolderShow show_folders = mFilter->getShowFolderState(); U32 hours = mFilter->getHoursAgo(); U32 date_search_direction = mFilter->getDateSearchDirection(); diff --git a/indra/newview/llpanelmarketplaceinbox.cpp b/indra/newview/llpanelmarketplaceinbox.cpp index 0925351350..35961da579 100644 --- a/indra/newview/llpanelmarketplaceinbox.cpp +++ b/indra/newview/llpanelmarketplaceinbox.cpp @@ -119,7 +119,7 @@ void LLPanelMarketplaceInbox::onFocusReceived() sidepanel_inventory->clearSelections(true, false); } - gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", time_corrected()); + gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", (U32)time_corrected()); } bool LLPanelMarketplaceInbox::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop, EDragAndDropType cargo_type, void *cargo_data, EAcceptance *accept, std::string& tooltip_msg) diff --git a/indra/newview/llpanelmarketplaceinboxinventory.cpp b/indra/newview/llpanelmarketplaceinboxinventory.cpp index 526462b940..557c7bbd7b 100644 --- a/indra/newview/llpanelmarketplaceinboxinventory.cpp +++ b/indra/newview/llpanelmarketplaceinboxinventory.cpp @@ -225,7 +225,7 @@ void LLInboxFolderViewFolder::deFreshify() { mFresh = false; - gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", time_corrected()); + gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", (U32)time_corrected()); LLInboxNewItemsStorage::getInstance()->removeItem(static_cast<LLFolderViewModelItemInventory*>(getViewModelItem())->getUUID()); } @@ -304,7 +304,7 @@ void LLInboxFolderViewItem::deFreshify() { mFresh = false; - gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", time_corrected()); + gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", (U32)time_corrected()); } LLInboxNewItemsStorage::LLInboxNewItemsStorage() diff --git a/indra/newview/llpanelpeoplemenus.cpp b/indra/newview/llpanelpeoplemenus.cpp index 172c7d0828..f8a73ddb46 100644 --- a/indra/newview/llpanelpeoplemenus.cpp +++ b/indra/newview/llpanelpeoplemenus.cpp @@ -245,11 +245,14 @@ bool PeopleContextMenu::enableContextMenuItem(const LLSD& userdata) { return LLLogChat::isTranscriptExist(mUUIDs.front()); } - else if (item == std::string("can_im") || item == std::string("can_invite") || - item == std::string("can_share") || item == std::string("can_pay")) + else if (item == std::string("can_im") || item == std::string("can_invite")) { return true; } + else if (item == std::string("can_share") || item == std::string("can_pay")) + { + return mUUIDs.size() == 1; + } return false; } diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp index 2a27a6e143..aa35335ad9 100644 --- a/indra/newview/llpanelpermissions.cpp +++ b/indra/newview/llpanelpermissions.cpp @@ -986,7 +986,7 @@ void shorten_name(std::string &name, const LLStyle::Params& style_params, S32 ma LLWString wline = utf8str_to_wstring(name); // panel supports two lines long names - S32 segment_length = font->maxDrawableChars(wline.c_str(), max_pixels, static_cast<S32>(wline.length()), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE); + S32 segment_length = font->maxDrawableChars(wline.c_str(), (F32)max_pixels, static_cast<S32>(wline.length()), LLFontGL::WORD_BOUNDARY_IF_POSSIBLE); if (segment_length == wline.length()) { // no work needed @@ -994,7 +994,7 @@ void shorten_name(std::string &name, const LLStyle::Params& style_params, S32 ma } S32 first_line_length = segment_length; - segment_length = font->maxDrawableChars(wline.substr(first_line_length).c_str(), max_pixels, static_cast<S32>(wline.length()), LLFontGL::ANYWHERE); + segment_length = font->maxDrawableChars(wline.substr(first_line_length).c_str(), (F32)max_pixels, static_cast<S32>(wline.length()), LLFontGL::ANYWHERE); if (segment_length + first_line_length == wline.length()) { // no work needed @@ -1003,8 +1003,8 @@ void shorten_name(std::string &name, const LLStyle::Params& style_params, S32 ma // name does not fit, cut it, add ... const LLWString dots_pad(utf8str_to_wstring(std::string("...."))); - S32 elipses_width = font->getWidthF32(dots_pad.c_str()); - segment_length = font->maxDrawableChars(wline.substr(first_line_length).c_str(), max_pixels - elipses_width, static_cast<S32>(wline.length()), LLFontGL::ANYWHERE); + F32 elipses_width = font->getWidthF32(dots_pad.c_str()); + segment_length = font->maxDrawableChars(wline.substr(first_line_length).c_str(), (F32)max_pixels - elipses_width, static_cast<S32>(wline.length()), LLFontGL::ANYWHERE); name = name.substr(0, segment_length + first_line_length) + std::string("..."); } diff --git a/indra/newview/llpanelplaceprofile.cpp b/indra/newview/llpanelplaceprofile.cpp index 4ceeaa5d51..18588514f8 100644 --- a/indra/newview/llpanelplaceprofile.cpp +++ b/indra/newview/llpanelplaceprofile.cpp @@ -395,9 +395,9 @@ void LLPanelPlaceProfile::displaySelectedParcelInfo(LLParcel* parcel, mPosRegion.setVec((F32)fmod(pos_global.mdV[VX], (F64)REGION_WIDTH_METERS), (F32)fmod(pos_global.mdV[VY], (F64)REGION_WIDTH_METERS), (F32)pos_global.mdV[VZ]); - parcel_data.global_x = pos_global.mdV[VX]; - parcel_data.global_y = pos_global.mdV[VY]; - parcel_data.global_z = pos_global.mdV[VZ]; + parcel_data.global_x = (F32)pos_global.mdV[VX]; + parcel_data.global_y = (F32)pos_global.mdV[VY]; + parcel_data.global_z = (F32)pos_global.mdV[VZ]; parcel_data.owner_id = parcel->getOwnerID(); std::string on = getString("on"); diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp index 1299c8c656..4e905ae0fd 100644 --- a/indra/newview/llpanelprimmediacontrols.cpp +++ b/indra/newview/llpanelprimmediacontrols.cpp @@ -421,7 +421,7 @@ void LLPanelPrimMediaControls::updateShape() if(mUpdateSlider && mMovieDuration!= 0) { F64 current_time = media_plugin->getCurrentTime(); - F32 percent = current_time / mMovieDuration; + F32 percent = (F32)(current_time / mMovieDuration); mMediaPlaySliderCtrl->setValue(percent); mMediaPlaySliderCtrl->setEnabled(true); } @@ -1309,7 +1309,7 @@ void LLPanelPrimMediaControls::onMediaPlaySliderCtrlMouseUp() } else { - media_impl->seek(cur_value * mMovieDuration); + media_impl->seek((F32)(cur_value * mMovieDuration)); } } diff --git a/indra/newview/llpanelsnapshot.cpp b/indra/newview/llpanelsnapshot.cpp index 2536dce606..32c9f6f402 100644 --- a/indra/newview/llpanelsnapshot.cpp +++ b/indra/newview/llpanelsnapshot.cpp @@ -41,7 +41,7 @@ #include "llagentbenefits.h" -constexpr S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512 +constexpr S32 MAX_TEXTURE_SIZE = 2048 ; //max upload texture size 2048 * 2048 S32 power_of_two(S32 sz, S32 upper) { @@ -61,7 +61,9 @@ LLPanelSnapshot::LLPanelSnapshot() // virtual bool LLPanelSnapshot::postBuild() { - getChild<LLUICtrl>("save_btn")->setLabelArg("[UPLOAD_COST]", std::to_string(LLAgentBenefitsMgr::current().getTextureUploadCost())); + S32 w = getTypedPreviewWidth(); + S32 h = getTypedPreviewHeight(); + getChild<LLUICtrl>("save_btn")->setLabelArg("[UPLOAD_COST]", std::to_string(LLAgentBenefitsMgr::current().getTextureUploadCost(w, h))); getChild<LLUICtrl>(getImageSizeComboName())->setCommitCallback(boost::bind(&LLPanelSnapshot::onResolutionComboCommit, this, _1)); if (!getWidthSpinnerName().empty()) { @@ -211,12 +213,12 @@ void LLPanelSnapshot::onCustomResolutionCommit() S32 width = widthSpinner->getValue().asInteger(); width = power_of_two(width, MAX_TEXTURE_SIZE); info["w"] = width; - widthSpinner->setIncrement(width >> 1); + widthSpinner->setIncrement((F32)(width >> 1)); widthSpinner->forceSetValue(width); S32 height = heightSpinner->getValue().asInteger(); height = power_of_two(height, MAX_TEXTURE_SIZE); - heightSpinner->setIncrement(height >> 1); - heightSpinner->forceSetValue(height); + heightSpinner->setIncrement((F32)(height >> 1)); + heightSpinner->forceSetValue((F32)height); info["h"] = height; } else diff --git a/indra/newview/llpanelsnapshotinventory.cpp b/indra/newview/llpanelsnapshotinventory.cpp index 4abb89120b..96b17acc40 100644 --- a/indra/newview/llpanelsnapshotinventory.cpp +++ b/indra/newview/llpanelsnapshotinventory.cpp @@ -155,7 +155,19 @@ void LLPanelSnapshotInventory::onResolutionCommit(LLUICtrl* ctrl) void LLPanelSnapshotInventoryBase::onSend() { - S32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(); + S32 w = 0; + S32 h = 0; + + if( mSnapshotFloater ) + { + LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView(); + if( preview ) + { + preview->getSize(w, h); + } + } + + S32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(w, h); if (can_afford_transaction(expected_upload_cost)) { if (mSnapshotFloater) diff --git a/indra/newview/llpanelsnapshotoptions.cpp b/indra/newview/llpanelsnapshotoptions.cpp index 776de460a9..962d3bba16 100644 --- a/indra/newview/llpanelsnapshotoptions.cpp +++ b/indra/newview/llpanelsnapshotoptions.cpp @@ -30,6 +30,7 @@ #include "llsidetraypanelcontainer.h" #include "llfloatersnapshot.h" // FIXME: create a snapshot model +#include "llsnapshotlivepreview.h" #include "llfloaterreg.h" #include "llagentbenefits.h" @@ -89,7 +90,19 @@ void LLPanelSnapshotOptions::onOpen(const LLSD& key) void LLPanelSnapshotOptions::updateUploadCost() { - S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(); + S32 w = 0; + S32 h = 0; + + if( mSnapshotFloater ) + { + LLSnapshotLivePreview* preview = mSnapshotFloater->getPreviewView(); + if( preview ) + { + preview->getSize(w, h); + } + } + + S32 upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(w, h); getChild<LLUICtrl>("save_to_inventory_btn")->setLabelArg("[AMOUNT]", llformat("%d", upload_cost)); } diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index 16c38bf1f0..951dc45a78 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -151,6 +151,7 @@ bool LLPanelVolume::postBuild() { childSetCommitCallback("Reflection Probe", onCommitIsReflectionProbe, this); childSetCommitCallback("Probe Update Type", onCommitProbe, this); + childSetCommitCallback("Probe Dynamic", onCommitProbe, this); childSetCommitCallback("Probe Volume Type", onCommitProbe, this); childSetCommitCallback("Probe Ambiance", onCommitProbe, this); childSetCommitCallback("Probe Near Clip", onCommitProbe, this); @@ -412,6 +413,7 @@ void LLPanelVolume::getState( ) getChild<LLSpinCtrl>("Probe Ambiance", true)->clear(); getChild<LLSpinCtrl>("Probe Near Clip", true)->clear(); getChild<LLComboBox>("Probe Update Type", true)->clear(); + getChild<LLUICtrl>("Probe Dynamic")->setValue(false); } else { @@ -446,6 +448,7 @@ void LLPanelVolume::getState( ) getChild<LLSpinCtrl>("Probe Ambiance", true)->setValue(volobjp->getReflectionProbeAmbiance()); getChild<LLSpinCtrl>("Probe Near Clip", true)->setValue(volobjp->getReflectionProbeNearClip()); getChild<LLComboBox>("Probe Update Type", true)->setValue(update_type); + getChild<LLUICtrl>("Probe Dynamic")->setValue(volobjp->getReflectionProbeIsDynamic()); } // Animated Mesh @@ -733,6 +736,7 @@ void LLPanelVolume::clearCtrls() getChildView("Reflection Probe")->setEnabled(false);; getChildView("Probe Volume Type")->setEnabled(false); getChildView("Probe Update Type")->setEnabled(false); + getChildView("Probe Dynamic")->setEnabled(false); getChildView("Probe Ambiance")->setEnabled(false); getChildView("Probe Near Clip")->setEnabled(false); getChildView("Animated Mesh Checkbox Ctrl")->setEnabled(false); @@ -895,25 +899,25 @@ void LLPanelVolume::sendPhysicsShapeType(LLUICtrl* ctrl, void* userdata) void LLPanelVolume::sendPhysicsGravity(LLUICtrl* ctrl, void* userdata) { - F32 val = ctrl->getValue().asReal(); + F32 val = (F32)ctrl->getValue().asReal(); LLSelectMgr::getInstance()->selectionSetGravity(val); } void LLPanelVolume::sendPhysicsFriction(LLUICtrl* ctrl, void* userdata) { - F32 val = ctrl->getValue().asReal(); + F32 val = (F32)ctrl->getValue().asReal(); LLSelectMgr::getInstance()->selectionSetFriction(val); } void LLPanelVolume::sendPhysicsRestitution(LLUICtrl* ctrl, void* userdata) { - F32 val = ctrl->getValue().asReal(); + F32 val = (F32)ctrl->getValue().asReal(); LLSelectMgr::getInstance()->selectionSetRestitution(val); } void LLPanelVolume::sendPhysicsDensity(LLUICtrl* ctrl, void* userdata) { - F32 val = ctrl->getValue().asReal(); + F32 val = (F32)ctrl->getValue().asReal(); LLSelectMgr::getInstance()->selectionSetDensity(val); } @@ -1095,10 +1099,10 @@ void LLPanelVolume::onPasteFeatures() objectp->setMaterial(material); objectp->sendMaterialUpdate(); - objectp->setPhysicsGravity(clipboard["physics"]["gravity"].asReal()); - objectp->setPhysicsFriction(clipboard["physics"]["friction"].asReal()); - objectp->setPhysicsDensity(clipboard["physics"]["density"].asReal()); - objectp->setPhysicsRestitution(clipboard["physics"]["restitution"].asReal()); + objectp->setPhysicsGravity((F32)clipboard["physics"]["gravity"].asReal()); + objectp->setPhysicsFriction((F32)clipboard["physics"]["friction"].asReal()); + objectp->setPhysicsDensity((F32)clipboard["physics"]["density"].asReal()); + objectp->setPhysicsRestitution((F32)clipboard["physics"]["restitution"].asReal()); objectp->updateFlags(true); } @@ -1123,10 +1127,10 @@ void LLPanelVolume::onPasteFeatures() LLFlexibleObjectData new_attributes; new_attributes = *attributes; new_attributes.setSimulateLOD(clipboard["flex"]["lod"].asInteger()); - new_attributes.setGravity(clipboard["flex"]["gav"].asReal()); - new_attributes.setTension(clipboard["flex"]["ten"].asReal()); - new_attributes.setAirFriction(clipboard["flex"]["fri"].asReal()); - new_attributes.setWindSensitivity(clipboard["flex"]["sen"].asReal()); + new_attributes.setGravity((F32)clipboard["flex"]["gav"].asReal()); + new_attributes.setTension((F32)clipboard["flex"]["ten"].asReal()); + new_attributes.setAirFriction((F32)clipboard["flex"]["fri"].asReal()); + new_attributes.setWindSensitivity((F32)clipboard["flex"]["sen"].asReal()); F32 fx = (F32)clipboard["flex"]["forx"].asReal(); F32 fy = (F32)clipboard["flex"]["fory"].asReal(); F32 fz = (F32)clipboard["flex"]["forz"].asReal(); @@ -1428,15 +1432,26 @@ void LLPanelVolume::onCommitProbe(LLUICtrl* ctrl, void* userdata) volobjp->setReflectionProbeAmbiance((F32)self->getChild<LLUICtrl>("Probe Ambiance")->getValue().asReal()); volobjp->setReflectionProbeNearClip((F32)self->getChild<LLUICtrl>("Probe Near Clip")->getValue().asReal()); - std::string update_type = self->getChild<LLUICtrl>("Probe Update Type")->getValue().asString(); + bool mirrors_enabled = LLPipeline::RenderMirrors; + bool is_mirror = false; - bool is_mirror = update_type.find("Mirror") != std::string::npos; + if (mirrors_enabled) + { + std::string update_type = self->getChild<LLUICtrl>("Probe Update Type")->getValue().asString(); - self->getChildView("Probe Volume Type")->setEnabled(!is_mirror); + is_mirror = update_type.find("Mirror") != std::string::npos; - volobjp->setReflectionProbeIsDynamic(update_type.find("Dynamic") != std::string::npos); - volobjp->setReflectionProbeIsMirror(is_mirror); + volobjp->setReflectionProbeIsDynamic(update_type.find("Dynamic") != std::string::npos); + volobjp->setReflectionProbeIsMirror(is_mirror); + } + else + { + is_mirror = volobjp->getReflectionProbeIsMirror(); + bool is_dynamic = self->getChild<LLUICtrl>("Probe Dynamic")->getValue().asBoolean(); + volobjp->setReflectionProbeIsDynamic(is_dynamic); + } + self->getChildView("Probe Volume Type")->setEnabled(!is_mirror); self->getChildView("Probe Ambiance")->setEnabled(!is_mirror); self->getChildView("Probe Near Clip")->setEnabled(!is_mirror); diff --git a/indra/newview/llpathfindingcharacter.cpp b/indra/newview/llpathfindingcharacter.cpp index 66cc26469e..a6d26727f4 100644 --- a/indra/newview/llpathfindingcharacter.cpp +++ b/indra/newview/llpathfindingcharacter.cpp @@ -83,7 +83,7 @@ void LLPathfindingCharacter::parseCharacterData(const LLSD &pCharacterData) { llassert(pCharacterData.has(CHARACTER_CPU_TIME_FIELD)); llassert(pCharacterData.get(CHARACTER_CPU_TIME_FIELD).isReal()); - mCPUTime = pCharacterData.get(CHARACTER_CPU_TIME_FIELD).asReal(); + mCPUTime = (F32)pCharacterData.get(CHARACTER_CPU_TIME_FIELD).asReal(); llassert(pCharacterData.has(CHARACTER_HORIZONTAL_FIELD)); llassert(pCharacterData.get(CHARACTER_HORIZONTAL_FIELD).isBoolean()); @@ -91,9 +91,9 @@ void LLPathfindingCharacter::parseCharacterData(const LLSD &pCharacterData) llassert(pCharacterData.has(CHARACTER_LENGTH_FIELD)); llassert(pCharacterData.get(CHARACTER_LENGTH_FIELD).isReal()); - mLength = pCharacterData.get(CHARACTER_LENGTH_FIELD).asReal(); + mLength = (F32)pCharacterData.get(CHARACTER_LENGTH_FIELD).asReal(); llassert(pCharacterData.has(CHARACTER_RADIUS_FIELD)); llassert(pCharacterData.get(CHARACTER_RADIUS_FIELD).isReal()); - mRadius = pCharacterData.get(CHARACTER_RADIUS_FIELD).asReal(); + mRadius = (F32)pCharacterData.get(CHARACTER_RADIUS_FIELD).asReal(); } diff --git a/indra/newview/llperfstats.cpp b/indra/newview/llperfstats.cpp index 64f438976a..37bb59a65c 100644 --- a/indra/newview/llperfstats.cpp +++ b/indra/newview/llperfstats.cpp @@ -91,7 +91,7 @@ namespace LLPerfStats const auto newval = gSavedSettings.getF32("RenderAvatarMaxART"); if(newval < log10(LLPerfStats::ART_UNLIMITED_NANOS/1000)) { - LLPerfStats::renderAvatarMaxART_ns = pow(10,newval)*1000; + LLPerfStats::renderAvatarMaxART_ns = (U64)pow(10,newval)*1000; } else { @@ -301,7 +301,7 @@ namespace LLPerfStats std::vector<LLVector3d> positions; uuid_vec_t avatar_ids; - LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, our_pos, distance); + LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, our_pos, (F32)distance); return static_cast<int>(positions.size()); } @@ -375,7 +375,7 @@ namespace LLPerfStats { // if we have less than the user's "max Non-Impostors" avatars within the desired range then adjust the limit. // also adjusts back up again for nearby crowds. - auto count = countNearbyAvatars(std::min(LLPipeline::RenderFarClip, tunables.userImpostorDistance)); + auto count = countNearbyAvatars((S32)std::min(LLPipeline::RenderFarClip, tunables.userImpostorDistance)); if( count != tunables.nonImpostors ) { tunables.updateNonImposters(((U32)count < LLVOAvatar::NON_IMPOSTORS_MAX_SLIDER) ? count : 0); @@ -476,7 +476,7 @@ namespace LLPerfStats // max render this frame may be higher than the last (cos new entrants and jitter) so make sure we are heading in the right direction if( new_render_limit_ns > renderAvatarMaxART_ns ) { - new_render_limit_ns = renderAvatarMaxART_ns; + new_render_limit_ns = (double)renderAvatarMaxART_ns; } if (new_render_limit_ns > LLPerfStats::ART_MIN_ADJUST_DOWN_NANOS) @@ -485,12 +485,12 @@ namespace LLPerfStats } // bounce at the bottom to prevent "no limit" - new_render_limit_ns = std::max((U64)new_render_limit_ns, (U64)LLPerfStats::ART_MINIMUM_NANOS); + new_render_limit_ns = (double)std::max((U64)new_render_limit_ns, (U64)LLPerfStats::ART_MINIMUM_NANOS); // assign the new value if (renderAvatarMaxART_ns != new_render_limit_ns) { - renderAvatarMaxART_ns = new_render_limit_ns; + renderAvatarMaxART_ns = (U64)new_render_limit_ns; tunables.updateSettingsFromRenderCostLimit(); } // LL_DEBUGS() << "AUTO_TUNE: avatar_budget adjusted to:" << new_render_limit_ns << LL_ENDL; diff --git a/indra/newview/llphysicsmotion.cpp b/indra/newview/llphysicsmotion.cpp index b6bcd6dd7d..6782aa2123 100644 --- a/indra/newview/llphysicsmotion.cpp +++ b/indra/newview/llphysicsmotion.cpp @@ -445,8 +445,8 @@ F32 LLPhysicsMotion::calculateAcceleration_local(const F32 velocity_local, const const F32 acceleration_local = (velocity_local - mVelocityJoint_local) / time_delta; const F32 smoothed_acceleration_local = - acceleration_local * 1.0/smoothing + - mAccelerationJoint_local * (smoothing-1.0)/smoothing; + acceleration_local * 1.0f/smoothing + + mAccelerationJoint_local * (smoothing-1.0f)/smoothing; return smoothed_acceleration_local; } @@ -603,7 +603,7 @@ bool LLPhysicsMotion::onUpdate(F32 time) // Drag is a force imparted by velocity (intuitively it is similar to wind resistance) // F = .5kv^2 - const F32 force_drag = .5*behavior_drag*velocity_joint_local*velocity_joint_local*llsgn(velocity_joint_local); + const F32 force_drag = (F32)(.5 * behavior_drag * velocity_joint_local * velocity_joint_local * llsgn(velocity_joint_local)); const F32 force_net = (force_accel + force_gravity + @@ -631,7 +631,7 @@ bool LLPhysicsMotion::onUpdate(F32 time) // Temporary debugging setting to cause all avatars to move, for profiling purposes. if (physics_test) { - velocity_new_local = sin(time*4.0); + velocity_new_local = sin(time*4.0f); } // Calculate the new parameters, or remain unchanged if max speed is 0. F32 position_new_local = position_current_local + velocity_new_local*time_iteration_step; @@ -697,7 +697,7 @@ bool LLPhysicsMotion::onUpdate(F32 time) // For non-self, if the avatar is small enough visually, then don't update. const F32 area_for_max_settings = 0.0; const F32 area_for_min_settings = 1400.0; - const F32 area_for_this_setting = area_for_max_settings + (area_for_min_settings-area_for_max_settings)*(1.0-lod_factor); + const F32 area_for_this_setting = area_for_max_settings + (area_for_min_settings-area_for_max_settings)*(1.0f-lod_factor); const F32 pixel_area = sqrtf(mCharacter->getPixelArea()); const bool is_self = (dynamic_cast<LLVOAvatarSelf *>(mCharacter) != NULL); @@ -763,8 +763,8 @@ void LLPhysicsMotion::setParamValue(const LLViewerVisualParam *param, { const F32 value_min_local = param->getMinWeight(); const F32 value_max_local = param->getMaxWeight(); - const F32 min_val = 0.5f-behavior_maxeffect/2.0; - const F32 max_val = 0.5f+behavior_maxeffect/2.0; + const F32 min_val = 0.5f-behavior_maxeffect/2.0f; + const F32 max_val = 0.5f+behavior_maxeffect/2.0f; // Scale from [0,1] to [min_val,max_val] const F32 new_value_rescaled = min_val + (max_val-min_val) * new_value_normalized; diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index c2188ea638..b7c929f0b5 100644 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -414,7 +414,13 @@ LLScriptEdCore::~LLScriptEdCore() if (script_search && script_search->getEditorCore() == this) { script_search->closeFloater(); - delete script_search; + // closeFloater can delete instance since it's not reusable nor single instance + // so make sure instance is still there before deleting + script_search = LLFloaterScriptSearch::getInstance(); + if (script_search) + { + delete script_search; + } } delete mLiveFile; diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 259332a3ff..2a5d7f2450 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -657,7 +657,7 @@ void LLPreviewTexture::adjustAspectRatio() S32 num = mImage->getFullWidth() / divisor; S32 denom = mImage->getFullHeight() / divisor; - if (setAspectRatio(num, denom)) + if (setAspectRatio((F32)num, (F32)denom)) { // Select corresponding ratio entry in the combo list LLComboBox* combo = getChild<LLComboBox>("combo_aspect_ratio"); @@ -677,7 +677,7 @@ void LLPreviewTexture::adjustAspectRatio() } else { - combo->setCurrentByIndex(found - mRatiosList.begin()); + combo->setCurrentByIndex((S32)(found - mRatiosList.begin())); } } } diff --git a/indra/newview/llprogressview.cpp b/indra/newview/llprogressview.cpp index e03984a44c..7bef0339c5 100644 --- a/indra/newview/llprogressview.cpp +++ b/indra/newview/llprogressview.cpp @@ -388,7 +388,7 @@ void LLProgressView::initLogos() // We don't know final screen rect yet, so we can't precalculate position fully LLTextBox *logos_label = getChild<LLTextBox>("logos_lbl"); - S32 texture_start_x = logos_label->getFont()->getWidthF32(logos_label->getText()) + default_pad; + S32 texture_start_x = (S32)logos_label->getFont()->getWidthF32(logos_label->getText()) + default_pad; S32 texture_start_y = -7; // Normally we would just preload these textures from textures.xml, @@ -590,7 +590,7 @@ bool LLProgressView::handleUpdate(const LLSD& event_data) if(percent.isDefined()) { - setPercent(percent.asReal()); + setPercent((F32)percent.asReal()); } return false; } diff --git a/indra/newview/llrecentpeople.cpp b/indra/newview/llrecentpeople.cpp index d64dfdfcbc..c698139c6d 100644 --- a/indra/newview/llrecentpeople.cpp +++ b/indra/newview/llrecentpeople.cpp @@ -114,8 +114,8 @@ F32 LLRecentPeople::getArrivalTimeByID(const LLUUID& id) if (it != mAvatarsArrivalTime.end()) { - return it->second; + return (F32)(it->second); } - return LLDate::now().secondsSinceEpoch(); + return (F32)LLDate::now().secondsSinceEpoch(); } diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index cb1ab0dac2..1efe51c1aa 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -230,7 +230,7 @@ void LLReflectionMapManager::update() if (mMipChain.empty()) { U32 res = mProbeResolution; - U32 count = log2((F32)res) + 0.5f; + U32 count = (U32)(log2((F32)res) + 0.5f); mMipChain.resize(count); for (U32 i = 0; i < count; ++i) @@ -251,7 +251,7 @@ void LLReflectionMapManager::update() auto const & iter = std::find(mProbes.begin(), mProbes.end(), probe); if (iter != mProbes.end()) { - deleteProbe(iter - mProbes.begin()); + deleteProbe((U32)(iter - mProbes.begin())); } } @@ -761,7 +761,7 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face) } - S32 mips = log2((F32)mProbeResolution) + 0.5f; + S32 mips = (S32)(log2((F32)mProbeResolution) + 0.5f); gReflectionMipProgram.bind(); S32 diffuseChannel = gReflectionMipProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_TEXTURE); @@ -839,7 +839,7 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face) static LLStaticHashedString sWidth("u_width"); gRadianceGenProgram.uniform1f(sRoughness, (F32)i / (F32)(mMipChain.size() - 1)); - gRadianceGenProgram.uniform1f(sMipLevel, i); + gRadianceGenProgram.uniform1f(sMipLevel, (GLfloat)i); gRadianceGenProgram.uniform1i(sWidth, mProbeResolution); for (int cf = 0; cf < 6; ++cf) @@ -1378,7 +1378,7 @@ void LLReflectionMapManager::initReflectionMaps() mReset = false; mReflectionProbeCount = count; mProbeResolution = nhpo2(llclamp(gSavedSettings.getU32("RenderReflectionProbeResolution"), (U32)64, (U32)512)); - mMaxProbeLOD = log2f(mProbeResolution) - 1.f; // number of mips - 1 + mMaxProbeLOD = log2f((F32)mProbeResolution) - 1.f; // number of mips - 1 if (mTexture.isNull() || mTexture->getWidth() != mProbeResolution || diff --git a/indra/newview/llscreenchannel.cpp b/indra/newview/llscreenchannel.cpp index 89ec2bf72e..f75e48c728 100644 --- a/indra/newview/llscreenchannel.cpp +++ b/indra/newview/llscreenchannel.cpp @@ -259,7 +259,7 @@ void LLScreenChannel::updatePositionAndSize(LLRect new_world_rect) //-------------------------------------------------------------------------- void LLScreenChannel::addToast(const LLToast::Params& p) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; bool store_toast = false, show_toast = false; if (mDisplayToastsAlways) diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp index 6eb8cf0b37..6f23477415 100644 --- a/indra/newview/llscripteditor.cpp +++ b/indra/newview/llscripteditor.cpp @@ -127,7 +127,7 @@ void LLScriptEditor::drawLineNumbers() ltext, // string to draw 0, // begin offset UI_TEXTEDITOR_LINE_NUMBER_MARGIN - 2, // x - line_bottom, // y + (F32)line_bottom, // y fg_color, LLFontGL::RIGHT, // horizontal alignment LLFontGL::BOTTOM, // vertical alignment diff --git a/indra/newview/llsechandler_basic.cpp b/indra/newview/llsechandler_basic.cpp index 2d8a5eaf13..1e50135e89 100644 --- a/indra/newview/llsechandler_basic.cpp +++ b/indra/newview/llsechandler_basic.cpp @@ -901,7 +901,7 @@ void _validateCert(int validation_policy, if (validation_policy & VALIDATION_POLICY_TIME) { - LLDate validation_date(time(NULL)); + LLDate validation_date((double)time(NULL)); if(validation_params.has(CERT_VALIDATION_DATE)) { validation_date = validation_params[CERT_VALIDATION_DATE]; @@ -1111,7 +1111,7 @@ void LLBasicCertificateStore::validate(int validation_policy, } else { - validation_date = LLDate(time(NULL)); // current time + validation_date = LLDate((double)time(NULL)); // current time } if((validation_date < cache_entry->second.first) || @@ -1358,8 +1358,8 @@ void LLSecAPIBasicHandler::_readProtectedData(unsigned char *unique_id, U32 id_l protected_data_stream.read((char *)buffer, BUFFER_READ_SIZE); EVP_DecryptUpdate(ctx, decrypted_buffer, &decrypted_length, - buffer, protected_data_stream.gcount()); - decrypted_data.append((const char *)decrypted_buffer, protected_data_stream.gcount()); + buffer, (int)protected_data_stream.gcount()); + decrypted_data.append((const char *)decrypted_buffer, (int)protected_data_stream.gcount()); } // RC4 is a stream cipher, so we don't bother to EVP_DecryptFinal, as there is @@ -1447,7 +1447,7 @@ void LLSecAPIBasicHandler::_writeProtectedData() } int encrypted_length; EVP_EncryptUpdate(ctx, encrypted_buffer, &encrypted_length, - buffer, formatted_data_istream.gcount()); + buffer, (int)formatted_data_istream.gcount()); protected_data_stream.write((const char *)encrypted_buffer, encrypted_length); } diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index b3420f9c57..fcd1c84ba4 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -56,6 +56,7 @@ #include "llattachmentsmgr.h" #include "llviewerwindow.h" #include "lldrawable.h" +#include "llfloatergltfasseteditor.h" #include "llfloaterinspect.h" #include "llfloaterreporter.h" #include "llfloaterreg.h" @@ -467,6 +468,11 @@ LLObjectSelectionHandle LLSelectMgr::selectObjectOnly(LLViewerObject* object, S3 if (object->isSelected() ) { // make sure point at position is updated updatePointAt(); + LLSelectNode* nodep = mSelectedObjects->findNode(object); + if (nodep) + { + nodep->selectGLTFNode(gltf_node, gltf_primitive, true); + } gEditMenuHandler = this; return NULL; } @@ -3052,7 +3058,7 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch) for (U8 te_num = 0; te_num < object->getNumTEs(); te_num++) { - const LLTextureEntry* tep = object->getTE(te_num); + LLTextureEntry* tep = object->getTE(te_num); bool planar = tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR; if (planar == stretch) @@ -3086,8 +3092,6 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch) object->setTEScale(te_num, diffuse_scale_s, diffuse_scale_t); - LLTextureEntry* tep = object->getTE(te_num); - if (tep && !tep->getMaterialParams().isNull()) { LLMaterialPtr orig = tep->getMaterialParams(); @@ -3125,6 +3129,47 @@ void LLSelectMgr::adjustTexturesByScale(bool send_to_sim, bool stretch) LLMaterialMgr::getInstance()->put(object->getID(), te_num, *p); } } + + if (tep->getGLTFMaterial()) + { + LLPointer<LLGLTFMaterial> material = tep->getGLTFMaterialOverride(); + if (!material) + { + material = new LLGLTFMaterial(); + tep->setGLTFMaterialOverride(material); + } + + F32 scale_x = 1; + F32 scale_y = 1; + + for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i) + { + LLVector3 scale_ratio = selectNode->mGLTFScaleRatios[te_num][i]; + + if (planar) + { + scale_x = scale_ratio.mV[s_axis] / object_scale.mV[s_axis]; + scale_y = scale_ratio.mV[t_axis] / object_scale.mV[t_axis]; + } + else + { + scale_x = scale_ratio.mV[s_axis] * object_scale.mV[s_axis]; + scale_y = scale_ratio.mV[t_axis] * object_scale.mV[t_axis]; + } + material->mTextureTransform[i].mScale.set(scale_x, scale_y); + } + + LLFetchedGLTFMaterial* render_mat = (LLFetchedGLTFMaterial*)tep->getGLTFRenderMaterial(); + if (render_mat) + { + render_mat->applyOverride(*material); + } + + if (send_to_sim) + { + LLGLTFMaterialList::queueModify(object, te_num, material); + } + } send = send_to_sim; } } @@ -6848,6 +6893,7 @@ void LLSelectNode::saveGLTFMaterials(const uuid_vec_t& materials, const gltf_mat void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) { mTextureScaleRatios.clear(); + mGLTFScaleRatios.clear(); if (mObject.notNull()) { @@ -6882,6 +6928,40 @@ void LLSelectNode::saveTextureScaleRatios(LLRender::eTexIndex index_to_query) v.mV[t_axis] = diffuse_t/scale.mV[t_axis]; mTextureScaleRatios.push_back(v); } + + LLGLTFMaterial* material = tep->getGLTFMaterialOverride(); + LLVector3 material_v; + F32 scale_x = 1; + F32 scale_y = 1; + std::vector<LLVector3> material_v_vec; + for (U32 i = 0; i < LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; ++i) + { + if (material) + { + LLGLTFMaterial::TextureTransform& transform = material->mTextureTransform[i]; + scale_x = transform.mScale[VX]; + scale_y = transform.mScale[VY]; + } + else + { + // Not having an override doesn't mean that there is no material + scale_x = 1; + scale_y = 1; + } + + if (tep->getTexGen() == LLTextureEntry::TEX_GEN_PLANAR) + { + material_v.mV[s_axis] = scale_x * scale.mV[s_axis]; + material_v.mV[t_axis] = scale_y * scale.mV[t_axis]; + } + else + { + material_v.mV[s_axis] = scale_x / scale.mV[s_axis]; + material_v.mV[t_axis] = scale_y / scale.mV[t_axis]; + } + material_v_vec.push_back(material_v); + } + mGLTFScaleRatios.push_back(material_v_vec); } } } @@ -7187,6 +7267,12 @@ void dialog_refresh_all() { panel_task_info->dirty(); } + + LLFloaterGLTFAssetEditor * gltf_editor = LLFloaterReg::findTypedInstance<LLFloaterGLTFAssetEditor>("gltf_asset_editor"); + if (gltf_editor) + { + gltf_editor->dirty(); + } } S32 get_family_count(LLViewerObject *parent) diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 0456b109d7..355e28595b 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -239,6 +239,7 @@ public: uuid_vec_t mSavedGLTFMaterialIds; gltf_materials_vec_t mSavedGLTFOverrideMaterials; std::vector<LLVector3> mTextureScaleRatios; + std::vector< std::vector<LLVector3> > mGLTFScaleRatios; std::vector<LLVector3> mSilhouetteVertices; // array of vertices to render silhouette of object std::vector<LLVector3> mSilhouetteNormals; // array of normals to render silhouette of object bool mSilhouetteExists; // need to generate silhouette? diff --git a/indra/newview/llsetkeybinddialog.cpp b/indra/newview/llsetkeybinddialog.cpp index e172e15a0e..5dbd579b45 100644 --- a/indra/newview/llsetkeybinddialog.cpp +++ b/indra/newview/llsetkeybinddialog.cpp @@ -337,8 +337,8 @@ void LLSetKeyBindDialog::onCancel(void* user_data) void LLSetKeyBindDialog::onBlank(void* user_data) { LLSetKeyBindDialog* self = (LLSetKeyBindDialog*)user_data; - // tmp needs 'no key' button - self->setKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, false); + + self->setKeyBind(CLICK_NONE, KEY_NONE, MASK_NONE, self->pCheckBox->getValue().asBoolean()); self->closeFloater(); } diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 42927769de..fdb73efa14 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -609,8 +609,8 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA legacy[SETTING_CLOUD_POS_DENSITY2] = ensure_array_4(settings[SETTING_CLOUD_POS_DENSITY2], 1.0); legacy[SETTING_CLOUD_SCALE] = llsd::array(settings[SETTING_CLOUD_SCALE], LLSD::Real(0.0), LLSD::Real(0.0), LLSD::Real(1.0)); legacy[SETTING_CLOUD_SCROLL_RATE] = settings[SETTING_CLOUD_SCROLL_RATE]; - legacy[SETTING_LEGACY_ENABLE_CLOUD_SCROLL] = llsd::array(LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][0].asReal())), - LLSD::Boolean(!is_approx_zero(settings[SETTING_CLOUD_SCROLL_RATE][1].asReal()))); + legacy[SETTING_LEGACY_ENABLE_CLOUD_SCROLL] = llsd::array(LLSD::Boolean(!is_approx_zero((F32)settings[SETTING_CLOUD_SCROLL_RATE][0].asReal())), + LLSD::Boolean(!is_approx_zero((F32)settings[SETTING_CLOUD_SCROLL_RATE][1].asReal()))); legacy[SETTING_CLOUD_SHADOW] = llsd::array(settings[SETTING_CLOUD_SHADOW].asReal(), 0.0f, 0.0f, 1.0f); legacy[SETTING_GAMMA] = llsd::array(settings[SETTING_GAMMA], 0.0f, 0.0f, 1.0f); legacy[SETTING_GLOW] = ensure_array_4(settings[SETTING_GLOW], 1.0); @@ -756,7 +756,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force) if (psky->getReflectionProbeAmbiance() != 0.f) { shader->uniform3fv(LLShaderMgr::AMBIENT, LLVector3(ambient.mV)); - shader->uniform1f(LLShaderMgr::SKY_HDR_SCALE, sqrtf(g)*2.0); // use a modifier here so 1.0 maps to the "most desirable" default and the maximum value doesn't go off the rails + shader->uniform1f(LLShaderMgr::SKY_HDR_SCALE, sqrtf(g)*2.0f); // use a modifier here so 1.0 maps to the "most desirable" default and the maximum value doesn't go off the rails } else if (psky->canAutoAdjust() && should_auto_adjust) { // auto-adjust legacy sky to take advantage of probe ambiance @@ -1055,7 +1055,7 @@ void LLSettingsVOWater::applySpecial(void *ptarget, bool force) shader->uniform3fv(LLShaderMgr::WATER_FOGCOLOR_LINEAR, linearColor3(fog_color).mV); - F32 blend_factor = env.getCurrentWater()->getBlendFactor(); + F32 blend_factor = (F32)env.getCurrentWater()->getBlendFactor(); shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); // update to normal lightnorm, water shader itself will use rotated lightnorm as necessary diff --git a/indra/newview/llsidepanelinventory.cpp b/indra/newview/llsidepanelinventory.cpp index 0d81f2c099..9b7289df67 100644 --- a/indra/newview/llsidepanelinventory.cpp +++ b/indra/newview/llsidepanelinventory.cpp @@ -372,7 +372,7 @@ void LLSidepanelInventory::onToggleInboxBtn() mInboxLayoutPanel->setTargetDim(gSavedPerAccountSettings.getS32("InventoryInboxHeight")); if (mInboxLayoutPanel->isInVisibleChain()) { - gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", time_corrected()); + gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", (U32)time_corrected()); } } else @@ -397,7 +397,7 @@ void LLSidepanelInventory::onOpen(const LLSD& key) #else if (mInboxEnabled && getChild<LLButton>(INBOX_BUTTON_NAME)->getToggleState()) { - gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", time_corrected()); + gSavedPerAccountSettings.setU32("LastInventoryInboxActivity", (U32)time_corrected()); } #endif diff --git a/indra/newview/llsidetraypanelcontainer.cpp b/indra/newview/llsidetraypanelcontainer.cpp index eb8e05ec27..44e0c3b05c 100644 --- a/indra/newview/llsidetraypanelcontainer.cpp +++ b/indra/newview/llsidetraypanelcontainer.cpp @@ -62,10 +62,10 @@ void LLSideTrayPanelContainer::onOpen(const LLSD& key) getCurrentPanel()->onOpen(key); } -void LLSideTrayPanelContainer::openPanel(const std::string& panel_name, const LLSD& key) +void LLSideTrayPanelContainer::openPanel(std::string_view panel_name, const LLSD& key) { LLSD combined_key = key; - combined_key[PARAM_SUB_PANEL_NAME] = panel_name; + combined_key[PARAM_SUB_PANEL_NAME] = std::string(panel_name); onOpen(combined_key); } diff --git a/indra/newview/llsidetraypanelcontainer.h b/indra/newview/llsidetraypanelcontainer.h index 5dfd7f2d83..0017d7743f 100644 --- a/indra/newview/llsidetraypanelcontainer.h +++ b/indra/newview/llsidetraypanelcontainer.h @@ -59,7 +59,7 @@ public: /** * Opens given subpanel. */ - void openPanel(const std::string& panel_name, const LLSD& key = LLSD::emptyMap()); + void openPanel(std::string_view panel_name, const LLSD& key = LLSD::emptyMap()); /** * Opens previous panel from panel navigation history. diff --git a/indra/newview/llslurl.cpp b/indra/newview/llslurl.cpp index 432ec3899a..9e567e3262 100644 --- a/indra/newview/llslurl.cpp +++ b/indra/newview/llslurl.cpp @@ -32,13 +32,15 @@ #include "llpanellogin.h" #include "llviewercontrol.h" #include "llviewernetwork.h" -#include "llfiltersd2xmlrpc.h" + #include "curl/curl.h" + const char* LLSLURL::SLURL_HTTP_SCHEME = "http"; const char* LLSLURL::SLURL_HTTPS_SCHEME = "https"; const char* LLSLURL::SLURL_SECONDLIFE_SCHEME = "secondlife"; const char* LLSLURL::SLURL_SECONDLIFE_PATH = "secondlife"; const char* LLSLURL::SLURL_COM = "slurl.com"; + // For DnD - even though www.slurl.com redirects to slurl.com in a browser, you can copy and drag // text with www.slurl.com or a link explicitly pointing at www.slurl.com so testing for this // version is required also. @@ -340,7 +342,7 @@ LLSLURL::LLSLURL(const std::string& grid, S32 y = ll_round((F32)fmod(position[VY], (F32)REGION_WIDTH_METERS)); S32 z = ll_round((F32)position[VZ]); mType = LOCATION; - mPosition = LLVector3(x, y, z); + mPosition = LLVector3((F32)x, (F32)y, (F32)z); } // create a simstring @@ -356,7 +358,7 @@ LLSLURL::LLSLURL(const std::string& grid, const LLVector3d& global_position) { *this = LLSLURL(LLGridManager::getInstance()->getGridId(grid), region, - LLVector3(global_position.mdV[VX], global_position.mdV[VY], global_position.mdV[VZ])); + LLVector3((F32)global_position.mdV[VX], (F32)global_position.mdV[VY], (F32)global_position.mdV[VZ])); } // create a slurl from a global position @@ -437,7 +439,7 @@ std::string LLSLURL::getLoginString() const LL_WARNS("AppInit") << "Unexpected SLURL type (" << (int)mType << ")for login string" << LL_ENDL; break; } - return xml_escape_string(unescaped_start.str()); + return LLStringFn::xml_encode(unescaped_start.str(), true); } bool LLSLURL::operator ==(const LLSLURL& rhs) diff --git a/indra/newview/llsnapshotlivepreview.cpp b/indra/newview/llsnapshotlivepreview.cpp index 787dd3b667..0b73aa493c 100644 --- a/indra/newview/llsnapshotlivepreview.cpp +++ b/indra/newview/llsnapshotlivepreview.cpp @@ -65,10 +65,10 @@ constexpr F32 FALL_TIME = 0.6f; constexpr S32 BORDER_WIDTH = 6; constexpr S32 TOP_PANEL_HEIGHT = 30; -constexpr S32 MAX_TEXTURE_SIZE = 512 ; //max upload texture size 512 * 512 +constexpr S32 MAX_TEXTURE_SIZE = 2048 ; //max upload texture size 2048 * 2048 std::set<LLSnapshotLivePreview*> LLSnapshotLivePreview::sList; -LLPointer<LLImageFormatted> LLSnapshotLivePreview::sSaveLocalImage = NULL; +LLPointer<LLImageFormatted> LLSnapshotLivePreview::sSaveLocalImage = nullptr; LLSnapshotLivePreview::LLSnapshotLivePreview (const LLSnapshotLivePreview::Params& p) : LLView(p), @@ -906,7 +906,7 @@ void LLSnapshotLivePreview::estimateDataSize() break; case LLSnapshotModel::SNAPSHOT_FORMAT_JPEG: // Observed from JPG compression tests - ratio = (110 - mSnapshotQuality) / 2; + ratio = (F32)(110 - mSnapshotQuality) / 2.f; break; case LLSnapshotModel::SNAPSHOT_FORMAT_BMP: ratio = 1.0; // No compression with BMP @@ -1024,7 +1024,7 @@ void LLSnapshotLivePreview::saveTexture(bool outfit_snapshot, std::string name) LLAgentUI::buildLocationString(pos_string, LLAgentUI::LOCATION_FORMAT_FULL); std::string who_took_it; LLAgentUI::buildFullname(who_took_it); - S32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(); + S32 expected_upload_cost = LLAgentBenefitsMgr::current().getTextureUploadCost(scaled->getWidth(), scaled->getHeight()); std::string res_name = outfit_snapshot ? name : "Snapshot : " + pos_string; std::string res_desc = outfit_snapshot ? "" : "Taken by " + who_took_it + " at " + pos_string; LLFolderType::EType folder_type = outfit_snapshot ? LLFolderType::FT_NONE : LLFolderType::FT_SNAPSHOT_CATEGORY; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 782d57aed8..ffe5fa394f 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -409,7 +409,7 @@ LLSpatialGroup* LLSpatialGroup::getParent() bool LLSpatialGroup::removeObject(LLDrawable *drawablep, bool from_octree) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL + LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL; if(!drawablep) { @@ -498,7 +498,7 @@ public: void LLSpatialGroup::setState(U32 state, S32 mode) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL + LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL; llassert(state <= LLSpatialGroup::STATE_MASK); @@ -547,7 +547,7 @@ public: void LLSpatialGroup::clearState(U32 state, S32 mode) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL + LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL; llassert(state <= LLSpatialGroup::STATE_MASK); @@ -634,7 +634,7 @@ void LLSpatialGroup::updateDistance(LLCamera &camera) F32 LLSpatialPartition::calcDistance(LLSpatialGroup* group, LLCamera& camera) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL + LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL; LLVector4a eye; LLVector4a origin; @@ -729,7 +729,7 @@ F32 LLSpatialGroup::getUpdateUrgency() const bool LLSpatialGroup::changeLOD() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL + LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL; if (hasState(ALPHA_DIRTY | OBJECT_DIRTY)) { @@ -818,7 +818,7 @@ void LLSpatialGroup::handleDestruction(const TreeNode* node) void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL + LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL; if (child->getListenerCount() == 0) { @@ -2035,7 +2035,7 @@ void renderNormals(LLDrawable *drawablep) obj_scale.normalize3(); // Create inverse-scale vector for normals - inv_scale.set(1.0 / scale_v3.mV[VX], 1.0 / scale_v3.mV[VY], 1.0 / scale_v3.mV[VZ], 0.0); + inv_scale.set(1.0f / scale_v3.mV[VX], 1.0f / scale_v3.mV[VY], 1.0f/ scale_v3.mV[VZ], 0.0f); inv_scale.mul(inv_scale); // Squared, to apply inverse scale twice inv_scale.normalize3fast(); @@ -2763,7 +2763,7 @@ void renderTexelDensity(LLDrawable* drawable) break; } - checkerboard_matrix.initScale(LLVector3(texturep->getWidth(discard_level) / 8, texturep->getHeight(discard_level) / 8, 1.f)); + checkerboard_matrix.initScale(LLVector3((F32)texturep->getWidth(discard_level) / 8.f, (F32)texturep->getHeight(discard_level) / 8.f, 1.f)); gGL.getTexUnit(0)->bind(LLViewerTexture::sCheckerBoardImagep, true); gGL.matrixMode(LLRender::MM_TEXTURE); @@ -3978,12 +3978,14 @@ void LLCullResult::clear() for (U32 i = 0; i < LLRenderPass::NUM_RENDER_TYPES; i++) { - for (U32 j = 0; j < mRenderMapSize[i]; j++) + drawinfo_list_t& render_map = mRenderMap[i]; + U32 render_map_size = llmin((U32)render_map.size(), mRenderMapSize[i]); + for (U32 j = 0; j < render_map_size; j++) { - mRenderMap[i][j] = 0; + render_map[j] = 0; } mRenderMapSize[i] = 0; - mRenderMapEnd[i] = &(mRenderMap[i][0]); + mRenderMapEnd[i] = &render_map.front(); } } diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index dd005874a5..b993ba16d5 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -957,7 +957,7 @@ bool idle_startup() // and startup time is close enough if we don't have a real value. if (gSavedPerAccountSettings.getU32("LastLogoff") == 0) { - gSavedPerAccountSettings.setU32("LastLogoff", time_corrected()); + gSavedPerAccountSettings.setU32("LastLogoff", (U32)time_corrected()); } //Default the path if one isn't set. @@ -1508,7 +1508,11 @@ bool idle_startup() // create a container's instance for start a controlling conversation windows // by the voice's events - LLFloaterIMContainer::getInstance(); + LLFloaterIMContainer *im_inst = LLFloaterIMContainer::getInstance(); + if(gAgent.isFirstLogin()) + { + im_inst->openFloater(im_inst->getKey()); + } if (gSavedSettings.getS32("ParcelMediaAutoPlayEnable") == 2) { LLViewerParcelAskPlay::getInstance()->loadSettings(); @@ -3665,7 +3669,7 @@ bool process_login_success_response() if(server_utc_time) { time_t now = time(NULL); - gUTCOffset = (server_utc_time - now); + gUTCOffset = (S32)(server_utc_time - now); // Print server timestamp LLSD substitution; diff --git a/indra/newview/llsurface.cpp b/indra/newview/llsurface.cpp index e6bced5c92..1826885069 100644 --- a/indra/newview/llsurface.cpp +++ b/indra/newview/llsurface.cpp @@ -54,6 +54,7 @@ #include "llglheaders.h" #include "lldrawpoolterrain.h" #include "lldrawable.h" +#include "llworldmipmap.h" extern LLPipeline gPipeline; extern bool gShiftFrame; @@ -74,7 +75,6 @@ LLSurface::LLSurface(U32 type, LLViewerRegion *regionp) : mDetailTextureScale(0.f), mOriginGlobal(0.0, 0.0, 0.0), mSTexturep(NULL), - mWaterTexturep(NULL), mGridsPerPatchEdge(0), mMetersPerGrid(1.0f), mMetersPerEdge(1.0f), @@ -129,14 +129,7 @@ LLSurface::~LLSurface() { gPipeline.removePool(poolp); // Don't enable this until we blitz the draw pool for it as well. -- djs - if (mSTexturep) - { - mSTexturep = NULL; - } - if (mWaterTexturep) - { - mWaterTexturep = NULL; - } + mSTexturep = NULL; } else { @@ -216,62 +209,17 @@ LLViewerTexture* LLSurface::getSTexture() return mSTexturep; } -LLViewerTexture* LLSurface::getWaterTexture() -{ - if (mWaterTexturep.notNull() && !mWaterTexturep->hasGLTexture()) - { - createWaterTexture(); - } - return mWaterTexturep; -} - void LLSurface::createSTexture() { if (!mSTexturep) { - // Fill with dummy gray data. - // GL NOT ACTIVE HERE - LLPointer<LLImageRaw> raw = new LLImageRaw(sTextureSize, sTextureSize, 3); - U8 *default_texture = raw->getData(); - for (S32 i = 0; i < sTextureSize; i++) - { - for (S32 j = 0; j < sTextureSize; j++) - { - *(default_texture + (i*sTextureSize + j)*3) = 128; - *(default_texture + (i*sTextureSize + j)*3 + 1) = 128; - *(default_texture + (i*sTextureSize + j)*3 + 2) = 128; - } - } + U64 handle = mRegionp->getHandle(); - mSTexturep = LLViewerTextureManager::getLocalTexture(raw.get(), false); - mSTexturep->dontDiscard(); - gGL.getTexUnit(0)->bind(mSTexturep); - mSTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - } -} + U32 grid_x, grid_y; -void LLSurface::createWaterTexture() -{ - if (!mWaterTexturep) - { - // Create the water texture - LLPointer<LLImageRaw> raw = new LLImageRaw(sTextureSize/2, sTextureSize/2, 4); - U8 *default_texture = raw->getData(); - for (S32 i = 0; i < sTextureSize/2; i++) - { - for (S32 j = 0; j < sTextureSize/2; j++) - { - *(default_texture + (i*sTextureSize/2 + j)*4) = MAX_WATER_COLOR.mV[0]; - *(default_texture + (i*sTextureSize/2 + j)*4 + 1) = MAX_WATER_COLOR.mV[1]; - *(default_texture + (i*sTextureSize/2 + j)*4 + 2) = MAX_WATER_COLOR.mV[2]; - *(default_texture + (i*sTextureSize/2 + j)*4 + 3) = MAX_WATER_COLOR.mV[3]; - } - } + grid_from_region_handle(handle, &grid_x, &grid_y); - mWaterTexturep = LLViewerTextureManager::getLocalTexture(raw.get(), false); - mWaterTexturep->dontDiscard(); - gGL.getTexUnit(0)->bind(mWaterTexturep); - mWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); + mSTexturep = LLWorldMipmap::loadObjectsTile(grid_x, grid_y, 1); } } @@ -285,11 +233,10 @@ void LLSurface::initTextures() /////////////////////// // - // Water texture + // Water object // if (gSavedSettings.getBOOL("RenderWater") ) { - createWaterTexture(); mWaterObjp = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_WATER, mRegionp); gPipeline.createObject(mWaterObjp); LLVector3d water_pos_global = from_region_handle(mRegionp->getHandle()); @@ -683,11 +630,8 @@ bool LLSurface::idleUpdate(F32 max_update_time) } } - if (did_update) - { - // some patches changed, update region reflection probes - mRegionp->updateReflectionProbes(); - } + // some patches changed, update region reflection probes + mRegionp->updateReflectionProbes(did_update); return did_update; } @@ -1221,98 +1165,3 @@ F32 LLSurface::getWaterHeight() const } } - -bool LLSurface::generateWaterTexture(const F32 x, const F32 y, - const F32 width, const F32 height) -{ - LL_PROFILE_ZONE_SCOPED - if (!getWaterTexture()) - { - return false; - } - - S32 tex_width = mWaterTexturep->getWidth(); - S32 tex_height = mWaterTexturep->getHeight(); - S32 tex_comps = mWaterTexturep->getComponents(); - S32 tex_stride = tex_width * tex_comps; - LLPointer<LLImageRaw> raw = new LLImageRaw(tex_width, tex_height, tex_comps); - U8 *rawp = raw->getData(); - - F32 scale = 256.f * getMetersPerGrid() / (F32)tex_width; - F32 scale_inv = 1.f / scale; - - S32 x_begin, y_begin, x_end, y_end; - - x_begin = ll_round(x * scale_inv); - y_begin = ll_round(y * scale_inv); - x_end = ll_round((x + width) * scale_inv); - y_end = ll_round((y + width) * scale_inv); - - if (x_end > tex_width) - { - x_end = tex_width; - } - if (y_end > tex_width) - { - y_end = tex_width; - } - - // OK, for now, just have the composition value equal the height at the point. - LLVector3 location; - LLColor4U coloru; - - const F32 WATER_HEIGHT = getWaterHeight(); - - S32 i, j, offset; - for (j = y_begin; j < y_end; j++) - { - for (i = x_begin; i < x_end; i++) - { - //F32 nv[2]; - //nv[0] = i/256.f; - //nv[1] = j/256.f; - // const S32 modulation = noise2(nv)*40; - offset = j*tex_stride + i*tex_comps; - location.mV[VX] = i*scale; - location.mV[VY] = j*scale; - - // Sample multiple points - const F32 height = resolveHeightRegion(location); - - if (height > WATER_HEIGHT) - { - // Above water... - coloru = MAX_WATER_COLOR; - coloru.mV[3] = ABOVE_WATERLINE_ALPHA; - *(rawp + offset++) = coloru.mV[0]; - *(rawp + offset++) = coloru.mV[1]; - *(rawp + offset++) = coloru.mV[2]; - *(rawp + offset++) = coloru.mV[3]; - } - else - { - // Want non-linear curve for transparency gradient - coloru = MAX_WATER_COLOR; - const F32 frac = 1.f - 2.f/(2.f - (height - WATER_HEIGHT)); - S32 alpha = 64 + ll_round((255-64)*frac); - - alpha = llmin(ll_round((F32)MAX_WATER_COLOR.mV[3]), alpha); - alpha = llmax(64, alpha); - - coloru.mV[3] = alpha; - *(rawp + offset++) = coloru.mV[0]; - *(rawp + offset++) = coloru.mV[1]; - *(rawp + offset++) = coloru.mV[2]; - *(rawp + offset++) = coloru.mV[3]; - } - } - } - - if (!mWaterTexturep->hasGLTexture()) - { - mWaterTexturep->createGLTexture(0, raw); - } - - mWaterTexturep->setSubImage(raw, x_begin, y_begin, x_end - x_begin, y_end - y_begin); - return true; -} diff --git a/indra/newview/llsurface.h b/indra/newview/llsurface.h index 324296a4d3..68295225b6 100644 --- a/indra/newview/llsurface.h +++ b/indra/newview/llsurface.h @@ -128,7 +128,7 @@ public: F32 getWaterHeight() const; LLViewerTexture *getSTexture(); - LLViewerTexture *getWaterTexture(); + bool hasZData() const { return mHasZData; } void dirtyAllPatches(); // Use this to dirty all patches when changing terrain parameters @@ -171,19 +171,11 @@ public: protected: void createSTexture(); - void createWaterTexture(); void initTextures(); - void initWater(); - void createPatchData(); // Allocates memory for patches. void destroyPatchData(); // Deallocates memory for patches. - bool generateWaterTexture(const F32 x, const F32 y, - const F32 width, const F32 height); // Generate texture from composition values. - - //F32 updateTexture(LLSurfacePatch *ppatch); - LLSurfacePatch *getPatch(const S32 x, const S32 y) const; protected: @@ -201,7 +193,6 @@ protected: // The textures should never be directly initialized - use the setter methods! LLPointer<LLViewerTexture> mSTexturep; // Texture for surface - LLPointer<LLViewerTexture> mWaterTexturep; // Water texture LLPointer<LLVOWater> mWaterObjp; diff --git a/indra/newview/llsurfacepatch.cpp b/indra/newview/llsurfacepatch.cpp index 042d770550..0550889a9b 100644 --- a/indra/newview/llsurfacepatch.cpp +++ b/indra/newview/llsurfacepatch.cpp @@ -895,7 +895,7 @@ bool LLSurfacePatch::updateTexture() void LLSurfacePatch::updateGL() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; F32 meters_per_grid = getSurface()->getMetersPerGrid(); F32 grids_per_patch_edge = (F32)getSurface()->getGridsPerPatchEdge(); @@ -906,15 +906,8 @@ void LLSurfacePatch::updateGL() updateCompositionStats(); F32 tex_patch_size = meters_per_grid*grids_per_patch_edge; - if (comp->generateMinimapTileLand((F32)origin_region[VX], (F32)origin_region[VY], - tex_patch_size, tex_patch_size)) - { - mSTexUpdate = false; - // Also generate the water texture - mSurfacep->generateWaterTexture((F32)origin_region.mdV[VX], (F32)origin_region.mdV[VY], - tex_patch_size, tex_patch_size); - } + mSTexUpdate = false; } void LLSurfacePatch::dirtyZ() diff --git a/indra/newview/llteleporthistorystorage.cpp b/indra/newview/llteleporthistorystorage.cpp index fa4e92e209..dd7c6aa9e3 100644 --- a/indra/newview/llteleporthistorystorage.cpp +++ b/indra/newview/llteleporthistorystorage.cpp @@ -127,7 +127,7 @@ void LLTeleportHistoryStorage::addItem(const std::string title, const LLVector3d S32 removed_index = -1; if (item_iter != mItems.end()) { - removed_index = item_iter - mItems.begin(); + removed_index = (S32)(item_iter - mItems.begin()); mItems.erase(item_iter); } diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index 843da97089..be7653c011 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -1260,7 +1260,7 @@ void LLTextureCache::updateEntryTimeStamp(S32 idx, Entry& entry) { if (!mReadOnly) { - entry.mTime = time(NULL); + entry.mTime = (U32)time(NULL); mUpdatedEntryMap[idx] = entry ; } } @@ -1299,7 +1299,7 @@ bool LLTextureCache::updateEntry(S32& idx, Entry& entry, S32 new_image_size, S32 mTexturesSizeTotal -= entry.mBodySize ; mTexturesSizeTotal += new_body_size ; } - entry.mTime = time(NULL); + entry.mTime = (U32)time(NULL); entry.mImageSize = new_image_size ; entry.mBodySize = new_body_size ; diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 81a70a81cf..e154777aef 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -2308,8 +2308,8 @@ void LLTextureCtrl::draw() font->renderUTF8( mLoadingPlaceholderString, 0, - llfloor(interior.mLeft+3), - llfloor(interior.mTop-v_offset), + (interior.mLeft+3), + (interior.mTop-v_offset), LLColor4::white, LLFontGL::LEFT, LLFontGL::BASELINE, @@ -2325,17 +2325,17 @@ void LLTextureCtrl::draw() v_offset += 12; tdesc = llformat(" PK : %d%%", U32(mTexturep->getDownloadProgress()*100.0)); - font->renderUTF8(tdesc, 0, llfloor(interior.mLeft+3), llfloor(interior.mTop-v_offset), + font->renderUTF8(tdesc, 0, interior.mLeft+3, interior.mTop-v_offset, LLColor4::white, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::DROP_SHADOW); v_offset += 12; tdesc = llformat(" LVL: %d", mTexturep->getDiscardLevel()); - font->renderUTF8(tdesc, 0, llfloor(interior.mLeft+3), llfloor(interior.mTop-v_offset), + font->renderUTF8(tdesc, 0, interior.mLeft+3, interior.mTop-v_offset, LLColor4::white, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::DROP_SHADOW); v_offset += 12; tdesc = llformat(" ID : %s...", (mImageAssetID.asString().substr(0,7)).c_str()); - font->renderUTF8(tdesc, 0, llfloor(interior.mLeft+3), llfloor(interior.mTop-v_offset), + font->renderUTF8(tdesc, 0, interior.mLeft+3, interior.mTop-v_offset, LLColor4::white, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::DROP_SHADOW); } } diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index ee13baaa18..689c555998 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -3210,7 +3210,7 @@ S32 LLTextureFetch::getFetchState(const LLUUID& id, F32& data_progress_p, F32& r { requested_priority = worker->mImagePriority; } - fetch_priority = worker->getImagePriority(); + fetch_priority = (U32)worker->getImagePriority(); can_use_http = worker->getCanUseHTTP() ; worker->unlockWorkMutex(); // -Mw } diff --git a/indra/newview/lltextureinfo.cpp b/indra/newview/lltextureinfo.cpp index 84ef45c97a..514064cf49 100644 --- a/indra/newview/lltextureinfo.cpp +++ b/indra/newview/lltextureinfo.cpp @@ -214,7 +214,7 @@ void LLTextureInfo::setRequestCompleteTimeAndLog(const LLUUID& id, U64Microsecon F64 region_vocache_hit_rate = 0; if (region_hit_count > 0 || region_miss_count > 0) { - region_vocache_hit_rate = region_hit_count / (region_hit_count + region_miss_count); + region_vocache_hit_rate = (F64)region_hit_count / (region_hit_count + region_miss_count); } object_cache["vo_region_hitcount"] = ll_sd_from_U64(region_hit_count); object_cache["vo_region_misscount"] = ll_sd_from_U64(region_miss_count); diff --git a/indra/newview/lltextureview.cpp b/indra/newview/lltextureview.cpp index f521293b96..92527fc3a9 100644 --- a/indra/newview/lltextureview.cpp +++ b/indra/newview/lltextureview.cpp @@ -59,8 +59,6 @@ #include "llvoavatarself.h" #include "lltexlayer.h" -extern F32 texmem_lower_bound_scale; - LLTextureView *gTextureView = NULL; #define HIGH_PRIORITY 100000000.f @@ -463,7 +461,7 @@ public: : texture_view("texture_view") { S32 line_height = LLFontGL::getFontMonospace()->getLineHeight(); - changeDefault(rect, LLRect(0,0,100,line_height * 4)); + changeDefault(rect, LLRect(0,0,0,line_height * 7)); } }; @@ -483,8 +481,8 @@ private: void LLGLTexMemBar::draw() { F32 discard_bias = LLViewerTexture::sDesiredDiscardBias; - F32 cache_usage = LLAppViewer::getTextureCache()->getUsage().valueInUnits<LLUnits::Megabytes>(); - F32 cache_max_usage = LLAppViewer::getTextureCache()->getMaxUsage().valueInUnits<LLUnits::Megabytes>(); + F32 cache_usage = (F32)LLAppViewer::getTextureCache()->getUsage().valueInUnits<LLUnits::Megabytes>(); + F32 cache_max_usage = (F32)LLAppViewer::getTextureCache()->getMaxUsage().valueInUnits<LLUnits::Megabytes>(); S32 line_height = LLFontGL::getFontMonospace()->getLineHeight(); S32 v_offset = 0;//(S32)((texture_bar_height + 2.2f) * mTextureView->mNumTextureBars + 2.0f); F32Bytes total_texture_downloaded = gTotalTextureData; @@ -494,19 +492,54 @@ void LLGLTexMemBar::draw() U32 total_objects = gObjectList.getNumObjects(); F32 x_right = 0.0; + U32 image_count = gTextureList.getNumImages(); + U32 raw_image_count = 0; + U64 raw_image_bytes = 0; + + U32 saved_raw_image_count = 0; + U64 saved_raw_image_bytes = 0; + + U32 aux_raw_image_count = 0; + U64 aux_raw_image_bytes = 0; + + for (auto& image : gTextureList) + { + const LLImageRaw* raw_image = image->getRawImage(); + + if (raw_image) + { + raw_image_count++; + raw_image_bytes += raw_image->getDataSize(); + } + + raw_image = image->getSavedRawImage(); + if (raw_image) + { + saved_raw_image_count++; + saved_raw_image_bytes += raw_image->getDataSize(); + } + + raw_image = image->getAuxRawImage(); + if (raw_image) + { + aux_raw_image_count++; + aux_raw_image_bytes += raw_image->getDataSize(); + } + } + + F64 raw_image_bytes_MB = raw_image_bytes / (1024.0 * 1024.0); + F64 saved_raw_image_bytes_MB = saved_raw_image_bytes / (1024.0 * 1024.0); + F64 aux_raw_image_bytes_MB = aux_raw_image_bytes / (1024.0 * 1024.0); + F64 texture_bytes_alloc = LLImageGL::getTextureBytesAllocated() / 1024.0 / 1024.0 * 1.3333f; // add 33% for mipmaps + F64 vertex_bytes_alloc = LLVertexBuffer::getBytesAllocated() / 1024.0 / 1024.0; + F64 render_bytes_alloc = LLRenderTarget::sBytesAllocated / 1024.0 / 1024.0; + //---------------------------------------------------------------------------- LLGLSUIDefault gls_ui; LLColor4 text_color(1.f, 1.f, 1.f, 0.75f); LLColor4 color; - // Gray background using completely magic numbers - gGL.color4f(0.f, 0.f, 0.f, 0.25f); - // const LLRect & rect(getRect()); - // gl_rect_2d(-4, v_offset, rect.mRight - rect.mLeft + 2, v_offset + line_height*4); - std::string text = ""; - LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*6, - text_color, LLFontGL::LEFT, LLFontGL::TOP); LLTrace::Recording& recording = LLViewerStats::instance().getRecording(); @@ -527,6 +560,10 @@ void LLGLTexMemBar::draw() U32 texFetchLatMed = U32(recording.getMean(LLTextureFetch::sTexFetchLatency).value() * 1000.0f); U32 texFetchLatMax = U32(recording.getMax(LLTextureFetch::sTexFetchLatency).value() * 1000.0f); + // draw a background above first line.... no idea where the rest of the background comes from for the below text + gGL.color4f(0.f, 0.f, 0.f, 0.25f); + gl_rect_2d(-10, getRect().getHeight() + line_height*2 + 1, getRect().getWidth()+2, getRect().getHeight()+2); + text = llformat("Est. Free: %d MB Sys Free: %d MB FBO: %d MB Bias: %.2f Cache: %.1f/%.1f MB", (S32)LLViewerTexture::sFreeVRAMMegabytes, LLMemory::getAvailableMemKB()/1024, @@ -534,11 +571,23 @@ void LLGLTexMemBar::draw() discard_bias, cache_usage, cache_max_usage); - //, cache_entries, cache_max_entries - - LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*6, + LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*8, text_color, LLFontGL::LEFT, LLFontGL::TOP); + text = llformat("Images: %d Raw: %d (%.2f MB) Saved: %d (%.2f MB) Aux: %d (%.2f MB)", image_count, raw_image_count, raw_image_bytes_MB, + saved_raw_image_count, saved_raw_image_bytes_MB, + aux_raw_image_count, aux_raw_image_bytes_MB); + LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height * 7, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + + text = llformat("Textures: %.2f MB Vertex: %.2f MB Render: %.2f MB Total: %.2f MB", + texture_bytes_alloc, + vertex_bytes_alloc, + render_bytes_alloc, + texture_bytes_alloc+vertex_bytes_alloc+render_bytes_alloc); + LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height * 6, + text_color, LLFontGL::LEFT, LLFontGL::TOP); + U32 cache_read(0U), cache_write(0U), res_wait(0U); LLAppViewer::getTextureFetch()->getStateStats(&cache_read, &cache_write, &res_wait); @@ -551,7 +600,6 @@ void LLGLTexMemBar::draw() cache_read, cache_write, res_wait); - LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*5, text_color, LLFontGL::LEFT, LLFontGL::TOP); @@ -583,8 +631,8 @@ void LLGLTexMemBar::draw() LLAppViewer::getImageDecodeThread()->getPending(), gTextureList.mCreateTextureList.size()); - x_right = 550.0; - LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0, v_offset + line_height*3, + x_right = 550.0f; + LLFontGL::getFontMonospace()->renderUTF8(text, 0, 0.f, (F32)(v_offset + line_height*3), text_color, LLFontGL::LEFT, LLFontGL::TOP, LLFontGL::NORMAL, LLFontGL::NO_SHADOW, S32_MAX, S32_MAX, &x_right); @@ -593,7 +641,7 @@ void LLGLTexMemBar::draw() color = bandwidth > max_bandwidth ? LLColor4::red : bandwidth > max_bandwidth*.75f ? LLColor4::yellow : text_color; color[VALPHA] = text_color[VALPHA]; text = llformat("BW:%.0f/%.0f",bandwidth.value(), max_bandwidth.value()); - LLFontGL::getFontMonospace()->renderUTF8(text, 0, x_right, v_offset + line_height*3, + LLFontGL::getFontMonospace()->renderUTF8(text, 0, (S32)x_right, v_offset + line_height*3, color, LLFontGL::LEFT, LLFontGL::TOP); // Mesh status line @@ -791,7 +839,7 @@ void LLTextureView::draw() LL_INFOS() << "ID\tMEM\tBOOST\tPRI\tWIDTH\tHEIGHT\tDISCARD" << LL_ENDL; } - for (LLViewerTextureList::image_priority_list_t::iterator iter = gTextureList.mImageList.begin(); + for (LLViewerTextureList::image_list_t::iterator iter = gTextureList.mImageList.begin(); iter != gTextureList.mImageList.end(); ) { LLPointer<LLViewerFetchedTexture> imagep = *iter++; diff --git a/indra/newview/llthumbnailctrl.cpp b/indra/newview/llthumbnailctrl.cpp index d26ad2f060..ae21d3e733 100644 --- a/indra/newview/llthumbnailctrl.cpp +++ b/indra/newview/llthumbnailctrl.cpp @@ -164,8 +164,8 @@ void LLThumbnailCtrl::draw() font->renderUTF8( mLoadingPlaceholderString, 0, - llfloor(draw_rect.mLeft+3), - llfloor(draw_rect.mTop-v_offset), + (draw_rect.mLeft+3), + (draw_rect.mTop-v_offset), LLColor4::white, LLFontGL::LEFT, LLFontGL::BASELINE, diff --git a/indra/newview/lltinygltfhelper.cpp b/indra/newview/lltinygltfhelper.cpp index 168708ca37..b8cb3d712d 100644 --- a/indra/newview/lltinygltfhelper.cpp +++ b/indra/newview/lltinygltfhelper.cpp @@ -140,7 +140,7 @@ LLColor4 LLTinyGLTFHelper::getColor(const std::vector<double>& in) LLColor4 out; for (S32 i = 0; i < llmin((S32)in.size(), 4); ++i) { - out.mV[i] = in[i]; + out.mV[i] = (F32)in[i]; } return out; diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp index 638a01a080..84503e66a5 100644 --- a/indra/newview/lltoast.cpp +++ b/indra/newview/lltoast.cpp @@ -94,8 +94,8 @@ LLToast::Params::Params() enable_hide_btn("enable_hide_btn", true), force_show("force_show", false), force_store("force_store", false), - fading_time_secs("fading_time_secs", gSavedSettings.getS32("ToastFadingTime")), - lifetime_secs("lifetime_secs", gSavedSettings.getS32("NotificationToastLifeTime")) + fading_time_secs("fading_time_secs", (F32)gSavedSettings.getS32("ToastFadingTime")), + lifetime_secs("lifetime_secs", (F32)gSavedSettings.getS32("NotificationToastLifeTime")) {}; LLToast::LLToast(const LLToast::Params& p) @@ -256,12 +256,12 @@ void LLToast::onFocusReceived() void LLToast::setLifetime(S32 seconds) { - mToastLifetime = seconds; + mToastLifetime = (F32)seconds; } void LLToast::setFadingTime(S32 seconds) { - mToastFadingTime = seconds; + mToastFadingTime = (F32)seconds; } void LLToast::closeToast() diff --git a/indra/newview/lltoastpanel.cpp b/indra/newview/lltoastpanel.cpp index 0ac2653021..6f8691bb26 100644 --- a/indra/newview/lltoastpanel.cpp +++ b/indra/newview/lltoastpanel.cpp @@ -114,7 +114,7 @@ void LLToastPanel::snapToMessageHeight(LLTextBase* message, S32 maxLineCount) LLToastPanel* LLToastPanel::buidPanelFromNotification( const LLNotificationPtr& notification) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; LLToastPanel* res = NULL; //process tip toast panels diff --git a/indra/newview/lltoolbrush.cpp b/indra/newview/lltoolbrush.cpp index e2b6924aeb..2fe81df4fb 100644 --- a/indra/newview/lltoolbrush.cpp +++ b/indra/newview/lltoolbrush.cpp @@ -547,7 +547,7 @@ void LLToolBrushLand::renderOverlay(LLSurface& land, const LLVector3& pos_region wz = land.getZ((i+di)+(j+dj)*land.mGridsPerEdge), norm_dist = sqrt((float)di*di + dj*dj) / half_edge, force_scale = sqrt(2.f) - norm_dist, // 1 at center, 0 at corner - wz2 = wz + .2 + (.2 + force/100) * force_scale, // top vertex + wz2 = wz + .2f + (.2f + force/100.f) * force_scale, // top vertex tic = .075f; // arrowhead size // vertical line gGL.vertex3f(wx, wy, wz); diff --git a/indra/newview/lltoolfocus.cpp b/indra/newview/lltoolfocus.cpp index 0ba7ae5e84..b8878b1e6f 100644 --- a/indra/newview/lltoolfocus.cpp +++ b/indra/newview/lltoolfocus.cpp @@ -440,7 +440,7 @@ bool LLToolCamera::handleHover(S32 x, S32 y, MASK mask) } else { - gAgentCamera.cameraZoomIn( pow( IN_FACTOR, dy ) ); + gAgentCamera.cameraZoomIn((F32)pow( IN_FACTOR, dy ) ); } } diff --git a/indra/newview/lltoolmorph.cpp b/indra/newview/lltoolmorph.cpp index b3871a6d6c..24cfca5eee 100644 --- a/indra/newview/lltoolmorph.cpp +++ b/indra/newview/lltoolmorph.cpp @@ -189,7 +189,7 @@ bool LLVisualParamHint::render() gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); gGL.loadIdentity(); - gGL.ortho(0.0f, mFullWidth, 0.0f, mFullHeight, -1.0f, 1.0f); + gGL.ortho(0.0f, (F32)mFullWidth, 0.0f, (F32)mFullHeight, -1.0f, 1.0f); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); diff --git a/indra/newview/lltracker.cpp b/indra/newview/lltracker.cpp index a28bbb3bf1..d4d3e71b46 100644 --- a/indra/newview/lltracker.cpp +++ b/indra/newview/lltracker.cpp @@ -516,7 +516,7 @@ void LLTracker::drawBeacon(LLVector3 pos_agent, std::string direction, LLColor4 height = pos_agent.mV[2]; } - nRows = ceil((BEACON_ROWS * height) / MAX_HEIGHT); + nRows = (U32)ceil((BEACON_ROWS * height) / MAX_HEIGHT); if(nRows<2) nRows=2; rowHeight = height / nRows; diff --git a/indra/newview/llurldispatcher.cpp b/indra/newview/llurldispatcher.cpp index fbcaaef1b8..39a9f0f8bc 100644 --- a/indra/newview/llurldispatcher.cpp +++ b/indra/newview/llurldispatcher.cpp @@ -306,9 +306,9 @@ public: LLVector3 coords(128, 128, 0); if (tokens.size() <= 4) { - coords = LLVector3(tokens[1].asReal(), - tokens[2].asReal(), - tokens[3].asReal()); + coords = LLVector3((F32)tokens[1].asReal(), + (F32)tokens[2].asReal(), + (F32)tokens[3].asReal()); } // Region names may be %20 escaped. @@ -332,9 +332,9 @@ public: { // region specified, coordinates (if any) are region-local LLVector3 local_pos( - params.has("x")? params["x"].asReal() : 128, - params.has("y")? params["y"].asReal() : 128, - params.has("z")? params["z"].asReal() : 0); + params.has("x")? (F32)params["x"].asReal() : 128.f, + params.has("y")? (F32)params["y"].asReal() : 128.f, + params.has("z")? (F32)params["z"].asReal() : 0.f); std::string regionname(params["regionname"]); std::string destination(LLSLURL(regionname, local_pos).getSLURLString()); // have to resolve region's global coordinates first diff --git a/indra/newview/llversioninfo.cpp b/indra/newview/llversioninfo.cpp index a571b5544b..4e8320b72a 100644 --- a/indra/newview/llversioninfo.cpp +++ b/indra/newview/llversioninfo.cpp @@ -76,37 +76,37 @@ LLVersionInfo::~LLVersionInfo() { } -S32 LLVersionInfo::getMajor() +S32 LLVersionInfo::getMajor() const { return LL_VIEWER_VERSION_MAJOR; } -S32 LLVersionInfo::getMinor() +S32 LLVersionInfo::getMinor() const { return LL_VIEWER_VERSION_MINOR; } -S32 LLVersionInfo::getPatch() +S32 LLVersionInfo::getPatch() const { return LL_VIEWER_VERSION_PATCH; } -U64 LLVersionInfo::getBuild() +U64 LLVersionInfo::getBuild() const { return LL_VIEWER_VERSION_BUILD; } -std::string LLVersionInfo::getVersion() +std::string LLVersionInfo::getVersion() const { return version; } -std::string LLVersionInfo::getShortVersion() +std::string LLVersionInfo::getShortVersion() const { return short_version; } -std::string LLVersionInfo::getChannelAndVersion() +std::string LLVersionInfo::getChannelAndVersion() const { if (mVersionChannel.empty()) { @@ -117,7 +117,7 @@ std::string LLVersionInfo::getChannelAndVersion() return mVersionChannel; } -std::string LLVersionInfo::getChannel() +std::string LLVersionInfo::getChannel() const { return mWorkingChannelName; } @@ -128,7 +128,7 @@ void LLVersionInfo::resetChannel(const std::string& channel) mVersionChannel.clear(); // Reset version and channel string til next use. } -LLVersionInfo::ViewerMaturity LLVersionInfo::getViewerMaturity() +LLVersionInfo::ViewerMaturity LLVersionInfo::getViewerMaturity() const { ViewerMaturity maturity; @@ -166,12 +166,12 @@ LLVersionInfo::ViewerMaturity LLVersionInfo::getViewerMaturity() } -std::string LLVersionInfo::getBuildConfig() +std::string LLVersionInfo::getBuildConfig() const { return build_configuration; } -std::string LLVersionInfo::getReleaseNotes() +std::string LLVersionInfo::getReleaseNotes() const { return mReleaseNotes; } diff --git a/indra/newview/llversioninfo.h b/indra/newview/llversioninfo.h index aed43263a6..237b37a084 100644 --- a/indra/newview/llversioninfo.h +++ b/indra/newview/llversioninfo.h @@ -52,38 +52,38 @@ public: ~LLVersionInfo(); /// return the major version number as an integer - S32 getMajor(); + S32 getMajor() const; /// return the minor version number as an integer - S32 getMinor(); + S32 getMinor() const; /// return the patch version number as an integer - S32 getPatch(); + S32 getPatch() const; /// return the build number as an integer - U64 getBuild(); + U64 getBuild() const; /// return the full viewer version as a string like "2.0.0.200030" - std::string getVersion(); + std::string getVersion() const; /// return the viewer version as a string like "2.0.0" - std::string getShortVersion(); + std::string getShortVersion() const; /// return the viewer version and channel as a string /// like "Second Life Release 2.0.0.200030" - std::string getChannelAndVersion(); + std::string getChannelAndVersion() const; /// return the channel name, e.g. "Second Life" - std::string getChannel(); + std::string getChannel() const; /// return the CMake build type - std::string getBuildConfig(); + std::string getBuildConfig() const; /// reset the channel name used by the viewer. void resetChannel(const std::string& channel); /// return the bit width of an address - S32 getAddressSize() { return ADDRESS_SIZE; } + S32 getAddressSize() const { return ADDRESS_SIZE; } typedef enum { @@ -92,11 +92,11 @@ public: BETA_VIEWER, RELEASE_VIEWER } ViewerMaturity; - ViewerMaturity getViewerMaturity(); + ViewerMaturity getViewerMaturity() const; /// get the release-notes URL, once it becomes available -- until then, /// return empty string - std::string getReleaseNotes(); + std::string getReleaseNotes() const; private: std::string version; @@ -107,7 +107,7 @@ private: std::string mWorkingChannelName; // Storage for the "version and channel" string. // This will get reset too. - std::string mVersionChannel; + mutable std::string mVersionChannel; std::string build_configuration; std::string mReleaseNotes; // Store unique_ptrs to the next couple things so we don't have to explain diff --git a/indra/newview/llviewerassetstorage.cpp b/indra/newview/llviewerassetstorage.cpp index 26707f5d9a..5ab9f76e47 100644 --- a/indra/newview/llviewerassetstorage.cpp +++ b/indra/newview/llviewerassetstorage.cpp @@ -376,6 +376,7 @@ void LLViewerAssetStorage::queueRequestHttp( bool duplicate, bool is_priority) { + LL_PROFILE_ZONE_SCOPED; LL_DEBUGS("ViewerAsset") << "Request asset via HTTP " << uuid << " type " << LLAssetType::lookup(atype) << LL_ENDL; bool with_http = true; diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index 337c18f218..50128d826a 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -226,7 +226,7 @@ LLUUID LLResourceUploadInfo::finishUpload(LLSD &result) LL_INFOS() << "inventory_item_flags " << flagsInventoryItem << LL_ENDL; } } - S32 creationDate = time_corrected(); + S32 creationDate = (S32)time_corrected(); LLUUID serverInventoryItem = result["new_inventory_item"].asUUID(); LLUUID serverAssetId = result["new_asset"].asUUID(); @@ -370,7 +370,8 @@ LLNewFileResourceUploadInfo::LLNewFileResourceUploadInfo( LLResourceUploadInfo(name, description, compressionInfo, destinationType, inventoryType, nextOWnerPerms, groupPerms, everyonePerms, expectedCost, show_inventory), - mFileName(fileName) + mFileName(fileName), + mMaxImageSize(LLViewerFetchedTexture::MAX_IMAGE_SIZE_DEFAULT) { } @@ -422,7 +423,7 @@ LLSD LLNewFileResourceUploadInfo::exportTempFile() else if (assetType == LLAssetType::AT_TEXTURE) { // It's an image file, the upload procedure is the same for all - if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec)) + if (!LLViewerTextureList::createUploadFile(getFileName(), filename, codec, mMaxImageSize)) { errorMessage = llformat("Problem with file %s:\n\n%s\n", getFileName().c_str(), LLImage::getLastThreadError().c_str()); diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index 5a07fbf802..365436ede0 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -161,13 +161,15 @@ public: std::string getFileName() const { return mFileName; }; + void setMaxImageSize(U32 maxUploadSize) { mMaxImageSize = maxUploadSize; } + protected: virtual LLSD exportTempFile(); private: std::string mFileName; - + S32 mMaxImageSize; }; //------------------------------------------------------------------------- diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index ab7953846f..766280e145 100644 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -153,12 +153,12 @@ void LLViewerCamera::updateCameraLocation(const LLVector3 ¢er, const LLVecto add(sVelocityStat, dpos); add(sAngularVelocityStat, drot); - mAverageSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sVelocityStat, 50); - mAverageAngularSpeed = LLTrace::get_frame_recording().getPeriodMeanPerSec(sAngularVelocityStat); + mAverageSpeed = (F32)LLTrace::get_frame_recording().getPeriodMeanPerSec(sVelocityStat, 50); + mAverageAngularSpeed = (F32)LLTrace::get_frame_recording().getPeriodMeanPerSec(sAngularVelocityStat); mCosHalfCameraFOV = cosf(0.5f * getView() * llmax(1.0f, getAspect())); // update pixel meter ratio using default fov, not modified one - mPixelMeterRatio = getViewHeightInPixels()/ (2.f*tanf(mCameraFOVDefault*0.5)); + mPixelMeterRatio = (F32)(getViewHeightInPixels()/ (2.f*tanf(mCameraFOVDefault*0.5f))); // update screen pixel area mScreenPixelArea =(S32)((F32)getViewHeightInPixels() * ((F32)getViewHeightInPixels() * getAspect())); } @@ -903,6 +903,6 @@ bool LLViewerCamera::isDefaultFOVChanged() void LLViewerCamera::updateCameraAngle(const LLSD& value) { - setDefaultFOV(value.asReal()); + setDefaultFOV((F32)value.asReal()); } diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index cd6e780aa8..0e1f4c09c7 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -263,12 +263,15 @@ static bool handleAnisotropicChanged(const LLSD& newvalue) static bool handleVSyncChanged(const LLSD& newvalue) { LLPerfStats::tunables.vsyncEnabled = newvalue.asBoolean(); - gViewerWindow->getWindow()->toggleVSync(newvalue.asBoolean()); - - if (newvalue.asBoolean()) + if (gViewerWindow && gViewerWindow->getWindow()) { - U32 current_target = gSavedSettings.getU32("TargetFPS"); - gSavedSettings.setU32("TargetFPS", std::min((U32)gViewerWindow->getWindow()->getRefreshRate(), current_target)); + gViewerWindow->getWindow()->toggleVSync(newvalue.asBoolean()); + + if (newvalue.asBoolean()) + { + U32 current_target = gSavedSettings.getU32("TargetFPS"); + gSavedSettings.setU32("TargetFPS", std::min((U32)gViewerWindow->getWindow()->getRefreshRate(), current_target)); + } } return true; @@ -634,7 +637,7 @@ void handleAutoTuneFPSChanged(const LLSD& newValue) LLPerfStats::tunables.userAutoTuneEnabled = newval; if(newval && LLPerfStats::renderAvatarMaxART_ns == 0) // If we've enabled autotune we override "unlimited" to max { - gSavedSettings.setF32("RenderAvatarMaxART",log10(LLPerfStats::ART_UNLIMITED_NANOS-1000));//triggers callback to update static var + gSavedSettings.setF32("RenderAvatarMaxART", (F32)log10(LLPerfStats::ART_UNLIMITED_NANOS-1000));//triggers callback to update static var } } @@ -797,6 +800,7 @@ void settings_setup_listeners() setting_setup_signal_listener(gSavedSettings, "RenderReflectionProbeDetail", handleReflectionProbeDetailChanged); setting_setup_signal_listener(gSavedSettings, "RenderReflectionsEnabled", handleReflectionProbeDetailChanged); setting_setup_signal_listener(gSavedSettings, "RenderScreenSpaceReflections", handleReflectionProbeDetailChanged); + setting_setup_signal_listener(gSavedSettings, "RenderMirrors", handleReflectionProbeDetailChanged); setting_setup_signal_listener(gSavedSettings, "RenderHeroProbeResolution", handleHeroProbeResolutionChanged); setting_setup_signal_listener(gSavedSettings, "RenderShadowDetail", handleSetShaderChanged); setting_setup_signal_listener(gSavedSettings, "RenderDeferredSSAO", handleSetShaderChanged); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 09f77c0c29..fbbcf9bd84 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -213,7 +213,7 @@ void display_update_camera() // Write some stats to LL_INFOS() void display_stats() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; const F32 FPS_LOG_FREQUENCY = 10.f; if (gRecentFPSTime.getElapsedTimeF32() >= FPS_LOG_FREQUENCY) { @@ -654,7 +654,7 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) gPipeline.resetFrameStats(); // Reset per-frame statistics. - if (!gDisconnected) + if (!gDisconnected && !LLApp::isExiting()) { // Render mirrors and associated hero probes before we render the rest of the scene. // This ensures the scene state in the hero probes are exactly the same as the rest of the scene before we render it. @@ -1539,6 +1539,11 @@ void render_ui_3d() gObjectList.resetObjectBeacons(); gSky.addSunMoonBeacons(); } + else + { + // Make sure particle effects disappear + LLHUDObject::renderAllForTimer(); + } stop_glerror(); } @@ -1591,7 +1596,7 @@ void render_ui_2d() } - if (gSavedSettings.getBOOL("RenderUIBuffer")) + if (LLPipeline::RenderUIBuffer) { if (LLView::sIsRectDirty) { @@ -1642,11 +1647,11 @@ void render_ui_2d() S32 height = gViewerWindow->getWindowHeightScaled(); gGL.getTexUnit(0)->bind(&gPipeline.mRT->uiScreen); gGL.begin(LLRender::TRIANGLE_STRIP); - gGL.color4f(1,1,1,1); - gGL.texCoord2f(0, 0); gGL.vertex2i(0, 0); - gGL.texCoord2f(width, 0); gGL.vertex2i(width, 0); - gGL.texCoord2f(0, height); gGL.vertex2i(0, height); - gGL.texCoord2f(width, height); gGL.vertex2i(width, height); + gGL.color4f(1.f,1.f,1.f,1.f); + gGL.texCoord2f(0.f, 0.f); gGL.vertex2i(0, 0); + gGL.texCoord2f((F32)width, 0.f); gGL.vertex2i(width, 0); + gGL.texCoord2f(0.f, (F32)height); gGL.vertex2i(0, height); + gGL.texCoord2f((F32)width, (F32)height); gGL.vertex2i(width, height); gGL.end(); } else diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index ceda2675d5..c97a512a57 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -47,6 +47,7 @@ #include "llfloaterbeacons.h" #include "llfloaterbuildoptions.h" #include "llfloaterbulkpermission.h" +#include "llfloaterbulkupload.h" #include "llfloaterbump.h" #include "llfloaterbuy.h" #include "llfloaterbuycontents.h" @@ -76,6 +77,7 @@ #include "llfloaterfonttest.h" #include "llfloaterforgetuser.h" #include "llfloatergesture.h" +#include "llfloatergltfasseteditor.h" #include "llfloatergodtools.h" #include "llfloatergridstatus.h" #include "llfloatergroups.h" @@ -206,6 +208,7 @@ public: "camera_presets", "delete_pref_preset", "forget_username", + "gltf_asset_editor", "god_tools", "group_picker", "hud", @@ -222,7 +225,8 @@ public: "upload_image", "upload_model", "upload_script", - "upload_sound" + "upload_sound", + "bulk_upload" }; return std::find(blacklist_clicked.begin(), blacklist_clicked.end(), fl_name) == blacklist_clicked.end(); } @@ -246,6 +250,7 @@ public: "env_edit_extdaycycle", "font_test", "forget_username", + "gltf_asset_editor", "god_tools", "group_picker", "hud", @@ -271,7 +276,8 @@ public: "upload_image", "upload_model", "upload_script", - "upload_sound" + "upload_sound", + "bulk_upload" }; return std::find(blacklist_untrusted.begin(), blacklist_untrusted.end(), fl_name) == blacklist_untrusted.end(); } @@ -336,6 +342,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("buy_object_contents", "floater_buy_contents.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuyContents>); LLFloaterReg::add("build", "floater_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTools>); LLFloaterReg::add("build_options", "floater_build_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuildOptions>); + LLFloaterReg::add("bulk_upload", "floater_bulk_upload.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBulkUpload>); LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBump>); LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCamera>); @@ -372,6 +379,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("forget_username", "floater_forget_user.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterForgetUser>); LLFloaterReg::add("gestures", "floater_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGesture>); + LLFloaterReg::add("gltf_asset_editor", "floater_gltf_asset_editor.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGLTFAssetEditor>); LLFloaterReg::add("god_tools", "floater_god_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGodTools>); LLFloaterReg::add("grid_status", "floater_grid_status.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGridStatus>); LLFloaterReg::add("group_picker", "floater_choose_group.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGroupPicker>); diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 96541b030c..e2022cae37 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -334,7 +334,7 @@ LLViewerInventoryItem::LLViewerInventoryItem(const LLUUID& uuid, U32 flags, time_t creation_date_utc) : LLInventoryItem(uuid, parent_uuid, perm, asset_uuid, type, inv_type, - name, desc, sale_info, flags, creation_date_utc), + name, desc, sale_info, flags, (S32)creation_date_utc), mIsComplete(true) { } @@ -534,7 +534,7 @@ void LLViewerInventoryItem::packMessage(LLMessageSystem* msg) const mSaleInfo.packMessage(msg); msg->addStringFast(_PREHASH_Name, mName); msg->addStringFast(_PREHASH_Description, mDescription); - msg->addS32Fast(_PREHASH_CreationDate, mCreationDate); + msg->addS32Fast(_PREHASH_CreationDate, (S32)mCreationDate); U32 crc = getCRC32(); msg->addU32Fast(_PREHASH_CRC, crc); } @@ -675,7 +675,7 @@ bool LLViewerInventoryCategory::fetch(S32 expiry_seconds) { LL_DEBUGS(LOG_INV) << "Fetching category children: " << mName << ", UUID: " << mUUID << LL_ENDL; mDescendentsRequested.reset(); - mDescendentsRequested.setTimerExpirySec(expiry_seconds); + mDescendentsRequested.setTimerExpirySec((F32)expiry_seconds); std::string url; if (gAgent.getRegion()) @@ -721,7 +721,7 @@ void LLViewerInventoryCategory::setFetching(LLViewerInventoryCategory::EFetchTyp mDescendentsRequested.reset(); if (AISAPI::isAvailable()) { - mDescendentsRequested.setTimerExpirySec(AISAPI::HTTP_TIMEOUT); + mDescendentsRequested.setTimerExpirySec((F32)AISAPI::HTTP_TIMEOUT); } else { diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp index ce6dfa4ad1..787ea02e4c 100644 --- a/indra/newview/llviewerjoystick.cpp +++ b/indra/newview/llviewerjoystick.cpp @@ -329,7 +329,7 @@ LLViewerJoystick::LLViewerJoystick() memset(mBtn, 0, sizeof(mBtn)); // factor in bandwidth? bandwidth = gViewerStats->mKBitStat - mPerfScale = 4000.f / gSysCPU.getMHz(); // hmm. why? + mPerfScale = 4000.f / (F32)gSysCPU.getMHz(); // hmm. why? mLastDeviceUUID = LLSD::Integer(1); } diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 23931ecf03..6fc9f2a6f0 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1253,41 +1253,46 @@ void LLViewerMedia::getOpenIDCookieCoro(std::string url) hostEnd = authority.size(); } - LLViewerMedia* inst = getInstance(); if (url.length()) { - LLMediaCtrl* media_instance = LLFloaterReg::getInstance("destinations")->getChild<LLMediaCtrl>("destination_guide_contents"); - if (media_instance) - { - std::string cookie_host = authority.substr(hostStart, hostEnd - hostStart); - std::string cookie_name = ""; - std::string cookie_value = ""; - std::string cookie_path = ""; - bool httponly = true; - bool secure = true; - if (inst->parseRawCookie(inst->mOpenIDCookie, cookie_name, cookie_value, cookie_path, httponly, secure) && - media_instance->getMediaPlugin()) + LLAppViewer::instance()->postToMainCoro([=]() { - // MAINT-5711 - inexplicably, the CEF setCookie function will no longer set the cookie if the - // url and domain are not the same. This used to be my.sl.com and id.sl.com respectively and worked. - // For now, we use the URL for the OpenID POST request since it will have the same authority - // as the domain field. - // (Feels like there must be a less dirty way to construct a URL from component LLURL parts) - // MAINT-6392 - Rider: Do not change, however, the original URI requested, since it is used further - // down. - std::string cefUrl(std::string(inst->mOpenIDURL.mURI) + "://" + std::string(inst->mOpenIDURL.mAuthority)); - - media_instance->getMediaPlugin()->setCookie(cefUrl, cookie_name, cookie_value, cookie_host, - cookie_path, httponly, secure); - - // Now that we have parsed the raw cookie, we must store it so that each new media instance - // can also get a copy and faciliate logging into internal SL sites. - media_instance->getMediaPlugin()->storeOpenIDCookie(cefUrl, cookie_name, cookie_value, - cookie_host, cookie_path, httponly, secure); - } - } + LLMediaCtrl* media_instance = LLFloaterReg::getInstance("destinations")->getChild<LLMediaCtrl>("destination_guide_contents"); + if (media_instance) + { + LLViewerMedia* inst = getInstance(); + std::string cookie_host = authority.substr(hostStart, hostEnd - hostStart); + std::string cookie_name = ""; + std::string cookie_value = ""; + std::string cookie_path = ""; + bool httponly = true; + bool secure = true; + if (inst->parseRawCookie(inst->mOpenIDCookie, cookie_name, cookie_value, cookie_path, httponly, secure) && + media_instance->getMediaPlugin()) + { + // MAINT-5711 - inexplicably, the CEF setCookie function will no longer set the cookie if the + // url and domain are not the same. This used to be my.sl.com and id.sl.com respectively and worked. + // For now, we use the URL for the OpenID POST request since it will have the same authority + // as the domain field. + // (Feels like there must be a less dirty way to construct a URL from component LLURL parts) + // MAINT-6392 - Rider: Do not change, however, the original URI requested, since it is used further + // down. + std::string cefUrl(std::string(inst->mOpenIDURL.mURI) + "://" + std::string(inst->mOpenIDURL.mAuthority)); + + media_instance->getMediaPlugin()->setCookie(cefUrl, cookie_name, cookie_value, cookie_host, + cookie_path, httponly, secure); + + // Now that we have parsed the raw cookie, we must store it so that each new media instance + // can also get a copy and faciliate logging into internal SL sites. + media_instance->getMediaPlugin()->storeOpenIDCookie(cefUrl, cookie_name, cookie_value, + cookie_host, cookie_path, httponly, secure); + } + } + }); } + LLViewerMedia* inst = getInstance(); + // Note: Rider: MAINT-6392 - Some viewer code requires access to the my.sl.com openid cookie for such // actions as posting snapshots to the feed. This is handled through HTTPCore rather than CEF and so // we must learn to SHARE the cookies. @@ -1901,7 +1906,7 @@ void LLViewerMediaImpl::loadURI() // or a seek happened before the media loaded. In either case, seek to the saved time. if(mPreviousMediaTime != 0.0f) { - seek(mPreviousMediaTime); + seek((F32)mPreviousMediaTime); } if(mPreviousMediaState == MEDIA_PLAYING) @@ -2036,7 +2041,7 @@ void LLViewerMediaImpl::skipBack(F32 step_scale) { back_step = 0.0; } - mMediaSource->seek(back_step); + mMediaSource->seek((F32)back_step); } } } @@ -2053,7 +2058,7 @@ void LLViewerMediaImpl::skipForward(F32 step_scale) { forward_step = mMediaSource->getDuration(); } - mMediaSource->seek(forward_step); + mMediaSource->seek((F32)forward_step); } } } @@ -2102,7 +2107,7 @@ void LLViewerMediaImpl::updateVolume() F64 attenuation = 1.0 + (gSavedSettings.getF32("MediaRollOffRate") * adjusted_distance); attenuation = 1.0 / (attenuation * attenuation); // the attenuation multiplier should never be more than one since that would increase volume - volume = volume * llmin(1.0, attenuation); + volume = volume * (F32)llmin(1.0, attenuation); } } @@ -2232,11 +2237,11 @@ void LLViewerMediaImpl::scaleTextureCoords(const LLVector2& texture_coords, S32 // Deal with repeating textures by wrapping the coordinates into the range [0, 1.0) texture_x = fmodf(texture_x, 1.0f); if(texture_x < 0.0f) - texture_x = 1.0 + texture_x; + texture_x = 1.0f + texture_x; texture_y = fmodf(texture_y, 1.0f); if(texture_y < 0.0f) - texture_y = 1.0 + texture_y; + texture_y = 1.0f + texture_y; // scale x and y to texel units. *x = ll_round(texture_x * mMediaSource->getTextureWidth()); diff --git a/indra/newview/llviewermediafocus.cpp b/indra/newview/llviewermediafocus.cpp index c8d25180b9..dbec66f81d 100644 --- a/indra/newview/llviewermediafocus.cpp +++ b/indra/newview/llviewermediafocus.cpp @@ -241,19 +241,19 @@ LLVector3d LLViewerMediaFocus::setCameraZoom(LLViewerObject* object, LLVector3 n if(camera_aspect < 1.0f || invert) { angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect()); - distance = width * 0.5 * padding_factor / tan(angle_of_view * 0.5f ); + distance = width * 0.5f * padding_factor / tanf(angle_of_view * 0.5f ); LL_DEBUGS() << "using width (" << width << "), angle_of_view = " << angle_of_view << ", distance = " << distance << LL_ENDL; } else { angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getView()); - distance = height * 0.5 * padding_factor / tan(angle_of_view * 0.5f ); + distance = height * 0.5f * padding_factor / tanf(angle_of_view * 0.5f ); LL_DEBUGS() << "using height (" << height << "), angle_of_view = " << angle_of_view << ", distance = " << distance << LL_ENDL; } - distance += depth * 0.5; + distance += depth * 0.5f; // Finally animate the camera to this new position and focal point LLVector3d target_pos; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 9a9a316adf..2687938b35 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -8139,6 +8139,15 @@ class LLAdvancedClickGLTFUpload: public view_listener_t } }; +class LLAdvancedClickGLTFEdit : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + LLFloaterReg::showInstance("gltf_asset_editor"); + return true; + } +}; + class LLAdvancedClickResizeWindow : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -9794,6 +9803,7 @@ void initialize_menus() view_listener_t::addMenu(new LLAdvancedClickGLTFOpen(), "Advanced.ClickGLTFOpen"); view_listener_t::addMenu(new LLAdvancedClickGLTFSaveAs(), "Advanced.ClickGLTFSaveAs"); view_listener_t::addMenu(new LLAdvancedClickGLTFUpload(), "Advanced.ClickGLTFUpload"); + view_listener_t::addMenu(new LLAdvancedClickGLTFEdit(), "Advanced.ClickGLTFEdit"); view_listener_t::addMenu(new LLAdvancedClickResizeWindow(), "Advanced.ClickResizeWindow"); view_listener_t::addMenu(new LLAdvancedPurgeShaderCache(), "Advanced.ClearShaderCache"); view_listener_t::addMenu(new LLAdvancedRebuildTerrain(), "Advanced.RebuildTerrain"); diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index e3da52fc78..c4fecf8dff 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -523,15 +523,8 @@ const void upload_single_file(const std::vector<std::string>& filenames, LLFileP return; } -void do_bulk_upload(std::vector<std::string> filenames, const LLSD& notification, const LLSD& response) +void do_bulk_upload(std::vector<std::string> filenames, bool allow_2k) { - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (option != 0) - { - // Cancel upload - return; - } - for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) { std::string filename = (*in_iter); @@ -551,7 +544,7 @@ void do_bulk_upload(std::vector<std::string> filenames, const LLSD& notification if (LLResourceUploadInfo::findAssetTypeAndCodecOfExtension(ext, asset_type, codec)) { bool resource_upload = false; - if (asset_type == LLAssetType::AT_TEXTURE) + if (asset_type == LLAssetType::AT_TEXTURE && allow_2k) { LLPointer<LLImageFormatted> image_frmted = LLImageFormatted::createFromType(codec); if (gDirUtilp->fileExists(filename) && image_frmted->load(filename)) @@ -567,7 +560,7 @@ void do_bulk_upload(std::vector<std::string> filenames, const LLSD& notification if (resource_upload) { - LLResourceUploadInfo::ptr_t uploadInfo(new LLNewFileResourceUploadInfo( + LLNewFileResourceUploadInfo* info_p = new LLNewFileResourceUploadInfo( filename, asset_name, asset_name, 0, @@ -575,7 +568,13 @@ void do_bulk_upload(std::vector<std::string> filenames, const LLSD& notification LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"), - expected_upload_cost)); + expected_upload_cost); + + if (!allow_2k) + { + info_p->setMaxImageSize(1024); + } + LLResourceUploadInfo::ptr_t uploadInfo(info_p); upload_new_resource(uploadInfo); } @@ -601,11 +600,30 @@ void do_bulk_upload(std::vector<std::string> filenames, const LLSD& notification } } -bool get_bulk_upload_expected_cost(const std::vector<std::string>& filenames, S32& total_cost, S32& file_count, S32& bvh_count) +void do_bulk_upload(std::vector<std::string> filenames, bool allow_2k, const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (option != 0) + { + // Cancel upload + return; + } + + do_bulk_upload(filenames, allow_2k); +} + +bool get_bulk_upload_expected_cost( + const std::vector<std::string>& filenames, + bool allow_2k, + S32& total_cost, + S32& file_count, + S32& bvh_count, + S32& textures_2k_count) { total_cost = 0; file_count = 0; bvh_count = 0; + textures_2k_count = 0; for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) { std::string filename = (*in_iter); @@ -622,12 +640,20 @@ bool get_bulk_upload_expected_cost(const std::vector<std::string>& filenames, S3 if (LLResourceUploadInfo::findAssetTypeAndCodecOfExtension(ext, asset_type, codec)) { - if (asset_type == LLAssetType::AT_TEXTURE) + if (asset_type == LLAssetType::AT_TEXTURE && allow_2k) { LLPointer<LLImageFormatted> image_frmted = LLImageFormatted::createFromType(codec); if (gDirUtilp->fileExists(filename) && image_frmted->load(filename)) { total_cost += LLAgentBenefitsMgr::current().getTextureUploadCost(image_frmted); + if (image_frmted) + { + S32 area = image_frmted->getHeight() * image_frmted->getWidth(); + if (area >= LLAgentBenefits::MIN_2K_TEXTURE_AREA) + { + textures_2k_count++; + } + } file_count++; } } @@ -682,38 +708,27 @@ bool get_bulk_upload_expected_cost(const std::vector<std::string>& filenames, S3 return file_count > 0; } -const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter type) +const void upload_bulk(const std::vector<std::string>& filtered_filenames, bool allow_2k) { - // TODO: - // Check user balance for entire cost - // Charge user entire cost - // Loop, uploading - // If an upload fails, refund the user for that one - // - // Also fix single upload to charge first, then refund - - // FIXME PREMIUM what about known types that can't be bulk uploaded - // (bvh)? These will fail in the item by item upload but won't be - // mentioned in the notification. - std::vector<std::string> filtered_filenames; - for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) - { - const std::string& filename = *in_iter; - if (check_file_extension(filename, type)) - { - filtered_filenames.push_back(filename); - } - } - S32 expected_upload_cost; S32 expected_upload_count; S32 bvh_count; - if (get_bulk_upload_expected_cost(filtered_filenames, expected_upload_cost, expected_upload_count, bvh_count)) + S32 textures_2k_count; + if (get_bulk_upload_expected_cost(filtered_filenames, allow_2k, expected_upload_cost, expected_upload_count, bvh_count, textures_2k_count)) { - LLSD args; - args["COST"] = expected_upload_cost; - args["COUNT"] = expected_upload_count; - LLNotificationsUtil::add("BulkUploadCostConfirmation", args, LLSD(), boost::bind(do_bulk_upload, filtered_filenames, _1, _2)); + LLSD key; + key["upload_cost"] = expected_upload_cost; + key["upload_count"] = expected_upload_count; + key["has_2k_textures"] = (textures_2k_count > 0); + + LLSD array; + for (const std::string& str : filtered_filenames) + { + array.append(str); + } + key["files"] = array; + + LLFloaterReg::showInstance("bulk_upload", key); if (filtered_filenames.size() > expected_upload_count) { @@ -738,6 +753,31 @@ const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker:: } +const void upload_bulk(const std::vector<std::string>& filenames, LLFilePicker::ELoadFilter type, bool allow_2k) +{ + // TODO: + // Check user balance for entire cost + // Charge user entire cost + // Loop, uploading + // If an upload fails, refund the user for that one + // + // Also fix single upload to charge first, then refund + + // FIXME PREMIUM what about known types that can't be bulk uploaded + // (bvh)? These will fail in the item by item upload but won't be + // mentioned in the notification. + std::vector<std::string> filtered_filenames; + for (std::vector<std::string>::const_iterator in_iter = filenames.begin(); in_iter != filenames.end(); ++in_iter) + { + const std::string& filename = *in_iter; + if (check_file_extension(filename, type)) + { + filtered_filenames.push_back(filename); + } + } + upload_bulk(filtered_filenames, allow_2k); +} + class LLFileUploadImage : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -803,7 +843,7 @@ class LLFileUploadBulk : public view_listener_t { gAgentCamera.changeCameraToDefault(); } - LLFilePickerReplyThread::startPicker(boost::bind(&upload_bulk, _1, _2), LLFilePicker::FFLOAD_ALL, true); + LLFilePickerReplyThread::startPicker(boost::bind(&upload_bulk, _1, _2, true), LLFilePicker::FFLOAD_ALL, true); return true; } }; diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h index 1acb701d50..d99f9dc4c6 100644 --- a/indra/newview/llviewermenufile.h +++ b/indra/newview/llviewermenufile.h @@ -64,13 +64,15 @@ void upload_new_resource( LLAssetStorage::LLStoreAssetCallback callback = LLAssetStorage::LLStoreAssetCallback(), void *userdata = NULL); - -void assign_defaults_and_show_upload_message( - LLAssetType::EType asset_type, - LLInventoryType::EType& inventory_type, - std::string& name, - const std::string& display_name, - std::string& description); +bool get_bulk_upload_expected_cost( + const std::vector<std::string>& filenames, + bool allow_2k, + S32& total_cost, + S32& file_count, + S32& bvh_count, + S32& textures_2k_count); + +void do_bulk_upload(std::vector<std::string> filenames, bool allow_2k); //consider moving all file pickers below to more suitable place class LLFilePickerThread : public LLThread diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 5a32f9654d..872a9a1581 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -3602,7 +3602,7 @@ void process_kill_object(LLMessageSystem *mesgsys, void **user_data) U32 local_id; mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_ID, local_id, i); - LLViewerObjectList::getUUIDFromLocal(id, local_id, ip, port); + gObjectList.getUUIDFromLocal(id, local_id, ip, port); if (id == LLUUID::null) { LL_DEBUGS("Messaging") << "Unknown kill for local " << local_id << LL_ENDL; @@ -3672,7 +3672,7 @@ void process_time_synch(LLMessageSystem *mesgsys, void **user_data) LLWorld::getInstance()->setSpaceTimeUSec(space_time_usec); - LL_DEBUGS("WindlightSync") << "Sun phase: " << phase << " rad = " << fmodf(phase / F_TWO_PI + 0.25, 1.f) * 24.f << " h" << LL_ENDL; + LL_DEBUGS("WindlightSync") << "Sun phase: " << phase << " rad = " << fmodf(phase / F_TWO_PI + 0.25f, 1.f) * 24.f << " h" << LL_ENDL; /* LAPRAS We decode these parts of the message but ignore them @@ -3691,7 +3691,7 @@ void process_sound_trigger(LLMessageSystem *msg, void **) } U64 region_handle = 0; - F32 gain = 0; + F32 gain = 0.f; LLUUID sound_id; LLUUID owner_id; LLUUID object_id; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index e108f9c268..094d866bc1 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -1940,14 +1940,14 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, if(mesgsys != NULL) { - LLViewerObjectList::getUUIDFromLocal(parent_uuid, + gObjectList.getUUIDFromLocal(parent_uuid, parent_id, mesgsys->getSenderIP(), mesgsys->getSenderPort()); } else { - LLViewerObjectList::getUUIDFromLocal(parent_uuid, + gObjectList.getUUIDFromLocal(parent_uuid, parent_id, mRegionp->getHost().getAddress(), mRegionp->getHost().getPort()); @@ -2062,7 +2062,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, // Debugging for suspected problems with local ids. //LLUUID parent_uuid; - //LLViewerObjectList::getUUIDFromLocal(parent_uuid, parent_id, mesgsys->getSenderIP(), mesgsys->getSenderPort() ); + //gObjectList.getUUIDFromLocal(parent_uuid, parent_id, mesgsys->getSenderIP(), mesgsys->getSenderPort() ); //if (parent_uuid != cur_parentp->getID() ) //{ // LL_ERRS() << "Local ID match but UUID mismatch of viewer object" << LL_ENDL; @@ -2085,14 +2085,14 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, if(mesgsys != NULL) { - LLViewerObjectList::getUUIDFromLocal(parent_uuid, + gObjectList.getUUIDFromLocal(parent_uuid, parent_id, gMessageSystem->getSenderIP(), gMessageSystem->getSenderPort()); } else { - LLViewerObjectList::getUUIDFromLocal(parent_uuid, + gObjectList.getUUIDFromLocal(parent_uuid, parent_id, mRegionp->getHost().getAddress(), mRegionp->getHost().getPort()); @@ -2451,7 +2451,7 @@ void LLViewerObject::idleUpdate(LLAgent &agent, const F64 &frame_time) { // calculate dt from last update F32 time_dilation = mRegionp ? mRegionp->getTimeDilation() : 1.0f; - F32 dt_raw = ((F64Seconds)frame_time - mLastInterpUpdateSecs).value(); + F32 dt_raw = (F32)((F64Seconds)frame_time - mLastInterpUpdateSecs).value(); F32 dt = time_dilation * dt_raw; applyAngularVelocity(dt); @@ -2950,7 +2950,7 @@ void LLViewerObject::fetchInventoryDelayed(const F64 &time_seconds) //static void LLViewerObject::fetchInventoryDelayedCoro(const LLUUID task_inv, const F64 time_seconds) { - llcoro::suspendUntilTimeout(time_seconds); + llcoro::suspendUntilTimeout((float)time_seconds); LLViewerObject *obj = gObjectList.findObject(task_inv); if (obj) { @@ -3676,6 +3676,8 @@ bool LLViewerObject::updateLOD() bool LLViewerObject::updateGeometry(LLDrawable *drawable) { + // return true means "update complete", return false means "try again next frame" + // default should be return true return true; } @@ -4416,6 +4418,7 @@ void LLViewerObject::moveGLTFNode(S32 node_index, const LLVector3& offset) matMul(trans, mat, mat); node.mMatrix = glm::make_mat4(mat.getF32ptr()); + node.mTRSValid = false; // TODO -- only update transforms for this node and its children (or use a dirty flag) mGLTFAsset->updateTransforms(); diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 08a1ba0f9b..cda8c99594 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -99,8 +99,6 @@ extern LLPipeline gPipeline; // Statics for object lookup tables. U32 LLViewerObjectList::sSimulatorMachineIndex = 1; // Not zero deliberately, to speed up index check. -std::map<U64, U32> LLViewerObjectList::sIPAndPortToIndex; -std::map<U64, LLUUID> LLViewerObjectList::sIndexAndLocalIDToUUID; LLViewerObjectList::LLViewerObjectList() { @@ -138,17 +136,17 @@ void LLViewerObjectList::getUUIDFromLocal(LLUUID &id, { U64 ipport = (((U64)ip) << 32) | (U64)port; - U32 index = sIPAndPortToIndex[ipport]; + U32 index = mIPAndPortToIndex[ipport]; if (!index) { index = sSimulatorMachineIndex++; - sIPAndPortToIndex[ipport] = index; + mIPAndPortToIndex[ipport] = index; } U64 indexid = (((U64)index) << 32) | (U64)local_id; - id = get_if_there(sIndexAndLocalIDToUUID, indexid, LLUUID::null); + id = get_if_there(mIndexAndLocalIDToUUID, indexid, LLUUID::null); } U64 LLViewerObjectList::getIndex(const U32 local_id, @@ -157,7 +155,7 @@ U64 LLViewerObjectList::getIndex(const U32 local_id, { U64 ipport = (((U64)ip) << 32) | (U64)port; - U32 index = sIPAndPortToIndex[ipport]; + U32 index = mIPAndPortToIndex[ipport]; if (!index) { @@ -177,14 +175,14 @@ bool LLViewerObjectList::removeFromLocalIDTable(const LLViewerObject* objectp) U32 ip = objectp->getRegion()->getHost().getAddress(); U32 port = objectp->getRegion()->getHost().getPort(); U64 ipport = (((U64)ip) << 32) | (U64)port; - U32 index = sIPAndPortToIndex[ipport]; + U32 index = mIPAndPortToIndex[ipport]; // LL_INFOS() << "Removing object from table, local ID " << local_id << ", ip " << ip << ":" << port << LL_ENDL; U64 indexid = (((U64)index) << 32) | (U64)local_id; - std::map<U64, LLUUID>::iterator iter = sIndexAndLocalIDToUUID.find(indexid); - if (iter == sIndexAndLocalIDToUUID.end()) + std::map<U64, LLUUID>::iterator iter = mIndexAndLocalIDToUUID.find(indexid); + if (iter == mIndexAndLocalIDToUUID.end()) { return false; } @@ -192,7 +190,7 @@ bool LLViewerObjectList::removeFromLocalIDTable(const LLViewerObject* objectp) // Found existing entry if (iter->second == objectp->getID()) { // Full UUIDs match, so remove the entry - sIndexAndLocalIDToUUID.erase(iter); + mIndexAndLocalIDToUUID.erase(iter); return true; } // UUIDs did not match - this would zap a valid entry, so don't erase it @@ -210,17 +208,17 @@ void LLViewerObjectList::setUUIDAndLocal(const LLUUID &id, { U64 ipport = (((U64)ip) << 32) | (U64)port; - U32 index = sIPAndPortToIndex[ipport]; + U32 index = mIPAndPortToIndex[ipport]; if (!index) { index = sSimulatorMachineIndex++; - sIPAndPortToIndex[ipport] = index; + mIPAndPortToIndex[ipport] = index; } U64 indexid = (((U64)index) << 32) | (U64)local_id; - sIndexAndLocalIDToUUID[indexid] = id; + mIndexAndLocalIDToUUID[indexid] = id; //LL_INFOS() << "Adding object to table, full ID " << id // << ", local ID " << local_id << ", ip " << ip << ":" << port << LL_ENDL; @@ -1129,10 +1127,10 @@ void LLViewerObjectList::fetchObjectCostsCoro(std::string url) { LLSD objectData = result[it->asString()]; - F32 linkCost = objectData["linked_set_resource_cost"].asReal(); - F32 objectCost = objectData["resource_cost"].asReal(); - F32 physicsCost = objectData["physics_cost"].asReal(); - F32 linkPhysicsCost = objectData["linked_set_physics_cost"].asReal(); + F32 linkCost = (F32)objectData["linked_set_resource_cost"].asReal(); + F32 objectCost = (F32)objectData["resource_cost"].asReal(); + F32 physicsCost = (F32)objectData["physics_cost"].asReal(); + F32 linkPhysicsCost = (F32)objectData["linked_set_physics_cost"].asReal(); gObjectList.updateObjectCost(objectId, objectCost, linkCost, physicsCost, linkPhysicsCost); } @@ -1257,10 +1255,10 @@ void LLViewerObjectList::fetchPhisicsFlagsCoro(std::string url) if (data.has("Density")) { - F32 density = data["Density"].asReal(); - F32 friction = data["Friction"].asReal(); - F32 restitution = data["Restitution"].asReal(); - F32 gravityMult = data["GravityMultiplier"].asReal(); + F32 density = (F32)data["Density"].asReal(); + F32 friction = (F32)data["Friction"].asReal(); + F32 restitution = (F32)data["Restitution"].asReal(); + F32 gravityMult = (F32)data["GravityMultiplier"].asReal(); gObjectList.updatePhysicsProperties(objectId, density, friction, restitution, gravityMult); diff --git a/indra/newview/llviewerobjectlist.h b/indra/newview/llviewerobjectlist.h index f0f236d6ae..ebdfd0d369 100644 --- a/indra/newview/llviewerobjectlist.h +++ b/indra/newview/llviewerobjectlist.h @@ -171,18 +171,18 @@ public: // used to discount stats from this frame bool mWasPaused; - static void getUUIDFromLocal(LLUUID &id, + void getUUIDFromLocal(LLUUID &id, const U32 local_id, const U32 ip, const U32 port); - static void setUUIDAndLocal(const LLUUID &id, + void setUUIDAndLocal(const LLUUID &id, const U32 local_id, const U32 ip, const U32 port); // Requires knowledge of message system info! - static bool removeFromLocalIDTable(const LLViewerObject* objectp); + bool removeFromLocalIDTable(const LLViewerObject* objectp); // Used ONLY by the orphaned object code. - static U64 getIndex(const U32 local_id, const U32 ip, const U32 port); + U64 getIndex(const U32 local_id, const U32 ip, const U32 port); S32 mNumUnknownUpdates; S32 mNumDeadObjectUpdates; @@ -216,9 +216,9 @@ protected: S32 mCurLazyUpdateIndex; static U32 sSimulatorMachineIndex; - static std::map<U64, U32> sIPAndPortToIndex; + std::map<U64, U32> mIPAndPortToIndex; - static std::map<U64, LLUUID> sIndexAndLocalIDToUUID; + std::map<U64, LLUUID> mIndexAndLocalIDToUUID; friend class LLViewerObject; @@ -257,7 +257,7 @@ extern LLViewerObjectList gObjectList; */ inline LLViewerObject *LLViewerObjectList::findObject(const LLUUID &id) { - std::map<LLUUID, LLPointer<LLViewerObject> >::iterator iter = mUUIDObjectMap.find(id); + auto iter = mUUIDObjectMap.find(id); if(iter != mUUIDObjectMap.end()) { return iter->second; diff --git a/indra/newview/llviewerparceloverlay.cpp b/indra/newview/llviewerparceloverlay.cpp index 1f14aa4afc..58b8a5b677 100755 --- a/indra/newview/llviewerparceloverlay.cpp +++ b/indra/newview/llviewerparceloverlay.cpp @@ -611,7 +611,7 @@ void LLViewerParcelOverlay::setDirty() void LLViewerParcelOverlay::updateGL() { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; updateOverlayTexture(); } diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 19a1990665..7623ab56a5 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1269,8 +1269,12 @@ U32 LLViewerRegion::getNumOfVisibleGroups() const return mImpl ? static_cast<U32>(mImpl->mVisibleGroups.size()) : 0; } -void LLViewerRegion::updateReflectionProbes() +void LLViewerRegion::updateReflectionProbes(bool full_update) { + if (!full_update && mReflectionMaps.empty()) + { + return; + } LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; const F32 probe_spacing = 32.f; const F32 probe_radius = sqrtf((probe_spacing * 0.5f) * (probe_spacing * 0.5f) * 3.f); @@ -1278,7 +1282,7 @@ void LLViewerRegion::updateReflectionProbes() F32 start = probe_spacing * 0.5f; - U32 grid_width = REGION_WIDTH_METERS / probe_spacing; + U32 grid_width = (U32)(REGION_WIDTH_METERS / probe_spacing); mReflectionMaps.resize(grid_width * grid_width); @@ -3143,16 +3147,24 @@ void LLViewerRegion::unpackRegionHandshake() compp->setParamsReady(); } - LLPBRTerrainFeatures::queueQuery(*this, [](LLUUID region_id, bool success, const LLModifyRegion& composition_changes) + std::string cap = getCapability("ModifyRegion"); // needed for queueQuery + if (cap.empty()) + { + LLFloaterRegionInfo::sRefreshFromRegion(this); + } + else { - if (!success) { return; } - LLViewerRegion* region = LLWorld::getInstance()->getRegionFromID(region_id); - if (!region) { return; } - LLVLComposition* compp = region->getComposition(); - if (!compp) { return; } - compp->apply(composition_changes); - LLFloaterRegionInfo::sRefreshFromRegion(region); - }); + LLPBRTerrainFeatures::queueQuery(*this, [](LLUUID region_id, bool success, const LLModifyRegion& composition_changes) + { + if (!success) { return; } + LLViewerRegion* region = LLWorld::getInstance()->getRegionFromID(region_id); + if (!region) { return; } + LLVLComposition* compp = region->getComposition(); + if (!compp) { return; } + compp->apply(composition_changes); + LLFloaterRegionInfo::sRefreshFromRegion(region); + }); + } } @@ -3735,7 +3747,7 @@ void LLViewerRegion::resetMaterialsCapThrottle() if ( mSimulatorFeatures.has("RenderMaterialsCapability") && mSimulatorFeatures["RenderMaterialsCapability"].isReal() ) { - requests_per_sec = mSimulatorFeatures["RenderMaterialsCapability"].asReal(); + requests_per_sec = (F32)mSimulatorFeatures["RenderMaterialsCapability"].asReal(); if ( requests_per_sec == 0.0f ) { requests_per_sec = 1.0f; diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 68247dc18e..d0ec1fe877 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -428,7 +428,7 @@ public: static bool isNewObjectCreationThrottleDisabled() {return sNewObjectCreationThrottle < 0;} // rebuild reflection probe list - void updateReflectionProbes(); + void updateReflectionProbes(bool full_update); private: void addToVOCacheTree(LLVOCacheEntry* entry); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 12d0aa4f8e..96354ea18f 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -495,8 +495,6 @@ void LLViewerShaderMgr::setShaders() mShaderList.clear(); - LLShaderMgr::sMirrorsEnabled = LLPipeline::RenderMirrors; - if (!gGLManager.mHasRequirements) { // Viewer will show 'hardware requirements' warning later @@ -755,6 +753,8 @@ std::string LLViewerShaderMgr::loadBasicShaders() bool ssr = gSavedSettings.getBOOL("RenderScreenSpaceReflections"); + bool mirrors = gSavedSettings.getBOOL("RenderMirrors"); + bool has_reflection_probes = gSavedSettings.getBOOL("RenderReflectionsEnabled") && gGLManager.mGLVersion > 3.99f; S32 probe_level = llclamp(gSavedSettings.getS32("RenderReflectionProbeLevel"), 0, 3); @@ -782,6 +782,11 @@ std::string LLViewerShaderMgr::loadBasicShaders() attribs["REF_SAMPLE_COUNT"] = "32"; } + if (mirrors) + { + attribs["HERO_PROBES"] = "1"; + } + { // PBR terrain const S32 mapping = clamp_terrain_mapping(gSavedSettings.getS32("RenderTerrainPBRPlanarSampleCount")); attribs["TERRAIN_PLANAR_TEXTURE_SAMPLE_COUNT"] = llformat("%d", mapping); diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp index 3499c7eb7d..d1ee9ea17c 100644 --- a/indra/newview/llviewerstats.cpp +++ b/indra/newview/llviewerstats.cpp @@ -284,13 +284,13 @@ void LLViewerStats::updateFrameStats(const F64Seconds time_diff) add(LLStatViewer::LOSS_5_PERCENT_TIME, time_diff); } - F32 sim_fps = getRecording().getLastValue(LLStatViewer::SIM_FPS); + F32 sim_fps = (F32)getRecording().getLastValue(LLStatViewer::SIM_FPS); if (0.f < sim_fps && sim_fps < 20.f) { add(LLStatViewer::SIM_20_FPS_TIME, time_diff); } - F32 sim_physics_fps = getRecording().getLastValue(LLStatViewer::SIM_PHYSICS_FPS); + F32 sim_physics_fps = (F32)getRecording().getLastValue(LLStatViewer::SIM_PHYSICS_FPS); if (0.f < sim_physics_fps && sim_physics_fps < 20.f) { diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index 0ab0265586..15902e8a87 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -220,7 +220,7 @@ public: LLRectf image_rect = draw_rect; image_rect.mRight = image_rect.mLeft + mImage->getWidth(); image_rect.mTop = image_rect.mBottom + mImage->getHeight(); - mImage->draw(LLRect(image_rect.mLeft, image_rect.mTop, image_rect.mRight, image_rect.mBottom)); + mImage->draw(LLRect((S32)image_rect.mLeft, (S32)image_rect.mTop, (S32)image_rect.mRight, (S32)image_rect.mBottom)); LLColor4 color; if (mEditor.getReadOnly()) diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index c1062b9a01..9648a9af18 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -63,23 +63,18 @@ #include "llwindow.h" /////////////////////////////////////////////////////////////////////////////// -// extern -const S32Megabytes gMinVideoRam(32); -const S32Megabytes gMaxVideoRam(512); - - // statics -LLPointer<LLViewerTexture> LLViewerTexture::sNullImagep = NULL; -LLPointer<LLViewerTexture> LLViewerTexture::sBlackImagep = NULL; -LLPointer<LLViewerTexture> LLViewerTexture::sCheckerBoardImagep = NULL; -LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sMissingAssetImagep = NULL; -LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sWhiteImagep = NULL; -LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultImagep = NULL; -LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sSmokeImagep = NULL; -LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sFlatNormalImagep = NULL; +LLPointer<LLViewerTexture> LLViewerTexture::sNullImagep = nullptr; +LLPointer<LLViewerTexture> LLViewerTexture::sBlackImagep = nullptr; +LLPointer<LLViewerTexture> LLViewerTexture::sCheckerBoardImagep = nullptr; +LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sMissingAssetImagep = nullptr; +LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sWhiteImagep = nullptr; +LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultImagep = nullptr; +LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sSmokeImagep = nullptr; +LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sFlatNormalImagep = nullptr; LLPointer<LLViewerFetchedTexture> LLViewerFetchedTexture::sDefaultIrradiancePBRp; LLViewerMediaTexture::media_map_t LLViewerMediaTexture::sMediaMap; -LLTexturePipelineTester* LLViewerTextureManager::sTesterp = NULL; +LLTexturePipelineTester* LLViewerTextureManager::sTesterp = nullptr; F32 LLViewerFetchedTexture::sMaxVirtualSize = 8192.f*8192.f; const std::string sTesterName("TextureTester"); @@ -89,18 +84,19 @@ S32 LLViewerTexture::sRawCount = 0; S32 LLViewerTexture::sAuxCount = 0; LLFrameTimer LLViewerTexture::sEvaluationTimer; F32 LLViewerTexture::sDesiredDiscardBias = 0.f; -F32 LLViewerTexture::sDesiredDiscardScale = 1.1f; + S32 LLViewerTexture::sMaxSculptRez = 128; //max sculpt image size -const S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64; +constexpr S32 MAX_CACHED_RAW_IMAGE_AREA = 64 * 64; const S32 MAX_CACHED_RAW_SCULPT_IMAGE_AREA = LLViewerTexture::sMaxSculptRez * LLViewerTexture::sMaxSculptRez; -const S32 MAX_CACHED_RAW_TERRAIN_IMAGE_AREA = 128 * 128; -const S32 DEFAULT_ICON_DIMENSIONS = 32; -const S32 DEFAULT_THUMBNAIL_DIMENSIONS = 256; +constexpr S32 MAX_CACHED_RAW_TERRAIN_IMAGE_AREA = 128 * 128; +constexpr S32 DEFAULT_ICON_DIMENSIONS = 32; +constexpr S32 DEFAULT_THUMBNAIL_DIMENSIONS = 256; U32 LLViewerTexture::sMinLargeImageSize = 65536; //256 * 256. U32 LLViewerTexture::sMaxSmallImageSize = MAX_CACHED_RAW_IMAGE_AREA; bool LLViewerTexture::sFreezeImageUpdates = false; F32 LLViewerTexture::sCurrentTime = 0.0f; +constexpr F32 MEMORY_CHECK_WAIT_TIME = 1.0f; constexpr F32 MIN_VRAM_BUDGET = 768.f; F32 LLViewerTexture::sFreeVRAMMegabytes = MIN_VRAM_BUDGET; @@ -413,8 +409,6 @@ void LLViewerTextureManager::init() } } imagep->createGLTexture(0, image_raw); - //cache the raw image - imagep->setCachedRawImage(0, image_raw); image_raw = NULL; #else LLViewerFetchedTexture::sDefaultImagep = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT, true, LLGLTexture::BOOST_UI); @@ -484,10 +478,6 @@ void LLViewerTexture::initClass() LLImageGL::sDefaultGLTexture = LLViewerFetchedTexture::sDefaultImagep->getGLTexture(); } -// non-const (used externally -F32 texmem_lower_bound_scale = 0.85f; -F32 texmem_middle_bound_scale = 0.925f; - //static void LLViewerTexture::updateClass() { @@ -512,21 +502,75 @@ void LLViewerTexture::updateClass() // NOTE: our metrics miss about half the vram we use, so this biases high but turns out to typically be within 5% of the real number F32 used = (F32)ll_round(texture_bytes_alloc + vertex_bytes_alloc + render_bytes_alloc); - F32 budget = max_vram_budget == 0 ? gGLManager.mVRAM : max_vram_budget; + F32 budget = max_vram_budget == 0 ? (F32)gGLManager.mVRAM : (F32)max_vram_budget; // try to leave half a GB for everyone else, but keep at least 768MB for ourselves F32 target = llmax(budget - 512.f, MIN_VRAM_BUDGET); sFreeVRAMMegabytes = target - used; - F32 over_pct = llmax((used-target) / target, 0.f); - sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.f + over_pct); + F32 over_pct = (used - target) / target; + + bool is_low = over_pct > 0.f; + + if (isSystemMemoryLow()) + { + is_low = true; + // System RAM is low -> ramp up discard bias over time to free memory + if (sEvaluationTimer.getElapsedTimeF32() > MEMORY_CHECK_WAIT_TIME) + { + static LLCachedControl<F32> low_mem_min_discard_increment(gSavedSettings, "RenderLowMemMinDiscardIncrement", .1f); + sDesiredDiscardBias += (F32) low_mem_min_discard_increment * (F32) gFrameIntervalSeconds; + sEvaluationTimer.reset(); + } + } + else + { + sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.f + over_pct); + + if (sDesiredDiscardBias > 1.f && over_pct < 0.f) + { + sDesiredDiscardBias -= gFrameIntervalSeconds * 0.01f; + } + } + + static bool was_low = false; + if (is_low && !was_low) + { + LL_WARNS() << "Low system memory detected, emergency downrezzing off screen textures" << LL_ENDL; + sDesiredDiscardBias = llmax(sDesiredDiscardBias, 1.5f); + + for (auto image : gTextureList) + { + gTextureList.updateImageDecodePriority(image); + } + } + + was_low = is_low; + + sDesiredDiscardBias = llclamp(sDesiredDiscardBias, 1.f, 3.f); + + LLViewerTexture::sFreezeImageUpdates = false; +} + +//static +bool LLViewerTexture::isSystemMemoryLow() +{ + static LLFrameTimer timer; + static U32Megabytes physical_res = U32Megabytes(U32_MAX); + + static LLCachedControl<U32> min_free_main_memory(gSavedSettings, "RenderMinFreeMainMemoryThreshold", 512); + const U32Megabytes MIN_FREE_MAIN_MEMORY(min_free_main_memory); - if (sDesiredDiscardBias > 1.f) + if (timer.getElapsedTimeF32() < MEMORY_CHECK_WAIT_TIME) //call this once per second. { - sDesiredDiscardBias -= gFrameIntervalSeconds * 0.01; + return physical_res < MIN_FREE_MAIN_MEMORY; } - LLViewerTexture::sFreezeImageUpdates = false; // sDesiredDiscardBias > (desired_discard_bias_max - 1.0f); + timer.reset(); + + LLMemory::updateMemoryInfo(); + physical_res = LLMemory::getAvailableMemKB(); + return physical_res < MIN_FREE_MAIN_MEMORY; } //end of static functions @@ -585,16 +629,15 @@ void LLViewerTexture::init(bool firstinit) mParcelMedia = NULL; memset(&mNumVolumes, 0, sizeof(U32)* LLRender::NUM_VOLUME_TEXTURE_CHANNELS); - mFaceList[LLRender::DIFFUSE_MAP].clear(); - mFaceList[LLRender::NORMAL_MAP].clear(); - mFaceList[LLRender::SPECULAR_MAP].clear(); - mNumFaces[LLRender::DIFFUSE_MAP] = - mNumFaces[LLRender::NORMAL_MAP] = - mNumFaces[LLRender::SPECULAR_MAP] = 0; - mVolumeList[LLRender::LIGHT_TEX].clear(); mVolumeList[LLRender::SCULPT_TEX].clear(); + for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; i++) + { + mNumFaces[i] = 0; + mFaceList[i].clear(); + } + mMainQueue = LL::WorkQueue::getInstance("mainloop"); mImageQueue = LL::WorkQueue::getInstance("LLImageGL"); } @@ -696,9 +739,6 @@ bool LLViewerTexture::bindDefaultImage(S32 stage) } stop_glerror(); - //check if there is cached raw image and switch to it if possible - switchToCachedImage(); - LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); if (tester) { @@ -899,18 +939,6 @@ void LLViewerTexture::reorganizeVolumeList() } } -//virtual -void LLViewerTexture::switchToCachedImage() -{ - //nothing here. -} - -//virtual -void LLViewerTexture::setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) -{ - //nothing here. -} - bool LLViewerTexture::isLargeImage() { return (S32)mTexelsPerImage > LLViewerTexture::sMinLargeImageSize; @@ -1045,10 +1073,6 @@ void LLViewerFetchedTexture::init(bool firstinit) mIsFetched = false; mInFastCacheList = false; - mCachedRawImage = NULL; - mCachedRawDiscardLevel = -1; - mCachedRawImageReady = false; - mSavedRawImage = NULL; mForceToSaveRawImage = false; mSaveRawImage = false; @@ -1106,9 +1130,6 @@ void LLViewerFetchedTexture::cleanup() // Clean up image data destroyRawImage(); - mCachedRawImage = NULL; - mCachedRawDiscardLevel = -1; - mCachedRawImageReady = false; mSavedRawImage = NULL; mSavedRawDiscardLevel = -1; } @@ -1188,13 +1209,17 @@ void LLViewerFetchedTexture::setForSculpt() { static const S32 MAX_INTERVAL = 8; //frames + forceToSaveRawImage(0, F32_MAX); + + setBoostLevel(llmax((S32)getBoostLevel(), + (S32)LLGLTexture::BOOST_SCULPTED)); + mForSculpt = true; if(isForSculptOnly() && hasGLTexture() && !getBoundRecently()) { destroyGLTexture(); //sculpt image does not need gl texture. mTextureState = ACTIVE; } - checkCachedRawSculptImage(); setMaxVirtualSizeResetInterval(MAX_INTERVAL); } @@ -1307,10 +1332,6 @@ void LLViewerFetchedTexture::addToCreateTexture() } } - //discard the cached raw image and the saved raw image - mCachedRawImageReady = false; - mCachedRawDiscardLevel = -1; - mCachedRawImage = NULL; mSavedRawDiscardLevel = -1; mSavedRawImage = NULL; } @@ -1600,7 +1621,11 @@ void LLViewerFetchedTexture::scheduleCreateTexture() } else { - gTextureList.mCreateTextureList.insert(this); + if (!mCreatePending) + { + mCreatePending = true; + gTextureList.mCreateTextureList.push(this); + } } } } @@ -1624,13 +1649,12 @@ void LLViewerFetchedTexture::setKnownDrawSize(S32 width, S32 height) void LLViewerFetchedTexture::setDebugText(const std::string& text) { - for (U32 ch = 0; ch < LLRender::NUM_TEXTURE_CHANNELS; ++ch) + for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i) { - llassert(mNumFaces[ch] <= mFaceList[ch].size()); - - for (U32 i = 0; i < mNumFaces[ch]; i++) + for (S32 fi = 0; fi < getNumFaces(i); ++fi) { - LLFace* facep = mFaceList[ch][i]; + LLFace* facep = (*(getFaceList(i)))[fi]; + if (facep) { LLDrawable* drawable = facep->getDrawable(); @@ -1643,10 +1667,15 @@ void LLViewerFetchedTexture::setDebugText(const std::string& text) } } +extern bool gCubeSnapshot; + //virtual void LLViewerFetchedTexture::processTextureStats() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + llassert(!gCubeSnapshot); // should only be called when the main camera is active + llassert(!LLPipeline::sShadowRender); + if(mFullyLoaded) { if(mDesiredDiscardLevel > mMinDesiredDiscardLevel)//need to load more @@ -2011,13 +2040,6 @@ bool LLViewerFetchedTexture::updateFetch() LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("vftuf - current < min"); make_request = false; } - else if(mCachedRawImage.notNull() // can be empty - && mCachedRawImageReady - && (current_discard < 0 || current_discard > mCachedRawDiscardLevel)) - { - make_request = false; - switchToCachedImage(); //use the cached raw data first - } if (make_request) { @@ -2511,20 +2533,6 @@ bool LLViewerFetchedTexture::doLoadedCallbacks() } // - // Do a readback if required, OR start off a texture decode - // - if (need_readback && (getMaxDiscardLevel() > gl_discard)) - { - // Do a readback to get the GL data into the raw image - // We have GL data. - - destroyRawImage(); - reloadRawImage(mLoadedCallbackDesiredDiscardLevel); - llassert(mRawImage.notNull()); - llassert(!mNeedsAux || mAuxRawImage.notNull()); - } - - // // Run raw/auxiliary data callbacks // if (run_raw_callbacks && mIsRawImageValid && (mRawDiscardLevel <= getMaxDiscardLevel())) @@ -2631,61 +2639,6 @@ void LLViewerFetchedTexture::forceImmediateUpdate() return; } -LLImageRaw* LLViewerFetchedTexture::reloadRawImage(S8 discard_level) -{ - llassert(mGLTexturep.notNull()); - llassert(discard_level >= 0); - llassert(mComponents > 0); - - if (mRawImage.notNull()) - { - //mRawImage is in use by somebody else, do not delete it. - return NULL; - } - - if(mSavedRawDiscardLevel >= 0 && mSavedRawDiscardLevel <= discard_level) - { - if (mSavedRawDiscardLevel != discard_level - && mBoostLevel != BOOST_ICON - && mBoostLevel != BOOST_THUMBNAIL) - { - mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), getComponents()); - mRawImage->copy(getSavedRawImage()); - } - else - { - mRawImage = getSavedRawImage(); - } - mRawDiscardLevel = discard_level; - } - else - { - //force to fetch raw image again if cached raw image is not good enough. - if(mCachedRawDiscardLevel > discard_level) - { - mRawImage = mCachedRawImage; - mRawDiscardLevel = mCachedRawDiscardLevel; - } - else //cached raw image is good enough, copy it. - { - if(mCachedRawDiscardLevel != discard_level) - { - mRawImage = new LLImageRaw(getWidth(discard_level), getHeight(discard_level), getComponents()); - mRawImage->copy(mCachedRawImage); - } - else - { - mRawImage = mCachedRawImage; - } - mRawDiscardLevel = discard_level; - } - } - mIsRawImageValid = true; - sRawCount++; - - return mRawImage; -} - bool LLViewerFetchedTexture::needsToSaveRawImage() { return mForceToSaveRawImage || mSaveRawImage; @@ -2710,7 +2663,6 @@ void LLViewerFetchedTexture::destroyRawImage() { saveRawImage(); } - setCachedRawImage(); } mRawImage = NULL; @@ -2720,151 +2672,6 @@ void LLViewerFetchedTexture::destroyRawImage() } } -//use the mCachedRawImage to (re)generate the gl texture. -//virtual -void LLViewerFetchedTexture::switchToCachedImage() -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - if(mCachedRawImage.notNull() && - !mNeedsCreateTexture) // <--- texture creation is pending, don't step on it - { - mRawImage = mCachedRawImage; - - if (getComponents() != mRawImage->getComponents()) - { - // We've changed the number of components, so we need to move any - // objects using this pool to a different pool. - mComponents = mRawImage->getComponents(); - mGLTexturep->setComponents(mComponents); - gTextureList.dirtyImage(this); - } - - mIsRawImageValid = true; - mRawDiscardLevel = mCachedRawDiscardLevel; - - scheduleCreateTexture(); - } -} - -//cache the imageraw forcefully. -//virtual -void LLViewerFetchedTexture::setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) -{ - if(imageraw != mRawImage.get()) - { - if (mBoostLevel == LLGLTexture::BOOST_ICON) - { - S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_ICON_DIMENSIONS; - S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_ICON_DIMENSIONS; - if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height) - { - mCachedRawImage = new LLImageRaw(expected_width, expected_height, imageraw->getComponents()); - mCachedRawImage->copyScaled(imageraw); - } - else - { - mCachedRawImage = imageraw; - } - } - else if (mBoostLevel == LLGLTexture::BOOST_THUMBNAIL) - { - S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : DEFAULT_THUMBNAIL_DIMENSIONS; - S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : DEFAULT_THUMBNAIL_DIMENSIONS; - if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height) - { - mCachedRawImage = new LLImageRaw(expected_width, expected_height, imageraw->getComponents()); - mCachedRawImage->copyScaled(imageraw); - } - else - { - mCachedRawImage = imageraw; - } - } - else - { - mCachedRawImage = imageraw; - } - mCachedRawDiscardLevel = discard_level; - mCachedRawImageReady = true; - } -} - -void LLViewerFetchedTexture::setCachedRawImage() -{ - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - if(mRawImage == mCachedRawImage) - { - return; - } - if(!mIsRawImageValid) - { - return; - } - - if(mCachedRawImageReady) - { - return; - } - - if(mCachedRawDiscardLevel < 0 || mCachedRawDiscardLevel > mRawDiscardLevel) - { - S32 i = 0; - S32 w = mRawImage->getWidth(); - S32 h = mRawImage->getHeight(); - - S32 max_size = MAX_CACHED_RAW_IMAGE_AREA; - if(LLGLTexture::BOOST_TERRAIN == mBoostLevel) - { - max_size = MAX_CACHED_RAW_TERRAIN_IMAGE_AREA; - } - if(mForSculpt) - { - max_size = MAX_CACHED_RAW_SCULPT_IMAGE_AREA; - mCachedRawImageReady = !mRawDiscardLevel; - } - else - { - mCachedRawImageReady = (!mRawDiscardLevel || ((w * h) >= max_size)); - } - - while(((w >> i) * (h >> i)) > max_size) - { - ++i; - } - - if(i) - { - if(!(w >> i) || !(h >> i)) - { - --i; - } - - { - //make a duplicate in case somebody else is using this raw image - mRawImage = mRawImage->scaled(w >> i, h >> i); - } - } - mCachedRawImage = mRawImage; - mRawDiscardLevel += i; - mCachedRawDiscardLevel = mRawDiscardLevel; - } -} - -void LLViewerFetchedTexture::checkCachedRawSculptImage() -{ - if(mCachedRawImageReady && mCachedRawDiscardLevel > 0) - { - if(getDiscardLevel() != 0) - { - mCachedRawImageReady = false; - } - else if(isForSculptOnly()) - { - resetTextureStats(); //do not update this image any more. - } - } -} - void LLViewerFetchedTexture::saveRawImage() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; @@ -2904,6 +2711,20 @@ void LLViewerFetchedTexture::saveRawImage() mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents()); } } + else if (mBoostLevel == LLGLTexture::BOOST_SCULPTED) + { + S32 expected_width = mKnownDrawWidth > 0 ? mKnownDrawWidth : sMaxSculptRez; + S32 expected_height = mKnownDrawHeight > 0 ? mKnownDrawHeight : sMaxSculptRez; + if (mRawImage->getWidth() > expected_width || mRawImage->getHeight() > expected_height) + { + mSavedRawImage = new LLImageRaw(expected_width, expected_height, mRawImage->getComponents()); + mSavedRawImage->copyScaled(mRawImage); + } + else + { + mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents()); + } + } else { mSavedRawImage = new LLImageRaw(mRawImage->getData(), mRawImage->getWidth(), mRawImage->getHeight(), mRawImage->getComponents()); @@ -2949,20 +2770,23 @@ void LLViewerFetchedTexture::forceToSaveRawImage(S32 desired_discard, F32 kept_t { mForceToSaveRawImage = true; mDesiredSavedRawDiscardLevel = desired_discard; + } +} - //copy from the cached raw image if exists. - if(mCachedRawImage.notNull() && mRawImage.isNull() ) - { - mRawImage = mCachedRawImage; - mRawDiscardLevel = mCachedRawDiscardLevel; - - saveRawImage(); +void LLViewerFetchedTexture::readbackRawImage() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - mRawImage = NULL; - mRawDiscardLevel = INVALID_DISCARD_LEVEL; + if (mGLTexturep.notNull() && mGLTexturep->getTexName() != 0 && mRawImage.isNull()) + { + mRawImage = new LLImageRaw(); + if (!mGLTexturep->readBackRaw(-1, mRawImage, false)) + { + mRawImage = nullptr; } } } + void LLViewerFetchedTexture::destroySavedRawImage() { if(mLastReferencedSavedRawImageTime < mKeptSavedRawImageTime) @@ -2997,6 +2821,11 @@ LLImageRaw* LLViewerFetchedTexture::getSavedRawImage() return mSavedRawImage; } +const LLImageRaw* LLViewerFetchedTexture::getSavedRawImage() const +{ + return mSavedRawImage; +} + bool LLViewerFetchedTexture::hasSavedRawImage() const { return mSavedRawImage.notNull(); @@ -3028,7 +2857,7 @@ LLViewerLODTexture::LLViewerLODTexture(const std::string& url, FTType f_type, co void LLViewerLODTexture::init(bool firstinit) { - mTexelsPerImage = 64.f*64.f; + mTexelsPerImage = 64*64; mDiscardVirtualSize = 0.f; mCalculatedDiscardLevel = -1.f; } @@ -3051,6 +2880,8 @@ void LLViewerLODTexture::processTextureStats() LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; updateVirtualSize(); + bool did_downscale = false; + static LLCachedControl<bool> textures_fullres(gSavedSettings,"TextureLoadFullRes", false); { // restrict texture resolution to download based on RenderMaxTextureResolution @@ -3108,10 +2939,7 @@ void LLViewerLODTexture::processTextureStats() mDiscardVirtualSize = mMaxVirtualSize; mCalculatedDiscardLevel = discard_level; } - if (mBoostLevel < LLGLTexture::BOOST_SCULPTED) - { - discard_level *= sDesiredDiscardScale; // scale (default 1.1f) - } + discard_level = floorf(discard_level); F32 min_discard = 0.f; @@ -3137,10 +2965,9 @@ void LLViewerLODTexture::processTextureStats() // S32 current_discard = getDiscardLevel(); - if (mBoostLevel < LLGLTexture::BOOST_AVATAR_BAKED && - current_discard >= 0) + if (mBoostLevel < LLGLTexture::BOOST_AVATAR_BAKED) { - if (current_discard < (mDesiredDiscardLevel-1) && !mForceToSaveRawImage) + if (current_discard < mDesiredDiscardLevel && !mForceToSaveRawImage) { // should scale down scaleDown(); } @@ -3160,9 +2987,6 @@ void LLViewerLODTexture::processTextureStats() mDesiredDiscardLevel = llmin(mDesiredDiscardLevel, (S8)mDesiredSavedRawDiscardLevel); } - // decay max virtual size over time - mMaxVirtualSize *= 0.8f; - // selection manager will immediately reset BOOST_SELECTED but never unsets it // unset it immediately after we consume it if (getBoostLevel() == BOOST_SELECTED) @@ -3171,22 +2995,24 @@ void LLViewerLODTexture::processTextureStats() } } +extern LLGLSLShader gCopyProgram; + bool LLViewerLODTexture::scaleDown() { - if(hasGLTexture() && mCachedRawDiscardLevel > getDiscardLevel()) + if (mGLTexturep.isNull() || !mGLTexturep->getHasGLTexture()) { - switchToCachedImage(); - - LLTexturePipelineTester* tester = (LLTexturePipelineTester*)LLMetricPerformanceTesterBasic::getTester(sTesterName); - if (tester) - { - tester->setStablizingTime(); - } + return false; + } - return true; + if (!mDownScalePending) + { + mDownScalePending = true; + gTextureList.mDownScaleQueue.push(this); } - return false; + + return true; } + //---------------------------------------------------------------------------------------------- //end of LLViewerLODTexture //---------------------------------------------------------------------------------------------- @@ -3658,7 +3484,19 @@ void LLViewerMediaTexture::setPlaying(bool playing) for(std::list< LLFace* >::iterator iter = mMediaFaceList.begin(); iter!= mMediaFaceList.end(); ++iter) { - switchTexture(LLRender::DIFFUSE_MAP, *iter); + LLFace* facep = *iter; + const LLTextureEntry* te = facep->getTextureEntry(); + if (te->getGLTFMaterial()) + { + // PBR material, switch emissive and basecolor + switchTexture(LLRender::EMISSIVE_MAP, *iter); + switchTexture(LLRender::BASECOLOR_MAP, *iter); + } + else + { + // blinn-phong material, switch diffuse map only + switchTexture(LLRender::DIFFUSE_MAP, *iter); + } } } else //stop playing this media @@ -4026,8 +3864,8 @@ LLMetricPerformanceTesterWithSession::LLTestSession* LLTexturePipelineTester::lo } //time - F32 start_time = (*log)[label]["StartFetchingTime"].asReal(); - F32 cur_time = (*log)[label]["Time"].asReal(); + F32 start_time = (F32)(*log)[label]["StartFetchingTime"].asReal(); + F32 cur_time = (F32)(*log)[label]["Time"].asReal(); if(start_time - start_fetching_time > F_ALMOST_ZERO) //fetching has paused for a while { sessionp->mTotalGrayTime += total_gray_time; @@ -4043,13 +3881,13 @@ LLMetricPerformanceTesterWithSession::LLTestSession* LLTexturePipelineTester::lo } else { - total_gray_time = (*log)[label]["TotalGrayTime"].asReal(); - total_stablizing_time = (*log)[label]["TotalStablizingTime"].asReal(); + total_gray_time = (F32)(*log)[label]["TotalGrayTime"].asReal(); + total_stablizing_time = (F32)(*log)[label]["TotalStablizingTime"].asReal(); - total_loading_sculpties_time = (*log)[label]["EndTimeLoadingSculpties"].asReal() - (*log)[label]["StartTimeLoadingSculpties"].asReal(); + total_loading_sculpties_time = (F32)(*log)[label]["EndTimeLoadingSculpties"].asReal() - (F32)(*log)[label]["StartTimeLoadingSculpties"].asReal(); if(start_fetching_sculpties_time < 0.f && total_loading_sculpties_time > 0.f) { - start_fetching_sculpties_time = (*log)[label]["StartTimeLoadingSculpties"].asReal(); + start_fetching_sculpties_time = (F32)(*log)[label]["StartTimeLoadingSculpties"].asReal(); } } @@ -4065,7 +3903,7 @@ LLMetricPerformanceTesterWithSession::LLTestSession* LLTexturePipelineTester::lo sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAverageBytesUsedForLargeImagePerSecond += (*log)[label]["TotalBytesBoundForLargeImage"].asInteger(); sessionp->mInstantPerformanceList[sessionp->mInstantPerformanceListCounter].mAveragePercentageBytesUsedPerSecond += - (*log)[label]["PercentageBytesBound"].asReal(); + (F32)(*log)[label]["PercentageBytesBound"].asReal(); frame_count++; if(cur_time - last_time >= 1.0f) { diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index dc9182bf1b..ada818c220 100644 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -37,13 +37,11 @@ #include "llmetricperformancetester.h" #include "httpcommon.h" #include "workqueue.h" +#include "gltf/common.h" #include <map> #include <list> -extern const S32Megabytes gMinVideoRam; -extern const S32Megabytes gMaxVideoRam; - class LLFace; class LLImageGL ; class LLImageRaw; @@ -102,7 +100,6 @@ public: DYNAMIC_TEXTURE, FETCHED_TEXTURE, LOD_TEXTURE, - ATLAS_TEXTURE, INVALID_TEXTURE_TYPE }; @@ -117,6 +114,7 @@ protected: public: static void initClass(); static void updateClass(); + static bool isSystemMemoryLow(); LLViewerTexture(bool usemipmaps = true); LLViewerTexture(const LLUUID& id, bool usemipmaps) ; @@ -165,8 +163,6 @@ public: S32 getNumVolumes(U32 channel) const; const ll_volume_list_t* getVolumeList(U32 channel) const { return &mVolumeList[channel]; } - - virtual void setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) ; bool isLargeImage() ; void setParcelMedia(LLViewerMediaTexture* media) {mParcelMedia = media;} @@ -174,6 +170,15 @@ public: LLViewerMediaTexture* getParcelMedia() const { return mParcelMedia;} /*virtual*/ void updateBindStatsForTester() ; + + struct MaterialEntry + { + S32 mIndex = LL::GLTF::INVALID_INDEX; + std::shared_ptr<LL::GLTF::Asset> mAsset; + }; + typedef std::vector<MaterialEntry> material_list_t; + material_list_t mMaterialList; // reverse pointer pointing to LL::GLTF::Materials using this image as texture + protected: void cleanup() ; void init(bool firstinit) ; @@ -184,8 +189,6 @@ private: friend class LLBumpImageList; friend class LLUIImageList; - virtual void switchToCachedImage(); - protected: friend class LLViewerTextureList; LLUUID mID; @@ -217,7 +220,6 @@ public: static S32 sAuxCount; static LLFrameTimer sEvaluationTimer; static F32 sDesiredDiscardBias; - static F32 sDesiredDiscardScale; static S32 sMaxSculptRez ; static U32 sMinLargeImageSize ; static U32 sMaxSmallImageSize ; @@ -370,7 +372,6 @@ public: U32 getFetchPriority() const { return mFetchPriority ;} F32 getDownloadProgress() const {return mDownloadProgress ;} - LLImageRaw* reloadRawImage(S8 discard_level) ; void destroyRawImage(); bool needsToSaveRawImage(); @@ -389,17 +390,20 @@ public: bool isForSculptOnly() const; //raw image management - void checkCachedRawSculptImage() ; LLImageRaw* getRawImage()const { return mRawImage ;} S32 getRawImageLevel() const {return mRawDiscardLevel;} - LLImageRaw* getCachedRawImage() const { return mCachedRawImage ;} - S32 getCachedRawImageLevel() const {return mCachedRawDiscardLevel;} - bool isCachedRawImageReady() const {return mCachedRawImageReady ;} bool isRawImageValid()const { return mIsRawImageValid ; } void forceToSaveRawImage(S32 desired_discard = 0, F32 kept_time = 0.f) ; - /*virtual*/ void setCachedRawImage(S32 discard_level, LLImageRaw* imageraw) override; + + // readback the raw image from OpenGL if mRawImage is not valid + void readbackRawImage(); + void destroySavedRawImage() ; LLImageRaw* getSavedRawImage() ; + S32 getSavedRawImageLevel() const {return mSavedRawDiscardLevel; } + + const LLImageRaw* getSavedRawImage() const; + const LLImageRaw* getAuxRawImage() const { return mAuxRawImage; } bool hasSavedRawImage() const ; F32 getElapsedLastReferencedSavedRawImageTime() const ; bool isFullyLoaded() const; @@ -415,8 +419,10 @@ public: /*virtual*/bool isActiveFetching() override; //is actively in fetching by the fetching pipeline. + bool mCreatePending = false; // if true, this is in gTextureList.mCreateTextureList + mutable bool mDownScalePending = false; // if true, this is in gTextureList.mDownScaleQueue + protected: - /*virtual*/ void switchToCachedImage() override; S32 getCurrentDiscardLevelForFetching() ; void forceToRefetchTexture(S32 desired_discard = 0, F32 kept_time = 60.f); @@ -425,12 +431,6 @@ private: void cleanup() ; void saveRawImage() ; - void setCachedRawImage() ; - - //for atlas - void resetFaceAtlas() ; - void invalidateAtlas(bool rebuild_geom) ; - bool insertToAtlas() ; private: bool mFullyLoaded; @@ -497,11 +497,6 @@ protected: F32 mLastReferencedSavedRawImageTime ; F32 mKeptSavedRawImageTime ; - //a small version of the copy of the raw image (<= 64 * 64) - LLPointer<LLImageRaw> mCachedRawImage; - S32 mCachedRawDiscardLevel; - bool mCachedRawImageReady; //the rez of the mCachedRawImage reaches the upper limit. - LLHost mTargetHost; // if invalid, just request from agent's simulator // Timers @@ -547,9 +542,10 @@ public: /*virtual*/ void processTextureStats(); bool isUpdateFrozen() ; + bool scaleDown(); + private: void init(bool firstinit) ; - bool scaleDown() ; private: F32 mDiscardVirtualSize; // Virtual size used to calculate desired discard diff --git a/indra/newview/llviewertextureanim.cpp b/indra/newview/llviewertextureanim.cpp index 238e6830ea..d64026d8a3 100644 --- a/indra/newview/llviewertextureanim.cpp +++ b/indra/newview/llviewertextureanim.cpp @@ -217,7 +217,7 @@ S32 LLViewerTextureAnim::animateTextures(F32 &off_s, F32 &off_t, result |= SCALE; mScaleS = scale_s = 1.f/mSizeX; mScaleT = scale_t = 1.f/mSizeY; - x_frame = fmod(frame_counter, mSizeX); + x_frame = fmodf(frame_counter, mSizeX); y_frame = (S32)(frame_counter / mSizeX); x_pos = x_frame * scale_s; y_pos = y_frame * scale_t; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index b90c1868fc..d31c53d000 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -70,6 +70,8 @@ S32 LLViewerTextureList::sNumImages = 0; LLViewerTextureList gTextureList; +extern LLGLSLShader gCopyProgram; + ETexListType get_element_type(S32 priority) { return (priority == LLViewerFetchedTexture::BOOST_ICON || priority == LLViewerFetchedTexture::BOOST_THUMBNAIL) ? TEX_LIST_SCALE : TEX_LIST_STANDARD; @@ -296,7 +298,7 @@ void LLViewerTextureList::shutdown() // Write out list of currently loaded textures for precaching on startup typedef std::set<std::pair<S32,LLViewerFetchedTexture*> > image_area_list_t; image_area_list_t image_area_list; - for (image_priority_list_t::iterator iter = mImageList.begin(); + for (image_list_t::iterator iter = mImageList.begin(); iter != mImageList.end(); ++iter) { LLViewerFetchedTexture* image = *iter; @@ -352,8 +354,11 @@ void LLViewerTextureList::shutdown() mCallbackList.clear(); // Flush all of the references - mLoadingStreamList.clear(); - mCreateTextureList.clear(); + while (!mCreateTextureList.empty()) + { + mCreateTextureList.front()->mCreatePending = false; + mCreateTextureList.pop(); + } mFastCacheList.clear(); mUUIDMap.clear(); @@ -367,7 +372,7 @@ void LLViewerTextureList::dump() { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; LL_INFOS() << "LLViewerTextureList::dump()" << LL_ENDL; - for (image_priority_list_t::iterator it = mImageList.begin(); it != mImageList.end(); ++it) + for (image_list_t::iterator it = mImageList.begin(); it != mImageList.end(); ++it) { LLViewerFetchedTexture* image = *it; @@ -381,15 +386,9 @@ void LLViewerTextureList::dump() } } -void LLViewerTextureList::destroyGL(bool save_state) -{ - LLImageGL::destroyGL(save_state); -} - -void LLViewerTextureList::restoreGL() +void LLViewerTextureList::destroyGL() { - llassert_always(mInitialized) ; - LLImageGL::restoreGL(); + LLImageGL::destroyGL(); } /* Vertical tab container button image IDs @@ -834,7 +833,7 @@ void LLViewerTextureList::updateImages(F32 max_time) } cleared = false; - LLAppViewer::getTextureFetch()->setTextureBandwidth(LLTrace::get_frame_recording().getPeriodMeanPerSec(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED).value()); + LLAppViewer::getTextureFetch()->setTextureBandwidth((F32)LLTrace::get_frame_recording().getPeriodMeanPerSec(LLStatViewer::TEXTURE_NETWORK_DATA_RECEIVED).value()); { using namespace LLStatViewer; @@ -895,7 +894,7 @@ void LLViewerTextureList::clearFetchingRequests() LLAppViewer::getTextureFetch()->deleteAllRequests(); - for (image_priority_list_t::iterator iter = mImageList.begin(); + for (image_list_t::iterator iter = mImageList.begin(); iter != mImageList.end(); ++iter) { LLViewerFetchedTexture* imagep = *iter; @@ -903,14 +902,6 @@ void LLViewerTextureList::clearFetchingRequests() } } -static void touch_texture(LLViewerFetchedTexture* tex, F32 vsize) -{ - if (tex) - { - tex->addTextureStats(vsize); - } -} - extern bool gCubeSnapshot; void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imagep) @@ -927,60 +918,69 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag static LLCachedControl<F32> texture_scale_min(gSavedSettings, "TextureScaleMinAreaFactor", 0.04f); static LLCachedControl<F32> texture_scale_max(gSavedSettings, "TextureScaleMaxAreaFactor", 25.f); - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE + if (imagep->getType() == LLViewerTexture::LOD_TEXTURE && imagep->getBoostLevel() == LLViewerTexture::BOOST_NONE) + { // reset max virtual size for unboosted LOD_TEXTURES + // this is an alternative to decaying mMaxVirtualSize over time + // that keeps textures from continously downrezzing and uprezzing in the background + imagep->mMaxVirtualSize = 0.f; + } + + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + bool onFace = false; + for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i) { - for (U32 i = 0; i < LLRender::NUM_TEXTURE_CHANNELS; ++i) + for (S32 fi = 0; fi < imagep->getNumFaces(i); ++fi) { - for (S32 fi = 0; fi < imagep->getNumFaces(i); ++fi) + LLFace* face = (*(imagep->getFaceList(i)))[fi]; + + if (face && face->getViewerObject()) { - LLFace* face = (*(imagep->getFaceList(i)))[fi]; + onFace = true; + F32 radius; + F32 cos_angle_to_view_dir; + bool in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius); + static LLCachedControl<F32> bias_unimportant_threshold(gSavedSettings, "TextureBiasUnimportantFactor", 0.25f); + F32 vsize = face->getPixelArea(); + + // Scale desired texture resolution higher or lower depending on texture scale + // + // Minimum usage examples: a 1024x1024 texture with aplhabet, runing string + // shows one letter at a time + // + // Maximum usage examples: huge chunk of terrain repeats texture + const LLTextureEntry* te = face->getTextureEntry(); + F32 min_scale = te ? llmin(fabsf(te->getScaleS()), fabsf(te->getScaleT())) : 1.f; + min_scale = llclamp(min_scale * min_scale, texture_scale_min(), texture_scale_max()); + vsize /= min_scale; + + // if bias is > 2, apply to on-screen textures as well + bool apply_bias = LLViewerTexture::sDesiredDiscardBias > 2.f; + + // apply bias to off screen objects or objects that are small on screen all the time + if (!in_frustum || !face->getDrawable()->isVisible() || face->getImportanceToCamera() < bias_unimportant_threshold) + { // further reduce by discard bias when off screen or occluded + apply_bias = true; + } - if (face && face->getViewerObject() && face->getTextureEntry()) + if (apply_bias) { - F32 vsize = face->getPixelArea(); - - // Scale desired texture resolution higher or lower depending on texture scale - // - // Minimum usage examples: a 1024x1024 texture with aplhabet, runing string - // shows one letter at a time - // - // Maximum usage examples: huge chunk of terrain repeats texture - const LLTextureEntry* te = face->getTextureEntry(); - F32 min_scale = te ? llmin(fabsf(te->getScaleS()), fabsf(te->getScaleT())) : 1.f; - min_scale = llclamp(min_scale*min_scale, texture_scale_min(), texture_scale_max()); - - vsize /= min_scale; - vsize /= LLViewerTexture::sDesiredDiscardBias; - vsize /= llmax(1.f, (LLViewerTexture::sDesiredDiscardBias-1.f) * (1.f + face->getDrawable()->mDistanceWRTCamera * bias_distance_scale)); - - F32 radius; - F32 cos_angle_to_view_dir; - bool in_frustum = face->calcPixelArea(cos_angle_to_view_dir, radius); - if (!in_frustum || !face->getDrawable()->isVisible()) - { // further reduce by discard bias when off screen or occluded - vsize /= LLViewerTexture::sDesiredDiscardBias; - } - // if a GLTF material is present, ignore that face - // as far as this texture stats go, but update the GLTF material - // stats - LLFetchedGLTFMaterial* mat = te ? (LLFetchedGLTFMaterial*)te->getGLTFRenderMaterial() : nullptr; - llassert(mat == nullptr || dynamic_cast<LLFetchedGLTFMaterial*>(te->getGLTFRenderMaterial()) != nullptr); - if (mat) - { - touch_texture(mat->mBaseColorTexture, vsize); - touch_texture(mat->mNormalTexture, vsize); - touch_texture(mat->mMetallicRoughnessTexture, vsize); - touch_texture(mat->mEmissiveTexture, vsize); - } - else - { - imagep->addTextureStats(vsize); - } + F32 bias = powf(4, LLViewerTexture::sDesiredDiscardBias - 1.f); + bias = (F32)llround(bias); + vsize /= bias; } + + imagep->addTextureStats(vsize); } } } + // make sure to addTextureStats for any spotlights that are using this texture + for (S32 vi = 0; vi < imagep->getNumVolumes(LLRender::LIGHT_TEX); ++vi) + { + LLVOVolume* volume = (*imagep->getVolumeList(LLRender::LIGHT_TEX))[vi]; + volume->updateSpotLightPriority(); + } + //imagep->setDebugText(llformat("%.3f - %d", sqrtf(imagep->getMaxVirtualSize()), imagep->getBoostLevel())); F32 lazy_flush_timeout = 30.f; // stop decoding @@ -1033,7 +1033,8 @@ void LLViewerTextureList::updateImageDecodePriority(LLViewerFetchedTexture* imag imagep->getLastReferencedTimer()->reset(); //reset texture state. - imagep->setInactive(); + if(!onFace) + imagep->setInactive(); } } @@ -1074,22 +1075,65 @@ F32 LLViewerTextureList::updateImagesCreateTextures(F32 max_time) // LLTimer create_timer; - image_list_t::iterator enditer = mCreateTextureList.begin(); - for (image_list_t::iterator iter = mCreateTextureList.begin(); - iter != mCreateTextureList.end();) + + if (!mDownScaleQueue.empty() && gPipeline.mDownResMap.isComplete()) { - image_list_t::iterator curiter = iter++; - enditer = iter; - LLViewerFetchedTexture *imagep = *curiter; + // just in case we downres textures, bind downresmap and copy program + gPipeline.mDownResMap.bindTarget(); + gCopyProgram.bind(); + gPipeline.mScreenTriangleVB->setBuffer(); + + // give time to downscaling first -- if mDownScaleQueue is not empty, we're running out of memory and need + // to free up memory by discarding off screen textures quickly + + // do at least 5 and make sure we don't get too far behind even if it violates + // the time limit. If we don't downscale quickly the viewer will hit swap and may + // freeze. + S32 min_count = (S32)mCreateTextureList.size() / 20 + 5; + + while (!mDownScaleQueue.empty()) + { + LLViewerFetchedTexture* image = mDownScaleQueue.front(); + llassert(image->mDownScalePending); + + LLImageGL* img = image->getGLTexture(); + if (img && img->getHasGLTexture()) + { + img->scaleDown(image->getDesiredDiscardLevel()); + } + + image->mDownScalePending = false; + mDownScaleQueue.pop(); + + if (create_timer.getElapsedTimeF32() > max_time && --min_count <= 0) + { + break; + } + } + + gCopyProgram.unbind(); + gPipeline.mDownResMap.flush(); + } + + // do at least 5 and make sure we don't get too far behind even if it violates + // the time limit. Textures pending creation have a copy of their texture data + // in system memory, so we don't want to let them pile up. + S32 min_count = (S32) mCreateTextureList.size() / 20 + 5; + + while (!mCreateTextureList.empty()) + { + LLViewerFetchedTexture *imagep = mCreateTextureList.front(); + llassert(imagep->mCreatePending); imagep->createTexture(); imagep->postCreateTexture(); + imagep->mCreatePending = false; + mCreateTextureList.pop(); - if (create_timer.getElapsedTimeF32() > max_time) + if (create_timer.getElapsedTimeF32() > max_time && --min_count <= 0) { break; } } - mCreateTextureList.erase(mCreateTextureList.begin(), enditer); return create_timer.getElapsedTimeF32(); } @@ -1132,7 +1176,10 @@ void LLViewerTextureList::forceImmediateUpdate(LLViewerFetchedTexture* imagep) removeImageFromList(imagep); } - imagep->processTextureStats(); + if (!gCubeSnapshot) + { // never call processTextureStats in a cube snapshot + imagep->processTextureStats(); + } imagep->sMaxVirtualSize = LLViewerFetchedTexture::sMaxVirtualSize; addImageToList(imagep); @@ -1142,6 +1189,7 @@ void LLViewerTextureList::forceImmediateUpdate(LLViewerFetchedTexture* imagep) F32 LLViewerTextureList::updateImagesFetchTextures(F32 max_time) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + typedef std::vector<LLPointer<LLViewerFetchedTexture> > entries_list_t; entries_list_t entries; @@ -1208,7 +1256,7 @@ void LLViewerTextureList::updateImagesUpdateStats() LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; if (mForceResetTextureStats) { - for (image_priority_list_t::iterator iter = mImageList.begin(); + for (image_list_t::iterator iter = mImageList.begin(); iter != mImageList.end(); ) { LLViewerFetchedTexture* imagep = *iter++; @@ -1228,7 +1276,7 @@ void LLViewerTextureList::decodeAllImages(F32 max_time) // Update texture stats and priorities std::vector<LLPointer<LLViewerFetchedTexture> > image_list; - for (image_priority_list_t::iterator iter = mImageList.begin(); + for (image_list_t::iterator iter = mImageList.begin(); iter != mImageList.end(); ) { LLViewerFetchedTexture* imagep = *iter++; @@ -1248,7 +1296,7 @@ void LLViewerTextureList::decodeAllImages(F32 max_time) image_list.clear(); // Update fetch (decode) - for (image_priority_list_t::iterator iter = mImageList.begin(); + for (image_list_t::iterator iter = mImageList.begin(); iter != mImageList.end(); ) { LLViewerFetchedTexture* imagep = *iter++; @@ -1275,7 +1323,7 @@ void LLViewerTextureList::decodeAllImages(F32 max_time) } } // Update fetch again - for (image_priority_list_t::iterator iter = mImageList.begin(); + for (image_list_t::iterator iter = mImageList.begin(); iter != mImageList.end(); ) { LLViewerFetchedTexture* imagep = *iter++; diff --git a/indra/newview/llviewertexturelist.h b/indra/newview/llviewertexturelist.h index e4ebb7b0e8..075f6ae915 100644 --- a/indra/newview/llviewertexturelist.h +++ b/indra/newview/llviewertexturelist.h @@ -33,7 +33,7 @@ #include "llviewertexture.h" #include "llui.h" #include <list> -#include <set> +#include <unordered_set> #include "lluiimage.h" const U32 LL_IMAGE_REZ_LOSSLESS_CUTOFF = 128; @@ -115,8 +115,7 @@ public: void init(); void shutdown(); void dump(); - void destroyGL(bool save_state = true); - void restoreGL(); + void destroyGL(); bool isInitialized() const {return mInitialized;} void findTexturesByID(const LLUUID &image_id, std::vector<LLViewerFetchedTexture*> &output); @@ -145,12 +144,13 @@ public: void clearFetchingRequests(); void setDebugFetching(LLViewerFetchedTexture* tex, S32 debug_level); -private: // do some book keeping on the specified texture // - updates decode priority // - updates desired discard level // - cleans up textures that haven't been referenced in awhile void updateImageDecodePriority(LLViewerFetchedTexture* imagep); + +private: F32 updateImagesCreateTextures(F32 max_time); F32 updateImagesFetchTextures(F32 max_time); void updateImagesUpdateStats(); @@ -188,7 +188,7 @@ private: LLViewerTexture::EBoostLevel boost_priority = LLGLTexture::BOOST_NONE, // Get the requested level immediately upon creation. S8 texture_type = LLViewerTexture::FETCHED_TEXTURE, LLGLint internal_format = 0, - LLGLenum primary_format = 0, + LLGLenum primary_format = 0, const LLUUID& force_id = LLUUID::null ); @@ -211,9 +211,15 @@ private: { return getImage(image_id, f_type, true, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, host); } public: - typedef std::set<LLPointer<LLViewerFetchedTexture> > image_list_t; - image_list_t mLoadingStreamList; - image_list_t mCreateTextureList; + typedef std::unordered_set<LLPointer<LLViewerFetchedTexture> > image_list_t; + typedef std::queue<LLPointer<LLViewerFetchedTexture> > image_queue_t; + + // images that have been loaded but are waiting to be uploaded to GL + image_queue_t mCreateTextureList; + + // images that must be downscaled quickly so we don't run out of memory + image_queue_t mDownScaleQueue; + image_list_t mCallbackList; image_list_t mFastCacheList; @@ -222,16 +228,19 @@ public: bool mForceResetTextureStats; + // to make "for (auto& imagep : gTextureList)" work + const image_list_t::const_iterator begin() const { return mImageList.cbegin(); } + const image_list_t::const_iterator end() const { return mImageList.cend(); } + private: typedef std::map< LLTextureKey, LLPointer<LLViewerFetchedTexture> > uuid_map_t; uuid_map_t mUUIDMap; LLTextureKey mLastUpdateKey; - typedef std::set < LLPointer<LLViewerFetchedTexture> > image_priority_list_t; - image_priority_list_t mImageList; + image_list_t mImageList; // simply holds on to LLViewerFetchedTexture references to stop them from being purged too soon - std::set<LLPointer<LLViewerFetchedTexture> > mImagePreloads; + std::unordered_set<LLPointer<LLViewerFetchedTexture> > mImagePreloads; bool mInitialized ; LLFrameTimer mForceDecodeTimer; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index cfa12bf178..9dc12c4856 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -805,8 +805,8 @@ public: LLCoordGL coord = gViewerWindow->getCurrentMouse(); // Convert x,y to raw pixel coords - S32 x_raw = llround(coord.mX * gViewerWindow->getWindowWidthRaw() / (F32) gViewerWindow->getWindowWidthScaled()); - S32 y_raw = llround(coord.mY * gViewerWindow->getWindowHeightRaw() / (F32) gViewerWindow->getWindowHeightScaled()); + S32 x_raw = (S32)llround(coord.mX * gViewerWindow->getWindowWidthRaw() / (F32) gViewerWindow->getWindowWidthScaled()); + S32 y_raw = (S32)llround(coord.mY * gViewerWindow->getWindowHeightRaw() / (F32) gViewerWindow->getWindowHeightScaled()); glReadPixels(x_raw, y_raw, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, color); addText(xpos, ypos, llformat("Pixel <%1d, %1d> R:%1d G:%1d B:%1d A:%1d", x_raw, y_raw, color[0], color[1], color[2], color[3])); @@ -1271,7 +1271,7 @@ LLWindowCallbacks::DragNDropResult LLViewerWindow::handleDragNDrop( LLWindow *wi LLTextureEntry *te = obj->getTE(object_face); // can modify URL if we can modify the object or we have navigate permissions - bool allow_modify_url = obj->permModify() || obj->hasMediaPermission( te->getMediaData(), LLVOVolume::MEDIA_PERM_INTERACT ); + bool allow_modify_url = obj->permModify() || (te && obj->hasMediaPermission( te->getMediaData(), LLVOVolume::MEDIA_PERM_INTERACT )); if (te && allow_modify_url ) { @@ -1827,10 +1827,8 @@ LLViewerWindow::LLViewerWindow(const Params& p) mToolStored( NULL ), mHideCursorPermanent( false ), mCursorHidden(false), - mIgnoreActivate( false ), mResDirty(false), mStatesDirty(false), - mCurrResolutionIndex(0), mProgressView(NULL) { // gKeyboard is still NULL, so it doesn't do LLWindowListener any good to @@ -2402,7 +2400,7 @@ void LLViewerWindow::shutdownGL() LLSelectMgr::getInstance()->cleanup(); LL_INFOS() << "Stopping GL during shutdown" << LL_ENDL; - stopGL(false); + stopGL(); stop_glerror(); gGL.shutdown(); @@ -2677,7 +2675,7 @@ void LLViewerWindow::draw() //S32 screen_x, screen_y; - if (!gSavedSettings.getBOOL("RenderUIBuffer")) + if (!LLPipeline::RenderUIBuffer) { LLView::sDirtyRect = getWindowRectScaled(); } @@ -4481,8 +4479,8 @@ LLVector3 LLViewerWindow::mouseDirectionGlobal(const S32 x, const S32 y) const F32 fov = LLViewerCamera::getInstance()->getView(); // find world view center in scaled ui coordinates - F32 center_x = getWorldViewRectScaled().getCenterX(); - F32 center_y = getWorldViewRectScaled().getCenterY(); + F32 center_x = (F32)getWorldViewRectScaled().getCenterX(); + F32 center_y = (F32)getWorldViewRectScaled().getCenterY(); // calculate pixel distance to screen F32 distance = ((F32)getWorldViewHeightScaled() * 0.5f) / (tan(fov / 2.f)); @@ -4507,8 +4505,8 @@ LLVector3 LLViewerWindow::mousePointHUD(const S32 x, const S32 y) const S32 height = getWorldViewHeightScaled(); // find world view center - F32 center_x = getWorldViewRectScaled().getCenterX(); - F32 center_y = getWorldViewRectScaled().getCenterY(); + F32 center_x = (F32)getWorldViewRectScaled().getCenterX(); + F32 center_y = (F32)getWorldViewRectScaled().getCenterY(); // remap with uniform scale (1/height) so that top is -0.5, bottom is +0.5 F32 hud_x = -((F32)x - center_x) / height; @@ -4530,8 +4528,8 @@ LLVector3 LLViewerWindow::mouseDirectionCamera(const S32 x, const S32 y) const S32 width = getWorldViewWidthScaled(); // find world view center - F32 center_x = getWorldViewRectScaled().getCenterX(); - F32 center_y = getWorldViewRectScaled().getCenterY(); + F32 center_x = (F32)getWorldViewRectScaled().getCenterX(); + F32 center_y = (F32)getWorldViewRectScaled().getCenterY(); // calculate click point relative to middle of screen F32 click_x = (((F32)x - center_x) / (F32)width) * fov_width * -1.f; @@ -4779,7 +4777,7 @@ void LLViewerWindow::saveImageLocal(LLImageFormatted *image, const snapshot_save args["NEED_MEMORY"] = needM_bytes_string; std::string freeM_bytes_string; - LLResMgr::getInstance()->getIntegerString(freeM_bytes_string, (b_space.free) >> 10); + LLResMgr::getInstance()->getIntegerString(freeM_bytes_string, (S32)(b_space.free >> 10)); args["FREE_MEMORY"] = freeM_bytes_string; LLNotificationsUtil::add("SnapshotToComputerFailed", args); @@ -5625,7 +5623,7 @@ void LLViewerWindow::setup3DRender() void LLViewerWindow::setup3DViewport(S32 x_offset, S32 y_offset) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_UI + LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; gGLViewport[0] = mWorldViewRectRaw.mLeft + x_offset; gGLViewport[1] = mWorldViewRectRaw.mBottom + y_offset; gGLViewport[2] = mWorldViewRectRaw.getWidth(); @@ -5715,7 +5713,7 @@ void LLViewerWindow::dumpState() << LL_ENDL; } -void LLViewerWindow::stopGL(bool save_state) +void LLViewerWindow::stopGL() { //Note: --bao //if not necessary, do not change the order of the function calls in this function. @@ -5761,7 +5759,7 @@ void LLViewerWindow::stopGL(bool save_state) gPostProcess->invalidate(); } - gTextureList.destroyGL(save_state); + gTextureList.destroyGL(); stop_glerror(); gGLManager.mIsDisabled = true; @@ -5778,6 +5776,14 @@ void LLViewerWindow::stopGL(bool save_state) void LLViewerWindow::restoreGL(const std::string& progress_message) { + llassert(false); + // DEPRECATED -- this is left over from when we would completely destroy and restore a GL context + // when switching from windowed to fullscreen. None of this machinery has been exercised in years + // and is unreliable. If we ever *do* have another use case where completely unloading and reloading + // everthing is necessary, requiring a viewer restart for that operation is a fine thing to do. + // -- davep + + //Note: --bao //if not necessary, do not change the order of the function calls in this function. //if change something, make sure it will not break anything. @@ -5790,8 +5796,6 @@ void LLViewerWindow::restoreGL(const std::string& progress_message) initGLDefaults(); LLGLState::restoreGL(); - gTextureList.restoreGL(); - // for future support of non-square pixels, and fonts that are properly stretched //LLFontGL::destroyDefaultFonts(); initFonts(); @@ -5867,122 +5871,6 @@ void LLViewerWindow::checkSettings() } } -void LLViewerWindow::restartDisplay(bool show_progress_bar) -{ - LL_INFOS() << "Restaring GL" << LL_ENDL; - stopGL(); - if (show_progress_bar) - { - restoreGL(LLTrans::getString("ProgressChangingResolution")); - } - else - { - restoreGL(); - } -} - -bool LLViewerWindow::changeDisplaySettings(LLCoordScreen size, bool enable_vsync, bool show_progress_bar) -{ - //bool was_maximized = gSavedSettings.getBOOL("WindowMaximized"); - - //gResizeScreenTexture = true; - - - //U32 fsaa = gSavedSettings.getU32("RenderFSAASamples"); - //U32 old_fsaa = mWindow->getFSAASamples(); - - // if not maximized, use the request size - if (!mWindow->getMaximized()) - { - mWindow->setSize(size); - } - - //if (fsaa == old_fsaa) - { - return true; - } - -/* - - // Close floaters that don't handle settings change - LLFloaterReg::hideInstance("snapshot"); - - bool result_first_try = false; - bool result_second_try = false; - - LLFocusableElement* keyboard_focus = gFocusMgr.getKeyboardFocus(); - send_agent_pause(); - LL_INFOS() << "Stopping GL during changeDisplaySettings" << LL_ENDL; - stopGL(); - mIgnoreActivate = true; - LLCoordScreen old_size; - LLCoordScreen old_pos; - mWindow->getSize(&old_size); - - //mWindow->setFSAASamples(fsaa); - - result_first_try = mWindow->switchContext(false, size, disable_vsync); - if (!result_first_try) - { - // try to switch back - //mWindow->setFSAASamples(old_fsaa); - result_second_try = mWindow->switchContext(false, old_size, disable_vsync); - - if (!result_second_try) - { - // we are stuck...try once again with a minimal resolution? - send_agent_resume(); - mIgnoreActivate = false; - return false; - } - } - send_agent_resume(); - - LL_INFOS() << "Restoring GL during resolution change" << LL_ENDL; - if (show_progress_bar) - { - restoreGL(LLTrans::getString("ProgressChangingResolution")); - } - else - { - restoreGL(); - } - - if (!result_first_try) - { - LLSD args; - args["RESX"] = llformat("%d",size.mX); - args["RESY"] = llformat("%d",size.mY); - LLNotificationsUtil::add("ResolutionSwitchFail", args); - size = old_size; // for reshape below - } - - bool success = result_first_try || result_second_try; - - if (success) - { - // maximize window if was maximized, else reposition - if (was_maximized) - { - mWindow->maximize(); - } - else - { - S32 windowX = gSavedSettings.getS32("WindowX"); - S32 windowY = gSavedSettings.getS32("WindowY"); - - mWindow->setPosition(LLCoordScreen ( windowX, windowY ) ); - } - } - - mIgnoreActivate = false; - gFocusMgr.setKeyboardFocus(keyboard_focus); - - return success; - - */ -} - F32 LLViewerWindow::getWorldViewAspectRatio() const { F32 world_aspect = (F32)mWorldViewRectRaw.getWidth() / (F32)mWorldViewRectRaw.getHeight(); diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 4a6b901b33..ba59ce4141 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -455,9 +455,7 @@ public: // handle shutting down GL and bringing it back up void requestResolutionUpdate(); void checkSettings(); - void restartDisplay(bool show_progress_bar); - bool changeDisplaySettings(LLCoordScreen size, bool enable_vsync, bool show_progress_bar); - bool getIgnoreDestroyWindow() { return mIgnoreActivate; } + F32 getWorldViewAspectRatio() const; const LLVector2& getDisplayScale() const { return mDisplayScale; } void calcDisplayScale(); @@ -471,7 +469,7 @@ private: void switchToolByMask(MASK mask); void destroyWindow(); void drawMouselookInstructions(); - void stopGL(bool save_state = true); + void stopGL(); void restoreGL(const std::string& progress_message = LLStringUtil::null); void initFonts(F32 zoom_factor = 1.f); void schedulePick(LLPickInfo& pick_info); @@ -528,8 +526,6 @@ private: std::string mOverlayTitle; // Used for special titles such as "Second Life - Special E3 2003 Beta" - bool mIgnoreActivate; - std::string mInitAlert; // Window / GL initialization requires an alert LLHandle<LLView> mWorldViewPlaceholder; // widget that spans the portion of screen dedicated to rendering the 3d world @@ -542,7 +538,6 @@ private: bool mResDirty; bool mStatesDirty; - U32 mCurrResolutionIndex; std::unique_ptr<LLWindowListener> mWindowListener; std::unique_ptr<LLViewerWindowListener> mViewerWindowListener; diff --git a/indra/newview/llvlcomposition.cpp b/indra/newview/llvlcomposition.cpp index ba255f2b24..f5f058a080 100644 --- a/indra/newview/llvlcomposition.cpp +++ b/indra/newview/llvlcomposition.cpp @@ -317,7 +317,7 @@ bool LLTerrainMaterials::makeMaterialsReady(bool boost, bool strict) // static bool LLTerrainMaterials::makeTextureReady(LLPointer<LLViewerFetchedTexture>& tex, bool boost) { - llassert(tex); + //llassert(tex); ??? maybe ok ??? if (!tex) { return false; } if (tex->getDiscardLevel() < 0) @@ -571,416 +571,6 @@ bool LLVLComposition::generateComposition() return LLTerrainMaterials::generateMaterials(); } -namespace -{ - void prepare_fallback_image(LLImageRaw* raw_image) - { - raw_image->resize(BASE_SIZE, BASE_SIZE, 4); - raw_image->fill(LLColor4U::white); - } - - // Check if the raw image is loaded for this texture at a discard - // level the minimap can use, and if not then try to get it loaded. - bool prepare_raw_image(LLPointer<LLImageRaw>& raw_image, bool emissive, LLViewerFetchedTexture* tex, bool& delete_raw_post) - { - if (!tex) - { - if (!emissive) - { - prepare_fallback_image(raw_image); - } - else - { - llassert(!raw_image); - raw_image = nullptr; - } - return true; - } - if (raw_image) - { - // Callback already initiated - if (raw_image->getDataSize() > 0) - { - // Callback finished - delete_raw_post = true; - return true; - } - else - { - return false; - } - } - - raw_image = new LLImageRaw(); - - S32 ddiscard = 0; - { - S32 min_dim = llmin(tex->getFullWidth(), tex->getFullHeight()); - while (min_dim > BASE_SIZE && ddiscard < MAX_DISCARD_LEVEL) - { - ddiscard++; - min_dim /= 2; - } - } - - struct PendingImage - { - LLImageRaw* mRawImage; - S32 mDesiredDiscard; - LLUUID mTextureId; - PendingImage(LLImageRaw* raw_image, S32 ddiscard, const LLUUID& texture_id) - : mRawImage(raw_image) - , mDesiredDiscard(ddiscard) - , mTextureId(texture_id) - { - mRawImage->ref(); - } - ~PendingImage() - { - mRawImage->unref(); - } - }; - PendingImage* pending_image = new PendingImage(raw_image, ddiscard, tex->getID()); - - loaded_callback_func cb = [](bool success, LLViewerFetchedTexture * src_vi, LLImageRaw * src, LLImageRaw * src_aux, S32 discard_level, bool is_final, void* userdata) { - PendingImage* pending = (PendingImage*)userdata; - // Owning LLVLComposition still exists - - // Assume mRawImage only used by single LLVLComposition for now - const bool in_use_by_composition = pending->mRawImage->getNumRefs() > 1; - llassert(pending->mRawImage->getNumRefs()); - llassert(pending->mRawImage->getNumRefs() <= 2); - const bool needs_data = !pending->mRawImage->getDataSize(); - if (in_use_by_composition && needs_data) - { - if (success && pending->mDesiredDiscard == discard_level) - { - pending->mRawImage->resize(BASE_SIZE, BASE_SIZE, src->getComponents()); - pending->mRawImage->copyScaled(src); - } - else if (is_final) - { - prepare_fallback_image(pending->mRawImage); - } - } - - if (is_final) { delete pending; } - }; - tex->setLoadedCallback(cb, ddiscard, true, false, pending_image, nullptr); - tex->forceToSaveRawImage(ddiscard); - - return false; - } -}; - -bool LLVLComposition::generateMinimapTileLand(const F32 x, const F32 y, - const F32 width, const F32 height) -{ - LL_PROFILE_ZONE_SCOPED - llassert(mSurfacep); - llassert(x >= 0.f); - llassert(y >= 0.f); - - /////////////////////////// - // - // Generate raw data arrays for surface textures - // - // - - // These have already been validated by generateComposition. - U8* st_data[ASSET_COUNT]; - S32 st_data_size[ASSET_COUNT]; // for debugging - - const bool use_textures = getMaterialType() != LLTerrainMaterials::Type::PBR; - if (use_textures) - { - if (!makeTexturesReady(true, true)) { return false; } - } - else - { - if (!makeMaterialsReady(true, true)) { return false; } - } - - for (S32 i = 0; i < ASSET_COUNT; i++) - { - if (mRawImages[i].isNull()) - { - // Read back a raw image for this discard level, if it exists - LLViewerFetchedTexture* tex; - LLViewerFetchedTexture* tex_emissive; // Can be null - bool has_base_color_factor; - bool has_emissive_factor; - bool has_alpha; - LLColor3 base_color_factor; - LLColor3 emissive_factor; - if (use_textures) - { - tex = mDetailTextures[i]; - tex_emissive = nullptr; - has_base_color_factor = false; - has_emissive_factor = false; - has_alpha = false; - llassert(tex); - } - else - { - LLPointer<LLFetchedGLTFMaterial>& mat = mDetailRenderMaterials[i]; - tex = mat->mBaseColorTexture; - tex_emissive = mat->mEmissiveTexture; - base_color_factor = LLColor3(mat->mBaseColor); - // *HACK: Treat alpha as black - base_color_factor *= (mat->mBaseColor.mV[VW]); - emissive_factor = mat->mEmissiveColor; - has_base_color_factor = (base_color_factor.mV[VX] != 1.f || - base_color_factor.mV[VY] != 1.f || - base_color_factor.mV[VZ] != 1.f); - has_emissive_factor = (emissive_factor.mV[VX] != 1.f || - emissive_factor.mV[VY] != 1.f || - emissive_factor.mV[VZ] != 1.f); - has_alpha = mat->mAlphaMode != LLGLTFMaterial::ALPHA_MODE_OPAQUE; - } - - if (!tex) { tex = LLViewerFetchedTexture::sWhiteImagep; } - - bool delete_raw_post = false; - bool delete_raw_post_emissive = false; - if (!prepare_raw_image(mRawImagesBaseColor[i], false, tex, delete_raw_post)) { return false; } - if (tex_emissive && !prepare_raw_image(mRawImagesEmissive[i], true, tex_emissive, delete_raw_post_emissive)) { return false; } - // tex_emissive can be null, and then will be ignored - - // In the simplest case, the minimap image is just the base color. - // This will be replaced if we need to do any tinting/compositing. - mRawImages[i] = mRawImagesBaseColor[i]; - - // *TODO: This isn't quite right for PBR: - // 1) It does not convert the color images from SRGB to linear - // before mixing (which will always require copying the image). - // 2) It mixes emissive and base color before mixing terrain - // materials, but it should be the other way around - // Long-term, we should consider a method that is more - // maintainable. Shaders, perhaps? Bake shaders to textures? - LLPointer<LLImageRaw> raw_emissive; - if (tex_emissive) - { - raw_emissive = mRawImagesEmissive[i]; - if (has_emissive_factor || - tex_emissive->getWidth(tex_emissive->getRawImageLevel()) != BASE_SIZE || - tex_emissive->getHeight(tex_emissive->getRawImageLevel()) != BASE_SIZE || - tex_emissive->getComponents() != 4) - { - LLPointer<LLImageRaw> newraw_emissive = new LLImageRaw(BASE_SIZE, BASE_SIZE, 4); - // Copy RGB, leave alpha alone (set to opaque by default) - newraw_emissive->copy(mRawImagesEmissive[i]); - if (has_emissive_factor) - { - newraw_emissive->tint(emissive_factor); - } - raw_emissive = newraw_emissive; - } - } - if (has_base_color_factor || - raw_emissive || - has_alpha || - tex->getWidth(tex->getRawImageLevel()) != BASE_SIZE || - tex->getHeight(tex->getRawImageLevel()) != BASE_SIZE || - tex->getComponents() != 3) - { - LLPointer<LLImageRaw> newraw = new LLImageRaw(BASE_SIZE, BASE_SIZE, 3); - if (has_alpha) - { - // Approximate the water underneath terrain alpha with solid water color - newraw->clear( - MAX_WATER_COLOR.mV[VX], - MAX_WATER_COLOR.mV[VY], - MAX_WATER_COLOR.mV[VZ], - 255); - } - newraw->composite(mRawImagesBaseColor[i]); - if (has_base_color_factor) - { - newraw->tint(base_color_factor); - } - // Apply emissive texture - if (raw_emissive) - { - newraw->addEmissive(raw_emissive); - } - - mRawImages[i] = newraw; // deletes old - } - - if (delete_raw_post) - { - tex->destroyRawImage(); - } - if (delete_raw_post_emissive) - { - tex_emissive->destroyRawImage(); - } - - // Remove intermediary image references - mRawImagesBaseColor[i] = nullptr; - mRawImagesEmissive[i] = nullptr; - } - st_data[i] = mRawImages[i]->getData(); - st_data_size[i] = mRawImages[i]->getDataSize(); - } - - /////////////////////////////////////// - // - // Generate and clamp x/y bounding box. - // - // - - S32 x_begin, y_begin, x_end, y_end; - x_begin = (S32)(x * mScaleInv); - y_begin = (S32)(y * mScaleInv); - x_end = ll_round( (x + width) * mScaleInv ); - y_end = ll_round( (y + width) * mScaleInv ); - - if (x_end > mWidth) - { - llassert(false); - x_end = mWidth; - } - if (y_end > mWidth) - { - llassert(false); - y_end = mWidth; - } - - - /////////////////////////////////////////// - // - // Generate target texture information, stride ratios. - // - // - - LLViewerTexture *texturep; - U32 tex_width, tex_height, tex_comps; - U32 tex_stride; - F32 tex_x_scalef, tex_y_scalef; - S32 tex_x_begin, tex_y_begin, tex_x_end, tex_y_end; - F32 tex_x_ratiof, tex_y_ratiof; - - texturep = mSurfacep->getSTexture(); - tex_width = texturep->getWidth(); - tex_height = texturep->getHeight(); - tex_comps = texturep->getComponents(); - tex_stride = tex_width * tex_comps; - - U32 st_comps = 3; - U32 st_width = BASE_SIZE; - U32 st_height = BASE_SIZE; - - if (tex_comps != st_comps) - { - llassert(false); - return false; - } - - tex_x_scalef = (F32)tex_width / (F32)mWidth; - tex_y_scalef = (F32)tex_height / (F32)mWidth; - tex_x_begin = (S32)((F32)x_begin * tex_x_scalef); - tex_y_begin = (S32)((F32)y_begin * tex_y_scalef); - tex_x_end = (S32)((F32)x_end * tex_x_scalef); - tex_y_end = (S32)((F32)y_end * tex_y_scalef); - - tex_x_ratiof = (F32)mWidth*mScale / (F32)tex_width; - tex_y_ratiof = (F32)mWidth*mScale / (F32)tex_height; - - LLPointer<LLImageRaw> raw = new LLImageRaw(tex_width, tex_height, tex_comps); - U8 *rawp = raw->getData(); - - F32 st_x_stride, st_y_stride; - st_x_stride = ((F32)st_width / (F32)mTexScaleX)*((F32)mWidth / (F32)tex_width); - st_y_stride = ((F32)st_height / (F32)mTexScaleY)*((F32)mWidth / (F32)tex_height); - - llassert(st_x_stride > 0.f); - llassert(st_y_stride > 0.f); - //////////////////////////////// - // - // Iterate through the target texture, striding through the - // subtextures and interpolating appropriately. - // - // - - F32 sti, stj; - S32 st_offset; - sti = (tex_x_begin * st_x_stride) - st_width*(llfloor((tex_x_begin * st_x_stride)/st_width)); - stj = (tex_y_begin * st_y_stride) - st_height*(llfloor((tex_y_begin * st_y_stride)/st_height)); - - st_offset = (llfloor(stj * st_width) + llfloor(sti)) * st_comps; - for (S32 j = tex_y_begin; j < tex_y_end; j++) - { - U32 offset = j * tex_stride + tex_x_begin * tex_comps; - sti = (tex_x_begin * st_x_stride) - st_width*((U32)(tex_x_begin * st_x_stride)/st_width); - for (S32 i = tex_x_begin; i < tex_x_end; i++) - { - S32 tex0, tex1; - F32 composition = getValueScaled(i*tex_x_ratiof, j*tex_y_ratiof); - - tex0 = llfloor( composition ); - tex0 = llclamp(tex0, 0, 3); - composition -= tex0; - tex1 = tex0 + 1; - tex1 = llclamp(tex1, 0, 3); - - st_offset = (lltrunc(sti) + lltrunc(stj)*st_width) * st_comps; - for (U32 k = 0; k < tex_comps; k++) - { - // Linearly interpolate based on composition. - if (st_offset >= st_data_size[tex0] || st_offset >= st_data_size[tex1]) - { - // SJB: This shouldn't be happening, but does... Rounding error? - //LL_WARNS() << "offset 0 [" << tex0 << "] =" << st_offset << " >= size=" << st_data_size[tex0] << LL_ENDL; - //LL_WARNS() << "offset 1 [" << tex1 << "] =" << st_offset << " >= size=" << st_data_size[tex1] << LL_ENDL; - } - else - { - F32 a = *(st_data[tex0] + st_offset); - F32 b = *(st_data[tex1] + st_offset); - rawp[ offset ] = (U8)lltrunc( a + composition * (b - a) ); - } - offset++; - st_offset++; - } - - sti += st_x_stride; - if (sti >= st_width) - { - sti -= st_width; - } - } - - stj += st_y_stride; - if (stj >= st_height) - { - stj -= st_height; - } - } - - if (!texturep->hasGLTexture()) - { - texturep->createGLTexture(0, raw); - } - texturep->setSubImage(raw, tex_x_begin, tex_y_begin, tex_x_end - tex_x_begin, tex_y_end - tex_y_begin); - - // Un-boost detail textures (will get re-boosted if rendering in high detail) - for (S32 i = 0; i < ASSET_COUNT; i++) - { - unboost_minimap_texture(mDetailTextures[i]); - } - - // Un-boost textures for each detail material (will get re-boosted if rendering in high detail) - for (S32 i = 0; i < ASSET_COUNT; i++) - { - unboost_minimap_material(mDetailMaterials[i]); - } - - return true; -} - F32 LLVLComposition::getStartHeight(S32 corner) { return mStartHeight[corner]; diff --git a/indra/newview/llvlcomposition.h b/indra/newview/llvlcomposition.h index 61c35ade28..2637d77183 100644 --- a/indra/newview/llvlcomposition.h +++ b/indra/newview/llvlcomposition.h @@ -114,8 +114,6 @@ public: // Viewer side hack to generate composition values bool generateHeights(const F32 x, const F32 y, const F32 width, const F32 height); bool generateComposition(); - // Generate texture from composition values. - bool generateMinimapTileLand(const F32 x, const F32 y, const F32 width, const F32 height); // Use these as indeces ito the get/setters below that use 'corner' enum ECorner diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 4f851eabce..fcd2f74108 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -2589,6 +2589,9 @@ void LLVOAvatar::idleUpdate(LLAgent &agent, const F64 &time) { LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; + if (LLApp::isExiting()) + return; + if (isDead()) { LL_INFOS() << "Warning! Idle on dead avatar" << LL_ENDL; @@ -4067,12 +4070,14 @@ void LLVOAvatar::updateDebugText() { // Leave mDebugText uncleared here, in case a derived class has added some state first - if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + static LLCachedControl<bool> debug_av_appearance_message(gSavedSettings, "DebugAvatarAppearanceMessage"); + if (debug_av_appearance_message) { updateAppearanceMessageDebugText(); } - if (gSavedSettings.getBOOL("DebugAvatarCompositeBaked")) + static LLCachedControl<bool> debug_av_composite_baked(gSavedSettings, "DebugAvatarCompositeBaked"); + if (debug_av_composite_baked) { if (!mBakedTextureDebugText.empty()) addDebugText(mBakedTextureDebugText); @@ -4531,7 +4536,7 @@ void LLVOAvatar::updateRootPositionAndRotation(LLAgent& agent, F32 speed, bool w root_pos += LLVector3d(getHoverOffset()); if (getOverallAppearance() == AOA_JELLYDOLL) { - F32 offz = -0.5 * (getScale()[VZ] - mBodySize.mV[VZ]); + F32 offz = -0.5f * (getScale()[VZ] - mBodySize.mV[VZ]); root_pos[2] += offz; // if (!isSelf() && !isControlAvatar()) // { @@ -4778,8 +4783,8 @@ bool LLVOAvatar::updateCharacter(LLAgent &agent) if (!getParent() && (isSitting() || was_sit_ground_constrained)) { - F32 off_z = LLVector3d(getHoverOffset()).mdV[VZ]; - if (off_z != 0.0) + F32 off_z = (F32)LLVector3d(getHoverOffset()).mdV[VZ]; + if (off_z != 0.0f) { LLVector3 pos = mRoot->getWorldPosition(); pos.mV[VZ] += off_z; @@ -7239,7 +7244,7 @@ void LLVOAvatar::updateGL() { if (mMeshTexturesDirty) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; updateMeshTextures(); mMeshTexturesDirty = false; } @@ -8529,7 +8534,7 @@ void LLVOAvatar::updateTooSlow() auto it = std::find(sAVsIgnoringARTLimit.begin(), sAVsIgnoringARTLimit.end(), mID); if (it != sAVsIgnoringARTLimit.end()) { - S32 index = it - sAVsIgnoringARTLimit.begin(); + S32 index = (S32)(it - sAVsIgnoringARTLimit.begin()); ignore_tune = (index < (MIN_NONTUNED_AVS - sAvatarsNearby + 1 + LLPerfStats::tunedAvatars)); } } @@ -8589,7 +8594,8 @@ LLMotion* LLVOAvatar::findMotion(const LLUUID& id) const // colorized if using deferred rendering. void LLVOAvatar::debugColorizeSubMeshes(U32 i, const LLColor4& color) { - if (gSavedSettings.getBOOL("DebugAvatarCompositeBaked")) + static LLCachedControl<bool> debug_av_composite_baked(gSavedSettings, "DebugAvatarCompositeBaked"); + if (debug_av_composite_baked) { avatar_joint_mesh_list_t::iterator iter = mBakedTextureDatas[i].mJointMeshes.begin(); avatar_joint_mesh_list_t::iterator end = mBakedTextureDatas[i].mJointMeshes.end(); @@ -8723,7 +8729,7 @@ void LLVOAvatar::updateMeshVisibility() // virtual void LLVOAvatar::updateMeshTextures() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR + LL_PROFILE_ZONE_SCOPED_CATEGORY_AVATAR; static S32 update_counter = 0; mBakedTextureDebugText.clear(); @@ -9505,7 +9511,7 @@ void LLVOAvatar::parseAppearanceMessage(LLMessageSystem* mesgsys, LLAppearanceMe std::vector<LLVisualParam*>::iterator it = std::find(contents.mParams.begin(), contents.mParams.end(),appearance_version_param); if (it != contents.mParams.end()) { - S32 index = it - contents.mParams.begin(); + S32 index = (S32)(it - contents.mParams.begin()); contents.mParamAppearanceVersion = ll_round(contents.mParamWeights[index]); //LL_DEBUGS("Avatar") << "appversion req by appearance_version param: " << contents.mParamAppearanceVersion << LL_ENDL; } @@ -11101,7 +11107,7 @@ void LLVOAvatar::accountRenderComplexityForObject( LLObjectComplexity object_complexity; object_complexity.objectName = attached_object->getAttachmentItemName(); object_complexity.objectId = attached_object->getAttachmentItemID(); - object_complexity.objectCost = attachment_total_cost; + object_complexity.objectCost = (U32)attachment_total_cost; object_complexity_list.push_back(object_complexity); } } diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp index e4a7b53d9f..57f7734fea 100644 --- a/indra/newview/llvoavatarself.cpp +++ b/indra/newview/llvoavatarself.cpp @@ -699,7 +699,7 @@ bool LLVOAvatarSelf::isValid() const // virtual void LLVOAvatarSelf::idleUpdate(LLAgent &agent, const F64 &time) { - if (isValid()) + if (isAgentAvatarValid()) { LLVOAvatar::idleUpdate(agent, time); idleUpdateTractorBeam(); @@ -1238,7 +1238,7 @@ bool LLVOAvatarSelf::detachObject(LLViewerObject *viewer_object) // Make sure the inventory is in sync with the avatar. // Update COF contents, don't trigger appearance update. - if (!isValid()) + if (!isAgentAvatarValid()) { LL_INFOS() << "removeItemLinks skipped, avatar is under destruction" << LL_ENDL; } @@ -2346,7 +2346,7 @@ LLSD summarize_by_buckets(std::vector<LLSD> in_records, key[field] = record[field]; } LLViewerStats::StatsAccumulator& stats = accum[key]; - F32 value = record[val_field].asReal(); + F32 value = (F32)record[val_field].asReal(); stats.push(value); } for (std::map<LLSD,LLViewerStats::StatsAccumulator>::iterator accum_it = accum.begin(); diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h index 77556c8412..051ac791c0 100644 --- a/indra/newview/llvoavatarself.h +++ b/indra/newview/llvoavatarself.h @@ -111,7 +111,7 @@ private: public: /*virtual*/ bool isSelf() const { return true; } virtual bool isBuddy() const { return false; } - /*virtual*/ bool isValid() const; + /*virtual*/ bool isValid() const; // use isAgentAvatarValid, it's fuller //-------------------------------------------------------------------- // Updates diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 0fe2a3e714..27c105c8d6 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -479,8 +479,8 @@ void LLVOCacheEntry::updateDebugSettings() LLMemory::updateMemoryInfo() ; U32 allocated_mem = LLMemory::getAllocatedMemKB().value(); static const F32 KB_to_MB = 1.f / 1024.f; - U32 clamped_memory = llclamp(allocated_mem * KB_to_MB, (F32) low_mem_bound_MB, (F32) high_mem_bound_MB); - const F32 adjust_range = high_mem_bound_MB - low_mem_bound_MB; + U32 clamped_memory = (U32)llclamp(allocated_mem * KB_to_MB, (F32) low_mem_bound_MB, (F32) high_mem_bound_MB); + const F32 adjust_range = (F32)(high_mem_bound_MB - low_mem_bound_MB); const F32 adjust_factor = (high_mem_bound_MB - clamped_memory) / adjust_range; // [0, 1] //min radius: all objects within this radius remain loaded in memory @@ -502,7 +502,7 @@ void LLVOCacheEntry::updateDebugSettings() static const U32 MIN_FRAMES = 10; static const U32 MAX_FRAMES = 64; const U32 clamped_frames = inv_obj_time ? llclamp((U32) inv_obj_time, MIN_FRAMES, MAX_FRAMES) : MAX_FRAMES; // [10, 64], with zero => 64 - sMinFrameRange = MIN_FRAMES + ((clamped_frames - MIN_FRAMES) * adjust_factor); + sMinFrameRange = MIN_FRAMES + (U32)((clamped_frames - MIN_FRAMES) * adjust_factor); } #endif // LL_TEST @@ -1762,7 +1762,7 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry: entry = new HeaderEntryInfo(); entry->mHandle = handle ; - entry->mTime = time(NULL) ; + entry->mTime = (U32)time(NULL) ; entry->mIndex = mNumEntries++; mHeaderEntryQueue.insert(entry) ; mHandleEntryMap[handle] = entry ; @@ -1775,7 +1775,7 @@ void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry: //resort mHeaderEntryQueue.erase(entry) ; - entry->mTime = time(NULL) ; + entry->mTime = (U32)time(NULL) ; mHeaderEntryQueue.insert(entry) ; } diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index e04bdbf1d9..6903af2619 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -451,6 +451,9 @@ void LLVOGrass::plantBlades() face->setVertexBuffer(NULL); face->setTEOffset(0); face->mCenterLocal = mPosition + mRegionp->getOriginAgent(); + const LLVector4a* ext = mDrawable->getSpatialExtents(); + face->mExtents[0] = ext[0]; + face->mExtents[1] = ext[1]; } mDepth = (face->mCenterLocal - LLViewerCamera::getInstance()->getOrigin())*LLViewerCamera::getInstance()->getAtAxis(); diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp index 81325b5648..060e1243ab 100644 --- a/indra/newview/llvoicevivox.cpp +++ b/indra/newview/llvoicevivox.cpp @@ -1284,7 +1284,7 @@ bool LLVivoxVoiceClient::establishVoiceConnection() { if (result.has("retry") && ++retries <= CONNECT_RETRY_MAX && !sShuttingDown) { - F32 timeout = LLSD::Real(result["retry"]); + F32 timeout = (F32)LLSD::Real(result["retry"]); timeout *= retries; LL_INFOS("Voice") << "Retry connection to voice service in " << timeout << " seconds" << LL_ENDL; llcoro::suspendUntilTimeout(timeout); diff --git a/indra/newview/llvoicewebrtc.cpp b/indra/newview/llvoicewebrtc.cpp index ede1542bd1..d18a32cb05 100644 --- a/indra/newview/llvoicewebrtc.cpp +++ b/indra/newview/llvoicewebrtc.cpp @@ -24,7 +24,6 @@ * $/LicenseInfo$ */ #include <algorithm> -#include <format> #include "llvoicewebrtc.h" #include "llsdutil.h" @@ -291,7 +290,7 @@ const LLVoiceVersionInfo& LLWebRTCVoiceClient::getVersion() void LLWebRTCVoiceClient::updateSettings() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; setVoiceEnabled(LLVoiceClient::getInstance()->voiceEnabled()); static LLCachedControl<S32> sVoiceEarLocation(gSavedSettings, "VoiceEarLocation"); @@ -336,7 +335,7 @@ void LLWebRTCVoiceClient::removeObserver(LLVoiceClientParticipantObserver *obser void LLWebRTCVoiceClient::notifyParticipantObservers() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; for (observer_set_t::iterator it = mParticipantObservers.begin(); it != mParticipantObservers.end();) { LLVoiceClientParticipantObserver *observer = *it; @@ -358,7 +357,7 @@ void LLWebRTCVoiceClient::removeObserver(LLVoiceClientStatusObserver *observer) void LLWebRTCVoiceClient::notifyStatusObservers(LLVoiceClientStatusObserver::EStatusType status) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; LL_DEBUGS("Voice") << "( " << LLVoiceClientStatusObserver::status2string(status) << " )" << " mSession=" << mSession << LL_ENDL; @@ -542,7 +541,7 @@ void LLWebRTCVoiceClient::voiceConnectionCoro() // for cross-region voice. void LLWebRTCVoiceClient::updateNeighboringRegions() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; static const std::vector<LLVector3d> neighbors {LLVector3d(0.0f, 1.0f, 0.0f), LLVector3d(0.707f, 0.707f, 0.0f), LLVector3d(1.0f, 0.0f, 0.0f), LLVector3d(0.707f, -0.707f, 0.0f), @@ -575,7 +574,7 @@ void LLWebRTCVoiceClient::updateNeighboringRegions() // shut down the current audio session to make room for the next one. void LLWebRTCVoiceClient::leaveAudioSession() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; if(mSession) { @@ -631,7 +630,7 @@ void LLWebRTCVoiceClient::OnDevicesChanged(const llwebrtc::LLWebRTCVoiceDeviceLi void LLWebRTCVoiceClient::OnDevicesChangedImpl(const llwebrtc::LLWebRTCVoiceDeviceList &render_devices, const llwebrtc::LLWebRTCVoiceDeviceList &capture_devices) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; std::string inputDevice = gSavedSettings.getString("VoiceInputAudioDevice"); std::string outputDevice = gSavedSettings.getString("VoiceOutputAudioDevice"); @@ -711,7 +710,7 @@ void LLWebRTCVoiceClient::tuningSetSpeakerVolume(float volume) if (volume != mTuningSpeakerVolume) { - mTuningSpeakerVolume = volume; + mTuningSpeakerVolume = (int)volume; } } @@ -719,11 +718,11 @@ float LLWebRTCVoiceClient::getAudioLevel() { if (mIsInTuningMode) { - return (1.0 - mWebRTCDeviceInterface->getTuningAudioLevel() * LEVEL_SCALE_WEBRTC) * mTuningMicGain / 2.1; + return (1.0f - mWebRTCDeviceInterface->getTuningAudioLevel() * LEVEL_SCALE_WEBRTC) * mTuningMicGain / 2.1f; } else { - return (1.0 - mWebRTCDeviceInterface->getPeerConnectionAudioLevel() * LEVEL_SCALE_WEBRTC) * mMicGain / 2.1; + return (1.0f - mWebRTCDeviceInterface->getPeerConnectionAudioLevel() * LEVEL_SCALE_WEBRTC) * mMicGain / 2.1f; } } @@ -798,7 +797,7 @@ void LLWebRTCVoiceClient::setHidden(bool hidden) // notify the observers. void LLWebRTCVoiceClient::OnConnectionEstablished(const std::string &channelID, const LLUUID ®ionID) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; if (gAgent.getRegion()->getRegionID() == regionID) { @@ -882,7 +881,7 @@ void LLWebRTCVoiceClient::setEarLocation(S32 loc) void LLWebRTCVoiceClient::updatePosition(void) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; LLViewerRegion *region = gAgent.getRegion(); if (region && isAgentAvatarValid()) @@ -1011,7 +1010,7 @@ void LLWebRTCVoiceClient::enforceTether() // standard 50m void LLWebRTCVoiceClient::sendPositionUpdate(bool force) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; std::string spatial_data; @@ -1127,7 +1126,7 @@ LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::addParticipantBy void LLWebRTCVoiceClient::removeParticipantByID(const std::string &channelID, const LLUUID &id, const LLUUID& region) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; participantStatePtr_t result; LLWebRTCVoiceClient::sessionState::ptr_t session = sessionState::matchSessionByChannelID(channelID); @@ -1157,7 +1156,7 @@ LLWebRTCVoiceClient::participantState::participantState(const LLUUID& agent_id, LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::sessionState::addParticipant(const LLUUID& agent_id, const LLUUID& region) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; participantStatePtr_t result; @@ -1195,7 +1194,7 @@ LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::sessionState::ad LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::sessionState::findParticipantByID(const LLUUID& id) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; participantStatePtr_t result; participantUUIDMap::iterator iter = mParticipantsByUUID.find(id); @@ -1210,7 +1209,7 @@ LLWebRTCVoiceClient::participantStatePtr_t LLWebRTCVoiceClient::sessionState::fi void LLWebRTCVoiceClient::sessionState::removeParticipant(const LLWebRTCVoiceClient::participantStatePtr_t &participant) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; if (participant) { @@ -1493,7 +1492,7 @@ void LLWebRTCVoiceClient::setMicGain(F32 gain) void LLWebRTCVoiceClient::setVoiceEnabled(bool enabled) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; LL_DEBUGS("Voice") << "( " << (enabled ? "enabled" : "disabled") << " )" @@ -1888,7 +1887,7 @@ void LLWebRTCVoiceClient::sessionState::revive() void LLWebRTCVoiceClient::sessionState::processSessionStates() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; auto iter = mSessions.begin(); while (iter != mSessions.end()) @@ -1909,7 +1908,7 @@ void LLWebRTCVoiceClient::sessionState::processSessionStates() // process the states on each connection associated with a session. bool LLWebRTCVoiceClient::sessionState::processConnectionStates() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; std::list<connectionPtr_t>::iterator iter = mWebRTCConnections.begin(); while (iter != mWebRTCConnections.end()) @@ -1933,7 +1932,7 @@ bool LLWebRTCVoiceClient::sessionState::processConnectionStates() // on our location. bool LLWebRTCVoiceClient::estateSessionState::processConnectionStates() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; if (!mShuttingDown) { @@ -2097,7 +2096,7 @@ LLVoiceWebRTCConnection::LLVoiceWebRTCConnection(const LLUUID ®ionID, const s { // retries wait a short period...randomize it so // all clients don't try to reconnect at once. - mRetryWaitSecs = ((F32) rand() / (RAND_MAX)) + 0.5; + mRetryWaitSecs = (F32)((F32) rand() / (RAND_MAX)) + 0.5f; mWebRTCPeerConnectionInterface = llwebrtc::newPeerConnection(); mWebRTCPeerConnectionInterface->setSignalingObserver(this); @@ -2169,7 +2168,7 @@ void LLVoiceWebRTCConnection::processIceUpdates() // will make the cap call to the server sending up the ICE candidates. void LLVoiceWebRTCConnection::processIceUpdatesCoro() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; if (mShutDown || LLWebRTCVoiceClient::isShuttingDown()) { @@ -2396,7 +2395,7 @@ void LLVoiceWebRTCConnection::sendData(const std::string &data) // The simulator will pass this on to the Secondlife WebRTC server. void LLVoiceWebRTCConnection::breakVoiceConnectionCoro() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; LL_DEBUGS("Voice") << "Disconnecting voice." << LL_ENDL; if (mWebRTCDataInterface) @@ -2455,7 +2454,7 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro() // will use the offer and answer to negotiate the session. void LLVoiceWebRTCSpatialConnection::requestVoiceConnection() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; LLViewerRegion *regionp = LLWorld::instance().getRegionFromID(mRegionID); @@ -2528,7 +2527,7 @@ void LLVoiceWebRTCSpatialConnection::requestVoiceConnection() void LLVoiceWebRTCConnection::OnVoiceConnectionRequestSuccess(const LLSD &result) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; if (LLWebRTCVoiceClient::isShuttingDown()) { @@ -2583,7 +2582,7 @@ static llwebrtc::LLWebRTCPeerConnectionInterface::InitOptions getConnectionOptio // Secondlife WebRTC server. bool LLVoiceWebRTCConnection::connectionStateMachine() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; processIceUpdates(); @@ -2679,7 +2678,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() case VOICE_STATE_SESSION_UP: { mRetryWaitPeriod = 0; - mRetryWaitSecs = ((F32) rand() / (RAND_MAX)) + 0.5; + mRetryWaitSecs = (F32)((F32) rand() / (RAND_MAX)) + 0.5f; // we'll stay here as long as the session remains up. if (mShutDown) @@ -2701,7 +2700,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine() { // back off the retry period, and do it by a small random // bit so all clients don't reconnect at once. - mRetryWaitSecs += ((F32) rand() / (RAND_MAX)) + 0.5; + mRetryWaitSecs += (F32)((F32) rand() / (RAND_MAX)) + 0.5f; mRetryWaitPeriod = 0; } } @@ -2777,7 +2776,7 @@ void LLVoiceWebRTCConnection::OnDataReceived(const std::string& data, bool binar // this pointer. void LLVoiceWebRTCConnection::OnDataReceivedImpl(const std::string &data, bool binary) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; if (mShutDown) { @@ -2944,7 +2943,7 @@ void LLVoiceWebRTCConnection::OnDataChannelReady(llwebrtc::LLWebRTCDataInterface // to peers. void LLVoiceWebRTCConnection::sendJoin() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; boost::json::object root; @@ -3018,7 +3017,7 @@ LLVoiceWebRTCAdHocConnection::~LLVoiceWebRTCAdHocConnection() // So, we have a separate requestVoiceConnection call. void LLVoiceWebRTCAdHocConnection::requestVoiceConnection() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE + LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE; LLViewerRegion *regionp = LLWorld::instance().getRegionFromID(mRegionID); diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 2b8ed74b0f..ab8d0d2564 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -107,7 +107,7 @@ void LLSkyTex::init(bool isShiny) { mTexture[i] = LLViewerTextureManager::getLocalTexture(false); mTexture[i]->setAddressMode(LLTexUnit::TAM_CLAMP); - mImageRaw[i] = new LLImageRaw(SKYTEX_RESOLUTION, SKYTEX_RESOLUTION, SKYTEX_COMPONENTS); + mImageRaw[i] = new LLImageRaw((U16)SKYTEX_RESOLUTION, (U16)SKYTEX_RESOLUTION, (S8)SKYTEX_COMPONENTS); initEmpty(i); } @@ -139,7 +139,7 @@ LLSkyTex::~LLSkyTex() S32 LLSkyTex::getResolution() { - return SKYTEX_RESOLUTION; + return (S32)SKYTEX_RESOLUTION; } S32 LLSkyTex::getCurrent() @@ -172,8 +172,8 @@ void LLSkyTex::initEmpty(const S32 tex) { for (S32 j = 0; j < SKYTEX_RESOLUTION; ++j) { - const S32 basic_offset = (i * SKYTEX_RESOLUTION + j); - S32 offset = basic_offset * SKYTEX_COMPONENTS; + const S32 basic_offset = (i * (S32)SKYTEX_RESOLUTION + j); + S32 offset = basic_offset * (S32)SKYTEX_COMPONENTS; data[offset] = 0; data[offset+1] = 0; data[offset+2] = 0; @@ -194,8 +194,8 @@ void LLSkyTex::create() { for (S32 j = 0; j < SKYTEX_RESOLUTION; ++j) { - const S32 basic_offset = (i * SKYTEX_RESOLUTION + j); - S32 offset = basic_offset * SKYTEX_COMPONENTS; + const S32 basic_offset = (i * (S32)SKYTEX_RESOLUTION + j); + S32 offset = basic_offset * (S32)SKYTEX_COMPONENTS; U32* pix = (U32*)(data + offset); LLColor4U temp = LLColor4U(mSkyData[basic_offset]); *pix = temp.asRGBA(); @@ -392,8 +392,8 @@ const LLVector3* LLHeavenBody::corners() const Sky ***************************************/ -const S32 SKYTEX_TILE_RES_X = SKYTEX_RESOLUTION / NUM_TILES_X; -const S32 SKYTEX_TILE_RES_Y = SKYTEX_RESOLUTION / NUM_TILES_Y; +const S32 SKYTEX_TILE_RES_X = (S32)SKYTEX_RESOLUTION / NUM_TILES_X; +const S32 SKYTEX_TILE_RES_Y = (S32)SKYTEX_RESOLUTION / NUM_TILES_Y; LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) : LLStaticViewerObject(id, pcode, regionp, true), diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index ad7570105e..17cffcadb4 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -83,26 +83,26 @@ protected: void setDir(const LLVector3 &dir, const S32 i, const S32 j) { - S32 offset = i * SKYTEX_RESOLUTION + j; + S32 offset = (S32)(i * SKYTEX_RESOLUTION + j); mSkyDirs[offset] = dir; } const LLVector3 &getDir(const S32 i, const S32 j) const { - S32 offset = i * SKYTEX_RESOLUTION + j; + S32 offset = (S32)(i * SKYTEX_RESOLUTION + j); return mSkyDirs[offset]; } void setPixel(const LLColor4 &col, const S32 i, const S32 j) { - S32 offset = i * SKYTEX_RESOLUTION + j; + S32 offset = (S32)(i * SKYTEX_RESOLUTION + j); mSkyData[offset] = col; } void setPixel(const LLColor4U &col, const S32 i, const S32 j) { LLImageDataSharedLock lock(mImageRaw[sCurrent]); - S32 offset = (i * SKYTEX_RESOLUTION + j) * SKYTEX_COMPONENTS; + S32 offset = (S32)((i * SKYTEX_RESOLUTION + j) * SKYTEX_COMPONENTS); U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]); *pix = col.asRGBA(); } @@ -111,7 +111,7 @@ protected: { LLColor4U col; LLImageDataSharedLock lock(mImageRaw[sCurrent]); - S32 offset = (i * SKYTEX_RESOLUTION + j) * SKYTEX_COMPONENTS; + S32 offset = (S32)((i * SKYTEX_RESOLUTION + j) * SKYTEX_COMPONENTS); U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]); col.fromRGBA( *pix ); return col; diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index 56742751e8..471174cf5d 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -142,7 +142,7 @@ void LLVOSurfacePatch::updateGL() { if (mPatchp) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; mPatchp->updateGL(); } } @@ -995,7 +995,7 @@ void gen_terrain_tangents(U16 strider_vertex_count, LLStrider<LLVector2> &texCoords0p, LLStrider<U16> &indicesp) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; LLVector4a *vertices = new LLVector4a[strider_vertex_count]; LLVector4a *normals = new LLVector4a[strider_vertex_count]; diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index a981c60ef2..d982592ee7 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -461,9 +461,7 @@ void LLVOTree::updateTextures() { setDebugText(llformat("%4.0f", (F32) sqrt(mPixelArea))); } - mTreeImagep->addTextureStats(mPixelArea); } - } @@ -479,7 +477,7 @@ LLDrawable* LLVOTree::createDrawable(LLPipeline *pipeline) // Just a placeholder for an actual object... LLFace *facep = mDrawable->addFace(poolp, mTreeImagep); facep->setSize(1, 3); - + facep->setTexture(LLRender::DIFFUSE_MAP, mTreeImagep); updateRadius(); return mDrawable; @@ -1169,6 +1167,10 @@ void LLVOTree::updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) LLVector4a pos; pos.load3(center.mV); mDrawable->setPositionGroup(pos); + + LLFace* facep = mDrawable->getFace(0); + facep->mExtents[0] = newMin; + facep->mExtents[1] = newMax; } bool LLVOTree::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, bool pick_transparent, bool pick_rigged, bool pick_unselectable, S32 *face_hitp, diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 71f3c2a3aa..2630aaf43e 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -851,19 +851,9 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) if (mSculptTexture.notNull()) { - mSculptTexture->setBoostLevel(llmax((S32)mSculptTexture->getBoostLevel(), - (S32)LLGLTexture::BOOST_SCULPTED)); mSculptTexture->setForSculpt() ; - if(!mSculptTexture->isCachedRawImageReady()) - { - S32 lod = llmin(mLOD, 3); - F32 lodf = ((F32)(lod + 1.0f)/4.f); - F32 tex_size = lodf * LLViewerTexture::sMaxSculptRez ; - mSculptTexture->addTextureStats(2.f * tex_size * tex_size, false); - } - - S32 texture_discard = mSculptTexture->getCachedRawImageLevel(); //try to match the texture + S32 texture_discard = mSculptTexture->getRawImageLevel(); //try to match the texture S32 current_discard = getVolume() ? getVolume()->getSculptLevel() : -2 ; if (texture_discard >= 0 && //texture has some data available @@ -1159,7 +1149,9 @@ void LLVOVolume::updateSculptTexture() LLUUID id = sculpt_params->getSculptTexture(); if (id.notNull()) { - mSculptTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, true, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); + mSculptTexture = LLViewerTextureManager::getFetchedTexture(id, FTT_DEFAULT, true, LLGLTexture::BOOST_SCULPTED, LLViewerTexture::LOD_TEXTURE); + mSculptTexture->forceToSaveRawImage(0, F32_MAX); + mSculptTexture->addTextureStats(256.f*256.f); } mSkinInfoUnavaliable = false; @@ -1252,8 +1244,22 @@ void LLVOVolume::sculpt() S8 sculpt_components = 0; const U8* sculpt_data = NULL; - S32 discard_level = mSculptTexture->getCachedRawImageLevel() ; - LLImageRaw* raw_image = mSculptTexture->getCachedRawImage() ; + S32 discard_level = mSculptTexture->getRawImageLevel() ; + LLImageRaw* raw_image = mSculptTexture->getRawImage() ; + + if (!raw_image) + { + raw_image = mSculptTexture->getSavedRawImage(); + S32 discard_level = mSculptTexture->getSavedRawImageLevel(); + } + + if (!raw_image) + { + // last resort, read back from GL + mSculptTexture->readbackRawImage(); + raw_image = mSculptTexture->getRawImage(); + discard_level = mSculptTexture->getRawImageLevel(); + } S32 max_discard = mSculptTexture->getMaxDiscardLevel(); if (discard_level > max_discard) @@ -1269,8 +1275,8 @@ void LLVOVolume::sculpt() if(current_discard < -2) { static S32 low_sculpty_discard_warning_count = 1; - S32 exponent = llmax(1, llfloor( log10((F64) low_sculpty_discard_warning_count) )); - S32 interval = pow(10.0, exponent); + S32 exponent = llmax(1, llfloor((F32)log10((F64) low_sculpty_discard_warning_count))); + S32 interval = (S32)pow(10.0, exponent); if ( low_sculpty_discard_warning_count < 10 || (low_sculpty_discard_warning_count % interval) == 0) { // Log first 10 time, then decreasing intervals afterwards otherwise this can flood the logs @@ -1288,8 +1294,8 @@ void LLVOVolume::sculpt() else if (current_discard > MAX_DISCARD_LEVEL) { static S32 high_sculpty_discard_warning_count = 1; - S32 exponent = llmax(1, llfloor( log10((F64) high_sculpty_discard_warning_count) )); - S32 interval = pow(10.0, exponent); + S32 exponent = llmax(1, llfloor((F32)log10((F64) high_sculpty_discard_warning_count))); + S32 interval = (S32)pow(10.0, exponent); if ( high_sculpty_discard_warning_count < 10 || (high_sculpty_discard_warning_count % interval) == 0) { // Log first 10 time, then decreasing intervals afterwards otherwise this can flood the logs @@ -1310,8 +1316,6 @@ void LLVOVolume::sculpt() if(!raw_image) { - llassert(discard_level < 0) ; - sculpt_width = 0; sculpt_height = 0; sculpt_data = NULL ; @@ -1537,7 +1541,7 @@ bool LLVOVolume::calcLOD() if (isRootEdit()) { S32 total_tris = recursiveGetTriangleCount(); - S32 est_max_tris = recursiveGetEstTrianglesMax(); + S32 est_max_tris = (S32)recursiveGetEstTrianglesMax(); setDebugText(llformat("TRIS SHOWN %d EST %d", total_tris, est_max_tris)); } } @@ -4049,12 +4053,12 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const // Scaling here is to make animated object vs // non-animated object ARC proportional to the // corresponding calculations for streaming cost. - num_triangles = (ANIMATED_OBJECT_COST_PER_KTRI * 0.001 * costs.getEstTrisForStreamingCost())/0.06; + num_triangles = (U32)((ANIMATED_OBJECT_COST_PER_KTRI * 0.001f * costs.getEstTrisForStreamingCost())/0.06f); } else { F32 radius = getScale().length()*0.5f; - num_triangles = costs.getRadiusWeightedTris(radius); + num_triangles = (U32)costs.getRadiusWeightedTris(radius); } } @@ -4530,7 +4534,7 @@ F32 LLVOVolume::getBinRadius() } else { - F32 szf = size_factor; + F32 szf = (F32)size_factor; radius = llmax(mDrawable->getRadius(), szf); //radius = llmax(radius, mDrawable->mDistanceWRTCamera * distance_factor[0]); } @@ -5741,18 +5745,23 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { continue; } -#if 0 -#if LL_RELEASE_WITH_DEBUG_INFO - const LLUUID pbr_id( "49c88210-7238-2a6b-70ac-92d4f35963cf" ); - const LLUUID obj_id( vobj->getID() ); - bool is_pbr = (obj_id == pbr_id); -#else - bool is_pbr = false; -#endif -#else - LLGLTFMaterial *gltf_mat = facep->getTextureEntry()->getGLTFRenderMaterial(); + + LLFetchedGLTFMaterial *gltf_mat = (LLFetchedGLTFMaterial*) facep->getTextureEntry()->getGLTFRenderMaterial(); bool is_pbr = gltf_mat != nullptr; -#endif + + if (is_pbr) + { + // tell texture streaming system to ignore blinn-phong textures + facep->setTexture(LLRender::DIFFUSE_MAP, nullptr); + facep->setTexture(LLRender::NORMAL_MAP, nullptr); + facep->setTexture(LLRender::SPECULAR_MAP, nullptr); + + // let texture streaming system know about PBR textures + facep->setTexture(LLRender::BASECOLOR_MAP, gltf_mat->mBaseColorTexture); + facep->setTexture(LLRender::GLTF_NORMAL_MAP, gltf_mat->mNormalTexture); + facep->setTexture(LLRender::METALLIC_ROUGHNESS_MAP, gltf_mat->mMetallicRoughnessTexture); + facep->setTexture(LLRender::EMISSIVE_MAP, gltf_mat->mEmissiveTexture); + } //ALWAYS null out vertex buffer on rebuild -- if the face lands in a render // batch, it will recover its vertex buffer reference from the spatial group @@ -5870,7 +5879,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) F32 alpha; if (is_pbr) { - alpha = gltf_mat ? gltf_mat->mBaseColor.mV[3] : 1.0; + alpha = gltf_mat ? gltf_mat->mBaseColor.mV[3] : 1.0f; } else { diff --git a/indra/newview/llvowater.cpp b/indra/newview/llvowater.cpp index 34040e1aca..4a7e231f30 100644 --- a/indra/newview/llvowater.cpp +++ b/indra/newview/llvowater.cpp @@ -59,7 +59,6 @@ LLVOWater::LLVOWater(const LLUUID &id, mbCanSelect = false; setScale(LLVector3(256.f, 256.f, 0.f)); // Hack for setting scale for bounding boxes/visibility. - mUseTexture = true; mIsEdgePatch = false; } @@ -101,14 +100,7 @@ LLDrawable *LLVOWater::createDrawable(LLPipeline *pipeline) LLDrawPoolWater *pool = (LLDrawPoolWater*) gPipeline.getPool(LLDrawPool::POOL_WATER); - if (mUseTexture) - { - mDrawable->setNumFaces(1, pool, mRegionp->getLand().getWaterTexture()); - } - else - { - mDrawable->setNumFaces(1, pool, LLWorld::getInstance()->getDefaultWaterTexture()); - } + mDrawable->setNumFaces(1, pool, LLWorld::getInstance()->getDefaultWaterTexture()); return mDrawable; } @@ -146,8 +138,8 @@ bool LLVOWater::updateGeometry(LLDrawable *drawable) S32 size_y = LLPipeline::sRenderTransparentWater ? 8 : 1; const LLVector3& scale = getScale(); - size_x *= llmin(llround(scale.mV[0] / 256.f), 8); - size_y *= llmin(llround(scale.mV[1] / 256.f), 8); + size_x *= (S32)llmin(llround(scale.mV[0] / 256.f), 8); + size_y *= (S32)llmin(llround(scale.mV[1] / 256.f), 8); const S32 num_quads = size_x * size_y; face->setSize(vertices_per_quad * num_quads, @@ -199,8 +191,8 @@ bool LLVOWater::updateGeometry(LLDrawable *drawable) position_agent.mV[VX] += (x + 0.5f) * step_x; position_agent.mV[VY] += (y + 0.5f) * step_y; - position_agent.mV[VX] = llround(position_agent.mV[VX]); - position_agent.mV[VY] = llround(position_agent.mV[VY]); + position_agent.mV[VX] = (F32)llround(position_agent.mV[VX]); + position_agent.mV[VY] = (F32)llround(position_agent.mV[VY]); *verticesp++ = position_agent - right + up; *verticesp++ = position_agent - right - up; @@ -249,11 +241,6 @@ void setVecZ(LLVector3& v) v.mV[VZ] = 1; } -void LLVOWater::setUseTexture(const bool use_texture) -{ - mUseTexture = use_texture; -} - void LLVOWater::setIsEdgePatch(const bool edge_patch) { mIsEdgePatch = edge_patch; diff --git a/indra/newview/llvowater.h b/indra/newview/llvowater.h index adae86691a..ba3da510c4 100644 --- a/indra/newview/llvowater.h +++ b/indra/newview/llvowater.h @@ -70,13 +70,10 @@ public: /*virtual*/ bool isActive() const; // Whether this object needs to do an idleUpdate. - void setUseTexture(const bool use_texture); void setIsEdgePatch(const bool edge_patch); - bool getUseTexture() const { return mUseTexture; } bool getIsEdgePatch() const { return mIsEdgePatch; } protected: - bool mUseTexture; bool mIsEdgePatch; S32 mRenderType; }; diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 2eadea20ef..9508d33eb3 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -805,10 +805,10 @@ void LLWorld::updateNetStats() add(LLStatViewer::PACKETS_OUT, packets_out); add(LLStatViewer::PACKETS_LOST, packets_lost); - F32 total_packets_in = LLViewerStats::instance().getRecording().getSum(LLStatViewer::PACKETS_IN); - if (total_packets_in > 0) + F32 total_packets_in = (F32)LLViewerStats::instance().getRecording().getSum(LLStatViewer::PACKETS_IN); + if (total_packets_in > 0.f) { - F32 total_packets_lost = LLViewerStats::instance().getRecording().getSum(LLStatViewer::PACKETS_LOST); + F32 total_packets_lost = (F32)LLViewerStats::instance().getRecording().getSum(LLStatViewer::PACKETS_LOST); sample(LLStatViewer::PACKETS_LOST_PERCENT, LLUnits::Ratio::fromValue((F32)total_packets_lost/(F32)total_packets_in)); } @@ -961,7 +961,6 @@ void LLWorld::updateWaterObjects() if (!getRegionFromHandle(region_handle)) { // No region at that area, so make water LLVOWater* waterp = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_WATER, gAgent.getRegion()); - waterp->setUseTexture(false); waterp->setPositionGlobal(LLVector3d(x + rwidth/2, y + rwidth/2, 256.f + water_height)); @@ -1015,7 +1014,6 @@ void LLWorld::updateWaterObjects() mEdgeWaterObjects[dir] = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_VOID_WATER, gAgent.getRegion()); waterp = mEdgeWaterObjects[dir]; - waterp->setUseTexture(false); waterp->setIsEdgePatch(true); gPipeline.createObject(waterp); } @@ -1266,7 +1264,7 @@ void send_agent_pause() void send_agent_resume() { - LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; // Note: used to check for LLWorld initialization before it became a singleton. // Rather than just remove this check I'm changing it to assure that the message // system has been initialized. -MG diff --git a/indra/newview/llworldmapview.cpp b/indra/newview/llworldmapview.cpp index 09a18a9825..a0eec1e941 100755 --- a/indra/newview/llworldmapview.cpp +++ b/indra/newview/llworldmapview.cpp @@ -255,7 +255,7 @@ void LLWorldMapView::zoom(F32 zoom) void LLWorldMapView::zoomWithPivot(F32 zoom, S32 x, S32 y) { mTargetMapScale = scaleFromZoom(zoom); - sZoomPivot = LLVector2(x, y); + sZoomPivot = LLVector2((F32)x, (F32)y); if (!sZoomTimer.getStarted() && mMapScale != mTargetMapScale) { sZoomTimer.start(); @@ -297,8 +297,8 @@ void LLWorldMapView::setScale(F32 scale, bool snap) if (!sZoomPivot.isExactlyZero()) { LLVector2 relative_pivot; - relative_pivot.mV[VX] = sZoomPivot.mV[VX] - (getRect().getWidth() / 2.0); - relative_pivot.mV[VY] = sZoomPivot.mV[VY] - (getRect().getHeight() / 2.0); + relative_pivot.mV[VX] = sZoomPivot.mV[VX] - (getRect().getWidth() / 2.0f); + relative_pivot.mV[VY] = sZoomPivot.mV[VY] - (getRect().getHeight() / 2.0f); LLVector2 zoom_pan_offset = relative_pivot - (relative_pivot * scale / old_scale); mPanX += zoom_pan_offset.mV[VX]; mPanY += zoom_pan_offset.mV[VY]; @@ -422,8 +422,8 @@ void LLWorldMapView::draw() // Find x and y position relative to camera's center. LLVector3d rel_region_pos = origin_global - camera_global; - F32 relative_x = (rel_region_pos.mdV[0] / REGION_WIDTH_METERS) * mMapScale; - F32 relative_y = (rel_region_pos.mdV[1] / REGION_WIDTH_METERS) * mMapScale; + F32 relative_x = (F32)(rel_region_pos.mdV[0] / REGION_WIDTH_METERS) * mMapScale; + F32 relative_y = (F32)(rel_region_pos.mdV[1] / REGION_WIDTH_METERS) * mMapScale; // Coordinates of the sim in pixels in the UI panel // When the view isn't panned, 0,0 = center of rectangle @@ -514,11 +514,11 @@ void LLWorldMapView::draw() { font->renderUTF8( mesg, 0, - llfloor(left + 3), llfloor(bottom + 2), + (F32)llfloor(left + 3), (F32)llfloor(bottom + 2), LLColor4::white, LLFontGL::LEFT, LLFontGL::BASELINE, LLFontGL::NORMAL, LLFontGL::DROP_SHADOW, S32_MAX, //max_chars - mMapScale, //max_pixels + (S32)mMapScale, //max_pixels NULL, /*use_ellipses*/true); } diff --git a/indra/newview/llworldmipmap.cpp b/indra/newview/llworldmipmap.cpp index e226fd4748..d8ea2b884f 100644 --- a/indra/newview/llworldmipmap.cpp +++ b/indra/newview/llworldmipmap.cpp @@ -178,6 +178,7 @@ LLPointer<LLViewerFetchedTexture> LLWorldMipmap::getObjectsTile(U32 grid_x, U32 } } +//static LLPointer<LLViewerFetchedTexture> LLWorldMipmap::loadObjectsTile(U32 grid_x, U32 grid_y, S32 level) { // Get the grid coordinates diff --git a/indra/newview/llworldmipmap.h b/indra/newview/llworldmipmap.h index ab98b55b72..907f24d1e7 100644 --- a/indra/newview/llworldmipmap.h +++ b/indra/newview/llworldmipmap.h @@ -74,11 +74,13 @@ public: // Convert world coordinates to mipmap grid coordinates at a given level static void globalToMipmap(F64 global_x, F64 global_y, S32 level, U32* grid_x, U32* grid_y); + // Load the relevant tile from S3 + static LLPointer<LLViewerFetchedTexture> loadObjectsTile(U32 grid_x, U32 grid_y, S32 level); + private: // Get a handle (key) from grid coordinates U64 convertGridToHandle(U32 grid_x, U32 grid_y) { return to_region_handle(grid_x * REGION_WIDTH_UNITS, grid_y * REGION_WIDTH_UNITS); } - // Load the relevant tile from S3 - LLPointer<LLViewerFetchedTexture> loadObjectsTile(U32 grid_x, U32 grid_y, S32 level); + // Clear a level from its "missing" tiles void cleanMissedTilesFromLevel(S32 level); diff --git a/indra/newview/llxmlrpclistener.cpp b/indra/newview/llxmlrpclistener.cpp index 1148e81fd5..7c7bd98bcd 100644 --- a/indra/newview/llxmlrpclistener.cpp +++ b/indra/newview/llxmlrpclistener.cpp @@ -39,12 +39,6 @@ #include <boost/scoped_ptr.hpp> #include <boost/range.hpp> // boost::begin(), boost::end() -#ifdef LL_USESYSTEMLIBS -#include <xmlrpc.h> -#else -#include <xmlrpc-epi/xmlrpc.h> -#endif - #include "curl/curl.h" // other Linden headers @@ -178,13 +172,6 @@ public: static const CURLcodeMapper sCURLcodeMapper; -LLXMLRPCListener::LLXMLRPCListener(const std::string& pumpname): - mBoundListener(LLEventPumps::instance(). - obtain(pumpname). - listen("LLXMLRPCListener", boost::bind(&LLXMLRPCListener::process, this, _1))) -{ -} - /** * Capture an outstanding LLXMLRPCTransaction and poll it periodically until * done. @@ -213,38 +200,20 @@ public: mMethod(command["method"]), mReplyPump(command["reply"]) { - // LL_ERRS if any of these are missing - const char* required[] = { "uri", "method", "reply" }; - // optional: "options" (array of string) - // Validate the request - std::set<std::string> missing; - for (const char** ri = boost::begin(required); ri != boost::end(required); ++ri) + // LL_ERRS if any of these keys are missing or empty + if (mUri.empty() || mMethod.empty() || mReplyPump.empty()) { - // If the command does not contain this required entry, add it to 'missing'. - if (! command.has(*ri)) - { - missing.insert(*ri); - } - } - if (! missing.empty()) - { - LL_ERRS("LLXMLRPCListener") << mMethod << " request missing params: "; - const char* separator = ""; - for (std::set<std::string>::const_iterator mi(missing.begin()), mend(missing.end()); - mi != mend; ++mi) - { - LL_CONT << separator << *mi; - separator = ", "; - } - LL_CONT << LL_ENDL; + LL_ERRS("LLXMLRPCListener") + << "Some params are missing: " + << "reply: '" << mReplyPump << "', " + << "method: '" << mMethod << "', " + << "uri: '" << mUri << "'" + << LL_ENDL; } - // Build the XMLRPC request. - XMLRPC_REQUEST request = XMLRPC_RequestNew(); - XMLRPC_RequestSetMethodName(request, mMethod.c_str()); - XMLRPC_RequestSetRequestType(request, xmlrpc_request_call); - XMLRPC_VALUE xparams = XMLRPC_CreateVector(NULL, xmlrpc_vector_struct); - LLSD params(command["params"]); + LLSD request_params = LLSD::emptyMap(); + + LLSD params = command.get("params"); if (params.isMap()) { for (LLSD::map_const_iterator pi(params.beginMap()), pend(params.endMap()); @@ -252,44 +221,33 @@ public: { std::string name(pi->first); LLSD param(pi->second); - if (param.isString()) + switch (param.type()) { - XMLRPC_VectorAppendString(xparams, name.c_str(), param.asString().c_str(), 0); - } - else if (param.isInteger() || param.isBoolean()) - { - XMLRPC_VectorAppendInt(xparams, name.c_str(), param.asInteger()); - } - else if (param.isReal()) - { - XMLRPC_VectorAppendDouble(xparams, name.c_str(), param.asReal()); - } - else - { - LL_ERRS("LLXMLRPCListener") << mMethod << " request param " - << name << " has unknown type: " << param << LL_ENDL; + case LLSD::TypeString: + case LLSD::TypeInteger: + case LLSD::TypeReal: + request_params.insert(name, param); + break; + case LLSD::TypeBoolean: + request_params.insert(name, param.asInteger()); + break; + default: + LL_ERRS("LLXMLRPCListener") << mMethod + << " request param '" << name << "' has unknown type: " << param << LL_ENDL; } } } - LLSD options(command["options"]); + + LLSD options = command.get("options"); if (options.isArray()) { - XMLRPC_VALUE xoptions = XMLRPC_CreateVector("options", xmlrpc_vector_array); - for (LLSD::array_const_iterator oi(options.beginArray()), oend(options.endArray()); - oi != oend; ++oi) - { - XMLRPC_VectorAppendString(xoptions, NULL, oi->asString().c_str(), 0); - } - XMLRPC_AddValueToVector(xparams, xoptions); + request_params.insert("options", options); } - XMLRPC_RequestSetData(request, xparams); - mTransaction.reset(new LLXMLRPCTransaction(mUri, request, true, command.has("http_params")? LLSD(command["http_params"]) : LLSD())); + LLSD http_params = command.get("http_params"); + mTransaction.reset(new LLXMLRPCTransaction(mUri, mMethod, request_params, http_params)); mPreviousStatus = mTransaction->status(NULL); - // Free the XMLRPC_REQUEST object and the attached data values. - XMLRPC_RequestFree(request, 1); - // Now ensure that we get regular callbacks to poll for completion. mBoundListener = LLEventPumps::instance(). @@ -323,7 +281,7 @@ public: data["error"] = ""; data["transfer_rate"] = 0.0; LLEventPump& replyPump(LLEventPumps::instance().obtain(mReplyPump)); - if (! done) + if (!done) { // Not done yet, carry on. if (status == LLXMLRPCTransaction::StatusDownloading @@ -367,10 +325,8 @@ public: // Given 'message', need we care? if (status == LLXMLRPCTransaction::StatusComplete) { - // Success! Parse data. - std::string status_string(data["status"]); - data["responses"] = parseResponse(status_string); - data["status"] = status_string; + // Success! Retrieve response data. + data["responses"] = mTransaction->response(); } // whether successful or not, send reply on requested LLEventPump @@ -388,159 +344,6 @@ public: } private: - /// Derived from LLUserAuth::parseResponse() and parseOptionInto() - LLSD parseResponse(std::string& status_string) - { - // Extract every member into data["responses"] (a map of string - // values). - XMLRPC_REQUEST response = mTransaction->response(); - if (! response) - { - LL_DEBUGS("LLXMLRPCListener") << "No response" << LL_ENDL; - return LLSD(); - } - - XMLRPC_VALUE param = XMLRPC_RequestGetData(response); - if (! param) - { - LL_DEBUGS("LLXMLRPCListener") << "Response contains no data" << LL_ENDL; - return LLSD(); - } - - // Now, parse everything - return parseValues(status_string, "", param); - } - - LLSD parseValue(std::string& status_string, const std::string& key, const std::string& key_pfx, XMLRPC_VALUE param) - { - LLSD response; - - XMLRPC_VALUE_TYPE_EASY type = XMLRPC_GetValueTypeEasy(param); - switch (type) - { - case xmlrpc_type_empty: - LL_INFOS("LLXMLRPCListener") << "Empty result for key " << key_pfx << key << LL_ENDL; - break; - case xmlrpc_type_base64: - { - S32 len = XMLRPC_GetValueStringLen(param); - const char* buf = XMLRPC_GetValueBase64(param); - if ((len > 0) && buf) - { - // During implementation this code was not tested - // If you encounter this, please make sure this is correct, - // then remove llassert - llassert(0); - - LLSD::Binary data; - data.resize(len); - memcpy((void*)&data[0], (void*)buf, len); - response = data; - } - else - { - LL_WARNS("LLXMLRPCListener") << "Potentially malformed xmlrpc_type_base64 for key " - << key_pfx << key << LL_ENDL; - } - break; - } - case xmlrpc_type_boolean: - { - response = LLSD::Boolean(XMLRPC_GetValueBoolean(param)); - LL_DEBUGS("LLXMLRPCListener") << "val: " << response << LL_ENDL; - break; - } - case xmlrpc_type_datetime: - { - std::string iso8601_date(XMLRPC_GetValueDateTime_ISO8601(param)); - LL_DEBUGS("LLXMLRPCListener") << "val: " << iso8601_date << LL_ENDL; - response = LLSD::Date(iso8601_date); - break; - } - case xmlrpc_type_double: - { - response = LLSD::Real(XMLRPC_GetValueDouble(param)); - LL_DEBUGS("LLXMLRPCListener") << "val: " << response << LL_ENDL; - break; - } - case xmlrpc_type_int: - { - response = LLSD::Integer(XMLRPC_GetValueInt(param)); - LL_DEBUGS("LLXMLRPCListener") << "val: " << response << LL_ENDL; - break; - } - case xmlrpc_type_string: - { - response = LLSD::String(XMLRPC_GetValueString(param)); - LL_DEBUGS("LLXMLRPCListener") << "val: " << response << LL_ENDL; - break; - } - case xmlrpc_type_mixed: - case xmlrpc_type_array: - { - // We expect this to be an array of submaps. Walk the array, - // recursively parsing each submap and collecting them. - LLSD array; - int i = 0; // for descriptive purposes - for (XMLRPC_VALUE row = XMLRPC_VectorRewind(param); row; - row = XMLRPC_VectorNext(param), ++i) - { - // Recursive call. For the lower-level key_pfx, if 'key' - // is "foo", pass "foo[0]:", then "foo[1]:", etc. In the - // nested call, a subkey "bar" will then be logged as - // "foo[0]:bar", and so forth. - // Parse the scalar subkey/value pairs from this array - // entry into a temp submap. Collect such submaps in 'array'. - - array.append(parseValue(status_string, "", - STRINGIZE(key_pfx << key << '[' << i << "]:"), - row)); - } - // Having collected an 'array' of 'submap's, insert that whole - // 'array' as the value of this 'key'. - response = array; - break; - } - case xmlrpc_type_struct: - { - response = parseValues(status_string, - STRINGIZE(key_pfx << key << ':'), - param); - break; - } - case xmlrpc_type_none: // Not expected - default: - // whoops - unrecognized type - LL_WARNS("LLXMLRPCListener") << "Unhandled xmlrpc type " << type << " for key " - << key_pfx << key << LL_ENDL; - response = STRINGIZE("<bad XMLRPC type " << type << '>'); - status_string = "BadType"; - } - return response; - } - - /** - * Parse key/value pairs from a given XMLRPC_VALUE into an LLSD map. - * @param key_pfx Used to describe a given key in log messages. At top - * level, pass "". When parsing an options array, pass the top-level key - * name of the array plus the index of the array entry; to this we'll - * append the subkey of interest. - * @param param XMLRPC_VALUE iterator. At top level, pass - * XMLRPC_RequestGetData(XMLRPC_REQUEST). - */ - LLSD parseValues(std::string& status_string, const std::string& key_pfx, XMLRPC_VALUE param) - { - LLSD responses; - for (XMLRPC_VALUE current = XMLRPC_VectorRewind(param); current; - current = XMLRPC_VectorNext(param)) - { - std::string key(XMLRPC_GetValueID(current)); - LL_DEBUGS("LLXMLRPCListener") << "key: " << key_pfx << key << LL_ENDL; - responses.insert(key, parseValue(status_string, key, key_pfx, current)); - } - return responses; - } - const LLReqID mReqID; const std::string mUri; const std::string mMethod; @@ -550,11 +353,18 @@ private: LLXMLRPCTransaction::EStatus mPreviousStatus; // To detect state changes. }; -bool LLXMLRPCListener::process(const LLSD& command) +LLXMLRPCListener::LLXMLRPCListener(const std::string& pumpname) +: mBoundListener(LLEventPumps::instance().obtain(pumpname).listen +( + "LLXMLRPCListener", + [&](const LLSD& command) -> bool + { + // Allocate a new heap Poller, but do not save a pointer to it. Poller + // will check its own status and free itself on completion of the request. + (new Poller(command)); + // Conventional event listener return + return false; + } +)) { - // Allocate a new heap Poller, but do not save a pointer to it. Poller - // will check its own status and free itself on completion of the request. - (new Poller(command)); - // conventional event listener return - return false; } diff --git a/indra/newview/llxmlrpclistener.h b/indra/newview/llxmlrpclistener.h index aaed98eec5..fd75acb8b1 100644 --- a/indra/newview/llxmlrpclistener.h +++ b/indra/newview/llxmlrpclistener.h @@ -42,9 +42,6 @@ public: /// Specify the pump name on which to listen LLXMLRPCListener(const std::string& pumpname); - /// Handle request events on the event pump specified at construction time - bool process(const LLSD& command); - private: LLTempBoundListener mBoundListener; }; diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index ec6e22cd7a..48461241a2 100644 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -42,22 +42,11 @@ #include "bufferarray.h" #include "llversioninfo.h" #include "llviewercontrol.h" +#include "llxmlnode.h" #include "stringize.h" // Have to include these last to avoid queue redefinition! -#ifdef LL_USESYSTEMLIBS -#include <xmlrpc.h> -#else -#include <xmlrpc-epi/xmlrpc.h> -#endif -// <xmlrpc-epi/queue.h> contains a harmful #define queue xmlrpc_queue. This -// breaks any use of std::queue. Ditch that #define: if any of our code wants -// to reference xmlrpc_queue, let it reference it directly. -#if defined(queue) -#undef queue -#endif - #include "llappviewer.h" #include "lltrans.h" @@ -75,123 +64,17 @@ namespace boost // nothing. static LLXMLRPCListener listener("LLXMLRPCTransaction"); -LLXMLRPCValue LLXMLRPCValue::operator[](const char* id) const -{ - return LLXMLRPCValue(XMLRPC_VectorGetValueWithID(mV, id)); -} - -std::string LLXMLRPCValue::asString() const -{ - const char* s = XMLRPC_GetValueString(mV); - return s ? s : ""; -} - -int LLXMLRPCValue::asInt() const { return XMLRPC_GetValueInt(mV); } -bool LLXMLRPCValue::asBool() const { return XMLRPC_GetValueBoolean(mV) != 0; } -double LLXMLRPCValue::asDouble() const { return XMLRPC_GetValueDouble(mV); } - -LLXMLRPCValue LLXMLRPCValue::rewind() -{ - return LLXMLRPCValue(XMLRPC_VectorRewind(mV)); -} - -LLXMLRPCValue LLXMLRPCValue::next() -{ - return LLXMLRPCValue(XMLRPC_VectorNext(mV)); -} - -bool LLXMLRPCValue::isValid() const -{ - return mV != NULL; -} - -LLXMLRPCValue LLXMLRPCValue::createArray() -{ - return LLXMLRPCValue(XMLRPC_CreateVector(NULL, xmlrpc_vector_array)); -} - -LLXMLRPCValue LLXMLRPCValue::createStruct() -{ - return LLXMLRPCValue(XMLRPC_CreateVector(NULL, xmlrpc_vector_struct)); -} - - -void LLXMLRPCValue::append(LLXMLRPCValue& v) -{ - XMLRPC_AddValueToVector(mV, v.mV); -} - -void LLXMLRPCValue::appendString(const std::string& v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueString(NULL, v.c_str(), 0)); -} - -void LLXMLRPCValue::appendInt(int v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueInt(NULL, v)); -} - -void LLXMLRPCValue::appendBool(bool v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueBoolean(NULL, v)); -} - -void LLXMLRPCValue::appendDouble(double v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueDouble(NULL, v)); -} - - -void LLXMLRPCValue::append(const char* id, LLXMLRPCValue& v) -{ - XMLRPC_SetValueID(v.mV, id, 0); - XMLRPC_AddValueToVector(mV, v.mV); -} - -void LLXMLRPCValue::appendString(const char* id, const std::string& v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueString(id, v.c_str(), 0)); -} - -void LLXMLRPCValue::appendInt(const char* id, int v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueInt(id, v)); -} - -void LLXMLRPCValue::appendBool(const char* id, bool v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueBoolean(id, v)); -} - -void LLXMLRPCValue::appendDouble(const char* id, double v) -{ - XMLRPC_AddValueToVector(mV, XMLRPC_CreateValueDouble(id, v)); -} - -void LLXMLRPCValue::cleanup() -{ - XMLRPC_CleanupValue(mV); - mV = NULL; -} - -XMLRPC_VALUE LLXMLRPCValue::getValue() const -{ - return mV; -} - - class LLXMLRPCTransaction::Handler : public LLCore::HttpHandler { public: Handler(LLCore::HttpRequest::ptr_t &request, LLXMLRPCTransaction::Impl *impl); - virtual ~Handler(); - virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); + void onCompleted(LLCore::HttpHandle handle, + LLCore::HttpResponse* response) override; typedef std::shared_ptr<LLXMLRPCTransaction::Handler> ptr_t; private: - LLXMLRPCTransaction::Impl *mImpl; LLCore::HttpRequest::ptr_t mRequest; }; @@ -213,18 +96,23 @@ public: LLCore::HttpHandle mPostH; std::string mURI; - std::string mProxyAddress; std::string mResponseText; - XMLRPC_REQUEST mResponse; + LLSD mResponseData; + bool mHasResponse; + bool mResponseParsed; + std::string mCertStore; - LLSD mErrorCertData; + LLSD mErrorCertData; - Impl(const std::string& uri, XMLRPC_REQUEST request, bool useGzip, const LLSD& httpParams); - Impl(const std::string& uri, - const std::string& method, LLXMLRPCValue params, bool useGzip); - ~Impl(); + Impl + ( + const std::string& uri, + const std::string& method, + const LLSD& params, + const LLSD& httpParams + ); bool process(); @@ -232,7 +120,8 @@ public: void setHttpStatus(const LLCore::HttpStatus &status); private: - void init(XMLRPC_REQUEST request, bool useGzip, const LLSD& httpParams); + bool parseResponse(LLXMLNodePtr root); + bool parseValue(LLSD& target, LLXMLNodePtr source); }; LLXMLRPCTransaction::Handler::Handler(LLCore::HttpRequest::ptr_t &request, @@ -242,10 +131,6 @@ LLXMLRPCTransaction::Handler::Handler(LLCore::HttpRequest::ptr_t &request, { } -LLXMLRPCTransaction::Handler::~Handler() -{ -} - void LLXMLRPCTransaction::Handler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) { @@ -272,92 +157,41 @@ void LLXMLRPCTransaction::Handler::onCompleted(LLCore::HttpHandle handle, return; } - mImpl->setStatus(LLXMLRPCTransaction::StatusComplete); mImpl->mTransferStats = response->getTransferStats(); - // the contents of a buffer array are potentially noncontiguous, so we + // The contents of a buffer array are potentially noncontiguous, so we // will need to copy them into an contiguous block of memory for XMLRPC. LLCore::BufferArray *body = response->getBody(); - char * bodydata = new char[body->size()]; - - body->read(0, bodydata, body->size()); - - mImpl->mResponse = XMLRPC_REQUEST_FromXML(bodydata, static_cast<int>(body->size()), 0); - - delete[] bodydata; - - bool hasError = false; - bool hasFault = false; - int faultCode = 0; - std::string faultString; - - LLXMLRPCValue error(XMLRPC_RequestGetError(mImpl->mResponse)); - if (error.isValid()) - { - hasError = true; - faultCode = error["faultCode"].asInt(); - faultString = error["faultString"].asString(); - } - else if (XMLRPC_ResponseIsFault(mImpl->mResponse)) - { - hasFault = true; - faultCode = XMLRPC_GetResponseFaultCode(mImpl->mResponse); - faultString = XMLRPC_GetResponseFaultString(mImpl->mResponse); - } + mImpl->mResponseText.resize(body->size()); - if (hasError || hasFault) - { - mImpl->setStatus(LLXMLRPCTransaction::StatusXMLRPCError); - - LL_WARNS() << "LLXMLRPCTransaction XMLRPC " - << (hasError ? "error " : "fault ") - << faultCode << ": " - << faultString << LL_ENDL; - LL_WARNS() << "LLXMLRPCTransaction request URI: " - << mImpl->mURI << LL_ENDL; - } + body->read(0, mImpl->mResponseText.data(), body->size()); + // We do not do the parsing in the HTTP coroutine, since it could exhaust + // the coroutine stack in extreme cases. Instead, we flag the data buffer + // as ready, and let mImpl decode it in its process() method, on the main + // coroutine. HB + mImpl->mHasResponse = true; + mImpl->setStatus(LLXMLRPCTransaction::StatusComplete); } //========================================================================= -LLXMLRPCTransaction::Impl::Impl(const std::string& uri, - XMLRPC_REQUEST request, bool useGzip, const LLSD& httpParams) - : mHttpRequest(), - mStatus(LLXMLRPCTransaction::StatusNotStarted), - mURI(uri), - mResponse(0) -{ - init(request, useGzip, httpParams); -} - - -LLXMLRPCTransaction::Impl::Impl(const std::string& uri, - const std::string& method, LLXMLRPCValue params, bool useGzip) - : mHttpRequest(), - mStatus(LLXMLRPCTransaction::StatusNotStarted), - mURI(uri), - mResponse(0) -{ - XMLRPC_REQUEST request = XMLRPC_RequestNew(); - XMLRPC_RequestSetMethodName(request, method.c_str()); - XMLRPC_RequestSetRequestType(request, xmlrpc_request_call); - XMLRPC_RequestSetData(request, params.getValue()); - - init(request, useGzip, LLSD()); - // DEV-28398: without this XMLRPC_RequestFree() call, it looks as though - // the 'request' object is simply leaked. It's less clear to me whether we - // should also ask to free request value data (second param 1), since the - // data come from 'params'. - XMLRPC_RequestFree(request, 1); -} - -void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip, const LLSD& httpParams) +LLXMLRPCTransaction::Impl::Impl +( + const std::string& uri, + const std::string& method, + const LLSD& params, + const LLSD& http_params +) + : mHttpRequest() + , mStatus(LLXMLRPCTransaction::StatusNotStarted) + , mURI(uri) + , mHasResponse(false) + , mResponseParsed(false) { LLCore::HttpOptions::ptr_t httpOpts; LLCore::HttpHeaders::ptr_t httpHeaders; - if (!mHttpRequest) { mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest); @@ -366,37 +200,34 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip, const // LLRefCounted starts with a 1 ref, so don't add a ref in the smart pointer httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()); - // delay between repeats will start from 5 sec and grow to 20 sec with each repeat - httpOpts->setMinBackoff(5E6L); - httpOpts->setMaxBackoff(20E6L); + // Delay between repeats will start from 5 sec and grow to 20 sec with each repeat + httpOpts->setMinBackoff((LLCore::HttpTime)5E6L); + httpOpts->setMaxBackoff((LLCore::HttpTime)20E6L); - httpOpts->setTimeout(httpParams.has("timeout") ? httpParams["timeout"].asInteger() : 40L); - if (httpParams.has("retries")) + httpOpts->setTimeout(http_params.has("timeout") ? http_params["timeout"].asInteger() : 40L); + if (http_params.has("retries")) { - httpOpts->setRetries(httpParams["retries"].asInteger()); + httpOpts->setRetries(http_params["retries"].asInteger()); } - if (httpParams.has("DNSCacheTimeout")) + if (http_params.has("DNSCacheTimeout")) { - httpOpts->setDNSCacheTimeout(httpParams["DNSCacheTimeout"].asInteger()); + httpOpts->setDNSCacheTimeout(http_params["DNSCacheTimeout"].asInteger()); } bool vefifySSLCert = !gSavedSettings.getBOOL("NoVerifySSLCert"); mCertStore = gSavedSettings.getString("CertStore"); - httpOpts->setSSLVerifyPeer( vefifySSLCert ); - httpOpts->setSSLVerifyHost( vefifySSLCert ? 2 : 0); + httpOpts->setSSLVerifyPeer(vefifySSLCert); + httpOpts->setSSLVerifyHost(vefifySSLCert ? 2 : 0); // LLRefCounted starts with a 1 ref, so don't add a ref in the smart pointer httpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders()); httpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_TEXT_XML); - std::string user_agent = stringize( - LLVersionInfo::instance().getChannel(), ' ', - LLVersionInfo::instance().getMajor(), '.', - LLVersionInfo::instance().getMinor(), '.', - LLVersionInfo::instance().getPatch(), " (", - LLVersionInfo::instance().getBuild(), ')'); + const LLVersionInfo& vi(LLVersionInfo::instance()); + std::string user_agent = vi.getChannel() + llformat(" %d.%d.%d (%llu)", + vi.getMajor(), vi.getMinor(), vi.getPatch(), vi.getBuild()); httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, user_agent); @@ -404,31 +235,70 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip, const //This might help with bug #503 */ //httpOpts->setDNSCacheTimeout(-1); - LLCore::BufferArray::ptr_t body = LLCore::BufferArray::ptr_t(new LLCore::BufferArray()); - - // TODO: See if there is a way to serialize to a preallocated buffer I'm - // not fond of the copy here. - int requestSize(0); - char * requestText = XMLRPC_REQUEST_ToXML(request, &requestSize); + std::string request = + "<?xml version=\"1.0\"?><methodCall><methodName>" + method + + "</methodName><params><param>" + params.asXMLRPCValue() + + "</param></params></methodCall>"; - body->append(requestText, requestSize); + LLCore::BufferArray::ptr_t body = LLCore::BufferArray::ptr_t(new LLCore::BufferArray()); - XMLRPC_Free(requestText); + body->append(request.c_str(), request.size()); - mHandler = LLXMLRPCTransaction::Handler::ptr_t(new Handler( mHttpRequest, this )); + mHandler = LLXMLRPCTransaction::Handler::ptr_t(new Handler(mHttpRequest, this)); mPostH = mHttpRequest->requestPost(LLCore::HttpRequest::DEFAULT_POLICY_ID, mURI, body.get(), httpOpts, httpHeaders, mHandler); - } - -LLXMLRPCTransaction::Impl::~Impl() +bool LLXMLRPCTransaction::Impl::parseResponse(LLXMLNodePtr root) { - if (mResponse) + // We have already checked in LLXMLNode::parseBuffer() that root contains + // exactly one child. + if (!root->hasName("methodResponse")) + { + LL_WARNS() << "Invalid root element in XML response; request URI: " + << mURI << LL_ENDL; + return false; + } + + LLXMLNodePtr first = root->getFirstChild(); + LLXMLNodePtr second = first->getFirstChild(); + if (first && !first->getNextSibling() && second && + !second->getNextSibling()) { - XMLRPC_RequestFree(mResponse, 1); + if (first->hasName("fault")) + { + LLSD fault; + if (parseValue(fault, second) && fault.isMap() && + fault.has("faultCode") && fault.has("faultString")) + { + LL_WARNS() << "Request failed. faultCode: '" + << fault.get("faultCode").asString() + << "', faultString: '" + << fault.get("faultString").asString() + << "', request URI: " << mURI << LL_ENDL; + return false; + } + } + else if (first->hasName("params") && + second->hasName("param") && !second->getNextSibling()) + { + LLXMLNodePtr third = second->getFirstChild(); + if (third && !third->getNextSibling() && + parseValue(mResponseData, third)) + { + return true; + } + } } + + LL_WARNS() << "Invalid response format; request URI: " << mURI << LL_ENDL; + return false; +} + +bool LLXMLRPCTransaction::Impl::parseValue(LLSD& target, LLXMLNodePtr src) +{ + return src->fromXMLRPCValue(target); } bool LLXMLRPCTransaction::Impl::process() @@ -439,6 +309,29 @@ bool LLXMLRPCTransaction::Impl::process() return true; //failed, quit. } + // Parse the response when we have one and it has not yet been parsed. HB + if (mHasResponse && !mResponseParsed) + { + LLXMLNodePtr root; + if (!LLXMLNode::parseBuffer(mResponseText.data(), mResponseText.size(), + root, nullptr)) + { + LL_WARNS() << "Failed parsing XML in response; request URI: " + << mURI << LL_ENDL; + } + else if (parseResponse(root)) + { + LL_INFOS() << "XMLRPC response parsed successfully; request URI: " + << mURI << LL_ENDL; + } + else + { + LL_WARNS() << "XMLRPC response parsing failed; request URI: " + << mURI << LL_ENDL; + } + mResponseParsed = true; + } + switch (mStatus) { case LLXMLRPCTransaction::StatusComplete: @@ -539,18 +432,16 @@ void LLXMLRPCTransaction::Impl::setHttpStatus(const LLCore::HttpStatus &status) } - -LLXMLRPCTransaction::LLXMLRPCTransaction( - const std::string& uri, XMLRPC_REQUEST request, bool useGzip, const LLSD& httpParams) -: impl(* new Impl(uri, request, useGzip, httpParams)) -{ } - - -LLXMLRPCTransaction::LLXMLRPCTransaction( +LLXMLRPCTransaction::LLXMLRPCTransaction +( const std::string& uri, - const std::string& method, LLXMLRPCValue params, bool useGzip) -: impl(* new Impl(uri, method, params, useGzip)) -{ } + const std::string& method, + const LLSD& params, + const LLSD& http_params +) +: impl(*new Impl(uri, method, params, http_params)) +{ +} LLXMLRPCTransaction::~LLXMLRPCTransaction() { @@ -590,14 +481,9 @@ std::string LLXMLRPCTransaction::statusURI() return impl.mStatusURI; } -XMLRPC_REQUEST LLXMLRPCTransaction::response() -{ - return impl.mResponse; -} - -LLXMLRPCValue LLXMLRPCTransaction::responseValue() +const LLSD& LLXMLRPCTransaction::response() { - return LLXMLRPCValue(XMLRPC_RequestGetData(impl.mResponse)); + return impl.mResponseData; } diff --git a/indra/newview/llxmlrpctransaction.h b/indra/newview/llxmlrpctransaction.h index 4c8796f936..f7a38f5f90 100644 --- a/indra/newview/llxmlrpctransaction.h +++ b/indra/newview/llxmlrpctransaction.h @@ -29,73 +29,22 @@ #include <string> -typedef struct _xmlrpc_request* XMLRPC_REQUEST; -typedef struct _xmlrpc_value* XMLRPC_VALUE; - // foward decl of types from xmlrpc.h (this usage is type safe) -class LLCertificate; - -class LLXMLRPCValue - // a c++ wrapper around XMLRPC_VALUE -{ -public: - LLXMLRPCValue() : mV(NULL) { } - LLXMLRPCValue(XMLRPC_VALUE value) : mV(value) { } - - bool isValid() const; - - std::string asString() const; - int asInt() const; - bool asBool() const; - double asDouble() const; - - LLXMLRPCValue operator[](const char*) const; - - LLXMLRPCValue rewind(); - LLXMLRPCValue next(); - - static LLXMLRPCValue createArray(); - static LLXMLRPCValue createStruct(); - - void append(LLXMLRPCValue&); - void appendString(const std::string&); - void appendInt(int); - void appendBool(bool); - void appendDouble(double); - void appendValue(LLXMLRPCValue&); - - void append(const char*, LLXMLRPCValue&); - void appendString(const char*, const std::string&); - void appendInt(const char*, int); - void appendBool(const char*, bool); - void appendDouble(const char*, double); - void appendValue(const char*, LLXMLRPCValue&); - - void cleanup(); - // only call this on the top level created value - - XMLRPC_VALUE getValue() const; - -private: - XMLRPC_VALUE mV; -}; - - +/// An asynchronous request and responses via XML-RPC class LLXMLRPCTransaction - // an asynchronous request and responses via XML-RPC { public: - LLXMLRPCTransaction(const std::string& uri, - XMLRPC_REQUEST request, bool useGzip = true, const LLSD& httpParams = LLSD()); - // does not take ownership of the request object - // request can be freed as soon as the transaction is constructed - - LLXMLRPCTransaction(const std::string& uri, - const std::string& method, LLXMLRPCValue params, bool useGzip = true); - // *does* take control of the request value, you must not free it + LLXMLRPCTransaction + ( + const std::string& uri, + const std::string& method, + const LLSD& params, + const LLSD& http_params = LLSD() + ); ~LLXMLRPCTransaction(); - typedef enum e_status { + typedef enum e_status + { StatusNotStarted, StatusStarted, StatusDownloading, @@ -105,26 +54,25 @@ public: StatusOtherError } EStatus; + /// Run the request a little, returns true when done bool process(); - // run the request a little, returns true when done + /// Return a status, and extended CURL code, if code isn't null EStatus status(int* curlCode); - // return status, and extended CURL code, if code isn't null LLSD getErrorCertData(); + + /// Return a message string, suitable for showing the user std::string statusMessage(); - // return a message string, suitable for showing the user + + /// Return a URI for the user with more information (can be empty) std::string statusURI(); - // return a URI for the user with more information - // can be empty - XMLRPC_REQUEST response(); - LLXMLRPCValue responseValue(); - // only valid if StatusComplete, otherwise NULL - // retains ownership of the result object, don't free it + /// Only non-empty if StatusComplete, otherwise Undefined + const LLSD& response(); + /// Only valid if StsatusComplete, otherwise 0.0 F64 transferRate(); - // only valid if StsatusComplete, otherwise 0.0 private: class Handler; @@ -133,6 +81,4 @@ private: Impl& impl; }; - - #endif // LLXMLRPCTRANSACTION_H diff --git a/indra/newview/noise.h b/indra/newview/noise.h index ae819cf542..fe3292ab9e 100644 --- a/indra/newview/noise.h +++ b/indra/newview/noise.h @@ -344,7 +344,7 @@ static void init(void) } // reintroduce entropy - srand(time(NULL)); // Flawfinder: ignore + srand((unsigned int)time(NULL)); // Flawfinder: ignore } #undef B diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6c9c4751d7..42a6987a18 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -776,9 +776,11 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; if (mRT == &mMainRT) { // hacky -- allocate auxillary buffer + + gCubeSnapshot = TRUE; + if (sReflectionProbesEnabled) { - gCubeSnapshot = true; mReflectionMapManager.initReflectionMaps(); } @@ -863,6 +865,10 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) const U32 post_color_fmt = post_hdr ? GL_RGBA16F : GL_RGBA; mPostMap.allocate(resX, resY, post_color_fmt); + // used to scale down textures + // See LLViwerTextureList::updateImagesCreateTextures and LLImageGL::scaleDown + mDownResMap.allocate(4, 4, GL_RGBA); + //HACK make screenbuffer allocations start failing after 30 seconds if (gSavedSettings.getBOOL("SimulateFBOFailure")) { @@ -1066,12 +1072,7 @@ void LLPipeline::refreshCachedSettings() RenderScreenSpaceReflectionAdaptiveStepMultiplier = gSavedSettings.getF32("RenderScreenSpaceReflectionAdaptiveStepMultiplier"); RenderScreenSpaceReflectionGlossySamples = gSavedSettings.getS32("RenderScreenSpaceReflectionGlossySamples"); RenderBufferVisualization = gSavedSettings.getS32("RenderBufferVisualization"); - if (gSavedSettings.getBOOL("RenderMirrors") != RenderMirrors) - { - RenderMirrors = gSavedSettings.getBOOL("RenderMirrors"); - LLViewerShaderMgr::instance()->clearShaderCache(); - LLViewerShaderMgr::instance()->setShaders(); - } + RenderMirrors = gSavedSettings.getBOOL("RenderMirrors"); RenderHeroProbeUpdateRate = gSavedSettings.getS32("RenderHeroProbeUpdateRate"); RenderHeroProbeConservativeUpdateMultiplier = gSavedSettings.getS32("RenderHeroProbeConservativeUpdateMultiplier"); @@ -1109,6 +1110,8 @@ void LLPipeline::releaseGLBuffers() mPostMap.release(); + mDownResMap.release(); + for (U32 i = 0; i < 3; i++) { mGlow[i].release(); @@ -1233,7 +1236,7 @@ void LLPipeline::createGLBuffers() F32 noise[noiseRes*noiseRes*3]; for (U32 i = 0; i < noiseRes*noiseRes*3; i++) { - noise[i] = ll_frand()*2.0-1.0; + noise[i] = ll_frand()*2.0f-1.0f; } LLImageGL::generateTextures(1, &mTrueNoiseMap); @@ -4562,7 +4565,8 @@ void LLPipeline::renderDebug() mReflectionMapManager.renderDebug(); } - if (gSavedSettings.getBOOL("RenderReflectionProbeVolumes") && !hud_only) + static LLCachedControl<bool> render_ref_probe_volumes(gSavedSettings, "RenderReflectionProbeVolumes"); + if (render_ref_probe_volumes && !hud_only) { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("probe debug display"); @@ -5284,7 +5288,7 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; assertInitialized(); - if (LLPipeline::sReflectionRender || gCubeSnapshot || LLPipeline::sRenderingHUDs) + if (LLPipeline::sReflectionRender || gCubeSnapshot || LLPipeline::sRenderingHUDs || LLApp::isExiting()) { return; } @@ -6906,7 +6910,7 @@ void LLPipeline::generateExposure(LLRenderTarget* src, LLRenderTarget* dst, bool } } shader->uniform1f(dt, gFrameIntervalSeconds); - shader->uniform2f(noiseVec, ll_frand() * 2.0 - 1.0, ll_frand() * 2.0 - 1.0); + shader->uniform2f(noiseVec, ll_frand() * 2.0f - 1.0f, ll_frand() * 2.0f - 1.0f); shader->uniform3f(dynamic_exposure_params, dynamic_exposure_coefficient, exp_min, exp_max); mScreenTriangleVB->setBuffer(); @@ -6952,7 +6956,7 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) { shader.bindTexture(LLShaderMgr::EXPOSURE_MAP, &mExposureMap); - shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, src->getWidth(), src->getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)src->getWidth(), (GLfloat)src->getHeight()); static LLCachedControl<F32> exposure(gSavedSettings, "RenderExposure", 1.f); @@ -7031,8 +7035,8 @@ void LLPipeline::generateGlow(LLRenderTarget* src) gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); } gGlowExtractProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, - mGlow[2].getWidth(), - mGlow[2].getHeight()); + (GLfloat)mGlow[2].getWidth(), + (GLfloat)mGlow[2].getHeight()); } { @@ -7357,7 +7361,7 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) gDeferredCoFProgram.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); gDeferredCoFProgram.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); - gDeferredCoFProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, dst->getWidth(), dst->getHeight()); + gDeferredCoFProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)dst->getWidth(), (GLfloat)dst->getHeight()); gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance / 1000.f); gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_BLUR_CONSTANT, blur_constant); gDeferredCoFProgram.uniform1f(LLShaderMgr::DOF_TAN_PIXEL_ANGLE, tanf(1.f / LLDrawable::sCurPixelAngle)); @@ -7383,7 +7387,7 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) gDeferredPostProgram.bind(); gDeferredPostProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, &mRT->deferredLight, LLTexUnit::TFO_POINT); - gDeferredPostProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, dst->getWidth(), dst->getHeight()); + gDeferredPostProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)dst->getWidth(), (GLfloat)dst->getHeight()); gDeferredPostProgram.uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); gDeferredPostProgram.uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); @@ -7416,7 +7420,7 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) gDeferredDoFCombineProgram.bindTexture(LLShaderMgr::DEFERRED_DIFFUSE, src, LLTexUnit::TFO_POINT); gDeferredDoFCombineProgram.bindTexture(LLShaderMgr::DEFERRED_LIGHT, &mRT->deferredLight, LLTexUnit::TFO_POINT); - gDeferredDoFCombineProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, dst->getWidth(), dst->getHeight()); + gDeferredDoFCombineProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)dst->getWidth(), (GLfloat)dst->getHeight()); gDeferredDoFCombineProgram.uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); gDeferredDoFCombineProgram.uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale); gDeferredDoFCombineProgram.uniform1f(LLShaderMgr::DOF_WIDTH, (dof_width - 1) / (F32)src->getWidth()); @@ -7779,15 +7783,15 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniform1f(LLShaderMgr::DEFERRED_BLUR_SIZE, RenderShadowBlurSize); shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_RADIUS, RenderSSAOScale); - shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_MAX_RADIUS, RenderSSAOMaxScale); + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_MAX_RADIUS, (GLfloat)RenderSSAOMaxScale); F32 ssao_factor = RenderSSAOFactor; shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_FACTOR, ssao_factor); - shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_FACTOR_INV, 1.0/ssao_factor); + shader.uniform1f(LLShaderMgr::DEFERRED_SSAO_FACTOR_INV, 1.0f/ssao_factor); LLVector3 ssao_effect = RenderSSAOEffect; - F32 matrix_diag = (ssao_effect[0] + 2.0*ssao_effect[1])/3.0; - F32 matrix_nondiag = (ssao_effect[0] - ssao_effect[1])/3.0; + F32 matrix_diag = (ssao_effect[0] + 2.0f*ssao_effect[1])/3.0f; + F32 matrix_nondiag = (ssao_effect[0] - ssao_effect[1])/3.0f; // This matrix scales (proj of color onto <1/rt(3),1/rt(3),1/rt(3)>) by // value factor, and scales remainder by saturation factor F32 ssao_effect_mat[] = { matrix_diag, matrix_nondiag, matrix_nondiag, @@ -7799,7 +7803,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ F32 shadow_bias_error = RenderShadowBiasError * fabsf(LLViewerCamera::getInstance()->getOrigin().mV[2])/3000.f; F32 shadow_bias = RenderShadowBias + shadow_bias_error; - shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, deferred_target->getWidth(), deferred_target->getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, (GLfloat)deferred_target->getWidth(), (GLfloat)deferred_target->getHeight()); shader.uniform1f(LLShaderMgr::DEFERRED_NEAR_CLIP, LLViewerCamera::getInstance()->getNear()*2.f); shader.uniform1f (LLShaderMgr::DEFERRED_SHADOW_OFFSET, RenderShadowOffset); //*shadow_offset_error); shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_BIAS, shadow_bias); @@ -7808,8 +7812,8 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, mTransformedSunDir.mV); shader.uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, mTransformedMoonDir.mV); - shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mRT->shadow[0].getWidth(), mRT->shadow[0].getHeight()); - shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mSpotShadow[0].getWidth(), mSpotShadow[0].getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, (GLfloat)mRT->shadow[0].getWidth(), (GLfloat)mRT->shadow[0].getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, (GLfloat)mSpotShadow[0].getWidth(), (GLfloat)mSpotShadow[0].getHeight()); shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); @@ -7940,8 +7944,8 @@ void LLPipeline::renderDeferredLighting() gDeferredSunProgram.uniform3fv(sOffset, slice, offset); gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, - deferred_light_target->getWidth(), - deferred_light_target->getHeight()); + (GLfloat)deferred_light_target->getWidth(), + (GLfloat)deferred_light_target->getHeight()); { LLGLDisable blend(GL_BLEND); @@ -8640,7 +8644,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) { gGL.getTexUnit(channel)->bind(img); - F32 lod_range = logf(img->getWidth())/logf(2.f); + F32 lod_range = logf((F32)img->getWidth())/logf(2.f); shader.uniform1f(LLShaderMgr::PROJECTOR_FOCUS, focus); shader.uniform1f(LLShaderMgr::PROJECTOR_LOD, lod_range); @@ -8765,17 +8769,17 @@ void LLPipeline::bindReflectionProbes(LLGLSLShader& shader) } - shader.uniform1f(LLShaderMgr::DEFERRED_SSR_ITR_COUNT, RenderScreenSpaceReflectionIterations); + shader.uniform1f(LLShaderMgr::DEFERRED_SSR_ITR_COUNT, (GLfloat)RenderScreenSpaceReflectionIterations); shader.uniform1f(LLShaderMgr::DEFERRED_SSR_DIST_BIAS, RenderScreenSpaceReflectionDistanceBias); shader.uniform1f(LLShaderMgr::DEFERRED_SSR_RAY_STEP, RenderScreenSpaceReflectionRayStep); - shader.uniform1f(LLShaderMgr::DEFERRED_SSR_GLOSSY_SAMPLES, RenderScreenSpaceReflectionGlossySamples); + shader.uniform1f(LLShaderMgr::DEFERRED_SSR_GLOSSY_SAMPLES, (GLfloat)RenderScreenSpaceReflectionGlossySamples); shader.uniform1f(LLShaderMgr::DEFERRED_SSR_REJECT_BIAS, RenderScreenSpaceReflectionDepthRejectBias); mPoissonOffset++; if (mPoissonOffset > 128 - RenderScreenSpaceReflectionGlossySamples) mPoissonOffset = 0; - shader.uniform1f(LLShaderMgr::DEFERRED_SSR_NOISE_SINE, mPoissonOffset); + shader.uniform1f(LLShaderMgr::DEFERRED_SSR_NOISE_SINE, (GLfloat)mPoissonOffset); shader.uniform1f(LLShaderMgr::DEFERRED_SSR_ADAPTIVE_STEP_MULT, RenderScreenSpaceReflectionAdaptiveStepMultiplier); channel = shader.enableTexture(LLShaderMgr::SCENE_DEPTH); @@ -8957,7 +8961,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gGL.diffuseColor4f(1, 1, 1, 1); - S32 shadow_detail = gSavedSettings.getS32("RenderShadowDetail"); + S32 shadow_detail = RenderShadowDetail; // if not using VSM, disable color writes if (shadow_detail <= 2) @@ -9941,7 +9945,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) { LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); F32 fade_amt = gFrameIntervalSeconds.value() - * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); + * (F32)llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); // should never happen llassert(mTargetShadowSpotLight[0] != mTargetShadowSpotLight[1] || mTargetShadowSpotLight[0].isNull()); @@ -10108,8 +10112,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) for (U32 i = 0; i < 16; i++) { - gGLLastModelView[i] = last_modelview[i]; - gGLLastProjection[i] = last_projection[i]; + gGLLastModelView[i] = (F32)last_modelview[i]; + gGLLastProjection[i] = (F32)last_projection[i]; } popRenderTypeMask(); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 1d2033b4f0..6c79d20149 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -725,6 +725,9 @@ public: // tonemapped and gamma corrected render ready for post LLRenderTarget mPostMap; + // downres scratch space for GPU downscaling of textures + LLRenderTarget mDownResMap; + LLCullResult mSky; LLCullResult mReflectedObjects; LLCullResult mRefractedObjects; diff --git a/indra/newview/skins/default/xui/da/floater_about.xml b/indra/newview/skins/default/xui/da/floater_about.xml index 7bcae69779..604eb7c58f 100644 --- a/indra/newview/skins/default/xui/da/floater_about.xml +++ b/indra/newview/skins/default/xui/da/floater_about.xml @@ -69,7 +69,6 @@ OpenSSL Copyright (C) 1998-2002 The OpenSSL Project. PCRE Copyright (c) 1997-2008 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) -xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler. google-perftools Copyright (c) 2005, Google Inc. diff --git a/indra/newview/skins/default/xui/de/floater_about.xml b/indra/newview/skins/default/xui/de/floater_about.xml index 10ccf0d5da..320db7f654 100644 --- a/indra/newview/skins/default/xui/de/floater_about.xml +++ b/indra/newview/skins/default/xui/de/floater_about.xml @@ -28,7 +28,6 @@ mit Open-Source-Beiträgen von:</text> PCRE Copyright (c) 1997-2012 University of Cambridge. SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga. SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com). - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly und Mark Adler. diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml index ff2fa93cbb..126cd84d56 100644 --- a/indra/newview/skins/default/xui/en/floater_about.xml +++ b/indra/newview/skins/default/xui/en/floater_about.xml @@ -111,7 +111,6 @@ Dummy Name replaced at run time PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler. diff --git a/indra/newview/skins/default/xui/en/floater_bulk_upload.xml b/indra/newview/skins/default/xui/en/floater_bulk_upload.xml new file mode 100644 index 0000000000..b2d03a5d04 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_bulk_upload.xml @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<floater + can_resize="false" + show_title="false" + can_minimize="false" + can_close="false" + header_height="10" + bg_opaque_image="Window_NoTitle_Foreground" + bg_alpha_image="Window_NoTitle_Background" + height="207" + layout="topleft" + name="bulk_upload" + width="430"> + <layout_stack + follows="all" + height="203" + layout="topleft" + left="8" + animate="false" + top="1" + orientation="vertical" + name="maint_layout" + width="421"> + <layout_panel + follows="all" + height="27" + layout="topleft" + auto_resize="false" + visible="true" + name="count_panel"> + <text + follows="left|top" + layout="topleft" + top="6" + left="20" + name="number_of_items" + height="20" + wrap="true"> + Number of items to upload: [COUNT] + </text> + </layout_panel> + <layout_panel + follows="all" + height="37" + layout="topleft" + auto_resize="false" + visible="true" + name="warning_panel"> + <text + name="textures_2k_warning" + follows="left|top" + layout="topleft" + top="6" + left="20" + height="30" + right="-20" + wrap="true"> + By default, one or more selected textures will be scaled to 2048px. + </text> + </layout_panel> + <layout_panel + follows="all" + height="23" + layout="topleft" + auto_resize="false" + visible="true" + name="checkbox_panel"> + <check_box + height="16" + left="20" + label="Scale textures to a maximum of 1024px" + layout="topleft" + name="upload_2k" /> + </layout_panel> + <layout_panel + follows="all" + height="27" + layout="topleft" + auto_resize="false" + visible="true" + name="cost_panel"> + <text + name="upload_cost" + follows="left|top" + layout="topleft" + font.style="BOLD" + top="6" + left="20" + height="20" + wrap="true"> + Upload cost: L$[COST] + </text> + </layout_panel> + <layout_panel + follows="all" + height="29" + layout="topleft" + auto_resize="false" + visible="true" + name="buttoms_panel"> + <button + follows="bottom|left|right" + height="23" + label="Upload" + layout="topleft" + mouse_opaque="false" + name="upload_btn" + top="1" + left="84" + width="120" /> + <button + follows="bottom|left|right" + height="23" + label="Cancel" + layout="topleft" + left_pad="12" + top_delta="0" + mouse_opaque="false" + name="cancel_btn" + width="120" /> + </layout_panel> + <layout_panel + follows="all" + height="40" + layout="topleft" + auto_resize="false" + visible="true" + name="link_panel"> + <text + follows="left|top" + layout="topleft" + top="6" + left="20" + name="new_folder_textbox" + height="39" + parse_urls="true" + skip_link_underline="true" + wrap="true"> +How textures are scaled during upload: +https://wiki.secondlife.com/wiki/Limits#All_Viewers + </text> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml b/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml new file mode 100644 index 0000000000..b17d0aa5b6 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_gltf_asset_editor.xml @@ -0,0 +1,284 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + legacy_header_height="18" + can_resize="true" + default_tab_group="1" + height="530" + width="256" + min_height="400" + min_width="200" + layout="topleft" + name="gltf asset editor" + title="[OBJECT_NAME]"> + <floater.string name="floater_title" value="GLTF Scene Editor"/> + <floater.string name="scene_tittle" value="Scene"/> + <floater.string name="node_tittle" value="Node"/> + <floater.string name="mesh_tittle" value="Mesh"/> + <floater.string name="skin_tittle" value="Skin"/> + + <layout_stack + name="main_layout" + orientation="vertical" + follows="all" + bottom="-1" + top="16" + left="5" + right="-1" + border_size="0"> + + <layout_panel + name="top_lp" + border="true" + bevel_style="in" + auto_resize="false" + user_resize="true" + visible="true" + height="200"> + <panel + follows="all" + layout="topleft" + name="item_list_panel" + visible="true" + bottom="-1" + top="1" + left="5" + right="-1"/> + </layout_panel> + + <layout_panel + name="transforms_panel" + border="true" + bevel_style="in" + auto_resize="true" + user_resize="true" + visible="true" + height="150"> + <menu_button + menu_filename="menu_copy_paste_pos.xml" + follows="top|left" + height="11" + image_disabled="ClipboardSmallMenu_Disabled" + image_selected="ClipboardSmallMenu_Press" + image_unselected="ClipboardSmallMenu_Off" + layout="topleft" + left="4" + top="10" + name="clipboard_pos_btn" + tool_tip="Paste options" + width="19"/> + <text + type="string" + length="1" + follows="left|top" + height="10" + layout="topleft" + name="label position" + tool_tip="Position (meters)" + left_pad="8" + top_delta="0" + width="121"> + Position (m) + </text> + <spinner + follows="left|top" + height="19" + increment="0.01" + initial_value="0" + label="X" + label_width="10" + layout="topleft" + left_delta="-27" + max_val="512" + min_val="-256" + name="Pos X" + text_enabled_color="1 0 0.3 .7" + top_pad="8" + width="87" /> + <spinner + follows="left|top" + height="19" + increment="0.01" + initial_value="0" + label="Y" + label_width="10" + layout="topleft" + left_delta="0" + max_val="512" + min_val="-256" + name="Pos Y" + text_enabled_color="EmphasisColor" + top_pad="3" + width="87" /> + <spinner + follows="left|top" + height="19" + increment="0.01" + initial_value="0" + label="Z" + label_width="10" + layout="topleft" + left_delta="0" + max_val="4096" + min_val="-32" + name="Pos Z" + text_enabled_color="0 0.8 1 .65" + top_pad="3" + width="87" /> + <menu_button + menu_filename="menu_copy_paste_size.xml" + follows="top|left" + height="11" + image_disabled="ClipboardSmallMenu_Disabled" + image_selected="ClipboardSmallMenu_Press" + image_unselected="ClipboardSmallMenu_Off" + layout="topleft" + left_delta="0" + top_pad="13" + name="clipboard_size_btn" + tool_tip="Paste options" + width="19"/> + <text + type="string" + length="1" + follows="left|top" + height="10" + layout="topleft" + left_pad="8" + top_delta="0" + name="label size" + tool_tip="Size (meters)" + width="121"> + Size (m) + </text> + <spinner + follows="left|top" + height="19" + increment="0.01" + initial_value="0" + label="X" + label_width="10" + layout="topleft" + left_delta="-27" + max_val="64" + min_val="0.01" + name="Scale X" + text_enabled_color="1 1 1 1" + top_pad="8" + width="87" /> + <spinner + follows="left|top" + height="19" + increment="0.01" + initial_value="0" + label="Y" + label_width="10" + layout="topleft" + left_delta="0" + max_val="64" + min_val="0.01" + name="Scale Y" + text_enabled_color="1 1 1 1" + top_pad="3" + width="87" /> + <spinner + follows="left|top" + height="19" + increment="0.01" + initial_value="0" + label="Z" + label_width="10" + layout="topleft" + left_delta="0" + max_val="64" + min_val="0.01" + name="Scale Z" + text_enabled_color="1 1 1 1" + top_pad="3" + width="87" /> + <menu_button + menu_filename="menu_copy_paste_rot.xml" + follows="top|left" + height="11" + image_disabled="ClipboardSmallMenu_Disabled" + image_selected="ClipboardSmallMenu_Press" + image_unselected="ClipboardSmallMenu_Off" + layout="topleft" + left_delta="0" + top_pad="13" + name="clipboard_rot_btn" + tool_tip="Paste options" + width="19"/> + <text + type="string" + length="1" + follows="left|top" + height="10" + layout="topleft" + left_pad="8" + top_delta="0" + name="label rotation" + tool_tip="Rotation (degrees)" + width="121"> + Rotation (°) + </text> + <spinner + decimal_digits="2" + follows="left|top" + height="19" + increment="1" + initial_value="0" + label="X" + label_width="10" + layout="topleft" + left_delta="-27" + max_val="9999" + min_val="-9999" + name="Rot X" + text_enabled_color="1 1 1 1" + top_pad="8" + width="87" /> + <spinner + decimal_digits="2" + follows="left|top" + height="19" + increment="1" + initial_value="0" + label="Y" + label_width="10" + layout="topleft" + left_delta="0" + max_val="9999" + min_val="-9999" + name="Rot Y" + text_enabled_color="1 1 1 1" + top_pad="3" + width="87" /> + <spinner + decimal_digits="2" + follows="left|top" + height="19" + increment="1" + initial_value="0" + label="Z" + label_width="10" + layout="topleft" + left_delta="0" + max_val="9999" + min_val="-9999" + name="Rot Z" + text_enabled_color="1 1 1 1" + top_pad="3" + width="87" /> + </layout_panel> + + <layout_panel + name="blank_panel" + border="true" + bevel_style="in" + auto_resize="true" + user_resize="true" + visible="false" + height="150"> + </layout_panel> + </layout_stack> +</floater> diff --git a/indra/newview/skins/default/xui/en/floater_im_container.xml b/indra/newview/skins/default/xui/en/floater_im_container.xml index 4df29c47de..176a2ca1a4 100644 --- a/indra/newview/skins/default/xui/en/floater_im_container.xml +++ b/indra/newview/skins/default/xui/en/floater_im_container.xml @@ -14,7 +14,7 @@ reuse_instance="true" title="CONVERSATIONS" bottom="-50" - right="-5" + left="5" width="450" min_width="38"> <string diff --git a/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml b/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml index 63185b537c..61738e73db 100644 --- a/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml +++ b/indra/newview/skins/default/xui/en/menu_people_nearby_multiselect.xml @@ -48,6 +48,9 @@ name="share"> <on_click function="Avatar.Share" /> + <on_enable + function="Avatar.EnableItem" + parameter="can_share" /> </menu_item_call> <menu_item_call enabled="false" @@ -56,6 +59,9 @@ name="pay"> <on_click function="Avatar.Pay" /> + <on_enable + function="Avatar.EnableItem" + parameter="can_pay" /> </menu_item_call> <menu_item_call label="Offer Teleport" diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index d5d2d00630..347638249b 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -2851,6 +2851,14 @@ function="World.EnvPreset" <menu_item_call.on_click function="Advanced.ClickGLTFUpload" /> </menu_item_call> + <menu_item_call + label="Edit..." + name="Edit..."> + <menu_item_call.on_enable + function="EnableGLTFUpload"/> + <menu_item_call.on_click + function="Advanced.ClickGLTFEdit" /> + </menu_item_call> </menu> <menu create_jump_keys="true" diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 73b001a526..2e08f6b3be 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -3032,6 +3032,15 @@ This is usually a temporary failure. Please customize and save the wearable agai </notification> <notification + icon="notifytip.tga" + name="OutOfDiskSpace" + type="notifytip"> +The system is out of disk space. You will need to free up some space on your computer or clear the cache. +<tag>fail</tag> + <unique/> + </notification> + + <notification icon="alertmodal.tga" name="YouHaveBeenLoggedOut" type="alertmodal"> @@ -4254,6 +4263,20 @@ Can't change appearance until clothing and shape are loaded. <notification icon="alertmodal.tga" + name="UsavedWearableChanges" + type="alertmodal"> +You have unsaved changes. + <tag>group</tag> + <tag>confirm</tag> + <usetemplate + ignoretext="Confirm before I discard unsaved wearable changes" + name="okcancelignore" + notext="Keep Editing" + yestext="Discard"/> + </notification> + + <notification + icon="alertmodal.tga" name="ClassifiedMustBeAlphanumeric" type="alertmodal"> The name of your classified must start with a letter from A to Z or a number. No punctuation is allowed. @@ -9060,17 +9083,6 @@ Your voice has been muted by moderator. name="okbutton" yestext="OK"/> </notification> - - <notification - icon="alertmodal.tga" - name="BulkUploadCostConfirmation" - type="alertmodal"> -This will upload [COUNT] items at a total cost of L$[COST]. Do you wish to continue with the upload? - <usetemplate - name="okcancelbuttons" - notext="Cancel" - yestext="Upload"/> - </notification> <notification icon="alertmodal.tga" diff --git a/indra/newview/skins/default/xui/es/floater_about.xml b/indra/newview/skins/default/xui/es/floater_about.xml index e14ba32f69..8103a95376 100644 --- a/indra/newview/skins/default/xui/es/floater_about.xml +++ b/indra/newview/skins/default/xui/es/floater_about.xml @@ -28,7 +28,6 @@ con contribuciones de código abierto de:</text> PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly y Mark Adler. diff --git a/indra/newview/skins/default/xui/fr/floater_about.xml b/indra/newview/skins/default/xui/fr/floater_about.xml index 09da1fb5fd..b6ea621177 100644 --- a/indra/newview/skins/default/xui/fr/floater_about.xml +++ b/indra/newview/skins/default/xui/fr/floater_about.xml @@ -28,7 +28,6 @@ avec les contributions Open Source de :</text> PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-Loup Gailly et Mark Adler. diff --git a/indra/newview/skins/default/xui/it/floater_about.xml b/indra/newview/skins/default/xui/it/floater_about.xml index 7e195d3ca9..77be47d749 100644 --- a/indra/newview/skins/default/xui/it/floater_about.xml +++ b/indra/newview/skins/default/xui/it/floater_about.xml @@ -28,7 +28,6 @@ con contributi open source da:</text> PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly e Mark Adler. diff --git a/indra/newview/skins/default/xui/ja/floater_about.xml b/indra/newview/skins/default/xui/ja/floater_about.xml index 12d763be37..6cd22f6a31 100644 --- a/indra/newview/skins/default/xui/ja/floater_about.xml +++ b/indra/newview/skins/default/xui/ja/floater_about.xml @@ -33,7 +33,6 @@ OpenSSL Copyright (C) 1998-2008 The OpenSSL Project. PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) -xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler. diff --git a/indra/newview/skins/default/xui/pt/floater_about.xml b/indra/newview/skins/default/xui/pt/floater_about.xml index aaed728f84..0e95c53109 100644 --- a/indra/newview/skins/default/xui/pt/floater_about.xml +++ b/indra/newview/skins/default/xui/pt/floater_about.xml @@ -28,7 +28,6 @@ com contribuições de código aberto de:</text> PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler. diff --git a/indra/newview/skins/default/xui/ru/floater_about.xml b/indra/newview/skins/default/xui/ru/floater_about.xml index a65a979ccd..22827bc397 100644 --- a/indra/newview/skins/default/xui/ru/floater_about.xml +++ b/indra/newview/skins/default/xui/ru/floater_about.xml @@ -28,7 +28,6 @@ PCRE (c) 1997-2012, Кембриджский университет SDL (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib (C) 1995-2012 Jean-loup Gailly и Mark Adler. diff --git a/indra/newview/skins/default/xui/tr/floater_about.xml b/indra/newview/skins/default/xui/tr/floater_about.xml index 40ca3707c3..ca21bee464 100644 --- a/indra/newview/skins/default/xui/tr/floater_about.xml +++ b/indra/newview/skins/default/xui/tr/floater_about.xml @@ -28,7 +28,6 @@ açık kaynak kod katkısında bulunanlar şunlardır:</text> PCRE Telif Hakkı (c) 1997-2012 University of Cambridge SDL Telif Hakkı (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Telif Hakkı (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Telif Hakkı (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Telif Hakkı (C) 1995-2012 Jean-loup Gailly ve Mark Adler. diff --git a/indra/newview/skins/default/xui/zh/floater_about.xml b/indra/newview/skins/default/xui/zh/floater_about.xml index a56ae753d1..727f598894 100644 --- a/indra/newview/skins/default/xui/zh/floater_about.xml +++ b/indra/newview/skins/default/xui/zh/floater_about.xml @@ -28,7 +28,6 @@ PCRE Copyright (c) 1997-2012 University of Cambridge SDL Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga SSLeay Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) - xmlrpc-epi Copyright (C) 2000 Epinions, Inc. xxHash Copyright (C) 2012-2020 Yann Collet. zlib Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler. diff --git a/indra/newview/tests/lldateutil_test.cpp b/indra/newview/tests/lldateutil_test.cpp index e9d4982e35..151aadfd4b 100644 --- a/indra/newview/tests/lldateutil_test.cpp +++ b/indra/newview/tests/lldateutil_test.cpp @@ -38,18 +38,23 @@ // Baked-in return values for getString() -std::map< std::string, std::string > gString; +std::map< std::string, std::string, std::less<>> gString; // Baked-in return values for getCountString() // map of pairs of input xml_desc and integer count typedef std::pair< std::string, int > count_string_t; std::map< count_string_t, std::string > gCountString; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(const std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { - std::string text = gString[xml_desc]; - LLStringUtil::format(text, args); - return text; + auto it = gString.find(xml_desc); + if (it != gString.end()) + { + std::string text = it->second; + LLStringUtil::format(text, args); + return text; + } + return {}; } std::string LLTrans::getCountString(const std::string& language, const std::string& xml_desc, S32 count) diff --git a/indra/newview/tests/lllogininstance_test.cpp b/indra/newview/tests/lllogininstance_test.cpp index df0f006d02..bff2289a7c 100644 --- a/indra/newview/tests/lllogininstance_test.cpp +++ b/indra/newview/tests/lllogininstance_test.cpp @@ -79,7 +79,7 @@ LLProgressView * LLViewerWindow::getProgressView(void) const { return 0; } LLViewerWindow* gViewerWindow; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { return std::string("test_trans"); } @@ -235,7 +235,7 @@ static LLEventPump * gTOSReplyPump = NULL; LLPointer<LLSecAPIHandler> gSecAPIHandler; //static -LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key, bool focus) +LLFloater* LLFloaterReg::showInstance(std::string_view name, const LLSD& key, bool focus) { gTOSType = name; gTOSReplyPump = &LLEventPumps::instance().obtain(key["reply_pump"]); diff --git a/indra/newview/tests/llslurl_test.cpp b/indra/newview/tests/llslurl_test.cpp index 3be44a9bd5..fc9f5b707a 100644 --- a/indra/newview/tests/llslurl_test.cpp +++ b/indra/newview/tests/llslurl_test.cpp @@ -46,10 +46,10 @@ static const char * const TEST_FILENAME("llslurl_test.xml"); class LLTrans { public: - static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); + static std::string getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); }; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { return std::string(); } diff --git a/indra/newview/tests/llviewernetwork_test.cpp b/indra/newview/tests/llviewernetwork_test.cpp index 40c2059d27..d9cb9e7538 100644 --- a/indra/newview/tests/llviewernetwork_test.cpp +++ b/indra/newview/tests/llviewernetwork_test.cpp @@ -45,10 +45,10 @@ static const char * const TEST_FILENAME("llviewernetwork_test.xml"); class LLTrans { public: - static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); + static std::string getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string = false); }; -std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args, bool def_string) +std::string LLTrans::getString(std::string_view xml_desc, const LLStringUtil::format_map_t& args, bool def_string) { std::string grid_label = std::string(); if(xml_desc == "AgniGridLabel") diff --git a/indra/newview/tests/llworldmap_test.cpp b/indra/newview/tests/llworldmap_test.cpp index 8564dbeeb6..d5bf189d82 100644 --- a/indra/newview/tests/llworldmap_test.cpp +++ b/indra/newview/tests/llworldmap_test.cpp @@ -66,7 +66,7 @@ void LLWorldMipmap::equalizeBoostLevels() { } LLPointer<LLViewerFetchedTexture> LLWorldMipmap::getObjectsTile(U32 grid_x, U32 grid_y, S32 level, bool load) { return NULL; } // Stub other stuff -std::string LLTrans::getString(const std::string &, const LLStringUtil::format_map_t&, bool def_string) { return std::string("test_trans"); } +std::string LLTrans::getString(std::string_view, const LLStringUtil::format_map_t&, bool def_string) { return std::string("test_trans"); } void LLUIString::updateResult() const { } void LLUIString::setArg(const std::string& , const std::string& ) { } void LLUIString::assign(const std::string& ) { } diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index 470c8bc8a8..5b6ac27575 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -567,8 +567,13 @@ class Windows_x86_64_Manifest(ViewerManifest): # These need to be installed as a SxS assembly, currently a 'private' assembly. # See http://msdn.microsoft.com/en-us/library/ms235291(VS.80).aspx self.path("msvcp140.dll") + self.path_optional("msvcp140_1.dll") + self.path_optional("msvcp140_2.dll") + self.path_optional("msvcp140_atomic_wait.dll") + self.path_optional("msvcp140_codecvt_ids.dll") self.path("vcruntime140.dll") self.path_optional("vcruntime140_1.dll") + self.path_optional("vcruntime140_threads.dll") # SLVoice executable with self.prefix(src=os.path.join(pkgdir, 'bin', 'release')): diff --git a/indra/test/io.cpp b/indra/test/io.cpp index 3bb549a98a..f77402065a 100644 --- a/indra/test/io.cpp +++ b/indra/test/io.cpp @@ -293,7 +293,7 @@ namespace tut len = BUFFER_LEN; last = mBuffer.readAfter(ch.in(), last, (U8*)buf, len); char* newline = strchr((char*)buf, '\n'); - S32 offset = -((len - 1) - (newline - buf)); + S32 offset = -((len - 1) - (S32)(newline - buf)); ++newline; *newline = '\0'; last_line.assign(buf); diff --git a/indra/test/test.cpp b/indra/test/test.cpp index cbd1077306..6c4a1f43b4 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -107,7 +107,7 @@ public: virtual void recordMessage(LLError::ELevel level, const std::string& message) { - LL_PROFILE_ZONE_SCOPED + LL_PROFILE_ZONE_SCOPED; mFile << message << std::endl; } diff --git a/indra/viewer_components/login/lllogin.cpp b/indra/viewer_components/login/lllogin.cpp index 2a0468f3ad..48fecb4f22 100644 --- a/indra/viewer_components/login/lllogin.cpp +++ b/indra/viewer_components/login/lllogin.cpp @@ -66,6 +66,16 @@ public: LLEventPump& getEventPump() { return mPump; } private: + LLSD hidePasswd(const LLSD& data) + { + LLSD result(data); + if (result.has("params") && result["params"].has("passwd")) + { + result["params"]["passwd"] = "*******"; + } + return result; + } + LLSD getProgressEventLLSD(const std::string& state, const std::string& change, const LLSD& data = LLSD()) { @@ -74,15 +84,16 @@ private: status_data["change"] = change; status_data["progress"] = 0.0f; - if(mAuthResponse.has("transfer_rate")) + if (mAuthResponse.has("transfer_rate")) { status_data["transfer_rate"] = mAuthResponse["transfer_rate"]; } - if(data.isDefined()) + if (data.isDefined()) { status_data["data"] = data; } + return status_data; } @@ -119,17 +130,18 @@ private: void LLLogin::Impl::connect(const std::string& uri, const LLSD& login_params) { - LL_DEBUGS("LLLogin") << " connect with uri '" << uri << "', login_params " << login_params << LL_ENDL; + LL_DEBUGS("LLLogin") << " connect with uri '" << uri << "', login_params " << login_params << LL_ENDL; // Launch a coroutine with our login_() method. Run the coroutine until // its first wait; at that point, return here. std::string coroname = - LLCoros::instance().launch("LLLogin::Impl::login_", - boost::bind(&Impl::loginCoro, this, uri, login_params)); - LL_DEBUGS("LLLogin") << " connected with uri '" << uri << "', login_params " << login_params << LL_ENDL; + LLCoros::instance().launch("LLLogin::Impl::login_", [&]() { loginCoro(uri, login_params); }); + + LL_DEBUGS("LLLogin") << " connected with uri '" << uri << "', login_params " << login_params << LL_ENDL; } -namespace { +namespace +{ // Instantiate this rendezvous point at namespace scope so it's already // present no matter how early the updater might post to it. // Use an LLEventMailDrop, which has future-like semantics: regardless of the @@ -140,12 +152,8 @@ static LLEventMailDrop sSyncPoint("LoginSync"); void LLLogin::Impl::loginCoro(std::string uri, LLSD login_params) { - LLSD printable_params = login_params; - if (printable_params.has("params") - && printable_params["params"].has("passwd")) - { - printable_params["params"]["passwd"] = "*******"; - } + LLSD printable_params = hidePasswd(login_params); + try { LL_DEBUGS("LLLogin") << "Entering coroutine " << LLCoros::getName() @@ -171,12 +179,7 @@ void LLLogin::Impl::loginCoro(std::string uri, LLSD login_params) ++attempts; LLSD progress_data; progress_data["attempt"] = attempts; - progress_data["request"] = request; - if (progress_data["request"].has("params") - && progress_data["request"]["params"].has("passwd")) - { - progress_data["request"]["params"]["passwd"] = "*******"; - } + progress_data["request"] = hidePasswd(request); sendProgressEvent("offline", "authenticating", progress_data); // We expect zero or more "Downloading" status events, followed by |