Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/canvas/WebGLExtensionInstancedArrays.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 "GLContext.h"
9
#include "mozilla/dom/WebGLRenderingContextBinding.h"
10
#include "WebGLContext.h"
11
12
namespace mozilla {
13
14
WebGLExtensionInstancedArrays::WebGLExtensionInstancedArrays(WebGLContext* webgl)
15
  : WebGLExtensionBase(webgl)
16
0
{
17
0
    MOZ_ASSERT(IsSupported(webgl), "Don't construct extension if unsupported.");
18
0
}
19
20
WebGLExtensionInstancedArrays::~WebGLExtensionInstancedArrays()
21
0
{
22
0
}
23
24
void
25
WebGLExtensionInstancedArrays::DrawArraysInstancedANGLE(GLenum mode,
26
                                                        GLint first,
27
                                                        GLsizei count,
28
                                                        GLsizei primcount)
29
0
{
30
0
    if (mIsLost) {
31
0
        mContext->ErrorInvalidOperation("%s: Extension is lost.",
32
0
                                        "drawArraysInstancedANGLE");
33
0
        return;
34
0
    }
35
0
36
0
    mContext->DrawArraysInstanced(mode, first, count, primcount);
37
0
}
38
39
void
40
WebGLExtensionInstancedArrays::DrawElementsInstancedANGLE(GLenum mode,
41
                                                          GLsizei count,
42
                                                          GLenum type,
43
                                                          WebGLintptr offset,
44
                                                          GLsizei primcount)
45
0
{
46
0
    if (mIsLost) {
47
0
        mContext->ErrorInvalidOperation("%s: Extension is lost.",
48
0
                                        "drawElementsInstancedANGLE");
49
0
        return;
50
0
    }
51
0
52
0
    mContext->DrawElementsInstanced(mode, count, type, offset, primcount);
53
0
}
54
55
void
56
WebGLExtensionInstancedArrays::VertexAttribDivisorANGLE(GLuint index,
57
                                                        GLuint divisor)
58
0
{
59
0
    if (mIsLost) {
60
0
        mContext->ErrorInvalidOperation("%s: Extension is lost.",
61
0
                                        "vertexAttribDivisorANGLE");
62
0
        return;
63
0
    }
64
0
65
0
    mContext->VertexAttribDivisor(index, divisor);
66
0
}
67
68
bool
69
WebGLExtensionInstancedArrays::IsSupported(const WebGLContext* webgl)
70
0
{
71
0
    gl::GLContext* gl = webgl->GL();
72
0
    return gl->IsSupported(gl::GLFeature::draw_instanced) &&
73
0
           gl->IsSupported(gl::GLFeature::instanced_arrays);
74
0
}
75
76
IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionInstancedArrays, ANGLE_instanced_arrays)
77
78
} // namespace mozilla