diff --git a/.gitignore b/.gitignore index 1521cf9a46189f6b57ab740a6818dd03a35d8503..49d5a3d8bb6c5d5879b041d50e249843996f2ef1 100755 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ indra/newview/search_history.txt indra/newview/teleport_history.txt indra/newview/typed_locations.txt indra/newview/vivox-runtime +indra/newview/skins/default/html/common/equirectangular/js indra/server-linux-* indra/temp indra/test/linden_file.dat diff --git a/autobuild.xml b/autobuild.xml index 62c08d7c44ce52fd3a4fd55eb50a812ff8309e91..e71c122a23a8861a753a951975334831f758c3c9 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -289,6 +289,58 @@ <key>version</key> <string>2.3.0</string> </map> + <key>cubemaptoequirectangular</key> + <map> + <key>copyright</key> + <string>Copyright (c) 2017 Jaume Sanchez Elias, http://www.clicktorelease.com</string> + <key>license</key> + <string>MIT</string> + <key>license_file</key> + <string>LICENSES/CUBEMAPTOEQUIRECTANGULAR_LICENSE.txt</string> + <key>name</key> + <string>cubemaptoequirectangular</string> + <key>platforms</key> + <map> + <key>darwin64</key> + <map> + <key>archive</key> + <map> + <key>hash</key> + <string>7e4622b497bc465b01ff6d3e7e0b4214</string> + <key>url</key> + <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/89303/815402/cubemaptoequirectangular-1.1.0-darwin64-564841.tar.bz2</string> + </map> + <key>name</key> + <string>darwin64</string> + </map> + <key>windows</key> + <map> + <key>archive</key> + <map> + <key>hash</key> + <string>b5ea7097ae10037024b0c2b3df9812b5</string> + <key>url</key> + <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/89307/815434/cubemaptoequirectangular-1.1.0-windows-564841.tar.bz2</string> + </map> + <key>name</key> + <string>windows</string> + </map> + <key>windows64</key> + <map> + <key>archive</key> + <map> + <key>hash</key> + <string>ac54672e0b38f52726f5c99047c913e4</string> + <key>url</key> + <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/89306/815431/cubemaptoequirectangular-1.1.0-windows64-564841.tar.bz2</string> + </map> + <key>name</key> + <string>windows64</string> + </map> + </map> + <key>version</key> + <string>1.1.0</string> + </map> <key>curl</key> <map> <key>copyright</key> @@ -743,6 +795,58 @@ <key>version</key> <string>0.10.6.314267</string> </map> + <key>jpegencoderbasic</key> + <map> + <key>copyright</key> + <string>Andreas Ritter, www.bytestrom.eu, 11/2009</string> + <key>license</key> + <string>NONE</string> + <key>license_file</key> + <string>LICENSES/JPEG_ENCODER_BASIC_LICENSE.txt</string> + <key>name</key> + <string>jpegencoderbasic</string> + <key>platforms</key> + <map> + <key>darwin64</key> + <map> + <key>archive</key> + <map> + <key>hash</key> + <string>c3c9e60bdc12b35e0e3d6b67d5635f60</string> + <key>url</key> + <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/89304/815407/jpegencoderbasic-1.0-darwin64-564842.tar.bz2</string> + </map> + <key>name</key> + <string>darwin64</string> + </map> + <key>windows</key> + <map> + <key>archive</key> + <map> + <key>hash</key> + <string>0a376676dbb43fdd0c81ffdfbc5e6f81</string> + <key>url</key> + <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/89308/815432/jpegencoderbasic-1.0-windows-564842.tar.bz2</string> + </map> + <key>name</key> + <string>windows</string> + </map> + <key>windows64</key> + <map> + <key>archive</key> + <map> + <key>hash</key> + <string>e70898903475d8ac2e81ff33278fc987</string> + <key>url</key> + <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/89309/815433/jpegencoderbasic-1.0-windows64-564842.tar.bz2</string> + </map> + <key>name</key> + <string>windows64</string> + </map> + </map> + <key>version</key> + <string>1.0</string> + </map> <key>kdu</key> <map> <key>copyright</key> @@ -1885,6 +1989,58 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string> <key>version</key> <string>4.10.0000.32327.5fc3fe7c.558436</string> </map> + <key>threejs</key> + <map> + <key>copyright</key> + <string>Copyright © 2010-2021 three.js authors</string> + <key>license</key> + <string>MIT</string> + <key>license_file</key> + <string>LICENSES/THREEJS_LICENSE.txt</string> + <key>name</key> + <string>threejs</string> + <key>platforms</key> + <map> + <key>darwin64</key> + <map> + <key>archive</key> + <map> + <key>hash</key> + <string>24440e8219e59d81423b68d3be381fef</string> + <key>url</key> + <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/89305/815412/threejs-0.132.2-darwin64-564843.tar.bz2</string> + </map> + <key>name</key> + <string>darwin64</string> + </map> + <key>windows</key> + <map> + <key>archive</key> + <map> + <key>hash</key> + <string>e1303fb9f2242a79aee5fd9f97726ace</string> + <key>url</key> + <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/89311/815452/threejs-0.132.2-windows-564843.tar.bz2</string> + </map> + <key>name</key> + <string>windows</string> + </map> + <key>windows64</key> + <map> + <key>archive</key> + <map> + <key>hash</key> + <string>46edf0f55417f8ef0d33a5c007bc3644</string> + <key>url</key> + <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/89310/815451/threejs-0.132.2-windows64-564843.tar.bz2</string> + </map> + <key>name</key> + <string>windows64</string> + </map> + </map> + <key>version</key> + <string>0.132.2</string> + </map> <key>tut</key> <map> <key>copyright</key> @@ -1996,9 +2152,9 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string> <key>archive</key> <map> <key>hash</key> - <string>97fac6d88480445c856083ed20d78093</string> + <string>a3c8357a2f5a62cd7de43181b02553bc</string> <key>url</key> - <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/85206/790666/viewer_manager-2.0.562101-darwin64-562101.tar.bz2</string> + <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/91396/829032/viewer_manager-2.0.566227-darwin64-566227.tar.bz2</string> </map> <key>name</key> <string>darwin64</string> @@ -2008,9 +2164,9 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string> <key>archive</key> <map> <key>hash</key> - <string>3f6271ec0e2e2f0cc1067d4c4102bb4c</string> + <string>0654b449d9bdf3507664cf5caa67336f</string> <key>url</key> - <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/85208/790681/viewer_manager-2.0.562101-windows-562101.tar.bz2</string> + <string>https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/91397/829041/viewer_manager-2.0.566227-windows-566227.tar.bz2</string> </map> <key>name</key> <string>windows</string> @@ -2021,7 +2177,7 @@ Copyright (c) 2012, 2014, 2015, 2016 nghttp2 contributors</string> <key>source_type</key> <string>hg</string> <key>version</key> - <string>2.0.562101</string> + <string>2.0.566227</string> </map> <key>vlc-bin</key> <map> diff --git a/doc/contributions.txt b/doc/contributions.txt index e918a0d3ac710d6e02c93b0a7882749f95625548..d3d9ef5cc710e26e46cacf556a613c8769681371 100755 --- a/doc/contributions.txt +++ b/doc/contributions.txt @@ -227,8 +227,15 @@ Ansariel Hiller SL-13364 SL-13858 SL-13697 + SL-14939 + SL-14940 + SL-14941 SL-13395 SL-3136 + SL-15200 + SL-15226 + SL-15227 + SL-15398 Aralara Rajal Arare Chantilly CHUIBUG-191 diff --git a/indra/cmake/CubemapToEquirectangularJS.cmake b/indra/cmake/CubemapToEquirectangularJS.cmake new file mode 100644 index 0000000000000000000000000000000000000000..bfe29260051a6f9b5fdae8553037b73b2ee9646e --- /dev/null +++ b/indra/cmake/CubemapToEquirectangularJS.cmake @@ -0,0 +1,5 @@ +# -*- cmake -*- +use_prebuilt_binary(cubemaptoequirectangular) + +# Main JS file +configure_file("${AUTOBUILD_INSTALL_DIR}/js/CubemapToEquirectangular.js" "${CMAKE_SOURCE_DIR}/newview/skins/default/html/common/equirectangular/js/CubemapToEquirectangular.js" COPYONLY) diff --git a/indra/cmake/JPEGEncoderBasic.cmake b/indra/cmake/JPEGEncoderBasic.cmake new file mode 100644 index 0000000000000000000000000000000000000000..0d2a3231bbb8ecf22e5109c51a90ac3cdfb7c67b --- /dev/null +++ b/indra/cmake/JPEGEncoderBasic.cmake @@ -0,0 +1,5 @@ +# -*- cmake -*- +use_prebuilt_binary(jpegencoderbasic) + +# Main JS file +configure_file("${AUTOBUILD_INSTALL_DIR}/js/jpeg_encoder_basic.js" "${CMAKE_SOURCE_DIR}/newview/skins/default/html/common/equirectangular/js/jpeg_encoder_basic.js" COPYONLY) diff --git a/indra/cmake/ThreeJS.cmake b/indra/cmake/ThreeJS.cmake new file mode 100644 index 0000000000000000000000000000000000000000..528adcbb25be14ee228af882ba77d1d344fa409b --- /dev/null +++ b/indra/cmake/ThreeJS.cmake @@ -0,0 +1,8 @@ +# -*- cmake -*- +use_prebuilt_binary(threejs) + +# Main three.js file +configure_file("${AUTOBUILD_INSTALL_DIR}/js/three.min.js" "${CMAKE_SOURCE_DIR}/newview/skins/default/html/common/equirectangular/js/three.min.js" COPYONLY) + +# Controls to move around the scene using mouse or keyboard +configure_file("${AUTOBUILD_INSTALL_DIR}/js/OrbitControls.js" "${CMAKE_SOURCE_DIR}/newview/skins/default/html/common/equirectangular/js/OrbitControls.js" COPYONLY) diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index a6b529f66d3daeff887887bc07ce8f12b7ce8e54..78ad6ae4bfaf02a8ad132be39c9dfab60046a4eb 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -94,7 +94,8 @@ BOOL LLApp::sDisableCrashlogger = FALSE; BOOL LLApp::sLogInSignal = FALSE; // static -LLApp::EAppStatus LLApp::sStatus = LLApp::APP_STATUS_STOPPED; // Keeps track of application status +// Keeps track of application status +LLScalarCond<LLApp::EAppStatus> LLApp::sStatus{LLApp::APP_STATUS_STOPPED}; LLAppErrorHandler LLApp::sErrorHandler = NULL; BOOL LLApp::sErrorThreadRunning = FALSE; @@ -445,7 +446,8 @@ static std::map<LLApp::EAppStatus, const char*> statusDesc // static void LLApp::setStatus(EAppStatus status) { - sStatus = status; + // notify everyone waiting on sStatus any time its value changes + sStatus.set_all(status); // This can also happen very late in the application lifecycle -- don't // resurrect a deleted LLSingleton @@ -503,28 +505,28 @@ void LLApp::setStopped() // static bool LLApp::isStopped() { - return (APP_STATUS_STOPPED == sStatus); + return (APP_STATUS_STOPPED == sStatus.get()); } // static bool LLApp::isRunning() { - return (APP_STATUS_RUNNING == sStatus); + return (APP_STATUS_RUNNING == sStatus.get()); } // static bool LLApp::isError() { - return (APP_STATUS_ERROR == sStatus); + return (APP_STATUS_ERROR == sStatus.get()); } // static bool LLApp::isQuitting() { - return (APP_STATUS_QUITTING == sStatus); + return (APP_STATUS_QUITTING == sStatus.get()); } // static diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h index d75df330ddf42e3b1c628688bff246dc55e409ef..8740cb8000befd57098594eb9e9a5602871c8d69 100644 --- a/indra/llcommon/llapp.h +++ b/indra/llcommon/llapp.h @@ -28,9 +28,11 @@ #define LL_LLAPP_H #include <map> +#include "llcond.h" #include "llrun.h" #include "llsd.h" #include <atomic> +#include <chrono> // Forward declarations class LLErrorThread; class LLLiveFile; @@ -207,6 +209,36 @@ class LL_COMMON_API LLApp static bool isExiting(); // Either quitting or error (app is exiting, cleanly or not) static int getPid(); + // + // Sleep for specified time while still running + // + // For use by a coroutine or thread that performs some maintenance on a + // periodic basis. (See also LLEventTimer.) This method supports the + // pattern of an "infinite" loop that sleeps for some time, performs some + // action, then sleeps again. The trouble with literally sleeping a worker + // thread is that it could potentially sleep right through attempted + // application shutdown. This method avoids that by returning false as + // soon as the application status changes away from APP_STATUS_RUNNING + // (isRunning()). + // + // sleep() returns true if it sleeps undisturbed for the entire specified + // duration. The idea is that you can code 'while sleep(duration) ...', + // which will break the loop once shutdown begins. + // + // Since any time-based LLUnit should be implicitly convertible to + // F32Milliseconds, accept that specific type as a proxy. + static bool sleep(F32Milliseconds duration); + // Allow any duration defined in terms of <chrono>. + // One can imagine a wonderfully general bidirectional conversion system + // between any type derived from LLUnits::LLUnit<T, LLUnits::Seconds> and + // any std::chrono::duration -- but that doesn't yet exist. + template <typename Rep, typename Period> + bool sleep(const std::chrono::duration<Rep, Period>& duration) + { + // wait_for_unequal() has the opposite bool return convention + return ! sStatus.wait_for_unequal(duration, APP_STATUS_RUNNING); + } + /** @name Error handling methods */ //@{ /** @@ -235,8 +267,8 @@ class LL_COMMON_API LLApp void setDebugFileNames(const std::string &path); // Return the Google Breakpad minidump filename after a crash. - std::string* getStaticDebugFile() { return &mStaticDebugFileName; } - std::string* getDynamicDebugFile() { return &mDynamicDebugFileName; } + std::string* getStaticDebugFile() { return &mStaticDebugFileName; } + std::string* getDynamicDebugFile() { return &mDynamicDebugFileName; } /** * @brief Get a reference to the application runner @@ -262,7 +294,7 @@ class LL_COMMON_API LLApp protected: static void setStatus(EAppStatus status); // Use this to change the application status. - static EAppStatus sStatus; // Reflects current application status + static LLScalarCond<EAppStatus> sStatus; // Reflects current application status static BOOL sErrorThreadRunning; // Set while the error thread is running static BOOL sDisableCrashlogger; // Let the OS handle crashes for us. diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 6cbf0e6373d79261af7fe6fe99b7dd3334567075..4548e858a4b8e7b12d6431472261f0a1e18adcf0 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -27,7 +27,6 @@ #ifndef LL_LLTHREAD_H #define LL_LLTHREAD_H -#include "llapp.h" #include "llapr.h" #include "llrefcount.h" #include <thread> diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp index 2f71168f9233c8fd64df6c7a76fa4830855f3a5a..120c15c6bc48fa6431fa71539d0b08d1111fb92c 100644 --- a/indra/llcommon/lluuid.cpp +++ b/indra/llcommon/lluuid.cpp @@ -33,6 +33,7 @@ #include <iphlpapi.h> #endif +#include "llapp.h" #include "lldefs.h" #include "llerror.h" diff --git a/indra/llfilesystem/lldiskcache.cpp b/indra/llfilesystem/lldiskcache.cpp index 2da3cdd0897809d368ee49d5158058f11fef393f..41efcd170df7e5f5581e8d866cd84d2be925be93 100644 --- a/indra/llfilesystem/lldiskcache.cpp +++ b/indra/llfilesystem/lldiskcache.cpp @@ -31,6 +31,7 @@ */ #include "linden_common.h" +#include "llapp.h" #include "llassettype.h" #include "lldir.h" #include <boost/filesystem.hpp> @@ -61,9 +62,37 @@ void LLDiskCache::createCache() { LLFile::mkdir(absl::StrCat(sCacheDir, gDirUtilp->getDirDelimiter(), prefixchar)); } - prepopulateCacheWithStatic(); + prepopulateCacheWithStatic(); } +// WARNING: purge() is called by LLPurgeDiskCacheThread. As such it must +// NOT touch any LLDiskCache data without introducing and locking a mutex! + +// Interaction through the filesystem itself should be safe. Let’s say thread +// A is accessing the cache file for reading/writing and thread B is trimming +// the cache. Let’s also assume using llifstream to open a file and +// boost::filesystem::remove are not atomic (which will be pretty much the +// case). + +// Now, A is trying to open the file using llifstream ctor. It does some +// checks if the file exists and whatever else it might be doing, but has not +// issued the call to the OS to actually open the file yet. Now B tries to +// delete the file: If the file has been already marked as in use by the OS, +// deleting the file will fail and B will continue with the next file. A can +// safely continue opening the file. If the file has not yet been marked as in +// use, B will delete the file. Now A actually wants to open it, operation +// will fail, subsequent check via llifstream.is_open will fail, asset will +// have to be re-requested. (Assuming here the viewer will actually handle +// this situation properly, that can also happen if there is a file containing +// garbage.) + +// Other situation: B is trimming the cache and A wants to read a file that is +// about to get deleted. boost::filesystem::remove does whatever it is doing +// before actually deleting the file. If A opens the file before the file is +// actually gone, the OS call from B to delete the file will fail since the OS +// will prevent this. B continues with the next file. If the file is already +// gone before A finally gets to open it, this operation will fail and the +// asset will have to be re-requested. void LLDiskCache::purge() { if (mEnableCacheDebugInfo) @@ -71,6 +100,7 @@ void LLDiskCache::purge() LL_INFOS() << "Total dir size before purge is " << dirFileSize(sCacheDir) << LL_ENDL; } + boost::system::error_code ec; auto start_time = std::chrono::high_resolution_clock::now(); typedef std::pair<std::time_t, std::pair<uintmax_t, boost::filesystem::path>> file_info_t; @@ -81,7 +111,6 @@ void LLDiskCache::purge() #else std::string cache_path(sCacheDir); #endif - boost::system::error_code ec; if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed()) { for (auto& entry : boost::make_iterator_range(boost::filesystem::recursive_directory_iterator(cache_path), {})) @@ -282,6 +311,7 @@ void LLDiskCache::updateFileAccessTime(const boost::filesystem::path& file_path) const std::string LLDiskCache::getCacheInfo() { uintmax_t cache_used_mb = dirFileSize(sCacheDir) / (1024U * 1024U); + uintmax_t max_in_mb = mMaxSizeBytes / (1024U * 1024U); F64 percent_used = ((F64)cache_used_mb / (F64)max_in_mb) * 100.0; @@ -345,12 +375,12 @@ void LLDiskCache::clearCache() * the component files but it's called infrequently so it's * likely just fine */ + boost::system::error_code ec; #if LL_WINDOWS boost::filesystem::path cache_path(ll_convert_string_to_wide(sCacheDir)); #else boost::filesystem::path cache_path(sCacheDir); #endif - boost::system::error_code ec; if (boost::filesystem::is_directory(cache_path, ec) && !ec.failed()) { boost::filesystem::remove_all(cache_path, ec); @@ -376,12 +406,12 @@ uintmax_t LLDiskCache::dirFileSize(const std::string dir) * so if performance is ever an issue, optimizing this or removing it altogether, * is an easy win. */ + boost::system::error_code ec; #if LL_WINDOWS boost::filesystem::path dir_path(ll_convert_string_to_wide(dir)); #else boost::filesystem::path dir_path(dir); #endif - boost::system::error_code ec; if (boost::filesystem::is_directory(dir_path, ec) && !ec.failed()) { for (auto& entry : boost::make_iterator_range(boost::filesystem::recursive_directory_iterator(dir_path), {})) @@ -405,3 +435,18 @@ uintmax_t LLDiskCache::dirFileSize(const std::string dir) return total_file_size; } + +LLPurgeDiskCacheThread::LLPurgeDiskCacheThread() : + LLThread("PurgeDiskCacheThread", nullptr) +{ +} + +void LLPurgeDiskCacheThread::run() +{ + constexpr std::chrono::seconds CHECK_INTERVAL{60}; + + while (LLApp::instance()->sleep(CHECK_INTERVAL)) + { + LLDiskCache::instance().purge(); + } +} diff --git a/indra/llfilesystem/lldiskcache.h b/indra/llfilesystem/lldiskcache.h index 67d174567579d6ed55d88932f2fe635e38e62f8e..bd38ffcfe560eb8bc9c7077692dea3f4d13ac2f9 100644 --- a/indra/llfilesystem/lldiskcache.h +++ b/indra/llfilesystem/lldiskcache.h @@ -115,9 +115,17 @@ class LLDiskCache final : * accessed is up to date (This is used in the mechanism for purging the cache) */ void updateFileAccessTime(const boost::filesystem::path& file_path); + /** * Purge the oldest items in the cache so that the combined size of all files * is no bigger than mMaxSizeBytes. + * + * WARNING: purge() is called by LLPurgeDiskCacheThread. As such it must + * NOT touch any LLDiskCache data without introducing and locking a mutex! + * + * Purging the disk cache involves nontrivial work on the viewer's + * filesystem. If called on the main thread, this causes a noticeable + * freeze. */ void purge(); @@ -191,4 +199,12 @@ class LLDiskCache final : absl::flat_hash_set<LLUUID> mSkipList; }; +class LLPurgeDiskCacheThread : public LLThread +{ +public: + LLPurgeDiskCacheThread(); + +protected: + void run() override; +}; #endif // _LLDISKCACHE diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index 72848739a6eb42b27bf9e5280268145e7fdd1aad..6daeb369903607cce0e14aae06ff1e176b01f9f9 100644 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -48,6 +48,7 @@ #include "apr_poll.h" // linden library headers +#include "llapp.h" #include "indra_constants.h" #include "lldir.h" #include "llerror.h" diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp index acfcae22be6d99652c741cc391ccee7453d96fc9..37a66269fea541bf52b0075a77f848e29bf43780 100644 --- a/indra/llplugin/llpluginclassmedia.cpp +++ b/indra/llplugin/llpluginclassmedia.cpp @@ -769,6 +769,15 @@ void LLPluginClassMedia::loadURI(const std::string &uri) sendMessage(message); } +void LLPluginClassMedia::executeJavaScript(const std::string &code) +{ + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "execute_javascript"); + + message.setValue("code", code); + + sendMessage(message); +} + const char* LLPluginClassMedia::priorityToString(EPriority priority) { const char* result = "UNKNOWN"; @@ -988,6 +997,19 @@ void LLPluginClassMedia::setJavascriptEnabled(const bool enabled) sendMessage(message); } +void LLPluginClassMedia::setWebSecurityDisabled(const bool disabled) +{ + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "web_security_disabled"); + message.setValueBoolean("disabled", disabled); + sendMessage(message); +} + +void LLPluginClassMedia::setFileAccessFromFileUrlsEnabled(const bool enabled) +{ + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "file_access_from_file_urls"); + message.setValueBoolean("enabled", enabled); + sendMessage(message); +} void LLPluginClassMedia::enableMediaPluginDebugging( bool enable ) { diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h index cf8bf667bd41f0b36ef1b5c4520c29db84885bd8..e4c2bab1e6e6524ff121b3560d93313edc3e5950 100644 --- a/indra/llplugin/llpluginclassmedia.h +++ b/indra/llplugin/llpluginclassmedia.h @@ -153,6 +153,8 @@ class LLPluginClassMedia final : public LLPluginProcessParentOwner void loadURI(const std::string &uri); + void executeJavaScript(const std::string &code); + // "Loading" means uninitialized or any state prior to fully running (processing commands) bool isPluginLoading(void) { return mPlugin?mPlugin->isLoading():false; }; @@ -228,6 +230,8 @@ class LLPluginClassMedia final : public LLPluginProcessParentOwner void setLanguageCode(const std::string &language_code); void setPluginsEnabled(const bool enabled); void setJavascriptEnabled(const bool enabled); + void setWebSecurityDisabled(const bool disabled); + void setFileAccessFromFileUrlsEnabled(const bool enabled); void setTarget(const std::string &target); /////////////////////////////////// diff --git a/indra/llplugin/llpluginprocessparent.cpp b/indra/llplugin/llpluginprocessparent.cpp index 344eb2fee0b467ef6ba0e9adca84bedff0ebca73..51f0cf409d2e03870ee0e18beeb7f5da3ede4c9d 100644 --- a/indra/llplugin/llpluginprocessparent.cpp +++ b/indra/llplugin/llpluginprocessparent.cpp @@ -28,6 +28,7 @@ #include "linden_common.h" +#include "llapp.h" #include "llpluginprocessparent.h" #include "llpluginmessagepipe.h" #include "llpluginmessageclasses.h" diff --git a/indra/media_plugins/cef/media_plugin_cef.cpp b/indra/media_plugins/cef/media_plugin_cef.cpp index 8d6084eb1cb57b7057d73a9a52d02d8f6ad7fa38..0528ccc9028e8e344a6c536239719c0e4535b02a 100644 --- a/indra/media_plugins/cef/media_plugin_cef.cpp +++ b/indra/media_plugins/cef/media_plugin_cef.cpp @@ -62,7 +62,7 @@ class MediaPluginCEF : void onTooltipCallback(std::string text); void onLoadStartCallback(); void onRequestExitCallback(); - void onLoadEndCallback(int httpStatusCode); + void onLoadEndCallback(int httpStatusCode, std::string url); void onLoadError(int status, const std::string error_text); void onAddressChangeCallback(std::string url); void onOpenPopupCallback(std::string url, std::string target); @@ -92,6 +92,8 @@ class MediaPluginCEF : bool mDisableGPU; bool mDisableNetworkService; bool mUseMockKeyChain; + bool mDisableWebSecurity; + bool mFileAccessFromFileUrls; std::string mUserAgentSubtring; std::string mAuthUsername; std::string mAuthPassword; @@ -138,6 +140,8 @@ MediaPluginBase(host_send_func, host_user_data) mDisableGPU = false; mDisableNetworkService = true; mUseMockKeyChain = true; + mDisableWebSecurity = false; + mFileAccessFromFileUrls = false; mUserAgentSubtring = ""; mAuthUsername = ""; mAuthPassword = ""; @@ -279,13 +283,14 @@ void MediaPluginCEF::onRequestExitCallback() //////////////////////////////////////////////////////////////////////////////// // -void MediaPluginCEF::onLoadEndCallback(int httpStatusCode) +void MediaPluginCEF::onLoadEndCallback(int httpStatusCode, std::string url) { LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_complete"); //message.setValue("uri", event.getEventUri()); // not easily available here in CEF - needed? message.setValueS32("result_code", httpStatusCode); message.setValueBoolean("history_back_available", mCEFLib->canGoBack()); message.setValueBoolean("history_forward_available", mCEFLib->canGoForward()); + message.setValue("uri", url); sendMessage(message); } @@ -382,14 +387,16 @@ const std::vector<std::string> MediaPluginCEF::onFileDialog(dullahan::EFileDialo } else if (dialog_type == dullahan::FD_SAVE_FILE) { + mPickedFiles.clear(); mAuthOK = false; LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "file_download"); + message.setValueBoolean("blocking_request", true); message.setValue("filename", default_file); sendMessage(message); - return std::vector<std::string>(); + return mPickedFiles; } return std::vector<std::string>(); @@ -550,7 +557,7 @@ void MediaPluginCEF::receiveMessage(const char* message_string) mCEFLib->setOnTitleChangeCallback(std::bind(&MediaPluginCEF::onTitleChangeCallback, this, std::placeholders::_1)); mCEFLib->setOnTooltipCallback(std::bind(&MediaPluginCEF::onTooltipCallback, this, std::placeholders::_1)); mCEFLib->setOnLoadStartCallback(std::bind(&MediaPluginCEF::onLoadStartCallback, this)); - mCEFLib->setOnLoadEndCallback(std::bind(&MediaPluginCEF::onLoadEndCallback, this, std::placeholders::_1)); + mCEFLib->setOnLoadEndCallback(std::bind(&MediaPluginCEF::onLoadEndCallback, this, std::placeholders::_1, std::placeholders::_2)); mCEFLib->setOnLoadErrorCallback(std::bind(&MediaPluginCEF::onLoadError, this, std::placeholders::_1, std::placeholders::_2)); mCEFLib->setOnAddressChangeCallback(std::bind(&MediaPluginCEF::onAddressChangeCallback, this, std::placeholders::_1)); mCEFLib->setOnOpenPopupCallback(std::bind(&MediaPluginCEF::onOpenPopupCallback, this, std::placeholders::_1, std::placeholders::_2)); @@ -590,6 +597,17 @@ void MediaPluginCEF::receiveMessage(const char* message_string) settings.disable_network_service = mDisableNetworkService; settings.use_mock_keychain = mUseMockKeyChain; #endif + // these were added to facilitate loading images directly into a local + // web page for the prototype 360 project in 2017 - something that is + // disallowed normally by the browser security model. Now the the source + // (cubemap) images are stores as JavaScript, we can avoid opening up + // this security hole (it was only set for the 360 floater but still + // a concern). Leaving them here, explicitly turn off vs removing + // entirely from this source file so that others are aware of them + // in the future. + settings.disable_web_security = false; + settings.file_access_from_file_urls = false; + // This setting applies to all plugins, not just Flash // Regarding, SL-15559 PDF files do not load in CEF v91, // it turns out that on Windows, PDF support is treated @@ -744,6 +762,11 @@ void MediaPluginCEF::receiveMessage(const char* message_string) std::string uri = message_in.getValue("uri"); mCEFLib->navigate(uri); } + else if (message_name == "execute_javascript") + { + std::string code = message_in.getValue("code"); + mCEFLib->executeJavaScript(code); + } else if (message_name == "set_cookie") { std::string uri = message_in.getValue("uri"); @@ -977,6 +1000,14 @@ void MediaPluginCEF::receiveMessage(const char* message_string) { mDisableGPU = message_in.getValueBoolean("disable"); } + else if (message_name == "web_security_disabled") + { + mDisableWebSecurity = message_in.getValueBoolean("disabled"); + } + else if (message_name == "file_access_from_file_urls") + { + mFileAccessFromFileUrls = message_in.getValueBoolean("enabled"); + } else if (message_name == "proxy_setup") { mProxyEnabled = message_in.getValueBoolean("enable"); diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 9181b2d174551e79682f6074fe34bfe46df2f541..92ef6757ed8950e7e0cb977715798d9654a6f586 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -12,6 +12,7 @@ include(Boost) include(BuildPackagesInfo) include(BuildVersion) include(CMakeCopyIfDifferent) +include(CubemapToEquirectangularJS) include(DBusGlib) include(DragDrop) include(Epoxy) @@ -20,6 +21,7 @@ include(FMODSTUDIO) include(Fonts) include(GLOD) include(Hunspell) +include(JPEGEncoderBasic) include(LLAppearance) include(LLAudio) include(LLCA) @@ -49,6 +51,7 @@ include(OpenSSL) include(PNG) include(Sentry) include(TemplateCheck) +include(ThreeJS) include(UI) include(UnixInstall) include(ViewerMiscLibs) @@ -233,6 +236,7 @@ set(viewer_SOURCE_FILES llfilteredwearablelist.cpp llfirstuse.cpp llflexibleobject.cpp + llfloater360capture.cpp llfloaterabout.cpp llfloaterassetrecovery.cpp llfloaterbvhpreview.cpp @@ -309,7 +313,7 @@ set(viewer_SOURCE_FILES llfloaternamedesc.cpp llfloaternotificationsconsole.cpp llfloaternotificationstabbed.cpp - llfloateroutfitphotopreview.cpp + llfloateroutfitphotopreview.cpp llfloateroutfitsnapshot.cpp llfloaterobjectweights.cpp llfloateropenobject.cpp @@ -907,6 +911,7 @@ set(viewer_HEADER_FILES llfilteredwearablelist.h llfirstuse.h llflexibleobject.h + llfloater360capture.h llfloaterabout.h llfloaterassetrecovery.h llfloaterbvhpreview.h @@ -2081,7 +2086,7 @@ endif (WINDOWS) # one of these being libz where you can find four or more versions in play # at once. On Linux, libz can be found at link and run time via a number # of paths: -# +# # => -lfreetype # => libz.so.1 (on install machine, not build) # => -lSDL @@ -2488,7 +2493,7 @@ if (LL_TESTS) llworldmap.cpp llworldmipmap.cpp PROPERTIES - LL_TEST_ADDITIONAL_SOURCE_FILES + LL_TEST_ADDITIONAL_SOURCE_FILES tests/llviewertexture_stub.cpp #llviewertexturelist.cpp ) @@ -2521,7 +2526,7 @@ if (LL_TESTS) llworldmap.cpp llworldmipmap.cpp PROPERTIES - LL_TEST_ADDITIONAL_SOURCE_FILES + LL_TEST_ADDITIONAL_SOURCE_FILES tests/llviewertexture_stub.cpp #llviewertexturelist.cpp LL_TEST_ADDITIONAL_LIBRARIES "${BOOST_SYSTEM_LIBRARY}" diff --git a/indra/newview/VIEWER_VERSION.txt b/indra/newview/VIEWER_VERSION.txt index a194c18e86e8852fe64f3912531362eadf6fe055..5e3ec53ea67740bc9cb87b2ba15e8f769b2ea460 100644 --- a/indra/newview/VIEWER_VERSION.txt +++ b/indra/newview/VIEWER_VERSION.txt @@ -1 +1 @@ -6.5.1 +6.5.2 diff --git a/indra/newview/app_settings/commands.xml b/indra/newview/app_settings/commands.xml index ec0f9663424fcdbea8f1827bdf65c02969cdab93..389fc66c2cae76a75ed9d6d4de5f125c37f82420 100644 --- a/indra/newview/app_settings/commands.xml +++ b/indra/newview/app_settings/commands.xml @@ -351,6 +351,17 @@ is_running_function="Floater.IsOpen" is_running_parameters="my_environments" /> + <command name="360capture" + available_in_toybox="true" + is_flashing_allowed="true" + icon="Command_360_Capture_Icon" + label_ref="Command_360_Capture_Label" + tooltip_ref="Command_360_Capture_Tooltip" + execute_function="Floater.ToggleOrBringToFront" + execute_parameters="360capture" + is_running_function="Floater.IsOpen" + is_running_parameters="360capture" + /> <command name="webbrowser" available_in_toybox="true" icon="Command_Webbrowser_Icon" diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 8e2d0038e46171c56a1c971ca624353beacce702..9f7e3989fb8458eef642ee6177785402ffbf6d28 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1696,7 +1696,7 @@ <key>Value</key> <integer>23</integer> </map> - <key>EnableCacheDebugInfo</key> + <key>EnableDiskCacheDebugInfo</key> <map> <key>Comment</key> <string>When set, display additional cache debugging information</string> @@ -2466,6 +2466,28 @@ <key>Value</key> <integer>1</integer> </map> + <key>BrowserFileAccessFromFileUrls</key> + <map> + <key>Comment</key> + <string>Allow access to local files via file urls in the embedded browser</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>BrowserPluginsEnabled</key> + <map> + <key>Comment</key> + <string>Enable Web plugins in the built-in Web browser?</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> <key>ChatBarCustomWidth</key> <map> <key>Comment</key> @@ -3919,7 +3941,7 @@ <key>Value</key> <integer>0</integer> </map> - <key>DoubleClickTeleport</key> + <key>DoubleClickTeleport</key> <map> <key>Comment</key> <string>Enable double-click to teleport where allowed (afects minimap and people panel)</string> @@ -9273,7 +9295,7 @@ <key>Value</key> <integer>0</integer> </map> - <key>RenderHiDPI</key> + <key>RenderHiDPI</key> <map> <key>Comment</key> <string>Enable support for HiDPI displays, like Retina (MacOS X ONLY, requires restart)</string> @@ -17081,29 +17103,83 @@ <string>Boolean</string> <key>Value</key> <integer>1</integer> + </map> + <key>360CaptureUseInterestListCap</key> + <map> + <key>Comment</key> + <string>Flag if set, uses the new InterestList cap to ask the simulator for full content</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> + <key>360CaptureJPEGEncodeQuality</key> + <map> + <key>Comment</key> + <string>Quality value to use in the JPEG encoder (0..100)</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>U32</string> + <key>Value</key> + <integer>95</integer> + </map> + <key>360CaptureDebugSaveImage</key> + <map> + <key>Comment</key> + <string>Flag if set, saves off each cube map as an image, as well as the JavaScript data URL, for debugging purposes</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> + </map> + <key>360CaptureOutputImageWidth</key> + <map> + <key>Comment</key> + <string>Width of the output 360 equirectangular image</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>U32</string> + <key>Value</key> + <integer>4096</integer> + </map> + <key>360CaptureHideAvatars</key> + <map> + <key>Comment</key> + <string>Flag if set, removes all the avatars from the 360 snapshot</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>0</integer> </map> - <key>EnableDiskCacheDebugInfo</key> - <map> - <key>Comment</key> - <string>Enable debug output for filesystem cache</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>Boolean</string> - <key>Value</key> - <integer>0</integer> - </map> - <key>MemProfiling</key> - <map> - <key>Comment</key> - <string>Enable allocator profiling</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>Boolean</string> - <key>Value</key> - <integer>0</integer> - </map> + <key>360CaptureCameraFOV</key> + <map> + <key>Comment</key> + <string>Field of view of the WebGL camera that converts the cubemap to an equirectangular image</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>U32</string> + <key>Value</key> + <integer>75</integer> + </map> + <key>360CaptureNumRenderPasses</key> + <map> + <key>Comment</key> + <string>Number of times to render the scene while taking a snapshot</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>U32</string> + <key>Value</key> + <integer>3</integer> + </map> </map> </llsd> - diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 0c21be8ac4401d425d2b1dc1b663f8ae02fdb707..2f80193f3a2efcd8f45d24c9c58a63f7e082f78c 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -2989,7 +2989,7 @@ bool LLAgent::requestGetCapability(const std::string &capName, httpCallback_t cb { std::string url; - url = getRegion()->getCapability(capName); + url = getRegionCapability(capName); if (url.empty()) { @@ -4846,23 +4846,19 @@ void LLAgent::requestAgentUserInfoCoro(std::string capurl) return; } - bool im_via_email; - bool is_verified_email; std::string email; std::string dir_visibility; - im_via_email = result["im_via_email"].asBoolean(); - is_verified_email = result["is_verified"].asBoolean(); email = result["email"].asString(); dir_visibility = result["directory_visibility"].asString(); // TODO: This should probably be changed. I'm not entirely comfortable // having LLAgent interact directly with the UI in this way. - LLFloaterPreference::updateUserInfo(dir_visibility, im_via_email, is_verified_email); + LLFloaterPreference::updateUserInfo(dir_visibility); LLFloaterSnapshot::setAgentEmail(email); } -void LLAgent::sendAgentUpdateUserInfo(bool im_via_email, const std::string& directory_visibility) +void LLAgent::sendAgentUpdateUserInfo(const std::string& directory_visibility) { std::string cap; @@ -4875,16 +4871,16 @@ void LLAgent::sendAgentUpdateUserInfo(bool im_via_email, const std::string& dire if (!cap.empty()) { LLCoros::instance().launch("updateAgentUserInfoCoro", - boost::bind(&LLAgent::updateAgentUserInfoCoro, this, cap, im_via_email, directory_visibility)); + boost::bind(&LLAgent::updateAgentUserInfoCoro, this, cap, directory_visibility)); } else { - sendAgentUpdateUserInfoMessage(im_via_email, directory_visibility); + sendAgentUpdateUserInfoMessage(directory_visibility); } } -void LLAgent::updateAgentUserInfoCoro(std::string capurl, bool im_via_email, std::string directory_visibility) +void LLAgent::updateAgentUserInfoCoro(std::string capurl, std::string directory_visibility) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -4895,8 +4891,8 @@ void LLAgent::updateAgentUserInfoCoro(std::string capurl, bool im_via_email, std httpOpts->setFollowRedirects(true); LLSD body(LLSDMap - ("dir_visibility", LLSD::String(directory_visibility)) - ("im_via_email", LLSD::Boolean(im_via_email))); + ("dir_visibility", LLSD::String(directory_visibility))); + LLSD result = httpAdapter->postAndSuspend(httpRequest, capurl, body, httpOpts, httpHeaders); @@ -4924,14 +4920,13 @@ void LLAgent::sendAgentUserInfoRequestMessage() sendReliableMessage(); } -void LLAgent::sendAgentUpdateUserInfoMessage(bool im_via_email, const std::string& directory_visibility) +void LLAgent::sendAgentUpdateUserInfoMessage(const std::string& directory_visibility) { gMessageSystem->newMessageFast(_PREHASH_UpdateUserInfo); gMessageSystem->nextBlockFast(_PREHASH_AgentData); gMessageSystem->addUUIDFast(_PREHASH_AgentID, getID()); gMessageSystem->addUUIDFast(_PREHASH_SessionID, getSessionID()); gMessageSystem->nextBlockFast(_PREHASH_UserData); - gMessageSystem->addBOOLFast(_PREHASH_IMViaEMail, im_via_email); gMessageSystem->addStringFast(_PREHASH_DirectoryVisibility, directory_visibility); gAgent.sendReliableMessage(); diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 6a6077608b9f5a84f7b9efb242edae72f0204c49..e4b53b3cd815933749e369dc0df41ed202323d5a 100644 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -960,14 +960,14 @@ class LLAgent : public LLOldEvents::LLObservable void sendAgentUserInfoRequest(); // IM to Email and Online visibility - void sendAgentUpdateUserInfo(bool im_to_email, const std::string& directory_visibility); + void sendAgentUpdateUserInfo(const std::string& directory_visibility); private: void requestAgentUserInfoCoro(std::string capurl); - void updateAgentUserInfoCoro(std::string capurl, bool im_via_email, std::string directory_visibility); + void updateAgentUserInfoCoro(std::string capurl, std::string directory_visibility); // DEPRECATED: may be removed when User Info cap propagates void sendAgentUserInfoRequestMessage(); - void sendAgentUpdateUserInfoMessage(bool im_via_email, const std::string& directory_visibility); + void sendAgentUpdateUserInfoMessage(const std::string& directory_visibility); //-------------------------------------------------------------------- // Receive diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 29e04e5d8c8664e8adb958d0790928b9bad8f355..722273132f3f9a2760cbe632435317abc332c8f3 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -615,13 +615,13 @@ static void settings_to_globals() static void settings_modify() { -// LLRenderTarget::sUseFBO = gSavedSettings.getBOOL("RenderDeferred"); -// [RLVa:KB] - @setsphere - LLRenderTarget::sUseFBO = gSavedSettings.getBOOL("RenderDeferred") || (gSavedSettings.getBOOL("WindLightUseAtmosShaders") && LLPipeline::sUseDepthTexture); -// [/RLVa:KB] LLPipeline::sRenderTransparentWater = gSavedSettings.getBOOL("RenderTransparentWater"); LLPipeline::sRenderBump = gSavedSettings.getBOOL("RenderObjectBump"); - LLPipeline::sRenderDeferred = LLPipeline::sRenderTransparentWater && LLPipeline::sRenderBump && gSavedSettings.getBOOL("RenderDeferred"); + LLPipeline::sRenderDeferred = LLPipeline::sRenderTransparentWater && LLPipeline::sRenderBump && gSavedSettings.getBOOL("RenderDeferred"); +// LLRenderTarget::sUseFBO = (LLPipeline::sRenderDeferred && gSavedSettings.getBOOL("RenderAvatarVP")); +// [RLVa:KB] - @setsphere + LLRenderTarget::sUseFBO = (LLPipeline::sRenderDeferred && gSavedSettings.getBOOL("RenderAvatarVP")) || (gSavedSettings.getBOOL("WindLightUseAtmosShaders") && LLPipeline::sUseDepthTexture); +// [/RLVa:KB] LLVOSurfacePatch::sLODFactor = gSavedSettings.getF32("RenderTerrainLODFactor"); LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor; //square lod factor to get exponential range of [1,4] gDebugGL = gSavedSettings.getBOOL("RenderDebugGL") || gDebugSession; @@ -677,6 +677,7 @@ LLAppViewer* LLAppViewer::sInstance = NULL; LLTextureCache* LLAppViewer::sTextureCache = NULL; LLImageDecodeThread* LLAppViewer::sImageDecodeThread = NULL; LLTextureFetch* LLAppViewer::sTextureFetch = NULL; +LLPurgeDiskCacheThread* LLAppViewer::sPurgeDiskCacheThread = NULL; std::string getRuntime() { @@ -1940,7 +1941,6 @@ bool LLAppViewer::cleanup() LLPrimitive::cleanupVolumeManager(); SUBSYSTEM_CLEANUP(LLWorldMapView); SUBSYSTEM_CLEANUP(LLFolderViewItem); - LL_INFOS() << "Saving Data" << LL_ENDL; // Store the time of our current logoff @@ -2054,6 +2054,7 @@ bool LLAppViewer::cleanup() sTextureFetch->shutdown(); sTextureCache->shutdown(); sImageDecodeThread->shutdown(); + sPurgeDiskCacheThread->shutdown(); sTextureFetch->shutDownTextureCacheThread() ; sTextureFetch->shutDownImageDecodeThread() ; @@ -2076,6 +2077,8 @@ bool LLAppViewer::cleanup() sImageDecodeThread = NULL; delete mFastTimerLogThread; mFastTimerLogThread = NULL; + delete sPurgeDiskCacheThread; + sPurgeDiskCacheThread = NULL; if (LLFastTimerView::sAnalyzePerformance) { @@ -2175,6 +2178,7 @@ bool LLAppViewer::initThreads() sImageDecodeThread, enable_threads && true, app_metrics_qa_mode); + LLAppViewer::sPurgeDiskCacheThread = new LLPurgeDiskCacheThread(); if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog) { @@ -4159,8 +4163,11 @@ void LLAppViewer::migrateCacheDirectory() //static U32 LLAppViewer::getTextureCacheVersion() { - //viewer texture cache version, change if the texture cache format changes. - const U32 TEXTURE_CACHE_VERSION = 8; + // Viewer texture cache version, change if the texture cache format changes. + // 2021-03-10 Bumping up by one to help obviate texture cache issues with + // Simple Cache Viewer - see SL-14985 for more information + //const U32 TEXTURE_CACHE_VERSION = 8; + const U32 TEXTURE_CACHE_VERSION = 9; return TEXTURE_CACHE_VERSION ; } @@ -4225,6 +4232,7 @@ bool LLAppViewer::initCache() LL_INFOS("AppCache") << "Cache location changed, cache needs purging" << LL_ENDL; gDirUtilp->setCacheDir(gSavedSettings.getString("CacheLocation")); purgeCache(); // purge old cache + gDirUtilp->deleteDirAndContents(gDirUtilp->getExpandedFilename(LL_PATH_CACHE, cache_dir_name)); gSavedSettings.setString("CacheLocation", new_cache_location); gSavedSettings.setString("CacheLocationTopFolder", gDirUtilp->getBaseFileName(new_cache_location)); } @@ -4257,6 +4265,7 @@ bool LLAppViewer::initCache() LLDiskCache::getInstance()->purge(); } } + LLAppViewer::getPurgeDiskCacheThread()->start(); LLSplashScreen::update(LLTrans::getString("StartupInitializingTextureCache")); diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 851df09941e77ccf361356a3f52b2f8fd352d591..5b5adf70673e9c8d959d3babd88adf39a31b2e97 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -58,6 +58,7 @@ class LLImageDecodeThread; class LLTextureFetch; class LLWatchdogTimeout; class LLViewerJoystick; +class LLPurgeDiskCacheThread; class LLViewerRegion; extern LLTrace::BlockTimerStatHandle FTM_FRAME; @@ -118,6 +119,7 @@ class LLAppViewer : public LLApp static LLTextureCache* getTextureCache() { return sTextureCache; } static LLImageDecodeThread* getImageDecodeThread() { return sImageDecodeThread; } static LLTextureFetch* getTextureFetch() { return sTextureFetch; } + static LLPurgeDiskCacheThread* getPurgeDiskCacheThread() { return sPurgeDiskCacheThread; } static U32 getTextureCacheVersion() ; static U32 getObjectCacheVersion() ; @@ -284,6 +286,7 @@ class LLAppViewer : public LLApp static LLTextureCache* sTextureCache; static LLImageDecodeThread* sImageDecodeThread; static LLTextureFetch* sTextureFetch; + static LLPurgeDiskCacheThread* sPurgeDiskCacheThread; S32 mNumSessions; diff --git a/indra/newview/lldrawpoolavatar.cpp b/indra/newview/lldrawpoolavatar.cpp index cde9328b5e0e8ccff9f039b6151b422aa79a044a..ab4dcdfef1fb8d940713a34e85e698d1b8bee988 100644 --- a/indra/newview/lldrawpoolavatar.cpp +++ b/indra/newview/lldrawpoolavatar.cpp @@ -1530,7 +1530,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) } LLVOAvatar *attached_av = avatarp->getAttachedAvatar(); - if (attached_av && LLVOAvatar::AOA_NORMAL != attached_av->getOverallAppearance()) + if (attached_av && (LLVOAvatar::AOA_NORMAL != attached_av->getOverallAppearance() || !gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_AVATAR))) { // Animesh attachment of a jellydolled or invisible parent - don't show return; diff --git a/indra/newview/llfloater360capture.cpp b/indra/newview/llfloater360capture.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0b2fa92e4b0dc003cc99127f8a0f1849f82eff49 --- /dev/null +++ b/indra/newview/llfloater360capture.cpp @@ -0,0 +1,930 @@ +/** + * @file llfloater360capture.cpp + * @author Callum Prentice (callum@lindenlab.com) + * @brief Floater code for the 360 Capture feature + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, 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 "llfloater360capture.h" + +#include "llagent.h" +#include "llagentui.h" +#include "llbase64.h" +#include "llcallbacklist.h" +#include "llenvironment.h" +#include "llimagejpeg.h" +#include "llmediactrl.h" +#include "llradiogroup.h" +#include "llslurl.h" +#include "lltextbox.h" +#include "lltrans.h" +#include "lluictrlfactory.h" +#include "llversioninfo.h" +#include "llviewercamera.h" +#include "llviewercontrol.h" +#include "llviewerpartsim.h" +#include "llviewerregion.h" +#include "llviewerwindow.h" +#include "pipeline.h" + +#include <iterator> + +LLFloater360Capture::LLFloater360Capture(const LLSD& key) + : LLFloater(key) +{ + // The handle to embedded browser that we use to + // render the WebGL preview as we as host the + // Cube Map to Equirectangular image code + mWebBrowser = nullptr; + + // Ask the simulator to send us everything (and not just + // what it thinks the connected Viewer can see) until + // such time as we ask it not to (the dtor). If we crash or + // otherwise, exit before this is turned off, the Simulator + // will take care of cleaning up for us. + if (gSavedSettings.getBOOL("360CaptureUseInterestListCap")) + { + // send everything to us for as long as this floater is open + const bool send_everything = true; + changeInterestListMode(send_everything); + } +} + +LLFloater360Capture::~LLFloater360Capture() +{ + if (mWebBrowser) + { + mWebBrowser->navigateStop(); + mWebBrowser->clearCache(); + mWebBrowser->unloadMediaSource(); + } + + // Tell the Simulator not to send us everything anymore + // and revert to the regular "keyhole" frustum of interest + // list updates. + if (gSavedSettings.getBOOL("360CaptureUseInterestListCap")) + { + const bool send_everything = false; + changeInterestListMode(send_everything); + } +} + +BOOL LLFloater360Capture::postBuild() +{ + mCaptureBtn = getChild<LLUICtrl>("capture_button"); + mCaptureBtn->setCommitCallback(boost::bind(&LLFloater360Capture::onCapture360ImagesBtn, this)); + + mSaveLocalBtn = getChild<LLUICtrl>("save_local_button"); + mSaveLocalBtn->setCommitCallback(boost::bind(&LLFloater360Capture::onSaveLocalBtn, this)); + mSaveLocalBtn->setEnabled(false); + + mWebBrowser = getChild<LLMediaCtrl>("360capture_contents"); + mWebBrowser->addObserver(this); + + // There is a group of radio buttons that define the quality + // by each having a 'value' that is returns equal to the pixel + // size (width == height) + mQualityRadioGroup = getChild<LLRadioGroup>("360_quality_selection"); + mQualityRadioGroup->setCommitCallback(boost::bind(&LLFloater360Capture::onChooseQualityRadioGroup, this)); + + // UX/UI called for preview mode (always the first index/option) + // by default each time vs restoring the last value + mQualityRadioGroup->setSelectedIndex(0); + + // Construct a URL pointing to the first page to load. Although + // we do not use this page for anything (after some significant + // design changes), we retain the code to load the start page + // in case that changes again one day. It also makes sure the + // embedded browser is active and ready to go for when the real + // page with the 360 preview is navigated to. + std::string url = STRINGIZE( + "file:///" << + getHTMLBaseFolder() << + mDefaultHTML + ); + mWebBrowser->navigateTo(url); + + // initial pass at determining what size (width == height since + // the cube map images are square) we should capture at. + setSourceImageSize(); + + // the size of the output equirectangular image. The height of an EQR image + // is always 1/2 of the width so we should not store it but rather, + // calculate it from the width directly + mOutputImageWidth = gSavedSettings.getU32("360CaptureOutputImageWidth"); + mOutputImageHeight = mOutputImageWidth / 2; + + // enable resizing and enable for width and for height + enableResizeCtrls(true, true, true); + + // initial heading that consumers of the equirectangular image + // (such as Facebook or Flickr) use to position initial view - + // we set during capture - stored as degrees (0..359) + mInitialHeadingDeg = 0.0; + + // save directory in which to store the images (must obliviously be + // writable by the viewer). Also create it for users who haven't + // used the 360 feature before. + mImageSaveDir = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter() + "eqrimg"; + LLFile::mkdir(mImageSaveDir); + + // We do an initial capture when the floater is opened, albeit at a 'preview' + // quality level (really low resolution, but really fast) + onCapture360ImagesBtn(); + + return true; +} + +// called when the user choose a quality level using +// the buttons in the radio group +void LLFloater360Capture::onChooseQualityRadioGroup() +{ + // set the size of the captured cube map images based + // on the quality level chosen + setSourceImageSize(); +} + +// Using a new capability, tell the simulator that we want it to send everything +// it knows about and not just what is in front of the camera, in its view +// frustum. We need this feature so that the contents of the region that appears +// in the 6 snapshots which we cannot see and is normally not "considered", is +// also rendered. Typically, this is turned on when the 360 capture floater is +// opened and turned off when it is closed. +// Note: for this version, we do not have a way to determine when "everything" +// has arrived and has been rendered so for now, the proposal is that users +// will need to experiment with the low resolution version and wait for some +// (hopefully) small period of time while the full contents resolves. +// Pass in a flag to ask the simulator/interest list to "send everything" or +// not (the default mode) +void LLFloater360Capture::changeInterestListMode(bool send_everything) +{ + LLSD body; + + if (send_everything) + { + body["mode"] = LLSD::String("360"); + } + else + { + body["mode"] = LLSD::String("default"); + } + + if (gAgent.requestPostCapability("InterestList", body, [](const LLSD & response) + { + LL_INFOS("360Capture") << + "InterestList capability responded: \n" << + ll_pretty_print_sd(response) << + LL_ENDL; + })) + { + LL_INFOS("360Capture") << + "Successfully posted an InterestList capability request with payload: \n" << + ll_pretty_print_sd(body) << + LL_ENDL; + } + else + { + LL_INFOS("360Capture") << + "Unable to post an InterestList capability request with payload: \n" << + ll_pretty_print_sd(body) << + LL_ENDL; + } +} + +// There is is a setting (360CaptureSourceImageSize) that holds the size +// (width == height since it's a square) of each of the 6 source snapshots. +// However there are some known (and I dare say, some more unknown conditions +// where the specified size is not possible and this function tries to figure it +// out and change that setting to the optimal value for the current conditions. +void LLFloater360Capture::setSourceImageSize() +{ + mSourceImageSize = mQualityRadioGroup->getSelectedValue().asInteger(); + + // If deferred rendering is off, we need to shrink the window we capture + // until it's smaller than the Viewer window dimensions. + if (!LLPipeline::sRenderDeferred) + { + LLRect window_rect = gViewerWindow->getWindowRectRaw(); + S32 window_width = window_rect.getWidth(); + S32 window_height = window_rect.getHeight(); + + // It's not possible (as I had hoped) to always render to an off screen + // buffer regardless of deferred rendering status so the next best + // option is to render to a buffer that is the size of the users app + // window. Note, this was changed - before it chose the smallest + // power of 2 less than the window size - but since that meant a + // 1023 height app window would result in a 512 pixel capture, Maxim + // tried this and it does indeed appear to work. Mayb need to revisit + // after the project viewer pass if people on low end graphics systems + // after having issues. + if (mSourceImageSize > window_width || mSourceImageSize > window_height) + { + mSourceImageSize = llmin(window_width, window_height, mSourceImageSize); + LL_INFOS("360Capture") << "Deferred rendering is forcing a smaller capture size: " << mSourceImageSize << LL_ENDL; + } + + // there has to be an easier way than this to get the value + // from the radio group item at index 0. Why doesn't + // LLRadioGroup::getSelectedValue(int index) exist? + int index = mQualityRadioGroup->getSelectedIndex(); + mQualityRadioGroup->setSelectedIndex(0); + int min_size = mQualityRadioGroup->getSelectedValue().asInteger(); + mQualityRadioGroup->setSelectedIndex(index); + + // If the maximum size we can support falls below a threshold then + // we should display a message in the log so we can try to debug + // why this is happening + if (mSourceImageSize < min_size) + { + LL_INFOS("360Capture") << "Small snapshot size due to deferred rendering and small app window" << LL_ENDL; + } + } +} + +// This function shouldn't exist! We use the tooltip text from +// the corresponding XUI file (floater_360capture.xml) as the +// overlay text for the final web page to inform the user +// about the quality level in play. There ought to be a +// UI function like LLView* getSelectedItemView() or similar +// but as far as I can tell, there isn't so we have to resort +// to finding it ourselves with this icky code.. +const std::string LLFloater360Capture::getSelectedQualityTooltip() +{ + // safey (or bravery?) + if (mQualityRadioGroup != nullptr) + { + // for all the child widgets for the radio group + // (just the radio buttons themselves I think) + for (child_list_const_reverse_iter_t iter = mQualityRadioGroup->getChildList()->rbegin(); + iter != mQualityRadioGroup->getChildList()->rend(); + ++iter) + { + // if we match the selected index (which we can get easily) + // with our position in the list of children + if (mQualityRadioGroup->getSelectedIndex() == + std::distance(mQualityRadioGroup->getChildList()->rend(), iter) - 1) + { + // return the plain old tooltip text + return (*iter)->getToolTip(); + } + } + } + + // if it's not found or not available, return an empty string + return std::string(); +} + +// Some of the 'magic' happens via a web page in an HTML directory +// and this code provides a single point of reference for its' location +const std::string LLFloater360Capture::getHTMLBaseFolder() +{ + std::string folder_name = gDirUtilp->getDefaultSkinDir(); + folder_name += gDirUtilp->getDirDelimiter(); + folder_name += "html"; + folder_name += gDirUtilp->getDirDelimiter(); + folder_name += "common"; + folder_name += gDirUtilp->getDirDelimiter(); + folder_name += "equirectangular"; + folder_name += gDirUtilp->getDirDelimiter(); + + return folder_name; +} + +// triggered when the 'capture' button in the UI is pressed +void LLFloater360Capture::onCapture360ImagesBtn() +{ + // launch the main capture code in a coroutine so we can + // yield/suspend at some points to give the main UI + // thread a look-in occasionally. + LLCoros::instance().launch("capture360cap", [this]() + { + capture360Images(); + }); +} + +// Gets the full path name for a given JavaScript file in the HTML folder. We +// use this ultimately as a parameter to the main web app so it knows where to find +// the JavaScript array containing the 6 cube map images, stored as data URLs +const std::string LLFloater360Capture::makeFullPathToJS(const std::string filename) +{ + std::string full_js_path = mImageSaveDir; + full_js_path += gDirUtilp->getDirDelimiter(); + full_js_path += filename; + + return full_js_path; +} + +// Write the header/prequel portion of the JavaScript array of data urls +// that we use to store the cube map images in (so the web code can load +// them without tweaking browser security - we'd have to do this if they +// we stored as plain old images) This deliberately overwrites the old +// one, if it exists +void LLFloater360Capture::writeDataURLHeader(const std::string filename) +{ + llofstream file_handle(filename.c_str()); + if (file_handle.is_open()) + { + file_handle << "// cube map images for Second Life Viewer panorama 360 images" << std::endl; + file_handle.close(); + } +} + +// Write the footer/sequel portion of the JavaScript image code. When this is +// called, the current file on disk will contain the header and the 6 data +// URLs, each with a well specified name. This final piece of JavaScript code +// creates an array from those data URLs that the main application can +// reference and read. +void LLFloater360Capture::writeDataURLFooter(const std::string filename) +{ + llofstream file_handle(filename.c_str(), std::ios_base::app); + if (file_handle.is_open()) + { + file_handle << "var cubemap_img_js = [" << std::endl; + file_handle << " img_posx, img_negx," << std::endl; + file_handle << " img_posy, img_negy," << std::endl; + file_handle << " img_posz, img_negz," << std::endl; + file_handle << "];" << std::endl; + + file_handle.close(); + } +} + +// Given a filename, a chunk of data (representing an image file) and the size +// of the buffer, we create a BASE64 encoded string and use it to build a JavaScript +// data URL that represents the image in a web browser environment +bool LLFloater360Capture::writeDataURL(const std::string filename, const std::string prefix, U8* data, unsigned int data_len) +{ + LL_INFOS("360Capture") << "Writing data URL for " << prefix << " to " << filename << LL_ENDL; + + const std::string data_url = LLBase64::encode(data, data_len); + + llofstream file_handle(filename.c_str(), std::ios_base::app); + if (file_handle.is_open()) + { + file_handle << "var img_"; + file_handle << prefix; + file_handle << " = '"; + file_handle << "data:image/jpeg; base64,"; + file_handle << data_url; + file_handle << "'"; + file_handle << std::endl; + file_handle.close(); + + return true; + } + + return false; +} + +// Encode the image from each of the 6 snapshots and save it out to +// the JavaScript array of data URLs +void LLFloater360Capture::encodeAndSave(LLPointer<LLImageRaw> raw_image, const std::string filename, const std::string prefix) +{ + // the default quality for the JPEG encoding is set quite high + // but this still seems to be a reasonable compromise for + // quality/size and is still much smaller than equivalent PNGs + int jpeg_encode_quality = gSavedSettings.getU32("360CaptureJPEGEncodeQuality"); + LLPointer<LLImageJPEG> jpeg_image = new LLImageJPEG(jpeg_encode_quality); + + // Actually encode the JPEG image. This is where a lot of time + // is spent now that the snapshot capture process has been + // optimized. The encode_time parameter doesn't appear to be + // used anymore. + const int encode_time = 0; + bool resultjpeg = jpeg_image->encode(raw_image, encode_time); + + if (resultjpeg) + { + // save individual cube map images as real JPEG files + // for debugging or curiosity) based on debug settings + if (gSavedSettings.getBOOL("360CaptureDebugSaveImage")) + { + const std::string jpeg_filename = STRINGIZE( + gDirUtilp->getLindenUserDir() << + gDirUtilp->getDirDelimiter() << + "eqrimg" << + gDirUtilp->getDirDelimiter() << + prefix << + "." << + jpeg_image->getExtension() + ); + + LL_INFOS("360Capture") << "Saving debug JPEG image as " << jpeg_filename << LL_ENDL; + jpeg_image->save(jpeg_filename); + } + + // actually write the JPEG image to disk as a data URL + writeDataURL(filename, prefix, jpeg_image->getData(), jpeg_image->getDataSize()); + } +} + +// Defer back to the main loop for a single rendered frame to give +// the renderer a chance to update the UI if it is needed +void LLFloater360Capture::suspendForAFrame() +{ + const U32 frame_count_delta = 1; + U32 curr_frame_count = LLFrameTimer::getFrameCount(); + while (LLFrameTimer::getFrameCount() <= curr_frame_count + frame_count_delta) + { + llcoro::suspend(); + } +} + +// A debug version of the snapshot code that simply fills the +// buffer with a pattern that can be used to investigate +// issues with encoding and saving off each RAW image. +// Probably not needed anymore but saving here just in case. +void LLFloater360Capture::mockSnapShot(LLImageRaw* raw) +{ + unsigned int width = raw->getWidth(); + unsigned int height = raw->getHeight(); + unsigned int depth = raw->getComponents(); + unsigned char* pixels = raw->getData(); + + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + unsigned long offset = y * width * depth + x * depth; + unsigned char red = x * 256 / width; + unsigned char green = y * 256 / height; + unsigned char blue = ((x + y) / 2) * 256 / (width + height) / 2; + pixels[offset + 0] = red; + pixels[offset + 1] = green; + pixels[offset + 2] = blue; + } + } +} + +// The main code that actually captures all 6 images and then saves them out to +// disk before navigating the embedded web browser to the page with the WebGL +// application that consumes them and creates an EQR image. This code runs as a +// coroutine so it can be suspended at certain points. +void LLFloater360Capture::capture360Images() +{ + // recheck the size of the cube map source images in case it changed + // since it was set when we opened the floater + setSourceImageSize(); + + // disable buttons while we are capturing + mCaptureBtn->setEnabled(false); + mSaveLocalBtn->setEnabled(false); + + bool render_attached_lights = LLPipeline::sRenderAttachedLights; + // determine whether or not to include avatar in the scene as we capture the 360 panorama + if (gSavedSettings.getBOOL("360CaptureHideAvatars")) + { + // Turn off the avatar if UI tells us to hide it. + // Note: the original call to gAvatar.hide(FALSE) did *not* hide + // attachments and so for most residents, there would be some debris + // left behind in the snapshot. + // Note: this toggles so if it set to on, this will turn it off and + // the subsequent call to the same thing after capture is finished + // will turn it back on again. Similarly, for the case where it + // was set to off - I think this is what we need + LLPipeline::toggleRenderTypeControl(LLPipeline::RENDER_TYPE_AVATAR); + LLPipeline::toggleRenderTypeControl(LLPipeline::RENDER_TYPE_PARTICLES); + LLPipeline::sRenderAttachedLights = FALSE; + } + + // these are the 6 directions we will point the camera - essentially, + // North, South, East, West, Up, Down + LLVector3 look_dirs[6] = { LLVector3(1, 0, 0), LLVector3(0, 1, 0), LLVector3(0, 0, 1), LLVector3(-1, 0, 0), LLVector3(0, -1, 0), LLVector3(0, 0, -1) }; + LLVector3 look_upvecs[6] = { LLVector3(0, 0, 1), LLVector3(0, 0, 1), LLVector3(0, -1, 0), LLVector3(0, 0, 1), LLVector3(0, 0, 1), LLVector3(0, 1, 0) }; + + // save current view/camera settings so we can restore them afterwards + S32 old_occlusion = LLPipeline::sUseOcclusion; + + // set new parameters specific to the 360 requirements + LLPipeline::sUseOcclusion = 0; + LLViewerCamera* camera = LLViewerCamera::getInstance(); + F32 old_fov = camera->getView(); + F32 old_aspect = camera->getAspect(); + F32 old_yaw = camera->getYaw(); + + // stop the motion of as much of the world moving as much as we can + freezeWorld(true); + + // Save the direction (in degrees) the camera is looking when we + // take the shot since that is what we write to image metadata + // '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; + LL_INFOS("360Capture") << "Recording a heading of " << (int)(mInitialHeadingDeg) << LL_ENDL; + + // camera constants for the square, cube map capture image + camera->setAspect(1.0); // must set aspect ratio first to avoid undesirable clamping of vertical FoV + camera->setView(F_PI_BY_TWO); + camera->yaw(0.0); + + // record how many times we changed camera to try to understand the "all shots are the same issue" + unsigned int camera_changed_times = 0; + + // the name of the JavaScript file written out that contains the 6 cube map images + // stored as a JavaScript array of data URLs. If you change this filename, you must + // also change the corresponding entry in the HTML file that uses it - + // (newview/skins/default/html/common/equirectangular/display_eqr.html) + const std::string cumemap_js_filename("cubemap_img.js"); + + // construct the full path to this file - typically stored in the users' + // Second Life settings / username / eqrimg folder. + const std::string cubemap_js_full_path = makeFullPathToJS(cumemap_js_filename); + + // Write the JavaScript file header (the top of the file before the + // declarations of the actual data URLs array). In practice, all this writes + // is a comment - it's main purpose is to reset the file from the last time + // it was written + writeDataURLHeader(cubemap_js_full_path); + + // the names of the prefixes we assign as the name to each data URL and are then + // consumed by the WebGL application. Nominally, they stand for positive and + // negative in the X/Y/Z directions. + static const std::string prefixes[6] = + { + "posx", "posz", "posy", + "negx", "negz", "negy", + }; + + // number of times to render the scene (display(..) inside + // the simple snapshot function in llViewerWindow. + // Note: rendering even just 1 more time (for a total of 2) + // has a dramatic effect on the scene contents and *much* + // less of it is missing. More investigation required + // but for the moment, this helps with missing content + // because of interest list issues. + int num_render_passes = gSavedSettings.getU32("360CaptureNumRenderPasses"); + + // time the encode process for later optimization + auto encode_time_total = 0.0; + + // for each of the 6 directions we shoot... + for (int i = 0; i < 6; i++) + { + // these buffers are where the raw, captured pixels are stored and + // the first time we use them, we have to make a new one + if (mRawImages[i] == nullptr) + { + mRawImages[i] = new LLImageRaw(mSourceImageSize, mSourceImageSize, 3); + } + else + // subsequent capture with floater open so we resize the buffer from + // the previous run + { + // LLImageRaw deletes the old one via operator= but just to be + // sure, we delete its' large data member first... + mRawImages[i]->deleteData(); + mRawImages[i] = new LLImageRaw(mSourceImageSize, mSourceImageSize, 3); + } + + // set up camera to look in each direction + camera->lookDir(look_dirs[i], look_upvecs[i]); + + // record if camera changed to try to understand the "all shots are the same issue" + if (camera->isChanged()) + { + ++camera_changed_times; + } + + // call the (very) simplified snapshot code that simply deals + // with a single image, no sub-images etc. but is very fast + gViewerWindow->simpleSnapshot(mRawImages[i], + mSourceImageSize, mSourceImageSize, num_render_passes); + + // encode each image and write to disk while saving how long it took to do so + auto t_start = std::chrono::high_resolution_clock::now(); + encodeAndSave(mRawImages[i], cubemap_js_full_path, prefixes[i]); + auto t_end = std::chrono::high_resolution_clock::now(); + auto duration = std::chrono::duration_cast<std::chrono::duration<double>>(t_end - t_start); + encode_time_total += duration.count(); + + // ping the main loop in case the snapshot process takes a really long + // time and we get disconnected + LLAppViewer::instance()->pingMainloopTimeout("LLFloater360Capture::capture360Images"); + } + + // display time to encode all 6 images. It tends to be a fairly linear + // time for each so we don't need to worry about displaying the time + // for each - this gives us plenty to use for optimizing + LL_INFOS("360Capture") << + "Time to encode and save 6 images was " << + encode_time_total << + " seconds" << + LL_ENDL; + + // Write the JavaScript file footer (the bottom of the file after the + // declarations of the actual data URLs array). The footer comprises of + // a JavaScript array declaration that references the 6 data URLs generated + // previously and is what is referred to in the display HTML file + // (newview/skins/default/html/common/equirectangular/display_eqr.html) + writeDataURLFooter(cubemap_js_full_path); + + // unfreeze the world now we have our shots + freezeWorld(false); + + // restore original view/camera/avatar settings settings + camera->setAspect(old_aspect); + camera->setView(old_fov); + camera->yaw(old_yaw); + LLPipeline::sUseOcclusion = old_occlusion; + + // if we toggled off the avatar because the Hide check box was ticked, + // we should toggle it back to where it was before we started the capture + if (gSavedSettings.getBOOL("360CaptureHideAvatars")) + { + LLPipeline::toggleRenderTypeControl(LLPipeline::RENDER_TYPE_AVATAR); + LLPipeline::toggleRenderTypeControl(LLPipeline::RENDER_TYPE_PARTICLES); + LLPipeline::sRenderAttachedLights = render_attached_lights; + } + + // record that we missed some shots in the log for later debugging + // note: we use 5 and not 6 because the first shot isn't regarded + // as a change - only the subsequent 5 are + if (camera_changed_times < 5) + { + LL_INFOS("360Capture") << "Warning: we only captured " << camera_changed_times << " images." << LL_ENDL; + } + + // now we have the 6 shots saved in a well specified location, + // we can load the web content that uses them + std::string url = "file:///" + getHTMLBaseFolder() + mEqrGenHTML; + mWebBrowser->navigateTo(url); + + // page is loaded and ready so we can turn on the buttons again + mCaptureBtn->setEnabled(true); + mSaveLocalBtn->setEnabled(true); + + // allow the UI to update by suspending and waiting for the + // main render loop to update the UI + suspendForAFrame(); +} + +// once the request is made to navigate to the web page containing the code +// to process the 6 images into an EQR one, we have to wait for it to finish +// loaded - we get a "navigate complete" event when that happens that we can act on +void LLFloater360Capture::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event) +{ + switch (event) + { + // not used right now but retaining because this event might + // be useful for a feature I am hoping to add + case MEDIA_EVENT_LOCATION_CHANGED: + break; + + // navigation in the browser completed + case MEDIA_EVENT_NAVIGATE_COMPLETE: + { + // Confirm that the navigation event does indeed apply to the + // page we are looking for. At the moment, this is the only + // one we care about so the test is superfluous but that might change. + std::string navigate_url = self->getNavigateURI(); + if (navigate_url.find(mEqrGenHTML) != std::string::npos) + { + // this string is being passed across to the web so replace all the windows backslash + // characters with forward slashes or (I think) the backslashes are treated as escapes + std::replace(mImageSaveDir.begin(), mImageSaveDir.end(), '\\', '/'); + + // we store the camera FOV (field of view) in a saved setting since this feels + // like something it would be interesting to change and experiment with + int camera_fov = gSavedSettings.getU32("360CaptureCameraFOV"); + + // compose the overlay for the final web page that tells the user + // what level of quality the capture was taken with + std::string overlay_label = "'" + getSelectedQualityTooltip() + "'"; + + // so now our page is loaded and images are in place - call + // the JavaScript init script with some parameters to initialize + // the WebGL based preview + const std::string cmd = STRINGIZE( + "init(" + << mOutputImageWidth + << ", " + << mOutputImageHeight + << ", " + << "'" + << mImageSaveDir + << "'" + << ", " + << camera_fov + << ", " + << LLViewerCamera::getInstance()->getYaw() + << ", " + << overlay_label + << ")" + ); + + // execute the command on the page + mWebBrowser->getMediaPlugin()->executeJavaScript(cmd); + } + } + break; + + default: + break; + } +} + +// called when the user wants to save the cube maps off to the final EQR image +void LLFloater360Capture::onSaveLocalBtn() +{ + // region name and URL + std::string region_name; // no sensible default + std::string region_url("http://secondlife.com"); + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + // region names can (and do) contain characters that would make passing + // them into a JavaScript function problematic - single quotes for example + // so we must escape/encode both + region_name = region->getName(); + + // escaping/encoding is a minefield - let's just remove any offending characters from the region name + region_name.erase(std::remove(region_name.begin(), region_name.end(), '\''), region_name.end()); + region_name.erase(std::remove(region_name.begin(), region_name.end(), '\"'), region_name.end()); + + // fortunately there is already an escaping function built into the SLURL generation code + LLSLURL slurl; + bool is_escaped = true; + LLAgentUI::buildSLURL(slurl, is_escaped); + region_url = slurl.getSLURLString(); + } + + // build suggested filename (the one that appears as the default + // in the Save dialog box) + const std::string suggested_filename = generate_proposed_filename(); + + // This string (the name of the product plus a truncated version number (no build)) + // is used in the XMP block as the name of the generating and stitching software. + // We save the version number here and not in the more generic 'software' item + // because that might help us determine something about the image in the future. + const std::string client_version = STRINGIZE( + LLVersionInfo::instance().getChannel() << + " " << + LLVersionInfo::instance().getShortVersion() + ); + + // save the time the image was created. I don't know if this should be + // UTC/ZULU or the users' local time. It probably doesn't matter. + std::time_t result = std::time(nullptr); + std::string ctime_str = std::ctime(&result); + std::string time_str = ctime_str.substr(0, ctime_str.length() - 1); + + // build the JavaScript data structure that is used to pass all the + // variables into the JavaScript function on the web page loaded into + // the embedded browser component of the floater. + const std::string xmp_details = STRINGIZE( + "{ " << + "pano_version: '" << "2.2.1" << "', " << + "software: '" << LLVersionInfo::instance().getChannel() << "', " << + "capture_software: '" << client_version << "', " << + "stitching_software: '" << client_version << "', " << + "width: " << mOutputImageWidth << ", " << + "height: " << mOutputImageHeight << ", " << + "heading: " << mInitialHeadingDeg << ", " << + "actual_source_image_size: " << mQualityRadioGroup->getSelectedValue().asInteger() << ", " << + "scaled_source_image_size: " << mSourceImageSize << ", " << + "first_photo_date: '" << time_str << "', " << + "last_photo_date: '" << time_str << "', " << + "region_name: '" << region_name << "', " << + "region_url: '" << region_url << "', " << + " }" + ); + + // build the JavaScript command to send to the web browser + const std::string cmd = "saveAsEqrImage(\"" + suggested_filename + "\", " + xmp_details + ")"; + + // send it to the browser instance, triggering the equirectangular capture + // process and complimentary offer to save the image + mWebBrowser->getMediaPlugin()->executeJavaScript(cmd); +} + +// We capture all 6 images sequentially and if parts of the world are moving +// E.G. clouds, water, objects - then we may get seams or discontinuities +// when the images are combined to form the EQR image. This code tries to +// stop everything so we can shoot for seamless shots. There is probably more +// we can do here - e.g. waves in the water probably won't line up. +void LLFloater360Capture::freezeWorld(bool enable) +{ + static bool clouds_scroll_paused = false; + if (enable) + { + // record the cloud scroll current value so we can restore it + clouds_scroll_paused = LLEnvironment::instance().isCloudScrollPaused(); + + // stop the clouds moving + LLEnvironment::instance().pauseCloudScroll(); + + // freeze all avatars + LLCharacter* avatarp; + for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); + iter != LLCharacter::sInstances.end(); ++iter) + { + avatarp = *iter; + mAvatarPauseHandles.push_back(avatarp->requestPause()); + } + + // freeze everything else + gSavedSettings.setBOOL("FreezeTime", true); + + // disable particle system + LLViewerPartSim::getInstance()->enable(false); + } + else // turning off freeze world mode, either temporarily or not. + { + // restart the clouds moving if they were not paused before + // we starting using the 360 capture floater + if (clouds_scroll_paused == false) + { + LLEnvironment::instance().resumeCloudScroll(); + } + + // thaw all avatars + mAvatarPauseHandles.clear(); + + // thaw everything else + gSavedSettings.setBOOL("FreezeTime", false); + + //enable particle system + LLViewerPartSim::getInstance()->enable(true); + } +} + +// Build the default filename that appears in the Save dialog box. We try +// to encode some metadata about too (region name, EQR dimensions, capture +// time) but the user if free to replace this with anything else before +// the images is saved. +const std::string LLFloater360Capture::generate_proposed_filename() +{ + std::ostringstream filename(""); + + // base name + filename << "sl360_"; + + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + // this looks complex but it's straightforward - removes all non-alpha chars from a string + // which in this case is the SL region name - we use it as a proposed filename but the user is free to change + std::string region_name = region->getName(); + std::replace_if(region_name.begin(), region_name.end(), [](int c) { return !std::isalnum(c); }, '_'); + if (region_name.length() > 0) + { + filename << region_name; + filename << "_"; + } + } + + // add in resolution to make it easier to tell what you captured later + filename << mOutputImageWidth; + filename << "x"; + filename << mOutputImageHeight; + filename << "_"; + + // Add in the size of the source image (width == height since it was square) + // Might be useful later for quality comparisons + filename << mSourceImageSize; + filename << "_"; + + // add in the current HH-MM-SS (with leading 0's) so users can easily save many shots in same folder + std::time_t cur_epoch = std::time(nullptr); + std::tm* tm_time = std::localtime(&cur_epoch); + filename << std::setfill('0') << std::setw(4) << (tm_time->tm_year + 1900); + filename << std::setfill('0') << std::setw(2) << (tm_time->tm_mon + 1); + filename << std::setfill('0') << std::setw(2) << tm_time->tm_mday; + filename << "_"; + filename << std::setfill('0') << std::setw(2) << tm_time->tm_hour; + filename << std::setfill('0') << std::setw(2) << tm_time->tm_min; + filename << std::setfill('0') << std::setw(2) << tm_time->tm_sec; + + // the unusual way we save the output image (originates in the + // embedded browser and not the C++ code) means that the system + // appends ".jpeg" to the file automatically on macOS at least, + // so we only need to do it ourselves for windows. +#if LL_WINDOWS + filename << ".jpg"; +#endif + + return filename.str(); +} diff --git a/indra/newview/llfloater360capture.h b/indra/newview/llfloater360capture.h new file mode 100644 index 0000000000000000000000000000000000000000..6da7ee074a399e4fa25f76af36aac1d0b18ab718 --- /dev/null +++ b/indra/newview/llfloater360capture.h @@ -0,0 +1,97 @@ +/** + * @file llfloater360capture.h + * @author Callum Prentice (callum@lindenlab.com) + * @brief Floater for the 360 capture feature + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, 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_FLOATER_360CAPTURE_H +#define LL_FLOATER_360CAPTURE_H + +#include "llfloater.h" +#include "llmediactrl.h" +#include "llcharacter.h" + +class LLImageRaw; +class LLTextBox; +class LLRadioGroup; + +class LLFloater360Capture: + public LLFloater, + public LLViewerMediaObserver +{ + friend class LLFloaterReg; + + private: + LLFloater360Capture(const LLSD& key); + + ~LLFloater360Capture(); + BOOL postBuild() override; + void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event) override; + + void changeInterestListMode(bool send_everything); + + const std::string getHTMLBaseFolder(); + void capture360Images(); + + const std::string makeFullPathToJS(const std::string filename); + void writeDataURLHeader(const std::string filename); + void writeDataURLFooter(const std::string filename); + bool writeDataURL(const std::string filename, const std::string prefix, U8* data, unsigned int data_len); + void encodeAndSave(LLPointer<LLImageRaw> raw_image, const std::string filename, const std::string prefix); + + std::vector<LLAnimPauseRequest> mAvatarPauseHandles; + void freezeWorld(bool enable); + + void mockSnapShot(LLImageRaw* raw); + + void suspendForAFrame(); + + const std::string generate_proposed_filename(); + + void setSourceImageSize(); + + LLMediaCtrl* mWebBrowser; + const std::string mDefaultHTML = "default.html"; + const std::string mEqrGenHTML = "eqr_gen.html"; + + LLUICtrl* mCaptureBtn; + void onCapture360ImagesBtn(); + + void onSaveLocalBtn(); + LLUICtrl* mSaveLocalBtn; + + LLRadioGroup* mQualityRadioGroup; + void onChooseQualityRadioGroup(); + const std::string getSelectedQualityTooltip(); + + int mSourceImageSize; + float mInitialHeadingDeg; + int mOutputImageWidth; + int mOutputImageHeight; + std::string mImageSaveDir; + + LLPointer<LLImageRaw> mRawImages[6]; +}; + +#endif // LL_FLOATER_360CAPTURE_H diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index b310034db6c077e8ea504a02dc764cbbf8f8c29c..8b7145831f6b2c892778cccead148402aaac5ffb 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -59,6 +59,7 @@ #include "llspinctrl.h" #include "lltabcontainer.h" #include "lltrans.h" +#include "llfilesystem.h" #include "llcallbacklist.h" #include "llviewertexteditor.h" #include "llviewernetwork.h" diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index f12824c09ed31e6990cb25060ec5f708bcd303bd..36388ec24622bda8dc8e51ff0a5b0d9e744fcef5 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -291,7 +291,6 @@ std::string LLFloaterPreference::sSkin = ""; LLFloaterPreference::LLFloaterPreference(const LLSD& key) : LLFloater(key), mGotPersonalInfo(false), - mOriginalIMViaEmail(false), mLanguageChanged(false), mAvatarDataInitialized(false), mSearchDataDirty(true) @@ -846,11 +845,9 @@ void LLFloaterPreference::apply() if (mGotPersonalInfo) { - bool new_im_via_email = getChild<LLUICtrl>("send_im_to_email")->getValue().asBoolean(); bool new_hide_online = getChild<LLUICtrl>("online_visibility")->getValue().asBoolean(); - if ((new_im_via_email != mOriginalIMViaEmail) - ||(new_hide_online != mOriginalHideOnlineStatus)) + if (new_hide_online != mOriginalHideOnlineStatus) { // This hack is because we are representing several different // possible strings with a single checkbox. Since most users @@ -864,7 +861,7 @@ void LLFloaterPreference::apply() //Update showonline value, otherwise multiple applys won't work mOriginalHideOnlineStatus = new_hide_online; } - gAgent.sendAgentUpdateUserInfo(new_im_via_email,mDirectoryVisibility); + gAgent.sendAgentUpdateUserInfo(mDirectoryVisibility); } } @@ -1260,12 +1257,12 @@ void LLFloaterPreference::onBtnCancel(const LLSD& userdata) } // static -void LLFloaterPreference::updateUserInfo(const std::string& visibility, bool im_via_email, bool is_verified_email) +void LLFloaterPreference::updateUserInfo(const std::string& visibility) { LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences"); if (instance) { - instance->setPersonalInfo(visibility, im_via_email, is_verified_email); + instance->setPersonalInfo(visibility); } } @@ -2006,10 +2003,9 @@ bool LLFloaterPreference::moveTranscriptsAndLog() return true; } -void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im_via_email, bool is_verified_email) +void LLFloaterPreference::setPersonalInfo(const std::string& visibility) { mGotPersonalInfo = true; - mOriginalIMViaEmail = im_via_email; mDirectoryVisibility = visibility; if (visibility == VISIBILITY_DEFAULT) @@ -2031,16 +2027,7 @@ void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im getChildView("friends_online_notify_checkbox")->setEnabled(TRUE); getChild<LLUICtrl>("online_visibility")->setValue(mOriginalHideOnlineStatus); getChild<LLUICtrl>("online_visibility")->setLabelArg("[DIR_VIS]", mDirectoryVisibility); - getChildView("send_im_to_email")->setEnabled(is_verified_email); - std::string tooltip; - if (!is_verified_email) - tooltip = getString("email_unverified_tooltip"); - - getChildView("send_im_to_email")->setToolTip(tooltip); - - // *TODO: Show or hide verify email text here based on is_verified_email - getChild<LLUICtrl>("send_im_to_email")->setValue(im_via_email); getChildView("favorites_on_login_check")->setEnabled(TRUE); getChildView("log_path_button")->setEnabled(TRUE); getChildView("chat_font_size")->setEnabled(TRUE); diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index 9b73d0359aca7542b25acb5e4a86404897265459..5641d5db56f242dfa37d544d3992bfecd6049949 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -89,7 +89,7 @@ class LLFloaterPreference final : public LLFloater, public LLAvatarPropertiesObs /*virtual*/ void changed(const LLUUID& session_id, U32 mask) {}; // static data update, called from message handler - static void updateUserInfo(const std::string& visibility, bool im_via_email, bool is_verified_email); + static void updateUserInfo(const std::string& visibility); // refresh all the graphics preferences menus static void refreshEnabledGraphics(); @@ -159,7 +159,7 @@ class LLFloaterPreference final : public LLFloater, public LLAvatarPropertiesObs void changeLogPath(const std::vector<std::string>& filenames, std::string proposed_name); bool moveTranscriptsAndLog(); void enableHistory(); - void setPersonalInfo(const std::string& visibility, bool im_via_email, bool is_verified_email); + void setPersonalInfo(const std::string& visibility); void refreshEnabledState(); void onCommitWindowedMode(); void refresh(); // Refresh enable/disable @@ -216,7 +216,6 @@ class LLFloaterPreference final : public LLFloater, public LLAvatarPropertiesObs static std::string sSkin; notifications_map mNotificationOptions; bool mGotPersonalInfo; - bool mOriginalIMViaEmail; bool mLanguageChanged; bool mAvatarDataInitialized; std::string mPriorInstantMessageLogPath; diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 6c0ef5bf444e44caf39f6b0e1075c8daf27d5d70..5f77a55092b22147dd1a9323bfe161ecb3c05b67 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -180,6 +180,10 @@ void LLFloaterSnapshotBase::ImplBase::updateLayout(LLFloaterSnapshotBase* floate thumbnail_placeholder->reshape(panel_width, thumbnail_placeholder->getRect().getHeight()); floaterp->getChild<LLUICtrl>("image_res_text")->setVisible(mAdvanced); floaterp->getChild<LLUICtrl>("file_size_label")->setVisible(mAdvanced); + if (floaterp->hasChild("360_label", TRUE)) + { + floaterp->getChild<LLUICtrl>("360_label")->setVisible(mAdvanced); + } if(!floaterp->isMinimized()) { floaterp->reshape(floater_width, floaterp->getRect().getHeight()); @@ -993,6 +997,10 @@ BOOL LLFloaterSnapshot::postBuild() getChild<LLButton>("retract_btn")->setCommitCallback(boost::bind(&LLFloaterSnapshot::onExtendFloater, this)); getChild<LLButton>("extend_btn")->setCommitCallback(boost::bind(&LLFloaterSnapshot::onExtendFloater, this)); + getChild<LLTextBox>("360_label")->setSoundFlags(LLView::MOUSE_UP); + getChild<LLTextBox>("360_label")->setShowCursorHand(false); + getChild<LLTextBox>("360_label")->setClickedCallback(boost::bind(&LLFloaterSnapshot::on360Snapshot, this)); + // Filters LLComboBox* filterbox = getChild<LLComboBox>("filters_combobox"); std::vector<std::string> filter_list = LLImageFiltersManager::getInstance()->getFiltersList(); @@ -1119,6 +1127,12 @@ void LLFloaterSnapshot::onExtendFloater() impl->setAdvanced(gSavedSettings.getBOOL("AdvanceSnapshot")); } +void LLFloaterSnapshot::on360Snapshot() +{ + LLFloaterReg::showInstance("360capture"); + closeFloater(); +} + //virtual void LLFloaterSnapshotBase::onClose(bool app_quitting) { diff --git a/indra/newview/llfloatersnapshot.h b/indra/newview/llfloatersnapshot.h index 0e5d4c1c10d291cae0385da6257f4b7b95a04060..651c4920a7d44c7009ca7e6db36dfaaa830445de 100644 --- a/indra/newview/llfloatersnapshot.h +++ b/indra/newview/llfloatersnapshot.h @@ -153,6 +153,7 @@ class LLFloaterSnapshot final : public LLFloaterSnapshotBase static void update(); void onExtendFloater(); + void on360Snapshot(); static LLFloaterSnapshot* getInstance(); static LLFloaterSnapshot* findInstance(); diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index da1ab06ffdf43be631c0357e899bbd867de3470e..a842c0bb22dfb8e3aaf7fd4f271cb438f9ec3529 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -3249,18 +3249,17 @@ void LLMeshHeaderHandler::processData(LLCore::BufferArray * /* body */, S32 /* b file.write(data, data_size); - // zero out the rest of the file - static const U8 block[65536] = {}; - - while (bytes - file.tell() > sizeof(block)) - { - file.write(block, sizeof(block)); - } - + // <FS:Ansariel> Fix asset caching S32 remaining = bytes - file.tell(); if (remaining > 0) { - file.write(block, remaining); + U8* block = new(std::nothrow) U8[remaining]; + if (block) + { + memset(block, 0, remaining); + file.write(block, remaining); + delete[] block; + } } file.close(); diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 62e8b99dbea929e296fd3d6c5cf3559d7e8cdefd..454d680927efb17fc71561448acc6c3600a31242 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -179,6 +179,17 @@ static bool handleSetShaderChanged(const LLSD& newvalue) return true; } +static bool handleAvatarVPChanged(const LLSD& newvalue) +{ + LLRenderTarget::sUseFBO = newvalue.asBoolean() + && gSavedSettings.getBOOL("RenderObjectBump") + && gSavedSettings.getBOOL("RenderTransparentWater") + && gSavedSettings.getBOOL("RenderDeferred"); + + handleSetShaderChanged(LLSD()); + return true; +} + static bool handleRenderPerfTestChanged(const LLSD& newvalue) { bool status = !newvalue.asBoolean(); @@ -218,7 +229,10 @@ static bool handleRenderPerfTestChanged(const LLSD& newvalue) bool handleRenderTransparentWaterChanged(const LLSD& newvalue) { - LLRenderTarget::sUseFBO = newvalue.asBoolean(); + LLRenderTarget::sUseFBO = newvalue.asBoolean() + && gSavedSettings.getBOOL("RenderObjectBump") + && gSavedSettings.getBOOL("RenderAvatarVP") + && gSavedSettings.getBOOL("RenderDeferred"); if (gPipeline.isInit()) { gPipeline.updateRenderTransparentWater(); @@ -487,7 +501,10 @@ static bool handleRenderDeferredChanged(const LLSD& newvalue) // static bool handleRenderBumpChanged(const LLSD& newval) { - LLRenderTarget::sUseFBO = newval.asBoolean(); + LLRenderTarget::sUseFBO = newval.asBoolean() + && gSavedSettings.getBOOL("RenderTransparentWater") + && gSavedSettings.getBOOL("RenderAvatarVP") + && gSavedSettings.getBOOL("RenderDeferred"); if (gPipeline.isInit()) { gPipeline.updateRenderBump(); @@ -687,7 +704,7 @@ void settings_setup_listeners() gSavedSettings.getControl("OctreeAttachmentSizeFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2)); gSavedSettings.getControl("RenderMaxTextureIndex")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); gSavedSettings.getControl("RenderUseTriStrips")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2)); - gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); + gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleAvatarVPChanged, _2)); gSavedSettings.getControl("RenderUIBuffer")->getSignal()->connect(boost::bind(&handleWindowResized, _2)); gSavedSettings.getControl("RenderDepthOfField")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2)); gSavedSettings.getControl("RenderFSAASamples")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2)); diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index ccd1df31ca438f0cb315ac19f8f602c72d57feef..e4078ac81663dd3d7b21cdfa53f9ff3ebe1bcf94 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -38,6 +38,7 @@ #include "llcommandhandler.h" #include "llcompilequeue.h" #include "llfasttimerview.h" +#include "llfloater360capture.h" #include "llfloaterabout.h" #include "llfloateraddpaymentmethod.h" #include "llfloaterauction.h" @@ -211,6 +212,7 @@ void LLViewerFloaterReg::registerFloaters() // *NOTE: Please keep these alphabetized for easier merges LLFloaterAboutUtil::registerFloater(); + LLFloaterReg::add("360capture", "floater_360capture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater360Capture>); LLFloaterReg::add("block_timers", "floater_fast_timers.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFastTimerView>); LLFloaterReg::add("about_land", "floater_about_land.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLand>); LLFloaterReg::add("add_payment_method", "floater_add_payment_method.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAddPaymentMethod>); diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 637239d7bd180b5b906be78bd53be5117a8c3d5f..42a3977000e7205662011017a225be4516184018 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1762,8 +1762,16 @@ LLPluginClassMedia* LLViewerMediaImpl::newSourceFromMediaType(std::string media_ media_source->cookies_enabled( cookies_enabled || clean_browser); // collect 'javascript enabled' setting from prefs and send to embedded browser - bool javascript_enabled = gSavedSettings.getBOOL( "BrowserJavascriptEnabled" ); - media_source->setJavascriptEnabled( javascript_enabled || clean_browser); + bool javascript_enabled = gSavedSettings.getBOOL("BrowserJavascriptEnabled"); + media_source->setJavascriptEnabled(javascript_enabled || clean_browser); + + // collect 'web security disabled' (see Chrome --web-security-disabled) setting from prefs and send to embedded browser + bool web_security_disabled = gSavedSettings.getBOOL("BrowserWebSecurityDisabled"); + media_source->setWebSecurityDisabled(web_security_disabled || clean_browser); + + // collect setting indicates if local file access from file URLs is allowed from prefs and send to embedded browser + bool file_access_from_file_urls = gSavedSettings.getBOOL("BrowserFileAccessFromFileUrls"); + media_source->setFileAccessFromFileUrlsEnabled(file_access_from_file_urls || clean_browser); // As of SL-15559 PDF files do not load in CEF v91 we enable plugins // but explicitly disable Flash (PDF support in CEF is now treated as a plugin) @@ -1924,6 +1932,15 @@ void LLViewerMediaImpl::loadURI() } } +////////////////////////////////////////////////////////////////////////////////////////// +void LLViewerMediaImpl::executeJavaScript(const std::string& code) +{ + if (mMediaSource) + { + mMediaSource->executeJavaScript(code); + } +} + ////////////////////////////////////////////////////////////////////////////////////////// void LLViewerMediaImpl::setSize(int width, int height) { @@ -3239,8 +3256,19 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla case LLViewerMediaObserver::MEDIA_EVENT_FILE_DOWNLOAD: { - //llinfos << "Media event - file download requested - filename is " << self->getFileDownloadFilename() << llendl; - LLNotificationsUtil::add("MediaFileDownloadUnsupported"); + LL_DEBUGS("Media") << "Media event - file download requested - filename is " << plugin->getFileDownloadFilename() << LL_ENDL; + // pick a file from SAVE FILE dialog + + // need a better algorithm that this or else, pass in type of save type + // from event that initiated it - this is okay for now - only thing + // that saves is 360s + std::string suggested_filename = plugin->getFileDownloadFilename(); + LLFilePicker::ESaveFilter filter = LLFilePicker::FFSAVE_ALL; + if (suggested_filename.find(".jpg") != std::string::npos || suggested_filename.find(".jpeg") != std::string::npos) + filter = LLFilePicker::FFSAVE_JPEG; + if (suggested_filename.find(".png") != std::string::npos) + filter = LLFilePicker::FFSAVE_PNG; + init_threaded_picker_save_dialog(plugin, filter, suggested_filename); } break; diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index f630adf7256186e4185d9f9f098d943d71cd8aef..2becb17031957574c70987158e1919ffba6b56f8 100644 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -207,6 +207,7 @@ class LLViewerMediaImpl bool initializeMedia(const std::string& mime_type); bool initializePlugin(const std::string& media_type); void loadURI(); + void executeJavaScript(const std::string& code); LLPluginClassMedia* getMediaPlugin() { return mMediaSource.get(); } void setSize(int width, int height); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index f39cd74efa4238ffe2c83db20bdab3734e020a65..95c3753a9dc72b88c236f6be21cb331741596c73 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -1301,12 +1301,55 @@ class LLAdvancedDumpScriptedCamera : public view_listener_t class LLAdvancedDumpRegionObjectCache : public view_listener_t { bool handleEvent(const LLSD& userdata) -{ + { handle_dump_region_object_cache(NULL); return true; } }; +class LLAdvancedInterestListFullUpdate : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + LLSD request; + LLSD body; + static bool using_360 = false; + + if (using_360) + { + body["mode"] = LLSD::String("default"); + } + else + { + body["mode"] = LLSD::String("360"); + } + using_360 = !using_360; + + if (gAgent.requestPostCapability("InterestList", body, [](const LLSD& response) + { + LL_INFOS("360Capture") << + "InterestList capability responded: \n" << + ll_pretty_print_sd(response) << + LL_ENDL; + })) + { + LL_INFOS("360Capture") << + "Successfully posted an InterestList capability request with payload: \n" << + ll_pretty_print_sd(body) << + LL_ENDL; + return true; + } + else + { + LL_INFOS("360Capture") << + "Unable to post an InterestList capability request with payload: \n" << + ll_pretty_print_sd(body) << + LL_ENDL; + return false; + } + } +}; + class LLAdvancedBuyCurrencyTest : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -2359,11 +2402,10 @@ class LLAdvancedLeaveAdminStatus : public view_listener_t // Advanced > Debugging // ////////////////////////// - class LLAdvancedForceErrorBreakpoint : public view_listener_t { bool handleEvent(const LLSD& userdata) - { + { force_error_breakpoint(NULL); return true; } @@ -9597,6 +9639,7 @@ void initialize_menus() // Advanced > World view_listener_t::addMenu(new LLAdvancedDumpScriptedCamera(), "Advanced.DumpScriptedCamera"); view_listener_t::addMenu(new LLAdvancedDumpRegionObjectCache(), "Advanced.DumpRegionObjectCache"); + view_listener_t::addMenu(new LLAdvancedInterestListFullUpdate(), "Advanced.InterestListFullUpdate"); // Advanced > UI commit.add("Advanced.WebBrowserTest", boost::bind(&handle_web_browser_test, _2)); // sigh! this one opens the MEDIA browser diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index d70650242faad30c7a1138c671a25ccf4b3186f6..d1ae3d7f618622129b3d3474743fd8fe261cebba 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -4037,6 +4037,7 @@ void process_kill_object(LLMessageSystem *mesgsys, void **user_data) { LLColor4 color(0.f,1.f,0.f,1.f); gPipeline.addDebugBlip(objectp->getPositionAgent(), color); + LL_DEBUGS("MessageBlip") << "Kill blip for local " << local_id << " at " << objectp->getPositionAgent() << LL_ENDL; } // Do the kill @@ -6882,15 +6883,12 @@ void process_user_info_reply(LLMessageSystem* msg, void**) << "wrong agent id." << LL_ENDL; } - BOOL im_via_email; - msg->getBOOLFast(_PREHASH_UserData, _PREHASH_IMViaEMail, im_via_email); std::string email; msg->getStringFast(_PREHASH_UserData, _PREHASH_EMail, email); std::string dir_visibility; msg->getStringFast(_PREHASH_UserData, _PREHASH_DirectoryVisibility, dir_visibility); - // For Message based user info information the is_verified is assumed to be false. - LLFloaterPreference::updateUserInfo(dir_visibility, im_via_email, false); + LLFloaterPreference::updateUserInfo(dir_visibility); LLFloaterSnapshot::setAgentEmail(email); } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 0ebd53268d224bb1205add090af6ea4761d8c999..0f31a44cb2fd260090d5e1a5314865edd950780f 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -2445,6 +2445,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, color.setVec(1.f, 0.f, 0.f, 1.f); } gPipeline.addDebugBlip(getPositionAgent(), color); + LL_DEBUGS("MessageBlip") << "Update type " << (S32)update_type << " blip for local " << mLocalID << " at " << getPositionAgent() << LL_ENDL; } const F32 MAG_CUTOFF = F_APPROXIMATELY_ZERO; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 38952feb8227c2ec0069f4f96a6750a630234cab..2c1d03d2b006daa9b2813bd1f1f938a641a27293 100644 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -3012,6 +3012,8 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("IncrementCOFVersion"); AISAPI::getCapNames(capabilityNames); + capabilityNames.append("InterestList"); + capabilityNames.append("GetDisplayNames"); capabilityNames.append("GetExperiences"); capabilityNames.append("AgentExperiences"); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 04dd2f6bff8b5b60729546ecbc1a935ecb32df7f..fe26623b3379e39302a82d0682349a636aaab880 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5375,6 +5375,104 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei return ret; } +BOOL LLViewerWindow::simpleSnapshot(LLImageRaw* raw, S32 image_width, S32 image_height, const int num_render_passes) +{ + gDisplaySwapBuffers = FALSE; + + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + setCursor(UI_CURSOR_WAIT); + + BOOL prev_draw_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI) ? TRUE : FALSE; + if (prev_draw_ui != false) + { + LLPipeline::toggleRenderDebugFeature(LLPipeline::RENDER_DEBUG_FEATURE_UI); + } + + LLPipeline::sShowHUDAttachments = FALSE; + LLRect window_rect = getWorldViewRectRaw(); + + S32 original_width = LLPipeline::sRenderDeferred ? gPipeline.mDeferredScreen.getWidth() : gViewerWindow->getWorldViewWidthRaw(); + S32 original_height = LLPipeline::sRenderDeferred ? gPipeline.mDeferredScreen.getHeight() : gViewerWindow->getWorldViewHeightRaw(); + + LLRenderTarget scratch_space; + U32 color_fmt = GL_RGBA; + const bool use_depth_buffer = true; + const bool use_stencil_buffer = true; + if (scratch_space.allocate(image_width, image_height, color_fmt, use_depth_buffer, use_stencil_buffer)) + { + if (gPipeline.allocateScreenBuffer(image_width, image_height)) + { + mWorldViewRectRaw.set(0, image_height, image_width, 0); + + scratch_space.bindTarget(); + } + else + { + scratch_space.release(); + gPipeline.allocateScreenBuffer(original_width, original_height); + } + } + + // we render the scene more than once since this helps + // greatly with the objects not being drawn in the + // snapshot when they are drawn in the scene. This is + // evident when you set this value via the debug setting + // called 360CaptureNumRenderPasses to 1. The theory is + // that the missing objects are caused by the sUseOcclusion + // property in pipeline but that the use in pipeline.cpp + // lags by a frame or two so rendering more than once + // appears to help a lot. + for (int i = 0; i < num_render_passes; ++i) + { + // turning this flag off here prohibits the screen swap + // to present the new page to the viewer - this stops + // the black flash in between captures when the number + // of render passes is more than 1. We need to also + // set it here because code in LLViewerDisplay resets + // it to TRUE each time. + gDisplaySwapBuffers = FALSE; + + // actually render the scene + const U32 subfield = 0; + const bool do_rebuild = true; + const F32 zoom = 1.0; + const bool for_snapshot = TRUE; + display(do_rebuild, zoom, subfield, for_snapshot); + } + + glReadPixels( + 0, 0, + image_width, + image_height, + GL_RGB, GL_UNSIGNED_BYTE, + raw->getData() + ); + stop_glerror(); + + gDisplaySwapBuffers = FALSE; + gDepthDirty = TRUE; + + if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) + { + if (prev_draw_ui != false) + { + LLPipeline::toggleRenderDebugFeature(LLPipeline::RENDER_DEBUG_FEATURE_UI); + } + } + + LLPipeline::sShowHUDAttachments = TRUE; + + setCursor(UI_CURSOR_ARROW); + + gPipeline.resetDrawOrders(); + mWorldViewRectRaw = window_rect; + scratch_space.flush(); + scratch_space.release(); + gPipeline.allocateScreenBuffer(original_width, original_height); + + return true; +} + void LLViewerWindow::destroyWindow() { if (mWindow) diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 5a39cb49115e4829997f17cb1342045453e7a4bf..9c7b7475ec8e0a1d0907de884c67564498aa68cc 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -355,7 +355,10 @@ class LLViewerWindow final : public LLWindowCallbacks BOOL saveSnapshot(const std::string& filename, S32 image_width, S32 image_height, BOOL show_ui = TRUE, BOOL show_hud = TRUE, BOOL do_rebuild = FALSE, LLSnapshotModel::ESnapshotLayerType type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR, LLSnapshotModel::ESnapshotFormat format = LLSnapshotModel::SNAPSHOT_FORMAT_BMP); BOOL rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect = TRUE, BOOL is_texture = FALSE, BOOL show_ui = TRUE, BOOL show_hud = TRUE, BOOL do_rebuild = FALSE, LLSnapshotModel::ESnapshotLayerType type = LLSnapshotModel::SNAPSHOT_TYPE_COLOR, S32 max_size = MAX_SNAPSHOT_IMAGE_SIZE); - BOOL thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL show_hud, BOOL do_rebuild, LLSnapshotModel::ESnapshotLayerType type); + + BOOL simpleSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, const int num_render_passes); + + BOOL thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 preview_height, BOOL show_ui, BOOL show_hud, BOOL do_rebuild, LLSnapshotModel::ESnapshotLayerType type); BOOL isSnapshotLocSet() const; void resetSnapshotLoc() const; diff --git a/indra/newview/skins/default/html/common/equirectangular/default.html b/indra/newview/skins/default/html/common/equirectangular/default.html new file mode 100644 index 0000000000000000000000000000000000000000..227b3065909d45b120ff120ab8482d59265aa129 --- /dev/null +++ b/indra/newview/skins/default/html/common/equirectangular/default.html @@ -0,0 +1,22 @@ +<html> +<head> +<style> +body { + background-color:#000; + background-image: linear-gradient(white 2px, transparent 2px), + linear-gradient(90deg, white 2px, transparent 2px), + linear-gradient(rgba(255,255,255,.3) 1px, transparent 1px), + linear-gradient(90deg, rgba(255,255,255,.3) 1px, transparent 1px); + background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px; + background-position:-2px -2px, -2px -2px, -1px -1px, -1px -1px; +} +</style> +</head> +<body> +<script> +function start() { +} +document.addEventListener('DOMContentLoaded', start); +</script> +</body> +</html> \ No newline at end of file diff --git a/indra/newview/skins/default/html/common/equirectangular/eqr_gen.html b/indra/newview/skins/default/html/common/equirectangular/eqr_gen.html new file mode 100644 index 0000000000000000000000000000000000000000..2675d37727a132a00200d5c50f74a9f62f9e7462 --- /dev/null +++ b/indra/newview/skins/default/html/common/equirectangular/eqr_gen.html @@ -0,0 +1,150 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> + <style> + body { + background: #333; + padding: 0; + margin: 0; + overflow: hidden; + } + #error_message { + z-index: 2; + background-color: #aa3333; + overflow: hidden; + display: none; + pointer-events:none; + font-family: monospace; + font-size: 3em; + color: white; + border-radius: 1em; + padding: 1em; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%) + } + #quality_window { + user-select: none; + z-index: 100; + position: absolute; + left: 8px; + top: 8px; + width: auto; + border-radius: 16px; + height: auto; + font-size: 1.5em; + text-align: center; + font-family: monospace; + background-color: rgba(200,200,200,0.35); + color: #000; + padding-left: 16px; + padding-right: 16px; + padding-top: 8px; + padding-bottom: 8px; + } + </style> +</head> +<body> + <script src="js/three.min.js"></script> + <script src="js/OrbitControls.js"></script> + <script src="js/jpeg_encoder_basic.js" type="text/javascript"></script> + <script src="js/CubemapToEquirectangular.js"></script> + <script> + var controls, camera, scene, renderer, equiManaged; + + function init(eqr_width, eqr_height, img_path, camera_fov, initial_heading, overlay_label) { + + camera = new THREE.PerspectiveCamera(camera_fov, window.innerWidth / window.innerHeight, 0.1, 100); + camera.position.x = 0.01; + + scene = new THREE.Scene(); + + renderer = new THREE.WebGLRenderer(); + renderer.autoClear = false; + renderer.setPixelRatio(window.devicePixelRatio); + renderer.setSize(window.innerWidth, window.innerHeight); + + var cubemap_img_js_url = img_path + '/cubemap_img.js'; + var cubemap_image_js = document.createElement('script'); + cubemap_image_js.setAttribute('type', 'text/javascript'); + cubemap_image_js.setAttribute('src', cubemap_img_js_url); + document.getElementsByTagName('head')[0].appendChild(cubemap_image_js); + cubemap_image_js.onload = function () { + document.getElementById("error_message").style.display = 'none' + scene.background = new THREE.CubeTextureLoader().load(cubemap_img_js); + equiManaged = new CubemapToEquirectangular(renderer, true, eqr_width, eqr_height); + }; + cubemap_image_js.onerror = function () { + document.getElementById("error_message").style.display = 'inline-block' + }; + + document.body.appendChild(renderer.domElement); + window.addEventListener('resize', onWindowResize, false); + + controls = new THREE.OrbitControls(camera, renderer.domElement); + controls.autoRotate = true; + controls.autoRotateSpeed = 0.2; + controls.enableZoom = false; + controls.enablePan = false; + controls.enableDamping = true; + controls.dampingFactor = 0.15; + controls.rotateSpeed = -0.5; + + // initial direction the camera faces + // We cannot edit camera rotation directly as the OrbitControls will + // immediately reset it so we need some math to tell the controls + // there to look at initially. Note there is also an offset of π/2 since + // the Viewer and three.js have slightly different coordinate systems + var spherical_target = new THREE.Spherical(1, Math.PI / 2, initial_heading + Math.PI / 2) + var target = new THREE.Vector3().setFromSpherical(spherical_target) + camera.position.set(target.x, target.y, target.z); + controls.update(); + controls.saveState(); + + // update the text that gets passed in from the C++ app for + // the translucent overlay label that tells us what we are seeing + document.getElementById('quality_window').innerHTML = overlay_label; + + animate(); + } + + window.addEventListener( + 'mousedown', + function (event) { + controls.autoRotate = false; + }, + false + ); + + window.addEventListener( + 'dblclick', + function (event) { + controls.autoRotate = true; + }, + false + ); + + function saveAsEqrImage(filename, xmp_details) { + equiManaged.update(camera, scene, filename, xmp_details); + } + + function onWindowResize() { + camera.aspect = window.innerWidth / window.innerHeight; + camera.updateProjectionMatrix(); + renderer.setSize(window.innerWidth, window.innerHeight); + } + + function animate() { + requestAnimationFrame(animate); + controls.update(); + renderer.render(scene, camera); + } + </script> + <div id="error_message">UNABLE TO LOAD EQR IMAGE</div> + <div id="quality_window">Preview Quality</div> +</body> +</html> \ No newline at end of file diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index cf9d25b10bd1f6678d5bf087b11e3c6151ca5286..40e8aebc4f175d6c5e00ec42aef47a495b6a93d9 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -135,7 +135,8 @@ with the same filename but different name <texture name="Check_Mark" file_name="icons/check_mark.png" preload="true" /> <texture name="Checker" file_name="checker.png" preload="false" /> - + + <texture name="Command_360_Capture_Icon" file_name="toolbar_icons/360_capture.png" preload="true" /> <texture name="Command_AboutLand_Icon" file_name="toolbar_icons/land.png" preload="true" /> <texture name="Command_Appearance_Icon" file_name="toolbar_icons/appearance.png" preload="true" /> <texture name="Command_Avatar_Icon" file_name="toolbar_icons/avatars.png" preload="true" /> diff --git a/indra/newview/skins/default/textures/toolbar_icons/360_capture.png b/indra/newview/skins/default/textures/toolbar_icons/360_capture.png new file mode 100644 index 0000000000000000000000000000000000000000..163cebe29fc7ff3c510d78e5769aca0d38aec1bb Binary files /dev/null and b/indra/newview/skins/default/textures/toolbar_icons/360_capture.png differ diff --git a/indra/newview/skins/default/xui/en/floater_360capture.xml b/indra/newview/skins/default/xui/en/floater_360capture.xml new file mode 100644 index 0000000000000000000000000000000000000000..c89489d145ce171d785ac1ef3fb41918184a0e8d --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_360capture.xml @@ -0,0 +1,135 @@ +<?xml version="1.0" encoding="UTF-8"?> +<floater can_resize="true" + height="400" + layout="topleft" + min_height="300" + min_width="400" + name="360capture" + help_topic="360capture" + save_rect="true" + title="360 SNAPSHOT" + width="800"> + <panel layout="topleft" + background_visible="true" + top="0" + follows="left|bottom|top" + left="0" + width="200" + bg_opaque_color="0.195 0.195 0.195 1" + background_opaque="true" + height="400" + name="ui_panel_left"> + <text + follows="top|left|right" + height="16" + layout="topleft" + left="10" + top="10" + width="100"> + Quality level + </text> + <radio_group + control_name="360QualitySelection" + follows="left|top" + height="94" + layout="topleft" + left_delta="20" + name="360_quality_selection" + top_pad="0" + width="180"> + <radio_item + height="20" + label="Preview (fast)" + layout="topleft" + left="0" + name="preview_quality" + value="128" + tool_tip="Preview quality" + top="0" + width="100" /> + <radio_item + height="20" + label="Medium" + layout="topleft" + left_delta="0" + name="medium_quality" + value="512" + tool_tip="Medium quality" + top_delta="20" + width="100" /> + <radio_item + height="20" + label="High" + layout="topleft" + left_delta="0" + name="high_quality" + value="1024" + tool_tip="High quality" + top_delta="20" + width="100" /> + <radio_item + height="20" + label="Maximum" + layout="topleft" + left_delta="0" + name="maximum_quality" + value="2048" + tool_tip="Maximum quality" + top_delta="20" + width="100" /> + </radio_group> + <check_box control_name="360CaptureHideAvatars" + follows="left|top" + height="15" + label="Hide all avatars" + layout="left" + left="10" + name="360_hide_avatar" + top_delta="0" + width="100"/> + <button follows="left|top" + height="20" + label="Create 360 image" + layout="topleft" + left="10" + name="capture_button" + top_delta="32" + width="180" /> + <button follows="left|top" + height="20" + label="Save as..." + layout="topleft" + left="10" + name="save_local_button" + top_delta="35" + width="180" /> + </panel> + <panel layout="topleft" + background_visible="true" + top="0" + follows="all" + left="200" + width="600" + bg_opaque_color="0.195 0.195 0.195 1" + background_opaque="true" + height="400" + name="ui_panel_right"> + <web_browser top="10" + follows="all" + bg_opaque_color="0.225 0.225 0.225 1" + left="0" + width="590" + height="368" + name="360capture_contents" + trusted_content="true" /> + <text follows="bottom" + layout="topleft" + name="statusbar" + height="17" + left="0" + top="382" + width="590"> + Click and drag on the image to pan + </text> + </panel> +</floater> \ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/floater_preferences.xml b/indra/newview/skins/default/xui/en/floater_preferences.xml index 1041e27b1db07423e30ae6acfed2d53b4547a636..7200fe09c779ca9a75c76056d89a1d9352155cde 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences.xml @@ -11,12 +11,6 @@ single_instance="true" title="PREFERENCES" width="658"> - <floater.string - name="email_unverified_tooltip"> - Please verify your email to enable IM to Email by visiting -https://accounts.secondlife.com/change_email/ - </floater.string> - <button follows="right|bottom" height="23" diff --git a/indra/newview/skins/default/xui/en/floater_snapshot.xml b/indra/newview/skins/default/xui/en/floater_snapshot.xml index 832c2ee7da62bfcb0c439653c4bc87d69a3987b4..f441e3cbd7eba15775786768876423e3caf7a086 100644 --- a/indra/newview/skins/default/xui/en/floater_snapshot.xml +++ b/indra/newview/skins/default/xui/en/floater_snapshot.xml @@ -400,7 +400,7 @@ layout="topleft" name="img_info_border" top_pad="0" - right="-10" + right="-130" follows="left|top|right" left_delta="0"/> <text @@ -411,11 +411,10 @@ height="14" layout="topleft" left="220" - right="-20" halign="left" name="image_res_text" top_delta="5" - width="200"> + width="250"> [WIDTH]px (width) x [HEIGHT]px (height) </text> <text @@ -423,7 +422,7 @@ font="SansSerifSmall" height="14" layout="topleft" - left="-65" + left="-185" length="1" halign="right" name="file_size_label" @@ -432,4 +431,19 @@ width="50"> [SIZE] KB </text> + <text + follows="right|top" + font="SansSerifSmall" + height="14" + layout="topleft" + left="-130" + length="1" + halign="right" + name="360_label" + text_color="0.3 0.82 1 1" + top_delta="0" + type="string" + width="115"> + Take a 360 snapshot + </text> </floater> diff --git a/indra/newview/skins/default/xui/en/floater_toybox.xml b/indra/newview/skins/default/xui/en/floater_toybox.xml index bc19d6e79f5d70c134c092a52516d7b5c686e9cf..bdc04a8a78864d4e32de2a6c5ab6ec9242bdceaf 100644 --- a/indra/newview/skins/default/xui/en/floater_toybox.xml +++ b/indra/newview/skins/default/xui/en/floater_toybox.xml @@ -4,7 +4,7 @@ can_dock="false" can_minimize="false" can_resize="false" - height="375" + height="430" help_topic="toybox" layout="topleft" legacy_header_height="18" @@ -45,7 +45,7 @@ Buttons will appear as shown or as icon-only depending on each toolbar's settings. </text> <toolbar - bottom="310" + bottom="365" button_display_mode="icons_with_text" follows="all" left="20" @@ -81,11 +81,11 @@ <panel bevel_style="none" border="true" - bottom="311" + bottom="366" follows="left|bottom|right" left="20" right="-20" - top="311" /> + top="366" /> <button follows="left|bottom|right" height="23" @@ -94,7 +94,7 @@ layout="topleft" left="185" name="btn_clear_all" - top="330" + top="385" width="130"> <button.commit_callback function="Toybox.ClearAll" /> </button> @@ -106,7 +106,7 @@ layout="topleft" left="335" name="btn_restore_defaults" - top="330" + top="385" width="130"> <button.commit_callback function="Toybox.RestoreDefaults" /> </button> diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index e34d6f5624f2b881a43c047a8a7216b90d15378a..8f5a5a364bdb3b493cef9ad364f3a1c7ce6572d7 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -793,6 +793,15 @@ function="Floater.Show" parameter="snapshot" /> </menu_item_call> + +<menu_item_call + label="360 snapshot" + name="Capture 360" + shortcut="control|alt|shift|s"> + <menu_item_call.on_click + function="Floater.Show" + parameter="360capture" /> + </menu_item_call> <menu_item_separator/> <menu_item_call label="Place profile" @@ -3799,6 +3808,14 @@ function="World.EnvPreset" <menu_item_call.on_click function="Advanced.DumpRegionObjectCache" /> </menu_item_call> + +<menu_item_call + label="Interest List: Full Update" + name="Interest List: Full Update" + shortcut="alt|shift|I"> + <menu_item_call.on_click + function="Advanced.InterestListFullUpdate" /> + </menu_item_call> </menu> <menu create_jump_keys="true" diff --git a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml index feeeb3cf296374484456f0d1d54cdfb145d13179..b812677e61c3b2041130103fa80fc9986779d5a2 100644 --- a/indra/newview/skins/default/xui/en/panel_preferences_chat.xml +++ b/indra/newview/skins/default/xui/en/panel_preferences_chat.xml @@ -40,15 +40,19 @@ width="330"> </check_box> - <check_box - enabled="false" - height="16" - label="Email me IMs when I'm offline" - layout="topleft" - name="send_im_to_email" - top_pad="4" - width="330"> - </check_box> + <text + font="SansSerifSmall" + height="16" + layout="topleft" + length="1" + name="email_settings" + skip_link_underline="true" + top_pad="6" + left_delta="2" + type="string" + width="350"> + [https://accounts.secondlife.com/change_email Email me IMs when I'm offline] + </text> <text layout="topleft" diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index f4c2ef2530db15bc14cebcca30843e64d87a644e..0115f8fb81b229591f58eecfe968a29be2cbf36f 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -4150,6 +4150,8 @@ Try enclosing path to the editor with double quotes. <!-- commands --> + <string +name="Command_360_Capture_Label">360 snapshot</string> <string name="Command_AboutLand_Label">About land</string> <string name="Command_AnimationOverride_Label">AO</string> <string name="Command_Appearance_Label">Outfits</string> @@ -4189,6 +4191,8 @@ Try enclosing path to the editor with double quotes. <string name="Command_Voice_Label">Voice Settings</string> <string name="Command_Webbrowser_Label">Web Browser</string> + <string +name="Command_360_Capture_Tooltip">Capture a 360 equirectangular image</string> <string name="Command_AboutLand_Tooltip">Information about the land you're visiting</string> <string name="Command_AnimationOverride_Tooltip">Animation Override</string> <string name="Command_Appearance_Tooltip">Change your avatar</string> diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index f649754f15fa4488f8fb2525992dc715002282ac..38c0f5c2da93bcda3a4464ca47077fc651d3d89f 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -167,18 +167,12 @@ def construct(self): self.path("*/*.xml") self.path("*/*.json") - # Local HTML files (e.g. loading screen) - # The claim is that we never use local html files any - # longer. But rather than commenting out this block, let's - # rename every html subdirectory as html.old. That way, if - # we're wrong, a user actually does have the relevant - # files; s/he just needs to rename every html.old - # directory back to html to recover them. - with self.prefix(src="*/html", dst="*/html.old"): - self.path("*.png") + # Update: 2017-11-01 CP Now we store app code in the html folder + # Initially the HTML/JS code to render equirectangular + # images for the 360 capture feature but more to follow. + with self.prefix(src="*/html", dst="*/html"): + self.path("*/*/*/*.js") self.path("*/*/*.html") - self.path("*/*/*.gif") - #build_data.json. Standard with exception handling is fine. If we can't open a new file for writing, we have worse problems #platform is computed above with other arg parsing