1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/src/WebGLVertexArray.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,91 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef WEBGLVERTEXARRAY_H_ 1.10 +#define WEBGLVERTEXARRAY_H_ 1.11 + 1.12 +#include "WebGLObjectModel.h" 1.13 +#include "WebGLBuffer.h" 1.14 +#include "WebGLVertexAttribData.h" 1.15 + 1.16 +#include "nsWrapperCache.h" 1.17 + 1.18 +#include "mozilla/LinkedList.h" 1.19 + 1.20 +namespace mozilla { 1.21 + 1.22 +class WebGLVertexArray MOZ_FINAL 1.23 + : public nsWrapperCache 1.24 + , public WebGLRefCountedObject<WebGLVertexArray> 1.25 + , public LinkedListElement<WebGLVertexArray> 1.26 + , public WebGLContextBoundObject 1.27 +{ 1.28 +// ----------------------------------------------------------------------------- 1.29 +// PUBLIC 1.30 +public: 1.31 + 1.32 + // ------------------------------------------------------------------------- 1.33 + // CONSTRUCTOR & DESTRUCTOR 1.34 + 1.35 + WebGLVertexArray(WebGLContext *context); 1.36 + 1.37 + ~WebGLVertexArray() { 1.38 + DeleteOnce(); 1.39 + }; 1.40 + 1.41 + 1.42 + // ------------------------------------------------------------------------- 1.43 + // IMPLMENET PARENT CLASSES 1.44 + 1.45 + void Delete(); 1.46 + 1.47 + WebGLContext* GetParentObject() const { 1.48 + return Context(); 1.49 + } 1.50 + 1.51 + virtual JSObject* WrapObject(JSContext *cx) MOZ_OVERRIDE; 1.52 + 1.53 + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WebGLVertexArray) 1.54 + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WebGLVertexArray) 1.55 + 1.56 + 1.57 + // ------------------------------------------------------------------------- 1.58 + // MEMBER FUNCTIONS 1.59 + 1.60 + bool HasEverBeenBound() { return mHasEverBeenBound; } 1.61 + void SetHasEverBeenBound(bool x) { mHasEverBeenBound = x; } 1.62 + GLuint GLName() const { return mGLName; } 1.63 + 1.64 + bool EnsureAttrib(GLuint index, const char *info); 1.65 + bool HasAttrib(GLuint index) { 1.66 + return index < mAttribs.Length(); 1.67 + } 1.68 + bool IsAttribArrayEnabled(GLuint index) { 1.69 + return HasAttrib(index) && mAttribs[index].enabled; 1.70 + } 1.71 + 1.72 + 1.73 +// ----------------------------------------------------------------------------- 1.74 +// PRIVATE 1.75 +private: 1.76 + 1.77 + // ------------------------------------------------------------------------- 1.78 + // MEMBERS 1.79 + 1.80 + GLuint mGLName; 1.81 + bool mHasEverBeenBound; 1.82 + nsTArray<WebGLVertexAttribData> mAttribs; 1.83 + WebGLRefPtr<WebGLBuffer> mBoundElementArrayBuffer; 1.84 + 1.85 + 1.86 + // ------------------------------------------------------------------------- 1.87 + // FRIENDSHIPS 1.88 + 1.89 + friend class WebGLContext; 1.90 +}; 1.91 + 1.92 +} // namespace mozilla 1.93 + 1.94 +#endif