summaryrefslogtreecommitdiffstats
path: root/dom/canvas
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-08-01 08:58:59 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-08-01 08:58:59 +0200
commite7f7100ba6759f30295dbc49f819ebb9c4785298 (patch)
tree939f31b2484c41ec415e9eb56aee1c2934752e65 /dom/canvas
parentddb2b976802181e05cb37a94480e9fb42ae6708a (diff)
downloadUXP-e7f7100ba6759f30295dbc49f819ebb9c4785298.tar
UXP-e7f7100ba6759f30295dbc49f819ebb9c4785298.tar.gz
UXP-e7f7100ba6759f30295dbc49f819ebb9c4785298.tar.lz
UXP-e7f7100ba6759f30295dbc49f819ebb9c4785298.tar.xz
UXP-e7f7100ba6759f30295dbc49f819ebb9c4785298.zip
Bug 1335296 - Expand about:support WebGL information
Diffstat (limited to 'dom/canvas')
-rw-r--r--dom/canvas/WebGLContextExtensions.cpp8
-rw-r--r--dom/canvas/WebGLContextState.cpp12
-rw-r--r--dom/canvas/WebGLContextUtils.cpp12
-rw-r--r--dom/canvas/WebGLContextUtils.h2
-rw-r--r--dom/canvas/WebGLExtensionDebugGet.cpp79
-rw-r--r--dom/canvas/WebGLExtensions.h14
-rw-r--r--dom/canvas/WebGLTypes.h1
-rw-r--r--dom/canvas/moz.build1
8 files changed, 117 insertions, 12 deletions
diff --git a/dom/canvas/WebGLContextExtensions.cpp b/dom/canvas/WebGLContextExtensions.cpp
index 4a5a23274..7f338b4e9 100644
--- a/dom/canvas/WebGLContextExtensions.cpp
+++ b/dom/canvas/WebGLContextExtensions.cpp
@@ -40,6 +40,7 @@ WebGLContext::GetExtensionString(WebGLExtensionID ext)
WEBGL_EXTENSION_IDENTIFIER(EXT_sRGB)
WEBGL_EXTENSION_IDENTIFIER(EXT_texture_filter_anisotropic)
WEBGL_EXTENSION_IDENTIFIER(EXT_disjoint_timer_query)
+ WEBGL_EXTENSION_IDENTIFIER(MOZ_debug_get)
WEBGL_EXTENSION_IDENTIFIER(OES_element_index_uint)
WEBGL_EXTENSION_IDENTIFIER(OES_standard_derivatives)
WEBGL_EXTENSION_IDENTIFIER(OES_texture_float)
@@ -91,6 +92,8 @@ bool WebGLContext::IsExtensionSupported(dom::CallerType callerType,
switch (ext) {
case WebGLExtensionID::EXT_disjoint_timer_query:
return WebGLExtensionDisjointTimerQuery::IsSupported(this);
+ case WebGLExtensionID::MOZ_debug_get:
+ return true;
case WebGLExtensionID::WEBGL_debug_renderer_info:
return true;
case WebGLExtensionID::WEBGL_debug_shaders:
@@ -372,6 +375,11 @@ WebGLContext::EnableExtension(WebGLExtensionID ext)
obj = new WebGLExtensionTextureFilterAnisotropic(this);
break;
+ // MOZ_
+ case WebGLExtensionID::MOZ_debug_get:
+ obj = new WebGLExtensionDebugGet(this);
+ break;
+
// OES_
case WebGLExtensionID::OES_element_index_uint:
obj = new WebGLExtensionElementIndexUint(this);
diff --git a/dom/canvas/WebGLContextState.cpp b/dom/canvas/WebGLContextState.cpp
index e0234f5c6..c2f4c1a75 100644
--- a/dom/canvas/WebGLContextState.cpp
+++ b/dom/canvas/WebGLContextState.cpp
@@ -61,18 +61,6 @@ WebGLContext::Enable(GLenum cap)
gl->fEnable(cap);
}
-static JS::Value
-StringValue(JSContext* cx, const nsAString& str, ErrorResult& rv)
-{
- JSString* jsStr = JS_NewUCStringCopyN(cx, str.BeginReading(), str.Length());
- if (!jsStr) {
- rv.Throw(NS_ERROR_OUT_OF_MEMORY);
- return JS::NullValue();
- }
-
- return JS::StringValue(jsStr);
-}
-
bool
WebGLContext::GetStencilBits(GLint* const out_stencilBits)
{
diff --git a/dom/canvas/WebGLContextUtils.cpp b/dom/canvas/WebGLContextUtils.cpp
index 9c0d34939..3fd32eb30 100644
--- a/dom/canvas/WebGLContextUtils.cpp
+++ b/dom/canvas/WebGLContextUtils.cpp
@@ -874,4 +874,16 @@ InfoFrom(WebGLTexImageFunc func, WebGLTexDimensions dims)
}
}
+JS::Value
+StringValue(JSContext* cx, const nsAString& str, ErrorResult& er)
+{
+ JSString* jsStr = JS_NewUCStringCopyN(cx, str.BeginReading(), str.Length());
+ if (!jsStr) {
+ er.Throw(NS_ERROR_OUT_OF_MEMORY);
+ return JS::NullValue();
+ }
+
+ return JS::StringValue(jsStr);
+}
+
} // namespace mozilla
diff --git a/dom/canvas/WebGLContextUtils.h b/dom/canvas/WebGLContextUtils.h
index 5401fc878..1d06659b1 100644
--- a/dom/canvas/WebGLContextUtils.h
+++ b/dom/canvas/WebGLContextUtils.h
@@ -94,6 +94,8 @@ WebGLContext::WebGLObjectAsJSObject(JSContext* cx,
*/
const char* InfoFrom(WebGLTexImageFunc func, WebGLTexDimensions dims);
+JS::Value StringValue(JSContext* cx, const nsAString& str, ErrorResult& er);
+
} // namespace mozilla
#endif // WEBGL_CONTEXT_UTILS_H_
diff --git a/dom/canvas/WebGLExtensionDebugGet.cpp b/dom/canvas/WebGLExtensionDebugGet.cpp
new file mode 100644
index 000000000..39bb3c57a
--- /dev/null
+++ b/dom/canvas/WebGLExtensionDebugGet.cpp
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* 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 "WebGLExtensions.h"
+
+#include "mozilla/dom/WebGLRenderingContextBinding.h"
+#include "WebGLContext.h"
+#include "WebGLContextUtils.h"
+
+namespace mozilla {
+
+WebGLExtensionDebugGet::WebGLExtensionDebugGet(WebGLContext* webgl)
+ : WebGLExtensionBase(webgl)
+{
+}
+
+WebGLExtensionDebugGet::~WebGLExtensionDebugGet()
+{
+}
+
+void
+WebGLExtensionDebugGet::GetParameter(JSContext* cx, GLenum pname,
+ JS::MutableHandle<JS::Value> retval,
+ ErrorResult& er) const
+{
+ const auto& gl = mContext->gl;
+ gl->MakeCurrent();
+
+ switch (pname) {
+ case LOCAL_GL_EXTENSIONS:
+ {
+ nsString ret;
+ if (!gl->IsCoreProfile()) {
+ const auto rawExts = (const char*)gl->fGetString(LOCAL_GL_EXTENSIONS);
+ ret = NS_ConvertUTF8toUTF16(rawExts);
+ } else {
+ const auto& numExts = gl->GetIntAs<GLuint>(LOCAL_GL_NUM_EXTENSIONS);
+ for (GLuint i = 0; i < numExts; i++) {
+ const auto rawExt = (const char*)gl->fGetStringi(LOCAL_GL_EXTENSIONS,
+ i);
+ if (i > 0) {
+ ret.AppendLiteral(" ");
+ }
+ ret.Append(NS_ConvertUTF8toUTF16(rawExt));
+ }
+ }
+ retval.set(StringValue(cx, ret, er));
+ return;
+ }
+
+ case LOCAL_GL_RENDERER:
+ case LOCAL_GL_VENDOR:
+ case LOCAL_GL_VERSION:
+ {
+ const auto raw = (const char*)gl->fGetString(pname);
+ retval.set(StringValue(cx, NS_ConvertUTF8toUTF16(raw), er));
+ return;
+ }
+
+ case 0x10000: // "WSI_INFO"
+ {
+ nsCString info;
+ gl->GetWSIInfo(&info);
+ retval.set(StringValue(cx, NS_ConvertUTF8toUTF16(info), er));
+ return;
+ }
+
+ default:
+ mContext->ErrorInvalidEnumArg("MOZ_debug_get.getParameter", "pname", pname);
+ retval.set(JS::NullValue());
+ return;
+ }
+}
+
+IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionDebugGet, MOZ_debug_get)
+
+} // namespace mozilla
diff --git a/dom/canvas/WebGLExtensions.h b/dom/canvas/WebGLExtensions.h
index 741f6997f..7b6b6b54b 100644
--- a/dom/canvas/WebGLExtensions.h
+++ b/dom/canvas/WebGLExtensions.h
@@ -12,6 +12,7 @@
#include "WebGLTypes.h"
namespace mozilla {
+class ErrorResult;
namespace dom {
template<typename T>
@@ -385,6 +386,19 @@ public:
DECL_WEBGL_EXTENSION_GOOP
};
+class WebGLExtensionDebugGet final
+ : public WebGLExtensionBase
+{
+public:
+ explicit WebGLExtensionDebugGet(WebGLContext* webgl);
+ virtual ~WebGLExtensionDebugGet();
+
+ void GetParameter(JSContext* cx, GLenum pname,
+ JS::MutableHandle<JS::Value> retval, ErrorResult& er) const;
+
+ DECL_WEBGL_EXTENSION_GOOP
+};
+
} // namespace mozilla
#endif // WEBGL_EXTENSIONS_H_
diff --git a/dom/canvas/WebGLTypes.h b/dom/canvas/WebGLTypes.h
index 42b8701f3..2f4a4368a 100644
--- a/dom/canvas/WebGLTypes.h
+++ b/dom/canvas/WebGLTypes.h
@@ -149,6 +149,7 @@ enum class WebGLExtensionID : uint8_t {
EXT_shader_texture_lod,
EXT_texture_filter_anisotropic,
EXT_disjoint_timer_query,
+ MOZ_debug_get,
OES_element_index_uint,
OES_standard_derivatives,
OES_texture_float,
diff --git a/dom/canvas/moz.build b/dom/canvas/moz.build
index f7555b33d..6d5e2756f 100644
--- a/dom/canvas/moz.build
+++ b/dom/canvas/moz.build
@@ -105,6 +105,7 @@ UNIFIED_SOURCES += [
'WebGLExtensionCompressedTextureETC1.cpp',
'WebGLExtensionCompressedTexturePVRTC.cpp',
'WebGLExtensionCompressedTextureS3TC.cpp',
+ 'WebGLExtensionDebugGet.cpp',
'WebGLExtensionDebugRendererInfo.cpp',
'WebGLExtensionDebugShaders.cpp',
'WebGLExtensionDepthTexture.cpp',