Line data Source code
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 : #ifndef WEBGL_VERTEX_ATTRIB_DATA_H_
7 : #define WEBGL_VERTEX_ATTRIB_DATA_H_
8 :
9 : #include "GLDefs.h"
10 : #include "WebGLObjectModel.h"
11 :
12 : namespace mozilla {
13 :
14 : class WebGLBuffer;
15 :
16 0 : class WebGLVertexAttribData final
17 : {
18 : public:
19 : uint32_t mDivisor;
20 : bool mEnabled;
21 :
22 : private:
23 : bool mIntegerFunc;
24 : public:
25 : WebGLRefPtr<WebGLBuffer> mBuf;
26 : private:
27 : GLenum mType;
28 : GLenum mBaseType;
29 : uint8_t mSize; // num of mType vals per vert
30 : uint8_t mBytesPerVertex;
31 : bool mNormalized;
32 : uint32_t mStride; // bytes
33 : uint32_t mExplicitStride;
34 : uint64_t mByteOffset;
35 :
36 : public:
37 :
38 : #define GETTER(X) const decltype(m##X)& X() const { return m##X; }
39 :
40 0 : GETTER(IntegerFunc)
41 0 : GETTER(Type)
42 0 : GETTER(BaseType)
43 0 : GETTER(Size)
44 0 : GETTER(BytesPerVertex)
45 0 : GETTER(Normalized)
46 0 : GETTER(Stride)
47 0 : GETTER(ExplicitStride)
48 0 : GETTER(ByteOffset)
49 :
50 : #undef GETTER
51 :
52 : // note that these initial values are what GL initializes vertex attribs to
53 0 : WebGLVertexAttribData()
54 0 : : mDivisor(0)
55 0 : , mEnabled(false)
56 : {
57 0 : VertexAttribPointer(false, nullptr, 4, LOCAL_GL_FLOAT, false, 0, 0);
58 0 : }
59 :
60 : void VertexAttribPointer(bool integerFunc, WebGLBuffer* buf, uint8_t size,
61 : GLenum type, bool normalized, uint32_t stride,
62 : uint64_t byteOffset);
63 :
64 : void DoVertexAttribPointer(gl::GLContext* gl, GLuint index) const;
65 : };
66 :
67 : } // namespace mozilla
68 :
69 : inline void
70 0 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& callback,
71 : mozilla::WebGLVertexAttribData& field,
72 : const char* name,
73 : uint32_t flags = 0)
74 : {
75 0 : CycleCollectionNoteChild(callback, field.mBuf.get(), name, flags);
76 0 : }
77 :
78 : #endif // WEBGL_VERTEX_ATTRIB_DATA_H_
|