widget/xpwidgets/GfxInfoWebGL.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* vim: se cin sw=2 ts=2 et : */
michael@0 2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 3 *
michael@0 4 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 5 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 7
michael@0 8 #include "GfxInfoWebGL.h"
michael@0 9
michael@0 10 #include "nsServiceManagerUtils.h"
michael@0 11
michael@0 12 #include "GLDefs.h"
michael@0 13 #include "nsIDOMWebGLRenderingContext.h"
michael@0 14 #include "nsICanvasRenderingContextInternal.h"
michael@0 15
michael@0 16 using namespace mozilla::widget;
michael@0 17
michael@0 18 nsresult
michael@0 19 GfxInfoWebGL::GetWebGLParameter(const nsAString& aParam, nsAString& aResult)
michael@0 20 {
michael@0 21 GLenum param;
michael@0 22
michael@0 23 if (aParam.EqualsLiteral("vendor")) param = LOCAL_GL_VENDOR;
michael@0 24 else if (aParam.EqualsLiteral("renderer")) param = LOCAL_GL_RENDERER;
michael@0 25 else if (aParam.EqualsLiteral("version")) param = LOCAL_GL_VERSION;
michael@0 26 else if (aParam.EqualsLiteral("shading_language_version")) param = LOCAL_GL_SHADING_LANGUAGE_VERSION;
michael@0 27 else if (aParam.EqualsLiteral("extensions")) param = LOCAL_GL_EXTENSIONS;
michael@0 28 else if (aParam.EqualsLiteral("full-renderer")) param = 0;
michael@0 29 else return NS_ERROR_INVALID_ARG;
michael@0 30
michael@0 31 nsCOMPtr<nsIDOMWebGLRenderingContext> webgl =
michael@0 32 do_CreateInstance("@mozilla.org/content/canvas-rendering-context;1?id=experimental-webgl");
michael@0 33 if (!webgl)
michael@0 34 return NS_ERROR_NOT_AVAILABLE;
michael@0 35
michael@0 36 nsCOMPtr<nsICanvasRenderingContextInternal> webglInternal =
michael@0 37 do_QueryInterface(webgl);
michael@0 38 if (!webglInternal)
michael@0 39 return NS_ERROR_NOT_AVAILABLE;
michael@0 40
michael@0 41 nsresult rv = webglInternal->SetDimensions(16, 16);
michael@0 42 NS_ENSURE_SUCCESS(rv, rv);
michael@0 43
michael@0 44 if (param)
michael@0 45 return webgl->MozGetUnderlyingParamString(param, aResult);
michael@0 46
michael@0 47 // this is the "full renderer" string, which is vendor + renderer + version
michael@0 48
michael@0 49 nsAutoString str;
michael@0 50
michael@0 51 rv = webgl->MozGetUnderlyingParamString(LOCAL_GL_VENDOR, str);
michael@0 52 NS_ENSURE_SUCCESS(rv, rv);
michael@0 53
michael@0 54 aResult.Append(str);
michael@0 55 aResult.AppendLiteral(" -- ");
michael@0 56
michael@0 57 rv = webgl->MozGetUnderlyingParamString(LOCAL_GL_RENDERER, str);
michael@0 58 NS_ENSURE_SUCCESS(rv, rv);
michael@0 59
michael@0 60 aResult.Append(str);
michael@0 61 aResult.AppendLiteral(" -- ");
michael@0 62
michael@0 63 rv = webgl->MozGetUnderlyingParamString(LOCAL_GL_VERSION, str);
michael@0 64 NS_ENSURE_SUCCESS(rv, rv);
michael@0 65
michael@0 66 aResult.Append(str);
michael@0 67
michael@0 68 return NS_OK;
michael@0 69 }

mercurial