Bug 797664 - Don't spew wwhen optional functions aren't found - r=vlad
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 18 Dec 2012 23:16:02 -0800
changeset 125616 3ef80b6f262298b14851b41bf754aebf46657f12
parent 125615 83ac1379e10e518dd77c684474b31133ac29d9aa
child 125617 46b1c88b81c2cf9748686d93bb1dcd675341f879
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad
bugs797664
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 797664 - Don't spew wwhen optional functions aren't found - r=vlad
gfx/gl/GLContext.cpp
gfx/gl/GLLibraryLoader.cpp
gfx/gl/GLLibraryLoader.h
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -520,17 +520,18 @@ GLContext::InitWithPrefix(const char *pr
         }
        
         // Load developer symbols, don't fail if we can't find them.
         SymLoadStruct auxSymbols[] = {
                 { (PRFuncPtr*) &mSymbols.fGetTexImage, { "GetTexImage", nullptr } },
                 { (PRFuncPtr*) &mSymbols.fGetTexLevelParameteriv, { "GetTexLevelParameteriv", nullptr } },
                 { nullptr, { nullptr } },
         };
-        LoadSymbols(&auxSymbols[0], trygl, prefix);
+        bool warnOnFailures = DebugMode();
+        LoadSymbols(&auxSymbols[0], trygl, prefix, warnOnFailures);
     }
 
     if (mInitialized) {
         GLint v[4];
 
         fGetIntegerv(LOCAL_GL_SCISSOR_BOX, v);
         mScissorStack.AppendElement(nsIntRect(v[0], v[1], v[2], v[3]));
 
--- a/gfx/gl/GLLibraryLoader.cpp
+++ b/gfx/gl/GLLibraryLoader.cpp
@@ -1,14 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "GLLibraryLoader.h"
 
+#include "nsDebug.h"
+
 namespace mozilla {
 namespace gl {
 
 bool
 GLLibraryLoader::OpenLibrary(const char *library)
 {
     PRLibSpec lspec;
     lspec.type = PR_LibSpec_Pathname;
@@ -17,25 +19,32 @@ GLLibraryLoader::OpenLibrary(const char 
     mLibrary = PR_LoadLibraryWithFlags(lspec, PR_LD_LAZY | PR_LD_LOCAL);
     if (!mLibrary)
         return false;
 
     return true;
 }
 
 bool
-GLLibraryLoader::LoadSymbols(SymLoadStruct *firstStruct, bool tryplatform, const char *prefix)
+GLLibraryLoader::LoadSymbols(SymLoadStruct *firstStruct,
+                             bool tryplatform,
+                             const char *prefix,
+                             bool warnOnFailure)
 {
-    return LoadSymbols(mLibrary, firstStruct, tryplatform ? mLookupFunc : nullptr, prefix);
+    return LoadSymbols(mLibrary,
+                       firstStruct,
+                       tryplatform ? mLookupFunc : nullptr,
+                       prefix,
+                       warnOnFailure);
 }
 
 PRFuncPtr
 GLLibraryLoader::LookupSymbol(PRLibrary *lib,
-                                  const char *sym,
-                                  PlatformLookupFunction lookupFunction)
+                              const char *sym,
+                              PlatformLookupFunction lookupFunction)
 {
     PRFuncPtr res = 0;
 
     // try finding it in the library directly, if we have one
     if (lib) {
         res = PR_FindFunctionSymbol(lib, sym);
     }
 
@@ -50,19 +59,20 @@ GLLibraryLoader::LookupSymbol(PRLibrary 
         res = PR_FindFunctionSymbolAndLibrary(sym, &leakedLibRef);
     }
 
     return res;
 }
 
 bool
 GLLibraryLoader::LoadSymbols(PRLibrary *lib,
-                                 SymLoadStruct *firstStruct,
-                                 PlatformLookupFunction lookupFunction,
-                                 const char *prefix)
+                             SymLoadStruct *firstStruct,
+                             PlatformLookupFunction lookupFunction,
+                             const char *prefix,
+                             bool warnOnFailure)
 {
     char sbuf[MAX_SYMBOL_LENGTH * 2];
     int failCount = 0;
 
     SymLoadStruct *ss = firstStruct;
     while (ss->symPointer) {
         *ss->symPointer = 0;
 
@@ -80,17 +90,19 @@ GLLibraryLoader::LoadSymbols(PRLibrary *
             PRFuncPtr p = LookupSymbol(lib, s, lookupFunction);
             if (p) {
                 *ss->symPointer = p;
                 break;
             }
         }
 
         if (*ss->symPointer == 0) {
-            fprintf (stderr, "Can't find symbol '%s'\n", ss->symNames[0]);
+            if (warnOnFailure)
+                printf_stderr("Can't find symbol '%s'.\n", ss->symNames[0]);
+
             failCount++;
         }
 
         ss++;
     }
 
     return failCount == 0 ? true : false;
 }
--- a/gfx/gl/GLLibraryLoader.h
+++ b/gfx/gl/GLLibraryLoader.h
@@ -32,29 +32,31 @@ public:
     };
 
     typedef struct {
         PRFuncPtr *symPointer;
         const char *symNames[MAX_SYMBOL_NAMES];
     } SymLoadStruct;
 
     bool LoadSymbols(SymLoadStruct *firstStruct,
-                       bool tryplatform = false,
-                       const char *prefix = nullptr);
+                     bool tryplatform = false,
+                     const char *prefix = nullptr,
+                     bool warnOnFailure = true);
 
     /*
      * Static version of the functions in this class
      */
     static PRFuncPtr LookupSymbol(PRLibrary *lib,
                                   const char *symname,
                                   PlatformLookupFunction lookupFunction = nullptr);
     static bool LoadSymbols(PRLibrary *lib,
-                              SymLoadStruct *firstStruct,
-                              PlatformLookupFunction lookupFunction = nullptr,
-                              const char *prefix = nullptr);
+                            SymLoadStruct *firstStruct,
+                            PlatformLookupFunction lookupFunction = nullptr,
+                            const char *prefix = nullptr,
+                            bool warnOnFailure = true);
 protected:
     GLLibraryLoader() {
         mLibrary = nullptr;
         mLookupFunc = nullptr;
     }
 
     PRLibrary *mLibrary;
     PlatformLookupFunction mLookupFunc;