diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-08-05 11:35:53 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-08-05 11:35:53 +0200 |
commit | 6bd66b1728eeddb058066edda740aaeb2ceaec23 (patch) | |
tree | 985faf01c526763515731569fa01a99f4dbef36e /dom/canvas/WebGLExtensionDebugGet.cpp | |
parent | e0a8dcfed131ffa58a5e2cb1d30fe48c745c2fdc (diff) | |
parent | 559824514dc95e02fbe81f1786e6ac13ee8e9d55 (diff) | |
download | UXP-6bd66b1728eeddb058066edda740aaeb2ceaec23.tar UXP-6bd66b1728eeddb058066edda740aaeb2ceaec23.tar.gz UXP-6bd66b1728eeddb058066edda740aaeb2ceaec23.tar.lz UXP-6bd66b1728eeddb058066edda740aaeb2ceaec23.tar.xz UXP-6bd66b1728eeddb058066edda740aaeb2ceaec23.zip |
Merge branch 'master' into js-modules
Diffstat (limited to 'dom/canvas/WebGLExtensionDebugGet.cpp')
-rw-r--r-- | dom/canvas/WebGLExtensionDebugGet.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
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 |