Newer
Older
Steven Bennetts
committed
* @file llappviewer.cpp
* @brief The LLAppViewer class definitions
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
Steven Bennetts
committed
* Second Life Viewer Source Code
* Copyright (C) 2012, 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
Steven Bennetts
committed
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
Steven Bennetts
committed
#include "llappviewer.h"
// Viewer includes
Steven Bennetts
committed
#include "llfeaturemanager.h"
#include "lluictrlfactory.h"
#include "lltexteditor.h"
#include "llenvironment.h"
Steven Bennetts
committed
#include "llerrorcontrol.h"
Tofu Linden
committed
#include "lleventtimer.h"
Steven Bennetts
committed
#include "llgroupmgr.h"
#include "llagent.h"
#include "llagentcamera.h"
Vadim Savchuk
committed
#include "llagentlanguage.h"
Richard Linden
committed
#include "llagentui.h"
#include "llagentwearables.h"
maxim_productengine
committed
#include "lldirpicker.h"
AlexanderP ProductEngine
committed
#include "llfloaterimcontainer.h"
#include "llimprocessing.h"
Steven Bennetts
committed
#include "llwindow.h"
#include "llviewerstats.h"
Don Kjer
committed
#include "llviewerstatsrecorder.h"
Leslie Linden
committed
#include "llmarketplacefunctions.h"
#include "llmarketplacenotifications.h"
Steven Bennetts
committed
#include "llmd5.h"
Steven Bennetts
committed
#include "llpumpio.h"
#include "llslurl.h"
Steven Bennetts
committed
#include "llstartup.h"
#include "llfocusmgr.h"
#include "llviewerjoystick.h"
#include "llallocator.h"
#include "llcalc.h"
#include "llconversationlog.h"
Richard Linden
committed
#include "lldxhardware.h"
#include "lltexturestats.h"
#include "lltrace.h"
Steven Bennetts
committed
#include "llviewerwindow.h"
#include "llviewerdisplay.h"
#include "llviewerparcelaskplay.h"
Steven Bennetts
committed
#include "llviewermessage.h"
#include "llviewerobjectlist.h"
#include "llworldmap.h"
#include "llmutelist.h"
#include "llviewerhelp.h"
#include "lluicolortable.h"
#include "llurldispatcher.h"
#include "llrender.h"
#include "llteleporthistory.h"
#include "lltoast.h"
Richard Linden
committed
#include "llsdutil_math.h"
#include "lllocationhistory.h"
#include "llfasttimerview.h"
#include "llvoicechannel.h"
Yuri Chebotarev
committed
#include "llurlmatch.h"
#include "lltextutil.h"
#include "lllogininstance.h"
Andrew A. de Laix
committed
#include "llprogressview.h"
brad kittenbrink
committed
#include "llvocache.h"
Callum Prentice
committed
#include "lldiskcache.h"
#include "llvopartgroup.h"
Kitty Barnett
committed
// [SL:KB] - Patch: Appearance-Misc | Checked: 2013-02-12 (Catznip-3.4)
#include "llappearancemgr.h"
// [/SL:KB]
// [RLVa:KB] - Checked: 2010-05-03 (RLVa-1.2.0g)
#include "rlvactions.h"
#include "rlvhandler.h"
// [/RLVa:KB]
Steven Bennetts
committed
#include "llweb.h"

Rye Mutt
committed
// [SL:KB] - Patch: Build-AssetRecovery | Checked: 2011-11-24 (Catznip-3.2)
#include "llfloaterassetrecovery.h"
// [/SL:KB]
#include "llfloatertexturefetchdebugger.h"
Xiaohong Bao
committed
#include "llscenemonitor.h"
simon
committed
#include "llavatarrenderinfoaccountant.h"
#include "lllocalbitmaps.h"
Steven Bennetts
committed
// Linden library includes
#include "lldiriterator.h"
dolphin@dolphin-THINK.lindenlab.com
committed
#include "llexperiencecache.h"
brad kittenbrink
committed
#include "llimagej2c.h"
#include "llmemory.h"
#include "llprimitive.h"
#include "llurlaction.h"
Seth ProductEngine
committed
#include "llurlentry.h"
#include "llvolumemgr.h"
brad kittenbrink
committed
#include "llxfermanager.h"
#include "llphysicsextensions.h"
Alexei Arabadji
committed
#include "llnotificationmanager.h"
#include "llnotifications.h"
#include "llnotificationsutil.h"
Alexei Arabadji
committed
#include "llleap.h"
#include "stringize.h"
#include "llcoros.h"
#include "llexception.h"
Rider Linden
committed
#if !LL_LINUX
Callum Prentice
committed
#include "cef/dullahan_version.h"
callum_linden
committed
#endif // LL_LINUX
// Third party library includes
#include <boost/bind.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>
#include <boost/throw_exception.hpp>
Steven Bennetts
committed
#if LL_WINDOWS
Oz Linden
committed
# include <share.h> // For _SH_DENYWR in processMarkerFiles
Steven Bennetts
committed
#else
Oz Linden
committed
# include <sys/file.h> // For processMarkerFiles
Steven Bennetts
committed
#endif
#include "llapr.h"
#include <boost/lexical_cast.hpp>
Steven Bennetts
committed
#include "llviewerkeyboard.h"
#include "lllfsthread.h"
#include "llworkerthread.h"
#include "lltexturecache.h"
#include "lltexturefetch.h"
#include "llimageworker.h"
Steven Bennetts
committed
// The files below handle dependencies from cleanup.
#include "llkeyframemotion.h"
#include "llworldmap.h"
#include "llhudmanager.h"
#include "lltoolmgr.h"
#include "llassetstorage.h"
#include "llpolymesh.h"
#include "llaudioengine.h"
#include "llstreamingaudio.h"
Steven Bennetts
committed
#include "llviewermenu.h"
#include "llselectmgr.h"
James Cook
committed
#include "lltrans.h"
Adam Moss
committed
#include "lltransutil.h"
Steven Bennetts
committed
#include "lltracker.h"
#include "llviewerparcelmgr.h"
#include "llworldmapview.h"
#include "llpostprocess.h"
Steven Bennetts
committed
#include "lldebugview.h"
#include "llconsole.h"
#include "llcontainerview.h"
Richard Nelson
committed
#include "lltooltip.h"
Steven Bennetts
committed
#include "llsdutil.h"
Kyle Machulis
committed
#include "llsdserialize.h"
Steven Bennetts
committed
#include "llworld.h"
#include "llhudeffecttrail.h"
#include "llvectorperfoptions.h"
#include "llwatchdog.h"
Steven Bennetts
committed
// Included so that constants/settings might be initialized
// in save_settings_to_globals()
#include "llbutton.h"
#include "llstatusbar.h"
#include "llsurface.h"
#include "llvosky.h"
#include "llvotree.h"
#include "llvoavatar.h"
#include "llfolderview.h"
#include "llagentpilot.h"
#include "llvovolume.h"
#include "llflexibleobject.h"
#include "llvosurfacepatch.h"
#include "llviewerfloaterreg.h"
#include "llcommandlineparser.h"
#include "llfloatermemleak.h"
James Cook
committed
#include "llfloaterreg.h"
pavelkproductengine
committed
#include "llfloateroutfitsnapshot.h"
#include "llfloatersnapshot.h"
#include "llsidepanelinventory.h"
Steven Bennetts
committed
// includes for idle() idleShutdown()
#include "llviewercontrol.h"
#include "lleventnotifier.h"
#include "llcallbacklist.h"
Gilbert Gonzales
committed
#include "lldeferredsounds.h"
Steven Bennetts
committed
#include "pipeline.h"
#include "llgesturemgr.h"
#include "llsky.h"
#include "llvlmanager.h"
#include "llviewercamera.h"
#include "lldrawpoolbump.h"
#include "llvieweraudio.h"
#include "llimview.h"
#include "llviewerthrottle.h"
Steven Bennetts
committed
#include "llavatariconctrl.h"
Yuri Chebotarev
committed
#include "llgroupiconctrl.h"
// Include for security api initialization
#include "llsecapi.h"
#include "llcoproceduremanager.h"
#include "llviewereventrecorder.h"
Steven Bennetts
committed
// *FIX: These extern globals should be cleaned up.
// The globals either represent state/config/resource-storage of either
// this app, or another 'component' of the viewer. App globals should be
// moved into the app class, where as the other globals should be
Steven Bennetts
committed
// moved out of here.
// If a global symbol reference seems valid, it will be included
// via header files above.
//----------------------------------------------------------------------------
// llviewernetwork.h
#include "llviewernetwork.h"
// define a self-registering event API object
#include "llappviewerlistener.h"
Steven Bennetts
committed
#if (LL_LINUX || LL_SOLARIS) && LL_GTK
#include "glib.h"
#endif // (LL_LINUX || LL_SOLARIS) && LL_GTK
#if LL_MSVC
// disable boost::lexical_cast warning
#pragma warning (disable:4702)
#endif
Steven Bennetts
committed
static LLAppViewerListener sAppViewerListener(LLAppViewer::instance);
////// Windows-specific includes to the bottom - nasty defines in these pollute the preprocessor
//
Steven Bennetts
committed
//----------------------------------------------------------------------------
// viewer.cpp - these are only used in viewer, should be easily moved.
#if LL_DARWIN
extern void init_apple_menu(const char* product);
#endif // LL_DARWIN
extern BOOL gRandomizeFramerate;
extern BOOL gPeriodicSlowFrame;
Steven Bennetts
committed
////////////////////////////////////////////////////////////
// All from the last globals push...
Brad Payne (Vir Linden)
committed
F32 gSimLastTime; // Used in LLAppViewer::init and send_viewer_stats()
Steven Bennetts
committed
F32 gSimFrames;
BOOL gShowObjectUpdates = FALSE;
Steven Bennetts
committed
eLastExecEvent gLastExecEvent = LAST_EXEC_NORMAL;
S32 gLastExecDuration = -1; // (<0 indicates unknown)
Steven Bennetts
committed
#if LL_WINDOWS
Oz Linden
committed
# define LL_PLATFORM_KEY "win"
#elif LL_DARWIN
# define LL_PLATFORM_KEY "mac"
#elif LL_LINUX
# define LL_PLATFORM_KEY "lnx"
Oz Linden
committed
# error "Unknown Platform"
#endif
const char* gPlatform = LL_PLATFORM_KEY;
Steven Bennetts
committed
Kyle Machulis
committed
LLSD gDebugInfo;
Steven Bennetts
committed
U32 gFrameCount = 0;
U32 gForegroundFrameCount = 0; // number of frames that app window was in foreground
LLPumpIO* gServicePump = NULL;
Steven Bennetts
committed
U64MicrosecondsImplicit gFrameTime = 0;
F32SecondsImplicit gFrameTimeSeconds = 0.f;
F32SecondsImplicit gFrameIntervalSeconds = 0.f;
F32 gFPSClamped = 10.f; // Pretend we start at target rate.
F32 gFrameDTClamped = 0.f; // Time between adjacent checks to network for packets
U64MicrosecondsImplicit gStartTime = 0; // gStartTime is "private", used only to calculate gFrameTimeSeconds
Steven Bennetts
committed
LLTimer gRenderStartTime;
LLFrameTimer gForegroundTime;
LLFrameTimer gLoggedInTime;
LLTimer gLogoutTimer;
static const F32 LOGOUT_REQUEST_TIME = 6.f; // this will be cut short by the LogoutReply msg.
F32 gLogoutMaxTime = LOGOUT_REQUEST_TIME;
Steven Bennetts
committed
Brad Payne (Vir Linden)
committed
S32 gPendingMetricsUploads = 0;
Steven Bennetts
committed
BOOL gDisconnected = FALSE;
// used to restore texture state after a mode switch
LLFrameTimer gRestoreGLTimer;
BOOL gRestoreGL = FALSE;
Callum Prentice
committed
bool gUseWireframe = FALSE;
ruslantproductengine
committed
//use for remember deferred mode in wireframe switch
Callum Prentice
committed
bool gInitialDeferredModeForWireframe = FALSE;
Steven Bennetts
committed
LLMemoryInfo gSysMemory;
U64Bytes gMemoryAllocated(0); // updated in display_stats() in llviewerdisplay.cpp
Steven Bennetts
committed
std::string gLastVersionChannel;
Steven Bennetts
committed
LLVector3 gWindVec(3.0, 3.0, 0.0);
LLVector3 gRelativeWindVec(0.0, 0.0, 0.0);
U32 gPacketsIn = 0;
BOOL gPrintMessagesThisFrame = FALSE;
BOOL gRandomizeFramerate = FALSE;
BOOL gPeriodicSlowFrame = FALSE;
BOOL gCrashOnStartup = FALSE;
BOOL gLLErrorActivated = FALSE;
BOOL gLogoutInProgress = FALSE;
AndreyL ProductEngine
committed
BOOL gSimulateMemLeak = FALSE;
Steven Bennetts
committed
////////////////////////////////////////////////////////////
// Internal globals... that should be removed.
static std::string gArgs;
const int MAX_MARKER_LENGTH = 1024;
const std::string MARKER_FILE_NAME("Alchemy.exec_marker");
const std::string START_MARKER_FILE_NAME("Alchemy.start_marker");
const std::string ERROR_MARKER_FILE_NAME("Alchemy.error_marker");
const std::string LLERROR_MARKER_FILE_NAME("Alchemy.llerror_marker");
const std::string LOGOUT_MARKER_FILE_NAME("Alchemy.logout_marker");
Kitty Barnett
committed
//static BOOL gDoDisconnect = FALSE;
// [RLVa:KB] - Checked: RLVa-2.3
BOOL gDoDisconnect = FALSE;
// [/RLVa:KB]
static std::string gLaunchFileOnQuit;
Steven Bennetts
committed
// Used on Win32 for other apps to identify our window (eg, win_setup)
const char* const VIEWER_WINDOW_CLASSNAME = "Alchemy";
//-- LLDeferredTaskList ------------------------------------------------------
/**
* A list of deferred tasks.
*
* We sometimes need to defer execution of some code until the viewer gets idle,
* e.g. removing an inventory item from within notifyObservers() may not work out.
*
* Tasks added to this list will be executed in the next LLAppViewer::idle() iteration.
* All tasks are executed only once.
*/
class LLDeferredTaskList final : public LLSingleton<LLDeferredTaskList>
{
LLSINGLETON_EMPTY_CTOR(LLDeferredTaskList);
LOG_CLASS(LLDeferredTaskList);
friend class LLAppViewer;
typedef boost::signals2::signal<void()> signal_t;
void addTask(const signal_t::slot_type& cb)
{
mSignal.connect(cb);
}
void run()
{
if (!mSignal.empty())
{
mSignal();
mSignal.disconnect_all_slots();
}
}
signal_t mSignal;
};
//----------------------------------------------------------------------------
// List of entries from strings.xml to always replace
static std::set<std::string> default_trans_args;
void init_default_trans_args()
{
default_trans_args.insert("SECOND_LIFE"); // World
default_trans_args.insert("APP_NAME");
Tofu Linden
committed
default_trans_args.insert("CAPITALIZED_APP_NAME");
default_trans_args.insert("SECOND_LIFE_GRID");
default_trans_args.insert("SUPPORT_SITE");
Nat Goodspeed
committed
// This URL shows up in a surprising number of places in various skin
// files. We really only want to have to maintain a single copy of it.
default_trans_args.insert("create_account_url");
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
struct SettingsFile : public LLInitParam::Block<SettingsFile>
{
Mandatory<std::string> name;
Optional<std::string> file_name;
Optional<bool> required,
persistent;
Optional<std::string> file_name_setting;
SettingsFile()
: name("name"),
file_name("file_name"),
required("required", false),
persistent("persistent", true),
file_name_setting("file_name_setting")
{}
};
struct SettingsGroup : public LLInitParam::Block<SettingsGroup>
{
Mandatory<std::string> name;
Mandatory<S32> path_index;
Multiple<SettingsFile> files;
SettingsGroup()
: name("name"),
path_index("path_index"),
files("file")
{}
};
struct SettingsFiles : public LLInitParam::Block<SettingsFiles>
{
Multiple<SettingsGroup> groups;
SettingsFiles()
: groups("group")
{}
};
static std::string gWindowTitle;
Steven Bennetts
committed
//----------------------------------------------------------------------------
// Metrics logging control constants
//----------------------------------------------------------------------------
static const F32 METRICS_INTERVAL_DEFAULT = 600.0;
static const F32 METRICS_INTERVAL_QA = 30.0;
static F32 app_metrics_interval = METRICS_INTERVAL_DEFAULT;
static bool app_metrics_qa_mode = false;
Steven Bennetts
committed
void idle_afk_check()
{
// check idle timers
F32 current_idle = gAwayTriggerTimer.getElapsedTimeF32();
static const LLCachedControl<S32> afk_timeout_cc(gSavedSettings, "AFKTimeout");
// [RLVa:KB] - Checked: 2010-05-03 (RLVa-1.2.0g) | Modified: RLVa-1.2.0g
// Enforce an idle time of 30 minutes if @allowidle=n restricted
F32 afk_timeout = (!gRlvHandler.hasBehaviour(RLV_BHVR_ALLOWIDLE)) ? afk_timeout_cc : 60 * 30;
// F32 afk_timeout = gSavedSettings.getS32("AFKTimeout");
if (afk_timeout && (current_idle > afk_timeout) && ! gAgent.getAFK())
Steven Bennetts
committed
{
LL_INFOS("IdleAway") << "Idle more than " << afk_timeout << " seconds: automatically changing to Away status" << LL_ENDL;
Steven Bennetts
committed
gAgent.setAFK();
}
}
// A callback set in LLAppViewer::init()
static void ui_audio_callback(const LLUUID& uuid)
Steven Bennetts
committed
{
if (gAudiop)
{
SoundData soundData(uuid, gAgent.getID(), 1.0f, LLAudioEngine::AUDIO_TYPE_UI);
gAudiop->triggerSound(soundData);
Steven Bennetts
committed
}
}
Gilbert Gonzales
committed
// A callback set in LLAppViewer::init()
static void deferred_ui_audio_callback(const LLUUID& uuid)
{
if (gAudiop)
{
SoundData soundData(uuid, gAgent.getID(), 1.0f, LLAudioEngine::AUDIO_TYPE_UI);
LLDeferredSounds::instance().deferSound(soundData);
Gilbert Gonzales
committed
}
}
Yuri Chebotarev
committed
bool create_text_segment_icon_from_url_match(LLUrlMatch* match,LLTextBase* base)
{
if(!match || !base || base->getPlainText())
Yuri Chebotarev
committed
return false;
LLUUID match_id = match->getID();
LLIconCtrl* icon;
if( match->getMenuName() == "menu_url_group.xml" // See LLUrlEntryGroup constructor
|| gAgent.isInGroup(match_id, TRUE)) //This check seems unfiting, urls are either /agent or /group
Yuri Chebotarev
committed
{
Yuri Chebotarev
committed
icon_params.group_id = match_id;
icon_params.rect = LLRect(0, 16, 16, 0);
icon_params.visible = true;
icon = LLUICtrlFactory::instance().create<LLGroupIconCtrl>(icon_params);
Yuri Chebotarev
committed
}
else
{
Yuri Chebotarev
committed
icon_params.avatar_id = match_id;
icon_params.rect = LLRect(0, 16, 16, 0);
icon_params.visible = true;
icon = LLUICtrlFactory::instance().create<LLAvatarIconCtrl>(icon_params);
Yuri Chebotarev
committed
}
LLInlineViewSegment::Params params;
params.force_newline = false;
params.view = icon;
params.left_pad = 4;
params.right_pad = 4;
Richard Linden
committed
params.top_pad = -2;
Yuri Chebotarev
committed
params.bottom_pad = 2;
base->appendWidget(params," ",false);
Yuri Chebotarev
committed
return true;
}
Steven Bennetts
committed
// Use these strictly for things that are constructed at startup,
// or for things that are performance critical. JC
static void settings_to_globals()
Steven Bennetts
committed
{
LLBUTTON_H_PAD = gSavedSettings.getS32("ButtonHPad");
BTN_HEIGHT_SMALL = gSavedSettings.getS32("ButtonHeightSmall");
BTN_HEIGHT = gSavedSettings.getS32("ButtonHeight");
MENU_BAR_HEIGHT = gSavedSettings.getS32("MenuBarHeight");
MENU_BAR_WIDTH = gSavedSettings.getS32("MenuBarWidth");
LLSurface::setTextureSize(gSavedSettings.getU32("RegionTextureSize"));
LLRender::sGLCoreProfile = gSavedSettings.getBOOL("RenderGLCoreProfile");
Graham Linden graham@lindenlab.com
committed
LLRender::sNsightDebugSupport = gSavedSettings.getBOOL("RenderNsightDebugSupport");
LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO");
Steven Bennetts
committed
LLImageGL::sGlobalUseAnisotropic = gSavedSettings.getBOOL("RenderAnisotropic");
LLImageGL::sCompressTextures = gSavedSettings.getBOOL("RenderCompressTextures");
LLVOVolume::sLODFactor = llclamp(gSavedSettings.getF32("RenderVolumeLODFactor"), 0.01f, MAX_LOD_FACTOR);
Steven Bennetts
committed
LLVOVolume::sDistanceFactor = 1.f-LLVOVolume::sLODFactor * 0.1f;
LLVolumeImplFlexible::sUpdateFactor = gSavedSettings.getF32("RenderFlexTimeFactor");
LLVOTree::sTreeFactor = gSavedSettings.getF32("RenderTreeLODFactor");
LLVOAvatar::sLODFactor = llclamp(gSavedSettings.getF32("RenderAvatarLODFactor"), 0.f, MAX_AVATAR_LOD_FACTOR);
LLVOAvatar::sPhysicsLODFactor = llclamp(gSavedSettings.getF32("RenderAvatarPhysicsLODFactor"), 0.f, MAX_AVATAR_LOD_FACTOR);
LLVOAvatar::updateImpostorRendering(gSavedSettings.getU32("RenderAvatarMaxNonImpostors"));
Steven Bennetts
committed
LLVOAvatar::sVisibleInFirstPerson = gSavedSettings.getBOOL("FirstPersonAvatarVisible");
// clamp auto-open time to some minimum usable value
LLFolderView::sAutoOpenTime = llmax(0.25f, gSavedSettings.getF32("FolderAutoOpenDelay"));
LLSelectMgr::sRectSelectInclusive = gSavedSettings.getBOOL("RectangleSelectInclusive");
LLSelectMgr::sRenderHiddenSelections = gSavedSettings.getBOOL("RenderHiddenSelections");
LLSelectMgr::sRenderLightRadius = gSavedSettings.getBOOL("RenderLightRadius");
Brad Payne (Vir Linden)
committed
gAgentPilot.setNumRuns(gSavedSettings.getS32("StatsNumRuns"));
gAgentPilot.setQuitAfterRuns(gSavedSettings.getBOOL("StatsQuitAfterRuns"));
gAgent.setHideGroupTitle(gSavedSettings.getBOOL("RenderHideGroupTitle"));
Steven Bennetts
committed
gDebugWindowProc = gSavedSettings.getBOOL("DebugWindowProc");
gShowObjectUpdates = gSavedSettings.getBOOL("ShowObjectUpdates");
LLWorldMapView::sMapScale = gSavedSettings.getF32("MapScale");
Steven Bennetts
committed
static void settings_modify()
{
David Parks
committed
LLRenderTarget::sUseFBO = gSavedSettings.getBOOL("RenderDeferred");
LLPipeline::sRenderTransparentWater = gSavedSettings.getBOOL("RenderTransparentWater");
Graham Madarasz
committed
LLPipeline::sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");
LLPipeline::sRenderDeferred = LLPipeline::sRenderTransparentWater && LLPipeline::sRenderBump && gSavedSettings.getBOOL("RenderDeferred");
LLVOSurfacePatch::sLODFactor = gSavedSettings.getF32("RenderTerrainLODFactor");
LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor; //square lod factor to get exponential range of [1,4]
gDebugGL = gSavedSettings.getBOOL("RenderDebugGL") || gDebugSession;
gDebugPipeline = gSavedSettings.getBOOL("RenderDebugPipeline");
Steven Bennetts
committed
}
class LLFastTimerLogThread : public LLThread
{
public:
std::string mFile;
LLFastTimerLogThread(std::string& test_name) : LLThread("fast timer log")
std::string file_name = test_name + std::string(".slp");
mFile = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, file_name);
}
void run()
{
andreykproductengine
committed
llofstream os(mFile.c_str());
while (!LLAppViewer::instance()->isQuitting())
{
Richard Linden
committed
LLTrace::BlockTimer::writeLog(os);
os.flush();
ms_sleep(32);
}
os.close();
}
};
//virtual
bool LLAppViewer::initSLURLHandler()
Steven Bennetts
committed
{
// does nothing unless subclassed
return false;
}
//virtual
bool LLAppViewer::sendURLToOtherInstance(const std::string& url)
{
// does nothing unless subclassed
Steven Bennetts
committed
return false;
}
//----------------------------------------------------------------------------
// LLAppViewer definition
// Static members.
// The single viewer app.
LLAppViewer* LLAppViewer::sInstance = NULL;
LLTextureCache* LLAppViewer::sTextureCache = NULL;
LLImageDecodeThread* LLAppViewer::sImageDecodeThread = NULL;
LLTextureFetch* LLAppViewer::sTextureFetch = NULL;
Steven Bennetts
committed
Richard Linden
committed
std::string getRuntime()
{
Richard Linden
committed
return llformat("%.4f", (F32)LLTimer::getElapsedSeconds().value());
Richard Linden
committed
}
LLAppViewer::LLAppViewer()
Richard Linden
committed
: mMarkerFile(),
mLogoutMarkerFile(),
Steven Bennetts
committed
mReportedCrash(false),
mNumSessions(0),
mPurgeCache(false),
mPurgeCacheOnExit(false),
mPurgeUserDataOnExit(false),
mSecondInstance(false),
mUpdaterNotFound(false),
Steven Bennetts
committed
mSavedFinalSnapshot(false),
mSavePerAccountSettings(false), // don't save settings on logout unless login succeeded.
mQuitRequested(false),
mLogoutRequestSent(false),
andreykproductengine
committed
mLastAgentControlFlags(0),
mLastAgentForceUpdate(0),
mMainloopTimeout(NULL),
mAgentRegionLastAlive(false),
mRandomizeFramerate(LLCachedControl<bool>(gSavedSettings,"Randomize Framerate", FALSE)),
mPeriodicSlowFrame(LLCachedControl<bool>(gSavedSettings,"Periodic Slow Frame", FALSE)),
mFastTimerLogThread(NULL),
pavelkproductengine
committed
mSettingsLocationList(NULL),
Andrey Kleshchev
committed
mIsFirstRun(false),
mMinMicroSecPerFrame(0.f)
Steven Bennetts
committed
{
if(NULL != sInstance)
{
LL_ERRS() << "Oh no! An instance of LLAppViewer already exists! LLAppViewer is sort of like a singleton." << LL_ENDL;
Steven Bennetts
committed
}
// Need to do this initialization before we do anything else, since anything
// that touches files should really go through the lldir API
gDirUtilp->initAppDirs("AlchemyNext");
//
// IMPORTANT! Do NOT put anything that will write
// into the log files during normal startup until AFTER
// we run the "program crashed last time" error handler below.
//
Steven Bennetts
committed
sInstance = this;
gLoggedInTime.stop();
processMarkerFiles();
//
// OK to write stuff to logs now, we've now crash reported if necessary
//
LLLoginInstance::instance().setPlatformInfo(gPlatform, LLOSInfo::instance().getOSVersionString(), LLOSInfo::instance().getOSStringSimple());
// Under some circumstances we want to read the static_debug_info.log file
// from the previous viewer run between this constructor call and the
// init() call, which will overwrite the static_debug_info.log file for
// THIS run. So setDebugFileNames() early.
#if LL_BUGSPLAT
// MAINT-8917: don't create a dump directory just for the
// static_debug_info.log file
std::string logdir = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "");
#else // ! LL_BUGSPLAT
// write Google Breakpad minidump files to a per-run dump directory to avoid multiple viewer issues.
std::string logdir = gDirUtilp->getExpandedFilename(LL_PATH_DUMP, "");
#endif // ! LL_BUGSPLAT
setDebugFileNames(logdir);
Steven Bennetts
committed
}
LLAppViewer::~LLAppViewer()
{
destroyMainloopTimeout();
Steven Bennetts
committed
// If we got to this destructor somehow, the app didn't hang.
Steven Bennetts
committed
}
class LLUITranslationBridge : public LLTranslationBridge
{
public:
virtual std::string getString(const std::string &xml_desc)
{
return LLTrans::getString(xml_desc);
}
};
namespace {
// With Xcode 6, _exit() is too magical to use with boost::bind(), so provide
// this little helper function.
void fast_exit(int rc)
{
_exit(rc);
}
}
Steven Bennetts
committed
bool LLAppViewer::init()
setupErrorHandling(mSecondInstance);
Steven Bennetts
committed
//
// Start of the application
//
Richard Nelson
committed
// initialize LLWearableType translation bridge.
// Memory will be cleaned up in ::cleanupClass()
LLWearableType::initParamSingleton(new LLUITranslationBridge());
// initialize the LLSettingsType translation bridge.
LLTranslationBridge::ptr_t trans = std::make_shared<LLUITranslationBridge>();
LLSettingsType::initParamSingleton(trans);
//initialize particle index pool
LLVOPartGroup::initClass();
// set skin search path to default, will be overridden later
// this allows simple skinned file lookups to work
gDirUtilp->setSkinFolder("default", "en");
Steven Bennetts
committed
// initLoggingAndGetLastDuration();
Steven Bennetts
committed
//
// OK to write stuff to logs now, we've now crash reported if necessary
//
init_default_trans_args();
if (!initConfiguration())
LL_INFOS("InitInfo") << "Configuration initialized." << LL_ENDL ;
//set the max heap size.
initMaxHeapSize() ;
LLCoros::instance().setStackSize(gSavedSettings.getS32("CoroutineStackSize"));
Oz Linden
committed
// Although initLoggingAndGetLastDuration() is the right place to mess with
// setFatalFunction(), we can't query gSavedSettings until after
// initConfiguration().
S32 rc(gSavedSettings.getS32("QAModeTermCode"));
if (rc >= 0)
{
// QAModeTermCode set, terminate with that rc on LL_ERRS. Use
// fast_exit() rather than exit() because normal cleanup depends too
// much on successful startup!
LLError::setFatalFunction(boost::bind(fast_exit, rc));
mAlloc.setProfilingEnabled(gSavedSettings.getBOOL("MemProfiling"));
Monty Brandenberg
committed
// Initialize the non-LLCurl libcurl library. Should be called
// before consumers (LLTextureFetch).
mAppCoreHttp.init();
Rider Linden
committed
LL_INFOS("InitInfo") << "LLCore::Http initialized." << LL_ENDL ;
if (gSavedSettings.getBOOL("QAModeMetrics"))
app_metrics_qa_mode = true;
app_metrics_interval = METRICS_INTERVAL_QA;
}
LLViewerAssetStatsFF::init();
LL_INFOS("InitInfo") << "Threads initialized." << LL_ENDL ;
Xiaohong Bao
committed
Vadim ProductEngine
committed
// Initialize settings early so that the defaults for ignorable dialogs are
// picked up and then correctly re-saved after launching the updater (STORM-1268).
LLUI::settings_map_t settings_map;
settings_map["config"] = &gSavedSettings;
settings_map["ignores"] = &gWarningSettings;
settings_map["floater"] = &gSavedSettings; // *TODO: New settings file
settings_map["account"] = &gSavedPerAccountSettings;
LLUI::initParamSingleton(settings_map,
Vadim ProductEngine
committed
LLUIImageList::getInstance(),
ui_audio_callback,
deferred_ui_audio_callback);
Vadim ProductEngine
committed
LL_INFOS("InitInfo") << "UI initialized." << LL_ENDL ;
// NOW LLUI::getLanguage() should work. gDirUtilp must know the language
// for this session ASAP so all the file-loading commands that follow,
// that use findSkinnedFilenames(), will include the localized files.
gDirUtilp->setSkinFolder(gDirUtilp->getSkinFolder(), LLUI::getLanguage());
// Setup LLTrans after LLUI::initClass has been called.
initStrings();
Vadim ProductEngine
committed
// Setup notifications after LLUI::initClass() has been called.
Vadim ProductEngine
committed
LLNotifications::instance();
LL_INFOS("InitInfo") << "Notifications initialized." << LL_ENDL ;
writeSystemInfo();
Steven Bennetts
committed
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// *FIX: The following code isn't grouped into functions yet.
// Various introspection concerning the libs we're using - particularly
LL_INFOS("InitInfo") << "J2C Engine is: " << LLImageJ2C::getEngineInfo() << LL_ENDL;
Rider Linden
committed
LL_INFOS("InitInfo") << "libcurl version is: " << LLCore::LLHttp::getCURLVersion() << LL_ENDL;
Steven Bennetts
committed
/////////////////////////////////////////////////
// OS-specific login dialogs
/////////////////////////////////////////////////
//test_cached_control();
Steven Bennetts
committed
// track number of times that app has run
mNumSessions = gSavedSettings.getS32("NumSessions");
mNumSessions++;
gSavedSettings.setS32("NumSessions", mNumSessions);
// LLKeyboard relies on LLUI to know what some accelerator keys are called.
LLKeyboard::setStringTranslatorFunc( LLTrans::getKeyboardString );
// Provide the text fields with callbacks for opening Urls
LLUrlAction::setOpenURLCallback(boost::bind(&LLWeb::loadURL, _1, LLStringUtil::null, LLStringUtil::null));
AndreyL ProductEngine
committed
LLUrlAction::setOpenURLInternalCallback(boost::bind(&LLWeb::loadURLInternal, _1, LLStringUtil::null, LLStringUtil::null, false));
LLUrlAction::setOpenURLExternalCallback(boost::bind(&LLWeb::loadURLExternal, _1, true, LLStringUtil::null));
LLUrlAction::setExecuteSLURLCallback(&LLURLDispatcher::dispatchFromTextEditor);
// Let code in llui access the viewer help floater
LLUI::getInstance()->mHelpImpl = LLViewerHelp::getInstance();
Xiaohong Bao
committed
LL_INFOS("InitInfo") << "UI initialization is done." << LL_ENDL ;
// Load translations for tooltips
LLFloater::initClass();
/////////////////////////////////////////////////
LLToolMgr::getInstance(); // Initialize tool manager if not already instantiated
LLViewerFloaterReg::registerFloaters();
Steven Bennetts
committed
/////////////////////////////////////////////////
//
// Load settings files
//
//
LLGroupMgr::parseRoleActions("role_actions.xml");
LLAgent::parseTeleportMessages("teleport_strings.xml");
Monroe Linden
committed
std::string mime_types_name;
#if LL_DARWIN
mime_types_name = "mime_types_mac.xml";
#elif LL_LINUX
mime_types_name = "mime_types_linux.xml";
#else
mime_types_name = "mime_types.xml";
#endif
LLMIMETypes::parseMIMETypes( mime_types_name );
// Copy settings to globals. *TODO: Remove or move to appropriage class initializers
// Setup settings listeners
settings_setup_listeners();
// Modify settings based on system configuration and compile options
settings_modify();
Steven Bennetts
committed
// Find partition serial number (Windows) or hardware serial (Mac)
mSerialNumber = generateSerialNumber();
// do any necessary set-up for accepting incoming SLURLs from apps
initSLURLHandler();
Steven Bennetts
committed
if(false == initHardwareTest())
{
// Early out from user choice.
return false;
}
LL_INFOS("InitInfo") << "Hardware test initialization done." << LL_ENDL ;
Steven Bennetts
committed
// Prepare for out-of-memory situations, during which we will crash on
// purpose and save a dump.
#if LL_WINDOWS && LL_RELEASE_FOR_DOWNLOAD && LL_USE_SMARTHEAP
MemSetErrorHandler(first_mem_error_handler);
#endif // LL_WINDOWS && LL_RELEASE_FOR_DOWNLOAD && LL_USE_SMARTHEAP
// *Note: this is where gViewerStats used to be created.
Steven Bennetts
committed
if (!initCache())
{
LL_WARNS("InitInfo") << "Failed to init cache" << LL_ENDL;
Steven Bennetts
committed
std::ostringstream msg;
msg << LLTrans::getString("MBUnableToAccessFile");
OSMessageBox(msg.str(),LLStringUtil::null,OSMB_OK);
return 0;
Steven Bennetts
committed
}
Xiaohong Bao
committed
LL_INFOS("InitInfo") << "Cache initialization is done." << LL_ENDL ;
Andrew A. de Laix
committed
LLMainLoopRepeater::instance().start();
Steven Bennetts
committed
//
// Initialize the window
//
Steven Bennetts
committed
initWindow();
Xiaohong Bao
committed
LL_INFOS("InitInfo") << "Window is initialized." << LL_ENDL ;
Steven Bennetts
committed
// initWindow also initializes the Feature List, so now we can initialize this global.
LLCubeMap::sUseCubeMaps = LLFeatureManager::getInstance()->isFeatureAvailable("RenderCubeMap");
// call all self-registered classes
LLInitClassList::instance().fireCallbacks();
LLFolderViewItem::initClass(); // SJB: Needs to happen after initWindow(), not sure why but related to fonts
Kyle Machulis
committed
gGLManager.getGLInfo(gDebugInfo);