From d9640ecc65d599506202a8f8ae1eba5ea698199d Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sat, 28 Jan 2012 22:02:10 -0600 Subject: [PATCH 01/36] Little cleanup regarding crashlogger toggling. --- indra/llcommon/llapp.cpp | 14 +++++++++++++- indra/llcommon/llapp.h | 9 ++++++--- indra/newview/llappviewer.cpp | 4 ++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index 75c85a105..168121c0f 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -401,6 +401,18 @@ bool LLApp::isExiting() return isQuitting() || isError(); } +void LLApp::disableCrashlogger() +{ + // Disable Breakpad exception handler. + sDisableCrashlogger = TRUE; +} + +// static +bool LLApp::isCrashloggerDisabled() +{ + return (sDisableCrashlogger == TRUE); +} + #if !LL_WINDOWS // static U32 LLApp::getSigChildCount() @@ -734,7 +746,7 @@ void default_unix_signal_handler(int signum, siginfo_t *info, void *) llwarns << "Signal handler - Flagging error status and waiting for shutdown" << llendl; } - if(LLApp::sDisableCrashlogger) //Don't gracefully handle any signals crash and core for a gdb post mortum + if (LLApp::isCrashloggerDisabled()) // Don't gracefully handle any signal, crash and core for a gdb post mortem { clear_signals(); llwarns << "Fatal signal received, not handling the crash here, passing back to operating system" << llendl; diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h index 09e88b326..6ad34c8fa 100644 --- a/indra/llcommon/llapp.h +++ b/indra/llcommon/llapp.h @@ -191,6 +191,11 @@ public: // virtual bool mainLoop() = 0; // Override for the application main loop. Needs to at least gracefully notice the QUITTING state and exit. + // + // Crash logging + // + void disableCrashlogger(); // Let the OS handle the crashes + static bool isCrashloggerDisabled(); // Get the here above set value // // Application status @@ -214,9 +219,6 @@ public: // void setErrorHandler(LLAppErrorHandler handler); void setSyncErrorHandler(LLAppErrorHandler handler); - - static BOOL sDisableCrashlogger; // Let the OS handle crashes for us. - #if !LL_WINDOWS // // Child process handling (Unix only for now) @@ -245,6 +247,7 @@ protected: static void setStatus(EAppStatus status); // Use this to change the application status. static 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. #if !LL_WINDOWS static LLAtomicU32* sSigChildCount; // Number of SIGCHLDs received. diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 51b9867a5..ad7387f3c 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2145,7 +2145,7 @@ bool LLAppViewer::initConfiguration() if(clp.hasOption("disablecrashlogger")) { llwarns << "Crashes will be handled by system, stack trace logs and crash logger are both disabled" <disableCrashlogger(); } // Handle initialization from settings. @@ -2731,7 +2731,7 @@ void LLAppViewer::handleViewerCrash() abort(); } - if(pApp->sDisableCrashlogger==TRUE) + if (LLApp::isCrashloggerDisabled()) { abort(); } From d0c782c7ae68324b862df2fd5ac23f89cf11d5d2 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sat, 28 Jan 2012 22:07:13 -0600 Subject: [PATCH 02/36] A few more translated tidbits. Also converted french strings.xml from BOM with windows lineendings, to non-BOM with unix lineendings. --- indra/llprimitive/llmaterialtable.cpp | 10 + indra/llprimitive/llmaterialtable.h | 1 + indra/newview/llagent.cpp | 12 +- indra/newview/llpanelvolume.cpp | 12 + .../skins/default/xui/en-us/strings.xml | 17 +- .../newview/skins/default/xui/fr/strings.xml | 1390 +++++++++-------- 6 files changed, 756 insertions(+), 686 deletions(-) diff --git a/indra/llprimitive/llmaterialtable.cpp b/indra/llprimitive/llmaterialtable.cpp index cb7154771..63687c258 100644 --- a/indra/llprimitive/llmaterialtable.cpp +++ b/indra/llprimitive/llmaterialtable.cpp @@ -127,6 +127,16 @@ LLMaterialTable::~LLMaterialTable() mMaterialInfoList.clear(); } +void LLMaterialTable::initTableTransNames(std::map namemap) +{ + for (info_list_t::iterator iter = mMaterialInfoList.begin(); + iter != mMaterialInfoList.end(); ++iter) + { + LLMaterialInfo *infop = *iter; + std::string name = infop->mName; + infop->mName = namemap[name]; + } +} void LLMaterialTable::initBasicTable() { // *TODO: Translate diff --git a/indra/llprimitive/llmaterialtable.h b/indra/llprimitive/llmaterialtable.h index c7144e884..77f29a8e0 100644 --- a/indra/llprimitive/llmaterialtable.h +++ b/indra/llprimitive/llmaterialtable.h @@ -110,6 +110,7 @@ public: void initBasicTable(); + void initTableTransNames(std::map namemap); BOOL add(U8 mcode, const std::string& name, const LLUUID &uuid); BOOL addCollisionSound(U8 mcode, U8 mcode2, const LLUUID &uuid); diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index b6ac5613c..2c7c1d4b4 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -1216,8 +1216,7 @@ void LLAgent::setAFK() gAwayTimer.start(); if (gAFKMenu) { - // *TODO:Translate - gAFKMenu->setLabel(std::string("Set Not Away")); + gAFKMenu->setLabel(LLTrans::getString("AvatarSetNotAway")); } } } @@ -1242,8 +1241,7 @@ void LLAgent::clearAFK() LL_INFOS("AFK") << "Clearing Away" << LL_ENDL; if (gAFKMenu) { - // *TODO:Translate - gAFKMenu->setLabel(std::string("Set Away")); + gAFKMenu->setLabel(LLTrans::getString("AvatarSetAway")); } } } @@ -1265,8 +1263,7 @@ void LLAgent::setBusy() mIsBusy = TRUE; if (gBusyMenu) { - // *TODO:Translate - gBusyMenu->setLabel(std::string("Set Not Busy")); + gBusyMenu->setLabel(LLTrans::getString("AvatarSetNotBusy")); } LLFloaterMute::getInstance()->updateButtons(); } @@ -1280,8 +1277,7 @@ void LLAgent::clearBusy() sendAnimationRequest(ANIM_AGENT_BUSY, ANIM_REQUEST_STOP); if (gBusyMenu) { - // *TODO:Translate - gBusyMenu->setLabel(std::string("Set Busy")); + gBusyMenu->setLabel(LLTrans::getString("AvatarSetBusy")); } LLFloaterMute::getInstance()->updateButtons(); } diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index e8356a57d..1a07d8a44 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -165,6 +165,18 @@ BOOL LLPanelVolume::postBuild() mSpinPhysicsRestitution = getChild("Physics Restitution"); mSpinPhysicsRestitution->setCommitCallback(boost::bind(&LLPanelVolume::sendPhysicsRestitution, this, _1, mSpinPhysicsRestitution)); } + + std::map material_name_map; + material_name_map["Stone"]= LLTrans::getString("Stone"); + material_name_map["Metal"]= LLTrans::getString("Metal"); + material_name_map["Glass"]= LLTrans::getString("Glass"); + material_name_map["Wood"]= LLTrans::getString("Wood"); + material_name_map["Flesh"]= LLTrans::getString("Flesh"); + material_name_map["Plastic"]= LLTrans::getString("Plastic"); + material_name_map["Rubber"]= LLTrans::getString("Rubber"); + material_name_map["Light"]= LLTrans::getString("Light"); + + LLMaterialTable::basic.initTableTransNames(material_name_map); // Start with everyone disabled clearCtrls(); diff --git a/indra/newview/skins/default/xui/en-us/strings.xml b/indra/newview/skins/default/xui/en-us/strings.xml index e72790169..738159f6e 100644 --- a/indra/newview/skins/default/xui/en-us/strings.xml +++ b/indra/newview/skins/default/xui/en-us/strings.xml @@ -1739,6 +1739,7 @@ string llGetEnv(string name) Returns a string with the requested data about the region + list llCastRay( Vector start, Vector end, list options ) Returns a list consisting of the following three values for each hit: UUID, Link number, Hit position. @@ -1803,18 +1804,32 @@ key llAvatarOnLinkSitTarget( integer link ) Returns a key that is the UUID of the user seated on the prim. + + + Not Away + Away + Not Busy + Busy Press ESC to return to World View - + Stone + Metal + Glass + Wood + Flesh + Plastic + Rubber + Light + Ctrl- Cmd- Opt- diff --git a/indra/newview/skins/default/xui/fr/strings.xml b/indra/newview/skins/default/xui/fr/strings.xml index e31f823e6..b051c2eb7 100644 --- a/indra/newview/skins/default/xui/fr/strings.xml +++ b/indra/newview/skins/default/xui/fr/strings.xml @@ -1,677 +1,713 @@ - - - - L$ - Linden Lab - - Second Life - - - Singularity Viewer - - - SINGULARITY VIEWER - - - Grille de Second Life - - - Portail Assistance Second Life - - - Détection du matériel... - - - Chargement de [APP_NAME]... - - - Vidage du cache... - - - Initialisation du cache des textures... - - - Initialisation VFS... - - - Échec d'initialisation des graphiques. Veuillez mettre votre pilote graphique à jour. - - - Restauration... - - - Changement de la résolution... - - - La connexion à [APP_NAME] apparaît peut-être comme étant gelée. Veuillez patienter. - - - Connexion... - - - Authentification en cours - - - Maintenance du compte en cours… - - - La tentative de connexion précédente a échoué. Connexion, esssai [NUMBER] - - - Monde en cours de chargement PATIENCE… - - - Navigateur Web incorporé en cours d'initialisation… - - - Multimédia en cours d'initialisation. Aimez vous Brahms ?… - - - Fichiers du cache en cours de vérification (peut prendre 60-90 s)ou pire... - - - Réponse en cours de traitement… - - - Monde en cours d'initialisation… - - - Décodage des images en cours, croisons les doigts... - - - Quicktime en cours d'initialisation - - - Quicktime introuvable, impossible de procéder à l'initialisation. - - - Initialisation de Quicktime réussie. - - - Capacités de la région demandées... - - - Capacités de la région demandées... Tentative n° [NUMBER]. - - - Liaison avec la région en cours de création... - - - Connexion avec la région en cours, avec un peu de chance ... - - - Habits en cours de téléchargement, esperons le ... - - - Échec de la connexion. - - - Quitter - - - Il y a peut-être des problèmes techniques dans cette region. Veuillez vérifier votre connexion Internet. - - - Enregistrement des paramètres... - - - Déconnexion... - - - Arrêt en cours... - - - Vous avez été déconnecté de la région où vous étiez. - - - Vous avez été transféré vers une région non valide. - - - Personne - - - (pas de nom) - - - Propriétaire : - - - Public - - - (Groupe) - - - Script - - - Propriétés physique - - - Toucher - - - [CURRENCY] - - - Laisser tomber l'inventaire - - - Fantôme - - - Temporaire - - - (cliquez-droit pour le menu) - - - Copie autorisée - - - À vendre : [AMOUNT] [CURRENCY] - - - À vendre : [MESSAGE] - - - Contruction de groupe - - - Pas de construction - - - Contruction de groupe - - - Non sécurisé - - - Interdiction de voler - - - Scripts de groupe - - - Pas de scripts - - - Terrain : - - - Impossible de faire glisser plus d'un objet ici - - - En cours d'extraction... - - - Notes de version - - - Chargement.. - - - (personne) - - - (en attente) - - - (hippos) - - - (aucun) - - - Aucune erreur - - - Requête de l'actif : échec - - - Requête de l'actif : fichier inexistant - - - Requête de l'actif : actif introuvable dans la base de données - - - Fin du ficher - - - Impossible d'ouvrir le fichier - - - Fichier introuvable - - - Délai d'attente du transfert du fichier dépassé - - - Disparition du circuit - - - Il y a une différence de prix entre le client et le serveur - - - Statut inconnu - - - (Apparence en cours de modification) - - - Absent - - - Occupé - - - Ignoré - Mute - - - Effrayé - - - En colère - - - Absent - - - Salto arrière - - - Rire en se tenant le ventre - - - Grand sourire - - - Envoyer un baiser - - - Bailler d'ennui - - - S'incliner - - - Applaudir - - - Révérence de cour - - - Pleurer - - - Danse 1 - - - Danse 2 - - - Danse 3 - - - Danse 4 - - - Danse 5 - - - Danse 6 - - - Danse 7 - - - Danse 8 - - - Mépris - - - Boire - - - Gêne - - - Désapprobation - - - Victoire - - - Yoga - - - Froncer les sourcils - - - Impatient - - - Sauter de joie - - - Va te faire voir ! - - - Baiser - - - Rire - - - Montrer ses muscles - - - Non (mécontent) - - - Non - - - Na na na na nère - - - Gauche-droite - - - Bouche ouverte - - - Paix - - - Montrer quelqu'un du doigt - - - Se montrer du doigt - - - Gauche - - - Droite - - - Compter (pierre-papier-ciseaux) - - - Papier (pierre-papier-ciseaux) - - - Pierre (pierre-papier-ciseaux) - - - Ciseaux (pierre-papier-ciseaux) - - - Dégoût - - - Coup de pied circulaire - - - Triste - - - Salut - - - Crier - - - Hausser les épaules - - - Sourire - - - Fumer, immobile - - - Fumer, prendre une bouffée - - - Fumer, jeter son mégot - - - Surprise - - - Coup d'épée - - - Caprice - - - Tirer la langue - - - Faire signe - - - Chuchoter - - - Siffler - - - Clin d'œil - - - Clin d'œil (Hollywood) - - - Soucis - - - Oui (Joie) - - - Oui - - - Chargement... - - - Hors ligne - - - chuchote : - - - crie : - - - PG - - - Mature - - - Adult - - - Hors ligne - - - Inconnu - - - (inconnu) - - - Dernière modification : (jamais) - - - Dernière modification : - - - Tous fichiers - - - Sons - - - Animations - - - Images - - - Enregistrer - - - Charger - - - Images Targa - - - Images Bitmap - - - Fichier de film AVI - - - Fichier d'animation XAF - - - Fichier XML - - - Fichier RAW - - - Images compressées - - - Charger des fichiers - - - Choisir le répertoire - - - - Appuyez sur ESC pour quitter la vue subjective - - - - Ctrl- - - - Cmd- - - - Opt- - - - Maj- - - - Ctrl- - - - Alt- - - - Maj- - - - Une erreur est survenue lors de la lecture de la ligne de commande. -Merci de consulter : http://wiki.secondlife.com/wiki/Client_parameters -Erreur : - - - [APP_NAME] - Utilisation de la ligne de commande : - - - [APP_NAME] ne peut accéder à un fichier requis. - -Cela vient du fait que quelqu'un a ouvert plusieurs copies ou que votre système pense qu'un fichier est ouvert. -Si ce message persiste, veuillez redémarrer votre ordinateur. -Si le problème persiste, vous devrez peut-être complètement désinstaller puis réinstaller [APP_NAME]. - - - Erreur fatale - - - [APP_NAME] nécessite un microprocesseur AltiVec (version G4 ou antérieure). - - - [APP_NAME] est déjà en cours d'exécution. -Vérifiez si une version minimisée du programme apparaît dans votre barre de tâches. -Si ce message persiste, redémarrez votre ordinateur. - - - [APP_NAME] semble avoir crashé lors de l'utilisation précédente. -Voulez-vous envoyer un rapport de crash ? - - - Notification - - - [APP_NAME] ne peut détecter DirectX 9.0b ou une version supérieure. -[APP_NAME] utilise DirectX pour détecter les matériels et/ou les pilotes qui ne sont pas à jour et peuvent causer des problèmes de stabilité, de performance ou des plantages. Bien que vous puissiez utiliser [APP_NAME] sans DirectX, nous vous recommandons de l'utiliser avec DirectX 9.0b. - -Voulez-vous continuer ? - - - Avertissement - - - RegisterClass a échoué - - - Erreur - - - Impossible d'ouvrir le mode plein écran à [WIDTH] x [HEIGHT]. -Utilisation du mode fenêtré. - - - Erreur de fermeture lors de la destruction de la fenêtre (DestroyWindow() a échoué) - - - Erreur de fermeture - - - Impossible de créer le contexte GL - - - Impossible de trouver le format pixel approprié - - - Impossible de trouver la description du format pixel - - - [APP_NAME] nécessite True Color (32 bits) pour s'exécuter. -Accédez aux paramètres d'affichage de votre ordinateur et réglez le mode couleur sur 32 bits. - - - [APP_NAME] ne peut pas s'exécuter, car il n'y pas de canal alpha 8 bits accessible. En général, ceci vient de problèmes avec le pilote de la carte vidéo. -Assurez-vous d'avoir installé le pilote de carte vidéo le plus récent possible. -Assurez-vous aussi que votre écran est réglé sur True Color (32 bits) sous Panneau de configuration > Affichage > Paramètres. -Si ce message persiste, veuillez aller sur la page [SUPPORT_SITE]. - - - Impossible de trouver le format pixel approprié - - - Impossible de créer le contexte de rendu GL - - - Impossible d'activer le contexte de rendu GL - - - [APP_NAME] ne peut pas s'exécuter car les pilotes de votre carte vidéo n'ont pas été installés correctement, ne sont pas à jour, ou sont pour du matériel non pris en charge. Assurez-vous d'avoir des pilotes de cartes vidéos récents, et même si vous avez les plus récents, réinstallez-les. - -Si ce message persiste, veuillez aller sur la page [SUPPORT_SITE]. - + + + + L$ + Linden Lab + + Second Life + + + Singularity Viewer + + + SINGULARITY VIEWER + + + Grille de Second Life + + + Portail Assistance Second Life + + + Détection du matériel... + + + Chargement de [APP_NAME]... + + + Vidage du cache... + + + Initialisation du cache des textures... + + + Initialisation VFS... + + + Échec d'initialisation des graphiques. Veuillez mettre votre pilote graphique à jour. + + + Restauration... + + + Changement de la résolution... + + + La connexion à [APP_NAME] apparaît peut-être comme étant gelée. Veuillez patienter. + + + Connexion... + + + Authentification en cours + + + Maintenance du compte en cours… + + + La tentative de connexion précédente a échoué. Connexion, esssai [NUMBER] + + + Monde en cours de chargement PATIENCE… + + + Navigateur Web incorporé en cours d'initialisation… + + + Multimédia en cours d'initialisation. Aimez vous Brahms ?… + + + Fichiers du cache en cours de vérification (peut prendre 60-90 s)ou pire... + + + Réponse en cours de traitement… + + + Monde en cours d'initialisation… + + + Décodage des images en cours, croisons les doigts... + + + Quicktime en cours d'initialisation + + + Quicktime introuvable, impossible de procéder à l'initialisation. + + + Initialisation de Quicktime réussie. + + + Capacités de la région demandées... + + + Capacités de la région demandées... Tentative n° [NUMBER]. + + + Liaison avec la région en cours de création... + + + Connexion avec la région en cours, avec un peu de chance ... + + + Habits en cours de téléchargement, esperons le ... + + + Échec de la connexion. + + + Quitter + + + Il y a peut-être des problèmes techniques dans cette region. Veuillez vérifier votre connexion Internet. + + + Enregistrement des paramètres... + + + Déconnexion... + + + Arrêt en cours... + + + Vous avez été déconnecté de la région où vous étiez. + + + Vous avez été transféré vers une région non valide. + + + Personne + + + (pas de nom) + + + Propriétaire : + + + Public + + + (Groupe) + + + Script + + + Propriétés physique + + + Toucher + + + [CURRENCY] + + + Laisser tomber l'inventaire + + + Fantôme + + + Temporaire + + + (cliquez-droit pour le menu) + + + Copie autorisée + + + À vendre : [AMOUNT] [CURRENCY] + + + À vendre : [MESSAGE] + + + Contruction de groupe + + + Pas de construction + + + Contruction de groupe + + + Non sécurisé + + + Interdiction de voler + + + Scripts de groupe + + + Pas de scripts + + + Terrain : + + + Impossible de faire glisser plus d'un objet ici + + + En cours d'extraction... + + + Notes de version + + + Chargement.. + + + (personne) + + + (en attente) + + + (hippos) + + + (aucun) + + + Aucune erreur + + + Requête de l'actif : échec + + + Requête de l'actif : fichier inexistant + + + Requête de l'actif : actif introuvable dans la base de données + + + Fin du ficher + + + Impossible d'ouvrir le fichier + + + Fichier introuvable + + + Délai d'attente du transfert du fichier dépassé + + + Disparition du circuit + + + Il y a une différence de prix entre le client et le serveur + + + Statut inconnu + + + (Apparence en cours de modification) + + + Absent + + + Occupé + + + Ignoré - Mute + + + Effrayé + + + En colère + + + Absent + + + Salto arrière + + + Rire en se tenant le ventre + + + Grand sourire + + + Envoyer un baiser + + + Bailler d'ennui + + + S'incliner + + + Applaudir + + + Révérence de cour + + + Pleurer + + + Danse 1 + + + Danse 2 + + + Danse 3 + + + Danse 4 + + + Danse 5 + + + Danse 6 + + + Danse 7 + + + Danse 8 + + + Mépris + + + Boire + + + Gêne + + + Désapprobation + + + Victoire + + + Yoga + + + Froncer les sourcils + + + Impatient + + + Sauter de joie + + + Va te faire voir ! + + + Baiser + + + Rire + + + Montrer ses muscles + + + Non (mécontent) + + + Non + + + Na na na na nère + + + Gauche-droite + + + Bouche ouverte + + + Paix + + + Montrer quelqu'un du doigt + + + Se montrer du doigt + + + Gauche + + + Droite + + + Compter (pierre-papier-ciseaux) + + + Papier (pierre-papier-ciseaux) + + + Pierre (pierre-papier-ciseaux) + + + Ciseaux (pierre-papier-ciseaux) + + + Dégoût + + + Coup de pied circulaire + + + Triste + + + Salut + + + Crier + + + Hausser les épaules + + + Sourire + + + Fumer, immobile + + + Fumer, prendre une bouffée + + + Fumer, jeter son mégot + + + Surprise + + + Coup d'épée + + + Caprice + + + Tirer la langue + + + Faire signe + + + Chuchoter + + + Siffler + + + Clin d'œil + + + Clin d'œil (Hollywood) + + + Soucis + + + Oui (Joie) + + + Oui + + + Chargement... + + + Hors ligne + + + chuchote : + + + crie : + + + PG + + + Mature + + + Adult + + + Hors ligne + + + Inconnu + + + (inconnu) + + + Dernière modification : (jamais) + + + Dernière modification : + + + Tous fichiers + + + Sons + + + Animations + + + Images + + + Enregistrer + + + Charger + + + Images Targa + + + Images Bitmap + + + Fichier de film AVI + + + Fichier d'animation XAF + + + Fichier XML + + + Fichier RAW + + + Images compressées + + + Charger des fichiers + + + Choisir le répertoire + + + Présent + + + Absent + + + Pas occupé + + + Occupé + + + Pierre + + + Métal + + + Verre + + + Bois + + + Chair + + + Plastique + + + Caoutchouc + + + Léger + + + + Appuyez sur ESC pour quitter la vue subjective + + + + Ctrl- + + + Cmd- + + + Opt- + + + Maj- + + + Ctrl- + + + Alt- + + + Maj- + + + Une erreur est survenue lors de la lecture de la ligne de commande. +Merci de consulter : http://wiki.secondlife.com/wiki/Client_parameters +Erreur : + + + [APP_NAME] - Utilisation de la ligne de commande : + + + [APP_NAME] ne peut accéder à un fichier requis. + +Cela vient du fait que quelqu'un a ouvert plusieurs copies ou que votre système pense qu'un fichier est ouvert. +Si ce message persiste, veuillez redémarrer votre ordinateur. +Si le problème persiste, vous devrez peut-être complètement désinstaller puis réinstaller [APP_NAME]. + + + Erreur fatale + + + [APP_NAME] nécessite un microprocesseur AltiVec (version G4 ou antérieure). + + + [APP_NAME] est déjà en cours d'exécution. +Vérifiez si une version minimisée du programme apparaît dans votre barre de tâches. +Si ce message persiste, redémarrez votre ordinateur. + + + [APP_NAME] semble avoir crashé lors de l'utilisation précédente. +Voulez-vous envoyer un rapport de crash ? + + + Notification + + + [APP_NAME] ne peut détecter DirectX 9.0b ou une version supérieure. +[APP_NAME] utilise DirectX pour détecter les matériels et/ou les pilotes qui ne sont pas à jour et peuvent causer des problèmes de stabilité, de performance ou des plantages. Bien que vous puissiez utiliser [APP_NAME] sans DirectX, nous vous recommandons de l'utiliser avec DirectX 9.0b. + +Voulez-vous continuer ? + + + Avertissement + + + RegisterClass a échoué + + + Erreur + + + Impossible d'ouvrir le mode plein écran à [WIDTH] x [HEIGHT]. +Utilisation du mode fenêtré. + + + Erreur de fermeture lors de la destruction de la fenêtre (DestroyWindow() a échoué) + + + Erreur de fermeture + + + Impossible de créer le contexte GL + + + Impossible de trouver le format pixel approprié + + + Impossible de trouver la description du format pixel + + + [APP_NAME] nécessite True Color (32 bits) pour s'exécuter. +Accédez aux paramètres d'affichage de votre ordinateur et réglez le mode couleur sur 32 bits. + + + [APP_NAME] ne peut pas s'exécuter, car il n'y pas de canal alpha 8 bits accessible. En général, ceci vient de problèmes avec le pilote de la carte vidéo. +Assurez-vous d'avoir installé le pilote de carte vidéo le plus récent possible. +Assurez-vous aussi que votre écran est réglé sur True Color (32 bits) sous Panneau de configuration > Affichage > Paramètres. +Si ce message persiste, veuillez aller sur la page [SUPPORT_SITE]. + + + Impossible de trouver le format pixel approprié + + + Impossible de créer le contexte de rendu GL + + + Impossible d'activer le contexte de rendu GL + + + [APP_NAME] ne peut pas s'exécuter car les pilotes de votre carte vidéo n'ont pas été installés correctement, ne sont pas à jour, ou sont pour du matériel non pris en charge. Assurez-vous d'avoir des pilotes de cartes vidéos récents, et même si vous avez les plus récents, réinstallez-les. + +Si ce message persiste, veuillez aller sur la page [SUPPORT_SITE]. + From c548aa34977bac7370810e3cc13fe2703d13cf18 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sat, 28 Jan 2012 22:11:51 -0600 Subject: [PATCH 03/36] Enable Hardware Skinning by default for med/high/ultra settings. --- indra/newview/app_settings/high_graphics.xml | 1 + indra/newview/app_settings/low_graphics.xml | 1 + indra/newview/app_settings/mid_graphics.xml | 1 + indra/newview/app_settings/ultra_graphics.xml | 1 + 4 files changed, 4 insertions(+) diff --git a/indra/newview/app_settings/high_graphics.xml b/indra/newview/app_settings/high_graphics.xml index 2e939f47e..d0f63fe7c 100644 --- a/indra/newview/app_settings/high_graphics.xml +++ b/indra/newview/app_settings/high_graphics.xml @@ -36,4 +36,5 @@ + diff --git a/indra/newview/app_settings/low_graphics.xml b/indra/newview/app_settings/low_graphics.xml index 79b25003f..9e9be14bb 100644 --- a/indra/newview/app_settings/low_graphics.xml +++ b/indra/newview/app_settings/low_graphics.xml @@ -36,4 +36,5 @@ + diff --git a/indra/newview/app_settings/mid_graphics.xml b/indra/newview/app_settings/mid_graphics.xml index 4660d0cd4..4c1ec5494 100644 --- a/indra/newview/app_settings/mid_graphics.xml +++ b/indra/newview/app_settings/mid_graphics.xml @@ -36,4 +36,5 @@ + diff --git a/indra/newview/app_settings/ultra_graphics.xml b/indra/newview/app_settings/ultra_graphics.xml index 78213ff87..6181cbdc0 100644 --- a/indra/newview/app_settings/ultra_graphics.xml +++ b/indra/newview/app_settings/ultra_graphics.xml @@ -36,4 +36,5 @@ + From 7ff58abc176be571198d45e22d171e71440e83f3 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sat, 28 Jan 2012 23:52:48 -0600 Subject: [PATCH 04/36] Too lazy to amend earlier commit. llpanelvolume.cpp needs lltrans.h --- indra/newview/llpanelvolume.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index 1a07d8a44..52f0a6e88 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -44,6 +44,7 @@ #include "llmaterialtable.h" #include "llpermissionsflags.h" #include "llstring.h" +#include "lltrans.h" #include "llvolume.h" #include "m3math.h" #include "material_codes.h" From ac1a6101e1ee83f46b5accb31fb22c6d0fc83d93 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 29 Jan 2012 01:16:34 -0600 Subject: [PATCH 05/36] Streaming audio ticker was getting stuck on (Loading...) --- indra/newview/shfloatermediaticker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/shfloatermediaticker.cpp b/indra/newview/shfloatermediaticker.cpp index 0b7eef36f..f3e1849af 100644 --- a/indra/newview/shfloatermediaticker.cpp +++ b/indra/newview/shfloatermediaticker.cpp @@ -101,7 +101,7 @@ void SHFloaterMediaTicker::updateTickerText() //called via draw. if(artist.isDefined() && title.isDefined()) mLoadTimer.stop(); else if(dirty) - mLoadTimer.reset(); + mLoadTimer.start(); else if(mLoadTimer.getStarted() && mLoadTimer.getElapsedTimeF64() > 10.f) //It has been 10 seconds.. give up. { if(!artist.isDefined()) From f5818b7621c770efe0f06b227941960293d815d7 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 29 Jan 2012 01:20:26 -0600 Subject: [PATCH 06/36] Pass FMOD_IGNORETAGS flag when creating FMOD Ex streams. Without the flag it is more prone to failing to successfully detect stream format info under certain circumstances. --- indra/llaudio/llstreamingaudio_fmodex.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/llaudio/llstreamingaudio_fmodex.cpp b/indra/llaudio/llstreamingaudio_fmodex.cpp index 1ad1b2eae..2b032e25b 100644 --- a/indra/llaudio/llstreamingaudio_fmodex.cpp +++ b/indra/llaudio/llstreamingaudio_fmodex.cpp @@ -372,7 +372,7 @@ LLAudioStreamManagerFMODEX::LLAudioStreamManagerFMODEX(FMOD::System *system, con exinfo.cbsize = sizeof(exinfo); exinfo.suggestedsoundtype = FMOD_SOUND_TYPE_MPEG; //Hint to speed up loading. - FMOD_RESULT result = mSystem->createStream(url.c_str(), FMOD_2D | FMOD_NONBLOCKING, &exinfo, &mInternetStream); + FMOD_RESULT result = mSystem->createStream(url.c_str(), FMOD_2D | FMOD_NONBLOCKING | FMOD_IGNORETAGS, &exinfo, &mInternetStream); if (result!= FMOD_OK) { From 6c921ba340187cf8568c8de75ec5e8aef6dc1707 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 29 Jan 2012 01:25:39 -0600 Subject: [PATCH 07/36] Routine V3 merge. --- indra/llcommon/llmemory.cpp | 1 + indra/llinventory/lleconomy.cpp | 63 +++++++++++++++++--------- indra/llinventory/lleconomy.h | 52 ++++++++++++--------- indra/llinventory/llsaleinfo.cpp | 2 +- indra/llmessage/llhttpassetstorage.cpp | 1 + indra/llmessage/llhttpclientadapter.h | 2 +- indra/llmessage/lliohttpserver.cpp | 40 ++++++++-------- indra/llmessage/lliosocket.cpp | 14 +++++- indra/llmessage/llpacketring.cpp | 45 ++++++++++++------ indra/llmessage/llpacketring.h | 4 +- indra/llmessage/llsdmessagereader.cpp | 3 +- indra/llmessage/message.cpp | 8 ++-- indra/llmessage/message.h | 13 +----- indra/newview/llviewerobject.h | 3 +- 14 files changed, 148 insertions(+), 103 deletions(-) diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index d284952d6..4939a44ce 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -162,6 +162,7 @@ void LLMemory::logMemoryInfo(BOOL update) if(update) { updateMemoryInfo() ; + LLPrivateMemoryPoolManager::getInstance()->updateStatistics() ; } llinfos << "Current allocated physical memory(KB): " << sAllocatedMemInKB << llendl ; diff --git a/indra/llinventory/lleconomy.cpp b/indra/llinventory/lleconomy.cpp index 4366d1eb2..d643ea6ed 100644 --- a/indra/llinventory/lleconomy.cpp +++ b/indra/llinventory/lleconomy.cpp @@ -1,31 +1,25 @@ /** * @file lleconomy.cpp * - * $LicenseInfo:firstyear=2002&license=viewergpl$ - * - * Copyright (c) 2002-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * 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$ */ @@ -54,6 +48,31 @@ LLGlobalEconomy::LLGlobalEconomy() LLGlobalEconomy::~LLGlobalEconomy() { } +void LLGlobalEconomy::addObserver(LLEconomyObserver* observer) +{ + mObservers.push_back(observer); +} + +void LLGlobalEconomy::removeObserver(LLEconomyObserver* observer) +{ + std::list::iterator it = + std::find(mObservers.begin(), mObservers.end(), observer); + if (it != mObservers.end()) + { + mObservers.erase(it); + } +} + +void LLGlobalEconomy::notifyObservers() +{ + for (std::list::iterator it = mObservers.begin(); + it != mObservers.end(); + ++it) + { + (*it)->onEconomyDataChange(); + } +} + // static void LLGlobalEconomy::processEconomyData(LLMessageSystem *msg, LLGlobalEconomy* econ_data) { @@ -94,6 +113,8 @@ void LLGlobalEconomy::processEconomyData(LLMessageSystem *msg, LLGlobalEconomy* econ_data->setTeleportPriceExponent(f); msg->getS32Fast(_PREHASH_Info, _PREHASH_PriceGroupCreate, i); econ_data->setPriceGroupCreate(i); + + econ_data->notifyObservers(); } S32 LLGlobalEconomy::calculateTeleportCost(F32 distance) const diff --git a/indra/llinventory/lleconomy.h b/indra/llinventory/lleconomy.h index e48008545..eb2ecf71b 100644 --- a/indra/llinventory/lleconomy.h +++ b/indra/llinventory/lleconomy.h @@ -1,31 +1,25 @@ /** * @file lleconomy.h * - * $LicenseInfo:firstyear=2002&license=viewergpl$ - * - * Copyright (c) 2002-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * 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$ */ @@ -37,6 +31,16 @@ class LLMessageSystem; class LLVector3; +/** + * Register an observer to be notified of economy data updates coming from server. + */ +class LLEconomyObserver +{ +public: + virtual ~LLEconomyObserver() {} + virtual void onEconomyDataChange() = 0; +}; + class LLGlobalEconomy { public: @@ -52,6 +56,10 @@ public: virtual void print(); + void addObserver(LLEconomyObserver* observer); + void removeObserver(LLEconomyObserver* observer); + void notifyObservers(); + static void processEconomyData(LLMessageSystem *msg, LLGlobalEconomy* econ_data); S32 calculateTeleportCost(F32 distance) const; @@ -95,6 +103,8 @@ private: S32 mTeleportMinPrice; F32 mTeleportPriceExponent; S32 mPriceGroupCreate; + + std::list mObservers; }; diff --git a/indra/llinventory/llsaleinfo.cpp b/indra/llinventory/llsaleinfo.cpp index e51e35e6e..b7afb28ad 100644 --- a/indra/llinventory/llsaleinfo.cpp +++ b/indra/llinventory/llsaleinfo.cpp @@ -30,8 +30,8 @@ * $/LicenseInfo$ */ -#include "linden_common.h" #include +#include "linden_common.h" #include "llsaleinfo.h" diff --git a/indra/llmessage/llhttpassetstorage.cpp b/indra/llmessage/llhttpassetstorage.cpp index 859842a15..66a6c00d1 100644 --- a/indra/llmessage/llhttpassetstorage.cpp +++ b/indra/llmessage/llhttpassetstorage.cpp @@ -128,6 +128,7 @@ LLHTTPAssetRequest::LLHTTPAssetRequest(LLHTTPAssetStorage *asp, : LLAssetRequest(uuid, type), mZInitialized(false) { + memset(&mZStream, 0, sizeof(mZStream)); // we'll initialize this later, but for now zero the whole C-style struct to avoid debug/coverity noise mAssetStoragep = asp; mCurlHandle = NULL; mCurlMultiHandle = curl_multi; diff --git a/indra/llmessage/llhttpclientadapter.h b/indra/llmessage/llhttpclientadapter.h index 7d61357a7..7f76390d0 100644 --- a/indra/llmessage/llhttpclientadapter.h +++ b/indra/llmessage/llhttpclientadapter.h @@ -34,7 +34,7 @@ #define LL_HTTPCLIENTADAPTER_H #include "llhttpclientinterface.h" -#include "llmemory.h" // LLSingleton<> +#include "llsingleton.h" // LLSingleton<> class LLHTTPClientAdapter : public LLHTTPClientInterface, public LLSingleton { diff --git a/indra/llmessage/lliohttpserver.cpp b/indra/llmessage/lliohttpserver.cpp index eb9fd80b8..aff3a7adf 100644 --- a/indra/llmessage/lliohttpserver.cpp +++ b/indra/llmessage/lliohttpserver.cpp @@ -4,31 +4,25 @@ * @date 2005-10-05 * @brief Implementation of the http server classes * - * $LicenseInfo:firstyear=2005&license=viewergpl$ - * - * Copyright (c) 2005-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * 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$ */ @@ -972,7 +966,9 @@ private: // static LLHTTPNode& LLIOHTTPServer::create(LLPumpIO& pump, U16 port) { - LLSocket::ptr_t socket = LLSocket::create(LLSocket::STREAM_TCP, port); + LLSocket::ptr_t socket = LLSocket::create( + LLSocket::STREAM_TCP, + port); if(!socket) { llerrs << "Unable to initialize socket" << llendl; diff --git a/indra/llmessage/lliosocket.cpp b/indra/llmessage/lliosocket.cpp index d80ca402c..2aa44b8fd 100644 --- a/indra/llmessage/lliosocket.cpp +++ b/indra/llmessage/lliosocket.cpp @@ -114,11 +114,21 @@ LLSocket::ptr_t LLSocket::create(EType type, U16 port) if(STREAM_TCP == type) { - status = apr_socket_create(&rv->mSocket, APR_INET, SOCK_STREAM, APR_PROTO_TCP, rv->mPool()); + status = apr_socket_create( + &rv->mSocket, + APR_INET, + SOCK_STREAM, + APR_PROTO_TCP, + rv->mPool()); } else if(DATAGRAM_UDP == type) { - status = apr_socket_create(&rv->mSocket, APR_INET, SOCK_DGRAM, APR_PROTO_UDP, rv->mPool()); + status = apr_socket_create( + &rv->mSocket, + APR_INET, + SOCK_DGRAM, + APR_PROTO_UDP, + rv->mPool()); } else { diff --git a/indra/llmessage/llpacketring.cpp b/indra/llmessage/llpacketring.cpp index 60359dfc5..abafaa511 100644 --- a/indra/llmessage/llpacketring.cpp +++ b/indra/llmessage/llpacketring.cpp @@ -239,15 +239,23 @@ S32 LLPacketRing::receivePacket (S32 socket, char *datap) // no delay, pull straight from net if (LLSocks::isEnabled()) { - proxywrap_t * header; - datap = datap-10; - header = (proxywrap_t *)datap; - packet_size = receive_packet(socket, datap); - mLastSender.setAddress(header->addr); - mLastSender.setPort(ntohs(header->port)); - if (packet_size > 10) + const U8 SOCKS_HEADER_SIZE = 10; + U8 buffer[NET_BUFFER_SIZE + SOCKS_HEADER_SIZE]; + packet_size = receive_packet(socket, static_cast(static_cast(buffer))); + + if (packet_size > SOCKS_HEADER_SIZE) { - packet_size -= 10; + // *FIX We are assuming ATYP is 0x01 (IPv4), not 0x03 (hostname) or 0x04 (IPv6) + memcpy(datap, buffer + SOCKS_HEADER_SIZE, packet_size - SOCKS_HEADER_SIZE); + proxywrap_t * header = static_cast(static_cast(buffer)); + mLastSender.setAddress(header->addr); + mLastSender.setPort(ntohs(header->port)); + + packet_size -= SOCKS_HEADER_SIZE; // The unwrapped packet size + } + else + { + packet_size = 0; } } else @@ -285,7 +293,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL if (!mUseOutThrottle) { - return doSendPacket(h_socket, send_buffer, buf_size, host ); + return sendPacketImpl(h_socket, send_buffer, buf_size, host ); } else { @@ -306,7 +314,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL mOutBufferLength -= packetp->getSize(); packet_size = packetp->getSize(); - status = doSendPacket(h_socket, packetp->getData(), packet_size, packetp->getHost()); + status = sendPacketImpl(h_socket, packetp->getData(), packet_size, packetp->getHost()); delete packetp; // Update the throttle @@ -315,7 +323,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL else { // If the queue's empty, we can just send this packet right away. - status = doSendPacket(h_socket, send_buffer, buf_size, host ); + status = sendPacketImpl(h_socket, send_buffer, buf_size, host ); packet_size = buf_size; // Update the throttle @@ -354,7 +362,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL return status; } -BOOL LLPacketRing::doSendPacket(int h_socket, const char * send_buffer, S32 buf_size, LLHost host) +BOOL LLPacketRing::sendPacketImpl(int h_socket, const char * send_buffer, S32 buf_size, LLHost host) { if (!LLSocks::isEnabled()) @@ -362,14 +370,21 @@ BOOL LLPacketRing::doSendPacket(int h_socket, const char * send_buffer, S32 buf_ return send_packet(h_socket, send_buffer, buf_size, host.getAddress(), host.getPort()); } - proxywrap_t *socks_header = (proxywrap_t *)&mProxyWrappedSendBuffer; + const U8 SOCKS_HEADER_SIZE = 10; + char headered_send_buffer[NET_BUFFER_SIZE + SOCKS_HEADER_SIZE]; + + proxywrap_t *socks_header = static_cast(static_cast(&headered_send_buffer)); socks_header->rsv = 0; socks_header->addr = host.getAddress(); socks_header->port = htons(host.getPort()); socks_header->atype = ADDRESS_IPV4; socks_header->frag = 0; - memcpy(mProxyWrappedSendBuffer+10, send_buffer, buf_size); + memcpy(headered_send_buffer + SOCKS_HEADER_SIZE, send_buffer, buf_size); - return send_packet(h_socket,(const char*) mProxyWrappedSendBuffer, buf_size+10, LLSocks::getInstance()->getUDPPproxy().getAddress(), LLSocks::getInstance()->getUDPPproxy().getPort()); + return send_packet( h_socket, + headered_send_buffer, + buf_size + SOCKS_HEADER_SIZE, + LLSocks::getInstance()->getUDPPproxy().getAddress(), + LLSocks::getInstance()->getUDPPproxy().getPort()); } diff --git a/indra/llmessage/llpacketring.h b/indra/llmessage/llpacketring.h index 355113e1a..c0f386d96 100644 --- a/indra/llmessage/llpacketring.h +++ b/indra/llmessage/llpacketring.h @@ -88,8 +88,8 @@ protected: LLHost mLastSender; LLHost mLastReceivingIF; - BOOL doSendPacket(int h_socket, const char * send_buffer, S32 buf_size, LLHost host); - U8 mProxyWrappedSendBuffer[NET_BUFFER_SIZE]; +private: + BOOL sendPacketImpl(int h_socket, const char * send_buffer, S32 buf_size, LLHost host); }; diff --git a/indra/llmessage/llsdmessagereader.cpp b/indra/llmessage/llsdmessagereader.cpp index 845a12d23..ffcf3dc3c 100644 --- a/indra/llmessage/llsdmessagereader.cpp +++ b/indra/llmessage/llsdmessagereader.cpp @@ -297,9 +297,10 @@ S32 getElementSize(const LLSD& llsd) case LLSD::TypeMap: case LLSD::TypeArray: case LLSD::TypeUndefined: + default: // TypeLLSDTypeEnd, TypeLLSDNumTypes, etc. return 0; } - return 0; + //return 0; } //virtual diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index b89b6ee2c..723fc6592 100644 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -556,11 +556,11 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count, bool faked_message, U8 fak S32 acks = 0; S32 true_rcv_size = 0; - U8* buffer = mTrueReceiveBuffer.buffer; + U8* buffer = mTrueReceiveBuffer; if(!faked_message) { - mTrueReceiveSize = mPacketRing.receivePacket(mSocket, (char *)mTrueReceiveBuffer.buffer); + mTrueReceiveSize = mPacketRing.receivePacket(mSocket, (char *)mTrueReceiveBuffer); receive_size = mTrueReceiveSize; mLastSender = mPacketRing.getLastSender(); mLastReceivingIF = mPacketRing.getLastReceivingInterface(); @@ -635,7 +635,7 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count, bool faked_message, U8 fak for(S32 i = 0; i < acks; ++i) { true_rcv_size -= sizeof(TPACKETID); - memcpy(&mem_id, &buffer[true_rcv_size], /* Flawfinder: ignore*/ + memcpy(&mem_id, &mTrueReceiveBuffer[true_rcv_size], /* Flawfinder: ignore*/ sizeof(TPACKETID)); packet_id = ntohl(mem_id); //LL_INFOS("Messaging") << "got ack: " << packet_id << llendl; @@ -3405,7 +3405,7 @@ void LLMessageSystem::dumpPacketToLog() { S32 offset = cur_line_pos * 3; snprintf(line_buffer + offset, sizeof(line_buffer) - offset, - "%02x ", mTrueReceiveBuffer.buffer[i]); /* Flawfinder: ignore */ + "%02x ", mTrueReceiveBuffer[i]); /* Flawfinder: ignore */ cur_line_pos++; if (cur_line_pos >= 16) { diff --git a/indra/llmessage/message.h b/indra/llmessage/message.h index 759dafca4..8fd428fd5 100644 --- a/indra/llmessage/message.h +++ b/indra/llmessage/message.h @@ -778,18 +778,7 @@ private: LLMessagePollInfo *mPollInfop; U8 mEncodedRecvBuffer[MAX_BUFFER_SIZE]; - -// Push current alignment to stack and set alignment to 1 byte boundary -#pragma pack(push,1) - - struct ReceiveBuffer_t - { - proxywrap_t header; - U8 buffer[MAX_BUFFER_SIZE]; - } mTrueReceiveBuffer; - -#pragma pack(pop) /* restore original alignment from stack */ - + U8 mTrueReceiveBuffer[MAX_BUFFER_SIZE]; S32 mTrueReceiveSize; // Must be valid during decode diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 857906949..d1ee94a3e 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -39,7 +39,7 @@ #include "llhudtext.h" #include "llhudicon.h" #include "llinventory.h" -#include "llmemory.h" +#include "llrefcount.h" #include "llmemtype.h" #include "llprimitive.h" #include "lluuid.h" @@ -49,6 +49,7 @@ #include "v3dmath.h" #include "v3math.h" #include "llvertexbuffer.h" +#include "llbbox.h" class LLAgent; // TODO: Get rid of this. class LLAudioSource; From 32c6365bf90209a3122b62c3f22ca03f07cacd44 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 29 Jan 2012 01:27:40 -0600 Subject: [PATCH 08/36] Octree tweakage. --- indra/llcommon/llmemory.cpp | 1 - indra/llmath/lloctree.h | 26 +++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index 4939a44ce..d284952d6 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -162,7 +162,6 @@ void LLMemory::logMemoryInfo(BOOL update) if(update) { updateMemoryInfo() ; - LLPrivateMemoryPoolManager::getInstance()->updateStatistics() ; } llinfos << "Current allocated physical memory(KB): " << sAllocatedMemInKB << llendl ; diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index c55c66dd8..017d48a0e 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -90,8 +90,8 @@ public: typedef LLOctreeTraveler oct_traveler; typedef LLTreeTraveler tree_traveler; typedef typename std::set > element_list; - typedef typename std::set >::iterator element_iter; - typedef typename std::set >::const_iterator const_element_iter; + typedef typename element_list::iterator element_iter; + typedef typename element_list::const_iterator const_element_iter; typedef typename std::vector*>::iterator tree_listener_iter; typedef typename std::vector* > child_list; typedef LLTreeNode BaseType; @@ -124,6 +124,8 @@ public: mOctant = ((oct_node*) mParent)->getOctant(mCenter); } + mElementCount = 0; + clearChildren(); } @@ -229,11 +231,11 @@ public: void accept(oct_traveler* visitor) { visitor->visit(this); } virtual bool isLeaf() const { return mChild.empty(); } - U32 getElementCount() const { return mData.size(); } + U32 getElementCount() const { return mElementCount; } element_list& getData() { return mData; } const element_list& getData() const { return mData; } - U32 getChildCount() const { return mChild.size(); } + U32 getChildCount() const { return mChildCount; } oct_node* getChild(U32 index) { return mChild[index]; } const oct_node* getChild(U32 index) const { return mChild[index]; } child_list& getChildren() { return mChild; } @@ -321,6 +323,8 @@ public: mData.insert(data); BaseType::insert(data); + + mElementCount = mData.size(); return true; } else @@ -356,6 +360,8 @@ public: { mData.insert(data); BaseType::insert(data); + + mElementCount = mData.size(); return true; } @@ -409,6 +415,7 @@ public: if (mData.find(data) != mData.end()) { //we have data mData.erase(data); + mElementCount = mData.size(); notifyRemoval(data); checkAlive(); return true; @@ -446,6 +453,7 @@ public: if (mData.find(data) != mData.end()) { mData.erase(data); + mElementCount = mData.size(); notifyRemoval(data); llwarns << "FOUND!" << llendl; checkAlive(); @@ -462,7 +470,7 @@ public: void clearChildren() { mChild.clear(); - + mChildCount = 0; U32* foo = (U32*) mChildMap; foo[0] = foo[1] = 0xFFFFFFFF; } @@ -522,9 +530,10 @@ public: } #endif - mChildMap[child->getOctant()] = (U8) mChild.size(); + mChildMap[child->getOctant()] = mChildCount; mChild.push_back(child); + ++mChildCount; child->setParent(this); if (!silent) @@ -553,12 +562,13 @@ public: delete mChild[index]; } mChild.erase(mChild.begin() + index); + --mChildCount; //rebuild child map U32* foo = (U32*) mChildMap; foo[0] = foo[1] = 0xFFFFFFFF; - for (U32 i = 0; i < mChild.size(); ++i) + for (U32 i = 0; i < mChildCount; ++i) { mChildMap[mChild[i]->getOctant()] = i; } @@ -611,8 +621,10 @@ protected: child_list mChild; U8 mChildMap[8]; + U32 mChildCount; element_list mData; + U32 mElementCount; }; From 9453c2c2e9e92f61efc9cf169d1e21a83d20c3c3 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 29 Jan 2012 01:33:14 -0600 Subject: [PATCH 09/36] Memory tracking system updated. --- indra/llcommon/CMakeLists.txt | 7 +- indra/llcommon/llallocator.cpp | 134 ++++++++ indra/llcommon/llallocator.h | 57 ++++ indra/llcommon/llallocator_heap_profile.cpp | 147 +++++++++ indra/llcommon/llallocator_heap_profile.h | 71 +++++ indra/llcommon/llfasttimer_class.h | 1 + indra/llcommon/llmemory.cpp | 336 +++++++++----------- indra/llcommon/llmemory.h | 1 + indra/llcommon/llmemtype.cpp | 232 ++++++++++++++ indra/llcommon/llmemtype.h | 306 +++++++++++------- indra/llimage/llimage.cpp | 12 +- indra/llimage/llimage.h | 4 +- indra/llimage/llimagej2c.cpp | 6 +- indra/llmessage/llcachename.cpp | 5 + indra/llmessage/lliosocket.cpp | 1 + indra/llmessage/message.cpp | 3 + indra/llrender/llgl.cpp | 2 + indra/llrender/llvertexbuffer.cpp | 35 +- indra/newview/app_settings/settings.xml | 11 + indra/newview/llappviewer.cpp | 10 +- indra/newview/llappviewer.h | 5 +- indra/newview/llmemoryview.cpp | 244 ++++++++------ indra/newview/llmemoryview.h | 13 +- indra/newview/llviewermenu.cpp | 4 +- indra/newview/pipeline.cpp | 87 ++--- 25 files changed, 1248 insertions(+), 486 deletions(-) create mode 100644 indra/llcommon/llallocator.cpp create mode 100644 indra/llcommon/llallocator.h create mode 100644 indra/llcommon/llallocator_heap_profile.cpp create mode 100644 indra/llcommon/llallocator_heap_profile.h create mode 100644 indra/llcommon/llmemtype.cpp diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index e939bb468..5450cc386 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -17,7 +17,9 @@ include_directories( set(llcommon_SOURCE_FILES aiframetimer.cpp imageids.cpp - indra_constants.cpp + indra_constants.cpp + llallocator.cpp + llallocator_heap_profile.cpp llapp.cpp llapr.cpp llaprpool.cpp @@ -52,6 +54,7 @@ set(llcommon_SOURCE_FILES llmd5.cpp llmemory.cpp llmemorystream.cpp + llmemtype.cpp llmetrics.cpp llmortician.cpp lloptioninterface.cpp @@ -101,6 +104,8 @@ set(llcommon_HEADER_FILES linden_common.h linked_lists.h llaccountingcost.h + llallocator.h + llallocator_heap_profile.h llagentconstants.h llavatarname.h llapp.h diff --git a/indra/llcommon/llallocator.cpp b/indra/llcommon/llallocator.cpp new file mode 100644 index 000000000..6f6abefc6 --- /dev/null +++ b/indra/llcommon/llallocator.cpp @@ -0,0 +1,134 @@ +/** + * @file llallocator.cpp + * @brief Implementation of the LLAllocator class. + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" +#include "llallocator.h" + +#if LL_USE_TCMALLOC + +#include "google/heap-profiler.h" +#include "google/commandlineflags_public.h" + +DECLARE_bool(heap_profile_use_stack_trace); +//DECLARE_double(tcmalloc_release_rate); + +// static +void LLAllocator::pushMemType(S32 type) +{ + if(isProfiling()) + { + PushMemType(type); + } +} + +// static +S32 LLAllocator::popMemType() +{ + if (isProfiling()) + { + return PopMemType(); + } + else + { + return -1; + } +} + +void LLAllocator::setProfilingEnabled(bool should_enable) +{ + // NULL disables dumping to disk + static char const * const PREFIX = NULL; + if(should_enable) + { + HeapProfilerSetUseStackTrace(false); + HeapProfilerStart(PREFIX); + } + else + { + HeapProfilerStop(); + } +} + +// static +bool LLAllocator::isProfiling() +{ + return IsHeapProfilerRunning(); +} + +std::string LLAllocator::getRawProfile() +{ + // *TODO - fix google-perftools to accept an buffer to avoid this + // malloc-copy-free cycle. + char * buffer = GetHeapProfile(); + std::string ret = buffer; + free(buffer); + return ret; +} + +#else // LL_USE_TCMALLOC + +// +// stub implementations for when tcmalloc is disabled +// + +// static +void LLAllocator::pushMemType(S32 type) +{ +} + +// static +S32 LLAllocator::popMemType() +{ + return -1; +} + +void LLAllocator::setProfilingEnabled(bool should_enable) +{ +} + +// static +bool LLAllocator::isProfiling() +{ + return false; +} + +std::string LLAllocator::getRawProfile() +{ + return std::string(); +} + +#endif // LL_USE_TCMALLOC + +LLAllocatorHeapProfile const & LLAllocator::getProfile() +{ + mProf.mLines.clear(); + + // *TODO - avoid making all these extra copies of things... + std::string prof_text = getRawProfile(); + //std::cout << prof_text << std::endl; + mProf.parse(prof_text); + return mProf; +} diff --git a/indra/llcommon/llallocator.h b/indra/llcommon/llallocator.h new file mode 100644 index 000000000..a91dd57d1 --- /dev/null +++ b/indra/llcommon/llallocator.h @@ -0,0 +1,57 @@ +/** + * @file llallocator.h + * @brief Declaration of the LLAllocator class. + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLALLOCATOR_H +#define LL_LLALLOCATOR_H + +#include + +#include "llmemtype.h" +#include "llallocator_heap_profile.h" + +class LL_COMMON_API LLAllocator { + friend class LLMemoryView; + friend class LLMemType; + +private: + static void pushMemType(S32 type); + static S32 popMemType(); + +public: + void setProfilingEnabled(bool should_enable); + + static bool isProfiling(); + + LLAllocatorHeapProfile const & getProfile(); + +private: + std::string getRawProfile(); + +private: + LLAllocatorHeapProfile mProf; +}; + +#endif // LL_LLALLOCATOR_H diff --git a/indra/llcommon/llallocator_heap_profile.cpp b/indra/llcommon/llallocator_heap_profile.cpp new file mode 100644 index 000000000..b574ef668 --- /dev/null +++ b/indra/llcommon/llallocator_heap_profile.cpp @@ -0,0 +1,147 @@ +/** + * @file llallocator_heap_profile.cpp + * @brief Implementation of the parser for tcmalloc heap profile data. + * @author Brad Kittenbrink + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" +#include "llallocator_heap_profile.h" + +#if LL_MSVC +// disable warning about boost::lexical_cast returning uninitialized data +// when it fails to parse the string +#pragma warning (disable:4701) +#pragma warning (disable:4702) +#endif + +#include +#include +#include +#include + +static const std::string HEAP_PROFILE_MAGIC_STR = "heap profile:"; + +static bool is_separator(char c) +{ + return isspace(c) || c == '[' || c == ']' || c == ':'; +} + +void LLAllocatorHeapProfile::parse(std::string const & prof_text) +{ + // a typedef for handling a token in the string buffer + // it's a begin/end pair of string::const_iterators + typedef boost::iterator_range range_t; + + mLines.clear(); + + if(prof_text.compare(0, HEAP_PROFILE_MAGIC_STR.length(), HEAP_PROFILE_MAGIC_STR) != 0) + { + // *TODO - determine if there should be some better error state than + // mLines being empty. -brad + llwarns << "invalid heap profile data passed into parser." << llendl; + return; + } + + std::vector< range_t > prof_lines; + + std::string::const_iterator prof_begin = prof_text.begin() + HEAP_PROFILE_MAGIC_STR.length(); + + range_t prof_range(prof_begin, prof_text.end()); + boost::algorithm::split(prof_lines, + prof_range, + boost::bind(std::equal_to(), '\n', _1)); + + std::vector< range_t >::const_iterator i; + for(i = prof_lines.begin(); i != prof_lines.end() && !i->empty(); ++i) + { + range_t const & line_text = *i; + + std::vector line_elems; + + boost::algorithm::split(line_elems, + line_text, + is_separator); + + std::vector< range_t >::iterator j; + j = line_elems.begin(); + + while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens + llassert_always(j != line_elems.end()); + U32 live_count = boost::lexical_cast(*j); + ++j; + + while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens + llassert_always(j != line_elems.end()); + U64 live_size = boost::lexical_cast(*j); + ++j; + + while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens + llassert_always(j != line_elems.end()); + U32 tot_count = boost::lexical_cast(*j); + ++j; + + while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens + llassert_always(j != line_elems.end()); + U64 tot_size = boost::lexical_cast(*j); + ++j; + + while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens + llassert(j != line_elems.end()); + if (j != line_elems.end()) + { + ++j; // skip the '@' + + mLines.push_back(line(live_count, live_size, tot_count, tot_size)); + line & current_line = mLines.back(); + + for(; j != line_elems.end(); ++j) + { + if(!j->empty()) + { + U32 marker = boost::lexical_cast(*j); + current_line.mTrace.push_back(marker); + } + } + } + } + // *TODO - parse MAPPED_LIBRARIES section here if we're ever interested in it +} + +void LLAllocatorHeapProfile::dump(std::ostream & out) const +{ + lines_t::const_iterator i; + for(i = mLines.begin(); i != mLines.end(); ++i) + { + out << i->mLiveCount << ": " << i->mLiveSize << '[' << i->mTotalCount << ": " << i->mTotalSize << "] @"; + + stack_trace::const_iterator j; + for(j = i->mTrace.begin(); j != i->mTrace.end(); ++j) + { + out << ' ' << *j; + } + out << '\n'; + } + out.flush(); +} + diff --git a/indra/llcommon/llallocator_heap_profile.h b/indra/llcommon/llallocator_heap_profile.h new file mode 100644 index 000000000..69300b829 --- /dev/null +++ b/indra/llcommon/llallocator_heap_profile.h @@ -0,0 +1,71 @@ +/** + * @file llallocator_heap_profile.h + * @brief Declaration of the parser for tcmalloc heap profile data. + * @author Brad Kittenbrink + * + * $LicenseInfo:firstyear=2009&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLALLOCATOR_HEAP_PROFILE_H +#define LL_LLALLOCATOR_HEAP_PROFILE_H + +#include "stdtypes.h" + +#include +#include + +class LLAllocatorHeapProfile +{ +public: + typedef int stack_marker; + + typedef std::vector stack_trace; + + struct line { + line(U32 live_count, U64 live_size, U32 tot_count, U64 tot_size) : + mLiveSize(live_size), + mTotalSize(tot_size), + mLiveCount(live_count), + mTotalCount(tot_count) + { + } + U64 mLiveSize, mTotalSize; + U32 mLiveCount, mTotalCount; + stack_trace mTrace; + }; + + typedef std::vector lines_t; + + LLAllocatorHeapProfile() + { + } + + void parse(std::string const & prof_text); + + void dump(std::ostream & out) const; + +public: + lines_t mLines; +}; + + +#endif // LL_LLALLOCATOR_HEAP_PROFILE_H diff --git a/indra/llcommon/llfasttimer_class.h b/indra/llcommon/llfasttimer_class.h index 536de6c0d..27db83c28 100644 --- a/indra/llcommon/llfasttimer_class.h +++ b/indra/llcommon/llfasttimer_class.h @@ -248,6 +248,7 @@ public: struct CurTimerData { + CurTimerData() : mCurTimer(NULL),mFrameState(NULL),mChildTime(0) {} LLFastTimer* mCurTimer; FrameState* mFrameState; U32 mChildTime; diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index d284952d6..446946ac4 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -32,9 +32,13 @@ #include "linden_common.h" + +//#if MEM_TRACK_MEM +#include "llthread.h" +//#endif + #if defined(LL_WINDOWS) -#define _WINSOCKAPI_ -# include +//# include # include #elif defined(LL_DARWIN) # include @@ -45,10 +49,9 @@ #endif #include "llmemory.h" -#include "llmemtype.h" -#include "llsys.h" -#include "llthread.h" +#include "llsys.h" +#include "llframetimer.h" //---------------------------------------------------------------------------- //static @@ -162,6 +165,7 @@ void LLMemory::logMemoryInfo(BOOL update) if(update) { updateMemoryInfo() ; + LLPrivateMemoryPoolManager::getInstance()->updateStatistics() ; } llinfos << "Current allocated physical memory(KB): " << sAllocatedMemInKB << llendl ; @@ -242,161 +246,6 @@ U32 LLMemory::getAllocatedMemKB() return sAllocatedMemInKB ; } -//---------------------------------------------------------------------------- - -//static -#if MEM_TRACK_TYPE -S32 LLMemType::sCurDepth = 0; -S32 LLMemType::sCurType = LLMemType::MTYPE_INIT; -S32 LLMemType::sType[LLMemType::MTYPE_MAX_DEPTH]; -S32 LLMemType::sMemCount[LLMemType::MTYPE_NUM_TYPES] = { 0 }; -S32 LLMemType::sMaxMemCount[LLMemType::MTYPE_NUM_TYPES] = { 0 }; -S32 LLMemType::sNewCount[LLMemType::MTYPE_NUM_TYPES] = { 0 }; -S32 LLMemType::sOverheadMem = 0; - -const char* LLMemType::sTypeDesc[LLMemType::MTYPE_NUM_TYPES] = -{ - "INIT", - "STARTUP", - "MAIN", - - "IMAGEBASE", - "IMAGERAW", - "IMAGEFORMATTED", - - "APPFMTIMAGE", - "APPRAWIMAGE", - "APPAUXRAWIMAGE", - - "DRAWABLE", - "OBJECT", - "PIPELINE", - "AVATAR", - "PARTICLES", - "REGIONS", - "INVENTORY", - "ANIMATION", - "NETWORK", - "PHYSICS", - "INTERESTLIST", - - "SCRIPT", - "SCRIPT_RUN", - "SCRIPT_BYTECODE", - - "IO_PUMP", - "IO_TCP", - "IO_BUFFER", - "IO_HTTP_SERVER" - "IO_SD_SERVER", - "IO_SD_CLIENT", - "IO_URL_REQUEST", - - "TEMP1", - "TEMP2", - "TEMP3", - "TEMP4", - "TEMP5", - "TEMP6", - "TEMP7", - "TEMP8", - "TEMP9" -}; - -#endif -S32 LLMemType::sTotalMem = 0; -S32 LLMemType::sMaxTotalMem = 0; - -//static -void LLMemType::printMem() -{ - S32 misc_mem = sTotalMem; -#if MEM_TRACK_TYPE - for (S32 i=0; i>20,sMaxMemCount[i]>>20, sNewCount[i]) << llendl; - } - misc_mem -= sMemCount[i]; - } -#endif - llinfos << llformat("MEM: % 20s %03d MB","MISC",misc_mem>>20) << llendl; - llinfos << llformat("MEM: % 20s %03d MB (Max=%d MB)","TOTAL",sTotalMem>>20,sMaxTotalMem>>20) << llendl; -} - -#if MEM_TRACK_MEM - -void* ll_allocate (size_t size) -{ - if (size == 0) - { - llwarns << "Null allocation" << llendl; - } - - size = (size+3)&~3; - S32 alloc_size = size + 4; -#if MEM_TRACK_TYPE - alloc_size += 4; -#endif - char* p = (char*)malloc(alloc_size); - if (p == NULL) - { - LLMemory::freeReserve(); - llerrs << "Out of memory Error" << llendl; - } - LLMemType::sTotalMem += size; - LLMemType::sMaxTotalMem = llmax(LLMemType::sTotalMem, LLMemType::sMaxTotalMem); - LLMemType::sOverheadMem += 4; - *(size_t*)p = size; - p += 4; -#if MEM_TRACK_TYPE - if (LLMemType::sCurType < 0 || LLMemType::sCurType >= LLMemType::MTYPE_NUM_TYPES) - { - llerrs << "Memory Type Error: new" << llendl; - } - LLMemType::sOverheadMem += 4; - *(S32*)p = LLMemType::sCurType; - p += 4; - LLMemType::sMemCount[LLMemType::sCurType] += size; - if (LLMemType::sMemCount[LLMemType::sCurType] > LLMemType::sMaxMemCount[LLMemType::sCurType]) - { - LLMemType::sMaxMemCount[LLMemType::sCurType] = LLMemType::sMemCount[LLMemType::sCurType]; - } - LLMemType::sNewCount[LLMemType::sCurType]++; -#endif - return (void*)p; -} - -void ll_release (void *pin) -{ - if (!pin) - { - return; - } - char* p = (char*)pin; -#if MEM_TRACK_TYPE - p -= 4; - S32 type = *(S32*)p; - if (type < 0 || type >= LLMemType::MTYPE_NUM_TYPES) - { - llerrs << "Memory Type Error: delete" << llendl; - } -#endif - p -= 4; - S32 size = *(size_t*)p; - LLMemType::sOverheadMem -= 4; -#if MEM_TRACK_TYPE - LLMemType::sMemCount[type] -= size; - LLMemType::sOverheadMem -= 4; - LLMemType::sNewCount[type]--; -#endif - LLMemType::sTotalMem -= size; - free(p); -} - -#else - void* ll_allocate (size_t size) { if (size == 0) @@ -412,38 +261,6 @@ void* ll_allocate (size_t size) return p; } -void ll_release (void *p) -{ - free(p); -} - -#endif - -#if MEM_TRACK_MEM - -void* operator new (size_t size) -{ - return ll_allocate(size); -} - -void* operator new[] (size_t size) -{ - return ll_allocate(size); -} - -void operator delete (void *p) -{ - ll_release(p); -} - -void operator delete[] (void *p) -{ - ll_release(p); -} - -#endif - - //---------------------------------------------------------------------------- #if defined(LL_WINDOWS) @@ -613,6 +430,141 @@ U32 LLMemory::getWorkingSetSize() #endif +//-------------------------------------------------------------------------------------------------- +#if MEM_TRACK_MEM +#include "llframetimer.h" + +//static +LLMemTracker* LLMemTracker::sInstance = NULL ; + +LLMemTracker::LLMemTracker() +{ + mLastAllocatedMem = LLMemory::getWorkingSetSize() ; + mCapacity = 128 ; + mCurIndex = 0 ; + mCounter = 0 ; + mDrawnIndex = 0 ; + mPaused = FALSE ; + + mMutexp = new LLMutex() ; + mStringBuffer = new char*[128] ; + mStringBuffer[0] = new char[mCapacity * 128] ; + for(S32 i = 1 ; i < mCapacity ; i++) + { + mStringBuffer[i] = mStringBuffer[i-1] + 128 ; + } +} + +LLMemTracker::~LLMemTracker() +{ + delete[] mStringBuffer[0] ; + delete[] mStringBuffer; + delete mMutexp ; +} + +//static +LLMemTracker* LLMemTracker::getInstance() +{ + if(!sInstance) + { + sInstance = new LLMemTracker() ; + } + return sInstance ; +} + +//static +void LLMemTracker::release() +{ + if(sInstance) + { + delete sInstance ; + sInstance = NULL ; + } +} + +//static +void LLMemTracker::track(const char* function, const int line) +{ + static const S32 MIN_ALLOCATION = 0 ; //1KB + + if(mPaused) + { + return ; + } + + U32 allocated_mem = LLMemory::getWorkingSetSize() ; + + LLMutexLock lock(mMutexp) ; + + S32 delta_mem = allocated_mem - mLastAllocatedMem ; + mLastAllocatedMem = allocated_mem ; + + if(delta_mem <= 0) + { + return ; //occupied memory does not grow + } + + if(delta_mem < MIN_ALLOCATION) + { + return ; + } + + char* buffer = mStringBuffer[mCurIndex++] ; + F32 time = (F32)LLFrameTimer::getElapsedSeconds() ; + S32 hours = (S32)(time / (60*60)); + S32 mins = (S32)((time - hours*(60*60)) / 60); + S32 secs = (S32)((time - hours*(60*60) - mins*60)); + strcpy(buffer, function) ; + sprintf(buffer + strlen(function), " line: %d DeltaMem: %d (bytes) Time: %d:%02d:%02d", line, delta_mem, hours,mins,secs) ; + + if(mCounter < mCapacity) + { + mCounter++ ; + } + if(mCurIndex >= mCapacity) + { + mCurIndex = 0 ; + } +} + + +//static +void LLMemTracker::preDraw(BOOL pause) +{ + mMutexp->lock() ; + + mPaused = pause ; + mDrawnIndex = mCurIndex - 1; + mNumOfDrawn = 0 ; +} + +//static +void LLMemTracker::postDraw() +{ + mMutexp->unlock() ; +} + +//static +const char* LLMemTracker::getNextLine() +{ + if(mNumOfDrawn >= mCounter) + { + return NULL ; + } + mNumOfDrawn++; + + if(mDrawnIndex < 0) + { + mDrawnIndex = mCapacity - 1 ; + } + + return mStringBuffer[mDrawnIndex--] ; +} + +#endif //MEM_TRACK_MEM +//-------------------------------------------------------------------------------------------------- + + //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- //minimum slot size and minimal slot size interval diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index c138fa0ef..d01b43917 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -40,6 +40,7 @@ #endif #include "llerror.h" +#include "llmemtype.h" #if LL_DEBUG inline void* ll_aligned_malloc( size_t size, int align ) { diff --git a/indra/llcommon/llmemtype.cpp b/indra/llcommon/llmemtype.cpp new file mode 100644 index 000000000..6290a7158 --- /dev/null +++ b/indra/llcommon/llmemtype.cpp @@ -0,0 +1,232 @@ +/** + * @file llmemtype.cpp + * @brief Simple memory allocation/deallocation tracking stuff here + * + * $LicenseInfo:firstyear=2002&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llmemtype.h" +#include "llallocator.h" + +std::vector LLMemType::DeclareMemType::mNameList; + +LLMemType::DeclareMemType LLMemType::MTYPE_INIT("Init"); +LLMemType::DeclareMemType LLMemType::MTYPE_STARTUP("Startup"); +LLMemType::DeclareMemType LLMemType::MTYPE_MAIN("Main"); +LLMemType::DeclareMemType LLMemType::MTYPE_FRAME("Frame"); + +LLMemType::DeclareMemType LLMemType::MTYPE_GATHER_INPUT("GatherInput"); +LLMemType::DeclareMemType LLMemType::MTYPE_JOY_KEY("JoyKey"); + +LLMemType::DeclareMemType LLMemType::MTYPE_IDLE("Idle"); +LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_PUMP("IdlePump"); +LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_NETWORK("IdleNetwork"); +LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_REGIONS("IdleUpdateRegions"); +LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_VIEWER_REGION("IdleUpdateViewerRegion"); +LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_SURFACE("IdleUpdateSurface"); +LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_UPDATE_PARCEL_OVERLAY("IdleUpdateParcelOverlay"); +LLMemType::DeclareMemType LLMemType::MTYPE_IDLE_AUDIO("IdleAudio"); + +LLMemType::DeclareMemType LLMemType::MTYPE_CACHE_PROCESS_PENDING("CacheProcessPending"); +LLMemType::DeclareMemType LLMemType::MTYPE_CACHE_PROCESS_PENDING_ASKS("CacheProcessPendingAsks"); +LLMemType::DeclareMemType LLMemType::MTYPE_CACHE_PROCESS_PENDING_REPLIES("CacheProcessPendingReplies"); + +LLMemType::DeclareMemType LLMemType::MTYPE_MESSAGE_CHECK_ALL("MessageCheckAll"); +LLMemType::DeclareMemType LLMemType::MTYPE_MESSAGE_PROCESS_ACKS("MessageProcessAcks"); + +LLMemType::DeclareMemType LLMemType::MTYPE_RENDER("Render"); +LLMemType::DeclareMemType LLMemType::MTYPE_SLEEP("Sleep"); + +LLMemType::DeclareMemType LLMemType::MTYPE_NETWORK("Network"); +LLMemType::DeclareMemType LLMemType::MTYPE_PHYSICS("Physics"); +LLMemType::DeclareMemType LLMemType::MTYPE_INTERESTLIST("InterestList"); + +LLMemType::DeclareMemType LLMemType::MTYPE_IMAGEBASE("ImageBase"); +LLMemType::DeclareMemType LLMemType::MTYPE_IMAGERAW("ImageRaw"); +LLMemType::DeclareMemType LLMemType::MTYPE_IMAGEFORMATTED("ImageFormatted"); + +LLMemType::DeclareMemType LLMemType::MTYPE_APPFMTIMAGE("AppFmtImage"); +LLMemType::DeclareMemType LLMemType::MTYPE_APPRAWIMAGE("AppRawImage"); +LLMemType::DeclareMemType LLMemType::MTYPE_APPAUXRAWIMAGE("AppAuxRawImage"); + +LLMemType::DeclareMemType LLMemType::MTYPE_DRAWABLE("Drawable"); + +LLMemType::DeclareMemType LLMemType::MTYPE_OBJECT("Object"); +LLMemType::DeclareMemType LLMemType::MTYPE_OBJECT_PROCESS_UPDATE("ObjectProcessUpdate"); +LLMemType::DeclareMemType LLMemType::MTYPE_OBJECT_PROCESS_UPDATE_CORE("ObjectProcessUpdateCore"); + +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY("Display"); +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE("DisplayUpdate"); +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE_CAMERA("DisplayUpdateCam"); +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE_GEOM("DisplayUpdateGeom"); +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_SWAP("DisplaySwap"); +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_UPDATE_HUD("DisplayUpdateHud"); +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_GEN_REFLECTION("DisplayGenRefl"); +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_IMAGE_UPDATE("DisplayImageUpdate"); +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_STATE_SORT("DisplayStateSort"); +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_SKY("DisplaySky"); +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_GEOM("DisplayRenderGeom"); +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_FLUSH("DisplayRenderFlush"); +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_UI("DisplayRenderUI"); +LLMemType::DeclareMemType LLMemType::MTYPE_DISPLAY_RENDER_ATTACHMENTS("DisplayRenderAttach"); + +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DATA("VertexData"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CONSTRUCTOR("VertexConstr"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DESTRUCTOR("VertexDestr"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CREATE_VERTICES("VertexCreateVerts"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CREATE_INDICES("VertexCreateIndices"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DESTROY_BUFFER("VertexDestroyBuff"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_DESTROY_INDICES("VertexDestroyIndices"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_UPDATE_VERTS("VertexUpdateVerts"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_UPDATE_INDICES("VertexUpdateIndices"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_ALLOCATE_BUFFER("VertexAllocateBuffer"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_RESIZE_BUFFER("VertexResizeBuffer"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_MAP_BUFFER("VertexMapBuffer"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_MAP_BUFFER_VERTICES("VertexMapBufferVerts"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES("VertexMapBufferIndices"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_UNMAP_BUFFER("VertexUnmapBuffer"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_SET_STRIDE("VertexSetStride"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_SET_BUFFER("VertexSetBuffer"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_SETUP_VERTEX_BUFFER("VertexSetupVertBuff"); +LLMemType::DeclareMemType LLMemType::MTYPE_VERTEX_CLEANUP_CLASS("VertexCleanupClass"); + +LLMemType::DeclareMemType LLMemType::MTYPE_SPACE_PARTITION("SpacePartition"); + +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE("Pipeline"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_INIT("PipelineInit"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_CREATE_BUFFERS("PipelineCreateBuffs"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RESTORE_GL("PipelineRestroGL"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UNLOAD_SHADERS("PipelineUnloadShaders"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_LIGHTING_DETAIL("PipelineLightingDetail"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_GET_POOL_TYPE("PipelineGetPoolType"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_ADD_POOL("PipelineAddPool"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_ALLOCATE_DRAWABLE("PipelineAllocDrawable"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_ADD_OBJECT("PipelineAddObj"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_CREATE_OBJECTS("PipelineCreateObjs"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UPDATE_MOVE("PipelineUpdateMove"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UPDATE_GEOM("PipelineUpdateGeom"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_VISIBLE("PipelineMarkVisible"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_MOVED("PipelineMarkMoved"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_SHIFT("PipelineMarkShift"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_SHIFT_OBJECTS("PipelineShiftObjs"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_TEXTURED("PipelineMarkTextured"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_MARK_REBUILD("PipelineMarkRebuild"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_UPDATE_CULL("PipelineUpdateCull"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_STATE_SORT("PipelineStateSort"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_POST_SORT("PipelinePostSort"); + +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_HUD_ELS("PipelineHudEls"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_HL("PipelineRenderHL"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM("PipelineRenderGeom"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM_DEFFERRED("PipelineRenderGeomDef"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM_POST_DEF("PipelineRenderGeomPostDef"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_GEOM_SHADOW("PipelineRenderGeomShadow"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_SELECT("PipelineRenderSelect"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_REBUILD_POOLS("PipelineRebuildPools"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_QUICK_LOOKUP("PipelineQuickLookup"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_OBJECTS("PipelineRenderObjs"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_GENERATE_IMPOSTOR("PipelineGenImpostors"); +LLMemType::DeclareMemType LLMemType::MTYPE_PIPELINE_RENDER_BLOOM("PipelineRenderBloom"); + +LLMemType::DeclareMemType LLMemType::MTYPE_UPKEEP_POOLS("UpkeepPools"); + +LLMemType::DeclareMemType LLMemType::MTYPE_AVATAR("Avatar"); +LLMemType::DeclareMemType LLMemType::MTYPE_AVATAR_MESH("AvatarMesh"); +LLMemType::DeclareMemType LLMemType::MTYPE_PARTICLES("Particles"); +LLMemType::DeclareMemType LLMemType::MTYPE_REGIONS("Regions"); + +LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY("Inventory"); +LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_DRAW("InventoryDraw"); +LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_BUILD_NEW_VIEWS("InventoryBuildNewViews"); +LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_DO_FOLDER("InventoryDoFolder"); +LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_POST_BUILD("InventoryPostBuild"); +LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_FROM_XML("InventoryFromXML"); +LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_CREATE_NEW_ITEM("InventoryCreateNewItem"); +LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_VIEW_INIT("InventoryViewInit"); +LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_VIEW_SHOW("InventoryViewShow"); +LLMemType::DeclareMemType LLMemType::MTYPE_INVENTORY_VIEW_TOGGLE("InventoryViewToggle"); + +LLMemType::DeclareMemType LLMemType::MTYPE_ANIMATION("Animation"); +LLMemType::DeclareMemType LLMemType::MTYPE_VOLUME("Volume"); +LLMemType::DeclareMemType LLMemType::MTYPE_PRIMITIVE("Primitive"); + +LLMemType::DeclareMemType LLMemType::MTYPE_SCRIPT("Script"); +LLMemType::DeclareMemType LLMemType::MTYPE_SCRIPT_RUN("ScriptRun"); +LLMemType::DeclareMemType LLMemType::MTYPE_SCRIPT_BYTECODE("ScriptByteCode"); + +LLMemType::DeclareMemType LLMemType::MTYPE_IO_PUMP("IoPump"); +LLMemType::DeclareMemType LLMemType::MTYPE_IO_TCP("IoTCP"); +LLMemType::DeclareMemType LLMemType::MTYPE_IO_BUFFER("IoBuffer"); +LLMemType::DeclareMemType LLMemType::MTYPE_IO_HTTP_SERVER("IoHttpServer"); +LLMemType::DeclareMemType LLMemType::MTYPE_IO_SD_SERVER("IoSDServer"); +LLMemType::DeclareMemType LLMemType::MTYPE_IO_SD_CLIENT("IoSDClient"); +LLMemType::DeclareMemType LLMemType::MTYPE_IO_URL_REQUEST("IOUrlRequest"); + +LLMemType::DeclareMemType LLMemType::MTYPE_DIRECTX_INIT("DirectXInit"); + +LLMemType::DeclareMemType LLMemType::MTYPE_TEMP1("Temp1"); +LLMemType::DeclareMemType LLMemType::MTYPE_TEMP2("Temp2"); +LLMemType::DeclareMemType LLMemType::MTYPE_TEMP3("Temp3"); +LLMemType::DeclareMemType LLMemType::MTYPE_TEMP4("Temp4"); +LLMemType::DeclareMemType LLMemType::MTYPE_TEMP5("Temp5"); +LLMemType::DeclareMemType LLMemType::MTYPE_TEMP6("Temp6"); +LLMemType::DeclareMemType LLMemType::MTYPE_TEMP7("Temp7"); +LLMemType::DeclareMemType LLMemType::MTYPE_TEMP8("Temp8"); +LLMemType::DeclareMemType LLMemType::MTYPE_TEMP9("Temp9"); + +LLMemType::DeclareMemType LLMemType::MTYPE_OTHER("Other"); + + +LLMemType::DeclareMemType::DeclareMemType(char const * st) +{ + mID = (S32)mNameList.size(); + mName = st; + + mNameList.push_back(mName); +} + +LLMemType::DeclareMemType::~DeclareMemType() +{ +} + +LLMemType::LLMemType(LLMemType::DeclareMemType& dt) +{ + mTypeIndex = dt.mID; + LLAllocator::pushMemType(dt.mID); +} + +LLMemType::~LLMemType() +{ + LLAllocator::popMemType(); +} + +char const * LLMemType::getNameFromID(S32 id) +{ + if (id < 0 || id >= (S32)DeclareMemType::mNameList.size()) + { + return "INVALID"; + } + + return DeclareMemType::mNameList[id]; +} + +//-------------------------------------------------------------------------------------------------- diff --git a/indra/llcommon/llmemtype.h b/indra/llcommon/llmemtype.h index d4cc67ea4..677fad303 100644 --- a/indra/llcommon/llmemtype.h +++ b/indra/llcommon/llmemtype.h @@ -36,128 +36,210 @@ //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- -class LLMemType; - -extern void* ll_allocate (size_t size); -extern void ll_release (void *p); - -#define MEM_TRACK_MEM 0 -#define MEM_TRACK_TYPE (1 && MEM_TRACK_MEM) - -#if MEM_TRACK_TYPE -#define MEM_DUMP_DATA 1 -#define MEM_TYPE_NEW(T) \ -static void* operator new(size_t s) { LLMemType mt(T); return ll_allocate(s); } \ -static void operator delete(void* p) { ll_release(p); } - -#else -#define MEM_TYPE_NEW(T) -#endif // MEM_TRACK_TYPE - - //---------------------------------------------------------------------------- +#include "linden_common.h" +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +// WARNING: Never commit with MEM_TRACK_MEM == 1 +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +#define MEM_TRACK_MEM (0 && LL_WINDOWS) + +#include + +#define MEM_TYPE_NEW(T) + class LL_COMMON_API LLMemType { public: - // Also update sTypeDesc in llmemory.cpp - enum EMemType + + // class we'll initialize all instances of as + // static members of MemType. Then use + // to construct any new mem type. + class LL_COMMON_API DeclareMemType { - MTYPE_INIT, - MTYPE_STARTUP, - MTYPE_MAIN, - - MTYPE_IMAGEBASE, - MTYPE_IMAGERAW, - MTYPE_IMAGEFORMATTED, + public: + DeclareMemType(char const * st); + ~DeclareMemType(); + + S32 mID; + char const * mName; - MTYPE_APPFMTIMAGE, - MTYPE_APPRAWIMAGE, - MTYPE_APPAUXRAWIMAGE, - - MTYPE_DRAWABLE, - MTYPE_OBJECT, - MTYPE_VERTEX_DATA, - MTYPE_SPACE_PARTITION, - MTYPE_PIPELINE, - MTYPE_AVATAR, - MTYPE_AVATAR_MESH, - MTYPE_PARTICLES, - MTYPE_REGIONS, - MTYPE_INVENTORY, - MTYPE_ANIMATION, - MTYPE_VOLUME, - MTYPE_PRIMITIVE, - - MTYPE_NETWORK, - MTYPE_PHYSICS, - MTYPE_INTERESTLIST, - - MTYPE_SCRIPT, - MTYPE_SCRIPT_RUN, - MTYPE_SCRIPT_BYTECODE, - - MTYPE_IO_PUMP, - MTYPE_IO_TCP, - MTYPE_IO_BUFFER, - MTYPE_IO_HTTP_SERVER, - MTYPE_IO_SD_SERVER, - MTYPE_IO_SD_CLIENT, - MTYPE_IO_URL_REQUEST, - - MTYPE_TEMP1, - MTYPE_TEMP2, - MTYPE_TEMP3, - MTYPE_TEMP4, - MTYPE_TEMP5, - MTYPE_TEMP6, - MTYPE_TEMP7, - MTYPE_TEMP8, - MTYPE_TEMP9, - - MTYPE_OTHER, // Special, used by display code - - MTYPE_NUM_TYPES + // array so we can map an index ID to Name + static std::vector mNameList; }; - enum { MTYPE_MAX_DEPTH = 64 }; - -public: - LLMemType(EMemType type) - { -#if MEM_TRACK_TYPE - if (type < 0 || type >= MTYPE_NUM_TYPES) - llerrs << "LLMemType error" << llendl; - if (sCurDepth < 0 || sCurDepth >= MTYPE_MAX_DEPTH) - llerrs << "LLMemType error" << llendl; - sType[sCurDepth] = sCurType; - sCurDepth++; - sCurType = type; -#endif - } - ~LLMemType() - { -#if MEM_TRACK_TYPE - sCurDepth--; - sCurType = sType[sCurDepth]; -#endif - } - static void reset(); - static void printMem(); + LLMemType(DeclareMemType& dt); + ~LLMemType(); + + static char const * getNameFromID(S32 id); + + static DeclareMemType MTYPE_INIT; + static DeclareMemType MTYPE_STARTUP; + static DeclareMemType MTYPE_MAIN; + static DeclareMemType MTYPE_FRAME; + + static DeclareMemType MTYPE_GATHER_INPUT; + static DeclareMemType MTYPE_JOY_KEY; + + static DeclareMemType MTYPE_IDLE; + static DeclareMemType MTYPE_IDLE_PUMP; + static DeclareMemType MTYPE_IDLE_NETWORK; + static DeclareMemType MTYPE_IDLE_UPDATE_REGIONS; + static DeclareMemType MTYPE_IDLE_UPDATE_VIEWER_REGION; + static DeclareMemType MTYPE_IDLE_UPDATE_SURFACE; + static DeclareMemType MTYPE_IDLE_UPDATE_PARCEL_OVERLAY; + static DeclareMemType MTYPE_IDLE_AUDIO; + + static DeclareMemType MTYPE_CACHE_PROCESS_PENDING; + static DeclareMemType MTYPE_CACHE_PROCESS_PENDING_ASKS; + static DeclareMemType MTYPE_CACHE_PROCESS_PENDING_REPLIES; + + static DeclareMemType MTYPE_MESSAGE_CHECK_ALL; + static DeclareMemType MTYPE_MESSAGE_PROCESS_ACKS; + + static DeclareMemType MTYPE_RENDER; + static DeclareMemType MTYPE_SLEEP; + + static DeclareMemType MTYPE_NETWORK; + static DeclareMemType MTYPE_PHYSICS; + static DeclareMemType MTYPE_INTERESTLIST; + + static DeclareMemType MTYPE_IMAGEBASE; + static DeclareMemType MTYPE_IMAGERAW; + static DeclareMemType MTYPE_IMAGEFORMATTED; -public: -#if MEM_TRACK_TYPE - static S32 sCurDepth; - static S32 sCurType; - static S32 sType[MTYPE_MAX_DEPTH]; - static S32 sMemCount[MTYPE_NUM_TYPES]; - static S32 sMaxMemCount[MTYPE_NUM_TYPES]; - static S32 sNewCount[MTYPE_NUM_TYPES]; - static S32 sOverheadMem; - static const char* sTypeDesc[MTYPE_NUM_TYPES]; -#endif - static S32 sTotalMem; - static S32 sMaxTotalMem; + static DeclareMemType MTYPE_APPFMTIMAGE; + static DeclareMemType MTYPE_APPRAWIMAGE; + static DeclareMemType MTYPE_APPAUXRAWIMAGE; + + static DeclareMemType MTYPE_DRAWABLE; + + static DeclareMemType MTYPE_OBJECT; + static DeclareMemType MTYPE_OBJECT_PROCESS_UPDATE; + static DeclareMemType MTYPE_OBJECT_PROCESS_UPDATE_CORE; + + static DeclareMemType MTYPE_DISPLAY; + static DeclareMemType MTYPE_DISPLAY_UPDATE; + static DeclareMemType MTYPE_DISPLAY_UPDATE_CAMERA; + static DeclareMemType MTYPE_DISPLAY_UPDATE_GEOM; + static DeclareMemType MTYPE_DISPLAY_SWAP; + static DeclareMemType MTYPE_DISPLAY_UPDATE_HUD; + static DeclareMemType MTYPE_DISPLAY_GEN_REFLECTION; + static DeclareMemType MTYPE_DISPLAY_IMAGE_UPDATE; + static DeclareMemType MTYPE_DISPLAY_STATE_SORT; + static DeclareMemType MTYPE_DISPLAY_SKY; + static DeclareMemType MTYPE_DISPLAY_RENDER_GEOM; + static DeclareMemType MTYPE_DISPLAY_RENDER_FLUSH; + static DeclareMemType MTYPE_DISPLAY_RENDER_UI; + static DeclareMemType MTYPE_DISPLAY_RENDER_ATTACHMENTS; + + static DeclareMemType MTYPE_VERTEX_DATA; + static DeclareMemType MTYPE_VERTEX_CONSTRUCTOR; + static DeclareMemType MTYPE_VERTEX_DESTRUCTOR; + static DeclareMemType MTYPE_VERTEX_CREATE_VERTICES; + static DeclareMemType MTYPE_VERTEX_CREATE_INDICES; + static DeclareMemType MTYPE_VERTEX_DESTROY_BUFFER; + static DeclareMemType MTYPE_VERTEX_DESTROY_INDICES; + static DeclareMemType MTYPE_VERTEX_UPDATE_VERTS; + static DeclareMemType MTYPE_VERTEX_UPDATE_INDICES; + static DeclareMemType MTYPE_VERTEX_ALLOCATE_BUFFER; + static DeclareMemType MTYPE_VERTEX_RESIZE_BUFFER; + static DeclareMemType MTYPE_VERTEX_MAP_BUFFER; + static DeclareMemType MTYPE_VERTEX_MAP_BUFFER_VERTICES; + static DeclareMemType MTYPE_VERTEX_MAP_BUFFER_INDICES; + static DeclareMemType MTYPE_VERTEX_UNMAP_BUFFER; + static DeclareMemType MTYPE_VERTEX_SET_STRIDE; + static DeclareMemType MTYPE_VERTEX_SET_BUFFER; + static DeclareMemType MTYPE_VERTEX_SETUP_VERTEX_BUFFER; + static DeclareMemType MTYPE_VERTEX_CLEANUP_CLASS; + + static DeclareMemType MTYPE_SPACE_PARTITION; + + static DeclareMemType MTYPE_PIPELINE; + static DeclareMemType MTYPE_PIPELINE_INIT; + static DeclareMemType MTYPE_PIPELINE_CREATE_BUFFERS; + static DeclareMemType MTYPE_PIPELINE_RESTORE_GL; + static DeclareMemType MTYPE_PIPELINE_UNLOAD_SHADERS; + static DeclareMemType MTYPE_PIPELINE_LIGHTING_DETAIL; + static DeclareMemType MTYPE_PIPELINE_GET_POOL_TYPE; + static DeclareMemType MTYPE_PIPELINE_ADD_POOL; + static DeclareMemType MTYPE_PIPELINE_ALLOCATE_DRAWABLE; + static DeclareMemType MTYPE_PIPELINE_ADD_OBJECT; + static DeclareMemType MTYPE_PIPELINE_CREATE_OBJECTS; + static DeclareMemType MTYPE_PIPELINE_UPDATE_MOVE; + static DeclareMemType MTYPE_PIPELINE_UPDATE_GEOM; + static DeclareMemType MTYPE_PIPELINE_MARK_VISIBLE; + static DeclareMemType MTYPE_PIPELINE_MARK_MOVED; + static DeclareMemType MTYPE_PIPELINE_MARK_SHIFT; + static DeclareMemType MTYPE_PIPELINE_SHIFT_OBJECTS; + static DeclareMemType MTYPE_PIPELINE_MARK_TEXTURED; + static DeclareMemType MTYPE_PIPELINE_MARK_REBUILD; + static DeclareMemType MTYPE_PIPELINE_UPDATE_CULL; + static DeclareMemType MTYPE_PIPELINE_STATE_SORT; + static DeclareMemType MTYPE_PIPELINE_POST_SORT; + + static DeclareMemType MTYPE_PIPELINE_RENDER_HUD_ELS; + static DeclareMemType MTYPE_PIPELINE_RENDER_HL; + static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM; + static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM_DEFFERRED; + static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM_POST_DEF; + static DeclareMemType MTYPE_PIPELINE_RENDER_GEOM_SHADOW; + static DeclareMemType MTYPE_PIPELINE_RENDER_SELECT; + static DeclareMemType MTYPE_PIPELINE_REBUILD_POOLS; + static DeclareMemType MTYPE_PIPELINE_QUICK_LOOKUP; + static DeclareMemType MTYPE_PIPELINE_RENDER_OBJECTS; + static DeclareMemType MTYPE_PIPELINE_GENERATE_IMPOSTOR; + static DeclareMemType MTYPE_PIPELINE_RENDER_BLOOM; + + static DeclareMemType MTYPE_UPKEEP_POOLS; + + static DeclareMemType MTYPE_AVATAR; + static DeclareMemType MTYPE_AVATAR_MESH; + static DeclareMemType MTYPE_PARTICLES; + static DeclareMemType MTYPE_REGIONS; + + static DeclareMemType MTYPE_INVENTORY; + static DeclareMemType MTYPE_INVENTORY_DRAW; + static DeclareMemType MTYPE_INVENTORY_BUILD_NEW_VIEWS; + static DeclareMemType MTYPE_INVENTORY_DO_FOLDER; + static DeclareMemType MTYPE_INVENTORY_POST_BUILD; + static DeclareMemType MTYPE_INVENTORY_FROM_XML; + static DeclareMemType MTYPE_INVENTORY_CREATE_NEW_ITEM; + static DeclareMemType MTYPE_INVENTORY_VIEW_INIT; + static DeclareMemType MTYPE_INVENTORY_VIEW_SHOW; + static DeclareMemType MTYPE_INVENTORY_VIEW_TOGGLE; + + static DeclareMemType MTYPE_ANIMATION; + static DeclareMemType MTYPE_VOLUME; + static DeclareMemType MTYPE_PRIMITIVE; + + static DeclareMemType MTYPE_SCRIPT; + static DeclareMemType MTYPE_SCRIPT_RUN; + static DeclareMemType MTYPE_SCRIPT_BYTECODE; + + static DeclareMemType MTYPE_IO_PUMP; + static DeclareMemType MTYPE_IO_TCP; + static DeclareMemType MTYPE_IO_BUFFER; + static DeclareMemType MTYPE_IO_HTTP_SERVER; + static DeclareMemType MTYPE_IO_SD_SERVER; + static DeclareMemType MTYPE_IO_SD_CLIENT; + static DeclareMemType MTYPE_IO_URL_REQUEST; + + static DeclareMemType MTYPE_DIRECTX_INIT; + + static DeclareMemType MTYPE_TEMP1; + static DeclareMemType MTYPE_TEMP2; + static DeclareMemType MTYPE_TEMP3; + static DeclareMemType MTYPE_TEMP4; + static DeclareMemType MTYPE_TEMP5; + static DeclareMemType MTYPE_TEMP6; + static DeclareMemType MTYPE_TEMP7; + static DeclareMemType MTYPE_TEMP8; + static DeclareMemType MTYPE_TEMP9; + + static DeclareMemType MTYPE_OTHER; // Special; used by display code + + S32 mTypeIndex; }; //---------------------------------------------------------------------------- diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 7b003c250..d6c2074f2 100644 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -170,7 +170,7 @@ void LLImageBase::deleteData() // virtual U8* LLImageBase::allocateData(S32 size) { - LLMemType mt1((LLMemType::EMemType)mMemType); + LLMemType mt1(mMemType); if (size < 0) { @@ -209,7 +209,7 @@ U8* LLImageBase::reallocateData(S32 size) if(mData && (mDataSize == size)) return mData; - LLMemType mt1((LLMemType::EMemType)mMemType); + LLMemType mt1(mMemType); U8 *new_datap = (U8*)ALLOCATE_MEM(sPrivatePoolp, size); if (!new_datap) { @@ -457,7 +457,7 @@ void LLImageRaw::clear(U8 r, U8 g, U8 b, U8 a) // Reverses the order of the rows in the image void LLImageRaw::verticalFlip() { - LLMemType mt1((LLMemType::EMemType)mMemType); + LLMemType mt1(mMemType); S32 row_bytes = getWidth() * getComponents(); U8* line_buffer = new (std::nothrow) U8[row_bytes]; if (!line_buffer ) @@ -595,7 +595,7 @@ void LLImageRaw::composite( LLImageRaw* src ) // Src and dst can be any size. Src has 4 components. Dst has 3 components. void LLImageRaw::compositeScaled4onto3(LLImageRaw* src) { - LLMemType mt1((LLMemType::EMemType)mMemType); + LLMemType mt1(mMemType); llinfos << "compositeScaled4onto3" << llendl; LLImageRaw* dst = this; // Just for clarity. @@ -846,7 +846,7 @@ void LLImageRaw::copyUnscaled3onto4( LLImageRaw* src ) // Src and dst can be any size. Src and dst have same number of components. void LLImageRaw::copyScaled( LLImageRaw* src ) { - LLMemType mt1((LLMemType::EMemType)mMemType); + LLMemType mt1(mMemType); LLImageRaw* dst = this; // Just for clarity. llassert_always( (1 == src->getComponents()) || (3 == src->getComponents()) || (4 == src->getComponents()) ); @@ -932,7 +932,7 @@ BOOL LLImageRaw::scaleDownWithoutBlending( S32 new_width, S32 new_height) BOOL LLImageRaw::scale( S32 new_width, S32 new_height, BOOL scale_image_data ) { - LLMemType mt1((LLMemType::EMemType)mMemType); + LLMemType mt1(mMemType); llassert((1 == getComponents()) || (3 == getComponents()) || (4 == getComponents()) ); S32 old_width = getWidth(); diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 0bed6468d..fc5012b41 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -35,7 +35,7 @@ #include "lluuid.h" #include "llstring.h" -#include "llmemory.h" +#include "llmemtype.h" #include "llthread.h" #include "aithreadsafe.h" @@ -162,7 +162,7 @@ private: static LLPrivateMemoryPool* sPrivatePoolp ; public: - S16 mMemType; // debug + LLMemType::DeclareMemType& mMemType; // debug }; // Raw representation of an image (used for textures, and other uncompressed formats diff --git a/indra/llimage/llimagej2c.cpp b/indra/llimage/llimagej2c.cpp index 564a66aa1..8c6fe3386 100644 --- a/indra/llimage/llimagej2c.cpp +++ b/indra/llimage/llimagej2c.cpp @@ -297,7 +297,7 @@ BOOL LLImageJ2C::decode(LLImageRaw *raw_imagep, F32 decode_time) // Returns TRUE to mean done, whether successful or not. BOOL LLImageJ2C::decodeChannels(LLImageRaw *raw_imagep, F32 decode_time, S32 first_channel, S32 max_channel_count ) { - LLMemType mt1((LLMemType::EMemType)mMemType); + LLMemType mt1(mMemType); BOOL res = TRUE; @@ -347,7 +347,7 @@ BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, F32 encode_time) BOOL LLImageJ2C::encode(const LLImageRaw *raw_imagep, const char* comment_text, F32 encode_time) { - LLMemType mt1((LLMemType::EMemType)mMemType); + LLMemType mt1(mMemType); resetLastError(); BOOL res = mImpl->encodeImpl(*this, *raw_imagep, comment_text, encode_time, mReversible); if (!mLastError.empty()) @@ -529,7 +529,7 @@ BOOL LLImageJ2C::loadAndValidate(const std::string &filename) BOOL LLImageJ2C::validate(U8 *data, U32 file_size) { - LLMemType mt1((LLMemType::EMemType)mMemType); + LLMemType mt1(mMemType); resetLastError(); diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index f9036c080..1466c79ed 100644 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -42,6 +42,7 @@ #include "llsdserialize.h" #include "lluuid.h" #include "message.h" +#include "llmemtype.h" #include @@ -771,6 +772,7 @@ bool LLCacheName::getIfThere(const LLUUID& id, std::string& fullname, BOOL& is_g // void LLCacheName::processPending() { + LLMemType mt_pp(LLMemType::MTYPE_CACHE_PROCESS_PENDING); const F32 SECS_BETWEEN_PROCESS = 0.1f; if(!impl.mProcessTimer.checkExpirationAndReset(SECS_BETWEEN_PROCESS)) { @@ -873,8 +875,10 @@ std::string LLCacheName::getDefaultLastName() { return "Resident"; } + void LLCacheName::Impl::processPendingAsks() { + LLMemType mt_ppa(LLMemType::MTYPE_CACHE_PROCESS_PENDING_ASKS); sendRequest(_PREHASH_UUIDNameRequest, mAskNameQueue); sendRequest(_PREHASH_UUIDGroupNameRequest, mAskGroupQueue); mAskNameQueue.clear(); @@ -883,6 +887,7 @@ void LLCacheName::Impl::processPendingAsks() void LLCacheName::Impl::processPendingReplies() { + LLMemType mt_ppr(LLMemType::MTYPE_CACHE_PROCESS_PENDING_REPLIES); // First call all the callbacks, because they might send messages. for(ReplyQueue::iterator it = mReplyQueue.begin(); it != mReplyQueue.end(); ++it) { diff --git a/indra/llmessage/lliosocket.cpp b/indra/llmessage/lliosocket.cpp index 2aa44b8fd..eb69e15ed 100644 --- a/indra/llmessage/lliosocket.cpp +++ b/indra/llmessage/lliosocket.cpp @@ -244,6 +244,7 @@ LLSocket::LLSocket() : mPool(LLThread::tldata().mRootPool), mPort(PORT_INVALID) { + LLMemType m1(LLMemType::MTYPE_IO_TCP); } LLSocket::~LLSocket() diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index 723fc6592..013aea32b 100644 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -86,6 +86,7 @@ #include "v3math.h" #include "v4math.h" #include "lltransfertargetvfile.h" +#include "llmemtype.h" // #include "llrand.h" @@ -811,6 +812,7 @@ S32 LLMessageSystem::getReceiveBytes() const void LLMessageSystem::processAcks() { + LLMemType mt_pa(LLMemType::MTYPE_MESSAGE_PROCESS_ACKS); F64 mt_sec = getMessageTimeSeconds(); { gTransferManager.updateTransfers(); @@ -4048,6 +4050,7 @@ void LLMessageSystem::setTimeDecodesSpamThreshold( F32 seconds ) // TODO: babbage: move gServicePump in to LLMessageSystem? bool LLMessageSystem::checkAllMessages(S64 frame_count, LLPumpIO* http_pump) { + LLMemType mt_cam(LLMemType::MTYPE_MESSAGE_CHECK_ALL); if(checkMessages(frame_count)) { return true; diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index bf06adb9f..e92657bc0 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -50,6 +50,7 @@ #include "llmath.h" #include "m4math.h" #include "llstring.h" +#include "llmemtype.h" #include "llstacktrace.h" #include "llglheaders.h" @@ -2203,6 +2204,7 @@ void LLGLNamePool::release(GLuint name) //static void LLGLNamePool::upkeepPools() { + LLMemType mt(LLMemType::MTYPE_UPKEEP_POOLS); for (tracker_t::instance_iter iter = beginInstances(); iter != endInstances(); ++iter) { LLGLNamePool & pool = *iter; diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index d50829928..21f486da6 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -731,7 +731,7 @@ void LLVertexBuffer::unbind() //static void LLVertexBuffer::cleanupClass() { - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_CLEANUP_CLASS); unbind(); sStreamIBOPool.cleanup(); @@ -812,7 +812,7 @@ LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) : mMappable(false), mFence(NULL) { - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_CONSTRUCTOR); if (mUsage == GL_DYNAMIC_DRAW_ARB && !sDisableVBOMapping) { @@ -880,7 +880,7 @@ S32 LLVertexBuffer::getSize() const //virtual LLVertexBuffer::~LLVertexBuffer() { - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTRUCTOR); destroyGLBuffer(); destroyGLIndices(); @@ -997,7 +997,7 @@ void LLVertexBuffer::releaseIndices() void LLVertexBuffer::createGLBuffer(U32 size) { - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_CREATE_VERTICES); if (mGLBuffer) { @@ -1028,7 +1028,7 @@ void LLVertexBuffer::createGLBuffer(U32 size) void LLVertexBuffer::createGLIndices(U32 size) { - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_CREATE_INDICES); if (mGLIndices) { @@ -1064,7 +1064,7 @@ void LLVertexBuffer::createGLIndices(U32 size) void LLVertexBuffer::destroyGLBuffer() { - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTROY_BUFFER); if (mGLBuffer) { if (mMappedDataUsingVBOs) @@ -1085,7 +1085,7 @@ void LLVertexBuffer::destroyGLBuffer() void LLVertexBuffer::destroyGLIndices() { - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_DESTROY_INDICES); if (mGLIndices) { if (mMappedIndexDataUsingVBOs) @@ -1106,7 +1106,7 @@ void LLVertexBuffer::destroyGLIndices() void LLVertexBuffer::updateNumVerts(S32 nverts) { - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_UPDATE_VERTS); llassert(nverts >= 0); @@ -1128,7 +1128,7 @@ void LLVertexBuffer::updateNumVerts(S32 nverts) void LLVertexBuffer::updateNumIndices(S32 nindices) { - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_UPDATE_INDICES); llassert(nindices >= 0); @@ -1144,7 +1144,7 @@ void LLVertexBuffer::updateNumIndices(S32 nindices) void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create) { - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_ALLOCATE_BUFFER); stop_glerror(); @@ -1265,7 +1265,7 @@ void LLVertexBuffer::resizeBuffer(S32 newnverts, S32 newnindices) llassert(newnverts >= 0); llassert(newnindices >= 0); - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_RESIZE_BUFFER); updateNumVerts(newnverts); updateNumIndices(newnindices); @@ -1313,7 +1313,7 @@ static LLFastTimer::DeclareTimer FTM_VBO_MAP_BUFFER("VBO Map"); volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range) { bindGLBuffer(true); - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_MAP_BUFFER); if (mFinal) { llerrs << "LLVertexBuffer::mapVeretxBuffer() called on a finalized buffer." << llendl; @@ -1362,6 +1362,7 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo if (!mVertexLocked) { + LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_VERTICES); mVertexLocked = true; sMappedCount++; stop_glerror(); @@ -1492,7 +1493,7 @@ static LLFastTimer::DeclareTimer FTM_VBO_MAP_INDEX("IBO Map"); volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range) { - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_MAP_BUFFER); bindGLIndices(true); if (mFinal) { @@ -1539,7 +1540,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range if (!mIndexLocked) { - //LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES); + LLMemType mt_v(LLMemType::MTYPE_VERTEX_MAP_BUFFER_INDICES); mIndexLocked = true; sMappedCount++; @@ -1663,7 +1664,7 @@ static LLFastTimer::DeclareTimer FTM_IBO_FLUSH_RANGE("Flush IBO Range"); void LLVertexBuffer::unmapBuffer() { - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_UNMAP_BUFFER); if (!useVBOs()) { return ; //nothing to unmap @@ -2007,7 +2008,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) { flush(); - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_SET_BUFFER); //set up pointers if the data mask is different ... bool setup = (sLastMask != data_mask); @@ -2149,7 +2150,7 @@ void LLVertexBuffer::setBuffer(U32 data_mask) // virtual (default) void LLVertexBuffer::setupVertexBuffer(U32 data_mask) { - LLMemType mt(LLMemType::MTYPE_VERTEX_DATA); + LLMemType mt2(LLMemType::MTYPE_VERTEX_SETUP_VERTEX_BUFFER); stop_glerror(); volatile U8* base = useVBOs() ? (U8*) mAlignedOffset : mMappedData; diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 7a9dc6d9e..1cdd74902 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -8043,6 +8043,17 @@ Value 512 + MemProfiling + + Comment + You want to use tcmalloc's memory profiling options. + Persist + 1 + Type + Boolean + Value + 0 + MenuAccessKeyTime Comment diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index ad7387f3c..d39f6de5d 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -630,6 +630,8 @@ bool LLAppViewer::init() initMaxHeapSize() ; LLPrivateMemoryPoolManager::initClass((BOOL)gSavedSettings.getBOOL("MemoryPrivatePoolEnabled"), (U32)gSavedSettings.getU32("MemoryPrivatePoolSize")) ; + + mAlloc.setProfilingEnabled(gSavedSettings.getBOOL("MemProfiling")); // *NOTE:Mani - LLCurl::initClass is not thread safe. // Called before threads are created. LLCurl::initClass(gSavedSettings.getBOOL("CurlUseMultipleThreads")); @@ -1023,8 +1025,10 @@ static LLFastTimer::DeclareTimer FTM_PUMP_SERVICE("Service"); static LLFastTimer::DeclareTimer FTM_SERVICE_CALLBACK("Callback"); static LLFastTimer::DeclareTimer FTM_AGENT_AUTOPILOT("Autopilot"); static LLFastTimer::DeclareTimer FTM_AGENT_UPDATE("Update"); + bool LLAppViewer::mainLoop() { + LLMemType mt1(LLMemType::MTYPE_MAIN); mMainloopTimeout = new LLWatchdogTimeout(); // *FIX:Mani - Make this a setting, once new settings exist in this branch. @@ -1042,7 +1046,6 @@ bool LLAppViewer::mainLoop() LLVoiceChannel::initClass(); LLVoiceClient::init(gServicePump); - LLMemType mt1(LLMemType::MTYPE_MAIN); LLTimer frameTimer,idleTimer; LLTimer debugTime; LLFrameTimer memCheckTimer; @@ -1115,6 +1118,7 @@ bool LLAppViewer::mainLoop() && !gViewerWindow->getShowProgress() && !gFocusMgr.focusLocked()) { + LLMemType mjk(LLMemType::MTYPE_JOY_KEY); joystick->scanJoystick(); gKeyboard->scanKeyboard(); if(isCrouch) @@ -1134,6 +1138,7 @@ bool LLAppViewer::mainLoop() if (gAres != NULL && gAres->isInitialized()) { + LLMemType mt_ip(LLMemType::MTYPE_IDLE_PUMP); pingMainloopTimeout("Main:ServicePump"); LLFastTimer t4(FTM_PUMP); { @@ -1188,6 +1193,7 @@ bool LLAppViewer::mainLoop() // Sleep and run background threads { + LLMemType mt_sleep(LLMemType::MTYPE_SLEEP); LLFastTimer t2(FTM_SLEEP); static const LLCachedControl run_multiple_threads("RunMultipleThreads",false); @@ -3707,6 +3713,7 @@ static LLFastTimer::DeclareTimer FTM_VLMANAGER("VL Manager"); /////////////////////////////////////////////////////// void LLAppViewer::idle() { + LLMemType mt_idle(LLMemType::MTYPE_IDLE); pingMainloopTimeout("Main:Idle"); // Update frame timers @@ -4287,6 +4294,7 @@ static LLFastTimer::DeclareTimer FTM_DYNAMIC_THROTTLE("Dynamic Throttle"); static LLFastTimer::DeclareTimer FTM_CHECK_REGION_CIRCUIT("Check Region Circuit"); void LLAppViewer::idleNetwork() { + LLMemType mt_in(LLMemType::MTYPE_IDLE_NETWORK); pingMainloopTimeout("idleNetwork"); gObjectList.mNumNewObjects = 0; diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h index 062607b0f..f268324d7 100644 --- a/indra/newview/llappviewer.h +++ b/indra/newview/llappviewer.h @@ -33,7 +33,8 @@ #ifndef LL_LLAPPVIEWER_H #define LL_LLAPPVIEWER_H -#include "llsys.h" // LLOSInfo +#include "llallocator.h" +#include "llsys.h" // for LLOSInfo #include "llviewercontrol.h" // settings_map_type class LLTextureCache; @@ -158,6 +159,7 @@ public: // *NOTE:Mani Fix this for login abstraction!! void handleLoginComplete(); + LLAllocator & getAllocator() { return mAlloc; } void addOnIdleCallback(const boost::function& cb); // add a callback to fire (once) when idle void purgeCache(); // Clear the local cache. @@ -245,6 +247,7 @@ private: bool mAgentRegionLastAlive; LLUUID mAgentRegionLastID; + LLAllocator mAlloc; LLFrameTimer mMemCheckTimer; diff --git a/indra/newview/llmemoryview.cpp b/indra/newview/llmemoryview.cpp index 215cc6940..6a57d5f56 100644 --- a/indra/newview/llmemoryview.cpp +++ b/indra/newview/llmemoryview.cpp @@ -32,37 +32,28 @@ #include "llviewerprecompiledheaders.h" -#include "indra_constants.h" #include "llmemoryview.h" -#include "llrect.h" -#include "llerror.h" -#include "llgl.h" -#include "llmath.h" -#include "llfontgl.h" -#include "llmemtype.h" - -#include "llcharacter.h" -#include "llui.h" +#include "llappviewer.h" +#include "llallocator_heap_profile.h" +#include "llgl.h" // LLGLSUIDefault +#include "llviewerwindow.h" #include "llviewercontrol.h" -#include "llstat.h" -#include "llfasttimer.h" +#include +#include + +#include "llmemory.h" LLMemoryView::LLMemoryView(const std::string& name, const LLRect& rect) : LLView(name, rect, TRUE), -mDelay(120) + mPaused(FALSE), + //mDelay(120), + mAlloc(NULL) { setVisible(FALSE); - mDumpTimer.reset(); - -#ifdef MEM_DUMP_DATA - // clear out file. - LLFILE *dump = LLFile::fopen("memusagedump.txt", "w"); - fclose(dump); -#endif } LLMemoryView::~LLMemoryView() @@ -79,6 +70,7 @@ BOOL LLMemoryView::handleMouseDown(S32 x, S32 y, MASK mask) } else { + mPaused = !mPaused; } return TRUE; } @@ -94,62 +86,143 @@ BOOL LLMemoryView::handleHover(S32 x, S32 y, MASK mask) return FALSE; } -////////////////////////////////////////////////////////////////////////////// - -struct mtv_display_info { - S32 memtype; - const char *desc; - const LLColor4 *color; -}; - -static const LLColor4 red0(0.5f, 0.0f, 0.0f, 1.0f); - -static const struct mtv_display_info mtv_display_table[] = +void LLMemoryView::refreshProfile() { - { LLMemType::MTYPE_INIT, "Init", &LLColor4::white }, - { LLMemType::MTYPE_STARTUP, "Startup", &LLColor4::cyan1 }, - { LLMemType::MTYPE_MAIN, "Main", &LLColor4::cyan2 }, - { LLMemType::MTYPE_IMAGEBASE, "ImageBase", &LLColor4::yellow1 }, - { LLMemType::MTYPE_IMAGERAW, "ImageRaw", &LLColor4::yellow2 }, - { LLMemType::MTYPE_IMAGEFORMATTED, "ImageFmtd", &LLColor4::yellow3 }, - { LLMemType::MTYPE_APPFMTIMAGE, "ViewerImageFmt", &LLColor4::orange1 }, - { LLMemType::MTYPE_APPRAWIMAGE, "ViewerImageRaw", &LLColor4::orange2 }, - { LLMemType::MTYPE_APPAUXRAWIMAGE, "ViewerImageAux", &LLColor4::orange3 }, - { LLMemType::MTYPE_DRAWABLE, "Drawable", &LLColor4::green1 }, - { LLMemType::MTYPE_OBJECT, "ViewerObject", &LLColor4::green2 }, - { LLMemType::MTYPE_PIPELINE, "Pipeline", &LLColor4::green3 }, - { LLMemType::MTYPE_PARTICLES, "Particles", &LLColor4::green4 }, - { LLMemType::MTYPE_SPACE_PARTITION, "Space Partition", &LLColor4::blue2 }, - { LLMemType::MTYPE_VERTEX_DATA, "Vertex Buffer", &LLColor4::blue3 }, - { LLMemType::MTYPE_AVATAR, "Avatar", &LLColor4::purple1 }, - { LLMemType::MTYPE_AVATAR_MESH, "Avatar Mesh", &LLColor4::purple2 }, - { LLMemType::MTYPE_ANIMATION, "Animation", &LLColor4::purple3 }, - { LLMemType::MTYPE_REGIONS, "Regions", &LLColor4::blue1 }, - { LLMemType::MTYPE_VOLUME, "Volume", &LLColor4::pink1 }, - { LLMemType::MTYPE_PRIMITIVE, "Profile", &LLColor4::pink2 }, - { LLMemType::MTYPE_TEMP1, "Temp1", &LLColor4::red1 }, - { LLMemType::MTYPE_TEMP2, "Temp2", &LLColor4::magenta1 }, - { LLMemType::MTYPE_TEMP3, "Temp3", &LLColor4::red2 }, - { LLMemType::MTYPE_TEMP4, "Temp4", &LLColor4::magenta2 }, - { LLMemType::MTYPE_TEMP5, "Temp5", &LLColor4::red3 }, - { LLMemType::MTYPE_TEMP6, "Temp6", &LLColor4::magenta3 }, - { LLMemType::MTYPE_TEMP7, "Temp7", &LLColor4::red4 }, - { LLMemType::MTYPE_TEMP8, "Temp8", &LLColor4::magenta4 }, + /* + LLAllocator & alloc = LLAppViewer::instance()->getAllocator(); + if(alloc.isProfiling()) { + std::string profile_text = alloc.getRawProfile(); - { LLMemType::MTYPE_OTHER, "Other", &red0 }, -}; -static const int MTV_DISPLAY_NUM = LL_ARRAY_SIZE(mtv_display_table); + boost::algorithm::split(mLines, profile_text, boost::bind(std::equal_to(), '\n', _1)); + } else { + mLines.clear(); + } + */ + if (mAlloc == NULL) { + mAlloc = &LLAppViewer::instance()->getAllocator(); + } + + mLines.clear(); + + if(mAlloc->isProfiling()) + { + const LLAllocatorHeapProfile &prof = mAlloc->getProfile(); + for(size_t i = 0; i < prof.mLines.size(); ++i) + { + std::stringstream ss; + ss << "Unfreed Mem: " << (prof.mLines[i].mLiveSize >> 20) << " M Trace: "; + for(size_t k = 0; k < prof.mLines[i].mTrace.size(); ++k) + { + ss << LLMemType::getNameFromID(prof.mLines[i].mTrace[k]) << " "; + } + mLines.push_back(utf8string_to_wstring(ss.str())); + } + } +} void LLMemoryView::draw() { - std::string tdesc; - S32 width = getRect().getWidth(); - S32 height = getRect().getHeight(); + const S32 UPDATE_INTERVAL = 60; + const S32 MARGIN_AMT = 10; + static S32 curUpdate = UPDATE_INTERVAL; + static LLColor4 s_console_color = gColors.getColor("ConsoleBackground"); + + // setup update interval + if (curUpdate >= UPDATE_INTERVAL) + { + refreshProfile(); + curUpdate = 0; + } + curUpdate++; + + // setup window properly + S32 height = (S32) (gViewerWindow->getWindowRectScaled().getHeight()*0.75f); + S32 width = (S32) (gViewerWindow->getWindowRectScaled().getWidth() * 0.9f); + setRect(LLRect().setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height)); + // setup window color + F32 console_opacity = llclamp(gSavedSettings.getF32("ConsoleBackgroundOpacity"), 0.f, 1.f); + LLColor4 color = s_console_color; + color.mV[VALPHA] *= console_opacity; + LLGLSUIDefault gls_ui; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gl_rect_2d(0, height, width, 0, LLColor4(0.f, 0.f, 0.f, 0.25f)); + gl_rect_2d(0, height, width, 0, color); + LLFontGL * font = LLFontGL::getFontSansSerifSmall(); + + // draw remaining lines + F32 y_pos = 0.f; + F32 y_off = 0.f; + + F32 line_height = font->getLineHeight(); + S32 target_width = width - 2 * MARGIN_AMT; + + // cut off lines on bottom + U32 max_lines = U32((height - 2 * line_height) / line_height); + y_pos = height - MARGIN_AMT - line_height; + y_off = 0.f; + +#if !MEM_TRACK_MEM + std::vector::const_iterator end = mLines.end(); + if(mLines.size() > max_lines) { + end = mLines.begin() + max_lines; + } + for (std::vector::const_iterator i = mLines.begin(); i != end; ++i) + { + font->render(*i, 0, MARGIN_AMT, y_pos - y_off, + LLColor4::white, + LLFontGL::LEFT, + LLFontGL::BASELINE, + LLFontGL::NORMAL, + LLFontGL::DROP_SHADOW, + S32_MAX, + target_width + ); + y_off += line_height; + } + +#else + LLMemTracker::getInstance()->preDraw(mPaused) ; + + { + F32 x_pos = MARGIN_AMT ; + U32 lines = 0 ; + const char* str = LLMemTracker::getInstance()->getNextLine() ; + while(str != NULL) + { + lines++ ; + font->renderUTF8(str, 0, x_pos, y_pos - y_off, + LLColor4::white, + LLFontGL::LEFT, + LLFontGL::BASELINE, + LLFontGL::NORMAL, + LLFontGL::DROP_SHADOW, + S32_MAX, + target_width, + NULL, FALSE); + + str = LLMemTracker::getInstance()->getNextLine() ; + y_off += line_height; + + if(lines >= max_lines) + { + lines = 0 ; + x_pos += 512.f ; + if(x_pos + 512.f > target_width) + { + break ; + } + + y_pos = height - MARGIN_AMT - line_height; + y_off = 0.f; + } + } + } + + LLMemTracker::getInstance()->postDraw() ; +#endif + #if MEM_TRACK_TYPE S32 left, top, right, bottom; @@ -267,40 +340,3 @@ void LLMemoryView::draw() LLView::draw(); } - -void LLMemoryView::setDataDumpInterval(float delay) -{ - mDelay = delay; -} - -void LLMemoryView::dumpData() -{ -#if MEM_TRACK_TYPE && MEM_DUMP_DATA - if (mDelay && (mDumpTimer.getElapsedTimeF32() > mDelay )) - { - // reset timer - mDumpTimer.reset(); - // append dump info to text file - LLFILE *dump = LLFile::fopen("memusagedump.txt", "a"); - - if (dump) - { - // write out total memory usage - fprintf (dump, "Total memory in use = %09d (%03d MB)\n", LLMemType::sTotalMem, LLMemType::sTotalMem>>20); - fprintf (dump, "High Water Mark = %09d (%03d MB)\n\n", LLMemType::sMaxTotalMem, LLMemType::sMaxTotalMem>>20); - // dump out usage of 'new' for each memory type - for (S32 i=0; i>20, LLMemType::sMaxMemCount[i], LLMemType::sMaxMemCount[i]>>20, LLMemType::sNewCount[i]); - fprintf (dump, "%s\n", outData.c_str()); - } - } - fprintf (dump, "\n\n"); - - fclose(dump); - } - } -#endif -} diff --git a/indra/newview/llmemoryview.h b/indra/newview/llmemoryview.h index 81466bd6b..d6ad2bfc1 100644 --- a/indra/newview/llmemoryview.h +++ b/indra/newview/llmemoryview.h @@ -35,6 +35,8 @@ #include "llview.h" +class LLAllocator; + class LLMemoryView : public LLView { public: @@ -46,14 +48,13 @@ public: virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual void draw(); -private: - void setDataDumpInterval(float delay); - void dumpData(); - - float mDelay; - LLFrameTimer mDumpTimer; + void refreshProfile(); private: + std::vector mLines; + LLAllocator* mAlloc; + BOOL mPaused ; + }; #endif diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index a70806851..01bc8dd22 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -946,14 +946,14 @@ void init_client_menu(LLMenuGL* menu) &get_visibility, (void*)gDebugView->mFastTimerView, '9', MASK_CONTROL|MASK_SHIFT ) ); -#if MEM_TRACK_MEM +//#if MEM_TRACK_MEM sub->append(new LLMenuItemCheckGL("Memory", &toggle_visibility, NULL, &get_visibility, (void*)gDebugView->mMemoryView, '0', MASK_CONTROL|MASK_SHIFT ) ); -#endif +//#endif sub->appendSeparator(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index bb2c9672e..f4604589c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -388,7 +388,7 @@ LLPipeline::LLPipeline() : void LLPipeline::init() { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_INIT); refreshCachedSettings(); @@ -868,6 +868,7 @@ void LLPipeline::releaseScreenBuffers() void LLPipeline::createGLBuffers() { stop_glerror(); + LLMemType mt_cb(LLMemType::MTYPE_PIPELINE_CREATE_BUFFERS); assertInitialized(); updateRenderDeferred(); @@ -982,6 +983,7 @@ void LLPipeline::createGLBuffers() void LLPipeline::restoreGL() { + LLMemType mt_cb(LLMemType::MTYPE_PIPELINE_RESTORE_GL); assertInitialized(); if (mVertexShadersEnabled) @@ -1043,6 +1045,7 @@ BOOL LLPipeline::canUseAntiAliasing() const void LLPipeline::unloadShaders() { + LLMemType mt_us(LLMemType::MTYPE_PIPELINE_UNLOAD_SHADERS); LLViewerShaderMgr::instance()->unloadShaders(); mVertexShadersLoaded = 0; @@ -1074,6 +1077,7 @@ S32 LLPipeline::getMaxLightingDetail() const S32 LLPipeline::setLightingDetail(S32 level) { + LLMemType mt_ld(LLMemType::MTYPE_PIPELINE_LIGHTING_DETAIL); refreshCachedSettings(); if (level < 0) @@ -1264,7 +1268,7 @@ LLDrawPool* LLPipeline::getPoolFromTE(const LLTextureEntry* te, LLViewerTexture* //static U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* imagep) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt_gpt(LLMemType::MTYPE_PIPELINE_GET_POOL_TYPE); if (!te || !imagep) { @@ -1294,7 +1298,7 @@ U32 LLPipeline::getPoolTypeFromTE(const LLTextureEntry* te, LLViewerTexture* ima void LLPipeline::addPool(LLDrawPool *new_poolp) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt_a(LLMemType::MTYPE_PIPELINE_ADD_POOL); assertInitialized(); mPools.insert(new_poolp); addToQuickLookup( new_poolp ); @@ -1306,7 +1310,7 @@ void LLPipeline::allocDrawable(LLViewerObject *vobj) { llerrs << "Null object passed to allocDrawable!" << llendl; } - LLMemType mt(LLMemType::MTYPE_DRAWABLE); + LLMemType mt_ad(LLMemType::MTYPE_PIPELINE_ALLOCATE_DRAWABLE); LLDrawable *drawable = new LLDrawable(); vobj->mDrawable = drawable; @@ -1399,7 +1403,7 @@ U32 LLPipeline::addObject(LLViewerObject *vobj) { return 0; } - + LLMemType mt_ao(LLMemType::MTYPE_PIPELINE_ADD_OBJECT); static const LLCachedControl render_delay_creation("RenderDelayCreation",false); if (!vobj->isAvatar() && render_delay_creation) { @@ -1416,7 +1420,7 @@ U32 LLPipeline::addObject(LLViewerObject *vobj) void LLPipeline::createObjects(F32 max_dtime) { LLFastTimer ftm(FTM_GEO_UPDATE); - LLMemType mt(LLMemType::MTYPE_DRAWABLE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_CREATE_OBJECTS); LLTimer update_timer; @@ -1591,7 +1595,7 @@ static LLFastTimer::DeclareTimer FTM_UPDATE_MOVE("Update Move"); void LLPipeline::updateMove() { LLFastTimer t(FTM_UPDATE_MOVE); - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt_um(LLMemType::MTYPE_PIPELINE_UPDATE_MOVE); static const LLCachedControl freeze_time("FreezeTime",false); if (freeze_time) @@ -1945,7 +1949,7 @@ static LLFastTimer::DeclareTimer FTM_CULL("Object Culling"); void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip, LLPlane* planep) { LLFastTimer t(FTM_CULL); - LLMemType mt_uc(LLMemType::MTYPE_PIPELINE); + LLMemType mt_uc(LLMemType::MTYPE_PIPELINE_UPDATE_CULL); grabReferences(result); @@ -2314,7 +2318,7 @@ void LLPipeline::rebuildGroups() void LLPipeline::updateGeom(F32 max_dtime) { LLTimer update_timer; - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_UPDATE_GEOM); LLPointer drawablep; LLFastTimer t(FTM_GEO_UPDATE); @@ -2417,7 +2421,7 @@ void LLPipeline::updateGeom(F32 max_dtime) void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_VISIBLE); if(drawablep && !drawablep->isDead()) { @@ -2462,7 +2466,7 @@ void LLPipeline::markVisible(LLDrawable *drawablep, LLCamera& camera) void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt_mm(LLMemType::MTYPE_PIPELINE_MARK_MOVED); if (!drawablep) { @@ -2508,7 +2512,7 @@ void LLPipeline::markMoved(LLDrawable *drawablep, BOOL damped_motion) void LLPipeline::markShift(LLDrawable *drawablep) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_SHIFT); if (!drawablep || drawablep->isDead()) { @@ -2531,7 +2535,7 @@ void LLPipeline::markShift(LLDrawable *drawablep) void LLPipeline::shiftObjects(const LLVector3 &offset) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_SHIFT_OBJECTS); assertInitialized(); @@ -2575,7 +2579,7 @@ void LLPipeline::shiftObjects(const LLVector3 &offset) void LLPipeline::markTextured(LLDrawable *drawablep) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_TEXTURED); if (drawablep && !drawablep->isDead() && assertInitialized()) { @@ -2666,7 +2670,7 @@ void LLPipeline::markRebuild(LLSpatialGroup* group, BOOL priority) void LLPipeline::markRebuild(LLDrawable *drawablep, LLDrawable::EDrawableFlags flag, BOOL priority) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_MARK_REBUILD); if (drawablep && !drawablep->isDead() && assertInitialized()) { @@ -2714,7 +2718,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) } LLFastTimer ftm(FTM_STATESORT); - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT); //LLVertexBuffer::unbind(); @@ -2815,7 +2819,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT); if (!sSkipUpdate && group->changeLOD()) { for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i) @@ -2834,7 +2838,7 @@ void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera) void LLPipeline::stateSort(LLSpatialBridge* bridge, LLCamera& camera) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT); if (/*!sShadowRender && */!sSkipUpdate && bridge->getSpatialGroup()->changeLOD()) { bool force_update = false; @@ -2844,7 +2848,7 @@ void LLPipeline::stateSort(LLSpatialBridge* bridge, LLCamera& camera) void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT); if (!drawablep || drawablep->isDead() @@ -3093,7 +3097,7 @@ void renderSoundHighlights(LLDrawable* drawablep) void LLPipeline::postSort(LLCamera& camera) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_POST_SORT); LLFastTimer ftm(FTM_STATESORT_POSTSORT); assertInitialized(); @@ -3333,6 +3337,7 @@ void LLPipeline::postSort(LLCamera& camera) void render_hud_elements() { + LLMemType mt_rhe(LLMemType::MTYPE_PIPELINE_RENDER_HUD_ELS); LLFastTimer t(FTM_RENDER_UI); gPipeline.disableLights(); @@ -3352,25 +3357,22 @@ void render_hud_elements() } LLGLDepthTest depth(GL_TRUE, GL_FALSE); - if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) + if (!LLPipeline::sReflectionRender && gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) { - if(!LLPipeline::sReflectionRender) - { - static const LLCachedControl RenderFSAASamples("RenderFSAASamples",0); - LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); - gViewerWindow->renderSelections(FALSE, FALSE, FALSE); // For HUD version in render_ui_3d() + static const LLCachedControl RenderFSAASamples("RenderFSAASamples",0); + LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); + gViewerWindow->renderSelections(FALSE, FALSE, FALSE); // For HUD version in render_ui_3d() - // Draw the tracking overlays - LLTracker::render3D(); + // Draw the tracking overlays + LLTracker::render3D(); - // Show the property lines - LLWorld::getInstance()->renderPropertyLines(); - LLViewerParcelMgr::getInstance()->render(); - LLViewerParcelMgr::getInstance()->renderParcelCollision(); + // Show the property lines + LLWorld::getInstance()->renderPropertyLines(); + LLViewerParcelMgr::getInstance()->render(); + LLViewerParcelMgr::getInstance()->renderParcelCollision(); - // Render name tags. - LLHUDObject::renderAll(); - } + // Render name tags. + LLHUDObject::renderAll(); } else if (gForceRenderLandFence) { @@ -3391,7 +3393,7 @@ void render_hud_elements() void LLPipeline::renderHighlights() { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_RENDER_HL); assertInitialized(); @@ -3456,9 +3458,10 @@ void LLPipeline::renderHighlights() //debug use U32 LLPipeline::sCurRenderPoolType = 0 ; + void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_RENDER_GEOM); LLFastTimer t(FTM_RENDER_GEOMETRY); assertInitialized(); @@ -3723,6 +3726,7 @@ void LLPipeline::renderGeom(LLCamera& camera, BOOL forceVBOUpdate) void LLPipeline::renderGeomDeferred(LLCamera& camera) { LLAppViewer::instance()->pingMainloopTimeout("Pipeline:RenderGeomDeferred"); + LLMemType mt_rgd(LLMemType::MTYPE_PIPELINE_RENDER_GEOM_DEFFERRED); LLFastTimer t(FTM_RENDER_GEOMETRY); LLFastTimer t2(FTM_POOLS); @@ -3822,6 +3826,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera) void LLPipeline::renderGeomPostDeferred(LLCamera& camera) { + LLMemType mt_rgpd(LLMemType::MTYPE_PIPELINE_RENDER_GEOM_POST_DEF); LLFastTimer t(FTM_POOLS); U32 cur_type = 0; @@ -3918,6 +3923,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera) void LLPipeline::renderGeomShadow(LLCamera& camera) { + LLMemType mt_rgs(LLMemType::MTYPE_PIPELINE_RENDER_GEOM_SHADOW); U32 cur_type = 0; LLGLEnable cull(GL_CULL_FACE); @@ -4351,7 +4357,7 @@ void LLPipeline::renderDebug() void LLPipeline::rebuildPools() { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_REBUILD_POOLS); assertInitialized(); @@ -4391,7 +4397,7 @@ void LLPipeline::rebuildPools() void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) { - LLMemType mt(LLMemType::MTYPE_PIPELINE); + LLMemType mt(LLMemType::MTYPE_PIPELINE_QUICK_LOOKUP); assertInitialized(); @@ -6000,6 +6006,7 @@ void LLPipeline::doResetVertexBuffers() void LLPipeline::renderObjects(U32 type, U32 mask, BOOL texture, BOOL batch_texture) { + LLMemType mt_ro(LLMemType::MTYPE_PIPELINE_RENDER_OBJECTS); assertInitialized(); gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; @@ -6075,6 +6082,7 @@ void LLPipeline::bindScreenToTexture() static LLFastTimer::DeclareTimer FTM_RENDER_BLOOM("Bloom"); void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, bool tiling) { + LLMemType mt_ru(LLMemType::MTYPE_PIPELINE_RENDER_BLOOM); if (!(gPipeline.canUseVertexShaders() && sRenderGlow)) { @@ -9201,6 +9209,7 @@ void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL textu void LLPipeline::generateImpostor(LLVOAvatar* avatar) { + LLMemType mt_gi(LLMemType::MTYPE_PIPELINE_GENERATE_IMPOSTOR); LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); From a0c549534f76c418fb110e2595a1237d261123ec Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 29 Jan 2012 17:10:04 -0600 Subject: [PATCH 10/36] Pulled apart LLInventoryPanel and LLInventoryView. TODO: LLInventoryView needs to be chopped apart into a floater (LLFloaterInventory) and a panel (LLPanelMainInventory). --- indra/llui/llview.cpp | 19 + indra/llui/llview.h | 4 + indra/newview/CMakeLists.txt | 6 +- indra/newview/floaterao.cpp | 3 +- indra/newview/llagentwearables.cpp | 4 +- indra/newview/llappviewer.cpp | 3 +- indra/newview/llassetuploadresponders.cpp | 3 +- indra/newview/llbuildnewviewsscheduler.h | 2 +- indra/newview/llfloateravatarpicker.cpp | 2 +- indra/newview/llfloaterbuycontents.cpp | 8 +- indra/newview/llfloatergesture.cpp | 3 +- indra/newview/llfloaterinventory.h | 37 + indra/newview/llfloaterlandmark.cpp | 2 +- indra/newview/llfloateropenobject.cpp | 4 +- indra/newview/llfloaterreporter.cpp | 2 +- indra/newview/llfolderview.cpp | 2 +- indra/newview/llimpanel.cpp | 2 +- indra/newview/llinventoryactions.cpp | 12 +- indra/newview/llinventorybridge.cpp | 3 +- indra/newview/llinventoryfunctions.cpp | 2 +- indra/newview/llinventorymodel.cpp | 3 +- .../llinventorymodelbackgroundfetch.cpp | 2 +- indra/newview/llinventorypanel.cpp | 775 ++++++++ .../{llinventoryview.h => llinventorypanel.h} | 157 +- indra/newview/llmenucommands.cpp | 3 +- indra/newview/llpanelavatar.cpp | 2 +- ...ntoryview.cpp => llpanelmaininventory.cpp} | 1556 +++++------------ indra/newview/llpanelmaininventory.h | 179 ++ indra/newview/llpreview.cpp | 2 +- indra/newview/llpreviewanim.cpp | 2 +- indra/newview/llpreviewlandmark.cpp | 5 +- indra/newview/llpreviewsound.cpp | 2 +- indra/newview/llpreviewtexture.cpp | 3 +- indra/newview/llstartup.cpp | 4 +- indra/newview/llstatusbar.cpp | 2 +- indra/newview/lltexturectrl.cpp | 2 +- indra/newview/lltoolbar.cpp | 2 +- indra/newview/lltooldraganddrop.cpp | 3 +- indra/newview/llviewerinventory.cpp | 3 +- indra/newview/llviewermenu.cpp | 3 +- indra/newview/llviewermessage.cpp | 3 +- indra/newview/llviewertexteditor.cpp | 2 +- indra/newview/llviewerwindow.cpp | 2 +- indra/newview/llvoavatar.cpp | 2 +- indra/newview/rlvhandler.cpp | 2 +- indra/newview/rlvhelper.cpp | 2 +- 46 files changed, 1514 insertions(+), 1332 deletions(-) create mode 100644 indra/newview/llfloaterinventory.h create mode 100644 indra/newview/llinventorypanel.cpp rename indra/newview/{llinventoryview.h => llinventorypanel.h} (56%) rename indra/newview/{llinventoryview.cpp => llpanelmaininventory.cpp} (60%) create mode 100644 indra/newview/llpanelmaininventory.h diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 29894db6c..61030a8f1 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -2381,6 +2381,25 @@ void LLView::registerEventListener(std::string name, LLSimpleListener* function) } +struct LLSignalListener : LLSimpleListener +{ + LLSignalListener(LLView::event_signal_t::slot_type &cb) + { + mSignal.connect(cb); + } + /*virtual*/ bool handleEvent(LLPointer event, const LLSD& userdata) + { + mSignal(event, userdata); + return true; + } + LLView::event_signal_t mSignal; +}; + +void LLView::registerEventListener(std::string name, event_signal_t::slot_type &cb) +{ + registerEventListener(name, new LLSignalListener(cb)); +} + void LLView::deregisterEventListener(std::string name) { dispatch_list_t::iterator itor = mDispatchList.find(name); diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 1ac357a1f..d69360515 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -446,6 +446,10 @@ public: LLSimpleListener* getListenerByName(const std::string& callback_name); void registerEventListener(std::string name, LLSimpleListener* function); void deregisterEventListener(std::string name); + + typedef boost::signals2::signal event, const LLSD& userdata)> event_signal_t; + void registerEventListener(std::string name, event_signal_t::slot_type &cb); + std::string findEventListener(LLSimpleListener *listener) const; void addListenerToControl(LLEventDispatcher *observer, const std::string& name, LLSD filter, LLSD userdata); diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 4e75cb535..d6e26d94c 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -298,7 +298,7 @@ set(viewer_SOURCE_FILES llinventorymodel.cpp llinventorymodelbackgroundfetch.cpp llinventoryobserver.cpp - llinventoryview.cpp + llinventorypanel.cpp lljoystickbutton.cpp lllandmarklist.cpp lllocalinventory.cpp @@ -357,6 +357,7 @@ set(viewer_SOURCE_FILES llpanellandobjects.cpp llpanellandoptions.cpp llpanellogin.cpp + llpanelmaininventory.cpp llpanelmorph.cpp llpanelmediahud.cpp llpanelmsgs.cpp @@ -776,7 +777,7 @@ set(viewer_HEADER_FILES llinventorymodel.h llinventorymodelbackgroundfetch.h llinventoryobserver.h - llinventoryview.h + llinventorypanel.h lljoystickbutton.h lllandmarklist.h lllightconstants.h @@ -837,6 +838,7 @@ set(viewer_HEADER_FILES llpanellandoptions.h llpanelLCD.h llpanellogin.h + llpanelmaininventory.h llpanelmorph.h llpanelmediahud.h llpanelmsgs.h diff --git a/indra/newview/floaterao.cpp b/indra/newview/floaterao.cpp index d15b20e92..cff0dbe23 100644 --- a/indra/newview/floaterao.cpp +++ b/indra/newview/floaterao.cpp @@ -13,7 +13,6 @@ #include "llvoavatarself.h" #include "llanimationstates.h" #include "lluictrlfactory.h" -#include "llinventoryview.h" #include "llstartup.h" #include "llpreviewnotecard.h" #include "llviewertexteditor.h" @@ -26,8 +25,8 @@ #include "llinventory.h" #include "llinventoryfunctions.h" +#include "llinventorypanel.h" #include "llinventorymodelbackgroundfetch.h" -#include "llinventoryview.h" #include "roles_constants.h" #include "llviewerregion.h" diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index 01cb1d74a..1f9a69386 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -40,7 +40,8 @@ #include "llfolderview.h" #include "llgesturemgr.h" #include "llinventorybridge.h" -#include "llinventoryview.h" +#include "llfloaterinventory.h" +#include "llinventorypanel.h" #include "llmd5.h" #include "llnotificationsutil.h" #include "lltexlayer.h" @@ -52,6 +53,7 @@ #include "cofmgr.h" #include "llfloatercustomize.h" + // [RLVa:KB] - Checked: 2010-09-27 (RLVa-1.1.3b) #include "rlvhandler.h" #include "rlvinventory.h" diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index d39f6de5d..a349c66d0 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -171,6 +171,7 @@ #include "llvovolume.h" #include "llflexibleobject.h" #include "llvosurfacepatch.h" +#include "llfloaterinventory.h" // includes for idle() idleShutdown() #include "floaterao.h" @@ -188,8 +189,6 @@ #include "llviewerthrottle.h" #include "llparcel.h" -#include "llinventoryview.h" - #include "llcommandlineparser.h" #include "llprogressview.h" diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index 9dda0221a..757252286 100644 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -47,7 +47,8 @@ #include "llfloaterbuycurrency.h" #include "llnotify.h" #include "llinventorymodel.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" +#include "llpanelmaininventory.h" #include "llpermissionsflags.h" #include "llpreviewnotecard.h" #include "llpreviewscript.h" diff --git a/indra/newview/llbuildnewviewsscheduler.h b/indra/newview/llbuildnewviewsscheduler.h index 2f819288f..83169d925 100644 --- a/indra/newview/llbuildnewviewsscheduler.h +++ b/indra/newview/llbuildnewviewsscheduler.h @@ -1,5 +1,5 @@ // -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llinventory.h" #include "lleventtimer.h" class LLBuildNewViewsScheduler : public LLEventTimer diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index 7b41bf74b..c3ac0cfa8 100644 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -39,7 +39,7 @@ #include "llbutton.h" #include "llfocusmgr.h" #include "llfoldervieweventlistener.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llinventorymodel.h" #include "llinventoryfunctions.h" #include "lllineeditor.h" diff --git a/indra/newview/llfloaterbuycontents.cpp b/indra/newview/llfloaterbuycontents.cpp index 38ed371f2..66a417dda 100644 --- a/indra/newview/llfloaterbuycontents.cpp +++ b/indra/newview/llfloaterbuycontents.cpp @@ -43,12 +43,10 @@ #include "llcachename.h" #include "llagent.h" // for agent id -#include "llalertdialog.h" #include "llcheckboxctrl.h" -#include "llinventorymodel.h" // for gInventory #include "llinventorydefines.h" -#include "llinventoryview.h" -#include "llinventoryicon.h" +#include "llinventoryfunctions.h" +#include "llinventorymodel.h" // for gInventory #include "llnotificationsutil.h" #include "llselectmgr.h" #include "llscrolllistctrl.h" @@ -284,7 +282,7 @@ void LLFloaterBuyContents::onClickBuy(void*) // We may want to wear this item if (sInstance->childGetValue("wear_check")) { - LLInventoryView::sWearNewClothing = TRUE; + LLInventoryState::sWearNewClothing = TRUE; } // Put the items where we put new folders. diff --git a/indra/newview/llfloatergesture.cpp b/indra/newview/llfloatergesture.cpp index 78d7a6b28..c2d7ac14b 100644 --- a/indra/newview/llfloatergesture.cpp +++ b/indra/newview/llfloatergesture.cpp @@ -43,8 +43,9 @@ #include "llbutton.h" #include "llcombobox.h" #include "llgesturemgr.h" +#include "llfloaterinventory.h" #include "llinventorymodel.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llkeyboard.h" #include "lllineeditor.h" #include "llpreviewgesture.h" diff --git a/indra/newview/llfloaterinventory.h b/indra/newview/llfloaterinventory.h new file mode 100644 index 000000000..c2041303d --- /dev/null +++ b/indra/newview/llfloaterinventory.h @@ -0,0 +1,37 @@ +/** + * @file llfloaterinventory.h + * @brief LLFloaterInventory, LLInventoryFolder, and LLInventoryItem + * class definition + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLFLOATERINVENTORY_H +#define LL_LLFLOATERINVENTORY_H + +#include "llpanelmaininventory.h" + + +#endif // LL_LLFLOATERINVENTORY_H + + + diff --git a/indra/newview/llfloaterlandmark.cpp b/indra/newview/llfloaterlandmark.cpp index b6dd5bd2a..42bbbe0d7 100644 --- a/indra/newview/llfloaterlandmark.cpp +++ b/indra/newview/llfloaterlandmark.cpp @@ -42,7 +42,7 @@ #include "llfoldervieweventlistener.h" #include "llinventory.h" #include "llinventoryfunctions.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llviewerinventory.h" #include "llpermissions.h" #include "llsaleinfo.h" diff --git a/indra/newview/llfloateropenobject.cpp b/indra/newview/llfloateropenobject.cpp index 7465eb94d..102856d6e 100644 --- a/indra/newview/llfloateropenobject.cpp +++ b/indra/newview/llfloateropenobject.cpp @@ -46,9 +46,10 @@ #include "llagent.h" // for agent id #include "llalertdialog.h" +#include "llfloaterinventory.h" #include "llinventorybridge.h" #include "llinventorymodel.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llpanelinventory.h" #include "llselectmgr.h" #include "lluiconstants.h" @@ -56,7 +57,6 @@ #include "lluictrlfactory.h" #include "llviewerwindow.h" - LLFloaterOpenObject* LLFloaterOpenObject::sInstance = NULL; LLFloaterOpenObject::LLFloaterOpenObject() diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp index 9dec6b49f..dccb8ab89 100644 --- a/indra/newview/llfloaterreporter.cpp +++ b/indra/newview/llfloaterreporter.cpp @@ -55,7 +55,7 @@ #include "llagent.h" #include "llbutton.h" #include "llcheckboxctrl.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "lllineeditor.h" #include "lltexturectrl.h" #include "llscrolllistctrl.h" diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index 5a6790b6d..bfe40f33c 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -35,12 +35,12 @@ #include "llfolderview.h" #include "llcallbacklist.h" +#include "llfloaterinventory.h" #include "llinventorybridge.h" #include "llinventoryclipboard.h" // *TODO: remove this once hack below gone. #include "llinventoryfilter.h" #include "llinventoryfunctions.h" #include "llinventorymodelbackgroundfetch.h" -#include "llinventoryview.h" #include "llfoldertype.h" #include "llkeyboard.h" #include "lllineeditor.h" diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp index 115476183..1bed779ff 100644 --- a/indra/newview/llimpanel.cpp +++ b/indra/newview/llimpanel.cpp @@ -52,9 +52,9 @@ #include "llfloater.h" #include "llfloatergroupinfo.h" #include "llimview.h" +#include "llfloaterinventory.h" #include "llinventory.h" #include "llinventoryfunctions.h" -#include "llinventoryview.h" #include "llfloateractivespeakers.h" #include "llfloateravatarinfo.h" #include "llfloaterchat.h" diff --git a/indra/newview/llinventoryactions.cpp b/indra/newview/llinventoryactions.cpp index 27c9dc56e..5c081054d 100644 --- a/indra/newview/llinventoryactions.cpp +++ b/indra/newview/llinventoryactions.cpp @@ -34,7 +34,7 @@ #include // for std::pair<> -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llpanelinventory.h" #include "llinventorybridge.h" @@ -56,6 +56,7 @@ #include "llfloateravatarinfo.h" #include "llfloaterchat.h" #include "llfloatercustomize.h" +#include "llfloaterinventory.h" #include "llfloaterproperties.h" #include "llfocusmgr.h" #include "llfolderview.h" @@ -257,14 +258,7 @@ class LLResetFilter : public inventory_listener_t { bool handleEvent(LLPointer event, const LLSD& userdata) { - LLInventoryViewFinder *finder = mPtr->getFinder(); - mPtr->getActivePanel()->getFilter()->resetDefault(); - if (finder) - { - finder->updateElementsFromFilter(); - } - - mPtr->setFilterTextFromFilter(); + mPtr->resetFilters(); return true; } }; diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 61418100f..ecdd0bc73 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -34,7 +34,7 @@ #include // for std::pair<> -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llinventorybridge.h" #include "llinventorydefines.h" #include "llinventoryfunctions.h" @@ -60,6 +60,7 @@ #include "llfloateravatarinfo.h" #include "llfloaterchat.h" #include "llfloatercustomize.h" +#include "llfloaterinventory.h" #include "llfloaterproperties.h" #include "llfloaterworldmap.h" diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index c4546838d..d9c508e03 100644 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -43,6 +43,7 @@ // newview includes #include "llappviewer.h" //#include "llfirstuse.h" +#include "llfloaterinventory.h" #include "llfocusmgr.h" #include "llfolderview.h" #include "llgesturemgr.h" @@ -51,7 +52,6 @@ #include "llinventorybridge.h" #include "llinventoryclipboard.h" #include "llinventorymodel.h" -#include "llinventoryview.h" #include "lllineeditor.h" #include "llmenugl.h" #include "llnotificationsutil.h" diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 5b4dab172..c85b6fa75 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -45,8 +45,9 @@ #include "llagent.h" #include "llfloater.h" +#include "llfloaterinventory.h" #include "llfocusmgr.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llviewerinventory.h" #include "llviewermessage.h" #include "llfoldertype.h" diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 5c67d5017..9be69dffb 100644 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -30,7 +30,7 @@ #include "llagent.h" #include "llappviewer.h" #include "llcallbacklist.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llinventorymodel.h" #include "llviewercontrol.h" #include "llviewerinventory.h" diff --git a/indra/newview/llinventorypanel.cpp b/indra/newview/llinventorypanel.cpp new file mode 100644 index 000000000..bc264cc1e --- /dev/null +++ b/indra/newview/llinventorypanel.cpp @@ -0,0 +1,775 @@ +/** + * @file llinventoryview.cpp + * @brief Implementation of the inventory view and associated stuff. + * + * $LicenseInfo:firstyear=2001&license=viewergpl$ + * + * Copyright (c) 2001-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" +#include "llinventorypanel.h" + +#include // for std::pair<> + +#include "llagent.h" +#include "llagentwearables.h" +#include "lluictrlfactory.h" +#include "llfloatercustomize.h" +#include "llfolderview.h" +#include "llimview.h" +#include "llinventorybridge.h" +#include "llinventoryfunctions.h" +#include "llinventorymodelbackgroundfetch.h" +#include "llviewerfoldertype.h" +#include "llvoavatarself.h" +#include "llscrollcontainer.h" +#include "llviewerassettype.h" + +#include "llsdserialize.h" + +// [RLVa:KB] +#include "rlvhandler.h" +// [/RLVa:KB] + +static LLRegisterWidget r("inventory_panel"); + + + +///---------------------------------------------------------------------------- +/// Local function declarations, constants, enums, and typedefs +///---------------------------------------------------------------------------- + + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLInventoryPanelObserver +// +// Bridge to support knowing when the inventory has changed. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +class LLInventoryPanelObserver : public LLInventoryObserver +{ +public: + LLInventoryPanelObserver(LLInventoryPanel* ip) : mIP(ip) {} + virtual ~LLInventoryPanelObserver() {} + virtual void changed(U32 mask) + { + mIP->modelChanged(mask); + } +protected: + LLInventoryPanel* mIP; +}; + + + + + +const std::string LLInventoryPanel::DEFAULT_SORT_ORDER = std::string("InventorySortOrder"); +const std::string LLInventoryPanel::RECENTITEMS_SORT_ORDER = std::string("RecentItemsSortOrder"); +const std::string LLInventoryPanel::WORNITEMS_SORT_ORDER = std::string("WornItemsSortOrder"); +const std::string LLInventoryPanel::INHERIT_SORT_ORDER = std::string(""); + +LLInventoryPanel::LLInventoryPanel(const std::string& name, + const std::string& sort_order_setting, + const LLRect& rect, + LLInventoryModel* inventory, + BOOL allow_multi_select, + LLView *parent_view) : + LLPanel(name, rect, TRUE), + mInventory(inventory), + mInventoryObserver(NULL), + mFolderRoot(NULL), + mScroller(NULL), + mAllowMultiSelect(allow_multi_select), + mSortOrderSetting(sort_order_setting) +{ + setBackgroundColor(gColors.getColor("InventoryBackgroundColor")); + setBackgroundVisible(TRUE); + setBackgroundOpaque(TRUE); +} + +BOOL LLInventoryPanel::postBuild() +{ + init_inventory_panel_actions(this); + + LLRect folder_rect(0, + 0, + getRect().getWidth(), + 0); + mFolderRoot = new LLFolderView(getName(), NULL, folder_rect, LLUUID::null, this); + mFolderRoot->setAllowMultiSelect(mAllowMultiSelect); + + // scroller + LLRect scroller_view_rect = getRect(); + scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom); + mScroller = new LLScrollableContainerView(std::string("Inventory Scroller"), + scroller_view_rect, + mFolderRoot); + mScroller->setFollowsAll(); + mScroller->setReserveScrollCorner(TRUE); + addChild(mScroller); + mFolderRoot->setScrollContainer(mScroller); + + // set up the callbacks from the inventory we're viewing, and then + // build everything. + mInventoryObserver = new LLInventoryPanelObserver(this); + mInventory->addObserver(mInventoryObserver); + rebuildViewsFor(LLUUID::null, LLInventoryObserver::ADD); + + // bit of a hack to make sure the inventory is open. + mFolderRoot->openFolder(std::string("My Inventory")); + + if (mSortOrderSetting != INHERIT_SORT_ORDER) + { + setSortOrder(gSavedSettings.getU32(mSortOrderSetting)); + } + else + { + setSortOrder(gSavedSettings.getU32(DEFAULT_SORT_ORDER)); + } + mFolderRoot->setSortOrder(mFolderRoot->getFilter()->getSortOrder()); + + + return TRUE; +} + +LLInventoryPanel::~LLInventoryPanel() +{ + if (mFolderRoot) + { + U32 sort_order = mFolderRoot->getSortOrder(); + if (mSortOrderSetting != INHERIT_SORT_ORDER) + { + gSavedSettings.setU32(mSortOrderSetting, sort_order); + } + } + + // LLView destructor will take care of the sub-views. + mInventory->removeObserver(mInventoryObserver); + delete mInventoryObserver; + mScroller = NULL; +} + +// virtual +LLXMLNodePtr LLInventoryPanel::getXML(bool save_children) const +{ + LLXMLNodePtr node = LLPanel::getXML(false); // Do not print out children + + node->setName(LL_INVENTORY_PANEL_TAG); + + node->createChild("allow_multi_select", TRUE)->setBoolValue(mFolderRoot->getAllowMultiSelect()); + + return node; +} + +LLView* LLInventoryPanel::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) +{ + LLInventoryPanel* panel; + + std::string name("inventory_panel"); + node->getAttributeString("name", name); + + BOOL allow_multi_select = TRUE; + node->getAttributeBOOL("allow_multi_select", allow_multi_select); + + LLRect rect; + createRect(node, rect, parent, LLRect()); + + std::string sort_order(INHERIT_SORT_ORDER); + node->getAttributeString("sort_order", sort_order); + + panel = new LLInventoryPanel(name, sort_order, + rect, &gInventory, + allow_multi_select, parent); + + panel->initFromXML(node, parent); + + panel->postBuild(); + + return panel; +} + +void LLInventoryPanel::draw() +{ + // select the desired item (in case it wasn't loaded when the selection was requested) + if (mSelectThisID.notNull()) + { + setSelection(mSelectThisID, false); + } + LLPanel::draw(); +} + +LLInventoryFilter* LLInventoryPanel::getFilter() +{ + if (mFolderRoot) + { + return mFolderRoot->getFilter(); + } + return NULL; +} + +const LLInventoryFilter* LLInventoryPanel::getFilter() const +{ + if (mFolderRoot) + { + return mFolderRoot->getFilter(); + } + return NULL; +} + +void LLInventoryPanel::setFilterTypes(U32 filter_types) +{ + getFilter()->setFilterTypes(filter_types); +} + +U32 LLInventoryPanel::getFilterTypes() const +{ + return mFolderRoot->getFilterTypes(); +} + +U32 LLInventoryPanel::getFilterPermMask() const +{ + return mFolderRoot->getFilterPermissions(); +} + +void LLInventoryPanel::setFilterPermMask(PermissionMask filter_perm_mask) +{ + getFilter()->setFilterPermissions(filter_perm_mask); +} + +void LLInventoryPanel::setFilterWorn(bool worn) +{ + getFilter()->setFilterWorn(worn); +} + +void LLInventoryPanel::setFilterSubString(const std::string& string) +{ + getFilter()->setFilterSubString(string); +} + +const std::string LLInventoryPanel::getFilterSubString() +{ + return mFolderRoot->getFilterSubString(); +} + +void LLInventoryPanel::setSortOrder(U32 order) +{ + getFilter()->setSortOrder(order); + if (getFilter()->isModified()) + { + mFolderRoot->setSortOrder(order); + // try to keep selection onscreen, even if it wasn't to start with + mFolderRoot->scrollToShowSelection(); + } +} + +U32 LLInventoryPanel::getSortOrder() const +{ + return mFolderRoot->getSortOrder(); +} + +void LLInventoryPanel::setSinceLogoff(BOOL sl) +{ + getFilter()->setDateRangeLastLogoff(sl); +} + +void LLInventoryPanel::setHoursAgo(U32 hours) +{ + getFilter()->setHoursAgo(hours); +} + +void LLInventoryPanel::setShowFolderState(LLInventoryFilter::EFolderShow show) +{ + getFilter()->setShowFolderState(show); +} + +LLInventoryFilter::EFolderShow LLInventoryPanel::getShowFolderState() +{ + return getFilter()->getShowFolderState(); +} + +void LLInventoryPanel::modelChanged(U32 mask) +{ + static LLFastTimer::DeclareTimer FTM_REFRESH("Inventory Refresh"); + LLFastTimer t2(FTM_REFRESH); + + bool handled = false; + + //if (!mViewsInitialized) return; + + const LLInventoryModel* model = getModel(); + if (!model) return; + + const LLInventoryModel::changed_items_t& changed_items = model->getChangedIDs(); + if (changed_items.empty()) return; + + for (LLInventoryModel::changed_items_t::const_iterator items_iter = changed_items.begin(); + items_iter != changed_items.end(); + ++items_iter) + { + const LLUUID& item_id = (*items_iter); + const LLInventoryObject* model_item = model->getObject(item_id); + LLFolderViewItem* view_item = mFolderRoot->getItemByID(item_id); + + // LLFolderViewFolder is derived from LLFolderViewItem so dynamic_cast from item + // to folder is the fast way to get a folder without searching through folders tree. + //LLFolderViewFolder* view_folder = dynamic_cast(view_item); + + ////////////////////////////// + // LABEL Operation + // Empty out the display name for relabel. + if (mask & LLInventoryObserver::LABEL) + { + handled = true; + if (view_item) + { + // Request refresh on this item (also flags for filtering) + LLInvFVBridge* bridge = (LLInvFVBridge*)view_item->getListener(); + if(bridge) + { // Clear the display name first, so it gets properly re-built during refresh() + bridge->clearDisplayName(); + + view_item->refresh(); + } + } + } + + ////////////////////////////// + // REBUILD Operation + // Destroy and regenerate the UI. + /*if (mask & LLInventoryObserver::REBUILD) + { + handled = true; + if (model_item && view_item) + { + view_item->destroyView(); + } + view_item = buildNewViews(item_id); + view_folder = dynamic_cast(view_item); + }*/ + + ////////////////////////////// + // INTERNAL Operation + // This could be anything. For now, just refresh the item. + if (mask & LLInventoryObserver::INTERNAL) + { + if (view_item) + { + view_item->refresh(); + } + } + + ////////////////////////////// + // SORT Operation + // Sort the folder. + /*if (mask & LLInventoryObserver::SORT) + { + if (view_folder) + { + view_folder->requestSort(); + } + }*/ + + // We don't typically care which of these masks the item is actually flagged with, since the masks + // may not be accurate (e.g. in the main inventory panel, I move an item from My Inventory into + // Landmarks; this is a STRUCTURE change for that panel but is an ADD change for the Landmarks + // panel). What's relevant is that the item and UI are probably out of sync and thus need to be + // resynchronized. + if (mask & (LLInventoryObserver::STRUCTURE | + LLInventoryObserver::ADD | + LLInventoryObserver::REMOVE)) + { + handled = true; + + ////////////////////////////// + // ADD Operation + // Item exists in memory but a UI element hasn't been created for it. + if (model_item && !view_item) + { + // Add the UI element for this item. + buildNewViews(item_id); + // Select any newly created object that has the auto rename at top of folder root set. + if(mFolderRoot->getRoot()->needsAutoRename()) + { + setSelection(item_id, FALSE); + } + } + + ////////////////////////////// + // STRUCTURE Operation + // This item already exists in both memory and UI. It was probably reparented. + else if (model_item && view_item) + { + // Don't process the item if it is the root + if (view_item->getRoot() != view_item) + { + LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolderRoot->getItemByID(model_item->getParentUUID()); + // Item has been moved. + if (view_item->getParentFolder() != new_parent) + { + if (new_parent != NULL) + { + // Item is to be moved and we found its new parent in the panel's directory, so move the item's UI. + view_item->getParentFolder()->extractItem(view_item); + view_item->addToFolder(new_parent, mFolderRoot); + } + else + { + // Item is to be moved outside the panel's directory (e.g. moved to trash for a panel that + // doesn't include trash). Just remove the item's UI. + view_item->destroyView(); + } + } + } + } + + ////////////////////////////// + // REMOVE Operation + // This item has been removed from memory, but its associated UI element still exists. + else if (!model_item && view_item) + { + // Remove the item's UI. + view_item->destroyView(); + } + } + } +} + +LLFolderView* LLInventoryPanel::getRootFolder() +{ + return mFolderRoot; +} +const LLUUID& LLInventoryPanel::getRootFolderID() const +{ + return mFolderRoot->getListener()->getUUID(); +} +void LLInventoryPanel::rebuildViewsFor(const LLUUID& id, U32 mask) +{ + // Destroy the old view for this ID so we can rebuild it. + LLFolderViewItem* old_view = mFolderRoot->getItemByID(id); + if (old_view && id.notNull()) + { + old_view->destroyView(); + } + + buildNewViews(id); +} + +LLFolderViewFolder * LLInventoryPanel::createFolderViewFolder(LLInvFVBridge * bridge) +{ + return new LLFolderViewFolder( + bridge->getDisplayName(), + bridge->getIcon(), + mFolderRoot, + bridge); +} + +LLFolderViewItem * LLInventoryPanel::createFolderViewItem(LLInvFVBridge * bridge) +{ + return new LLFolderViewItem( + bridge->getDisplayName(), + bridge->getIcon(), + bridge->getCreationDate(), + mFolderRoot, + bridge); +} + +void LLInventoryPanel::buildNewViews(const LLUUID& id) +{ + LLInventoryObject* const objectp = gInventory.getObject(id); + LLFolderViewItem* itemp = NULL; + + + if (objectp) + { + const LLUUID &parent_id = objectp->getParentUUID(); + LLFolderViewFolder* parent_folder = (LLFolderViewFolder*)mFolderRoot->getItemByID(parent_id); + if (objectp->getType() <= LLAssetType::AT_NONE || + objectp->getType() >= LLAssetType::AT_COUNT) + { + llwarns << "LLInventoryPanel::buildNewViews called with invalid objectp->mType : " + << ((S32) objectp->getType()) << " name " << objectp->getName() << " UUID " << objectp->getUUID() + << llendl; + } + else if ((objectp->getType() == LLAssetType::AT_CATEGORY) && + (objectp->getActualType() != LLAssetType::AT_LINK_FOLDER)) // build new view for category + { + LLInvFVBridge* new_listener = LLInvFVBridge::createBridge(objectp->getType(), + objectp->getType(), + LLInventoryType::IT_CATEGORY, + this, + objectp->getUUID()); + + if (new_listener) + { + LLFolderViewFolder* folderp = createFolderViewFolder(new_listener); + if (folderp) + { + folderp->setItemSortOrder(mFolderRoot->getSortOrder()); + } + itemp = folderp; + } + } + else // build new view for item + { + LLInventoryItem* item = (LLInventoryItem*)objectp; + LLInvFVBridge* new_listener = LLInvFVBridge::createBridge( + item->getType(), + item->getActualType(), + item->getInventoryType(), + this, + item->getUUID(), + item->getFlags()); + if (new_listener) + { + itemp = createFolderViewItem(new_listener); + } + } + + + + if (itemp) + { + if (parent_folder) + { + itemp->addToFolder(parent_folder, mFolderRoot); + } + else + { + llwarns << "Couldn't find parent folder for child " << itemp->getLabel() << llendl; + delete itemp; + } + } + } + + // If this is a folder, add the children of the folder and recursively add any + // child folders. + if (id.isNull() + || (objectp + && objectp->getType() == LLAssetType::AT_CATEGORY)) + { + LLViewerInventoryCategory::cat_array_t* categories; + LLViewerInventoryItem::item_array_t* items; + mInventory->lockDirectDescendentArrays(id, categories, items); + + if(categories) + { + for (LLViewerInventoryCategory::cat_array_t::const_iterator cat_iter = categories->begin(); + cat_iter != categories->end(); + ++cat_iter) + { + const LLViewerInventoryCategory* cat = (*cat_iter); + buildNewViews(cat->getUUID()); + } + } + + if(items) + { + for (LLViewerInventoryItem::item_array_t::const_iterator item_iter = items->begin(); + item_iter != items->end(); + ++item_iter) + { + const LLViewerInventoryItem* item = (*item_iter); + buildNewViews(item->getUUID()); + } + } + mInventory->unlockDirectDescendentArrays(id); + } +} + +struct LLConfirmPurgeData +{ + LLUUID mID; + LLInventoryModel* mModel; +}; + +class LLIsNotWorn : public LLInventoryCollectFunctor +{ +public: + LLIsNotWorn() {} + virtual ~LLIsNotWorn() {} + virtual bool operator()(LLInventoryCategory* cat, + LLInventoryItem* item) + { + return !gAgentWearables.isWearingItem(item->getUUID()); + } +}; + +class LLOpenFolderByID : public LLFolderViewFunctor +{ +public: + LLOpenFolderByID(const LLUUID& id) : mID(id) {} + virtual ~LLOpenFolderByID() {} + virtual void doFolder(LLFolderViewFolder* folder) + { + if (folder->getListener() && folder->getListener()->getUUID() == mID) folder->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_UP); + } + virtual void doItem(LLFolderViewItem* item) {} +protected: + const LLUUID& mID; +}; + + +void LLInventoryPanel::openSelected() +{ + LLFolderViewItem* folder_item = mFolderRoot->getCurSelectedItem(); + if(!folder_item) return; + LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getListener(); + if(!bridge) return; + bridge->openItem(); +} + +void LLInventoryPanel::unSelectAll() +{ + mFolderRoot->setSelection(NULL, FALSE, FALSE); +} + + +BOOL LLInventoryPanel::handleHover(S32 x, S32 y, MASK mask) +{ + BOOL handled = LLView::handleHover(x, y, mask); + if(handled) + { + ECursorType cursor = getWindow()->getCursor(); + if (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() && cursor == UI_CURSOR_ARROW) + { + // replace arrow cursor with arrow and hourglass cursor + getWindow()->setCursor(UI_CURSOR_WORKING); + } + } + else + { + getWindow()->setCursor(UI_CURSOR_ARROW); + } + return TRUE; +} + +BOOL LLInventoryPanel::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg) +{ + + BOOL handled = LLPanel::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); + + if (handled) + { + mFolderRoot->setDragAndDropThisFrame(); + } + + return handled; +} + + +void LLInventoryPanel::openAllFolders() +{ + mFolderRoot->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_DOWN); + mFolderRoot->arrangeAll(); +} + +void LLInventoryPanel::closeAllFolders() +{ + mFolderRoot->setOpenArrangeRecursively(FALSE, LLFolderViewFolder::RECURSE_DOWN); + mFolderRoot->arrangeAll(); +} + +void LLInventoryPanel::openDefaultFolderForType(LLAssetType::EType type) +{ + LLUUID category_id = mInventory->findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(type)); + LLOpenFolderByID opener(category_id); + mFolderRoot->applyFunctorRecursively(opener); +} + +void LLInventoryPanel::setSelection(const LLUUID& obj_id, BOOL take_keyboard_focus) +{ + LLFolderViewItem* itemp = mFolderRoot->getItemByID(obj_id); + if(itemp && itemp->getListener()) + { + itemp->getListener()->arrangeAndSet(itemp, TRUE, take_keyboard_focus); + mSelectThisID.setNull(); + return; + } + else + { + // save the desired item to be selected later (if/when ready) + mSelectThisID = obj_id; + } +} +void LLInventoryPanel::setSelectCallback(LLFolderView::SelectCallback callback, void* user_data) +{ + if (mFolderRoot) + { + mFolderRoot->setSelectCallback(callback, user_data); + } +} +void LLInventoryPanel::clearSelection() +{ + mFolderRoot->clearSelection(); + mSelectThisID.setNull(); +} + +void LLInventoryPanel::createNewItem(const std::string& name, + const LLUUID& parent_id, + LLAssetType::EType asset_type, + LLInventoryType::EType inv_type, + U32 next_owner_perm) +{ + std::string desc; + LLViewerAssetType::generateDescriptionFor(asset_type, desc); + next_owner_perm = (next_owner_perm) ? next_owner_perm : PERM_MOVE | PERM_TRANSFER; + + + if (inv_type == LLInventoryType::IT_GESTURE) + { + LLPointer cb = new CreateGestureCallback(); + create_inventory_item(gAgent.getID(), gAgent.getSessionID(), + parent_id, LLTransactionID::tnull, name, desc, asset_type, inv_type, + NOT_WEARABLE, next_owner_perm, cb); + } + else + { + LLPointer cb = NULL; + create_inventory_item(gAgent.getID(), gAgent.getSessionID(), + parent_id, LLTransactionID::tnull, name, desc, asset_type, inv_type, + NOT_WEARABLE, next_owner_perm, cb); + } + +} + +BOOL LLInventoryPanel::getSinceLogoff() +{ + return getFilter()->isSinceLogoff(); +} + +// DEBUG ONLY +// static +void LLInventoryPanel::dumpSelectionInformation(void* user_data) +{ + LLInventoryPanel* iv = (LLInventoryPanel*)user_data; + iv->mFolderRoot->dumpSelectionInformation(); +} diff --git a/indra/newview/llinventoryview.h b/indra/newview/llinventorypanel.h similarity index 56% rename from indra/newview/llinventoryview.h rename to indra/newview/llinventorypanel.h index acba7d7f1..3a26926e4 100644 --- a/indra/newview/llinventoryview.h +++ b/indra/newview/llinventorypanel.h @@ -31,8 +31,8 @@ * $/LicenseInfo$ */ -#ifndef LL_LLINVENTORYVIEW_H -#define LL_LLINVENTORYVIEW_H +#ifndef LL_LLINVENTORYPANEL_H +#define LL_LLINVENTORYPANEL_H #include "llassetstorage.h" #include "lldarray.h" @@ -178,159 +178,8 @@ protected: class LLInventoryView; -class LLInventoryViewFinder : public LLFloater -{ -public: - LLInventoryViewFinder(const std::string& name, - const LLRect& rect, - LLInventoryView* inventory_view); - virtual void draw(); - virtual void onClose(bool app_quitting); - void changeFilter(LLInventoryFilter* filter); - void updateElementsFromFilter(); - BOOL getCheckShowEmpty(); - BOOL getCheckSinceLogoff(); - - static void onTimeAgo(LLUICtrl*, void *); - static void onCheckSinceLogoff(LLUICtrl*, void *); - static void onCloseBtn(void* user_data); - static void selectAllTypes(void* user_data); - static void selectNoTypes(void* user_data); - -protected: - LLInventoryView* mInventoryView; - LLSpinCtrl* mSpinSinceDays; - LLSpinCtrl* mSpinSinceHours; - LLInventoryFilter* mFilter; -}; - -class LLInventoryView : public LLFloater, LLInventoryObserver -{ -friend class LLInventoryViewFinder; - -public: - LLInventoryView(const std::string& name, const std::string& rect, - LLInventoryModel* inventory); - LLInventoryView(const std::string& name, const LLRect& rect, - LLInventoryModel* inventory); - ~LLInventoryView(); - - /*virtual*/ void changed(U32 mask); - - BOOL postBuild(); - - // - // Misc functions - // - void setFilterTextFromFilter() { mFilterText = mActivePanel->getFilter()->getFilterText(); } - void startSearch(); - // This method makes sure that an inventory view exists, is - // visible, and has focus. The view chosen is returned. - static LLInventoryView* showAgentInventory(BOOL take_keyboard_focus = FALSE); - - // Return the active inventory view if there is one. Active is - // defined as the inventory that is the closest to the front, and - // is visible. - static LLInventoryView* getActiveInventory(); - - // This method calls showAgentInventory() if no views are visible, - // or hides/destroyes them all if any are visible. - static void toggleVisibility(); - static void toggleVisibility(void*) { toggleVisibility(); } - -// [RLVa:KB] - Checked: 2009-07-10 (RLVa-1.0.0g) - static void closeAll() - { - // If there are mulitple inventory floaters open then clicking the "Inventory" button will close - // them one by one (see LLToolBar::onClickInventory() => toggleVisibility() ) until we get to the - // last one which will just be hidden instead of closed/destroyed (see LLInventoryView::onClose) - // - // However the view isn't removed from sActiveViews until its destructor is called and since - // 'LLMortician::sDestroyImmediate == FALSE' while the viewer is running the destructor won't be - // called right away - // - // Result: we can't call close() on the last (sActiveViews.count() will still be > 1) because - // onClose() would take the wrong branch and destroy() it as well - // - // Workaround: "fix" onClose() to count only views that aren't marked as "dead" - - LLInventoryView* pView; U8 flagsSound; - for (S32 idx = sActiveViews.count() - 1; idx >= 0; idx--) - { - pView = sActiveViews.get(idx); - flagsSound = pView->getSoundFlags(); - pView->setSoundFlags(LLView::SILENT); // Suppress the window close sound - pView->close(); // onClose() protects against closing the last inventory floater - pView->setSoundFlags(flagsSound); // One view won't be destroy()'ed so it needs its sound flags restored - } - } -// [/RLVa:KB] - - // Final cleanup, destroy all open inventory views. - static void cleanup(); - - // LLView & LLFloater functionality - virtual void onClose(bool app_quitting); - virtual void setVisible(BOOL visible); - virtual void draw(); - virtual BOOL handleKeyHere(KEY key, MASK mask); - - BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, - EDragAndDropType cargo_type, - void* cargo_data, - EAcceptance* accept, - std::string& tooltip_msg); - LLInventoryPanel* getPanel() { return mActivePanel; } - LLInventoryPanel* getActivePanel() { return mActivePanel; } - - static BOOL filtersVisible(void* user_data); - static void onClearSearch(void* user_data); - static void onFoldersByName(void *user_data); - static BOOL checkFoldersByName(void *user_data); - static void onSearchEdit(const std::string& search_string, void* user_data ); - - static void onQuickFilterCommit(LLUICtrl* ctrl, void* user_data); - static void refreshQuickFilter(LLUICtrl* ctrl); - - static void onFilterSelected(void* userdata, bool from_click); - static void onResetAll(void* userdata); - static void onExpandAll(void* userdata); - static void onCollapseAll(void* userdata); - static void onSelectionChange(const std::deque &items, BOOL user_action, void* data); - - const std::string getFilterSubString() { return mActivePanel->getFilterSubString(); } - void setFilterSubString(const std::string& string) { mActivePanel->setFilterSubString(string); } - - // HACK: Until we can route this info through the instant message hierarchy - static BOOL sWearNewClothing; - static LLUUID sWearNewClothingTransactionID; // wear all clothing in this transaction - - void toggleFindOptions(); - void updateSortControls(); - - LLInventoryViewFinder* getFinder() { return (LLInventoryViewFinder*)mFinderHandle.get(); } - -protected: - // internal initialization code - void init(LLInventoryModel* inventory); - -protected: - LLSearchEditor* mSearchEditor; - LLComboBox* mQuickFilterCombo; - LLTabContainer* mFilterTabs; - LLHandle mFinderHandle; - LLInventoryPanel* mActivePanel; - LLSaveFolderState* mSavedFolderState; - - std::string mFilterText; - - - // This container is used to hold all active inventory views. This - // is here to support the inventory toggle show button. - static LLDynamicArray sActiveViews; -}; ///---------------------------------------------------------------------------- /// Function declarations, constants, enums, and typedefs @@ -358,7 +207,7 @@ void open_texture(const LLUUID& item_id, const std::string& title, BOOL show_kee const BOOL TAKE_FOCUS_YES = TRUE; const BOOL TAKE_FOCUS_NO = FALSE; -#endif // LL_LLINVENTORYVIEW_H +#endif // LL_LLINVENTORYPANEL_H diff --git a/indra/newview/llmenucommands.cpp b/indra/newview/llmenucommands.cpp index 87867ddfd..acc23f599 100644 --- a/indra/newview/llmenucommands.cpp +++ b/indra/newview/llmenucommands.cpp @@ -49,10 +49,11 @@ #include "llfirstuse.h" #include "llfloaterchat.h" #include "llfloaterdirectory.h" +#include "llfloaterinventory.h" #include "llfloatermap.h" #include "llfloaterworldmap.h" #include "llgivemoney.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llnotify.h" #include "llstatusbar.h" #include "llimview.h" diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index d2b3c76cc..590d6da0a 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -53,11 +53,11 @@ #include "llfloaterfriends.h" #include "llfloatergroupinfo.h" #include "llfloatergroups.h" +#include "llfloaterinventory.h" #include "llfloaterworldmap.h" #include "llfloatermute.h" #include "llfloateravatarinfo.h" #include "lliconctrl.h" -#include "llinventoryview.h" #include "lllineeditor.h" #include "llnameeditor.h" #include "llmutelist.h" diff --git a/indra/newview/llinventoryview.cpp b/indra/newview/llpanelmaininventory.cpp similarity index 60% rename from indra/newview/llinventoryview.cpp rename to indra/newview/llpanelmaininventory.cpp index a373a4697..161b3da28 100644 --- a/indra/newview/llinventoryview.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -1,433 +1,87 @@ /** - * @file llinventoryview.cpp - * @brief Implementation of the inventory view and associated stuff. + * @file llpanelmaininventory.cpp + * @brief Implementation of llpanelmaininventory. * - * $LicenseInfo:firstyear=2001&license=viewergpl$ - * - * Copyright (c) 2001-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * 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. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * 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. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * 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 // for std::pair<> - -#include "llinventoryview.h" -#include "llinventorybridge.h" -#include "llinventorydefines.h" - -#include "message.h" +#include "llpanelmaininventory.h" #include "llagent.h" #include "llagentcamera.h" -#include "llcallingcard.h" -#include "llcheckboxctrl.h" // for radio buttons -#include "llradiogroup.h" -#include "llspinctrl.h" -#include "lltextbox.h" -#include "llui.h" - -#include "llfirstuse.h" -#include "llfloateravatarinfo.h" -#include "llfloaterchat.h" -#include "llfloatercustomize.h" -#include "llfocusmgr.h" -#include "llfolderview.h" -#include "llgesturemgr.h" -#include "lliconctrl.h" +#include "lleconomy.h" +#include "llinventorybridge.h" #include "llinventoryfunctions.h" -#include "llinventoryclipboard.h" #include "llinventorymodelbackgroundfetch.h" -#include "lllineeditor.h" -#include "llmenugl.h" -#include "llpreviewanim.h" -#include "llpreviewgesture.h" -#include "llpreviewlandmark.h" -#include "llpreviewnotecard.h" -#include "llpreviewscript.h" -#include "llpreviewsound.h" +#include "llinventorypanel.h" #include "llpreviewtexture.h" #include "llresmgr.h" #include "llscrollcontainer.h" -#include "llscrollbar.h" -#include "llimview.h" -#include "lltooldraganddrop.h" -#include "llviewertexturelist.h" -#include "llviewerinventory.h" -#include "llviewerassettype.h" -#include "llviewerobjectlist.h" -#include "llviewerwindow.h" -#include "llwearablelist.h" -#include "llappviewer.h" -#include "llviewermessage.h" -#include "llviewerregion.h" -#include "lltabcontainer.h" -#include "lluictrlfactory.h" -#include "llselectmgr.h" - #include "llsdserialize.h" +#include "llspinctrl.h" +#include "lltooldraganddrop.h" +#include "llviewermenu.h" +#include "llviewertexturelist.h" +#include "llpanelinventory.h" +#include "llappviewer.h" -// [RLVa:KB] #include "rlvhandler.h" -// [/RLVa:KB] -static LLRegisterWidget r("inventory_panel"); +const std::string FILTERS_FILENAME("filters.xml"); LLDynamicArray LLInventoryView::sActiveViews; - -//BOOL LLInventoryView::sOpenNextNewItem = FALSE; -BOOL LLInventoryView::sWearNewClothing = FALSE; -LLUUID LLInventoryView::sWearNewClothingTransactionID; - -///---------------------------------------------------------------------------- -/// Local function declarations, constants, enums, and typedefs -///---------------------------------------------------------------------------- - const S32 INV_MIN_WIDTH = 240; const S32 INV_MIN_HEIGHT = 150; const S32 INV_FINDER_WIDTH = 160; const S32 INV_FINDER_HEIGHT = 408; -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Class LLInventoryPanelObserver -// -// Bridge to support knowing when the inventory has changed. -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -class LLInventoryPanelObserver : public LLInventoryObserver +//BOOL LLInventoryView::sOpenNextNewItem = FALSE; +class LLInventoryViewFinder : public LLFloater { public: - LLInventoryPanelObserver(LLInventoryPanel* ip) : mIP(ip) {} - virtual ~LLInventoryPanelObserver() {} - virtual void changed(U32 mask) - { - mIP->modelChanged(mask); - } -protected: - LLInventoryPanel* mIP; -}; - -///---------------------------------------------------------------------------- -/// LLInventoryViewFinder -///---------------------------------------------------------------------------- - -LLInventoryViewFinder::LLInventoryViewFinder(const std::string& name, + LLInventoryViewFinder(const std::string& name, const LLRect& rect, - LLInventoryView* inventory_view) : - LLFloater(name, rect, std::string("Filters"), RESIZE_NO, - INV_FINDER_WIDTH, INV_FINDER_HEIGHT, DRAG_ON_TOP, - MINIMIZE_NO, CLOSE_YES), - mInventoryView(inventory_view), - mFilter(inventory_view->mActivePanel->getFilter()) -{ + LLInventoryView* inventory_view); + virtual void draw(); + /*virtual*/ BOOL postBuild(); + virtual void onClose(bool app_quitting); + void changeFilter(LLInventoryFilter* filter); + void updateElementsFromFilter(); + BOOL getCheckShowEmpty(); + BOOL getCheckSinceLogoff(); - LLUICtrlFactory::getInstance()->buildFloater(this, "floater_inventory_view_finder.xml"); + static void onTimeAgo(LLUICtrl*, void *); + static void onCheckSinceLogoff(LLUICtrl*, void *); + static void onCloseBtn(void* user_data); + static void selectAllTypes(void* user_data); + static void selectNoTypes(void* user_data); - childSetAction("All", selectAllTypes, this); - childSetAction("None", selectNoTypes, this); - - mSpinSinceHours = getChild("spin_hours_ago"); - childSetCommitCallback("spin_hours_ago", onTimeAgo, this); - - mSpinSinceDays = getChild("spin_days_ago"); - childSetCommitCallback("spin_days_ago", onTimeAgo, this); - -// mCheckSinceLogoff = getChild("check_since_logoff"); - childSetCommitCallback("check_since_logoff", onCheckSinceLogoff, this); - - childSetAction("Close", onCloseBtn, this); - - updateElementsFromFilter(); -} - - -void LLInventoryViewFinder::onCheckSinceLogoff(LLUICtrl *ctrl, void *user_data) -{ - LLInventoryViewFinder *self = (LLInventoryViewFinder *)user_data; - if (!self) return; - - bool since_logoff= self->childGetValue("check_since_logoff"); - - if (!since_logoff && - !( self->mSpinSinceDays->get() || self->mSpinSinceHours->get() ) ) - { - self->mSpinSinceHours->set(1.0f); - } -} - -void LLInventoryViewFinder::onTimeAgo(LLUICtrl *ctrl, void *user_data) -{ - LLInventoryViewFinder *self = (LLInventoryViewFinder *)user_data; - if (!self) return; - - bool since_logoff=true; - if ( self->mSpinSinceDays->get() || self->mSpinSinceHours->get() ) - { - since_logoff = false; - } - self->childSetValue("check_since_logoff", since_logoff); -} - -void LLInventoryViewFinder::changeFilter(LLInventoryFilter* filter) -{ - mFilter = filter; - updateElementsFromFilter(); -} - -void LLInventoryViewFinder::updateElementsFromFilter() -{ - if (!mFilter) - return; - - // Get data needed for filter display - U32 filter_types = mFilter->getFilterTypes(); - std::string filter_string = mFilter->getFilterSubString(); - LLInventoryFilter::EFolderShow show_folders = mFilter->getShowFolderState(); - U32 hours = mFilter->getHoursAgo(); - - // update the ui elements - LLFloater::setTitle(mFilter->getName()); - childSetValue("check_animation", (S32) (filter_types & 0x1 << LLInventoryType::IT_ANIMATION)); - - childSetValue("check_calling_card", (S32) (filter_types & 0x1 << LLInventoryType::IT_CALLINGCARD)); - childSetValue("check_clothing", (S32) (filter_types & 0x1 << LLInventoryType::IT_WEARABLE)); - childSetValue("check_gesture", (S32) (filter_types & 0x1 << LLInventoryType::IT_GESTURE)); - childSetValue("check_landmark", (S32) (filter_types & 0x1 << LLInventoryType::IT_LANDMARK)); - childSetValue("check_notecard", (S32) (filter_types & 0x1 << LLInventoryType::IT_NOTECARD)); - childSetValue("check_object", (S32) (filter_types & 0x1 << LLInventoryType::IT_OBJECT)); - childSetValue("check_script", (S32) (filter_types & 0x1 << LLInventoryType::IT_LSL)); - childSetValue("check_sound", (S32) (filter_types & 0x1 << LLInventoryType::IT_SOUND)); - childSetValue("check_texture", (S32) (filter_types & 0x1 << LLInventoryType::IT_TEXTURE)); - childSetValue("check_snapshot", (S32) (filter_types & 0x1 << LLInventoryType::IT_SNAPSHOT)); - childSetValue("check_show_empty", show_folders == LLInventoryFilter::SHOW_ALL_FOLDERS); - childSetValue("check_since_logoff", mFilter->isSinceLogoff()); - mSpinSinceHours->set((F32)(hours % 24)); - mSpinSinceDays->set((F32)(hours / 24)); -} - -void LLInventoryViewFinder::draw() -{ - U32 filter = 0xffffffff; - BOOL filtered_by_all_types = TRUE; - - if (!childGetValue("check_animation")) - { - filter &= ~(0x1 << LLInventoryType::IT_ANIMATION); - filtered_by_all_types = FALSE; - } - - - if (!childGetValue("check_calling_card")) - { - filter &= ~(0x1 << LLInventoryType::IT_CALLINGCARD); - filtered_by_all_types = FALSE; - } - - if (!childGetValue("check_clothing")) - { - filter &= ~(0x1 << LLInventoryType::IT_WEARABLE); - filtered_by_all_types = FALSE; - } - - if (!childGetValue("check_gesture")) - { - filter &= ~(0x1 << LLInventoryType::IT_GESTURE); - filtered_by_all_types = FALSE; - } - - if (!childGetValue("check_landmark")) - - - { - filter &= ~(0x1 << LLInventoryType::IT_LANDMARK); - filtered_by_all_types = FALSE; - } - - if (!childGetValue("check_notecard")) - { - filter &= ~(0x1 << LLInventoryType::IT_NOTECARD); - filtered_by_all_types = FALSE; - } - - if (!childGetValue("check_object")) - { - filter &= ~(0x1 << LLInventoryType::IT_OBJECT); - filter &= ~(0x1 << LLInventoryType::IT_ATTACHMENT); - filtered_by_all_types = FALSE; - } - - if (!childGetValue("check_script")) - { - filter &= ~(0x1 << LLInventoryType::IT_LSL); - filtered_by_all_types = FALSE; - } - - if (!childGetValue("check_sound")) - { - filter &= ~(0x1 << LLInventoryType::IT_SOUND); - filtered_by_all_types = FALSE; - } - - if (!childGetValue("check_texture")) - { - filter &= ~(0x1 << LLInventoryType::IT_TEXTURE); - filtered_by_all_types = FALSE; - } - - if (!childGetValue("check_snapshot")) - { - filter &= ~(0x1 << LLInventoryType::IT_SNAPSHOT); - filtered_by_all_types = FALSE; - } - - if (!filtered_by_all_types) - { - // don't include folders in filter, unless I've selected everything - filter &= ~(0x1 << LLInventoryType::IT_CATEGORY); - } - - // update the panel, panel will update the filter - mInventoryView->mActivePanel->setShowFolderState(getCheckShowEmpty() ? - LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); - mInventoryView->mActivePanel->setFilterTypes(filter); - if (getCheckSinceLogoff()) - { - mSpinSinceDays->set(0); - mSpinSinceHours->set(0); - } - U32 days = (U32)mSpinSinceDays->get(); - U32 hours = (U32)mSpinSinceHours->get(); - if (hours > 24) - { - days += hours / 24; - hours = (U32)hours % 24; - mSpinSinceDays->set((F32)days); - mSpinSinceHours->set((F32)hours); - } - hours += days * 24; - mInventoryView->mActivePanel->setHoursAgo(hours); - mInventoryView->mActivePanel->setSinceLogoff(getCheckSinceLogoff()); - mInventoryView->setFilterTextFromFilter(); - - LLFloater::draw(); -} - -void LLInventoryViewFinder::onClose(bool app_quitting) -{ - if (mInventoryView) mInventoryView->getControl("Inventory.ShowFilters")->setValue(FALSE); - // If you want to reset the filter on close, do it here. This functionality was - // hotly debated - Paulm -#if 0 - if (mInventoryView) - { - LLInventoryView::onResetFilter((void *)mInventoryView); - } -#endif - destroy(); -} - - -BOOL LLInventoryViewFinder::getCheckShowEmpty() -{ - return childGetValue("check_show_empty"); -} - -BOOL LLInventoryViewFinder::getCheckSinceLogoff() -{ - return childGetValue("check_since_logoff"); -} - -void LLInventoryViewFinder::onCloseBtn(void* user_data) -{ - LLInventoryViewFinder* finderp = (LLInventoryViewFinder*)user_data; - finderp->close(); -} - -// static -void LLInventoryViewFinder::selectAllTypes(void* user_data) -{ - LLInventoryViewFinder* self = (LLInventoryViewFinder*)user_data; - if(!self) return; - - self->childSetValue("check_animation", TRUE); - self->childSetValue("check_calling_card", TRUE); - self->childSetValue("check_clothing", TRUE); - self->childSetValue("check_gesture", TRUE); - self->childSetValue("check_landmark", TRUE); - self->childSetValue("check_notecard", TRUE); - self->childSetValue("check_object", TRUE); - self->childSetValue("check_script", TRUE); - self->childSetValue("check_sound", TRUE); - self->childSetValue("check_texture", TRUE); - self->childSetValue("check_snapshot", TRUE); - -/* - self->mCheckCallingCard->set(TRUE); - self->mCheckClothing->set(TRUE); - self->mCheckGesture->set(TRUE); - self->mCheckLandmark->set(TRUE); - self->mCheckNotecard->set(TRUE); - self->mCheckObject->set(TRUE); - self->mCheckScript->set(TRUE); - self->mCheckSound->set(TRUE); - self->mCheckTexture->set(TRUE); - self->mCheckSnapshot->set(TRUE);*/ -} - -//static -void LLInventoryViewFinder::selectNoTypes(void* user_data) -{ - LLInventoryViewFinder* self = (LLInventoryViewFinder*)user_data; - if(!self) return; - - /* - self->childSetValue("check_animation", FALSE); - self->mCheckCallingCard->set(FALSE); - self->mCheckClothing->set(FALSE); - self->mCheckGesture->set(FALSE); - self->mCheckLandmark->set(FALSE); - self->mCheckNotecard->set(FALSE); - self->mCheckObject->set(FALSE); - self->mCheckScript->set(FALSE); - self->mCheckSound->set(FALSE); - self->mCheckTexture->set(FALSE); - self->mCheckSnapshot->set(FALSE);*/ - - - self->childSetValue("check_animation", FALSE); - self->childSetValue("check_calling_card", FALSE); - self->childSetValue("check_clothing", FALSE); - self->childSetValue("check_gesture", FALSE); - self->childSetValue("check_landmark", FALSE); - self->childSetValue("check_notecard", FALSE); - self->childSetValue("check_object", FALSE); - self->childSetValue("check_script", FALSE); - self->childSetValue("check_sound", FALSE); - self->childSetValue("check_texture", FALSE); - self->childSetValue("check_snapshot", FALSE); -} +protected: + LLInventoryView* mInventoryView; + LLSpinCtrl* mSpinSinceDays; + LLSpinCtrl* mSpinSinceHours; + LLInventoryFilter* mFilter; +}; ///---------------------------------------------------------------------------- @@ -481,7 +135,12 @@ void LLInventoryView::init(LLInventoryModel* inventory) mSavedFolderState->setApply(FALSE); LLUICtrlFactory::getInstance()->buildFloater(this, "floater_inventory.xml", NULL); +} +BOOL LLInventoryView::postBuild() +{ + gInventory.addObserver(this); + mFilterTabs = (LLTabContainer*)getChild("inventory filter tabs"); // Set up the default inv. panel/filter settings. @@ -515,8 +174,8 @@ void LLInventoryView::init(LLInventoryModel* inventory) // Now load the stored settings from disk, if available. std::ostringstream filterSaveName; - filterSaveName << gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "filters.xml"); - llinfos << "LLInventoryView::init: reading from " << filterSaveName << llendl; + filterSaveName << gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, FILTERS_FILENAME); + llinfos << "LLInventoryView::init: reading from " << filterSaveName.str() << llendl; llifstream file(filterSaveName.str()); LLSD savedFilterState; if (file.is_open()) @@ -554,11 +213,6 @@ void LLInventoryView::init(LLInventoryModel* inventory) sActiveViews.put(this); - gInventory.addObserver(this); -} - -BOOL LLInventoryView::postBuild() -{ childSetTabChangeCallback("inventory filter tabs", "All Items", onFilterSelected, this); childSetTabChangeCallback("inventory filter tabs", "Recent Items", onFilterSelected, this); childSetTabChangeCallback("inventory filter tabs", "Worn Items", onFilterSelected, this); @@ -580,27 +234,36 @@ LLInventoryView::~LLInventoryView( void ) if (all_items_panel) { LLInventoryFilter* filter = all_items_panel->getFilter(); - LLSD filterState; - filter->toLLSD(filterState); - filterRoot[filter->getName()] = filterState; + if (filter) + { + LLSD filterState; + filter->toLLSD(filterState); + filterRoot[filter->getName()] = filterState; + } } LLInventoryPanel* recent_items_panel = getChild("Recent Items"); if (recent_items_panel) { LLInventoryFilter* filter = recent_items_panel->getFilter(); - LLSD filterState; - filter->toLLSD(filterState); - filterRoot[filter->getName()] = filterState; + if (filter) + { + LLSD filterState; + filter->toLLSD(filterState); + filterRoot[filter->getName()] = filterState; + } } LLInventoryPanel* worn_items_panel = getChild("Worn Items"); if (worn_items_panel) { LLInventoryFilter* filter = worn_items_panel->getFilter(); - LLSD filterState; - filter->toLLSD(filterState); - filterRoot[filter->getName()] = filterState; + if (filter) + { + LLSD filterState; + filter->toLLSD(filterState); + filterRoot[filter->getName()] = filterState; + } } std::ostringstream filterSaveName; @@ -618,32 +281,6 @@ LLInventoryView::~LLInventoryView( void ) delete mSavedFolderState; } -void LLInventoryView::draw() -{ - if (LLInventoryModelBackgroundFetch::instance().isEverythingFetched()) - { - LLLocale locale(LLLocale::USER_LOCALE); - std::ostringstream title; - title << "Inventory"; - std::string item_count_string; - LLResMgr::getInstance()->getIntegerString(item_count_string, gInventory.getItemCount()); - title << " (" << item_count_string << " items)"; - title << mFilterText; - setTitle(title.str()); - } - if (mActivePanel && mSearchEditor) - { - mSearchEditor->setText(mActivePanel->getFilterSubString()); - } - - if (mActivePanel && mQuickFilterCombo) - { - refreshQuickFilter( mQuickFilterCombo ); - } - - LLFloater::draw(); -} - void LLInventoryView::startSearch() { // this forces focus to line editor portion of search editor @@ -726,21 +363,7 @@ BOOL LLInventoryView::handleKeyHere(KEY key, MASK mask) } -void LLInventoryView::changed(U32 mask) -{ - std::ostringstream title; - title << "Inventory"; - if (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive()) - { - LLLocale locale(LLLocale::USER_LOCALE); - std::string item_count_string; - LLResMgr::getInstance()->getIntegerString(item_count_string, gInventory.getItemCount()); - title << " (Fetched " << item_count_string << " items...)"; - } - title << mFilterText; - setTitle(title.str()); -} // static // *TODO: remove take_keyboard_focus param @@ -858,30 +481,6 @@ void LLInventoryView::cleanup() } } -void LLInventoryView::toggleFindOptions() -{ - LLFloater *floater = getFinder(); - if (!floater) - { - LLInventoryViewFinder * finder = new LLInventoryViewFinder(std::string("Inventory Finder"), - LLRect(getRect().mLeft - INV_FINDER_WIDTH, getRect().mTop, getRect().mLeft, getRect().mTop - INV_FINDER_HEIGHT), - this); - mFinderHandle = finder->getHandle(); - finder->open(); /*Flawfinder: ignore*/ - addDependentFloater(mFinderHandle); - - // start background fetch of folders - LLInventoryModelBackgroundFetch::instance().start(); - - mFloaterControls[std::string("Inventory.ShowFilters")]->setValue(TRUE); - } - else - { - floater->close(); - - mFloaterControls[std::string("Inventory.ShowFilters")]->setValue(FALSE); - } -} void LLInventoryView::updateSortControls() { @@ -896,6 +495,18 @@ void LLInventoryView::updateSortControls() getControl("Inventory.SystemFoldersToTop")->setValue(sys_folders_on_top); } +void LLInventoryView::resetFilters() +{ + LLInventoryViewFinder *finder = getFinder(); + getActivePanel()->getFilter()->resetDefault(); + if (finder) + { + finder->updateElementsFromFilter(); + } + + setFilterTextFromFilter(); +} + // static BOOL LLInventoryView::filtersVisible(void* user_data) { @@ -1323,6 +934,17 @@ void LLInventoryView::onSelectionChange(const std::deque &ite } } +const std::string LLInventoryView::getFilterSubString() +{ + return mActivePanel->getFilterSubString(); +} + +void LLInventoryView::setFilterSubString(const std::string& string) +{ + mActivePanel->setFilterSubString(string); +} + + BOOL LLInventoryView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data, @@ -1345,685 +967,383 @@ BOOL LLInventoryView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, return handled; } -const std::string LLInventoryPanel::DEFAULT_SORT_ORDER = std::string("InventorySortOrder"); -const std::string LLInventoryPanel::RECENTITEMS_SORT_ORDER = std::string("RecentItemsSortOrder"); -const std::string LLInventoryPanel::WORNITEMS_SORT_ORDER = std::string("WornItemsSortOrder"); -const std::string LLInventoryPanel::INHERIT_SORT_ORDER = std::string(""); - -LLInventoryPanel::LLInventoryPanel(const std::string& name, - const std::string& sort_order_setting, - const LLRect& rect, - LLInventoryModel* inventory, - BOOL allow_multi_select, - LLView *parent_view) : - LLPanel(name, rect, TRUE), - mInventory(inventory), - mInventoryObserver(NULL), - mFolderRoot(NULL), - mScroller(NULL), - mAllowMultiSelect(allow_multi_select), - mSortOrderSetting(sort_order_setting) +void LLInventoryView::changed(U32 mask) { - setBackgroundColor(gColors.getColor("InventoryBackgroundColor")); - setBackgroundVisible(TRUE); - setBackgroundOpaque(TRUE); + std::ostringstream title; + title << "Inventory"; + if (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive()) + { + LLLocale locale(LLLocale::USER_LOCALE); + std::string item_count_string; + LLResMgr::getInstance()->getIntegerString(item_count_string, gInventory.getItemCount()); + title << " (Fetched " << item_count_string << " items...)"; + } + title << mFilterText; + setTitle(title.str()); + } -BOOL LLInventoryPanel::postBuild() +void LLInventoryView::draw() { - init_inventory_panel_actions(this); - - LLRect folder_rect(0, - 0, - getRect().getWidth(), - 0); - mFolderRoot = new LLFolderView(getName(), NULL, folder_rect, LLUUID::null, this); - mFolderRoot->setAllowMultiSelect(mAllowMultiSelect); - - // scroller - LLRect scroller_view_rect = getRect(); - scroller_view_rect.translate(-scroller_view_rect.mLeft, -scroller_view_rect.mBottom); - mScroller = new LLScrollableContainerView(std::string("Inventory Scroller"), - scroller_view_rect, - mFolderRoot); - mScroller->setFollowsAll(); - mScroller->setReserveScrollCorner(TRUE); - addChild(mScroller); - mFolderRoot->setScrollContainer(mScroller); - - // set up the callbacks from the inventory we're viewing, and then - // build everything. - mInventoryObserver = new LLInventoryPanelObserver(this); - mInventory->addObserver(mInventoryObserver); - rebuildViewsFor(LLUUID::null, LLInventoryObserver::ADD); - - // bit of a hack to make sure the inventory is open. - mFolderRoot->openFolder(std::string("My Inventory")); - - if (mSortOrderSetting != INHERIT_SORT_ORDER) + if (LLInventoryModelBackgroundFetch::instance().isEverythingFetched()) { - setSortOrder(gSavedSettings.getU32(mSortOrderSetting)); + LLLocale locale(LLLocale::USER_LOCALE); + std::ostringstream title; + title << "Inventory"; + std::string item_count_string; + LLResMgr::getInstance()->getIntegerString(item_count_string, gInventory.getItemCount()); + title << " (" << item_count_string << " items)"; + title << mFilterText; + setTitle(title.str()); + } + if (mActivePanel && mSearchEditor) + { + mSearchEditor->setText(mActivePanel->getFilterSubString()); + } + + if (mActivePanel && mQuickFilterCombo) + { + refreshQuickFilter( mQuickFilterCombo ); + } + + LLFloater::draw(); +} + +void LLInventoryView::setFilterTextFromFilter() +{ + mFilterText = mActivePanel->getFilter()->getFilterText(); +} + +void LLInventoryView::toggleFindOptions() +{ + LLFloater *floater = getFinder(); + if (!floater) + { + LLInventoryViewFinder * finder = new LLInventoryViewFinder(std::string("Inventory Finder"), + LLRect(getRect().mLeft - INV_FINDER_WIDTH, getRect().mTop, getRect().mLeft, getRect().mTop - INV_FINDER_HEIGHT), + this); + mFinderHandle = finder->getHandle(); + finder->open(); /*Flawfinder: ignore*/ + addDependentFloater(mFinderHandle); + + // start background fetch of folders + LLInventoryModelBackgroundFetch::instance().start(); + + mFloaterControls[std::string("Inventory.ShowFilters")]->setValue(TRUE); } else { - setSortOrder(gSavedSettings.getU32(DEFAULT_SORT_ORDER)); + floater->close(); + + mFloaterControls[std::string("Inventory.ShowFilters")]->setValue(FALSE); } - mFolderRoot->setSortOrder(mFolderRoot->getFilter()->getSortOrder()); +} +///---------------------------------------------------------------------------- +/// LLInventoryViewFinder +///---------------------------------------------------------------------------- +LLInventoryViewFinder* LLInventoryView::getFinder() +{ + return (LLInventoryViewFinder*)mFinderHandle.get(); +} +LLInventoryViewFinder::LLInventoryViewFinder(const std::string& name, + const LLRect& rect, + LLInventoryView* inventory_view) : + LLFloater(name, rect, std::string("Filters"), RESIZE_NO, + INV_FINDER_WIDTH, INV_FINDER_HEIGHT, DRAG_ON_TOP, + MINIMIZE_NO, CLOSE_YES), + mInventoryView(inventory_view), + mFilter(inventory_view->mActivePanel->getFilter()) +{ + + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_inventory_view_finder.xml"); + updateElementsFromFilter(); +} + +BOOL LLInventoryViewFinder::postBuild() +{ + childSetAction("All", selectAllTypes, this); + childSetAction("None", selectNoTypes, this); + + mSpinSinceHours = getChild("spin_hours_ago"); + childSetCommitCallback("spin_hours_ago", onTimeAgo, this); + + mSpinSinceDays = getChild("spin_days_ago"); + childSetCommitCallback("spin_days_ago", onTimeAgo, this); + +// mCheckSinceLogoff = getChild("check_since_logoff"); + childSetCommitCallback("check_since_logoff", onCheckSinceLogoff, this); + + childSetAction("Close", onCloseBtn, this); + + updateElementsFromFilter(); return TRUE; } -LLInventoryPanel::~LLInventoryPanel() + +void LLInventoryViewFinder::onCheckSinceLogoff(LLUICtrl *ctrl, void *user_data) { - if (mFolderRoot) - { - U32 sort_order = mFolderRoot->getSortOrder(); - if (mSortOrderSetting != INHERIT_SORT_ORDER) - { - gSavedSettings.setU32(mSortOrderSetting, sort_order); - } - } + LLInventoryViewFinder *self = (LLInventoryViewFinder *)user_data; + if (!self) return; - // LLView destructor will take care of the sub-views. - mInventory->removeObserver(mInventoryObserver); - delete mInventoryObserver; - mScroller = NULL; -} - -// virtual -LLXMLNodePtr LLInventoryPanel::getXML(bool save_children) const -{ - LLXMLNodePtr node = LLPanel::getXML(false); // Do not print out children - - node->setName(LL_INVENTORY_PANEL_TAG); - - node->createChild("allow_multi_select", TRUE)->setBoolValue(mFolderRoot->getAllowMultiSelect()); - - return node; -} - -LLView* LLInventoryPanel::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) -{ - LLInventoryPanel* panel; - - std::string name("inventory_panel"); - node->getAttributeString("name", name); - - BOOL allow_multi_select = TRUE; - node->getAttributeBOOL("allow_multi_select", allow_multi_select); - - LLRect rect; - createRect(node, rect, parent, LLRect()); - - std::string sort_order(INHERIT_SORT_ORDER); - node->getAttributeString("sort_order", sort_order); - - panel = new LLInventoryPanel(name, sort_order, - rect, &gInventory, - allow_multi_select, parent); - - panel->initFromXML(node, parent); - - panel->postBuild(); - - return panel; -} - -void LLInventoryPanel::draw() -{ - // select the desired item (in case it wasn't loaded when the selection was requested) - if (mSelectThisID.notNull()) - { - setSelection(mSelectThisID, false); - } - LLPanel::draw(); -} - -LLInventoryFilter* LLInventoryPanel::getFilter() -{ - if (mFolderRoot) - { - return mFolderRoot->getFilter(); - } - return NULL; -} - -const LLInventoryFilter* LLInventoryPanel::getFilter() const -{ - if (mFolderRoot) - { - return mFolderRoot->getFilter(); - } - return NULL; -} - -void LLInventoryPanel::setFilterTypes(U32 filter_types) -{ - getFilter()->setFilterTypes(filter_types); -} - -U32 LLInventoryPanel::getFilterTypes() const -{ - return mFolderRoot->getFilterTypes(); -} - -U32 LLInventoryPanel::getFilterPermMask() const -{ - return mFolderRoot->getFilterPermissions(); -} - -void LLInventoryPanel::setFilterPermMask(PermissionMask filter_perm_mask) -{ - getFilter()->setFilterPermissions(filter_perm_mask); -} - -void LLInventoryPanel::setFilterWorn(bool worn) -{ - getFilter()->setFilterWorn(worn); -} - -void LLInventoryPanel::setFilterSubString(const std::string& string) -{ - getFilter()->setFilterSubString(string); -} - -const std::string LLInventoryPanel::getFilterSubString() -{ - return mFolderRoot->getFilterSubString(); -} - -void LLInventoryPanel::setSortOrder(U32 order) -{ - getFilter()->setSortOrder(order); - if (getFilter()->isModified()) - { - mFolderRoot->setSortOrder(order); - // try to keep selection onscreen, even if it wasn't to start with - mFolderRoot->scrollToShowSelection(); - } -} - -U32 LLInventoryPanel::getSortOrder() const -{ - return mFolderRoot->getSortOrder(); -} - -void LLInventoryPanel::setSinceLogoff(BOOL sl) -{ - getFilter()->setDateRangeLastLogoff(sl); -} - -void LLInventoryPanel::setHoursAgo(U32 hours) -{ - getFilter()->setHoursAgo(hours); -} - -void LLInventoryPanel::setShowFolderState(LLInventoryFilter::EFolderShow show) -{ - getFilter()->setShowFolderState(show); -} - -LLInventoryFilter::EFolderShow LLInventoryPanel::getShowFolderState() -{ - return getFilter()->getShowFolderState(); -} - -void LLInventoryPanel::modelChanged(U32 mask) -{ - static LLFastTimer::DeclareTimer FTM_REFRESH("Inventory Refresh"); - LLFastTimer t2(FTM_REFRESH); - - bool handled = false; - - //if (!mViewsInitialized) return; - - const LLInventoryModel* model = getModel(); - if (!model) return; - - const LLInventoryModel::changed_items_t& changed_items = model->getChangedIDs(); - if (changed_items.empty()) return; - - for (LLInventoryModel::changed_items_t::const_iterator items_iter = changed_items.begin(); - items_iter != changed_items.end(); - ++items_iter) - { - const LLUUID& item_id = (*items_iter); - const LLInventoryObject* model_item = model->getObject(item_id); - LLFolderViewItem* view_item = mFolderRoot->getItemByID(item_id); - - // LLFolderViewFolder is derived from LLFolderViewItem so dynamic_cast from item - // to folder is the fast way to get a folder without searching through folders tree. - //LLFolderViewFolder* view_folder = dynamic_cast(view_item); - - ////////////////////////////// - // LABEL Operation - // Empty out the display name for relabel. - if (mask & LLInventoryObserver::LABEL) - { - handled = true; - if (view_item) - { - // Request refresh on this item (also flags for filtering) - LLInvFVBridge* bridge = (LLInvFVBridge*)view_item->getListener(); - if(bridge) - { // Clear the display name first, so it gets properly re-built during refresh() - bridge->clearDisplayName(); - - view_item->refresh(); - } - } - } - - ////////////////////////////// - // REBUILD Operation - // Destroy and regenerate the UI. - /*if (mask & LLInventoryObserver::REBUILD) - { - handled = true; - if (model_item && view_item) - { - view_item->destroyView(); - } - view_item = buildNewViews(item_id); - view_folder = dynamic_cast(view_item); - }*/ - - ////////////////////////////// - // INTERNAL Operation - // This could be anything. For now, just refresh the item. - if (mask & LLInventoryObserver::INTERNAL) - { - if (view_item) - { - view_item->refresh(); - } - } - - ////////////////////////////// - // SORT Operation - // Sort the folder. - /*if (mask & LLInventoryObserver::SORT) - { - if (view_folder) - { - view_folder->requestSort(); - } - }*/ - - // We don't typically care which of these masks the item is actually flagged with, since the masks - // may not be accurate (e.g. in the main inventory panel, I move an item from My Inventory into - // Landmarks; this is a STRUCTURE change for that panel but is an ADD change for the Landmarks - // panel). What's relevant is that the item and UI are probably out of sync and thus need to be - // resynchronized. - if (mask & (LLInventoryObserver::STRUCTURE | - LLInventoryObserver::ADD | - LLInventoryObserver::REMOVE)) - { - handled = true; - - ////////////////////////////// - // ADD Operation - // Item exists in memory but a UI element hasn't been created for it. - if (model_item && !view_item) - { - // Add the UI element for this item. - buildNewViews(item_id); - // Select any newly created object that has the auto rename at top of folder root set. - if(mFolderRoot->getRoot()->needsAutoRename()) - { - setSelection(item_id, FALSE); - } - } - - ////////////////////////////// - // STRUCTURE Operation - // This item already exists in both memory and UI. It was probably reparented. - else if (model_item && view_item) - { - // Don't process the item if it is the root - if (view_item->getRoot() != view_item) - { - LLFolderViewFolder* new_parent = (LLFolderViewFolder*)mFolderRoot->getItemByID(model_item->getParentUUID()); - // Item has been moved. - if (view_item->getParentFolder() != new_parent) - { - if (new_parent != NULL) - { - // Item is to be moved and we found its new parent in the panel's directory, so move the item's UI. - view_item->getParentFolder()->extractItem(view_item); - view_item->addToFolder(new_parent, mFolderRoot); - } - else - { - // Item is to be moved outside the panel's directory (e.g. moved to trash for a panel that - // doesn't include trash). Just remove the item's UI. - view_item->destroyView(); - } - } - } - } - - ////////////////////////////// - // REMOVE Operation - // This item has been removed from memory, but its associated UI element still exists. - else if (!model_item && view_item) - { - // Remove the item's UI. - view_item->destroyView(); - } - } - } -} - -LLFolderView* LLInventoryPanel::getRootFolder() -{ - return mFolderRoot; -} -const LLUUID& LLInventoryPanel::getRootFolderID() const -{ - return mFolderRoot->getListener()->getUUID(); -} -void LLInventoryPanel::rebuildViewsFor(const LLUUID& id, U32 mask) -{ - // Destroy the old view for this ID so we can rebuild it. - LLFolderViewItem* old_view = mFolderRoot->getItemByID(id); - if (old_view && id.notNull()) - { - old_view->destroyView(); - } - - buildNewViews(id); -} - -LLFolderViewFolder * LLInventoryPanel::createFolderViewFolder(LLInvFVBridge * bridge) -{ - return new LLFolderViewFolder( - bridge->getDisplayName(), - bridge->getIcon(), - mFolderRoot, - bridge); -} - -LLFolderViewItem * LLInventoryPanel::createFolderViewItem(LLInvFVBridge * bridge) -{ - return new LLFolderViewItem( - bridge->getDisplayName(), - bridge->getIcon(), - bridge->getCreationDate(), - mFolderRoot, - bridge); -} - -void LLInventoryPanel::buildNewViews(const LLUUID& id) -{ - LLInventoryObject* const objectp = gInventory.getObject(id); - LLFolderViewItem* itemp = NULL; + bool since_logoff= self->childGetValue("check_since_logoff"); - - if (objectp) - { - const LLUUID &parent_id = objectp->getParentUUID(); - LLFolderViewFolder* parent_folder = (LLFolderViewFolder*)mFolderRoot->getItemByID(parent_id); - if (objectp->getType() <= LLAssetType::AT_NONE || - objectp->getType() >= LLAssetType::AT_COUNT) - { - llwarns << "LLInventoryPanel::buildNewViews called with invalid objectp->mType : " - << ((S32) objectp->getType()) << " name " << objectp->getName() << " UUID " << objectp->getUUID() - << llendl; - } - else if ((objectp->getType() == LLAssetType::AT_CATEGORY) && - (objectp->getActualType() != LLAssetType::AT_LINK_FOLDER)) // build new view for category - { - LLInvFVBridge* new_listener = LLInvFVBridge::createBridge(objectp->getType(), - objectp->getType(), - LLInventoryType::IT_CATEGORY, - this, - objectp->getUUID()); - - if (new_listener) - { - LLFolderViewFolder* folderp = createFolderViewFolder(new_listener); - folderp->setItemSortOrder(mFolderRoot->getSortOrder()); - itemp = folderp; - } - } - else // build new view for item - { - LLInventoryItem* item = (LLInventoryItem*)objectp; - LLInvFVBridge* new_listener = LLInvFVBridge::createBridge( - item->getType(), - item->getActualType(), - item->getInventoryType(), - this, - item->getUUID(), - item->getFlags()); - if (new_listener) - { - itemp = createFolderViewItem(new_listener); - } - } - - - - if (itemp) - { - if (parent_folder) - { - itemp->addToFolder(parent_folder, mFolderRoot); - } - else - { - llwarns << "Couldn't find parent folder for child " << itemp->getLabel() << llendl; - delete itemp; - } - } - } - - // If this is a folder, add the children of the folder and recursively add any - // child folders. - if (id.isNull() - || (objectp - && objectp->getType() == LLAssetType::AT_CATEGORY)) + if (!since_logoff && + !( self->mSpinSinceDays->get() || self->mSpinSinceHours->get() ) ) { - LLViewerInventoryCategory::cat_array_t* categories; - LLViewerInventoryItem::item_array_t* items; - mInventory->lockDirectDescendentArrays(id, categories, items); - - if(categories) - { - for (LLViewerInventoryCategory::cat_array_t::const_iterator cat_iter = categories->begin(); - cat_iter != categories->end(); - ++cat_iter) - { - const LLViewerInventoryCategory* cat = (*cat_iter); - buildNewViews(cat->getUUID()); - } - } - - if(items) - { - for (LLViewerInventoryItem::item_array_t::const_iterator item_iter = items->begin(); - item_iter != items->end(); - ++item_iter) - { - const LLViewerInventoryItem* item = (*item_iter); - buildNewViews(item->getUUID()); - } - } - mInventory->unlockDirectDescendentArrays(id); - } + self->mSpinSinceHours->set(1.0f); + } } -struct LLConfirmPurgeData +void LLInventoryViewFinder::onTimeAgo(LLUICtrl *ctrl, void *user_data) { - LLUUID mID; - LLInventoryModel* mModel; -}; - -class LLIsNotWorn : public LLInventoryCollectFunctor -{ -public: - LLIsNotWorn() {} - virtual ~LLIsNotWorn() {} - virtual bool operator()(LLInventoryCategory* cat, - LLInventoryItem* item) + LLInventoryViewFinder *self = (LLInventoryViewFinder *)user_data; + if (!self) return; + + bool since_logoff=true; + if ( self->mSpinSinceDays->get() || self->mSpinSinceHours->get() ) { - return !gAgentWearables.isWearingItem(item->getUUID()); + since_logoff = false; } -}; - -class LLOpenFolderByID : public LLFolderViewFunctor -{ -public: - LLOpenFolderByID(const LLUUID& id) : mID(id) {} - virtual ~LLOpenFolderByID() {} - virtual void doFolder(LLFolderViewFolder* folder) - { - if (folder->getListener() && folder->getListener()->getUUID() == mID) folder->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_UP); - } - virtual void doItem(LLFolderViewItem* item) {} -protected: - const LLUUID& mID; -}; - - -void LLInventoryPanel::openSelected() -{ - LLFolderViewItem* folder_item = mFolderRoot->getCurSelectedItem(); - if(!folder_item) return; - LLInvFVBridge* bridge = (LLInvFVBridge*)folder_item->getListener(); - if(!bridge) return; - bridge->openItem(); + self->childSetValue("check_since_logoff", since_logoff); } -void LLInventoryPanel::unSelectAll() -{ - mFolderRoot->setSelection(NULL, FALSE, FALSE); +void LLInventoryViewFinder::changeFilter(LLInventoryFilter* filter) +{ + mFilter = filter; + updateElementsFromFilter(); } - -BOOL LLInventoryPanel::handleHover(S32 x, S32 y, MASK mask) +void LLInventoryViewFinder::updateElementsFromFilter() { - BOOL handled = LLView::handleHover(x, y, mask); - if(handled) - { - ECursorType cursor = getWindow()->getCursor(); - if (LLInventoryModelBackgroundFetch::instance().backgroundFetchActive() && cursor == UI_CURSOR_ARROW) - { - // replace arrow cursor with arrow and hourglass cursor - getWindow()->setCursor(UI_CURSOR_WORKING); - } - } - else - { - getWindow()->setCursor(UI_CURSOR_ARROW); - } - return TRUE; -} - -BOOL LLInventoryPanel::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, - EDragAndDropType cargo_type, - void* cargo_data, - EAcceptance* accept, - std::string& tooltip_msg) -{ - - BOOL handled = LLPanel::handleDragAndDrop(x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg); - - if (handled) - { - mFolderRoot->setDragAndDropThisFrame(); - } - - return handled; -} - - -void LLInventoryPanel::openAllFolders() -{ - mFolderRoot->setOpenArrangeRecursively(TRUE, LLFolderViewFolder::RECURSE_DOWN); - mFolderRoot->arrangeAll(); -} - -void LLInventoryPanel::closeAllFolders() -{ - mFolderRoot->setOpenArrangeRecursively(FALSE, LLFolderViewFolder::RECURSE_DOWN); - mFolderRoot->arrangeAll(); -} - -void LLInventoryPanel::openDefaultFolderForType(LLAssetType::EType type) -{ - LLUUID category_id = mInventory->findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(type)); - LLOpenFolderByID opener(category_id); - mFolderRoot->applyFunctorRecursively(opener); -} - -void LLInventoryPanel::setSelection(const LLUUID& obj_id, BOOL take_keyboard_focus) -{ - LLFolderViewItem* itemp = mFolderRoot->getItemByID(obj_id); - if(itemp && itemp->getListener()) - { - itemp->getListener()->arrangeAndSet(itemp, TRUE, take_keyboard_focus); - mSelectThisID.setNull(); + if (!mFilter) return; - } - else - { - // save the desired item to be selected later (if/when ready) - mSelectThisID = obj_id; - } -} -void LLInventoryPanel::setSelectCallback(LLFolderView::SelectCallback callback, void* user_data) -{ - if (mFolderRoot) - { - mFolderRoot->setSelectCallback(callback, user_data); - } -} -void LLInventoryPanel::clearSelection() -{ - mFolderRoot->clearSelection(); - mSelectThisID.setNull(); + + // Get data needed for filter display + U32 filter_types = mFilter->getFilterTypes(); + std::string filter_string = mFilter->getFilterSubString(); + LLInventoryFilter::EFolderShow show_folders = mFilter->getShowFolderState(); + U32 hours = mFilter->getHoursAgo(); + + // update the ui elements + LLFloater::setTitle(mFilter->getName()); + childSetValue("check_animation", (S32) (filter_types & 0x1 << LLInventoryType::IT_ANIMATION)); + + childSetValue("check_calling_card", (S32) (filter_types & 0x1 << LLInventoryType::IT_CALLINGCARD)); + childSetValue("check_clothing", (S32) (filter_types & 0x1 << LLInventoryType::IT_WEARABLE)); + childSetValue("check_gesture", (S32) (filter_types & 0x1 << LLInventoryType::IT_GESTURE)); + childSetValue("check_landmark", (S32) (filter_types & 0x1 << LLInventoryType::IT_LANDMARK)); + childSetValue("check_notecard", (S32) (filter_types & 0x1 << LLInventoryType::IT_NOTECARD)); + childSetValue("check_object", (S32) (filter_types & 0x1 << LLInventoryType::IT_OBJECT)); + childSetValue("check_script", (S32) (filter_types & 0x1 << LLInventoryType::IT_LSL)); + childSetValue("check_sound", (S32) (filter_types & 0x1 << LLInventoryType::IT_SOUND)); + childSetValue("check_texture", (S32) (filter_types & 0x1 << LLInventoryType::IT_TEXTURE)); + childSetValue("check_snapshot", (S32) (filter_types & 0x1 << LLInventoryType::IT_SNAPSHOT)); + childSetValue("check_show_empty", show_folders == LLInventoryFilter::SHOW_ALL_FOLDERS); + childSetValue("check_since_logoff", mFilter->isSinceLogoff()); + mSpinSinceHours->set((F32)(hours % 24)); + mSpinSinceDays->set((F32)(hours / 24)); } -void LLInventoryPanel::createNewItem(const std::string& name, - const LLUUID& parent_id, - LLAssetType::EType asset_type, - LLInventoryType::EType inv_type, - U32 next_owner_perm) +void LLInventoryViewFinder::draw() { - std::string desc; - LLViewerAssetType::generateDescriptionFor(asset_type, desc); - next_owner_perm = (next_owner_perm) ? next_owner_perm : PERM_MOVE | PERM_TRANSFER; + U32 filter = 0xffffffff; + BOOL filtered_by_all_types = TRUE; - - if (inv_type == LLInventoryType::IT_GESTURE) + if (!childGetValue("check_animation")) { - LLPointer cb = new CreateGestureCallback(); - create_inventory_item(gAgent.getID(), gAgent.getSessionID(), - parent_id, LLTransactionID::tnull, name, desc, asset_type, inv_type, - NOT_WEARABLE, next_owner_perm, cb); + filter &= ~(0x1 << LLInventoryType::IT_ANIMATION); + filtered_by_all_types = FALSE; } - else - { - LLPointer cb = NULL; - create_inventory_item(gAgent.getID(), gAgent.getSessionID(), - parent_id, LLTransactionID::tnull, name, desc, asset_type, inv_type, - NOT_WEARABLE, next_owner_perm, cb); - } - -} -BOOL LLInventoryPanel::getSinceLogoff() -{ - return getFilter()->isSinceLogoff(); + + if (!childGetValue("check_calling_card")) + { + filter &= ~(0x1 << LLInventoryType::IT_CALLINGCARD); + filtered_by_all_types = FALSE; + } + + if (!childGetValue("check_clothing")) + { + filter &= ~(0x1 << LLInventoryType::IT_WEARABLE); + filtered_by_all_types = FALSE; + } + + if (!childGetValue("check_gesture")) + { + filter &= ~(0x1 << LLInventoryType::IT_GESTURE); + filtered_by_all_types = FALSE; + } + + if (!childGetValue("check_landmark")) + + + { + filter &= ~(0x1 << LLInventoryType::IT_LANDMARK); + filtered_by_all_types = FALSE; + } + + if (!childGetValue("check_notecard")) + { + filter &= ~(0x1 << LLInventoryType::IT_NOTECARD); + filtered_by_all_types = FALSE; + } + + if (!childGetValue("check_object")) + { + filter &= ~(0x1 << LLInventoryType::IT_OBJECT); + filter &= ~(0x1 << LLInventoryType::IT_ATTACHMENT); + filtered_by_all_types = FALSE; + } + + if (!childGetValue("check_script")) + { + filter &= ~(0x1 << LLInventoryType::IT_LSL); + filtered_by_all_types = FALSE; + } + + if (!childGetValue("check_sound")) + { + filter &= ~(0x1 << LLInventoryType::IT_SOUND); + filtered_by_all_types = FALSE; + } + + if (!childGetValue("check_texture")) + { + filter &= ~(0x1 << LLInventoryType::IT_TEXTURE); + filtered_by_all_types = FALSE; + } + + if (!childGetValue("check_snapshot")) + { + filter &= ~(0x1 << LLInventoryType::IT_SNAPSHOT); + filtered_by_all_types = FALSE; + } + + if (!filtered_by_all_types) + { + // don't include folders in filter, unless I've selected everything + filter &= ~(0x1 << LLInventoryType::IT_CATEGORY); + } + + // update the panel, panel will update the filter + mInventoryView->mActivePanel->setShowFolderState(getCheckShowEmpty() ? + LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS); + mInventoryView->mActivePanel->setFilterTypes(filter); + if (getCheckSinceLogoff()) + { + mSpinSinceDays->set(0); + mSpinSinceHours->set(0); + } + U32 days = (U32)mSpinSinceDays->get(); + U32 hours = (U32)mSpinSinceHours->get(); + if (hours > 24) + { + days += hours / 24; + hours = (U32)hours % 24; + mSpinSinceDays->set((F32)days); + mSpinSinceHours->set((F32)hours); + } + hours += days * 24; + mInventoryView->mActivePanel->setHoursAgo(hours); + mInventoryView->mActivePanel->setSinceLogoff(getCheckSinceLogoff()); + mInventoryView->setFilterTextFromFilter(); + + LLFloater::draw(); } -// DEBUG ONLY -// static -void LLInventoryPanel::dumpSelectionInformation(void* user_data) +void LLInventoryViewFinder::onClose(bool app_quitting) { - LLInventoryPanel* iv = (LLInventoryPanel*)user_data; - iv->mFolderRoot->dumpSelectionInformation(); + if (mInventoryView) mInventoryView->getControl("Inventory.ShowFilters")->setValue(FALSE); + // If you want to reset the filter on close, do it here. This functionality was + // hotly debated - Paulm +#if 0 + if (mInventoryView) + { + LLInventoryView::onResetFilter((void *)mInventoryView); + } +#endif + destroy(); +} + + +BOOL LLInventoryViewFinder::getCheckShowEmpty() +{ + return childGetValue("check_show_empty"); +} + +BOOL LLInventoryViewFinder::getCheckSinceLogoff() +{ + return childGetValue("check_since_logoff"); +} + +void LLInventoryViewFinder::onCloseBtn(void* user_data) +{ + LLInventoryViewFinder* finderp = (LLInventoryViewFinder*)user_data; + finderp->close(); +} + +// static +void LLInventoryViewFinder::selectAllTypes(void* user_data) +{ + LLInventoryViewFinder* self = (LLInventoryViewFinder*)user_data; + if(!self) return; + + self->childSetValue("check_animation", TRUE); + self->childSetValue("check_calling_card", TRUE); + self->childSetValue("check_clothing", TRUE); + self->childSetValue("check_gesture", TRUE); + self->childSetValue("check_landmark", TRUE); + self->childSetValue("check_notecard", TRUE); + self->childSetValue("check_object", TRUE); + self->childSetValue("check_script", TRUE); + self->childSetValue("check_sound", TRUE); + self->childSetValue("check_texture", TRUE); + self->childSetValue("check_snapshot", TRUE); + +/* + self->mCheckCallingCard->set(TRUE); + self->mCheckClothing->set(TRUE); + self->mCheckGesture->set(TRUE); + self->mCheckLandmark->set(TRUE); + self->mCheckNotecard->set(TRUE); + self->mCheckObject->set(TRUE); + self->mCheckScript->set(TRUE); + self->mCheckSound->set(TRUE); + self->mCheckTexture->set(TRUE); + self->mCheckSnapshot->set(TRUE);*/ +} + +//static +void LLInventoryViewFinder::selectNoTypes(void* user_data) +{ + LLInventoryViewFinder* self = (LLInventoryViewFinder*)user_data; + if(!self) return; + + /* + self->childSetValue("check_animation", FALSE); + self->mCheckCallingCard->set(FALSE); + self->mCheckClothing->set(FALSE); + self->mCheckGesture->set(FALSE); + self->mCheckLandmark->set(FALSE); + self->mCheckNotecard->set(FALSE); + self->mCheckObject->set(FALSE); + self->mCheckScript->set(FALSE); + self->mCheckSound->set(FALSE); + self->mCheckTexture->set(FALSE); + self->mCheckSnapshot->set(FALSE);*/ + + + self->childSetValue("check_animation", FALSE); + self->childSetValue("check_calling_card", FALSE); + self->childSetValue("check_clothing", FALSE); + self->childSetValue("check_gesture", FALSE); + self->childSetValue("check_landmark", FALSE); + self->childSetValue("check_notecard", FALSE); + self->childSetValue("check_object", FALSE); + self->childSetValue("check_script", FALSE); + self->childSetValue("check_sound", FALSE); + self->childSetValue("check_texture", FALSE); + self->childSetValue("check_snapshot", FALSE); } diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h new file mode 100644 index 000000000..cce2672d5 --- /dev/null +++ b/indra/newview/llpanelmaininventory.h @@ -0,0 +1,179 @@ +/** + * @file llpanelmaininventory.h + * @brief llpanelmaininventory.h + * class definition + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLPANELMAININVENTORY_H +#define LL_LLPANELMAININVENTORY_H + +#include "llfloater.h" +#include "llinventoryobserver.h" + +#include "llfolderview.h" + +class LLFolderViewItem; +class LLInventoryPanel; +class LLSaveFolderState; +class LLFilterEditor; +class LLTabContainer; +class LLMenuButton; +class LLMenuGL; +class LLToggleableMenu; +class LLFloater; +class LLSearchEditor; +class LLComboBox; + +class LLInventoryView : public LLFloater, LLInventoryObserver +{ +friend class LLInventoryViewFinder; + +public: + LLInventoryView(const std::string& name, const std::string& rect, + LLInventoryModel* inventory); + LLInventoryView(const std::string& name, const LLRect& rect, + LLInventoryModel* inventory); + ~LLInventoryView(); + + BOOL postBuild(); + +//TODO: Move these statics. + static LLInventoryView* showAgentInventory(BOOL take_keyboard_focus=FALSE); + static LLInventoryView* getActiveInventory(); + static void toggleVisibility(); + static void toggleVisibility(void*) { toggleVisibility(); } + // Final cleanup, destroy all open inventory views. + static void cleanup(); + + + // LLView & LLFloater functionality + virtual void onClose(bool app_quitting); + virtual void setVisible(BOOL visible); + + virtual BOOL handleKeyHere(KEY key, MASK mask); + + // Inherited functionality + BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg); + /*virtual*/ void changed(U32 mask); + /*virtual*/ void draw(); + + + LLInventoryPanel* getPanel() { return mActivePanel; } + LLInventoryPanel* getActivePanel() { return mActivePanel; } + const LLInventoryPanel* getActivePanel() const { return mActivePanel; } + + const std::string& getFilterText() const { return mFilterText; } + static void onSearchEdit(const std::string& search_string, void* user_data ); + // + // Misc functions + // + void setFilterTextFromFilter(); + void startSearch(); + + void toggleFindOptions(); + static void onSelectionChange(const std::deque &items, BOOL user_action, void* data); + static BOOL filtersVisible(void* user_data); + static void onClearSearch(void* user_data); + static void onFoldersByName(void *user_data); + static BOOL checkFoldersByName(void *user_data); + + + static void onFilterSelected(void* userdata, bool from_click); + + const std::string getFilterSubString(); + void setFilterSubString(const std::string& string); + + + + static void onQuickFilterCommit(LLUICtrl* ctrl, void* user_data); + static void refreshQuickFilter(LLUICtrl* ctrl); + + static void onResetAll(void* userdata); + static void onExpandAll(void* userdata); + static void onCollapseAll(void* userdata); + + void updateSortControls(); + + void resetFilters(); + + +// [RLVa:KB] - Checked: 2009-07-10 (RLVa-1.0.0g) + static void closeAll() + { + // If there are mulitple inventory floaters open then clicking the "Inventory" button will close + // them one by one (see LLToolBar::onClickInventory() => toggleVisibility() ) until we get to the + // last one which will just be hidden instead of closed/destroyed (see LLInventoryView::onClose) + // + // However the view isn't removed from sActiveViews until its destructor is called and since + // 'LLMortician::sDestroyImmediate == FALSE' while the viewer is running the destructor won't be + // called right away + // + // Result: we can't call close() on the last (sActiveViews.count() will still be > 1) because + // onClose() would take the wrong branch and destroy() it as well + // + // Workaround: "fix" onClose() to count only views that aren't marked as "dead" + + LLInventoryView* pView; U8 flagsSound; + for (S32 idx = sActiveViews.count() - 1; idx >= 0; idx--) + { + pView = sActiveViews.get(idx); + flagsSound = pView->getSoundFlags(); + pView->setSoundFlags(LLView::SILENT); // Suppress the window close sound + pView->close(); // onClose() protects against closing the last inventory floater + pView->setSoundFlags(flagsSound); // One view won't be destroy()'ed so it needs its sound flags restored + } + } +// [/RLVa:KB] + + +protected: + // internal initialization code + void init(LLInventoryModel* inventory); + +protected: + LLInventoryViewFinder* getFinder(); + LLSearchEditor* mSearchEditor; + LLComboBox* mQuickFilterCombo; + LLTabContainer* mFilterTabs; + LLHandle mFinderHandle; + LLInventoryPanel* mActivePanel; + LLSaveFolderState* mSavedFolderState; + + std::string mFilterText; + + + // This container is used to hold all active inventory views. This + // is here to support the inventory toggle show button. + static LLDynamicArray sActiveViews; +}; + + +#endif // LL_LLPANELMAININVENTORY_H + + + diff --git a/indra/newview/llpreview.cpp b/indra/newview/llpreview.cpp index 5b2c9cfae..1ba07c364 100644 --- a/indra/newview/llpreview.cpp +++ b/indra/newview/llpreview.cpp @@ -34,6 +34,7 @@ #include "stdenums.h" #include "llpreview.h" +#include "llfloaterinventory.h" #include "lllineeditor.h" #include "llinventory.h" #include "llinventorydefines.h" @@ -53,7 +54,6 @@ #include "llagent.h" #include "llvoavatarself.h" #include "llselectmgr.h" -#include "llinventoryview.h" #include "llviewerinventory.h" #include "llviewerassettype.h" diff --git a/indra/newview/llpreviewanim.cpp b/indra/newview/llpreviewanim.cpp index 803a76ba5..a4e8dfddd 100644 --- a/indra/newview/llpreviewanim.cpp +++ b/indra/newview/llpreviewanim.cpp @@ -34,9 +34,9 @@ #include "llpreviewanim.h" #include "llbutton.h" +#include "llfloaterinventory.h" #include "llresmgr.h" #include "llinventory.h" -#include "llinventoryview.h" #include "llvoavatarself.h" #include "llagent.h" // gAgent #include "llkeyframemotion.h" diff --git a/indra/newview/llpreviewlandmark.cpp b/indra/newview/llpreviewlandmark.cpp index 5d3411549..c67f7c13d 100644 --- a/indra/newview/llpreviewlandmark.cpp +++ b/indra/newview/llpreviewlandmark.cpp @@ -44,8 +44,8 @@ #include "llagent.h" #include "llbutton.h" #include "lleconomy.h" +#include "llfloaterinventory.h" #include "llfloaterworldmap.h" -#include "llinventoryview.h" #include "lliconctrl.h" #include "lllandmarklist.h" #include "lllineeditor.h" @@ -60,9 +60,6 @@ #include "lluictrlfactory.h" #include "lltexturectrl.h" - - - //////////////////////////////////////////////////////////////////////////// // LLPreviewLandmark diff --git a/indra/newview/llpreviewsound.cpp b/indra/newview/llpreviewsound.cpp index a537990fd..446647f9b 100644 --- a/indra/newview/llpreviewsound.cpp +++ b/indra/newview/llpreviewsound.cpp @@ -35,8 +35,8 @@ #include "llaudioengine.h" #include "llagent.h" // gAgent #include "llbutton.h" +#include "llfloaterinventory.h" #include "llinventory.h" -#include "llinventoryview.h" #include "lllineeditor.h" #include "llpreviewsound.h" #include "llresmgr.h" diff --git a/indra/newview/llpreviewtexture.cpp b/indra/newview/llpreviewtexture.cpp index 338aa899e..d714b7444 100644 --- a/indra/newview/llpreviewtexture.cpp +++ b/indra/newview/llpreviewtexture.cpp @@ -38,8 +38,8 @@ #include "llbutton.h" #include "llcombobox.h" #include "statemachine/aifilepicker.h" +#include "llfloaterinventory.h" #include "llimagetga.h" -#include "llinventoryview.h" #include "llinventory.h" #include "llnotificationsutil.h" #include "llresmgr.h" @@ -52,7 +52,6 @@ #include "lllineeditor.h" #include "llfloateravatarinfo.h" - const S32 PREVIEW_TEXTURE_MIN_WIDTH = 300; const S32 PREVIEW_TEXTURE_MIN_HEIGHT = 120; diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index d678dc490..b5e02fe8f 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -115,6 +115,7 @@ #include "llfloaterchat.h" #include "llfloatergesture.h" #include "llfloaterhud.h" +#include "llfloaterinventory.h" #include "llfloaterland.h" #include "llfloatertopobjects.h" #include "llfloatertos.h" @@ -130,7 +131,7 @@ #include "llimview.h" // for gIMMgr #include "llinventoryfunctions.h" #include "llinventorymodelbackgroundfetch.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llkeyboard.h" #include "llloginhandler.h" // gLoginHandler, SLURL support #include "llpanellogin.h" @@ -206,7 +207,6 @@ #include "llsocks5.h" #include "jcfloaterareasearch.h" - // #include "llpanellogin.h" //#include "llfloateravatars.h" diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index 34b83a1cf..6adecfeb4 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -42,12 +42,12 @@ #include "llfloaterbuycurrency.h" #include "llfloaterchat.h" #include "llfloaterdirectory.h" // to spawn search +#include "llfloaterinventory.h" #include "llfloaterlagmeter.h" #include "llfloaterland.h" #include "llfloaterregioninfo.h" #include "llfloaterscriptdebug.h" #include "llhudicon.h" -#include "llinventoryview.h" #include "llkeyboard.h" #include "lllineeditor.h" #include "llmenugl.h" diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index 267c838ec..a6ab683b4 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -48,7 +48,7 @@ #include "llinventory.h" #include "llinventoryfunctions.h" #include "llinventorymodelbackgroundfetch.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "lllineeditor.h" #include "llui.h" #include "llviewerinventory.h" diff --git a/indra/newview/lltoolbar.cpp b/indra/newview/lltoolbar.cpp index 06ab0428d..becb8baf4 100644 --- a/indra/newview/lltoolbar.cpp +++ b/indra/newview/lltoolbar.cpp @@ -50,9 +50,9 @@ #include "lluiconstants.h" #include "llvoavatar.h" #include "lltooldraganddrop.h" -#include "llinventoryview.h" #include "llfloaterchatterbox.h" #include "llfloaterfriends.h" +#include "llfloaterinventory.h" #include "llfloatersnapshot.h" #include "llfloateravatarlist.h" #include "lltoolmgr.h" diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index c4967c2e9..d25c4df77 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -45,6 +45,7 @@ #include "llviewercontrol.h" #include "llfirstuse.h" #include "llfloater.h" +#include "llfloaterinventory.h" #include "llfloatertools.h" #include "llfocusmgr.h" #include "llgesturemgr.h" @@ -55,7 +56,7 @@ #include "llinventorybridge.h" #include "llinventorydefines.h" #include "llinventoryfunctions.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llmutelist.h" #include "llnotify.h" #include "llpreviewnotecard.h" diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 417bbb234..60491e952 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -39,6 +39,7 @@ #include "llagent.h" #include "llagentcamera.h" +#include "llfloaterinventory.h" #include "llviewercontrol.h" #include "llconsole.h" #include "llinventorymodel.h" @@ -49,7 +50,7 @@ #include "llinventorybridge.h" #include "llinventorydefines.h" #include "llinventorymodelbackgroundfetch.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llviewerregion.h" #include "llviewerobjectlist.h" diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 01bc8dd22..42ea1e456 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -130,6 +130,7 @@ #include "llfloaterhtmlsimple.h" #include "llfloaterhud.h" #include "llfloaterinspect.h" +#include "llfloaterinventory.h" #include "llfloaterlagmeter.h" #include "llfloaterland.h" #include "llfloaterlandholdings.h" @@ -171,7 +172,7 @@ #include "llimagetga.h" #include "llinventorydefines.h" #include "llinventoryfunctions.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llkeyboard.h" #include "llpanellogin.h" #include "llmenucommands.h" diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index ef5efc2ac..13d5074e3 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -82,6 +82,7 @@ #include "llfloaterchat.h" #include "llfloatergroupinfo.h" #include "llfloaterimagepreview.h" +#include "llfloaterinventory.h" #include "llfloaterland.h" #include "llfloaterregioninfo.h" #include "llfloaterlandholdings.h" @@ -98,7 +99,7 @@ #include "llimpanel.h" #include "llinventorydefines.h" #include "llinventorymodel.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llmenugl.h" #include "llmutelist.h" #include "llnotify.h" diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp index 2ec7cf396..b7b4dbc27 100644 --- a/indra/newview/llviewertexteditor.cpp +++ b/indra/newview/llviewertexteditor.cpp @@ -38,7 +38,7 @@ #include "llinventory.h" #include "llinventorydefines.h" #include "llinventorymodel.h" -#include "llinventoryview.h" +#include "llinventorypanel.h" #include "llinventorybridge.h" // for landmark prefix string #include "llviewertexteditor.h" diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 7c7dc6c99..5267c32e8 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -105,6 +105,7 @@ #include "llfloatereditui.h" // HACK JAMESDEBUG for ui editor #include "llfloaterland.h" #include "llfloaterinspect.h" +#include "llfloaterinventory.h" #include "llfloaternamedesc.h" #include "llfloaterpreference.h" #include "llfloatersnapshot.h" @@ -121,7 +122,6 @@ #include "llimagebmp.h" #include "llimagej2c.h" #include "llimageworker.h" -#include "llinventoryview.h" #include "llkeyboard.h" #include "lllineeditor.h" #include "llmenugl.h" diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index e1e846560..db9ae5cb6 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -54,12 +54,12 @@ #include "llfirstuse.h" #include "llfloaterchat.h" +#include "llfloaterinventory.h" #include "llheadrotmotion.h" #include "llhudeffecttrail.h" #include "llhudmanager.h" #include "llinventorybridge.h" -#include "llinventoryview.h" #include "llinventoryfunctions.h" #include "llhudnametag.h" #include "llhudtext.h" // for mText/mDebugText diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index e3da0a79a..1fd9239ee 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -22,6 +22,7 @@ #include "llfloaterchat.h" #include "llfloaterdaycycle.h" #include "llfloaterenvsettings.h" +#include "llfloaterinventory.h" #include "llfloaterland.h" #include "llfloatermap.h" #include "llfloaterregioninfo.h" @@ -29,7 +30,6 @@ #include "llfloaterwater.h" #include "llfloaterwindlight.h" #include "llfloaterworldmap.h" -#include "llinventoryview.h" #include "llviewermenu.h" #include "llviewermessage.h" #include "llviewerobjectlist.h" diff --git a/indra/newview/rlvhelper.cpp b/indra/newview/rlvhelper.cpp index c27ee59ce..77c25b02b 100644 --- a/indra/newview/rlvhelper.cpp +++ b/indra/newview/rlvhelper.cpp @@ -16,9 +16,9 @@ #include "llviewerprecompiledheaders.h" #include "llattachmentsmgr.h" +#include "llfloaterinventory.h" #include "llfloaterwindlight.h" #include "llgesturemgr.h" -#include "llinventoryview.h" #include "llinventorybridge.h" #include "llnotificationsutil.h" #include "llviewerobject.h" From 681901cb7c42d13da7c45aa2a454d1590fabd523 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 29 Jan 2012 17:15:18 -0600 Subject: [PATCH 11/36] LLInventoryViewFinder renamed to LLFloaterInventoryFinder --- indra/newview/llpanelmaininventory.cpp | 59 ++++++++++++++------------ indra/newview/llpanelmaininventory.h | 4 +- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 161b3da28..a844f8a78 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -56,10 +56,10 @@ const S32 INV_FINDER_WIDTH = 160; const S32 INV_FINDER_HEIGHT = 408; //BOOL LLInventoryView::sOpenNextNewItem = FALSE; -class LLInventoryViewFinder : public LLFloater +class LLFloaterInventoryFinder : public LLFloater { public: - LLInventoryViewFinder(const std::string& name, + LLFloaterInventoryFinder(const std::string& name, const LLRect& rect, LLInventoryView* inventory_view); virtual void draw(); @@ -116,6 +116,7 @@ LLInventoryView::LLInventoryView(const std::string& name, void LLInventoryView::init(LLInventoryModel* inventory) { + LLMemType mt(LLMemType::MTYPE_INVENTORY_VIEW_INIT); // Callbacks init_inventory_actions(this); @@ -497,7 +498,7 @@ void LLInventoryView::updateSortControls() void LLInventoryView::resetFilters() { - LLInventoryViewFinder *finder = getFinder(); + LLFloaterInventoryFinder *finder = getFinder(); getActivePanel()->getFilter()->resetDefault(); if (finder) { @@ -531,7 +532,7 @@ void LLInventoryView::onClearSearch(void* user_data) if (finder) { - LLInventoryViewFinder::selectAllTypes(finder); + LLFloaterInventoryFinder::selectAllTypes(finder); } // re-open folders that were initially open @@ -678,7 +679,7 @@ void LLInventoryView::onQuickFilterCommit(LLUICtrl* ctrl, void* user_data) // Force the filters window to update itself, if it's open. - LLInventoryViewFinder* finder = view->getFinder(); + LLFloaterInventoryFinder* finder = view->getFinder(); if( finder ) { finder->updateElementsFromFilter(); @@ -897,7 +898,7 @@ void LLInventoryView::onFilterSelected(void* userdata, bool from_click) LLInventoryView* self = (LLInventoryView*) userdata; LLInventoryFilter* filter; - LLInventoryViewFinder *finder = self->getFinder(); + LLFloaterInventoryFinder *finder = self->getFinder(); // Find my index self->mActivePanel = (LLInventoryPanel*)self->childGetVisibleTab("inventory filter tabs"); @@ -1016,10 +1017,11 @@ void LLInventoryView::setFilterTextFromFilter() void LLInventoryView::toggleFindOptions() { + LLMemType mt(LLMemType::MTYPE_INVENTORY_VIEW_TOGGLE); LLFloater *floater = getFinder(); if (!floater) { - LLInventoryViewFinder * finder = new LLInventoryViewFinder(std::string("Inventory Finder"), + LLFloaterInventoryFinder * finder = new LLFloaterInventoryFinder(std::string("Inventory Finder"), LLRect(getRect().mLeft - INV_FINDER_WIDTH, getRect().mTop, getRect().mLeft, getRect().mTop - INV_FINDER_HEIGHT), this); mFinderHandle = finder->getHandle(); @@ -1039,15 +1041,15 @@ void LLInventoryView::toggleFindOptions() } } ///---------------------------------------------------------------------------- -/// LLInventoryViewFinder +/// LLFloaterInventoryFinder ///---------------------------------------------------------------------------- -LLInventoryViewFinder* LLInventoryView::getFinder() +LLFloaterInventoryFinder* LLInventoryView::getFinder() { - return (LLInventoryViewFinder*)mFinderHandle.get(); + return (LLFloaterInventoryFinder*)mFinderHandle.get(); } -LLInventoryViewFinder::LLInventoryViewFinder(const std::string& name, +LLFloaterInventoryFinder::LLFloaterInventoryFinder(const std::string& name, const LLRect& rect, LLInventoryView* inventory_view) : LLFloater(name, rect, std::string("Filters"), RESIZE_NO, @@ -1061,7 +1063,7 @@ LLInventoryViewFinder::LLInventoryViewFinder(const std::string& name, updateElementsFromFilter(); } -BOOL LLInventoryViewFinder::postBuild() +BOOL LLFloaterInventoryFinder::postBuild() { childSetAction("All", selectAllTypes, this); childSetAction("None", selectNoTypes, this); @@ -1082,9 +1084,9 @@ BOOL LLInventoryViewFinder::postBuild() } -void LLInventoryViewFinder::onCheckSinceLogoff(LLUICtrl *ctrl, void *user_data) +void LLFloaterInventoryFinder::onCheckSinceLogoff(LLUICtrl *ctrl, void *user_data) { - LLInventoryViewFinder *self = (LLInventoryViewFinder *)user_data; + LLFloaterInventoryFinder *self = (LLFloaterInventoryFinder *)user_data; if (!self) return; bool since_logoff= self->childGetValue("check_since_logoff"); @@ -1096,9 +1098,9 @@ void LLInventoryViewFinder::onCheckSinceLogoff(LLUICtrl *ctrl, void *user_data) } } -void LLInventoryViewFinder::onTimeAgo(LLUICtrl *ctrl, void *user_data) +void LLFloaterInventoryFinder::onTimeAgo(LLUICtrl *ctrl, void *user_data) { - LLInventoryViewFinder *self = (LLInventoryViewFinder *)user_data; + LLFloaterInventoryFinder *self = (LLFloaterInventoryFinder *)user_data; if (!self) return; bool since_logoff=true; @@ -1109,13 +1111,13 @@ void LLInventoryViewFinder::onTimeAgo(LLUICtrl *ctrl, void *user_data) self->childSetValue("check_since_logoff", since_logoff); } -void LLInventoryViewFinder::changeFilter(LLInventoryFilter* filter) +void LLFloaterInventoryFinder::changeFilter(LLInventoryFilter* filter) { mFilter = filter; updateElementsFromFilter(); } -void LLInventoryViewFinder::updateElementsFromFilter() +void LLFloaterInventoryFinder::updateElementsFromFilter() { if (!mFilter) return; @@ -1146,8 +1148,9 @@ void LLInventoryViewFinder::updateElementsFromFilter() mSpinSinceDays->set((F32)(hours / 24)); } -void LLInventoryViewFinder::draw() +void LLFloaterInventoryFinder::draw() { + LLMemType mt(LLMemType::MTYPE_INVENTORY_DRAW); U32 filter = 0xffffffff; BOOL filtered_by_all_types = TRUE; @@ -1253,7 +1256,7 @@ void LLInventoryViewFinder::draw() LLFloater::draw(); } -void LLInventoryViewFinder::onClose(bool app_quitting) +void LLFloaterInventoryFinder::onClose(bool app_quitting) { if (mInventoryView) mInventoryView->getControl("Inventory.ShowFilters")->setValue(FALSE); // If you want to reset the filter on close, do it here. This functionality was @@ -1268,26 +1271,26 @@ void LLInventoryViewFinder::onClose(bool app_quitting) } -BOOL LLInventoryViewFinder::getCheckShowEmpty() +BOOL LLFloaterInventoryFinder::getCheckShowEmpty() { return childGetValue("check_show_empty"); } -BOOL LLInventoryViewFinder::getCheckSinceLogoff() +BOOL LLFloaterInventoryFinder::getCheckSinceLogoff() { return childGetValue("check_since_logoff"); } -void LLInventoryViewFinder::onCloseBtn(void* user_data) +void LLFloaterInventoryFinder::onCloseBtn(void* user_data) { - LLInventoryViewFinder* finderp = (LLInventoryViewFinder*)user_data; + LLFloaterInventoryFinder* finderp = (LLFloaterInventoryFinder*)user_data; finderp->close(); } // static -void LLInventoryViewFinder::selectAllTypes(void* user_data) +void LLFloaterInventoryFinder::selectAllTypes(void* user_data) { - LLInventoryViewFinder* self = (LLInventoryViewFinder*)user_data; + LLFloaterInventoryFinder* self = (LLFloaterInventoryFinder*)user_data; if(!self) return; self->childSetValue("check_animation", TRUE); @@ -1316,9 +1319,9 @@ void LLInventoryViewFinder::selectAllTypes(void* user_data) } //static -void LLInventoryViewFinder::selectNoTypes(void* user_data) +void LLFloaterInventoryFinder::selectNoTypes(void* user_data) { - LLInventoryViewFinder* self = (LLInventoryViewFinder*)user_data; + LLFloaterInventoryFinder* self = (LLFloaterInventoryFinder*)user_data; if(!self) return; /* diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h index cce2672d5..7cb2d23a2 100644 --- a/indra/newview/llpanelmaininventory.h +++ b/indra/newview/llpanelmaininventory.h @@ -47,7 +47,7 @@ class LLComboBox; class LLInventoryView : public LLFloater, LLInventoryObserver { -friend class LLInventoryViewFinder; +friend class LLFloaterInventoryFinder; public: LLInventoryView(const std::string& name, const std::string& rect, @@ -156,7 +156,7 @@ protected: void init(LLInventoryModel* inventory); protected: - LLInventoryViewFinder* getFinder(); + LLFloaterInventoryFinder* getFinder(); LLSearchEditor* mSearchEditor; LLComboBox* mQuickFilterCombo; LLTabContainer* mFilterTabs; From b045d9bd96bf2c757a1251e3777894864018924e Mon Sep 17 00:00:00 2001 From: Shyotl Date: Mon, 30 Jan 2012 03:28:35 -0600 Subject: [PATCH 12/36] Precache a few more inventory icons. --- indra/newview/llvovolume.cpp | 2 +- .../skins/Pony-Aquablue/textures/textures.xml | 3 +++ .../skins/Pony-Purple/textures/textures.xml | 3 +++ indra/newview/skins/dark/textures/textures.xml | 3 +++ .../newview/skins/darkgred/textures/textures.xml | 3 +++ .../skins/darkorange/textures/textures.xml | 3 +++ .../skins/default/textures/inv_item_mesh.tga | Bin 0 -> 749 bytes indra/newview/skins/default/textures/textures.xml | 3 +++ indra/newview/skins/emerald/textures/textures.xml | 3 +++ indra/newview/skins/gemini/textures/textures.xml | 3 +++ indra/newview/skins/gred/textures/textures.xml | 3 +++ indra/newview/skins/kdarknv/textures/textures.xml | 3 +++ indra/newview/skins/kliteat/textures/textures.xml | 3 +++ .../newview/skins/openlife/textures/textures.xml | 3 +++ .../newview/skins/pslgreen/textures/textures.xml | 3 +++ .../newview/skins/pslpurple/textures/textures.xml | 3 +++ indra/newview/skins/wisdom/textures/textures.xml | 3 +++ 17 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 indra/newview/skins/default/textures/inv_item_mesh.tga diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 4280821c4..c6e57e97b 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -821,7 +821,7 @@ BOOL LLVOVolume::setVolume(const LLVolumeParams ¶ms_in, const S32 detail, bo if (is404) { - setIcon(LLViewerTextureManager::getFetchedTextureFromFile("icons/Inv_Mesh.png", TRUE, LLViewerTexture::BOOST_UI)); + setIcon(LLViewerTextureManager::getFetchedTextureFromFile("inv_item_mesh.tga", TRUE, LLViewerTexture::BOOST_UI)); //render prim proxy when mesh loading attempts give up volume_params.setSculptID(LLUUID::null, LL_SCULPT_TYPE_NONE); diff --git a/indra/newview/skins/Pony-Aquablue/textures/textures.xml b/indra/newview/skins/Pony-Aquablue/textures/textures.xml index 70cd3e113..41fe7a9f9 100644 --- a/indra/newview/skins/Pony-Aquablue/textures/textures.xml +++ b/indra/newview/skins/Pony-Aquablue/textures/textures.xml @@ -130,6 +130,9 @@ + + + diff --git a/indra/newview/skins/Pony-Purple/textures/textures.xml b/indra/newview/skins/Pony-Purple/textures/textures.xml index 70cd3e113..41fe7a9f9 100644 --- a/indra/newview/skins/Pony-Purple/textures/textures.xml +++ b/indra/newview/skins/Pony-Purple/textures/textures.xml @@ -130,6 +130,9 @@ + + + diff --git a/indra/newview/skins/dark/textures/textures.xml b/indra/newview/skins/dark/textures/textures.xml index 4dbbdf01b..451b70062 100644 --- a/indra/newview/skins/dark/textures/textures.xml +++ b/indra/newview/skins/dark/textures/textures.xml @@ -154,6 +154,9 @@ + + + diff --git a/indra/newview/skins/darkgred/textures/textures.xml b/indra/newview/skins/darkgred/textures/textures.xml index 4dbbdf01b..451b70062 100644 --- a/indra/newview/skins/darkgred/textures/textures.xml +++ b/indra/newview/skins/darkgred/textures/textures.xml @@ -154,6 +154,9 @@ + + + diff --git a/indra/newview/skins/darkorange/textures/textures.xml b/indra/newview/skins/darkorange/textures/textures.xml index 70cd3e113..41fe7a9f9 100644 --- a/indra/newview/skins/darkorange/textures/textures.xml +++ b/indra/newview/skins/darkorange/textures/textures.xml @@ -130,6 +130,9 @@ + + + diff --git a/indra/newview/skins/default/textures/inv_item_mesh.tga b/indra/newview/skins/default/textures/inv_item_mesh.tga new file mode 100644 index 0000000000000000000000000000000000000000..b6fad44b20a5e6c1ab811dafd912afa328a43838 GIT binary patch literal 749 zcmYL{OK4L;6o#+&dNpai1-&Y97)8m;=- znyuA4t^?40x;zJ!rE{()`^iNzL%xw^0@Jdg8wLvENahlm zBk5XQ*I$s|jKW;!f)#1OrtUs8oXTPQ#5BU^#^Ku0314~`&bru22`aT8E)FlHYUpGJ z@yS^vrruyz`4dv*1++b0M8lZ^Hg@!(`N~r?Wu_1q%);8%25tvxzpv&HA-~)^JCJ<% z9?1vqke4csRAm9d{`2tm97nWJMpO14Vwa!5({)6o!U>VfH%JgjpGB(jr7ACfhVQ@t zHunxAlAl&3g2!^~fhp44B2%5S#M5;HvFxP!Z*_)8AK}@12!VktqGJ_=M@w*cgQ8p{ z8_0^fmWG>rb^1ey-GNY&kuFSaAk+>poHbCEaRIxde4(?VOiA?FUuU zTJOAqt7SJDM@sM?9ubLfRb^kIrQSnM!r`GJ5_exSeGfuI*I>H6k~&Xn{->{{D=nHe zUF#9Oa1(aC6V}$0r2ZjsRaCt+lWv$SIXpfXmRp{Pq>ZZ8A}v+vDCg?ZGunn)9+zca Usa_&KX*Vi?3a_HOhWM5D5Aaji^8f$< literal 0 HcmV?d00001 diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index c7929b058..973f76923 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -133,6 +133,9 @@ + + + diff --git a/indra/newview/skins/emerald/textures/textures.xml b/indra/newview/skins/emerald/textures/textures.xml index 9e1d9b519..8ccd5fa5d 100644 --- a/indra/newview/skins/emerald/textures/textures.xml +++ b/indra/newview/skins/emerald/textures/textures.xml @@ -130,6 +130,9 @@ + + + diff --git a/indra/newview/skins/gemini/textures/textures.xml b/indra/newview/skins/gemini/textures/textures.xml index 2c4b0cbea..792f6a453 100644 --- a/indra/newview/skins/gemini/textures/textures.xml +++ b/indra/newview/skins/gemini/textures/textures.xml @@ -130,6 +130,9 @@ + + + diff --git a/indra/newview/skins/gred/textures/textures.xml b/indra/newview/skins/gred/textures/textures.xml index 4dbbdf01b..451b70062 100644 --- a/indra/newview/skins/gred/textures/textures.xml +++ b/indra/newview/skins/gred/textures/textures.xml @@ -154,6 +154,9 @@ + + + diff --git a/indra/newview/skins/kdarknv/textures/textures.xml b/indra/newview/skins/kdarknv/textures/textures.xml index 07c74c2b1..d26f9ccb4 100644 --- a/indra/newview/skins/kdarknv/textures/textures.xml +++ b/indra/newview/skins/kdarknv/textures/textures.xml @@ -130,6 +130,9 @@ + + + diff --git a/indra/newview/skins/kliteat/textures/textures.xml b/indra/newview/skins/kliteat/textures/textures.xml index 82e990837..195b13f42 100644 --- a/indra/newview/skins/kliteat/textures/textures.xml +++ b/indra/newview/skins/kliteat/textures/textures.xml @@ -134,6 +134,9 @@ + + + diff --git a/indra/newview/skins/openlife/textures/textures.xml b/indra/newview/skins/openlife/textures/textures.xml index 7adbcd402..b3b964c2e 100644 --- a/indra/newview/skins/openlife/textures/textures.xml +++ b/indra/newview/skins/openlife/textures/textures.xml @@ -134,6 +134,9 @@ + + + diff --git a/indra/newview/skins/pslgreen/textures/textures.xml b/indra/newview/skins/pslgreen/textures/textures.xml index 4dbbdf01b..451b70062 100644 --- a/indra/newview/skins/pslgreen/textures/textures.xml +++ b/indra/newview/skins/pslgreen/textures/textures.xml @@ -154,6 +154,9 @@ + + + diff --git a/indra/newview/skins/pslpurple/textures/textures.xml b/indra/newview/skins/pslpurple/textures/textures.xml index 4dbbdf01b..451b70062 100644 --- a/indra/newview/skins/pslpurple/textures/textures.xml +++ b/indra/newview/skins/pslpurple/textures/textures.xml @@ -154,6 +154,9 @@ + + + diff --git a/indra/newview/skins/wisdom/textures/textures.xml b/indra/newview/skins/wisdom/textures/textures.xml index 34c9dea7e..550ea5ff1 100644 --- a/indra/newview/skins/wisdom/textures/textures.xml +++ b/indra/newview/skins/wisdom/textures/textures.xml @@ -130,6 +130,9 @@ + + + From 9973dfd1c7e8a43853b56de49c11538b08c3413d Mon Sep 17 00:00:00 2001 From: Shyotl Date: Mon, 30 Jan 2012 03:44:20 -0600 Subject: [PATCH 13/36] Tweaked stream buffer size used in fmodex. --- indra/llaudio/llstreamingaudio_fmodex.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/indra/llaudio/llstreamingaudio_fmodex.cpp b/indra/llaudio/llstreamingaudio_fmodex.cpp index 2b032e25b..6d97bcc49 100644 --- a/indra/llaudio/llstreamingaudio_fmodex.cpp +++ b/indra/llaudio/llstreamingaudio_fmodex.cpp @@ -74,7 +74,9 @@ LLStreamingAudio_FMODEX::LLStreamingAudio_FMODEX(FMOD::System *system) : { // Number of milliseconds of audio to buffer for the audio card. // Must be larger than the usual Second Life frame stutter time. - mSystem->setStreamBufferSize(200, FMOD_TIMEUNIT_MS); + const U32 buffer_seconds = 5; //sec + const U32 estimated_bitrate = 128; //kbit/sec + mSystem->setStreamBufferSize(estimated_bitrate * buffer_seconds * 128/*bytes/kbit*/, FMOD_TIMEUNIT_RAWBYTES); // Here's where we set the size of the network buffer and some buffering // parameters. In this case we want a network buffer of 16k, we want it From e327e7a15e5aa45e6f123d236ca7dd753747909a Mon Sep 17 00:00:00 2001 From: Shyotl Date: Mon, 30 Jan 2012 03:49:52 -0600 Subject: [PATCH 14/36] Converted some frequent setting lookups to LLCachedControl --- indra/newview/llagentwearables.cpp | 3 ++- indra/newview/llconsole.cpp | 10 +++++--- indra/newview/lldrawpoolalpha.cpp | 3 ++- indra/newview/lldrawpoolterrain.cpp | 3 ++- indra/newview/lldrawpoolwater.cpp | 3 ++- indra/newview/llmemoryview.cpp | 6 +++-- indra/newview/llmeshrepository.cpp | 9 ++++--- indra/newview/llviewerdisplay.cpp | 6 +++-- indra/newview/llviewerjointmesh.cpp | 3 ++- indra/newview/llviewertexture.cpp | 2 +- indra/newview/llvoavatar.cpp | 39 ++++++++++++++++++----------- indra/newview/pipeline.cpp | 3 ++- 12 files changed, 58 insertions(+), 32 deletions(-) diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index 1f9a69386..a583d771a 100644 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -564,7 +564,8 @@ BOOL LLAgentWearables::isWearableCopyable(LLWearableType::EType type, U32 index) BOOL LLAgentWearables::areWearablesLoaded() const { - if(gSavedSettings.getBOOL("RenderUnloadedAvatar")) + static const LLCachedControl rener_unloaded_avatar("RenderUnloadedAvatar"); + if(rener_unloaded_avatar) return TRUE; return mWearablesLoaded; } diff --git a/indra/newview/llconsole.cpp b/indra/newview/llconsole.cpp index d45de57f9..ccd4c4eb2 100644 --- a/indra/newview/llconsole.cpp +++ b/indra/newview/llconsole.cpp @@ -160,7 +160,7 @@ void LLConsole::draw() F32 skip_time = cur_time - mLinePersistTime; F32 fade_time = cur_time - mFadeTime; - U32 max_lines = gSavedSettings.getS32("ConsoleMaxLines"); + static const LLCachedControl max_lines("ConsoleMaxLines"); U32 num_lines=0; paragraph_t::reverse_iterator paragraph_it; @@ -170,7 +170,7 @@ void LLConsole::draw() while (!mParagraphs.empty() && paragraph_it != mParagraphs.rend()) { num_lines += (*paragraph_it)->mLines.size(); - if(num_lines > max_lines + if(num_lines > (U32)max_lines.get() || ( (mLinePersistTime > (F32)0.f) && ((*paragraph_it)->mAddTime - skip_time)/(mLinePersistTime - mFadeTime) <= (F32)0.f)) { //All lines above here are done. Lose them. for (U32 i=0;i console_background_opacity("ConsoleBackgroundOpacity"); + F32 console_opacity = llclamp(console_background_opacity.get(), 0.f, 1.f); + static const LLCachedControl console_background(gColors,"ConsoleBackground"); + LLColor4 color = console_background; color.mV[VALPHA] *= console_opacity; F32 line_height = mFont->getLineHeight(); diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 4eba9292e..c0999b62c 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -107,11 +107,12 @@ void LLDrawPoolAlpha::renderDeferred(S32 pass) S32 LLDrawPoolAlpha::getNumPostDeferredPasses() { + static const LLCachedControl render_depth_of_field("RenderDepthOfField"); if (LLPipeline::sImpostorRender) { //skip depth buffer filling pass when rendering impostors return 1; } - else if (gSavedSettings.getBOOL("RenderDepthOfField")) + else if (render_depth_of_field) { return 2; } diff --git a/indra/newview/lldrawpoolterrain.cpp b/indra/newview/lldrawpoolterrain.cpp index 5225af4e7..b26896d07 100644 --- a/indra/newview/lldrawpoolterrain.cpp +++ b/indra/newview/lldrawpoolterrain.cpp @@ -128,7 +128,8 @@ U32 LLDrawPoolTerrain::getVertexDataMask() void LLDrawPoolTerrain::prerender() { mVertexShaderLevel = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT); - sDetailMode = gSavedSettings.getS32("RenderTerrainDetail"); + static const LLCachedControl render_terrain_detail("RenderTerrainDetail"); + sDetailMode = render_terrain_detail; } void LLDrawPoolTerrain::beginRenderPass( S32 pass ) diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 438e40524..8daa0f69d 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -573,7 +573,8 @@ void LLDrawPoolWater::shade() mWaterNormp->addTextureStats(1024.f*1024.f); gGL.getTexUnit(bumpTex)->bind(mWaterNormp) ; - if (gSavedSettings.getBOOL("RenderWaterMipNormal")) + static const LLCachedControl render_water_mip_normal("RenderWaterMipNormal"); + if (render_water_mip_normal) { mWaterNormp->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); } diff --git a/indra/newview/llmemoryview.cpp b/indra/newview/llmemoryview.cpp index 6a57d5f56..5cba79d9d 100644 --- a/indra/newview/llmemoryview.cpp +++ b/indra/newview/llmemoryview.cpp @@ -125,7 +125,8 @@ void LLMemoryView::draw() const S32 UPDATE_INTERVAL = 60; const S32 MARGIN_AMT = 10; static S32 curUpdate = UPDATE_INTERVAL; - static LLColor4 s_console_color = gColors.getColor("ConsoleBackground"); + static const LLCachedControl console_background(gColors,"ConsoleBackground"); + static LLColor4 s_console_color = console_background; // setup update interval if (curUpdate >= UPDATE_INTERVAL) @@ -141,7 +142,8 @@ void LLMemoryView::draw() setRect(LLRect().setLeftTopAndSize(getRect().mLeft, getRect().mTop, width, height)); // setup window color - F32 console_opacity = llclamp(gSavedSettings.getF32("ConsoleBackgroundOpacity"), 0.f, 1.f); + static const LLCachedControl console_background_opacity("ConsoleBackgroundOpacity"); + F32 console_opacity = llclamp(console_background_opacity.get(), 0.f, 1.f); LLColor4 color = s_console_color; color.mV[VALPHA] *= console_opacity; diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 3e6f72afd..a6409c5b3 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -2240,7 +2240,8 @@ S32 LLMeshRepository::loadMesh(LLVOVolume* vobj, const LLVolumeParams& mesh_para void LLMeshRepository::notifyLoadedMeshes() { //called from main thread - LLMeshRepoThread::sMaxConcurrentRequests = gSavedSettings.getU32("MeshMaxConcurrentRequests"); + static const LLCachedControl max_concurrent_requests("MeshMaxConcurrentRequests"); + LLMeshRepoThread::sMaxConcurrentRequests = max_concurrent_requests; #if MESH_IMPORT //clean up completed upload threads @@ -3580,7 +3581,8 @@ void LLMeshRepository::buildPhysicsMesh(LLModel::Decomposition& decomp) bool LLMeshRepository::meshUploadEnabled() { LLViewerRegion *region = gAgent.getRegion(); - if(gSavedSettings.getBOOL("MeshEnabled") && + static const LLCachedControl mesh_enabled("MeshEnabled"); + if(mesh_enabled && region) { return region->meshUploadEnabled(); @@ -3591,7 +3593,8 @@ bool LLMeshRepository::meshUploadEnabled() bool LLMeshRepository::meshRezEnabled() { LLViewerRegion *region = gAgent.getRegion(); - if(gSavedSettings.getBOOL("MeshEnabled") && + static const LLCachedControl mesh_enabled("MeshEnabled"); + if(mesh_enabled && region) { return region->meshRezEnabled(); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index e03ca1019..1631bdeeb 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1063,7 +1063,8 @@ void render_hud_attachments() hud_cam.setAxes(LLVector3(1,0,0), LLVector3(0,1,0), LLVector3(0,0,1)); LLViewerCamera::updateFrustumPlanes(hud_cam, TRUE); - bool render_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) && gSavedSettings.getBOOL("RenderHUDParticles"); + static const LLCachedControl render_hud_particles("RenderHUDParticles"); + bool render_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) && render_hud_particles; //only render hud objects gPipeline.pushRenderTypeMask(); @@ -1407,7 +1408,8 @@ void render_ui_3d() } // Coordinate axes - if (gSavedSettings.getBOOL("ShowAxes")) + static const LLCachedControl show_axes("ShowAxes"); + if (show_axes) { draw_axes(); } diff --git a/indra/newview/llviewerjointmesh.cpp b/indra/newview/llviewerjointmesh.cpp index a255d88f3..4379140e3 100644 --- a/indra/newview/llviewerjointmesh.cpp +++ b/indra/newview/llviewerjointmesh.cpp @@ -568,7 +568,8 @@ U32 LLViewerJointMesh::drawShape( F32 pixelArea, BOOL first_pass, BOOL is_dummy) { // This warning will always trigger if you've hacked the avatar to show as incomplete. // Ignore the warning if that's the case. - if (!gSavedSettings.getBOOL("RenderUnloadedAvatar")) + static const LLCachedControl rener_unloaded_avatar("RenderUnloadedAvatar"); + if (!rener_unloaded_avatar) { llwarns << "Layerset without composite" << llendl; } diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp index 66c79505b..2b783881e 100644 --- a/indra/newview/llviewertexture.cpp +++ b/indra/newview/llviewertexture.cpp @@ -2126,7 +2126,7 @@ bool LLViewerFetchedTexture::updateFetch() c = mComponents; } - const U32 override_tex_discard_level = gSavedSettings.getU32("TextureDiscardLevel"); + static const LLCachedControl override_tex_discard_level("TextureDiscardLevel"); if (override_tex_discard_level != 0) { desired_discard = override_tex_discard_level; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index db9ae5cb6..c10af283c 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -3551,12 +3551,12 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last) new_name = TRUE; } - LLColor4 avatar_name_color = gColors.getColor( "AvatarNameColor" ); + static const LLCachedControl avatar_name_color(gColors, "AvatarNameColor" ); //As pointed out by Zwagoth, we really shouldn't be doing this per-frame. Skip if we already have the data. -HgB if (mClientTag == "") { - mClientColor = gColors.getColor( "AvatarNameColor" ); + mClientColor = avatar_name_color; if(isFullyLoaded()) { //Zwagoth's new client identification - HgB @@ -3591,7 +3591,8 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last) // friends in a special color. -- charbl if (LLAvatarTracker::instance().getBuddyInfo(this->getID()) != NULL) { - if (gSavedSettings.getBOOL("AscentShowFriendsTag")) + static const LLCachedControl ascent_show_friends_tag("AscentShowFriendsTag"); + if (ascent_show_friends_tag) { mClientTag = "Friend"; } @@ -3611,33 +3612,41 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last) //Lindens are always more Linden than your friend, make that take precedence if(LLMuteList::getInstance()->isLinden(getFullname())) { - mClientColor = gSavedSettings.getColor4("AscentLindenColor"); + static const LLCachedControl ascent_linden_color(gColors, "AscentLindenColor" ); + mClientColor = ascent_linden_color; } //check if they are an estate owner at their current position else if(estate_owner.notNull() && this->getID() == estate_owner) { - mClientColor = gSavedSettings.getColor4("AscentEstateOwnerColor"); + static const LLCachedControl ascent_estate_owner_color(gColors, "AscentEstateOwnerColor" ); + mClientColor = ascent_estate_owner_color; } //without these dots, SL would suck. else if (LLAvatarTracker::instance().getBuddyInfo(this->getID()) != NULL) { - mClientColor = gSavedSettings.getColor4("AscentFriendColor"); + static const LLCachedControl ascent_friend_color(gColors, "AscentFriendColor" ); + mClientColor = ascent_friend_color; } //big fat jerkface who is probably a jerk, display them as such. else if(LLMuteList::getInstance()->isMuted(this->getID())) { - mClientColor = gSavedSettings.getColor4("AscentMutedColor"); + static const LLCachedControl ascent_muted_color(gColors, "AscentMutedColor" ); + mClientColor = ascent_muted_color; } } client = mClientTag; - if ((isSelf() && gSavedSettings.getBOOL("AscentShowSelfTagColor")) - || (!isSelf() && gSavedSettings.getBOOL("AscentShowOthersTagColor"))) - avatar_name_color = mClientColor; + + static const LLCachedControl ascent_show_self_tag_color("AscentShowSelfTagColor"); + static const LLCachedControl ascent_show_others_tag_color("AscentShowOthersTagColor"); + LLColor4 name_color = avatar_name_color; + if ((isSelf() && ascent_show_self_tag_color) + || (!isSelf() && ascent_show_others_tag_color)) + name_color = mClientColor; - avatar_name_color.setAlpha(alpha); - mNameText->setColor(avatar_name_color); + name_color.setAlpha(alpha); + mNameText->setColor(name_color); LLQuaternion root_rot = mRoot.getWorldRotation(); //mNameText->setUsePixelSize(TRUE); @@ -3719,7 +3728,8 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last) } //idle text std::string idle_string; - if(!isSelf() && mIdleTimer.getElapsedTimeF32() > 120.f && gSavedSettings.getBOOL("AscentShowIdleTime")) + static LLCachedControl ascent_show_idle_time("AscentShowIdleTime"); + if(!isSelf() && mIdleTimer.getElapsedTimeF32() > 120.f && ascent_show_idle_time) { idle_string = getIdleTime(); } @@ -7912,7 +7922,8 @@ BOOL LLVOAvatar::isFullyLoaded() const { // [SL:KB] - Patch: Appearance-SyncAttach | Checked: 2010-09-22 (Catznip-2.2.0a) | Added: Catznip-2.2.0a // Changes to LLAppearanceMgr::updateAppearanceFromCOF() expect this function to actually return mFullyLoaded for gAgentAvatarp - if ( (!isSelf()) && (gSavedSettings.getBOOL("RenderUnloadedAvatar")) ) + static const LLCachedControl rener_unloaded_avatar("RenderUnloadedAvatar"); + if ( (!isSelf()) && (rener_unloaded_avatar) ) return TRUE; else return mFullyLoaded; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f4604589c..3daee4398 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -955,7 +955,8 @@ void LLPipeline::createGLBuffers() //F32 sp = acosf(sa)/(1.f-spec); - sa = powf(sa, gSavedSettings.getF32("RenderSpecularExponent")); + static const LLCachedControl render_specular_exponent("RenderSpecularExponent"); + sa = powf(sa, render_specular_exponent); F32 a = acosf(sa*0.25f+0.75f); F32 m = llmax(0.5f-spec*0.5f, 0.001f); F32 t2 = tanf(a)/m; From f6711e6b4fd6b645ecba44dcbcdb48ec6b447e38 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Mon, 30 Jan 2012 03:52:16 -0600 Subject: [PATCH 15/36] Dont alphamask the bodies of visually muted avatars. --- indra/newview/llvoavatar.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index c10af283c..854e12414 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -4059,6 +4059,7 @@ void LLVOAvatar::slamPosition() bool LLVOAvatar::isVisuallyMuted() { + if(isSelf())return false; static LLCachedControl max_attachment_bytes(gSavedSettings, "RenderAutoMuteByteLimit"); static LLCachedControl max_attachment_area(gSavedSettings, "RenderAutoMuteSurfaceAreaLimit"); @@ -4917,8 +4918,8 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) if (pass == AVATAR_RENDER_PASS_SINGLE) { - - const bool should_alpha_mask = shouldAlphaMask(); + bool is_muted = isVisuallyMuted(); //Disable masking and also disable alpha in LLViewerJoint::render + const bool should_alpha_mask = !is_muted && shouldAlphaMask(); LLGLState test(GL_ALPHA_TEST, should_alpha_mask); if (should_alpha_mask && !LLGLSLShader::sNoFixedFunction) @@ -4933,19 +4934,19 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) { if (isTextureVisible(TEX_HEAD_BAKED) || mIsDummy) { - num_indices += mMeshLOD[MESH_ID_HEAD]->render(mAdjustedPixelArea, TRUE, mIsDummy); + num_indices += mMeshLOD[MESH_ID_HEAD]->render(mAdjustedPixelArea, TRUE, mIsDummy || is_muted); first_pass = FALSE; } } if (isTextureVisible(TEX_UPPER_BAKED) || mIsDummy) { - num_indices += mMeshLOD[MESH_ID_UPPER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy); + num_indices += mMeshLOD[MESH_ID_UPPER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy || is_muted); first_pass = FALSE; } if (isTextureVisible(TEX_LOWER_BAKED) || mIsDummy) { - num_indices += mMeshLOD[MESH_ID_LOWER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy); + num_indices += mMeshLOD[MESH_ID_LOWER_BODY]->render(mAdjustedPixelArea, first_pass, mIsDummy || is_muted); first_pass = FALSE; } } From eaecc9a4d096eecc26dacc72c86ed9f5360410e4 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Mon, 30 Jan 2012 19:50:41 -0600 Subject: [PATCH 16/36] RenderVBOEnable was completely broken by ll, so I fixed it. --- indra/llrender/llvertexbuffer.cpp | 47 +++++++++++-------------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 21f486da6..99fcebc4a 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -750,41 +750,26 @@ void LLVertexBuffer::cleanupClass() S32 LLVertexBuffer::determineUsage(S32 usage) { - S32 ret_usage = usage; - - if (!sEnableVBOs) - { - ret_usage = 0; - } - - if (usage == GL_STREAM_DRAW_ARB && !sUseStreamDraw) - { - ret_usage = 0; - } - - if (usage == GL_DYNAMIC_DRAW_ARB && sPreferStreamDraw) - { - ret_usage = GL_STREAM_DRAW_ARB; - } - - if (usage == 0 && LLRender::sGLCoreProfile) + if (LLRender::sGLCoreProfile) { //MUST use VBOs for all rendering - ret_usage = GL_STREAM_DRAW_ARB; + if(!usage) + usage = GL_STREAM_DRAW_ARB; + } + else if (!sEnableVBOs || !usage) + { + return 0; } - if (usage && usage != GL_STREAM_DRAW_ARB) - { //only stream_draw and dynamic_draw are supported when using VBOs, dynamic draw is the default - if (sDisableVBOMapping) - { //always use stream draw if VBO mapping is disabled - ret_usage = GL_STREAM_DRAW_ARB; - } - else - { - ret_usage = GL_DYNAMIC_DRAW_ARB; - } + //Only stream_draw and dynamic_draw are supported when using VBOs, dynamic draw is the default. + //Always use stream_draw VBO if mapping is disabled, or stream is enabled and preferred/expected + if( sDisableVBOMapping || (sUseStreamDraw && (sPreferStreamDraw || usage == GL_STREAM_DRAW_ARB))) + { + return GL_STREAM_DRAW_ARB; + } + else + { + return GL_DYNAMIC_DRAW_ARB; } - - return ret_usage; } LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) : From d15ed9ed3471c8027fc7d23f5b01f86e46445e7f Mon Sep 17 00:00:00 2001 From: Shyotl Date: Tue, 31 Jan 2012 02:54:42 -0600 Subject: [PATCH 17/36] I borked up the sUseStreamDraw logic earlier. When its a stream type, and sUseStreamDraw is false, don't use a vbo at all (I mistakenly had it use a dynamic vbo instead). Also, removed an unused (due to being renamed) setting from settings.xml --- indra/llrender/llvertexbuffer.cpp | 9 ++++----- indra/newview/app_settings/settings.xml | 11 ----------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 99fcebc4a..6a9ee5997 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -753,16 +753,15 @@ S32 LLVertexBuffer::determineUsage(S32 usage) if (LLRender::sGLCoreProfile) { //MUST use VBOs for all rendering if(!usage) - usage = GL_STREAM_DRAW_ARB; + return GL_STREAM_DRAW_ARB; } - else if (!sEnableVBOs || !usage) + else if (!sEnableVBOs || !usage || (!sUseStreamDraw && usage == GL_STREAM_DRAW_ARB)) { return 0; } - //Only stream_draw and dynamic_draw are supported when using VBOs, dynamic draw is the default. - //Always use stream_draw VBO if mapping is disabled, or stream is enabled and preferred/expected - if( sDisableVBOMapping || (sUseStreamDraw && (sPreferStreamDraw || usage == GL_STREAM_DRAW_ARB))) + //Always use stream_draw VBO if mapping is disabled, or stream is preferred or expected + if( sDisableVBOMapping || sPreferStreamDraw || (usage == GL_STREAM_DRAW_ARB)) { return GL_STREAM_DRAW_ARB; } diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 1cdd74902..55f6a70f0 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -11379,17 +11379,6 @@ Boolean Value 1 - - RenderUseStreamVBO - - Comment - Use VBO's for stream buffers - Persist - 1 - Type - Boolean - Value - 1 RenderPreferStreamDraw From 8ae25e48124307cdf19f21f7881fabdd7a6d5dda Mon Sep 17 00:00:00 2001 From: Shyotl Date: Tue, 31 Jan 2012 02:57:32 -0600 Subject: [PATCH 18/36] GCC compile fix. --- indra/newview/llpanelmaininventory.h | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/llpanelmaininventory.h b/indra/newview/llpanelmaininventory.h index 7cb2d23a2..43d4184d1 100644 --- a/indra/newview/llpanelmaininventory.h +++ b/indra/newview/llpanelmaininventory.h @@ -44,6 +44,7 @@ class LLToggleableMenu; class LLFloater; class LLSearchEditor; class LLComboBox; +class LLFloaterInventoryFinder; class LLInventoryView : public LLFloater, LLInventoryObserver { From a4e05eea9dbf09be66d7530b5b97384ce394bcd0 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Wed, 1 Feb 2012 03:23:55 +0100 Subject: [PATCH 19/36] Delete singleton instance last, which seems slightly more robust. --- indra/llcommon/llsingleton.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 49d99f2cd..07ac7d8ce 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -151,9 +151,10 @@ public: */ static void deleteSingleton() { - delete getData().mSingletonInstance; - getData().mSingletonInstance = NULL; + DERIVED_TYPE* instance = getData().mSingletonInstance; getData().mInitState = DELETED; + getData().mSingletonInstance = NULL; + delete instance; } static SingletonInstanceData& getData() From 77a21f95e52487129e90d981d845242c7ef03f05 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Wed, 1 Feb 2012 03:27:04 +0100 Subject: [PATCH 20/36] Singleton<> improvements. Allow Singleton<>::instance to be inlined and add a new warning for accesses to the singleton while its being initialized. --- indra/llcommon/llsingleton.h | 46 +++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 07ac7d8ce..6fac2c8a9 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -176,25 +176,11 @@ public: { SingletonInstanceData& data = getData(); - if (data.mInitState == CONSTRUCTING) + if (data.mInitState != INITIALIZED) { - llerrs << "Tried to access singleton " << typeid(DERIVED_TYPE).name() << " from singleton constructor!" << llendl; + createInstance(data); } - if (data.mInitState == DELETED) - { - llwarns << "Trying to access deleted singleton " << typeid(DERIVED_TYPE).name() << " creating new instance" << llendl; - } - - if (!data.mSingletonInstance) - { - data.mInitState = CONSTRUCTING; - data.mSingletonInstance = new DERIVED_TYPE(); - data.mInitState = INITIALIZING; - data.mSingletonInstance->initSingleton(); - data.mInitState = INITIALIZED; - } - return data.mSingletonInstance; } @@ -220,7 +206,35 @@ public: } private: + static void createInstance(SingletonInstanceData& data); virtual void initSingleton() {} }; +// Moved this here cause it's too big to be inlined --Aleric. +template +void LLSingleton::createInstance(SingletonInstanceData& data) +{ + if (data.mInitState == CONSTRUCTING) + { + llerrs << "Tried to access singleton " << typeid(DERIVED_TYPE).name() << " from singleton constructor!" << llendl; + } + + if (data.mInitState == DELETED) + { + llwarns << "Trying to access deleted singleton " << typeid(DERIVED_TYPE).name() << " creating new instance" << llendl; + } + + if (data.mInitState == INITIALIZING) + { + llwarns << "Tried to access singleton " << typeid(DERIVED_TYPE).name() << " from initSingleton(), using half-initialized object" << llendl; + return; + } + + data.mInitState = CONSTRUCTING; + data.mSingletonInstance = new DERIVED_TYPE(); + data.mInitState = INITIALIZING; + data.mSingletonInstance->initSingleton(); + data.mInitState = INITIALIZED; +} + #endif From 2044b880153e049b5c7f691f7b6425a7f604843b Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Wed, 1 Feb 2012 03:31:19 +0100 Subject: [PATCH 21/36] Don't use NamedTimerFactory while it's being initialized. --- indra/llcommon/llfasttimer_class.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/indra/llcommon/llfasttimer_class.cpp b/indra/llcommon/llfasttimer_class.cpp index 20f64d1a1..9b09b7926 100644 --- a/indra/llcommon/llfasttimer_class.cpp +++ b/indra/llcommon/llfasttimer_class.cpp @@ -130,8 +130,16 @@ public: mActiveTimerRoot->setCollapsed(false); mRootFrameState = new LLFastTimer::FrameState(mActiveTimerRoot); - mRootFrameState->mParent = &mTimerRoot->getFrameState(); - mActiveTimerRoot->setParent(mTimerRoot); + // getFrameState and setParent recursively call this function, + // so we have to work around that by using a specialized implementation + // for the special case were mTimerRoot != mActiveTimerRoot -- Aleric + mRootFrameState->mParent = &LLFastTimer::getFrameStateList()[0]; // &mTimerRoot->getFrameState() + // And the following four lines are mActiveTimerRoot->setParent(mTimerRoot); + llassert(!mActiveTimerRoot->mParent); + mActiveTimerRoot->mParent = mTimerRoot; // mParent = parent; + mRootFrameState->mParent = mRootFrameState->mParent; // getFrameState().mParent = &parent->getFrameState(); + mTimerRoot->getChildren().push_back(mActiveTimerRoot); // parent->getChildren().push_back(this); + mTimerRoot->mNeedsSorting = true; // parent->mNeedsSorting = true; mAppTimer = new LLFastTimer(mRootFrameState); } From e1675f6bd1db1cedcdbdb81367b9cd53b788d095 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Wed, 1 Feb 2012 03:32:10 +0100 Subject: [PATCH 22/36] Remove erroneous comment. --- indra/llimage/llimage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 0bed6468d..5005fddab 100644 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -330,7 +330,7 @@ public: virtual void setLastError(const std::string& message, const std::string& filename = std::string()); protected: - BOOL copyData(U8 *data, S32 size); // calls updateData() + BOOL copyData(U8 *data, S32 size); protected: S8 mCodec; From e7b2972fc8fc1cf6ea32630910a870446c632ae6 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Wed, 1 Feb 2012 03:33:39 +0100 Subject: [PATCH 23/36] LLVFile::readFile must return LLPrivateMemoryPool allocated data. --- indra/llvfs/llvfile.cpp | 6 +++--- indra/llvfs/llvfile.h | 4 +++- indra/newview/lltexlayer.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/indra/llvfs/llvfile.cpp b/indra/llvfs/llvfile.cpp index 7e60c0fd5..419d1b76c 100644 --- a/indra/llvfs/llvfile.cpp +++ b/indra/llvfs/llvfile.cpp @@ -130,7 +130,7 @@ BOOL LLVFile::read(U8 *buffer, S32 bytes, BOOL async, F32 priority) } //static -U8* LLVFile::readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read) +U8* LLVFile::readFile(LLVFS *vfs, LLPrivateMemoryPool* poolp, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read) { U8 *data; LLVFile file(vfs, uuid, type, LLVFile::READ); @@ -142,12 +142,12 @@ U8* LLVFile::readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S } else { - data = new U8[file_size]; + data = (U8*)ALLOCATE_MEM(poolp, file_size); file.read(data, file_size); /* Flawfinder: ignore */ if (file.getLastBytesRead() != (S32)file_size) { - delete[] data; + FREE_MEM(poolp, data); data = NULL; file_size = 0; } diff --git a/indra/llvfs/llvfile.h b/indra/llvfs/llvfile.h index c3bca8c73..6a112cc45 100644 --- a/indra/llvfs/llvfile.h +++ b/indra/llvfs/llvfile.h @@ -38,6 +38,8 @@ #include "llvfs.h" #include "llvfsthread.h" +class LLPrivateMemoryPool; + class LLVFile { public: @@ -45,7 +47,7 @@ public: ~LLVFile(); BOOL read(U8 *buffer, S32 bytes, BOOL async = FALSE, F32 priority = 128.f); /* Flawfinder: ignore */ - static U8* readFile(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read = 0); + static U8* readFile(LLVFS *vfs, LLPrivateMemoryPool* poolp, const LLUUID &uuid, LLAssetType::EType type, S32* bytes_read = 0); void setReadPriority(const F32 priority); BOOL isReadComplete(); S32 getLastBytesRead(); diff --git a/indra/newview/lltexlayer.cpp b/indra/newview/lltexlayer.cpp index 06f72c774..9bd5ebf94 100644 --- a/indra/newview/lltexlayer.cpp +++ b/indra/newview/lltexlayer.cpp @@ -402,7 +402,7 @@ void LLTexLayerSetBuffer::readBackAndUpload() BOOL valid = FALSE; LLPointer integrity_test = new LLImageJ2C; S32 file_size = 0; - U8* data = LLVFile::readFile(gVFS, asset_id, LLAssetType::AT_TEXTURE, &file_size); + U8* data = LLVFile::readFile(gVFS, LLImageBase::getPrivatePool(), asset_id, LLAssetType::AT_TEXTURE, &file_size); if (data) { valid = integrity_test->validate(data, file_size); // integrity_test will delete 'data' From 315552d1e08c66709a4db6acf5a933529f4c438c Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Wed, 1 Feb 2012 03:34:19 +0100 Subject: [PATCH 24/36] Allow main window to be unfocused during startup in debug mode. --- indra/newview/llstartup.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index d678dc490..cddfdf3e6 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -2766,6 +2766,11 @@ bool idle_startup() LL_DEBUGS("AppInit") << "Initialization complete" << LL_ENDL; gRenderStartTime.reset(); + // We're not allowed to call reset() when paused, and we might or might not be paused depending on + // whether or not the main window lost focus before we get here (see LLViewerWindow::handleFocusLost). + // The simplest, legal way to make sure we're unpaused is to just pause/unpause here. + gForegroundTime.pause(); + gForegroundTime.unpause(); gForegroundTime.reset(); if (gSavedSettings.getBOOL("FetchInventoryOnLogin") From e9fa5e6f3dd36ae54f9a8c75b3e2e21dcfa97531 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Wed, 1 Feb 2012 07:48:40 -0600 Subject: [PATCH 25/36] Fixed some static initialization brokenness with fasttimers. --- indra/llcommon/llfasttimer_class.cpp | 37 ++++++++++++++++------------ indra/llcommon/llfasttimer_class.h | 27 +++++++++++++------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/indra/llcommon/llfasttimer_class.cpp b/indra/llcommon/llfasttimer_class.cpp index 1f7d0432a..240f2c61a 100644 --- a/indra/llcommon/llfasttimer_class.cpp +++ b/indra/llcommon/llfasttimer_class.cpp @@ -57,7 +57,6 @@ S32 LLFastTimer::sLastFrameIndex = -1; U64 LLFastTimer::sLastFrameTime = LLFastTimer::getCPUClockCount64(); bool LLFastTimer::sPauseHistory = 0; bool LLFastTimer::sResetHistory = 0; -LLFastTimer::CurTimerData LLFastTimer::sCurTimerData; BOOL LLFastTimer::sLog = FALSE; std::string LLFastTimer::sLogName = ""; BOOL LLFastTimer::sMetricLog = FALSE; @@ -72,7 +71,6 @@ U64 LLFastTimer::sClockResolution = 1000000000; // Nanosecond resolution U64 LLFastTimer::sClockResolution = 1000000; // Microsecond resolution #endif -std::vector* LLFastTimer::sTimerInfos = NULL; U64 LLFastTimer::sTimerCycles = 0; U32 LLFastTimer::sTimerCalls = 0; @@ -235,7 +233,8 @@ void LLFastTimer::DeclareTimer::updateCachedPointers() } // also update frame states of timers on stack - LLFastTimer* cur_timerp = LLFastTimer::sCurTimerData.mCurTimer; + static LLFastTimer::CurTimerData& static_cur_data = LLFastTimer::CurTimerData::get(); + LLFastTimer* cur_timerp = static_cur_data.mCurTimer; while(cur_timerp->mLastTimerData.mCurTimer != cur_timerp) { cur_timerp->mFrameState = &cur_timerp->mFrameState->mTimer->getFrameState(); @@ -462,10 +461,12 @@ void LLFastTimer::NamedTimer::accumulateTimings() { U32 cur_time = getCPUClockCount32(); + static LLFastTimer::CurTimerData& static_cur_data = LLFastTimer::CurTimerData::get(); + // walk up stack of active timers and accumulate current time while leaving timing structures active - LLFastTimer* cur_timer = sCurTimerData.mCurTimer; + LLFastTimer* cur_timer = static_cur_data.mCurTimer; // root defined by parent pointing to self - CurTimerData* cur_data = &sCurTimerData; + CurTimerData* cur_data = &static_cur_data; while(cur_timer->mLastTimerData.mCurTimer != cur_timer) { U32 cumulative_time_delta = cur_time - cur_timer->mStartTime; @@ -614,8 +615,10 @@ void LLFastTimer::NamedTimer::reset() // effectively zeroing out any accumulated time U32 cur_time = getCPUClockCount32(); + static LLFastTimer::CurTimerData& static_cur_data = LLFastTimer::CurTimerData::get(); + // root defined by parent pointing to self - CurTimerData* cur_data = &sCurTimerData; + CurTimerData* cur_data = &static_cur_data; LLFastTimer* cur_timer = cur_data->mCurTimer; while(cur_timer->mLastTimerData.mCurTimer != cur_timer) { @@ -649,12 +652,13 @@ void LLFastTimer::NamedTimer::reset() //static LLFastTimer::info_list_t& LLFastTimer::getFrameStateList() -{ - if (!sTimerInfos) - { - sTimerInfos = new info_list_t(); - } - return *sTimerInfos; +{ + //Static local varaible to avoid static initialization order fiasco. + //NamedTimerFactory ctor uses this object, and is called during static initialization... + //often before llfasttimer_class.cpp's translation unit. + //'leak' is harmless and intended to ensure it out-scopes NamedTimerFactory. + static info_list_t* timer_infos = new info_list_t(); + return *timer_infos; } @@ -787,10 +791,11 @@ LLFastTimer::LLFastTimer(LLFastTimer::FrameState* state) U32 start_time = getCPUClockCount32(); mStartTime = start_time; mFrameState->mActiveCount++; - LLFastTimer::sCurTimerData.mCurTimer = this; - LLFastTimer::sCurTimerData.mFrameState = mFrameState; - LLFastTimer::sCurTimerData.mChildTime = 0; - mLastTimerData = LLFastTimer::sCurTimerData; + static LLFastTimer::CurTimerData& static_cur_data = LLFastTimer::CurTimerData::get(); + static_cur_data.mCurTimer = this; + static_cur_data.mFrameState = mFrameState; + static_cur_data.mChildTime = 0; + mLastTimerData = static_cur_data; } diff --git a/indra/llcommon/llfasttimer_class.h b/indra/llcommon/llfasttimer_class.h index 27db83c28..9a547dd69 100644 --- a/indra/llcommon/llfasttimer_class.h +++ b/indra/llcommon/llfasttimer_class.h @@ -169,11 +169,11 @@ public: // keep current parent as long as it is active when we are frame_state->mMoveUpTree |= (frame_state->mParent->mActiveCount == 0); - LLFastTimer::CurTimerData* cur_timer_data = &LLFastTimer::sCurTimerData; - mLastTimerData = *cur_timer_data; - cur_timer_data->mCurTimer = this; - cur_timer_data->mFrameState = frame_state; - cur_timer_data->mChildTime = 0; + static LLFastTimer::CurTimerData& static_cur_data = LLFastTimer::CurTimerData::get(); + mLastTimerData = static_cur_data; + static_cur_data.mCurTimer = this; + static_cur_data.mFrameState = frame_state; + static_cur_data.mChildTime = 0; #endif #if TIME_FAST_TIMERS U64 timer_end = getCPUClockCount64(); @@ -195,7 +195,9 @@ public: LLFastTimer::FrameState* frame_state = mFrameState; U32 total_time = getCPUClockCount32() - mStartTime; - frame_state->mSelfTimeCounter += total_time - LLFastTimer::sCurTimerData.mChildTime; + static LLFastTimer::CurTimerData& static_cur_data = LLFastTimer::CurTimerData::get(); + + frame_state->mSelfTimeCounter += total_time - static_cur_data.mChildTime; frame_state->mActiveCount--; // store last caller to bootstrap tree creation @@ -205,7 +207,7 @@ public: // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; - LLFastTimer::sCurTimerData = mLastTimerData; + static_cur_data = mLastTimerData; #endif #if TIME_FAST_TIMERS U64 timer_end = getCPUClockCount64(); @@ -252,8 +254,16 @@ public: LLFastTimer* mCurTimer; FrameState* mFrameState; U32 mChildTime; + static CurTimerData& get() + { + //Static local varaible to avoid static initialization order fiasco. + //NamedTimerFactory ctor uses this object, and is called during static initialization... + //often before llfasttimer_class.cpp's translation unit. + //'leak' is harmless and intended to ensure it out-scopes NamedTimerFactory. + static CurTimerData* timer_data = new CurTimerData(); + return *timer_data; + } }; - static CurTimerData sCurTimerData; static std::string sClockType; public: @@ -265,7 +275,6 @@ private: static S32 sCurFrameIndex; static S32 sLastFrameIndex; static U64 sLastFrameTime; - static info_list_t* sTimerInfos; U32 mStartTime; LLFastTimer::FrameState* mFrameState; From 1747d529d8af8b16690ea91e2d99c834a56226e8 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Thu, 2 Feb 2012 18:05:07 -0600 Subject: [PATCH 26/36] Stall object updates (including flexi) while tiling. Also fix matrix stack breakage --- indra/newview/llviewerdisplay.cpp | 19 +++++++++++-------- indra/newview/pipeline.cpp | 8 ++++++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 1631bdeeb..a78f98f2d 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -639,14 +639,17 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo LLHUDObject::updateAll(); stop_glerror(); - gFrameStats.start(LLFrameStats::UPDATE_GEOM); - const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds; // 50 ms/second update time - gPipeline.createObjects(max_geom_update_time); - gPipeline.processPartitionQ(); - gPipeline.updateGeom(max_geom_update_time); - stop_glerror(); - gPipeline.updateGL(); - stop_glerror(); + if(!tiling) + { + gFrameStats.start(LLFrameStats::UPDATE_GEOM); + const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds; // 50 ms/second update time + gPipeline.createObjects(max_geom_update_time); + gPipeline.processPartitionQ(); + gPipeline.updateGeom(max_geom_update_time); + stop_glerror(); + gPipeline.updateGL(); + stop_glerror(); + } gFrameStats.start(LLFrameStats::UPDATE_CULL); S32 water_clip = 0; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 3daee4398..f9cf2030e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6153,6 +6153,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b if (tiling && !LLPipeline::sRenderDeferred) //Need to coax this into working with deferred now that tiling is back. { + gGlowCombineProgram.bind(); + gGL.getTexUnit(0)->bind(&mGlow[1]); { //LLGLEnable stencil(GL_STENCIL_TEST); @@ -6194,12 +6196,14 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b gGL.setSceneBlendType(LLRender::BT_ALPHA); } - gGL.flush(); gGL.matrixMode(LLRender::MM_PROJECTION); gGL.popMatrix(); - gGL.matrixMode(GL_MODELVIEW); + gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); + gGlowCombineProgram.unbind(); + + gGL.flush(); return; } From db28c382e02a10df313a7ad0b24b4dc725a45b7c Mon Sep 17 00:00:00 2001 From: Shyotl Date: Thu, 2 Feb 2012 18:07:29 -0600 Subject: [PATCH 27/36] Apparently LLMeshRepoThread::lodReceived leaked and LL decided to fix it. --- indra/newview/llmeshrepository.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index a6409c5b3..7af322e63 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1075,17 +1075,19 @@ bool LLMeshRepoThread::headerReceived(const LLVolumeParams& mesh_params, U8* dat bool LLMeshRepoThread::lodReceived(const LLVolumeParams& mesh_params, S32 lod, U8* data, S32 data_size) { - LLVolume* volume = new LLVolume(mesh_params, LLVolumeLODGroup::getVolumeScaleFromDetail(lod)); + LLPointer volume = new LLVolume(mesh_params, LLVolumeLODGroup::getVolumeScaleFromDetail(lod)); std::string mesh_string((char*) data, data_size); std::istringstream stream(mesh_string); if (volume->unpackVolumeFaces(stream, data_size)) { - LoadedMesh mesh(volume, mesh_params, lod); if (volume->getNumFaces() > 0) { - LLMutexLock lock(mMutex); - mLoadedQ.push(mesh); + LoadedMesh mesh(volume, mesh_params, lod); + { + LLMutexLock lock(mMutex); + mLoadedQ.push(mesh); + } return true; } } From a690c970e6bc16a6c81d22b902d09ad5490dd043 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Thu, 2 Feb 2012 18:14:52 -0600 Subject: [PATCH 28/36] RenderAutoMuteByteLimit and RenderAutoMuteSurfaceArea: Only 'grey' out visually blocked avatars on impostor pass. --- indra/newview/llvoavatar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index aa807c282..100d9445a 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -4918,7 +4918,7 @@ U32 LLVOAvatar::renderSkinned(EAvatarRenderPass pass) if (pass == AVATAR_RENDER_PASS_SINGLE) { - bool is_muted = isVisuallyMuted(); //Disable masking and also disable alpha in LLViewerJoint::render + bool is_muted = LLPipeline::sImpostorRender && isVisuallyMuted(); //Disable masking and also disable alpha in LLViewerJoint::render const bool should_alpha_mask = !is_muted && shouldAlphaMask(); LLGLState test(GL_ALPHA_TEST, should_alpha_mask); From 5e0140ba81b3d18ff2bb26d3d3a91a34ed930b8c Mon Sep 17 00:00:00 2001 From: Shyotl Date: Thu, 2 Feb 2012 23:43:04 -0600 Subject: [PATCH 29/36] Fixed a minor syntax error in menu_inventory.xml. --- indra/newview/skins/default/xui/en-us/menu_inventory.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/skins/default/xui/en-us/menu_inventory.xml b/indra/newview/skins/default/xui/en-us/menu_inventory.xml index c34e9fe34..37f0f9d21 100644 --- a/indra/newview/skins/default/xui/en-us/menu_inventory.xml +++ b/indra/newview/skins/default/xui/en-us/menu_inventory.xml @@ -306,5 +306,5 @@ - <--menu_item_separator name="Wearable Separator" /--> + From 9ee0c5acf308bd0af56435a939c17b10e419a3c4 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Thu, 2 Feb 2012 23:44:35 -0600 Subject: [PATCH 30/36] Having BackgroundYieldTime set to a large enough value would cause a stall if client isn't in focus during login. --- indra/newview/llappviewer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index a349c66d0..b42ead885 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1213,6 +1213,9 @@ bool LLAppViewer::mainLoop() // of equal priority on Windows if (milliseconds_to_sleep > 0) { + //Prevent sleeping too long while in the login process (tends to cause stalling) + if(LLStartUp::getStartupState() >= STATE_LOGIN_AUTH_INIT && LLStartUp::getStartupState() < STATE_STARTED) + milliseconds_to_sleep = llmin(milliseconds_to_sleep,250); ms_sleep(milliseconds_to_sleep); // also pause worker threads during this wait period LLAppViewer::getTextureCache()->pause(); From 726dc02aaa7e9e648b117fbdb9de6e7b5daf50a7 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Fri, 3 Feb 2012 14:11:10 -0600 Subject: [PATCH 31/36] Was looking up ascent colors in incorrect control group. --- indra/newview/llvoavatar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 100d9445a..bff31c7f0 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -3612,25 +3612,25 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last) //Lindens are always more Linden than your friend, make that take precedence if(LLMuteList::getInstance()->isLinden(getFullname())) { - static const LLCachedControl ascent_linden_color(gColors, "AscentLindenColor" ); + static const LLCachedControl ascent_linden_color( "AscentLindenColor" ); mClientColor = ascent_linden_color; } //check if they are an estate owner at their current position else if(estate_owner.notNull() && this->getID() == estate_owner) { - static const LLCachedControl ascent_estate_owner_color(gColors, "AscentEstateOwnerColor" ); + static const LLCachedControl ascent_estate_owner_color( "AscentEstateOwnerColor" ); mClientColor = ascent_estate_owner_color; } //without these dots, SL would suck. else if (LLAvatarTracker::instance().getBuddyInfo(this->getID()) != NULL) { - static const LLCachedControl ascent_friend_color(gColors, "AscentFriendColor" ); + static const LLCachedControl ascent_friend_color( "AscentFriendColor" ); mClientColor = ascent_friend_color; } //big fat jerkface who is probably a jerk, display them as such. else if(LLMuteList::getInstance()->isMuted(this->getID())) { - static const LLCachedControl ascent_muted_color(gColors, "AscentMutedColor" ); + static const LLCachedControl ascent_muted_color( "AscentMutedColor" ); mClientColor = ascent_muted_color; } } From b6fa215c4efc735ecdf07ab362631e5c49bd5c6f Mon Sep 17 00:00:00 2001 From: Shyotl Date: Fri, 3 Feb 2012 14:11:29 -0600 Subject: [PATCH 32/36] Don't render particles on visually muted avatars. --- indra/newview/llviewerpartsim.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp index 4759454ee..e70975b11 100644 --- a/indra/newview/llviewerpartsim.cpp +++ b/indra/newview/llviewerpartsim.cpp @@ -682,7 +682,7 @@ void LLViewerPartSim::updateSimulation() if (!mViewerPartSources[i]->isDead()) { BOOL upd = TRUE; - if (!LLPipeline::sRenderAttachedParticles) + //if (!LLPipeline::sRenderAttachedParticles) { LLViewerObject* vobj = mViewerPartSources[i]->mSourceObjectp; if (vobj && (vobj->getPCode() == LL_PCODE_VOLUME)) @@ -690,7 +690,14 @@ void LLViewerPartSim::updateSimulation() LLVOVolume* vvo = (LLVOVolume *)vobj; if (vvo && vvo->isAttachment()) { - upd = FALSE; + if (!LLPipeline::sRenderAttachedParticles) + upd = FALSE; + else + { + LLVOAvatar *avatar = vvo->getAvatar(); + if(avatar && avatar->isVisuallyMuted()) + upd = FALSE; + } } } } From bf44d3f98e0419195e6bb601aa6a028aa973f449 Mon Sep 17 00:00:00 2001 From: Shyotl Date: Fri, 3 Feb 2012 14:12:36 -0600 Subject: [PATCH 33/36] Prevent using multisample FBOs if FBOs are not enabled, or multisample FBOs are unsupported --- indra/newview/pipeline.cpp | 11 ++++++++--- indra/newview/pipeline.h | 1 - 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f9cf2030e..cb3c19b74 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -607,7 +607,13 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) { refreshCachedSettings(); static const LLCachedControl RenderFSAASamples("RenderFSAASamples",0); - U32 samples = RenderFSAASamples; + U32 samples = RenderFSAASamples.get() - RenderFSAASamples.get() % 2; //Must be multipe of 2. + + //Don't multisample if not using FXAA, or if fbos are disabled, or if multisampled fbos are not supported. + if(!LLPipeline::sRenderDeferred && (!LLRenderTarget::sUseFBO || !gGLManager.mHasFramebufferMultisample)) + { + samples = 0; + } //try to allocate screen buffers at requested resolution and samples // - on failure, shrink number of samples and try again @@ -628,8 +634,7 @@ void LLPipeline::allocateScreenBuffer(U32 resX, U32 resY) releaseScreenBuffers(); } - if(LLPipeline::sRenderDeferred || !LLRenderTarget::sUseFBO || !gGLManager.mHasFramebufferMultisample) - samples = 0; + samples = 0; //reduce resolution while (resY > 0 && resX > 0) diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 5b139f860..47e7b963e 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -502,7 +502,6 @@ public: static BOOL sRenderBump; static BOOL sBakeSunlight; static BOOL sNoAlpha; - static BOOL sUseFBO; static BOOL sUseFarClip; static BOOL sShadowRender; static BOOL sSkipUpdate; //skip lod updates From e18e051bfcc88997706cb65bcc366a01aa2e753f Mon Sep 17 00:00:00 2001 From: Shyotl Date: Fri, 3 Feb 2012 14:25:51 -0600 Subject: [PATCH 34/36] sDelayedVBOEnable is still required to prevent framerates from getting clobbered on gl context change. --- indra/newview/pipeline.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index cb3c19b74..ee5968a41 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -158,7 +158,7 @@ extern BOOL gDebugGL; // hack counter for rendering a fixed number of frames after toggling // fullscreen to work around DEV-5361 -//static S32 sDelayedVBOEnable = 0; +static S32 sDelayedVBOEnable = 0; BOOL gAvatarBacklight = FALSE; @@ -556,8 +556,11 @@ void LLPipeline::destroyGL() if (LLVertexBuffer::sEnableVBOs) { // render 30 frames after switching to work around DEV-5361 - //sDelayedVBOEnable = 30; - LLVertexBuffer::sEnableVBOs = FALSE; + if(!LLRenderTarget::sUseFBO) + { + sDelayedVBOEnable = 30; + LLVertexBuffer::sEnableVBOs = FALSE; + } } } @@ -580,6 +583,7 @@ void LLPipeline::throttleNewMemoryAllocation(BOOL disable) } } } + void LLPipeline::resizeScreenTexture() { LLFastTimer ft(FTM_RESIZE_SCREEN_TEXTURE); @@ -2331,14 +2335,14 @@ void LLPipeline::updateGeom(F32 max_dtime) assertInitialized(); - /*if (sDelayedVBOEnable > 0) + if (sDelayedVBOEnable > 0) { if (--sDelayedVBOEnable <= 0) { resetVertexBuffers(); LLVertexBuffer::sEnableVBOs = TRUE; } - }*/ + } // notify various object types to reset internal cost metrics, etc. // for now, only LLVOVolume does this to throttle LOD changes From 5a455eac9175581db4568cfc93b2c96091318281 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Sat, 4 Feb 2012 18:28:24 +0100 Subject: [PATCH 35/36] Fixed LLFastTimers et al. No longer crash when std::vector moves in memory when it grows. Fixed display of timer values (in ms). --- indra/llcommon/llfasttimer_class.cpp | 241 ++++++++++++++---- indra/llcommon/llfasttimer_class.h | 14 +- indra/llcommon/lltimer.cpp | 6 +- indra/llcommon/lltimer.h | 2 +- indra/newview/statemachine/aistatemachine.cpp | 6 +- 5 files changed, 201 insertions(+), 68 deletions(-) diff --git a/indra/llcommon/llfasttimer_class.cpp b/indra/llcommon/llfasttimer_class.cpp index 1f7d0432a..81ccc8a8e 100644 --- a/indra/llcommon/llfasttimer_class.cpp +++ b/indra/llcommon/llfasttimer_class.cpp @@ -23,6 +23,125 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ + +// +// LLFastTimer documentation, written by Aleric (Feb 2012). +// +// Disclaimer: this is horrible code and I distantiate myself from it's design. +// It's neither robust nor object oriented. I just document what I find, in +// order to be able to fix the bugs (that logically result from such a design). +// +// Note that the choosen names of the variables are non-intuitive and make +// understanding the code harder. However, I didn't change them in order to +// make merging less of a nightmare in the future -- Aleric. +// +// +// First of all, absolutely nothing in this code is even remotely thread-safe: +// FastTimers should only be used from the main thread and never from another +// thread. +// +// NamedTimerFactory is a singleton, accessed through NamedTimerFactory::instance(). +// +// It has four pointer members which are initialized once to point to +// four objects with a life-time equal to the application/singleton: +// +// mTimerRoot --> NamedTimer("root") +// mActiveTimerRoot --> NamedTimer("Frame") +// mRootFrameState --> FrameState(mActiveTimerRoot) +// mAppTimer --> LLFastTimer(mRootFrameState) +// +// A NamedTimer has a name and a life-time of approximately that of the application. +// There is exactly one instance per unique name. +// NamedTimer's are ordered in a hierarchy with each one parent and zero or more +// children (the "root" has parent NULL). +// The parent of mActiveTimerRoot is mTimerRoot, which has one child: mActiveTimerRoot. +// NamedTimer::getDepth() returns the number of parents; mTimerRoot has a depth of 0, +// mActiveTimerRoot has a depth of 1 and so on. NamedTimer::getRootNamedTimer() just +// returns mActiveTimerRoot. +// +// Each NamedTimer is linked to exactly one FrameState object, namely +// LLFastTimer::getFrameStateList()[named_timer.getFrameStateIndex()], where +// getFrameStateList() is a static function returning a global std::vector. +// This vector is ordered "Depth First" (the FrameState objects (belonging to +// NamedTimer objects) with smallest depth first). The vector is resorted a few +// times in the beginning (and indexes in FrameState updated) since timers are added +// whenever they are first used, not in "Depth First" order, but stabilizes after a +// while. This implies that FrameState pointers can't really be used: FrameState +// objects move around in memory whenever something is inserted or removed from the +// std::vector and/or when the vector is resorted. However, FrameState pointers ARE +// being used and code exists that tries to update those pointers in the above +// mentioned cases (this part had bugs, which I now fixed). +// +// FrameState objects point back to their corresponding NamedTimer through mTimer. +// They have also parents: the FrameState object corresponding to the parent of mTimer. +// +// Thus, so far we have (assuming "namedtimerX" was created first): +// +// NamedTimer's: FrameState's: +// +// NULL +// ^ +// | +// depth=0: "root" (mTimerRoot) <-------> getFrameStateList()[0] +// ^ ^ +// | (parent) | (parent) +// | | +// depth=1: "Frame" (mActiveTimerRoot) <-------> mRootFrameState +// ^ ^ ^ ^ +// | | | | +// | (parent) | (parent) | (parent) | (parent) +// | | | | +// depth=2: "namedtimerX" | <-------> getFrameStateList()[2] | +// "namedtimerY" <-------> getFrameStateList()[3] +// +// where the NamedTimer's point to the corresponding FrameState's by means of +// NamedTimer::mFrameStateIndex, and the FrameState's point back through FrameState::mTimer. +// +// Note the missing getFrameStateList()[1], which is ignored and replaced by +// a specific call to 'new FrameState' in initSingleton(). The reason for that is +// probably because otherwise mRootFrameState has to be updated every time the +// frame state list vector is moved in memory. This special case adds some complexity to, +// for instance, getFrameState() which now needs to test if the caller is mActiveTimerRoot. +// +// DeclareTimer objects are NameTimer/FrameState pointer pairs with again a lifetime +// of approximately that of the application. The are usually static, even global, +// and are passed an name as string; the name is looked up and added if not already +// existing, or else the previously created pair is returned. Obviously, "root" and +// "Frame" are the only ones that don't have a corresponding DeclareTimer object. +// +// LLFastTimer objects are short lived objects, created in a scope and destroyed +// at the end in order to measure the time that the application spent in that +// scope. They are passed DeclareTimer objects to know which timer to append to. +// LLFastTimer::mFrameState is a pointer to the corresponding timer. +// The static LLFastTimer::sCurTimerData is a CurTimerData struct that has +// a duplicate of that pointer as well as a pointer to the corresponding NamedTimer, +// of the last LLFastTimer object that was created (and not destroyed again); +// in other words: the running timer with the largest depth. +// When a new LLFastTimer object is created while one is already running, +// then this sCurTimerData is saved in the already running one (as +// LLFastTimer::mLastTimerData) and restored upon destruction of that child timer. +// +// The following FrameState pointers are being used: +// +// FrameState::mParent +// DeclareTimer::mFrameState +// CurTimerData::mFrameState +// LLFastTimer::mFrameState +// +// All of those can be invalidated whenever something is added to the std::vector, +// and when that vector is sorted. +// +// Adding new FrameState objects is done in NamedTimer(std::string const& name), called from +// createNamedTimer(), called whenever a DeclareTimer is constructed. At the end of the +// DeclareTimer constructor update_cached_pointers_if_changed() is called, which calls +// updateCachedPointers() if the std::vector moved in memory since last time it was called. +// +// Sorting is done in NamedTimer::resetFrame(), which theoretically can be called from +// anywhere. Also here updateCachedPointers() is called, directly after sorting the vector. +// +// I fixed updateCachedPointers() to correct all of the above pointers and removed +// another FrameState pointer that was unnecessary. + #include "linden_common.h" #include "llfasttimer.h" @@ -64,14 +183,6 @@ BOOL LLFastTimer::sMetricLog = FALSE; LLMutex* LLFastTimer::sLogLock = NULL; std::queue LLFastTimer::sLogQueue; -#define USE_RDTSC 0 - -#if LL_LINUX || LL_SOLARIS -U64 LLFastTimer::sClockResolution = 1000000000; // Nanosecond resolution -#else -U64 LLFastTimer::sClockResolution = 1000000; // Microsecond resolution -#endif - std::vector* LLFastTimer::sTimerInfos = NULL; U64 LLFastTimer::sTimerCycles = 0; U32 LLFastTimer::sTimerCalls = 0; @@ -134,10 +245,11 @@ public: // so we have to work around that by using a specialized implementation // for the special case were mTimerRoot != mActiveTimerRoot -- Aleric mRootFrameState->mParent = &LLFastTimer::getFrameStateList()[0]; // &mTimerRoot->getFrameState() + mRootFrameState->mParent->mActiveCount = 1; // And the following four lines are mActiveTimerRoot->setParent(mTimerRoot); llassert(!mActiveTimerRoot->mParent); mActiveTimerRoot->mParent = mTimerRoot; // mParent = parent; - mRootFrameState->mParent = mRootFrameState->mParent; // getFrameState().mParent = &parent->getFrameState(); + //mRootFrameState->mParent = mRootFrameState->mParent; // getFrameState().mParent = &parent->getFrameState(); mTimerRoot->getChildren().push_back(mActiveTimerRoot); // parent->getChildren().push_back(this); mTimerRoot->mNeedsSorting = true; // parent->mNeedsSorting = true; @@ -195,7 +307,7 @@ private: LLFastTimer::NamedTimer* mActiveTimerRoot; LLFastTimer::NamedTimer* mTimerRoot; LLFastTimer* mAppTimer; - LLFastTimer::FrameState* mRootFrameState; + LLFastTimer::FrameState* mRootFrameState; // Points to memory allocated with new, so this pointer is not invalidated. }; void update_cached_pointers_if_changed() @@ -204,9 +316,9 @@ void update_cached_pointers_if_changed() static LLFastTimer::FrameState* sFirstTimerAddress = NULL; if (&*(LLFastTimer::getFrameStateList().begin()) != sFirstTimerAddress) { - LLFastTimer::DeclareTimer::updateCachedPointers(); + LLFastTimer::updateCachedPointers(); + sFirstTimerAddress = &*(LLFastTimer::getFrameStateList().begin()); } - sFirstTimerAddress = &*(LLFastTimer::getFrameStateList().begin()); } LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name, bool open ) @@ -225,53 +337,69 @@ LLFastTimer::DeclareTimer::DeclareTimer(const std::string& name) } // static -void LLFastTimer::DeclareTimer::updateCachedPointers() +void LLFastTimer::updateCachedPointers() { - // propagate frame state pointers to timer declarations - for (instance_iter it = beginInstances(); it != endInstances(); ++it) + // Update DeclareTimer::mFrameState pointers. + for (DeclareTimer::instance_iter it = DeclareTimer::beginInstances(); it != DeclareTimer::endInstances(); ++it) { // update cached pointer it->mFrameState = &it->mTimer.getFrameState(); } - // also update frame states of timers on stack - LLFastTimer* cur_timerp = LLFastTimer::sCurTimerData.mCurTimer; - while(cur_timerp->mLastTimerData.mCurTimer != cur_timerp) + // Update CurTimerData::mFrameState and LLFastTimer::mFrameState of timers on the stack. + FrameState& root_frame_state(NamedTimerFactory::instance().getRootFrameState()); // This one is not invalidated. + CurTimerData* cur_timer_data = &LLFastTimer::sCurTimerData; + // If the the following condition holds then cur_timer_data->mCurTimer == mAppTimer and + // we can stop since mAppTimer->mFrameState is allocated with new and does not invalidate. + while(cur_timer_data->mFrameState != &root_frame_state) { - cur_timerp->mFrameState = &cur_timerp->mFrameState->mTimer->getFrameState(); - cur_timerp = cur_timerp->mLastTimerData.mCurTimer; + cur_timer_data->mFrameState = cur_timer_data->mCurTimer->mFrameState = &cur_timer_data->mNamedTimer->getFrameState(); + cur_timer_data = &cur_timer_data->mCurTimer->mLastTimerData; + } + + // Update FrameState::mParent + info_list_t& frame_state_list(getFrameStateList()); + FrameState* const vector_start = &*frame_state_list.begin(); + int const vector_size = frame_state_list.size(); + FrameState const* const old_vector_start = root_frame_state.mParent; + if (vector_start != old_vector_start) + { + // Vector was moved; if it was sorted then FrameState::mParent will get fixed after returning from this function (see LLFastTimer::NamedTimer::resetFrame). + root_frame_state.mParent = vector_start; + ptrdiff_t offset = vector_start - old_vector_start; + llassert(frame_state_list[vector_size - 1].mParent == vector_start); // The one that was added at the end is already OK. + for (int i = 2; i < vector_size - 1; ++i) + { + FrameState*& parent(frame_state_list[i].mParent); + if (parent != &root_frame_state) + { + parent += offset; + } + } } } -//static -#if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) -U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer -{ - return sClockResolution >> 8; -} -#else // windows or x86-mac or x86-linux or x86-solaris -U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer -{ -#if USE_RDTSC || !LL_WINDOWS - //getCPUFrequency returns MHz and sCPUClockFrequency wants to be in Hz - static U64 sCPUClockFrequency = U64(LLProcessorInfo().getCPUFrequency()*1000000.0); - - // we drop the low-order byte in our timers, so report a lower frequency +// See lltimer.cpp. +#if LL_LINUX || LL_DARWIN || LL_SOLARIS +std::string LLFastTimer::sClockType = "gettimeofday"; +#elif LL_WINDOWS +std::string LLFastTimer::sClockType = "QueryPerformanceCounter"; #else - // If we're not using RDTSC, each fasttimer tick is just a performance counter tick. - // Not redefining the clock frequency itself (in llprocessor.cpp/calculate_cpu_frequency()) - // since that would change displayed MHz stats for CPUs +#error "Platform not supported" +#endif + +//static +U64 LLFastTimer::countsPerSecond() // counts per second for the *32-bit* timer +{ static bool firstcall = true; static U64 sCPUClockFrequency; if (firstcall) { - QueryPerformanceFrequency((LARGE_INTEGER*)&sCPUClockFrequency); + sCPUClockFrequency = calc_clock_frequency(); firstcall = false; } -#endif return sCPUClockFrequency >> 8; } -#endif LLFastTimer::FrameState::FrameState(LLFastTimer::NamedTimer* timerp) : mActiveCount(0), @@ -409,11 +537,12 @@ void LLFastTimer::NamedTimer::buildHierarchy() // bootstrap tree construction by attaching to last timer to be on stack // when this timer was called - if (timer.getFrameState().mLastCaller && timer.mParent == NamedTimerFactory::instance().getRootTimer()) + FrameState& frame_state(timer.getFrameState()); + if (frame_state.mLastCaller && timer.mParent == NamedTimerFactory::instance().getRootTimer()) { - timer.setParent(timer.getFrameState().mLastCaller->mTimer); + timer.setParent(frame_state.mLastCaller); // no need to push up tree on first use, flag can be set spuriously - timer.getFrameState().mMoveUpTree = false; + frame_state.mMoveUpTree = false; } } } @@ -572,15 +701,14 @@ void LLFastTimer::NamedTimer::resetFrame() timerp->mFrameStateIndex = index; index++; - - llassert_always(timerp->mFrameStateIndex < (S32)getFrameStateList().size()); } + llassert(index == (S32)getFrameStateList().size()); // sort timers by DFS traversal order to improve cache coherency std::sort(getFrameStateList().begin(), getFrameStateList().end(), SortTimersDFS()); // update pointers into framestatelist now that we've sorted it - DeclareTimer::updateCachedPointers(); + updateCachedPointers(); // reset for next frame { @@ -652,7 +780,11 @@ LLFastTimer::info_list_t& LLFastTimer::getFrameStateList() { if (!sTimerInfos) { - sTimerInfos = new info_list_t(); + sTimerInfos = new info_list_t; +#if 0 + // Avoid the vector being moved in memory by reserving enough memory right away. + sTimerInfos->reserve(1024); +#endif } return *sTimerInfos; } @@ -784,22 +916,27 @@ const LLFastTimer::NamedTimer* LLFastTimer::getTimerByName(const std::string& na LLFastTimer::LLFastTimer(LLFastTimer::FrameState* state) : mFrameState(state) { + // Only called for mAppTimer with mRootFrameState, which never invalidates. + llassert(state == &NamedTimerFactory::instance().getRootFrameState()); + U32 start_time = getCPUClockCount32(); mStartTime = start_time; mFrameState->mActiveCount++; LLFastTimer::sCurTimerData.mCurTimer = this; + LLFastTimer::sCurTimerData.mNamedTimer = mFrameState->mTimer; LLFastTimer::sCurTimerData.mFrameState = mFrameState; LLFastTimer::sCurTimerData.mChildTime = 0; + // This is the root FastTimer (mAppTimer), mark it as such by having + // mLastTimerData be equal to sCurTimerData (which is a rather arbitrary + // and not very logical way to do that --Aleric). mLastTimerData = LLFastTimer::sCurTimerData; } - ////////////////////////////////////////////////////////////////////////////// // // Important note: These implementations must be FAST! // - //LL_COMMON_API U64 get_clock_count(); // in lltimer.cpp // These use QueryPerformanceCounter, which is arguably fine and also works on AMD architectures. U32 LLFastTimer::getCPUClockCount32() @@ -812,9 +949,3 @@ U64 LLFastTimer::getCPUClockCount64() return get_clock_count(); } -#if LL_WINDOWS -std::string LLFastTimer::sClockType = "QueryPerformanceCounter"; -#else -std::string LLFastTimer::sClockType = "gettimeofday"; -#endif - diff --git a/indra/llcommon/llfasttimer_class.h b/indra/llcommon/llfasttimer_class.h index 536de6c0d..c6a6f59c1 100644 --- a/indra/llcommon/llfasttimer_class.h +++ b/indra/llcommon/llfasttimer_class.h @@ -52,7 +52,7 @@ public: U32 mSelfTimeCounter; U32 mCalls; FrameState* mParent; // info for caller timer - FrameState* mLastCaller; // used to bootstrap tree construction + NamedTimer* mLastCaller; // used to bootstrap tree construction NamedTimer* mTimer; U16 mActiveCount; // number of timers with this ID active on stack bool mMoveUpTree; // needs to be moved up the tree of timers at the end of frame @@ -144,8 +144,6 @@ public: DeclareTimer(const std::string& name, bool open); DeclareTimer(const std::string& name); - static void updateCachedPointers(); - private: NamedTimer& mTimer; FrameState* mFrameState; @@ -172,6 +170,7 @@ public: LLFastTimer::CurTimerData* cur_timer_data = &LLFastTimer::sCurTimerData; mLastTimerData = *cur_timer_data; cur_timer_data->mCurTimer = this; + cur_timer_data->mNamedTimer = &timer.mTimer; cur_timer_data->mFrameState = frame_state; cur_timer_data->mChildTime = 0; #endif @@ -200,7 +199,7 @@ public: // store last caller to bootstrap tree creation // do this in the destructor in case of recursion to get topmost caller - frame_state->mLastCaller = mLastTimerData.mFrameState; + frame_state->mLastCaller = mLastTimerData.mNamedTimer; // we are only tracking self time, so subtract our total time delta from parents mLastTimerData.mChildTime += total_time; @@ -239,6 +238,9 @@ public: // call this to reset timer hierarchy, averages, etc. static void reset(); + // called to update all FrameState pointers. + static void updateCachedPointers(); + static U64 countsPerSecond(); static S32 getLastFrameIndex() { return sLastFrameIndex; } static S32 getCurFrameIndex() { return sCurFrameIndex; } @@ -249,6 +251,7 @@ public: struct CurTimerData { LLFastTimer* mCurTimer; + NamedTimer* mNamedTimer; FrameState* mFrameState; U32 mChildTime; }; @@ -258,7 +261,6 @@ public: public: static U32 getCPUClockCount32(); static U64 getCPUClockCount64(); - static U64 sClockResolution; private: static S32 sCurFrameIndex; @@ -272,6 +274,4 @@ private: }; -typedef class LLFastTimer LLFastTimer; - #endif // LL_LLFASTTIMER_H diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 1762b3b00..2d515c212 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -198,7 +198,7 @@ U64 get_clock_count() return clock_count.QuadPart - offset; } -F64 calc_clock_frequency(U32 uiMeasureMSecs) +F64 calc_clock_frequency(void) { __int64 freq; QueryPerformanceFrequency((LARGE_INTEGER *) &freq); @@ -209,7 +209,7 @@ F64 calc_clock_frequency(U32 uiMeasureMSecs) #if LL_LINUX || LL_DARWIN || LL_SOLARIS // Both Linux and Mac use gettimeofday for accurate time -F64 calc_clock_frequency(unsigned int uiMeasureMSecs) +F64 calc_clock_frequency(void) { return 1000000.0; // microseconds, so 1 Mhz. } @@ -226,7 +226,7 @@ U64 get_clock_count() void update_clock_frequencies() { - gClockFrequency = calc_clock_frequency(50U); + gClockFrequency = calc_clock_frequency(); gClockFrequencyInv = 1.0/gClockFrequency; gClocksToMicroseconds = gClockFrequencyInv * SEC_TO_MICROSEC; } diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index 478585e54..2316944f4 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -113,7 +113,7 @@ public: // Various functions for initializing/accessing clock and timing stuff. Don't use these without REALLY knowing how they work. // LL_COMMON_API U64 get_clock_count(); -LL_COMMON_API F64 calc_clock_frequency(U32 msecs); +LL_COMMON_API F64 calc_clock_frequency(); LL_COMMON_API void update_clock_frequencies(); // Sleep for milliseconds diff --git a/indra/newview/statemachine/aistatemachine.cpp b/indra/newview/statemachine/aistatemachine.cpp index 49f7ee0ba..cbe261cc4 100644 --- a/indra/newview/statemachine/aistatemachine.cpp +++ b/indra/newview/statemachine/aistatemachine.cpp @@ -38,6 +38,8 @@ #include "aithreadsafe.h" #include "aistatemachine.h" +extern F64 calc_clock_frequency(void); + extern LLControlGroup gSavedSettings; // Local variables. @@ -79,7 +81,7 @@ AITHREADSAFESIMPLE(U64, AIStateMachine::sMaxCount, ); void AIStateMachine::updateSettings(void) { Dout(dc::statemachine, "Initializing AIStateMachine::sMaxCount"); - *AIAccess(sMaxCount) = LLFastTimer::sClockResolution * gSavedSettings.getU32("StateMachineMaxTime") / 1000; + *AIAccess(sMaxCount) = calc_clock_frequency() * gSavedSettings.getU32("StateMachineMaxTime") / 1000; } //---------------------------------------------------------------------------- @@ -320,7 +322,7 @@ void AIStateMachine::mainloop(void*) if (total_clocks >= max_count) { #ifndef LL_RELEASE_FOR_DOWNLOAD - llwarns << "AIStateMachine::mainloop did run for " << (total_clocks * 1000 / LLFastTimer::sClockResolution) << " ms." << llendl; + llwarns << "AIStateMachine::mainloop did run for " << (total_clocks * 1000 / calc_clock_frequency()) << " ms." << llendl; #endif std::sort(active_statemachines.begin(), active_statemachines.end(), QueueElementComp()); break; From 2617df44db7793d97a4bd8d990f292f02fefdd3e Mon Sep 17 00:00:00 2001 From: Shyotl Date: Sun, 5 Feb 2012 05:58:36 -0600 Subject: [PATCH 36/36] VC doesn't seem to like ctor being used to assign a reference pointer. --- indra/llcommon/llfasttimer_class.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/llcommon/llfasttimer_class.cpp b/indra/llcommon/llfasttimer_class.cpp index 81ccc8a8e..83c5b4fc1 100644 --- a/indra/llcommon/llfasttimer_class.cpp +++ b/indra/llcommon/llfasttimer_class.cpp @@ -370,7 +370,7 @@ void LLFastTimer::updateCachedPointers() llassert(frame_state_list[vector_size - 1].mParent == vector_start); // The one that was added at the end is already OK. for (int i = 2; i < vector_size - 1; ++i) { - FrameState*& parent(frame_state_list[i].mParent); + FrameState*& parent = frame_state_list[i].mParent; if (parent != &root_frame_state) { parent += offset;