michael@0: /* vim: se cin sw=2 ts=2 et : */ michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "GfxInfoWebGL.h" michael@0: michael@0: #include "nsServiceManagerUtils.h" michael@0: michael@0: #include "GLDefs.h" michael@0: #include "nsIDOMWebGLRenderingContext.h" michael@0: #include "nsICanvasRenderingContextInternal.h" michael@0: michael@0: using namespace mozilla::widget; michael@0: michael@0: nsresult michael@0: GfxInfoWebGL::GetWebGLParameter(const nsAString& aParam, nsAString& aResult) michael@0: { michael@0: GLenum param; michael@0: michael@0: if (aParam.EqualsLiteral("vendor")) param = LOCAL_GL_VENDOR; michael@0: else if (aParam.EqualsLiteral("renderer")) param = LOCAL_GL_RENDERER; michael@0: else if (aParam.EqualsLiteral("version")) param = LOCAL_GL_VERSION; michael@0: else if (aParam.EqualsLiteral("shading_language_version")) param = LOCAL_GL_SHADING_LANGUAGE_VERSION; michael@0: else if (aParam.EqualsLiteral("extensions")) param = LOCAL_GL_EXTENSIONS; michael@0: else if (aParam.EqualsLiteral("full-renderer")) param = 0; michael@0: else return NS_ERROR_INVALID_ARG; michael@0: michael@0: nsCOMPtr webgl = michael@0: do_CreateInstance("@mozilla.org/content/canvas-rendering-context;1?id=experimental-webgl"); michael@0: if (!webgl) michael@0: return NS_ERROR_NOT_AVAILABLE; michael@0: michael@0: nsCOMPtr webglInternal = michael@0: do_QueryInterface(webgl); michael@0: if (!webglInternal) michael@0: return NS_ERROR_NOT_AVAILABLE; michael@0: michael@0: nsresult rv = webglInternal->SetDimensions(16, 16); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: if (param) michael@0: return webgl->MozGetUnderlyingParamString(param, aResult); michael@0: michael@0: // this is the "full renderer" string, which is vendor + renderer + version michael@0: michael@0: nsAutoString str; michael@0: michael@0: rv = webgl->MozGetUnderlyingParamString(LOCAL_GL_VENDOR, str); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: aResult.Append(str); michael@0: aResult.AppendLiteral(" -- "); michael@0: michael@0: rv = webgl->MozGetUnderlyingParamString(LOCAL_GL_RENDERER, str); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: aResult.Append(str); michael@0: aResult.AppendLiteral(" -- "); michael@0: michael@0: rv = webgl->MozGetUnderlyingParamString(LOCAL_GL_VERSION, str); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: aResult.Append(str); michael@0: michael@0: return NS_OK; michael@0: }