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 3 // found in the LICENSE file. 4 5 #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGL_WEBGL_VERTEX_ARRAY_OBJECT_BASE_H_ 6 #define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGL_WEBGL_VERTEX_ARRAY_OBJECT_BASE_H_ 7 8 #include "third_party/blink/renderer/modules/webgl/webgl_buffer.h" 9 #include "third_party/blink/renderer/modules/webgl/webgl_context_object.h" 10 #include "third_party/blink/renderer/platform/heap/handle.h" 11 12 namespace blink { 13 14 class WebGLVertexArrayObjectBase : public WebGLContextObject { 15 public: 16 enum VaoType { 17 kVaoTypeDefault, 18 kVaoTypeUser, 19 }; 20 21 ~WebGLVertexArrayObjectBase() override; 22 Object()23 GLuint Object() const { return object_; } 24 IsDefaultObject()25 bool IsDefaultObject() const { return type_ == kVaoTypeDefault; } 26 HasEverBeenBound()27 bool HasEverBeenBound() const { return Object() && has_ever_been_bound_; } SetHasEverBeenBound()28 void SetHasEverBeenBound() { has_ever_been_bound_ = true; } 29 BoundElementArrayBuffer()30 WebGLBuffer* BoundElementArrayBuffer() const { 31 return bound_element_array_buffer_; 32 } 33 void SetElementArrayBuffer(WebGLBuffer*); 34 35 WebGLBuffer* GetArrayBufferForAttrib(GLuint); 36 void SetArrayBufferForAttrib(GLuint, WebGLBuffer*); 37 void SetAttribEnabled(GLuint, bool); 38 bool GetAttribEnabled(GLuint) const; IsAllEnabledAttribBufferBound()39 bool IsAllEnabledAttribBufferBound() const { 40 return is_all_enabled_attrib_buffer_bound_; 41 } 42 void UnbindBuffer(WebGLBuffer*); 43 44 void Trace(Visitor*) override; 45 46 protected: 47 WebGLVertexArrayObjectBase(WebGLRenderingContextBase*, VaoType); 48 49 private: 50 void DispatchDetached(gpu::gles2::GLES2Interface*); HasObject()51 bool HasObject() const override { return object_ != 0; } 52 void DeleteObjectImpl(gpu::gles2::GLES2Interface*) override; 53 54 void UpdateAttribBufferBoundStatus(); 55 56 GLuint object_; 57 58 VaoType type_; 59 bool has_ever_been_bound_; 60 Member<WebGLBuffer> bound_element_array_buffer_; 61 HeapVector<Member<WebGLBuffer>> array_buffer_list_; 62 Vector<bool> attrib_enabled_; 63 bool is_all_enabled_attrib_buffer_bound_; 64 }; 65 66 } // namespace blink 67 68 #endif // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBGL_WEBGL_VERTEX_ARRAY_OBJECT_BASE_H_ 69