2017-01-31 05:58:52 +03:00
|
|
|
/* -*- 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"
|
2017-04-11 11:50:59 +03:00
|
|
|
#include "GLContext.h"
|
2017-01-31 05:58:52 +03:00
|
|
|
#include "WebGLContext.h"
|
|
|
|
#include "WebGLContextUtils.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2017-04-11 11:50:59 +03:00
|
|
|
WebGLExtensionMOZDebug::WebGLExtensionMOZDebug(WebGLContext* webgl)
|
2018-11-30 13:46:48 +03:00
|
|
|
: WebGLExtensionBase(webgl) {}
|
2017-01-31 05:58:52 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
WebGLExtensionMOZDebug::~WebGLExtensionMOZDebug() {}
|
2017-01-31 05:58:52 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
void WebGLExtensionMOZDebug::GetParameter(JSContext* cx, GLenum pname,
|
|
|
|
JS::MutableHandle<JS::Value> retval,
|
|
|
|
ErrorResult& er) const {
|
|
|
|
if (mIsLost) return;
|
|
|
|
const WebGLContext::FuncScope funcScope(*mContext, "MOZ_debug.getParameter");
|
|
|
|
MOZ_ASSERT(!mContext->IsContextLost());
|
2018-07-27 07:46:33 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
const auto& gl = mContext->gl;
|
2017-01-31 05:58:52 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
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));
|
2017-01-31 05:58:52 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
retval.set(StringValue(cx, ret, er));
|
|
|
|
return;
|
|
|
|
}
|
2017-01-31 05:58:52 +03:00
|
|
|
|
|
|
|
case LOCAL_GL_RENDERER:
|
|
|
|
case LOCAL_GL_VENDOR:
|
2018-11-30 13:46:48 +03:00
|
|
|
case LOCAL_GL_VERSION: {
|
|
|
|
const auto raw = (const char*)gl->fGetString(pname);
|
|
|
|
retval.set(StringValue(cx, NS_ConvertUTF8toUTF16(raw), er));
|
|
|
|
return;
|
|
|
|
}
|
2017-01-31 05:58:52 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
case dom::MOZ_debug_Binding::WSI_INFO: {
|
|
|
|
nsCString info;
|
|
|
|
gl->GetWSIInfo(&info);
|
|
|
|
retval.set(StringValue(cx, NS_ConvertUTF8toUTF16(info), er));
|
|
|
|
return;
|
|
|
|
}
|
2017-01-31 05:58:52 +03:00
|
|
|
|
2018-07-23 22:58:44 +03:00
|
|
|
case dom::MOZ_debug_Binding::DOES_INDEX_VALIDATION:
|
2018-11-30 13:46:48 +03:00
|
|
|
retval.set(JS::BooleanValue(mContext->mNeedsIndexValidation));
|
|
|
|
return;
|
2018-07-23 22:58:44 +03:00
|
|
|
|
2017-01-31 05:58:52 +03:00
|
|
|
default:
|
2018-11-30 13:46:48 +03:00
|
|
|
mContext->ErrorInvalidEnumInfo("pname", pname);
|
|
|
|
retval.set(JS::NullValue());
|
|
|
|
return;
|
|
|
|
}
|
2017-01-31 05:58:52 +03:00
|
|
|
}
|
|
|
|
|
2017-04-11 11:50:59 +03:00
|
|
|
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionMOZDebug, MOZ_debug)
|
2017-01-31 05:58:52 +03:00
|
|
|
|
2018-11-30 13:46:48 +03:00
|
|
|
} // namespace mozilla
|