Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/canvas/WebGLExtensionMOZDebug.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "WebGLExtensions.h"
7
8
#include "mozilla/dom/WebGLRenderingContextBinding.h"
9
#include "GLContext.h"
10
#include "WebGLContext.h"
11
#include "WebGLContextUtils.h"
12
13
namespace mozilla {
14
15
WebGLExtensionMOZDebug::WebGLExtensionMOZDebug(WebGLContext* webgl)
16
    : WebGLExtensionBase(webgl)
17
0
{
18
0
}
19
20
WebGLExtensionMOZDebug::~WebGLExtensionMOZDebug()
21
0
{
22
0
}
23
24
void
25
WebGLExtensionMOZDebug::GetParameter(JSContext* cx, GLenum pname,
26
                                     JS::MutableHandle<JS::Value> retval,
27
                                     ErrorResult& er) const
28
0
{
29
0
    if (mIsLost)
30
0
        return;
31
0
    const WebGLContext::FuncScope funcScope(*mContext, "MOZ_debug.getParameter");
32
0
    MOZ_ASSERT(!mContext->IsContextLost());
33
0
34
0
    const auto& gl = mContext->gl;
35
0
36
0
    switch (pname) {
37
0
    case LOCAL_GL_EXTENSIONS:
38
0
        {
39
0
            nsString ret;
40
0
            if (!gl->IsCoreProfile()) {
41
0
                const auto rawExts = (const char*)gl->fGetString(LOCAL_GL_EXTENSIONS);
42
0
                ret = NS_ConvertUTF8toUTF16(rawExts);
43
0
            } else {
44
0
                const auto& numExts = gl->GetIntAs<GLuint>(LOCAL_GL_NUM_EXTENSIONS);
45
0
                for (GLuint i = 0; i < numExts; i++) {
46
0
                    const auto rawExt = (const char*)gl->fGetStringi(LOCAL_GL_EXTENSIONS,
47
0
                                                                     i);
48
0
                    if (i > 0) {
49
0
                        ret.AppendLiteral(" ");
50
0
                    }
51
0
                    ret.Append(NS_ConvertUTF8toUTF16(rawExt));
52
0
                }
53
0
            }
54
0
            retval.set(StringValue(cx, ret, er));
55
0
            return;
56
0
        }
57
0
58
0
    case LOCAL_GL_RENDERER:
59
0
    case LOCAL_GL_VENDOR:
60
0
    case LOCAL_GL_VERSION:
61
0
        {
62
0
            const auto raw = (const char*)gl->fGetString(pname);
63
0
            retval.set(StringValue(cx, NS_ConvertUTF8toUTF16(raw), er));
64
0
            return;
65
0
        }
66
0
67
0
    case dom::MOZ_debug_Binding::WSI_INFO:
68
0
        {
69
0
            nsCString info;
70
0
            gl->GetWSIInfo(&info);
71
0
            retval.set(StringValue(cx, NS_ConvertUTF8toUTF16(info), er));
72
0
            return;
73
0
        }
74
0
75
0
    case dom::MOZ_debug_Binding::DOES_INDEX_VALIDATION:
76
0
        retval.set(JS::BooleanValue(mContext->mNeedsIndexValidation));
77
0
        return;
78
0
79
0
    default:
80
0
        mContext->ErrorInvalidEnumInfo("pname", pname);
81
0
        retval.set(JS::NullValue());
82
0
        return;
83
0
    }
84
0
}
85
86
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionMOZDebug, MOZ_debug)
87
88
} // namespace mozilla