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/. */
5 
6 #ifndef WEBGL_TRANSFORM_FEEDBACK_H_
7 #define WEBGL_TRANSFORM_FEEDBACK_H_
8 
9 #include "WebGLContext.h"
10 #include "WebGLObjectModel.h"
11 
12 namespace mozilla {
13 namespace webgl {
14 struct CachedDrawFetchLimits;
15 }
16 
17 class WebGLTransformFeedback final : public WebGLContextBoundObject {
18   friend class ScopedDrawWithTransformFeedback;
19   friend class WebGLContext;
20   friend class WebGL2Context;
21   friend class WebGLProgram;
22 
23   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(WebGLTransformFeedback, override)
24 
25   friend const webgl::CachedDrawFetchLimits* ValidateDraw(WebGLContext*, GLenum,
26                                                           uint32_t);
27 
28  public:
29   const GLuint mGLName;
30   bool mHasBeenBound = false;
31 
32  private:
33   // GLES 3.0.4 p267, Table 6.24 "Transform Feedback State"
34   // It's not yet in the ES3 spec, but the generic TF buffer bind point has been
35   // moved to context state, instead of TFO state.
36   std::vector<IndexedBufferBinding> mIndexedBindings;
37   bool mIsPaused;
38   bool mIsActive;
39   // Not in state tables:
40   RefPtr<WebGLProgram> mActive_Program;
41   MOZ_INIT_OUTSIDE_CTOR GLenum mActive_PrimMode;
42   MOZ_INIT_OUTSIDE_CTOR size_t mActive_VertPosition;
43   MOZ_INIT_OUTSIDE_CTOR size_t mActive_VertCapacity;
44 
45  public:
46   WebGLTransformFeedback(WebGLContext* webgl, GLuint tf);
47 
48  private:
49   ~WebGLTransformFeedback() override;
50 
51  public:
IsActiveAndNotPaused()52   bool IsActiveAndNotPaused() const { return mIsActive && !mIsPaused; }
53 
54   // GL Funcs
55   void BeginTransformFeedback(GLenum primMode);
56   void EndTransformFeedback();
57   void PauseTransformFeedback();
58   void ResumeTransformFeedback();
59 };
60 
61 }  // namespace mozilla
62 
63 #endif  // WEBGL_TRANSFORM_FEEDBACK_H_
64