summaryrefslogtreecommitdiff
path: root/widget/GfxInfoWebGL.cpp
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /widget/GfxInfoWebGL.cpp
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloaduxp-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
Add m-esr52 at 52.6.0
Diffstat (limited to 'widget/GfxInfoWebGL.cpp')
-rw-r--r--widget/GfxInfoWebGL.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/widget/GfxInfoWebGL.cpp b/widget/GfxInfoWebGL.cpp
new file mode 100644
index 0000000000..6583ee475a
--- /dev/null
+++ b/widget/GfxInfoWebGL.cpp
@@ -0,0 +1,69 @@
+/* vim: se cin sw=2 ts=2 et : */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#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<nsIDOMWebGLRenderingContext> webgl =
+ do_CreateInstance("@mozilla.org/content/canvas-rendering-context;1?id=webgl");
+ if (!webgl)
+ return NS_ERROR_NOT_AVAILABLE;
+
+ nsCOMPtr<nsICanvasRenderingContextInternal> 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;
+}