widget/xpwidgets/GfxInfoBase.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/xpwidgets/GfxInfoBase.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,108 @@
     1.4 +/* vim: se cin sw=2 ts=2 et : */
     1.5 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.6 + *
     1.7 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.10 +
    1.11 +#ifndef __mozilla_widget_GfxInfoBase_h__
    1.12 +#define __mozilla_widget_GfxInfoBase_h__
    1.13 +
    1.14 +#include "nsIGfxInfo.h"
    1.15 +#include "nsCOMPtr.h"
    1.16 +#include "nsIObserver.h"
    1.17 +#include "nsWeakReference.h"
    1.18 +#include "GfxDriverInfo.h"
    1.19 +#include "nsTArray.h"
    1.20 +#include "nsString.h"
    1.21 +#include "GfxInfoCollector.h"
    1.22 +#include "nsIGfxInfoDebug.h"
    1.23 +#include "mozilla/Mutex.h"
    1.24 +#include "js/Value.h"
    1.25 +#include "mozilla/Attributes.h"
    1.26 +
    1.27 +namespace mozilla {
    1.28 +namespace widget {  
    1.29 +
    1.30 +class GfxInfoBase : public nsIGfxInfo,
    1.31 +                    public nsIObserver,
    1.32 +                    public nsSupportsWeakReference
    1.33 +#ifdef DEBUG
    1.34 +                  , public nsIGfxInfoDebug
    1.35 +#endif
    1.36 +{
    1.37 +public:
    1.38 +  GfxInfoBase();
    1.39 +  virtual ~GfxInfoBase();
    1.40 +
    1.41 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.42 +  NS_DECL_NSIOBSERVER
    1.43 +
    1.44 +  // We only declare a subset of the nsIGfxInfo interface. It's up to derived
    1.45 +  // classes to implement the rest of the interface.  
    1.46 +  // Derived classes need to use
    1.47 +  // using GfxInfoBase::GetFeatureStatus;
    1.48 +  // using GfxInfoBase::GetFeatureSuggestedDriverVersion;
    1.49 +  // using GfxInfoBase::GetWebGLParameter;
    1.50 +  // to import the relevant methods into their namespace.
    1.51 +  NS_IMETHOD GetFeatureStatus(int32_t aFeature, int32_t *_retval);
    1.52 +  NS_IMETHOD GetFeatureSuggestedDriverVersion(int32_t aFeature, nsAString & _retval);
    1.53 +  NS_IMETHOD GetWebGLParameter(const nsAString & aParam, nsAString & _retval);
    1.54 +
    1.55 +  NS_IMETHOD GetFailures(uint32_t *failureCount, char ***failures);
    1.56 +  NS_IMETHOD_(void) LogFailure(const nsACString &failure);
    1.57 +  NS_IMETHOD GetInfo(JSContext*, JS::MutableHandle<JS::Value>);
    1.58 +
    1.59 +  // Initialization function. If you override this, you must call this class's
    1.60 +  // version of Init first.
    1.61 +  // We need Init to be called separately from the constructor so we can
    1.62 +  // register as an observer after all derived classes have been constructed
    1.63 +  // and we know we have a non-zero refcount.
    1.64 +  // Ideally, Init() would be void-return, but the rules of
    1.65 +  // NS_GENERIC_FACTORY_CONSTRUCTOR_INIT require it be nsresult return.
    1.66 +  virtual nsresult Init();
    1.67 +  
    1.68 +  // only useful on X11
    1.69 +  NS_IMETHOD_(void) GetData() { }
    1.70 +
    1.71 +  static void AddCollector(GfxInfoCollectorBase* collector);
    1.72 +  static void RemoveCollector(GfxInfoCollectorBase* collector);
    1.73 +
    1.74 +  static nsTArray<GfxDriverInfo>* mDriverInfo;
    1.75 +  static bool mDriverInfoObserverInitialized;
    1.76 +
    1.77 +  virtual nsString Model() { return EmptyString(); }
    1.78 +  virtual nsString Hardware() { return EmptyString(); }
    1.79 +  virtual nsString Product() { return EmptyString(); }
    1.80 +  virtual nsString Manufacturer() { return EmptyString(); }
    1.81 +  virtual uint32_t OperatingSystemVersion() { return 0; }
    1.82 +
    1.83 +protected:
    1.84 +
    1.85 +  virtual nsresult GetFeatureStatusImpl(int32_t aFeature, int32_t* aStatus,
    1.86 +                                        nsAString& aSuggestedDriverVersion,
    1.87 +                                        const nsTArray<GfxDriverInfo>& aDriverInfo,
    1.88 +                                        OperatingSystem* aOS = nullptr);
    1.89 +
    1.90 +  // Gets the driver info table. Used by GfxInfoBase to check for general cases
    1.91 +  // (while subclasses check for more specific ones).
    1.92 +  virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo() = 0;
    1.93 +
    1.94 +private:
    1.95 +  virtual int32_t FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& aDriverInfo,
    1.96 +                                              nsAString& aSuggestedVersion,
    1.97 +                                              int32_t aFeature,
    1.98 +                                              OperatingSystem os);
    1.99 +
   1.100 +  void EvaluateDownloadedBlacklist(nsTArray<GfxDriverInfo>& aDriverInfo);
   1.101 +
   1.102 +  nsCString mFailures[9]; // The choice of 9 is Ehsan's
   1.103 +  uint32_t mFailureCount;
   1.104 +  Mutex mMutex;
   1.105 +
   1.106 +};
   1.107 +
   1.108 +}
   1.109 +}
   1.110 +
   1.111 +#endif /* __mozilla_widget_GfxInfoBase_h__ */

mercurial