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 : * ***** BEGIN LICENSE BLOCK *****
5 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 : *
7 : * The contents of this file are subject to the Mozilla Public License Version
8 : * 1.1 (the "License"); you may not use this file except in compliance with
9 : * the License. You may obtain a copy of the License at
10 : * http://www.mozilla.org/MPL/
11 : *
12 : * Software distributed under the License is distributed on an "AS IS" basis,
13 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 : * for the specific language governing rights and limitations under the
15 : * License.
16 : *
17 : * The Original Code is mozilla.org code.
18 : *
19 : * The Initial Developer of the Original Code is
20 : * Mozilla Foundation.
21 : * Portions created by the Initial Developer are Copyright (C) 2011
22 : * the Initial Developer. All Rights Reserved.
23 : *
24 : * Contributor(s):
25 : *
26 : * Alternatively, the contents of this file may be used under the terms of
27 : * either the GNU General Public License Version 2 or later (the "GPL"), or
28 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 : * in which case the provisions of the GPL or the LGPL are applicable instead
30 : * of those above. If you wish to allow use of your version of this file only
31 : * under the terms of either the GPL or the LGPL, and not to allow others to
32 : * use your version of this file under the terms of the MPL, indicate your
33 : * decision by deleting the provisions above and replace them with the notice
34 : * and other provisions required by the GPL or the LGPL. If you do not delete
35 : * the provisions above, a recipient may use your version of this file under
36 : * the terms of any one of the MPL, the GPL or the LGPL.
37 : *
38 : * ***** END LICENSE BLOCK ***** */
39 :
40 : #ifndef __mozilla_widget_GfxInfoBase_h__
41 : #define __mozilla_widget_GfxInfoBase_h__
42 :
43 : #include "nsIGfxInfo.h"
44 : #include "nsCOMPtr.h"
45 : #include "nsIObserver.h"
46 : #include "nsWeakReference.h"
47 : #include "GfxDriverInfo.h"
48 : #include "nsTArray.h"
49 : #include "nsString.h"
50 : #include "GfxInfoCollector.h"
51 : #include "nsIGfxInfoDebug.h"
52 :
53 : namespace mozilla {
54 : namespace widget {
55 :
56 : class GfxInfoBase : public nsIGfxInfo,
57 : public nsIObserver,
58 : public nsSupportsWeakReference
59 : #ifdef DEBUG
60 : , public nsIGfxInfoDebug
61 : #endif
62 : {
63 : public:
64 : GfxInfoBase();
65 : virtual ~GfxInfoBase();
66 :
67 : NS_DECL_ISUPPORTS
68 : NS_DECL_NSIOBSERVER
69 :
70 : // We only declare a subset of the nsIGfxInfo interface. It's up to derived
71 : // classes to implement the rest of the interface.
72 : // Derived classes need to use
73 : // using GfxInfoBase::GetFeatureStatus;
74 : // using GfxInfoBase::GetFeatureSuggestedDriverVersion;
75 : // using GfxInfoBase::GetWebGLParameter;
76 : // to import the relevant methods into their namespace.
77 : NS_SCRIPTABLE NS_IMETHOD GetFeatureStatus(PRInt32 aFeature, PRInt32 *_retval NS_OUTPARAM);
78 : NS_SCRIPTABLE NS_IMETHOD GetFeatureSuggestedDriverVersion(PRInt32 aFeature, nsAString & _retval NS_OUTPARAM);
79 : NS_SCRIPTABLE NS_IMETHOD GetWebGLParameter(const nsAString & aParam, nsAString & _retval NS_OUTPARAM);
80 :
81 : NS_SCRIPTABLE NS_IMETHOD GetFailures(PRUint32 *failureCount NS_OUTPARAM, char ***failures NS_OUTPARAM);
82 : NS_IMETHOD_(void) LogFailure(const nsACString &failure);
83 : NS_SCRIPTABLE NS_IMETHOD GetInfo(JSContext*, jsval*);
84 :
85 : // Initialization function. If you override this, you must call this class's
86 : // version of Init first.
87 : // We need Init to be called separately from the constructor so we can
88 : // register as an observer after all derived classes have been constructed
89 : // and we know we have a non-zero refcount.
90 : // Ideally, Init() would be void-return, but the rules of
91 : // NS_GENERIC_FACTORY_CONSTRUCTOR_INIT require it be nsresult return.
92 : virtual nsresult Init();
93 :
94 : // only useful on X11
95 0 : NS_IMETHOD_(void) GetData() { }
96 :
97 : static void AddCollector(GfxInfoCollectorBase* collector);
98 : static void RemoveCollector(GfxInfoCollectorBase* collector);
99 :
100 : static nsTArray<GfxDriverInfo>* mDriverInfo;
101 : static bool mDriverInfoObserverInitialized;
102 :
103 : protected:
104 :
105 : virtual nsresult GetFeatureStatusImpl(PRInt32 aFeature, PRInt32* aStatus,
106 : nsAString& aSuggestedDriverVersion,
107 : const nsTArray<GfxDriverInfo>& aDriverInfo,
108 : OperatingSystem* aOS = nsnull);
109 :
110 : // Gets the driver info table. Used by GfxInfoBase to check for general cases
111 : // (while subclasses check for more specific ones).
112 : virtual const nsTArray<GfxDriverInfo>& GetGfxDriverInfo() = 0;
113 :
114 : private:
115 : virtual PRInt32 FindBlocklistedDeviceInList(const nsTArray<GfxDriverInfo>& aDriverInfo,
116 : nsAString& aSuggestedVersion,
117 : PRInt32 aFeature,
118 : OperatingSystem os);
119 :
120 : void EvaluateDownloadedBlacklist(nsTArray<GfxDriverInfo>& aDriverInfo);
121 :
122 : nsCString mFailures[9]; // The choice of 9 is Ehsan's
123 : PRUint32 mFailureCount;
124 :
125 : };
126 :
127 : }
128 : }
129 :
130 : #endif /* __mozilla_widget_GfxInfoBase_h__ */
|