зеркало из https://github.com/mozilla/pjs.git
Bug 678330. Use IOKit to get precise GPU information in GfxInfo on Mac. r=bjacob
This lets us get vendor and device ids. --HG-- extra : rebase_source : 1760ecc1c406c227e473c462e39c95375abb318e
This commit is contained in:
Родитель
80637d0088
Коммит
48b79773d1
|
@ -2219,7 +2219,8 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
<h1><a name="chromium"></a>Chromium License</h1>
|
||||
|
||||
<p>This license applies to parts of the code in
|
||||
<span class="path">editor/libeditor/base/nsEditorEventListener.cpp</span>
|
||||
<span class="path">editor/libeditor/base/nsEditorEventListener.cpp</span>,
|
||||
<span class="path">widget/src/cocoa/GfxInfo.mm</span>
|
||||
and also some files in the directories
|
||||
<span class="path">ipc/chromium/</span>,
|
||||
<span class="path">dom/plugins/</span>,
|
||||
|
|
|
@ -50,6 +50,8 @@ namespace widget {
|
|||
class GfxInfo : public GfxInfoBase
|
||||
{
|
||||
public:
|
||||
|
||||
GfxInfo();
|
||||
// We only declare the subset of nsIGfxInfo that we actually implement. The
|
||||
// rest is brought forward from GfxInfoBase.
|
||||
NS_SCRIPTABLE NS_IMETHOD GetD2DEnabled(PRBool *aD2DEnabled);
|
||||
|
@ -84,6 +86,7 @@ protected:
|
|||
|
||||
private:
|
||||
|
||||
void GetDeviceInfo();
|
||||
void AddCrashReportAnnotations();
|
||||
nsString mRendererIDsString;
|
||||
nsString mAdapterRAMString;
|
||||
|
@ -93,6 +96,9 @@ private:
|
|||
nsString mDriverDate;
|
||||
nsString mDeviceKey;
|
||||
|
||||
PRUint32 mAdapterVendorID;
|
||||
PRUint32 mAdapterDeviceID;
|
||||
|
||||
PRUint32 mRendererIDs[16];
|
||||
};
|
||||
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
#include "mozilla/FunctionTimer.h"
|
||||
#include "nsToolkit.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <IOKit/IOKitLib.h>
|
||||
|
||||
#if defined(MOZ_CRASHREPORTER)
|
||||
#include "nsExceptionHandler.h"
|
||||
#include "nsICrashReporter.h"
|
||||
|
@ -52,6 +55,53 @@
|
|||
|
||||
using namespace mozilla::widget;
|
||||
|
||||
GfxInfo::GfxInfo()
|
||||
: mAdapterVendorID(0),
|
||||
mAdapterDeviceID(0)
|
||||
{
|
||||
}
|
||||
|
||||
// The following three functions are derived from Chromium code
|
||||
static CFTypeRef SearchPortForProperty(io_registry_entry_t dspPort,
|
||||
CFStringRef propertyName)
|
||||
{
|
||||
return IORegistryEntrySearchCFProperty(dspPort,
|
||||
kIOServicePlane,
|
||||
propertyName,
|
||||
kCFAllocatorDefault,
|
||||
kIORegistryIterateRecursively |
|
||||
kIORegistryIterateParents);
|
||||
}
|
||||
|
||||
static PRUint32 IntValueOfCFData(CFDataRef d)
|
||||
{
|
||||
PRUint32 value = 0;
|
||||
|
||||
if (d) {
|
||||
const PRUint32 *vp = reinterpret_cast<const PRUint32*>(CFDataGetBytePtr(d));
|
||||
if (vp != NULL)
|
||||
value = *vp;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void
|
||||
GfxInfo::GetDeviceInfo()
|
||||
{
|
||||
io_registry_entry_t dsp_port = CGDisplayIOServicePort(kCGDirectMainDisplay);
|
||||
CFTypeRef vendor_id_ref = SearchPortForProperty(dsp_port, CFSTR("vendor-id"));
|
||||
if (vendor_id_ref) {
|
||||
mAdapterVendorID = IntValueOfCFData((CFDataRef)vendor_id_ref);
|
||||
CFRelease(vendor_id_ref);
|
||||
}
|
||||
CFTypeRef device_id_ref = SearchPortForProperty(dsp_port, CFSTR("device-id"));
|
||||
if (device_id_ref) {
|
||||
mAdapterDeviceID = IntValueOfCFData((CFDataRef)device_id_ref);
|
||||
CFRelease(device_id_ref);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
GfxInfo::Init()
|
||||
{
|
||||
|
@ -89,6 +139,8 @@ GfxInfo::Init()
|
|||
|
||||
CGLDestroyRendererInfo(renderer);
|
||||
|
||||
GetDeviceInfo();
|
||||
|
||||
AddCrashReportAnnotations();
|
||||
|
||||
return rv;
|
||||
|
@ -205,7 +257,7 @@ GfxInfo::GetAdapterDriverDate2(nsAString & aAdapterDriverDate)
|
|||
NS_IMETHODIMP
|
||||
GfxInfo::GetAdapterVendorID(PRUint32 *aAdapterVendorID)
|
||||
{
|
||||
*aAdapterVendorID = 0;
|
||||
*aAdapterVendorID = mAdapterVendorID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -220,7 +272,7 @@ GfxInfo::GetAdapterVendorID2(PRUint32 *aAdapterVendorID)
|
|||
NS_IMETHODIMP
|
||||
GfxInfo::GetAdapterDeviceID(PRUint32 *aAdapterDeviceID)
|
||||
{
|
||||
*aAdapterDeviceID = 0;
|
||||
*aAdapterDeviceID = mAdapterDeviceID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче