2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2014-09-18 02:08:41 +04: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 "WebGL2Context.h"
|
2014-11-26 05:00:06 +03:00
|
|
|
#include "WebGLActiveInfo.h"
|
|
|
|
#include "WebGLProgram.h"
|
|
|
|
#include "WebGLTransformFeedback.h"
|
2014-09-18 02:08:41 +04:00
|
|
|
#include "GLContext.h"
|
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
namespace mozilla {
|
2014-09-18 02:08:41 +04:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
// Transform Feedback
|
|
|
|
|
|
|
|
already_AddRefed<WebGLTransformFeedback>
|
|
|
|
WebGL2Context::CreateTransformFeedback() {
|
2018-07-27 07:46:33 +03:00
|
|
|
const FuncScope funcScope(*this, "createTransformFeedback");
|
2014-11-26 05:00:06 +03:00
|
|
|
if (IsContextLost()) return nullptr;
|
|
|
|
|
2016-09-10 07:02:54 +03:00
|
|
|
GLuint tf = 0;
|
2014-11-26 05:00:06 +03:00
|
|
|
gl->fGenTransformFeedbacks(1, &tf);
|
|
|
|
|
2016-09-10 07:02:54 +03:00
|
|
|
RefPtr<WebGLTransformFeedback> ret = new WebGLTransformFeedback(this, tf);
|
|
|
|
return ret.forget();
|
2014-09-18 02:08:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void WebGL2Context::DeleteTransformFeedback(WebGLTransformFeedback* tf) {
|
2018-07-27 07:46:33 +03:00
|
|
|
const FuncScope funcScope(*this, "deleteTransformFeedback");
|
|
|
|
if (!ValidateDeleteObject(tf)) return;
|
2014-11-26 05:00:06 +03:00
|
|
|
|
2016-09-10 07:02:54 +03:00
|
|
|
if (tf->mIsActive) {
|
2018-07-27 07:46:33 +03:00
|
|
|
ErrorInvalidOperation("Cannot delete active transform feedbacks.");
|
2014-11-26 05:00:06 +03:00
|
|
|
return;
|
2016-09-10 07:02:54 +03:00
|
|
|
}
|
2014-11-26 05:00:06 +03:00
|
|
|
|
2016-09-10 07:02:54 +03:00
|
|
|
if (mBoundTransformFeedback == tf) {
|
2015-10-28 01:01:29 +03:00
|
|
|
BindTransformFeedback(LOCAL_GL_TRANSFORM_FEEDBACK, nullptr);
|
2016-09-10 07:02:54 +03:00
|
|
|
}
|
2014-11-26 05:00:06 +03:00
|
|
|
|
|
|
|
tf->RequestDelete();
|
2014-09-18 02:08:41 +04:00
|
|
|
}
|
|
|
|
|
2018-07-27 07:46:33 +03:00
|
|
|
bool WebGL2Context::IsTransformFeedback(
|
|
|
|
const WebGLTransformFeedback* const obj) {
|
|
|
|
const FuncScope funcScope(*this, "isTransformFeedback");
|
|
|
|
if (!ValidateIsObject(obj)) return false;
|
2014-11-26 05:00:06 +03:00
|
|
|
|
2018-10-17 09:54:28 +03:00
|
|
|
if (obj->IsDeleteRequested()) return false;
|
|
|
|
|
|
|
|
return obj->mHasBeenBound;
|
2014-09-18 02:08:41 +04:00
|
|
|
}
|
|
|
|
|
2014-11-26 05:00:06 +03:00
|
|
|
void WebGL2Context::BindTransformFeedback(GLenum target,
|
|
|
|
WebGLTransformFeedback* tf) {
|
2018-07-27 07:46:33 +03:00
|
|
|
const FuncScope funcScope(*this, "bindTransformFeedback");
|
2014-11-26 05:00:06 +03:00
|
|
|
if (IsContextLost()) return;
|
|
|
|
|
|
|
|
if (target != LOCAL_GL_TRANSFORM_FEEDBACK)
|
2018-07-27 07:46:33 +03:00
|
|
|
return ErrorInvalidEnum("`target` must be TRANSFORM_FEEDBACK.");
|
2016-09-10 07:02:54 +03:00
|
|
|
|
2018-07-27 07:46:33 +03:00
|
|
|
if (tf && !ValidateObject("tf", *tf)) return;
|
2014-11-26 05:00:06 +03:00
|
|
|
|
2016-09-10 07:02:54 +03:00
|
|
|
if (mBoundTransformFeedback->mIsActive &&
|
|
|
|
!mBoundTransformFeedback->mIsPaused) {
|
2018-07-27 07:46:33 +03:00
|
|
|
ErrorInvalidOperation(
|
|
|
|
"Currently bound transform feedback is active and not"
|
|
|
|
" paused.");
|
2016-09-10 07:02:54 +03:00
|
|
|
return;
|
2014-11-26 05:00:06 +03:00
|
|
|
}
|
|
|
|
|
2016-09-10 07:02:54 +03:00
|
|
|
////
|
|
|
|
|
|
|
|
mBoundTransformFeedback = (tf ? tf : mDefaultTransformFeedback);
|
2014-11-26 05:00:06 +03:00
|
|
|
|
2016-09-10 07:02:54 +03:00
|
|
|
gl->fBindTransformFeedback(target, mBoundTransformFeedback->mGLName);
|
2016-12-29 11:08:39 +03:00
|
|
|
|
|
|
|
if (mBoundTransformFeedback) {
|
2018-10-17 09:54:28 +03:00
|
|
|
mBoundTransformFeedback->mHasBeenBound = true;
|
2016-12-29 11:08:39 +03:00
|
|
|
}
|
2014-09-18 02:08:41 +04:00
|
|
|
}
|
|
|
|
|
2016-09-10 07:02:54 +03:00
|
|
|
void WebGL2Context::BeginTransformFeedback(GLenum primMode) {
|
2018-07-27 07:46:33 +03:00
|
|
|
const FuncScope funcScope(*this, "beginTransformFeedback");
|
2014-11-26 05:00:06 +03:00
|
|
|
if (IsContextLost()) return;
|
|
|
|
|
2016-09-10 07:02:54 +03:00
|
|
|
mBoundTransformFeedback->BeginTransformFeedback(primMode);
|
2014-09-18 02:08:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void WebGL2Context::EndTransformFeedback() {
|
2018-07-27 07:46:33 +03:00
|
|
|
const FuncScope funcScope(*this, "endTransformFeedback");
|
2014-11-26 05:00:06 +03:00
|
|
|
if (IsContextLost()) return;
|
|
|
|
|
2016-09-10 07:02:54 +03:00
|
|
|
mBoundTransformFeedback->EndTransformFeedback();
|
2014-09-18 02:08:41 +04:00
|
|
|
}
|
|
|
|
|
2014-11-26 05:00:06 +03:00
|
|
|
void WebGL2Context::PauseTransformFeedback() {
|
2018-07-27 07:46:33 +03:00
|
|
|
const FuncScope funcScope(*this, "pauseTransformFeedback");
|
2014-11-26 05:00:06 +03:00
|
|
|
if (IsContextLost()) return;
|
2014-09-18 02:08:41 +04:00
|
|
|
|
2016-09-10 07:02:54 +03:00
|
|
|
mBoundTransformFeedback->PauseTransformFeedback();
|
2014-09-18 02:08:41 +04:00
|
|
|
}
|
|
|
|
|
2014-11-26 05:00:06 +03:00
|
|
|
void WebGL2Context::ResumeTransformFeedback() {
|
2018-07-27 07:46:33 +03:00
|
|
|
const FuncScope funcScope(*this, "resumeTransformFeedback");
|
2014-11-26 05:00:06 +03:00
|
|
|
if (IsContextLost()) return;
|
|
|
|
|
2016-09-10 07:02:54 +03:00
|
|
|
mBoundTransformFeedback->ResumeTransformFeedback();
|
2014-09-18 02:08:41 +04:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:58:07 +03:00
|
|
|
void WebGL2Context::TransformFeedbackVaryings(
|
2014-11-26 05:00:06 +03:00
|
|
|
WebGLProgram& program, const dom::Sequence<nsString>& varyings,
|
|
|
|
GLenum bufferMode) {
|
2018-07-27 07:46:33 +03:00
|
|
|
const FuncScope funcScope(*this, "transformFeedbackVaryings");
|
2014-11-26 05:00:06 +03:00
|
|
|
if (IsContextLost()) return;
|
|
|
|
|
2018-07-27 07:46:33 +03:00
|
|
|
if (!ValidateObject("program", program)) return;
|
2014-11-26 05:00:06 +03:00
|
|
|
|
2016-11-02 00:58:07 +03:00
|
|
|
program.TransformFeedbackVaryings(varyings, bufferMode);
|
2014-11-26 05:00:06 +03:00
|
|
|
}
|
|
|
|
|
2016-11-02 00:58:07 +03:00
|
|
|
already_AddRefed<WebGLActiveInfo> WebGL2Context::GetTransformFeedbackVarying(
|
|
|
|
const WebGLProgram& program, GLuint index) {
|
2018-07-27 07:46:33 +03:00
|
|
|
const FuncScope funcScope(*this, "getTransformFeedbackVarying");
|
2014-11-26 05:00:06 +03:00
|
|
|
if (IsContextLost()) return nullptr;
|
|
|
|
|
2018-07-27 07:46:33 +03:00
|
|
|
if (!ValidateObject("program", program)) return nullptr;
|
2014-11-26 05:00:06 +03:00
|
|
|
|
2016-11-02 00:58:07 +03:00
|
|
|
return program.GetTransformFeedbackVarying(index);
|
2014-09-18 02:08:41 +04:00
|
|
|
}
|
2015-07-15 03:37:28 +03:00
|
|
|
|
|
|
|
} // namespace mozilla
|