OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WebGLVertexArrayObjectBase_h | 5 #ifndef WebGLVertexArrayObjectBase_h |
6 #define WebGLVertexArrayObjectBase_h | 6 #define WebGLVertexArrayObjectBase_h |
7 | 7 |
8 #include "modules/webgl/WebGLBuffer.h" | 8 #include "modules/webgl/WebGLBuffer.h" |
9 #include "modules/webgl/WebGLContextObject.h" | 9 #include "modules/webgl/WebGLContextObject.h" |
10 #include "platform/heap/Handle.h" | 10 #include "platform/heap/Handle.h" |
11 #include "wtf/PassRefPtr.h" | |
12 | 11 |
13 namespace blink { | 12 namespace blink { |
14 | 13 |
15 class WebGLVertexArrayObjectBase : public WebGLContextObject { | 14 class WebGLVertexArrayObjectBase : public WebGLContextObject { |
16 public: | 15 public: |
17 enum VaoType { | 16 enum VaoType { |
18 VaoTypeDefault, | 17 VaoTypeDefault, |
19 VaoTypeUser, | 18 VaoTypeUser, |
20 }; | 19 }; |
21 | 20 |
22 ~WebGLVertexArrayObjectBase() override; | 21 ~WebGLVertexArrayObjectBase() override; |
23 | 22 |
24 Platform3DObject object() const { return m_object; } | 23 Platform3DObject object() const { return m_object; } |
25 | 24 |
26 // Cached values for vertex attrib range checks | 25 // Cached values for vertex attrib range checks |
27 class VertexAttribState final : public NoBaseWillBeGarbageCollected<VertexAt
tribState> { | 26 class VertexAttribState final : public GarbageCollected<VertexAttribState> { |
28 public: | 27 public: |
29 VertexAttribState() | 28 VertexAttribState() |
30 : enabled(false) | 29 : enabled(false) |
31 , bytesPerElement(0) | 30 , bytesPerElement(0) |
32 , size(4) | 31 , size(4) |
33 , type(GL_FLOAT) | 32 , type(GL_FLOAT) |
34 , normalized(false) | 33 , normalized(false) |
35 , stride(16) | 34 , stride(16) |
36 , originalStride(0) | 35 , originalStride(0) |
37 , offset(0) | 36 , offset(0) |
38 , divisor(0) | 37 , divisor(0) |
39 { | 38 { |
40 } | 39 } |
41 | 40 |
42 DECLARE_TRACE(); | 41 DECLARE_TRACE(); |
43 | 42 |
44 bool enabled; | 43 bool enabled; |
45 RefPtrWillBeMember<WebGLBuffer> bufferBinding; | 44 Member<WebGLBuffer> bufferBinding; |
46 GLsizei bytesPerElement; | 45 GLsizei bytesPerElement; |
47 GLint size; | 46 GLint size; |
48 GLenum type; | 47 GLenum type; |
49 bool normalized; | 48 bool normalized; |
50 GLsizei stride; | 49 GLsizei stride; |
51 GLsizei originalStride; | 50 GLsizei originalStride; |
52 GLintptr offset; | 51 GLintptr offset; |
53 GLuint divisor; | 52 GLuint divisor; |
54 }; | 53 }; |
55 | 54 |
56 bool isDefaultObject() const { return m_type == VaoTypeDefault; } | 55 bool isDefaultObject() const { return m_type == VaoTypeDefault; } |
57 | 56 |
58 bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; } | 57 bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; } |
59 void setHasEverBeenBound() { m_hasEverBeenBound = true; } | 58 void setHasEverBeenBound() { m_hasEverBeenBound = true; } |
60 | 59 |
61 PassRefPtrWillBeRawPtr<WebGLBuffer> boundElementArrayBuffer() const { return
m_boundElementArrayBuffer; } | 60 WebGLBuffer* boundElementArrayBuffer() const { return m_boundElementArrayBuf
fer; } |
62 void setElementArrayBuffer(PassRefPtrWillBeRawPtr<WebGLBuffer>); | 61 void setElementArrayBuffer(WebGLBuffer*); |
63 | 62 |
64 VertexAttribState* getVertexAttribState(size_t); | 63 VertexAttribState* getVertexAttribState(size_t); |
65 void setVertexAttribState(GLuint, GLsizei, GLint, GLenum, GLboolean, GLsizei
, GLintptr, PassRefPtrWillBeRawPtr<WebGLBuffer>); | 64 void setVertexAttribState(GLuint, GLsizei, GLint, GLenum, GLboolean, GLsizei
, GLintptr, WebGLBuffer*); |
66 void unbindBuffer(PassRefPtrWillBeRawPtr<WebGLBuffer>); | 65 void unbindBuffer(WebGLBuffer*); |
67 void setVertexAttribDivisor(GLuint index, GLuint divisor); | 66 void setVertexAttribDivisor(GLuint index, GLuint divisor); |
68 | 67 |
69 DECLARE_VIRTUAL_TRACE(); | 68 DECLARE_VIRTUAL_TRACE(); |
70 | 69 |
71 protected: | 70 protected: |
72 WebGLVertexArrayObjectBase(WebGLRenderingContextBase*, VaoType); | 71 WebGLVertexArrayObjectBase(WebGLRenderingContextBase*, VaoType); |
73 | 72 |
74 private: | 73 private: |
75 void dispatchDetached(WebGraphicsContext3D*); | 74 void dispatchDetached(WebGraphicsContext3D*); |
76 bool hasObject() const override { return m_object != 0; } | 75 bool hasObject() const override { return m_object != 0; } |
77 void deleteObjectImpl(WebGraphicsContext3D*) override; | 76 void deleteObjectImpl(WebGraphicsContext3D*) override; |
78 | 77 |
79 Platform3DObject m_object; | 78 Platform3DObject m_object; |
80 | 79 |
81 VaoType m_type; | 80 VaoType m_type; |
82 bool m_hasEverBeenBound; | 81 bool m_hasEverBeenBound; |
83 #if ENABLE(OILPAN) | |
84 bool m_destructionInProgress; | 82 bool m_destructionInProgress; |
85 #endif | 83 Member<WebGLBuffer> m_boundElementArrayBuffer; |
86 RefPtrWillBeMember<WebGLBuffer> m_boundElementArrayBuffer; | 84 HeapVector<Member<VertexAttribState>> m_vertexAttribState; |
87 WillBeHeapVector<OwnPtrWillBeMember<VertexAttribState>> m_vertexAttribState; | |
88 }; | 85 }; |
89 | 86 |
90 } // namespace blink | 87 } // namespace blink |
91 | 88 |
92 #endif // WebGLVertexArrayObjectBase_h | 89 #endif // WebGLVertexArrayObjectBase_h |
OLD | NEW |