2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2017-01-31 05:58:52 +03:00
|
|
|
/* 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)
|
2017-01-31 05:58:52 +03:00
|
|
|
: WebGLExtensionBase(webgl) {}
|
|
|
|
|
2017-04-11 11:50:59 +03:00
|
|
|
WebGLExtensionMOZDebug::~WebGLExtensionMOZDebug() {}
|
2017-01-31 05:58:52 +03:00
|
|
|
|
2017-04-11 11:50:59 +03:00
|
|
|
void WebGLExtensionMOZDebug::GetParameter(JSContext* cx, GLenum pname,
|
2017-01-31 05:58:52 +03:00
|
|
|
JS::MutableHandle<JS::Value> retval,
|
|
|
|
ErrorResult& er) const {
|
2019-05-24 15:04:12 +03:00
|
|
|
if (mIsLost || !mContext) return;
|
2018-07-27 07:46:33 +03:00
|
|
|
const WebGLContext::FuncScope funcScope(*mContext, "MOZ_debug.getParameter");
|
|
|
|
MOZ_ASSERT(!mContext->IsContextLost());
|
|
|
|
|
2017-01-31 05:58:52 +03:00
|
|
|
const auto& gl = mContext->gl;
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2017-01-31 05:58:52 +03:00
|
|
|
retval.set(StringValue(cx, ret, er));
|
2018-11-30 13:46:48 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-01-31 05:58:52 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-07-23 22:58:44 +03:00
|
|
|
case dom::MOZ_debug_Binding::WSI_INFO: {
|
2017-01-31 05:58:52 +03:00
|
|
|
nsCString info;
|
|
|
|
gl->GetWSIInfo(&info);
|
|
|
|
retval.set(StringValue(cx, NS_ConvertUTF8toUTF16(info), er));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-23 22:58:44 +03:00
|
|
|
case dom::MOZ_debug_Binding::DOES_INDEX_VALIDATION:
|
|
|
|
retval.set(JS::BooleanValue(mContext->mNeedsIndexValidation));
|
|
|
|
return;
|
|
|
|
|
2017-01-31 05:58:52 +03:00
|
|
|
default:
|
2018-07-27 07:46:33 +03:00
|
|
|
mContext->ErrorInvalidEnumInfo("pname", pname);
|
2017-01-31 05:58:52 +03:00
|
|
|
retval.set(JS::NullValue());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-11 11:50:59 +03:00
|
|
|
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionMOZDebug, MOZ_debug)
|
2017-01-31 05:58:52 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|