Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / canvas / WebGL2ContextTransformFeedback.cpp
blob3dc6484604388250fa532b419235cfcaf8d2d541
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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/. */
6 #include "WebGL2Context.h"
7 #include "WebGLProgram.h"
8 #include "WebGLTransformFeedback.h"
9 #include "GLContext.h"
11 namespace mozilla {
13 // -------------------------------------------------------------------------
14 // Transform Feedback
16 RefPtr<WebGLTransformFeedback> WebGL2Context::CreateTransformFeedback() {
17 const FuncScope funcScope(*this, "createTransformFeedback");
18 if (IsContextLost()) return nullptr;
20 GLuint tf = 0;
21 gl->fGenTransformFeedbacks(1, &tf);
23 return new WebGLTransformFeedback(this, tf);
26 void WebGL2Context::BindTransformFeedback(WebGLTransformFeedback* tf) {
27 FuncScope funcScope(*this, "bindTransformFeedback");
28 if (IsContextLost()) return;
29 funcScope.mBindFailureGuard = true;
31 if (tf && !ValidateObject("tf", *tf)) return;
33 if (mBoundTransformFeedback->mIsActive &&
34 !mBoundTransformFeedback->mIsPaused) {
35 ErrorInvalidOperation(
36 "Currently bound transform feedback is active and not"
37 " paused.");
38 return;
41 ////
43 mBoundTransformFeedback = (tf ? tf : mDefaultTransformFeedback.get());
45 gl->fBindTransformFeedback(LOCAL_GL_TRANSFORM_FEEDBACK,
46 mBoundTransformFeedback->mGLName);
48 if (mBoundTransformFeedback) {
49 mBoundTransformFeedback->mHasBeenBound = true;
52 funcScope.mBindFailureGuard = false;
55 void WebGL2Context::BeginTransformFeedback(GLenum primMode) {
56 const FuncScope funcScope(*this, "beginTransformFeedback");
57 if (IsContextLost()) return;
59 mBoundTransformFeedback->BeginTransformFeedback(primMode);
62 void WebGL2Context::EndTransformFeedback() {
63 const FuncScope funcScope(*this, "endTransformFeedback");
64 if (IsContextLost()) return;
66 mBoundTransformFeedback->EndTransformFeedback();
69 void WebGL2Context::PauseTransformFeedback() {
70 const FuncScope funcScope(*this, "pauseTransformFeedback");
71 if (IsContextLost()) return;
73 mBoundTransformFeedback->PauseTransformFeedback();
76 void WebGL2Context::ResumeTransformFeedback() {
77 const FuncScope funcScope(*this, "resumeTransformFeedback");
78 if (IsContextLost()) return;
80 mBoundTransformFeedback->ResumeTransformFeedback();
83 void WebGL2Context::TransformFeedbackVaryings(
84 WebGLProgram& program, const std::vector<std::string>& varyings,
85 GLenum bufferMode) const {
86 const FuncScope funcScope(*this, "transformFeedbackVaryings");
87 if (IsContextLost()) return;
89 if (!ValidateObject("program", program)) return;
91 program.TransformFeedbackVaryings(varyings, bufferMode);
94 } // namespace mozilla