diff --git a/content/canvas/src/WebGLContext.cpp b/content/canvas/src/WebGLContext.cpp index db0456495ca0..3f9e0aa48a8f 100644 --- a/content/canvas/src/WebGLContext.cpp +++ b/content/canvas/src/WebGLContext.cpp @@ -695,6 +695,33 @@ WebGLContext::GetContextAttributes(jsval *aResult) return NS_OK; } +/* [noscript] DOMString mozGetUnderlyingParamString(in WebGLenum pname); */ +NS_IMETHODIMP +WebGLContext::MozGetUnderlyingParamString(PRUint32 pname, nsAString& retval) +{ + retval.SetIsVoid(PR_TRUE); + + MakeContextCurrent(); + + switch (pname) { + case LOCAL_GL_VENDOR: + case LOCAL_GL_RENDERER: + case LOCAL_GL_VERSION: + case LOCAL_GL_SHADING_LANGUAGE_VERSION: + case LOCAL_GL_EXTENSIONS: { + const char *s = (const char *) gl->fGetString(pname); + retval.Assign(NS_ConvertASCIItoUTF16(nsDependentCString(s))); + } + break; + + default: + return NS_ERROR_INVALID_ARG; + } + + return NS_OK; +} + + // // XPCOM goop // @@ -830,31 +857,37 @@ NAME_NOT_SUPPORTED(WebGLFramebuffer) NAME_NOT_SUPPORTED(WebGLRenderbuffer) /* [noscript] attribute WebGLint location; */ -NS_IMETHODIMP WebGLUniformLocation::GetLocation(WebGLint *aLocation) +NS_IMETHODIMP +WebGLUniformLocation::GetLocation(WebGLint *aLocation) { return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP WebGLUniformLocation::SetLocation(WebGLint aLocation) + +NS_IMETHODIMP +WebGLUniformLocation::SetLocation(WebGLint aLocation) { return NS_ERROR_NOT_IMPLEMENTED; } /* readonly attribute WebGLint size; */ -NS_IMETHODIMP WebGLActiveInfo::GetSize(WebGLint *aSize) +NS_IMETHODIMP +WebGLActiveInfo::GetSize(WebGLint *aSize) { *aSize = mSize; return NS_OK; } /* readonly attribute WebGLenum type; */ -NS_IMETHODIMP WebGLActiveInfo::GetType(WebGLenum *aType) +NS_IMETHODIMP +WebGLActiveInfo::GetType(WebGLenum *aType) { *aType = mType; return NS_OK; } /* readonly attribute DOMString name; */ -NS_IMETHODIMP WebGLActiveInfo::GetName(nsAString & aName) +NS_IMETHODIMP +WebGLActiveInfo::GetName(nsAString & aName) { aName = mName; return NS_OK; diff --git a/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl b/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl index 2a9184cc9151..ed902276e7f1 100644 --- a/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl +++ b/dom/interfaces/canvas/nsIDOMWebGLRenderingContext.idl @@ -822,4 +822,9 @@ interface nsIDOMWebGLRenderingContext : nsISupports void vertexAttribPointer(in WebGLuint idx, in WebGLint size, in WebGLenum type, in WebGLboolean normalized, in WebGLsizei stride, in WebGLsizeiptr offset); void viewport(in WebGLint x, in WebGLint y, in WebGLsizei width, in WebGLsizei height); + + // get an underlying GL parameter, without any WebGL intervention. + // Most useful for querying GL_VENDOR/GL_RENDERER for identifying + // the underlying renderer to the user. + [noscript] DOMString mozGetUnderlyingParamString(in WebGLenum pname); }; diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js index 4711b7b0f833..20396c691525 100644 --- a/toolkit/content/aboutSupport.js +++ b/toolkit/content/aboutSupport.js @@ -1,3 +1,4 @@ +# -*- Mode: js2; indent-tabs-mode: nil; js2-basic-offset: 2; -*- # ***** BEGIN LICENSE BLOCK ***** # Version: MPL 1.1/GPL 2.0/LGPL 2.1 # @@ -240,8 +241,18 @@ function populateGraphicsSection() { createElement("td", dwEnabled), ])); - appendChildren(graphics_tbody, trGraphics); + var webglrenderer; + try { + webglrenderer = gfxInfo.getWebGLParameter("full-renderer"); + } catch (e) { + webglrenderer = "(WebGL unavailable)"; + } + trGraphics.push(createParentElement("tr", [ + createHeader(bundle.GetStringFromName("webglRenderer")), + createElement("td", webglrenderer) + ])); + appendChildren(graphics_tbody, trGraphics); } // end if (gfxInfo) let windows = Services.ww.getWindowEnumerator(); diff --git a/toolkit/locales/en-US/chrome/global/aboutSupport.properties b/toolkit/locales/en-US/chrome/global/aboutSupport.properties index bf079c20a748..0d9fa3ce62a3 100644 --- a/toolkit/locales/en-US/chrome/global/aboutSupport.properties +++ b/toolkit/locales/en-US/chrome/global/aboutSupport.properties @@ -23,3 +23,4 @@ adapterDrivers = Adapter Drivers adapterRAM = Adapter RAM driverVersion = Driver Version driverDate = Driver Date +webglRenderer = WebGL Renderer diff --git a/widget/public/nsIGfxInfo.idl b/widget/public/nsIGfxInfo.idl index 2af4c4f98466..670cb573899e 100644 --- a/widget/public/nsIGfxInfo.idl +++ b/widget/public/nsIGfxInfo.idl @@ -117,5 +117,12 @@ interface nsIGfxInfo : nsISupports * FEATURE_BLOCKED_DRIVER_VERSION, otherwise return an empty string. */ DOMString getFeatureSuggestedDriverVersion(in long aFeature); + + /** + * WebGL info; valid params are "full-renderer", "vendor", "renderer", "version", + * "shading_language_version", "extensions". These return info from + * underlying GL impl that's used to implement WebGL. + */ + DOMString getWebGLParameter(in DOMString aParam); }; diff --git a/widget/src/cocoa/GfxInfo.mm b/widget/src/cocoa/GfxInfo.mm index 95d9941e8c54..7e27acd8ee26 100644 --- a/widget/src/cocoa/GfxInfo.mm +++ b/widget/src/cocoa/GfxInfo.mm @@ -40,6 +40,7 @@ #include #include "GfxInfo.h" +#include "GfxInfoWebGL.h" #include "nsUnicharUtils.h" #include "mozilla/FunctionTimer.h" @@ -234,3 +235,9 @@ GfxInfo::GetFeatureSuggestedDriverVersion(PRInt32 aFeature, nsAString& aSuggeste { return NS_OK; } + +NS_IMETHODIMP +GfxInfo::GetWebGLParameter(const nsAString& aParam, nsAString& aResult) +{ + return GfxInfoWebGL::GetWebGLParameter(aParam, aResult); +} diff --git a/widget/src/windows/GfxInfo.cpp b/widget/src/windows/GfxInfo.cpp index 6e46cc5328ef..37973a8068cf 100644 --- a/widget/src/windows/GfxInfo.cpp +++ b/widget/src/windows/GfxInfo.cpp @@ -39,6 +39,7 @@ #include #include "gfxWindowsPlatform.h" #include "GfxInfo.h" +#include "GfxInfoWebGL.h" #include "nsUnicharUtils.h" #include "nsPrintfCString.h" #include "mozilla/FunctionTimer.h" @@ -751,3 +752,9 @@ GfxInfo::GetFeatureSuggestedDriverVersion(PRInt32 aFeature, nsAString& aSuggeste PRInt32 i; return GetFeatureStatusImpl(aFeature, &i, aSuggestedDriverVersion); } + +NS_IMETHODIMP +GfxInfo::GetWebGLParameter(const nsAString& aParam, nsAString& aResult) +{ + return GfxInfoWebGL::GetWebGLParameter(aParam, aResult); +} diff --git a/widget/src/xpwidgets/GfxInfoWebGL.cpp b/widget/src/xpwidgets/GfxInfoWebGL.cpp new file mode 100644 index 000000000000..45c859e0339b --- /dev/null +++ b/widget/src/xpwidgets/GfxInfoWebGL.cpp @@ -0,0 +1,101 @@ +/* vim: se cin sw=2 ts=2 et : */ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "GfxInfoWebGL.h" + +#include "nsServiceManagerUtils.h" + +#include "GLDefs.h" +#include "nsIDOMWebGLRenderingContext.h" +#include "nsICanvasRenderingContextInternal.h" + +using namespace mozilla::widget; + +nsresult +GfxInfoWebGL::GetWebGLParameter(const nsAString& aParam, nsAString& aResult) +{ + GLenum param; + + if (aParam.EqualsLiteral("vendor")) param = LOCAL_GL_VENDOR; + else if (aParam.EqualsLiteral("renderer")) param = LOCAL_GL_RENDERER; + else if (aParam.EqualsLiteral("version")) param = LOCAL_GL_VERSION; + else if (aParam.EqualsLiteral("shading_language_version")) param = LOCAL_GL_SHADING_LANGUAGE_VERSION; + else if (aParam.EqualsLiteral("extensions")) param = LOCAL_GL_EXTENSIONS; + else if (aParam.EqualsLiteral("full-renderer")) param = 0; + else return NS_ERROR_INVALID_ARG; + + nsCOMPtr webgl = + do_CreateInstance("@mozilla.org/content/canvas-rendering-context;1?id=experimental-webgl"); + if (!webgl) + return NS_ERROR_NOT_AVAILABLE; + + nsCOMPtr webglInternal = + do_QueryInterface(webgl); + if (!webglInternal) + return NS_ERROR_NOT_AVAILABLE; + + nsresult rv = webglInternal->SetDimensions(16, 16); + NS_ENSURE_SUCCESS(rv, rv); + + if (param) + return webgl->MozGetUnderlyingParamString(param, aResult); + + // this is the "full renderer" string, which is vendor + renderer + version + + nsAutoString str; + + rv = webgl->MozGetUnderlyingParamString(LOCAL_GL_VENDOR, str); + NS_ENSURE_SUCCESS(rv, rv); + + aResult.Append(str); + aResult.AppendLiteral(" -- "); + + rv = webgl->MozGetUnderlyingParamString(LOCAL_GL_RENDERER, str); + NS_ENSURE_SUCCESS(rv, rv); + + aResult.Append(str); + aResult.AppendLiteral(" -- "); + + rv = webgl->MozGetUnderlyingParamString(LOCAL_GL_VERSION, str); + NS_ENSURE_SUCCESS(rv, rv); + + aResult.Append(str); + + return NS_OK; +} diff --git a/widget/src/xpwidgets/GfxInfoWebGL.h b/widget/src/xpwidgets/GfxInfoWebGL.h new file mode 100644 index 000000000000..2b920e870931 --- /dev/null +++ b/widget/src/xpwidgets/GfxInfoWebGL.h @@ -0,0 +1,59 @@ +/* vim: se cin sw=2 ts=2 et : */ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef __mozilla_widget_GfxInfoWebGL_h__ +#define __mozilla_widget_GfxInfoWebGL_h__ + +#include "nsString.h" + +namespace mozilla { +namespace widget { + +class GfxInfoWebGL { +public: + static nsresult GetWebGLParameter(const nsAString& aParam, nsAString& aResult); + +protected: + GfxInfoWebGL() { } +}; + +} +} + +#endif diff --git a/widget/src/xpwidgets/Makefile.in b/widget/src/xpwidgets/Makefile.in index c5638400f4f8..1b4056fe4daf 100644 --- a/widget/src/xpwidgets/Makefile.in +++ b/widget/src/xpwidgets/Makefile.in @@ -68,6 +68,7 @@ CPPSRCS = \ nsWidgetAtoms.cpp \ nsIdleService.cpp \ nsClipboardPrivacyHandler.cpp \ + GfxInfoWebGL.cpp \ $(NULL) ifdef MOZ_IPC