widget/xpwidgets/GfxInfoBase.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* vim: se cin sw=2 ts=2 et : */
     2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     3  *
     4  * This Source Code Form is subject to the terms of the Mozilla Public
     5  * License, v. 2.0. If a copy of the MPL was not distributed with this
     6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     8 #ifndef __mozilla_widget_GfxInfoBase_h__
     9 #define __mozilla_widget_GfxInfoBase_h__
    11 #include "nsIGfxInfo.h"
    12 #include "nsCOMPtr.h"
    13 #include "nsIObserver.h"
    14 #include "nsWeakReference.h"
    15 #include "GfxDriverInfo.h"
    16 #include "nsTArray.h"
    17 #include "nsString.h"
    18 #include "GfxInfoCollector.h"
    19 #include "nsIGfxInfoDebug.h"
    20 #include "mozilla/Mutex.h"
    21 #include "js/Value.h"
    22 #include "mozilla/Attributes.h"
    24 namespace mozilla {
    25 namespace widget {  
    27 class GfxInfoBase : public nsIGfxInfo,
    28                     public nsIObserver,
    29                     public nsSupportsWeakReference
    30 #ifdef DEBUG
    31                   , public nsIGfxInfoDebug
    32 #endif
    33 {
    34 public:
    35   GfxInfoBase();
    36   virtual ~GfxInfoBase();
    38   NS_DECL_THREADSAFE_ISUPPORTS
    39   NS_DECL_NSIOBSERVER
    41   // We only declare a subset of the nsIGfxInfo interface. It's up to derived
    42   // classes to implement the rest of the interface.  
    43   // Derived classes need to use
    44   // using GfxInfoBase::GetFeatureStatus;
    45   // using GfxInfoBase::GetFeatureSuggestedDriverVersion;
    46   // using GfxInfoBase::GetWebGLParameter;
    47   // to import the relevant methods into their namespace.
    48   NS_IMETHOD GetFeatureStatus(int32_t aFeature, int32_t *_retval);
    49   NS_IMETHOD GetFeatureSuggestedDriverVersion(int32_t aFeature, nsAString & _retval);
    50   NS_IMETHOD GetWebGLParameter(const nsAString & aParam, nsAString & _retval);
    52   NS_IMETHOD GetFailures(uint32_t *failureCount, char ***failures);
    53   NS_IMETHOD_(void) LogFailure(const nsACString &failure);
    54   NS_IMETHOD GetInfo(JSContext*, JS::MutableHandle<JS::Value>);
    56   // Initialization function. If you override this, you must call this class's
    57   // version of Init first.
    58   // We need Init to be called separately from the constructor so we can
    59   // register as an observer after all derived classes have been constructed
    60   // and we know we have a non-zero refcount.
    61   // Ideally, Init() would be void-return, but the rules of
    62   // NS_GENERIC_FACTORY_CONSTRUCTOR_INIT require it be nsresult return.
    63   virtual nsresult Init();
    65   // only useful on X11
    66   NS_IMETHOD_(void) GetData() { }
    68   static void AddCollector(GfxInfoCollectorBase* collector);
    69   static void RemoveCollector(GfxInfoCollectorBase* collector);
    71   static nsTArray<GfxDriverInfo>* mDriverInfo;
    72   static bool mDriverInfoObserverInitialized;
    74   virtual nsString Model() { return EmptyString(); }
    75   virtual nsString Hardware() { return EmptyString(); }
    76   virtual nsString Product() { return EmptyString(); }
    77   virtual nsString Manufacturer() { return EmptyString(); }
    78   virtual uint32_t OperatingSystemVersion() { return 0; }
    80 protected:
    82   virtual nsresult GetFeatureStatusImpl(int32_t aFeature, int32_t* aStatus,
    83                                         nsAString& aSuggestedDriverVersion,
    84                                         const nsTArray<GfxDriverInfo>& aDriverInfo,
    85                                         OperatingSystem* aOS = nullptr);
    87   // Gets the driver info table. Used by GfxInfoBase to check for general cases
    88   // (while subclasses check for more specific ones).
    89   virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo() = 0;
    91 private:
    92   virtual int32_t FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& aDriverInfo,
    93                                               nsAString& aSuggestedVersion,
    94                                               int32_t aFeature,
    95                                               OperatingSystem os);
    97   void EvaluateDownloadedBlacklist(nsTArray<GfxDriverInfo>& aDriverInfo);
    99   nsCString mFailures[9]; // The choice of 9 is Ehsan's
   100   uint32_t mFailureCount;
   101   Mutex mMutex;
   103 };
   105 }
   106 }
   108 #endif /* __mozilla_widget_GfxInfoBase_h__ */

mercurial