diff options
Diffstat (limited to 'dom/canvas')
-rw-r--r-- | dom/canvas/CanvasRenderingContextHelper.cpp | 14 | ||||
-rw-r--r-- | dom/canvas/WebGL1Context.cpp | 3 | ||||
-rw-r--r-- | dom/canvas/WebGLContext.cpp | 24 | ||||
-rw-r--r-- | dom/canvas/WebGLContextExtensions.cpp | 8 | ||||
-rw-r--r-- | dom/canvas/WebGLContextState.cpp | 12 | ||||
-rw-r--r-- | dom/canvas/WebGLContextUtils.cpp | 12 | ||||
-rw-r--r-- | dom/canvas/WebGLContextUtils.h | 2 | ||||
-rw-r--r-- | dom/canvas/WebGLExtensionDebugGet.cpp | 79 | ||||
-rw-r--r-- | dom/canvas/WebGLExtensions.h | 14 | ||||
-rw-r--r-- | dom/canvas/WebGLTypes.h | 1 | ||||
-rw-r--r-- | dom/canvas/moz.build | 1 |
11 files changed, 117 insertions, 53 deletions
diff --git a/dom/canvas/CanvasRenderingContextHelper.cpp b/dom/canvas/CanvasRenderingContextHelper.cpp index 3000e59bd..61317fb51 100644 --- a/dom/canvas/CanvasRenderingContextHelper.cpp +++ b/dom/canvas/CanvasRenderingContextHelper.cpp @@ -7,7 +7,6 @@ #include "ImageBitmapRenderingContext.h" #include "ImageEncoder.h" #include "mozilla/dom/CanvasRenderingContext2D.h" -#include "mozilla/Telemetry.h" #include "mozilla/UniquePtr.h" #include "nsContentUtils.h" #include "nsDOMJSUtils.h" @@ -138,13 +137,10 @@ CanvasRenderingContextHelper::CreateContextHelper(CanvasContextType aContextType break; case CanvasContextType::Canvas2D: - Telemetry::Accumulate(Telemetry::CANVAS_2D_USED, 1); ret = new CanvasRenderingContext2D(aCompositorBackend); break; case CanvasContextType::WebGL1: - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_USED, 1); - ret = WebGL1Context::Create(); if (!ret) return nullptr; @@ -152,8 +148,6 @@ CanvasRenderingContextHelper::CreateContextHelper(CanvasContextType aContextType break; case CanvasContextType::WebGL2: - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_USED, 1); - ret = WebGL2Context::Create(); if (!ret) return nullptr; @@ -205,16 +199,8 @@ CanvasRenderingContextHelper::GetContext(JSContext* aCx, // See bug 645792 and bug 1215072. // We want to throw only if dictionary initialization fails, // so only in case aRv has been set to some error value. - if (contextType == CanvasContextType::WebGL1) - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_SUCCESS, 0); - else if (contextType == CanvasContextType::WebGL2) - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL2_SUCCESS, 0); return nullptr; } - if (contextType == CanvasContextType::WebGL1) - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_SUCCESS, 1); - else if (contextType == CanvasContextType::WebGL2) - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL2_SUCCESS, 1); } else { // We already have a context of some type. if (contextType != mCurrentContextType) diff --git a/dom/canvas/WebGL1Context.cpp b/dom/canvas/WebGL1Context.cpp index c1818a3f9..e82cafbe5 100644 --- a/dom/canvas/WebGL1Context.cpp +++ b/dom/canvas/WebGL1Context.cpp @@ -6,7 +6,6 @@ #include "WebGL1Context.h" #include "mozilla/dom/WebGLRenderingContextBinding.h" -#include "mozilla/Telemetry.h" #include "WebGLFormats.h" namespace mozilla { @@ -43,8 +42,6 @@ WebGL1Context::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) nsresult NS_NewCanvasRenderingContextWebGL(nsIDOMWebGLRenderingContext** out_result) { - mozilla::Telemetry::Accumulate(mozilla::Telemetry::CANVAS_WEBGL_USED, 1); - nsIDOMWebGLRenderingContext* ctx = mozilla::WebGL1Context::Create(); NS_ADDREF(*out_result = ctx); diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index 32eed6354..14bc7e3e3 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -825,10 +825,6 @@ NS_IMETHODIMP WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) { if (signedWidth < 0 || signedHeight < 0) { - if (!gl) { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_FAILURE_ID, - NS_LITERAL_CSTRING("FEATURE_FAILURE_WEBGL_SIZE")); - } GenerateWarning("Canvas size is too large (seems like a negative value wrapped)"); return NS_ERROR_OUT_OF_MEMORY; } @@ -884,12 +880,6 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) return NS_OK; } - nsCString failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WEBGL_UNKOWN"); - auto autoTelemetry = mozilla::MakeScopeExit([&] { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_FAILURE_ID, - failureId); - }); - // End of early return cases. // At this point we know that we're not just resizing an existing context, // we are initializing a new context. @@ -911,7 +901,6 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) // resource handles created from older context generations. if (!(mGeneration + 1).isValid()) { // exit without changing the value of mGeneration - failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WEBGL_TOO_MANY"); const nsLiteralCString text("Too many WebGL contexts created this run."); ThrowEvent_WebGLContextCreationError(text); return NS_ERROR_FAILURE; @@ -928,11 +917,6 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) disabled |= gfxPlatform::InSafeMode(); if (disabled) { - if (gfxPlatform::InSafeMode()) { - failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WEBGL_SAFEMODE"); - } else { - failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WEBGL_DISABLED"); - } const nsLiteralCString text("WebGL is currently disabled."); ThrowEvent_WebGLContextCreationError(text); return NS_ERROR_FAILURE; @@ -945,7 +929,6 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) if (mOptions.failIfMajorPerformanceCaveat) { nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo(); if (!HasAcceleratedLayers(gfxInfo)) { - failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WEBGL_PERF_CAVEAT"); const nsLiteralCString text("failIfMajorPerformanceCaveat: Compositor is not" " hardware-accelerated."); ThrowEvent_WebGLContextCreationError(text); @@ -961,12 +944,9 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) if (!CreateAndInitGL(forceEnabled, &failReasons)) { nsCString text("WebGL creation failed: "); for (const auto& cur : failReasons) { - Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_FAILURE_ID, cur.key); - text.AppendASCII("\n* "); text.Append(cur.info); } - failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_REASON"); ThrowEvent_WebGLContextCreationError(text); return NS_ERROR_FAILURE; } @@ -978,7 +958,6 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) DestroyResourcesAndContext(); MOZ_ASSERT(!gl); - failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WEBGL_PERF_WARP"); const nsLiteralCString text("failIfMajorPerformanceCaveat: Driver is not" " hardware-accelerated."); ThrowEvent_WebGLContextCreationError(text); @@ -992,7 +971,6 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) DestroyResourcesAndContext(); MOZ_ASSERT(!gl); - failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WEBGL_DXGL_INTEROP2"); const nsLiteralCString text("Caveat: WGL without DXGLInterop2."); ThrowEvent_WebGLContextCreationError(text); return NS_ERROR_FAILURE; @@ -1001,7 +979,6 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) } if (!ResizeBackbuffer(width, height)) { - failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WEBGL_BACKBUFFER"); const nsLiteralCString text("Initializing WebGL backbuffer failed."); ThrowEvent_WebGLContextCreationError(text); return NS_ERROR_FAILURE; @@ -1085,7 +1062,6 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight) ////// - failureId = NS_LITERAL_CSTRING("SUCCESS"); return NS_OK; } 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', |