Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/canvas/WebGL2ContextTransformFeedback.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 4; 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 "WebGL2Context.h"
7
#include "WebGLActiveInfo.h"
8
#include "WebGLProgram.h"
9
#include "WebGLTransformFeedback.h"
10
#include "GLContext.h"
11
12
namespace mozilla {
13
14
// -------------------------------------------------------------------------
15
// Transform Feedback
16
17
already_AddRefed<WebGLTransformFeedback>
18
WebGL2Context::CreateTransformFeedback()
19
0
{
20
0
    const FuncScope funcScope(*this, "createTransformFeedback");
21
0
    if (IsContextLost())
22
0
        return nullptr;
23
0
24
0
    GLuint tf = 0;
25
0
    gl->fGenTransformFeedbacks(1, &tf);
26
0
27
0
    RefPtr<WebGLTransformFeedback> ret = new WebGLTransformFeedback(this, tf);
28
0
    return ret.forget();
29
0
}
30
31
void
32
WebGL2Context::DeleteTransformFeedback(WebGLTransformFeedback* tf)
33
0
{
34
0
    const FuncScope funcScope(*this, "deleteTransformFeedback");
35
0
    if (!ValidateDeleteObject(tf))
36
0
        return;
37
0
38
0
    if (tf->mIsActive) {
39
0
        ErrorInvalidOperation("Cannot delete active transform feedbacks.");
40
0
        return;
41
0
    }
42
0
43
0
    if (mBoundTransformFeedback == tf) {
44
0
        BindTransformFeedback(LOCAL_GL_TRANSFORM_FEEDBACK, nullptr);
45
0
    }
46
0
47
0
    tf->RequestDelete();
48
0
}
49
50
bool
51
WebGL2Context::IsTransformFeedback(const WebGLTransformFeedback* const obj)
52
0
{
53
0
    const FuncScope funcScope(*this, "isTransformFeedback");
54
0
    if (!ValidateIsObject(obj))
55
0
        return false;
56
0
57
0
    return gl->fIsTransformFeedback(obj->mGLName);
58
0
}
59
60
void
61
WebGL2Context::BindTransformFeedback(GLenum target, WebGLTransformFeedback* tf)
62
0
{
63
0
    const FuncScope funcScope(*this, "bindTransformFeedback");
64
0
    if (IsContextLost())
65
0
        return;
66
0
67
0
    if (target != LOCAL_GL_TRANSFORM_FEEDBACK)
68
0
        return ErrorInvalidEnum("`target` must be TRANSFORM_FEEDBACK.");
69
0
70
0
    if (tf && !ValidateObject("tf", *tf))
71
0
        return;
72
0
73
0
    if (mBoundTransformFeedback->mIsActive &&
74
0
        !mBoundTransformFeedback->mIsPaused)
75
0
    {
76
0
        ErrorInvalidOperation("Currently bound transform feedback is active and not"
77
0
                              " paused.");
78
0
        return;
79
0
    }
80
0
81
0
    ////
82
0
83
0
    if (mBoundTransformFeedback) {
84
0
        mBoundTransformFeedback->AddBufferBindCounts(-1);
85
0
    }
86
0
87
0
    mBoundTransformFeedback = (tf ? tf : mDefaultTransformFeedback);
88
0
89
0
    gl->fBindTransformFeedback(target, mBoundTransformFeedback->mGLName);
90
0
91
0
    if (mBoundTransformFeedback) {
92
0
        mBoundTransformFeedback->AddBufferBindCounts(+1);
93
0
    }
94
0
}
95
96
void
97
WebGL2Context::BeginTransformFeedback(GLenum primMode)
98
0
{
99
0
    const FuncScope funcScope(*this, "beginTransformFeedback");
100
0
    if (IsContextLost())
101
0
        return;
102
0
103
0
    mBoundTransformFeedback->BeginTransformFeedback(primMode);
104
0
}
105
106
void
107
WebGL2Context::EndTransformFeedback()
108
0
{
109
0
    const FuncScope funcScope(*this, "endTransformFeedback");
110
0
    if (IsContextLost())
111
0
        return;
112
0
113
0
    mBoundTransformFeedback->EndTransformFeedback();
114
0
}
115
116
void
117
WebGL2Context::PauseTransformFeedback()
118
0
{
119
0
    const FuncScope funcScope(*this, "pauseTransformFeedback");
120
0
    if (IsContextLost())
121
0
        return;
122
0
123
0
    mBoundTransformFeedback->PauseTransformFeedback();
124
0
}
125
126
void
127
WebGL2Context::ResumeTransformFeedback()
128
0
{
129
0
    const FuncScope funcScope(*this, "resumeTransformFeedback");
130
0
    if (IsContextLost())
131
0
        return;
132
0
133
0
    mBoundTransformFeedback->ResumeTransformFeedback();
134
0
}
135
136
void
137
WebGL2Context::TransformFeedbackVaryings(WebGLProgram& program,
138
                                         const dom::Sequence<nsString>& varyings,
139
                                         GLenum bufferMode)
140
0
{
141
0
    const FuncScope funcScope(*this, "transformFeedbackVaryings");
142
0
    if (IsContextLost())
143
0
        return;
144
0
145
0
    if (!ValidateObject("program", program))
146
0
        return;
147
0
148
0
    program.TransformFeedbackVaryings(varyings, bufferMode);
149
0
}
150
151
already_AddRefed<WebGLActiveInfo>
152
WebGL2Context::GetTransformFeedbackVarying(const WebGLProgram& program, GLuint index)
153
0
{
154
0
    const FuncScope funcScope(*this, "getTransformFeedbackVarying");
155
0
    if (IsContextLost())
156
0
        return nullptr;
157
0
158
0
    if (!ValidateObject("program", program))
159
0
        return nullptr;
160
0
161
0
    return program.GetTransformFeedbackVarying(index);
162
0
}
163
164
} // namespace mozilla